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
)
25 unsigned char abssid
[6];
26 unsigned char rates
[NL80211_MAX_SUPP_RATES
];
28 char *value
= NULL
, *sptr
= NULL
;
36 { .name
= "HT20", .val
= NL80211_CHAN_HT20
, },
37 { .name
= "HT40+", .val
= NL80211_CHAN_HT40PLUS
, },
38 { .name
= "HT40-", .val
= NL80211_CHAN_HT40MINUS
, },
39 { .name
= "NOHT", .val
= NL80211_CHAN_NO_HT
, },
47 NLA_PUT(msg
, NL80211_ATTR_SSID
, strlen(argv
[0]), argv
[0]);
52 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_FREQ
,
53 strtoul(argv
[0], &end
, 10));
60 for (i
= 0; i
< ARRAY_SIZE(htmap
); i
++) {
61 if (strcasecmp(htmap
[i
].name
, argv
[0]) == 0) {
66 if (i
!= ARRAY_SIZE(htmap
)) {
67 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_CHANNEL_TYPE
,
75 if (argc
&& strcmp(argv
[0], "fixed-freq") == 0) {
76 NLA_PUT_FLAG(msg
, NL80211_ATTR_FREQ_FIXED
);
82 if (mac_addr_a2n(abssid
, argv
[0]) == 0) {
83 NLA_PUT(msg
, NL80211_ATTR_MAC
, 6, abssid
);
89 if (argc
> 1 && strcmp(argv
[0], "beacon-interval") == 0) {
92 bintval
= strtoul(argv
[0], &end
, 10);
95 NLA_PUT_U32(msg
, NL80211_ATTR_BEACON_INTERVAL
, bintval
);
101 if (argc
> 1 && strcmp(argv
[0], "basic-rates") == 0) {
105 value
= strtok_r(argv
[0], ",", &sptr
);
107 while (value
&& n_rates
< NL80211_MAX_SUPP_RATES
) {
108 rate
= strtod(value
, &end
);
109 rates
[n_rates
] = rate
* 2;
111 /* filter out suspicious values */
112 if (*end
!= '\0' || !rates
[n_rates
] ||
113 rate
*2 != rates
[n_rates
])
117 value
= strtok_r(NULL
, ",", &sptr
);
120 NLA_PUT(msg
, NL80211_ATTR_BSS_BASIC_RATES
, n_rates
, rates
);
127 if (argc
> 1 && strcmp(argv
[0], "mcast-rate") == 0) {
131 rate
= strtod(argv
[0], &end
);
135 NLA_PUT_U32(msg
, NL80211_ATTR_MCAST_RATE
, (int)(rate
* 10));
143 if (strcmp(*argv
, "key") != 0 && strcmp(*argv
, "keys") != 0)
149 return parse_keys(msg
, argv
, argc
);
154 static int leave_ibss(struct nl80211_state
*state
,
157 int argc
, char **argv
)
161 COMMAND(ibss
, leave
, NULL
,
162 NL80211_CMD_LEAVE_IBSS
, 0, CIB_NETDEV
, leave_ibss
,
163 "Leave the current IBSS cell.");
165 "<SSID> <freq in MHz> [HT20|HT40+|HT40-|NOHT] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>]"
166 " [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] "
168 NL80211_CMD_JOIN_IBSS
, 0, CIB_NETDEV
, join_ibss
,
169 "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
170 "it on the given frequency. When fixed frequency is requested, don't\n"
171 "join/create a cell on a different frequency. When a fixed BSSID is\n"
172 "requested use that BSSID and do not adopt another cell's BSSID even\n"
173 "if it has higher TSF and the same SSID. If an IBSS is created, create\n"
174 "it with the specified basic-rates, multicast-rate and beacon-interval.");