8 #include <netlink/genl/genl.h>
9 #include <netlink/genl/family.h>
10 #include <netlink/genl/ctrl.h>
11 #include <netlink/msg.h>
12 #include <netlink/attr.h>
19 static int join_ibss(struct nl80211_state
*state
,
22 int argc
, char **argv
,
26 unsigned char abssid
[6];
27 unsigned char rates
[NL80211_MAX_SUPP_RATES
];
29 char *value
= NULL
, *sptr
= NULL
;
37 { .name
= "HT20", .val
= NL80211_CHAN_HT20
, },
38 { .name
= "HT40+", .val
= NL80211_CHAN_HT40PLUS
, },
39 { .name
= "HT40-", .val
= NL80211_CHAN_HT40MINUS
, },
40 { .name
= "NOHT", .val
= NL80211_CHAN_NO_HT
, },
48 NLA_PUT(msg
, NL80211_ATTR_SSID
, strlen(argv
[0]), argv
[0]);
53 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_FREQ
,
54 strtoul(argv
[0], &end
, 10));
61 for (i
= 0; i
< ARRAY_SIZE(htmap
); i
++) {
62 if (strcasecmp(htmap
[i
].name
, argv
[0]) == 0) {
67 if (i
!= ARRAY_SIZE(htmap
)) {
68 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_CHANNEL_TYPE
,
76 if (argc
&& strcmp(argv
[0], "fixed-freq") == 0) {
77 NLA_PUT_FLAG(msg
, NL80211_ATTR_FREQ_FIXED
);
83 if (mac_addr_a2n(abssid
, argv
[0]) == 0) {
84 NLA_PUT(msg
, NL80211_ATTR_MAC
, 6, abssid
);
90 if (argc
> 1 && strcmp(argv
[0], "beacon-interval") == 0) {
93 bintval
= strtoul(argv
[0], &end
, 10);
96 NLA_PUT_U32(msg
, NL80211_ATTR_BEACON_INTERVAL
, bintval
);
102 if (argc
> 1 && strcmp(argv
[0], "basic-rates") == 0) {
106 value
= strtok_r(argv
[0], ",", &sptr
);
108 while (value
&& n_rates
< NL80211_MAX_SUPP_RATES
) {
109 rate
= strtod(value
, &end
);
110 rates
[n_rates
] = rate
* 2;
112 /* filter out suspicious values */
113 if (*end
!= '\0' || !rates
[n_rates
] ||
114 rate
*2 != rates
[n_rates
])
118 value
= strtok_r(NULL
, ",", &sptr
);
121 NLA_PUT(msg
, NL80211_ATTR_BSS_BASIC_RATES
, n_rates
, rates
);
128 if (argc
> 1 && strcmp(argv
[0], "mcast-rate") == 0) {
132 rate
= strtod(argv
[0], &end
);
136 NLA_PUT_U32(msg
, NL80211_ATTR_MCAST_RATE
, (int)(rate
* 10));
144 if (strcmp(*argv
, "key") != 0 && strcmp(*argv
, "keys") != 0)
150 return parse_keys(msg
, argv
, argc
);
155 static int leave_ibss(struct nl80211_state
*state
,
158 int argc
, char **argv
,
163 COMMAND(ibss
, leave
, NULL
,
164 NL80211_CMD_LEAVE_IBSS
, 0, CIB_NETDEV
, leave_ibss
,
165 "Leave the current IBSS cell.");
167 "<SSID> <freq in MHz> [HT20|HT40+|HT40-|NOHT] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
168 " [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] "
170 NL80211_CMD_JOIN_IBSS
, 0, CIB_NETDEV
, join_ibss
,
171 "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
172 "it on the given frequency. When fixed frequency is requested, don't\n"
173 "join/create a cell on a different frequency. When a fixed BSSID is\n"
174 "requested use that BSSID and do not adopt another cell's BSSID even\n"
175 "if it has higher TSF and the same SSID. If an IBSS is created, create\n"
176 "it with the specified basic-rates, multicast-rate and beacon-interval.");