diff options
Diffstat (limited to 'src/common/sysinfo.c')
-rw-r--r-- | src/common/sysinfo.c | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 66907761..874fb6d9 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -24,24 +24,99 @@ #include <osmo-bts/gsm_data.h> +#define BTS_HAS_SI(bts, sinum) ((bts)->si_valid & (1 << sinum)) + +/* Apply the rules from 05.02 6.3.1.3 Mapping of BCCH Data */ uint8_t *bts_sysinfo_get(struct gsm_bts *bts, struct gsm_time *g_time) { - /* Apply the rules from 05.02 6.3.1.3 Mapping of BCCH Data */ + struct gsm_bts_role_bts *btsb = bts_role_bts(bts); + unsigned int tc4_cnt = 0; + unsigned int tc4_sub[4]; + + /* System information type 2 bis or 2 ter messages are sent if + * needed, as determined by the system operator. If only one of + * them is needed, it is sent when TC = 5. If both are needed, + * 2bis is sent when TC = 5 and 2ter is sent at least once + * within any of 4 consecutive occurrences of TC = 4. */ + /* System information type 2 quater is sent if needed, as + * determined by the system operator. If sent on BCCH Norm, it + * shall be sent when TC = 5 if neither of 2bis and 2ter are + * used, otherwise it shall be sent at least once within any of + * 4 consecutive occurrences of TC = 4. If sent on BCCH Ext, it + * is sent at least once within any of 4 consecutive occurrences + * of TC = 5. */ + /* System Information type 9 is sent in those blocks with + * TC = 4 which are specified in system information type 3 as + * defined in 3GPP TS 04.08. */ + /* System Information Type 13 need only be sent if GPRS support + * is indicated in one or more of System Information Type 3 or 4 + * or 7 or 8 messages. These messages also indicate if the + * message is sent on the BCCH Norm or if the message is + * transmitted on the BCCH Ext. In the case that the message is + * sent on the BCCH Norm, it is sent at least once within any of + * 4 consecutive occurrences of TC = 4. */ + + /* We only implement BCCH Norm at this time */ switch (g_time->tc) { case 0: + /* System Information Type 1 need only be sent if + * frequency hopping is in use or when the NCH is + * present in a cell. If the MS finds another message + * when TC = 0, it can assume that System Information + * Type 1 is not in use. */ return GSM_BTS_SI(bts, SYSINFO_TYPE_1); case 1: + /* A SI 2 message will be sent at least every time TC = 1. */ return GSM_BTS_SI(bts, SYSINFO_TYPE_2); case 2: return GSM_BTS_SI(bts, SYSINFO_TYPE_3); case 3: return GSM_BTS_SI(bts, SYSINFO_TYPE_4); case 4: - /* FIXME: iterate over 2ter, 2quater, 9, 13 */ - return GSM_BTS_SI(bts, SYSINFO_TYPE_2ter); + /* iterate over 2ter, 2quater, 9, 13 */ + /* determine how many SI we need to send on TC=4, + * and which of them we send when */ + if (BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) { + tc4_sub[tc4_cnt] = SYSINFO_TYPE_2ter; + tc4_cnt += 1; /* 2bis */ + } + if (BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) && + (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) || + BTS_HAS_SI(bts, SYSINFO_TYPE_2bis))) { + tc4_sub[tc4_cnt] = SYSINFO_TYPE_2quater; + tc4_cnt += 1; + } + if (BTS_HAS_SI(bts, SYSINFO_TYPE_13)) { + tc4_sub[tc4_cnt] = SYSINFO_TYPE_13; + tc4_cnt += 1; + } + if (BTS_HAS_SI(bts, SYSINFO_TYPE_9)) { + /* FIXME: check SI3 scheduling info! */ + tc4_sub[tc4_cnt] = SYSINFO_TYPE_9; + tc4_cnt += 1; + } + /* increment static counter by one, modulo count */ + btsb->si.tc4_ctr = (btsb->si.tc4_ctr + 1) % tc4_cnt; + return GSM_BTS_SI(bts, tc4_sub[btsb->si.tc4_ctr]); case 5: - /* FIXME: 2bis, 2ter, 2quater */ - return GSM_BTS_SI(bts, SYSINFO_TYPE_2bis); + /* 2bis, 2ter, 2quater */ + if (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && + !BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) + return GSM_BTS_SI(bts, SYSINFO_TYPE_2bis); + + else if (BTS_HAS_SI(bts, SYSINFO_TYPE_2ter) && + !BTS_HAS_SI(bts, SYSINFO_TYPE_2bis)) + return GSM_BTS_SI(bts, SYSINFO_TYPE_2ter); + + else if (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && + BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) + return GSM_BTS_SI(bts, SYSINFO_TYPE_2bis); + + else if (BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) && + !BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && + !BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) + return GSM_BTS_SI(bts, SYSINFO_TYPE_2quater); + break; case 6: return GSM_BTS_SI(bts, SYSINFO_TYPE_3); case 7: |