summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-10-02 01:12:32 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-10-02 01:12:32 +0700
commitdfd357985e9a119ac0e3131b2cbc936d4d9b2449 (patch)
treea8417a7e1b38a5ceec898dcec551584a2dd6ad26 /src
parent6a50ae922b2664fb844aadea61b163911b5587fa (diff)
layer23/app_ccch_scan.c: clean up System Information handling
Diffstat (limited to 'src')
-rw-r--r--src/host/layer23/src/misc/app_ccch_scan.c123
1 files changed, 64 insertions, 59 deletions
diff --git a/src/host/layer23/src/misc/app_ccch_scan.c b/src/host/layer23/src/misc/app_ccch_scan.c
index 31b72f82..49adee99 100644
--- a/src/host/layer23/src/misc/app_ccch_scan.c
+++ b/src/host/layer23/src/misc/app_ccch_scan.c
@@ -45,108 +45,113 @@ static struct {
int ccch_mode;
} app_state;
-static void dump_bcch(struct osmocom_ms *ms, uint8_t tc, const uint8_t *data)
+static int bcch_check_tc(uint8_t si_type, uint8_t tc)
{
- struct gsm48_system_information_type_header *si_hdr;
- si_hdr = (struct gsm48_system_information_type_header *) data;
+ /* FIXME: there is no tc information (always 0) */
+ return 0;
- /* GSM 05.02 §6.3.1.3 Mapping of BCCH data */
- switch (si_hdr->system_information) {
+ switch (si_type) {
case GSM48_MT_RR_SYSINFO_1:
-#ifdef BCCH_TC_CHECK
if (tc != 0)
- LOGP(DRR, LOGL_ERROR, "SI1 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_2:
-#ifdef BCCH_TC_CHECK
if (tc != 1)
- LOGP(DRR, LOGL_ERROR, "SI2 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_3:
-#ifdef BCCH_TC_CHECK
if (tc != 2 && tc != 6)
- LOGP(DRR, LOGL_ERROR, "SI3 on the wrong TC: %d\n", tc);
-#endif
- if (app_state.ccch_mode == CCCH_MODE_NONE) {
- struct gsm48_system_information_type_3 *si3 =
- (struct gsm48_system_information_type_3 *)data;
-
- if (si3->control_channel_desc.ccch_conf == RSL_BCCH_CCCH_CONF_1_C)
- app_state.ccch_mode = CCCH_MODE_COMBINED;
- else
- app_state.ccch_mode = CCCH_MODE_NON_COMBINED;
-
- l1ctl_tx_ccch_mode_req(ms, app_state.ccch_mode);
- }
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_4:
-#ifdef BCCH_TC_CHECK
if (tc != 3 && tc != 7)
- LOGP(DRR, LOGL_ERROR, "SI4 on the wrong TC: %d\n", tc);
-#endif
- break;
- case GSM48_MT_RR_SYSINFO_5:
- break;
- case GSM48_MT_RR_SYSINFO_6:
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_7:
-#ifdef BCCH_TC_CHECK
if (tc != 7)
- LOGP(DRR, LOGL_ERROR, "SI7 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_8:
-#ifdef BCCH_TC_CHECK
if (tc != 3)
- LOGP(DRR, LOGL_ERROR, "SI8 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_9:
-#ifdef BCCH_TC_CHECK
if (tc != 4)
- LOGP(DRR, LOGL_ERROR, "SI9 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_13:
-#ifdef BCCH_TC_CHECK
if (tc != 4 && tc != 0)
- LOGP(DRR, LOGL_ERROR, "SI13 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_16:
-#ifdef BCCH_TC_CHECK
if (tc != 6)
- LOGP(DRR, LOGL_ERROR, "SI16 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_17:
-#ifdef BCCH_TC_CHECK
if (tc != 2)
- LOGP(DRR, LOGL_ERROR, "SI17 on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_2bis:
-#ifdef BCCH_TC_CHECK
if (tc != 5)
- LOGP(DRR, LOGL_ERROR, "SI2bis on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
case GSM48_MT_RR_SYSINFO_2ter:
-#ifdef BCCH_TC_CHECK
if (tc != 5 && tc != 4)
- LOGP(DRR, LOGL_ERROR, "SI2ter on the wrong TC: %d\n", tc);
-#endif
+ return -EINVAL;
break;
+
+ /* The following types are used on SACCH only */
+ case GSM48_MT_RR_SYSINFO_5:
+ case GSM48_MT_RR_SYSINFO_6:
case GSM48_MT_RR_SYSINFO_5bis:
- break;
case GSM48_MT_RR_SYSINFO_5ter:
break;
+
+ /* Unknown SI type */
default:
- LOGP(DRR, LOGL_ERROR, "Unknown SI: %d\n",
- si_hdr->system_information);
+ LOGP(DRR, LOGL_INFO, "Unknown SI (type=0x%02x)\n", si_type);
+ return -ENOTSUP;
+ };
+
+ return 0;
+}
+
+static void handle_si3(struct osmocom_ms *ms,
+ struct gsm48_system_information_type_3 *si)
+{
+ if (app_state.ccch_mode != CCCH_MODE_NONE)
+ return;
+
+ if (si->control_channel_desc.ccch_conf == RSL_BCCH_CCCH_CONF_1_C)
+ app_state.ccch_mode = CCCH_MODE_COMBINED;
+ else
+ app_state.ccch_mode = CCCH_MODE_NON_COMBINED;
+
+ l1ctl_tx_ccch_mode_req(ms, app_state.ccch_mode);
+}
+
+static void dump_bcch(struct osmocom_ms *ms, uint8_t tc, const uint8_t *data)
+{
+ struct gsm48_system_information_type_header *si_hdr;
+ si_hdr = (struct gsm48_system_information_type_header *) data;
+ uint8_t si_type = si_hdr->system_information;
+
+ LOGP(DRR, LOGL_INFO, "BCCH message (type=0x%02x): %s\n",
+ si_type, gsm48_rr_msg_name(si_type));
+
+ if (bcch_check_tc(si_type, tc) == -EINVAL)
+ LOGP(DRR, LOGL_INFO, "SI on wrong tc=%u\n", tc);
+
+ /* GSM 05.02 §6.3.1.3 Mapping of BCCH data */
+ switch (si_type) {
+ case GSM48_MT_RR_SYSINFO_3:
+ handle_si3(ms,
+ (struct gsm48_system_information_type_3 *) data);
break;
+
+ default:
+ /* We don't care about other types of SI */
+ break; /* thus there is nothing to do */
};
}