]> git.ipfire.org Git - thirdparty/iw.git/blame - ibss.c
print "00-0f-ac:7" instead of "Unknown (00-0f-ac:7)" to make it shorter
[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
JB
42 if (argc) {
43 if (mac_addr_a2n(abssid, argv[0]))
edea4d14
JB
44 return 1;
45 NLA_PUT(msg, NL80211_ATTR_MAC, 6, abssid);
95940df3
JB
46 argv++;
47 argc--;
edea4d14
JB
48 }
49
95940df3
JB
50 if (argc)
51 return 1;
edea4d14
JB
52
53 return 0;
54 nla_put_failure:
55 return -ENOSPC;
56}
57
58static 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}
65COMMAND(ibss, leave, NULL,
66 NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss);
95940df3 67COMMAND(ibss, join, "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>]",
edea4d14 68 NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss);