]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - iw.h
print wdev id in event info
[thirdparty/iw.git] / iw.h
diff --git a/iw.h b/iw.h
index 22c05f44a5b1cb69c638c3b04315d05719773661..54ecbc3d584a3d6732c8435f29e5cfd10033c3c6 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -1,34 +1,33 @@
 #ifndef __IW_H
 #define __IW_H
 
-#ifndef _ISOC99_SOURCE
-#define _ISOC99_SOURCE
-#endif
-
 #include <stdbool.h>
 #include <netlink/netlink.h>
 #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
 
-#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 {
@@ -36,6 +35,7 @@ enum id_input {
        II_NETDEV,
        II_PHY_NAME,
        II_PHY_IDX,
+       II_WDEV,
 };
 
 struct cmd {
@@ -54,13 +54,16 @@ struct cmd {
        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;
 };
 
 #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)\
+#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"))) = {     \
@@ -73,11 +76,17 @@ 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) \
        struct cmd                                                      \
@@ -109,7 +118,9 @@ 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,
@@ -122,6 +133,8 @@ __u32 __do_listen_events(struct nl80211_state *state,
 
 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);