]>
Commit | Line | Data |
---|---|---|
cad53b3f JB |
1 | #ifndef __IW_H |
2 | #define __IW_H | |
3 | ||
7fabd346 | 4 | #include <stdbool.h> |
45d543f0 | 5 | #include <netlink/netlink.h> |
cad53b3f JB |
6 | #include <netlink/genl/genl.h> |
7 | #include <netlink/genl/family.h> | |
8 | #include <netlink/genl/ctrl.h> | |
9 | ||
f408e01b JB |
10 | #include "nl80211.h" |
11 | ||
3d1e8704 LCC |
12 | #define ETH_ALEN 6 |
13 | ||
57077d64 PE |
14 | #ifndef CONFIG_LIBNL20 |
15 | # define nl_sock nl_handle | |
dfd13ee5 | 16 | #endif |
57077d64 PE |
17 | |
18 | struct nl80211_state { | |
19 | struct nl_sock *nl_sock; | |
cad53b3f JB |
20 | struct nl_cache *nl_cache; |
21 | struct genl_family *nl80211; | |
ded1f078 JB |
22 | |
23 | const char *ifname; | |
cad53b3f JB |
24 | }; |
25 | ||
bd396f2a JB |
26 | enum command_identify_by { |
27 | CIB_NONE, | |
28 | CIB_PHY, | |
29 | CIB_NETDEV, | |
7c37a24d JB |
30 | }; |
31 | ||
32 | enum id_input { | |
33 | II_NONE, | |
34 | II_NETDEV, | |
35 | II_PHY_NAME, | |
36 | II_PHY_IDX, | |
bd396f2a | 37 | }; |
45c7212c | 38 | |
bd396f2a JB |
39 | struct cmd { |
40 | const char *section; | |
41 | const char *name; | |
42 | const char *args; | |
01ae06f9 | 43 | const char *help; |
bd396f2a JB |
44 | const enum nl80211_commands cmd; |
45 | int nl_msg_flags; | |
ce5af55c | 46 | int hidden; |
bd396f2a | 47 | const enum command_identify_by idby; |
5e75fd04 JB |
48 | /* |
49 | * The handler should return a negative error code, | |
50 | * zero on success, 1 if the arguments were wrong | |
51 | * and the usage message should and 2 otherwise. | |
52 | */ | |
7c37a24d JB |
53 | int (*handler)(struct nl80211_state *state, |
54 | struct nl_cb *cb, | |
bd396f2a JB |
55 | struct nl_msg *msg, |
56 | int argc, char **argv); | |
57 | }; | |
3d1e8704 | 58 | |
7d736016 JB |
59 | #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0])) |
60 | ||
01ae06f9 | 61 | #define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help)\ |
ce5af55c | 62 | static const struct cmd \ |
9b92e691 JB |
63 | __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\ |
64 | __attribute__((used)) __attribute__((section("__cmd"))) = { \ | |
65 | .section = (_section), \ | |
66 | .name = (_name), \ | |
67 | .args = (_args), \ | |
68 | .cmd = (_nlcmd), \ | |
69 | .nl_msg_flags = (_flags), \ | |
70 | .hidden = (_hidden), \ | |
71 | .idby = (_idby), \ | |
72 | .handler = (_handler), \ | |
01ae06f9 | 73 | .help = (_help), \ |
9b92e691 | 74 | } |
01ae06f9 JB |
75 | #define COMMAND(section, name, args, cmd, flags, idby, handler, help) \ |
76 | __COMMAND(#section, name, #name, args, cmd, flags, 0, idby, handler, help) | |
77 | #define HIDDEN(section, name, args, cmd, flags, idby, handler) \ | |
78 | __COMMAND(#section, name, #name, args, cmd, flags, 1, idby, handler, NULL) | |
79 | #define TOPLEVEL(name, args, cmd, flags, idby, handler, help) \ | |
80 | __COMMAND(NULL, name, #name, args, cmd, flags, 0, idby, handler, help) | |
bd396f2a JB |
81 | extern struct cmd __start___cmd; |
82 | extern struct cmd __stop___cmd; | |
14a0380d | 83 | |
133b069f | 84 | extern const char iw_version[]; |
7c37a24d | 85 | |
957a0f07 JB |
86 | extern int iw_debug; |
87 | ||
7c37a24d JB |
88 | int handle_cmd(struct nl80211_state *state, enum id_input idby, |
89 | int argc, char **argv); | |
7fabd346 JB |
90 | |
91 | struct print_event_args { | |
92 | bool frame, time; | |
93 | }; | |
94 | ||
72041aa0 JB |
95 | __u32 listen_events(struct nl80211_state *state, |
96 | const int n_waits, const __u32 *waits); | |
7fabd346 JB |
97 | __u32 __listen_events(struct nl80211_state *state, |
98 | const int n_waits, const __u32 *waits, | |
99 | struct print_event_args *args); | |
7c37a24d JB |
100 | |
101 | ||
3d1e8704 LCC |
102 | int mac_addr_a2n(unsigned char *mac_addr, char *arg); |
103 | int mac_addr_n2a(char *mac_addr, unsigned char *arg); | |
104 | ||
51e9bd80 JB |
105 | int parse_keys(struct nl_msg *msg, char **argv, int argc); |
106 | ||
541ef425 | 107 | const char *iftype_name(enum nl80211_iftype iftype); |
379f8397 JB |
108 | int ieee80211_channel_to_frequency(int chan); |
109 | int ieee80211_frequency_to_channel(int freq); | |
541ef425 | 110 | |
748f8489 JB |
111 | void print_ssid_escaped(const uint8_t len, const uint8_t *data); |
112 | ||
57077d64 | 113 | int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *group); |
2c61ba61 | 114 | |
601c6ab2 LR |
115 | char *reg_initiator_to_string(__u8 initiator); |
116 | ||
27c49ed6 | 117 | const char *get_reason_str(uint16_t reason); |
22c7d879 | 118 | const char *get_status_str(uint16_t status); |
27c49ed6 | 119 | |
ded1f078 JB |
120 | int set_interface_up(const char *ifname); |
121 | ||
cad53b3f | 122 | #endif /* __IW_H */ |