mac80211: update to wireless-testing 2012-02-06
[openwrt/staging/chunkeey.git] / package / iw / patches / 110-ibss_ht.patch
1 --- a/ibss.c
2 +++ b/ibss.c
3 @@ -27,6 +27,7 @@ static int join_ibss(struct nl80211_stat
4 char *value = NULL, *sptr = NULL;
5 float rate;
6 int bintval;
7 + unsigned int htval;
8
9 if (argc < 2)
10 return 1;
11 @@ -44,6 +45,12 @@ static int join_ibss(struct nl80211_stat
12 argv++;
13 argc--;
14
15 + if (argc && parse_channel_type(argv[0], &htval)) {
16 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, htval);
17 + argv++;
18 + argc--;
19 + }
20 +
21 if (argc && strcmp(argv[0], "fixed-freq") == 0) {
22 NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
23 argv++;
24 @@ -134,7 +141,7 @@ COMMAND(ibss, leave, NULL,
25 NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
26 "Leave the current IBSS cell.");
27 COMMAND(ibss, join,
28 - "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
29 + "<SSID> <freq in MHz> [HT20|HT40+|HT40-] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
30 " [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] "
31 "[key d:0:abcde]",
32 NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
33 --- a/iw.h
34 +++ b/iw.h
35 @@ -133,6 +133,7 @@ int parse_hex_mask(char *hexmask, unsign
36 unsigned char *parse_hex(char *hex, size_t *outlen);
37
38 int parse_keys(struct nl_msg *msg, char **argv, int argc);
39 +int parse_channel_type(const char *str, unsigned int *htval);
40
41 void print_ht_mcs(const __u8 *mcs);
42 void print_ampdu_length(__u8 exponent);
43 --- a/phy.c
44 +++ b/phy.c
45 @@ -33,30 +33,14 @@ static int handle_freqchan(struct nl_msg
46 int argc, char **argv)
47 {
48 char *end;
49 - static const struct {
50 - const char *name;
51 - unsigned int val;
52 - } htmap[] = {
53 - { .name = "HT20", .val = NL80211_CHAN_HT20, },
54 - { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
55 - { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
56 - };
57 unsigned int htval = NL80211_CHAN_NO_HT;
58 unsigned int freq;
59 - int i;
60
61 if (!argc || argc > 2)
62 return 1;
63
64 - if (argc == 2) {
65 - for (i = 0; i < ARRAY_SIZE(htmap); i++) {
66 - if (strcasecmp(htmap[i].name, argv[1]) == 0) {
67 - htval = htmap[i].val;
68 - break;
69 - }
70 - }
71 - if (htval == NL80211_CHAN_NO_HT)
72 - return 1;
73 + if (argc == 2 && !parse_channel_type(argv[1], &htval)) {
74 + return 1;
75 }
76
77 if (!*argv[0])
78 --- a/util.c
79 +++ b/util.c
80 @@ -382,6 +382,33 @@ int parse_keys(struct nl_msg *msg, char
81 return 2;
82 }
83
84 +/*
85 + * Convert a string "HT20", "HT40+" or "HT40-" into nl80211
86 + * value. Conversion is case insensitive. Returns 1 on success, 0 on error.
87 + */
88 +
89 +int parse_channel_type(const char *str, unsigned int *htval)
90 +{
91 + static const struct {
92 + const char *name;
93 + unsigned int val;
94 + } htmap[] = {
95 + { .name = "HT20", .val = NL80211_CHAN_HT20, },
96 + { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
97 + { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
98 + };
99 + int i;
100 +
101 + for (i = 0; i < ARRAY_SIZE(htmap); i++) {
102 + if (strcasecmp(htmap[i].name, str) == 0) {
103 + *htval = htmap[i].val;
104 + return 1;
105 + }
106 + }
107 +
108 + return 0;
109 +}
110 +
111 static void print_mcs_index(const __u8 *mcs)
112 {
113 unsigned int mcs_bit, prev_bit = -2, prev_cont = 0;