]>
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 #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
;
26 enum command_identify_by
{
44 const enum nl80211_commands cmd
;
47 const enum command_identify_by idby
;
49 * The handler should return a negative error code,
50 * zero on success, 1 if the arguments were wrong
51 * and the usage message should and 2 otherwise.
53 int (*handler
)(struct nl80211_state
*state
,
56 int argc
, char **argv
);
59 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
61 #define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help)\
62 static const struct cmd \
63 __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
64 __attribute__((used)) __attribute__((section("__cmd"))) = { \
65 .section = (_section), \
69 .nl_msg_flags = (_flags), \
70 .hidden = (_hidden), \
72 .handler = (_handler), \
75 #define COMMAND(section, name, args, cmd, flags, idby, handler, help) \
76 __COMMAND(#section, name, #name, args, cmd, flags, 0, idby, handler, help)
77 #define HIDDEN(section, name, args, cmd, flags, idby, handler) \
78 __COMMAND(#section, name, #name, args, cmd, flags, 1, idby, handler, NULL)
79 #define TOPLEVEL(name, args, cmd, flags, idby, handler, help) \
80 __COMMAND(NULL, name, #name, args, cmd, flags, 0, idby, handler, help)
81 extern struct cmd __start___cmd
;
82 extern struct cmd __stop___cmd
;
84 extern const char iw_version
[];
88 int handle_cmd(struct nl80211_state
*state
, enum id_input idby
,
89 int argc
, char **argv
);
91 struct print_event_args
{
95 __u32
listen_events(struct nl80211_state
*state
,
96 const int n_waits
, const __u32
*waits
);
97 __u32
__listen_events(struct nl80211_state
*state
,
98 const int n_waits
, const __u32
*waits
,
99 struct print_event_args
*args
);
102 int mac_addr_a2n(unsigned char *mac_addr
, char *arg
);
103 void mac_addr_n2a(char *mac_addr
, unsigned char *arg
);
105 int parse_keys(struct nl_msg
*msg
, char **argv
, int argc
);
107 const char *iftype_name(enum nl80211_iftype iftype
);
108 int ieee80211_channel_to_frequency(int chan
);
109 int ieee80211_frequency_to_channel(int freq
);
111 void print_ssid_escaped(const uint8_t len
, const uint8_t *data
);
113 int nl_get_multicast_id(struct nl_sock
*sock
, const char *family
, const char *group
);
115 char *reg_initiator_to_string(__u8 initiator
);
117 const char *get_reason_str(uint16_t reason
);
118 const char *get_status_str(uint16_t status
);
120 int set_interface_up(const char *ifname
);
127 #define BIT(x) (1ULL<<(x))
129 void print_ies(unsigned char *ie
, int ielen
, bool unknown
,
130 enum print_ie_type ptype
);