aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-02-15 18:28:04 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-03-13 14:28:15 +0100
commit11a4d9dd91216fe353e94bfdbbab53bc4f891c0d (patch)
tree21f0639b659ab4a77ab25727895875bc6fdb5e43 /tests
parentb10ec0be5ffcd8759bb8b1461549a7eaf570bd9b (diff)
support for more cell ID list types in libosmocore
Introduce gsm0808_dec_cell_id_list2() with supports additional types of cell identifier lists. The new parsing routines are based on similar routines used by the paging code in osmo-bsc's osmo_bsc_bssap.c. Likewise, introduce gsm0808_enc_cell_id_list2() with support for the same additional types of cell identifier lists. The old API using struct gsm0808_cell_id_list is deprecated. The previous definition was insufficient because it assumed that all decoded cell ID types could be represented with a single uint16_t. It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h) despite being a host-side representation of data in an IE. The only user I am aware of is in osmo-msc, where this struct is used for one local variable. osmo-msc releases >= 1.1.0 make use of this API. While here, fix a small bug in a test: test_gsm0808_enc_dec_cell_id_list_bss() set the cell ID type to 'LAC' but obviously wants to use type 'BSS'. Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb Related: OS#2847
Diffstat (limited to 'tests')
-rw-r--r--tests/gsm0808/gsm0808_test.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 189d5483..21a0c992 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -451,26 +451,26 @@ static void test_create_paging()
RSL_CHANNEED_TCH_ForH };
struct msgb *msg;
- struct gsm0808_cell_id_list cil;
+ struct gsm0808_cell_id_list2 cil;
uint32_t tmsi = 0x12345678;
uint8_t chan_needed = RSL_CHANNEED_TCH_ForH;
char imsi[] = "001010000001234";
cil.id_discr = CELL_IDENT_LAC;
- cil.id_list_lac[0] = 0x2342;
+ cil.id_list[0].lac = 0x2342;
cil.id_list_len = 1;
printf("Testing creating Paging Request\n");
- msg = gsm0808_create_paging(imsi, NULL, &cil, NULL);
+ msg = gsm0808_create_paging2(imsi, NULL, &cil, NULL);
VERIFY(msg, res, ARRAY_SIZE(res));
msgb_free(msg);
- msg = gsm0808_create_paging(imsi, &tmsi, &cil, NULL);
+ msg = gsm0808_create_paging2(imsi, &tmsi, &cil, NULL);
VERIFY(msg, res2, ARRAY_SIZE(res2));
msgb_free(msg);
- msg = gsm0808_create_paging(imsi, &tmsi, &cil, &chan_needed);
+ msg = gsm0808_create_paging2(imsi, &tmsi, &cil, &chan_needed);
VERIFY(msg, res3, ARRAY_SIZE(res3));
msgb_free(msg);
}
@@ -751,25 +751,24 @@ static void test_gsm0808_enc_dec_encrypt_info()
static void test_gsm0808_enc_dec_cell_id_list_lac()
{
- struct gsm0808_cell_id_list enc_cil;
- struct gsm0808_cell_id_list dec_cil;
+ struct gsm0808_cell_id_list2 enc_cil;
+ struct gsm0808_cell_id_list2 dec_cil;
struct msgb *msg;
uint8_t rc_enc;
int rc_dec;
memset(&enc_cil, 0, sizeof(enc_cil));
enc_cil.id_discr = CELL_IDENT_LAC;
- enc_cil.id_list_lac[0] = 0x0124;
- enc_cil.id_list_lac[1] = 0xABCD;
- enc_cil.id_list_lac[2] = 0x5678;
+ enc_cil.id_list[0].lac = 0x0124;
+ enc_cil.id_list[0].lac = 0xABCD;
+ enc_cil.id_list[0].lac = 0x5678;
enc_cil.id_list_len = 3;
msg = msgb_alloc(1024, "output buffer");
- rc_enc = gsm0808_enc_cell_id_list(msg, &enc_cil);
+ rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil);
OSMO_ASSERT(rc_enc == 9);
- rc_dec = gsm0808_dec_cell_id_list(&dec_cil, msg->data + 2,
- msg->len - 2);
+ rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2);
OSMO_ASSERT(rc_dec == 7);
OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0);
@@ -779,8 +778,8 @@ static void test_gsm0808_enc_dec_cell_id_list_lac()
static void test_gsm0808_enc_dec_cell_id_list_single_lac()
{
- struct gsm0808_cell_id_list enc_cil;
- struct gsm0808_cell_id_list dec_cil;
+ struct gsm0808_cell_id_list2 enc_cil;
+ struct gsm0808_cell_id_list2 dec_cil;
struct msgb *msg;
uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x03,
0x05, 0x23, 0x42
@@ -790,16 +789,15 @@ static void test_gsm0808_enc_dec_cell_id_list_single_lac()
memset(&enc_cil, 0, sizeof(enc_cil));
enc_cil.id_discr = CELL_IDENT_LAC;
- enc_cil.id_list_lac[0] = 0x2342;
+ enc_cil.id_list[0].lac = 0x2342;
enc_cil.id_list_len = 1;
msg = msgb_alloc(1024, "output buffer");
- rc_enc = gsm0808_enc_cell_id_list(msg, &enc_cil);
+ rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil);
OSMO_ASSERT(rc_enc == 5);
OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0);
- rc_dec = gsm0808_dec_cell_id_list(&dec_cil, msg->data + 2,
- msg->len - 2);
+ rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2);
OSMO_ASSERT(rc_dec == 3);
OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0);
@@ -809,21 +807,20 @@ static void test_gsm0808_enc_dec_cell_id_list_single_lac()
static void test_gsm0808_enc_dec_cell_id_list_bss()
{
- struct gsm0808_cell_id_list enc_cil;
- struct gsm0808_cell_id_list dec_cil;
+ struct gsm0808_cell_id_list2 enc_cil;
+ struct gsm0808_cell_id_list2 dec_cil;
struct msgb *msg;
uint8_t rc_enc;
int rc_dec;
memset(&enc_cil, 0, sizeof(enc_cil));
- enc_cil.id_discr = CELL_IDENT_LAC;
+ enc_cil.id_discr = CELL_IDENT_BSS;
msg = msgb_alloc(1024, "output buffer");
- rc_enc = gsm0808_enc_cell_id_list(msg, &enc_cil);
+ rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil);
OSMO_ASSERT(rc_enc == 3);
- rc_dec = gsm0808_dec_cell_id_list(&dec_cil, msg->data + 2,
- msg->len - 2);
+ rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2);
OSMO_ASSERT(rc_dec == 1);
OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0);