]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - scan.c
iw: document handler return value 1 as HANDLER_RET_USAGE
[thirdparty/iw.git] / scan.c
diff --git a/scan.c b/scan.c
index e98f5d72e6db33000ff86253a4e49d6f94490eef..bc1f936d9f0a6c5e48d03eb4e68b647a549cfc11 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -1,7 +1,6 @@
 #include <net/if.h>
 #include <errno.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdbool.h>
 
 #include <netlink/genl/genl.h>
@@ -446,8 +445,11 @@ static int handle_scan(struct nl80211_state *state,
 
        if (ies || meshid) {
                tmpies = (unsigned char *) malloc(ies_len + meshid_len);
-               if (!tmpies)
+               if (!tmpies) {
+                       free(ies);
+                       free(meshid);
                        goto nla_put_failure;
+               }
                if (ies) {
                        memcpy(tmpies, ies, ies_len);
                        free(ies);
@@ -456,7 +458,10 @@ static int handle_scan(struct nl80211_state *state,
                        memcpy(&tmpies[ies_len], meshid, meshid_len);
                        free(meshid);
                }
-               NLA_PUT(msg, NL80211_ATTR_IE, ies_len + meshid_len, tmpies);
+               if (nla_put(msg, NL80211_ATTR_IE, ies_len + meshid_len, tmpies) < 0) {
+                       free(tmpies);
+                       goto nla_put_failure;
+               }
                free(tmpies);
        }
 
@@ -1160,6 +1165,8 @@ static void print_capabilities(const uint8_t type, uint8_t len, const uint8_t *d
                        CAPA(46, "WNM-Notification");
                        CAPA(47, "Reserved");
                        CAPA(48, "UTF-8 SSID");
+                       CAPA(70, "FTM Responder");
+                       CAPA(71, "FTM Initiator");
                        default:
                                printf(" %d", bit);
                                break;
@@ -1912,6 +1919,12 @@ static int print_bss_handler(struct nl_msg *msg, void *arg)
        }
        printf("\n");
 
+       if (bss[NL80211_BSS_LAST_SEEN_BOOTTIME]) {
+               unsigned long long bt;
+               bt = (unsigned long long)nla_get_u64(bss[NL80211_BSS_LAST_SEEN_BOOTTIME]);
+               printf("\tlast seen: %llu.%.3llus [boottime]\n", bt/1000000000, (bt%1000000000)/1000000);
+       }
+
        if (bss[NL80211_BSS_TSF]) {
                unsigned long long tsf;
                tsf = (unsigned long long)nla_get_u64(bss[NL80211_BSS_TSF]);
@@ -2009,6 +2022,7 @@ static int handle_scan_combined(struct nl80211_state *state,
                NL80211_CMD_SCAN_ABORTED,
        };
        int trig_argc, dump_argc, err;
+       int i;
 
        if (argc >= 3 && !strcmp(argv[2], "-u")) {
                dump_argc = 4;
@@ -2026,7 +2040,7 @@ static int handle_scan_combined(struct nl80211_state *state,
        trig_argv[0] = argv[0];
        trig_argv[1] = "scan";
        trig_argv[2] = "trigger";
-       int i;
+
        for (i = 0; i < argc - 2 - (dump_argc - 3); i++)
                trig_argv[i + 3] = argv[i + 2 + (dump_argc - 3)];
        err = handle_cmd(state, id, trig_argc, trig_argv);