]> git.ipfire.org Git - thirdparty/iw.git/blame - iw.h
iw: Support ht-capability overrides mask.
[thirdparty/iw.git] / iw.h
CommitLineData
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>
a82abc2c 9#include <endian.h>
cad53b3f 10
f408e01b 11#include "nl80211.h"
a82abc2c 12#include "ieee80211.h"
f408e01b 13
3d1e8704
LCC
14#define ETH_ALEN 6
15
ded667b0
YY
16/* libnl 1.x compatibility code */
17#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
57077d64 18# define nl_sock nl_handle
dfd13ee5 19#endif
57077d64
PE
20
21struct nl80211_state {
22 struct nl_sock *nl_sock;
f09cee6d 23 int nl80211_id;
cad53b3f
JB
24};
25
bd396f2a
JB
26enum command_identify_by {
27 CIB_NONE,
28 CIB_PHY,
29 CIB_NETDEV,
7c37a24d
JB
30};
31
32enum id_input {
33 II_NONE,
34 II_NETDEV,
35 II_PHY_NAME,
36 II_PHY_IDX,
bd396f2a 37};
45c7212c 38
bd396f2a 39struct cmd {
bd396f2a
JB
40 const char *name;
41 const char *args;
01ae06f9 42 const char *help;
bd396f2a
JB
43 const enum nl80211_commands cmd;
44 int nl_msg_flags;
ce5af55c 45 int hidden;
bd396f2a 46 const enum command_identify_by idby;
5e75fd04
JB
47 /*
48 * The handler should return a negative error code,
49 * zero on success, 1 if the arguments were wrong
50 * and the usage message should and 2 otherwise.
51 */
7c37a24d
JB
52 int (*handler)(struct nl80211_state *state,
53 struct nl_cb *cb,
bd396f2a
JB
54 struct nl_msg *msg,
55 int argc, char **argv);
1633ddf7 56 const struct cmd *(*selector)(int argc, char **argv);
4698bfc2 57 const struct cmd *parent;
bd396f2a 58};
3d1e8704 59
7d736016 60#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
3ff24563 61#define DIV_ROUND_UP(x, y) (((x) + (y - 1)) / (y))
7d736016 62
1633ddf7 63#define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel)\
78bebb71 64 static struct cmd \
9b92e691
JB
65 __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
66 __attribute__((used)) __attribute__((section("__cmd"))) = { \
9b92e691
JB
67 .name = (_name), \
68 .args = (_args), \
69 .cmd = (_nlcmd), \
70 .nl_msg_flags = (_flags), \
71 .hidden = (_hidden), \
72 .idby = (_idby), \
73 .handler = (_handler), \
01ae06f9 74 .help = (_help), \
4698bfc2 75 .parent = _section, \
1633ddf7
JB
76 .selector = (_sel), \
77 }
78#define __ACMD(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel, _alias)\
79 __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel);\
80 static const struct cmd *_alias = &__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden
01ae06f9 81#define COMMAND(section, name, args, cmd, flags, idby, handler, help) \
1633ddf7
JB
82 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, NULL)
83#define COMMAND_ALIAS(section, name, args, cmd, flags, idby, handler, help, selector, alias)\
84 __ACMD(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, selector, alias)
01ae06f9 85#define HIDDEN(section, name, args, cmd, flags, idby, handler) \
1633ddf7 86 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL, NULL)
4698bfc2
JB
87
88#define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help) \
78bebb71 89 struct cmd \
4698bfc2
JB
90 __section ## _ ## _name \
91 __attribute__((used)) __attribute__((section("__cmd"))) = { \
92 .name = (#_name), \
93 .args = (_args), \
94 .cmd = (_nlcmd), \
95 .nl_msg_flags = (_flags), \
96 .idby = (_idby), \
97 .handler = (_handler), \
98 .help = (_help), \
99 }
100#define SECTION(_name) \
78bebb71 101 struct cmd __section ## _ ## _name \
4698bfc2
JB
102 __attribute__((used)) __attribute__((section("__cmd"))) = { \
103 .name = (#_name), \
104 .hidden = 1, \
105 }
106
107#define DECLARE_SECTION(_name) \
78bebb71 108 extern struct cmd __section ## _ ## _name;
14a0380d 109
133b069f 110extern const char iw_version[];
7c37a24d 111
957a0f07
JB
112extern int iw_debug;
113
7c37a24d
JB
114int handle_cmd(struct nl80211_state *state, enum id_input idby,
115 int argc, char **argv);
7fabd346
JB
116
117struct print_event_args {
981b21ad
JB
118 struct timeval ts; /* internal */
119 bool have_ts; /* must be set false */
120 bool frame, time, reltime;
7fabd346
JB
121};
122
72041aa0
JB
123__u32 listen_events(struct nl80211_state *state,
124 const int n_waits, const __u32 *waits);
ee374e4d
JB
125int __prepare_listen_events(struct nl80211_state *state);
126__u32 __do_listen_events(struct nl80211_state *state,
127 const int n_waits, const __u32 *waits,
128 struct print_event_args *args);
7c37a24d
JB
129
130
3d1e8704 131int mac_addr_a2n(unsigned char *mac_addr, char *arg);
febeb0c0 132void mac_addr_n2a(char *mac_addr, unsigned char *arg);
3ff24563
JB
133int parse_hex_mask(char *hexmask, unsigned char **result, size_t *result_len,
134 unsigned char **mask);
236d4191 135unsigned char *parse_hex(char *hex, size_t *outlen);
3d1e8704 136
51e9bd80
JB
137int parse_keys(struct nl_msg *msg, char **argv, int argc);
138
7ddfb679 139void print_ht_mcs(const __u8 *mcs);
0950993f
LR
140void print_ampdu_length(__u8 exponent);
141void print_ampdu_spacing(__u8 spacing);
357c1a5d 142void print_ht_capability(__u16 cap);
deb3501c 143
541ef425 144const char *iftype_name(enum nl80211_iftype iftype);
9990c1e9 145const char *command_name(enum nl80211_commands cmd);
379f8397
JB
146int ieee80211_channel_to_frequency(int chan);
147int ieee80211_frequency_to_channel(int freq);
541ef425 148
748f8489
JB
149void print_ssid_escaped(const uint8_t len, const uint8_t *data);
150
57077d64 151int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *group);
2c61ba61 152
601c6ab2
LR
153char *reg_initiator_to_string(__u8 initiator);
154
27c49ed6 155const char *get_reason_str(uint16_t reason);
22c7d879 156const char *get_status_str(uint16_t status);
27c49ed6 157
febeb0c0
JB
158enum print_ie_type {
159 PRINT_SCAN,
160 PRINT_LINK,
161};
162
163#define BIT(x) (1ULL<<(x))
164
165void print_ies(unsigned char *ie, int ielen, bool unknown,
166 enum print_ie_type ptype);
167
4698bfc2
JB
168
169DECLARE_SECTION(set);
170DECLARE_SECTION(get);
171
cad53b3f 172#endif /* __IW_H */