2018-10-10 20:48:23

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 1/2] iw: Make input to mac_addr_n2a() const

The parameter is not modified, so we can make it constant. This makes it
possible to provide other const parameters to this function.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
iw.h | 2 +-
util.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/iw.h b/iw.h
index 47aa27d..bdd39ee 100644
--- a/iw.h
+++ b/iw.h
@@ -175,7 +175,7 @@ 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);
+void mac_addr_n2a(char *mac_addr, const 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);
diff --git a/util.c b/util.c
index 5b286b7..796549e 100644
--- a/util.c
+++ b/util.c
@@ -5,7 +5,7 @@
#include "iw.h"
#include "nl80211.h"

-void mac_addr_n2a(char *mac_addr, unsigned char *arg)
+void mac_addr_n2a(char *mac_addr, const unsigned char *arg)
{
int i, l;

--
2.11.0



2018-10-10 20:48:23

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 2/2] iw: scan: parse OWE Transition Mode element

This adds code to parse the Opportunistic Wireless Encryption Transition
Mode element.

Without this patch the output looks like this:
WFA 0x1c, data: 00 37 b7 36 dc 0c 08 4f 70 65 6e 57 72 74 34
With this patch it looks like this:
OWE Transition Mode:
BSSID: 00:37:b7:36:dc:0c
SSID: OpenWrt4

Signed-off-by: Hauke Mehrtens <[email protected]>
---
scan.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/scan.c b/scan.c
index 7695216..a798c70 100644
--- a/scan.c
+++ b/scan.c
@@ -1950,10 +1950,39 @@ static inline void print_hs20_ind(const uint8_t type, uint8_t len,
printf("\t\tUnexpected length: %i\n", len);
}

+static void print_wifi_owe_tarns(const uint8_t type, uint8_t len,
+ const uint8_t *data,
+ const struct print_ies_data *ie_buffer)
+{
+ char mac_addr[20];
+ int ssid_len;
+
+ printf("\n");
+ if (len < 7)
+ return;
+
+ mac_addr_n2a(mac_addr, data);
+ printf("\t\tBSSID: %s\n", mac_addr);
+
+ ssid_len = data[6];
+ if (ssid_len > len - 7)
+ return;
+ printf("\t\tSSID: ");
+ print_ssid_escaped(ssid_len, data + 7);
+ printf("\n");
+
+ /* optional elements */
+ if (len >= ssid_len + 9) {
+ printf("\t\tBand Info: %u\n", data[ssid_len + 7]);
+ printf("\t\tChannel Info: %u\n", data[ssid_len + 8]);
+ }
+}
+
static const struct ie_print wfa_printers[] = {
[9] = { "P2P", print_p2p, 2, 255, BIT(PRINT_SCAN), },
[16] = { "HotSpot 2.0 Indication", print_hs20_ind, 1, 255, BIT(PRINT_SCAN), },
[18] = { "HotSpot 2.0 OSEN", print_wifi_osen, 1, 255, BIT(PRINT_SCAN), },
+ [28] = { "OWE Transition Mode", print_wifi_owe_tarns, 7, 255, BIT(PRINT_SCAN), },
};

static void print_vendor(unsigned char len, unsigned char *data,
--
2.11.0