]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - iw.h
Add cac command to allow clearing channels
[thirdparty/iw.git] / iw.h
diff --git a/iw.h b/iw.h
index a7545610db1f8ea56f7d55d1b7c0d9a01642f8d4..7d563919326aa19192921e2fb6cc98f2513d2b79 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -6,25 +6,29 @@
 #include <netlink/genl/genl.h>
 #include <netlink/genl/family.h>
 #include <netlink/genl/ctrl.h>
+#include <endian.h>
 
 #include "nl80211.h"
+#include "ieee80211.h"
 
 #define ETH_ALEN 6
+#define VHT_MUMIMO_GROUP_LEN 24
 
-#ifndef CONFIG_LIBNL20
+/* libnl 1.x compatibility code */
+#if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30)
 #  define nl_sock nl_handle
 #endif
 
 struct nl80211_state {
        struct nl_sock *nl_sock;
-       struct nl_cache *nl_cache;
-       struct genl_family *nl80211;
+       int nl80211_id;
 };
 
 enum command_identify_by {
        CIB_NONE,
        CIB_PHY,
        CIB_NETDEV,
+       CIB_WDEV,
 };
 
 enum id_input {
@@ -32,8 +36,12 @@ enum id_input {
        II_NETDEV,
        II_PHY_NAME,
        II_PHY_IDX,
+       II_WDEV,
 };
 
+#define HANDLER_RET_USAGE 1
+#define HANDLER_RET_DONE 3
+
 struct cmd {
        const char *name;
        const char *args;
@@ -44,20 +52,37 @@ struct cmd {
        const enum command_identify_by idby;
        /*
         * The handler should return a negative error code,
-        * zero on success, 1 if the arguments were wrong
-        * and the usage message should and 2 otherwise.
+        * zero on success, 1 if the arguments were wrong.
+        * Return 2 iff you provide the error message yourself.
         */
        int (*handler)(struct nl80211_state *state,
-                      struct nl_cb *cb,
                       struct nl_msg *msg,
-                      int argc, char **argv);
+                      int argc, char **argv,
+                      enum id_input id);
+       const struct cmd *(*selector)(int argc, char **argv);
        const struct cmd *parent;
 };
 
+struct chanmode {
+       const char *name;
+       unsigned int width;
+       int freq1_diff;
+       int chantype; /* for older kernel */
+};
+
+struct chandef {
+       enum nl80211_chan_width width;
+
+       unsigned int control_freq;
+       unsigned int center_freq1;
+       unsigned int center_freq2;
+};
+
 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
+#define DIV_ROUND_UP(x, y) (((x) + (y - 1)) / (y))
 
-#define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help)\
-       static const struct cmd                                         \
+#define __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel)\
+       static struct cmd                                               \
        __cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
        __attribute__((used)) __attribute__((section("__cmd"))) = {     \
                .name = (_name),                                        \
@@ -69,14 +94,20 @@ struct cmd {
                .handler = (_handler),                                  \
                .help = (_help),                                        \
                .parent = _section,                                     \
-        }
+               .selector = (_sel),                                     \
+       }
+#define __ACMD(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel, _alias)\
+       __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel);\
+       static const struct cmd *_alias = &__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden
 #define COMMAND(section, name, args, cmd, flags, idby, handler, help)  \
-       __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help)
+       __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, NULL)
+#define COMMAND_ALIAS(section, name, args, cmd, flags, idby, handler, help, selector, alias)\
+       __ACMD(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help, selector, alias)
 #define HIDDEN(section, name, args, cmd, flags, idby, handler)         \
-       __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL)
+       __COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL, NULL)
 
 #define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help) \
-       const struct cmd                                                \
+       struct cmd                                                      \
        __section ## _ ## _name                                         \
        __attribute__((used)) __attribute__((section("__cmd"))) = {     \
                .name = (#_name),                                       \
@@ -88,14 +119,14 @@ struct cmd {
                .help = (_help),                                        \
         }
 #define SECTION(_name)                                                 \
-       const struct cmd __section ## _ ## _name                        \
+       struct cmd __section ## _ ## _name                              \
        __attribute__((used)) __attribute__((section("__cmd"))) = {     \
                .name = (#_name),                                       \
                .hidden = 1,                                            \
        }
 
 #define DECLARE_SECTION(_name)                                         \
-       extern const struct cmd __section ## _ ## _name;
+       extern struct cmd __section ## _ ## _name;
 
 extern const char iw_version[];
 
@@ -105,29 +136,41 @@ int handle_cmd(struct nl80211_state *state, enum id_input idby,
               int argc, char **argv);
 
 struct print_event_args {
-       bool frame, time;
+       struct timeval ts; /* internal */
+       bool have_ts; /* must be set false */
+       bool frame, time, reltime;
 };
 
 __u32 listen_events(struct nl80211_state *state,
                    const int n_waits, const __u32 *waits);
-__u32 __listen_events(struct nl80211_state *state,
-                     const int n_waits, const __u32 *waits,
-                     struct print_event_args *args);
+int __prepare_listen_events(struct nl80211_state *state);
+__u32 __do_listen_events(struct nl80211_state *state,
+                        const int n_waits, const __u32 *waits,
+                        struct print_event_args *args);
 
+int valid_handler(struct nl_msg *msg, void *arg);
+void register_handler(int (*handler)(struct nl_msg *, void *), void *data);
 
 int mac_addr_a2n(unsigned char *mac_addr, char *arg);
 void mac_addr_n2a(char *mac_addr, unsigned char *arg);
+int parse_hex_mask(char *hexmask, unsigned char **result, size_t *result_len,
+                  unsigned char **mask);
+unsigned char *parse_hex(char *hex, size_t *outlen);
 
 int parse_keys(struct nl_msg *msg, char **argv, int argc);
+int parse_freqchan(struct chandef *chandef, bool chan, int argc, char **argv, int *parsed);
+int put_chandef(struct nl_msg *msg, struct chandef *chandef);
 
-void print_mcs_set(const uint8_t *data);
+void print_ht_mcs(const __u8 *mcs);
 void print_ampdu_length(__u8 exponent);
 void print_ampdu_spacing(__u8 spacing);
 void print_ht_capability(__u16 cap);
+void print_vht_info(__u32 capa, const __u8 *mcs);
 
+char *channel_width_name(enum nl80211_chan_width width);
 const char *iftype_name(enum nl80211_iftype iftype);
 const char *command_name(enum nl80211_commands cmd);
-int ieee80211_channel_to_frequency(int chan);
+int ieee80211_channel_to_frequency(int chan, enum nl80211_band band);
 int ieee80211_frequency_to_channel(int freq);
 
 void print_ssid_escaped(const uint8_t len, const uint8_t *data);
@@ -149,6 +192,15 @@ enum print_ie_type {
 void print_ies(unsigned char *ie, int ielen, bool unknown,
               enum print_ie_type ptype);
 
+void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen);
+void iw_hexdump(const char *prefix, const __u8 *data, size_t len);
+
+int get_cf1(const struct chanmode *chanmode, unsigned long freq);
+
+#define SCHED_SCAN_OPTIONS "[interval <in_msecs> | scan_plans [<interval_secs:iterations>*] <interval_secs>] " \
+       "[delay <in_secs>] [freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] "  \
+       "[randomise[=<addr>/<mask>]]"
+int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv);
 
 DECLARE_SECTION(set);
 DECLARE_SECTION(get);