]> git.ipfire.org Git - thirdparty/iw.git/blob - iw.h
Merge branch 'master' into scan-test
[thirdparty/iw.git] / iw.h
1 #ifndef __IW_H
2 #define __IW_H
3
4 #include <netlink/genl/genl.h>
5 #include <netlink/genl/family.h>
6 #include <netlink/genl/ctrl.h>
7
8 #include "nl80211.h"
9
10 #define ETH_ALEN 6
11
12 struct nl80211_state {
13 #ifdef CONFIG_LIBNL20
14 struct nl_sock *nl_handle;
15 #else
16 struct nl_handle *nl_handle;
17 #endif
18 struct nl_cache *nl_cache;
19 struct genl_family *nl80211;
20 };
21
22 enum command_identify_by {
23 CIB_NONE,
24 CIB_PHY,
25 CIB_NETDEV,
26 };
27
28 struct cmd {
29 const char *section;
30 const char *name;
31 const char *args;
32 const enum nl80211_commands cmd;
33 int nl_msg_flags;
34 int hidden;
35 const enum command_identify_by idby;
36 /*
37 * The handler should return a negative error code,
38 * zero on success, 1 if the arguments were wrong
39 * and the usage message should and 2 otherwise.
40 */
41 int (*handler)(struct nl_cb *cb,
42 struct nl_msg *msg,
43 int argc, char **argv);
44 };
45
46 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
47
48 #define __COMMAND(sect, name, args, nlcmd, flags, hidden, idby, handler)\
49 static const struct cmd \
50 __cmd_ ## handler ## _ ## nlcmd ## _ ## idby ## _ ## hidden \
51 __attribute__((used)) __attribute__((section("__cmd"))) \
52 = { sect, name, args, nlcmd, flags, hidden, idby, handler }
53 #define COMMAND(section, name, args, cmd, flags, idby, handler) \
54 __COMMAND(#section, #name, args, cmd, flags, 0, idby, handler)
55 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
56 __COMMAND(#section, #name, args, cmd, flags, 1, idby, handler)
57 #define TOPLEVEL(name, args, cmd, flags, idby, handler) \
58 __COMMAND(NULL, #name, args, cmd, flags, 0, idby, handler)
59 extern struct cmd __start___cmd;
60 extern struct cmd __stop___cmd;
61
62 int mac_addr_a2n(unsigned char *mac_addr, char *arg);
63 int mac_addr_n2a(char *mac_addr, unsigned char *arg);
64
65 const char *iftype_name(enum nl80211_iftype iftype);
66 int ieee80211_channel_to_frequency(int chan);
67 int ieee80211_frequency_to_channel(int freq);
68
69 int nl_get_multicast_id(struct nl_handle *handle, const char *family, const char *group);
70
71 #endif /* __IW_H */