]>
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>
14 /* libnl 1.x compatibility code */
15 #if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
16 # define nl_sock nl_handle
19 struct nl80211_state
{
20 struct nl_sock
*nl_sock
;
21 struct nl_cache
*nl_cache
;
22 struct genl_family
*nl80211
;
25 enum command_identify_by
{
42 const enum nl80211_commands cmd
;
45 const enum command_identify_by idby
;
47 * The handler should return a negative error code,
48 * zero on success, 1 if the arguments were wrong
49 * and the usage message should and 2 otherwise.
51 int (*handler
)(struct nl80211_state
*state
,
54 int argc
, char **argv
);
55 const struct cmd
*(*selector
)(int argc
, char **argv
);
56 const struct cmd
*parent
;
59 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
60 #define DIV_ROUND_UP(x, y) (((x) + (y - 1)) / (y))
62 #define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel)\
64 __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
65 __attribute__((used)) __attribute__((section("__cmd"))) = { \
69 .nl_msg_flags = (_flags), \
70 .hidden = (_hidden), \
72 .handler = (_handler), \
77 #define __ACMD(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel, _alias)\
78 __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel);\
79 static const struct cmd *_alias = &__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden
80 #define COMMAND(section, name, args, cmd, flags, idby, handler, help) \
81 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, NULL)
82 #define COMMAND_ALIAS(section, name, args, cmd, flags, idby, handler, help, selector, alias)\
83 __ACMD(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, selector, alias)
84 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
85 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL, NULL)
87 #define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help) \
89 __section ## _ ## _name \
90 __attribute__((used)) __attribute__((section("__cmd"))) = { \
94 .nl_msg_flags = (_flags), \
96 .handler = (_handler), \
99 #define SECTION(_name) \
100 struct cmd __section ## _ ## _name \
101 __attribute__((used)) __attribute__((section("__cmd"))) = { \
106 #define DECLARE_SECTION(_name) \
107 extern struct cmd __section ## _ ## _name;
109 extern const char iw_version
[];
113 int handle_cmd(struct nl80211_state
*state
, enum id_input idby
,
114 int argc
, char **argv
);
116 struct print_event_args
{
117 struct timeval ts
; /* internal */
118 bool have_ts
; /* must be set false */
119 bool frame
, time
, reltime
;
122 __u32
listen_events(struct nl80211_state
*state
,
123 const int n_waits
, const __u32
*waits
);
124 int __prepare_listen_events(struct nl80211_state
*state
);
125 __u32
__do_listen_events(struct nl80211_state
*state
,
126 const int n_waits
, const __u32
*waits
,
127 struct print_event_args
*args
);
130 int mac_addr_a2n(unsigned char *mac_addr
, char *arg
);
131 void mac_addr_n2a(char *mac_addr
, unsigned char *arg
);
132 int parse_hex_mask(char *hexmask
, unsigned char **result
, size_t *result_len
,
133 unsigned char **mask
);
134 unsigned char *parse_hex(char *hex
, size_t *outlen
);
136 int parse_keys(struct nl_msg
*msg
, char **argv
, int argc
);
138 void print_ht_mcs(const __u8
*mcs
);
139 void print_ampdu_length(__u8 exponent
);
140 void print_ampdu_spacing(__u8 spacing
);
141 void print_ht_capability(__u16 cap
);
143 const char *iftype_name(enum nl80211_iftype iftype
);
144 const char *command_name(enum nl80211_commands cmd
);
145 int ieee80211_channel_to_frequency(int chan
);
146 int ieee80211_frequency_to_channel(int freq
);
148 void print_ssid_escaped(const uint8_t len
, const uint8_t *data
);
150 int nl_get_multicast_id(struct nl_sock
*sock
, const char *family
, const char *group
);
152 char *reg_initiator_to_string(__u8 initiator
);
154 const char *get_reason_str(uint16_t reason
);
155 const char *get_status_str(uint16_t status
);
162 #define BIT(x) (1ULL<<(x))
164 void print_ies(unsigned char *ie
, int ielen
, bool unknown
,
165 enum print_ie_type ptype
);
168 DECLARE_SECTION(set
);
169 DECLARE_SECTION(get
);