ie: add info struct for OWE transition
James Prestwood
PATCH 1/6 ie: add info struct for OWE transition
These members are currently stored in scan_bss but with the addition of operating class/band info this will become 5 separate members. This is a bit excessive to store in scan_bss separately so instead this structure can hold everything related to the OWE transition IE.
--- src/ie.h | 6 ++++++ 1 file changed, 6 insertions(+)
src/ie.h +6 -0
@@ -488,6 +488,12 @@ struct ie_fils_ip_addr_response_info {uint8_t ipv6_lifetime;/* Zero if not provided */ }; +struct ie_owe_transition_info { +uint8_t bssid[6 ]; +uint8_t ssid[32 ]; +size_t ssid_len; +}; +extern const unsigned char ieee_oui[3 ];extern const unsigned char microsoft_oui[3 ];extern const unsigned char wifi_alliance_oui[3 ];
Signature · 1 line
2.31.1
James Prestwood
PATCH 2/6 scan: use structure for OWE transition parsing
This changes scan_bss from using separate members for each OWE transition element data type (ssid, ssid_len, and bssid) to a structure that holds them all.
This is being done because OWE transition has option operating class and channel bytes which will soon be parsed. This would end up needing 5 separate members in scan_bss which is a bit much for a single IE that needs to be parsed.
This makes checking the presense of the IE more convenient as well since it can be done with a simple NULL pointer check rather than having to l_memeqzero the BSSID.
--- src/ie.c | 10 ++++------ src/ie.h | 4 +--- src/network.c | 9 ++------- src/scan.c | 26 ++++++++++++++++---------- src/scan.h | 5 ++--- src/station.c | 43 ++++++++++++++++++++++--------------------- 6 files changed, 47 insertions(+), 50 deletions(-)
src/ie.c +4 -6
@@ -2500,9 +2500,7 @@ int ie_parse_network_cost(const void *data, size_t len, }int ie_parse_owe_transition (const void *data,size_t len, -uint8_t bssid[static 6 ], -uint8_t ssid[static 32 ], -size_t *ssid_len) +struct ie_owe_transition_info *info) {const uint8_t *ie = data;size_t slen;
@@ -2534,10 +2532,10 @@ int ie_parse_owe_transition(const void *data, size_t len,if (len != slen +13 )return -ENOMSG ; -memcpy (bssid, ie +6 ,6 ); +memcpy (info->bssid, ie +6 ,6 ); -memcpy (ssid, ie +13 , slen); - *ssid_len = slen; +memcpy (info->ssid, ie +13 , slen); + info->ssid_len = slen;return 0 ; }
src/ie.h +1 -3
@@ -639,6 +639,4 @@ int ie_parse_network_cost(const void *data, size_t len, uint16_t *flags, uint16_t *level);int ie_parse_owe_transition (const void *data,size_t len, -uint8_t bssid[static 6 ], -uint8_t ssid[static 32 ], -size_t *ssid_len); +struct ie_owe_transition_info *info);
src/network.c +2 -7
@@ -1110,11 +1110,6 @@ const struct l_queue_entry *network_bss_list_get_entries(return l_queue_get_entries (network->bss_list); } -static bool bss_is_owe (struct scan_bss *bss) -{ -return !l_memeqzero (bss->owe_trans_bssid,6 ) && bss->rsne; -} -struct scan_bss *network_bss_select (struct network *network,bool fallback_to_blacklist) {
@@ -1141,13 +1136,13 @@ struct scan_bss *network_bss_select(struct network *network, candidate = bss;/* OWE Transition BSS */ -if (!l_memeqzero (bss->owe_trans_bssid,6 )) { +if (!bss->owe_trans) {/* Don't want to connect to the Open BSS if possible */ if (!bss->rsne)continue ;/* Candidate is not OWE, set this as new candidate */ -if (!bss_is_owe (candidate)) +if (!(candidate->owe_trans && candidate->rsne)) candidate = bss; }
src/scan.c +16 -10
@@ -686,8 +686,8 @@ static void add_owe_scan_cmd(struct scan_context *sc, struct scan_request *sr, }else params.freqs = freqs; - params.ssid = bss->owe_trans_ssid; - params.ssid_len = bss->owe_trans_ssid_len; + params.ssid = bss->owe_trans->ssid; + params.ssid_len = bss->owe_trans->ssid_len; params.flush = true; cmd =scan_build_cmd (sc, ignore_flush, false, ¶ms);
@@ -736,14 +736,14 @@ uint32_t scan_owe_hidden(uint64_t wdev_id, struct l_queue *list,/* First */ if (!ssid) { - ssid = bss->owe_trans_ssid; - ssid_len = bss->owe_trans_ssid_len; + ssid = bss->owe_trans->ssid; + ssid_len = bss->owe_trans->ssid_len;continue ; } -if (ssid_len == bss->owe_trans_ssid_len && - !memcmp (ssid, bss->owe_trans_ssid, - bss->owe_trans_ssid_len)) +if (ssid_len == bss->owe_trans->ssid_len && + !memcmp (ssid, bss->owe_trans->ssid, + bss->owe_trans->ssid_len))continue ; same_ssid = false;
@@ -1060,9 +1060,14 @@ static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data, }if (is_ie_wfa_ie (data, len,IE_WFA_OI_OWE_TRANSITION )) { -ie_parse_owe_transition (data -2 , len +2 , bss->owe_trans_bssid, - bss->owe_trans_ssid, - &bss->owe_trans_ssid_len); + bss->owe_trans = l_new(struct ie_owe_transition_info, 1); + +if (ie_parse_owe_transition (data -2 , len +2 , + bss->owe_trans) <0 ) { +l_free (bss->owe_trans); + bss->owe_trans =NULL ; + } +return ; }
@@ -1511,6 +1516,7 @@ void scan_bss_free(struct scan_bss *bss)l_free (bss->osen);l_free (bss->rc_ie);l_free (bss->wfd); +l_free (bss->owe_trans);switch (bss->source_frame) {case SCAN_BSS_PROBE_RESP :
src/scan.h +2 -3
@@ -22,6 +22,7 @@struct scan_freq_set ;struct ie_rsn_info ; +struct ie_owe_transition_info ;struct p2p_probe_resp ;struct p2p_probe_req ;struct p2p_beacon ;
@@ -62,6 +63,7 @@ struct scan_bss {struct p2p_probe_req *p2p_probe_req_info;struct p2p_beacon *p2p_beacon_info; }; +struct ie_owe_transition_info *owe_trans;uint8_t mde[3 ];uint8_t ssid[32 ];uint8_t ssid_len;
@@ -76,9 +78,6 @@ struct scan_bss {uint64_t parent_tsf;uint8_t *wfd;/* Concatenated WFD IEs */ ssize_t wfd_size;/* Size of Concatenated WFD IEs */ -uint8_t owe_trans_ssid[32 ]; -size_t owe_trans_ssid_len; -uint8_t owe_trans_bssid[6 ]; bool mde_present : 1; bool cc_present : 1; bool cap_rm_neighbor_report : 1;
src/station.c +22 -21
110 lines not on this page · raw message
Signature · 1 line
2.31.1
James Prestwood
PATCH 3/6 nlmon: update to use ie_owe_transition_info
In reply to James Prestwood--- monitor/nlmon.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
monitor/nlmon.c +5 -6
@@ -1012,17 +1012,16 @@ static void print_ipv4(unsigned int level, const char *label,static void print_ie_wfa_owe_transition (unsigned int level,const char *label,const void *data,uint16_t size) { -uint8_t bssid[6 ]; -uint8_t ssid[32 ]; -size_t ssid_len; +struct ie_owe_transition_info info; -if (ie_parse_owe_transition (data, size, bssid, ssid, &ssid_len) <0 ) { +if (ie_parse_owe_transition (data, size, &info) <0 ) {print_attr (level +1 ,"Error parsing" );return ; } -print_attr (level +1 ,"BSSID: " MAC ,MAC_STR (bssid)); -print_attr (level +1 ,"SSID: %s" ,util_ssid_to_utf8 (ssid_len, ssid)); +print_attr (level +1 ,"BSSID: " MAC ,MAC_STR (info.bssid)); +print_attr (level +1 ,"SSID: %s" ,util_ssid_to_utf8 (info.ssid_len, + info.ssid)); } static void print_ie_vendor(unsigned int level, const char *label,
Signature · 1 line
2.31.1
James Prestwood
PATCH 4/6 ie: parse operating class/channel for ie_owe_transition_info
In reply to James PrestwoodThis operating class/channel is also verified while parsing and parsing will fail if band_oci_frequency fails.
This does put a requirement on anything that uses ie.c to also include band.c. Makefile has been updated.
--- Makefile.am | 16 ++++++++++------ src/ie.c | 31 ++++++++++++++++++++----------- src/ie.h | 2 ++ 3 files changed, 32 insertions(+), 17 deletions(-)
Makefile.am +10 -6
@@ -316,7 +316,8 @@ monitor_iwmon_SOURCES = monitor/main.c linux/nl80211.h \ src/eapolutil.h src/eapolutil.c \ src/nl80211cmd.h src/nl80211cmd.c \ src/p2putil.c src/p2putil.h \ - src/anqputil.h src/anqputil.c + src/anqputil.h src/anqputil.c \ + src/band.h src/band.c monitor_iwmon_LDADD = $(ell_ldadd) if MANUAL_PAGES
@@ -357,7 +358,8 @@ tools_probe_req_SOURCES = tools/probe-req.c src/mpdu.h src/mpdu.c \ src/ie.h src/ie.c \ src/nl80211util.h src/nl80211util.c \ src/util.h src/util.c \ - src/common.h src/common.c + src/common.h src/common.c \ + src/band.h src/band.c tools_probe_req_LDADD = $(ell_ldadd) if HWSIM
@@ -439,7 +441,7 @@ unit_test_kdf_sha256_SOURCES = unit/test-kdf-sha256.c \ src/crypto.h src/crypto.c unit_test_kdf_sha256_LDADD = $(ell_ldadd) -unit_test_ie_SOURCES = unit/test-ie.c src/ie.h src/ie.c +unit_test_ie_SOURCES = unit/test-ie.c src/ie.h src/ie.c src/band.h src/band.c unit_test_ie_LDADD = $(ell_ldadd) unit_test_band_SOURCES = unit/test-band.c src/band.h src/band.c
@@ -451,7 +453,8 @@ unit_test_crypto_LDADD = $(ell_ldadd) unit_test_mpdu_SOURCES = unit/test-mpdu.c \ src/mpdu.h src/mpdu.c \ - src/ie.h src/ie.c + src/ie.h src/ie.c \ + src/band.h src/band.c unit_test_mpdu_LDADD = $(ell_ldadd) unit_test_eapol_SOURCES = unit/test-eapol.c \
@@ -481,7 +484,7 @@ unit_test_util_SOURCES = src/util.h src/util.c \ unit_test_util_LDADD = $(ell_ldadd) unit_test_ssid_security_SOURCES = unit/test-ssid-security.c src/ie.h src/ie.c \ - src/common.h src/common.c + src/common.h src/common.c src/band.h src/band.c unit_test_ssid_security_LDADD = $(ell_ldadd) unit_test_wsc_SOURCES = unit/test-wsc.c src/wscutil.h src/wscutil.c \
@@ -533,7 +536,8 @@ unit_test_p2p_SOURCES = unit/test-p2p.c src/wscutil.h src/wscutil.c \ src/crypto.h src/crypto.c \ src/ie.h src/ie.c \ src/util.h src/util.c \ - src/p2putil.h src/p2putil.c + src/p2putil.h src/p2putil.c \ + src/band.h src/band.c unit_test_p2p_LDADD = $(ell_ldadd) TESTS = $(unit_tests)
src/ie.c +20 -11
@@ -33,6 +33,7 @@#include "src/util.h" #include "src/crypto.h" #include "src/ie.h" +#include "src/band.h" const unsigned char ieee_oui[3 ] = {0x00 ,0x0f ,0xac };const unsigned char microsoft_oui[3 ] = {0x00 ,0x50 ,0xf2 };
@@ -2503,6 +2504,10 @@ int ie_parse_owe_transition(const void *data, size_t len, struct ie_owe_transition_info *info) {const uint8_t *ie = data; +const uint8_t *bssid; +const uint8_t *ssid; +uint8_t oper_class =0 ; +uint8_t channel =0 ;size_t slen;if (len <14 || ie[0 ] !=IE_TYPE_VENDOR_SPECIFIC )
@@ -2520,22 +2525,26 @@ int ie_parse_owe_transition(const void *data, size_t len,* * "Band Info and Channel Info are optional fields. If configured, * both fields shall be included in an OWE Transition Mode element" -* -* TODO: Support Band/Channel bytes: -* For the time being the OWE transition AP is assumed to be on the same -* channel as the open AP. This means there should be no band/channel -* bytes at the end of the IE. Currently hostapd has no support for this -* so it can be skipped. In addition 802.11 Appendix E-1 needs to be -* encoded as a table to map Country/operating class to channels to make -* any sense of it. */ -if (len != slen +13 ) +if (len != slen +13 && len != slen +15 )return -ENOMSG ; -memcpy (info->bssid, ie +6 ,6 ); + bssid = ie +6 ; + ssid = ie +13 ; + +if (len == slen +15 ) { + oper_class =l_get_u8 (ie +13 + slen); + channel =l_get_u8 (ie +14 + slen); + +if (oci_to_frequency (oper_class, channel) <0 ) +return -ENOMSG ; + } -memcpy (info->ssid, ie +13 , slen); +memcpy (info->bssid, bssid,6 ); +memcpy (info->ssid, ssid, slen); info->ssid_len = slen; + info->oper_class = oper_class; + info->channel = channel;return 0 ; }
src/ie.h +2 -0
@@ -492,6 +492,8 @@ struct ie_owe_transition_info {uint8_t bssid[6 ];uint8_t ssid[32 ];size_t ssid_len; +uint8_t oper_class; +uint8_t channel; };extern const unsigned char ieee_oui[3 ];
Signature · 1 line
2.31.1
Denis Kenzior
Re: [PATCH 4/6] ie: parse operating class/channel for ie_owe_transition_info
Hi James,
Quoted 11 lines · James Prestwood
This operating class/channel is also verified while parsing and parsing will fail if
band_oci_frequencyfails.This does put a requirement on anything that uses
ie.cto also includeband.c.Makefilehas been updated.--- Makefile.am | 16 ++++++++++------ src/ie.c | 31 ++++++++++++++++++++----------- src/ie.h | 2 ++ 3 files changed, 32 insertions(+), 17 deletions(-)
Can we avoid invoking band_* functions in ie.c? I'm not sure I want to make them dependent on each other since band carries some data structures that closely mirror nl80211.
<snip>
src/ie.c int ie_parse_owe_transition(const void *data, size_t len, · line 2541
Quoted 8 lines
src/ie.c +8
-0+ +if (len == slen +15 ) { + oper_class =l_get_u8 (ie +13 + slen); + channel =l_get_u8 (ie +14 + slen); + +if (oci_to_frequency (oper_class, channel) <0 ) +return -ENOMSG ; + }
Maybe make station or scan itself validate this info?
Regards,
-Denis
James Prestwood
Re: [PATCH 4/6] ie: parse operating class/channel for ie_owe_transition_info
Quoted 23 lines · Denis Kenzior
Hi James,
Quoted 11 lines · James Prestwood
This operating class/channel is also verified while parsing and parsing will fail if
band_oci_frequencyfails.This does put a requirement on anything that uses
ie.cto also includeband.c.Makefilehas been updated.
---
Makefile.am | 16 ++++++++++------
src/ie.c | 31 ++++++++++++++++++++----------- src/ie.h | 2 ++3 files changed, 32 insertions(+), 17 deletions(-)Can we avoid invoking band_* functions in ie.c? I'm not sure I want to make
them dependent on each other since band carries some data structures that
closely mirror nl80211.<snip>
Quoted 10 lines
src/ie.c int ie_parse_owe_transition(const void *data, size_t len, · line 2541
Quoted 8 lines
src/ie.c +8
-0+ + if (len == slen + 15) { + oper_class = l_get_u8(ie + 13 + slen); + channel = l_get_u8(ie + 14 + slen); + + if (oci_to_frequency(oper_class, channel) < 0) + return -ENOMSG; + }Maybe make station or scan itself validate this info?
Ok we can do it in scan when parsing the IE. I wanted to avoid doing it when scanning (scan_owe_hidden) because it makes the failure logic annoying, but doing it when parsing the BSS's is fine too.
Quoted 3 lines
Regards,
-Denis
James Prestwood
PATCH 5/6 scan: use oper_class/channel for OWE hidden scans
In reply to James PrestwoodIf these are included in the OWE transition IE use them to scan for the OWE hidden network.
--- src/scan.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
src/scan.c +21 -2
@@ -50,6 +50,7 @@#include "src/p2putil.h" #include "src/mpdu.h" #include "src/scan.h" +#include "src/band.h" /* User configurable options */ static double RANK_5G_FACTOR ;
@@ -670,6 +671,22 @@ uint32_t scan_active_full(uint64_t wdev_id, trigger, notify, userdata, destroy); } +static void scan_add_owe_freq (struct scan_freq_set *freqs, +const struct scan_bss *bss) +{ +int freq; + +if (bss->owe_trans->oper_class) + freq =oci_to_frequency (bss->owe_trans->oper_class, + bss->owe_trans->channel); +else + freq = bss->frequency; + +L_WARN_ON (freq <0 ); + +scan_freq_set_add (freqs, freq); +} + static void add_owe_scan_cmd(struct scan_context *sc, struct scan_request *sr, bool ignore_flush, struct scan_freq_set *freqs,
@@ -681,7 +698,9 @@ static void add_owe_scan_cmd(struct scan_context *sc, struct scan_request *sr,if (!freqs) { tmp =scan_freq_set_new (); -scan_freq_set_add (tmp, bss->frequency); + +scan_add_owe_freq (tmp, bss); + params.freqs = tmp; }else params.freqs = freqs;
@@ -732,7 +751,7 @@ uint32_t scan_owe_hidden(uint64_t wdev_id, struct l_queue *list,for (entry =l_queue_get_entries (list); entry; entry = entry->next) { bss = entry->data; -scan_freq_set_add (freqs, bss->frequency); +scan_add_owe_freq (freqs, bss);/* First */ if (!ssid) {
Signature · 1 line
2.31.1
James Prestwood
PATCH 6/6 auto-t: add oper class/band tests for OWE transition
In reply to James Prestwood--- .../testOWE-transition/connection_test.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)
autotests/testOWE-transition/connection_test.py +26 -0
@@ -196,6 +196,30 @@ class Test(unittest.TestCase): with self.assertRaises(iwd.NotFoundEx): self.validate(self.wd, self.hapd_owe, connect_hidden=True) + def test_owe_transition_band_info(self): + self.hapd_open.set_value('vendor_elements', 'dd17506f9a1c02000000f1000a6f77652d68696464656e5103') + self.hapd_open.reload() + self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e') + self.hapd_owe.set_value('channel', '3') + self.hapd_owe.reload() + + self.hapd_owe2.disable() + self.hapd_open2.disable() + + self.validate(self.wd, self.hapd_owe) + + def test_owe_transition_wrong_band_info(self): + self.hapd_open.set_value('vendor_elements', 'dd17506f9a1c02000000f1000a6f77652d68696464656e5102') + self.hapd_open.reload() + self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e') + self.hapd_owe.set_value('channel', '3') + self.hapd_owe.reload() + + self.hapd_owe2.disable() + self.hapd_open2.disable() + + self.validate(self.wd, self.hapd_open) + def setUp(self): self.wd = IWD(True) self.hapd_owe = HostapdCLI(config='ssidOWE.conf')
@@ -206,6 +230,8 @@ class Test(unittest.TestCase): def tearDown(self): IWD.clear_storage() + self.hapd_owe.set_value('channel', '1') + self.wd = None self.hapd_open = None self.hapd_owe = None
Signature · 1 line
2.31.1
Denis Kenzior
Hi James,
Quoted 9 lines · James Prestwood
These members are currently stored in
scan_bssbut with the addition of operating class/band info this will become 5 separate members. This is a bit excessive to store inscan_bssseparately so instead this structure can hold everything related to the OWE transition IE.--- src/ie.h | 6 ++++++ 1 file changed, 6 insertions(+)
Patches 1-3 applied, thanks.
Regards,
-Denis