Wireless Daemon for Linux
 help / color / mirror / Atom feed
* [PATCH v2 1/8] ie: add ie_parse_oci
@ 2021-10-19 18:19 James Prestwood
  0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2021-10-19 18:19 UTC (permalink / raw)
  To: iwd 

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

This is a very minimal parser, more or less to put the type
and length checks into a single location.
---
 src/ie.c | 20 ++++++++++++++++++++
 src/ie.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/src/ie.c b/src/ie.c
index 11746c5c..a5f3cbc2 100644
--- a/src/ie.c
+++ b/src/ie.c
@@ -2552,3 +2552,23 @@ int ie_parse_owe_transition(const void *data, size_t len,
 
 	return 0;
 }
+
+int ie_parse_oci(const void *data, size_t len, const uint8_t **oci)
+{
+	struct ie_tlv_iter iter;
+
+	ie_tlv_iter_init(&iter, data, len);
+
+	if (!ie_tlv_iter_next(&iter))
+		return -EMSGSIZE;
+
+	if (ie_tlv_iter_get_length(&iter) != 3)
+		return -EMSGSIZE;
+
+	if (ie_tlv_iter_get_tag(&iter) != IE_TYPE_OCI)
+		return -EPROTOTYPE;
+
+	*oci = ie_tlv_iter_get_data(&iter);
+
+	return 0;
+}
diff --git a/src/ie.h b/src/ie.h
index f6b15abb..b122524b 100644
--- a/src/ie.h
+++ b/src/ie.h
@@ -645,3 +645,5 @@ int ie_parse_network_cost(const void *data, size_t len,
 
 int ie_parse_owe_transition(const void *data, size_t len,
 				struct ie_owe_transition_info *info);
+
+int ie_parse_oci(const void *data, size_t len, const uint8_t **oci);
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/8] ie: add ie_parse_oci
@ 2021-10-19 18:34 Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2021-10-19 18:34 UTC (permalink / raw)
  To: iwd 

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Hi James,

On 10/19/21 1:19 PM, James Prestwood wrote:
> This is a very minimal parser, more or less to put the type
> and length checks into a single location.
> ---
>   src/ie.c | 20 ++++++++++++++++++++
>   src/ie.h |  2 ++
>   2 files changed, 22 insertions(+)
> 

All applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-19 18:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 18:34 [PATCH v2 1/8] ie: add ie_parse_oci Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2021-10-19 18:19 James Prestwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox