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