blob: 7e537096bd892f9ff0fe9c2375bd27fdb9326b6b [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};
125
126
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200127/* send template for Mobile Identity (TMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100128template MobileIdentityLV ts_MI_TMSI_LV(OCT4 tmsi) := {
129 lengthIndicator := 0, /* overwritten */
130 mobileIdentityV := {
131 typeOfIdentity := '000'B, /* overwritten */
132 oddEvenInd_identity := {
133 tmsi_ptmsi := {
134 oddevenIndicator := '0'B,
135 fillerDigit := '1111'B,
136 octets := tmsi
137 }
138 }
139 }
140}
141
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200142/* send template for Mobile Identity (TMSI) */
Harald Welte6abb9fe2018-02-17 15:24:48 +0100143function ts_MI_TMSI_TLV(template (omit) OCT4 tmsi) return template (omit) MobileIdentityTLV {
144 var template (omit) MobileIdentityTLV ret;
145 if (istemplatekind(tmsi, "omit")) {
146 return omit;
147 } else {
148 ret := {
149 elementIdentifier := '0100011'B,
150 spare1 := '0'B,
151 mobileIdentityLV := ts_MI_TMSI_LV(valueof(tmsi))
152 }
153 return ret;
154 }
Harald Welte38575a72018-02-15 20:41:37 +0100155}
156
Harald Welteb0386df2018-02-16 18:14:28 +0100157template MobileIdentityTLV ts_MI_IMEISV_TLV(hexstring imeisv) := {
158 elementIdentifier := '0100011'B,
159 spare1 := '0'B,
160 mobileIdentityLV := ts_MI_IMEISV_LV(imeisv)
161}
162
Harald Weltec76f29f2017-11-22 12:46:46 +0100163private function f_enc_IMSI_L3(hexstring digits) return IMSI_L3 {
164 var IMSI_L3 l3;
165 var integer len := lengthof(digits);
166 if (len rem 2 == 1) { /* modulo remainder */
Harald Welte365f4ed2017-11-23 00:00:43 +0100167 l3.oddevenIndicator := '1'B;
Harald Welteae136252018-01-24 20:53:21 +0100168 l3.fillerDigit := omit;
Harald Weltec76f29f2017-11-22 12:46:46 +0100169 } else {
Harald Welte365f4ed2017-11-23 00:00:43 +0100170 l3.oddevenIndicator := '0'B;
Harald Welteae136252018-01-24 20:53:21 +0100171 l3.fillerDigit := '1111'B;
Harald Weltec76f29f2017-11-22 12:46:46 +0100172 }
173 l3.digits := digits;
174 return l3;
175}
176
Harald Welteba7b6d92018-01-23 21:32:34 +0100177private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {
178 var IMEI_L3 l3;
179 var integer len := lengthof(digits);
180 if (len rem 2 == 1) { /* modulo remainder */
181 l3.oddevenIndicator := '1'B;
182 } else {
183 l3.oddevenIndicator := '0'B;
184 }
185 l3.digits := digits;
186 return l3;
187}
188
Harald Welteb0386df2018-02-16 18:14:28 +0100189private function f_enc_IMEI_SV(hexstring digits) return IMEI_SV {
190 var IMEI_SV l3;
191 var integer len := lengthof(digits);
192 if (len rem 2 == 1) { /* modulo remainder */
193 l3.oddevenIndicator := '1'B;
194 } else {
195 l3.oddevenIndicator := '0'B;
196 }
197 l3.digits := digits;
198 l3.fillerDigit := '1111'B;
199 return l3;
200}
201
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200202/* send template for Mobile Identity (IMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100203template (value) MobileIdentityLV ts_MI_IMSI_LV(hexstring imsi_digits) := {
204 lengthIndicator := 0, /* overwritten */
205 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100206 typeOfIdentity := '001'B,
Harald Weltec76f29f2017-11-22 12:46:46 +0100207 oddEvenInd_identity := {
208 imsi := f_enc_IMSI_L3(imsi_digits)
209 }
210 }
211}
212
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200213/* send template for Mobile Identity (IMEI) */
Harald Welteba7b6d92018-01-23 21:32:34 +0100214template (value) MobileIdentityLV ts_MI_IMEI_LV(hexstring imei_digits) := {
215 lengthIndicator := 0, /* overwritten */
216 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100217 typeOfIdentity := '010'B,
Harald Welteba7b6d92018-01-23 21:32:34 +0100218 oddEvenInd_identity := {
219 imei := f_enc_IMEI_L3(imei_digits)
220 }
221 }
222}
223
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200224/* send template for Mobile Identity (IMEISV) */
Harald Welteb0386df2018-02-16 18:14:28 +0100225template (value) MobileIdentityLV ts_MI_IMEISV_LV(hexstring imei_digits) := {
226 lengthIndicator := 0, /* overwritten */
227 mobileIdentityV := {
228 typeOfIdentity := '011'B,
229 oddEvenInd_identity := {
230 imei_sv := f_enc_IMEI_SV(imei_digits)
231 }
232 }
233}
234
Harald Welteba7b6d92018-01-23 21:32:34 +0100235
Harald Weltec76f29f2017-11-22 12:46:46 +0100236/* Send template for Classmark 2 */
237template (value) MobileStationClassmark2_LV ts_CM2 := {
238 lengthIndicator := 0,
239 rf_PowerCapability := '000'B,
240 a5_1 := '0'B,
241 esind := '1'B,
242 revisionLevel := '10'B,
243 spare1_1 := '0'B,
Harald Welte898113b2018-01-31 18:32:21 +0100244 mobileStationClassmark2_oct4 := {
245 fc := '1'B,
246 vgcs := '0'B,
247 vbs := '0'B,
248 sm_Capability := '1'B,
249 ss_ScreenIndicator := '01'B,
250 ps_Capability := '1'B,
251 spare2_1 := '0'B
252 },
253 mobileStationClassmark2_oct5 := {
254 a5_2 := '0'B,
255 a5_3 := '1'B,
256 cmsp := '0'B,
257 solsa := '0'B,
258 ucs2 := '0'B,
259 lcsva_cap := '0'B,
260 spare5_7 :='0'B,
261 cm3 := '0'B
262 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100263};
264
265/* Send template for CM SERVICE REQUEST */
Harald Welte6ed6bf92018-01-24 21:09:15 +0100266template (value) PDU_ML3_MS_NW ts_CM_SERV_REQ(CmServiceType serv_type, MobileIdentityLV mi_lv) := {
Harald Weltec76f29f2017-11-22 12:46:46 +0100267 discriminator := '0000'B, /* overwritten */
268 tiOrSkip := {
269 skipIndicator := '0000'B
270 },
271 msgs := {
272 mm := {
273 cMServiceRequest := {
274 messageType := '000000'B, /* overwritten */
275 nsd := '00'B,
Harald Welte6ed6bf92018-01-24 21:09:15 +0100276 cm_ServiceType := int2bit(enum2int(serv_type), 4),
Harald Weltec76f29f2017-11-22 12:46:46 +0100277 cipheringKeySequenceNumber := { '000'B, '0'B },
278 mobileStationClassmark2 := ts_CM2,
279 mobileIdentity := mi_lv,
280 priorityLevel := omit,
281 additionalUpdateParameterTV := omit,
282 deviceProperties := omit
283 }
284 }
285 }
286}
287
Harald Welte0195ab12018-01-24 21:50:20 +0100288template (value) CipheringKeySequenceNumberV ts_CKSN(integer key_seq) := {
289 keySequence := int2bit(key_seq, 3),
290 spare := '0'B
291}
292
293/* Send template for CM RE-ESTABLISH REQUEST */
294template (value) PDU_ML3_MS_NW ts_CM_REEST_REQ(integer cksn, MobileIdentityLV mi_lv) := {
295 discriminator := '0000'B, /* overwritten */
296 tiOrSkip := {
297 skipIndicator := '0000'B
298 },
299 msgs := {
300 mm := {
301 cMReEstablReq := {
302 messageType := '101000'B, /* overwritten */
303 nsd := '00'B,
304 cipheringKeySequenceNumber := ts_CKSN(cksn),
305 spare := '0000'B,
306 mobileStationClassmark2 := ts_CM2,
307 mobileIdentityLV := mi_lv,
308 locationAreaIdentification := omit,
309 deviceProperties := omit
310 }
311 }
312 }
313}
314
315
Harald Welte6ff81902018-01-21 19:09:08 +0100316template PDU_ML3_NW_MS tr_MT_simple(template BIT4 discr := ?) := {
317 discriminator := discr,
318 tiOrSkip := {
319 skipIndicator := '0000'B
320 },
321 msgs := ?
322}
323
324
325template PDU_ML3_NW_MS tr_CM_SERV_ACC := {
326 discriminator := '0101'B,
327 tiOrSkip := {
328 skipIndicator := '0000'B
329 },
330 msgs := {
331 mm := {
332 cMServiceAccept := {
333 messageType := '100001'B,
334 nsd := ?
335 }
336 }
337 }
338}
339
340
Harald Weltecb6cc332018-01-21 13:59:08 +0100341template PDU_ML3_NW_MS tr_CM_SERV_REJ(template OCT1 rej_cause := ?) := {
342 discriminator := '0101'B,
343 tiOrSkip := {
344 skipIndicator := '0000'B
345 },
346 msgs := {
347 mm := {
348 cMServiceReject := {
349 messageType := '100010'B,
350 nsd := ?,
351 rejectCause := rej_cause,
352 t3246_Value := *
353 }
354 }
355 }
356}
357
Harald Welte68e495b2018-02-25 00:05:57 +0100358template PDU_ML3_NW_MS tr_PAGING_REQ1(template MobileIdentityLV mi1 := ?,
359 template MobileIdentityTLV mi2 := *) := {
360 discriminator := '0110'B,
361 tiOrSkip := {
362 skipIndicator := '0000'B
363 },
364 msgs := {
365 rrm := {
366 pagingReq_Type1 := {
367 messageType := '00100001'B,
368 pageMode := ?,
369 channelNeeded := ?,
370 mobileIdentity1 := mi1,
371 mobileIdentity2 := mi2,
372 p1RestOctets := ?
373 }
374 }
375 }
376}
377
Stefan Sperling4c32b952018-05-29 20:51:04 +0200378/* Template for receiving a Paging Request Type1 message with a given TMSI in the first mobile identity. */
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +0700379template MobileIdentityLV tr_PAGING_REQ1_MI1_TMSI(octetstring tmsi) := {
Stefan Sperling4c32b952018-05-29 20:51:04 +0200380 lengthIndicator := 5,
381 mobileIdentityV := {
382 typeOfIdentity := '100'B,
383 oddEvenInd_identity := {
384 tmsi_ptmsi := {
385 oddevenIndicator := '0'B,
386 fillerDigit := '1111'B,
387 octets := tmsi
388 }
389 }
390 }
391
392}
393
Harald Welte68e495b2018-02-25 00:05:57 +0100394template PDU_ML3_NW_MS tr_PAGING_REQ2(template TMSIP_TMSI_V mi1 := ?,
395 template TMSIP_TMSI_V mi2 := ?,
396 template MobileIdentityTLV mi3 := *) := {
397 discriminator := '0110'B,
398 tiOrSkip := {
399 skipIndicator := '0000'B
400 },
401 msgs := {
402 rrm := {
403 pagingReq_Type2 := {
404 messageType := '00100010'B,
405 pageMode := ?,
406 channelNeeded := ?,
407 mobileIdentity1 := mi1,
408 mobileIdentity2 := mi2,
409 mobileIdentity3 := mi3,
410 p2RestOctets := ?
411 }
412 }
413 }
414}
415
416template PDU_ML3_NW_MS tr_PAGING_REQ3(template TMSIP_TMSI_V mi1 := ?,
417 template TMSIP_TMSI_V mi2 := ?,
418 template TMSIP_TMSI_V mi3 := ?,
419 template TMSIP_TMSI_V mi4 := ?) := {
420 discriminator := '0110'B,
421 tiOrSkip := {
422 skipIndicator := '0000'B
423 },
424 msgs := {
425 rrm := {
426 pagingReq_Type3 := {
427 messageType := '00100100'B,
428 pageMode := ?,
429 channelNeeded := ?,
430 mobileIdentity1 := mi1,
431 mobileIdentity2 := mi2,
432 mobileIdentity3 := mi3,
433 mobileIdentity4 := mi4,
434 p3RestOctets := ?
435 }
436 }
437 }
438}
439
440
441
Harald Weltec76f29f2017-11-22 12:46:46 +0100442/* Send template for PAGING RESPONSE */
443template (value) PDU_ML3_MS_NW ts_PAG_RESP(MobileIdentityLV mi_lv) := {
444 discriminator := '0000'B, /* overwritten */
445 tiOrSkip := {
446 skipIndicator := '0000'B
447 },
448 msgs := {
449 rrm := {
450 pagingResponse := {
451 messageType := '00000000'B, /* overwritten */
452 cipheringKeySequenceNumber := { '000'B, '0'B },
453 spare1_4 := '0000'B,
454 mobileStationClassmark := ts_CM2,
455 mobileIdentity := mi_lv,
456 additionalUpdateParameters := omit
457 }
458 }
459 }
460}
461
Harald Welte15166142017-12-16 23:02:08 +0100462template (value) PDU_ML3_MS_NW ts_RRM_ModeModifyAck(ChannelDescription2_V desc, ChannelMode_V mode) := {
463 discriminator := '0000'B, /* overwritten */
464 tiOrSkip := {
465 skipIndicator := '0000'B
466 },
467 msgs := {
468 rrm := {
469 channelModeModifyAck := {
470 messageType := '00010111'B,
471 channelDescription := desc,
472 channelMode := mode,
473 extendedTSCSet := omit
474 }
475 }
476 }
477}
478
Harald Weltee613f962018-04-18 22:38:16 +0200479template (value) PDU_ML3_NW_MS ts_RRM_CiphModeCmd(BIT3 alg_id) := {
480 discriminator := '0000'B, /* overwritten */
481 tiOrSkip := {
482 skipIndicator := '0000'B
483 },
484 msgs := {
485 rrm := {
486 cipheringModeCommand := {
487 messageType := '00110101'B,
488 cipherModeSetting := {
489 sC := '1'B,
490 algorithmIdentifier := alg_id
491 },
492 cipherModeResponse := {
493 cR := '0'B,
494 spare := '000'B
495 }
496 }
497 }
498 }
499}
500
Harald Welte73cd2712017-12-17 00:44:52 +0100501template (value) PDU_ML3_MS_NW ts_RRM_CiphModeCompl := {
502 discriminator := '0000'B, /* overwritten */
503 tiOrSkip := {
504 skipIndicator := '0000'B
505 },
506 msgs := {
507 rrm := {
508 cipheringModeComplete := {
509 messageType := '00110010'B,
510 mobileEquipmentIdentity := omit
511 }
512 }
513 }
514}
515
Harald Welteecb254b2018-01-29 22:01:54 +0100516template (value) PDU_ML3_MS_NW ts_RRM_AssignmentComplete(OCT1 cause) := {
517 discriminator := '0000'B, /* overwritten */
518 tiOrSkip := {
519 skipIndicator := '0000'B
520 },
521 msgs := {
522 rrm := {
523 assignmentComplete := {
524 messageType := '00101001'B,
525 rR_Cause := {
526 valuePart := cause
527 }
528 }
529 }
530 }
531}
Harald Welte15166142017-12-16 23:02:08 +0100532
Harald Welte898113b2018-01-31 18:32:21 +0100533template (value) PDU_ML3_MS_NW ts_RRM_AssignmentFailure(OCT1 cause) := {
534 discriminator := '0000'B, /* overwritten */
535 tiOrSkip := {
536 skipIndicator := '0000'B
537 },
538 msgs := {
539 rrm := {
540 assignmentFailure := {
541 messageType := '00101111'B,
542 rR_Cause := {
543 valuePart := cause
544 }
545 }
546 }
547 }
548}
549
Harald Weltefbf9b5e2018-01-31 20:41:23 +0100550template (value) PDU_ML3_MS_NW ts_RRM_HandoverFailure(OCT1 cause) := {
551 discriminator := '0000'B, /* overwritten */
552 tiOrSkip := {
553 skipIndicator := '0000'B
554 },
555 msgs := {
556 rrm := {
557 handoverFailure := {
558 messageType := '00101000'B,
559 rRCause := {
560 valuePart := cause
561 },
562 pSCause := omit
563 }
564 }
565 }
566}
Harald Welte898113b2018-01-31 18:32:21 +0100567
Harald Welte261af4b2018-02-12 21:20:39 +0100568template (value) PDU_ML3_MS_NW ts_RRM_HandoverComplete(OCT1 cause) := {
569 discriminator := '0000'B, /* overwritten */
570 tiOrSkip := {
571 skipIndicator := '0000'B
572 },
573 msgs := {
574 rrm := {
575 handoverComplete := {
576 messageType := '00101100'B,
577 rRCause := {
578 valuePart := cause
579 },
580 mobileObsservedTimeDiff := omit,
581 mobileTimeDifferenceHyperframe := omit
582 }
583 }
584 }
585}
586
Harald Welte187f7a92019-09-05 11:15:20 +0200587template (present) PDU_ML3_NW_MS tr_RR_APP_INFO(template (present) BIT4 apdu_id,
588 template (present) octetstring data,
589 template (present) APDU_Flags_V flags := ?) := {
590 discriminator := '0000'B, /* overwritten */
591 tiOrSkip := {
592 skipIndicator := '0000'B
593 },
594 msgs := {
595 rrm := {
596 applicationInformation := {
597 messageType := '00111000'B,
598 aPDU_ID := apdu_id,
599 aPDU_Flags := flags,
600 aPDU_Data := {
601 lengthIndicator := ?,
602 aPDU_DataValue := data
603 }
604 }
605 }
606 }
607}
608
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100609template (value) PDU_ML3_NW_MS ts_RR_HandoverCommand := {
610 discriminator := '0110'B,
611 tiOrSkip := {
612 skipIndicator := '0000'B
613 },
614 msgs := {
615 rrm := {
616 handoverCommand := {
617 messageType := '00101011'B,
618 cellDescription := {
619 bcc := '001'B,
620 ncc := '010'B,
621 BCCHArfcn_HighPart := '11'B,
622 BCCHArfcn_LowPart := '04'O
623 },
624 channelDescription2 := {
625 timeslotNumber := '110'B,
626 channelTypeandTDMAOffset := '00001'B,
627 octet3 := '00'O,
628 octet4 := '09'O
629 },
630 handoverReference := {
631 handoverReferenceValue := '00'O
632 },
633 powerCommandAndAccesstype := {
634 powerlevel := '00000'B,
635 fPC_EP := '0'B,
636 ePC_Mode := '0'B,
637 aTC := '0'B
638 },
639 synchronizationIndication := omit,
640 frequencyShortListAfterTime := omit,
641 frequencyListAfterTime := omit,
642 cellChannelDescription := omit,
643 multislotAllocation := omit,
644 modeOfChannelSet1 := omit,
645 modeOfChannelSet2 := omit,
646 modeOfChannelSet3 := omit,
647 modeOfChannelSet4 := omit,
648 modeOfChannelSet5 := omit,
649 modeOfChannelSet6 := omit,
650 modeOfChannelSet7 := omit,
651 modeOfChannelSet8 := omit,
652 descrOf2ndCh_at := omit,
653 modeOf2ndChannel := omit,
654 frequencyChannelSequence_at := omit,
655 mobileAllocation_at := omit,
656 startingTime := omit,
657 timeDifference := omit,
658 timingAdvance := omit,
659 frequencyShortListBeforeTime := omit,
660 frequencyListBeforeTime := omit,
661 descrOf1stCh_bt := omit,
662 descrOf2ndCh_bt := omit,
663 frequencyChannelSequence_bt := omit,
664 mobileAllocation_bt := omit,
665 cipherModeSetting := omit,
666 vGCS_TargetModeIndication := omit,
667 multiRateConfiguration := omit,
668 dynamicARFCN_Mapping := omit,
669 vGCS_Ciphering_Parameters := omit,
670 dedicatedServiceInformation := omit,
671 pLMNIndex := omit,
672 extendedTSCSet_afterTime := omit,
673 extendedTSCSet_beforeTime := omit
674 }
675 }
676 }
677}
678
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200679template PDU_ML3_NW_MS tr_RR_HandoverCommand := {
680 discriminator := '0110'B,
681 tiOrSkip := {
682 skipIndicator := '0000'B
683 },
684 msgs := {
685 rrm := {
686 handoverCommand := {
687 messageType := '00101011'B,
688 cellDescription := ?,
689 channelDescription2 := ?,
690 handoverReference := ?,
691 powerCommandAndAccesstype := ?,
692 synchronizationIndication := *,
693 frequencyShortListAfterTime := *,
694 frequencyListAfterTime := *,
695 cellChannelDescription := *,
696 multislotAllocation := *,
697 modeOfChannelSet1 := *,
698 modeOfChannelSet2 := *,
699 modeOfChannelSet3 := *,
700 modeOfChannelSet4 := *,
701 modeOfChannelSet5 := *,
702 modeOfChannelSet6 := *,
703 modeOfChannelSet7 := *,
704 modeOfChannelSet8 := *,
705 descrOf2ndCh_at := *,
706 modeOf2ndChannel := *,
707 frequencyChannelSequence_at := *,
708 mobileAllocation_at := *,
709 startingTime := *,
710 timeDifference := *,
711 timingAdvance := *,
712 frequencyShortListBeforeTime := *,
713 frequencyListBeforeTime := *,
714 descrOf1stCh_bt := *,
715 descrOf2ndCh_bt := *,
716 frequencyChannelSequence_bt := *,
717 mobileAllocation_bt := *,
718 cipherModeSetting := *,
719 vGCS_TargetModeIndication := *,
720 multiRateConfiguration := *,
721 dynamicARFCN_Mapping := *,
722 vGCS_Ciphering_Parameters := *,
723 dedicatedServiceInformation := *,
724 pLMNIndex := *,
725 extendedTSCSet_afterTime := *,
726 extendedTSCSet_beforeTime := *
727 }
728 }
729 }
730}
731
Harald Welte898113b2018-01-31 18:32:21 +0100732function ts_CM3_TLV(template (omit) OCTN cm3) return template MobileStationClassmark3_TLV {
733 if (not isvalue(cm3)) {
734 return omit;
735 }
736 var template MobileStationClassmark3_TLV ret := {
737 elementIdentifier := '20'O,
738 lengthIndicator := 0, /* overwritten */
739 valuePart := cm3
740 }
741 return ret;
742}
743
744template (value) PDU_ML3_MS_NW ts_RRM_CM_CHG(MobileStationClassmark2_LV cm2,
745 template (omit) MobileStationClassmark3_TLV cm3 := omit) := {
746 discriminator := '0110'B,
747 tiOrSkip := {
748 skipIndicator := '0000'B
749 },
750 msgs := {
751 rrm := {
752 classmarkChange := {
753 messageType := '00010110'B,
754 mobileStationClassmark2 := cm2,
755 mobileStationClassmark3 := cm3
756 }
757 }
758 }
759}
760
Neels Hofmeyr92b12b72018-09-18 14:30:23 +0200761template PDU_ML3_NW_MS tr_RRM_CM_ENQUIRY := {
762 discriminator := '0110'B,
763 tiOrSkip := {
764 skipIndicator := '0000'B
765 },
766 msgs := {
767 rrm := {
768 classmarkEnquiry := {
769 messageType := '00010011'B,
770 classmarkEnquiryMask := *
771 }
772 }
773 }
774}
775
Harald Weltee3bd6582018-01-31 22:51:25 +0100776template (value) PDU_ML3_MS_NW ts_RRM_UL_REL(OCT1 cause) := {
777 discriminator := '0110'B,
778 tiOrSkip := {
779 skipIndicator := '0000'B
780 },
781 msgs := {
782 rrm := {
783 uplinkRelease := {
784 messageType := '00001110'B,
785 rR_Cause := {
786 valuePart := cause
787 }
788 }
789 }
790 }
791}
792
793template PDU_ML3_MS_NW tr_RRM_RR_STATUS(template OCT1 cause := ?) := {
794 discriminator := '0110'B,
795 tiOrSkip := {
796 skipIndicator := '0000'B
797 },
798 msgs := {
799 rrm := {
800 rR_Status := {
801 messageType := '00010010'B,
802 rR_Cause := {
803 valuePart := cause
804 }
805 }
806 }
807 }
808}
809
Harald Welte924b6ea2019-02-04 01:05:34 +0100810template PDU_ML3_NW_MS tr_RRM_RR_RELEASE(template OCT1 cause := ?) := {
811 discriminator := '0110'B,
812 tiOrSkip := {
813 skipIndicator := '0000'B
814 },
815 msgs := {
816 rrm := {
817 channelRelease := {
818 messageType := '00001101'B,
819 rRCause := {
820 valuePart := cause
821 },
822 bARange := *,
823 groupChannelDescription := *,
824 groupCipherKeyNumber := *,
825 gPRSResumption := *,
826 bAListPref := *,
827 uTRANFrequencyList := *,
828 cellChannelDescr := *,
829 cellSelectionIndicator := *,
830 enhanced_DTM_CS_Release_Indication := *,
831 vGCS_Ciphering_Parameters := *,
832 group_Channel_Description_2 := *,
833 talkerIdentity := *,
834 talkerPriorityStatus := *,
835 vGCS_AMR_Configuration := *,
836 individual_Priorities := *
837 }
838 }
839 }
840}
Harald Weltee3bd6582018-01-31 22:51:25 +0100841
Harald Welte99787102019-02-04 10:41:36 +0100842template PDU_ML3_NW_MS tr_RRM_RR_RELEASE_CSFB(template OCT1 cause := ?) modifies tr_RRM_RR_RELEASE := {
843 msgs := {
844 rrm := {
845 channelRelease := {
846 cellSelectionIndicator := {
847 elementIdentifier := '77'O,
848 lengthIndicator := ?,
849 cellSelectionIndicatorValue := ?
850 }
851 }
852 }
853 }
854}
Harald Weltee3bd6582018-01-31 22:51:25 +0100855
Harald Weltecb6cc332018-01-21 13:59:08 +0100856template PDU_ML3_MS_NW ts_ML3_MO := {
857 discriminator := '0000'B,
858 tiOrSkip := {
859 skipIndicator := '0000'B
860 },
861 msgs := ?
862}
863
864template LocationUpdatingType ts_ML3_IE_LuType := {
865 lut := ?,
866 spare1_1 := '0'B,
867 fop := '0'B
868}
869
870template LocationUpdatingType ts_ML3_IE_LuType_Normal modifies ts_ML3_IE_LuType := {
871 lut := '00'B
872}
873
874template LocationUpdatingType ts_ML3_IE_LuType_Periodic modifies ts_ML3_IE_LuType := {
875 lut := '01'B
876}
877
878template LocationUpdatingType ts_ML3_IE_LuType_Attach modifies ts_ML3_IE_LuType := {
879 lut := '10'B
880}
881
882template CipheringKeySequenceNumberV ts_ML3_IE_CKSN(integer cksn) := {
883 keySequence := int2bit(cksn, 3),
884 spare := '0'B
885}
886
887template PDU_ML3_MS_NW ts_ML3_MO_LU_Req(LocationUpdatingType lu_type, LocationAreaIdentification_V lai,
888 MobileIdentityLV mi, MobileStationClassmark1_V cm1)
889modifies ts_ML3_MO := {
890 msgs := {
891 mm := {
892 locationUpdateRequest := {
893 messageType := '001000'B,
894 nsd := '00'B, /* ? */
895 locationUpdatingType := lu_type,
896 cipheringKeySequenceNumber := ts_ML3_IE_CKSN(0),
897 locationAreaIdentification := lai,
898 mobileStationClassmark1 := cm1,
899 mobileIdentityLV := mi,
900 classmarkInformationType2_forUMTS := omit,
901 additionalUpdateParameterTV := omit,
902 deviceProperties := omit,
903 mS_NetworkFeatureSupport := omit
904 }
905 }
906 }
907}
908
Harald Welte6ff81902018-01-21 19:09:08 +0100909template PDU_ML3_MS_NW ts_ML3_MO_TmsiRealloc_Cmpl modifies ts_ML3_MO := {
910 msgs := {
911 mm := {
912 tmsiReallocComplete := {
913 messageType := '011011'B,
914 nsd := '00'B
915 }
916 }
917 }
918}
919
920template PDU_ML3_NW_MS tr_ML3_MT_LU_Acc := {
921 discriminator := '0101'B,
922 tiOrSkip := {
923 skipIndicator := '0000'B
924 },
925 msgs := {
926 mm := {
927 locationUpdateAccept := {
928 messageType := '000010'B,
929 nsd := '00'B,
930 locationAreaIdentification := ?,
931 mobileIdentityTLV := *,
932 followOnProceed := *,
933 cTS_Permission := *,
934 equivalentPLMNs := *,
935 emergencyNumberList := *,
936 perMS_T3212 := *
937 }
938 }
939 }
940}
941
942template PDU_ML3_NW_MS tr_ML3_MT_LU_Rej(template OCT1 cause := ?) := {
943 discriminator := '0101'B,
944 tiOrSkip := {
945 skipIndicator := '0000'B
946 },
947 msgs := {
948 mm := {
949 locationUpdateReject := {
950 messageType := '000100'B,
951 nsd := '00'B,
952 rejectCause := cause,
953 t3246_Value := *
954 }
955 }
956 }
957}
958
Oliver Smithaf2f1f82019-07-19 12:33:12 +0200959private function f_id_type_or_any(template CmIdentityType id_type) return template bitstring {
960 if (istemplatekind(id_type, "?")) {
961 return ?;
962 } else {
963 return int2bit(enum2int(valueof(id_type)), 3);
964 }
965}
966
Oliver Smith32898452019-07-09 12:32:35 +0200967template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
Harald Welteba7b6d92018-01-23 21:32:34 +0100968 discriminator := '0101'B,
969 tiOrSkip := {
970 skipIndicator := '0000'B
971 },
972 msgs := {
973 mm := {
974 identityRequest := {
975 messageType := '011000'B,
976 nsd := '00'B,
Oliver Smithaf2f1f82019-07-19 12:33:12 +0200977 identityType := f_id_type_or_any(id_type),
Harald Welteba7b6d92018-01-23 21:32:34 +0100978 spare1_5 := ?
979 }
980 }
981 }
982}
983
984template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp(MobileIdentityLV mi) modifies ts_ML3_MO := {
985 msgs := {
986 mm := {
987 identityResponse := {
988 messageType := '011001'B,
989 nsd := '00'B,
990 mobileIdentityLV := mi,
991 p_TMSI_TypeTV := omit,
992 routingAreaIdentification2TLV := omit,
993 p_TMSISignature2TLV := omit
994 }
995 }
996 }
997}
998template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMSI(hexstring imsi) :=
999 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMSI_LV(imsi)));
1000template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMEI(hexstring imei) :=
1001 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMEI_LV(imei)));
1002
1003
Neels Hofmeyr63382472018-03-01 19:57:44 +01001004template (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 +01001005 rf_PowerCapability := '010'B,
1006 a5_1 := a5_1_unavail,
Neels Hofmeyr63382472018-03-01 19:57:44 +01001007 esind := esind,
Harald Welte45164da2018-01-24 12:51:27 +01001008 revisionLevel := rev,
1009 spare1_1 := '0'B
1010}
1011
1012template PDU_ML3_MS_NW ts_ML3_MO_MM_IMSI_DET_Ind(MobileIdentityLV mi,
1013 template MobileStationClassmark1_V cm1 := ts_CM1)
1014modifies ts_ML3_MO := {
1015 msgs := {
1016 mm := {
1017 imsiDetachIndication := {
1018 messageType := '000001'B,
1019 nsd := '00'B,
1020 mobileStationClassmark1 := cm1,
1021 mobileIdentityLV := mi
1022 }
1023 }
1024 }
1025}
1026
Harald Welted748a052018-01-22 02:59:24 +01001027template PDU_ML3_MS_NW ts_ML3_MO_CC(integer tid) := {
1028 discriminator := '0011'B,
1029 tiOrSkip := {
1030 transactionId := {
Daniel Willmanndcf9eb92018-02-02 20:07:52 +01001031 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001032 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001033 tIExtension := omit
1034 }
1035 }
1036}
1037
1038template (value) CalledPartyBCD_Number ts_Called(hexstring digits) := {
1039 elementIdentifier := '5E'O,
1040 lengthIndicator := 0, /* overwritten */
1041 numberingPlanIdentification := '0000'B,
1042 typeOfNumber := '000'B, /* unknown */
1043 ext1 := '0'B,
1044 digits := digits
1045}
1046
Harald Welte812f7a42018-01-27 00:49:18 +01001047template CalledPartyBCD_Number tr_Called(template hexstring digits) := {
1048 elementIdentifier := '5E'O,
1049 lengthIndicator := ?,
1050 numberingPlanIdentification := ?,
1051 typeOfNumber := ?,
1052 ext1 := ?,
1053 digits := digits
1054}
1055
Stefan Sperling26d57be2018-11-12 17:03:26 +01001056private function f_pad_digits(hexstring digits) return hexstring {
1057 if (lengthof(digits) mod 2 != 0) {
1058 /* Add trailing nibble of 1-bit padding, like the CallingPartyBCD_Number encoder would do.
1059 * Otherwise our template won't match the data received (see OS#2930). */
1060 return digits & 'F'H;
1061 }
1062 return digits;
1063}
1064
Harald Welte812f7a42018-01-27 00:49:18 +01001065template CallingPartyBCD_Number tr_Calling(template hexstring digits) := {
1066 elementIdentifier := '5C'O,
1067 lengthIndicator := ?,
1068 oct3 := ?,
Stefan Sperling26d57be2018-11-12 17:03:26 +01001069 digits := f_pad_digits(valueof(digits))
Harald Welte812f7a42018-01-27 00:49:18 +01001070}
1071
Harald Welte4b2b3a62018-01-26 10:32:39 +01001072type integer SpeechVer;
1073
1074template (value) Speech_AuxiliarySpeech ts_SpeechAux(SpeechVer ver, BIT1 suffix) := {
1075 speechVersionIndication := int2bit(ver-1,3) & suffix,
1076 spare1_1 := '0'B,
1077 cTM_or_Spare := '0'B,
1078 coding := '0'B,
1079 extension_octet_3a_3b := '0'B
1080}
1081
1082template (value) Speech_AuxiliarySpeech ts_SpeechAuxFR(SpeechVer ver) := ts_SpeechAux(ver, '0'B);
1083template (value) Speech_AuxiliarySpeech ts_SpeechAuxHR(SpeechVer ver) := ts_SpeechAux(ver, '1'B);
1084
Harald Welted748a052018-01-22 02:59:24 +01001085template (value) BearerCapability_TLV ts_Bcap_voice := {
1086 elementIdentifier := '04'O,
1087 lengthIndicator := 0, /* overwritten */
1088 octet3 := {
1089 informationTransferCapability := '000'B,
1090 transferMode := '0'B,
1091 codingStandard := '0'B,
1092 radioChannelRequirement := '11'B, /* FR preferred */
1093 extension_octet_3 := '0'B, /* overwritten */
Harald Welte4b2b3a62018-01-26 10:32:39 +01001094 speech_aux_3a_3b := {
1095 valueof(ts_SpeechAuxHR(3)),
1096 valueof(ts_SpeechAuxFR(3)),
1097 valueof(ts_SpeechAuxFR(2)),
1098 valueof(ts_SpeechAuxFR(1)),
1099 valueof(ts_SpeechAuxHR(1))
1100 }
Harald Welted748a052018-01-22 02:59:24 +01001101 },
1102 octet4 := omit,
1103 octet5 := omit,
1104 octet6 := omit,
1105 octet7 := omit
1106}
1107
1108template PDU_ML3_MS_NW ts_ML3_MO_CC_SETUP(integer tid, hexstring called, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1109 discriminator := '0011'B,
1110 tiOrSkip := {
1111 transactionId := {
1112 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001113 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001114 tIExtension := omit
1115 }
1116 },
1117 msgs := {
1118 cc := {
1119 setup_MS_NW := {
1120 messageType := '000101'B,
1121 nsd := '00'B,
1122 bcRepeatIndicator := omit,
1123 bearerCapability1 := bcap,
1124 bearerCapability2 := omit,
1125 facility := omit,
1126 callingPartySubAddress := omit,
1127 calledPartyBCD_Number := ts_Called(called),
1128 calledPartySubAddress := omit,
1129 llc_RepeatIndicator := omit,
1130 lowLayerCompatibility1 := omit,
1131 lowLayerCompatibility2 := omit,
1132 hlc_RepeatIndicator := omit,
1133 highLayerCompatibility1 := omit,
1134 highLayerCompatibility2 := omit,
1135 user_user := omit,
1136 ss_VersionIndicator := omit,
1137 clir_Suppression := omit,
1138 clir_Invocation := omit,
1139 cC_Capabilities := omit,
1140 facility_ccbs1 := omit,
1141 facility_ccbs2 := omit,
1142 streamIdentifier := omit,
1143 supportedCodecs := omit,
1144 redial := omit
1145 }
1146 }
1147 }
1148}
1149
Harald Welte45164da2018-01-24 12:51:27 +01001150template PDU_ML3_MS_NW ts_ML3_MO_CC_EMERG_SETUP(integer tid, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1151 discriminator := '0011'B,
1152 tiOrSkip := {
1153 transactionId := {
1154 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001155 tiFlag := c_TIF_ORIG,
Harald Welte45164da2018-01-24 12:51:27 +01001156 tIExtension := omit
1157 }
1158 },
1159 msgs := {
1160 cc := {
1161 emergencySetup := {
1162 messageType := '001110'B,
1163 nsd := '00'B,
1164 bearerCapability := bcap,
1165 streamIdentifier := omit,
1166 supportedCodecs := omit,
1167 emergencyCategory := omit
1168 }
1169 }
1170 }
1171}
1172
1173
Harald Welted748a052018-01-22 02:59:24 +01001174template PDU_ML3_NW_MS tr_ML3_MT_CC_CALL_PROC(integer tid) := {
1175 discriminator := '0011'B,
1176 tiOrSkip := {
1177 transactionId := {
1178 tio := int2bit(tid, 3),
1179 tiFlag := ?,
1180 tIExtension := omit
1181 }
1182 },
1183 msgs := {
1184 cc := {
1185 callProceeding := {
1186 messageType := '000010'B,
1187 nsd := '00'B,
1188 repeatIndicator := *,
1189 bearerCapability1 := *,
1190 bearerCapability2 := *,
1191 facility := *,
1192 progressIndicator := *,
1193 priorityGranted := *,
1194 networkCCCapabilities := *
1195 }
1196 }
1197 }
1198}
1199
1200template PDU_ML3_NW_MS tr_ML3_MT_CC_ALERTING(integer tid) := {
1201 discriminator := '0011'B,
1202 tiOrSkip := {
1203 transactionId := {
1204 tio := int2bit(tid, 3),
1205 tiFlag := ?,
1206 tIExtension := omit
1207 }
1208 },
1209 msgs := {
1210 cc := {
1211 alerting_NW_MS := {
1212 messageType := '000001'B,
1213 nsd := '00'B,
1214 facility := *,
1215 progressIndicator := *,
1216 user_user := *
1217 }
1218 }
1219 }
1220}
1221
Harald Welte33ec09b2018-02-10 15:34:46 +01001222template PDU_ML3_MS_NW ts_ML3_MO_CC_ALERTING(integer tid) := {
1223 discriminator := '0011'B,
1224 tiOrSkip := {
1225 transactionId := {
1226 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001227 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001228 tIExtension := omit
1229 }
1230 },
1231 msgs := {
1232 cc := {
1233 alerting_MS_NW := {
1234 messageType := '000001'B,
1235 nsd := '00'B,
1236 facility := omit,
1237 user_user := omit,
1238 ss_VersionIndicator := omit
1239 }
1240 }
1241 }
1242}
1243
1244template PDU_ML3_MS_NW ts_ML3_MT_CC_ALERTING(integer tid) := {
1245 discriminator := '0011'B,
1246 tiOrSkip := {
1247 transactionId := {
1248 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001249 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001250 tIExtension := omit
1251 }
1252 },
1253 msgs := {
1254 cc := {
1255 alerting_MS_NW := {
1256 messageType := '000001'B,
1257 nsd := '00'B,
1258 facility := omit,
1259 user_user := omit,
1260 ss_VersionIndicator := omit
1261 }
1262 }
1263 }
1264}
1265
1266template PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT(integer tid) := {
1267 discriminator := '0011'B,
1268 tiOrSkip := {
1269 transactionId := {
1270 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001271 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001272 tIExtension := omit
1273 }
1274 },
1275 msgs := {
1276 cc := {
1277 connect_MS_NW := {
1278 messageType := '000111'B,
1279 nsd := '00'B,
1280 facility := omit,
1281 connectedSubAddress := omit,
1282 user_user := omit,
1283 ss_VersionIndicator := omit,
1284 streamIdentifier := omit
1285 }
1286 }
1287 }
1288}
1289
Harald Welte4017d552018-01-26 21:40:05 +01001290template PDU_ML3_NW_MS tr_ML3_MT_CC_CONNECT(integer tid) := {
1291 discriminator := '0011'B,
1292 tiOrSkip := {
1293 transactionId := {
1294 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001295 tiFlag := c_TIF_REPL,
Harald Welte4017d552018-01-26 21:40:05 +01001296 tIExtension := omit
1297 }
1298 },
1299 msgs := {
1300 cc := {
1301 connect_NW_MS := {
1302 messageType := '000111'B,
1303 nsd := '00'B,
1304 facility := *,
1305 progressIndicator := *,
1306 connectedNumber := *,
1307 connectedSubAddress := *,
1308 user_user := *
1309 }
1310 }
1311 }
1312}
1313
1314template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT_ACK(integer tid) := {
1315 discriminator := '0011'B,
1316 tiOrSkip := {
1317 transactionId := {
1318 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001319 tiFlag := c_TIF_ORIG,
Harald Welte4017d552018-01-26 21:40:05 +01001320 tIExtension := omit
1321 }
1322 },
1323 msgs := {
1324 cc := {
1325 connectAck := {
1326 messageType := '001111'B,
1327 nsd := '00'B
1328 }
1329 }
1330 }
1331}
1332
Daniel Willmann8b084372018-02-04 13:35:26 +01001333template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_START_DTMF(integer tid, charstring number) := {
1334 discriminator := '0011'B,
1335 tiOrSkip := {
1336 transactionId := {
1337 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001338 tiFlag := c_TIF_ORIG,
Daniel Willmann8b084372018-02-04 13:35:26 +01001339 tIExtension := omit
1340 }
1341 },
1342 msgs := {
1343 cc := {
1344 startDTMF := {
1345 messageType := '110101'B,
1346 nsd := '00'B,
1347 keypadFacility := {
1348 elementIdentifier := '2C'O,
1349 keypadInformation := int2bit(char2int(number), 7),
1350 spare_1 := '0'B
1351 }
1352 }
1353 }
1354 }
1355}
1356
Harald Welte2bb825f2018-01-22 11:31:18 +01001357template PDU_ML3_NW_MS tr_ML3_MT_CC_DISC(integer tid) := {
1358 discriminator := '0011'B,
1359 tiOrSkip := {
1360 transactionId := {
1361 tio := int2bit(tid, 3),
1362 tiFlag := ?,
1363 tIExtension := omit
1364 }
1365 },
1366 msgs := {
1367 cc := {
1368 disconnect_NW_MS := {
1369 messageType := '100101'B,
1370 nsd := '00'B,
1371 cause := ?,
1372 facility := *,
1373 progressIndicator := *,
1374 user_user := *,
1375 allowedActions := *
1376 }
1377 }
1378 }
1379}
1380
1381template PDU_ML3_NW_MS tr_ML3_MT_CC_RELEASE(integer tid) := {
1382 discriminator := '0011'B,
1383 tiOrSkip := {
1384 transactionId := {
1385 tio := int2bit(tid, 3),
1386 tiFlag := ?,
1387 tIExtension := omit
1388 }
1389 },
1390 msgs := {
1391 cc := {
1392 release_NW_MS := {
1393 messageType := '101101'B,
1394 nsd := '00'B,
1395 cause := ?,
1396 secondCause := *,
1397 facility := *,
1398 user_user := *
1399 }
1400 }
1401 }
1402}
Harald Welted748a052018-01-22 02:59:24 +01001403
Harald Welte33ec09b2018-02-10 15:34:46 +01001404template PDU_ML3_MS_NW ts_ML3_MO_CC_RELEASE(integer tid, BIT1 tid_remote, BIT7 cause) := {
1405 discriminator := '0011'B,
1406 tiOrSkip := {
1407 transactionId := {
1408 tio := int2bit(tid, 3),
1409 tiFlag := tid_remote,
1410 tIExtension := omit
1411 }
1412 },
1413 msgs := {
1414 cc := {
1415 release_MS_NW := {
1416 messageType := '101101'B,
1417 nsd := '00'B,
1418 cause := ts_ML3_Cause(cause),
1419 secondCause := omit,
1420 facility := omit,
1421 user_user := omit,
1422 ss_VersionIndicator := omit
1423 }
1424 }
1425 }
1426}
1427
1428
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001429template (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 +01001430 discriminator := '0011'B,
1431 tiOrSkip := {
1432 transactionId := {
1433 tio := int2bit(tid, 3),
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001434 tiFlag := tid_remote,
Harald Welteb71901a2018-01-26 19:16:05 +01001435 tIExtension := omit
1436 }
1437 },
1438 msgs := {
1439 cc := {
1440 releaseComplete_MS_NW := {
1441 messageType := '101010'B,
1442 nsd := '00'B,
1443 cause := omit,
1444 facility := omit,
1445 user_user := omit,
1446 ss_VersionIndicator := omit
1447 }
1448 }
1449 }
1450}
1451
Harald Welte33ec09b2018-02-10 15:34:46 +01001452template PDU_ML3_NW_MS tr_ML3_MT_CC_REL_COMPL(integer tid) := {
1453 discriminator := '0011'B,
1454 tiOrSkip := {
1455 transactionId := {
1456 tio := int2bit(tid, 3),
1457 tiFlag := ?,
1458 tIExtension := omit
1459 }
1460 },
1461 msgs := {
1462 cc := {
1463 releaseComplete_NW_MS := {
1464 messageType := '101010'B,
1465 nsd := '00'B,
1466 cause := *,
1467 facility := *,
1468 user_user := *
1469 }
1470 }
1471 }
1472}
1473
1474
Harald Welteb71901a2018-01-26 19:16:05 +01001475
Harald Welte77a8eba2018-01-22 21:22:32 +01001476template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ(template OCT16 rand := ?) := {
1477 discriminator := '0101'B,
1478 tiOrSkip := {
1479 skipIndicator := '0000'B
1480 },
1481 msgs := {
1482 mm := {
1483 authenticationRequest := {
1484 messageType := '010010'B,
1485 nsd := '00'B,
1486 cipheringKeySequenceNumber := ?,
1487 spare2_4 := ?,
1488 authenticationParRAND := rand,
1489 authenticationParAUTN := *
1490 }
1491 }
1492 }
1493}
1494
Harald Welte0cedf2c2018-10-28 23:28:35 +01001495template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ_3G(template OCT16 rand := ?, template OCT16 autn) := {
1496 discriminator := '0101'B,
1497 tiOrSkip := {
1498 skipIndicator := '0000'B
1499 },
1500 msgs := {
1501 mm := {
1502 authenticationRequest := {
1503 messageType := '010010'B,
1504 nsd := '00'B,
1505 cipheringKeySequenceNumber := ?,
1506 spare2_4 := ?,
1507 authenticationParRAND := rand,
1508 authenticationParAUTN := {
1509 elementIdentifier := '20'O,
1510 lengthIndicator := ?,
1511 autnValue := autn
1512 }
1513 }
1514 }
1515 }
1516}
1517
Harald Welte77a8eba2018-01-22 21:22:32 +01001518template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_2G(OCT4 sres) := {
1519 discriminator := '0101'B,
1520 tiOrSkip := {
1521 skipIndicator := '0000'B
1522 },
1523 msgs := {
1524 mm := {
1525 authenticationResponse := {
1526 messageType := '010100'B,
1527 nsd := '00'B,
1528 authenticationParSRES := sres,
1529 authenticationParSRESext := omit
1530 }
1531 }
1532 }
1533}
1534
1535template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_3G(OCT4 sres, octetstring res) := {
1536 discriminator := '0101'B,
1537 tiOrSkip := {
1538 skipIndicator := '0000'B
1539 },
1540 msgs := {
1541 mm := {
1542 authenticationResponse := {
1543 messageType := '010100'B,
1544 nsd := '00'B,
1545 authenticationParSRES := sres,
1546 authenticationParSRESext := {
1547 elementIdentifier := '21'O,
1548 lengthIndicator := 0, /* overwritten */
1549 valueField := res
1550 }
1551 }
1552 }
1553 }
1554}
Harald Weltecb6cc332018-01-21 13:59:08 +01001555
Harald Welte812f7a42018-01-27 00:49:18 +01001556template PDU_ML3_MS_NW ts_ML3_MO_CC_CALL_CONF(integer tid,
1557 template BearerCapability_TLV bcap := omit) := {
1558 discriminator := '0011'B,
1559 tiOrSkip := {
1560 transactionId := {
1561 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001562 tiFlag := c_TIF_REPL, /* response from destination */
Harald Welte812f7a42018-01-27 00:49:18 +01001563 tIExtension := omit
1564 }
1565 },
1566 msgs := {
1567 cc := {
1568 callConfirmed := {
1569 messageType := '001000'B,
1570 nsd := '00'B,
1571 repeatIndicator := omit,
1572 bearerCapability1 := bcap,
1573 bearerCapability2 := omit,
1574 cause := omit,
1575 cC_Capabilities := omit,
1576 streamIdentifier := omit,
1577 supportedCodecs := omit
1578 }
1579 }
1580 }
1581}
1582
1583
1584template PDU_ML3_NW_MS tr_ML3_MT_CC_SETUP(integer tid, template hexstring called := *,
1585 template hexstring calling := *,
1586 template BearerCapability_TLV bcap := *) := {
1587 discriminator := '0011'B,
1588 tiOrSkip := {
1589 transactionId := {
1590 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001591 tiFlag := c_TIF_ORIG, /* from originator */
Harald Welte812f7a42018-01-27 00:49:18 +01001592 tIExtension := omit
1593 }
1594 },
1595 msgs := {
1596 cc := {
1597 setup_NW_MS := {
1598 messageType := '000101'B,
1599 nsd := '00'B,
1600 bcRepeatIndicator := *,
1601 bearerCapability1 := bcap,
1602 bearerCapability2 := *,
1603 facility := *,
1604 progressIndicator := *,
1605 signal := *,
1606 callingPartyBCD_Number := tr_Calling(calling) ifpresent,
1607 callingPartySubAddress := *,
1608 calledPartyBCD_Number := tr_Called(called) ifpresent,
1609 calledPartySubAddress := *,
1610 redirectingPartyBCDNumber := *,
1611 redirectingPartySubaddress := *,
1612 llc_RepeatIndicator := *,
1613 lowLayerCompatibility1 := *,
1614 lowLayerCompatibility2 := *,
1615 hlc_RepeatIndicator := *,
1616 highLayerCompatibility1 := *,
1617 highLayerCompatibility2 := *,
1618 user_user := *,
1619 priority := *,
1620 alert := *,
1621 networkCCCapabilities := *,
1622 causeofNoCli := *,
1623 backupBearerCapacity := *
1624 }
1625 }
1626 }
1627}
1628
Harald Welte38575a72018-02-15 20:41:37 +01001629/***********************************************************************
Harald Welte53603962018-05-28 11:13:09 +02001630 * Supplementary Services
1631 ***********************************************************************/
1632
1633private template (value) Facility_TLV ts_FacTLV(OCTN facility) := {
1634 elementIdentifier := '1C'O,
1635 lengthIndicator := lengthof(facility),
1636 facilityInformation := facility
1637}
1638private template Facility_TLV tr_FacTLV(template OCTN facility) := {
1639 elementIdentifier := '1C'O,
1640 lengthIndicator := ?,
1641 facilityInformation := facility
1642}
1643
1644private template (value) Facility_LV ts_FacLV(OCTN facility) := {
1645 lengthIndicator := lengthof(facility),
1646 facilityInformation := facility
1647}
1648private template Facility_LV tr_FacLV(template OCTN facility) := {
1649 lengthIndicator := ?,
1650 facilityInformation := facility
1651}
1652
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001653private function f_facility_or_omit(template (omit) OCTN facility)
1654return template (omit) Facility_TLV {
1655 if (istemplatekind(facility, "omit")) {
1656 return omit;
1657 } else {
1658 return ts_FacTLV(valueof(facility));
1659 }
1660}
1661private function f_facility_or_wc(template OCTN facility)
1662return template Facility_TLV {
1663 if (istemplatekind(facility, "*")) {
1664 return *;
1665 } else if (istemplatekind(facility, "?")) {
1666 return ?;
Vadim Yanitskiy52f8b6e2018-06-19 17:32:46 +07001667 } else if (istemplatekind(facility, "omit")) {
1668 return omit;
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001669 } else {
1670 return tr_FacTLV(facility);
1671 }
1672}
1673
Harald Welte53603962018-05-28 11:13:09 +02001674template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_REGISTER(
1675 uint3_t tid, BIT1 ti_flag,
1676 OCTN facility,
1677 template (omit) SS_VersionIndicator ss_ver := omit
1678) := {
1679 discriminator := '1011'B,
1680 tiOrSkip := {
1681 transactionId := {
1682 tio := int2bit(tid, 3),
1683 tiFlag := ti_flag,
1684 tIExtension := omit
1685 }
1686 },
1687 msgs := {
1688 ss := {
1689 register := {
1690 messageType := '111011'B,
1691 nsd := '00'B,
1692 facility := ts_FacTLV(facility),
1693 ss_version := ss_ver
1694 }
1695 }
1696 }
1697}
1698template PDU_ML3_MS_NW tr_ML3_MO_SS_REGISTER(
1699 template uint3_t tid, template BIT1 ti_flag,
1700 template OCTN facility,
1701 template SS_VersionIndicator ss_ver := omit
1702) := {
1703 discriminator := '1011'B,
1704 tiOrSkip := {
1705 transactionId := {
1706 tio := f_tid_or_wc(tid),
1707 tiFlag := ti_flag,
1708 tIExtension := omit
1709 }
1710 },
1711 msgs := {
1712 ss := {
1713 register := {
1714 messageType := '111011'B,
1715 nsd := '00'B,
1716 facility := tr_FacTLV(facility),
1717 ss_version := ss_ver
1718 }
1719 }
1720 }
1721}
1722
1723template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_REGISTER(
1724 uint3_t tid, BIT1 ti_flag,
1725 OCTN facility
1726) := {
1727 discriminator := '1011'B,
1728 tiOrSkip := {
1729 transactionId := {
1730 tio := int2bit(tid, 3),
1731 tiFlag := ti_flag,
1732 tIExtension := omit
1733 }
1734 },
1735 msgs := {
1736 ss := {
1737 register := {
1738 messageType := '111011'B,
1739 nsd := '00'B,
1740 facility := ts_FacTLV(facility)
1741 }
1742 }
1743 }
1744}
1745template PDU_ML3_NW_MS tr_ML3_MT_SS_REGISTER(
1746 template uint3_t tid, template BIT1 ti_flag,
1747 template OCTN facility
1748) := {
1749 discriminator := '1011'B,
1750 tiOrSkip := {
1751 transactionId := {
1752 tio := f_tid_or_wc(tid),
1753 tiFlag := ti_flag,
1754 tIExtension := omit
1755 }
1756 },
1757 msgs := {
1758 ss := {
1759 register := {
1760 messageType := '111011'B,
1761 nsd := '00'B,
1762 facility := tr_FacTLV(facility)
1763 }
1764 }
1765 }
1766}
1767
1768template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_FACILITY(
1769 uint3_t tid, BIT1 ti_flag,
1770 OCTN facility
1771) := {
1772 discriminator := '1011'B,
1773 tiOrSkip := {
1774 transactionId := {
1775 tio := int2bit(tid, 3),
1776 tiFlag := ti_flag,
1777 tIExtension := omit
1778 }
1779 },
1780 msgs := {
1781 ss := {
1782 facility := {
1783 messageType := '111010'B,
1784 nsd := '00'B,
1785 facility := ts_FacLV(facility)
1786 }
1787 }
1788 }
1789}
1790template PDU_ML3_MS_NW tr_ML3_MO_SS_FACILITY(
1791 template uint3_t tid, template BIT1 ti_flag,
1792 template OCTN facility
1793) := {
1794 discriminator := '1011'B,
1795 tiOrSkip := {
1796 transactionId := {
1797 tio := f_tid_or_wc(tid),
1798 tiFlag := ti_flag,
1799 tIExtension := omit
1800 }
1801 },
1802 msgs := {
1803 ss := {
1804 facility := {
1805 messageType := '111010'B,
1806 nsd := '00'B,
1807 facility := tr_FacLV(facility)
1808 }
1809 }
1810 }
1811}
1812
1813template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_FACILITY(
1814 uint3_t tid, BIT1 ti_flag,
1815 OCTN facility
1816) := {
1817 discriminator := '1011'B,
1818 tiOrSkip := {
1819 transactionId := {
1820 tio := int2bit(tid, 3),
1821 tiFlag := ti_flag,
1822 tIExtension := omit
1823 }
1824 },
1825 msgs := {
1826 ss := {
1827 facility := {
1828 messageType := '111010'B,
1829 nsd := '00'B,
1830 facility := ts_FacLV(facility)
1831 }
1832 }
1833 }
1834}
1835template PDU_ML3_NW_MS tr_ML3_MT_SS_FACILITY(
1836 template uint3_t tid, template BIT1 ti_flag,
1837 template OCTN facility
1838) := {
1839 discriminator := '1011'B,
1840 tiOrSkip := {
1841 transactionId := {
1842 tio := f_tid_or_wc(tid),
1843 tiFlag := ti_flag,
1844 tIExtension := omit
1845 }
1846 },
1847 msgs := {
1848 ss := {
1849 facility := {
1850 messageType := '111010'B,
1851 nsd := '00'B,
1852 facility := tr_FacLV(facility)
1853 }
1854 }
1855 }
1856}
1857
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001858template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_RELEASE_COMPLETE(
1859 uint3_t tid, BIT1 ti_flag,
1860 template (omit) ML3_Cause_TLV cause := omit,
1861 template (omit) OCTN facility := omit
1862) := {
1863 discriminator := '1011'B,
1864 tiOrSkip := {
1865 transactionId := {
1866 tio := int2bit(tid, 3),
1867 tiFlag := ti_flag,
1868 tIExtension := omit
1869 }
1870 },
1871 msgs := {
1872 ss := {
1873 releaseComplete_MS_NW := {
1874 messageType := '101010'B,
1875 nsd := '00'B,
1876 cause := cause,
1877 facility := f_facility_or_omit(facility)
1878 }
1879 }
1880 }
1881}
1882template PDU_ML3_MS_NW tr_ML3_MO_SS_RELEASE_COMPLETE(
1883 template uint3_t tid, template BIT1 ti_flag,
1884 template ML3_Cause_TLV cause := *,
1885 template OCTN facility := *
1886) := {
1887 discriminator := '1011'B,
1888 tiOrSkip := {
1889 transactionId := {
1890 tio := f_tid_or_wc(tid),
1891 tiFlag := ti_flag,
1892 tIExtension := omit
1893 }
1894 },
1895 msgs := {
1896 ss := {
1897 releaseComplete_MS_NW := {
1898 messageType := '101010'B,
1899 nsd := '00'B,
1900 cause := cause,
1901 facility := f_facility_or_wc(facility)
1902 }
1903 }
1904 }
1905}
1906
1907template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_RELEASE_COMPLETE(
1908 uint3_t tid, BIT1 ti_flag,
1909 template (omit) ML3_Cause_TLV cause := omit,
1910 template (omit) OCTN facility := omit
1911) := {
1912 discriminator := '1011'B,
1913 tiOrSkip := {
1914 transactionId := {
1915 tio := int2bit(tid, 3),
1916 tiFlag := ti_flag,
1917 tIExtension := omit
1918 }
1919 },
1920 msgs := {
1921 ss := {
1922 releaseComplete_NW_MS := {
1923 messageType := '101010'B,
1924 nsd := '00'B,
1925 cause := cause,
1926 facility := f_facility_or_omit(facility)
1927 }
1928 }
1929 }
1930}
1931template PDU_ML3_NW_MS tr_ML3_MT_SS_RELEASE_COMPLETE(
1932 template uint3_t tid, template BIT1 ti_flag,
1933 template ML3_Cause_TLV cause := *,
1934 template OCTN facility := *
1935) := {
1936 discriminator := '1011'B,
1937 tiOrSkip := {
1938 transactionId := {
1939 tio := f_tid_or_wc(tid),
1940 tiFlag := ti_flag,
1941 tIExtension := omit
1942 }
1943 },
1944 msgs := {
1945 ss := {
1946 releaseComplete_NW_MS := {
1947 messageType := '101010'B,
1948 nsd := '00'B,
1949 cause := cause,
1950 facility := f_facility_or_wc(facility)
1951 }
1952 }
1953 }
1954}
1955
Harald Welte53603962018-05-28 11:13:09 +02001956/***********************************************************************
Harald Welte38575a72018-02-15 20:41:37 +01001957 * GPRS Mobility Management
1958 ***********************************************************************/
1959
1960template (value) MSNetworkCapabilityV ts_GMM_MsNetCapV := {
1961 gea1bit := '1'B,
1962 smCapabilitiesviaDedicatedChannels := '1'B,
1963 smCapabilitiesviaGPRSChannels := '0'B,
1964 ucs2Support := '1'B,
1965 ssScreeningIndicator := '01'B,
1966 solSACapability := omit,
1967 revisionLevelIndicatior := omit,
1968 pFCFeatureMode := omit,
1969 extendedGEAbits := omit,
1970 lcsVAcapability := omit,
1971 pSInterRATHOtoUTRANIuModeCapability := omit,
1972 pSInterRATHOtoEUTRANS1ModeCapability := omit,
1973 eMMCombinedProceduresCapability := omit,
1974 iSRSupport := omit,
1975 sRVCCtoGERANUTRANCapability := omit,
1976 ePCCapability := omit,
1977 nFCapability := omit,
1978 gERANNertworkSharingCapability := omit,
1979 spare_octets := omit
1980};
1981
1982template (value) MSNetworkCapabilityLV ts_GMM_MsNetCapLV := {
1983 lengthIndicator := 0, /* overwritten */
1984 msNetworkCapabilityV := ts_GMM_MsNetCapV
1985};
1986
1987type enumerated GprsAttachType {
1988 GPRS_ATT_T_GPRS,
1989 GPRS_ATT_T_GPRS_IMSI_COMBINED
1990};
1991
1992function ts_GMM_AttachType(boolean combined := false, boolean follow_on_pending := false)
1993return AttachTypeV {
1994 var AttachTypeV att;
1995 if (combined) {
1996 att.attachType := '011'B;
1997 } else {
1998 att.attachType := '001'B;
1999 }
2000 att.for_l3 := bool2bit(combined);
2001 return att;
2002}
2003
2004type enumerated GprsUpdateType {
2005 GPRS_UPD_T_RA ('000'B),
2006 GPRS_UPD_T_RA_LA_COMBINED ('001'B),
2007 GPRS_UPD_T_RA_LA_COMBINED_IMSI_ATT ('010'B),
2008 GPRS_UPD_T_PERIODIC ('011'B)
2009};
2010
2011/* 10.5.5.18 Update Type */
2012template UpdateTypeV ts_GMM_UpdateType(GprsUpdateType upd_t, boolean combined := false,
2013 boolean follow_on_pending := false) := {
2014 valueField := int2bit(enum2int(upd_t), 3),
2015 for_l3 := bool2bit(combined)
2016}
2017
2018template (value) DRXParameterV ts_DrxParameterV := {
2019 splitPGCycleCode := '00'O, /* no DRX */
2020 nonDRXTimer := '000'B, /* no non-DRX mode */
2021 splitOnCCCH := '0'B, /* not supported */
2022 cnSpecificDRXCycleLength := '0000'B /* SI value used */
2023};
2024
2025template (value) AccessCapabilitiesStruct ts_AccesssCap := {
2026 lengthIndicator := 0, /* overwritten */
2027 accessCapabilities := {
2028 rfPowerCapability := '001'B, /* FIXME */
2029 presenceBitA5 := '0'B,
2030 a5bits := omit,
2031 esind := '1'B,
2032 psbit := '0'B,
2033 vgcs := '0'B,
2034 vbs := '0'B,
2035 presenceBitMultislot := '0'B,
2036 multislotcap := omit,
2037 accessCapAdditionsAfterRel97 := omit
2038 },
2039 spare_bits := omit
2040}
2041
2042template (value) MSRACapabilityValuesRecord ts_RaCapRec(BIT4 att) := {
2043 mSRACapabilityValues := {
2044 mSRACapabilityValuesExclude1111 := {
2045 accessTechnType := '0001'B, /* E-GSM */
2046 accessCapabilities := ts_AccesssCap
2047 }
2048 },
2049 presenceBitMSRACap := '0'B
2050};
2051
2052template (value) MSRadioAccessCapabilityLV ts_MS_RaCapa := {
2053 lengthIndicator := 0, /* overwritten */
2054 msRadioAccessCapabilityV := {
2055 ts_RaCapRec('0001'B) /* E-GSM */
2056 }
2057}
2058
2059template (value) PDU_L3_MS_SGSN
2060 ts_GMM_ATTACH_REQ(MobileIdentityLV mi_lv, RoutingAreaIdentificationV old_ra,
2061 boolean combined := false, boolean follow_on_pending := false,
2062 template (omit) MobileStationClassmark2_TLV cm2_tlv,
2063 template (omit) MobileStationClassmark3_TLV cm3_tlv
2064 ) := {
2065 discriminator := '0000'B, /* overwritten */
2066 tiOrSkip := {
2067 skipIndicator := '0000'B
2068 },
2069 msgs := {
2070 gprs_mm := {
2071 attachRequest := {
2072 messageType := '00000000'B, /* overwritten */
2073 msNetworkCapability := ts_GMM_MsNetCapLV,
2074 attachType := valueof(ts_GMM_AttachType(combined, follow_on_pending)),
2075 gprsCKSN := { '111'B, '0'B },
2076 drxParam := ts_DrxParameterV,
2077 mobileIdentity := mi_lv,
2078 oldRoutingAreaID := old_ra,
2079 msRACap := ts_MS_RaCapa,
2080 ptmsiSignature := omit, /* TODO */
2081 reqGPRStimer := omit,
2082 tmsiStatus := omit,
2083 pC_LCSCapability := omit,
2084 mobileStationClassmark2 := cm2_tlv,
2085 mobileStationClassmark3 := cm3_tlv,
2086 supportedCodecs := omit,
2087 uENetworkCapability := omit,
2088 additionalMobileIdentity := omit,
2089 routingAreaIdentification2 := omit,
2090 voiceDomainandUEsUsageSetting := omit,
2091 deviceProperties := omit,
2092 p_TMSI_Type := omit,
2093 mS_NetworkFeatureSupport := omit,
2094 oldLocationAreaIdentification := omit,
2095 additionalUpdateType := omit,
2096 tMSIBasedNRIcontainer := omit,
2097 t3324 := omit,
2098 t3312_ExtendedValue := omit,
2099 extendedDRXParameters := omit
2100 }
2101 }
2102 }
2103}
2104
Harald Welteb0386df2018-02-16 18:14:28 +01002105private function tr_MI_TMSI_TLV(template OCT4 tmsi) return template MobileIdentityTLV {
2106 if (istemplatekind(tmsi, "*")) {
2107 return *;
2108 } else if (istemplatekind(tmsi, "?")) {
2109 return ?;
2110 } else {
2111 var template MobileIdentityTLV mi := {
2112 elementIdentifier := '0011000'B,
2113 spare1 := '0'B,
2114 mobileIdentityLV := {
2115 lengthIndicator := 4,
2116 mobileIdentityV := {
2117 typeOfIdentity := '100'B,
2118 oddEvenInd_identity := {
2119 tmsi_ptmsi := {
2120 oddevenIndicator := '1'B,
2121 fillerDigit := '1111'B,
2122 octets := tmsi
2123 }
2124 }
2125 }
2126 }
2127 };
2128 return mi;
2129 }
2130}
2131
2132template PDU_L3_SGSN_MS tr_GMM_ATTACH_ACCEPT(template BIT3 res := ?,
2133 template RoutingAreaIdentificationV ra := ?,
2134 template OCT4 ptmsi := *) := {
2135 discriminator := '1000'B,
2136 tiOrSkip := {
2137 skipIndicator := '0000'B
2138 },
2139 msgs := {
2140 gprs_mm := {
2141 attachAccept := {
2142 messageType := '00000010'B,
2143 attachResult := { res, ? },
2144 forceToStandby := ?,
2145 updateTimer := ?,
2146 radioPriority := ?,
2147 radioPriorityTOM8 := ?,
2148 routingAreaIdentification := ra,
2149 ptmsiSignature := *,
2150 readyTimer := *,
2151 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2152 msIdentity := *,
2153 gmmCause := *,
2154 t3302 := *,
2155 cellNotification := *,
2156 equivalentPLMNs := *,
2157 networkFeatureSupport := *,
2158 emergencyNumberList := *,
2159 requestedMSInformation := *,
2160 t3319 := *,
2161 t3323 := *,
2162 t3312_ExtendedValue := *,
2163 additionalNetworkFeatureSupport := *,
2164 t3324 := *,
2165 extendedDRXParameters := *
2166 }
2167 }
2168 }
2169}
Harald Welte38575a72018-02-15 20:41:37 +01002170
Harald Welte5b7c8122018-02-16 21:48:17 +01002171template PDU_L3_SGSN_MS tr_GMM_ATTACH_REJECT(template OCT1 cause) := {
2172 discriminator := '1000'B,
2173 tiOrSkip := {
2174 skipIndicator := '0000'B
2175 },
2176 msgs := {
2177 gprs_mm := {
2178 attachReject := {
2179 messageType := '00000100'B,
2180 gmmCause := {
2181 causeValue := cause
2182 },
2183 t3302 := *,
2184 t3346 := *
2185 }
2186 }
2187 }
2188}
2189
2190
Harald Welte38575a72018-02-15 20:41:37 +01002191template (value) PDU_L3_MS_SGSN ts_GMM_ATTACH_COMPL := {
2192 discriminator := '0000'B, /* overwritten */
2193 tiOrSkip := {
2194 skipIndicator := '0000'B
2195 },
2196 msgs := {
2197 gprs_mm := {
2198 attachComplete := {
2199 messageType := '00000000'B, /* overwritten */
2200 interRATHandoverInformation := omit,
2201 eUTRANinterRATHandoverInformation := omit
2202 }
2203 }
2204 }
2205}
2206
2207template (value) PDU_L3_MS_SGSN
2208 ts_GMM_RAU_REQ(MobileIdentityLV mi_lv, GprsUpdateType upd_type,
2209 RoutingAreaIdentificationV old_ra,
2210 boolean follow_on_pending := false,
2211 template (omit) MobileStationClassmark2_TLV cm2_tlv,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002212 template (omit) MobileStationClassmark3_TLV cm3_tlv,
2213 template (omit) OCT4 p_tmsi := omit
Harald Welte38575a72018-02-15 20:41:37 +01002214 ) := {
2215 discriminator := '0000'B, /* overwritten */
2216 tiOrSkip := {
2217 skipIndicator := '0000'B
2218 },
2219 msgs := {
2220 gprs_mm := {
2221 routingAreaUpdateRequest := {
2222 messageType := '00000000'B, /* overwritten */
2223 updateType := ts_GMM_UpdateType(upd_type, follow_on_pending),
2224 gprsCKSN := { '111'B, '0'B },
2225 oldRoutingAreaId := old_ra,
2226 msRACap := ts_MS_RaCapa,
2227 oldPTMSISignature := omit, /* TODO */
2228 readyTimerValue := omit,
2229 drxParameter := omit,
2230 tmsiStatus := omit,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002231 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
Harald Welte38575a72018-02-15 20:41:37 +01002232 mSNetworkCapability := omit,
2233 pdpContextStatus := omit, /* TODO */
2234 pC_LCSCapability := omit,
Harald Welte04683d02018-02-16 22:43:45 +01002235 mBMS_ContextStatus := omit,
Harald Welte38575a72018-02-15 20:41:37 +01002236 uENetworkCapability := omit,
2237 additionalMobileIdentity := omit,
2238 oldRoutingAreaIdentification2 := omit,
2239 mobileStationClassmark2 := cm2_tlv,
2240 mobileStationClassmark3 := cm3_tlv,
2241 supportedCodecs := omit,
2242 voiceDomainUEUsageSetting := omit,
2243 p_TMSI_Type := omit,
2244 deviceProperties := omit,
2245 mS_NetworkFeatureSupport := omit,
2246 oldLocationAreaIdentification := omit,
2247 additionalUpdateType := omit,
2248 tMSIBasedNRIcontainer := omit,
2249 t3324 := omit,
2250 t3312_ExtendedValue := omit,
2251 extendedDRXParameters := omit
2252 }
2253 }
2254 }
2255}
2256
Harald Welte04683d02018-02-16 22:43:45 +01002257template PDU_L3_SGSN_MS tr_GMM_RAU_REJECT(template OCT1 cause := ?) := {
2258 discriminator := '1000'B,
2259 tiOrSkip := {
2260 skipIndicator := '0000'B
2261 },
2262 msgs := {
2263 gprs_mm := {
2264 routingAreaUpdateReject := {
2265 messageType := '00001011'B,
2266 gmmCause := {
2267 causeValue := cause
2268 },
2269 forceToStandby := ?,
2270 spare := '0000'B,
2271 t3302 := *,
2272 t3346 := *
2273 }
2274 }
2275 }
2276}
2277
Harald Welte91636de2018-02-17 10:16:14 +01002278template PDU_L3_SGSN_MS tr_GMM_RAU_ACCEPT(template BIT3 res := ?,
2279 template RoutingAreaIdentificationV ra := ?,
2280 template OCT4 ptmsi := *) := {
2281 discriminator := '1000'B,
2282 tiOrSkip := {
2283 skipIndicator := '0000'B
2284 },
2285 msgs := {
2286 gprs_mm := {
2287 routingAreaUpdateAccept := {
2288 messageType := '00001001'B,
2289 forceToStandby := ?,
2290 updateResult := { res, ? },
2291 raUpdateTimer := ?,
2292 routingAreaId := ra,
2293 ptmsiSignature := *,
2294 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2295 msIdentity := *,
2296 receiveNPDUNumbers := *,
2297 readyTimer := *,
2298 gmmCause := *,
2299 t3302 := *,
2300 cellNotification := *,
2301 equivalentPLMNs := *,
2302 pdpContextStatus := *,
2303 networkFeatureSupport := *,
2304 emergencyNumberList := *,
2305 mBMS_ContextStatus := *,
2306 requestedMSInformation := *,
2307 t3319 := *,
2308 t3323 := *,
2309 t3312_ExtendedValue := *,
2310 additionalNetworkFeatureSupport := *,
2311 t3324 := *,
2312 extendedDRXParameters := *
2313 }
2314 }
2315 }
2316}
Harald Welte04683d02018-02-16 22:43:45 +01002317
Harald Welte38575a72018-02-15 20:41:37 +01002318template (value) PDU_L3_MS_SGSN ts_GMM_RAU_COMPL := {
2319 discriminator := '0000'B, /* overwritten */
2320 tiOrSkip := {
2321 skipIndicator := '0000'B
2322 },
2323 msgs := {
2324 gprs_mm := {
2325 routingAreaUpdateComplete := {
2326 messageType := '00000000'B, /* overwritten */
2327 receiveNPDUNumbers := omit,
2328 interRATHandoverInformation := omit,
2329 eUTRANinterRATHandoverInformation := omit
2330 }
2331 }
2332 }
2333}
2334
2335template (value) PDU_L3_MS_SGSN ts_GMM_PTMSI_REALL_COMPL := {
2336 discriminator := '0000'B, /* overwritten */
2337 tiOrSkip := {
2338 skipIndicator := '0000'B
2339 },
2340 msgs := {
2341 gprs_mm := {
2342 p_TMSIReallocationComplete := {
2343 messageType := '00000000'B /* overwritten */
2344 }
2345 }
2346 }
2347}
2348
2349template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_CIPH_COMPL(ACReferenceNumberV ref, OCT4 res) := {
2350 discriminator := '0000'B, /* overwritten */
2351 tiOrSkip := {
2352 skipIndicator := '0000'B
2353 },
2354 msgs := {
2355 gprs_mm := {
2356 authenticationAndCipheringResponse := {
2357 messageType := '00000000'B, /* overwritten */
2358 acReferenceNumber := ref,
2359 spare := '0000'B,
2360 authenticationParResp := {
2361 elementIdentifier := '22'O,
2362 valueField := res
2363 },
2364 imeisv := omit,
2365 authenticationRespParExt := omit
2366 }
2367 }
2368 }
2369}
2370
Harald Welteb0386df2018-02-16 18:14:28 +01002371template PDU_L3_SGSN_MS tr_GMM_ID_REQ(template BIT3 id_type := ?) := {
2372 discriminator := '1000'B,
2373 tiOrSkip := {
2374 skipIndicator := '0000'B
2375 },
2376 msgs := {
2377 gprs_mm := {
2378 identityRequest := {
2379 messageType := '00010101'B,
2380 identityType := { id_type, '0'B },
2381 forceToStandby := ?
2382 }
2383 }
2384 }
2385}
2386
Harald Welte38575a72018-02-15 20:41:37 +01002387template (value) PDU_L3_MS_SGSN ts_GMM_ID_RESP(MobileIdentityLV mi_lv) := {
2388 discriminator := '0000'B, /* overwritten */
2389 tiOrSkip := {
2390 skipIndicator := '0000'B
2391 },
2392 msgs := {
2393 gprs_mm := {
2394 identityResponse := {
2395 messageType := '00000000'B, /* overwritten */
2396 mobileIdentity := mi_lv
2397 }
2398 }
2399 }
2400}
2401
Harald Welteb0386df2018-02-16 18:14:28 +01002402template PDU_L3_SGSN_MS tr_GMM_AUTH_REQ(template OCT16 rand := ?, template BIT3 ciph_alg := ?) := {
2403 discriminator := '1000'B,
2404 tiOrSkip := {
2405 skipIndicator := '0000'B
2406 },
2407 msgs := {
2408 gprs_mm := {
2409 authenticationAndCipheringRequest := {
2410 messageType := '00010010'B,
2411 cipheringAlgorithm := { ciph_alg, '0'B },
2412 imeisvRequest := ?,
2413 forceToStandby := ?,
2414 acReferenceNumber := ?,
2415 authenticationParameterRAND := {
2416 elementIdentifier := '21'O,
2417 randValue := rand
2418 },
2419 cipheringKeySequenceNumber := *,
2420 authenticationParameterAUTN := *
2421 }
2422 }
2423 }
2424}
2425
2426template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_RESP_2G(BIT4 ac_ref, OCT4 sres) := {
2427 discriminator := '1000'B,
2428 tiOrSkip := {
2429 skipIndicator := '0000'B
2430 },
2431 msgs := {
2432 gprs_mm := {
2433 authenticationAndCipheringResponse := {
2434 messageType := '00010011'B,
2435 acReferenceNumber := { valueField := ac_ref },
2436 spare := '0000'B,
2437 authenticationParResp := {
2438 elementIdentifier := '22'O,
2439 valueField := sres
2440 },
2441 imeisv := omit,
2442 authenticationRespParExt := omit
2443 }
2444 }
2445 }
2446}
2447
Alexander Couzens15faf922018-09-04 15:16:26 +02002448template PDU_L3_MS_SGSN ts_GMM_AUTH_FAIL_UMTS_AKA_RESYNC(octetstring auts) := {
2449 discriminator := '1000'B,
2450 tiOrSkip := {
2451 skipIndicator := '0000'B
2452 },
2453 msgs := {
2454 gprs_mm := {
2455 authenticationAndCipheringFailure := {
2456 messageType := '00011100'B,
2457 gmmCause := {
2458 causeValue := '15'O /* GMM_CAUSE_SYNC_FAIL 10.5.3.2.2 */
2459 },
2460 authenticationFailureParam := {
2461 elementIdentifier := '30'O,
2462 lengthIndicator := 14,
2463 valueField := auts
2464 }
2465 }
2466 }
2467 }
2468}
2469
Harald Welteb0386df2018-02-16 18:14:28 +01002470
Harald Welte38575a72018-02-15 20:41:37 +01002471const BIT3 c_GMM_DTT_MO_GPRS := '001'B;
2472const BIT3 c_GMM_DTT_MO_IMSI := '010'B;
2473const BIT3 c_GMM_DTT_MO_GPRS_IMSI_COMBINED := '011'B;
2474
Alexander Couzensb6ab4562018-05-17 02:59:22 +02002475const BIT3 c_GMM_DTT_MT_REATTACH_REQUIRED := '001'B;
2476const BIT3 c_GMM_DTT_MT_REATTACH_NOT_REQUIRED := '010'B;
2477const BIT3 c_GMM_DTT_MT_IMSI_DETACH := '011'B;
2478
Harald Welte6abb9fe2018-02-17 15:24:48 +01002479template (value) DetachTypeV ts_GMM_DetType(BIT3 dtt, boolean power_off := false) := {
Harald Welte38575a72018-02-15 20:41:37 +01002480 detachType := dtt,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002481 powerOffFlag := bool2bit(power_off)
Harald Welte38575a72018-02-15 20:41:37 +01002482}
2483
Harald Welte6abb9fe2018-02-17 15:24:48 +01002484function ts_PtmsiSigTV(template (omit) OCT3 val) return template (omit) P_TMSISignatureTV {
2485 var template (omit) P_TMSISignatureTV ret;
2486 if (istemplatekind(val, "omit")) {
2487 return omit;
2488 } else {
2489 ret := {
2490 elementIdentifier := '19'O,
2491 valueField := valueof(val)
2492 }
2493 return ret;
2494 }
2495}
2496
2497function ts_PtmsiSigTLV(template (omit) OCT3 val) return template (omit) P_TMSISignature2TLV {
2498 var template (omit) P_TMSISignature2TLV ret;
2499 if (istemplatekind(val, "omit")) {
2500 return omit;
2501 } else {
2502 ret := {
2503 elementIdentifier := '19'O,
2504 lengthIndicator := 3,
2505 valueField := valueof(val)
2506 }
2507 return ret;
2508 }
2509}
2510
2511template (value) PDU_L3_MS_SGSN ts_GMM_DET_REQ_MO(BIT3 dtt := c_GMM_DTT_MO_GPRS,
2512 boolean power_off := false,
2513 template (omit) OCT4 p_tmsi := omit,
2514 template (omit) OCT3 p_tmsi_sig := omit) := {
Harald Welte38575a72018-02-15 20:41:37 +01002515 discriminator := '0000'B, /* overwritten */
2516 tiOrSkip := {
2517 skipIndicator := '0000'B
2518 },
2519 msgs := {
2520 gprs_mm := {
2521 detachRequest_MS_SGSN := {
2522 messageType := '00000000'B, /* overwritten */
Harald Welte6abb9fe2018-02-17 15:24:48 +01002523 detachType := valueof(ts_GMM_DetType(dtt, power_off)),
Harald Welte38575a72018-02-15 20:41:37 +01002524 spare := '0000'B,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002525 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
2526 ptmsiSignature := ts_PtmsiSigTLV(p_tmsi_sig)
2527 }
2528 }
2529 }
2530}
2531
2532template PDU_L3_SGSN_MS tr_GMM_DET_ACCEPT_MT := {
2533 discriminator := '1000'B,
2534 tiOrSkip := {
2535 skipIndicator := '0000'B
2536 },
2537 msgs := {
2538 gprs_mm := {
2539 detachAccept_SGSN_MS := {
2540 messageType := '00000110'B,
2541 forceToStandby := ?,
2542 spare := '0000'B
Harald Welte38575a72018-02-15 20:41:37 +01002543 }
2544 }
2545 }
2546}
Harald Welte812f7a42018-01-27 00:49:18 +01002547
Alexander Couzensd62fba52018-05-22 16:08:39 +02002548template PDU_L3_SGSN_MS tr_GMM_DET_REQ_MT(
2549 template BIT3 dtt := *,
2550 template BIT3 forceToStandby := ?,
Alexander Couzensd8604ab2018-05-29 15:46:06 +02002551 template OCT1 cause := *) := {
Harald Welte835b15f2018-02-18 14:39:11 +01002552 discriminator := '1000'B,
2553 tiOrSkip := {
2554 skipIndicator := '0000'B
2555 },
2556 msgs := {
2557 gprs_mm := {
2558 detachRequest_SGSN_MS := {
2559 messageType := '00000101'B,
Alexander Couzensd62fba52018-05-22 16:08:39 +02002560 detachType := { dtt, ? },
2561 forceToStandby := { forceToStandby, '0'B },
2562 gmmCause := {
2563 elementIdentifier := '25'O,
2564 causeValue := { cause }
2565 }
2566 }
2567 }
2568 }
2569}
2570
2571template PDU_L3_MS_SGSN ts_GMM_DET_ACCEPT_MO := {
2572 discriminator := '0000'B, /* overwritten */
2573 tiOrSkip := {
2574 skipIndicator := '0000'B
2575 },
2576 msgs := {
2577 gprs_mm := {
2578 detachAccept_MS_SGSN := {
2579 messageType := '00000000'B
Harald Welte835b15f2018-02-18 14:39:11 +01002580 }
2581 }
2582 }
2583}
Harald Welteeded9ad2018-02-17 20:57:34 +01002584
2585function ts_ApnTLV(template (omit) octetstring apn) return template (omit) AccessPointNameTLV {
2586 if (istemplatekind(apn, "omit")) {
2587 return omit;
2588 } else {
2589 var template (omit) AccessPointNameTLV ret := {
2590 elementIdentifier := '28'O,
2591 lengthIndicator := 0, /* overwritten */
2592 accessPointNameValue := apn
2593 }
2594 return ret;
2595 }
2596}
2597
2598function ts_PcoTLV(template (omit) ProtocolConfigOptionsV pco)
2599 return template (omit) ProtocolConfigOptionsTLV {
2600 if (istemplatekind(pco, "omit")) {
2601 return omit;
2602 } else {
2603 var template (omit) ProtocolConfigOptionsTLV ret := {
2604 elementIdentifier := '27'O,
2605 lengthIndicator := 0, /* overwritten */
2606 protocolConfigOptionsV := pco
2607 }
2608 return ret;
2609 }
2610}
2611
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002612function ts_TearDownIndicatorTV(in template (omit) boolean ind)
2613 return template (omit) TearDownIndicatorTV {
2614 if (istemplatekind(ind, "omit")) {
2615 return omit;
2616 } else {
2617 var template (omit) TearDownIndicatorTV ret := {
2618 tearDownIndicatorV := {
2619 tdi_flag := bool2bit(valueof(ind)),
2620 spare := '000'B
2621 },
2622 elementIdentifier := '1001'B
2623 }
2624 return ret;
2625 }
2626}
2627
Harald Welteeded9ad2018-02-17 20:57:34 +01002628template (value) PDU_L3_MS_SGSN ts_SM_ACT_PDP_REQ(BIT3 tid, BIT4 nsapi, BIT4 sapi, QoSV qos,
2629 PDPAddressV addr,
2630 template (omit) octetstring apn := omit,
2631 template (omit) ProtocolConfigOptionsV pco := omit
2632 ) := {
2633 discriminator := '0000'B, /* overwritten */
2634 tiOrSkip := {
2635 transactionId := {
2636 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002637 tiFlag := c_TIF_ORIG,
Harald Welteeded9ad2018-02-17 20:57:34 +01002638 tIExtension := omit
2639 }
2640 },
2641 msgs := {
2642 gprs_sm := {
2643 activatePDPContextRequest := {
2644 messageType := '00000000'B, /* overwritten */
2645 requestedNSAPI := { nsapi, '0000'B },
2646 requestedLLCSAPI := { sapi, '0000'B },
2647 requestedQoS := {
2648 lengthIndicator := 0, /* overwritten */
2649 qoSV := qos
2650 },
2651 requestedPDPaddress := {
2652 lengthIndicator := 0, /* overwritten */
2653 pdpAddressV := addr
2654 },
2655 accessPointName := ts_ApnTLV(apn),
2656 protocolConfigOpts := ts_PcoTLV(pco),
2657 requestType := omit,
2658 deviceProperties := omit,
2659 nBIFOM_Container := omit
2660 }
2661 }
2662 }
2663}
2664
2665template PDU_L3_SGSN_MS tr_SM_ACT_PDP_REJ(template BIT3 tid := ?, template OCT1 cause := ?) := {
2666 discriminator := '1010'B,
2667 tiOrSkip := {
2668 transactionId := {
2669 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002670 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002671 tIExtension := omit
2672 }
2673 },
2674 msgs := {
2675 gprs_sm := {
2676 activatePDPContextReject := {
Harald Welte4aacdd82018-02-18 21:24:05 +01002677 messageType := '01000011'B,
Harald Welteeded9ad2018-02-17 20:57:34 +01002678 smCause := cause,
2679 protocolConfigOpts := *,
2680 backOffTimer := *,
2681 reAttemptIndicator := *,
2682 nBIFOM_Container := *
2683 }
2684 }
2685 }
2686}
2687
2688template PDU_L3_SGSN_MS tr_SM_ACT_PDP_ACCEPT(template BIT3 tid := ?, template BIT4 sapi := ?,
2689 template QoSV qos := ?)
2690:= {
2691 discriminator := '1010'B,
2692 tiOrSkip := {
2693 transactionId := {
2694 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002695 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002696 tIExtension := omit
2697 }
2698 },
2699 msgs := {
2700 gprs_sm := {
2701 activatePDPContextAccept := {
2702 messageType := '01000010'B,
2703 negotiatedLLCSAPI := { sapi, '0000'B },
2704 negotiatedQoS := {
2705 lengthIndicator := ?,
2706 qoSV := qos
2707 },
2708 radioPriority := ?,
2709 spare := '0000'B,
2710 pdpAddress := *,
2711 protocolConfigOpts := *,
2712 packetFlowID := *,
2713 sMCause2 := *,
2714 connectivityType := *,
2715 wLANOffloadIndication := *,
2716 nBIFOM_Container := *
2717 }
2718 }
2719 }
2720}
2721
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002722template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_REQ_MO(BIT3 tid, OCT1 cause,
2723 template (omit) boolean tdown := omit,
Harald Welte6f203162018-02-18 22:04:55 +01002724 template (omit) ProtocolConfigOptionsV pco := omit
2725 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002726 discriminator := '1010'B,
Harald Welte6f203162018-02-18 22:04:55 +01002727 tiOrSkip := {
2728 transactionId := {
2729 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002730 tiFlag := c_TIF_ORIG,
Harald Welte6f203162018-02-18 22:04:55 +01002731 tIExtension := omit
2732 }
2733 },
2734 msgs := {
2735 gprs_sm := {
2736 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002737 messageType := '01000110'B,
Harald Welte6f203162018-02-18 22:04:55 +01002738 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002739 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte6f203162018-02-18 22:04:55 +01002740 protocolConfigOpts := ts_PcoTLV(pco),
2741 mBMSprotocolConfigOptions := omit,
2742 t3396 := omit,
2743 wLANOffloadIndication := omit,
2744 nBIFOM_Container := omit
2745 }
2746 }
2747 }
2748}
2749
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002750template (value) PDU_L3_SGSN_MS ts_SM_DEACT_PDP_REQ_MT(BIT3 tid, OCT1 cause,
2751 template (omit) boolean tdown := omit,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002752 template (omit) ProtocolConfigOptionsV pco := omit
2753 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002754 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002755 tiOrSkip := {
2756 transactionId := {
2757 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002758 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002759 tIExtension := omit
2760 }
2761 },
2762 msgs := {
2763 gprs_sm := {
2764 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002765 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002766 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002767 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte57b9b7f2018-02-18 22:28:13 +01002768 protocolConfigOpts := ts_PcoTLV(pco),
2769 mBMSprotocolConfigOptions := omit,
2770 t3396 := omit,
2771 wLANOffloadIndication := omit,
2772 nBIFOM_Container := omit
2773 }
2774 }
2775 }
2776}
2777
2778template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_REQ_MT(template BIT3 tid, template OCT1 cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002779 template (omit) boolean tdown := omit,
2780 template (omit) ProtocolConfigOptionsV pco := omit
2781 ) := {
2782 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002783 tiOrSkip := {
2784 transactionId := {
2785 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002786 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002787 tIExtension := omit
2788 }
2789 },
2790 msgs := {
2791 gprs_sm := {
2792 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002793 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002794 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002795 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
2796 protocolConfigOpts := ts_PcoTLV(pco),
Harald Welte57b9b7f2018-02-18 22:28:13 +01002797 mBMSprotocolConfigOptions := *,
2798 t3396 := *,
2799 wLANOffloadIndication := *,
2800 nBIFOM_Container := *
2801 }
2802 }
2803 }
2804}
2805
Harald Welte6f203162018-02-18 22:04:55 +01002806template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_ACCEPT_MT(template BIT3 tid := ?)
2807:= {
2808 discriminator := '1010'B,
2809 tiOrSkip := {
2810 transactionId := {
2811 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002812 tiFlag := c_TIF_REPL,
Harald Welte6f203162018-02-18 22:04:55 +01002813 tIExtension := omit
2814 }
2815 },
2816 msgs := {
2817 gprs_sm := {
2818 deactivatePDPContextAccept := {
2819 messageType := '01000111'B,
2820 protocolConfigOpts := *,
2821 mBMSprotocolConfigOptions := *,
2822 nBIFOM_Container := *
2823 }
2824 }
2825 }
2826}
2827
Harald Welte57b9b7f2018-02-18 22:28:13 +01002828template PDU_L3_MS_SGSN tr_SM_DEACT_PDP_ACCEPT_MO(template BIT3 tid := ?)
2829:= {
2830 discriminator := '1010'B,
2831 tiOrSkip := {
2832 transactionId := {
2833 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002834 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002835 tIExtension := omit
2836 }
2837 },
2838 msgs := {
2839 gprs_sm := {
2840 deactivatePDPContextAccept := {
2841 messageType := '01000111'B,
2842 protocolConfigOpts := *,
2843 mBMSprotocolConfigOptions := *,
2844 nBIFOM_Container := *
2845 }
2846 }
2847 }
2848}
2849
2850template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_ACCEPT_MO(BIT3 tid)
2851:= {
2852 discriminator := '1010'B,
2853 tiOrSkip := {
2854 transactionId := {
2855 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002856 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002857 tIExtension := omit
2858 }
2859 },
2860 msgs := {
2861 gprs_sm := {
2862 deactivatePDPContextAccept := {
2863 messageType := '01000111'B,
2864 protocolConfigOpts := omit,
2865 mBMSprotocolConfigOptions := omit,
2866 nBIFOM_Container := omit
2867 }
2868 }
2869 }
2870}
2871
Harald Welteeded9ad2018-02-17 20:57:34 +01002872
2873
Harald Weltee5695f52018-02-16 14:46:15 +01002874private function f_concat_pad(integer tot_len, hexstring prefix, integer suffix) return hexstring {
2875 var integer suffix_len := tot_len - lengthof(prefix);
2876 var charstring suffix_ch := int2str(suffix);
2877 var integer pad_len := suffix_len - lengthof(suffix_ch);
2878
2879 return prefix & int2hex(0, pad_len) & str2hex(suffix_ch);
2880}
2881
2882function f_gen_imei(integer suffix) return hexstring {
Oliver Smith745ed952019-07-05 14:08:17 +02002883 return f_concat_pad(14, '49999'H, suffix);
Harald Weltee5695f52018-02-16 14:46:15 +01002884}
2885
2886function f_gen_imsi(integer suffix) return hexstring {
2887 return f_concat_pad(15, '26242'H, suffix);
2888}
2889
2890function f_gen_msisdn(integer suffix) return hexstring {
2891 return f_concat_pad(12, '49123'H, suffix);
2892}
2893
Harald Welte7484fc42018-02-24 14:09:45 +01002894external function enc_MobileIdentityLV(in MobileIdentityLV si) return octetstring
2895 with { extension "prototype(convert) encode(RAW)" };
Harald Weltee5695f52018-02-16 14:46:15 +01002896
Vadim Yanitskiy322c7932020-01-01 23:03:47 +01002897external function dec_MobileIdentityV(in octetstring mi) return MobileIdentityV
2898 with { extension "prototype(convert) decode(RAW)" };
2899
Harald Weltecb6cc332018-01-21 13:59:08 +01002900
Harald Weltef45efeb2018-04-09 18:19:24 +02002901
2902/* SMS TPDU Layer */
2903
2904template (value) TPDU_RP_DATA_MS_SGSN ts_SMS_SUBMIT(OCT1 msg_ref, template (value) TP_DA dst_addr,
2905 template (value) OCT1 pid, template (value) OCT1 dcs,
2906 integer length_ind, octetstring user_data) := {
2907 sMS_SUBMIT := {
2908 tP_MTI := '01'B, /* SUBMIT */
2909 tP_RD := '1'B, /* reject duplicates */
2910 tP_VPF := '00'B, /* not present */
2911 tP_SRR := '0'B, /* no status report requested */
2912 tP_UDHI := '0'B, /* no user data header in UD */
2913 tP_RP := '0'B, /* no reply path */
2914 tP_MR := msg_ref,
2915 tP_DA := dst_addr,
2916 tP_PID := pid,
2917 tP_DCS := dcs,
2918 tP_VP := omit,
2919 tP_UDL_UD := {
2920 tP_LengthIndicator := length_ind,
2921 tP_UD := user_data
2922 }
2923 }
2924}
2925
2926template TPDU_RP_DATA_SGSN_MS tr_SMS_DELIVER(template TP_OA src_addr := ?,
2927 template octetstring user_data := ?,
2928 template OCT1 pid := ?, template OCT1 dcs := ?,
2929 template BIT1 mms := ?
2930 ) := {
2931 sMS_DELIVER := {
2932 tP_MTI := '00'B, /* DELIVER */
2933 tP_MMS := mms, /* more messages to send */
2934 tP_LP := ?, /* ?!? */
2935 tP_Spare := '0'B,
2936 tP_SRI := '0'B, /* status report indication */
2937 tP_UDHI := '0'B, /* no user data header in UD */
2938 tP_RP := '0'B, /* no reply path */
2939 tP_OA := src_addr,
2940 tP_PID := pid,
2941 tP_DCS := dcs,
2942 tP_SCTS := ?,
2943 tP_UDL_UD := {
2944 tP_LengthIndicator := ?,
2945 tP_UD := user_data
2946 }
2947 }
2948}
2949
2950/* RP Layer */
2951
2952private function ts_RpOrig(template (omit) RP_NumberingPlan_and_NumberDigits rp_orig)
2953return RP_OriginatorAddressLV {
2954 var RP_OriginatorAddressLV ret;
2955 if (istemplatekind(rp_orig, "omit")) {
2956 ret := { 0, omit };
2957 } else {
2958 ret := { 0, valueof(rp_orig) };
2959 }
2960 return ret;
2961}
2962
2963private function ts_RpDst(template (omit) RP_NumberingPlan_and_NumberDigits rp_dst)
2964return RP_DestinationAddressLV {
2965 var RP_DestinationAddressLV ret;
2966 if (istemplatekind(rp_dst, "omit")) {
2967 ret := { 0, omit };
2968 } else {
2969 ret := { 0, valueof(rp_dst) };
2970 }
2971 return ret;
2972}
2973
2974template (value) RPDU_MS_SGSN ts_RP_DATA_MO(OCT1 msg_ref,
2975 template (omit) RP_NumberingPlan_and_NumberDigits rp_orig,
2976 template (omit) RP_NumberingPlan_and_NumberDigits rp_dst,
2977 template (value) TPDU_RP_DATA_MS_SGSN tpdu) := {
2978 rP_DATA_MS_SGSN := {
2979 rP_MTI := '000'B,
2980 rP_Spare := '00000'B,
2981 rP_MessageReference := msg_ref,
2982 rP_OriginatorAddress := ts_RpOrig(rp_orig),
2983 rP_DestinationAddress := ts_RpDst(rp_dst),
2984 rP_User_Data := {
2985 rP_LengthIndicator := 0, /* overwritten */
2986 rP_TPDU := tpdu
2987 }
2988 }
2989}
2990
2991template RPDU_SGSN_MS tr_RP_DATA_MT(template OCT1 msg_ref,
2992 template RP_NumberingPlan_and_NumberDigits rp_orig,
2993 template RP_NumberingPlan_and_NumberDigits rp_dst,
2994 template TPDU_RP_DATA_SGSN_MS tpdu) := {
2995 rP_DATA_SGSN_MS := {
2996 rP_MTI := '001'B,
2997 rP_Spare := '00000'B,
2998 rP_MessageReference := msg_ref,
2999 rP_OriginatorAddress := { ?, rp_orig },
3000 rP_DestinationAddress := { ?, rp_dst },
3001 rP_User_Data := {
3002 rP_LengthIndicator := ?,
3003 rP_TPDU := tpdu
3004 }
3005
3006 }
3007}
3008
3009template (value) RPDU_MS_SGSN ts_RP_ACK_MO(OCT1 msg_ref) := {
3010 rP_ACK_MS_SGSN := {
3011 rP_MTI := '010'B,
3012 rP_Spare := '00000'B,
3013 rP_MessageReference := msg_ref,
3014 rP_User_Data := omit /* FIXME: report */
3015 }
3016}
3017
3018template RPDU_SGSN_MS tr_RP_ACK_MT(template OCT1 msg_ref) := {
3019 rP_ACK_SGSN_MS := {
3020 rP_MTI := '011'B,
3021 rP_Spare := '00000'B,
3022 rP_MessageReference := msg_ref,
3023 rP_User_Data := omit /* FIXME: report */
3024 }
3025}
3026
3027template (value) RPDU_MS_SGSN ts_RP_ERROR_MO(OCT1 msg_ref, uint7_t cause) := {
3028 rP_ERROR_MS_SGSN := {
3029 rP_MTI := '100'B,
3030 rP_Spare := '00000'B,
3031 rP_Message_Reference := msg_ref,
3032 rP_CauseLV := {
3033 rP_LengthIndicator := 0, /* overwritten */
3034 rP_CauseV := {
3035 causeValue := int2bit(cause, 7),
3036 ext := '0'B
3037 },
3038 rP_diagnisticField := omit
3039 },
3040 rP_User_Data := omit /* FIXME: report */
3041 }
3042}
3043
3044private function f_cause_or_wc(template uint7_t cause) return template BIT7 {
3045 if (istemplatekind(cause, "?")) {
3046 return ?;
3047 } else if (istemplatekind(cause, "*")) {
3048 return *;
3049 } else {
3050 return int2bit(valueof(cause), 7);
3051 }
3052}
3053
3054template RPDU_SGSN_MS tr_RP_ERROR_MT(template OCT1 msg_ref, template uint7_t cause) := {
3055 rP_ERROR_SGSN_MS := {
3056 rP_MTI := '101'B,
3057 rP_Spare := '00000'B,
3058 rP_Message_Reference := msg_ref,
3059 rP_CauseLV := {
Vadim Yanitskiye9e93012020-01-15 12:35:17 +07003060 rP_LengthIndicator := ?,
Harald Weltef45efeb2018-04-09 18:19:24 +02003061 rP_CauseV := {
3062 causeValue := f_cause_or_wc(cause),
3063 ext := '0'B
3064 },
3065 rP_diagnisticField := omit
3066 },
3067 rP_User_Data := omit /* FIXME: report */
3068 }
3069}
3070
3071
3072template (value) RPDU_MS_SGSN ts_RP_SMMA_MO(OCT1 msg_ref) := {
3073 rP_SMMA := {
3074 rP_MTI := '110'B,
3075 rP_Spare := '00000'B,
3076 rP_MessageReference := msg_ref
3077 }
3078}
3079
3080
3081
3082
3083/* CP Layer */
3084
3085template (value) L3_SMS_MS_SGSN ts_CP_DATA_MO(template (value) RPDU_MS_SGSN rpdu) := {
3086 cP_DATA := {
3087 cP_messageType := '00000001'B,
3088 cP_User_Data := {
3089 lengthIndicator := 0, /* overwritten */
3090 cP_RPDU := rpdu
3091 }
3092 }
3093}
3094
3095template (value) L3_SMS_MS_SGSN ts_CP_ACK_MO := {
3096 cP_ACK := {
3097 cP_messageType := '00000100'B
3098 }
3099}
3100
3101template (value) L3_SMS_MS_SGSN ts_CP_ERROR_MO(OCT1 cause) := {
3102 cP_ERROR := {
3103 cP_messageType := '00010000'B,
3104 cP_Cause := {
3105 causeValue := cause
3106 }
3107 }
3108}
3109
3110template L3_SMS_SGSN_MS tr_CP_DATA_MT(template RPDU_SGSN_MS rpdu) := {
3111 cP_DATA := {
3112 cP_messageType := '00000001'B,
3113 cP_User_Data := {
3114 lengthIndicator := ?,
3115 cP_RPDU := rpdu
3116 }
3117 }
3118}
3119
3120template L3_SMS_SGSN_MS tr_CP_ACK_MT := {
3121 cP_ACK := {
3122 cP_messageType := '00000100'B
3123 }
3124}
3125
3126template L3_SMS_SGSN_MS tr_CP_ERROR_MT(template OCT1 cause) := {
3127 cP_ERROR := {
3128 cP_messageType := '00010000'B,
3129 cP_Cause := {
3130 causeValue := cause
3131 }
3132 }
3133}
3134
3135/* L3 Wrapper */
3136
3137template (value) PDU_ML3_MS_NW ts_ML3_MO_SMS(uint3_t tid, BIT1 ti_flag,
3138 template (value) L3_SMS_MS_SGSN sms_mo) := {
3139 discriminator := '1001'B,
3140 tiOrSkip := {
3141 transactionId := {
3142 tio := int2bit(tid, 3),
3143 tiFlag := ti_flag,
3144 tIExtension := omit
3145 }
3146 },
3147 msgs := {
3148 sms := sms_mo
3149 }
3150}
3151
3152private function f_tid_or_wc(template uint3_t tid) return template BIT3 {
3153 var template BIT3 ret;
3154 if (istemplatekind(tid, "*")) {
3155 return *;
3156 } else if (istemplatekind(tid, "?")) {
3157 return ?;
3158 } else {
3159 return int2bit(valueof(tid), 3);
3160 }
3161}
3162
3163template PDU_ML3_NW_MS tr_ML3_MT_SMS(template uint3_t tid, template BIT1 ti_flag,
3164 template L3_SMS_SGSN_MS sms_mt) := {
3165 discriminator := '1001'B,
3166 tiOrSkip := {
3167 transactionId := {
3168 tio := f_tid_or_wc(tid),
3169 tiFlag := ti_flag,
3170 tIExtension := omit
3171 }
3172 },
3173 msgs := {
3174 sms := sms_mt
3175 }
3176}
3177
Philipp Maier9b690e42018-12-21 11:50:03 +01003178template PDU_ML3_NW_MS tr_ML3_MT_MM_Info := {
3179 discriminator := '0101'B,
3180 tiOrSkip := {
3181 skipIndicator := '0000'B
3182 },
3183 msgs := {
3184 mm := {
3185 mMInformation := {
3186 messageType := '110010'B,
3187 nsd := '00'B,
3188 fullNetworkName := *,
3189 shortNetworkName := *,
3190 localtimeZone := *,
3191 univTime := *,
3192 lSAIdentity := *,
3193 networkDST := *
3194 }
3195 }
3196 }
3197}
Harald Weltef45efeb2018-04-09 18:19:24 +02003198
3199
3200
Harald Weltec76f29f2017-11-22 12:46:46 +01003201}