]> git.ipfire.org Git - thirdparty/iw.git/blob - ibss.c
document scan commands
[thirdparty/iw.git] / ibss.c
1 #include <errno.h>
2
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>
8
9 #include "nl80211.h"
10 #include "iw.h"
11
12 static int join_ibss(struct nl80211_state *state,
13 struct nl_cb *cb,
14 struct nl_msg *msg,
15 int argc, char **argv)
16 {
17 char *end;
18 unsigned char abssid[6];
19
20 if (argc < 2)
21 return 1;
22
23 /* SSID */
24 NLA_PUT(msg, NL80211_ATTR_SSID, strlen(argv[0]), argv[0]);
25 argv++;
26 argc--;
27
28 /* freq */
29 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ,
30 strtoul(argv[0], &end, 10));
31 if (*end != '\0')
32 return 1;
33 argv++;
34 argc--;
35
36 if (argc && strcmp(argv[0], "fixed-freq") == 0) {
37 NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
38 argv++;
39 argc--;
40 }
41
42 if (argc) {
43 if (mac_addr_a2n(abssid, argv[0]))
44 return 1;
45 NLA_PUT(msg, NL80211_ATTR_MAC, 6, abssid);
46 argv++;
47 argc--;
48 }
49
50 if (argc)
51 return 1;
52
53 return 0;
54 nla_put_failure:
55 return -ENOSPC;
56 }
57
58 static int leave_ibss(struct nl80211_state *state,
59 struct nl_cb *cb,
60 struct nl_msg *msg,
61 int argc, char **argv)
62 {
63 return 0;
64 }
65 COMMAND(ibss, leave, NULL,
66 NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
67 "Leave the current IBSS cell.");
68 COMMAND(ibss, join, "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>]",
69 NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
70 "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
71 "it on the given frequency. When fixed frequency is requested, don't\n"
72 "join/create a cell on a different frequency. When a fixed BSSID is\n"
73 "requested use that BSSID and do not adopt another cell's BSSID even\n"
74 "if it has higher TSF and the same SSID.");