blob: 092026e3ad73a4074ec81115c949e113844a754e [file] [log] [blame]
Harald Weltec76f29f2017-11-22 12:46:46 +01001module L3_Templates {
2
Harald Welte35bb7162018-01-03 21:07:52 +01003/* L3 Templates, building on top of MobileL3*_Types from Ericsson.
4 *
Harald Weltef45efeb2018-04-09 18:19:24 +02005 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte35bb7162018-01-03 21:07:52 +01006 * All rights reserved.
7 *
8 * Released under the terms of GNU General Public License, Version 2 or
9 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +020010 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
Harald Welte35bb7162018-01-03 21:07:52 +010012 */
13
Harald Weltec76f29f2017-11-22 12:46:46 +010014import from General_Types all;
Harald Welte38575a72018-02-15 20:41:37 +010015import from Osmocom_Types all;
Harald Weltec76f29f2017-11-22 12:46:46 +010016import from MobileL3_Types all;
17import from MobileL3_CommonIE_Types all;
18import from MobileL3_MM_Types all;
19import from MobileL3_RRM_Types all;
Harald Weltecb6cc332018-01-21 13:59:08 +010020import from MobileL3_CC_Types all;
Harald Welte38575a72018-02-15 20:41:37 +010021import from MobileL3_GMM_SM_Types all;
Harald Weltef45efeb2018-04-09 18:19:24 +020022import from MobileL3_SMS_Types all;
Harald Weltecb6cc332018-01-21 13:59:08 +010023
Harald Welte51affb62018-04-09 14:17:45 +020024/* TS 24.007 Table 11.3 TI Flag */
25const BIT1 c_TIF_ORIG := '0'B;
26const BIT1 c_TIF_REPL := '1'B;
Harald Weltec76f29f2017-11-22 12:46:46 +010027
28type enumerated CmServiceType {
29 CM_TYPE_MO_CALL ('0001'B),
30 CM_TYPE_EMERG_CALL ('0010'B),
31 CM_TYPE_MO_SMS ('0100'B),
Harald Welte6ed6bf92018-01-24 21:09:15 +010032 CM_TYPE_SS_ACT ('1000'B),
33 CM_TYPE_VGCS ('1001'B),
34 CM_TYPE_VBS ('1010'B),
35 CM_TYPE_LCS ('1011'B)
Harald Weltec76f29f2017-11-22 12:46:46 +010036}
37
Oliver Smith32898452019-07-09 12:32:35 +020038/* TS 24.008 10.5.3.4 Identity Type */
39type enumerated CmIdentityType {
40 CM_ID_TYPE_IMSI ('001'B),
41 CM_ID_TYPE_IMEI ('010'B),
42 CM_ID_TYPE_IMEISV ('011'B),
43 CM_ID_TYPE_TMSI ('100'B),
44 CM_ID_TYPE_PTMSI_RAI_PTMSI_SIG ('101'B)
45}
46
Harald Welte33ec09b2018-02-10 15:34:46 +010047template ML3_Cause_TLV ts_ML3_Cause(BIT7 cause, BIT4 loc := '0001'B, BIT2 std := '11'B) := {
48 elementIdentifier := '08'O,
49 lengthIndicator := 0, /* overwritten */
50 oct3 := {
51 location := loc,
52 spare1_1 := '0'B,
53 codingStandard := std,
54 ext1 := '0'B,
55 recommendation := omit,
56 ext2 := omit
57 },
58 oct4 := {
59 causeValue := cause,
60 ext3 := '1'B
61 },
62 diagnostics := omit
63}
64
Harald Weltec76f29f2017-11-22 12:46:46 +010065
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +070066/* 3GPP TS 24.008, section 10.5.1.4 "Mobile Identity" */
67template (value) MobileIdentityTLV ts_MI_TLV(template (value) MobileIdentityV mi) := {
68 elementIdentifier := '0010111'B,
69 spare1 := '0'B,
70 mobileIdentityLV := ts_MI_LV(mi)
71};
72template MobileIdentityTLV tr_MI_TLV(template MobileIdentityV mi) := {
73 elementIdentifier := '0010111'B,
74 spare1 := '0'B,
75 mobileIdentityLV := tr_MI_LV(mi)
76};
77
78template (value) MobileIdentityLV ts_MI_LV(template (value) MobileIdentityV mi) := {
79 lengthIndicator := 0, /* overwritten */
80 mobileIdentityV := mi
81};
82template MobileIdentityLV tr_MI_LV(template MobileIdentityV mi) := {
83 lengthIndicator := ?,
84 mobileIdentityV := mi
85};
86
87/* Universal (send & receive) template for No Identity */
88template MobileIdentityV t_MI_NoIdentity(template (present) hexstring filler := 'F'H) := {
89 typeOfIdentity := '000'B,
90 oddEvenInd_identity := {
91 no_identity := {
92 /* Always old, since length can be 1, 3, or 5 */
93 oddevenIndicator := '0'B,
94 fillerDigits := filler
95 }
96 }
97};
98
99/* Universal (send & receive) template for TMSI/P-TMSI */
100template MobileIdentityV t_MI_TMSI(template (present) OCT4 tmsi) := {
101 typeOfIdentity := '100'B,
102 oddEvenInd_identity := {
103 tmsi_ptmsi := {
104 oddevenIndicator := '0'B,
105 fillerDigit := '1111'B,
106 octets := tmsi
107 }
108 }
109};
110
111private function f_tr_MI_IMSI(template (present) hexstring digits)
112return template (present) IMSI_L3 {
113 if (istemplatekind(digits, "?")) {
114 return ?;
115 } else {
116 return f_enc_IMSI_L3(valueof(digits))
117 }
118}
119template MobileIdentityV tr_MI_IMSI(template hexstring imsi) := {
120 typeOfIdentity := '001'B,
121 oddEvenInd_identity := {
122 imsi := f_tr_MI_IMSI(imsi)
123 }
124};
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +0700125template (value) MobileIdentityV ts_MI_IMSI(hexstring imsi) := {
126 typeOfIdentity := '001'B,
127 oddEvenInd_identity := {
128 imsi := f_enc_IMSI_L3(imsi)
129 }
130};
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +0700131
132
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200133/* send template for Mobile Identity (TMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100134template MobileIdentityLV ts_MI_TMSI_LV(OCT4 tmsi) := {
135 lengthIndicator := 0, /* overwritten */
136 mobileIdentityV := {
137 typeOfIdentity := '000'B, /* overwritten */
138 oddEvenInd_identity := {
139 tmsi_ptmsi := {
140 oddevenIndicator := '0'B,
141 fillerDigit := '1111'B,
142 octets := tmsi
143 }
144 }
145 }
146}
147
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200148/* send template for Mobile Identity (TMSI) */
Harald Welte6abb9fe2018-02-17 15:24:48 +0100149function ts_MI_TMSI_TLV(template (omit) OCT4 tmsi) return template (omit) MobileIdentityTLV {
150 var template (omit) MobileIdentityTLV ret;
151 if (istemplatekind(tmsi, "omit")) {
152 return omit;
153 } else {
154 ret := {
155 elementIdentifier := '0100011'B,
156 spare1 := '0'B,
157 mobileIdentityLV := ts_MI_TMSI_LV(valueof(tmsi))
158 }
159 return ret;
160 }
Harald Welte38575a72018-02-15 20:41:37 +0100161}
162
Harald Welteb0386df2018-02-16 18:14:28 +0100163template MobileIdentityTLV ts_MI_IMEISV_TLV(hexstring imeisv) := {
164 elementIdentifier := '0100011'B,
165 spare1 := '0'B,
166 mobileIdentityLV := ts_MI_IMEISV_LV(imeisv)
167}
168
Harald Weltec76f29f2017-11-22 12:46:46 +0100169private function f_enc_IMSI_L3(hexstring digits) return IMSI_L3 {
170 var IMSI_L3 l3;
171 var integer len := lengthof(digits);
172 if (len rem 2 == 1) { /* modulo remainder */
Harald Welte365f4ed2017-11-23 00:00:43 +0100173 l3.oddevenIndicator := '1'B;
Harald Welteae136252018-01-24 20:53:21 +0100174 l3.fillerDigit := omit;
Harald Weltec76f29f2017-11-22 12:46:46 +0100175 } else {
Harald Welte365f4ed2017-11-23 00:00:43 +0100176 l3.oddevenIndicator := '0'B;
Harald Welteae136252018-01-24 20:53:21 +0100177 l3.fillerDigit := '1111'B;
Harald Weltec76f29f2017-11-22 12:46:46 +0100178 }
179 l3.digits := digits;
180 return l3;
181}
182
Harald Welteba7b6d92018-01-23 21:32:34 +0100183private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {
184 var IMEI_L3 l3;
185 var integer len := lengthof(digits);
186 if (len rem 2 == 1) { /* modulo remainder */
187 l3.oddevenIndicator := '1'B;
188 } else {
189 l3.oddevenIndicator := '0'B;
190 }
191 l3.digits := digits;
192 return l3;
193}
194
Harald Welteb0386df2018-02-16 18:14:28 +0100195private function f_enc_IMEI_SV(hexstring digits) return IMEI_SV {
196 var IMEI_SV l3;
197 var integer len := lengthof(digits);
198 if (len rem 2 == 1) { /* modulo remainder */
199 l3.oddevenIndicator := '1'B;
200 } else {
201 l3.oddevenIndicator := '0'B;
202 }
203 l3.digits := digits;
204 l3.fillerDigit := '1111'B;
205 return l3;
206}
207
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200208/* send template for Mobile Identity (IMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100209template (value) MobileIdentityLV ts_MI_IMSI_LV(hexstring imsi_digits) := {
210 lengthIndicator := 0, /* overwritten */
211 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100212 typeOfIdentity := '001'B,
Harald Weltec76f29f2017-11-22 12:46:46 +0100213 oddEvenInd_identity := {
214 imsi := f_enc_IMSI_L3(imsi_digits)
215 }
216 }
217}
218
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200219/* send template for Mobile Identity (IMEI) */
Harald Welteba7b6d92018-01-23 21:32:34 +0100220template (value) MobileIdentityLV ts_MI_IMEI_LV(hexstring imei_digits) := {
221 lengthIndicator := 0, /* overwritten */
222 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100223 typeOfIdentity := '010'B,
Harald Welteba7b6d92018-01-23 21:32:34 +0100224 oddEvenInd_identity := {
225 imei := f_enc_IMEI_L3(imei_digits)
226 }
227 }
228}
229
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200230/* send template for Mobile Identity (IMEISV) */
Harald Welteb0386df2018-02-16 18:14:28 +0100231template (value) MobileIdentityLV ts_MI_IMEISV_LV(hexstring imei_digits) := {
232 lengthIndicator := 0, /* overwritten */
233 mobileIdentityV := {
234 typeOfIdentity := '011'B,
235 oddEvenInd_identity := {
236 imei_sv := f_enc_IMEI_SV(imei_digits)
237 }
238 }
239}
240
Harald Welteba7b6d92018-01-23 21:32:34 +0100241
Harald Weltec76f29f2017-11-22 12:46:46 +0100242/* Send template for Classmark 2 */
243template (value) MobileStationClassmark2_LV ts_CM2 := {
244 lengthIndicator := 0,
245 rf_PowerCapability := '000'B,
246 a5_1 := '0'B,
247 esind := '1'B,
248 revisionLevel := '10'B,
249 spare1_1 := '0'B,
Harald Welte898113b2018-01-31 18:32:21 +0100250 mobileStationClassmark2_oct4 := {
251 fc := '1'B,
252 vgcs := '0'B,
253 vbs := '0'B,
254 sm_Capability := '1'B,
255 ss_ScreenIndicator := '01'B,
256 ps_Capability := '1'B,
257 spare2_1 := '0'B
258 },
259 mobileStationClassmark2_oct5 := {
260 a5_2 := '0'B,
261 a5_3 := '1'B,
262 cmsp := '0'B,
263 solsa := '0'B,
264 ucs2 := '0'B,
265 lcsva_cap := '0'B,
266 spare5_7 :='0'B,
267 cm3 := '0'B
268 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100269};
270
271/* Send template for CM SERVICE REQUEST */
Harald Welte6ed6bf92018-01-24 21:09:15 +0100272template (value) PDU_ML3_MS_NW ts_CM_SERV_REQ(CmServiceType serv_type, MobileIdentityLV mi_lv) := {
Harald Weltec76f29f2017-11-22 12:46:46 +0100273 discriminator := '0000'B, /* overwritten */
274 tiOrSkip := {
275 skipIndicator := '0000'B
276 },
277 msgs := {
278 mm := {
279 cMServiceRequest := {
280 messageType := '000000'B, /* overwritten */
281 nsd := '00'B,
Harald Welte6ed6bf92018-01-24 21:09:15 +0100282 cm_ServiceType := int2bit(enum2int(serv_type), 4),
Harald Weltec76f29f2017-11-22 12:46:46 +0100283 cipheringKeySequenceNumber := { '000'B, '0'B },
284 mobileStationClassmark2 := ts_CM2,
285 mobileIdentity := mi_lv,
286 priorityLevel := omit,
287 additionalUpdateParameterTV := omit,
288 deviceProperties := omit
289 }
290 }
291 }
292}
293
Harald Welte0195ab12018-01-24 21:50:20 +0100294template (value) CipheringKeySequenceNumberV ts_CKSN(integer key_seq) := {
295 keySequence := int2bit(key_seq, 3),
296 spare := '0'B
297}
298
299/* Send template for CM RE-ESTABLISH REQUEST */
300template (value) PDU_ML3_MS_NW ts_CM_REEST_REQ(integer cksn, MobileIdentityLV mi_lv) := {
301 discriminator := '0000'B, /* overwritten */
302 tiOrSkip := {
303 skipIndicator := '0000'B
304 },
305 msgs := {
306 mm := {
307 cMReEstablReq := {
308 messageType := '101000'B, /* overwritten */
309 nsd := '00'B,
310 cipheringKeySequenceNumber := ts_CKSN(cksn),
311 spare := '0000'B,
312 mobileStationClassmark2 := ts_CM2,
313 mobileIdentityLV := mi_lv,
314 locationAreaIdentification := omit,
315 deviceProperties := omit
316 }
317 }
318 }
319}
320
321
Harald Welte6ff81902018-01-21 19:09:08 +0100322template PDU_ML3_NW_MS tr_MT_simple(template BIT4 discr := ?) := {
323 discriminator := discr,
324 tiOrSkip := {
325 skipIndicator := '0000'B
326 },
327 msgs := ?
328}
329
330
331template PDU_ML3_NW_MS tr_CM_SERV_ACC := {
332 discriminator := '0101'B,
333 tiOrSkip := {
334 skipIndicator := '0000'B
335 },
336 msgs := {
337 mm := {
338 cMServiceAccept := {
339 messageType := '100001'B,
340 nsd := ?
341 }
342 }
343 }
344}
345
346
Harald Weltecb6cc332018-01-21 13:59:08 +0100347template PDU_ML3_NW_MS tr_CM_SERV_REJ(template OCT1 rej_cause := ?) := {
348 discriminator := '0101'B,
349 tiOrSkip := {
350 skipIndicator := '0000'B
351 },
352 msgs := {
353 mm := {
354 cMServiceReject := {
355 messageType := '100010'B,
356 nsd := ?,
357 rejectCause := rej_cause,
358 t3246_Value := *
359 }
360 }
361 }
362}
363
Harald Welte68e495b2018-02-25 00:05:57 +0100364template PDU_ML3_NW_MS tr_PAGING_REQ1(template MobileIdentityLV mi1 := ?,
365 template MobileIdentityTLV mi2 := *) := {
366 discriminator := '0110'B,
367 tiOrSkip := {
368 skipIndicator := '0000'B
369 },
370 msgs := {
371 rrm := {
372 pagingReq_Type1 := {
373 messageType := '00100001'B,
374 pageMode := ?,
375 channelNeeded := ?,
376 mobileIdentity1 := mi1,
377 mobileIdentity2 := mi2,
378 p1RestOctets := ?
379 }
380 }
381 }
382}
383
Stefan Sperling4c32b952018-05-29 20:51:04 +0200384/* Template for receiving a Paging Request Type1 message with a given TMSI in the first mobile identity. */
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +0700385template MobileIdentityLV tr_PAGING_REQ1_MI1_TMSI(octetstring tmsi) := {
Stefan Sperling4c32b952018-05-29 20:51:04 +0200386 lengthIndicator := 5,
387 mobileIdentityV := {
388 typeOfIdentity := '100'B,
389 oddEvenInd_identity := {
390 tmsi_ptmsi := {
391 oddevenIndicator := '0'B,
392 fillerDigit := '1111'B,
393 octets := tmsi
394 }
395 }
396 }
397
398}
399
Harald Welte68e495b2018-02-25 00:05:57 +0100400template PDU_ML3_NW_MS tr_PAGING_REQ2(template TMSIP_TMSI_V mi1 := ?,
401 template TMSIP_TMSI_V mi2 := ?,
402 template MobileIdentityTLV mi3 := *) := {
403 discriminator := '0110'B,
404 tiOrSkip := {
405 skipIndicator := '0000'B
406 },
407 msgs := {
408 rrm := {
409 pagingReq_Type2 := {
410 messageType := '00100010'B,
411 pageMode := ?,
412 channelNeeded := ?,
413 mobileIdentity1 := mi1,
414 mobileIdentity2 := mi2,
415 mobileIdentity3 := mi3,
416 p2RestOctets := ?
417 }
418 }
419 }
420}
421
422template PDU_ML3_NW_MS tr_PAGING_REQ3(template TMSIP_TMSI_V mi1 := ?,
423 template TMSIP_TMSI_V mi2 := ?,
424 template TMSIP_TMSI_V mi3 := ?,
425 template TMSIP_TMSI_V mi4 := ?) := {
426 discriminator := '0110'B,
427 tiOrSkip := {
428 skipIndicator := '0000'B
429 },
430 msgs := {
431 rrm := {
432 pagingReq_Type3 := {
433 messageType := '00100100'B,
434 pageMode := ?,
435 channelNeeded := ?,
436 mobileIdentity1 := mi1,
437 mobileIdentity2 := mi2,
438 mobileIdentity3 := mi3,
439 mobileIdentity4 := mi4,
440 p3RestOctets := ?
441 }
442 }
443 }
444}
445
446
447
Harald Weltec76f29f2017-11-22 12:46:46 +0100448/* Send template for PAGING RESPONSE */
449template (value) PDU_ML3_MS_NW ts_PAG_RESP(MobileIdentityLV mi_lv) := {
450 discriminator := '0000'B, /* overwritten */
451 tiOrSkip := {
452 skipIndicator := '0000'B
453 },
454 msgs := {
455 rrm := {
456 pagingResponse := {
457 messageType := '00000000'B, /* overwritten */
458 cipheringKeySequenceNumber := { '000'B, '0'B },
459 spare1_4 := '0000'B,
460 mobileStationClassmark := ts_CM2,
461 mobileIdentity := mi_lv,
462 additionalUpdateParameters := omit
463 }
464 }
465 }
466}
467
Harald Welte15166142017-12-16 23:02:08 +0100468template (value) PDU_ML3_MS_NW ts_RRM_ModeModifyAck(ChannelDescription2_V desc, ChannelMode_V mode) := {
469 discriminator := '0000'B, /* overwritten */
470 tiOrSkip := {
471 skipIndicator := '0000'B
472 },
473 msgs := {
474 rrm := {
475 channelModeModifyAck := {
476 messageType := '00010111'B,
477 channelDescription := desc,
478 channelMode := mode,
479 extendedTSCSet := omit
480 }
481 }
482 }
483}
484
Harald Weltee613f962018-04-18 22:38:16 +0200485template (value) PDU_ML3_NW_MS ts_RRM_CiphModeCmd(BIT3 alg_id) := {
486 discriminator := '0000'B, /* overwritten */
487 tiOrSkip := {
488 skipIndicator := '0000'B
489 },
490 msgs := {
491 rrm := {
492 cipheringModeCommand := {
493 messageType := '00110101'B,
494 cipherModeSetting := {
495 sC := '1'B,
496 algorithmIdentifier := alg_id
497 },
498 cipherModeResponse := {
499 cR := '0'B,
500 spare := '000'B
501 }
502 }
503 }
504 }
505}
506
Harald Welte73cd2712017-12-17 00:44:52 +0100507template (value) PDU_ML3_MS_NW ts_RRM_CiphModeCompl := {
508 discriminator := '0000'B, /* overwritten */
509 tiOrSkip := {
510 skipIndicator := '0000'B
511 },
512 msgs := {
513 rrm := {
514 cipheringModeComplete := {
515 messageType := '00110010'B,
516 mobileEquipmentIdentity := omit
517 }
518 }
519 }
520}
521
Harald Welteecb254b2018-01-29 22:01:54 +0100522template (value) PDU_ML3_MS_NW ts_RRM_AssignmentComplete(OCT1 cause) := {
523 discriminator := '0000'B, /* overwritten */
524 tiOrSkip := {
525 skipIndicator := '0000'B
526 },
527 msgs := {
528 rrm := {
529 assignmentComplete := {
530 messageType := '00101001'B,
531 rR_Cause := {
532 valuePart := cause
533 }
534 }
535 }
536 }
537}
Harald Welte15166142017-12-16 23:02:08 +0100538
Harald Welte898113b2018-01-31 18:32:21 +0100539template (value) PDU_ML3_MS_NW ts_RRM_AssignmentFailure(OCT1 cause) := {
540 discriminator := '0000'B, /* overwritten */
541 tiOrSkip := {
542 skipIndicator := '0000'B
543 },
544 msgs := {
545 rrm := {
546 assignmentFailure := {
547 messageType := '00101111'B,
548 rR_Cause := {
549 valuePart := cause
550 }
551 }
552 }
553 }
554}
555
Harald Weltefbf9b5e2018-01-31 20:41:23 +0100556template (value) PDU_ML3_MS_NW ts_RRM_HandoverFailure(OCT1 cause) := {
557 discriminator := '0000'B, /* overwritten */
558 tiOrSkip := {
559 skipIndicator := '0000'B
560 },
561 msgs := {
562 rrm := {
563 handoverFailure := {
564 messageType := '00101000'B,
565 rRCause := {
566 valuePart := cause
567 },
568 pSCause := omit
569 }
570 }
571 }
572}
Harald Welte898113b2018-01-31 18:32:21 +0100573
Harald Welte261af4b2018-02-12 21:20:39 +0100574template (value) PDU_ML3_MS_NW ts_RRM_HandoverComplete(OCT1 cause) := {
575 discriminator := '0000'B, /* overwritten */
576 tiOrSkip := {
577 skipIndicator := '0000'B
578 },
579 msgs := {
580 rrm := {
581 handoverComplete := {
582 messageType := '00101100'B,
583 rRCause := {
584 valuePart := cause
585 },
586 mobileObsservedTimeDiff := omit,
587 mobileTimeDifferenceHyperframe := omit
588 }
589 }
590 }
591}
592
Harald Welte187f7a92019-09-05 11:15:20 +0200593template (present) PDU_ML3_NW_MS tr_RR_APP_INFO(template (present) BIT4 apdu_id,
594 template (present) octetstring data,
595 template (present) APDU_Flags_V flags := ?) := {
596 discriminator := '0000'B, /* overwritten */
597 tiOrSkip := {
598 skipIndicator := '0000'B
599 },
600 msgs := {
601 rrm := {
602 applicationInformation := {
603 messageType := '00111000'B,
604 aPDU_ID := apdu_id,
605 aPDU_Flags := flags,
606 aPDU_Data := {
607 lengthIndicator := ?,
608 aPDU_DataValue := data
609 }
610 }
611 }
612 }
613}
614
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100615template (value) PDU_ML3_NW_MS ts_RR_HandoverCommand := {
616 discriminator := '0110'B,
617 tiOrSkip := {
618 skipIndicator := '0000'B
619 },
620 msgs := {
621 rrm := {
622 handoverCommand := {
623 messageType := '00101011'B,
624 cellDescription := {
625 bcc := '001'B,
626 ncc := '010'B,
627 BCCHArfcn_HighPart := '11'B,
628 BCCHArfcn_LowPart := '04'O
629 },
630 channelDescription2 := {
631 timeslotNumber := '110'B,
632 channelTypeandTDMAOffset := '00001'B,
633 octet3 := '00'O,
634 octet4 := '09'O
635 },
636 handoverReference := {
637 handoverReferenceValue := '00'O
638 },
639 powerCommandAndAccesstype := {
640 powerlevel := '00000'B,
641 fPC_EP := '0'B,
642 ePC_Mode := '0'B,
643 aTC := '0'B
644 },
645 synchronizationIndication := omit,
646 frequencyShortListAfterTime := omit,
647 frequencyListAfterTime := omit,
648 cellChannelDescription := omit,
649 multislotAllocation := omit,
650 modeOfChannelSet1 := omit,
651 modeOfChannelSet2 := omit,
652 modeOfChannelSet3 := omit,
653 modeOfChannelSet4 := omit,
654 modeOfChannelSet5 := omit,
655 modeOfChannelSet6 := omit,
656 modeOfChannelSet7 := omit,
657 modeOfChannelSet8 := omit,
658 descrOf2ndCh_at := omit,
659 modeOf2ndChannel := omit,
660 frequencyChannelSequence_at := omit,
661 mobileAllocation_at := omit,
662 startingTime := omit,
663 timeDifference := omit,
664 timingAdvance := omit,
665 frequencyShortListBeforeTime := omit,
666 frequencyListBeforeTime := omit,
667 descrOf1stCh_bt := omit,
668 descrOf2ndCh_bt := omit,
669 frequencyChannelSequence_bt := omit,
670 mobileAllocation_bt := omit,
671 cipherModeSetting := omit,
672 vGCS_TargetModeIndication := omit,
673 multiRateConfiguration := omit,
674 dynamicARFCN_Mapping := omit,
675 vGCS_Ciphering_Parameters := omit,
676 dedicatedServiceInformation := omit,
677 pLMNIndex := omit,
678 extendedTSCSet_afterTime := omit,
679 extendedTSCSet_beforeTime := omit
680 }
681 }
682 }
683}
684
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200685template PDU_ML3_NW_MS tr_RR_HandoverCommand := {
686 discriminator := '0110'B,
687 tiOrSkip := {
688 skipIndicator := '0000'B
689 },
690 msgs := {
691 rrm := {
692 handoverCommand := {
693 messageType := '00101011'B,
694 cellDescription := ?,
695 channelDescription2 := ?,
696 handoverReference := ?,
697 powerCommandAndAccesstype := ?,
698 synchronizationIndication := *,
699 frequencyShortListAfterTime := *,
700 frequencyListAfterTime := *,
701 cellChannelDescription := *,
702 multislotAllocation := *,
703 modeOfChannelSet1 := *,
704 modeOfChannelSet2 := *,
705 modeOfChannelSet3 := *,
706 modeOfChannelSet4 := *,
707 modeOfChannelSet5 := *,
708 modeOfChannelSet6 := *,
709 modeOfChannelSet7 := *,
710 modeOfChannelSet8 := *,
711 descrOf2ndCh_at := *,
712 modeOf2ndChannel := *,
713 frequencyChannelSequence_at := *,
714 mobileAllocation_at := *,
715 startingTime := *,
716 timeDifference := *,
717 timingAdvance := *,
718 frequencyShortListBeforeTime := *,
719 frequencyListBeforeTime := *,
720 descrOf1stCh_bt := *,
721 descrOf2ndCh_bt := *,
722 frequencyChannelSequence_bt := *,
723 mobileAllocation_bt := *,
724 cipherModeSetting := *,
725 vGCS_TargetModeIndication := *,
726 multiRateConfiguration := *,
727 dynamicARFCN_Mapping := *,
728 vGCS_Ciphering_Parameters := *,
729 dedicatedServiceInformation := *,
730 pLMNIndex := *,
731 extendedTSCSet_afterTime := *,
732 extendedTSCSet_beforeTime := *
733 }
734 }
735 }
736}
737
Harald Welte898113b2018-01-31 18:32:21 +0100738function ts_CM3_TLV(template (omit) OCTN cm3) return template MobileStationClassmark3_TLV {
739 if (not isvalue(cm3)) {
740 return omit;
741 }
742 var template MobileStationClassmark3_TLV ret := {
743 elementIdentifier := '20'O,
744 lengthIndicator := 0, /* overwritten */
745 valuePart := cm3
746 }
747 return ret;
748}
749
750template (value) PDU_ML3_MS_NW ts_RRM_CM_CHG(MobileStationClassmark2_LV cm2,
751 template (omit) MobileStationClassmark3_TLV cm3 := omit) := {
752 discriminator := '0110'B,
753 tiOrSkip := {
754 skipIndicator := '0000'B
755 },
756 msgs := {
757 rrm := {
758 classmarkChange := {
759 messageType := '00010110'B,
760 mobileStationClassmark2 := cm2,
761 mobileStationClassmark3 := cm3
762 }
763 }
764 }
765}
766
Neels Hofmeyr92b12b72018-09-18 14:30:23 +0200767template PDU_ML3_NW_MS tr_RRM_CM_ENQUIRY := {
768 discriminator := '0110'B,
769 tiOrSkip := {
770 skipIndicator := '0000'B
771 },
772 msgs := {
773 rrm := {
774 classmarkEnquiry := {
775 messageType := '00010011'B,
776 classmarkEnquiryMask := *
777 }
778 }
779 }
780}
781
Harald Weltee3bd6582018-01-31 22:51:25 +0100782template (value) PDU_ML3_MS_NW ts_RRM_UL_REL(OCT1 cause) := {
783 discriminator := '0110'B,
784 tiOrSkip := {
785 skipIndicator := '0000'B
786 },
787 msgs := {
788 rrm := {
789 uplinkRelease := {
790 messageType := '00001110'B,
791 rR_Cause := {
792 valuePart := cause
793 }
794 }
795 }
796 }
797}
798
799template PDU_ML3_MS_NW tr_RRM_RR_STATUS(template OCT1 cause := ?) := {
800 discriminator := '0110'B,
801 tiOrSkip := {
802 skipIndicator := '0000'B
803 },
804 msgs := {
805 rrm := {
806 rR_Status := {
807 messageType := '00010010'B,
808 rR_Cause := {
809 valuePart := cause
810 }
811 }
812 }
813 }
814}
815
Harald Welte924b6ea2019-02-04 01:05:34 +0100816template PDU_ML3_NW_MS tr_RRM_RR_RELEASE(template OCT1 cause := ?) := {
817 discriminator := '0110'B,
818 tiOrSkip := {
819 skipIndicator := '0000'B
820 },
821 msgs := {
822 rrm := {
823 channelRelease := {
824 messageType := '00001101'B,
825 rRCause := {
826 valuePart := cause
827 },
828 bARange := *,
829 groupChannelDescription := *,
830 groupCipherKeyNumber := *,
831 gPRSResumption := *,
832 bAListPref := *,
833 uTRANFrequencyList := *,
834 cellChannelDescr := *,
835 cellSelectionIndicator := *,
836 enhanced_DTM_CS_Release_Indication := *,
837 vGCS_Ciphering_Parameters := *,
838 group_Channel_Description_2 := *,
839 talkerIdentity := *,
840 talkerPriorityStatus := *,
841 vGCS_AMR_Configuration := *,
842 individual_Priorities := *
843 }
844 }
845 }
846}
Harald Weltee3bd6582018-01-31 22:51:25 +0100847
Harald Welte99787102019-02-04 10:41:36 +0100848template PDU_ML3_NW_MS tr_RRM_RR_RELEASE_CSFB(template OCT1 cause := ?) modifies tr_RRM_RR_RELEASE := {
849 msgs := {
850 rrm := {
851 channelRelease := {
852 cellSelectionIndicator := {
853 elementIdentifier := '77'O,
854 lengthIndicator := ?,
855 cellSelectionIndicatorValue := ?
856 }
857 }
858 }
859 }
860}
Harald Weltee3bd6582018-01-31 22:51:25 +0100861
Harald Weltecb6cc332018-01-21 13:59:08 +0100862template PDU_ML3_MS_NW ts_ML3_MO := {
863 discriminator := '0000'B,
864 tiOrSkip := {
865 skipIndicator := '0000'B
866 },
867 msgs := ?
868}
869
870template LocationUpdatingType ts_ML3_IE_LuType := {
871 lut := ?,
872 spare1_1 := '0'B,
873 fop := '0'B
874}
875
876template LocationUpdatingType ts_ML3_IE_LuType_Normal modifies ts_ML3_IE_LuType := {
877 lut := '00'B
878}
879
880template LocationUpdatingType ts_ML3_IE_LuType_Periodic modifies ts_ML3_IE_LuType := {
881 lut := '01'B
882}
883
884template LocationUpdatingType ts_ML3_IE_LuType_Attach modifies ts_ML3_IE_LuType := {
885 lut := '10'B
886}
887
888template CipheringKeySequenceNumberV ts_ML3_IE_CKSN(integer cksn) := {
889 keySequence := int2bit(cksn, 3),
890 spare := '0'B
891}
892
893template PDU_ML3_MS_NW ts_ML3_MO_LU_Req(LocationUpdatingType lu_type, LocationAreaIdentification_V lai,
894 MobileIdentityLV mi, MobileStationClassmark1_V cm1)
895modifies ts_ML3_MO := {
896 msgs := {
897 mm := {
898 locationUpdateRequest := {
899 messageType := '001000'B,
900 nsd := '00'B, /* ? */
901 locationUpdatingType := lu_type,
902 cipheringKeySequenceNumber := ts_ML3_IE_CKSN(0),
903 locationAreaIdentification := lai,
904 mobileStationClassmark1 := cm1,
905 mobileIdentityLV := mi,
906 classmarkInformationType2_forUMTS := omit,
907 additionalUpdateParameterTV := omit,
908 deviceProperties := omit,
909 mS_NetworkFeatureSupport := omit
910 }
911 }
912 }
913}
914
Harald Welte6ff81902018-01-21 19:09:08 +0100915template PDU_ML3_MS_NW ts_ML3_MO_TmsiRealloc_Cmpl modifies ts_ML3_MO := {
916 msgs := {
917 mm := {
918 tmsiReallocComplete := {
919 messageType := '011011'B,
920 nsd := '00'B
921 }
922 }
923 }
924}
925
926template PDU_ML3_NW_MS tr_ML3_MT_LU_Acc := {
927 discriminator := '0101'B,
928 tiOrSkip := {
929 skipIndicator := '0000'B
930 },
931 msgs := {
932 mm := {
933 locationUpdateAccept := {
934 messageType := '000010'B,
935 nsd := '00'B,
936 locationAreaIdentification := ?,
937 mobileIdentityTLV := *,
938 followOnProceed := *,
939 cTS_Permission := *,
940 equivalentPLMNs := *,
941 emergencyNumberList := *,
942 perMS_T3212 := *
943 }
944 }
945 }
946}
947
948template PDU_ML3_NW_MS tr_ML3_MT_LU_Rej(template OCT1 cause := ?) := {
949 discriminator := '0101'B,
950 tiOrSkip := {
951 skipIndicator := '0000'B
952 },
953 msgs := {
954 mm := {
955 locationUpdateReject := {
956 messageType := '000100'B,
957 nsd := '00'B,
958 rejectCause := cause,
959 t3246_Value := *
960 }
961 }
962 }
963}
964
Oliver Smithaf2f1f82019-07-19 12:33:12 +0200965private function f_id_type_or_any(template CmIdentityType id_type) return template bitstring {
966 if (istemplatekind(id_type, "?")) {
967 return ?;
968 } else {
969 return int2bit(enum2int(valueof(id_type)), 3);
970 }
971}
972
Oliver Smith32898452019-07-09 12:32:35 +0200973template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
Harald Welteba7b6d92018-01-23 21:32:34 +0100974 discriminator := '0101'B,
975 tiOrSkip := {
976 skipIndicator := '0000'B
977 },
978 msgs := {
979 mm := {
980 identityRequest := {
981 messageType := '011000'B,
982 nsd := '00'B,
Oliver Smithaf2f1f82019-07-19 12:33:12 +0200983 identityType := f_id_type_or_any(id_type),
Harald Welteba7b6d92018-01-23 21:32:34 +0100984 spare1_5 := ?
985 }
986 }
987 }
988}
989
990template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp(MobileIdentityLV mi) modifies ts_ML3_MO := {
991 msgs := {
992 mm := {
993 identityResponse := {
994 messageType := '011001'B,
995 nsd := '00'B,
996 mobileIdentityLV := mi,
997 p_TMSI_TypeTV := omit,
998 routingAreaIdentification2TLV := omit,
999 p_TMSISignature2TLV := omit
1000 }
1001 }
1002 }
1003}
1004template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMSI(hexstring imsi) :=
1005 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMSI_LV(imsi)));
1006template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMEI(hexstring imei) :=
1007 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMEI_LV(imei)));
1008
1009
Neels Hofmeyr63382472018-03-01 19:57:44 +01001010template (value) MobileStationClassmark1_V ts_CM1(BIT1 a5_1_unavail := '0'B, BIT2 rev := '10'B, BIT1 esind := '1'B) := {
Harald Welte45164da2018-01-24 12:51:27 +01001011 rf_PowerCapability := '010'B,
1012 a5_1 := a5_1_unavail,
Neels Hofmeyr63382472018-03-01 19:57:44 +01001013 esind := esind,
Harald Welte45164da2018-01-24 12:51:27 +01001014 revisionLevel := rev,
1015 spare1_1 := '0'B
1016}
1017
1018template PDU_ML3_MS_NW ts_ML3_MO_MM_IMSI_DET_Ind(MobileIdentityLV mi,
1019 template MobileStationClassmark1_V cm1 := ts_CM1)
1020modifies ts_ML3_MO := {
1021 msgs := {
1022 mm := {
1023 imsiDetachIndication := {
1024 messageType := '000001'B,
1025 nsd := '00'B,
1026 mobileStationClassmark1 := cm1,
1027 mobileIdentityLV := mi
1028 }
1029 }
1030 }
1031}
1032
Harald Welted748a052018-01-22 02:59:24 +01001033template PDU_ML3_MS_NW ts_ML3_MO_CC(integer tid) := {
1034 discriminator := '0011'B,
1035 tiOrSkip := {
1036 transactionId := {
Daniel Willmanndcf9eb92018-02-02 20:07:52 +01001037 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001038 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001039 tIExtension := omit
1040 }
1041 }
1042}
1043
1044template (value) CalledPartyBCD_Number ts_Called(hexstring digits) := {
1045 elementIdentifier := '5E'O,
1046 lengthIndicator := 0, /* overwritten */
1047 numberingPlanIdentification := '0000'B,
1048 typeOfNumber := '000'B, /* unknown */
1049 ext1 := '0'B,
1050 digits := digits
1051}
1052
Harald Welte812f7a42018-01-27 00:49:18 +01001053template CalledPartyBCD_Number tr_Called(template hexstring digits) := {
1054 elementIdentifier := '5E'O,
1055 lengthIndicator := ?,
1056 numberingPlanIdentification := ?,
1057 typeOfNumber := ?,
1058 ext1 := ?,
1059 digits := digits
1060}
1061
Stefan Sperling26d57be2018-11-12 17:03:26 +01001062private function f_pad_digits(hexstring digits) return hexstring {
1063 if (lengthof(digits) mod 2 != 0) {
1064 /* Add trailing nibble of 1-bit padding, like the CallingPartyBCD_Number encoder would do.
1065 * Otherwise our template won't match the data received (see OS#2930). */
1066 return digits & 'F'H;
1067 }
1068 return digits;
1069}
1070
Harald Welte812f7a42018-01-27 00:49:18 +01001071template CallingPartyBCD_Number tr_Calling(template hexstring digits) := {
1072 elementIdentifier := '5C'O,
1073 lengthIndicator := ?,
1074 oct3 := ?,
Stefan Sperling26d57be2018-11-12 17:03:26 +01001075 digits := f_pad_digits(valueof(digits))
Harald Welte812f7a42018-01-27 00:49:18 +01001076}
1077
Harald Welte4b2b3a62018-01-26 10:32:39 +01001078type integer SpeechVer;
1079
1080template (value) Speech_AuxiliarySpeech ts_SpeechAux(SpeechVer ver, BIT1 suffix) := {
1081 speechVersionIndication := int2bit(ver-1,3) & suffix,
1082 spare1_1 := '0'B,
1083 cTM_or_Spare := '0'B,
1084 coding := '0'B,
1085 extension_octet_3a_3b := '0'B
1086}
1087
1088template (value) Speech_AuxiliarySpeech ts_SpeechAuxFR(SpeechVer ver) := ts_SpeechAux(ver, '0'B);
1089template (value) Speech_AuxiliarySpeech ts_SpeechAuxHR(SpeechVer ver) := ts_SpeechAux(ver, '1'B);
1090
Harald Welted748a052018-01-22 02:59:24 +01001091template (value) BearerCapability_TLV ts_Bcap_voice := {
1092 elementIdentifier := '04'O,
1093 lengthIndicator := 0, /* overwritten */
1094 octet3 := {
1095 informationTransferCapability := '000'B,
1096 transferMode := '0'B,
1097 codingStandard := '0'B,
1098 radioChannelRequirement := '11'B, /* FR preferred */
1099 extension_octet_3 := '0'B, /* overwritten */
Harald Welte4b2b3a62018-01-26 10:32:39 +01001100 speech_aux_3a_3b := {
1101 valueof(ts_SpeechAuxHR(3)),
1102 valueof(ts_SpeechAuxFR(3)),
1103 valueof(ts_SpeechAuxFR(2)),
1104 valueof(ts_SpeechAuxFR(1)),
1105 valueof(ts_SpeechAuxHR(1))
1106 }
Harald Welted748a052018-01-22 02:59:24 +01001107 },
1108 octet4 := omit,
1109 octet5 := omit,
1110 octet6 := omit,
1111 octet7 := omit
1112}
1113
1114template PDU_ML3_MS_NW ts_ML3_MO_CC_SETUP(integer tid, hexstring called, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1115 discriminator := '0011'B,
1116 tiOrSkip := {
1117 transactionId := {
1118 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001119 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001120 tIExtension := omit
1121 }
1122 },
1123 msgs := {
1124 cc := {
1125 setup_MS_NW := {
1126 messageType := '000101'B,
1127 nsd := '00'B,
1128 bcRepeatIndicator := omit,
1129 bearerCapability1 := bcap,
1130 bearerCapability2 := omit,
1131 facility := omit,
1132 callingPartySubAddress := omit,
1133 calledPartyBCD_Number := ts_Called(called),
1134 calledPartySubAddress := omit,
1135 llc_RepeatIndicator := omit,
1136 lowLayerCompatibility1 := omit,
1137 lowLayerCompatibility2 := omit,
1138 hlc_RepeatIndicator := omit,
1139 highLayerCompatibility1 := omit,
1140 highLayerCompatibility2 := omit,
1141 user_user := omit,
1142 ss_VersionIndicator := omit,
1143 clir_Suppression := omit,
1144 clir_Invocation := omit,
1145 cC_Capabilities := omit,
1146 facility_ccbs1 := omit,
1147 facility_ccbs2 := omit,
1148 streamIdentifier := omit,
1149 supportedCodecs := omit,
1150 redial := omit
1151 }
1152 }
1153 }
1154}
1155
Harald Welte45164da2018-01-24 12:51:27 +01001156template PDU_ML3_MS_NW ts_ML3_MO_CC_EMERG_SETUP(integer tid, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1157 discriminator := '0011'B,
1158 tiOrSkip := {
1159 transactionId := {
1160 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001161 tiFlag := c_TIF_ORIG,
Harald Welte45164da2018-01-24 12:51:27 +01001162 tIExtension := omit
1163 }
1164 },
1165 msgs := {
1166 cc := {
1167 emergencySetup := {
1168 messageType := '001110'B,
1169 nsd := '00'B,
1170 bearerCapability := bcap,
1171 streamIdentifier := omit,
1172 supportedCodecs := omit,
1173 emergencyCategory := omit
1174 }
1175 }
1176 }
1177}
1178
1179
Harald Welted748a052018-01-22 02:59:24 +01001180template PDU_ML3_NW_MS tr_ML3_MT_CC_CALL_PROC(integer tid) := {
1181 discriminator := '0011'B,
1182 tiOrSkip := {
1183 transactionId := {
1184 tio := int2bit(tid, 3),
1185 tiFlag := ?,
1186 tIExtension := omit
1187 }
1188 },
1189 msgs := {
1190 cc := {
1191 callProceeding := {
1192 messageType := '000010'B,
1193 nsd := '00'B,
1194 repeatIndicator := *,
1195 bearerCapability1 := *,
1196 bearerCapability2 := *,
1197 facility := *,
1198 progressIndicator := *,
1199 priorityGranted := *,
1200 networkCCCapabilities := *
1201 }
1202 }
1203 }
1204}
1205
1206template PDU_ML3_NW_MS tr_ML3_MT_CC_ALERTING(integer tid) := {
1207 discriminator := '0011'B,
1208 tiOrSkip := {
1209 transactionId := {
1210 tio := int2bit(tid, 3),
1211 tiFlag := ?,
1212 tIExtension := omit
1213 }
1214 },
1215 msgs := {
1216 cc := {
1217 alerting_NW_MS := {
1218 messageType := '000001'B,
1219 nsd := '00'B,
1220 facility := *,
1221 progressIndicator := *,
1222 user_user := *
1223 }
1224 }
1225 }
1226}
1227
Harald Welte33ec09b2018-02-10 15:34:46 +01001228template PDU_ML3_MS_NW ts_ML3_MO_CC_ALERTING(integer tid) := {
1229 discriminator := '0011'B,
1230 tiOrSkip := {
1231 transactionId := {
1232 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001233 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001234 tIExtension := omit
1235 }
1236 },
1237 msgs := {
1238 cc := {
1239 alerting_MS_NW := {
1240 messageType := '000001'B,
1241 nsd := '00'B,
1242 facility := omit,
1243 user_user := omit,
1244 ss_VersionIndicator := omit
1245 }
1246 }
1247 }
1248}
1249
1250template PDU_ML3_MS_NW ts_ML3_MT_CC_ALERTING(integer tid) := {
1251 discriminator := '0011'B,
1252 tiOrSkip := {
1253 transactionId := {
1254 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001255 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001256 tIExtension := omit
1257 }
1258 },
1259 msgs := {
1260 cc := {
1261 alerting_MS_NW := {
1262 messageType := '000001'B,
1263 nsd := '00'B,
1264 facility := omit,
1265 user_user := omit,
1266 ss_VersionIndicator := omit
1267 }
1268 }
1269 }
1270}
1271
1272template PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT(integer tid) := {
1273 discriminator := '0011'B,
1274 tiOrSkip := {
1275 transactionId := {
1276 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001277 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001278 tIExtension := omit
1279 }
1280 },
1281 msgs := {
1282 cc := {
1283 connect_MS_NW := {
1284 messageType := '000111'B,
1285 nsd := '00'B,
1286 facility := omit,
1287 connectedSubAddress := omit,
1288 user_user := omit,
1289 ss_VersionIndicator := omit,
1290 streamIdentifier := omit
1291 }
1292 }
1293 }
1294}
1295
Harald Welte4017d552018-01-26 21:40:05 +01001296template PDU_ML3_NW_MS tr_ML3_MT_CC_CONNECT(integer tid) := {
1297 discriminator := '0011'B,
1298 tiOrSkip := {
1299 transactionId := {
1300 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001301 tiFlag := c_TIF_REPL,
Harald Welte4017d552018-01-26 21:40:05 +01001302 tIExtension := omit
1303 }
1304 },
1305 msgs := {
1306 cc := {
1307 connect_NW_MS := {
1308 messageType := '000111'B,
1309 nsd := '00'B,
1310 facility := *,
1311 progressIndicator := *,
1312 connectedNumber := *,
1313 connectedSubAddress := *,
1314 user_user := *
1315 }
1316 }
1317 }
1318}
1319
1320template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT_ACK(integer tid) := {
1321 discriminator := '0011'B,
1322 tiOrSkip := {
1323 transactionId := {
1324 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001325 tiFlag := c_TIF_ORIG,
Harald Welte4017d552018-01-26 21:40:05 +01001326 tIExtension := omit
1327 }
1328 },
1329 msgs := {
1330 cc := {
1331 connectAck := {
1332 messageType := '001111'B,
1333 nsd := '00'B
1334 }
1335 }
1336 }
1337}
1338
Daniel Willmann8b084372018-02-04 13:35:26 +01001339template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_START_DTMF(integer tid, charstring number) := {
1340 discriminator := '0011'B,
1341 tiOrSkip := {
1342 transactionId := {
1343 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001344 tiFlag := c_TIF_ORIG,
Daniel Willmann8b084372018-02-04 13:35:26 +01001345 tIExtension := omit
1346 }
1347 },
1348 msgs := {
1349 cc := {
1350 startDTMF := {
1351 messageType := '110101'B,
1352 nsd := '00'B,
1353 keypadFacility := {
1354 elementIdentifier := '2C'O,
1355 keypadInformation := int2bit(char2int(number), 7),
1356 spare_1 := '0'B
1357 }
1358 }
1359 }
1360 }
1361}
1362
Harald Welte2bb825f2018-01-22 11:31:18 +01001363template PDU_ML3_NW_MS tr_ML3_MT_CC_DISC(integer tid) := {
1364 discriminator := '0011'B,
1365 tiOrSkip := {
1366 transactionId := {
1367 tio := int2bit(tid, 3),
1368 tiFlag := ?,
1369 tIExtension := omit
1370 }
1371 },
1372 msgs := {
1373 cc := {
1374 disconnect_NW_MS := {
1375 messageType := '100101'B,
1376 nsd := '00'B,
1377 cause := ?,
1378 facility := *,
1379 progressIndicator := *,
1380 user_user := *,
1381 allowedActions := *
1382 }
1383 }
1384 }
1385}
1386
1387template PDU_ML3_NW_MS tr_ML3_MT_CC_RELEASE(integer tid) := {
1388 discriminator := '0011'B,
1389 tiOrSkip := {
1390 transactionId := {
1391 tio := int2bit(tid, 3),
1392 tiFlag := ?,
1393 tIExtension := omit
1394 }
1395 },
1396 msgs := {
1397 cc := {
1398 release_NW_MS := {
1399 messageType := '101101'B,
1400 nsd := '00'B,
1401 cause := ?,
1402 secondCause := *,
1403 facility := *,
1404 user_user := *
1405 }
1406 }
1407 }
1408}
Harald Welted748a052018-01-22 02:59:24 +01001409
Harald Welte33ec09b2018-02-10 15:34:46 +01001410template PDU_ML3_MS_NW ts_ML3_MO_CC_RELEASE(integer tid, BIT1 tid_remote, BIT7 cause) := {
1411 discriminator := '0011'B,
1412 tiOrSkip := {
1413 transactionId := {
1414 tio := int2bit(tid, 3),
1415 tiFlag := tid_remote,
1416 tIExtension := omit
1417 }
1418 },
1419 msgs := {
1420 cc := {
1421 release_MS_NW := {
1422 messageType := '101101'B,
1423 nsd := '00'B,
1424 cause := ts_ML3_Cause(cause),
1425 secondCause := omit,
1426 facility := omit,
1427 user_user := omit,
1428 ss_VersionIndicator := omit
1429 }
1430 }
1431 }
1432}
1433
1434
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001435template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_REL_COMPL(integer tid, BIT1 tid_remote := '0'B) := {
Harald Welteb71901a2018-01-26 19:16:05 +01001436 discriminator := '0011'B,
1437 tiOrSkip := {
1438 transactionId := {
1439 tio := int2bit(tid, 3),
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001440 tiFlag := tid_remote,
Harald Welteb71901a2018-01-26 19:16:05 +01001441 tIExtension := omit
1442 }
1443 },
1444 msgs := {
1445 cc := {
1446 releaseComplete_MS_NW := {
1447 messageType := '101010'B,
1448 nsd := '00'B,
1449 cause := omit,
1450 facility := omit,
1451 user_user := omit,
1452 ss_VersionIndicator := omit
1453 }
1454 }
1455 }
1456}
1457
Harald Welte33ec09b2018-02-10 15:34:46 +01001458template PDU_ML3_NW_MS tr_ML3_MT_CC_REL_COMPL(integer tid) := {
1459 discriminator := '0011'B,
1460 tiOrSkip := {
1461 transactionId := {
1462 tio := int2bit(tid, 3),
1463 tiFlag := ?,
1464 tIExtension := omit
1465 }
1466 },
1467 msgs := {
1468 cc := {
1469 releaseComplete_NW_MS := {
1470 messageType := '101010'B,
1471 nsd := '00'B,
1472 cause := *,
1473 facility := *,
1474 user_user := *
1475 }
1476 }
1477 }
1478}
1479
1480
Harald Welteb71901a2018-01-26 19:16:05 +01001481
Harald Welte77a8eba2018-01-22 21:22:32 +01001482template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ(template OCT16 rand := ?) := {
1483 discriminator := '0101'B,
1484 tiOrSkip := {
1485 skipIndicator := '0000'B
1486 },
1487 msgs := {
1488 mm := {
1489 authenticationRequest := {
1490 messageType := '010010'B,
1491 nsd := '00'B,
1492 cipheringKeySequenceNumber := ?,
1493 spare2_4 := ?,
1494 authenticationParRAND := rand,
1495 authenticationParAUTN := *
1496 }
1497 }
1498 }
1499}
1500
Harald Welte0cedf2c2018-10-28 23:28:35 +01001501template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ_3G(template OCT16 rand := ?, template OCT16 autn) := {
1502 discriminator := '0101'B,
1503 tiOrSkip := {
1504 skipIndicator := '0000'B
1505 },
1506 msgs := {
1507 mm := {
1508 authenticationRequest := {
1509 messageType := '010010'B,
1510 nsd := '00'B,
1511 cipheringKeySequenceNumber := ?,
1512 spare2_4 := ?,
1513 authenticationParRAND := rand,
1514 authenticationParAUTN := {
1515 elementIdentifier := '20'O,
1516 lengthIndicator := ?,
1517 autnValue := autn
1518 }
1519 }
1520 }
1521 }
1522}
1523
Harald Welte77a8eba2018-01-22 21:22:32 +01001524template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_2G(OCT4 sres) := {
1525 discriminator := '0101'B,
1526 tiOrSkip := {
1527 skipIndicator := '0000'B
1528 },
1529 msgs := {
1530 mm := {
1531 authenticationResponse := {
1532 messageType := '010100'B,
1533 nsd := '00'B,
1534 authenticationParSRES := sres,
1535 authenticationParSRESext := omit
1536 }
1537 }
1538 }
1539}
1540
1541template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_3G(OCT4 sres, octetstring res) := {
1542 discriminator := '0101'B,
1543 tiOrSkip := {
1544 skipIndicator := '0000'B
1545 },
1546 msgs := {
1547 mm := {
1548 authenticationResponse := {
1549 messageType := '010100'B,
1550 nsd := '00'B,
1551 authenticationParSRES := sres,
1552 authenticationParSRESext := {
1553 elementIdentifier := '21'O,
1554 lengthIndicator := 0, /* overwritten */
1555 valueField := res
1556 }
1557 }
1558 }
1559 }
1560}
Harald Weltecb6cc332018-01-21 13:59:08 +01001561
Harald Welte812f7a42018-01-27 00:49:18 +01001562template PDU_ML3_MS_NW ts_ML3_MO_CC_CALL_CONF(integer tid,
1563 template BearerCapability_TLV bcap := omit) := {
1564 discriminator := '0011'B,
1565 tiOrSkip := {
1566 transactionId := {
1567 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001568 tiFlag := c_TIF_REPL, /* response from destination */
Harald Welte812f7a42018-01-27 00:49:18 +01001569 tIExtension := omit
1570 }
1571 },
1572 msgs := {
1573 cc := {
1574 callConfirmed := {
1575 messageType := '001000'B,
1576 nsd := '00'B,
1577 repeatIndicator := omit,
1578 bearerCapability1 := bcap,
1579 bearerCapability2 := omit,
1580 cause := omit,
1581 cC_Capabilities := omit,
1582 streamIdentifier := omit,
1583 supportedCodecs := omit
1584 }
1585 }
1586 }
1587}
1588
1589
1590template PDU_ML3_NW_MS tr_ML3_MT_CC_SETUP(integer tid, template hexstring called := *,
1591 template hexstring calling := *,
1592 template BearerCapability_TLV bcap := *) := {
1593 discriminator := '0011'B,
1594 tiOrSkip := {
1595 transactionId := {
1596 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001597 tiFlag := c_TIF_ORIG, /* from originator */
Harald Welte812f7a42018-01-27 00:49:18 +01001598 tIExtension := omit
1599 }
1600 },
1601 msgs := {
1602 cc := {
1603 setup_NW_MS := {
1604 messageType := '000101'B,
1605 nsd := '00'B,
1606 bcRepeatIndicator := *,
1607 bearerCapability1 := bcap,
1608 bearerCapability2 := *,
1609 facility := *,
1610 progressIndicator := *,
1611 signal := *,
1612 callingPartyBCD_Number := tr_Calling(calling) ifpresent,
1613 callingPartySubAddress := *,
1614 calledPartyBCD_Number := tr_Called(called) ifpresent,
1615 calledPartySubAddress := *,
1616 redirectingPartyBCDNumber := *,
1617 redirectingPartySubaddress := *,
1618 llc_RepeatIndicator := *,
1619 lowLayerCompatibility1 := *,
1620 lowLayerCompatibility2 := *,
1621 hlc_RepeatIndicator := *,
1622 highLayerCompatibility1 := *,
1623 highLayerCompatibility2 := *,
1624 user_user := *,
1625 priority := *,
1626 alert := *,
1627 networkCCCapabilities := *,
1628 causeofNoCli := *,
1629 backupBearerCapacity := *
1630 }
1631 }
1632 }
1633}
1634
Harald Welte38575a72018-02-15 20:41:37 +01001635/***********************************************************************
Harald Welte53603962018-05-28 11:13:09 +02001636 * Supplementary Services
1637 ***********************************************************************/
1638
1639private template (value) Facility_TLV ts_FacTLV(OCTN facility) := {
1640 elementIdentifier := '1C'O,
1641 lengthIndicator := lengthof(facility),
1642 facilityInformation := facility
1643}
1644private template Facility_TLV tr_FacTLV(template OCTN facility) := {
1645 elementIdentifier := '1C'O,
1646 lengthIndicator := ?,
1647 facilityInformation := facility
1648}
1649
1650private template (value) Facility_LV ts_FacLV(OCTN facility) := {
1651 lengthIndicator := lengthof(facility),
1652 facilityInformation := facility
1653}
1654private template Facility_LV tr_FacLV(template OCTN facility) := {
1655 lengthIndicator := ?,
1656 facilityInformation := facility
1657}
1658
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001659private function f_facility_or_omit(template (omit) OCTN facility)
1660return template (omit) Facility_TLV {
1661 if (istemplatekind(facility, "omit")) {
1662 return omit;
1663 } else {
1664 return ts_FacTLV(valueof(facility));
1665 }
1666}
1667private function f_facility_or_wc(template OCTN facility)
1668return template Facility_TLV {
1669 if (istemplatekind(facility, "*")) {
1670 return *;
1671 } else if (istemplatekind(facility, "?")) {
1672 return ?;
Vadim Yanitskiy52f8b6e2018-06-19 17:32:46 +07001673 } else if (istemplatekind(facility, "omit")) {
1674 return omit;
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001675 } else {
1676 return tr_FacTLV(facility);
1677 }
1678}
1679
Harald Welte53603962018-05-28 11:13:09 +02001680template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_REGISTER(
1681 uint3_t tid, BIT1 ti_flag,
1682 OCTN facility,
1683 template (omit) SS_VersionIndicator ss_ver := omit
1684) := {
1685 discriminator := '1011'B,
1686 tiOrSkip := {
1687 transactionId := {
1688 tio := int2bit(tid, 3),
1689 tiFlag := ti_flag,
1690 tIExtension := omit
1691 }
1692 },
1693 msgs := {
1694 ss := {
1695 register := {
1696 messageType := '111011'B,
1697 nsd := '00'B,
1698 facility := ts_FacTLV(facility),
1699 ss_version := ss_ver
1700 }
1701 }
1702 }
1703}
1704template PDU_ML3_MS_NW tr_ML3_MO_SS_REGISTER(
1705 template uint3_t tid, template BIT1 ti_flag,
1706 template OCTN facility,
1707 template SS_VersionIndicator ss_ver := omit
1708) := {
1709 discriminator := '1011'B,
1710 tiOrSkip := {
1711 transactionId := {
1712 tio := f_tid_or_wc(tid),
1713 tiFlag := ti_flag,
1714 tIExtension := omit
1715 }
1716 },
1717 msgs := {
1718 ss := {
1719 register := {
1720 messageType := '111011'B,
1721 nsd := '00'B,
1722 facility := tr_FacTLV(facility),
1723 ss_version := ss_ver
1724 }
1725 }
1726 }
1727}
1728
1729template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_REGISTER(
1730 uint3_t tid, BIT1 ti_flag,
1731 OCTN facility
1732) := {
1733 discriminator := '1011'B,
1734 tiOrSkip := {
1735 transactionId := {
1736 tio := int2bit(tid, 3),
1737 tiFlag := ti_flag,
1738 tIExtension := omit
1739 }
1740 },
1741 msgs := {
1742 ss := {
1743 register := {
1744 messageType := '111011'B,
1745 nsd := '00'B,
1746 facility := ts_FacTLV(facility)
1747 }
1748 }
1749 }
1750}
1751template PDU_ML3_NW_MS tr_ML3_MT_SS_REGISTER(
1752 template uint3_t tid, template BIT1 ti_flag,
1753 template OCTN facility
1754) := {
1755 discriminator := '1011'B,
1756 tiOrSkip := {
1757 transactionId := {
1758 tio := f_tid_or_wc(tid),
1759 tiFlag := ti_flag,
1760 tIExtension := omit
1761 }
1762 },
1763 msgs := {
1764 ss := {
1765 register := {
1766 messageType := '111011'B,
1767 nsd := '00'B,
1768 facility := tr_FacTLV(facility)
1769 }
1770 }
1771 }
1772}
1773
1774template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_FACILITY(
1775 uint3_t tid, BIT1 ti_flag,
1776 OCTN facility
1777) := {
1778 discriminator := '1011'B,
1779 tiOrSkip := {
1780 transactionId := {
1781 tio := int2bit(tid, 3),
1782 tiFlag := ti_flag,
1783 tIExtension := omit
1784 }
1785 },
1786 msgs := {
1787 ss := {
1788 facility := {
1789 messageType := '111010'B,
1790 nsd := '00'B,
1791 facility := ts_FacLV(facility)
1792 }
1793 }
1794 }
1795}
1796template PDU_ML3_MS_NW tr_ML3_MO_SS_FACILITY(
1797 template uint3_t tid, template BIT1 ti_flag,
1798 template OCTN facility
1799) := {
1800 discriminator := '1011'B,
1801 tiOrSkip := {
1802 transactionId := {
1803 tio := f_tid_or_wc(tid),
1804 tiFlag := ti_flag,
1805 tIExtension := omit
1806 }
1807 },
1808 msgs := {
1809 ss := {
1810 facility := {
1811 messageType := '111010'B,
1812 nsd := '00'B,
1813 facility := tr_FacLV(facility)
1814 }
1815 }
1816 }
1817}
1818
1819template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_FACILITY(
1820 uint3_t tid, BIT1 ti_flag,
1821 OCTN facility
1822) := {
1823 discriminator := '1011'B,
1824 tiOrSkip := {
1825 transactionId := {
1826 tio := int2bit(tid, 3),
1827 tiFlag := ti_flag,
1828 tIExtension := omit
1829 }
1830 },
1831 msgs := {
1832 ss := {
1833 facility := {
1834 messageType := '111010'B,
1835 nsd := '00'B,
1836 facility := ts_FacLV(facility)
1837 }
1838 }
1839 }
1840}
1841template PDU_ML3_NW_MS tr_ML3_MT_SS_FACILITY(
1842 template uint3_t tid, template BIT1 ti_flag,
1843 template OCTN facility
1844) := {
1845 discriminator := '1011'B,
1846 tiOrSkip := {
1847 transactionId := {
1848 tio := f_tid_or_wc(tid),
1849 tiFlag := ti_flag,
1850 tIExtension := omit
1851 }
1852 },
1853 msgs := {
1854 ss := {
1855 facility := {
1856 messageType := '111010'B,
1857 nsd := '00'B,
1858 facility := tr_FacLV(facility)
1859 }
1860 }
1861 }
1862}
1863
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001864template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_RELEASE_COMPLETE(
1865 uint3_t tid, BIT1 ti_flag,
1866 template (omit) ML3_Cause_TLV cause := omit,
1867 template (omit) OCTN facility := omit
1868) := {
1869 discriminator := '1011'B,
1870 tiOrSkip := {
1871 transactionId := {
1872 tio := int2bit(tid, 3),
1873 tiFlag := ti_flag,
1874 tIExtension := omit
1875 }
1876 },
1877 msgs := {
1878 ss := {
1879 releaseComplete_MS_NW := {
1880 messageType := '101010'B,
1881 nsd := '00'B,
1882 cause := cause,
1883 facility := f_facility_or_omit(facility)
1884 }
1885 }
1886 }
1887}
1888template PDU_ML3_MS_NW tr_ML3_MO_SS_RELEASE_COMPLETE(
1889 template uint3_t tid, template BIT1 ti_flag,
1890 template ML3_Cause_TLV cause := *,
1891 template OCTN facility := *
1892) := {
1893 discriminator := '1011'B,
1894 tiOrSkip := {
1895 transactionId := {
1896 tio := f_tid_or_wc(tid),
1897 tiFlag := ti_flag,
1898 tIExtension := omit
1899 }
1900 },
1901 msgs := {
1902 ss := {
1903 releaseComplete_MS_NW := {
1904 messageType := '101010'B,
1905 nsd := '00'B,
1906 cause := cause,
1907 facility := f_facility_or_wc(facility)
1908 }
1909 }
1910 }
1911}
1912
1913template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_RELEASE_COMPLETE(
1914 uint3_t tid, BIT1 ti_flag,
1915 template (omit) ML3_Cause_TLV cause := omit,
1916 template (omit) OCTN facility := omit
1917) := {
1918 discriminator := '1011'B,
1919 tiOrSkip := {
1920 transactionId := {
1921 tio := int2bit(tid, 3),
1922 tiFlag := ti_flag,
1923 tIExtension := omit
1924 }
1925 },
1926 msgs := {
1927 ss := {
1928 releaseComplete_NW_MS := {
1929 messageType := '101010'B,
1930 nsd := '00'B,
1931 cause := cause,
1932 facility := f_facility_or_omit(facility)
1933 }
1934 }
1935 }
1936}
1937template PDU_ML3_NW_MS tr_ML3_MT_SS_RELEASE_COMPLETE(
1938 template uint3_t tid, template BIT1 ti_flag,
1939 template ML3_Cause_TLV cause := *,
1940 template OCTN facility := *
1941) := {
1942 discriminator := '1011'B,
1943 tiOrSkip := {
1944 transactionId := {
1945 tio := f_tid_or_wc(tid),
1946 tiFlag := ti_flag,
1947 tIExtension := omit
1948 }
1949 },
1950 msgs := {
1951 ss := {
1952 releaseComplete_NW_MS := {
1953 messageType := '101010'B,
1954 nsd := '00'B,
1955 cause := cause,
1956 facility := f_facility_or_wc(facility)
1957 }
1958 }
1959 }
1960}
1961
Harald Welte53603962018-05-28 11:13:09 +02001962/***********************************************************************
Harald Welte38575a72018-02-15 20:41:37 +01001963 * GPRS Mobility Management
1964 ***********************************************************************/
1965
1966template (value) MSNetworkCapabilityV ts_GMM_MsNetCapV := {
1967 gea1bit := '1'B,
1968 smCapabilitiesviaDedicatedChannels := '1'B,
1969 smCapabilitiesviaGPRSChannels := '0'B,
1970 ucs2Support := '1'B,
1971 ssScreeningIndicator := '01'B,
1972 solSACapability := omit,
1973 revisionLevelIndicatior := omit,
1974 pFCFeatureMode := omit,
1975 extendedGEAbits := omit,
1976 lcsVAcapability := omit,
1977 pSInterRATHOtoUTRANIuModeCapability := omit,
1978 pSInterRATHOtoEUTRANS1ModeCapability := omit,
1979 eMMCombinedProceduresCapability := omit,
1980 iSRSupport := omit,
1981 sRVCCtoGERANUTRANCapability := omit,
1982 ePCCapability := omit,
1983 nFCapability := omit,
1984 gERANNertworkSharingCapability := omit,
1985 spare_octets := omit
1986};
1987
1988template (value) MSNetworkCapabilityLV ts_GMM_MsNetCapLV := {
1989 lengthIndicator := 0, /* overwritten */
1990 msNetworkCapabilityV := ts_GMM_MsNetCapV
1991};
1992
1993type enumerated GprsAttachType {
1994 GPRS_ATT_T_GPRS,
1995 GPRS_ATT_T_GPRS_IMSI_COMBINED
1996};
1997
1998function ts_GMM_AttachType(boolean combined := false, boolean follow_on_pending := false)
1999return AttachTypeV {
2000 var AttachTypeV att;
2001 if (combined) {
2002 att.attachType := '011'B;
2003 } else {
2004 att.attachType := '001'B;
2005 }
2006 att.for_l3 := bool2bit(combined);
2007 return att;
2008}
2009
2010type enumerated GprsUpdateType {
2011 GPRS_UPD_T_RA ('000'B),
2012 GPRS_UPD_T_RA_LA_COMBINED ('001'B),
2013 GPRS_UPD_T_RA_LA_COMBINED_IMSI_ATT ('010'B),
2014 GPRS_UPD_T_PERIODIC ('011'B)
2015};
2016
2017/* 10.5.5.18 Update Type */
2018template UpdateTypeV ts_GMM_UpdateType(GprsUpdateType upd_t, boolean combined := false,
2019 boolean follow_on_pending := false) := {
2020 valueField := int2bit(enum2int(upd_t), 3),
2021 for_l3 := bool2bit(combined)
2022}
2023
2024template (value) DRXParameterV ts_DrxParameterV := {
2025 splitPGCycleCode := '00'O, /* no DRX */
2026 nonDRXTimer := '000'B, /* no non-DRX mode */
2027 splitOnCCCH := '0'B, /* not supported */
2028 cnSpecificDRXCycleLength := '0000'B /* SI value used */
2029};
2030
2031template (value) AccessCapabilitiesStruct ts_AccesssCap := {
2032 lengthIndicator := 0, /* overwritten */
2033 accessCapabilities := {
2034 rfPowerCapability := '001'B, /* FIXME */
2035 presenceBitA5 := '0'B,
2036 a5bits := omit,
2037 esind := '1'B,
2038 psbit := '0'B,
2039 vgcs := '0'B,
2040 vbs := '0'B,
2041 presenceBitMultislot := '0'B,
2042 multislotcap := omit,
2043 accessCapAdditionsAfterRel97 := omit
2044 },
2045 spare_bits := omit
2046}
2047
2048template (value) MSRACapabilityValuesRecord ts_RaCapRec(BIT4 att) := {
2049 mSRACapabilityValues := {
2050 mSRACapabilityValuesExclude1111 := {
2051 accessTechnType := '0001'B, /* E-GSM */
2052 accessCapabilities := ts_AccesssCap
2053 }
2054 },
2055 presenceBitMSRACap := '0'B
2056};
2057
2058template (value) MSRadioAccessCapabilityLV ts_MS_RaCapa := {
2059 lengthIndicator := 0, /* overwritten */
2060 msRadioAccessCapabilityV := {
2061 ts_RaCapRec('0001'B) /* E-GSM */
2062 }
2063}
2064
2065template (value) PDU_L3_MS_SGSN
2066 ts_GMM_ATTACH_REQ(MobileIdentityLV mi_lv, RoutingAreaIdentificationV old_ra,
2067 boolean combined := false, boolean follow_on_pending := false,
2068 template (omit) MobileStationClassmark2_TLV cm2_tlv,
2069 template (omit) MobileStationClassmark3_TLV cm3_tlv
2070 ) := {
2071 discriminator := '0000'B, /* overwritten */
2072 tiOrSkip := {
2073 skipIndicator := '0000'B
2074 },
2075 msgs := {
2076 gprs_mm := {
2077 attachRequest := {
2078 messageType := '00000000'B, /* overwritten */
2079 msNetworkCapability := ts_GMM_MsNetCapLV,
2080 attachType := valueof(ts_GMM_AttachType(combined, follow_on_pending)),
2081 gprsCKSN := { '111'B, '0'B },
2082 drxParam := ts_DrxParameterV,
2083 mobileIdentity := mi_lv,
2084 oldRoutingAreaID := old_ra,
2085 msRACap := ts_MS_RaCapa,
2086 ptmsiSignature := omit, /* TODO */
2087 reqGPRStimer := omit,
2088 tmsiStatus := omit,
2089 pC_LCSCapability := omit,
2090 mobileStationClassmark2 := cm2_tlv,
2091 mobileStationClassmark3 := cm3_tlv,
2092 supportedCodecs := omit,
2093 uENetworkCapability := omit,
2094 additionalMobileIdentity := omit,
2095 routingAreaIdentification2 := omit,
2096 voiceDomainandUEsUsageSetting := omit,
2097 deviceProperties := omit,
2098 p_TMSI_Type := omit,
2099 mS_NetworkFeatureSupport := omit,
2100 oldLocationAreaIdentification := omit,
2101 additionalUpdateType := omit,
2102 tMSIBasedNRIcontainer := omit,
2103 t3324 := omit,
2104 t3312_ExtendedValue := omit,
2105 extendedDRXParameters := omit
2106 }
2107 }
2108 }
2109}
2110
Harald Welteb0386df2018-02-16 18:14:28 +01002111private function tr_MI_TMSI_TLV(template OCT4 tmsi) return template MobileIdentityTLV {
2112 if (istemplatekind(tmsi, "*")) {
2113 return *;
2114 } else if (istemplatekind(tmsi, "?")) {
2115 return ?;
2116 } else {
2117 var template MobileIdentityTLV mi := {
2118 elementIdentifier := '0011000'B,
2119 spare1 := '0'B,
2120 mobileIdentityLV := {
2121 lengthIndicator := 4,
2122 mobileIdentityV := {
2123 typeOfIdentity := '100'B,
2124 oddEvenInd_identity := {
2125 tmsi_ptmsi := {
2126 oddevenIndicator := '1'B,
2127 fillerDigit := '1111'B,
2128 octets := tmsi
2129 }
2130 }
2131 }
2132 }
2133 };
2134 return mi;
2135 }
2136}
2137
2138template PDU_L3_SGSN_MS tr_GMM_ATTACH_ACCEPT(template BIT3 res := ?,
2139 template RoutingAreaIdentificationV ra := ?,
2140 template OCT4 ptmsi := *) := {
2141 discriminator := '1000'B,
2142 tiOrSkip := {
2143 skipIndicator := '0000'B
2144 },
2145 msgs := {
2146 gprs_mm := {
2147 attachAccept := {
2148 messageType := '00000010'B,
2149 attachResult := { res, ? },
2150 forceToStandby := ?,
2151 updateTimer := ?,
2152 radioPriority := ?,
2153 radioPriorityTOM8 := ?,
2154 routingAreaIdentification := ra,
2155 ptmsiSignature := *,
2156 readyTimer := *,
2157 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2158 msIdentity := *,
2159 gmmCause := *,
2160 t3302 := *,
2161 cellNotification := *,
2162 equivalentPLMNs := *,
2163 networkFeatureSupport := *,
2164 emergencyNumberList := *,
2165 requestedMSInformation := *,
2166 t3319 := *,
2167 t3323 := *,
2168 t3312_ExtendedValue := *,
2169 additionalNetworkFeatureSupport := *,
2170 t3324 := *,
2171 extendedDRXParameters := *
2172 }
2173 }
2174 }
2175}
Harald Welte38575a72018-02-15 20:41:37 +01002176
Harald Welte5b7c8122018-02-16 21:48:17 +01002177template PDU_L3_SGSN_MS tr_GMM_ATTACH_REJECT(template OCT1 cause) := {
2178 discriminator := '1000'B,
2179 tiOrSkip := {
2180 skipIndicator := '0000'B
2181 },
2182 msgs := {
2183 gprs_mm := {
2184 attachReject := {
2185 messageType := '00000100'B,
2186 gmmCause := {
2187 causeValue := cause
2188 },
2189 t3302 := *,
2190 t3346 := *
2191 }
2192 }
2193 }
2194}
2195
2196
Harald Welte38575a72018-02-15 20:41:37 +01002197template (value) PDU_L3_MS_SGSN ts_GMM_ATTACH_COMPL := {
2198 discriminator := '0000'B, /* overwritten */
2199 tiOrSkip := {
2200 skipIndicator := '0000'B
2201 },
2202 msgs := {
2203 gprs_mm := {
2204 attachComplete := {
2205 messageType := '00000000'B, /* overwritten */
2206 interRATHandoverInformation := omit,
2207 eUTRANinterRATHandoverInformation := omit
2208 }
2209 }
2210 }
2211}
2212
2213template (value) PDU_L3_MS_SGSN
2214 ts_GMM_RAU_REQ(MobileIdentityLV mi_lv, GprsUpdateType upd_type,
2215 RoutingAreaIdentificationV old_ra,
2216 boolean follow_on_pending := false,
2217 template (omit) MobileStationClassmark2_TLV cm2_tlv,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002218 template (omit) MobileStationClassmark3_TLV cm3_tlv,
2219 template (omit) OCT4 p_tmsi := omit
Harald Welte38575a72018-02-15 20:41:37 +01002220 ) := {
2221 discriminator := '0000'B, /* overwritten */
2222 tiOrSkip := {
2223 skipIndicator := '0000'B
2224 },
2225 msgs := {
2226 gprs_mm := {
2227 routingAreaUpdateRequest := {
2228 messageType := '00000000'B, /* overwritten */
2229 updateType := ts_GMM_UpdateType(upd_type, follow_on_pending),
2230 gprsCKSN := { '111'B, '0'B },
2231 oldRoutingAreaId := old_ra,
2232 msRACap := ts_MS_RaCapa,
2233 oldPTMSISignature := omit, /* TODO */
2234 readyTimerValue := omit,
2235 drxParameter := omit,
2236 tmsiStatus := omit,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002237 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
Harald Welte38575a72018-02-15 20:41:37 +01002238 mSNetworkCapability := omit,
2239 pdpContextStatus := omit, /* TODO */
2240 pC_LCSCapability := omit,
Harald Welte04683d02018-02-16 22:43:45 +01002241 mBMS_ContextStatus := omit,
Harald Welte38575a72018-02-15 20:41:37 +01002242 uENetworkCapability := omit,
2243 additionalMobileIdentity := omit,
2244 oldRoutingAreaIdentification2 := omit,
2245 mobileStationClassmark2 := cm2_tlv,
2246 mobileStationClassmark3 := cm3_tlv,
2247 supportedCodecs := omit,
2248 voiceDomainUEUsageSetting := omit,
2249 p_TMSI_Type := omit,
2250 deviceProperties := omit,
2251 mS_NetworkFeatureSupport := omit,
2252 oldLocationAreaIdentification := omit,
2253 additionalUpdateType := omit,
2254 tMSIBasedNRIcontainer := omit,
2255 t3324 := omit,
2256 t3312_ExtendedValue := omit,
2257 extendedDRXParameters := omit
2258 }
2259 }
2260 }
2261}
2262
Harald Welte04683d02018-02-16 22:43:45 +01002263template PDU_L3_SGSN_MS tr_GMM_RAU_REJECT(template OCT1 cause := ?) := {
2264 discriminator := '1000'B,
2265 tiOrSkip := {
2266 skipIndicator := '0000'B
2267 },
2268 msgs := {
2269 gprs_mm := {
2270 routingAreaUpdateReject := {
2271 messageType := '00001011'B,
2272 gmmCause := {
2273 causeValue := cause
2274 },
2275 forceToStandby := ?,
2276 spare := '0000'B,
2277 t3302 := *,
2278 t3346 := *
2279 }
2280 }
2281 }
2282}
2283
Harald Welte91636de2018-02-17 10:16:14 +01002284template PDU_L3_SGSN_MS tr_GMM_RAU_ACCEPT(template BIT3 res := ?,
2285 template RoutingAreaIdentificationV ra := ?,
2286 template OCT4 ptmsi := *) := {
2287 discriminator := '1000'B,
2288 tiOrSkip := {
2289 skipIndicator := '0000'B
2290 },
2291 msgs := {
2292 gprs_mm := {
2293 routingAreaUpdateAccept := {
2294 messageType := '00001001'B,
2295 forceToStandby := ?,
2296 updateResult := { res, ? },
2297 raUpdateTimer := ?,
2298 routingAreaId := ra,
2299 ptmsiSignature := *,
2300 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2301 msIdentity := *,
2302 receiveNPDUNumbers := *,
2303 readyTimer := *,
2304 gmmCause := *,
2305 t3302 := *,
2306 cellNotification := *,
2307 equivalentPLMNs := *,
2308 pdpContextStatus := *,
2309 networkFeatureSupport := *,
2310 emergencyNumberList := *,
2311 mBMS_ContextStatus := *,
2312 requestedMSInformation := *,
2313 t3319 := *,
2314 t3323 := *,
2315 t3312_ExtendedValue := *,
2316 additionalNetworkFeatureSupport := *,
2317 t3324 := *,
2318 extendedDRXParameters := *
2319 }
2320 }
2321 }
2322}
Harald Welte04683d02018-02-16 22:43:45 +01002323
Harald Welte38575a72018-02-15 20:41:37 +01002324template (value) PDU_L3_MS_SGSN ts_GMM_RAU_COMPL := {
2325 discriminator := '0000'B, /* overwritten */
2326 tiOrSkip := {
2327 skipIndicator := '0000'B
2328 },
2329 msgs := {
2330 gprs_mm := {
2331 routingAreaUpdateComplete := {
2332 messageType := '00000000'B, /* overwritten */
2333 receiveNPDUNumbers := omit,
2334 interRATHandoverInformation := omit,
2335 eUTRANinterRATHandoverInformation := omit
2336 }
2337 }
2338 }
2339}
2340
2341template (value) PDU_L3_MS_SGSN ts_GMM_PTMSI_REALL_COMPL := {
2342 discriminator := '0000'B, /* overwritten */
2343 tiOrSkip := {
2344 skipIndicator := '0000'B
2345 },
2346 msgs := {
2347 gprs_mm := {
2348 p_TMSIReallocationComplete := {
2349 messageType := '00000000'B /* overwritten */
2350 }
2351 }
2352 }
2353}
2354
2355template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_CIPH_COMPL(ACReferenceNumberV ref, OCT4 res) := {
2356 discriminator := '0000'B, /* overwritten */
2357 tiOrSkip := {
2358 skipIndicator := '0000'B
2359 },
2360 msgs := {
2361 gprs_mm := {
2362 authenticationAndCipheringResponse := {
2363 messageType := '00000000'B, /* overwritten */
2364 acReferenceNumber := ref,
2365 spare := '0000'B,
2366 authenticationParResp := {
2367 elementIdentifier := '22'O,
2368 valueField := res
2369 },
2370 imeisv := omit,
2371 authenticationRespParExt := omit
2372 }
2373 }
2374 }
2375}
2376
Harald Welteb0386df2018-02-16 18:14:28 +01002377template PDU_L3_SGSN_MS tr_GMM_ID_REQ(template BIT3 id_type := ?) := {
2378 discriminator := '1000'B,
2379 tiOrSkip := {
2380 skipIndicator := '0000'B
2381 },
2382 msgs := {
2383 gprs_mm := {
2384 identityRequest := {
2385 messageType := '00010101'B,
2386 identityType := { id_type, '0'B },
2387 forceToStandby := ?
2388 }
2389 }
2390 }
2391}
2392
Harald Welte38575a72018-02-15 20:41:37 +01002393template (value) PDU_L3_MS_SGSN ts_GMM_ID_RESP(MobileIdentityLV mi_lv) := {
2394 discriminator := '0000'B, /* overwritten */
2395 tiOrSkip := {
2396 skipIndicator := '0000'B
2397 },
2398 msgs := {
2399 gprs_mm := {
2400 identityResponse := {
2401 messageType := '00000000'B, /* overwritten */
2402 mobileIdentity := mi_lv
2403 }
2404 }
2405 }
2406}
2407
Harald Welteb0386df2018-02-16 18:14:28 +01002408template PDU_L3_SGSN_MS tr_GMM_AUTH_REQ(template OCT16 rand := ?, template BIT3 ciph_alg := ?) := {
2409 discriminator := '1000'B,
2410 tiOrSkip := {
2411 skipIndicator := '0000'B
2412 },
2413 msgs := {
2414 gprs_mm := {
2415 authenticationAndCipheringRequest := {
2416 messageType := '00010010'B,
2417 cipheringAlgorithm := { ciph_alg, '0'B },
2418 imeisvRequest := ?,
2419 forceToStandby := ?,
2420 acReferenceNumber := ?,
2421 authenticationParameterRAND := {
2422 elementIdentifier := '21'O,
2423 randValue := rand
2424 },
2425 cipheringKeySequenceNumber := *,
2426 authenticationParameterAUTN := *
2427 }
2428 }
2429 }
2430}
2431
2432template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_RESP_2G(BIT4 ac_ref, OCT4 sres) := {
2433 discriminator := '1000'B,
2434 tiOrSkip := {
2435 skipIndicator := '0000'B
2436 },
2437 msgs := {
2438 gprs_mm := {
2439 authenticationAndCipheringResponse := {
2440 messageType := '00010011'B,
2441 acReferenceNumber := { valueField := ac_ref },
2442 spare := '0000'B,
2443 authenticationParResp := {
2444 elementIdentifier := '22'O,
2445 valueField := sres
2446 },
2447 imeisv := omit,
2448 authenticationRespParExt := omit
2449 }
2450 }
2451 }
2452}
2453
Alexander Couzens15faf922018-09-04 15:16:26 +02002454template PDU_L3_MS_SGSN ts_GMM_AUTH_FAIL_UMTS_AKA_RESYNC(octetstring auts) := {
2455 discriminator := '1000'B,
2456 tiOrSkip := {
2457 skipIndicator := '0000'B
2458 },
2459 msgs := {
2460 gprs_mm := {
2461 authenticationAndCipheringFailure := {
2462 messageType := '00011100'B,
2463 gmmCause := {
2464 causeValue := '15'O /* GMM_CAUSE_SYNC_FAIL 10.5.3.2.2 */
2465 },
2466 authenticationFailureParam := {
2467 elementIdentifier := '30'O,
2468 lengthIndicator := 14,
2469 valueField := auts
2470 }
2471 }
2472 }
2473 }
2474}
2475
Harald Welteb0386df2018-02-16 18:14:28 +01002476
Harald Welte38575a72018-02-15 20:41:37 +01002477const BIT3 c_GMM_DTT_MO_GPRS := '001'B;
2478const BIT3 c_GMM_DTT_MO_IMSI := '010'B;
2479const BIT3 c_GMM_DTT_MO_GPRS_IMSI_COMBINED := '011'B;
2480
Alexander Couzensb6ab4562018-05-17 02:59:22 +02002481const BIT3 c_GMM_DTT_MT_REATTACH_REQUIRED := '001'B;
2482const BIT3 c_GMM_DTT_MT_REATTACH_NOT_REQUIRED := '010'B;
2483const BIT3 c_GMM_DTT_MT_IMSI_DETACH := '011'B;
2484
Harald Welte6abb9fe2018-02-17 15:24:48 +01002485template (value) DetachTypeV ts_GMM_DetType(BIT3 dtt, boolean power_off := false) := {
Harald Welte38575a72018-02-15 20:41:37 +01002486 detachType := dtt,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002487 powerOffFlag := bool2bit(power_off)
Harald Welte38575a72018-02-15 20:41:37 +01002488}
2489
Harald Welte6abb9fe2018-02-17 15:24:48 +01002490function ts_PtmsiSigTV(template (omit) OCT3 val) return template (omit) P_TMSISignatureTV {
2491 var template (omit) P_TMSISignatureTV ret;
2492 if (istemplatekind(val, "omit")) {
2493 return omit;
2494 } else {
2495 ret := {
2496 elementIdentifier := '19'O,
2497 valueField := valueof(val)
2498 }
2499 return ret;
2500 }
2501}
2502
2503function ts_PtmsiSigTLV(template (omit) OCT3 val) return template (omit) P_TMSISignature2TLV {
2504 var template (omit) P_TMSISignature2TLV ret;
2505 if (istemplatekind(val, "omit")) {
2506 return omit;
2507 } else {
2508 ret := {
2509 elementIdentifier := '19'O,
2510 lengthIndicator := 3,
2511 valueField := valueof(val)
2512 }
2513 return ret;
2514 }
2515}
2516
2517template (value) PDU_L3_MS_SGSN ts_GMM_DET_REQ_MO(BIT3 dtt := c_GMM_DTT_MO_GPRS,
2518 boolean power_off := false,
2519 template (omit) OCT4 p_tmsi := omit,
2520 template (omit) OCT3 p_tmsi_sig := omit) := {
Harald Welte38575a72018-02-15 20:41:37 +01002521 discriminator := '0000'B, /* overwritten */
2522 tiOrSkip := {
2523 skipIndicator := '0000'B
2524 },
2525 msgs := {
2526 gprs_mm := {
2527 detachRequest_MS_SGSN := {
2528 messageType := '00000000'B, /* overwritten */
Harald Welte6abb9fe2018-02-17 15:24:48 +01002529 detachType := valueof(ts_GMM_DetType(dtt, power_off)),
Harald Welte38575a72018-02-15 20:41:37 +01002530 spare := '0000'B,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002531 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
2532 ptmsiSignature := ts_PtmsiSigTLV(p_tmsi_sig)
2533 }
2534 }
2535 }
2536}
2537
2538template PDU_L3_SGSN_MS tr_GMM_DET_ACCEPT_MT := {
2539 discriminator := '1000'B,
2540 tiOrSkip := {
2541 skipIndicator := '0000'B
2542 },
2543 msgs := {
2544 gprs_mm := {
2545 detachAccept_SGSN_MS := {
2546 messageType := '00000110'B,
2547 forceToStandby := ?,
2548 spare := '0000'B
Harald Welte38575a72018-02-15 20:41:37 +01002549 }
2550 }
2551 }
2552}
Harald Welte812f7a42018-01-27 00:49:18 +01002553
Alexander Couzensd62fba52018-05-22 16:08:39 +02002554template PDU_L3_SGSN_MS tr_GMM_DET_REQ_MT(
2555 template BIT3 dtt := *,
2556 template BIT3 forceToStandby := ?,
Alexander Couzensd8604ab2018-05-29 15:46:06 +02002557 template OCT1 cause := *) := {
Harald Welte835b15f2018-02-18 14:39:11 +01002558 discriminator := '1000'B,
2559 tiOrSkip := {
2560 skipIndicator := '0000'B
2561 },
2562 msgs := {
2563 gprs_mm := {
2564 detachRequest_SGSN_MS := {
2565 messageType := '00000101'B,
Alexander Couzensd62fba52018-05-22 16:08:39 +02002566 detachType := { dtt, ? },
2567 forceToStandby := { forceToStandby, '0'B },
2568 gmmCause := {
2569 elementIdentifier := '25'O,
2570 causeValue := { cause }
2571 }
2572 }
2573 }
2574 }
2575}
2576
2577template PDU_L3_MS_SGSN ts_GMM_DET_ACCEPT_MO := {
2578 discriminator := '0000'B, /* overwritten */
2579 tiOrSkip := {
2580 skipIndicator := '0000'B
2581 },
2582 msgs := {
2583 gprs_mm := {
2584 detachAccept_MS_SGSN := {
2585 messageType := '00000000'B
Harald Welte835b15f2018-02-18 14:39:11 +01002586 }
2587 }
2588 }
2589}
Harald Welteeded9ad2018-02-17 20:57:34 +01002590
2591function ts_ApnTLV(template (omit) octetstring apn) return template (omit) AccessPointNameTLV {
2592 if (istemplatekind(apn, "omit")) {
2593 return omit;
2594 } else {
2595 var template (omit) AccessPointNameTLV ret := {
2596 elementIdentifier := '28'O,
2597 lengthIndicator := 0, /* overwritten */
2598 accessPointNameValue := apn
2599 }
2600 return ret;
2601 }
2602}
2603
2604function ts_PcoTLV(template (omit) ProtocolConfigOptionsV pco)
2605 return template (omit) ProtocolConfigOptionsTLV {
2606 if (istemplatekind(pco, "omit")) {
2607 return omit;
2608 } else {
2609 var template (omit) ProtocolConfigOptionsTLV ret := {
2610 elementIdentifier := '27'O,
2611 lengthIndicator := 0, /* overwritten */
2612 protocolConfigOptionsV := pco
2613 }
2614 return ret;
2615 }
2616}
2617
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002618function ts_TearDownIndicatorTV(in template (omit) boolean ind)
2619 return template (omit) TearDownIndicatorTV {
2620 if (istemplatekind(ind, "omit")) {
2621 return omit;
2622 } else {
2623 var template (omit) TearDownIndicatorTV ret := {
2624 tearDownIndicatorV := {
2625 tdi_flag := bool2bit(valueof(ind)),
2626 spare := '000'B
2627 },
2628 elementIdentifier := '1001'B
2629 }
2630 return ret;
2631 }
2632}
2633
Harald Welteeded9ad2018-02-17 20:57:34 +01002634template (value) PDU_L3_MS_SGSN ts_SM_ACT_PDP_REQ(BIT3 tid, BIT4 nsapi, BIT4 sapi, QoSV qos,
2635 PDPAddressV addr,
2636 template (omit) octetstring apn := omit,
2637 template (omit) ProtocolConfigOptionsV pco := omit
2638 ) := {
2639 discriminator := '0000'B, /* overwritten */
2640 tiOrSkip := {
2641 transactionId := {
2642 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002643 tiFlag := c_TIF_ORIG,
Harald Welteeded9ad2018-02-17 20:57:34 +01002644 tIExtension := omit
2645 }
2646 },
2647 msgs := {
2648 gprs_sm := {
2649 activatePDPContextRequest := {
2650 messageType := '00000000'B, /* overwritten */
2651 requestedNSAPI := { nsapi, '0000'B },
2652 requestedLLCSAPI := { sapi, '0000'B },
2653 requestedQoS := {
2654 lengthIndicator := 0, /* overwritten */
2655 qoSV := qos
2656 },
2657 requestedPDPaddress := {
2658 lengthIndicator := 0, /* overwritten */
2659 pdpAddressV := addr
2660 },
2661 accessPointName := ts_ApnTLV(apn),
2662 protocolConfigOpts := ts_PcoTLV(pco),
2663 requestType := omit,
2664 deviceProperties := omit,
2665 nBIFOM_Container := omit
2666 }
2667 }
2668 }
2669}
2670
2671template PDU_L3_SGSN_MS tr_SM_ACT_PDP_REJ(template BIT3 tid := ?, template OCT1 cause := ?) := {
2672 discriminator := '1010'B,
2673 tiOrSkip := {
2674 transactionId := {
2675 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002676 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002677 tIExtension := omit
2678 }
2679 },
2680 msgs := {
2681 gprs_sm := {
2682 activatePDPContextReject := {
Harald Welte4aacdd82018-02-18 21:24:05 +01002683 messageType := '01000011'B,
Harald Welteeded9ad2018-02-17 20:57:34 +01002684 smCause := cause,
2685 protocolConfigOpts := *,
2686 backOffTimer := *,
2687 reAttemptIndicator := *,
2688 nBIFOM_Container := *
2689 }
2690 }
2691 }
2692}
2693
2694template PDU_L3_SGSN_MS tr_SM_ACT_PDP_ACCEPT(template BIT3 tid := ?, template BIT4 sapi := ?,
2695 template QoSV qos := ?)
2696:= {
2697 discriminator := '1010'B,
2698 tiOrSkip := {
2699 transactionId := {
2700 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002701 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002702 tIExtension := omit
2703 }
2704 },
2705 msgs := {
2706 gprs_sm := {
2707 activatePDPContextAccept := {
2708 messageType := '01000010'B,
2709 negotiatedLLCSAPI := { sapi, '0000'B },
2710 negotiatedQoS := {
2711 lengthIndicator := ?,
2712 qoSV := qos
2713 },
2714 radioPriority := ?,
2715 spare := '0000'B,
2716 pdpAddress := *,
2717 protocolConfigOpts := *,
2718 packetFlowID := *,
2719 sMCause2 := *,
2720 connectivityType := *,
2721 wLANOffloadIndication := *,
2722 nBIFOM_Container := *
2723 }
2724 }
2725 }
2726}
2727
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002728template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_REQ_MO(BIT3 tid, OCT1 cause,
2729 template (omit) boolean tdown := omit,
Harald Welte6f203162018-02-18 22:04:55 +01002730 template (omit) ProtocolConfigOptionsV pco := omit
2731 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002732 discriminator := '1010'B,
Harald Welte6f203162018-02-18 22:04:55 +01002733 tiOrSkip := {
2734 transactionId := {
2735 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002736 tiFlag := c_TIF_ORIG,
Harald Welte6f203162018-02-18 22:04:55 +01002737 tIExtension := omit
2738 }
2739 },
2740 msgs := {
2741 gprs_sm := {
2742 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002743 messageType := '01000110'B,
Harald Welte6f203162018-02-18 22:04:55 +01002744 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002745 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte6f203162018-02-18 22:04:55 +01002746 protocolConfigOpts := ts_PcoTLV(pco),
2747 mBMSprotocolConfigOptions := omit,
2748 t3396 := omit,
2749 wLANOffloadIndication := omit,
2750 nBIFOM_Container := omit
2751 }
2752 }
2753 }
2754}
2755
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002756template (value) PDU_L3_SGSN_MS ts_SM_DEACT_PDP_REQ_MT(BIT3 tid, OCT1 cause,
2757 template (omit) boolean tdown := omit,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002758 template (omit) ProtocolConfigOptionsV pco := omit
2759 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002760 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002761 tiOrSkip := {
2762 transactionId := {
2763 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002764 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002765 tIExtension := omit
2766 }
2767 },
2768 msgs := {
2769 gprs_sm := {
2770 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002771 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002772 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002773 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte57b9b7f2018-02-18 22:28:13 +01002774 protocolConfigOpts := ts_PcoTLV(pco),
2775 mBMSprotocolConfigOptions := omit,
2776 t3396 := omit,
2777 wLANOffloadIndication := omit,
2778 nBIFOM_Container := omit
2779 }
2780 }
2781 }
2782}
2783
2784template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_REQ_MT(template BIT3 tid, template OCT1 cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002785 template (omit) boolean tdown := omit,
2786 template (omit) ProtocolConfigOptionsV pco := omit
2787 ) := {
2788 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002789 tiOrSkip := {
2790 transactionId := {
2791 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002792 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002793 tIExtension := omit
2794 }
2795 },
2796 msgs := {
2797 gprs_sm := {
2798 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002799 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002800 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002801 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
2802 protocolConfigOpts := ts_PcoTLV(pco),
Harald Welte57b9b7f2018-02-18 22:28:13 +01002803 mBMSprotocolConfigOptions := *,
2804 t3396 := *,
2805 wLANOffloadIndication := *,
2806 nBIFOM_Container := *
2807 }
2808 }
2809 }
2810}
2811
Harald Welte6f203162018-02-18 22:04:55 +01002812template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_ACCEPT_MT(template BIT3 tid := ?)
2813:= {
2814 discriminator := '1010'B,
2815 tiOrSkip := {
2816 transactionId := {
2817 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002818 tiFlag := c_TIF_REPL,
Harald Welte6f203162018-02-18 22:04:55 +01002819 tIExtension := omit
2820 }
2821 },
2822 msgs := {
2823 gprs_sm := {
2824 deactivatePDPContextAccept := {
2825 messageType := '01000111'B,
2826 protocolConfigOpts := *,
2827 mBMSprotocolConfigOptions := *,
2828 nBIFOM_Container := *
2829 }
2830 }
2831 }
2832}
2833
Harald Welte57b9b7f2018-02-18 22:28:13 +01002834template PDU_L3_MS_SGSN tr_SM_DEACT_PDP_ACCEPT_MO(template BIT3 tid := ?)
2835:= {
2836 discriminator := '1010'B,
2837 tiOrSkip := {
2838 transactionId := {
2839 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002840 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002841 tIExtension := omit
2842 }
2843 },
2844 msgs := {
2845 gprs_sm := {
2846 deactivatePDPContextAccept := {
2847 messageType := '01000111'B,
2848 protocolConfigOpts := *,
2849 mBMSprotocolConfigOptions := *,
2850 nBIFOM_Container := *
2851 }
2852 }
2853 }
2854}
2855
2856template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_ACCEPT_MO(BIT3 tid)
2857:= {
2858 discriminator := '1010'B,
2859 tiOrSkip := {
2860 transactionId := {
2861 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002862 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002863 tIExtension := omit
2864 }
2865 },
2866 msgs := {
2867 gprs_sm := {
2868 deactivatePDPContextAccept := {
2869 messageType := '01000111'B,
2870 protocolConfigOpts := omit,
2871 mBMSprotocolConfigOptions := omit,
2872 nBIFOM_Container := omit
2873 }
2874 }
2875 }
2876}
2877
Harald Welteeded9ad2018-02-17 20:57:34 +01002878
2879
Harald Weltee5695f52018-02-16 14:46:15 +01002880private function f_concat_pad(integer tot_len, hexstring prefix, integer suffix) return hexstring {
2881 var integer suffix_len := tot_len - lengthof(prefix);
2882 var charstring suffix_ch := int2str(suffix);
2883 var integer pad_len := suffix_len - lengthof(suffix_ch);
2884
2885 return prefix & int2hex(0, pad_len) & str2hex(suffix_ch);
2886}
2887
2888function f_gen_imei(integer suffix) return hexstring {
Oliver Smith745ed952019-07-05 14:08:17 +02002889 return f_concat_pad(14, '49999'H, suffix);
Harald Weltee5695f52018-02-16 14:46:15 +01002890}
2891
2892function f_gen_imsi(integer suffix) return hexstring {
2893 return f_concat_pad(15, '26242'H, suffix);
2894}
2895
2896function f_gen_msisdn(integer suffix) return hexstring {
2897 return f_concat_pad(12, '49123'H, suffix);
2898}
2899
Harald Welte7484fc42018-02-24 14:09:45 +01002900external function enc_MobileIdentityLV(in MobileIdentityLV si) return octetstring
2901 with { extension "prototype(convert) encode(RAW)" };
Harald Weltee5695f52018-02-16 14:46:15 +01002902
Vadim Yanitskiy322c7932020-01-01 23:03:47 +01002903external function dec_MobileIdentityV(in octetstring mi) return MobileIdentityV
2904 with { extension "prototype(convert) decode(RAW)" };
2905
Harald Weltecb6cc332018-01-21 13:59:08 +01002906
Harald Weltef45efeb2018-04-09 18:19:24 +02002907
2908/* SMS TPDU Layer */
2909
2910template (value) TPDU_RP_DATA_MS_SGSN ts_SMS_SUBMIT(OCT1 msg_ref, template (value) TP_DA dst_addr,
2911 template (value) OCT1 pid, template (value) OCT1 dcs,
2912 integer length_ind, octetstring user_data) := {
2913 sMS_SUBMIT := {
2914 tP_MTI := '01'B, /* SUBMIT */
2915 tP_RD := '1'B, /* reject duplicates */
2916 tP_VPF := '00'B, /* not present */
2917 tP_SRR := '0'B, /* no status report requested */
2918 tP_UDHI := '0'B, /* no user data header in UD */
2919 tP_RP := '0'B, /* no reply path */
2920 tP_MR := msg_ref,
2921 tP_DA := dst_addr,
2922 tP_PID := pid,
2923 tP_DCS := dcs,
2924 tP_VP := omit,
2925 tP_UDL_UD := {
2926 tP_LengthIndicator := length_ind,
2927 tP_UD := user_data
2928 }
2929 }
2930}
2931
2932template TPDU_RP_DATA_SGSN_MS tr_SMS_DELIVER(template TP_OA src_addr := ?,
2933 template octetstring user_data := ?,
2934 template OCT1 pid := ?, template OCT1 dcs := ?,
2935 template BIT1 mms := ?
2936 ) := {
2937 sMS_DELIVER := {
2938 tP_MTI := '00'B, /* DELIVER */
2939 tP_MMS := mms, /* more messages to send */
2940 tP_LP := ?, /* ?!? */
2941 tP_Spare := '0'B,
2942 tP_SRI := '0'B, /* status report indication */
2943 tP_UDHI := '0'B, /* no user data header in UD */
2944 tP_RP := '0'B, /* no reply path */
2945 tP_OA := src_addr,
2946 tP_PID := pid,
2947 tP_DCS := dcs,
2948 tP_SCTS := ?,
2949 tP_UDL_UD := {
2950 tP_LengthIndicator := ?,
2951 tP_UD := user_data
2952 }
2953 }
2954}
2955
2956/* RP Layer */
2957
2958private function ts_RpOrig(template (omit) RP_NumberingPlan_and_NumberDigits rp_orig)
2959return RP_OriginatorAddressLV {
2960 var RP_OriginatorAddressLV ret;
2961 if (istemplatekind(rp_orig, "omit")) {
2962 ret := { 0, omit };
2963 } else {
2964 ret := { 0, valueof(rp_orig) };
2965 }
2966 return ret;
2967}
2968
2969private function ts_RpDst(template (omit) RP_NumberingPlan_and_NumberDigits rp_dst)
2970return RP_DestinationAddressLV {
2971 var RP_DestinationAddressLV ret;
2972 if (istemplatekind(rp_dst, "omit")) {
2973 ret := { 0, omit };
2974 } else {
2975 ret := { 0, valueof(rp_dst) };
2976 }
2977 return ret;
2978}
2979
2980template (value) RPDU_MS_SGSN ts_RP_DATA_MO(OCT1 msg_ref,
2981 template (omit) RP_NumberingPlan_and_NumberDigits rp_orig,
2982 template (omit) RP_NumberingPlan_and_NumberDigits rp_dst,
2983 template (value) TPDU_RP_DATA_MS_SGSN tpdu) := {
2984 rP_DATA_MS_SGSN := {
2985 rP_MTI := '000'B,
2986 rP_Spare := '00000'B,
2987 rP_MessageReference := msg_ref,
2988 rP_OriginatorAddress := ts_RpOrig(rp_orig),
2989 rP_DestinationAddress := ts_RpDst(rp_dst),
2990 rP_User_Data := {
2991 rP_LengthIndicator := 0, /* overwritten */
2992 rP_TPDU := tpdu
2993 }
2994 }
2995}
2996
2997template RPDU_SGSN_MS tr_RP_DATA_MT(template OCT1 msg_ref,
2998 template RP_NumberingPlan_and_NumberDigits rp_orig,
2999 template RP_NumberingPlan_and_NumberDigits rp_dst,
3000 template TPDU_RP_DATA_SGSN_MS tpdu) := {
3001 rP_DATA_SGSN_MS := {
3002 rP_MTI := '001'B,
3003 rP_Spare := '00000'B,
3004 rP_MessageReference := msg_ref,
3005 rP_OriginatorAddress := { ?, rp_orig },
3006 rP_DestinationAddress := { ?, rp_dst },
3007 rP_User_Data := {
3008 rP_LengthIndicator := ?,
3009 rP_TPDU := tpdu
3010 }
3011
3012 }
3013}
3014
3015template (value) RPDU_MS_SGSN ts_RP_ACK_MO(OCT1 msg_ref) := {
3016 rP_ACK_MS_SGSN := {
3017 rP_MTI := '010'B,
3018 rP_Spare := '00000'B,
3019 rP_MessageReference := msg_ref,
3020 rP_User_Data := omit /* FIXME: report */
3021 }
3022}
3023
3024template RPDU_SGSN_MS tr_RP_ACK_MT(template OCT1 msg_ref) := {
3025 rP_ACK_SGSN_MS := {
3026 rP_MTI := '011'B,
3027 rP_Spare := '00000'B,
3028 rP_MessageReference := msg_ref,
3029 rP_User_Data := omit /* FIXME: report */
3030 }
3031}
3032
3033template (value) RPDU_MS_SGSN ts_RP_ERROR_MO(OCT1 msg_ref, uint7_t cause) := {
3034 rP_ERROR_MS_SGSN := {
3035 rP_MTI := '100'B,
3036 rP_Spare := '00000'B,
3037 rP_Message_Reference := msg_ref,
3038 rP_CauseLV := {
3039 rP_LengthIndicator := 0, /* overwritten */
3040 rP_CauseV := {
3041 causeValue := int2bit(cause, 7),
3042 ext := '0'B
3043 },
3044 rP_diagnisticField := omit
3045 },
3046 rP_User_Data := omit /* FIXME: report */
3047 }
3048}
3049
3050private function f_cause_or_wc(template uint7_t cause) return template BIT7 {
3051 if (istemplatekind(cause, "?")) {
3052 return ?;
3053 } else if (istemplatekind(cause, "*")) {
3054 return *;
3055 } else {
3056 return int2bit(valueof(cause), 7);
3057 }
3058}
3059
3060template RPDU_SGSN_MS tr_RP_ERROR_MT(template OCT1 msg_ref, template uint7_t cause) := {
3061 rP_ERROR_SGSN_MS := {
3062 rP_MTI := '101'B,
3063 rP_Spare := '00000'B,
3064 rP_Message_Reference := msg_ref,
3065 rP_CauseLV := {
Vadim Yanitskiye9e93012020-01-15 12:35:17 +07003066 rP_LengthIndicator := ?,
Harald Weltef45efeb2018-04-09 18:19:24 +02003067 rP_CauseV := {
3068 causeValue := f_cause_or_wc(cause),
3069 ext := '0'B
3070 },
3071 rP_diagnisticField := omit
3072 },
3073 rP_User_Data := omit /* FIXME: report */
3074 }
3075}
3076
3077
3078template (value) RPDU_MS_SGSN ts_RP_SMMA_MO(OCT1 msg_ref) := {
3079 rP_SMMA := {
3080 rP_MTI := '110'B,
3081 rP_Spare := '00000'B,
3082 rP_MessageReference := msg_ref
3083 }
3084}
3085
3086
3087
3088
3089/* CP Layer */
3090
3091template (value) L3_SMS_MS_SGSN ts_CP_DATA_MO(template (value) RPDU_MS_SGSN rpdu) := {
3092 cP_DATA := {
3093 cP_messageType := '00000001'B,
3094 cP_User_Data := {
3095 lengthIndicator := 0, /* overwritten */
3096 cP_RPDU := rpdu
3097 }
3098 }
3099}
3100
3101template (value) L3_SMS_MS_SGSN ts_CP_ACK_MO := {
3102 cP_ACK := {
3103 cP_messageType := '00000100'B
3104 }
3105}
3106
3107template (value) L3_SMS_MS_SGSN ts_CP_ERROR_MO(OCT1 cause) := {
3108 cP_ERROR := {
3109 cP_messageType := '00010000'B,
3110 cP_Cause := {
3111 causeValue := cause
3112 }
3113 }
3114}
3115
3116template L3_SMS_SGSN_MS tr_CP_DATA_MT(template RPDU_SGSN_MS rpdu) := {
3117 cP_DATA := {
3118 cP_messageType := '00000001'B,
3119 cP_User_Data := {
3120 lengthIndicator := ?,
3121 cP_RPDU := rpdu
3122 }
3123 }
3124}
3125
3126template L3_SMS_SGSN_MS tr_CP_ACK_MT := {
3127 cP_ACK := {
3128 cP_messageType := '00000100'B
3129 }
3130}
3131
3132template L3_SMS_SGSN_MS tr_CP_ERROR_MT(template OCT1 cause) := {
3133 cP_ERROR := {
3134 cP_messageType := '00010000'B,
3135 cP_Cause := {
3136 causeValue := cause
3137 }
3138 }
3139}
3140
3141/* L3 Wrapper */
3142
3143template (value) PDU_ML3_MS_NW ts_ML3_MO_SMS(uint3_t tid, BIT1 ti_flag,
3144 template (value) L3_SMS_MS_SGSN sms_mo) := {
3145 discriminator := '1001'B,
3146 tiOrSkip := {
3147 transactionId := {
3148 tio := int2bit(tid, 3),
3149 tiFlag := ti_flag,
3150 tIExtension := omit
3151 }
3152 },
3153 msgs := {
3154 sms := sms_mo
3155 }
3156}
3157
3158private function f_tid_or_wc(template uint3_t tid) return template BIT3 {
3159 var template BIT3 ret;
3160 if (istemplatekind(tid, "*")) {
3161 return *;
3162 } else if (istemplatekind(tid, "?")) {
3163 return ?;
3164 } else {
3165 return int2bit(valueof(tid), 3);
3166 }
3167}
3168
3169template PDU_ML3_NW_MS tr_ML3_MT_SMS(template uint3_t tid, template BIT1 ti_flag,
3170 template L3_SMS_SGSN_MS sms_mt) := {
3171 discriminator := '1001'B,
3172 tiOrSkip := {
3173 transactionId := {
3174 tio := f_tid_or_wc(tid),
3175 tiFlag := ti_flag,
3176 tIExtension := omit
3177 }
3178 },
3179 msgs := {
3180 sms := sms_mt
3181 }
3182}
3183
Philipp Maier9b690e42018-12-21 11:50:03 +01003184template PDU_ML3_NW_MS tr_ML3_MT_MM_Info := {
3185 discriminator := '0101'B,
3186 tiOrSkip := {
3187 skipIndicator := '0000'B
3188 },
3189 msgs := {
3190 mm := {
3191 mMInformation := {
3192 messageType := '110010'B,
3193 nsd := '00'B,
3194 fullNetworkName := *,
3195 shortNetworkName := *,
3196 localtimeZone := *,
3197 univTime := *,
3198 lSAIdentity := *,
3199 networkDST := *
3200 }
3201 }
3202 }
3203}
Harald Weltef45efeb2018-04-09 18:19:24 +02003204
3205
3206
Harald Weltec76f29f2017-11-22 12:46:46 +01003207}