blob: b282454b1a5a38830087ec3b35f976e0af43c084 [file] [log] [blame]
Harald Welteea260342019-08-01 09:49:38 +02001module CBSP_Types {
2
3/* CBSP_Types, defining abstract TTCN-3 data types for the CBSP protocol.
4 *
5 * CBSP is a ETSI/3GPP standard protocol used between CBC (Cell Broadcast Centre)
6 * and BSC (Base Station Controller) in 2G/GSM/GERAN networks. It is specified
7 * in 3GPP TS 48.049.
8 *
9 * (C) 2019 by Harald Welte <laforge@gnumonks.org>
10 * All rights reserved.
11 *
12 * Released under the terms of GNU General Public License, Version 2 or
13 * (at your option) any later version.
14 */
15
16import from General_Types all;
17import from Osmocom_Types all;
18import from BSSAP_Types all;
19
20
21/* 8.2.2 Message Type */
22type enumerated CBSP_MessageType {
23 CBSP_MSGT_WRITE_REPLACE ('01'O),
24 CBSP_MSGT_WRITE_REPLACE_COMPL ('02'O),
25 CBSP_MSGT_WRITE_REPLACE_FAIL ('03'O),
26 CBSP_MSGT_KILL ('04'O),
27 CBSP_MSGT_KILL_COMPL ('05'O),
28 CBSP_MSGT_KILL_FAIL ('06'O),
29 CBSP_MSGT_LOAD_QUERY ('07'O),
30 CBSP_MSGT_LOAD_QUERY_COMPL ('08'O),
31 CBSP_MSGT_LOAD_QUERY_FAIL ('09'O),
32 CBSP_MSGT_MSG_STATUS_QUERY ('0a'O),
33 CBSP_MSGT_MSG_STATUS_QUERY_COMPL ('0b'O),
34 CBSP_MSGT_MSG_STATUS_QUERY_FAIL ('0c'O),
35 CBSP_MSGT_SET_DRX ('0d'O),
36 CBSP_MSGT_SET_DRX_COMPL ('0e'O),
37 CBSP_MSGT_SET_DRX_FAIL ('0f'O),
38 CBSP_MSGT_RESET ('10'O),
39 CBSP_MSGT_RESET_COMPL ('11'O),
40 CBSP_MSGT_RESET_FAIL ('12'O),
41 CBSP_MSGT_RESTART ('13'O),
42 CBSP_MSGT_FAILURE ('14'O),
43 CBSP_MSGT_ERROR_IND ('15'O),
44 CBSP_MSGT_KEEP_ALIVE ('16'O),
45 CBSP_MSGT_KEEP_ALIVE_COMPL ('17'O)
46} with { variant "FIELDLENGTH(8)" };
47
48/* 8.2.1 Information Element Identifier */
49type enumerated CBSP_IEI {
50 CBSP_IEI_MSG_CONTENT ('01'O),
51 CBSP_IEI_OLD_SERIAL_NR ('02'O),
52 CBSP_IEI_NEW_SERIAL_NR ('03'O),
53 CBSP_IEI_CELL_LIST ('04'O),
54 CBSP_IEI_CATEGORY ('05'O),
55 CBSP_IEI_REP_PERIOD ('06'O),
56 CBSP_IEI_NUM_BCAST_REQ ('07'O),
57 CBSP_IEI_NUM_BCAST_COMPL_LIST ('08'O),
58 CBSP_IEI_FAILURE_LIST ('09'O),
59 CBSP_IEI_RR_LOADING_LIST ('0a'O),
60 CBSP_IEI_CAUSE ('0b'O),
61 CBSP_IEI_DCS ('0c'O),
62 CBSP_IEI_RECOVERY_IND ('0d'O),
63 CBSP_IEI_MSG_ID ('0e'O),
64 CBSP_IEI_EMERG_IND ('0f'O),
65 CBSP_IEI_WARN_TYPE ('10'O),
66 CBSP_IEI_WARN_SEC_INFO ('11'O),
67 CBSP_IEI_CHANNEL_IND ('12'O),
68 CBSP_IEI_NUM_OF_PAGES ('13'O),
69 CBSP_IEI_SCHEDULE_PERIOD ('14'O),
70 CBSP_IEI_NUM_OF_RES_SLOTS ('15'O),
71 CBSP_IEI_BCAST_MSG_TYPE ('16'O),
72 CBSP_IEI_WARNING_PERIOD ('17'O),
73 CBSP_IEI_KEEP_ALIVE_REP_PERIOD ('18'O)
74} with { variant "FIELDLENGTH(8)" };
75
76/* 8.2.7 Category */
77type enumerated CBSP_Category {
78 CBSP_CATEG_HIGH_PRIO ('00'O),
79 CBSP_CATEG_BACKGROUND ('01'O),
80 CBSP_CATEG_NORMAL ('02'O)
81} with { variant "FIELDLENGTH(8)" };
82
83/* Cell ID Discriminator (8.2.11, ...) */
84type enumerated CBSP_CellIdDisc {
85 CBSP_CIDD_WHOLE_CGI (0),
86 CBSP_CIDD_LAC_CI (1),
87 CBSP_CIDD_CI (2),
88 CBSP_CIDD_LAI (4),
89 CBSP_CIDD_LAC (5),
90 CBSP_CIDD_ALL_IN_BSC (6)
91} with { variant "FIELDLENGTH(4)" };
92
93/* 8.2.13 Cause */
94type enumerated CBSP_Cause {
95 CBSP_CAUSE_PARAM_NOT_RECOGNISED ('00'O),
96 CBSP_CAUSE_PARAM_VAL_INVALID ('01'O),
97 CBSP_CAUSE_MSG_REF_NOT_IDENTIFIED ('02'O),
98 CBSP_CAUSE_CELL_ID_NOT_VALID ('03'O),
99 CBSP_CAUSE_UNRECOGNISED_MSG ('04'O),
100 CBSP_CAUSE_MISSING_MAND_IE ('05'O),
101 CBSP_CAUSE_BSC_CAPACITY_EXCEEDED ('06'O),
102 CBSP_CAUSE_CELL_MEMORY_EXCEEDED ('07'O),
103 CBSP_CAUSE_BSC_MEMORY_EXCEEDED ('08'O),
104 CBSP_CAUSE_CB_NOT_SUPPORTED ('09'O),
105 CBSP_CAUSE_CB_NOT_OPERATIONAL ('0a'O),
106 CBSP_CAUSE_INCOMPATIBLE_DRX_PARAM ('0b'O),
107 CBSP_CAUSE_EXT_CHAN_NOT_SUPPORTED ('0c'O),
108 CBSP_CAUSE_MSG_REF_ALREADY_USED ('0d'O),
109 CBSP_CAUSE_UNSPECIFIED_ERROR ('0e'O),
110 CBSP_CAUSE_LAI_OR_LAC_NPT_VALID ('0f'O)
111} with { variant "FIELDLENGTH(8)" };
112
113type record CBSP_IE_MessageContent {
114 uint8_t user_len,
115 octetstring val
Harald Welte09538f82019-08-01 09:50:25 +0200116} with { variant (val) "FIELDLENGTH(82)"
117 variant (val) "ALIGN(left)" };
Harald Welteea260342019-08-01 09:49:38 +0200118
119/* 8.2.6 Cell List */
120type record CBSP_IE_CellList {
121 uint16_t len,
122 BIT4 spare1_4,
123 BIT4 cell_id_discr,
124 BSSMAP_FIELD_CellIdentificationList cell_id
125} with {
126 variant (len) "LENGTHTO(cell_id_discr,spare1_4,cell_id)"
127 variant (cell_id) "CROSSTAG(
128 cIl_CGI, cell_id_discr = '0000'B;
129 cIl_LAC_CI, cell_id_discr = '0001'B;
130 cIl_CI, cell_id_discr = '0010'B;
131 cIl_LAI, cell_id_discr = '0100'B;
132 cIl_LAC, cell_id_discr = '0101'B;
133 cIl_allInBSS, cell_id_discr = '0110'B;
134 )"
135};
136
137/* 8.2.10 Number of Broadcasts Completed List */
138type record CBSP_IE_NumBcastComplList {
139 uint16_t len,
140 BIT4 spare1_4,
141 BIT4 cell_id_discr,
142 CBSP_FIELD_NumBcastCompl list
143} with {
144 variant (len) "LENGTHTO(cell_id_discr,spare1_4,list)"
145 variant (list) "CROSSTAG(
146 cI_CGI, cell_id_discr = '0000'B;
147 cI_LAC_CI, cell_id_discr = '0001'B;
148 cI_CI, cell_id_discr = '0010'B;
149 cI_LAI, cell_id_discr = '0100'B;
150 cI_LAC, cell_id_discr = '0101'B;
151 cI_allInBSS, cell_id_discr = '0110'B;
152 )"
153};
154type union CBSP_FIELD_NumBcastCompl {
155 CBSP_FIELD_NumBcastCompl_CGI cI_CGI,
156 CBSP_FIELD_NumBcastCompl_LAC_CI cI_LAC_CI,
157 OCT0 cI_allInBSS,
158 CBSP_FIELD_NumBcastCompl_CI cI_CI,
159 CBSP_FIELD_NumBcastCompl_LAC cI_LAC,
160 CBSP_FIELD_NumBcastCompl_LAI cI_LAI
161};
162type record CBSP_FIELD_NumBcastCompl_CGI {
163 BSSMAP_FIELD_CellIdentification_CGI ci,
Harald Weltef42c7872022-03-28 21:28:42 +0200164 uint16_t num_bcast_compl,
Harald Welteea260342019-08-01 09:49:38 +0200165 CBSP_NumBcastInfo num_bcast_info,
166 BIT4 spare1_4
167};
168type record CBSP_FIELD_NumBcastCompl_LAC_CI {
169 BSSMAP_FIELD_CellIdentification_LAC_CI ci,
Harald Weltef42c7872022-03-28 21:28:42 +0200170 uint16_t num_bcast_compl,
Harald Welteea260342019-08-01 09:49:38 +0200171 CBSP_NumBcastInfo num_bcast_info,
172 BIT4 spare1_4
173};
174type record CBSP_FIELD_NumBcastCompl_LAI {
175 BSSMAP_FIELD_CellIdentification_LAI ci,
Harald Weltef42c7872022-03-28 21:28:42 +0200176 uint16_t num_bcast_compl,
Harald Welteea260342019-08-01 09:49:38 +0200177 CBSP_NumBcastInfo num_bcast_info,
178 BIT4 spare1_4
179};
180type record CBSP_FIELD_NumBcastCompl_CI {
181 OCT2 ci,
Harald Weltef42c7872022-03-28 21:28:42 +0200182 uint16_t num_bcast_compl,
Harald Welteea260342019-08-01 09:49:38 +0200183 CBSP_NumBcastInfo num_bcast_info,
184 BIT4 spare1_4
185};
186type record CBSP_FIELD_NumBcastCompl_LAC {
187 OCT2 lac,
Harald Weltef42c7872022-03-28 21:28:42 +0200188 uint16_t num_bcast_compl,
Harald Welteea260342019-08-01 09:49:38 +0200189 CBSP_NumBcastInfo num_bcast_info,
190 BIT4 spare1_4
191};
192type enumerated CBSP_NumBcastInfo {
193 CBSP_NUM_BCAST_INFO_VALID (0),
194 CBSP_NUM_BCAST_INFO_OVERFLOW (1),
195 CBSP_NUM_BCAST_INFO_UNKNOWN (2)
196} with { variant "FIELDLENGTH(4)" };
197
198
199/* 8.2.11 Failure List */
200type record CBSP_FailureListItem {
201 BIT4 spare1_4,
202 BIT4 cell_id_discr,
203 CBSP_FIELD_CellIdentification cell_id,
204 CBSP_Cause cause
205} with {
206 variant (cell_id) "CROSSTAG(
207 cI_CGI, cell_id_discr = '0000'B;
208 cI_LAC_CI, cell_id_discr = '0001'B;
209 cI_CI, cell_id_discr = '0010'B;
210 cI_LAI, cell_id_discr = '0100'B;
211 cI_LAC, cell_id_discr = '0101'B;
212 cI_allInBSS, cell_id_discr = '0110'B;
213 )"
214};
215type union CBSP_FIELD_CellIdentification
216{
217 BSSMAP_FIELD_CellIdentification_CGI cI_CGI,
218 BSSMAP_FIELD_CellIdentification_LAC_CI cI_LAC_CI,
219 OCT2 cI_CI,
220 BSSMAP_FIELD_CellIdentification_LAI cI_LAI,
221 OCT2 cI_LAC,
222 OCT2 cI_allInBSS
223};
224
225type record of CBSP_FailureListItem CBSP_FailureListItems;
226type record CBSP_IE_FailureList {
227 uint16_t len,
228 CBSP_FailureListItems list
229} with {
230 variant (len) "LENGTHTO(list)"
231};
232
233/* 8.2.12 RR Loading List */
234type record CBSP_IE_RrLoadingList {
235 uint16_t len,
236 BIT4 spare1_4,
237 BIT4 cell_id_discr,
238 CBSP_FIELD_RrLoadingList list
239} with {
240 variant (len) "LENGTHTO(cell_id_discr,spare1_4,list)"
241 variant (list) "CROSSTAG(
242 cI_CGI, cell_id_discr = '0000'B;
243 cI_LAC_CI, cell_id_discr = '0001'B;
244 cI_CI, cell_id_discr = '0010'B;
245 cI_LAI, cell_id_discr = '0100'B;
246 cI_LAC, cell_id_discr = '0101'B;
247 cI_allInBSS, cell_id_discr = '0110'B;
248 )"
249};
250type union CBSP_FIELD_RrLoadingList {
251 CBSP_FIELD_RrLoadingList_CGI cI_CGI,
252 CBSP_FIELD_RrLoadingList_LAC_CI cI_LAC_CI,
253 OCT0 cI_allInBSS,
254 CBSP_FIELD_RrLoadingList_CI cI_CI,
255 CBSP_FIELD_RrLoadingList_LAC cI_LAC,
256 CBSP_FIELD_RrLoadingList_LAI cI_LAI
257};
258type record CBSP_FIELD_RrLoadingList_CGI {
259 BSSMAP_FIELD_CellIdentification_CGI ci,
260 uint8_t load1,
261 uint8_t load2
262};
263type record CBSP_FIELD_RrLoadingList_LAC_CI {
264 BSSMAP_FIELD_CellIdentification_LAC_CI ci,
265 uint8_t load1,
266 uint8_t load2
267};
268type record CBSP_FIELD_RrLoadingList_LAI {
269 BSSMAP_FIELD_CellIdentification_LAI ci,
270 uint8_t load1,
271 uint8_t load2
272};
273type record CBSP_FIELD_RrLoadingList_CI {
274 OCT2 ci,
275 uint8_t load1,
276 uint8_t load2
277};
278type record CBSP_FIELD_RrLoadingList_LAC {
279 OCT2 lac,
280 uint8_t load1,
281 uint8_t load2
282};
283
284/* 8.2.15 Recovery Indication */
285type record CBSP_IE_RecoveryInd {
286 BIT4 spare1_4,
287 CBSP_RecoveryInd recovery
288};
289type enumerated CBSP_RecoveryInd {
290 CBSP_RI_DATA_AVAILABLE (0),
291 CBSP_RI_DATA_LOST (1)
292} with { variant "FIELDLENGTH(4)" };
293
294/* 8.2.24 Broadcast Message Type */
295type record CBSP_IE_BcastMsgType {
296 BIT4 spare1_4,
297 CBSP_BcastMsgType msg_type
298};
299type enumerated CBSP_BcastMsgType {
300 CBSP_BC_MSGT_CBS (0),
301 CBSP_BC_MSGT_EMERG (1)
302} with { variant "FIELDLENGTH(4)" };
303
304
305type union CBSP_IE_Body {
306 CBSP_IE_MessageContent msg_content,
307 uint16_t old_ser_nr,
308 uint16_t new_ser_nr,
309 CBSP_IE_CellList cell_list,
310 CBSP_Category category,
311 uint16_t rep_period,
312 uint16_t num_bcast_req,
313 CBSP_IE_NumBcastComplList num_bcast_compl_list,
314 CBSP_IE_FailureList failure_list,
315 CBSP_IE_RrLoadingList rr_loading_list,
316 CBSP_Cause cause,
317 uint8_t dcs,
318 CBSP_IE_RecoveryInd recovery_ind,
319 uint16_t msg_id,
320 uint8_t emerg_ind,
321 uint16_t warn_type,
322 octetstring warn_sec_info,
323 uint8_t channel_ind,
324 uint8_t num_of_pages,
325 uint8_t schedule_period,
326 uint8_t num_of_res_slots,
327 CBSP_IE_BcastMsgType bcast_msg_type,
328 uint8_t warning_period,
329 uint8_t keep_alive_rep_period
330} with {
331 variant (warn_sec_info) "FIELDLENGTH(50)"
332};
333
334type record CBSP_IE {
335 CBSP_IEI iei,
336 CBSP_IE_Body body
337} with {
338 variant (body) "CROSSTAG( msg_content, iei = CBSP_IEI_MSG_CONTENT;
339 old_ser_nr, iei = CBSP_IEI_OLD_SERIAL_NR;
340 new_ser_nr, iei = CBSP_IEI_NEW_SERIAL_NR;
341 cell_list, iei = CBSP_IEI_CELL_LIST;
342 category, iei = CBSP_IEI_CATEGORY;
343 rep_period, iei = CBSP_IEI_REP_PERIOD;
344 num_bcast_req, iei = CBSP_IEI_NUM_BCAST_REQ;
345 num_bcast_compl_list, iei = CBSP_IEI_NUM_BCAST_COMPL_LIST;
346 failure_list, iei = CBSP_IEI_FAILURE_LIST;
347 rr_loading_list, iei = CBSP_IEI_RR_LOADING_LIST;
348 cause, iei = CBSP_IEI_CAUSE;
349 dcs, iei = CBSP_IEI_DCS;
350 recovery_ind, iei = CBSP_IEI_RECOVERY_IND;
351 msg_id, iei = CBSP_IEI_MSG_ID;
352 emerg_ind, iei = CBSP_IEI_EMERG_IND;
353 warn_type, iei = CBSP_IEI_WARN_TYPE;
354 warn_sec_info, iei = CBSP_IEI_WARN_SEC_INFO;
355 channel_ind, iei = CBSP_IEI_CHANNEL_IND;
356 num_of_pages, iei = CBSP_IEI_NUM_OF_PAGES;
357 schedule_period, iei = CBSP_IEI_SCHEDULE_PERIOD;
358 num_of_res_slots, iei = CBSP_IEI_NUM_OF_RES_SLOTS;
359 bcast_msg_type, iei = CBSP_IEI_BCAST_MSG_TYPE;
360 warning_period, iei = CBSP_IEI_WARNING_PERIOD;
361 keep_alive_rep_period, iei = CBSP_IEI_KEEP_ALIVE_REP_PERIOD
362 )"
363};
364
365type set of CBSP_IE CBSP_IEs;
366
367type record CBSP_PDU {
368 CBSP_MessageType msg_type,
369 uint24_t len,
370 CBSP_IEs ies
371} with {
372 variant (len) "LENGTHTO(ies)"
373};
374
375external function enc_CBSP_PDU(in CBSP_PDU msg) return octetstring
376 with { extension "prototype(convert) encode(RAW)" };
377
378external function dec_CBSP_PDU(in octetstring msg) return CBSP_PDU
379 with { extension "prototype(convert) decode(RAW)" };
380
Harald Welte08332302019-08-01 09:54:40 +0200381/* convert from warning period encoding to seconds */
382function f_cbsp_period2s(uint8_t period) return integer
383{
384 if (period == 0) {
385 return -1; /* infinite */
386 } else if (period <= 10) {
387 return period;
388 } else if (period <= 20) {
389 return 10 + (period - 10)*2;
390 } else if (period <= 38) {
391 return 30 + (period - 20)*5;
392 } else if (period <= 86) {
393 return 120 + (period - 38)*10;
394 } else if (period <= 186) {
395 return 600 + (period - 86)*30;
396 } else {
397 return 0;
398 }
399}
Harald Welteea260342019-08-01 09:49:38 +0200400
401} with { encode "RAW"; variant "FIELDORDER(msb)" }