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.
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 @@
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 @@
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));