From: Alexander Simon <alexander.simon@saxnet.de>
To: linux-wireless@vger.kernel.org
Subject: patch for iw
Date: Tue, 21 Jun 2011 18:01:27 +0200 [thread overview]
Message-ID: <1308672087.2656.13.camel@alex-2> (raw)
In-Reply-To: <1308671129.2656.4.camel@alex-2>
Here is a patch for iw to set a ht channel type when joining an IBSS.
diff -Nrup iw-0.9.22/ibss.c iw-0.9.22_ibss_n//ibss.c
--- iw-0.9.22/ibss.c 2011-02-04 13:29:39.000000000 +0100
+++ iw-0.9.22_ibss_n//ibss.c 2011-05-03 21:31:00.000000000 +0200
@@ -27,6 +27,7 @@ static int join_ibss(struct nl80211_stat
char *value = NULL, *sptr = NULL;
float rate;
int bintval;
+ unsigned int htval;
if (argc < 2)
return 1;
@@ -44,6 +45,12 @@ static int join_ibss(struct nl80211_stat
argv++;
argc--;
+ if (argc && parse_channel_type(argv[0], &htval)) {
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, htval);
+ argv++;
+ argc--;
+ }
+
if (argc && strcmp(argv[0], "fixed-freq") == 0) {
NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
argv++;
@@ -134,7 +141,7 @@ COMMAND(ibss, leave, NULL,
NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
"Leave the current IBSS cell.");
COMMAND(ibss, join,
- "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
+ "<SSID> <freq in MHz> [HT20|HT40+|HT40-] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
" [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] "
"[key d:0:abcde]",
NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
diff -Nrup iw-0.9.22/iw.h iw-0.9.22_ibss_n//iw.h
--- iw-0.9.22/iw.h 2011-02-04 13:29:39.000000000 +0100
+++ iw-0.9.22_ibss_n//iw.h 2011-05-03 14:52:02.000000000 +0200
@@ -130,6 +130,7 @@ void mac_addr_n2a(char *mac_addr, unsign
unsigned char *parse_hex(char *hex, size_t *outlen);
int parse_keys(struct nl_msg *msg, char **argv, int argc);
+int parse_channel_type(const char *str, unsigned int *htval);
void print_ht_mcs(const __u8 *mcs);
void print_ampdu_length(__u8 exponent);
diff -Nrup iw-0.9.22/phy.c iw-0.9.22_ibss_n//phy.c
--- iw-0.9.22/phy.c 2011-02-04 13:29:39.000000000 +0100
+++ iw-0.9.22_ibss_n//phy.c 2011-05-03 14:52:02.000000000 +0200
@@ -33,30 +33,14 @@ static int handle_freqchan(struct nl_msg
int argc, char **argv)
{
char *end;
- static const struct {
- const char *name;
- unsigned int val;
- } htmap[] = {
- { .name = "HT20", .val = NL80211_CHAN_HT20, },
- { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
- { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
- };
unsigned int htval = NL80211_CHAN_NO_HT;
unsigned int freq;
- int i;
if (!argc || argc > 2)
return 1;
- if (argc == 2) {
- for (i = 0; i < ARRAY_SIZE(htmap); i++) {
- if (strcasecmp(htmap[i].name, argv[1]) == 0) {
- htval = htmap[i].val;
- break;
- }
- }
- if (htval == NL80211_CHAN_NO_HT)
- return 1;
+ if (argc == 2 && !parse_channel_type(argv[1], &htval)) {
+ return 1;
}
if (!*argv[0])
diff -Nrup iw-0.9.22/util.c iw-0.9.22_ibss_n//util.c
--- iw-0.9.22/util.c 2011-02-04 13:29:39.000000000 +0100
+++ iw-0.9.22_ibss_n//util.c 2011-05-03 14:52:02.000000000 +0200
@@ -345,6 +345,33 @@ int parse_keys(struct nl_msg *msg, char
return 2;
}
+/*
+ * Convert a string "HT20", "HT40+" or "HT40-" into nl80211
+ * value. Conversion is case insensitive. Returns 1 on success, 0 on error.
+ */
+
+int parse_channel_type(const char *str, unsigned int *htval)
+{
+ static const struct {
+ const char *name;
+ unsigned int val;
+ } htmap[] = {
+ { .name = "HT20", .val = NL80211_CHAN_HT20, },
+ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
+ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(htmap); i++) {
+ if (strcasecmp(htmap[i].name, str) == 0) {
+ *htval = htmap[i].val;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static void print_mcs_index(const __u8 *mcs)
{
unsigned int mcs_bit, prev_bit = -2, prev_cont = 0;
next prev parent reply other threads:[~2011-06-21 16:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-21 15:45 [RFC v3 1/3] mac80211: add some helper functions Alexander Simon
2011-06-21 15:52 ` [RFC v3 2/3] nl80211: channel type attribute for IBSS Alexander Simon
2011-06-24 18:56 ` Felix Fietkau
2011-07-04 10:07 ` Alexander Simon
2011-07-04 10:10 ` Johannes Berg
2011-06-27 12:46 ` Johannes Berg
2011-06-21 15:53 ` [RFC v3 3/3] mac80211: HT operation in IBSS Alexander Simon
2011-06-24 19:21 ` Felix Fietkau
2011-06-27 12:50 ` Johannes Berg
2011-06-27 12:51 ` Johannes Berg
2011-06-21 16:01 ` Alexander Simon [this message]
2011-06-27 12:42 ` patch for iw Johannes Berg
2011-06-21 16:02 ` [RFC v3 1/3] mac80211: add some helper functions Johannes Berg
2011-06-24 19:01 ` Felix Fietkau
2011-06-27 12:46 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1308672087.2656.13.camel@alex-2 \
--to=alexander.simon@saxnet.de \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.