]>
git.ipfire.org Git - thirdparty/iw.git/blob - iw.h
5eb9083b823d1ba5fbd267940421c4100bc0bbf7
5 #include <netlink/netlink.h>
6 #include <netlink/genl/genl.h>
7 #include <netlink/genl/family.h>
8 #include <netlink/genl/ctrl.h>
14 #ifndef CONFIG_LIBNL20
15 # define nl_sock nl_handle
18 struct nl80211_state
{
19 struct nl_sock
*nl_sock
;
20 struct nl_cache
*nl_cache
;
21 struct genl_family
*nl80211
;
24 enum command_identify_by
{
41 const enum nl80211_commands cmd
;
44 const enum command_identify_by idby
;
46 * The handler should return a negative error code,
47 * zero on success, 1 if the arguments were wrong
48 * and the usage message should and 2 otherwise.
50 int (*handler
)(struct nl80211_state
*state
,
53 int argc
, char **argv
);
54 const struct cmd
*parent
;
57 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
59 #define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help)\
61 __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
62 __attribute__((used)) __attribute__((section("__cmd"))) = { \
66 .nl_msg_flags = (_flags), \
67 .hidden = (_hidden), \
69 .handler = (_handler), \
73 #define COMMAND(section, name, args, cmd, flags, idby, handler, help) \
74 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help)
75 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
76 __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL)
78 #define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help) \
80 __section ## _ ## _name \
81 __attribute__((used)) __attribute__((section("__cmd"))) = { \
85 .nl_msg_flags = (_flags), \
87 .handler = (_handler), \
90 #define SECTION(_name) \
91 struct cmd __section ## _ ## _name \
92 __attribute__((used)) __attribute__((section("__cmd"))) = { \
97 #define DECLARE_SECTION(_name) \
98 extern struct cmd __section ## _ ## _name;
100 extern const char iw_version
[];
104 int handle_cmd(struct nl80211_state
*state
, enum id_input idby
,
105 int argc
, char **argv
);
107 struct print_event_args
{
108 struct timeval ts
; /* internal */
109 bool have_ts
; /* must be set false */
110 bool frame
, time
, reltime
;
113 __u32
listen_events(struct nl80211_state
*state
,
114 const int n_waits
, const __u32
*waits
);
115 int __prepare_listen_events(struct nl80211_state
*state
);
116 __u32
__do_listen_events(struct nl80211_state
*state
,
117 const int n_waits
, const __u32
*waits
,
118 struct print_event_args
*args
);
121 int mac_addr_a2n(unsigned char *mac_addr
, char *arg
);
122 void mac_addr_n2a(char *mac_addr
, unsigned char *arg
);
123 unsigned char *parse_hex(char *hex
, size_t *outlen
);
125 int parse_keys(struct nl_msg
*msg
, char **argv
, int argc
);
127 void print_ht_mcs(const __u8
*mcs
);
128 void print_ampdu_length(__u8 exponent
);
129 void print_ampdu_spacing(__u8 spacing
);
130 void print_ht_capability(__u16 cap
);
132 const char *iftype_name(enum nl80211_iftype iftype
);
133 const char *command_name(enum nl80211_commands cmd
);
134 int ieee80211_channel_to_frequency(int chan
);
135 int ieee80211_frequency_to_channel(int freq
);
137 void print_ssid_escaped(const uint8_t len
, const uint8_t *data
);
139 int nl_get_multicast_id(struct nl_sock
*sock
, const char *family
, const char *group
);
141 char *reg_initiator_to_string(__u8 initiator
);
143 const char *get_reason_str(uint16_t reason
);
144 const char *get_status_str(uint16_t status
);
151 #define BIT(x) (1ULL<<(x))
153 void print_ies(unsigned char *ie
, int ielen
, bool unknown
,
154 enum print_ie_type ptype
);
157 DECLARE_SECTION(set
);
158 DECLARE_SECTION(get
);