]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - station.c
add trailing \n to fprintfs missing it
[thirdparty/iw.git] / station.c
index 33a9cadebd1eddb819967da32c6f1f86e2e35fb1..8cf038dfcf6ab9ccb79dfae28f29b9153444d12b 100644 (file)
--- a/station.c
+++ b/station.c
@@ -11,6 +11,8 @@
 #include "nl80211.h"
 #include "iw.h"
 
+SECTION(station);
+
 enum plink_state {
        LISTEN,
        OPN_SNT,
@@ -65,13 +67,13 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
         */
 
        if (!tb[NL80211_ATTR_STA_INFO]) {
-               fprintf(stderr, "sta stats missing!");
+               fprintf(stderr, "sta stats missing!\n");
                return NL_SKIP;
        }
        if (nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
                             tb[NL80211_ATTR_STA_INFO],
                             stats_policy)) {
-               fprintf(stderr, "failed to parse nested attributes!");
+               fprintf(stderr, "failed to parse nested attributes!\n");
                return NL_SKIP;
        }
 
@@ -101,7 +103,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
        if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
                if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
                                     sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
-                       fprintf(stderr, "failed to parse nested rate attributes!");
+                       fprintf(stderr, "failed to parse nested rate attributes!\n");
                } else {
                        printf("\n\ttx bitrate:\t");
                        if (rinfo[NL80211_RATE_INFO_BITRATE]) {
@@ -125,7 +127,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
                printf("\n\tmesh plid:\t%d",
                        nla_get_u16(sinfo[NL80211_STA_INFO_PLID]));
        if (sinfo[NL80211_STA_INFO_PLINK_STATE]) {
-               switch (nla_get_u16(sinfo[NL80211_STA_INFO_PLINK_STATE])) {
+               switch (nla_get_u8(sinfo[NL80211_STA_INFO_PLINK_STATE])) {
                case LISTEN:
                        strcpy(state_name, "LISTEN");
                        break;
@@ -194,7 +196,7 @@ COMMAND(station, del, "<MAC address>",
        NL80211_CMD_DEL_STATION, 0, CIB_NETDEV, handle_station_get,
        "Remove the given station entry (use with caution!)");
 
-static int handle_station_set(struct nl80211_state *state,
+static int handle_station_set_plink(struct nl80211_state *state,
                              struct nl_cb *cb,
                              struct nl_msg *msg,
                              int argc, char **argv)
@@ -239,9 +241,56 @@ static int handle_station_set(struct nl80211_state *state,
        return -ENOBUFS;
 }
 COMMAND(station, set, "<MAC address> plink_action <open|block>",
-       NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set,
+       NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
        "Set mesh peer link action for this station (peer).");
 
+static int handle_station_set_vlan(struct nl80211_state *state,
+                             struct nl_cb *cb,
+                             struct nl_msg *msg,
+                             int argc, char **argv)
+{
+       unsigned char mac_addr[ETH_ALEN];
+       unsigned long sta_vlan = 0;
+       char *err = NULL;
+
+       if (argc < 3)
+               return 1;
+
+       if (mac_addr_a2n(mac_addr, argv[0])) {
+               fprintf(stderr, "invalid mac address\n");
+               return 2;
+       }
+       argc--;
+       argv++;
+
+       if (strcmp("vlan", argv[0]) != 0)
+               return 1;
+       argc--;
+       argv++;
+
+       sta_vlan = strtoul(argv[0], &err, 0);
+       if (err && *err) {
+               fprintf(stderr, "invalid vlan id\n");
+               return 2;
+       }
+       argc--;
+       argv++;
+
+       if (argc)
+               return 1;
+
+       NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
+       NLA_PUT_U32(msg, NL80211_ATTR_STA_VLAN, sta_vlan);
+
+       return 0;
+ nla_put_failure:
+       return -ENOBUFS;
+}
+COMMAND(station, set, "<MAC address> vlan <ifindex>",
+       NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_vlan,
+       "Set an AP VLAN for this station.");
+
+
 static int handle_station_dump(struct nl80211_state *state,
                               struct nl_cb *cb,
                               struct nl_msg *msg,