blob: fe06150aa418d96d001613a3b9c0294a7e2db79a [file] [log] [blame]
Harald Welteea260342019-08-01 09:49:38 +02001module CBSP_Templates {
2
3import from Osmocom_Types all;
4import from BSSAP_Types all;
5import from CBSP_Types all;
6
7/* TODO: receive templates must match IEs in any arbitrary order */
8
9/* For some reason the TTCN-3 RAW codec cannot automatically figure out the IEI
10 * that it needs to set for a given union-choice (body). So we have to explicitly
11 * specify the IEI by the caller :( */
12template (value) CBSP_IE ts_CBSP_IE(CBSP_IEI iei, template (value) CBSP_IE_Body body) := {
13 iei := iei,
14 body := body
15}
16
17template CBSP_IE tr_CBSP_IE(template CBSP_IE_Body body) := {
18 iei := ?,
19 body := body
20}
21
22
23template (value) CBSP_IE ts_CbspMsgId(template (value) uint16_t val) :=
24 ts_CBSP_IE(CBSP_IEI_MSG_ID, {msg_id := val});
25template CBSP_IE tr_CbspMsgId(template uint16_t val := ?) :=
26 tr_CBSP_IE({msg_id := val});
27
28template (value) CBSP_IE ts_NewSerNo(template (value) uint16_t val) :=
29 ts_CBSP_IE(CBSP_IEI_NEW_SERIAL_NR, {new_ser_nr := val});
30template CBSP_IE tr_NewSerNo(template uint16_t val := ?) :=
31 tr_CBSP_IE({new_ser_nr := val});
32
33template (value) CBSP_IE ts_OldSerNo(template (value) uint16_t val) :=
34 ts_CBSP_IE(CBSP_IEI_OLD_SERIAL_NR, {old_ser_nr := val});
35template CBSP_IE tr_OldSerNo(template uint16_t val := ?) :=
36 tr_CBSP_IE({old_ser_nr := val});
37
38template (value) CBSP_IE ts_CbspKARepPeriod(template (value) uint8_t rep_per) :=
39 ts_CBSP_IE(CBSP_IEI_KEEP_ALIVE_REP_PERIOD, {keep_alive_rep_period := rep_per});
40template CBSP_IE tr_CbspKARepPeriod(template uint8_t rep_per := ?) :=
41 tr_CBSP_IE({keep_alive_rep_period := rep_per});
42
43function ts_CbspChannelInd(template (omit) uint8_t val) return template (omit) CBSP_IE {
44 var template (omit) CBSP_IE ie;
45 if (istemplatekind(val, "omit")) {
46 ie := omit;
47 } else {
48 ie := ts_CBSP_IE(CBSP_IEI_CHANNEL_IND, {channel_ind := val});
49 }
50 return ie;
51}
52function tr_CbspChannelInd(template uint8_t val := ?) return template CBSP_IE {
53 var template CBSP_IE ie;
54 if (istemplatekind(val, "omit")) {
55 ie := omit;
56 } else if (istemplatekind(val, "*")) {
57 ie := tr_CBSP_IE({channel_ind := ?}) ifpresent;
58 } else {
59 ie := tr_CBSP_IE({channel_ind := val});
60 }
61 return ie;
62}
63
64template (value) CBSP_IE ts_CbspCause(template (value) CBSP_Cause c) :=
65 ts_CBSP_IE(CBSP_IEI_CAUSE, {cause := c});
66template CBSP_IE tr_CbspCause(template CBSP_Cause c := ?) :=
67 tr_CBSP_IE({cause := c});
68
69template (value) CBSP_IE ts_CbspCellList(template (value) BSSMAP_FIELD_CellIdentificationList list) :=
70 ts_CBSP_IE(CBSP_IEI_CELL_LIST, {
71 cell_list := {
72 len := 0,
73 spare1_4 := '0000'B,
74 cell_id_discr := '0000'B,
75 cell_id := list
76 }});
77template CBSP_IE tr_CbspCellList(template BSSMAP_FIELD_CellIdentificationList list := ?) :=
78 tr_CBSP_IE({
79 cell_list := {
80 len := ?,
81 spare1_4 := ?,
82 cell_id_discr := ?,
83 cell_id := list
84 }});
85
86template (value) CBSP_IE ts_CbspCategory(template (value) CBSP_Category cat) :=
87 ts_CBSP_IE(CBSP_IEI_CATEGORY, {category := cat});
88template CBSP_IE tr_CbspCategory(template CBSP_Category cat := ?) :=
89 tr_CBSP_IE({category := cat});
90
91template (value) CBSP_IE ts_CbspRepetitionPeriod(template (value) uint16_t per) :=
92 ts_CBSP_IE(CBSP_IEI_REP_PERIOD, {rep_period := per});
93template CBSP_IE tr_CbspRepetitionPeriod(template uint16_t per := ?) :=
94 tr_CBSP_IE({rep_period := per});
95
96template (value) CBSP_IE ts_CbspNumBcastReq(template (value) uint16_t num) :=
97 ts_CBSP_IE(CBSP_IEI_NUM_BCAST_REQ, {num_bcast_req := num});
98template CBSP_IE tr_CbspNumBcastReq(template uint16_t num := ?) :=
99 tr_CBSP_IE({num_bcast_req := num});
100
101template (value) CBSP_IE ts_CbspNumPages(template (value) uint8_t num) :=
102 ts_CBSP_IE(CBSP_IEI_NUM_OF_PAGES, {num_of_pages := num});
103template CBSP_IE tr_CbspNumPages(template uint16_t num := ?) :=
104 tr_CBSP_IE({num_of_pages := num});
105
106template (value) CBSP_IE ts_EmergencyInd(template (value) uint8_t val) :=
107 ts_CBSP_IE(CBSP_IEI_EMERG_IND, {emerg_ind := val});
108template CBSP_IE tr_EmergencyInd(template uint8_t val := ?) :=
109 tr_CBSP_IE({emerg_ind := val});
110
111template (value) CBSP_IE ts_WarningType(template (value) uint16_t val) :=
112 ts_CBSP_IE(CBSP_IEI_WARN_TYPE, {warn_type := val});
113template CBSP_IE tr_WarningType(template uint16_t val) :=
114 tr_CBSP_IE({warn_type := val});
115
116template (value) CBSP_IE ts_WarnSecInfo(template (value) octetstring payl := ''O) :=
117 ts_CBSP_IE(CBSP_IEI_WARN_SEC_INFO, {warn_sec_info := payl});
118template CBSP_IE tr_WarnSecInfo(template octetstring payl := ?) :=
119 tr_CBSP_IE({warn_sec_info := payl});
120
121template (value) CBSP_IE ts_WarningPeriod(template (value) uint8_t val) :=
122 ts_CBSP_IE(CBSP_IEI_WARNING_PERIOD, {warning_period := val});
123template CBSP_IE tr_WarningPeriod(template uint8_t val := ?) :=
124 tr_CBSP_IE({warning_period := val});
125
126template (value) CBSP_IE ts_CbspFailList(template (value) CBSP_FailureListItems items) :=
127 ts_CBSP_IE(CBSP_IEI_FAILURE_LIST, {failure_list := {
128 len := 0,
129 list := items
130 }});
131template CBSP_IE tr_CbspFailList(template CBSP_FailureListItems items := ?) :=
132 tr_CBSP_IE({failure_list := {
Harald Welte09538f82019-08-01 09:50:25 +0200133 len := ?,
Harald Welteea260342019-08-01 09:49:38 +0200134 list := items
135 }});
136
137template (value) CBSP_IE ts_CbspNumComplList(template (value) CBSP_IE_NumBcastComplList list) :=
138 ts_CBSP_IE(CBSP_IEI_NUM_BCAST_COMPL_LIST, {num_bcast_compl_list := list});
139template CBSP_IE tr_CbspNumComplList(template CBSP_IE_NumBcastComplList list := ?) :=
140 tr_CBSP_IE({num_bcast_compl_list := list});
141
142template (value) CBSP_IE ts_CbspBcastMsgType(template (value) CBSP_BcastMsgType bi) :=
143 ts_CBSP_IE(CBSP_IEI_BCAST_MSG_TYPE, {bcast_msg_type := {
144 spare1_4 := '0000'B,
145 msg_type := bi
146 }});
147template CBSP_IE tr_CbspBcastMsgType(template CBSP_BcastMsgType bi := ?) :=
148 tr_CBSP_IE({bcast_msg_type := {
149 spare1_4 := ?,
150 msg_type := bi
151 }});
152
153template (value) CBSP_IE ts_CbspRecoveryInd(template (value) CBSP_RecoveryInd ri) :=
154 ts_CBSP_IE(CBSP_IEI_RECOVERY_IND, {recovery_ind := {
155 spare1_4 := '0000'B,
156 recovery := ri
157 }});
158template CBSP_IE tr_CbspRecoveryInd(template CBSP_RecoveryInd ri) :=
159 tr_CBSP_IE({recovery_ind := {
160 spare1_4 := ?,
161 recovery := ri
162 }});
163
164template (value) CBSP_IE ts_CbspMsgContent(template (value) octetstring payload, uint8_t user_len) :=
165 ts_CBSP_IE(CBSP_IEI_MSG_CONTENT, {msg_content := {
166 user_len := user_len,
167 val := payload
168 }});
169template CBSP_IE tr_CbspMsgContent(template octetstring payload := ?, template uint8_t user_len := ?) :=
170 tr_CBSP_IE({msg_content := {
171 user_len := user_len,
172 val := payload
173 }});
174
175template (value) CBSP_IE ts_CbspDCS(template (value) uint8_t dcs) :=
176 ts_CBSP_IE(CBSP_IEI_DCS, {dcs := dcs});
177template CBSP_IE tr_CbspDCS(template uint8_t dcs := ?) :=
178 tr_CBSP_IE({dcs := dcs});
179
180
181template (value) CBSP_PDU ts_CBSP(CBSP_MessageType msg_type, template (value) CBSP_IEs ies) := {
182 msg_type := msg_type,
183 len := 0, /* overwritten */
184 ies := ies
185}
186template CBSP_PDU tr_CBSP(template CBSP_MessageType msg_type := ?, template CBSP_IEs ies := *) := {
187 msg_type := msg_type,
188 len := ?,
189 ies := ies
190}
191
192
193
194/* 8.1.3.1 WRITE REPLACE */
195function ts_CBSP_WRITE_CBS(template (value) uint16_t msg_id,
196 template (value) uint16_t new_ser_nr,
197 template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
198 template (value) uint8_t channel_ind,
199 template (value) CBSP_Category category,
200 template (value) uint16_t rep_period,
201 template (value) uint16_t num_bcast_req,
202 template (value) uint8_t dcs,
203 template (value) CBSP_IEs content) return template (value) CBSP_PDU {
204 var template (value) CBSP_IEs ies := {
205 ts_CbspMsgId(msg_id),
206 ts_NewSerNo(new_ser_nr),
207 ts_CbspCellList(cell_list),
208 ts_CbspChannelInd(channel_ind),
209 ts_CbspCategory(category),
210 ts_CbspRepetitionPeriod(rep_period),
211 ts_CbspNumBcastReq(num_bcast_req),
212 ts_CbspDCS(dcs),
213 ts_CbspNumPages(lengthof(content))
214 };
215 return ts_CBSP(CBSP_MSGT_WRITE_REPLACE, valueof(ies) & valueof(content));
216}
217template CBSP_PDU tr_CBSP_WRITE_CBS(template uint16_t msg_id := ?, template uint16_t new_ser_nr := ?,
218 template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
219 template uint8_t channel_ind := ?,
220 template CBSP_Category category := ?,
221 template uint16_t rep_period := ?,
222 template uint16_t num_bcast_req := ?,
223 template uint8_t dcs := ?,
224 template CBSP_IEs content := ?
225 ) :=
226 tr_CBSP(CBSP_MSGT_WRITE_REPLACE, ({
227 tr_CbspMsgId(msg_id),
228 tr_NewSerNo(new_ser_nr),
229 tr_CbspCellList(cell_list),
230 tr_CbspChannelInd(channel_ind),
231 tr_CbspCategory(category),
232 tr_CbspRepetitionPeriod(rep_period),
233 tr_CbspNumBcastReq(num_bcast_req),
234 tr_CbspDCS(dcs),
235 tr_CbspNumPages(lengthof(content)), all from content }));
236
237
238function ts_CBSP_REPLACE_CBS(uint16_t msg_id, uint16_t new_ser_nr, uint16_t old_ser_nr,
239 template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
240 template (value) uint8_t channel_ind,
241 template (value) CBSP_Category category,
242 template (value) uint16_t rep_period,
243 template (value) uint16_t num_bcast_req,
244 template (value) uint8_t dcs,
245 template (value) CBSP_IEs content) return template (value) CBSP_PDU {
246 var template (value) CBSP_IEs ies := {
247 ts_CbspMsgId(msg_id),
248 ts_NewSerNo(new_ser_nr),
249 ts_OldSerNo(old_ser_nr),
250 ts_CbspCellList(cell_list),
251 ts_CbspChannelInd(channel_ind),
252 ts_CbspCategory(category),
253 ts_CbspRepetitionPeriod(rep_period),
254 ts_CbspNumBcastReq(num_bcast_req),
255 ts_CbspDCS(dcs),
256 ts_CbspNumPages(lengthof(content))
257 };
258 return ts_CBSP(CBSP_MSGT_WRITE_REPLACE, valueof(ies) & valueof(content));
259}
260template CBSP_PDU tr_CBSP_REPLACE_CBS(template uint16_t msg_id := ?, template uint16_t new_ser_nr := ?,
261 template uint16_t old_ser_nr := ?,
262 template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
263 template uint8_t channel_ind := ?,
264 template CBSP_Category category := ?,
265 template uint16_t rep_period := ?,
266 template uint16_t num_bcast_req := ?,
267 template uint8_t dcs := ?,
268 template CBSP_IEs content := ?
269 ) :=
270 tr_CBSP(CBSP_MSGT_WRITE_REPLACE, ({
271 tr_CbspMsgId(msg_id),
272 tr_NewSerNo(new_ser_nr),
273 tr_OldSerNo(old_ser_nr),
274 tr_CbspCellList(cell_list),
275 tr_CbspChannelInd(channel_ind),
276 tr_CbspCategory(category),
277 tr_CbspRepetitionPeriod(rep_period),
278 tr_CbspNumBcastReq(num_bcast_req),
279 tr_CbspDCS(dcs),
280 tr_CbspNumPages(lengthof(content)), all from content }));
281
282template (value) CBSP_PDU ts_CBSP_WRITE_EMERG(uint16_t msg_id, uint16_t new_ser_nr,
283 template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
284 template (value) uint8_t emerg_ind,
285 template (value) uint16_t warn_type,
Harald Welteea260342019-08-01 09:49:38 +0200286 template (value) uint8_t warn_per
287 ) :=
288 ts_CBSP(CBSP_MSGT_WRITE_REPLACE, {
289 ts_CbspMsgId(msg_id),
290 ts_NewSerNo(new_ser_nr),
291 ts_CbspCellList(cell_list),
292 ts_EmergencyInd(emerg_ind),
293 ts_WarningType(warn_type),
294 ts_WarnSecInfo,
295 ts_WarningPeriod(warn_per) });
296template CBSP_PDU tr_CBSP_WRITE_EMERG(template uint16_t msg_id := ?, template uint16_t new_ser_nr := ?,
297 template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
298 template uint8_t emerg_ind := ?,
299 template uint16_t warn_type := ?,
300 template uint16_t num_bcast_req := ?,
301 template uint8_t warn_per := ?
302 ) :=
303 tr_CBSP(CBSP_MSGT_WRITE_REPLACE, {
304 tr_CbspMsgId(msg_id),
305 tr_NewSerNo(new_ser_nr),
306 tr_CbspCellList(cell_list),
307 tr_EmergencyInd(emerg_ind),
308 tr_WarningType(warn_type),
309 tr_WarnSecInfo,
310 tr_WarningPeriod(warn_per) });
311
312
313template (value) CBSP_PDU ts_CBSP_REPLACE_EMERG(uint16_t msg_id, uint16_t new_ser_nr, uint16_t old_ser_nr,
314 template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
315 template (value) uint8_t emerg_ind,
316 template (value) uint16_t warn_type,
317 template (value) uint16_t num_bcast_req,
318 template (value) uint8_t warn_per
319 ) :=
320 ts_CBSP(CBSP_MSGT_WRITE_REPLACE, {
321 ts_CbspMsgId(msg_id),
322 ts_NewSerNo(new_ser_nr),
323 ts_OldSerNo(old_ser_nr),
324 ts_CbspCellList(cell_list),
325 ts_EmergencyInd(emerg_ind),
326 ts_WarningType(warn_type),
327 ts_WarnSecInfo,
328 ts_WarningPeriod(warn_per) });
329template CBSP_PDU tr_CBSP_REPLACE_EMERG(template uint16_t msg_id := ?, template uint16_t new_ser_nr := ?,
330 template uint16_t old_ser_nr := ?,
331 template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
332 template uint8_t emerg_ind := ?,
333 template uint16_t warn_type := ?,
334 template uint16_t num_bcast_req := ?,
335 template uint8_t warn_per := ?
336 ) :=
337 tr_CBSP(CBSP_MSGT_WRITE_REPLACE, {
338 tr_CbspMsgId(msg_id),
339 tr_NewSerNo(new_ser_nr),
340 tr_OldSerNo(old_ser_nr),
341 tr_CbspCellList(cell_list),
342 tr_EmergencyInd(emerg_ind),
343 tr_WarningType(warn_type),
344 tr_WarnSecInfo,
345 tr_WarningPeriod(warn_per) });
346
347/* 8.1.3.2 WRITE-REPLACE COMPLETE */
348function ts_CBSP_WRITE_CBS_COMPL(uint16_t msg_id, uint16_t new_ser_nr,
349 template (omit) BSSMAP_FIELD_CellIdentificationList cell_list,
350 template (value) uint8_t channel_ind)
351return template (value) CBSP_PDU {
352 var template (value) CBSP_IEs ies := {
353 ts_CbspMsgId(msg_id),
354 ts_NewSerNo(new_ser_nr)
355 };
356 if (not istemplatekind(cell_list, "omit")) {
357 ies[lengthof(ies)] := ts_CbspCellList(cell_list);
358 }
359 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
360 return ts_CBSP(CBSP_MSGT_WRITE_REPLACE_COMPL, ies);
361}
362function tr_CBSP_WRITE_CBS_COMPL(template uint16_t msg_id, template uint16_t new_ser_nr,
363 template BSSMAP_FIELD_CellIdentificationList cell_list,
364 template uint8_t channel_ind)
365return template CBSP_PDU {
366 var template CBSP_IEs ies := {
367 tr_CbspMsgId(msg_id),
368 tr_NewSerNo(new_ser_nr)
369 };
370 if (istemplatekind(cell_list, "*")) {
371 ies[lengthof(ies)] := tr_CbspCellList ifpresent;
372 } else if (istemplatekind(cell_list, "?")) {
373 ies[lengthof(ies)] := tr_CbspCellList(?);
374 } else if (not istemplatekind(cell_list, "omit")) {
375 ies[lengthof(ies)] := tr_CbspCellList(cell_list);
376 }
Harald Welte25a60752019-09-06 23:08:23 +0200377 if (not istemplatekind(channel_ind, "omit")) {
378 ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
379 }
Harald Welteea260342019-08-01 09:49:38 +0200380 return tr_CBSP(CBSP_MSGT_WRITE_REPLACE_COMPL, ies);
381}
382
383
384function ts_CBSP_REPLACE_CBS_COMPL(uint16_t msg_id, uint16_t new_ser_nr, uint16_t old_ser_nr,
385 template (value) CBSP_IE_NumBcastComplList compl_list,
386 template (omit) BSSMAP_FIELD_CellIdentificationList cell_list,
387 template (value) uint8_t channel_ind)
388return template (value) CBSP_PDU {
389 var template (value) CBSP_IEs ies := {
390 ts_CbspMsgId(msg_id),
391 ts_NewSerNo(new_ser_nr),
392 ts_OldSerNo(old_ser_nr),
393 ts_CbspNumComplList(compl_list)
394 };
395 if (not istemplatekind(cell_list, "omit")) {
396 ies[lengthof(ies)] := ts_CbspCellList(cell_list);
397 }
398 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
399 return ts_CBSP(CBSP_MSGT_WRITE_REPLACE_COMPL, ies);
400}
401function tr_CBSP_REPLACE_CBS_COMPL(template uint16_t msg_id, template uint16_t new_ser_nr,
402 template uint16_t old_ser_nr,
403 template CBSP_IE_NumBcastComplList compl_list,
404 template BSSMAP_FIELD_CellIdentificationList cell_list,
405 template uint8_t channel_ind)
406return template CBSP_PDU {
407 var template CBSP_IEs ies := {
408 tr_CbspMsgId(msg_id),
409 tr_NewSerNo(new_ser_nr),
410 tr_OldSerNo(old_ser_nr),
411 tr_CbspNumComplList(compl_list)
412 };
413 if (istemplatekind(cell_list, "*")) {
414 ies[lengthof(ies)] := tr_CbspCellList ifpresent;
415 } else if (istemplatekind(cell_list, "?")) {
416 ies[lengthof(ies)] := tr_CbspCellList(?);
417 } else if (not istemplatekind(cell_list, "omit")) {
418 ies[lengthof(ies)] := tr_CbspCellList(cell_list);
419 }
Harald Welte25a60752019-09-06 23:08:23 +0200420 if (not istemplatekind(channel_ind, "omit")) {
421 ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
422 }
Harald Welteea260342019-08-01 09:49:38 +0200423 return tr_CBSP(CBSP_MSGT_WRITE_REPLACE_COMPL, ies);
424}
425
426
427/* 8.1.3.3 WRITE-REPLACE FAILURE */
428function ts_CBSP_WRITE_CBS_FAIL(uint16_t msg_id, uint16_t new_ser_nr,
429 template (value) CBSP_FailureListItems fail_list,
430 template (omit) CBSP_IE_NumBcastComplList compl_list,
431 template (omit) BSSMAP_FIELD_CellIdentificationList cell_list,
432 template (value) uint8_t channel_ind)
433return template (value) CBSP_PDU {
434 var template (value) CBSP_IEs ies := {
435 ts_CbspMsgId(msg_id),
436 ts_NewSerNo(new_ser_nr),
437 ts_CbspFailList(fail_list)
438 };
439 if (not istemplatekind(compl_list, "omit")) {
440 ies[lengthof(ies)] := ts_CbspNumComplList(compl_list);
441 }
442 if (not istemplatekind(cell_list, "omit")) {
443 ies[lengthof(ies)] := ts_CbspCellList(cell_list);
444 }
445 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
446 return ts_CBSP(CBSP_MSGT_WRITE_REPLACE_FAIL, ies);
447}
448function tr_CBSP_WRITE_CBS_FAIL(template uint16_t msg_id, template uint16_t new_ser_nr,
449 template CBSP_FailureListItems fail_list,
450 template CBSP_IE_NumBcastComplList compl_list,
451 template BSSMAP_FIELD_CellIdentificationList cell_list,
452 template uint8_t channel_ind)
453return template CBSP_PDU {
454 var template CBSP_IEs ies := {
455 tr_CbspMsgId(msg_id),
456 tr_NewSerNo(new_ser_nr),
457 tr_CbspFailList(fail_list)
458 };
459 if (istemplatekind(compl_list, "*")) {
Harald Welteb5223232019-09-05 11:13:56 +0200460 //ies[lengthof(ies)] := tr_CbspNumComplList ifpresent;
Harald Welteea260342019-08-01 09:49:38 +0200461 } else if (istemplatekind(compl_list, "?")) {
462 ies[lengthof(ies)] := tr_CbspNumComplList(?);
463 } else if (not istemplatekind(compl_list, "omit")) {
464 ies[lengthof(ies)] := tr_CbspNumComplList(compl_list);
465 }
466 if (istemplatekind(cell_list, "*")) {
467 ies[lengthof(ies)] := tr_CbspCellList ifpresent;
468 } else if (istemplatekind(cell_list, "?")) {
469 ies[lengthof(ies)] := tr_CbspCellList(?);
470 } else if (not istemplatekind(cell_list, "omit")) {
471 ies[lengthof(ies)] := tr_CbspCellList(cell_list);
472 }
Harald Welte25a60752019-09-06 23:08:23 +0200473 if (not istemplatekind(channel_ind, "omit")) {
474 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
475 }
Harald Welteea260342019-08-01 09:49:38 +0200476 return tr_CBSP(CBSP_MSGT_WRITE_REPLACE_FAIL, ies);
477}
478
479
480function ts_CBSP_REPLACE_CBS_FAIL(uint16_t msg_id, uint16_t new_ser_nr, uint16_t old_ser_nr,
481 template (value) CBSP_FailureListItems fail_list,
482 template (omit) CBSP_IE_NumBcastComplList compl_list,
483 template (omit) BSSMAP_FIELD_CellIdentificationList cell_list,
484 template (value) uint8_t channel_ind)
485return template (value) CBSP_PDU {
486 var template (value) CBSP_IEs ies := {
487 ts_CbspMsgId(msg_id),
488 ts_NewSerNo(new_ser_nr),
489 ts_OldSerNo(old_ser_nr),
490 ts_CbspFailList(fail_list)
491 };
492 if (not istemplatekind(compl_list, "omit")) {
493 ies[lengthof(ies)] := ts_CbspNumComplList(compl_list);
494 }
495 if (not istemplatekind(cell_list, "omit")) {
496 ies[lengthof(ies)] := ts_CbspCellList(cell_list);
497 }
498 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
499 return ts_CBSP(CBSP_MSGT_WRITE_REPLACE_FAIL, ies);
500}
501function tr_CBSP_REPLACE_CBS_FAIL(template uint16_t msg_id, template uint16_t new_ser_nr,
502 template uint16_t old_ser_nr,
503 template CBSP_FailureListItems fail_list,
504 template CBSP_IE_NumBcastComplList compl_list,
505 template BSSMAP_FIELD_CellIdentificationList cell_list,
506 template uint8_t channel_ind)
507return template CBSP_PDU {
508 var template CBSP_IEs ies := {
509 tr_CbspMsgId(msg_id),
510 tr_NewSerNo(new_ser_nr),
511 tr_OldSerNo(old_ser_nr),
512 tr_CbspFailList(fail_list)
513 };
514 if (istemplatekind(compl_list, "*")) {
Harald Welteb5223232019-09-05 11:13:56 +0200515 //ies[lengthof(ies)] := tr_CbspCellList ifpresent;
Harald Welteea260342019-08-01 09:49:38 +0200516 } else if (istemplatekind(compl_list, "?")) {
517 ies[lengthof(ies)] := tr_CbspNumComplList(?);
518 } else if (not istemplatekind(compl_list, "omit")) {
519 ies[lengthof(ies)] := tr_CbspNumComplList(compl_list);
520 }
521 if (istemplatekind(cell_list, "*")) {
Harald Welteb5223232019-09-05 11:13:56 +0200522 //ies[lengthof(ies)] := tr_CbspCellList ifpresent;
Harald Welteea260342019-08-01 09:49:38 +0200523 } else if (istemplatekind(cell_list, "?")) {
524 ies[lengthof(ies)] := tr_CbspCellList(?);
525 } else if (not istemplatekind(cell_list, "omit")) {
526 ies[lengthof(ies)] := tr_CbspCellList(cell_list);
527 }
528 ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
529 return tr_CBSP(CBSP_MSGT_WRITE_REPLACE_FAIL, ies);
530}
531
532/* 8.1.3.4 KILL */
533template (value) CBSP_PDU ts_CBSP_KILL(template (value) uint16_t msg_id,
534 template (value) uint16_t old_ser_nr,
535 template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
536 template (omit) uint8_t channel_ind) :=
537 ts_CBSP(CBSP_MSGT_KILL, {
538 ts_CbspMsgId(msg_id),
539 ts_OldSerNo(old_ser_nr),
540 ts_CbspCellList(cell_list),
541 ts_CbspChannelInd(channel_ind)});
542template CBSP_PDU tr_CBSP_KILL(template uint16_t msg_id := ?, template uint16_t old_ser_nr := ?,
543 template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
544 template uint8_t channel_ind := ?) :=
545 tr_CBSP(CBSP_MSGT_KILL, {
546 tr_CbspMsgId(msg_id),
547 tr_OldSerNo(old_ser_nr),
548 tr_CbspCellList(cell_list),
549 tr_CbspChannelInd(channel_ind) });
550
551/* 8.1.3.5 KILL COMPLETE */
552function ts_CBSP_KILL_COMPL(template (value) uint16_t msg_id, template (value) uint16_t old_ser_nr,
553 template (omit) CBSP_IE_NumBcastComplList compl_list,
554 template (omit) BSSMAP_FIELD_CellIdentificationList cell_list,
555 template (omit) uint8_t channel_ind)
556return template (value) CBSP_PDU {
557 var template (value) CBSP_IEs ies := {
558 ts_CbspMsgId(msg_id),
559 ts_OldSerNo(old_ser_nr)
560 };
561 if (not istemplatekind(compl_list, "omit")) {
562 ies[lengthof(ies)] := ts_CbspNumComplList(compl_list);
563 }
564 if (not istemplatekind(cell_list, "omit")) {
565 ies[lengthof(ies)] := ts_CbspCellList(cell_list);
566 }
567 if (not istemplatekind(channel_ind, "omit")) {
568 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
569 }
570 return ts_CBSP(CBSP_MSGT_KILL_COMPL, ies);
571}
572function tr_CBSP_KILL_COMPL(template uint16_t msg_id := ?, template uint16_t old_ser_nr := ?,
573 template CBSP_IE_NumBcastComplList compl_list := ?,
574 template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
575 template uint8_t channel_ind)
576return template CBSP_PDU {
577 var template CBSP_IEs ies := {
578 tr_CbspMsgId(msg_id),
579 tr_OldSerNo(old_ser_nr)
580 };
581 if (istemplatekind(compl_list, "*")) {
582 ies[lengthof(ies)] := *;
583 } else if (not istemplatekind(compl_list, "omit")) {
584 ies[lengthof(ies)] := tr_CbspNumComplList(compl_list);
585 }
586 if (istemplatekind(cell_list, "*")) {
587 ies[lengthof(ies)] := *;
588 } else if (not istemplatekind(cell_list, "omit")) {
589 ies[lengthof(ies)] := tr_CbspCellList(cell_list);
590 }
591 if (istemplatekind(channel_ind, "*")) {
592 ies[lengthof(ies)] := *;
593 } else if (not istemplatekind(channel_ind, "omit")) {
594 ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
595 }
596 return tr_CBSP(CBSP_MSGT_KILL_COMPL, ies);
597}
598
599/* 8.1.3.6 KILL FAILURE */
600function ts_CBSP_KILL_FAIL(template (value) uint16_t msg_id, template (value) uint16_t old_ser_nr,
601 template (value) CBSP_FailureListItems fail_list,
602 template (omit) CBSP_IE_NumBcastComplList compl_list,
603 template (omit) BSSMAP_FIELD_CellIdentificationList cell_list,
604 template (omit) uint8_t channel_ind)
605return template (value) CBSP_PDU {
606 var template (value) CBSP_IEs ies := {
607 ts_CbspMsgId(msg_id),
608 ts_OldSerNo(old_ser_nr),
609 ts_CbspFailList(fail_list)
610 };
611 if (not istemplatekind(compl_list, "omit")) {
612 ies[lengthof(ies)] := ts_CbspNumComplList(compl_list);
613 }
614 if (not istemplatekind(cell_list, "omit")) {
615 ies[lengthof(ies)] := ts_CbspCellList(cell_list);
616 }
617 if (not istemplatekind(channel_ind, "omit")) {
618 ies[lengthof(ies)] := ts_CbspChannelInd(channel_ind);
619 }
620 return ts_CBSP(CBSP_MSGT_KILL_FAIL, ies);
621}
622function tr_CBSP_KILL_FAIL(template uint16_t msg_id := ?, template uint16_t old_ser_nr := ?,
623 template CBSP_FailureListItems fail_list := ?,
624 template CBSP_IE_NumBcastComplList compl_list := *,
625 template BSSMAP_FIELD_CellIdentificationList cell_list := *,
626 template uint8_t channel_ind := *)
627return template CBSP_PDU {
628 var template CBSP_IEs ies := {
629 tr_CbspMsgId(msg_id),
630 tr_OldSerNo(old_ser_nr),
631 tr_CbspFailList(fail_list)
632 };
633 if (istemplatekind(compl_list, "*")) {
Harald Welteb5223232019-09-05 11:13:56 +0200634 //ies[lengthof(ies)] := tr_CbspNumComplList ifpresent;
Harald Welteea260342019-08-01 09:49:38 +0200635 } else if (not istemplatekind(compl_list, "omit")) {
636 ies[lengthof(ies)] := tr_CbspNumComplList(compl_list);
637 }
Harald Welte885de1c2020-04-20 17:50:22 +0200638 if (istemplatekind(cell_list, "*")) {
Harald Welteb5223232019-09-05 11:13:56 +0200639 //ies[lengthof(ies)] := tr_CbspCellList ifpresent;
Harald Welteea260342019-08-01 09:49:38 +0200640 } else if (not istemplatekind(cell_list, "omit")) {
641 ies[lengthof(ies)] := tr_CbspCellList(cell_list);
642 }
643 if (istemplatekind(channel_ind, "*")) {
644 ies[lengthof(ies)] := tr_CbspChannelInd(?) ifpresent;
645 } else if (not istemplatekind(channel_ind, "omit")) {
646 ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
647 }
648 return tr_CBSP(CBSP_MSGT_KILL_FAIL, ies);
649}
650
651
652/* 8.1.3.16 RESET */
653template (value) CBSP_PDU ts_CBSP_RESET(template (value) BSSMAP_FIELD_CellIdentificationList cell_list) :=
654 ts_CBSP(CBSP_MSGT_RESET, {
655 ts_CbspCellList(cell_list)
656 });
657template CBSP_PDU tr_CBSP_RESET(template BSSMAP_FIELD_CellIdentificationList cell_list := ?) :=
658 tr_CBSP(CBSP_MSGT_RESET, {
659 tr_CbspCellList(cell_list)
660 });
661
662/* 8.1.3.17 RESET COMPLETE */
663template (value) CBSP_PDU ts_CBSP_RESET_COMPL(template (value) BSSMAP_FIELD_CellIdentificationList cell_list) :=
664 ts_CBSP(CBSP_MSGT_RESET_COMPL, {
665 ts_CbspCellList(cell_list)
666 });
667template CBSP_PDU tr_CBSP_RESET_COMPL(template BSSMAP_FIELD_CellIdentificationList cell_list := ?) :=
668 tr_CBSP(CBSP_MSGT_RESET_COMPL, {
669 tr_CbspCellList(cell_list)
670 });
671
672/* 8.1.3.18 RESET FAILURE */
673template (value) CBSP_PDU ts_CBSP_RESET_FAIL(template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
674 template (value) CBSP_FailureListItems fail_items) :=
675 ts_CBSP(CBSP_MSGT_RESET_FAIL, {
676 ts_CbspFailList(fail_items),
677 ts_CbspCellList(cell_list)
678 });
679
680template CBSP_PDU tr_CBSP_RESET_FAIL(template BSSMAP_FIELD_CellIdentificationList cell_list,
681 template CBSP_FailureListItems fail_items) :=
682 tr_CBSP(CBSP_MSGT_RESET_FAIL, {
683 tr_CbspFailList(fail_items),
684 tr_CbspCellList(cell_list)
685 });
686
687/* 8.1.3.18a KEEP-ALIVE */
688template (value) CBSP_PDU ts_CBSP_KEEP_ALIVE(uint8_t rep_period) :=
689 ts_CBSP(CBSP_MSGT_KEEP_ALIVE, {ts_CbspKARepPeriod(rep_period)});
690template CBSP_PDU tr_CBSP_KEEP_ALIVE(template uint8_t rep_period := ?) :=
691 tr_CBSP(CBSP_MSGT_KEEP_ALIVE, {tr_CbspKARepPeriod(rep_period)});
692
693/* 8.1.3.18b KEEP-ALIVE COMPLETE */
694template (value) CBSP_PDU ts_CBSP_KEEP_ALIVE_COMPL :=
695 ts_CBSP(CBSP_MSGT_KEEP_ALIVE_COMPL, {});
696template CBSP_PDU tr_CBSP_KEEP_ALIVE_COMPL :=
697 tr_CBSP(CBSP_MSGT_KEEP_ALIVE_COMPL, {});
698
699/* 8.1.3.19 RESTART */
700template (value) CBSP_PDU ts_CBSP_RESTART(template (value) BSSMAP_FIELD_CellIdentificationList cell_list,
701 template (value) CBSP_BcastMsgType msg_type,
702 template (value) CBSP_RecoveryInd rec_ind) :=
703 ts_CBSP(CBSP_MSGT_RESTART, {
704 ts_CbspCellList(cell_list),
705 ts_CbspBcastMsgType(msg_type),
706 ts_CbspRecoveryInd(rec_ind)
707 });
708template CBSP_PDU tr_CBSP_RESTART(template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
709 template CBSP_BcastMsgType msg_type := ?,
710 template CBSP_RecoveryInd rec_ind := ?) :=
711 tr_CBSP(CBSP_MSGT_RESTART, {
712 tr_CbspCellList(cell_list),
713 tr_CbspBcastMsgType(msg_type),
714 tr_CbspRecoveryInd(rec_ind)
715 });
716
717/* 8.1.3.20 FAILURE */
718template (value) CBSP_PDU ts_CBSP_FAILURE(template (value) CBSP_FailureListItems fail_list,
719 template (value) CBSP_BcastMsgType msg_type) :=
720 ts_CBSP(CBSP_MSGT_FAILURE, {
721 ts_CbspFailList(fail_list),
722 ts_CbspBcastMsgType(msg_type)
723 });
724template CBSP_PDU tr_CBSP_FAILURE(template CBSP_FailureListItems fail_list := ?,
725 template CBSP_BcastMsgType msg_type := ?) :=
726 tr_CBSP(CBSP_MSGT_FAILURE, {
727 tr_CbspFailList(fail_list),
728 tr_CbspBcastMsgType(msg_type)
729 });
730
731/* 8.1.3.21 ERROR INDICATION */
732template (value) CBSP_PDU ts_CBSP_ERROR_IND(CBSP_Cause cause) :=
733 ts_CBSP(CBSP_MSGT_ERROR_IND, {ts_CbspCause(cause)});
734template CBSP_PDU tr_CBSP_ERROR_IND(template CBSP_Cause cause) :=
735 tr_CBSP(CBSP_MSGT_ERROR_IND, {tr_CbspCause(cause), *});
736
737
738function f_cbsp_find_ie(CBSP_PDU msg, CBSP_IEI iei, out CBSP_IE ret) return boolean {
739 for (var integer i := 0; i < sizeof(msg.ies); i := i+1) {
740 if (msg.ies[i].iei == iei) {
741 ret := msg.ies[i];
742 return true;
743 }
744 }
745 return false;
746}
747
748
749}