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