Vadim Yanitskiy | 0df8c94 | 2020-05-02 16:23:35 +0700 | [diff] [blame] | 1 | /** |
| 2 | * GSM Rest Octets definitions as per 3GPP TS 44.018. |
| 3 | * |
| 4 | * (C) 2020 Vadim Yanitskiy <axilirator@gmail.com> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
| 13 | module GSM_RestOctets { |
| 14 | |
| 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
| 17 | |
| 18 | /* 10.5.2.34 SI 3 Rest Octets */ |
| 19 | type record SI3RestOctets { |
| 20 | SelectionParamsOpt sel_params, |
| 21 | PowerOffsetOpt pwr_offset, |
| 22 | BIT1 si_2ter_ind, |
| 23 | BIT1 early_cm_ind, |
| 24 | SchedIfAndWhere sched_where, |
| 25 | GPRSIndicatorOpt gprs_ind, |
| 26 | BIT1 umts_early_cm_ind, |
| 27 | SI2quaterIndicatorOpt si2_quater_ind, |
| 28 | BIT1 iu_mode_ind ('1'B) optional, |
| 29 | SI21IndicatorOpt si21_ind optional |
| 30 | /* ... spare padding ... */ |
| 31 | } with { |
| 32 | variant (si_2ter_ind) "CSN.1 L/H" |
| 33 | variant (early_cm_ind) "CSN.1 L/H" |
| 34 | variant (umts_early_cm_ind) "CSN.1 L/H" |
| 35 | |
| 36 | /* If Iu mode is not supported in the cell, the Iu Indicator is not sent |
| 37 | * within this cell. Iu Indicator is included if and only if GPRS is |
| 38 | * not supported, and Iu mode is supported in the cell. */ |
| 39 | variant (iu_mode_ind) "PRESENCE(gprs_ind.presence = '0'B)" |
| 40 | /* SI21 field is only present if 'WHERE' information is not present. */ |
| 41 | variant (si21_ind) "PRESENCE(sched_where.presence = '0'B)" |
Vadim Yanitskiy | 135b45e | 2020-05-04 19:54:02 +0700 | [diff] [blame] | 42 | |
| 43 | /* The TITAN's RAW encoder generates an octet-aligned octetstring, |
| 44 | * so we should make sure that unused bits contain proper padding. */ |
| 45 | variant "PADDING(yes), PADDING_PATTERN('00101011'B)" |
Vadim Yanitskiy | 0df8c94 | 2020-05-02 16:23:35 +0700 | [diff] [blame] | 46 | }; |
| 47 | |
Vadim Yanitskiy | 72add6d | 2020-05-03 21:46:42 +0700 | [diff] [blame] | 48 | /* 10.5.2.35 SI 4 Rest Octets (O & S) */ |
| 49 | type record SI4RestOctets { |
| 50 | SelectionParamsOpt sel_params, |
| 51 | PowerOffsetOpt pwr_offset, |
| 52 | GPRSIndicatorOpt gprs_ind, |
| 53 | BIT1 s_presence, // L/H |
| 54 | /* TODO: optional "Rest Octets S" part */ |
| 55 | bitstring s optional |
| 56 | } with { |
| 57 | variant (s_presence) "CSN.1 L/H" |
| 58 | variant (s) "PRESENCE(s_presence = '1'B)" |
Vadim Yanitskiy | 135b45e | 2020-05-04 19:54:02 +0700 | [diff] [blame] | 59 | |
| 60 | /* The TITAN's RAW encoder generates an octet-aligned octetstring, |
| 61 | * so we should make sure that unused bits contain proper padding. */ |
| 62 | variant "PADDING(yes), PADDING_PATTERN('00101011'B)" |
Vadim Yanitskiy | 72add6d | 2020-05-03 21:46:42 +0700 | [diff] [blame] | 63 | }; |
| 64 | |
Vadim Yanitskiy | 0df8c94 | 2020-05-02 16:23:35 +0700 | [diff] [blame] | 65 | /* Selection Parameters */ |
| 66 | type record SelectionParams { |
| 67 | boolean cbq, |
| 68 | uint6_t cr_offset, |
| 69 | uint3_t temp_offset, |
| 70 | uint5_t penalty_time |
| 71 | } with { |
| 72 | variant (cbq) "FIELDLENGTH(1)" |
| 73 | }; |
| 74 | |
| 75 | /* Optional Selection Parameters: L | H < Selection Parameters > */ |
| 76 | type record SelectionParamsOpt { |
| 77 | BIT1 presence, // L/H |
| 78 | SelectionParams params optional |
| 79 | } with { |
| 80 | variant (presence) "CSN.1 L/H" |
| 81 | variant (params) "PRESENCE(presence = '1'B)" |
| 82 | }; |
| 83 | |
| 84 | /* Optional Power Offset: L | H < Power Offset bit(2) > */ |
| 85 | type record PowerOffsetOpt { |
| 86 | BIT1 presence, // L/H |
| 87 | uint2_t offset optional |
| 88 | } with { |
| 89 | variant (presence) "CSN.1 L/H" |
| 90 | variant (offset) "PRESENCE(presence = '1'B)" |
| 91 | }; |
| 92 | |
| 93 | /* Scheduling if and where: L | H < WHERE bit(3) > */ |
| 94 | type record SchedIfAndWhere { |
| 95 | BIT1 presence, // L/H |
| 96 | uint3_t where optional |
| 97 | } with { |
| 98 | variant (presence) "CSN.1 L/H" |
| 99 | variant (where) "PRESENCE(presence = '1'B)" |
| 100 | }; |
| 101 | |
| 102 | type record GPRSIndicator { |
| 103 | uint3_t ra_colour, |
| 104 | BIT1 si13_pos |
| 105 | } with { variant "" }; |
| 106 | |
| 107 | /* Optional GPRS Indicator: L | H < GPRS Indicator > */ |
| 108 | type record GPRSIndicatorOpt { |
| 109 | BIT1 presence, // L/H |
| 110 | GPRSIndicator ind optional |
| 111 | } with { |
| 112 | variant (presence) "CSN.1 L/H" |
| 113 | variant (ind) "PRESENCE(presence = '1'B)" |
| 114 | }; |
| 115 | |
| 116 | /* Optional SI2quater Indicator: L | H < SI2quater Indicator > */ |
| 117 | type record SI2quaterIndicatorOpt { |
| 118 | BIT1 presence, // L/H |
| 119 | BIT1 ind optional |
| 120 | } with { |
| 121 | variant (presence) "CSN.1 L/H" |
| 122 | variant (ind) "PRESENCE(presence = '1'B)" |
| 123 | }; |
| 124 | |
| 125 | /* Optional SI21 Indicator: L | H < SI21 Position > */ |
| 126 | type record SI21IndicatorOpt { |
| 127 | BIT1 presence, // L/H |
| 128 | BIT1 pos optional |
| 129 | } with { |
| 130 | variant (presence) "CSN.1 L/H" |
| 131 | variant (pos) "PRESENCE(presence = '1'B)" |
| 132 | }; |
| 133 | |
| 134 | external function enc_SI3RestOctets(in SI3RestOctets ro) return octetstring |
| 135 | with { extension "prototype(convert) encode(RAW)" }; |
| 136 | external function dec_SI3RestOctets(in octetstring stream) return SI3RestOctets |
| 137 | with { extension "prototype(convert) decode(RAW)" }; |
| 138 | |
Vadim Yanitskiy | 72add6d | 2020-05-03 21:46:42 +0700 | [diff] [blame] | 139 | external function enc_SI4RestOctets(in SI4RestOctets ro) return octetstring |
| 140 | with { extension "prototype(convert) encode(RAW)" }; |
| 141 | external function dec_SI4RestOctets(in octetstring stream) return SI4RestOctets |
| 142 | with { extension "prototype(convert) decode(RAW)" }; |
| 143 | |
Vadim Yanitskiy | 0df8c94 | 2020-05-02 16:23:35 +0700 | [diff] [blame] | 144 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 145 | /* Basic templates to be extended in place */ |
| 146 | template (value) SI3RestOctets ts_SI3RestOctets := { |
| 147 | sel_params := { |
| 148 | presence := CSN1_L, |
| 149 | params := omit |
| 150 | }, |
| 151 | pwr_offset := { |
| 152 | presence := CSN1_L, |
| 153 | offset := omit |
| 154 | }, |
| 155 | si_2ter_ind := CSN1_L, |
| 156 | early_cm_ind := CSN1_L, |
| 157 | sched_where := { |
| 158 | presence := CSN1_L, |
| 159 | where := omit |
| 160 | }, |
| 161 | gprs_ind := { |
| 162 | presence := CSN1_L, |
| 163 | ind := omit |
| 164 | }, |
| 165 | umts_early_cm_ind := CSN1_L, |
| 166 | si2_quater_ind := { |
| 167 | presence := CSN1_L, |
| 168 | ind := omit |
| 169 | }, |
| 170 | iu_mode_ind := omit, |
| 171 | si21_ind := { |
| 172 | presence := CSN1_L, |
| 173 | pos := omit |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | template (value) SI4RestOctets ts_SI4RestOctets := { |
| 178 | sel_params := { |
| 179 | presence := CSN1_L, |
| 180 | params := omit |
| 181 | }, |
| 182 | pwr_offset := { |
| 183 | presence := CSN1_L, |
| 184 | offset := omit |
| 185 | }, |
| 186 | gprs_ind := { |
| 187 | presence := CSN1_L, |
| 188 | ind := omit |
| 189 | }, |
| 190 | s_presence := CSN1_L, |
| 191 | s := omit |
| 192 | } |
| 193 | |
| 194 | |
Vadim Yanitskiy | 0df8c94 | 2020-05-02 16:23:35 +0700 | [diff] [blame] | 195 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |