10 static int join_ibss(struct nl80211_state
*state
,
12 int argc
, char **argv
,
16 unsigned char abssid
[6];
17 unsigned char rates
[NL80211_MAX_SUPP_RATES
];
19 char *value
= NULL
, *sptr
= NULL
;
24 const struct chanmode
*chanmode_selected
= NULL
;
25 static const struct chanmode chanmode
[] = {
27 .width
= NL80211_CHAN_WIDTH_20
,
29 .chantype
= NL80211_CHAN_HT20
},
31 .width
= NL80211_CHAN_WIDTH_40
,
33 .chantype
= NL80211_CHAN_HT40PLUS
},
35 .width
= NL80211_CHAN_WIDTH_40
,
37 .chantype
= NL80211_CHAN_HT40MINUS
},
39 .width
= NL80211_CHAN_WIDTH_20_NOHT
,
41 .chantype
= NL80211_CHAN_NO_HT
},
43 .width
= NL80211_CHAN_WIDTH_5
,
47 .width
= NL80211_CHAN_WIDTH_10
,
51 .width
= NL80211_CHAN_WIDTH_80
,
60 NLA_PUT(msg
, NL80211_ATTR_SSID
, strlen(argv
[0]), argv
[0]);
65 freq
= strtoul(argv
[0], &end
, 10);
69 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_FREQ
, freq
);
74 for (i
= 0; i
< ARRAY_SIZE(chanmode
); i
++) {
75 if (strcasecmp(chanmode
[i
].name
, argv
[0]) == 0) {
76 chanmode_selected
= &chanmode
[i
];
80 if (chanmode_selected
) {
81 NLA_PUT_U32(msg
, NL80211_ATTR_CHANNEL_WIDTH
,
82 chanmode_selected
->width
);
83 NLA_PUT_U32(msg
, NL80211_ATTR_CENTER_FREQ1
,
84 get_cf1(chanmode_selected
, freq
));
85 if (chanmode_selected
->chantype
!= -1)
87 NL80211_ATTR_WIPHY_CHANNEL_TYPE
,
88 chanmode_selected
->chantype
);
96 if (argc
&& strcmp(argv
[0], "fixed-freq") == 0) {
97 NLA_PUT_FLAG(msg
, NL80211_ATTR_FREQ_FIXED
);
103 if (mac_addr_a2n(abssid
, argv
[0]) == 0) {
104 NLA_PUT(msg
, NL80211_ATTR_MAC
, 6, abssid
);
110 if (argc
> 1 && strcmp(argv
[0], "beacon-interval") == 0) {
113 bintval
= strtoul(argv
[0], &end
, 10);
116 NLA_PUT_U32(msg
, NL80211_ATTR_BEACON_INTERVAL
, bintval
);
122 if (argc
> 1 && strcmp(argv
[0], "basic-rates") == 0) {
126 value
= strtok_r(argv
[0], ",", &sptr
);
128 while (value
&& n_rates
< NL80211_MAX_SUPP_RATES
) {
129 rate
= strtod(value
, &end
);
130 rates
[n_rates
] = rate
* 2;
132 /* filter out suspicious values */
133 if (*end
!= '\0' || !rates
[n_rates
] ||
134 rate
*2 != rates
[n_rates
])
138 value
= strtok_r(NULL
, ",", &sptr
);
141 NLA_PUT(msg
, NL80211_ATTR_BSS_BASIC_RATES
, n_rates
, rates
);
148 if (argc
> 1 && strcmp(argv
[0], "mcast-rate") == 0) {
152 rate
= strtod(argv
[0], &end
);
156 NLA_PUT_U32(msg
, NL80211_ATTR_MCAST_RATE
, (int)(rate
* 10));
164 if (strcmp(*argv
, "key") != 0 && strcmp(*argv
, "keys") != 0)
170 return parse_keys(msg
, argv
, argc
);
175 static int leave_ibss(struct nl80211_state
*state
,
177 int argc
, char **argv
,
182 COMMAND(ibss
, leave
, NULL
,
183 NL80211_CMD_LEAVE_IBSS
, 0, CIB_NETDEV
, leave_ibss
,
184 "Leave the current IBSS cell.");
186 "<SSID> <freq in MHz> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
187 " [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] "
189 NL80211_CMD_JOIN_IBSS
, 0, CIB_NETDEV
, join_ibss
,
190 "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
191 "it on the given frequency. When fixed frequency is requested, don't\n"
192 "join/create a cell on a different frequency. When a fixed BSSID is\n"
193 "requested use that BSSID and do not adopt another cell's BSSID even\n"
194 "if it has higher TSF and the same SSID. If an IBSS is created, create\n"
195 "it with the specified basic-rates, multicast-rate and beacon-interval.");