Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj at gmail.com>
To: iwd at lists.01.org
Subject: [PATCH v2 1/8] ie: add ie_parse_oci
Date: Tue, 19 Oct 2021 11:19:03 -0700	[thread overview]
Message-ID: <20211019181910.558043-1-prestwoj@gmail.com> (raw)

[-- 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

             reply	other threads:[~2021-10-19 18:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 18:19 James Prestwood [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-19 18:34 [PATCH v2 1/8] ie: add ie_parse_oci Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019181910.558043-1-prestwoj@gmail.com \
    --to=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox