diff options
author | Stefan Sperling <ssperling@sysmocom.de> | 2018-03-15 19:38:15 +0100 |
---|---|---|
committer | Stefan Sperling <ssperling@sysmocom.de> | 2018-03-15 19:44:37 +0100 |
commit | 2338145d5b4e27447bb9026c0bb8251a59d7c20d (patch) | |
tree | b3b92b2c61c2bb69d25e265fcc77b5f032172827 /src | |
parent | e1a86748a2c7f6154644deee0477f629a86ca8ec (diff) |
use gsm48_decode_lai2() in gsm0808_dec_cell_id_list()
This makes gsm0808_dec_cell_id_list() properly decode 3-digit MNCs.
Add a test which encodes/decodes a LAI_AND_LAC list with 3-digit MNCs.
Change-Id: If6b941720de33dca66b6b1aa2cb95a3275708b7f
Related: OS#2847
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/gsm0808_utils.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 2d95ec68..ac1e8520 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -677,16 +677,15 @@ 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) +/* Decode 5-byte LAI list element data (see TS 08.08 3.2.2.27) into MCC/MNC/LAC. */ +static void decode_lai(const uint8_t *data, struct osmo_location_area_id *decoded) { struct gsm48_loc_area_id lai; - /* Copy data to stack to prevent unaligned access in gsm48_decode_lai(). */ + /* Copy data to stack to prevent unaligned access in gsm48_decode_lai2(). */ memcpy(&lai, data, sizeof(lai)); /* don't byte swap yet */ - return gsm48_decode_lai(&lai, mcc, mnc, lac) ? -1 : 0; + gsm48_decode_lai2(&lai, decoded); } static int parse_cell_id_global_list(struct gsm0808_cell_id_list2 *cil, const uint8_t *data, size_t remain, @@ -704,8 +703,7 @@ static int parse_cell_id_global_list(struct gsm0808_cell_id_list2 *cil, const ui return -ENOSPC; id = &cil->id_list[i].global; lai_offset = i * elemlen; - if (decode_lai(&data[lai_offset], &id->lai.plmn.mcc, &id->lai.plmn.mnc, &id->lai.lac) != 0) - return -EINVAL; + decode_lai(&data[lai_offset], &id->lai); ci_be = (uint16_t *)(&data[lai_offset + sizeof(struct gsm48_loc_area_id)]); id->cell_identity = osmo_load16be(ci_be); *consumed += elemlen; @@ -776,8 +774,7 @@ static int parse_cell_id_lai_and_lac(struct gsm0808_cell_id_list2 *cil, const ui if (i >= GSM0808_CELL_ID_LIST2_MAXLEN) return -ENOSPC; id = &cil->id_list[i].lai_and_lac; - if (decode_lai(&data[i * elemlen], &id->plmn.mcc, &id->plmn.mnc, &id->lac) != 0) - return -EINVAL; + decode_lai(&data[i * elemlen], id); *consumed += elemlen; remain -= elemlen; i++; |