]> git.ipfire.org Git - thirdparty/iw.git/blob - iw.h
print nicer auth/assoc/deauth/disassoc events
[thirdparty/iw.git] / iw.h
1 #ifndef __IW_H
2 #define __IW_H
3
4 #include <netlink/netlink.h>
5 #include <netlink/genl/genl.h>
6 #include <netlink/genl/family.h>
7 #include <netlink/genl/ctrl.h>
8
9 #include "nl80211.h"
10
11 #define ETH_ALEN 6
12
13 #ifndef CONFIG_LIBNL20
14 # define nl_sock nl_handle
15 #endif
16
17 struct nl80211_state {
18 struct nl_sock *nl_sock;
19 struct nl_cache *nl_cache;
20 struct genl_family *nl80211;
21 };
22
23 enum command_identify_by {
24 CIB_NONE,
25 CIB_PHY,
26 CIB_NETDEV,
27 };
28
29 enum id_input {
30 II_NONE,
31 II_NETDEV,
32 II_PHY_NAME,
33 II_PHY_IDX,
34 };
35
36 struct cmd {
37 const char *section;
38 const char *name;
39 const char *args;
40 const enum nl80211_commands cmd;
41 int nl_msg_flags;
42 int hidden;
43 const enum command_identify_by idby;
44 /*
45 * The handler should return a negative error code,
46 * zero on success, 1 if the arguments were wrong
47 * and the usage message should and 2 otherwise.
48 */
49 int (*handler)(struct nl80211_state *state,
50 struct nl_cb *cb,
51 struct nl_msg *msg,
52 int argc, char **argv);
53 };
54
55 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
56
57 #define __COMMAND(sect, symname, name, args, nlcmd, flags, hidden, idby, handler)\
58 static const struct cmd \
59 __cmd ## _ ## symname ## _ ## handler ## _ ## nlcmd ## _ ## idby ## _ ## hidden\
60 __attribute__((used)) __attribute__((section("__cmd"))) \
61 = { sect, name, args, nlcmd, flags, hidden, idby, handler }
62 #define COMMAND(section, name, args, cmd, flags, idby, handler) \
63 __COMMAND(#section, name, #name, args, cmd, flags, 0, idby, handler)
64 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
65 __COMMAND(#section, name, #name, args, cmd, flags, 1, idby, handler)
66 #define TOPLEVEL(name, args, cmd, flags, idby, handler) \
67 __COMMAND(NULL, name, #name, args, cmd, flags, 0, idby, handler)
68 extern struct cmd __start___cmd;
69 extern struct cmd __stop___cmd;
70
71 extern const char iw_version[];
72
73 int handle_cmd(struct nl80211_state *state, enum id_input idby,
74 int argc, char **argv);
75 __u32 listen_events(struct nl80211_state *state,
76 const int n_waits, const __u32 *waits);
77
78
79 int mac_addr_a2n(unsigned char *mac_addr, char *arg);
80 int mac_addr_n2a(char *mac_addr, unsigned char *arg);
81
82 const char *iftype_name(enum nl80211_iftype iftype);
83 int ieee80211_channel_to_frequency(int chan);
84 int ieee80211_frequency_to_channel(int freq);
85
86 int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *group);
87
88 char *reg_initiator_to_string(__u8 initiator);
89
90 const char *get_reason_str(uint16_t reason);
91
92 #endif /* __IW_H */