update scrambling only if we have good CRC

When a bad frame is received, the scrambling should not be updated,
because setting scrambling to wrong values will completely break further
decoding (until another SYNC frame is received).

Change-Id: I5e88b52fcbb98532d7ab6ca85e4f956589a595ab
This commit is contained in:
Jan Hrach 2018-07-30 23:19:52 +02:00 committed by Harald Welte
parent 05fa2d54bb
commit 013ef6e8a1
1 changed files with 10 additions and 8 deletions

View File

@ -229,14 +229,16 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
printf("MCC %s(%u) ", osmo_ubit_dump(type2+31, 10), bits_to_uint(type2+31, 10));
printf("MNC %s(%u)\n", osmo_ubit_dump(type2+41, 14), bits_to_uint(type2+41, 14));
/* obtain information from SYNC PDU */
tcd->colour_code = bits_to_uint(type2+4, 6);
tcd->time.tn = bits_to_uint(type2+10, 2);
tcd->time.fn = bits_to_uint(type2+12, 5);
tcd->time.mn = bits_to_uint(type2+17, 6);
tcd->mcc = bits_to_uint(type2+31, 10);
tcd->mnc = bits_to_uint(type2+41, 14);
/* compute the scrambling code for the current cell */
tcd->scramb_init = tetra_scramb_get_init(tcd->mcc, tcd->mnc, tcd->colour_code);
if (tup->crc_ok) {
tcd->colour_code = bits_to_uint(type2+4, 6);
tcd->time.tn = bits_to_uint(type2+10, 2);
tcd->time.fn = bits_to_uint(type2+12, 5);
tcd->time.mn = bits_to_uint(type2+17, 6);
tcd->mcc = bits_to_uint(type2+31, 10);
tcd->mnc = bits_to_uint(type2+41, 14);
/* compute the scrambling code for the current cell */
tcd->scramb_init = tetra_scramb_get_init(tcd->mcc, tcd->mnc, tcd->colour_code);
}
/* update the PHY layer time */
memcpy(&t_phy_state.time, &tcd->time, sizeof(t_phy_state.time));
tup->lchan = TETRA_LC_BSCH;