2017-07-14 16:25:59 +00:00
|
|
|
/* Encoding/Decoding routines for GSM System Information messages
|
2019-05-27 09:54:11 +00:00
|
|
|
* according to 3GPP TS 44.018 Version 12.3.0 Release 12
|
|
|
|
*
|
|
|
|
* (C) 2018 Harald Welte <laforge@gnumonks.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Released under the terms of GNU General Public License, Version 2 or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2017-07-14 16:25:59 +00:00
|
|
|
|
|
|
|
module GSM_SystemInformation {
|
|
|
|
|
|
|
|
import from General_Types all;
|
2017-07-15 13:58:13 +00:00
|
|
|
import from GSM_Types all;
|
2017-08-20 20:47:44 +00:00
|
|
|
import from GSM_RR_Types all;
|
2020-07-06 00:39:40 +00:00
|
|
|
import from GSM_RestOctets all;
|
2017-07-14 16:28:55 +00:00
|
|
|
import from Osmocom_Types all;
|
2017-07-14 16:25:59 +00:00
|
|
|
|
|
|
|
type union ArfcnOrMaio {
|
|
|
|
uint12_t arfcn,
|
|
|
|
MaioHsn maio_hsn
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 24.008 10.5.1.1 */
|
2017-07-28 11:30:24 +00:00
|
|
|
type uint16_t SysinfoCellIdentity;
|
2017-07-14 16:25:59 +00:00
|
|
|
|
|
|
|
/* 44.018 10.5.2.1b */
|
|
|
|
type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" };
|
|
|
|
|
|
|
|
/* 44.018 10.5.2.3 */
|
2018-02-25 15:17:33 +00:00
|
|
|
type enumerated CellOptions_DTX {
|
|
|
|
MS_MAY_USE_UL_DTX ('00'B),
|
|
|
|
MS_SHALL_USE_UL_DTX ('01'B),
|
|
|
|
MS_SHALL_NOT_USE_UL_DTX ('10'B)
|
|
|
|
} with { variant "FIELDLENGTH(2)" };
|
2017-07-14 16:25:59 +00:00
|
|
|
type record CellOptions {
|
|
|
|
boolean dn_ind,
|
|
|
|
boolean pwrc,
|
2018-02-25 15:17:33 +00:00
|
|
|
CellOptions_DTX dtx,
|
|
|
|
uint4_t radio_link_tout_div4
|
2017-07-14 16:25:59 +00:00
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 10.5.2.3a */
|
|
|
|
type record CellOptionsSacch {
|
|
|
|
BIT1 dtx_ext,
|
|
|
|
boolean pwrc,
|
|
|
|
BIT2 dtx,
|
|
|
|
BIT4 radio_link_timeout
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 10.5.2.4 */
|
|
|
|
type record CellSelectionParameters {
|
2018-02-25 15:17:33 +00:00
|
|
|
uint3_t cell_resel_hyst_2dB,
|
2017-07-14 16:25:59 +00:00
|
|
|
uint5_t ms_txpwr_max_cch,
|
2018-02-25 15:17:33 +00:00
|
|
|
BIT1 acs,
|
2017-07-14 16:25:59 +00:00
|
|
|
boolean neci,
|
|
|
|
uint6_t rxlev_access_min
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 10.5.2.11 */
|
2018-02-25 15:17:33 +00:00
|
|
|
type enumerated CtrlChanDesc_CC {
|
|
|
|
CCHAN_DESC_1CCCH_NOT_COMBINED ('000'B),
|
|
|
|
CCHAN_DESC_1CCCH_COMBINED ('001'B),
|
|
|
|
CCHAN_DESC_2CCCH_NOT_COMBINED ('010'B),
|
|
|
|
CCHAN_DESC_3CCCH_NOT_COMBINED ('100'B),
|
|
|
|
CCHAN_DESC_4CCCH_NOT_COMBINED ('110'B)
|
|
|
|
} with { variant "FIELDLENGTH(3)" };
|
|
|
|
type enumerated CBQ3 {
|
|
|
|
CBQ3_IU_MODE_NOT_SUPPORTED ('00'B),
|
|
|
|
CBQ3_IU_MODE_MS_BARRED ('01'B),
|
|
|
|
CBQ3_IU_MODE_NOT_BARRED ('10'B)
|
|
|
|
} with { variant "FIELDLENGTH(2)" };
|
2017-07-14 16:25:59 +00:00
|
|
|
type record ControlChannelDescription {
|
2018-02-25 15:17:33 +00:00
|
|
|
boolean msc_r99,
|
2017-07-14 16:25:59 +00:00
|
|
|
boolean att,
|
|
|
|
uint3_t bs_ag_blks_res,
|
2018-02-25 15:17:33 +00:00
|
|
|
CtrlChanDesc_CC ccch_conf,
|
2017-07-14 16:25:59 +00:00
|
|
|
boolean si22ind,
|
2018-02-25 15:17:33 +00:00
|
|
|
CBQ3 cbq3,
|
2017-07-14 16:25:59 +00:00
|
|
|
BIT2 spare,
|
2018-02-25 15:17:33 +00:00
|
|
|
uint3_t bs_pa_mfrms, /* off by 2 */
|
2017-07-14 16:25:59 +00:00
|
|
|
uint8_t t3212
|
|
|
|
} with { variant "" };
|
|
|
|
|
2017-07-16 01:05:02 +00:00
|
|
|
template ControlChannelDescription t_ControlChannelDescription := { ?, ?, ?, ?, ?, ?, '00'B, ?, ? };
|
|
|
|
|
2017-07-14 16:25:59 +00:00
|
|
|
/* 44.018 10.5.2.22 */
|
|
|
|
type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" };
|
|
|
|
|
|
|
|
/* 44.018 10.5.2.22a */
|
|
|
|
type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" };
|
|
|
|
|
|
|
|
type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
|
|
|
|
|
|
|
|
/* 44.018 10.5.2.29 */
|
2018-02-25 15:17:33 +00:00
|
|
|
type enumerated RachCtrlPar_MR {
|
|
|
|
RACH_MAX_RETRANS_1 ('00'B),
|
|
|
|
RACH_MAX_RETRANS_2 ('01'B),
|
|
|
|
RACH_MAX_RETRANS_4 ('10'B),
|
|
|
|
RACH_MAX_RETRANS_7 ('11'B)
|
|
|
|
} with { variant "FIELDLENGTH(2)" };
|
2017-07-14 16:25:59 +00:00
|
|
|
type record RachControlParameters {
|
2018-02-25 15:17:33 +00:00
|
|
|
RachCtrlPar_MR max_retrans,
|
2017-07-14 16:25:59 +00:00
|
|
|
BIT4 tx_integer,
|
|
|
|
boolean cell_barr_access,
|
2018-02-25 15:17:33 +00:00
|
|
|
boolean re_not_allowed,
|
|
|
|
AccessControlClass acc
|
|
|
|
} with { variant (acc) "FIELDLENGTH(16)" };
|
2017-07-14 16:25:59 +00:00
|
|
|
|
|
|
|
/* 44.018 9.1.31 */
|
|
|
|
type record SystemInformationType1 {
|
|
|
|
CellChannelDescription cell_chan_desc,
|
|
|
|
RachControlParameters rach_control,
|
2020-05-04 14:22:41 +00:00
|
|
|
RestOctets rest_octets length(0..1)
|
|
|
|
} with { variant "" };
|
2017-07-14 16:25:59 +00:00
|
|
|
|
|
|
|
/* 44.018 9.1.32 */
|
|
|
|
type record SystemInformationType2 {
|
|
|
|
NeighbourCellDescription bcch_freq_list,
|
|
|
|
BIT8 ncc_permitted,
|
|
|
|
RachControlParameters rach_control
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 9.1.33 */
|
|
|
|
type record SystemInformationType2bis {
|
|
|
|
NeighbourCellDescription extd_bcch_freq_list,
|
|
|
|
RachControlParameters rach_control,
|
2020-05-04 14:22:41 +00:00
|
|
|
RestOctets rest_octets length(0..1)
|
|
|
|
} with { variant "" };
|
2017-07-14 16:25:59 +00:00
|
|
|
|
|
|
|
/* 44.018 9.1.34 */
|
|
|
|
type record SystemInformationType2ter {
|
|
|
|
NeighbourCellDescription2 extd_bcch_freq_list,
|
2020-05-04 14:22:41 +00:00
|
|
|
RestOctets rest_octets length(0..4)
|
|
|
|
} with { variant "" };
|
2017-07-14 16:25:59 +00:00
|
|
|
|
2020-07-06 00:39:58 +00:00
|
|
|
type record SystemInformationType2quater {
|
|
|
|
SI2quaterRestOctets rest_octets
|
|
|
|
} with { variant "" };
|
|
|
|
|
2017-07-14 16:25:59 +00:00
|
|
|
/* 44.018 9.1.35 */
|
|
|
|
type record SystemInformationType3 {
|
2017-07-28 11:30:24 +00:00
|
|
|
SysinfoCellIdentity cell_id,
|
2017-07-14 16:25:59 +00:00
|
|
|
LocationAreaIdentification lai,
|
|
|
|
ControlChannelDescription ctrl_chan_desc,
|
|
|
|
CellOptions cell_options,
|
|
|
|
CellSelectionParameters cell_sel_par,
|
|
|
|
RachControlParameters rach_control,
|
2020-07-06 00:39:40 +00:00
|
|
|
SI3RestOctets rest_octets
|
2020-05-04 14:22:41 +00:00
|
|
|
} with { variant "" };
|
2017-07-14 16:25:59 +00:00
|
|
|
|
2017-07-16 01:05:02 +00:00
|
|
|
template SystemInformationType3 t_SI3 := {
|
|
|
|
cell_id := ?,
|
|
|
|
lai := ?,
|
|
|
|
ctrl_chan_desc := t_ControlChannelDescription,
|
|
|
|
cell_options := ?,
|
|
|
|
cell_sel_par := ?,
|
|
|
|
rach_control := ?,
|
|
|
|
rest_octets := ?
|
|
|
|
};
|
2021-06-21 09:49:43 +00:00
|
|
|
|
2017-07-16 01:05:02 +00:00
|
|
|
|
2017-07-14 16:25:59 +00:00
|
|
|
/* 44.018 9.1.36 */
|
|
|
|
type record SystemInformationType4 {
|
|
|
|
LocationAreaIdentification lai,
|
|
|
|
CellSelectionParameters cell_sel_par,
|
|
|
|
RachControlParameters rach_control,
|
2017-07-16 19:03:17 +00:00
|
|
|
ChannelDescriptionTV cbch_chan_desc optional,
|
2020-08-24 20:59:45 +00:00
|
|
|
MobileAllocationTLV cbch_mobile_alloc optional,
|
2020-07-06 00:39:40 +00:00
|
|
|
SI4RestOctets rest_octets /* see 10.5.2.35 */
|
2017-07-14 16:25:59 +00:00
|
|
|
} with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" };
|
|
|
|
|
|
|
|
/* 44.018 9.1.37 */
|
|
|
|
type record SystemInformationType5 {
|
|
|
|
NeighbourCellDescription bcch_freq_list
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 9.1.38 */
|
|
|
|
type record SystemInformationType5bis {
|
|
|
|
NeighbourCellDescription extd_bcch_freq_list
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 9.1.39 */
|
|
|
|
type record SystemInformationType5ter {
|
|
|
|
NeighbourCellDescription2 extd_bcch_freq_list
|
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
/* 44.018 9.1.40 */
|
|
|
|
type record SystemInformationType6 {
|
2017-07-28 11:30:24 +00:00
|
|
|
SysinfoCellIdentity cell_id,
|
2017-07-14 16:25:59 +00:00
|
|
|
LocationAreaIdentification lai,
|
|
|
|
CellOptionsSacch cell_options,
|
|
|
|
BIT8 ncc_permitted,
|
2022-03-10 14:03:26 +00:00
|
|
|
SI6RestOctets rest_octets
|
2020-05-04 14:22:41 +00:00
|
|
|
} with { variant "" };
|
2017-07-14 16:25:59 +00:00
|
|
|
|
2021-02-09 19:20:17 +00:00
|
|
|
/* 44.018 9.1.43a */
|
|
|
|
type record SystemInformationType13 {
|
|
|
|
SI13RestOctets rest_octets
|
|
|
|
} with { variant "" };
|
|
|
|
|
2017-07-15 17:59:33 +00:00
|
|
|
type union SystemInformationUnion {
|
2017-07-14 16:25:59 +00:00
|
|
|
SystemInformationType1 si1,
|
|
|
|
SystemInformationType2 si2,
|
|
|
|
SystemInformationType2bis si2bis,
|
|
|
|
SystemInformationType2ter si2ter,
|
2020-07-06 00:39:58 +00:00
|
|
|
SystemInformationType2quater si2quater,
|
2017-07-14 16:25:59 +00:00
|
|
|
SystemInformationType3 si3,
|
|
|
|
SystemInformationType4 si4,
|
|
|
|
SystemInformationType5 si5,
|
|
|
|
SystemInformationType5bis si5bis,
|
|
|
|
SystemInformationType5ter si5ter,
|
2017-07-15 21:59:49 +00:00
|
|
|
SystemInformationType6 si6,
|
2021-02-09 19:20:17 +00:00
|
|
|
SystemInformationType13 si13,
|
2017-07-15 21:59:49 +00:00
|
|
|
octetstring other
|
2017-07-15 17:59:33 +00:00
|
|
|
} with { variant "" };
|
|
|
|
|
|
|
|
type record SystemInformation {
|
2017-07-16 05:34:13 +00:00
|
|
|
RrHeader header,
|
2017-07-15 17:59:33 +00:00
|
|
|
SystemInformationUnion payload
|
|
|
|
} with { variant (payload) "CROSSTAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
|
2017-07-15 13:58:13 +00:00
|
|
|
si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
|
|
|
|
si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
|
|
|
|
si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
|
2020-07-06 00:39:58 +00:00
|
|
|
si2quater, header.message_type = SYSTEM_INFORMATION_TYPE_2quater;
|
2017-07-15 13:58:13 +00:00
|
|
|
si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
|
|
|
|
si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
|
|
|
|
si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
|
|
|
|
si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
|
|
|
|
si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
|
|
|
|
si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
|
2021-02-09 19:20:17 +00:00
|
|
|
si13, header.message_type = SYSTEM_INFORMATION_TYPE_13;
|
2017-07-15 21:59:49 +00:00
|
|
|
other, OTHERWISE;
|
2017-07-14 16:25:59 +00:00
|
|
|
)" };
|
|
|
|
|
2020-05-04 16:59:01 +00:00
|
|
|
external function enc_SystemInformationNoPad(in SystemInformation si) return octetstring
|
2017-07-14 16:25:59 +00:00
|
|
|
with { extension "prototype(convert) encode(RAW)" };
|
|
|
|
external function dec_SystemInformation(in octetstring stream) return SystemInformation
|
|
|
|
with { extension "prototype(convert) decode(RAW)" };
|
|
|
|
|
2020-05-04 16:59:01 +00:00
|
|
|
/* Due to a buggy nature of TITAN's padding attributes, we have to apply padding manually. */
|
|
|
|
function enc_SystemInformation(in SystemInformation si) return octetstring
|
|
|
|
{
|
|
|
|
var octetstring si_enc := enc_SystemInformationNoPad(si);
|
|
|
|
|
|
|
|
/* Resulting message length depends on SI Type */
|
|
|
|
select (si.header.message_type) {
|
|
|
|
case (SYSTEM_INFORMATION_TYPE_5,
|
|
|
|
SYSTEM_INFORMATION_TYPE_5bis,
|
|
|
|
SYSTEM_INFORMATION_TYPE_5ter) {
|
|
|
|
/* SACCH: no Rest Octets, return 'as-is' */
|
|
|
|
return si_enc;
|
|
|
|
}
|
|
|
|
case (SYSTEM_INFORMATION_TYPE_6) {
|
|
|
|
/* SACCH: pad to 19 octets, leave room for L1/LAPDm headers */
|
|
|
|
return f_pad_oct(si_enc, 19, '2B'O);
|
|
|
|
}
|
|
|
|
case else {
|
|
|
|
/* BCCH: pad to 23 octets */
|
|
|
|
return f_pad_oct(si_enc, 23, '2B'O);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-10 19:37:17 +00:00
|
|
|
external function dec_SystemInformationSafeBT(in octetstring stream, out SystemInformation si)
|
|
|
|
return integer /* Decoding result: successful (0) or unsuccessful (1) */
|
|
|
|
with { extension "prototype(backtrack) decode(RAW)" };
|
|
|
|
|
|
|
|
/* Some types of System Information (mostly the Rest Octets) are not fully implemented,
|
|
|
|
* so calling the generic dec_SystemInformation() may result in a DTE. This function
|
|
|
|
* additionally checks RR Protocol Discriminator, and should be used in the most cases. */
|
|
|
|
function dec_SystemInformationSafe(in octetstring stream, out SystemInformation si)
|
|
|
|
return integer {
|
|
|
|
/* Try to decode a given octetstring as System Information */
|
|
|
|
if (dec_SystemInformationSafeBT(stream, si) != 0) {
|
|
|
|
log("Failed to decode (RR) System Information: ", stream);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the protocol discriminator (we expect RR messages) */
|
|
|
|
if (si.header.rr_protocol_discriminator != bit2int('0110'B)) {
|
|
|
|
log("Protocol discriminator is not RR (!= '0110'B): ",
|
|
|
|
si.header.rr_protocol_discriminator);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-14 16:25:59 +00:00
|
|
|
} with { encode "RAW"; variant "FIELDORDER(msb)" }
|