blob: c5b0953dd5fd1082f6618a945a986a2cc2b93cc5 [file] [log] [blame]
Harald Weltee0abc472018-02-05 09:13:31 +01001module Osmocom_Gb_Types {
2
3 /* This module contains additional definitions and templates that we use on top of the
4 * TITAN NS + BSSGP modules */
5
6 import from General_Types all;
7 import from Osmocom_Types all;
8 import from GSM_Types all;
Harald Weltee0abc472018-02-05 09:13:31 +01009 import from BSSGP_Types all
10 import from NS_Types all
Harald Weltef4bf1312018-06-30 11:05:20 +020011 import from Native_Functions all;
Harald Weltee0abc472018-02-05 09:13:31 +010012
13 type uint16_t Nsvci;
14 type uint16_t Nsei;
15 type uint16_t BssgpBvci;
16
17 /* TS 48.016 10.3.7 */
18 type enumerated NsPduType {
19 NS_PDUT_NS_UNITDATA ('00000000'B),
20 NS_PDUT_NS_RESET ('00000010'B),
21 NS_PDUT_NS_RESET_ACK ('00000011'B),
22 NS_PDUT_NS_BLOCK ('00000100'B),
23 NS_PDUT_NS_BLOCK_ACK ('00000101'B),
24 NS_PDUT_NS_UNBLOCK ('00000110'B),
25 NS_PDUT_NS_UNBLOCK_ACK ('00000111'B),
26 NS_PDUT_NS_STATUS ('00001000'B),
27 NS_PDUT_NS_ALIVE ('00001010'B),
28 NS_PDUT_NS_ALIVE_ACK ('00001011'B)
29 /* FIXME: SNS */
30 } with { variant "FIELDLENGTH(8)" };
31
32 /* TS 48.016 10.3 */
33 type enumerated NsIEI {
34 NS_IEI_CAUSE ('00000000'B),
35 NS_IEI_NSVCI ('00000001'B),
36 NS_IEI_NS_PDU ('00000010'B),
37 NS_IEI_BVCI ('00000011'B),
38 NS_IEI_NSEI ('00000100'B),
39 NS_IEI_LIST_IPv4 ('00000101'B),
40 NS_IEI_LIST_IPv6 ('00000110'B),
41 NS_IEI_MAX_NUM_NSVC ('00000111'B),
42 NS_IEI_NUM_IPv4_EP ('00001000'B),
43 NS_IEI_NUM_IPv6_EP ('00001001'B),
44 NS_IEI_RESET_FLAG ('00001010'B),
45 NS_IEI_IP_ADDRESS ('00001011'B)
46 } with { variant "FIELDLENGTH(8)" };
47
48 /* TS 48.016 10.3.2 */
49 type enumerated NsCause {
50 NS_CAUSE_TRANSIT_NETWORK_FAILURE ('00000000'B),
51 NS_CAUSE_OM_INTERVENTION ('00000001'B),
52 NS_CAUSE_EQUIPMENT_FAILURE ('00000010'B),
53 NS_CAUSE_NSVC_BLOCKED ('00000011'B),
54 NS_CAUSE_NSVC_UNKNOWN ('00000100'B),
55 NS_CAUSE_BVCI_UNKNOWN_AT_NSE ('00000101'B),
56 NS_CAUSE_SEMANTICALLY_INCORRECT_PDU ('00001000'B),
57 NS_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE ('00001010'B),
58 NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED ('00001011'B),
59 NS_CAUSE_INVALID_ESSENTIAL_IE ('00001100'B),
60 NS_CAUSE_MISSING_ESSENTIAL_IE ('00001101'B),
61 NS_CAUSE_INVALID_NR_OF_IPv4_ENDPOINTS ('00001110'B),
62 NS_CAUSE_INVALID_NR_OF_IPv6_ENDPOINTS ('00001111'B),
63 NS_CAUSE_INVALID_NR_OF_NSVCS ('00010000'B),
64 NS_CAUSE_INVALID_WEIGHTS ('00010001'B),
65 NS_CAUSE_UNKNOWN_IP_ENDPOINT ('00010010'B),
66 NS_CAUSE_UNKNOWN_IP_ADDRESS ('00010011'B),
67 NS_CAUSE_IP_TEST_FAILEDA ('00010100'B)
68 } with { variant "FIELDLENGTH(8)" };
69
Harald Welte387ab372018-06-30 10:27:06 +020070 template (value) NS_SDU_ControlBits t_SduCtrlB := {
Harald Weltee0abc472018-02-05 09:13:31 +010071 rBit := '0'B,
72 cBit := '0'B,
73 spare := '000000'B
74 }
75
Harald Welte387ab372018-06-30 10:27:06 +020076 template (value) CauseNS ts_NS_IE_CAUSE(NsCause cause) := {
77 iEI := '00'O,
78 ext := '1'B,
79 lengthIndicator := {
80 length1 := 1
81 },
82 cause := int2oct(enum2int(valueof(cause)), 1)
83 }
Harald Weltef4bf1312018-06-30 11:05:20 +020084 function ts_NS_IE_CAUSE_omit(template (omit) NsCause cause) return template (omit) CauseNS {
85 var template (omit) CauseNS ret;
86 if (istemplatekind(cause, "omit")) {
87 return omit;
88 } else {
89 ret := {
90 iEI := '00'O,
91 ext := '1'B,
92 lengthIndicator := {
93 length1 := 1
94 },
95 cause := int2oct(enum2int(valueof(cause)), 1)
96 }
97 return ret;
98 }
99 }
Harald Welte387ab372018-06-30 10:27:06 +0200100
101 function tr_NS_IE_CAUSE(template NsCause cause) return template CauseNS {
Harald Weltee0abc472018-02-05 09:13:31 +0100102 var template CauseNS ret;
103 ret.iEI := '00'O;
104 ret.ext := '1'B;
105 ret.lengthIndicator := { length1 := 1 };
Harald Weltef4bf1312018-06-30 11:05:20 +0200106 if (istemplatekind(cause, "omit")) {
107 return omit;
108 } else if (istemplatekind(cause, "*")) {
109 return *;
110 } else if (istemplatekind(cause, "?")) {
Harald Weltee0abc472018-02-05 09:13:31 +0100111 ret.cause := ?
Harald Weltef4bf1312018-06-30 11:05:20 +0200112 } else {
113 ret.cause := int2oct(enum2int(valueof(cause)), 1);
Harald Weltee0abc472018-02-05 09:13:31 +0100114 }
115 return ret;
116 }
117
Harald Welte630d0e62019-02-22 23:26:40 +0100118 function ts_SNS_IP_ADDR(template (omit) IPAddress ip) return template (omit) IP_Address_NS {
119 var template (omit) IP_Address_NS ret;
120 if (istemplatekind(ip, "omit")) {
121 return omit;
122 } else {
123 ret.iEI := '0B'O;
124 ret.ipAddress := ip;
125 if (ischosen(ip.ip4Address)) {
126 ret.addressType := '01'O;
127 } else {
128 ret.addressType := '02'O;
129 }
130 }
131 return ret;
132 }
133 function tr_SNS_IP_ADDR(template IPAddress ip) return template IP_Address_NS {
134 var template IP_Address_NS ret;
135 ret.iEI := '0B'O;
136 if (istemplatekind(ip, "omit")) {
137 return omit;
138 } else if (istemplatekind(ip, "*")) {
139 return *;
140 } else if (istemplatekind(ip, "?")) {
141 return ?;
142 } else {
143 ret.ipAddress := ip;
144 if (ischosen(ip.ip4Address)) {
145 ret.addressType := '01'O;
146 } else {
147 ret.addressType := '02'O;
148 }
149 }
150 return ret;
151 }
152
Harald Weltee0abc472018-02-05 09:13:31 +0100153 private function f_oct_or_wc(template integer inp, integer len) return template octetstring {
Harald Weltef4bf1312018-06-30 11:05:20 +0200154 if (istemplatekind(inp, "omit")) {
155 return omit;
156 } else if (istemplatekind(inp, "*")) {
157 return *;
158 } else if (istemplatekind(inp, "?")) {
159 return ?;
Harald Weltee0abc472018-02-05 09:13:31 +0100160 }
Harald Weltef4bf1312018-06-30 11:05:20 +0200161 return int2oct(valueof(inp), len);
Harald Weltee0abc472018-02-05 09:13:31 +0100162 }
163
Harald Welte387ab372018-06-30 10:27:06 +0200164 template (value) NS_VCI ts_NS_IE_NSVCI(Nsvci nsvci) := {
165 iEI := '01'O,
166 ext := '1'B,
167 lengthIndicator := {
168 length1 := 2
169 },
170 nS_VCI := int2oct(nsvci, 2)
171 }
172 template NS_VCI tr_NS_IE_NSVCI(template Nsvci nsvci) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100173 iEI := '01'O,
174 ext := '1'B,
175 lengthIndicator := {
176 length1 := 2
177 },
178 nS_VCI := f_oct_or_wc(nsvci, 2)
179 }
180
Harald Welte387ab372018-06-30 10:27:06 +0200181 template (value) NSEI_NS ts_NS_IE_NSEI(Nsei nsei) := {
182 iEI:= '04'O,
183 ext := '1'B,
184 lengthIndicator := {
185 length1 := 2
186 },
187 nSEI := int2oct(nsei, 2)
188 }
189 template NSEI_NS tr_NS_IE_NSEI(template Nsei nsei) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100190 iEI:= '04'O,
191 ext := '1'B,
192 lengthIndicator := {
193 length1 := 2
194 },
195 nSEI := f_oct_or_wc(nsei, 2)
196 }
197
Harald Weltef4bf1312018-06-30 11:05:20 +0200198 template (value) IP4_Element ts_SNS_IPv4(charstring ip, integer udp_port,
199 uint8_t sig_weight := 1, uint8_t data_weight := 1) := {
200 ipAddress := f_inet_addr(ip),
201 uDP_Port := int2oct(udp_port, 2),
202 signallingWeight := int2oct(sig_weight, 1),
203 dataWeight := int2oct(data_weight, 1)
204 }
205 function tr_SNS_IPv4(template charstring ip, template integer udp_port,
206 template uint8_t sig_weight := ?, template uint8_t data_weight := ?)
207 return template IP4_Element {
208 var template IP4_Element e;
209 if (istemplatekind(ip, "?")) {
210 e.ipAddress := ?;
211 } else {
212 e.ipAddress := f_inet_addr(valueof(ip));
213 }
214 if (istemplatekind(udp_port, "?")) {
215 e.uDP_Port := ?;
216 } else {
217 e.uDP_Port := int2oct(valueof(udp_port), 2);
218 }
219 if (istemplatekind(sig_weight, "?")) {
220 e.signallingWeight := ?;
221 } else {
222 e.signallingWeight := int2oct(valueof(sig_weight), 1);
223 }
224 if (istemplatekind(data_weight, "?")) {
225 e.dataWeight := ?;
226 } else {
227 e.dataWeight := int2oct(valueof(data_weight), 1);
228 }
229 return e;
230 }
231
Harald Welte387ab372018-06-30 10:27:06 +0200232
233 template (value) PDU_NS ts_NS_RESET(NsCause cause, Nsvci nsvci, Nsei nsei) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100234 pDU_NS_Reset := {
235 nsPduType := '02'O,
Harald Welte387ab372018-06-30 10:27:06 +0200236 causeNS := ts_NS_IE_CAUSE(cause),
237 nS_VCI := ts_NS_IE_NSVCI(nsvci),
238 nSEI_NS := ts_NS_IE_NSEI(nsei)
239 }
240 }
241 template PDU_NS tr_NS_RESET(template NsCause cause, template Nsvci nsvci, template Nsei nsei) := {
242 pDU_NS_Reset := {
243 nsPduType := '02'O,
244 causeNS := tr_NS_IE_CAUSE(cause),
245 nS_VCI := tr_NS_IE_NSVCI(nsvci),
246 nSEI_NS := tr_NS_IE_NSEI(nsei)
Harald Weltee0abc472018-02-05 09:13:31 +0100247 }
248 }
249
Harald Welte387ab372018-06-30 10:27:06 +0200250 template (value) PDU_NS ts_NS_RESET_ACK(Nsvci nsvci, Nsei nsei) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100251 pDU_NS_Reset_Ack := {
252 nsPduType := '03'O,
Harald Welte387ab372018-06-30 10:27:06 +0200253 nS_VCI := ts_NS_IE_NSVCI(nsvci),
254 nSEI_NS := ts_NS_IE_NSEI(nsei)
255 }
256 }
257 template PDU_NS tr_NS_RESET_ACK(template Nsvci nsvci, template Nsei nsei) := {
258 pDU_NS_Reset_Ack := {
259 nsPduType := '03'O,
260 nS_VCI := tr_NS_IE_NSVCI(nsvci),
261 nSEI_NS := tr_NS_IE_NSEI(nsei)
Harald Weltee0abc472018-02-05 09:13:31 +0100262 }
263 }
264
Harald Welte387ab372018-06-30 10:27:06 +0200265 template (value) PDU_NS ts_NS_BLOCK(NsCause cause, Nsvci nsvci) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100266 pDU_NS_Block := {
267 nsPduType := '04'O,
Harald Welte387ab372018-06-30 10:27:06 +0200268 causeNS := ts_NS_IE_CAUSE(cause),
269 nS_VCI := ts_NS_IE_NSVCI(nsvci)
270 }
271 }
272 template PDU_NS tr_NS_BLOCK(template NsCause cause, template Nsvci nsvci) := {
273 pDU_NS_Block := {
274 nsPduType := '04'O,
275 causeNS := tr_NS_IE_CAUSE(cause),
276 nS_VCI := tr_NS_IE_NSVCI(nsvci)
Harald Weltee0abc472018-02-05 09:13:31 +0100277 }
278 }
279
Harald Welte387ab372018-06-30 10:27:06 +0200280 template (value) PDU_NS ts_NS_BLOCK_ACK(Nsvci nsvci) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100281 pDU_NS_Block_Ack := {
282 nsPduType := '05'O,
Harald Welte387ab372018-06-30 10:27:06 +0200283 nS_VCI := ts_NS_IE_NSVCI(nsvci)
284 }
285 }
286 template PDU_NS tr_NS_BLOCK_ACK(template Nsvci nsvci) := {
287 pDU_NS_Block_Ack := {
288 nsPduType := '05'O,
289 nS_VCI := tr_NS_IE_NSVCI(nsvci)
Harald Weltee0abc472018-02-05 09:13:31 +0100290 }
291 }
292
293 template PDU_NS t_NS_UNBLOCK := {
294 pDU_NS_Unblock := {
295 nsPduType := '06'O
296 }
297 }
298
299 template PDU_NS t_NS_UNBLOCK_ACK := {
300 pDU_NS_Unblock_Ack := {
301 nsPduType := '07'O
302 }
303 }
304
305 template PDU_NS t_NS_ALIVE := {
306 pDU_NS_Alive := {
307 nsPduType := '0A'O
308 }
309 }
310
311 template PDU_NS t_NS_ALIVE_ACK := {
312 pDU_NS_Alive_Ack := {
313 nsPduType := '0B'O
314 }
315 }
316
Harald Welte387ab372018-06-30 10:27:06 +0200317 template (value) PDU_NS ts_NS_STATUS(NsCause cause, PDU_NS pdu) := {
Harald Weltee0abc472018-02-05 09:13:31 +0100318 pDU_NS_Status := {
319 nsPduType := '08'O,
Harald Welte387ab372018-06-30 10:27:06 +0200320 causeNS := ts_NS_IE_CAUSE(cause),
Harald Weltee0abc472018-02-05 09:13:31 +0100321 nS_VCI := omit,
322 nS_PDU := {
323 iEI := '02'O,
324 ext := '1'B,
325 lengthIndicator := {
326 length1 := 0 /* overwritten */
327 },
328 ns_PDU := enc_PDU_NS(pdu)
329 },
330 bVCI_NS := omit,
331 listofIP4Elements := omit,
332 listofIP6Elements := omit
333 }
334 }
335
Alexander Couzens9843b662020-09-07 05:20:54 +0200336 template PDU_NS tr_NS_STATUS(template NsCause cause) := {
337 pDU_NS_Status := {
338 nsPduType := '08'O,
339 causeNS := tr_NS_IE_CAUSE(cause),
340 nS_VCI := *,
341 nS_PDU := *,
342 bVCI_NS := *,
343 listofIP4Elements := *,
344 listofIP6Elements := *
345 }
346 }
347
Harald Welte387ab372018-06-30 10:27:06 +0200348 template (value) PDU_NS ts_NS_UNITDATA(template (value) NS_SDU_ControlBits bits, BssgpBvci bvci, octetstring sdu) := {
349 pDU_NS_Unitdata := {
350 nsPduType := '00'O,
351 nS_SDU_ControlBits := bits,
352 bVCI := int2oct(bvci, 2),
353 nS_SDU := sdu
354 }
355 }
356 template PDU_NS tr_NS_UNITDATA(template NS_SDU_ControlBits bits, template BssgpBvci bvci, template
Harald Weltee0abc472018-02-05 09:13:31 +0100357octetstring sdu) := {
358 pDU_NS_Unitdata := {
359 nsPduType := '00'O,
360 nS_SDU_ControlBits := bits,
361 bVCI := f_oct_or_wc(bvci, 2),
362 nS_SDU := sdu
363 }
364 }
365
366
Harald Weltef4bf1312018-06-30 11:05:20 +0200367
368 private function ts_num_of_ep(OCT1 iei, template (omit) uint16_t num_ep)
369 return template (omit) NumberOfIP_Endpoints {
370 var template (omit) NumberOfIP_Endpoints t;
371 if (istemplatekind(num_ep, "omit")) {
372 return omit;
373 } else {
374 t.iEI := iei;
375 t.numberOfIP_Endpoints := int2oct(valueof(num_ep), 2);
376 return t;
377 }
378 }
379 private function tr_num_of_ep(OCT1 iei, template uint16_t num_ep)
380 return template NumberOfIP_Endpoints {
381 var template NumberOfIP_Endpoints t;
382 if (istemplatekind(num_ep, "omit")) {
383 return omit;
384 } else if (istemplatekind(num_ep, "*")) {
385 return *;
386 } else if (istemplatekind(num_ep, "?")) {
387 return ?;
388 } else {
389 t.iEI := iei;
390 t.numberOfIP_Endpoints := int2oct(valueof(num_ep), 2);
391 return t;
392 }
393 }
394
395
396 template (value) ResetFlag ts_SNS_IE_ResetFlag(boolean rst) := {
397 iEI := '0A'O,
398 resetBIT := bool2bit(rst),
399 spare := '0000000'B
400 }
401 template ResetFlag tr_SNS_IE_ResetFlag(template boolean rst) := {
402 iEI := '0A'O,
403 resetBIT := bool2bit_tmpl(rst),
404 spare := '0000000'B
405 }
406
407 template (value) EndFlag ts_SNS_IE_EndFlag(boolean end) := {
408 eBIT := bool2bit(end),
409 spare := '0000000'B
410 }
411 template EndFlag tr_SNS_IE_EndFlag(template boolean end) := {
412 eBIT := bool2bit_tmpl(end),
413 spare := '0000000'B
414 }
415
416 template (value) MaxNumberOfNSVCs ts_SNS_IE_MaxNumOfNSVCs(uint16_t num) := {
417 iEI := '07'O,
418 maxNumberOfNSVCs := int2oct(num, 2)
419 }
420 template MaxNumberOfNSVCs tr_SNS_IE_MaxNumOfNSVCs(template uint16_t num) := {
421 iEI := '07'O,
422 maxNumberOfNSVCs := f_oct_or_wc(num, 2)
423 }
424
425 template (value) PDU_NS ts_SNS_SIZE(Nsei nsei, boolean rst_flag := true,
426 uint16_t max_nsvcs := 2,
427 template (omit) uint16_t num_v4 := 1,
428 template (omit) uint16_t num_v6 := omit) := {
429 pDU_SNS_Size := {
430 nsPduType := '12'O,
431 nSEI_NS := ts_NS_IE_NSEI(nsei),
432 resetFlag := ts_SNS_IE_ResetFlag(rst_flag),
433 maxNumberOfNSVCs := ts_SNS_IE_MaxNumOfNSVCs(max_nsvcs),
434 numberOfIP4_Endpoints := ts_num_of_ep('08'O, num_v4),
435 numberOfIP6_Endpoints := ts_num_of_ep('09'O, num_v6)
436 }
437 }
438 template PDU_NS tr_SNS_SIZE(template Nsei nsei, template boolean rst_flag := ?,
439 template uint16_t max_nsvcs := ?,
440 template uint16_t num_v4 := ?,
441 template uint16_t num_v6 := *) := {
442 pDU_SNS_Size := {
443 nsPduType := '12'O,
444 nSEI_NS := tr_NS_IE_NSEI(nsei),
445 resetFlag := tr_SNS_IE_ResetFlag(rst_flag),
446 maxNumberOfNSVCs := tr_SNS_IE_MaxNumOfNSVCs(max_nsvcs),
447 numberOfIP4_Endpoints := tr_num_of_ep('08'O, num_v4),
448 numberOfIP6_Endpoints := tr_num_of_ep('09'O, num_v6)
449 }
450 }
451
452 template PDU_NS ts_SNS_SIZE_ACK(Nsei nsei, template (omit) NsCause cause) := {
453 pDU_SNS_Size_Ack := {
454 nsPduType := '13'O,
455 nSEI_NS := ts_NS_IE_NSEI(nsei),
456 causeNS := ts_NS_IE_CAUSE_omit(cause)
457 }
458 }
459 template PDU_NS tr_SNS_SIZE_ACK(template Nsei nsei, template NsCause cause) := {
460 pDU_SNS_Size_Ack := {
461 nsPduType := '13'O,
462 nSEI_NS := tr_NS_IE_NSEI(nsei),
463 causeNS := tr_NS_IE_CAUSE(cause)
464 }
465 }
466
467 private function ts_SNS_IE_ListIP4(template (omit) IP4_Elements elem)
468 return template (omit) ListofIP4Elements {
469 var template (omit) ListofIP4Elements r;
470 if (istemplatekind(elem, "omit")) {
471 return omit;
472 } else {
473 r := {
474 iEI := '05'O,
475 ext := '1'B,
476 lengthIndicator := {
477 length1 := 0 /* overwritten */
478 },
479 iP4_Elements := elem
480 }
481 return r;
482 }
483 }
484 private function tr_SNS_IE_ListIP4(template IP4_Elements elem)
485 return template ListofIP4Elements {
486 var template ListofIP4Elements r;
487 if (istemplatekind(elem, "omit")) {
488 return omit;
489 } else {
490 r := {
491 iEI := '05'O,
492 ext := '1'B,
493 lengthIndicator := {
494 length1 := ? /* overwritten */
495 },
496 iP4_Elements := elem
497 }
498 return r;
499 }
500 }
501
502 private function ts_SNS_IE_ListIP6(template (omit) IP6_Elements elem)
503 return template (omit) ListofIP6Elements {
504 var template (omit) ListofIP6Elements r;
505 if (istemplatekind(elem, "omit")) {
506 return omit;
507 } else {
508 r := {
509 iEI := '06'O,
510 ext := '1'B,
511 lengthIndicator := {
512 length1 := 0 /* overwritten */
513 },
514 iP6_Elements := elem
515 }
516 return r;
517 }
518 }
519 private function tr_SNS_IE_ListIP6(template IP6_Elements elem)
520 return template ListofIP6Elements {
521 var template ListofIP6Elements r;
522 if (istemplatekind(elem, "omit")) {
523 return omit;
Harald Welte630d0e62019-02-22 23:26:40 +0100524 } else if (istemplatekind(elem, "*")) {
525 return *;
Harald Weltef4bf1312018-06-30 11:05:20 +0200526 } else {
527 r := {
528 iEI := '06'O,
529 ext := '1'B,
530 lengthIndicator := {
531 length1 := ? /* overwritten */
532 },
533 iP6_Elements := elem
534 }
535 return r;
536 }
537 }
538
539 template (value) PDU_NS ts_SNS_CONFIG(Nsei nsei, boolean end_flag,
540 template (omit) IP4_Elements v4,
541 template (omit) IP6_Elements v6 := omit) := {
542 pDU_SNS_Config := {
543 nsPduType := '0F'O,
544 endFlag := ts_SNS_IE_EndFlag(end_flag),
545 nSEI_NS := ts_NS_IE_NSEI(nsei),
546 listofIP4Elements := ts_SNS_IE_ListIP4(v4),
547 listofIP6Elements := ts_SNS_IE_ListIP6(v6)
548 }
549 }
550 template PDU_NS tr_SNS_CONFIG(template Nsei nsei, template boolean end_flag,
551 template IP4_Elements v4,
552 template IP6_Elements v6 := omit) := {
553 pDU_SNS_Config := {
554 nsPduType := '0F'O,
555 endFlag := tr_SNS_IE_EndFlag(end_flag),
556 nSEI_NS := tr_NS_IE_NSEI(nsei),
557 listofIP4Elements := tr_SNS_IE_ListIP4(v4),
558 listofIP6Elements := tr_SNS_IE_ListIP6(v6)
559 }
560 }
561
562 template (value) PDU_NS ts_SNS_CONFIG_ACK(Nsei nsei, template (omit) NsCause cause) := {
563 pDU_SNS_Config_Ack := {
564 nsPduType := '10'O,
565 nSEI_NS := ts_NS_IE_NSEI(nsei),
566 causeNS := ts_NS_IE_CAUSE_omit(cause)
567 }
568 }
569 template PDU_NS tr_SNS_CONFIG_ACK(template Nsei nsei, template NsCause cause) := {
570 pDU_SNS_Config_Ack := {
571 nsPduType := '10'O,
572 nSEI_NS := tr_NS_IE_NSEI(nsei),
573 causeNS := tr_NS_IE_CAUSE(cause)
574 }
575 }
576
Harald Welte630d0e62019-02-22 23:26:40 +0100577 template (value) PDU_NS ts_SNS_ADD(Nsei nsei, uint8_t trans_id,
578 template (omit) IP4_Elements v4,
579 template (omit) IP6_Elements v6 := omit) := {
580 pDU_SNS_Add := {
581 nsPduType := '0D'O,
582 nSEI_NS := ts_NS_IE_NSEI(nsei),
583 transactionID := trans_id,
584 listofIP4Elements := ts_SNS_IE_ListIP4(v4),
585 listofIP6Elements := ts_SNS_IE_ListIP6(v6)
586 }
587 }
588 template PDU_NS tr_SNS_ADD(template Nsei nsei, template uint8_t trans_id,
589 template IP4_Elements v4,
590 template IP6_Elements v6 := omit) := {
591 pDU_SNS_Add := {
592 nsPduType := '0D'O,
593 nSEI_NS := tr_NS_IE_NSEI(nsei),
594 transactionID := trans_id,
595 listofIP4Elements := tr_SNS_IE_ListIP4(v4),
596 listofIP6Elements := tr_SNS_IE_ListIP6(v6)
597 }
598 }
599
600 template (value) PDU_NS ts_SNS_DEL(Nsei nsei, uint8_t trans_id,
601 template (omit) IPAddress ip_sns,
602 template (omit) IP4_Elements v4,
603 template (omit) IP6_Elements v6 := omit) := {
604 pDU_SNS_Delete := {
605 nsPduType := '11'O,
606 nSEI_NS := ts_NS_IE_NSEI(nsei),
607 transactionID := trans_id,
608 iP_Address_NS := ts_SNS_IP_ADDR(ip_sns),
609 listofIP4Elements := ts_SNS_IE_ListIP4(v4),
610 listofIP6Elements := ts_SNS_IE_ListIP6(v6)
611 }
612 }
613 template PDU_NS tr_SNS_DEL(template Nsei nsei, template uint8_t trans_id,
614 template IPAddress ip_sns,
615 template IP4_Elements v4,
616 template IP6_Elements v6 := omit) := {
617 pDU_SNS_Delete := {
618 nsPduType := '11'O,
619 nSEI_NS := tr_NS_IE_NSEI(nsei),
620 transactionID := trans_id,
621 iP_Address_NS := tr_SNS_IP_ADDR(ip_sns),
622 listofIP4Elements := tr_SNS_IE_ListIP4(v4),
623 listofIP6Elements := tr_SNS_IE_ListIP6(v6)
624 }
625 }
626
Harald Welte72099552019-02-23 15:09:22 +0100627 template (value) PDU_NS ts_SNS_CHG_WEIGHT(Nsei nsei, uint8_t trans_id,
628 template (omit) IP4_Elements v4,
629 template (omit) IP6_Elements v6 := omit) := {
630 pDU_SNS_ChangeWeight := {
631 nsPduType := '0E'O,
632 nSEI_NS := ts_NS_IE_NSEI(nsei),
633 transactionID := trans_id,
634 listofIP4Elements := ts_SNS_IE_ListIP4(v4),
635 listofIP6Elements := ts_SNS_IE_ListIP6(v6)
636 }
637 }
638 template PDU_NS tr_SNS_CHG_WEIGHT(template Nsei nsei, template uint8_t trans_id,
639 template IP4_Elements v4,
640 template IP6_Elements v6 := omit) := {
641 pDU_SNS_ChangeWeight := {
642 nsPduType := '0E'O,
643 nSEI_NS := tr_NS_IE_NSEI(nsei),
644 transactionID := trans_id,
645 listofIP4Elements := tr_SNS_IE_ListIP4(v4),
646 listofIP6Elements := tr_SNS_IE_ListIP6(v6)
647 }
648 }
649
Harald Welte630d0e62019-02-22 23:26:40 +0100650
651 template (value) PDU_NS ts_SNS_ACK(Nsei nsei, uint8_t trans_id,
652 template (omit) NsCause cause := omit,
653 template (omit) IP4_Elements v4 := omit,
654 template (omit) IP6_Elements v6 := omit) := {
655 pDU_SNS_Ack := {
656 nsPduType := '0C'O,
657 nSEI_NS := ts_NS_IE_NSEI(nsei),
658 transactionID := trans_id,
659 causeNS := ts_NS_IE_CAUSE_omit(cause),
660 iP_Address_NS := omit,
661 listofIP4Elements := ts_SNS_IE_ListIP4(v4),
662 listofIP6Elements := ts_SNS_IE_ListIP6(v6)
663 }
664 }
665 template PDU_NS tr_SNS_ACK(template Nsei nsei, template uint8_t trans_id := ?,
666 template NsCause cause := omit,
667 template IP4_Elements v4 := *,
668 template IP6_Elements v6 := *) := {
669 pDU_SNS_Ack := {
670 nsPduType := '0C'O,
671 nSEI_NS := tr_NS_IE_NSEI(nsei),
672 transactionID := trans_id,
673 causeNS := tr_NS_IE_CAUSE(cause),
674 iP_Address_NS := omit,
675 listofIP4Elements := tr_SNS_IE_ListIP4(v4),
676 listofIP6Elements := tr_SNS_IE_ListIP6(v6)
677 }
678 }
679
680
681
682
683
684
685
Harald Weltee0abc472018-02-05 09:13:31 +0100686 type record BssgpCellId {
687 RoutingAreaIdentification ra_id,
688 CellIdentity cell_id
689 } with { variant "" };
690
691 type enumerated BssgpCause {
692 BSSGP_CAUSE_PROC_OVERLOAD ('00'H),
693 BSSGP_CAUSE_EQUIMENT_FAILURE ('01'H),
694 BSSGP_CAUSE_TRANSIT_NETWORK_FAILURE ('02'H),
695 BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS ('03'H),
696 BSSGP_CAUSE_UNKNOWN_MS ('04'H),
697 BSSGP_CAUSE_BVCI_UNKNOWN ('05'H),
698 BSSGP_CAUSE_CELL_TRAFFIC_CONGESTION ('06'H),
699 BSSGP_CAUSE_SGSN_CONGESTION ('07'H),
700 BSSGP_CAUSE_OM_INTERVENTION ('08'H),
701 BSSGP_CAUSE_BVCI_BLOCKED ('09'H),
702 BSSGP_CAUSE_PFC_CREATE_FAILURE ('0a'H),
703 BSSGP_CAUSE_PFC_PREEMPTED ('0b'H),
704 BSSGP_CAUSE_ABQP_NO_MORE_SUPPORTED ('0c'H),
705 BSSGP_CAUSE_SEMANTICALLY_INCORRECT_PDU ('20'H),
706 BSSGP_CAUSE_INVALID_MANDATORY_IE ('21'H),
707 BSSGP_CAUSE_MISSING_MANDATORY_IE ('22'H),
708 BSSGP_CAUSE_MISSING_CONDITIONAL_IE ('23'H),
709 BSSGP_CAUSE_UNEXPECTED_CONDITIONAL_IE ('24'H),
710 BSSGP_CAUSE_CONDITIONAL_IE_ERROR ('25'H),
711 BSSGP_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE ('26'H),
712 BSSGP_CAUSE_PROTOCOL_ERROR_UNSPECIFIED ('27'H),
713 BSSGP_CAUSE_PDU_NOT_COMPATIBLE_WITH_FEATURE_SET ('28'H),
714 BSSGP_CAUSE_REQUESTED_INFO_NOT_AVAILABLE ('29'H),
715 BSSGP_CAUSE_UNKNOWN_DESTINATION_ADDRESS ('2a'H),
716 BSSGP_CAUSE_UNKNOWN_RIM_APP_IDENTITY ('2b'H),
717 BSSGP_CAUSE_INVALID_CONTAINER_UNIT_INFO ('2c'H),
718 BSSGP_CAUSE_PFC_QUEUING ('2d'H),
719 BSSGP_CAUSE_PFC_CREATED_SUCCESSFULLY ('2e'H),
720 BSSGP_CAUSE_T12_EXPIRY ('2f'H),
721 BSSGP_CAUSE_MS_UNDER_PS_HANDOVER_TREATMENT ('30'H),
722 BSSGP_CAUSE_UPLINK_QUALITY ('31'H),
723 BSSGP_CAUSE_UPLINK_STRENGTH ('32'H),
724 BSSGP_CAUSE_DOWNLINK_QUALITY ('33'H),
725 BSSGP_CAUSE_DOWNLINK_STRENGTH ('34'H),
726 BSSGP_CAUSE_DISTANCE ('35'H),
727 BSSGP_CAUSE_BETTER_CELL ('36'H),
728 BSSGP_CAUSE_TRAFFIC ('37'H),
729 BSSGP_CAUSE_OM_INTERVENTION2 ('38'H),
730 BSSGP_CAUSE_MS_BACK_ON_OLD_CHANNEL ('39'H),
731 BSSGP_CAUSE_T13_EXPIRY ('3a'H),
732 BSSGP_CAUSE_T14_EXPIRY ('3b'H),
733 BSSGP_CAUSE_NOT_ALL_REQUESTED_PFC_CREATED ('3c'H)
734 } with { variant "FIELDLENGTH(8)" };
735
736
737 template BVCI t_BSSGP_BVCI(template BssgpBvci bvci) := {
738 iEI := '04'O,
739 ext := '1'B,
740 lengthIndicator := {
741 length1 := 2
742 },
743 unstructured_value := f_oct_or_wc(bvci, 2)
744 }
745
Harald Welte23989a62019-03-21 21:32:45 +0100746 template (value) TLLI_BSSGP ts_BSSGP_TLLI(template (value) GprsTlli tlli) := {
747 iEI := '1F'O,
748 ext := '1'B,
749 lengthIndicator := {
750 length1 := 4
751 },
752 tLLI_Value := tlli
753 }
754 template TLLI_BSSGP tr_BSSGP_TLLI(template GprsTlli tlli) := {
755 iEI := '1F'O,
756 ext := '1'B,
757 lengthIndicator := {
758 length1 := 4
759 },
760 tLLI_Value := tlli
761 }
762
763 template (value) Suspend_Reference_Number ts_BSSGP_SUSP_REF(template (value) OCT1 susp_ref) := {
764 iEI := '1D'O,
765 ext := '1'B,
766 lengthIndicator := {
767 length1 := 1
768 },
769 suspend_Reference_Number_value := susp_ref
770 }
771 template Suspend_Reference_Number tr_BSSGP_SUSP_REF(template OCT1 susp_ref) := {
772 iEI := '1D'O,
773 ext := '1'B,
774 lengthIndicator := {
775 length1 := 1
776 },
777 suspend_Reference_Number_value := susp_ref
778 }
779
Harald Weltee0abc472018-02-05 09:13:31 +0100780 template IMSI_BSSGP tr_BSSGP_IMSI(template hexstring imsi) := {
781 iEI := '0D'O,
782 ext := '1'B,
783 lengthIndicator := ?,
784 type_of_Identity := '001'B,
785 oddevenIndicator := ?,
786 digits := imsi
787 }
788
789 template IMSI_BSSGP ts_BSSGP_IMSI(hexstring imsi) := {
790 iEI := '0D'O,
791 ext := '1'B,
792 lengthIndicator := { length1 := 0 /* overwritten */ },
793 type_of_Identity := '001'B,
794 oddevenIndicator := f_hex_is_odd_length(imsi),
795 digits := imsi
796 }
797
798 template TMSI_BSSGP ts_BSSGP_TMSI(GsmTmsi tmsi) := {
799 iEI := '20'O,
800 ext := '1'B,
801 lengthIndicator := { length1 := 4 },
802 tMSI_Value := int2oct(tmsi, 4)
803 }
804
805 function f_bssgp_length_ind(integer len) return LIN2_2a {
806 var LIN2_2a ret;
807 if (len > 255) {
808 ret := { length2 := len };
809 } else {
810 ret := { length1 := len };
811 }
812 return ret;
813 }
814
815 template LLC_PDU ts_BSSGP_LLC_PDU(octetstring pdu) := {
816 iEI := '0D'O,
817 ext := '1'B,
818 lengthIndicator := f_bssgp_length_ind(lengthof(pdu)),
819 lLC_PDU := pdu
820 }
821
822 template LLC_PDU tr_BSSGP_LLC_PDU(template octetstring pdu := ?) := {
Harald Welte7024baa2018-03-02 23:37:51 +0100823 iEI := '0E'O,
824 ext := ?,
Harald Weltee0abc472018-02-05 09:13:31 +0100825 lengthIndicator := ?,
826 lLC_PDU := pdu
827 }
828
Harald Welte23989a62019-03-21 21:32:45 +0100829 function ts_BSSGP_CAUSE(template (omit) BssgpCause cause) return template (omit) Cause_BSSGP {
830 var template (omit) Cause_BSSGP ret;
831 if (istemplatekind(cause, "omit")) {
832 ret := omit;
833 } else {
834 ret.iEI := '07'O;
835 ret.ext := '1'B;
836 ret.lengthIndicator := { length1 := 1 };
837 ret.cause_Value := int2oct(enum2int(valueof(cause)), 1);
838 }
839 return ret;
840 }
Harald Weltee0abc472018-02-05 09:13:31 +0100841 function t_BSSGP_CAUSE(template BssgpCause cause) return template Cause_BSSGP {
842 var template Cause_BSSGP ret;
Harald Weltebacca282018-03-02 16:03:59 +0100843 ret.iEI := '07'O;
Harald Weltee0abc472018-02-05 09:13:31 +0100844 ret.ext := '1'B;
845 ret.lengthIndicator := { length1 := 1 };
846 if (isvalue(cause)) {
847 ret.cause_Value := int2oct(enum2int(valueof(cause)), 1);
848 } else {
849 ret.cause_Value := ?
850 }
851 return ret;
852 }
853
854 function t_BSSGP_IE_CellId(template BssgpCellId cid) return template Cell_Identifier {
855 var template Cell_Identifier ret := {
856 iEI := '08'O,
857 ext := '1'B,
858 lengthIndicator := { length1 := 8 },
859 mccDigit1 := ?,
860 mccDigit2 := ?,
861 mccDigit3 := ?,
862 mncDigit3 := ?,
863 mncDigit1 := ?,
864 mncDigit2 := ?,
865 lac := ?,
866 rac := ?,
867 cI_value := ?
868 }
869 if (istemplatekind(cid, "omit")) {
870 return omit;
871 } else if (istemplatekind(cid, "*")) {
872 return *;
873 } else if (istemplatekind(cid, "?")) {
874 return ?;
875 }
876 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
877 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
878 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
879 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
880 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
Harald Welte797ab3a2019-03-21 21:33:28 +0100881 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
Harald Welte797ab3a2019-03-21 21:33:28 +0100882 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
Alexander Couzensc7dddbd2019-04-11 19:18:35 +0200883 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
Harald Weltee0abc472018-02-05 09:13:31 +0100884 }
885 if (isvalue(cid.ra_id.lai.lac)) {
886 ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2);
887 }
888 }
889 if (isvalue(cid) and isvalue(cid.ra_id)) {
890 ret.rac := f_oct_or_wc(cid.ra_id.rac, 1);
891 }
892 if (isvalue(cid)) {
893 ret.cI_value := f_oct_or_wc(cid.cell_id, 2);
894 }
895 return ret;
896 }
897
898 template PDU_BSSGP ts_BVC_RESET(BssgpCause cause, BssgpBvci bvci,
899 template BssgpCellId cell_id) := {
900 pDU_BSSGP_BVC_RESET := {
901 bssgpPduType := '22'O,
902 bVCI := t_BSSGP_BVCI(bvci),
Harald Welte23989a62019-03-21 21:32:45 +0100903 cause := ts_BSSGP_CAUSE(cause),
Harald Weltee0abc472018-02-05 09:13:31 +0100904 cell_Identifier := t_BSSGP_IE_CellId(cell_id),
905 feature_bitmap := omit,
906 extended_Feature_Bitmap := omit
907 }
908 }
909
910 template PDU_BSSGP tr_BVC_RESET(template BssgpCause cause, template BssgpBvci bvci,
911 template BssgpCellId cell_id) := {
912 pDU_BSSGP_BVC_RESET := {
913 bssgpPduType := '22'O,
914 bVCI := t_BSSGP_BVCI(bvci),
915 cause := t_BSSGP_CAUSE(cause),
916 cell_Identifier := t_BSSGP_IE_CellId(cell_id),
917 feature_bitmap := *,
918 extended_Feature_Bitmap := *
919 }
920 }
921
922 template PDU_BSSGP ts_BVC_RESET_ACK(BssgpBvci bvci, template BssgpCellId cell_id) := {
923 pDU_BSSGP_BVC_RESET_ACK := {
924 bssgpPduType := '23'O,
925 bVCI := t_BSSGP_BVCI(bvci),
926 cell_Identifier := t_BSSGP_IE_CellId(cell_id),
927 feature_bitmap := omit,
928 extended_Feature_Bitmap := omit
929 }
930 }
931
932 template PDU_BSSGP tr_BVC_RESET_ACK(template BssgpBvci bvci, template BssgpCellId cell_id) := {
933 pDU_BSSGP_BVC_RESET_ACK := {
934 bssgpPduType := '23'O,
935 bVCI := t_BSSGP_BVCI(bvci),
936 cell_Identifier := t_BSSGP_IE_CellId(cell_id),
937 feature_bitmap := *,
938 extended_Feature_Bitmap := *
939 }
940 }
941
942
943 template PDU_BSSGP t_BVC_UNBLOCK(template BssgpBvci bvci) := {
944 pDU_BSSGP_BVC_UNBLOCK := {
945 bssgpPduType := '24'O,
946 bVCI := t_BSSGP_BVCI(bvci)
947 }
948 }
949
950 template PDU_BSSGP t_BVC_UNBLOCK_ACK(template BssgpBvci bvci) := {
951 pDU_BSSGP_BVC_UNBLOCK_ACK := {
952 bssgpPduType := '25'O,
953 bVCI := t_BSSGP_BVCI(bvci)
954 }
955 }
956
957 template PDU_BSSGP t_BVC_BLOCK(template BssgpBvci bvci, template BssgpCause cause) := {
958 pDU_BSSGP_BVC_BLOCK := {
959 bssgpPduType := '20'O,
960 bVCI := t_BSSGP_BVCI(bvci),
961 cause := t_BSSGP_CAUSE(cause)
962 }
963 }
964
965 template PDU_BSSGP t_BVC_BLOCK_ACK(template BssgpBvci bvci) := {
966 pDU_BSSGP_BVC_BLOCK_ACK := {
967 bssgpPduType := '21'O,
968 bVCI := t_BSSGP_BVCI(bvci)
969 }
970 }
971
972 template PDU_BSSGP t_BVC_FC_BVC(uint16_t bmax, uint16_t bucket_leak_rate,
973 uint16_t bmax_default_ms, uint16_t r_default_ms, OCT1 tag) := {
974 pDU_BSSGP_FLOW_CONTROL_BVC := {
975 bssgpPduType := '26'O,
976 tag := {
977 iEI := '1E'O,
978 ext := '1'B,
979 lengthIndicator := {
Harald Welteedcdd902018-03-02 22:04:54 +0100980 length1 := 1
Harald Weltee0abc472018-02-05 09:13:31 +0100981 },
982 unstructured_Value := tag
983 },
984 bVC_Bucket_Size := {
985 iEI := '05'O,
986 ext := '1'B,
987 lengthIndicator := {
988 length1 := 2
989 },
990 bmax := f_oct_or_wc(bmax, 2)
991 },
992 bucket_Leak_Rate := {
993 iEI := '03'O,
994 ext := '1'B,
995 lengthIndicator := {
Harald Welteedcdd902018-03-02 22:04:54 +0100996 length1 := 2
Harald Weltee0abc472018-02-05 09:13:31 +0100997 },
998 r_Value := f_oct_or_wc(bucket_leak_rate, 2)
999 },
1000 bmax_default_MS := {
1001 iEI := '01'O,
1002 ext := '1'B,
1003 lengthIndicator := {
1004 length1 := 2
1005 },
1006 bmax := f_oct_or_wc(bmax_default_ms, 2)
1007 },
1008 r_default_MS := {
1009 iEI := '1C'O,
1010 ext := '1'B,
1011 lengthIndicator := {
1012 length1 := 2
1013 },
1014 r_default_MS_value := f_oct_or_wc(r_default_ms, 2)
1015 },
1016 bucket_Full_Ratio := omit,
1017 bVC_Measurement := omit,
1018 flow_Control_Granularity := omit
1019 }
1020 }
Harald Welteedcdd902018-03-02 22:04:54 +01001021 template PDU_BSSGP tr_BVC_FC_BVC(template uint16_t bmax := ?,
1022 template uint16_t bucket_leak_rate := ?,
1023 template uint16_t bmax_default_ms := ?,
1024 template uint16_t r_default_ms := ?,
1025 template OCT1 tag := ?) := {
1026 pDU_BSSGP_FLOW_CONTROL_BVC := {
1027 bssgpPduType := '26'O,
1028 tag := {
1029 iEI := '1E'O,
1030 ext := '1'B,
1031 lengthIndicator := {
1032 length1 := 1
1033 },
1034 unstructured_Value := tag
1035 },
1036 bVC_Bucket_Size := {
1037 iEI := '05'O,
1038 ext := '1'B,
1039 lengthIndicator := {
1040 length1 := 2
1041 },
1042 bmax := f_oct_or_wc(bmax, 2)
1043 },
1044 bucket_Leak_Rate := {
1045 iEI := '03'O,
1046 ext := '1'B,
1047 lengthIndicator := {
1048 length1 := 2
1049 },
1050 r_Value := f_oct_or_wc(bucket_leak_rate, 2)
1051 },
1052 bmax_default_MS := {
1053 iEI := '01'O,
1054 ext := '1'B,
1055 lengthIndicator := {
1056 length1 := 2
1057 },
1058 bmax := f_oct_or_wc(bmax_default_ms, 2)
1059 },
1060 r_default_MS := {
1061 iEI := '1C'O,
1062 ext := '1'B,
1063 lengthIndicator := {
1064 length1 := 2
1065 },
1066 r_default_MS_value := f_oct_or_wc(r_default_ms, 2)
1067 },
1068 bucket_Full_Ratio := *,
1069 bVC_Measurement := *,
1070 flow_Control_Granularity := *
1071 }
1072 }
1073
Harald Weltee0abc472018-02-05 09:13:31 +01001074 template PDU_BSSGP t_BVC_FC_BVC_ACK(template OCT1 tag) := {
1075 pDU_BSSGP_FLOW_CONTROL_BVC_ACK := {
1076 bssgpPduType := '27'O,
1077 tag := {
1078 iEI := '1E'O,
1079 ext := '1'B,
1080 lengthIndicator := {
1081 length1 := 2
1082 },
1083 unstructured_Value := tag
1084 }
1085 }
1086 }
1087
1088 template PDU_BSSGP ts_BSSGP_STATUS(template BssgpBvci bvci, template BssgpCause cause,
1089 PDU_BSSGP pdu) := {
1090 pDU_BSSGP_STATUS := {
Pau Espin Pedrolc03eb122020-08-27 18:54:24 +02001091 bssgpPduType := '41'O,
Harald Weltee0abc472018-02-05 09:13:31 +01001092 cause := t_BSSGP_CAUSE(cause),
1093 bVCI := t_BSSGP_BVCI(bvci),
1094 pDU_in_Error := {
1095 iEI := '15'O,
1096 ext := '1'B,
1097 lengthIndicator := {
1098 length1 := 0 /* overwritten */
1099 },
1100 erroneous_BSSGP_PDU := enc_PDU_BSSGP(pdu)
1101 }
1102 }
1103 }
1104
Pau Espin Pedrolc03eb122020-08-27 18:54:24 +02001105 template PDU_BSSGP tr_BSSGP_STATUS(template BVCI bvci := ?, template BssgpCause cause := ?,
1106 template octetstring pdu := ?) := {
1107 pDU_BSSGP_STATUS := {
1108 bssgpPduType := '41'O,
1109 cause := t_BSSGP_CAUSE(cause),
1110 bVCI := bvci,
1111 pDU_in_Error := {
1112 iEI := '15'O,
1113 ext := '1'B,
1114 lengthIndicator := {
1115 length1 := ?
1116 },
1117 erroneous_BSSGP_PDU := pdu
1118 }
1119 }
1120 }
1121
Pau Espin Pedrol1860bf82020-04-25 16:23:35 +02001122 private function f_presence_bit_MultislotCap_GPRS_BSSGP(template (omit) MultislotCap_GPRS_BSSGP mscap_gprs) return BIT1 {
Pau Espin Pedrol2422d1f2020-01-23 17:51:04 +01001123 if (istemplatekind(mscap_gprs, "omit")) {
1124 return '0'B;
1125 }
1126 return '1'B;
1127 }
Pau Espin Pedrol1860bf82020-04-25 16:23:35 +02001128 private function f_presence_bit_MultislotCap_EGPRS_BSSGP(template (omit) MultislotCap_EGPRS_BSSGP mscap_egprs) return BIT1 {
Pau Espin Pedrol2422d1f2020-01-23 17:51:04 +01001129 if (istemplatekind(mscap_egprs, "omit")) {
1130 return '0'B;
1131 }
1132 return '1'B;
1133 }
1134 template (value) MSRACapabilityValuesRecord_BSSGP ts_RaCapRec_BSSGP(BIT4 att := '0001'B /* E-GSM */, template (omit) MultislotCap_GPRS_BSSGP mscap_gprs := omit, template (omit) MultislotCap_EGPRS_BSSGP mscap_egprs := omit) := {
1135 mSRACapabilityValues := {
1136 mSRACapabilityValuesExclude1111 := {
1137 accessTechnType := att, /* E-GSM */
1138 accessCapabilities := {
1139 lengthIndicator := 0, /* overwritten */
1140 accessCapabilities := {
1141 rfPowerCapability := '001'B, /* FIXME */
1142 presenceBitA5 := '0'B,
1143 a5bits := omit,
1144 esind := '1'B,
1145 psbit := '0'B,
1146 vgcs := '0'B,
1147 vbs := '0'B,
1148 presenceBitMultislot := '1'B,
1149 multislotcap := {
1150 presenceBitHscsd := '0'B,
1151 hscsdmultislotclass := omit,
Pau Espin Pedrol1860bf82020-04-25 16:23:35 +02001152 presenceBitGprs := f_presence_bit_MultislotCap_GPRS_BSSGP(mscap_gprs),
Pau Espin Pedrol2422d1f2020-01-23 17:51:04 +01001153 gprsmultislot := mscap_gprs,
1154 presenceBitSms := '0'B,
1155 multislotCap_SMS := omit,
1156 multislotCapAdditionsAfterRel97 := {
1157 presenceBitEcsdmulti := '0'B,
1158 ecsdmultislotclass := omit,
Pau Espin Pedrol1860bf82020-04-25 16:23:35 +02001159 presenceBitEgprsmulti := f_presence_bit_MultislotCap_EGPRS_BSSGP(mscap_egprs),
Pau Espin Pedrol2422d1f2020-01-23 17:51:04 +01001160 multislotCap_EGPRS := mscap_egprs,
1161 presenceBitDtmGprsmulti := '0'B,
1162 multislotCapdtmgprsmultislotsubclass := omit
1163 }
1164 },
1165 accessCapAdditionsAfterRel97 := omit
1166 },
1167 spare_bits := omit
1168 }
1169 }
1170 },
1171 presenceBitMSRACap := '0'B
1172 };
1173
Harald Weltee0abc472018-02-05 09:13:31 +01001174 template QoS_Profile_V t_defaultQos := {
1175 peak_Bit_Rate := int2oct(80, 2),
1176 precedence := '000'B,
1177 a_bit := '0'B,
1178 t_bit := '0'B,
1179 c_r_bit := '0'B,
1180 peakBitRateGranularity := '00'B
1181 }
1182
1183 template QoS_Profile ts_QoS_TLV(template QoS_Profile_V qos) := {
1184 iEI := '18'O,
1185 ext := '1'B,
1186 lengthIndicator := { length1 := 3 },
1187 peak_Bit_Rate := qos.peak_Bit_Rate,
1188 precedence := qos.precedence,
1189 a_bit := qos.a_bit,
1190 t_bit := qos.t_bit,
1191 c_r_bit := qos.c_r_bit,
1192 peakBitRateGranularity := qos.peakBitRateGranularity
1193 }
1194
1195 template PDU_Lifetime t_DefaultLifetime(uint16_t delay := 65535) := {
1196 iEI := '16'O,
1197 ext := '1'B,
1198 lengthIndicator := {
1199 length1 := 2
1200 },
1201 delay_Value := f_oct_or_wc(delay, 2)
1202 }
1203
Pau Espin Pedrol88bf5372019-12-09 21:12:28 +01001204 template DRX_Parameters t_defaultDRXparam := {
1205 iEI := '0A'O,
1206 ext := '1'B,
1207 lengthIndicator := {
1208 length1 := 2
1209 },
1210 splitPG_CycleCode := '00'O,
1211 nonDRXTimer := '000'B,
1212 splitOnCCCH := '0'B,
1213 cnSpecificDRXCycleLength := '0000'B
1214 }
1215
Pau Espin Pedrol2422d1f2020-01-23 17:51:04 +01001216 function ts_BSSGP_IE_MSRAcap_omit(template (omit) MSRadioAccessCapabilityV_BSSGP racap) return template (omit) MS_Radio_Access_Capability {
1217 var template (omit) MS_Radio_Access_Capability ret;
1218 if (istemplatekind(racap, "omit")) {
1219 return omit;
1220 } else {
1221 ret := {
1222 iEI := '00'O,
1223 ext := '1'B,
1224 lengthIndicator := {
1225 length1 := 1
1226 },
1227 mSRadioAccessCapabilityV_BSSGP := racap
1228 }
1229 return ret;
1230 }
1231 }
1232
Pau Espin Pedrolc03eb122020-08-27 18:54:24 +02001233 template PDU_BSSGP ts_BSSGP_DL_UD(GprsTlli tlli, octetstring pdu,
1234 template (omit) MSRadioAccessCapabilityV_BSSGP racap := omit,
1235 template (omit) IMSI_BSSGP imsi := omit) := {
Harald Weltee0abc472018-02-05 09:13:31 +01001236 pDU_BSSGP_DL_UNITDATA := {
1237 bssgpPduType := '00'O,
Harald Welteacc93ab2018-03-02 21:39:09 +01001238 tLLI_current := tlli,
Harald Weltee0abc472018-02-05 09:13:31 +01001239 qoS_Profile := t_defaultQos,
1240 pDU_Lifetime := t_DefaultLifetime(65535),
Pau Espin Pedrol2422d1f2020-01-23 17:51:04 +01001241 mS_Radio_Access_Capability := ts_BSSGP_IE_MSRAcap_omit(racap),
Harald Weltee0abc472018-02-05 09:13:31 +01001242 priority := omit,
1243 dRX_Parameters := omit,
Pau Espin Pedrolc03eb122020-08-27 18:54:24 +02001244 iMSI := imsi,
Harald Weltee0abc472018-02-05 09:13:31 +01001245 tLLI_old := omit,
1246 pFI := omit,
1247 lSA_Information := omit,
1248 service_UTRAN_CCO := omit,
1249 service_Class_Indicator := omit,
1250 subscriber_Profile_ID_For_RAT_Priority := omit,
1251 redirection_Indication := omit,
1252 redirection_Completed := omit,
1253 unconfirmed_Send_State_Variable := omit,
1254 sCI := omit,
1255 gGSN_PGW_Location := omit,
1256 eDRX_Paremeters := omit,
1257 old_Routing_Area_Identification := omit,
1258 attach_Indicator := omit,
1259 alignment_octets := omit,
1260 lLC_PDU := ts_BSSGP_LLC_PDU(pdu),
1261 initialLLC_PDU := omit
1262 }
1263 }
1264
1265 template PDU_BSSGP tr_BSSGP_DL_UD := {
1266 pDU_BSSGP_DL_UNITDATA := {
1267 bssgpPduType := '00'O,
1268 tLLI_current := ?,
1269 qoS_Profile := ?,
1270 pDU_Lifetime := ?,
1271 mS_Radio_Access_Capability := *,
1272 priority := *,
1273 dRX_Parameters := *,
1274 iMSI := *,
1275 tLLI_old := *,
1276 pFI := *,
1277 lSA_Information := *,
1278 service_UTRAN_CCO := *,
1279 service_Class_Indicator := *,
1280 subscriber_Profile_ID_For_RAT_Priority := *,
1281 redirection_Indication := *,
1282 redirection_Completed := *,
1283 unconfirmed_Send_State_Variable := *,
1284 sCI := *,
1285 gGSN_PGW_Location := *,
1286 eDRX_Paremeters := *,
1287 old_Routing_Area_Identification := *,
1288 attach_Indicator := *,
1289 alignment_octets := *,
1290 lLC_PDU := tr_BSSGP_LLC_PDU,
1291 initialLLC_PDU := *
1292 }
1293 }
1294
Harald Welteacc93ab2018-03-02 21:39:09 +01001295 template PDU_BSSGP ts_BSSGP_UL_UD(GprsTlli tlli, BssgpCellId cell_id, octetstring payload) := {
Harald Welte78d9f272018-02-16 18:13:45 +01001296 pDU_BSSGP_UL_UNITDATA := {
1297 bssgpPduType := '01'O,
1298 tLLI := tlli,
1299 qoS_Profile := t_defaultQos,
1300 cell_Identifier := t_BSSGP_IE_CellId(cell_id),
1301 pFI := omit,
1302 lSA_Identifier_List := omit,
1303 redirect_Attempt_Flag := omit,
1304 iMSI_BSSGP := omit,
1305 unconfirmed_Send_State_Variable := omit,
1306 selected_PLMN_ID := omit,
1307 selected_Operator := omit,
1308 cS_Registered_Operator := omit,
1309 alignment_octets := omit,
1310 lLC_PDU := ts_BSSGP_LLC_PDU(payload)
1311 }
1312 }
1313
Harald Weltee0abc472018-02-05 09:13:31 +01001314 template PDU_BSSGP tr_BSSGP_UL_UD(template GprsTlli tlli := ?, template BssgpCellId cell_id := ?,
1315 template octetstring payload := ?) := {
1316 pDU_BSSGP_UL_UNITDATA := {
1317 bssgpPduType := '01'O,
Harald Welteacc93ab2018-03-02 21:39:09 +01001318 tLLI := tlli,
Harald Weltee0abc472018-02-05 09:13:31 +01001319 qoS_Profile := ?,
1320 cell_Identifier := t_BSSGP_IE_CellId(cell_id),
1321 pFI := *,
1322 lSA_Identifier_List := *,
1323 redirect_Attempt_Flag := *,
1324 iMSI_BSSGP := *,
1325 unconfirmed_Send_State_Variable := *,
1326 selected_PLMN_ID := *,
1327 selected_Operator := *,
1328 cS_Registered_Operator := *,
1329 alignment_octets := *,
1330 lLC_PDU := tr_BSSGP_LLC_PDU(payload)
1331 }
1332 }
1333
Pau Espin Pedrol88bf5372019-12-09 21:12:28 +01001334 template PDU_BSSGP tr_BSSGP_CS_PAGING(BssgpBvci bvci) := {
1335 pDU_BSSGP_PAGING_CS := {
1336 bssgpPduType := '07'O,
1337 iMSI := ?,
1338 dRX_Parameters := ?,
1339 paging_Field4 := {
1340 bVCI := t_BSSGP_BVCI(bvci)
1341 },
1342 tLLI := *,
1343 channel_needed := *,
1344 eMLPP_Priority := *,
1345 tMSI := *,
1346 global_CN_Id := *
1347 }
1348 }
1349
1350 template PDU_BSSGP ts_BSSGP_CS_PAGING_IMSI(BssgpBvci bvci, hexstring imsi) := {
1351 pDU_BSSGP_PAGING_CS := {
1352 bssgpPduType := '07'O,
1353 iMSI := ts_BSSGP_IMSI(imsi),
1354 dRX_Parameters := t_defaultDRXparam,
1355 paging_Field4 := {
1356 bVCI := t_BSSGP_BVCI(bvci)
1357 },
1358 tLLI := omit,
1359 channel_needed := omit,
1360 eMLPP_Priority := omit,
1361 tMSI := omit,
1362 global_CN_Id := omit
1363 }
1364 }
1365
Vadim Yanitskiy7b224212020-03-26 02:43:55 +07001366 template PDU_BSSGP ts_BSSGP_CS_PAGING_PTMSI(BssgpBvci bvci, hexstring imsi, GsmTmsi tmsi) := {
1367 pDU_BSSGP_PAGING_CS := {
1368 bssgpPduType := '07'O,
1369 iMSI := ts_BSSGP_IMSI(imsi),
1370 dRX_Parameters := t_defaultDRXparam,
1371 paging_Field4 := {
1372 bVCI := t_BSSGP_BVCI(bvci)
1373 },
1374 tLLI := omit,
1375 channel_needed := omit,
1376 eMLPP_Priority := omit,
1377 tMSI := ts_BSSGP_TMSI(tmsi),
1378 global_CN_Id := omit
1379 }
1380 }
1381
Harald Weltea36b2462020-06-17 22:11:08 +02001382 template PDU_BSSGP tr_BSSGP_PS_PAGING(template BssgpBvci bvci) := {
Harald Welte78d9f272018-02-16 18:13:45 +01001383 pDU_BSSGP_PAGING_PS := {
1384 bssgpPduType := '06'O,
1385 iMSI := ?,
1386 dRX_Parameters := *,
1387 paging_Field4 := {
1388 bVCI := t_BSSGP_BVCI(bvci)
1389 },
1390 pFI := *,
1391 aBQP := *,
1392 qoS_Profile := ?,
1393 pTMSI := *,
1394 eDRX_Paremeters := *
1395 }
1396 }
1397
Harald Weltee0abc472018-02-05 09:13:31 +01001398 template PDU_BSSGP ts_BSSGP_PS_PAGING_IMSI(BssgpBvci bvci, hexstring imsi) := {
1399 pDU_BSSGP_PAGING_PS := {
1400 bssgpPduType := '06'O,
1401 iMSI := ts_BSSGP_IMSI(imsi),
1402 dRX_Parameters := omit,
1403 paging_Field4 := {
1404 bVCI := t_BSSGP_BVCI(bvci)
1405 },
1406 pFI := omit,
1407 aBQP := omit,
1408 qoS_Profile := ts_QoS_TLV(t_defaultQos),
1409 pTMSI := omit,
1410 eDRX_Paremeters := omit
1411 }
1412 }
1413
1414 template PDU_BSSGP ts_BSSGP_PS_PAGING_PTMSI(BssgpBvci bvci, hexstring imsi, GsmTmsi tmsi) := {
1415 pDU_BSSGP_PAGING_PS := {
1416 bssgpPduType := '06'O,
1417 iMSI := ts_BSSGP_IMSI(imsi),
1418 dRX_Parameters := omit,
1419 paging_Field4 := {
1420 bVCI := t_BSSGP_BVCI(bvci)
1421 },
1422 pFI := omit,
1423 aBQP := omit,
1424 qoS_Profile := ts_QoS_TLV(t_defaultQos),
1425 pTMSI := ts_BSSGP_TMSI(tmsi),
1426 eDRX_Paremeters := omit
1427 }
1428 }
1429
Harald Welte23989a62019-03-21 21:32:45 +01001430 template (value) Routeing_Area ts_BSSGP_RA_ID(RoutingAreaIdentification input) := {
1431 iEI := '1B'O,
1432 ext := '1'B,
1433 lengthIndicator := {
1434 length1 := 6
1435 },
1436 mccDigit1 := input.lai.mcc_mnc[0],
1437 mccDigit2 := input.lai.mcc_mnc[1],
1438 mccDigit3 := input.lai.mcc_mnc[2],
1439 mncDigit3 := input.lai.mcc_mnc[3],
1440 mncDigit1 := input.lai.mcc_mnc[4],
1441 mncDigit2 := input.lai.mcc_mnc[5],
1442 lac := int2oct(input.lai.lac, 2),
1443 rac := int2oct(input.rac, 1)
1444 }
1445
1446 template (value) PDU_BSSGP ts_BSSGP_SUSPEND(GprsTlli tlli, RoutingAreaIdentification ra_id) := {
1447 pDU_BSSGP_SUSPEND := {
1448 bssgpPduType := '0B'O,
1449 tLLI := ts_BSSGP_TLLI(tlli),
1450 routeing_Area := ts_BSSGP_RA_ID(ra_id)
1451 }
1452 }
1453 template PDU_BSSGP tr_BSSGP_SUSPEND(template GprsTlli tlli, RoutingAreaIdentification ra_id) := {
1454 pDU_BSSGP_SUSPEND := {
1455 bssgpPduType := '0B'O,
1456 tLLI := tr_BSSGP_TLLI(tlli),
1457 routeing_Area := ts_BSSGP_RA_ID(ra_id)
1458 }
1459 }
1460
1461 template (value) PDU_BSSGP ts_BSSGP_SUSPEND_ACK(GprsTlli tlli, RoutingAreaIdentification ra_id,
1462 template (value) OCT1 susp_ref) := {
1463 pDU_BSSGP_SUSPEND_ACK := {
1464 bssgpPduType := '0C'O,
1465 tLLI := ts_BSSGP_TLLI(tlli),
1466 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1467 suspend_Reference_Number := ts_BSSGP_SUSP_REF(susp_ref)
1468 }
1469 }
1470 template PDU_BSSGP tr_BSSGP_SUSPEND_ACK(GprsTlli tlli, RoutingAreaIdentification ra_id,
1471 template OCT1 susp_ref) := {
1472 pDU_BSSGP_SUSPEND_ACK := {
1473 bssgpPduType := '0C'O,
1474 tLLI := tr_BSSGP_TLLI(tlli),
1475 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1476 suspend_Reference_Number := tr_BSSGP_SUSP_REF(susp_ref)
1477 }
1478 }
1479
1480 template (value) PDU_BSSGP ts_BSSGP_SUSPEND_NACK(GprsTlli tlli, RoutingAreaIdentification ra_id,
1481 template (omit) BssgpCause cause) := {
1482 pDU_BSSGP_SUSPEND_NACK := {
1483 bssgpPduType := '0D'O,
1484 tLLI := ts_BSSGP_TLLI(tlli),
1485 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1486 cause := ts_BSSGP_CAUSE(cause)
1487 }
1488 }
1489 template PDU_BSSGP tr_BSSGP_SUSPEND_NACK(GprsTlli tlli, RoutingAreaIdentification ra_id,
1490 template BssgpCause cause) := {
1491 pDU_BSSGP_SUSPEND_NACK := {
1492 bssgpPduType := '0D'O,
1493 tLLI := tr_BSSGP_TLLI(tlli),
1494 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1495 cause := t_BSSGP_CAUSE(cause)
1496 }
1497 }
1498
1499
1500
1501 template (value) PDU_BSSGP ts_BSSGP_RESUME(GprsTlli tlli, RoutingAreaIdentification ra_id,
1502 OCT1 susp_ref) := {
1503 pDU_BSSGP_RESUME := {
1504 bssgpPduType := '0E'O,
1505 tLLI := ts_BSSGP_TLLI(tlli),
1506 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1507 suspend_Reference_Number := ts_BSSGP_SUSP_REF(susp_ref)
1508 }
1509 }
1510 template PDU_BSSGP tr_BSSGP_RESUME(template GprsTlli tlli, RoutingAreaIdentification ra_id,
1511 template OCT1 susp_ref) := {
1512 pDU_BSSGP_RESUME := {
1513 bssgpPduType := '0E'O,
1514 tLLI := tr_BSSGP_TLLI(tlli),
1515 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1516 suspend_Reference_Number := tr_BSSGP_SUSP_REF(susp_ref)
1517 }
1518 }
1519
1520 template (value) PDU_BSSGP ts_BSSGP_RESUME_ACK(GprsTlli tlli, RoutingAreaIdentification ra_id)
1521 := {
1522 pDU_BSSGP_RESUME_ACK := {
1523 bssgpPduType := '0F'O,
1524 tLLI := ts_BSSGP_TLLI(tlli),
1525 routeing_Area := ts_BSSGP_RA_ID(ra_id)
1526 }
1527 }
1528 template PDU_BSSGP tr_BSSGP_RESUME_ACK(template GprsTlli tlli,
1529 RoutingAreaIdentification ra_id) := {
1530 pDU_BSSGP_RESUME_ACK := {
1531 bssgpPduType := '0F'O,
1532 tLLI := tr_BSSGP_TLLI(tlli),
1533 routeing_Area := ts_BSSGP_RA_ID(ra_id)
1534 }
1535 }
1536
1537 template (value) PDU_BSSGP ts_BSSGP_RESUME_NACK(GprsTlli tlli, RoutingAreaIdentification ra_id,
1538 template (omit) BssgpCause cause) := {
1539 pDU_BSSGP_RESUME_NACK := {
1540 bssgpPduType := '10'O,
1541 tLLI := ts_BSSGP_TLLI(tlli),
1542 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1543 cause := ts_BSSGP_CAUSE(cause)
1544 }
1545 }
1546 template PDU_BSSGP tr_BSSGP_RESUME_NACK(template GprsTlli tlli,
1547 RoutingAreaIdentification ra_id,
1548 template BssgpCause cause) := {
1549 pDU_BSSGP_RESUME_NACK := {
1550 bssgpPduType := '10'O,
1551 tLLI := tr_BSSGP_TLLI(tlli),
1552 routeing_Area := ts_BSSGP_RA_ID(ra_id),
1553 cause := t_BSSGP_CAUSE(cause)
1554 }
1555 }
1556
1557
1558
Harald Weltee0abc472018-02-05 09:13:31 +01001559
1560} with { encode "RAW" };