aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2021-01-06 20:56:43 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2021-01-18 21:11:44 +0100
commit7450f77f5786a0d096f37aa4b90268c143ffd4a8 (patch)
tree8f40ecd25473bd9c2fa56b55c87bc9c925e74a65 /tests
parent9828d28fc37cf12a447759335c56573671700c18 (diff)
bssgp_rim: move bssgp_parse_rim_ri and bssgp_create_rim_ri to gprs_bssgp_rim
The function bssgp_parse_rim_ri() and bssgp_create_rim_ri() are located in gprs_bssgp.c, since there is now a gprs_bssgp_rim.c module it makes more sense to put them there. Also adjust the code a bit so that its more intuitive to read. Change-Id: Icd667f41d5735de56cd9fb257670337c679dd258 Related: SYS#5103
Diffstat (limited to 'tests')
-rw-r--r--tests/gb/gprs_bssgp_rim_test.c135
-rw-r--r--tests/gb/gprs_bssgp_rim_test.ok56
-rw-r--r--tests/gb/gprs_bssgp_test.c133
-rw-r--r--tests/gb/gprs_bssgp_test.ok56
4 files changed, 191 insertions, 189 deletions
diff --git a/tests/gb/gprs_bssgp_rim_test.c b/tests/gb/gprs_bssgp_rim_test.c
index 8c6a00d0..d08421b1 100644
--- a/tests/gb/gprs_bssgp_rim_test.c
+++ b/tests/gb/gprs_bssgp_rim_test.c
@@ -24,6 +24,137 @@
#include <string.h>
#include <unistd.h>
+void dump_rim_ri(struct bssgp_rim_routing_info *ri)
+{
+ switch (ri->discr) {
+ case BSSGP_RIM_ROUTING_INFO_GERAN:
+ printf("GERAN cell identifier\n");
+ printf(" * mcc: %u\n", ri->geran.raid.mcc);
+ printf(" mnc: %u\n", ri->geran.raid.mnc);
+ printf(" mnc 3 digits: %u\n", ri->geran.raid.mnc_3_digits);
+ printf(" lac: %u\n", ri->geran.raid.lac);
+ printf(" rac: %u\n", ri->geran.raid.rac);
+ printf(" * cell id: %04x\n", ri->geran.cid);
+ break;
+ case BSSGP_RIM_ROUTING_INFO_UTRAN:
+ printf("UTRAN RNC identifier\n");
+ printf(" * mcc: %u\n", ri->utran.raid.mcc);
+ printf(" mnc: %u\n", ri->utran.raid.mnc);
+ printf(" mnc 3 digits: %u\n", ri->utran.raid.mnc_3_digits);
+ printf(" lac: %u\n", ri->utran.raid.lac);
+ printf(" rac: %u\n", ri->utran.raid.rac);
+ printf(" * rnc id: %04x\n", ri->utran.rncid);
+ break;
+ case BSSGP_RIM_ROUTING_INFO_EUTRAN:
+ printf("EUTRAN eNB identifier\n");
+ printf(" * mcc: %u\n", ri->eutran.tai.mcc);
+ printf(" mnc: %u\n", ri->eutran.tai.mnc);
+ printf(" mnc 3 digits: %u\n", ri->eutran.tai.mnc_3_digits);
+ printf(" tac: %u\n", ri->eutran.tai.tac);
+ printf(" * global_enb_id: %s\n",
+ osmo_hexdump_nospc(ri->eutran.global_enb_id,
+ ri->eutran.global_enb_id_len));
+ break;
+ default:
+ OSMO_ASSERT(false);
+ }
+}
+
+static void test_bssgp_parse_rim_ri()
+{
+ int rc;
+ struct bssgp_rim_routing_info result;
+ uint8_t testvec_geran[] =
+ { 0x00, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 };
+ uint8_t testvec_utran[] =
+ { 0x01, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 };
+ uint8_t testvec_eutran[] =
+ { 0x02, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 };
+
+ printf("----- %s START\n", __func__);
+
+ rc = bssgp_parse_rim_ri(&result, testvec_geran,
+ sizeof(testvec_geran));
+ printf("rc=%d\n", rc);
+ dump_rim_ri(&result);
+ printf("\n");
+
+ rc = bssgp_parse_rim_ri(&result, testvec_utran,
+ sizeof(testvec_utran));
+ printf("rc=%d\n", rc);
+ dump_rim_ri(&result);
+ printf("\n");
+
+ rc = bssgp_parse_rim_ri(&result, testvec_eutran,
+ sizeof(testvec_eutran));
+ printf("rc=%d\n", rc);
+ dump_rim_ri(&result);
+ printf("\n");
+
+ printf("----- %s END\n", __func__);
+}
+
+static void test_bssgp_create_rim_ri()
+{
+ int rc;
+ struct bssgp_rim_routing_info ri;
+ uint8_t result[15];
+
+ printf("----- %s START\n", __func__);
+ memset(&ri, 0, sizeof(ri));
+ memset(result, 0, sizeof(result));
+ ri.discr = BSSGP_RIM_ROUTING_INFO_GERAN;
+
+ ri.geran.raid.mcc = 262;
+ ri.geran.raid.mnc = 42;
+ ri.geran.raid.mnc_3_digits = false;
+ ri.geran.raid.lac = 13200;
+ ri.geran.raid.rac = 0;
+ ri.geran.cid = 0x51e1;
+ dump_rim_ri(&ri);
+ rc = bssgp_create_rim_ri(result, &ri);
+ printf("rc=%d, ", rc);
+ if (rc > 0)
+ printf("result=%s", osmo_hexdump_nospc(result, rc));
+ printf("\n\n");
+
+ memset(&ri, 0, sizeof(ri));
+ memset(result, 0, sizeof(result));
+ ri.discr = BSSGP_RIM_ROUTING_INFO_UTRAN;
+ ri.utran.raid.mcc = 262;
+ ri.utran.raid.mnc = 42;
+ ri.utran.raid.mnc_3_digits = 0;
+ ri.utran.raid.lac = 13200;
+ ri.utran.raid.rac = 0;
+ ri.utran.rncid = 0x51e1;
+ dump_rim_ri(&ri);
+ rc = bssgp_create_rim_ri(result, &ri);
+ printf("rc=%d, ", rc);
+ if (rc > 0)
+ printf("result=%s", osmo_hexdump_nospc(result, rc));
+ printf("\n\n");
+
+ memset(&ri, 0, sizeof(ri));
+ memset(result, 0, sizeof(result));
+ ri.discr = BSSGP_RIM_ROUTING_INFO_EUTRAN;
+ ri.eutran.tai.mcc = 262;
+ ri.eutran.tai.mnc = 42;
+ ri.eutran.tai.mnc_3_digits = 0;
+ ri.eutran.tai.tac = 13200;
+ ri.eutran.global_enb_id[0] = 0x00;
+ ri.eutran.global_enb_id[1] = 0x51;
+ ri.eutran.global_enb_id[2] = 0xe1;
+ ri.eutran.global_enb_id_len = 3;
+ dump_rim_ri(&ri);
+ rc = bssgp_create_rim_ri(result, &ri);
+ printf("rc=%d, ", rc);
+ if (rc > 0)
+ printf("result=%s", osmo_hexdump_nospc(result, rc));
+ printf("\n\n");
+
+ printf("----- %s END\n", __func__);
+}
+
void dump_bssgp_ran_inf_req_app_cont_nacc(struct bssgp_ran_inf_req_app_cont_nacc *app_cont)
{
printf(" app_cont: bssgp_ran_inf_req_app_cont_nacc:\n");
@@ -636,6 +767,10 @@ int main(int argc, char **argv)
{
printf("===== BSSGP RIM test START\n");
+ /* RIM routing information */
+ test_bssgp_parse_rim_ri();
+ test_bssgp_create_rim_ri();
+
/* RIM containers */
test_bssgp_dec_ran_inf_req_rim_cont_nacc();
test_bssgp_enc_ran_inf_req_rim_cont_nacc();
diff --git a/tests/gb/gprs_bssgp_rim_test.ok b/tests/gb/gprs_bssgp_rim_test.ok
index d075ca3e..df5a41df 100644
--- a/tests/gb/gprs_bssgp_rim_test.ok
+++ b/tests/gb/gprs_bssgp_rim_test.ok
@@ -1,4 +1,60 @@
===== BSSGP RIM test START
+----- test_bssgp_parse_rim_ri START
+rc=9
+GERAN cell identifier
+ * mcc: 262
+ mnc: 42
+ mnc 3 digits: 0
+ lac: 13200
+ rac: 0
+ * cell id: 51e1
+
+rc=9
+UTRAN RNC identifier
+ * mcc: 262
+ mnc: 42
+ mnc 3 digits: 0
+ lac: 13200
+ rac: 0
+ * rnc id: 51e1
+
+rc=9
+EUTRAN eNB identifier
+ * mcc: 262
+ mnc: 42
+ mnc 3 digits: 0
+ tac: 13200
+ * global_enb_id: 0051e1
+
+----- test_bssgp_parse_rim_ri END
+----- test_bssgp_create_rim_ri START
+GERAN cell identifier
+ * mcc: 262
+ mnc: 42
+ mnc 3 digits: 0
+ lac: 13200
+ rac: 0
+ * cell id: 51e1
+rc=9, result=0062f22433900051e1
+
+UTRAN RNC identifier
+ * mcc: 262
+ mnc: 42
+ mnc 3 digits: 0
+ lac: 13200
+ rac: 0
+ * rnc id: 51e1
+rc=9, result=0162f22433900051e1
+
+EUTRAN eNB identifier
+ * mcc: 262
+ mnc: 42
+ mnc 3 digits: 0
+ tac: 13200
+ * global_enb_id: 0051e1
+rc=9, result=0262f22433900051e1
+
+----- test_bssgp_create_rim_ri END
----- test_bssgp_dec_ran_inf_req_rim_cont_nacc START
rc=0, bssgp_ran_inf_req_rim_cont:
app_id = 01
diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c
index e1c920a9..52e986e8 100644
--- a/tests/gb/gprs_bssgp_test.c
+++ b/tests/gb/gprs_bssgp_test.c
@@ -289,137 +289,6 @@ static void test_bssgp_msgb_copy()
printf("----- %s END\n", __func__);
}
-void dump_rim_ri(struct bssgp_rim_routing_info *ri)
-{
- switch (ri->discr) {
- case BSSGP_RIM_ROUTING_INFO_GERAN:
- printf("GERAN cell identifier\n");
- printf(" * mcc: %u\n", ri->geran.raid.mcc);
- printf(" mnc: %u\n", ri->geran.raid.mnc);
- printf(" mnc 3 digits: %u\n", ri->geran.raid.mnc_3_digits);
- printf(" lac: %u\n", ri->geran.raid.lac);
- printf(" rac: %u\n", ri->geran.raid.rac);
- printf(" * cell id: %04x\n", ri->geran.cid);
- break;
- case BSSGP_RIM_ROUTING_INFO_UTRAN:
- printf("UTRAN RNC identifier\n");
- printf(" * mcc: %u\n", ri->utran.raid.mcc);
- printf(" mnc: %u\n", ri->utran.raid.mnc);
- printf(" mnc 3 digits: %u\n", ri->utran.raid.mnc_3_digits);
- printf(" lac: %u\n", ri->utran.raid.lac);
- printf(" rac: %u\n", ri->utran.raid.rac);
- printf(" * rnc id: %04x\n", ri->utran.rncid);
- break;
- case BSSGP_RIM_ROUTING_INFO_EUTRAN:
- printf("EUTRAN eNB identifier\n");
- printf(" * mcc: %u\n", ri->eutran.tai.mcc);
- printf(" mnc: %u\n", ri->eutran.tai.mnc);
- printf(" mnc 3 digits: %u\n", ri->eutran.tai.mnc_3_digits);
- printf(" tac: %u\n", ri->eutran.tai.tac);
- printf(" * global_enb_id: %s\n",
- osmo_hexdump_nospc(ri->eutran.global_enb_id,
- ri->eutran.global_enb_id_len));
- break;
- default:
- OSMO_ASSERT(false);
- }
-}
-
-static void test_bssgp_parse_rim_ri()
-{
- int rc;
- struct bssgp_rim_routing_info result;
- uint8_t testvec_geran[] =
- { 0x00, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 };
- uint8_t testvec_utran[] =
- { 0x01, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 };
- uint8_t testvec_eutran[] =
- { 0x02, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 };
-
- printf("----- %s START\n", __func__);
-
- rc = bssgp_parse_rim_ri(&result, testvec_geran,
- sizeof(testvec_geran));
- printf("rc=%d\n", rc);
- dump_rim_ri(&result);
- printf("\n");
-
- rc = bssgp_parse_rim_ri(&result, testvec_utran,
- sizeof(testvec_utran));
- printf("rc=%d\n", rc);
- dump_rim_ri(&result);
- printf("\n");
-
- rc = bssgp_parse_rim_ri(&result, testvec_eutran,
- sizeof(testvec_eutran));
- printf("rc=%d\n", rc);
- dump_rim_ri(&result);
- printf("\n");
-
- printf("----- %s END\n", __func__);
-}
-
-static void test_bssgp_create_rim_ri()
-{
- int rc;
- struct bssgp_rim_routing_info ri;
- uint8_t result[15];
-
- printf("----- %s START\n", __func__);
- memset(&ri, 0, sizeof(ri));
- memset(result, 0, sizeof(result));
- ri.discr = BSSGP_RIM_ROUTING_INFO_GERAN;
-
- ri.geran.raid.mcc = 262;
- ri.geran.raid.mnc = 42;
- ri.geran.raid.mnc_3_digits = false;
- ri.geran.raid.lac = 13200;
- ri.geran.raid.rac = 0;
- ri.geran.cid = 0x51e1;
- dump_rim_ri(&ri);
- rc = bssgp_create_rim_ri(result, &ri);
- printf("rc=%d, ", rc);
- if (rc > 0)
- printf("result=%s", osmo_hexdump_nospc(result, rc));
- printf("\n\n");
-
- memset(&ri, 0, sizeof(ri));
- memset(result, 0, sizeof(result));
- ri.discr = BSSGP_RIM_ROUTING_INFO_UTRAN;
- ri.utran.raid.mcc = 262;
- ri.utran.raid.mnc = 42;
- ri.utran.raid.mnc_3_digits = 0;
- ri.utran.raid.lac = 13200;
- ri.utran.raid.rac = 0;
- ri.utran.rncid = 0x51e1;
- dump_rim_ri(&ri);
- rc = bssgp_create_rim_ri(result, &ri);
- printf("rc=%d, ", rc);
- if (rc > 0)
- printf("result=%s", osmo_hexdump_nospc(result, rc));
- printf("\n\n");
-
- memset(&ri, 0, sizeof(ri));
- memset(result, 0, sizeof(result));
- ri.discr = BSSGP_RIM_ROUTING_INFO_EUTRAN;
- ri.eutran.tai.mcc = 262;
- ri.eutran.tai.mnc = 42;
- ri.eutran.tai.mnc_3_digits = 0;
- ri.eutran.tai.tac = 13200;
- ri.eutran.global_enb_id[0] = 0x00;
- ri.eutran.global_enb_id[1] = 0x51;
- ri.eutran.global_enb_id[2] = 0xe1;
- ri.eutran.global_enb_id_len = 3;
- dump_rim_ri(&ri);
- rc = bssgp_create_rim_ri(result, &ri);
- printf("rc=%d, ", rc);
- if (rc > 0)
- printf("result=%s", osmo_hexdump_nospc(result, rc));
- printf("\n\n");
-
- printf("----- %s END\n", __func__);
-}
-
static struct log_info info = {};
int main(int argc, char **argv)
@@ -448,8 +317,6 @@ int main(int argc, char **argv)
test_bssgp_bad_reset();
test_bssgp_flow_control_bvc();
test_bssgp_msgb_copy();
- test_bssgp_parse_rim_ri();
- test_bssgp_create_rim_ri();
printf("===== BSSGP test END\n\n");
exit(EXIT_SUCCESS);
diff --git a/tests/gb/gprs_bssgp_test.ok b/tests/gb/gprs_bssgp_test.ok
index 744f1a79..c5b3e7d1 100644
--- a/tests/gb/gprs_bssgp_test.ok
+++ b/tests/gb/gprs_bssgp_test.ok
@@ -17,61 +17,5 @@ Got message: 26 1e 81 2a 05 82 10 22 03 82 c0 40 01 82 08 11 1c 82 60 20 3c 81 7
Old msgb: [L3]> 22 04 82 00 02 07 81 08
New msgb: [L3]> 22 04 82 00 02 07 81 08
----- test_bssgp_msgb_copy END
------ test_bssgp_parse_rim_ri START
-rc=9
-GERAN cell identifier
- * mcc: 262
- mnc: 42
- mnc 3 digits: 0
- lac: 13200
- rac: 0
- * cell id: 51e1
-
-rc=9
-UTRAN RNC identifier
- * mcc: 262
- mnc: 42
- mnc 3 digits: 0
- lac: 13200
- rac: 0
- * rnc id: 51e1
-
-rc=9
-EUTRAN eNB identifier
- * mcc: 262
- mnc: 42
- mnc 3 digits: 0
- tac: 13200
- * global_enb_id: 0051e1
-
------ test_bssgp_parse_rim_ri END
------ test_bssgp_create_rim_ri START
-GERAN cell identifier
- * mcc: 262
- mnc: 42
- mnc 3 digits: 0
- lac: 13200
- rac: 0
- * cell id: 51e1
-rc=9, result=0062f22433900051e1
-
-UTRAN RNC identifier
- * mcc: 262
- mnc: 42
- mnc 3 digits: 0
- lac: 13200
- rac: 0
- * rnc id: 51e1
-rc=9, result=0162f22433900051e1
-
-EUTRAN eNB identifier
- * mcc: 262
- mnc: 42
- mnc 3 digits: 0
- tac: 13200
- * global_enb_id: 0051e1
-rc=9, result=0262f22433900051e1
-
------ test_bssgp_create_rim_ri END
===== BSSGP test END