3 #include <netlink/genl/genl.h>
4 #include <netlink/genl/family.h>
5 #include <netlink/genl/ctrl.h>
6 #include <netlink/msg.h>
7 #include <netlink/attr.h>
14 static int join_ibss(struct nl80211_state
*state
,
17 int argc
, char **argv
)
20 unsigned char abssid
[6];
21 unsigned char rates
[NL80211_MAX_SUPP_RATES
];
23 char *value
= NULL
, *sptr
= NULL
;
30 NLA_PUT(msg
, NL80211_ATTR_SSID
, strlen(argv
[0]), argv
[0]);
35 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_FREQ
,
36 strtoul(argv
[0], &end
, 10));
42 if (argc
&& strcmp(argv
[0], "fixed-freq") == 0) {
43 NLA_PUT_FLAG(msg
, NL80211_ATTR_FREQ_FIXED
);
49 if (mac_addr_a2n(abssid
, argv
[0]) == 0) {
50 NLA_PUT(msg
, NL80211_ATTR_MAC
, 6, abssid
);
57 if (argc
> 1 && strcmp(argv
[0], "basic-rates") == 0) {
61 value
= strtok_r(argv
[0], ",", &sptr
);
63 while (value
&& n_rates
< NL80211_MAX_SUPP_RATES
) {
64 rate
= strtod(value
, &end
);
65 rates
[n_rates
] = rate
* 2;
67 /* filter out suspicious values */
68 if (*end
!= '\0' || !rates
[n_rates
] ||
69 rate
*2 != rates
[n_rates
])
73 value
= strtok_r(NULL
, ",", &sptr
);
76 NLA_PUT(msg
, NL80211_ATTR_BSS_BASIC_RATES
, n_rates
, rates
);
85 if (strcmp(*argv
, "key") != 0 && strcmp(*argv
, "keys") != 0)
91 return parse_keys(msg
, argv
, argc
);
96 static int leave_ibss(struct nl80211_state
*state
,
99 int argc
, char **argv
)
103 COMMAND(ibss
, leave
, NULL
,
104 NL80211_CMD_LEAVE_IBSS
, 0, CIB_NETDEV
, leave_ibss
,
105 "Leave the current IBSS cell.");
107 "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] "
108 "[basic-rates <rate in Mbps,rate2,...>] [key d:0:abcde]",
109 NL80211_CMD_JOIN_IBSS
, 0, CIB_NETDEV
, join_ibss
,
110 "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
111 "it on the given frequency. When fixed frequency is requested, don't\n"
112 "join/create a cell on a different frequency. When a fixed BSSID is\n"
113 "requested use that BSSID and do not adopt another cell's BSSID even\n"
114 "if it has higher TSF and the same SSID.");