]>
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
{
45 const enum nl80211_commands cmd
;
48 const enum command_identify_by idby
;
50 * The handler should return a negative error code,
51 * zero on success, 1 if the arguments were wrong
52 * and the usage message should and 2 otherwise.
54 int (*handler
)(struct nl80211_state
*state
,
57 int argc
, char **argv
,
59 const struct cmd
*(*selector
)(int argc
, char **argv
);
60 const struct cmd
*parent
;
63 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
64 #define DIV_ROUND_UP(x, y) (((x) + (y - 1)) / (y))
66 #define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel)\
68 __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
69 __attribute__((used)) __attribute__((section("__cmd"))) = { \
73 .nl_msg_flags = (_flags), \
74 .hidden = (_hidden), \
76 .handler = (_handler), \
81 #define __ACMD(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel, _alias)\
82 __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel);\
83 static const struct cmd *_alias = &__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden
84 #define COMMAND(section, name, args, cmd, flags, idby, handler, help) \
85 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, NULL)
86 #define COMMAND_ALIAS(section, name, args, cmd, flags, idby, handler, help, selector, alias)\
87 __ACMD(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, selector, alias)
88 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
89 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL, NULL)
91 #define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help) \
93 __section ## _ ## _name \
94 __attribute__((used)) __attribute__((section("__cmd"))) = { \
98 .nl_msg_flags = (_flags), \
100 .handler = (_handler), \
103 #define SECTION(_name) \
104 struct cmd __section ## _ ## _name \
105 __attribute__((used)) __attribute__((section("__cmd"))) = { \
110 #define DECLARE_SECTION(_name) \
111 extern struct cmd __section ## _ ## _name;
113 extern const char iw_version
[];
117 int handle_cmd(struct nl80211_state
*state
, enum id_input idby
,
118 int argc
, char **argv
);
120 struct print_event_args
{
121 struct timeval ts
; /* internal */
122 bool have_ts
; /* must be set false */
123 bool frame
, time
, reltime
;
126 __u32
listen_events(struct nl80211_state
*state
,
127 const int n_waits
, const __u32
*waits
);
128 int __prepare_listen_events(struct nl80211_state
*state
);
129 __u32
__do_listen_events(struct nl80211_state
*state
,
130 const int n_waits
, const __u32
*waits
,
131 struct print_event_args
*args
);
134 int mac_addr_a2n(unsigned char *mac_addr
, char *arg
);
135 void mac_addr_n2a(char *mac_addr
, unsigned char *arg
);
136 int parse_hex_mask(char *hexmask
, unsigned char **result
, size_t *result_len
,
137 unsigned char **mask
);
138 unsigned char *parse_hex(char *hex
, size_t *outlen
);
140 int parse_keys(struct nl_msg
*msg
, char **argv
, int argc
);
142 void print_ht_mcs(const __u8
*mcs
);
143 void print_ampdu_length(__u8 exponent
);
144 void print_ampdu_spacing(__u8 spacing
);
145 void print_ht_capability(__u16 cap
);
146 void print_vht_info(__u32 capa
, const __u8
*mcs
);
148 char *channel_width_name(enum nl80211_chan_width width
);
149 const char *iftype_name(enum nl80211_iftype iftype
);
150 const char *command_name(enum nl80211_commands cmd
);
151 int ieee80211_channel_to_frequency(int chan
);
152 int ieee80211_frequency_to_channel(int freq
);
154 void print_ssid_escaped(const uint8_t len
, const uint8_t *data
);
156 int nl_get_multicast_id(struct nl_sock
*sock
, const char *family
, const char *group
);
158 char *reg_initiator_to_string(__u8 initiator
);
160 const char *get_reason_str(uint16_t reason
);
161 const char *get_status_str(uint16_t status
);
168 #define BIT(x) (1ULL<<(x))
170 void print_ies(unsigned char *ie
, int ielen
, bool unknown
,
171 enum print_ie_type ptype
);
174 DECLARE_SECTION(set
);
175 DECLARE_SECTION(get
);