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