]> git.ipfire.org Git - thirdparty/iw.git/blame - ibss.c
don't emit usage to stderr
[thirdparty/iw.git] / ibss.c
CommitLineData
edea4d14
JB
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
12static int join_ibss(struct nl80211_state *state,
13 struct nl_cb *cb,
14 struct nl_msg *msg,
15 int argc, char **argv)
16{
95940df3 17 char *end;
edea4d14
JB
18 unsigned char abssid[6];
19
95940df3
JB
20 if (argc < 2)
21 return 1;
edea4d14 22
95940df3
JB
23 /* SSID */
24 NLA_PUT(msg, NL80211_ATTR_SSID, strlen(argv[0]), argv[0]);
edea4d14
JB
25 argv++;
26 argc--;
27
95940df3
JB
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--;
edea4d14 35
95940df3
JB
36 if (argc && strcmp(argv[0], "fixed-freq") == 0) {
37 NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
38 argv++;
39 argc--;
edea4d14
JB
40 }
41
95940df3 42 if (argc) {
51e9bd80
JB
43 if (mac_addr_a2n(abssid, argv[0]) == 0) {
44 NLA_PUT(msg, NL80211_ATTR_MAC, 6, abssid);
45 argv++;
46 argc--;
47 }
edea4d14
JB
48 }
49
1e03690e
JB
50 if (!argc)
51 return 0;
edea4d14 52
1e03690e
JB
53 if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
54 return 1;
ded1f078 55
1e03690e
JB
56 argv++;
57 argc--;
51e9bd80 58
1e03690e 59 return parse_keys(msg, argv, argc);
edea4d14
JB
60 nla_put_failure:
61 return -ENOSPC;
62}
63
64static int leave_ibss(struct nl80211_state *state,
65 struct nl_cb *cb,
66 struct nl_msg *msg,
67 int argc, char **argv)
68{
69 return 0;
70}
71COMMAND(ibss, leave, NULL,
806bad30
JB
72 NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
73 "Leave the current IBSS cell.");
51e9bd80 74COMMAND(ibss, join, "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [key d:0:abcde]",
806bad30
JB
75 NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
76 "Join the IBSS cell with the given SSID, if it doesn't exist create\n"
77 "it on the given frequency. When fixed frequency is requested, don't\n"
78 "join/create a cell on a different frequency. When a fixed BSSID is\n"
79 "requested use that BSSID and do not adopt another cell's BSSID even\n"
80 "if it has higher TSF and the same SSID.");