Skip to contentSkip to conversation

ie: parse operating class/channel for ie_owe_transition_info

PATCH In review James Prestwood 2 participants 6 messages Sep 22, 2021

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH v2 1/4 ie: parse operating class/channel for ie_owe_transition_info

This 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.

---
 src/ie.c | 28 +++++++++++++++++-----------
 src/ie.h |  2 ++
 2 files changed, 19 insertions(+), 11 deletions(-)
src/ie.c +17 -11
index 0abc01cb..f0163ea2 100644
@@ -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 };
@@ -2504,6 +2505,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)
@@ -2521,22 +2526,23 @@ 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);
+	}
 
-	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
index 81388496..c912d6c3 100644
@@ -493,6 +493,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
#1 lore raw

Hi James

Quoted 5 lines · James Prestwood

This 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.

I updated the commit description and...

Quoted 10 lines
---
  src/ie.c | 28 +++++++++++++++++-----------
  src/ie.h |  2 ++
  2 files changed, 19 insertions(+), 11 deletions(-)
src/ie.c +0 -0
index 0abc01cb..f0163ea2 100644

src/ie.c line 37

Quoted 5 lines
src/ie.c +1 -0
@@ -33,6 +33,7 @@
  #include "src/util.h"
  #include "src/crypto.h"
  #include "src/ie.h"
+#include "src/band.h"
 

I took out this include. Applied, thanks.

Regards,
-Denis

author
#2 lore raw

PATCH v2 2/4 scan: validate OWE transition operating class/channel

In reply to James Prestwood

If the IE's operating class and channel doesn't validate don't bother storing the IE at all.

---
 src/scan.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
src/scan.c +12 -4
index 54a7bc84..3f36ea3e 100644
@@ -1063,11 +1063,19 @@ static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data,
 		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;
-		}
+						bss->owe_trans) < 0)
+			goto free_owe_trans;
+
+		if (bss->owe_trans->oper_class && oci_to_frequency(
+						bss->owe_trans->oper_class,
+						bss->owe_trans->channel) < 0)
+			goto free_owe_trans;
+
+		return;
 
+free_owe_trans:
+		l_free(bss->owe_trans);
+		bss->owe_trans = NULL;
 		return;
 	}
 
Signature · 1 line
2.31.1
#3 lore raw

Re: [PATCH v2 2/4] scan: validate OWE transition operating class/channel

Hi James,

Quoted 22 lines · James Prestwood

If the IE's operating class and channel doesn't validate don't bother storing the IE at all.

---
  src/scan.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)
src/scan.c +4 -4
index 54a7bc84..3f36ea3e 100644
@@ -1063,11 +1063,19 @@ static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data,
  		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;
-		}
+						bss->owe_trans) < 0)
+			goto free_owe_trans;
+
+		if (bss->owe_trans->oper_class && oci_to_frequency(

src/scan.c static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data, · line 1079

Quoted 10 lines
src/scan.c +8 -0
+						bss->owe_trans->oper_class,
+						bss->owe_trans->channel) < 0)
+			goto free_owe_trans;
+
+		return;
 
+free_owe_trans:
+		l_free(bss->owe_trans);
+		bss->owe_trans = NULL;
  		return;

I simplified the logic here slightly through the use of _auto_ and l_steal_ptr.

src/scan.c static void scan_parse_vendor_specific(struct scan_bss *bss, const void *data, · line 1081

Quoted 3 lines
src/scan.c +0 -0
  	}
 

Patches 2-4 applied, thanks.

Regards,
-Denis

author
#4 lore raw

PATCH v2 3/4 scan: use oper_class/channel for OWE hidden scans

In reply to James Prestwood

If 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
index 3f36ea3e..96ce51e2 100644
@@ -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
author
#5 lore raw

PATCH v2 4/4 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
index 7240e3a8..9555766e 100644
@@ -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