From 1a8a80aeae4c2e5c870ae5b032d9a6ae60b67ac8 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Wed, 6 Dec 2017 03:36:48 +0700 Subject: mobile/gsm48_rr.c: fix ACCH System Information parsing According to GSM 04.08, the System Information messages, such as SI5, SI5ter, SI5bis and SI6 (described in sections 9.1.37-40), have no the 'L2 Pseudo Length' (10.5.2.19) field, unlike others. So, previously the ACCH SI messages were ignored due to an implementation error - the gsm48_system_information_type_header struct isn't applicable here, because it assumes the 'l2_plen'. Since there is no (yet?) equivalent struct for the ACCH SI, this change replaces the wrong struct by the 'gsm48_hdr', which satisfies described requirements. Moreover, this change cleans up some gsm48_rr_rx_sysinfo* functions, getting rid of meaningless pionter shifting. Change-Id: I9166996f146af7973bf02a8a1c965581dc58a4a5 --- src/host/layer23/src/mobile/gsm48_rr.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/host/layer23/src/mobile/gsm48_rr.c b/src/host/layer23/src/mobile/gsm48_rr.c index ac272143..403e32dd 100644 --- a/src/host/layer23/src/mobile/gsm48_rr.c +++ b/src/host/layer23/src/mobile/gsm48_rr.c @@ -1943,10 +1943,9 @@ static int gsm48_rr_rx_sysinfo4(struct osmocom_ms *ms, struct msgb *msg) /* receive "SYSTEM INFORMATION 5" message (9.1.37) */ static int gsm48_rr_rx_sysinfo5(struct osmocom_ms *ms, struct msgb *msg) { - /* NOTE: pseudo length is not in this structure, so we skip */ - struct gsm48_system_information_type_5 *si = msgb_l3(msg) + 1; + struct gsm48_system_information_type_5 *si = msgb_l3(msg); struct gsm48_sysinfo *s = ms->cellsel.si; - int payload_len = msgb_l3len(msg) - sizeof(*si) - 1; + int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { LOGP(DRR, LOGL_INFO, "No cell selected, SYSTEM INFORMATION 5 " @@ -1973,10 +1972,9 @@ static int gsm48_rr_rx_sysinfo5(struct osmocom_ms *ms, struct msgb *msg) /* receive "SYSTEM INFORMATION 5bis" message (9.1.38) */ static int gsm48_rr_rx_sysinfo5bis(struct osmocom_ms *ms, struct msgb *msg) { - /* NOTE: pseudo length is not in this structure, so we skip */ - struct gsm48_system_information_type_5bis *si = msgb_l3(msg) + 1; + struct gsm48_system_information_type_5bis *si = msgb_l3(msg); struct gsm48_sysinfo *s = ms->cellsel.si; - int payload_len = msgb_l3len(msg) - sizeof(*si) - 1; + int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { LOGP(DRR, LOGL_INFO, "No cell selected, SYSTEM INFORMATION 5bis" @@ -2004,10 +2002,9 @@ static int gsm48_rr_rx_sysinfo5bis(struct osmocom_ms *ms, struct msgb *msg) /* receive "SYSTEM INFORMATION 5ter" message (9.1.39) */ static int gsm48_rr_rx_sysinfo5ter(struct osmocom_ms *ms, struct msgb *msg) { - /* NOTE: pseudo length is not in this structure, so we skip */ - struct gsm48_system_information_type_5ter *si = msgb_l3(msg) + 1; + struct gsm48_system_information_type_5ter *si = msgb_l3(msg); struct gsm48_sysinfo *s = ms->cellsel.si; - int payload_len = msgb_l3len(msg) - sizeof(*si) - 1; + int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { LOGP(DRR, LOGL_INFO, "No cell selected, SYSTEM INFORMATION 5ter" @@ -2035,11 +2032,10 @@ static int gsm48_rr_rx_sysinfo5ter(struct osmocom_ms *ms, struct msgb *msg) /* receive "SYSTEM INFORMATION 6" message (9.1.39) */ static int gsm48_rr_rx_sysinfo6(struct osmocom_ms *ms, struct msgb *msg) { - /* NOTE: pseudo length is not in this structure, so we skip */ - struct gsm48_system_information_type_6 *si = msgb_l3(msg) + 1; + struct gsm48_system_information_type_6 *si = msgb_l3(msg); struct gsm48_sysinfo *s = ms->cellsel.si; struct rx_meas_stat *meas = &ms->meas; - int payload_len = msgb_l3len(msg) - sizeof(*si) - 1; + int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { LOGP(DRR, LOGL_INFO, "No cell selected, SYSTEM INFORMATION 6 " @@ -4748,7 +4744,7 @@ static int gsm48_rr_rx_acch(struct osmocom_ms *ms, struct msgb *msg) struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm_settings *set = &ms->settings; struct abis_rsl_rll_hdr *rllh = msgb_l2(msg); - struct gsm48_system_information_type_header *sih = msgb_l3(msg); + struct gsm48_hdr *sih = msgb_l3(msg); uint8_t ind_ta, ind_tx_power; if (msgb_l2len(msg) < sizeof(*rllh) + 2 + 2) { @@ -4772,7 +4768,7 @@ static int gsm48_rr_rx_acch(struct osmocom_ms *ms, struct msgb *msg) rr->cd_now.ind_tx_power = ind_tx_power; } - switch (sih->system_information) { + switch (sih->msg_type) { case GSM48_MT_RR_SYSINFO_5: return gsm48_rr_rx_sysinfo5(ms, msg); case GSM48_MT_RR_SYSINFO_5bis: @@ -4783,7 +4779,7 @@ static int gsm48_rr_rx_acch(struct osmocom_ms *ms, struct msgb *msg) return gsm48_rr_rx_sysinfo6(ms, msg); default: LOGP(DRR, LOGL_NOTICE, "ACCH message type 0x%02x unknown.\n", - sih->system_information); + sih->msg_type); return -EINVAL; } } -- cgit v1.2.3