This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/21863 ) Change subject: bssgp_rim: move bssgp_parse_rim_ri and bssgp_create_rim_ri to gprs_bssgp_rim ...................................................................... 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. Change-Id: Icd667f41d5735de56cd9fb257670337c679dd258 Related: SYS#5103 --- M include/osmocom/gprs/gprs_bssgp.h M include/osmocom/gprs/gprs_bssgp_rim.h M src/gb/gprs_bssgp.c M src/gb/gprs_bssgp_rim.c M tests/gb/gprs_bssgp_rim_test.c M tests/gb/gprs_bssgp_rim_test.ok M tests/gb/gprs_bssgp_test.c M tests/gb/gprs_bssgp_test.ok 8 files changed, 307 insertions(+), 308 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/21863/1 diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h index d228c53..9255661 100644 --- a/include/osmocom/gprs/gprs_bssgp.h +++ b/include/osmocom/gprs/gprs_bssgp.h @@ -178,37 +178,6 @@ int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid, uint16_t cid); -enum bssgp_rim_routing_info_discr { - BSSGP_RIM_ROUTING_INFO_GERAN, - BSSGP_RIM_ROUTING_INFO_UTRAN, - BSSGP_RIM_ROUTING_INFO_EUTRAN, -}; - -/*! BSSGP RIM Routing information, see also 3GPP TS 48.018, section 11.3.70 */ -struct bssgp_rim_routing_info { - enum bssgp_rim_routing_info_discr discr; - union { - struct { - struct gprs_ra_id raid; - uint16_t cid; - } geran; - struct { - struct gprs_ra_id raid; - uint16_t rncid; - } utran; - struct { - struct osmo_eutran_tai tai; - /* See also 3GPP TS 36.413 9.2.1.37 and 3GPP TS 36.401 */ - uint8_t global_enb_id[8]; - uint8_t global_enb_id_len; - } eutran; - }; -}; - -int bssgp_parse_rim_ri(struct bssgp_rim_routing_info *ri, const uint8_t *buf, - unsigned int len); -int bssgp_create_rim_ri(uint8_t *buf, const struct bssgp_rim_routing_info *ri); - /* Wrapper around TLV parser to parse BSSGP IEs */ static inline int bssgp_tlv_parse(struct tlv_parsed *tp, const uint8_t *buf, int len) { diff --git a/include/osmocom/gprs/gprs_bssgp_rim.h b/include/osmocom/gprs/gprs_bssgp_rim.h index c801c29..2486351 100644 --- a/include/osmocom/gprs/gprs_bssgp_rim.h +++ b/include/osmocom/gprs/gprs_bssgp_rim.h @@ -2,6 +2,36 @@ #include <osmocom/gprs/protocol/gsm_08_18.h> +enum bssgp_rim_routing_info_discr { + BSSGP_RIM_ROUTING_INFO_GERAN, + BSSGP_RIM_ROUTING_INFO_UTRAN, + BSSGP_RIM_ROUTING_INFO_EUTRAN, +}; + +/*! BSSGP RIM Routing information, see also 3GPP TS 48.018, section 11.3.70 */ +struct bssgp_rim_routing_info { + enum bssgp_rim_routing_info_discr discr; + union { + struct { + struct gprs_ra_id raid; + uint16_t cid; + } geran; + struct { + struct gprs_ra_id raid; + uint16_t rncid; + } utran; + struct { + struct osmo_eutran_tai tai; + /* See also 3GPP TS 36.413 9.2.1.37 and 3GPP TS 36.401 */ + uint8_t global_enb_id[8]; + uint8_t global_enb_id_len; + } eutran; + }; +}; + +int bssgp_parse_rim_ri(struct bssgp_rim_routing_info *ri, const uint8_t *buf, unsigned int len); +int bssgp_create_rim_ri(uint8_t *buf, const struct bssgp_rim_routing_info *ri); + /* 3GPP TS 48.018, table 11.3.62a.1.b: RAN-INFORMATION-REQUEST RIM Container Contents */ struct bssgp_ran_inf_req_rim_cont { uint8_t app_id; diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index fd2a48c..4551427 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -326,93 +326,6 @@ return 8; } -/*! Parse a RIM Routing information IE (3GPP TS 48.018, chapter 11.3.70). - * \param[out] ri user provided memory to store the parsed results. - * \param[in] buf input buffer of the value part of the IE. - * \returns length of parsed octets, -EINVAL on error. */ -int bssgp_parse_rim_ri(struct bssgp_rim_routing_info *ri, const uint8_t *buf, - unsigned int len) -{ - struct gprs_ra_id raid_temp; - - memset(ri, 0, sizeof(*ri)); - if (len < 2) - return -EINVAL; - - ri->discr = buf[0] & 0x0f; - - switch (ri->discr) { - case BSSGP_RIM_ROUTING_INFO_GERAN: - if (len < 9) - return -EINVAL; - ri->geran.cid = bssgp_parse_cell_id(&ri->geran.raid, buf + 1); - return 9; - case BSSGP_RIM_ROUTING_INFO_UTRAN: - if (len < 9) - return -EINVAL; - gsm48_parse_ra(&ri->utran.raid, buf + 1); - ri->utran.rncid = osmo_load16be(buf + 7); - return 9; - case BSSGP_RIM_ROUTING_INFO_EUTRAN: - if (len < 7 || len > 14) - return -EINVAL; - /* Note: 3GPP TS 24.301 Figure 9.9.3.32.1 and 3GPP TS 24.008 - * Figure 10.5.130 specify MCC/MNC encoding in the same way, - * so we can re-use gsm48_parse_ra() for that. */ - gsm48_parse_ra(&raid_temp, buf + 1); - ri->eutran.tai.mcc = raid_temp.mcc; - ri->eutran.tai.mnc = raid_temp.mnc; - ri->eutran.tai.mnc_3_digits = raid_temp.mnc_3_digits; - ri->eutran.tai.tac = osmo_load16be(buf + 4); - memcpy(ri->eutran.global_enb_id, buf + 6, len - 6); - ri->eutran.global_enb_id_len = len - 6; - return len; - default: - return -EINVAL; - } -} - -/*! Encode a RIM Routing information IE (3GPP TS 48.018, chapter 11.3.70). - * \param[out] buf user provided memory (at least 14 byte) for the generated value part of the IE. - * \param[in] ri user provided input data struct. - * \returns length of encoded octets, -EINVAL on error. */ -int bssgp_create_rim_ri(uint8_t *buf, const struct bssgp_rim_routing_info *ri) -{ - int rc; - struct gprs_ra_id raid_temp; - - buf[0] = ri->discr & 0x0f; - buf++; - - switch (ri->discr) { - case BSSGP_RIM_ROUTING_INFO_GERAN: - rc = bssgp_create_cell_id(buf, &ri->geran.raid, ri->geran.cid); - if (rc < 0) - return -EINVAL; - return rc + 1; - case BSSGP_RIM_ROUTING_INFO_UTRAN: - gsm48_encode_ra((struct gsm48_ra_id *)buf, &ri->utran.raid); - osmo_store16be(ri->utran.rncid, buf + 6); - return 9; - case BSSGP_RIM_ROUTING_INFO_EUTRAN: - /* Note: 3GPP TS 24.301 Figure 9.9.3.32.1 and 3GPP TS 24.008 - * Figure 10.5.130 specify MCC/MNC encoding in the same way, - * so we can re-use gsm48_encode_ra() for that. */ - raid_temp.mcc = ri->eutran.tai.mcc; - raid_temp.mnc = ri->eutran.tai.mnc; - raid_temp.mnc_3_digits = ri->eutran.tai.mnc_3_digits; - gsm48_encode_ra((struct gsm48_ra_id *)buf, &raid_temp); - osmo_store16be(ri->eutran.tai.tac, buf + 3); - OSMO_ASSERT(ri->eutran.global_enb_id_len <= - sizeof(ri->eutran.global_enb_id)); - memcpy(buf + 5, ri->eutran.global_enb_id, - ri->eutran.global_enb_id_len); - return ri->eutran.global_enb_id_len + 6; - default: - return -EINVAL; - } -} - /* Chapter 8.4 BVC-Reset Procedure */ static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp, uint16_t ns_bvci) diff --git a/src/gb/gprs_bssgp_rim.c b/src/gb/gprs_bssgp_rim.c index f6aeb1d..56f2d4d 100644 --- a/src/gb/gprs_bssgp_rim.c +++ b/src/gb/gprs_bssgp_rim.c @@ -27,6 +27,93 @@ #include <osmocom/gprs/gprs_bssgp.h> #include <osmocom/gprs/gprs_bssgp_rim.h> +/*! Parse a RIM Routing information IE (3GPP TS 48.018, chapter 11.3.70). + * \param[out] ri user provided memory to store the parsed results. + * \param[in] buf input buffer of the value part of the IE. + * \returns length of parsed octets, -EINVAL on error. */ +int bssgp_parse_rim_ri(struct bssgp_rim_routing_info *ri, const uint8_t *buf, + unsigned int len) +{ + struct gprs_ra_id raid_temp; + + memset(ri, 0, sizeof(*ri)); + if (len < 2) + return -EINVAL; + + ri->discr = buf[0] & 0x0f; + + switch (ri->discr) { + case BSSGP_RIM_ROUTING_INFO_GERAN: + if (len < 9) + return -EINVAL; + ri->geran.cid = bssgp_parse_cell_id(&ri->geran.raid, buf + 1); + return 9; + case BSSGP_RIM_ROUTING_INFO_UTRAN: + if (len < 9) + return -EINVAL; + gsm48_parse_ra(&ri->utran.raid, buf + 1); + ri->utran.rncid = osmo_load16be(buf + 7); + return 9; + case BSSGP_RIM_ROUTING_INFO_EUTRAN: + if (len < 7 || len > 14) + return -EINVAL; + /* Note: 3GPP TS 24.301 Figure 9.9.3.32.1 and 3GPP TS 24.008 + * Figure 10.5.130 specify MCC/MNC encoding in the same way, + * so we can re-use gsm48_parse_ra() for that. */ + gsm48_parse_ra(&raid_temp, buf + 1); + ri->eutran.tai.mcc = raid_temp.mcc; + ri->eutran.tai.mnc = raid_temp.mnc; + ri->eutran.tai.mnc_3_digits = raid_temp.mnc_3_digits; + ri->eutran.tai.tac = osmo_load16be(buf + 4); + memcpy(ri->eutran.global_enb_id, buf + 6, len - 6); + ri->eutran.global_enb_id_len = len - 6; + return len; + default: + return -EINVAL; + } +} + +/*! Encode a RIM Routing information IE (3GPP TS 48.018, chapter 11.3.70). + * \param[out] buf user provided memory (at least 14 byte) for the generated value part of the IE. + * \param[in] ri user provided input data struct. + * \returns length of encoded octets, -EINVAL on error. */ +int bssgp_create_rim_ri(uint8_t *buf, const struct bssgp_rim_routing_info *ri) +{ + int rc; + struct gprs_ra_id raid_temp; + + buf[0] = ri->discr & 0x0f; + buf++; + + switch (ri->discr) { + case BSSGP_RIM_ROUTING_INFO_GERAN: + rc = bssgp_create_cell_id(buf, &ri->geran.raid, ri->geran.cid); + if (rc < 0) + return -EINVAL; + return rc + 1; + case BSSGP_RIM_ROUTING_INFO_UTRAN: + gsm48_encode_ra((struct gsm48_ra_id *)buf, &ri->utran.raid); + osmo_store16be(ri->utran.rncid, buf + 6); + return 9; + case BSSGP_RIM_ROUTING_INFO_EUTRAN: + /* Note: 3GPP TS 24.301 Figure 9.9.3.32.1 and 3GPP TS 24.008 + * Figure 10.5.130 specify MCC/MNC encoding in the same way, + * so we can re-use gsm48_encode_ra() for that. */ + raid_temp.mcc = ri->eutran.tai.mcc; + raid_temp.mnc = ri->eutran.tai.mnc; + raid_temp.mnc_3_digits = ri->eutran.tai.mnc_3_digits; + gsm48_encode_ra((struct gsm48_ra_id *)buf, &raid_temp); + osmo_store16be(ri->eutran.tai.tac, buf + 3); + OSMO_ASSERT(ri->eutran.global_enb_id_len <= + sizeof(ri->eutran.global_enb_id)); + memcpy(buf + 5, ri->eutran.global_enb_id, + ri->eutran.global_enb_id_len); + return ri->eutran.global_enb_id_len + 6; + default: + return -EINVAL; + } +} + /* See also 3GPP TS 48.018 table 11.3.62a.1.b, table 11.3.62a.2.b, and table 11.3.62a.5.b. Those container * types share common IEs. */ #define DEC_RIM_CONT_COMMON \ diff --git a/tests/gb/gprs_bssgp_rim_test.c b/tests/gb/gprs_bssgp_rim_test.c index 99073a2..d7a19d4 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_rim_cont(struct bssgp_ran_inf_req_rim_cont *rim_cont) { printf("bssgp_ran_inf_req_rim_cont:\n"); @@ -516,6 +647,8 @@ int main(int argc, char **argv) { printf("===== BSSGP RIM test START\n"); + test_bssgp_parse_rim_ri(); + test_bssgp_create_rim_ri(); test_bssgp_dec_ran_inf_req_rim_cont(); test_bssgp_enc_ran_inf_req_rim_cont(); test_bssgp_dec_ran_inf_rim_cont(); diff --git a/tests/gb/gprs_bssgp_rim_test.ok b/tests/gb/gprs_bssgp_rim_test.ok index 92d3282..4f3ebcd 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 START rc=0, bssgp_ran_inf_req_rim_cont: app_id = 01 @@ -18,7 +74,7 @@ prot_ver = 1 app_cont: 62f22433900051e1 app_cont_len: 8 -rc=25, result=4b81014c84000000014f81f25581014d8862f22433900051e1 +rc=25, result=4b81014c84000000014f81025581014d8862f22433900051e1 ----- test_bssgp_enc_ran_inf_req_rim_cont END ----- test_bssgp_dec_ran_inf_rim_cont START rc=0, bssgp_ran_inf_rim_cont: diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c index e1c920a..52e986e 100644 --- a/tests/gb/gprs_bssgp_test.c +++ b/tests/gb/gprs_bssgp_test.c @@ -289,137 +289,6 @@ 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 @@ 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 744f1a7..c5b3e7d 100644 --- a/tests/gb/gprs_bssgp_test.ok +++ b/tests/gb/gprs_bssgp_test.ok @@ -17,61 +17,5 @@ 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 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21863 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Icd667f41d5735de56cd9fb257670337c679dd258 Gerrit-Change-Number: 21863 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201223/d044e9f8/attachment.htm>