diff mbox series

[v2,03/17] EHT: Add support for Multi-Link element defragmentation

Message ID 1664612489-29288-4-git-send-email-quic_vjakkam@quicinc.com
State Changes Requested
Headers show
Series MLD STA: Add support for four-way handshake and SAE external authentication | expand

Commit Message

Veerendranath Jakkam Oct. 1, 2022, 8:21 a.m. UTC
Add support for element defragmentation of different types of Multi-Link
elements.

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
---
 src/common/ieee802_11_common.c | 49 +++++++++++++++++++++++++++++++++++++++---
 src/common/ieee802_11_common.h | 10 +++++++--
 2 files changed, 54 insertions(+), 5 deletions(-)

Comments

Peer, Ilan Oct. 3, 2022, 12:29 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: Hostap <hostap-bounces@lists.infradead.org> On Behalf Of
> Veerendranath Jakkam
> Sent: Saturday, October 01, 2022 11:21
> To: hostap@lists.infradead.org
> Cc: quic_vjakkam@quicinc.com
> Subject: [PATCH v2 03/17] EHT: Add support for Multi-Link element
> defragmentation
> 
> Add support for element defragmentation of different types of Multi-Link
> elements.
> 

The design of the element defragmentation would be much simpler if instead of saving the
pointers to the fragment elements during parsing of the frame, when an element needs to
be defragmented (based on the element length), it can be done on the fly as the fragments
of the elements are expected to be right after the element. Thus, once we have the pointer
to the element that needs to be fragmented and its length we can easily get all the other
elements and do the defragmentation. Obviously, the fragment element length etc. would
still need to be validated during the frame parsing.

What do you think? 

Regards,

Ilan.
diff mbox series

Patch

diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index 41346a0..6891eca 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -235,6 +235,9 @@  static int ieee802_11_parse_mle(const u8 *pos, size_t elen,
 		return -1;
 	}
 
+	if (elen == 254)
+		elems->frag_ies.last_mle_type = mle_type;
+
 	return 0;
 }
 
@@ -257,6 +260,7 @@  static int ieee802_11_parse_extension(const u8 *pos, size_t elen,
 	elen--;
 
 	elems->frag_ies.last_eid_ext = 0;
+	elems->frag_ies.last_mle_type = -1;
 
 	switch (ext_id) {
 	case WLAN_EID_EXT_ASSOC_DELAY_INFO:
@@ -399,6 +403,7 @@  static void ieee802_11_parse_fragment(struct frag_ies_info *frag_ies,
 	frag_ies->frags[frag_ies->n_frags].ie_len = elen;
 	frag_ies->frags[frag_ies->n_frags].eid = frag_ies->last_eid;
 	frag_ies->frags[frag_ies->n_frags].eid_ext = frag_ies->last_eid_ext;
+	frag_ies->frags[frag_ies->n_frags].mle_type = frag_ies->last_mle_type;
 	frag_ies->n_frags++;
 }
 
@@ -2729,7 +2734,7 @@  enum oper_chan_width op_class_to_ch_width(u8 op_class)
 
 
 struct wpabuf * ieee802_11_defrag_data(struct ieee802_11_elems *elems,
-				       u8 eid, u8 eid_ext,
+				       u8 eid, u8 eid_ext, int mle_type,
 				       const u8 *data, u8 len)
 {
 	struct frag_ies_info *frag_ies = &elems->frag_ies;
@@ -2747,7 +2752,8 @@  struct wpabuf * ieee802_11_defrag_data(struct ieee802_11_elems *elems,
 		int ret;
 
 		if (frag_ies->frags[i].eid != eid ||
-		    frag_ies->frags[i].eid_ext != eid_ext)
+		    frag_ies->frags[i].eid_ext != eid_ext ||
+		    frag_ies->frags[i].mle_type != mle_type)
 			continue;
 
 		ret = wpabuf_resize(&buf, frag_ies->frags[i].ie_len);
@@ -2799,7 +2805,44 @@  struct wpabuf * ieee802_11_defrag(struct ieee802_11_elems *elems,
 		return NULL;
 	}
 
-	return ieee802_11_defrag_data(elems, eid, eid_ext, data, len);
+	return ieee802_11_defrag_data(elems, eid, eid_ext, -1, data, len);
+}
+
+
+struct wpabuf * ieee802_11_defrag_mle(struct ieee802_11_elems *elems, u8 type)
+{
+	const u8 *data;
+	u8 len;
+
+	switch (type) {
+	case MULTI_LINK_CONTROL_TYPE_BASIC:
+		data = elems->basic_mle;
+		len = elems->basic_mle_len;
+		break;
+	case MULTI_LINK_CONTROL_TYPE_PROBE_REQ:
+		data = elems->probe_req_mle;
+		len = elems->probe_req_mle_len;
+		break;
+	case MULTI_LINK_CONTROL_TYPE_RECONF:
+		data = elems->reconf_mle;
+		len = elems->reconf_mle_len;
+		break;
+	case MULTI_LINK_CONTROL_TYPE_TDLS:
+		data = elems->tdls_mle;
+		len = elems->tdls_mle_len;
+		break;
+	case MULTI_LINK_CONTROL_TYPE_PRIOR_ACCESS:
+		data = elems->prior_access_mle;
+		len = elems->prior_access_mle_len;
+		break;
+	default:
+		wpa_printf(MSG_DEBUG,
+			   "Defragmentation not supported. mle_type=%d", type);
+		return NULL;
+	}
+
+	return ieee802_11_defrag_data(elems, WLAN_EID_EXTENSION,
+				      WLAN_EID_EXT_MULTI_LINK, type, data, len);
 }
 
 
diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h
index ff6d2a8..0203e03 100644
--- a/src/common/ieee802_11_common.h
+++ b/src/common/ieee802_11_common.h
@@ -35,15 +35,20 @@  struct frag_ies_info {
 	struct {
 		u8 eid;
 		u8 eid_ext;
+		int mle_type;
 		const u8 *ie;
 		u8 ie_len;
 	} frags[MAX_NUM_FRAG_IES_SUPPORTED];
 
 	u8 n_frags;
 
-	/* the last parsed element ID and element extension ID */
+	/*
+	 * the last parsed element ID, element extension ID and Multi-Link
+	 * element type.
+	 */
 	u8 last_eid;
 	u8 last_eid_ext;
+	int last_mle_type;
 };
 
 /* Parsed Information Elements */
@@ -349,10 +354,11 @@  int ieee802_edmg_is_allowed(struct ieee80211_edmg_config allowed,
 			    struct ieee80211_edmg_config requested);
 
 struct wpabuf * ieee802_11_defrag_data(struct ieee802_11_elems *elems,
-				       u8 eid, u8 eid_ext,
+				       u8 eid, u8 eid_ext, int mle_type,
 				       const u8 *data, u8 len);
 struct wpabuf * ieee802_11_defrag(struct ieee802_11_elems *elems,
 				  u8 eid, u8 eid_ext);
+struct wpabuf * ieee802_11_defrag_mle(struct ieee802_11_elems *elems, u8 type);
 const u8 * get_ml_ie(const u8 *ies, size_t len, u8 type);
 const u8 * get_basic_mle_mld_addr(const u8 *buf, size_t len);