2 #include <netlink/genl/genl.h>
3 #include <netlink/genl/family.h>
4 #include <netlink/genl/ctrl.h>
5 #include <netlink/msg.h>
6 #include <netlink/attr.h>
12 static int handle_start_ap(struct nl80211_state
*state
,
13 struct nl_msg
*msg
, int argc
, char **argv
,
16 struct chandef chandef
;
26 NLA_PUT(msg
, NL80211_ATTR_SSID
, strlen(argv
[0]), argv
[0]);
31 res
= parse_freqchan(&chandef
, false, argc
, argv
, &parsed
);
36 res
= put_chandef(msg
, &chandef
);
41 val
= strtoul(argv
[0], &end
, 10);
45 NLA_PUT_U32(msg
, NL80211_ATTR_BEACON_INTERVAL
, val
);
50 val
= strtoul(argv
[0], &end
, 10);
54 NLA_PUT_U32(msg
, NL80211_ATTR_DTIM_PERIOD
, val
);
58 /* beacon head must be provided */
59 if (strcmp(argv
[0], "head") != 0)
64 len
= strlen(argv
[0]);
65 if (!len
|| (len
% 2))
68 if (!hex2bin(&argv
[0][0], buf
))
71 NLA_PUT(msg
, NL80211_ATTR_BEACON_HEAD
, (len
/ 2), &buf
);
78 /* tail is optional */
79 if (strcmp(argv
[0], "tail") == 0) {
86 len
= strlen(argv
[0]);
87 if (!len
|| (len
% 2))
90 if (!hex2bin(&argv
[0][0], buf
))
93 NLA_PUT(msg
, NL80211_ATTR_BEACON_TAIL
, (len
/ 2), &buf
);
101 if (strcmp(*argv
, "key") != 0 && strcmp(*argv
, "keys") != 0)
107 return parse_keys(msg
, argv
, argc
);
111 COMMAND(ap
, start
, "",
112 NL80211_CMD_NEW_BEACON
, 0, CIB_NETDEV
, handle_start_ap
,
113 "<SSID> <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]"
114 " <beacon interval in TU> <DTIM period> head"
115 " <beacon head in hexadecimal> [tail <beacon tail in hexadecimal>]"
116 " [key0:abcde d:1:6162636465]\n");
118 static int handle_stop_ap(struct nl80211_state
*state
,
120 int argc
, char **argv
,
125 COMMAND(ap
, stop
, "",
126 NL80211_CMD_DEL_BEACON
, 0, CIB_NETDEV
, handle_stop_ap
,
127 "Stop AP functionality\n");