aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-04-30 17:47:16 +0200
committerHarald Welte <laforge@gnumonks.org>2016-04-30 17:47:16 +0200
commitf764a15c2339d5b24f0258d6605d5c38229209cc (patch)
treef3b7ddf50ee98c9ed2c906bd86428f5c40bd1bc3
parent02601c878585732ec75e33d02a45e5ab1147d4a1 (diff)
Add test case about RANAP MaxBitrate encoding
Our version of asn1c/libasn1c used to have an INTEGER encoding but, where the encoding of integers of > 2 bytes length was broken. Add a test case to what we expect with the updated/fixed libasn1c. If your compilation breaks, please upate to libasn1c with related fix commited a few minutes ago.
-rw-r--r--src/tests/test-ranap.c29
-rw-r--r--src/tests/test-ranap.ok23
2 files changed, 46 insertions, 6 deletions
diff --git a/src/tests/test-ranap.c b/src/tests/test-ranap.c
index acdf05b..5c30edf 100644
--- a/src/tests/test-ranap.c
+++ b/src/tests/test-ranap.c
@@ -27,6 +27,7 @@
#include <osmocom/ranap/ranap_common.h>
#include <osmocom/ranap/ranap_ies_defs.h>
#include <osmocom/ranap/ranap_msg_factory.h>
+#include <osmocom/ranap/RANAP_MaxBitrate.h>
#include "test_common.h"
@@ -36,6 +37,22 @@ int asn1_xer_print = 1;
extern void *tall_msgb_ctx;
+static void test_aper_int(uint32_t inp)
+{
+ RANAP_MaxBitrate_t mbr = inp;
+ asn_enc_rval_t rv;
+ uint8_t buf[32];
+
+ memset(buf, 0, sizeof(buf));
+
+ rv = aper_encode_to_buffer(&asn_DEF_RANAP_MaxBitrate, &mbr, buf, sizeof(buf));
+ if (rv.encoded == -1) {
+ fprintf(stderr, "Failed\n");
+ return;
+ }
+ printf("Encoded MaxBitRate %u to %s\n", mbr, osmo_hexdump(buf, rv.encoded/8));
+}
+
int main(int argc, char **argv)
{
uint8_t nas_buf[] = { 0xaa, 0xbb, 0xcc };
@@ -56,6 +73,18 @@ int main(int argc, char **argv)
test_common_init();
+ test_aper_int(1);
+ test_aper_int(2);
+ test_aper_int(3);
+ test_aper_int(255);
+ test_aper_int(256);
+ test_aper_int(257);
+ test_aper_int(64000);
+ test_aper_int(0xffff);
+ test_aper_int(0xffff+1);
+ test_aper_int(0xffff+2);
+ test_aper_int(16000000);
+
for (i = 0; i < 1; i++) {
printf("\n==> DIRECT TRANSFER\n");
msg = ranap_new_msg_dt(0, nas_buf, sizeof(nas_buf));
diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok
index 3e9bcda..430535c 100644
--- a/src/tests/test-ranap.ok
+++ b/src/tests/test-ranap.ok
@@ -1,3 +1,14 @@
+Encoded MaxBitRate 1 to 00 00
+Encoded MaxBitRate 2 to 00 01
+Encoded MaxBitRate 3 to 00 02
+Encoded MaxBitRate 255 to 00 fe
+Encoded MaxBitRate 256 to 00 ff
+Encoded MaxBitRate 257 to 40 01 00
+Encoded MaxBitRate 64000 to 40 f9 ff
+Encoded MaxBitRate 65535 to 40 ff fe
+Encoded MaxBitRate 65536 to 40 ff ff
+Encoded MaxBitRate 65537 to 80 01 00 00
+Encoded MaxBitRate 16000000 to 80 f4 23 ff
==> DIRECT TRANSFER
<RANAP_IE>
@@ -77,7 +88,7 @@
<firstValue>
38 02 D8 01 2F A7 20 2F A8 00 00 F4 4C 08 0A 02
80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28
- 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00
+ 14 00 3C 40 00 00 00 50 3D 02 02 00 0D C0 35 00
01 0A 0B 0C 0D 40 00 00 00 01
</firstValue>
<secondCriticality><ignore/></secondCriticality>
@@ -90,11 +101,11 @@
00 00 01 00 35 00 3A 38 02 D8 01 2F A7 20 2F A8
00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14
00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D
- 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 00 00 00
+ 02 02 00 0D C0 35 00 01 0A 0B 0C 0D 40 00 00 00
01 40 01 00
</value>
</RANAP_IE>
-00 00 00 4b 00 00 01 00 36 40 44 00 00 01 00 35 00 3a 38 02 d8 01 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 00 00 00 01 40 01 00
+00 00 00 4b 00 00 01 00 36 40 44 00 00 01 00 35 00 3a 38 02 d8 01 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 02 00 0d c0 35 00 01 0a 0b 0c 0d 40 00 00 00 01 40 01 00
==> RAB ASSIGNMENT COMMAND (DATA)
<RANAP_ProtocolIE-FieldPair>
@@ -102,7 +113,7 @@
<firstCriticality><reject/></firstCriticality>
<firstValue>
38 04 10 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06
- 08 9E 00 00 04 1B 80 35 00 01 1A 1B 1C 1D 00 11
+ 08 9E 00 04 00 1B 80 35 00 01 1A 1B 1C 1D 00 11
22 33 44
</firstValue>
<secondCriticality><ignore/></secondCriticality>
@@ -113,12 +124,12 @@
<criticality><ignore/></criticality>
<value>
00 00 01 00 35 00 23 38 04 10 DE 18 69 FF 80 0C
- 34 FF 00 1F 40 08 06 08 9E 00 00 04 1B 80 35 00
+ 34 FF 00 1F 40 08 06 08 9E 00 04 00 1B 80 35 00
01 1A 1B 1C 1D 00 11 22 33 44 40 06 78 1C 00 00
00 00
</value>
</RANAP_IE>
-00 00 00 39 00 00 01 00 36 40 32 00 00 01 00 35 00 23 38 04 10 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 04 1b 80 35 00 01 1a 1b 1c 1d 00 11 22 33 44 40 06 78 1c 00 00 00 00
+00 00 00 39 00 00 01 00 36 40 32 00 00 01 00 35 00 23 38 04 10 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 04 00 1b 80 35 00 01 1a 1b 1c 1d 00 11 22 33 44 40 06 78 1c 00 00 00 00
==> RESET CMD
<RANAP_IE>