From c62ca4e18584b13d92ae242f58f8f73a9ec89cd2 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 10 Jun 2019 15:46:58 -0700 Subject: [PATCH] scan: update vendor specific IE parsing to handle WFA The vendor specific IE was being parsed only to check if the AP supported WPA, which used a Microsoft OUI. Hotspot/OSEN uses neither WPA or RSN (although its nearly identical to RSN) so the we also need to check for this Wifi-Alliance OUI and set bss->osen (new) if found. --- src/scan.c | 28 ++++++++++++++++++++++++---- src/scan.h | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/scan.c b/src/scan.c index 5537c756..87aaca8e 100644 --- a/src/scan.c +++ b/src/scan.c @@ -731,6 +731,20 @@ static bool start_next_scan_request(struct scan_context *sc) return false; } +static bool scan_parse_vendor_specific(struct scan_bss *bss, const void *data, + uint16_t len) +{ + if (!bss->wpa && is_ie_wpa_ie(data, len)) { + bss->wpa = l_memdup(data - 2, len + 2); + return true; + } else if (!bss->osen && is_ie_wfa_ie(data, len, IE_WFA_OI_OSEN)) + bss->osen = l_memdup(data - 2, len + 2); + else + return false; + + return false; +} + static bool scan_parse_bss_information_elements(struct scan_bss *bss, const void *data, uint16_t len) { @@ -778,10 +792,8 @@ static bool scan_parse_bss_information_elements(struct scan_bss *bss, break; case IE_TYPE_VENDOR_SPECIFIC: - /* Interested only in WPA IE from Vendor data */ - if (!bss->wpa && is_ie_wpa_ie(iter.data, iter.len)) - bss->wpa = l_memdup(iter.data - 2, - iter.len + 2); + /* Interested only in WPA/WFA IE from Vendor data */ + scan_parse_vendor_specific(bss, iter.data, iter.len); break; case IE_TYPE_MOBILITY_DOMAIN: if (!bss->mde_present && iter.len == 3) { @@ -1069,6 +1081,14 @@ int scan_bss_get_rsn_info(const struct scan_bss *bss, struct ie_rsn_info *info) res, strerror(-res)); return res; } + } else if (bss->osen) { + int res = ie_parse_osen_from_data(bss->osen, bss->osen[1] + 2, + info); + if (res < 0) { + l_debug("Cannot parse OSEN IE (%d, %s)", + res, strerror(-res)); + return res; + } } else return -ENOENT; diff --git a/src/scan.h b/src/scan.h index 93e8cf74..ef6356e4 100644 --- a/src/scan.h +++ b/src/scan.h @@ -48,6 +48,7 @@ struct scan_bss { uint16_t capability; uint8_t *rsne; uint8_t *wpa; + uint8_t *osen; uint8_t *wsc; /* Concatenated WSC IEs */ ssize_t wsc_size; /* Size of Concatenated WSC IEs */ uint8_t mde[3];