summaryrefslogtreecommitdiffstats
path: root/tests/tlv
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-13 03:36:49 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-13 05:28:09 +0200
commita78b22ba203d9674bb797623b9c1dd985b523663 (patch)
tree77453b0de925087e818ff474c6ac2a6bb02421f2 /tests/tlv
parent74663d97c6677d92ba9ed4338c190b8dc42b537e (diff)
add tlv_parse2(), capable of multiple instances of the same IE
Allow passing multiple struct tlv_parsed in an array, to allow parsing as many repeated IEs as are expected by the caller. From tlv_parse(), call tlv_parse2() with dec_multiple = 1 to yield the previous behavior. tlv_parse() remains valid API. An example of multiple IEs is the BSSMAP Handover Request, containing Cell Identifier (Serving) and Cell Identifier (Target), both defined by 3GPP TS 48.008 3.2.2.17 with identical IE tags; both are mandatory. Related: OS#2283 (inter-BSC HO, BSC side) Change-Id: Id04008eaf0a1cafdbdc11b7efc556e3035b1c84d
Diffstat (limited to 'tests/tlv')
-rw-r--r--tests/tlv/tlv_test.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/tlv/tlv_test.c b/tests/tlv/tlv_test.c
index 39732756..e2065b00 100644
--- a/tests/tlv/tlv_test.c
+++ b/tests/tlv/tlv_test.c
@@ -254,6 +254,7 @@ static void test_tlv_repeated_ie()
int i, rc;
const uint8_t tag = 0x1a;
struct tlv_parsed dec;
+ struct tlv_parsed dec3[3];
struct tlv_definition def;
memset(&def, 0, sizeof(def));
@@ -273,6 +274,16 @@ static void test_tlv_repeated_ie()
/* Value pointer should point at first value in test data array. */
OSMO_ASSERT(dec.lv[tag].val == &test_data[2]);
OSMO_ASSERT(*dec.lv[tag].val == test_data[2]);
+
+ /* Accept three decodings, pointing at first, second and third val */
+ rc = tlv_parse2(dec3, 3, &def, &test_data[1], sizeof(test_data) - 1, tag, 0);
+ OSMO_ASSERT(rc == i/3);
+ OSMO_ASSERT(dec3[0].lv[tag].len == 1);
+ OSMO_ASSERT(dec3[0].lv[tag].val == &test_data[2]);
+ OSMO_ASSERT(dec3[1].lv[tag].len == 1);
+ OSMO_ASSERT(dec3[1].lv[tag].val == &test_data[2 + 3]);
+ OSMO_ASSERT(dec3[2].lv[tag].len == 1);
+ OSMO_ASSERT(dec3[2].lv[tag].val == &test_data[2 + 3 + 3]);
}
int main(int argc, char **argv)