aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--include/osmocom/gsm/gsm0808.h7
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h29
-rw-r--r--include/osmocom/gsm/gsm23003.h7
-rw-r--r--include/osmocom/gsm/protocol/gsm_08_08.h7
-rw-r--r--src/gsm/gsm0808.c36
-rw-r--r--src/gsm/gsm0808_utils.c258
-rw-r--r--src/gsm/libosmogsm.map3
-rw-r--r--tests/gsm0808/gsm0808_test.c47
8 files changed, 360 insertions, 34 deletions
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 8c276f5..9153d99 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -30,6 +30,7 @@
struct sockaddr_storage;
struct msgb;
+struct gsm0808_cell_id_list2;
struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc,
uint16_t cc, int lac, uint16_t _ci);
@@ -70,9 +71,13 @@ struct msgb *gsm0808_create_ass_fail(uint8_t cause, const uint8_t *rr_cause,
*scl);
struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause);
struct msgb *gsm0808_create_clear_rqst(uint8_t cause);
+struct msgb *gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi,
+ const struct gsm0808_cell_id_list2 *cil,
+ const uint8_t *chan_needed);
struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
const struct gsm0808_cell_id_list *cil,
- const uint8_t *chan_needed);
+ const uint8_t *chan_needed)
+ OSMO_DEPRECATED("use gsm0808_create_paging2 instead");
struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id);
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id);
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index 7432164..363fc39 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -26,6 +26,27 @@
struct sockaddr_storage;
#include <osmocom/gsm/protocol/gsm_08_08.h>
+#include <osmocom/gsm/gsm23003.h>
+
+ /*! (225-1)/2 is the maximum number of elements in a cell identifier list. */
+#define GSM0808_CELL_ID_LIST2_MAXLEN 127
+
+/*! Parsed representation of a cell identifier list IE. */
+struct gsm0808_cell_id_list2 {
+ enum CELL_IDENT id_discr;
+ union {
+ /*!
+ * All elements of these arrays contain parsed representations of the
+ * data in the corresponding IE, in host-byte order.
+ */
+ struct osmo_cell_global_id global;
+ struct osmo_lac_and_ci_id lac_and_ci;
+ uint16_t ci;
+ struct osmo_location_area_id lai_and_lac;
+ uint16_t lac;
+ } id_list[GSM0808_CELL_ID_LIST2_MAXLEN];
+ unsigned int id_list_len;
+};
uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
const struct sockaddr_storage *ss);
@@ -48,10 +69,14 @@ uint8_t gsm0808_enc_encrypt_info(struct msgb *msg,
const struct gsm0808_encrypt_info *ei);
int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei,
const uint8_t *elem, uint8_t len);
+uint8_t gsm0808_enc_cell_id_list2(struct msgb *msg, const struct gsm0808_cell_id_list2 *cil);
uint8_t gsm0808_enc_cell_id_list(struct msgb *msg,
- const struct gsm0808_cell_id_list *cil);
+ const struct gsm0808_cell_id_list *cil)
+ OSMO_DEPRECATED("use gsm0808_enc_cell_id_list2 instead");
+int gsm0808_dec_cell_id_list2(struct gsm0808_cell_id_list2 *cil, const uint8_t *elem, uint8_t len);
int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
- const uint8_t *elem, uint8_t len);
+ const uint8_t *elem, uint8_t len)
+ OSMO_DEPRECATED("use gsm0808_dec_cell_id_list2 instead");
int gsm0808_chan_type_to_speech_codec(uint8_t perm_spch);
int gsm0808_speech_codec_from_chan_type(struct gsm0808_speech_codec *sc,
uint8_t perm_spch);
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 5d1fbd7..02e7971 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -30,6 +30,13 @@ struct osmo_cell_global_id {
uint16_t cell_identity;
};
+/* Actually defined in 3GPP TS 48.008 3.2.2.27 Cell Identifier List,
+ * but conceptually belongs with the above structures. */
+struct osmo_lac_and_ci_id {
+ uint16_t lac;
+ uint16_t ci;
+};
+
/* 12.5 */
struct osmo_service_area_id {
struct osmo_location_area_id lai;
diff --git a/include/osmocom/gsm/protocol/gsm_08_08.h b/include/osmocom/gsm/protocol/gsm_08_08.h
index ba347ef..947f90f 100644
--- a/include/osmocom/gsm/protocol/gsm_08_08.h
+++ b/include/osmocom/gsm/protocol/gsm_08_08.h
@@ -501,8 +501,13 @@ struct gsm0808_encrypt_info {
unsigned int key_len;
};
-/* 3GPP TS 48.008 3.2.2.27 Cell Identifier List */
#define CELL_ID_LIST_LAC_MAXLEN 127
+/*!
+ * DEPRECATED: This definition of the cell identifier list is
+ * insufficient. It cannot support all types of cell identifiers.
+ * Use struct gsm0808_cell_id_list2 in gsm0808_utils.h instead.
+ *
+ * 3GPP TS 48.008 3.2.2.27 Cell Identifier List */
struct gsm0808_cell_id_list {
uint8_t id_discr;
uint16_t id_list_lac[CELL_ID_LIST_LAC_MAXLEN];
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index b43e0e6..3003284 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -521,16 +521,16 @@ struct msgb *gsm0808_create_clear_rqst(uint8_t cause)
* \param[in] cil Cell Identity List (where to page)
* \param[in] chan_needed Channel Type needed
* \returns callee-allocated msgb with BSSMAP PAGING message */
-struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
- const struct gsm0808_cell_id_list *cil,
- const uint8_t *chan_needed)
+struct msgb *gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi,
+ const struct gsm0808_cell_id_list2 *cil,
+ const uint8_t *chan_needed)
{
struct msgb *msg;
uint8_t mid_buf[GSM48_MI_SIZE + 2];
int mid_len;
uint32_t tmsi_sw;
- /* Mandatory emelents! */
+ /* Mandatory elements! */
OSMO_ASSERT(imsi);
OSMO_ASSERT(cil);
@@ -558,7 +558,7 @@ struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
/* Cell Identifier List 3.2.2.27 */
if (cil)
- gsm0808_enc_cell_id_list(msg, cil);
+ gsm0808_enc_cell_id_list2(msg, cil);
/* Channel Needed 3.2.2.36 */
if (chan_needed) {
@@ -573,6 +573,32 @@ struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
return msg;
}
+/*! DEPRECATED: Use gsm0808_create_paging2 instead.
+ * Create BSSMAP PAGING message.
+ * \param[in] imsi Mandatory paged IMSI in string representation
+ * \param[in] tmsi Optional paged TMSI
+ * \param[in] cil Cell Identity List (where to page)
+ * \param[in] chan_needed Channel Type needed
+ * \returns callee-allocated msgb with BSSMAP PAGING message */
+struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
+ const struct gsm0808_cell_id_list *cil,
+ const uint8_t *chan_needed)
+{
+ struct gsm0808_cell_id_list2 cil2 = {};
+
+ /* Mandatory emelents! */
+ OSMO_ASSERT(cil);
+
+ if (cil->id_list_len > GSM0808_CELL_ID_LIST2_MAXLEN)
+ return NULL;
+
+ cil2.id_discr = cil->id_discr;
+ memcpy(cil2.id_list, cil->id_list_lac, cil->id_list_len * sizeof(cil2.id_list[0].lac));
+ cil2.id_list_len = cil->id_list_len;
+
+ return gsm0808_create_paging2(imsi, tmsi, &cil2, chan_needed);
+}
+
/*! Prepend a DTAP header to given Message Buffer
* \param[in] msgb Message Buffer
* \param[in] link_id Link Identifier */
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 93e6074..a07ef0e 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -27,6 +27,8 @@
#include <string.h>
#include <errno.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
+#include <osmocom/gsm/gsm48.h>
+#include <osmocom/gsm/gsm0808_utils.h>
#define IP_V4_ADDR_LEN 4
#define IP_V6_ADDR_LEN 16
@@ -571,6 +573,75 @@ int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei,
* \param[out] msg Message Buffer to which IE is to be appended
* \param[in] cil Cell ID List to be encoded
* \returns number of bytes appended to \a msg */
+uint8_t gsm0808_enc_cell_id_list2(struct msgb *msg,
+ const struct gsm0808_cell_id_list2 *cil)
+{
+ uint8_t *old_tail;
+ uint8_t *tlv_len;
+ unsigned int i;
+
+ OSMO_ASSERT(msg);
+ OSMO_ASSERT(cil);
+
+ msgb_put_u8(msg, GSM0808_IE_CELL_IDENTIFIER_LIST);
+ tlv_len = msgb_put(msg, 1);
+ old_tail = msg->tail;
+
+ msgb_put_u8(msg, cil->id_discr & 0x0f);
+
+ OSMO_ASSERT(cil->id_list_len <= GSM0808_CELL_ID_LIST2_MAXLEN)
+ switch (cil->id_discr) {
+ case CELL_IDENT_WHOLE_GLOBAL:
+ for (i = 0; i < cil->id_list_len; i++) {
+ const struct osmo_cell_global_id *id = &cil->id_list[i].global;
+ struct gsm48_loc_area_id lai;
+ gsm48_generate_lai(&lai, id->lai.plmn.mcc, id->lai.plmn.mnc, id->lai.lac);
+ memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
+ msgb_put_u16(msg, id->cell_identity);
+ }
+ break;
+ case CELL_IDENT_LAC_AND_CI:
+ for (i = 0; i < cil->id_list_len; i++) {
+ const struct osmo_lac_and_ci_id *id = &cil->id_list[i].lac_and_ci;
+ msgb_put_u16(msg, id->lac);
+ msgb_put_u16(msg, id->ci);
+ }
+ break;
+ case CELL_IDENT_CI:
+ for (i = 0; i < cil->id_list_len; i++)
+ msgb_put_u16(msg, cil->id_list[i].ci);
+ break;
+ case CELL_IDENT_LAI_AND_LAC:
+ for (i = 0; i < cil->id_list_len; i++) {
+ const struct osmo_location_area_id *id = &cil->id_list[i].lai_and_lac;
+ struct gsm48_loc_area_id lai;
+ gsm48_generate_lai(&lai, id->plmn.mcc, id->plmn.mnc, id->lac);
+ memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
+ }
+ break;
+ case CELL_IDENT_LAC:
+ for (i = 0; i < cil->id_list_len; i++)
+ msgb_put_u16(msg, cil->id_list[i].lac);
+ break;
+ case CELL_IDENT_BSS:
+ case CELL_IDENT_NO_CELL:
+ /* Does not have any list items */
+ break;
+ default:
+ /* Support for other identifier list types is not implemented. */
+ OSMO_ASSERT(false);
+ }
+
+ *tlv_len = (uint8_t) (msg->tail - old_tail);
+ return *tlv_len + 2;
+}
+
+/*! DEPRECATED: Use gsm0808_enc_cell_id_list2 instead.
+ *
+ * Encode TS 08.08 Cell Identifier List IE
+ * \param[out] msg Message Buffer to which IE is to be appended
+ * \param[in] cil Cell ID List to be encoded
+ * \returns number of bytes appended to \a msg */
uint8_t gsm0808_enc_cell_id_list(struct msgb *msg,
const struct gsm0808_cell_id_list *cil)
{
@@ -606,11 +677,198 @@ uint8_t gsm0808_enc_cell_id_list(struct msgb *msg,
return *tlv_len + 2;
}
+/* Decode 5-byte LAI list element data (see TS 08.08 3.2.2.27) into MCC/MNC/LAC.
+ * Return 0 if successful, negative on error. */
+static int decode_lai(const uint8_t *data, uint16_t *mcc, uint16_t *mnc, uint16_t *lac)
+{
+ struct gsm48_loc_area_id lai;
+
+ /* Copy data to stack to prevent unaligned access in gsm48_decode_lai(). */
+ memcpy(&lai, data, sizeof(lai)); /* don't byte swap yet */
+
+ return gsm48_decode_lai(&lai, mcc, mnc, lac) ? -1 : 0;
+}
+
+static int parse_cell_id_global_list(struct osmo_cell_global_id *id_list, const uint8_t *data, size_t remain,
+ size_t *consumed)
+{
+ struct osmo_cell_global_id *id;
+ uint16_t *ci_be;
+ size_t lai_offset;
+ int i = 0;
+ const size_t elemlen = sizeof(struct gsm48_loc_area_id) + sizeof(*ci_be);
+
+ *consumed = 0;
+ while (remain >= elemlen) {
+ if (i >= GSM0808_CELL_ID_LIST2_MAXLEN)
+ return -ENOSPC;
+ id = &id_list[i];
+ lai_offset = 1 + i * elemlen;
+ if (decode_lai(&data[lai_offset], &id->lai.plmn.mcc, &id->lai.plmn.mnc, &id->lai.lac) != 0)
+ return -EINVAL;
+ ci_be = (uint16_t *)(&data[lai_offset + sizeof(struct gsm48_loc_area_id)]);
+ id->cell_identity = osmo_load16be(ci_be);
+ *consumed += elemlen;
+ remain -= elemlen;
+ i++;
+ }
+
+ return i;
+}
+
+static int parse_cell_id_lac_and_ci_list(struct osmo_lac_and_ci_id *id_list, const uint8_t *data, size_t remain,
+ size_t *consumed)
+{
+ uint16_t *lacp_be, *ci_be;
+ struct osmo_lac_and_ci_id *id;
+ int i = 0;
+ const size_t elemlen = sizeof(*lacp_be) + sizeof(*ci_be);
+
+ *consumed = 0;
+
+ if (remain < elemlen)
+ return -EINVAL;
+
+ lacp_be = (uint16_t *)(&data[0]);
+ ci_be = (uint16_t *)(&data[2]);
+ while (remain >= elemlen) {
+ if (i >= GSM0808_CELL_ID_LIST2_MAXLEN)
+ return -ENOSPC;
+ id = &id_list[i];
+ id->lac = osmo_load16be(lacp_be);
+ id->ci = osmo_load16be(ci_be);
+ *consumed += elemlen;
+ remain -= elemlen;
+ lacp_be++;
+ ci_be++;
+ }
+
+ return i;
+}
+
+static int parse_cell_id_ci_list(uint16_t *id_list, const uint8_t *data, size_t remain, size_t *consumed)
+{
+ const uint16_t *ci_be = (const uint16_t *)data;
+ int i = 0;
+ const size_t elemlen = sizeof(*ci_be);
+
+ *consumed = 0;
+ while (remain >= elemlen) {
+ if (i >= GSM0808_CELL_ID_LIST2_MAXLEN)
+ return -ENOSPC;
+ id_list[i++] = osmo_load16be(ci_be++);
+ consumed += elemlen;
+ remain -= elemlen;
+ }
+ return i;
+}
+
+static int parse_cell_id_lai_and_lac(struct osmo_location_area_id *id_list, const uint8_t *data, size_t remain,
+ size_t *consumed)
+{
+ struct osmo_location_area_id *id;
+ int i = 0;
+ const size_t elemlen = sizeof(struct gsm48_loc_area_id);
+
+ *consumed = 0;
+ while (remain >= elemlen) {
+ if (i >= GSM0808_CELL_ID_LIST2_MAXLEN)
+ return -ENOSPC;
+ id = &id_list[i];
+ if (decode_lai(&data[1 + i * elemlen], &id->plmn.mcc, &id->plmn.mnc, &id->lac) != 0)
+ return -EINVAL;
+ *consumed += elemlen;
+ remain -= elemlen;
+ i++;
+ }
+
+ return i;
+}
+
+static int parse_cell_id_lac_list(uint16_t *id_list, const uint8_t *data, size_t remain, size_t *consumed)
+{
+ const uint16_t *lac_be = (const uint16_t *)data;
+ int i = 0;
+ const size_t elemlen = sizeof(*lac_be);
+
+ *consumed = 0;
+ while (remain >= elemlen) {
+ if (i >= GSM0808_CELL_ID_LIST2_MAXLEN)
+ return -ENOSPC;
+ id_list[i++] = osmo_load16be(lac_be++);
+ *consumed += elemlen;
+ remain -= elemlen;
+ }
+ return i;
+}
+
/*! Decode Cell Identifier List IE
* \param[out] cil Caller-provided memory to store Cell ID list
* \param[in] elem IE value to be decoded
* \param[in] len Length of \a elem in bytes
* \returns number of bytes parsed; negative on error */
+int gsm0808_dec_cell_id_list2(struct gsm0808_cell_id_list2 *cil,
+ const uint8_t *elem, uint8_t len)
+{
+ uint8_t id_discr;
+ size_t bytes_elem = 0;
+ int list_len = 0;
+
+ OSMO_ASSERT(cil);
+ if (!elem)
+ return -EINVAL;
+ if (len == 0)
+ return -EINVAL;
+
+ memset(cil, 0, sizeof(*cil));
+
+ id_discr = *elem & 0x0f;
+ elem++;
+ len--;
+
+ switch (id_discr) {
+ case CELL_IDENT_WHOLE_GLOBAL:
+ list_len = parse_cell_id_global_list(&cil->id_list[0].global, elem, len, &bytes_elem);
+ break;
+ case CELL_IDENT_LAC_AND_CI:
+ list_len = parse_cell_id_lac_and_ci_list(&cil->id_list[0].lac_and_ci, elem, len, &bytes_elem);
+ break;
+ case CELL_IDENT_CI:
+ list_len = parse_cell_id_ci_list(&cil->id_list[0].ci, elem, len, &bytes_elem);
+ break;
+ case CELL_IDENT_LAI_AND_LAC:
+ list_len = parse_cell_id_lai_and_lac(&cil->id_list[0].lai_and_lac, elem, len, &bytes_elem);
+ break;
+ case CELL_IDENT_LAC:
+ list_len = parse_cell_id_lac_list(&cil->id_list[0].lac, elem, len, &bytes_elem);
+ break;
+ case CELL_IDENT_BSS:
+ case CELL_IDENT_NO_CELL:
+ /* Does not have any list items */
+ break;
+ default:
+ /* Remaining cell identification types are not implemented. */
+ return -EINVAL;
+ }
+
+ if (list_len < 0) /* parsing error */
+ return list_len;
+
+ cil->id_discr = id_discr;
+ cil->id_list_len = list_len;
+
+ /* One byte for the cell ID discriminator + any remaining bytes in
+ * the IE which were consumed by the parser functions above. */
+ return 1 + (int)bytes_elem;
+}
+
+/*! DEPRECATED: Use gsm0808_dec_cell_id_list2 instead.
+ *
+ * Decode Cell Identifier List IE
+ * \param[out] cil Caller-provided memory to store Cell ID list
+ * \param[in] elem IE value to be decoded
+ * \param[in] len Length of \a elem in bytes
+ * \returns number of bytes parsed; negative on error */
int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
const uint8_t *elem, uint8_t len)
{
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index b903504..36a7712 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -151,6 +151,7 @@ gsm0808_create_clear_command;
gsm0808_create_clear_complete;
gsm0808_create_clear_rqst;
gsm0808_create_paging;
+gsm0808_create_paging2;
gsm0808_create_dtap;
gsm0808_create_layer3;
gsm0808_create_layer3_aoip;
@@ -170,7 +171,9 @@ gsm0808_dec_channel_type;
gsm0808_enc_encrypt_info;
gsm0808_dec_encrypt_info;
gsm0808_enc_cell_id_list;
+gsm0808_enc_cell_id_list2;
gsm0808_dec_cell_id_list;
+gsm0808_dec_cell_id_list2;
gsm0808_chan_type_to_speech_codec;
gsm0808_speech_codec_from_chan_type;
gsm0808_speech_codec_type_names;
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 189d548..21a0c99 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);