]>
git.ipfire.org Git - thirdparty/iw.git/blob - iw.h
5 #include <netlink/netlink.h>
6 #include <netlink/genl/genl.h>
7 #include <netlink/genl/family.h>
8 #include <netlink/genl/ctrl.h>
12 #include "ieee80211.h"
16 /* libnl 1.x compatibility code */
17 #if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
18 # define nl_sock nl_handle
21 struct nl80211_state
{
22 struct nl_sock
*nl_sock
;
26 enum command_identify_by
{
41 #define HANDLER_RET_USAGE 1
42 #define HANDLER_RET_DONE 3
48 const enum nl80211_commands cmd
;
51 const enum command_identify_by idby
;
53 * The handler should return a negative error code,
54 * zero on success, 1 if the arguments were wrong.
55 * Return 2 iff you provide the error message yourself.
57 int (*handler
)(struct nl80211_state
*state
,
59 int argc
, char **argv
,
61 const struct cmd
*(*selector
)(int argc
, char **argv
);
62 const struct cmd
*parent
;
69 int chantype
; /* for older kernel */
72 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
73 #define DIV_ROUND_UP(x, y) (((x) + (y - 1)) / (y))
75 #define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel)\
77 __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
78 __attribute__((used)) __attribute__((section("__cmd"))) = { \
82 .nl_msg_flags = (_flags), \
83 .hidden = (_hidden), \
85 .handler = (_handler), \
90 #define __ACMD(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel, _alias)\
91 __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel);\
92 static const struct cmd *_alias = &__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden
93 #define COMMAND(section, name, args, cmd, flags, idby, handler, help) \
94 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, NULL)
95 #define COMMAND_ALIAS(section, name, args, cmd, flags, idby, handler, help, selector, alias)\
96 __ACMD(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, selector, alias)
97 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
98 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL, NULL)
100 #define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help) \
102 __section ## _ ## _name \
103 __attribute__((used)) __attribute__((section("__cmd"))) = { \
107 .nl_msg_flags = (_flags), \
109 .handler = (_handler), \
112 #define SECTION(_name) \
113 struct cmd __section ## _ ## _name \
114 __attribute__((used)) __attribute__((section("__cmd"))) = { \
119 #define DECLARE_SECTION(_name) \
120 extern struct cmd __section ## _ ## _name;
122 extern const char iw_version
[];
126 int handle_cmd(struct nl80211_state
*state
, enum id_input idby
,
127 int argc
, char **argv
);
129 struct print_event_args
{
130 struct timeval ts
; /* internal */
131 bool have_ts
; /* must be set false */
132 bool frame
, time
, reltime
;
135 __u32
listen_events(struct nl80211_state
*state
,
136 const int n_waits
, const __u32
*waits
);
137 int __prepare_listen_events(struct nl80211_state
*state
);
138 __u32
__do_listen_events(struct nl80211_state
*state
,
139 const int n_waits
, const __u32
*waits
,
140 struct print_event_args
*args
);
142 int valid_handler(struct nl_msg
*msg
, void *arg
);
143 void register_handler(int (*handler
)(struct nl_msg
*, void *), void *data
);
145 int mac_addr_a2n(unsigned char *mac_addr
, char *arg
);
146 void mac_addr_n2a(char *mac_addr
, unsigned char *arg
);
147 int parse_hex_mask(char *hexmask
, unsigned char **result
, size_t *result_len
,
148 unsigned char **mask
);
149 unsigned char *parse_hex(char *hex
, size_t *outlen
);
151 int parse_keys(struct nl_msg
*msg
, char **argv
, int argc
);
153 void print_ht_mcs(const __u8
*mcs
);
154 void print_ampdu_length(__u8 exponent
);
155 void print_ampdu_spacing(__u8 spacing
);
156 void print_ht_capability(__u16 cap
);
157 void print_vht_info(__u32 capa
, const __u8
*mcs
);
159 char *channel_width_name(enum nl80211_chan_width width
);
160 const char *iftype_name(enum nl80211_iftype iftype
);
161 const char *command_name(enum nl80211_commands cmd
);
162 int ieee80211_channel_to_frequency(int chan
, enum nl80211_band band
);
163 int ieee80211_frequency_to_channel(int freq
);
165 void print_ssid_escaped(const uint8_t len
, const uint8_t *data
);
167 int nl_get_multicast_id(struct nl_sock
*sock
, const char *family
, const char *group
);
169 char *reg_initiator_to_string(__u8 initiator
);
171 const char *get_reason_str(uint16_t reason
);
172 const char *get_status_str(uint16_t status
);
179 #define BIT(x) (1ULL<<(x))
181 void print_ies(unsigned char *ie
, int ielen
, bool unknown
,
182 enum print_ie_type ptype
);
184 void parse_bitrate(struct nlattr
*bitrate_attr
, char *buf
, int buflen
);
185 void iw_hexdump(const char *prefix
, const __u8
*data
, size_t len
);
187 int get_cf1(const struct chanmode
*chanmode
, unsigned long freq
);
189 #define SCHED_SCAN_OPTIONS "interval <in_msecs> [delay <in_secs>] " \
190 "[freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] [randomise[=<addr>/<mask>]]"
191 int parse_sched_scan(struct nl_msg
*msg
, int *argc
, char ***argv
);
193 DECLARE_SECTION(set
);
194 DECLARE_SECTION(get
);