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