aboutsummaryrefslogtreecommitdiffstats
path: root/src/eir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eir.c')
-rw-r--r--src/eir.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/eir.c b/src/eir.c
index 913a038d..419f4445 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -369,3 +369,26 @@ size_t eir_append_data(uint8_t *eir, size_t eir_len, uint8_t type,
return eir_len;
}
+
+size_t eir_length(uint8_t *eir, size_t maxlen)
+{
+ uint8_t field_len;
+ size_t parsed, length;
+
+ for (parsed = 0, length = 0; parsed < maxlen - 1; parsed += field_len) {
+ field_len = eir[0];
+
+ if (field_len == 0)
+ break;
+
+ parsed += field_len + 1;
+
+ if (parsed > maxlen)
+ break;
+
+ length = parsed;
+ eir += field_len + 1;
+ }
+
+ return length;
+}