]>
Commit | Line | Data |
---|---|---|
1 | #include <errno.h> | |
2 | #include <string.h> | |
3 | ||
4 | #include "nl80211.h" | |
5 | #include "iw.h" | |
6 | ||
7 | SECTION(ocb); | |
8 | ||
9 | static int join_ocb(struct nl80211_state *state, | |
10 | struct nl_msg *msg, int argc, char **argv, | |
11 | enum id_input id) | |
12 | { | |
13 | unsigned long freq; | |
14 | char *end; | |
15 | unsigned int i; | |
16 | const struct chanmode *chanmode_selected = NULL; | |
17 | static const struct chanmode chanmode[] = { | |
18 | { .name = "5MHz", | |
19 | .width = NL80211_CHAN_WIDTH_5, | |
20 | .freq1_diff = 0, | |
21 | .chantype = -1 }, | |
22 | { .name = "10MHz", | |
23 | .width = NL80211_CHAN_WIDTH_10, | |
24 | .freq1_diff = 0, | |
25 | .chantype = -1 }, | |
26 | }; | |
27 | ||
28 | if (argc < 2) | |
29 | return 1; | |
30 | ||
31 | /* freq */ | |
32 | freq = strtoul(argv[0], &end, 10); | |
33 | if (*end != '\0') | |
34 | return 1; | |
35 | ||
36 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); | |
37 | argv++; | |
38 | argc--; | |
39 | ||
40 | /* channel width */ | |
41 | for (i = 0; i < ARRAY_SIZE(chanmode); i++) { | |
42 | if (strcasecmp(chanmode[i].name, argv[0]) == 0) { | |
43 | chanmode_selected = &chanmode[i]; | |
44 | break; | |
45 | } | |
46 | } | |
47 | if (chanmode_selected) { | |
48 | NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH, | |
49 | chanmode_selected->width); | |
50 | NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1, | |
51 | get_cf1(chanmode_selected, freq)); | |
52 | ||
53 | argv++; | |
54 | argc--; | |
55 | } else { | |
56 | return 1; | |
57 | } | |
58 | ||
59 | return 0; | |
60 | ||
61 | nla_put_failure: | |
62 | return -ENOBUFS; | |
63 | } | |
64 | COMMAND(ocb, join, "<freq in MHz> <5MHz|10MHz>", | |
65 | NL80211_CMD_JOIN_OCB, 0, CIB_NETDEV, join_ocb, | |
66 | "Join the OCB mode network."); | |
67 | ||
68 | static int leave_ocb(struct nl80211_state *state, | |
69 | struct nl_msg *msg, int argc, char **argv, | |
70 | enum id_input id) | |
71 | { | |
72 | if (argc) | |
73 | return 1; | |
74 | ||
75 | return 0; | |
76 | } | |
77 | COMMAND(ocb, leave, NULL, NL80211_CMD_LEAVE_OCB, 0, CIB_NETDEV, leave_ocb, | |
78 | "Leave the OCB mode network."); |