]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - interface.c
iw: display 5/10 MHz channel widths
[thirdparty/iw.git] / interface.c
index f8e39b37147042826acb6f07824605725ce1c547..2802235b6cd31baa64aeb775e80c76c4186d80a0 100644 (file)
@@ -1,4 +1,3 @@
-#include <net/if.h>
 #include <errno.h>
 #include <string.h>
 #include <stdbool.h>
@@ -104,6 +103,9 @@ static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type,
            strcmp(tpstr, "ibss") == 0) {
                *type = NL80211_IFTYPE_ADHOC;
                return 0;
+       } else if (strcmp(tpstr, "ocb") == 0) {
+               *type = NL80211_IFTYPE_OCB;
+               return 0;
        } else if (strcmp(tpstr, "monitor") == 0) {
                *type = NL80211_IFTYPE_MONITOR;
                return 0;
@@ -162,7 +164,6 @@ nla_put_failure:
 }
 
 static int handle_interface_add(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -253,7 +254,6 @@ COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [f
        NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL);
 
 static int handle_interface_del(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -295,6 +295,10 @@ char *channel_width_name(enum nl80211_chan_width width)
                return "80+80 MHz";
        case NL80211_CHAN_WIDTH_160:
                return "160 MHz";
+       case NL80211_CHAN_WIDTH_5:
+               return "5 MHz";
+       case NL80211_CHAN_WIDTH_10:
+               return "10 MHz";
        default:
                return "unknown";
        }
@@ -367,23 +371,28 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
                printf("\n");
        }
 
+       if (tb_msg[NL80211_ATTR_WIPHY_TX_POWER_LEVEL]) {
+               uint32_t txp = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_TX_POWER_LEVEL]);
+
+               printf("%s\ttxpower %d.%.2d dBm\n",
+                      indent, txp / 100, txp % 100);
+       }
+
        return NL_SKIP;
 }
 
 static int handle_interface_info(struct nl80211_state *state,
-                                struct nl_cb *cb,
                                 struct nl_msg *msg,
                                 int argc, char **argv,
                                 enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, NULL);
+       register_handler(print_iface_handler, NULL);
        return 0;
 }
 TOPLEVEL(info, NULL, NL80211_CMD_GET_INTERFACE, 0, CIB_NETDEV, handle_interface_info,
         "Show information for this interface.");
 
 static int handle_interface_set(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -414,7 +423,6 @@ COMMAND(set, monitor, "<flag>*",
        VALID_FLAGS);
 
 static int handle_interface_meshid(struct nl80211_state *state,
-                                  struct nl_cb *cb,
                                   struct nl_msg *msg,
                                   int argc, char **argv,
                                   enum id_input id)
@@ -438,20 +446,18 @@ COMMAND(set, meshid, "<meshid>",
 static unsigned int dev_dump_wiphy;
 
 static int handle_dev_dump(struct nl80211_state *state,
-                          struct nl_cb *cb,
                           struct nl_msg *msg,
                           int argc, char **argv,
                           enum id_input id)
 {
        dev_dump_wiphy = -1;
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, &dev_dump_wiphy);
+       register_handler(print_iface_handler, &dev_dump_wiphy);
        return 0;
 }
 TOPLEVEL(dev, NULL, NL80211_CMD_GET_INTERFACE, NLM_F_DUMP, CIB_NONE, handle_dev_dump,
         "List all network interfaces for wireless hardware.");
 
 static int handle_interface_type(struct nl80211_state *state,
-                                struct nl_cb *cb,
                                 struct nl_msg *msg,
                                 int argc, char **argv,
                                 enum id_input id)
@@ -478,7 +484,6 @@ COMMAND(set, type, "<type>",
        IFACE_TYPES);
 
 static int handle_interface_4addr(struct nl80211_state *state,
-                                 struct nl_cb *cb,
                                  struct nl_msg *msg,
                                  int argc, char **argv,
                                  enum id_input id)
@@ -492,7 +497,6 @@ COMMAND(set, 4addr, "<on|off>",
        "Set interface 4addr (WDS) mode.");
 
 static int handle_interface_noack_map(struct nl80211_state *state,
-                                     struct nl_cb *cb,
                                      struct nl_msg *msg,
                                      int argc, char **argv,
                                      enum id_input id)
@@ -520,7 +524,6 @@ COMMAND(set, noack_map, "<map>",
 
 
 static int handle_interface_wds_peer(struct nl80211_state *state,
-                                    struct nl_cb *cb,
                                     struct nl_msg *msg,
                                     int argc, char **argv,
                                     enum id_input id)
@@ -552,7 +555,6 @@ COMMAND(set, peer, "<MAC address>",
        "Set interface WDS peer.");
 
 static int set_mcast_rate(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
@@ -560,10 +562,8 @@ static int set_mcast_rate(struct nl80211_state *state,
        float rate;
        char *end;
 
-       if (argc != 1) {
-               printf("Invalid parameters!\n");
-               return 2;
-       }
+       if (argc != 1)
+               return 1;
 
        rate = strtod(argv[0], &end);
        if (*end != '\0')