diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/cbsp.c | 8 | ||||
-rw-r--r-- | src/gsm/gsm0808_utils.c | 21 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c index 84b92358..c13be617 100644 --- a/src/gsm/cbsp.c +++ b/src/gsm/cbsp.c @@ -515,7 +515,7 @@ static int cbsp_decode_cell_list(struct osmo_cbsp_cell_list *cl, void *ctx, osmo_cbsp_errstr = "cell list: error decoding cell_id_union"; return rc; } - cur += rc; + cur += gsm0808_cell_id_size(cl->id_discr); llist_add_tail(&ent->list, &cl->list); } return 0; @@ -538,7 +538,7 @@ static int cbsp_decode_fail_list(struct llist_head *fl, void *ctx, osmo_cbsp_errstr = "fail list: error decoding cell_id_union"; return rc; } - cur += rc; + cur += gsm0808_cell_id_size(ent->id_discr); ent->cause = *cur++; llist_add_tail(&ent->list, fl); } @@ -562,7 +562,7 @@ static int cbsp_decode_loading_list(struct osmo_cbsp_loading_list *ll, void *ctx osmo_cbsp_errstr = "load list: error decoding cell_id_union"; return rc; } - cur += rc; + cur += gsm0808_cell_id_size(ll->id_discr); if (cur + 2 > buf + len) { talloc_free(ent); osmo_cbsp_errstr = "load list: truncated IE"; @@ -592,7 +592,7 @@ static int cbsp_decode_num_compl_list(struct osmo_cbsp_num_compl_list *cl, void osmo_cbsp_errstr = "completed list: error decoding cell_id_union"; return rc; } - cur += rc; + cur += gsm0808_cell_id_size(cl->id_discr); if (cur + 3 > buf + len) { talloc_free(ent); osmo_cbsp_errstr = "completed list: truncated IE"; diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 364a04fe..7416d8f5 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -767,6 +767,27 @@ int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei, return (int)(elem - old_elem); } +/* Return the size of the value part of a cell identifier of given type */ +int gsm0808_cell_id_size(enum CELL_IDENT discr) +{ + switch (discr) { + case CELL_IDENT_WHOLE_GLOBAL: + return 7; + case CELL_IDENT_LAC_AND_CI: + return 4; + case CELL_IDENT_CI: + return 2; + case CELL_IDENT_LAI_AND_LAC: + return 5; + case CELL_IDENT_LAC: + return 2; + case CELL_IDENT_BSS: + case CELL_IDENT_NO_CELL: + return 0; + default: + return -EINVAL; + } +} /*! Decode a single GSM 08.08 Cell ID list element payload * \param[out] out caller-provided output union * \param[in] discr Cell ID discriminator describing type to be decoded |