aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test-ranap.c
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 /src/tests/test-ranap.c
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.
Diffstat (limited to 'src/tests/test-ranap.c')
-rw-r--r--src/tests/test-ranap.c29
1 files changed, 29 insertions, 0 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));