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