blob: e6efb688192b5d8a04c9580e7012818e6354a702 [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
Neels Hofmeyre51ce492021-07-27 22:30:08 +020065template ML3_Cause_LV ts_ML3_Cause_LV(BIT7 cause, BIT4 loc := '0001'B, BIT2 std := '11'B) := {
66 lengthIndicator := 0, /* overwritten */
67 oct3 := {
68 location := loc,
69 spare1_1 := '0'B,
70 codingStandard := std,
71 ext1 := '0'B,
72 recommendation := omit,
73 ext2 := omit
74 },
75 oct4 := {
76 causeValue := cause,
77 ext3 := '1'B
78 },
79 diagnostics := omit
80}
81
Harald Weltec76f29f2017-11-22 12:46:46 +010082
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +070083/* 3GPP TS 24.008, section 10.5.1.4 "Mobile Identity" */
84template (value) MobileIdentityTLV ts_MI_TLV(template (value) MobileIdentityV mi) := {
85 elementIdentifier := '0010111'B,
86 spare1 := '0'B,
87 mobileIdentityLV := ts_MI_LV(mi)
88};
89template MobileIdentityTLV tr_MI_TLV(template MobileIdentityV mi) := {
90 elementIdentifier := '0010111'B,
91 spare1 := '0'B,
92 mobileIdentityLV := tr_MI_LV(mi)
93};
94
95template (value) MobileIdentityLV ts_MI_LV(template (value) MobileIdentityV mi) := {
96 lengthIndicator := 0, /* overwritten */
97 mobileIdentityV := mi
98};
99template MobileIdentityLV tr_MI_LV(template MobileIdentityV mi) := {
100 lengthIndicator := ?,
101 mobileIdentityV := mi
102};
103
104/* Universal (send & receive) template for No Identity */
105template MobileIdentityV t_MI_NoIdentity(template (present) hexstring filler := 'F'H) := {
106 typeOfIdentity := '000'B,
107 oddEvenInd_identity := {
108 no_identity := {
109 /* Always old, since length can be 1, 3, or 5 */
110 oddevenIndicator := '0'B,
111 fillerDigits := filler
112 }
113 }
114};
115
116/* Universal (send & receive) template for TMSI/P-TMSI */
117template MobileIdentityV t_MI_TMSI(template (present) OCT4 tmsi) := {
118 typeOfIdentity := '100'B,
119 oddEvenInd_identity := {
120 tmsi_ptmsi := {
121 oddevenIndicator := '0'B,
122 fillerDigit := '1111'B,
123 octets := tmsi
124 }
125 }
126};
127
128private function f_tr_MI_IMSI(template (present) hexstring digits)
129return template (present) IMSI_L3 {
130 if (istemplatekind(digits, "?")) {
131 return ?;
132 } else {
133 return f_enc_IMSI_L3(valueof(digits))
134 }
135}
Harald Weltebd982952020-08-21 12:34:16 +0200136template MobileIdentityV tr_MI_IMSI(template (present) hexstring imsi) := {
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +0700137 typeOfIdentity := '001'B,
138 oddEvenInd_identity := {
139 imsi := f_tr_MI_IMSI(imsi)
140 }
141};
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +0700142template (value) MobileIdentityV ts_MI_IMSI(hexstring imsi) := {
143 typeOfIdentity := '001'B,
144 oddEvenInd_identity := {
145 imsi := f_enc_IMSI_L3(imsi)
146 }
147};
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +0700148
149
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200150/* send template for Mobile Identity (TMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100151template MobileIdentityLV ts_MI_TMSI_LV(OCT4 tmsi) := {
152 lengthIndicator := 0, /* overwritten */
153 mobileIdentityV := {
154 typeOfIdentity := '000'B, /* overwritten */
155 oddEvenInd_identity := {
156 tmsi_ptmsi := {
157 oddevenIndicator := '0'B,
158 fillerDigit := '1111'B,
159 octets := tmsi
160 }
161 }
162 }
163}
164
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200165/* send template for Mobile Identity (TMSI) */
Harald Welte6abb9fe2018-02-17 15:24:48 +0100166function ts_MI_TMSI_TLV(template (omit) OCT4 tmsi) return template (omit) MobileIdentityTLV {
167 var template (omit) MobileIdentityTLV ret;
168 if (istemplatekind(tmsi, "omit")) {
169 return omit;
170 } else {
171 ret := {
172 elementIdentifier := '0100011'B,
173 spare1 := '0'B,
174 mobileIdentityLV := ts_MI_TMSI_LV(valueof(tmsi))
175 }
176 return ret;
177 }
Harald Welte38575a72018-02-15 20:41:37 +0100178}
179
Harald Welteb0386df2018-02-16 18:14:28 +0100180template MobileIdentityTLV ts_MI_IMEISV_TLV(hexstring imeisv) := {
181 elementIdentifier := '0100011'B,
182 spare1 := '0'B,
183 mobileIdentityLV := ts_MI_IMEISV_LV(imeisv)
184}
185
Harald Weltec76f29f2017-11-22 12:46:46 +0100186private function f_enc_IMSI_L3(hexstring digits) return IMSI_L3 {
187 var IMSI_L3 l3;
188 var integer len := lengthof(digits);
189 if (len rem 2 == 1) { /* modulo remainder */
Harald Welte365f4ed2017-11-23 00:00:43 +0100190 l3.oddevenIndicator := '1'B;
Harald Welteae136252018-01-24 20:53:21 +0100191 l3.fillerDigit := omit;
Harald Weltec76f29f2017-11-22 12:46:46 +0100192 } else {
Harald Welte365f4ed2017-11-23 00:00:43 +0100193 l3.oddevenIndicator := '0'B;
Harald Welteae136252018-01-24 20:53:21 +0100194 l3.fillerDigit := '1111'B;
Harald Weltec76f29f2017-11-22 12:46:46 +0100195 }
196 l3.digits := digits;
197 return l3;
198}
199
Harald Welteba7b6d92018-01-23 21:32:34 +0100200private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {
201 var IMEI_L3 l3;
202 var integer len := lengthof(digits);
Neels Hofmeyr16617812020-06-10 17:31:18 +0200203 /* IMEI_L3 is always 15 digits. That is actually a 14 digit IMEI + a Luhn checksum digit (see
204 * libosmocore/include/osmocom/gsm/protocol/gsm_23_003.h)
205 *
206 * Here, we must not make the oddevenIndicator depend on the 'digits' parameter, because:
207 * - The IMEI_L3 template assumes always 15 digits.
208 * - The 'digits' parameter, however, may also contain less digits, 14 in the case of
209 * f_gen_imei().
210 * - The IMEI_L3 template will then fill up with zeros to make 15 digits.
211 * Hence oddevenIndicator must always indicate 'odd' == '1'B.
212 *
213 * FIXME: if the caller passes less than 15 digits, the Luhn checksum digit then ends up zero == most probably
214 * wrong.
215 */
216 l3.oddevenIndicator := '1'B;
Harald Welteba7b6d92018-01-23 21:32:34 +0100217 l3.digits := digits;
218 return l3;
219}
220
Harald Welteb0386df2018-02-16 18:14:28 +0100221private function f_enc_IMEI_SV(hexstring digits) return IMEI_SV {
222 var IMEI_SV l3;
223 var integer len := lengthof(digits);
224 if (len rem 2 == 1) { /* modulo remainder */
225 l3.oddevenIndicator := '1'B;
226 } else {
227 l3.oddevenIndicator := '0'B;
228 }
229 l3.digits := digits;
230 l3.fillerDigit := '1111'B;
231 return l3;
232}
233
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200234/* send template for Mobile Identity (IMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100235template (value) MobileIdentityLV ts_MI_IMSI_LV(hexstring imsi_digits) := {
236 lengthIndicator := 0, /* overwritten */
237 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100238 typeOfIdentity := '001'B,
Harald Weltec76f29f2017-11-22 12:46:46 +0100239 oddEvenInd_identity := {
240 imsi := f_enc_IMSI_L3(imsi_digits)
241 }
242 }
243}
244
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200245/* send template for Mobile Identity (IMEI) */
Harald Welteba7b6d92018-01-23 21:32:34 +0100246template (value) MobileIdentityLV ts_MI_IMEI_LV(hexstring imei_digits) := {
247 lengthIndicator := 0, /* overwritten */
248 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100249 typeOfIdentity := '010'B,
Harald Welteba7b6d92018-01-23 21:32:34 +0100250 oddEvenInd_identity := {
251 imei := f_enc_IMEI_L3(imei_digits)
252 }
253 }
254}
255
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200256/* send template for Mobile Identity (IMEISV) */
Harald Welteb0386df2018-02-16 18:14:28 +0100257template (value) MobileIdentityLV ts_MI_IMEISV_LV(hexstring imei_digits) := {
258 lengthIndicator := 0, /* overwritten */
259 mobileIdentityV := {
260 typeOfIdentity := '011'B,
261 oddEvenInd_identity := {
262 imei_sv := f_enc_IMEI_SV(imei_digits)
263 }
264 }
265}
266
Harald Welteba7b6d92018-01-23 21:32:34 +0100267
Harald Weltec76f29f2017-11-22 12:46:46 +0100268/* Send template for Classmark 2 */
269template (value) MobileStationClassmark2_LV ts_CM2 := {
270 lengthIndicator := 0,
271 rf_PowerCapability := '000'B,
272 a5_1 := '0'B,
273 esind := '1'B,
274 revisionLevel := '10'B,
275 spare1_1 := '0'B,
Harald Welte898113b2018-01-31 18:32:21 +0100276 mobileStationClassmark2_oct4 := {
277 fc := '1'B,
278 vgcs := '0'B,
279 vbs := '0'B,
280 sm_Capability := '1'B,
281 ss_ScreenIndicator := '01'B,
282 ps_Capability := '1'B,
283 spare2_1 := '0'B
284 },
285 mobileStationClassmark2_oct5 := {
286 a5_2 := '0'B,
287 a5_3 := '1'B,
288 cmsp := '0'B,
289 solsa := '0'B,
290 ucs2 := '0'B,
291 lcsva_cap := '0'B,
292 spare5_7 :='0'B,
293 cm3 := '0'B
294 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100295};
296
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200297template LocationUpdatingType LU_Type_Normal := {
298 lut := '00'B,
299 spare1_1 := '0'B,
300 fop := '0'B
301};
302
303template LocationUpdatingType LU_Type_Periodic := {
304 lut := '01'B,
305 spare1_1 := '0'B,
306 fop := '0'B
307};
308
309template LocationUpdatingType LU_Type_IMSI_Attach := {
310 lut := '10'B,
311 spare1_1 := '0'B,
312 fop := '0'B
313};
314
315/* Send template for LOCATION UPDATING REQUEST */
316template PDU_ML3_MS_NW ts_LU_REQ(template LocationUpdatingType lu_type, MobileIdentityLV mi_lv,
317 OCT3 mcc_mnc := '123456'O) := {
318 discriminator := '0000'B, /* overwritten */
319 tiOrSkip := {
320 skipIndicator := '0000'B
321 },
322 msgs := {
323 mm := {
324 locationUpdateRequest := {
325 messageType := '000000'B, /* overwritten */
326 nsd := '00'B,
327 locationUpdatingType := lu_type,
328 cipheringKeySequenceNumber := { '000'B, '0'B },
329 locationAreaIdentification := {
330 mcc_mnc := mcc_mnc,
331 lac := '172A'O
332 },
333 mobileStationClassmark1 := ts_CM1,
334 mobileIdentityLV := mi_lv,
335 classmarkInformationType2_forUMTS := omit,
336 additionalUpdateParameterTV := omit,
337 deviceProperties := omit,
338 mS_NetworkFeatureSupport := omit
339 }
340 }
341 }
342}
343
344template PDU_ML3_NW_MS ts_LU_ACCEPT(template MobileIdentityTLV mi_tlv := omit) := {
345 discriminator := '0000'B, /* overwritten */
346 tiOrSkip := {
347 skipIndicator := '0000'B
348 },
349 msgs := {
350 mm := {
351 locationUpdateAccept := {
352 messageType := '000000'B, /* overwritten */
353 nsd := '00'B,
354 locationAreaIdentification := {
355 mcc_mnc := '123456'O,
356 lac := '172A'O
357 },
358 mobileIdentityTLV := mi_tlv,
359 followOnProceed := omit,
360 cTS_Permission := omit,
361 equivalentPLMNs := omit,
362 emergencyNumberList := omit,
363 perMS_T3212 := omit
364 }
365 }
366 }
367}
368
Harald Weltec76f29f2017-11-22 12:46:46 +0100369/* Send template for CM SERVICE REQUEST */
Harald Welte6ed6bf92018-01-24 21:09:15 +0100370template (value) PDU_ML3_MS_NW ts_CM_SERV_REQ(CmServiceType serv_type, MobileIdentityLV mi_lv) := {
Harald Weltec76f29f2017-11-22 12:46:46 +0100371 discriminator := '0000'B, /* overwritten */
372 tiOrSkip := {
373 skipIndicator := '0000'B
374 },
375 msgs := {
376 mm := {
377 cMServiceRequest := {
378 messageType := '000000'B, /* overwritten */
379 nsd := '00'B,
Harald Welte6ed6bf92018-01-24 21:09:15 +0100380 cm_ServiceType := int2bit(enum2int(serv_type), 4),
Harald Weltec76f29f2017-11-22 12:46:46 +0100381 cipheringKeySequenceNumber := { '000'B, '0'B },
382 mobileStationClassmark2 := ts_CM2,
383 mobileIdentity := mi_lv,
384 priorityLevel := omit,
385 additionalUpdateParameterTV := omit,
386 deviceProperties := omit
387 }
388 }
389 }
390}
391
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100392template (value) PDU_ML3_NW_MS ts_CM_SERV_REJ(OCT1 rejectCause) := {
393 discriminator := '0000'B, /* overwritten */
394 tiOrSkip := {
395 skipIndicator := '0000'B
396 },
397 msgs := {
398 mm := {
399 cMServiceReject := {
400 messageType := '000000'B, /* overwritten */
401 nsd := '00'B,
402 rejectCause := rejectCause,
403 t3246_Value := omit
404 }
405 }
406 }
407}
408
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +0200409template (value) PDU_ML3_MS_NW ts_CM_REESTABL_REQ(MobileIdentityLV mi_lv) := {
410 discriminator := '0000'B, /* overwritten */
411 tiOrSkip := {
412 skipIndicator := '0000'B
413 },
414 msgs := {
415 mm := {
416 cMReEstablReq := {
417 messageType := '000000'B, /* overwritten */
418 nsd := '00'B,
419 cipheringKeySequenceNumber := { '000'B, '0'B },
420 spare := '0000'B,
421 mobileStationClassmark2 := ts_CM2,
422 mobileIdentityLV := mi_lv,
423 locationAreaIdentification := omit,
424 deviceProperties := omit
425 }
426 }
427 }
428}
429
Harald Welte0195ab12018-01-24 21:50:20 +0100430template (value) CipheringKeySequenceNumberV ts_CKSN(integer key_seq) := {
431 keySequence := int2bit(key_seq, 3),
432 spare := '0'B
433}
434
435/* Send template for CM RE-ESTABLISH REQUEST */
436template (value) PDU_ML3_MS_NW ts_CM_REEST_REQ(integer cksn, MobileIdentityLV mi_lv) := {
437 discriminator := '0000'B, /* overwritten */
438 tiOrSkip := {
439 skipIndicator := '0000'B
440 },
441 msgs := {
442 mm := {
443 cMReEstablReq := {
444 messageType := '101000'B, /* overwritten */
445 nsd := '00'B,
446 cipheringKeySequenceNumber := ts_CKSN(cksn),
447 spare := '0000'B,
448 mobileStationClassmark2 := ts_CM2,
449 mobileIdentityLV := mi_lv,
450 locationAreaIdentification := omit,
451 deviceProperties := omit
452 }
453 }
454 }
455}
456
457
Harald Welte6ff81902018-01-21 19:09:08 +0100458template PDU_ML3_NW_MS tr_MT_simple(template BIT4 discr := ?) := {
459 discriminator := discr,
460 tiOrSkip := {
461 skipIndicator := '0000'B
462 },
463 msgs := ?
464}
465
466
467template PDU_ML3_NW_MS tr_CM_SERV_ACC := {
468 discriminator := '0101'B,
469 tiOrSkip := {
470 skipIndicator := '0000'B
471 },
472 msgs := {
473 mm := {
474 cMServiceAccept := {
475 messageType := '100001'B,
476 nsd := ?
477 }
478 }
479 }
480}
481
482
Harald Weltecb6cc332018-01-21 13:59:08 +0100483template PDU_ML3_NW_MS tr_CM_SERV_REJ(template OCT1 rej_cause := ?) := {
484 discriminator := '0101'B,
485 tiOrSkip := {
486 skipIndicator := '0000'B
487 },
488 msgs := {
489 mm := {
490 cMServiceReject := {
491 messageType := '100010'B,
492 nsd := ?,
493 rejectCause := rej_cause,
494 t3246_Value := *
495 }
496 }
497 }
498}
499
Harald Welte68e495b2018-02-25 00:05:57 +0100500template PDU_ML3_NW_MS tr_PAGING_REQ1(template MobileIdentityLV mi1 := ?,
501 template MobileIdentityTLV mi2 := *) := {
502 discriminator := '0110'B,
503 tiOrSkip := {
504 skipIndicator := '0000'B
505 },
506 msgs := {
507 rrm := {
508 pagingReq_Type1 := {
509 messageType := '00100001'B,
510 pageMode := ?,
511 channelNeeded := ?,
512 mobileIdentity1 := mi1,
513 mobileIdentity2 := mi2,
514 p1RestOctets := ?
515 }
516 }
517 }
518}
519
520template PDU_ML3_NW_MS tr_PAGING_REQ2(template TMSIP_TMSI_V mi1 := ?,
521 template TMSIP_TMSI_V mi2 := ?,
522 template MobileIdentityTLV mi3 := *) := {
523 discriminator := '0110'B,
524 tiOrSkip := {
525 skipIndicator := '0000'B
526 },
527 msgs := {
528 rrm := {
529 pagingReq_Type2 := {
530 messageType := '00100010'B,
531 pageMode := ?,
532 channelNeeded := ?,
533 mobileIdentity1 := mi1,
534 mobileIdentity2 := mi2,
535 mobileIdentity3 := mi3,
536 p2RestOctets := ?
537 }
538 }
539 }
540}
541
542template PDU_ML3_NW_MS tr_PAGING_REQ3(template TMSIP_TMSI_V mi1 := ?,
543 template TMSIP_TMSI_V mi2 := ?,
544 template TMSIP_TMSI_V mi3 := ?,
545 template TMSIP_TMSI_V mi4 := ?) := {
546 discriminator := '0110'B,
547 tiOrSkip := {
548 skipIndicator := '0000'B
549 },
550 msgs := {
551 rrm := {
552 pagingReq_Type3 := {
553 messageType := '00100100'B,
554 pageMode := ?,
555 channelNeeded := ?,
556 mobileIdentity1 := mi1,
557 mobileIdentity2 := mi2,
558 mobileIdentity3 := mi3,
559 mobileIdentity4 := mi4,
560 p3RestOctets := ?
561 }
562 }
563 }
564}
565
566
567
Harald Weltec76f29f2017-11-22 12:46:46 +0100568/* Send template for PAGING RESPONSE */
569template (value) PDU_ML3_MS_NW ts_PAG_RESP(MobileIdentityLV mi_lv) := {
570 discriminator := '0000'B, /* overwritten */
571 tiOrSkip := {
572 skipIndicator := '0000'B
573 },
574 msgs := {
575 rrm := {
576 pagingResponse := {
577 messageType := '00000000'B, /* overwritten */
578 cipheringKeySequenceNumber := { '000'B, '0'B },
579 spare1_4 := '0000'B,
580 mobileStationClassmark := ts_CM2,
581 mobileIdentity := mi_lv,
582 additionalUpdateParameters := omit
583 }
584 }
585 }
586}
587
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200588template ChannelDescription2_V tr_ChannelDescription2_V(template BIT3 timeslotNumber := ?,
589 template BIT5 channelTypeandTDMAOffset := ?) := {
590 timeslotNumber := timeslotNumber,
591 channelTypeandTDMAOffset := channelTypeandTDMAOffset,
592 octet3 := ?,
593 octet4 := ?
594}
595
596template ChannelMode_V tr_ChannelMode_V(template OCT1 mode) := {
597 mode := mode
598}
599
600template ExtendedTSCSet_TV tr_ExtendedTSCSet_TV(template BIT2 cSDomainTSCSet := ?) := {
601 elementIdentifier := '6D'O,
602 cSDomainTSCSet := cSDomainTSCSet,
603 secondPSDomainTSCAssigned := ?,
604 primaryPSDomainTSCSet := ?,
605 secondaryPSDomainTSCSet := ?,
606 secondaryPSDomainTSCValue := ?
607}
608
609template PDU_ML3_NW_MS tr_RRM_ModeModify(template ChannelDescription2_V desc := ?,
610 template ChannelMode_V mode := ?,
611 template ExtendedTSCSet_TV extendedTSCSet) := {
612 discriminator := '0110'B,
613 tiOrSkip := {
614 skipIndicator := '0000'B
615 },
616 msgs := {
617 rrm := {
618 channelModeModify := {
619 messageType := '00010000'B,
620 channelDescription := desc,
621 channelMode := mode,
622 vGCS_TargetModeIndication := omit,
623 multiRateConfiguration := omit,
624 vGCS_Ciphering_Parameters := omit,
625 extendedTSCSet := extendedTSCSet
626 }
627 }
628 }
629}
630
631template (value) PDU_ML3_MS_NW ts_RRM_ModeModifyAck(ChannelDescription2_V desc, ChannelMode_V mode,
632 template (omit) ExtendedTSCSet_TV extendedTSCSet := omit) := {
Harald Welte15166142017-12-16 23:02:08 +0100633 discriminator := '0000'B, /* overwritten */
634 tiOrSkip := {
635 skipIndicator := '0000'B
636 },
637 msgs := {
638 rrm := {
639 channelModeModifyAck := {
640 messageType := '00010111'B,
641 channelDescription := desc,
642 channelMode := mode,
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200643 extendedTSCSet := extendedTSCSet
Harald Welte15166142017-12-16 23:02:08 +0100644 }
645 }
646 }
647}
648
Harald Weltee613f962018-04-18 22:38:16 +0200649template (value) PDU_ML3_NW_MS ts_RRM_CiphModeCmd(BIT3 alg_id) := {
650 discriminator := '0000'B, /* overwritten */
651 tiOrSkip := {
652 skipIndicator := '0000'B
653 },
654 msgs := {
655 rrm := {
656 cipheringModeCommand := {
657 messageType := '00110101'B,
658 cipherModeSetting := {
659 sC := '1'B,
660 algorithmIdentifier := alg_id
661 },
662 cipherModeResponse := {
663 cR := '0'B,
664 spare := '000'B
665 }
666 }
667 }
668 }
669}
670
Harald Welte73cd2712017-12-17 00:44:52 +0100671template (value) PDU_ML3_MS_NW ts_RRM_CiphModeCompl := {
672 discriminator := '0000'B, /* overwritten */
673 tiOrSkip := {
674 skipIndicator := '0000'B
675 },
676 msgs := {
677 rrm := {
678 cipheringModeComplete := {
679 messageType := '00110010'B,
680 mobileEquipmentIdentity := omit
681 }
682 }
683 }
684}
685
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200686template ChannelMode_TV tr_ChannelMode_TV(template OCT1 mode) := {
687 elementIdentifier := '63'O,
688 mode := mode
689}
690
691template (present) PDU_ML3_NW_MS tr_RR_AssignmentCommand(
692 template ChannelDescription2_V desc := ?,
693 template ChannelMode_TV mode := ?,
694 template ExtendedTSCSet_TV extendedTSCSet := omit
695) := {
696 discriminator := '0110'B,
697 tiOrSkip := {
698 skipIndicator := '0000'B
699 },
700 msgs := {
701 rrm := {
702 assignmentCommand := {
703 messageType := '00101110'B,
704 descrOf1stChAfterTime := desc,
705 PowerCommand := ?,
706 frequencyList_at := omit,
707 cellChannelDescr := omit,
708 descrMultislotAllocation := omit,
709 modeOf1stChannel := mode,
710 channelSet2 := omit,
711 channelSet3 := omit,
712 channelSet4 := omit,
713 channelSet5 := omit,
714 channelSet6 := omit,
715 channelSet7 := omit,
716 channelSet8 := omit,
717 descrOf2ndChAfterTime := omit,
718 modeOf2ndChannel := omit,
719 mobileAllocation_at := omit,
720 startingTime := omit,
721 frequencyList_bt := omit,
722 descrOf1stCh_bt := omit,
723 descrOf2ndCh_bt := omit,
724 frequencyChannelSequence := omit,
725 mobileAllocation_bt := omit,
726 cipherModeSetting := omit,
727 vGCS_TargetModeIndication := omit,
728 multiRateConfiguration := omit,
729 vGCS_Ciphering_Parameters := omit,
730 extendedTSCSet_afterTime := extendedTSCSet,
731 extendedTSCSet_beforeTime := omit
732 }
733 }
734 }
735}
736
Harald Welteecb254b2018-01-29 22:01:54 +0100737template (value) PDU_ML3_MS_NW ts_RRM_AssignmentComplete(OCT1 cause) := {
738 discriminator := '0000'B, /* overwritten */
739 tiOrSkip := {
740 skipIndicator := '0000'B
741 },
742 msgs := {
743 rrm := {
744 assignmentComplete := {
745 messageType := '00101001'B,
746 rR_Cause := {
747 valuePart := cause
748 }
749 }
750 }
751 }
752}
Harald Welte15166142017-12-16 23:02:08 +0100753
Harald Welte898113b2018-01-31 18:32:21 +0100754template (value) PDU_ML3_MS_NW ts_RRM_AssignmentFailure(OCT1 cause) := {
755 discriminator := '0000'B, /* overwritten */
756 tiOrSkip := {
757 skipIndicator := '0000'B
758 },
759 msgs := {
760 rrm := {
761 assignmentFailure := {
762 messageType := '00101111'B,
763 rR_Cause := {
764 valuePart := cause
765 }
766 }
767 }
768 }
769}
770
Harald Weltefbf9b5e2018-01-31 20:41:23 +0100771template (value) PDU_ML3_MS_NW ts_RRM_HandoverFailure(OCT1 cause) := {
772 discriminator := '0000'B, /* overwritten */
773 tiOrSkip := {
774 skipIndicator := '0000'B
775 },
776 msgs := {
777 rrm := {
778 handoverFailure := {
779 messageType := '00101000'B,
780 rRCause := {
781 valuePart := cause
782 },
783 pSCause := omit
784 }
785 }
786 }
787}
Harald Welte898113b2018-01-31 18:32:21 +0100788
Harald Welte261af4b2018-02-12 21:20:39 +0100789template (value) PDU_ML3_MS_NW ts_RRM_HandoverComplete(OCT1 cause) := {
790 discriminator := '0000'B, /* overwritten */
791 tiOrSkip := {
792 skipIndicator := '0000'B
793 },
794 msgs := {
795 rrm := {
796 handoverComplete := {
797 messageType := '00101100'B,
798 rRCause := {
799 valuePart := cause
800 },
801 mobileObsservedTimeDiff := omit,
802 mobileTimeDifferenceHyperframe := omit
803 }
804 }
805 }
806}
807
Harald Welte187f7a92019-09-05 11:15:20 +0200808template (present) PDU_ML3_NW_MS tr_RR_APP_INFO(template (present) BIT4 apdu_id,
809 template (present) octetstring data,
810 template (present) APDU_Flags_V flags := ?) := {
811 discriminator := '0000'B, /* overwritten */
812 tiOrSkip := {
813 skipIndicator := '0000'B
814 },
815 msgs := {
816 rrm := {
817 applicationInformation := {
818 messageType := '00111000'B,
819 aPDU_ID := apdu_id,
820 aPDU_Flags := flags,
821 aPDU_Data := {
822 lengthIndicator := ?,
823 aPDU_DataValue := data
824 }
825 }
826 }
827 }
828}
829
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100830template (value) PDU_ML3_NW_MS ts_RR_HandoverCommand := {
831 discriminator := '0110'B,
832 tiOrSkip := {
833 skipIndicator := '0000'B
834 },
835 msgs := {
836 rrm := {
837 handoverCommand := {
838 messageType := '00101011'B,
839 cellDescription := {
840 bcc := '001'B,
841 ncc := '010'B,
842 BCCHArfcn_HighPart := '11'B,
843 BCCHArfcn_LowPart := '04'O
844 },
845 channelDescription2 := {
846 timeslotNumber := '110'B,
847 channelTypeandTDMAOffset := '00001'B,
848 octet3 := '00'O,
849 octet4 := '09'O
850 },
851 handoverReference := {
852 handoverReferenceValue := '00'O
853 },
854 powerCommandAndAccesstype := {
855 powerlevel := '00000'B,
856 fPC_EP := '0'B,
857 ePC_Mode := '0'B,
858 aTC := '0'B
859 },
860 synchronizationIndication := omit,
861 frequencyShortListAfterTime := omit,
862 frequencyListAfterTime := omit,
863 cellChannelDescription := omit,
864 multislotAllocation := omit,
865 modeOfChannelSet1 := omit,
866 modeOfChannelSet2 := omit,
867 modeOfChannelSet3 := omit,
868 modeOfChannelSet4 := omit,
869 modeOfChannelSet5 := omit,
870 modeOfChannelSet6 := omit,
871 modeOfChannelSet7 := omit,
872 modeOfChannelSet8 := omit,
873 descrOf2ndCh_at := omit,
874 modeOf2ndChannel := omit,
875 frequencyChannelSequence_at := omit,
876 mobileAllocation_at := omit,
877 startingTime := omit,
878 timeDifference := omit,
879 timingAdvance := omit,
880 frequencyShortListBeforeTime := omit,
881 frequencyListBeforeTime := omit,
882 descrOf1stCh_bt := omit,
883 descrOf2ndCh_bt := omit,
884 frequencyChannelSequence_bt := omit,
885 mobileAllocation_bt := omit,
886 cipherModeSetting := omit,
887 vGCS_TargetModeIndication := omit,
888 multiRateConfiguration := omit,
889 dynamicARFCN_Mapping := omit,
890 vGCS_Ciphering_Parameters := omit,
891 dedicatedServiceInformation := omit,
892 pLMNIndex := omit,
893 extendedTSCSet_afterTime := omit,
894 extendedTSCSet_beforeTime := omit
895 }
896 }
897 }
898}
899
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200900template PDU_ML3_NW_MS tr_RR_HandoverCommand := {
901 discriminator := '0110'B,
902 tiOrSkip := {
903 skipIndicator := '0000'B
904 },
905 msgs := {
906 rrm := {
907 handoverCommand := {
908 messageType := '00101011'B,
909 cellDescription := ?,
910 channelDescription2 := ?,
911 handoverReference := ?,
912 powerCommandAndAccesstype := ?,
913 synchronizationIndication := *,
914 frequencyShortListAfterTime := *,
915 frequencyListAfterTime := *,
916 cellChannelDescription := *,
917 multislotAllocation := *,
918 modeOfChannelSet1 := *,
919 modeOfChannelSet2 := *,
920 modeOfChannelSet3 := *,
921 modeOfChannelSet4 := *,
922 modeOfChannelSet5 := *,
923 modeOfChannelSet6 := *,
924 modeOfChannelSet7 := *,
925 modeOfChannelSet8 := *,
926 descrOf2ndCh_at := *,
927 modeOf2ndChannel := *,
928 frequencyChannelSequence_at := *,
929 mobileAllocation_at := *,
930 startingTime := *,
931 timeDifference := *,
932 timingAdvance := *,
933 frequencyShortListBeforeTime := *,
934 frequencyListBeforeTime := *,
935 descrOf1stCh_bt := *,
936 descrOf2ndCh_bt := *,
937 frequencyChannelSequence_bt := *,
938 mobileAllocation_bt := *,
939 cipherModeSetting := *,
940 vGCS_TargetModeIndication := *,
941 multiRateConfiguration := *,
942 dynamicARFCN_Mapping := *,
943 vGCS_Ciphering_Parameters := *,
944 dedicatedServiceInformation := *,
945 pLMNIndex := *,
946 extendedTSCSet_afterTime := *,
947 extendedTSCSet_beforeTime := *
948 }
949 }
950 }
951}
952
Harald Welte898113b2018-01-31 18:32:21 +0100953function ts_CM3_TLV(template (omit) OCTN cm3) return template MobileStationClassmark3_TLV {
954 if (not isvalue(cm3)) {
955 return omit;
956 }
957 var template MobileStationClassmark3_TLV ret := {
958 elementIdentifier := '20'O,
959 lengthIndicator := 0, /* overwritten */
960 valuePart := cm3
961 }
962 return ret;
963}
964
965template (value) PDU_ML3_MS_NW ts_RRM_CM_CHG(MobileStationClassmark2_LV cm2,
966 template (omit) MobileStationClassmark3_TLV cm3 := omit) := {
967 discriminator := '0110'B,
968 tiOrSkip := {
969 skipIndicator := '0000'B
970 },
971 msgs := {
972 rrm := {
973 classmarkChange := {
974 messageType := '00010110'B,
975 mobileStationClassmark2 := cm2,
976 mobileStationClassmark3 := cm3
977 }
978 }
979 }
980}
981
Neels Hofmeyr92b12b72018-09-18 14:30:23 +0200982template PDU_ML3_NW_MS tr_RRM_CM_ENQUIRY := {
983 discriminator := '0110'B,
984 tiOrSkip := {
985 skipIndicator := '0000'B
986 },
987 msgs := {
988 rrm := {
989 classmarkEnquiry := {
990 messageType := '00010011'B,
991 classmarkEnquiryMask := *
992 }
993 }
994 }
995}
996
Harald Weltee3bd6582018-01-31 22:51:25 +0100997template (value) PDU_ML3_MS_NW ts_RRM_UL_REL(OCT1 cause) := {
998 discriminator := '0110'B,
999 tiOrSkip := {
1000 skipIndicator := '0000'B
1001 },
1002 msgs := {
1003 rrm := {
1004 uplinkRelease := {
1005 messageType := '00001110'B,
1006 rR_Cause := {
1007 valuePart := cause
1008 }
1009 }
1010 }
1011 }
1012}
1013
1014template PDU_ML3_MS_NW tr_RRM_RR_STATUS(template OCT1 cause := ?) := {
1015 discriminator := '0110'B,
1016 tiOrSkip := {
1017 skipIndicator := '0000'B
1018 },
1019 msgs := {
1020 rrm := {
1021 rR_Status := {
1022 messageType := '00010010'B,
1023 rR_Cause := {
1024 valuePart := cause
1025 }
1026 }
1027 }
1028 }
1029}
1030
Harald Welte924b6ea2019-02-04 01:05:34 +01001031template PDU_ML3_NW_MS tr_RRM_RR_RELEASE(template OCT1 cause := ?) := {
1032 discriminator := '0110'B,
1033 tiOrSkip := {
1034 skipIndicator := '0000'B
1035 },
1036 msgs := {
1037 rrm := {
1038 channelRelease := {
1039 messageType := '00001101'B,
1040 rRCause := {
1041 valuePart := cause
1042 },
1043 bARange := *,
1044 groupChannelDescription := *,
1045 groupCipherKeyNumber := *,
1046 gPRSResumption := *,
1047 bAListPref := *,
1048 uTRANFrequencyList := *,
1049 cellChannelDescr := *,
1050 cellSelectionIndicator := *,
1051 enhanced_DTM_CS_Release_Indication := *,
1052 vGCS_Ciphering_Parameters := *,
1053 group_Channel_Description_2 := *,
1054 talkerIdentity := *,
1055 talkerPriorityStatus := *,
1056 vGCS_AMR_Configuration := *,
1057 individual_Priorities := *
1058 }
1059 }
1060 }
1061}
Harald Weltee3bd6582018-01-31 22:51:25 +01001062
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001063template PDU_ML3_NW_MS tr_RRM_RR_RELEASE_CellSelectInd(template OCT1 cause := ?) modifies tr_RRM_RR_RELEASE := {
Harald Welte99787102019-02-04 10:41:36 +01001064 msgs := {
1065 rrm := {
1066 channelRelease := {
1067 cellSelectionIndicator := {
1068 elementIdentifier := '77'O,
1069 lengthIndicator := ?,
1070 cellSelectionIndicatorValue := ?
1071 }
1072 }
1073 }
1074 }
1075}
Harald Weltee3bd6582018-01-31 22:51:25 +01001076
Harald Weltecb6cc332018-01-21 13:59:08 +01001077template PDU_ML3_MS_NW ts_ML3_MO := {
1078 discriminator := '0000'B,
1079 tiOrSkip := {
1080 skipIndicator := '0000'B
1081 },
1082 msgs := ?
1083}
1084
1085template LocationUpdatingType ts_ML3_IE_LuType := {
1086 lut := ?,
1087 spare1_1 := '0'B,
1088 fop := '0'B
1089}
1090
1091template LocationUpdatingType ts_ML3_IE_LuType_Normal modifies ts_ML3_IE_LuType := {
1092 lut := '00'B
1093}
1094
1095template LocationUpdatingType ts_ML3_IE_LuType_Periodic modifies ts_ML3_IE_LuType := {
1096 lut := '01'B
1097}
1098
1099template LocationUpdatingType ts_ML3_IE_LuType_Attach modifies ts_ML3_IE_LuType := {
1100 lut := '10'B
1101}
1102
1103template CipheringKeySequenceNumberV ts_ML3_IE_CKSN(integer cksn) := {
1104 keySequence := int2bit(cksn, 3),
1105 spare := '0'B
1106}
1107
1108template PDU_ML3_MS_NW ts_ML3_MO_LU_Req(LocationUpdatingType lu_type, LocationAreaIdentification_V lai,
1109 MobileIdentityLV mi, MobileStationClassmark1_V cm1)
1110modifies ts_ML3_MO := {
1111 msgs := {
1112 mm := {
1113 locationUpdateRequest := {
1114 messageType := '001000'B,
1115 nsd := '00'B, /* ? */
1116 locationUpdatingType := lu_type,
1117 cipheringKeySequenceNumber := ts_ML3_IE_CKSN(0),
1118 locationAreaIdentification := lai,
1119 mobileStationClassmark1 := cm1,
1120 mobileIdentityLV := mi,
1121 classmarkInformationType2_forUMTS := omit,
1122 additionalUpdateParameterTV := omit,
1123 deviceProperties := omit,
1124 mS_NetworkFeatureSupport := omit
1125 }
1126 }
1127 }
1128}
1129
Harald Welte6ff81902018-01-21 19:09:08 +01001130template PDU_ML3_MS_NW ts_ML3_MO_TmsiRealloc_Cmpl modifies ts_ML3_MO := {
1131 msgs := {
1132 mm := {
1133 tmsiReallocComplete := {
1134 messageType := '011011'B,
1135 nsd := '00'B
1136 }
1137 }
1138 }
1139}
1140
1141template PDU_ML3_NW_MS tr_ML3_MT_LU_Acc := {
1142 discriminator := '0101'B,
1143 tiOrSkip := {
1144 skipIndicator := '0000'B
1145 },
1146 msgs := {
1147 mm := {
1148 locationUpdateAccept := {
1149 messageType := '000010'B,
1150 nsd := '00'B,
1151 locationAreaIdentification := ?,
1152 mobileIdentityTLV := *,
1153 followOnProceed := *,
1154 cTS_Permission := *,
1155 equivalentPLMNs := *,
1156 emergencyNumberList := *,
1157 perMS_T3212 := *
1158 }
1159 }
1160 }
1161}
1162
1163template PDU_ML3_NW_MS tr_ML3_MT_LU_Rej(template OCT1 cause := ?) := {
1164 discriminator := '0101'B,
1165 tiOrSkip := {
1166 skipIndicator := '0000'B
1167 },
1168 msgs := {
1169 mm := {
1170 locationUpdateReject := {
1171 messageType := '000100'B,
1172 nsd := '00'B,
1173 rejectCause := cause,
1174 t3246_Value := *
1175 }
1176 }
1177 }
1178}
1179
Oliver Smithaf2f1f82019-07-19 12:33:12 +02001180private function f_id_type_or_any(template CmIdentityType id_type) return template bitstring {
1181 if (istemplatekind(id_type, "?")) {
1182 return ?;
1183 } else {
1184 return int2bit(enum2int(valueof(id_type)), 3);
1185 }
1186}
1187
Oliver Smith32898452019-07-09 12:32:35 +02001188template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
Harald Welteba7b6d92018-01-23 21:32:34 +01001189 discriminator := '0101'B,
1190 tiOrSkip := {
1191 skipIndicator := '0000'B
1192 },
1193 msgs := {
1194 mm := {
1195 identityRequest := {
1196 messageType := '011000'B,
1197 nsd := '00'B,
Oliver Smithaf2f1f82019-07-19 12:33:12 +02001198 identityType := f_id_type_or_any(id_type),
Harald Welteba7b6d92018-01-23 21:32:34 +01001199 spare1_5 := ?
1200 }
1201 }
1202 }
1203}
1204
1205template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp(MobileIdentityLV mi) modifies ts_ML3_MO := {
1206 msgs := {
1207 mm := {
1208 identityResponse := {
1209 messageType := '011001'B,
1210 nsd := '00'B,
1211 mobileIdentityLV := mi,
1212 p_TMSI_TypeTV := omit,
1213 routingAreaIdentification2TLV := omit,
1214 p_TMSISignature2TLV := omit
1215 }
1216 }
1217 }
1218}
1219template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMSI(hexstring imsi) :=
1220 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMSI_LV(imsi)));
1221template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMEI(hexstring imei) :=
1222 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMEI_LV(imei)));
1223
1224
Neels Hofmeyr63382472018-03-01 19:57:44 +01001225template (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 +01001226 rf_PowerCapability := '010'B,
1227 a5_1 := a5_1_unavail,
Neels Hofmeyr63382472018-03-01 19:57:44 +01001228 esind := esind,
Harald Welte45164da2018-01-24 12:51:27 +01001229 revisionLevel := rev,
1230 spare1_1 := '0'B
1231}
1232
1233template PDU_ML3_MS_NW ts_ML3_MO_MM_IMSI_DET_Ind(MobileIdentityLV mi,
1234 template MobileStationClassmark1_V cm1 := ts_CM1)
1235modifies ts_ML3_MO := {
1236 msgs := {
1237 mm := {
1238 imsiDetachIndication := {
1239 messageType := '000001'B,
1240 nsd := '00'B,
1241 mobileStationClassmark1 := cm1,
1242 mobileIdentityLV := mi
1243 }
1244 }
1245 }
1246}
1247
Harald Welted748a052018-01-22 02:59:24 +01001248template PDU_ML3_MS_NW ts_ML3_MO_CC(integer tid) := {
1249 discriminator := '0011'B,
1250 tiOrSkip := {
1251 transactionId := {
Daniel Willmanndcf9eb92018-02-02 20:07:52 +01001252 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001253 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001254 tIExtension := omit
1255 }
Harald Welte9bf43cc2020-08-21 12:33:18 +02001256 },
1257 msgs := -
Harald Welted748a052018-01-22 02:59:24 +01001258}
1259
1260template (value) CalledPartyBCD_Number ts_Called(hexstring digits) := {
1261 elementIdentifier := '5E'O,
1262 lengthIndicator := 0, /* overwritten */
1263 numberingPlanIdentification := '0000'B,
1264 typeOfNumber := '000'B, /* unknown */
Vadim Yanitskiy559f5dc2021-02-05 03:08:11 +01001265 ext1 := '1'B, /* no extension */
Harald Welted748a052018-01-22 02:59:24 +01001266 digits := digits
1267}
1268
Harald Welte812f7a42018-01-27 00:49:18 +01001269template CalledPartyBCD_Number tr_Called(template hexstring digits) := {
1270 elementIdentifier := '5E'O,
1271 lengthIndicator := ?,
1272 numberingPlanIdentification := ?,
1273 typeOfNumber := ?,
Vadim Yanitskiy559f5dc2021-02-05 03:08:11 +01001274 ext1 := '1'B, /* no extension */
Harald Welte812f7a42018-01-27 00:49:18 +01001275 digits := digits
1276}
1277
Stefan Sperling26d57be2018-11-12 17:03:26 +01001278private function f_pad_digits(hexstring digits) return hexstring {
1279 if (lengthof(digits) mod 2 != 0) {
1280 /* Add trailing nibble of 1-bit padding, like the CallingPartyBCD_Number encoder would do.
1281 * Otherwise our template won't match the data received (see OS#2930). */
1282 return digits & 'F'H;
1283 }
1284 return digits;
1285}
1286
Harald Welte812f7a42018-01-27 00:49:18 +01001287template CallingPartyBCD_Number tr_Calling(template hexstring digits) := {
1288 elementIdentifier := '5C'O,
1289 lengthIndicator := ?,
1290 oct3 := ?,
Stefan Sperling26d57be2018-11-12 17:03:26 +01001291 digits := f_pad_digits(valueof(digits))
Harald Welte812f7a42018-01-27 00:49:18 +01001292}
1293
Harald Welte4b2b3a62018-01-26 10:32:39 +01001294type integer SpeechVer;
1295
1296template (value) Speech_AuxiliarySpeech ts_SpeechAux(SpeechVer ver, BIT1 suffix) := {
1297 speechVersionIndication := int2bit(ver-1,3) & suffix,
1298 spare1_1 := '0'B,
1299 cTM_or_Spare := '0'B,
1300 coding := '0'B,
1301 extension_octet_3a_3b := '0'B
1302}
1303
1304template (value) Speech_AuxiliarySpeech ts_SpeechAuxFR(SpeechVer ver) := ts_SpeechAux(ver, '0'B);
1305template (value) Speech_AuxiliarySpeech ts_SpeechAuxHR(SpeechVer ver) := ts_SpeechAux(ver, '1'B);
1306
Harald Welted748a052018-01-22 02:59:24 +01001307template (value) BearerCapability_TLV ts_Bcap_voice := {
1308 elementIdentifier := '04'O,
1309 lengthIndicator := 0, /* overwritten */
1310 octet3 := {
1311 informationTransferCapability := '000'B,
1312 transferMode := '0'B,
1313 codingStandard := '0'B,
1314 radioChannelRequirement := '11'B, /* FR preferred */
1315 extension_octet_3 := '0'B, /* overwritten */
Harald Welte4b2b3a62018-01-26 10:32:39 +01001316 speech_aux_3a_3b := {
1317 valueof(ts_SpeechAuxHR(3)),
1318 valueof(ts_SpeechAuxFR(3)),
1319 valueof(ts_SpeechAuxFR(2)),
1320 valueof(ts_SpeechAuxFR(1)),
1321 valueof(ts_SpeechAuxHR(1))
1322 }
Harald Welted748a052018-01-22 02:59:24 +01001323 },
1324 octet4 := omit,
1325 octet5 := omit,
1326 octet6 := omit,
1327 octet7 := omit
1328}
1329
1330template PDU_ML3_MS_NW ts_ML3_MO_CC_SETUP(integer tid, hexstring called, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1331 discriminator := '0011'B,
1332 tiOrSkip := {
1333 transactionId := {
1334 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001335 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001336 tIExtension := omit
1337 }
1338 },
1339 msgs := {
1340 cc := {
1341 setup_MS_NW := {
1342 messageType := '000101'B,
1343 nsd := '00'B,
1344 bcRepeatIndicator := omit,
1345 bearerCapability1 := bcap,
1346 bearerCapability2 := omit,
1347 facility := omit,
1348 callingPartySubAddress := omit,
1349 calledPartyBCD_Number := ts_Called(called),
1350 calledPartySubAddress := omit,
1351 llc_RepeatIndicator := omit,
1352 lowLayerCompatibility1 := omit,
1353 lowLayerCompatibility2 := omit,
1354 hlc_RepeatIndicator := omit,
1355 highLayerCompatibility1 := omit,
1356 highLayerCompatibility2 := omit,
1357 user_user := omit,
1358 ss_VersionIndicator := omit,
1359 clir_Suppression := omit,
1360 clir_Invocation := omit,
1361 cC_Capabilities := omit,
1362 facility_ccbs1 := omit,
1363 facility_ccbs2 := omit,
1364 streamIdentifier := omit,
1365 supportedCodecs := omit,
1366 redial := omit
1367 }
1368 }
1369 }
1370}
1371
Harald Welte45164da2018-01-24 12:51:27 +01001372template PDU_ML3_MS_NW ts_ML3_MO_CC_EMERG_SETUP(integer tid, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1373 discriminator := '0011'B,
1374 tiOrSkip := {
1375 transactionId := {
1376 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001377 tiFlag := c_TIF_ORIG,
Harald Welte45164da2018-01-24 12:51:27 +01001378 tIExtension := omit
1379 }
1380 },
1381 msgs := {
1382 cc := {
1383 emergencySetup := {
1384 messageType := '001110'B,
1385 nsd := '00'B,
1386 bearerCapability := bcap,
1387 streamIdentifier := omit,
1388 supportedCodecs := omit,
1389 emergencyCategory := omit
1390 }
1391 }
1392 }
1393}
1394
1395
Harald Welted748a052018-01-22 02:59:24 +01001396template PDU_ML3_NW_MS tr_ML3_MT_CC_CALL_PROC(integer tid) := {
1397 discriminator := '0011'B,
1398 tiOrSkip := {
1399 transactionId := {
1400 tio := int2bit(tid, 3),
1401 tiFlag := ?,
1402 tIExtension := omit
1403 }
1404 },
1405 msgs := {
1406 cc := {
1407 callProceeding := {
1408 messageType := '000010'B,
1409 nsd := '00'B,
1410 repeatIndicator := *,
1411 bearerCapability1 := *,
1412 bearerCapability2 := *,
1413 facility := *,
1414 progressIndicator := *,
1415 priorityGranted := *,
1416 networkCCCapabilities := *
1417 }
1418 }
1419 }
1420}
1421
1422template PDU_ML3_NW_MS tr_ML3_MT_CC_ALERTING(integer tid) := {
1423 discriminator := '0011'B,
1424 tiOrSkip := {
1425 transactionId := {
1426 tio := int2bit(tid, 3),
1427 tiFlag := ?,
1428 tIExtension := omit
1429 }
1430 },
1431 msgs := {
1432 cc := {
1433 alerting_NW_MS := {
1434 messageType := '000001'B,
1435 nsd := '00'B,
1436 facility := *,
1437 progressIndicator := *,
1438 user_user := *
1439 }
1440 }
1441 }
1442}
1443
Harald Welte33ec09b2018-02-10 15:34:46 +01001444template PDU_ML3_MS_NW ts_ML3_MO_CC_ALERTING(integer tid) := {
1445 discriminator := '0011'B,
1446 tiOrSkip := {
1447 transactionId := {
1448 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001449 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001450 tIExtension := omit
1451 }
1452 },
1453 msgs := {
1454 cc := {
1455 alerting_MS_NW := {
1456 messageType := '000001'B,
1457 nsd := '00'B,
1458 facility := omit,
1459 user_user := omit,
1460 ss_VersionIndicator := omit
1461 }
1462 }
1463 }
1464}
1465
1466template PDU_ML3_MS_NW ts_ML3_MT_CC_ALERTING(integer tid) := {
1467 discriminator := '0011'B,
1468 tiOrSkip := {
1469 transactionId := {
1470 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001471 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001472 tIExtension := omit
1473 }
1474 },
1475 msgs := {
1476 cc := {
1477 alerting_MS_NW := {
1478 messageType := '000001'B,
1479 nsd := '00'B,
1480 facility := omit,
1481 user_user := omit,
1482 ss_VersionIndicator := omit
1483 }
1484 }
1485 }
1486}
1487
1488template PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT(integer tid) := {
1489 discriminator := '0011'B,
1490 tiOrSkip := {
1491 transactionId := {
1492 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001493 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001494 tIExtension := omit
1495 }
1496 },
1497 msgs := {
1498 cc := {
1499 connect_MS_NW := {
1500 messageType := '000111'B,
1501 nsd := '00'B,
1502 facility := omit,
1503 connectedSubAddress := omit,
1504 user_user := omit,
1505 ss_VersionIndicator := omit,
1506 streamIdentifier := omit
1507 }
1508 }
1509 }
1510}
1511
Harald Welte4017d552018-01-26 21:40:05 +01001512template PDU_ML3_NW_MS tr_ML3_MT_CC_CONNECT(integer tid) := {
1513 discriminator := '0011'B,
1514 tiOrSkip := {
1515 transactionId := {
1516 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001517 tiFlag := c_TIF_REPL,
Harald Welte4017d552018-01-26 21:40:05 +01001518 tIExtension := omit
1519 }
1520 },
1521 msgs := {
1522 cc := {
1523 connect_NW_MS := {
1524 messageType := '000111'B,
1525 nsd := '00'B,
1526 facility := *,
1527 progressIndicator := *,
1528 connectedNumber := *,
1529 connectedSubAddress := *,
1530 user_user := *
1531 }
1532 }
1533 }
1534}
1535
1536template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT_ACK(integer tid) := {
1537 discriminator := '0011'B,
1538 tiOrSkip := {
1539 transactionId := {
1540 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001541 tiFlag := c_TIF_ORIG,
Harald Welte4017d552018-01-26 21:40:05 +01001542 tIExtension := omit
1543 }
1544 },
1545 msgs := {
1546 cc := {
1547 connectAck := {
1548 messageType := '001111'B,
1549 nsd := '00'B
1550 }
1551 }
1552 }
1553}
1554
Daniel Willmann8b084372018-02-04 13:35:26 +01001555template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_START_DTMF(integer tid, charstring number) := {
1556 discriminator := '0011'B,
1557 tiOrSkip := {
1558 transactionId := {
1559 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001560 tiFlag := c_TIF_ORIG,
Daniel Willmann8b084372018-02-04 13:35:26 +01001561 tIExtension := omit
1562 }
1563 },
1564 msgs := {
1565 cc := {
1566 startDTMF := {
1567 messageType := '110101'B,
1568 nsd := '00'B,
1569 keypadFacility := {
1570 elementIdentifier := '2C'O,
1571 keypadInformation := int2bit(char2int(number), 7),
1572 spare_1 := '0'B
1573 }
1574 }
1575 }
1576 }
1577}
1578
Harald Welte2bb825f2018-01-22 11:31:18 +01001579template PDU_ML3_NW_MS tr_ML3_MT_CC_DISC(integer tid) := {
1580 discriminator := '0011'B,
1581 tiOrSkip := {
1582 transactionId := {
1583 tio := int2bit(tid, 3),
1584 tiFlag := ?,
1585 tIExtension := omit
1586 }
1587 },
1588 msgs := {
1589 cc := {
1590 disconnect_NW_MS := {
1591 messageType := '100101'B,
1592 nsd := '00'B,
1593 cause := ?,
1594 facility := *,
1595 progressIndicator := *,
1596 user_user := *,
1597 allowedActions := *
1598 }
1599 }
1600 }
1601}
1602
Neels Hofmeyre51ce492021-07-27 22:30:08 +02001603template PDU_ML3_MS_NW ts_ML3_MO_CC_DISC(integer tid, BIT1 tid_remote, BIT7 cause) := {
1604 discriminator := '0011'B,
1605 tiOrSkip := {
1606 transactionId := {
1607 tio := int2bit(tid, 3),
1608 tiFlag := tid_remote,
1609 tIExtension := omit
1610 }
1611 },
1612 msgs := {
1613 cc := {
1614 disconnect_MS_NW := {
1615 messageType := '100101'B,
1616 nsd := '00'B,
1617 cause := ts_ML3_Cause_LV(cause),
1618 facility := omit,
1619 user_user := omit,
1620 ss_VersionIndicator := omit
1621 }
1622 }
1623 }
1624}
1625
Harald Welte2bb825f2018-01-22 11:31:18 +01001626template PDU_ML3_NW_MS tr_ML3_MT_CC_RELEASE(integer tid) := {
1627 discriminator := '0011'B,
1628 tiOrSkip := {
1629 transactionId := {
1630 tio := int2bit(tid, 3),
1631 tiFlag := ?,
1632 tIExtension := omit
1633 }
1634 },
1635 msgs := {
1636 cc := {
1637 release_NW_MS := {
1638 messageType := '101101'B,
1639 nsd := '00'B,
1640 cause := ?,
1641 secondCause := *,
1642 facility := *,
1643 user_user := *
1644 }
1645 }
1646 }
1647}
Harald Welted748a052018-01-22 02:59:24 +01001648
Harald Welte33ec09b2018-02-10 15:34:46 +01001649template PDU_ML3_MS_NW ts_ML3_MO_CC_RELEASE(integer tid, BIT1 tid_remote, BIT7 cause) := {
1650 discriminator := '0011'B,
1651 tiOrSkip := {
1652 transactionId := {
1653 tio := int2bit(tid, 3),
1654 tiFlag := tid_remote,
1655 tIExtension := omit
1656 }
1657 },
1658 msgs := {
1659 cc := {
1660 release_MS_NW := {
1661 messageType := '101101'B,
1662 nsd := '00'B,
1663 cause := ts_ML3_Cause(cause),
1664 secondCause := omit,
1665 facility := omit,
1666 user_user := omit,
1667 ss_VersionIndicator := omit
1668 }
1669 }
1670 }
1671}
1672
1673
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001674template (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 +01001675 discriminator := '0011'B,
1676 tiOrSkip := {
1677 transactionId := {
1678 tio := int2bit(tid, 3),
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001679 tiFlag := tid_remote,
Harald Welteb71901a2018-01-26 19:16:05 +01001680 tIExtension := omit
1681 }
1682 },
1683 msgs := {
1684 cc := {
1685 releaseComplete_MS_NW := {
1686 messageType := '101010'B,
1687 nsd := '00'B,
1688 cause := omit,
1689 facility := omit,
1690 user_user := omit,
1691 ss_VersionIndicator := omit
1692 }
1693 }
1694 }
1695}
1696
Harald Welte33ec09b2018-02-10 15:34:46 +01001697template PDU_ML3_NW_MS tr_ML3_MT_CC_REL_COMPL(integer tid) := {
1698 discriminator := '0011'B,
1699 tiOrSkip := {
1700 transactionId := {
1701 tio := int2bit(tid, 3),
1702 tiFlag := ?,
1703 tIExtension := omit
1704 }
1705 },
1706 msgs := {
1707 cc := {
1708 releaseComplete_NW_MS := {
1709 messageType := '101010'B,
1710 nsd := '00'B,
1711 cause := *,
1712 facility := *,
1713 user_user := *
1714 }
1715 }
1716 }
1717}
1718
1719
Harald Welteb71901a2018-01-26 19:16:05 +01001720
Harald Welte77a8eba2018-01-22 21:22:32 +01001721template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ(template OCT16 rand := ?) := {
1722 discriminator := '0101'B,
1723 tiOrSkip := {
1724 skipIndicator := '0000'B
1725 },
1726 msgs := {
1727 mm := {
1728 authenticationRequest := {
1729 messageType := '010010'B,
1730 nsd := '00'B,
1731 cipheringKeySequenceNumber := ?,
1732 spare2_4 := ?,
1733 authenticationParRAND := rand,
1734 authenticationParAUTN := *
1735 }
1736 }
1737 }
1738}
1739
Harald Welte0cedf2c2018-10-28 23:28:35 +01001740template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ_3G(template OCT16 rand := ?, template OCT16 autn) := {
1741 discriminator := '0101'B,
1742 tiOrSkip := {
1743 skipIndicator := '0000'B
1744 },
1745 msgs := {
1746 mm := {
1747 authenticationRequest := {
1748 messageType := '010010'B,
1749 nsd := '00'B,
1750 cipheringKeySequenceNumber := ?,
1751 spare2_4 := ?,
1752 authenticationParRAND := rand,
1753 authenticationParAUTN := {
1754 elementIdentifier := '20'O,
1755 lengthIndicator := ?,
1756 autnValue := autn
1757 }
1758 }
1759 }
1760 }
1761}
1762
Harald Welte77a8eba2018-01-22 21:22:32 +01001763template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_2G(OCT4 sres) := {
1764 discriminator := '0101'B,
1765 tiOrSkip := {
1766 skipIndicator := '0000'B
1767 },
1768 msgs := {
1769 mm := {
1770 authenticationResponse := {
1771 messageType := '010100'B,
1772 nsd := '00'B,
1773 authenticationParSRES := sres,
1774 authenticationParSRESext := omit
1775 }
1776 }
1777 }
1778}
1779
1780template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_3G(OCT4 sres, octetstring res) := {
1781 discriminator := '0101'B,
1782 tiOrSkip := {
1783 skipIndicator := '0000'B
1784 },
1785 msgs := {
1786 mm := {
1787 authenticationResponse := {
1788 messageType := '010100'B,
1789 nsd := '00'B,
1790 authenticationParSRES := sres,
1791 authenticationParSRESext := {
1792 elementIdentifier := '21'O,
1793 lengthIndicator := 0, /* overwritten */
1794 valueField := res
1795 }
1796 }
1797 }
1798 }
1799}
Harald Weltecb6cc332018-01-21 13:59:08 +01001800
Harald Welte812f7a42018-01-27 00:49:18 +01001801template PDU_ML3_MS_NW ts_ML3_MO_CC_CALL_CONF(integer tid,
1802 template BearerCapability_TLV bcap := omit) := {
1803 discriminator := '0011'B,
1804 tiOrSkip := {
1805 transactionId := {
1806 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001807 tiFlag := c_TIF_REPL, /* response from destination */
Harald Welte812f7a42018-01-27 00:49:18 +01001808 tIExtension := omit
1809 }
1810 },
1811 msgs := {
1812 cc := {
1813 callConfirmed := {
1814 messageType := '001000'B,
1815 nsd := '00'B,
1816 repeatIndicator := omit,
1817 bearerCapability1 := bcap,
1818 bearerCapability2 := omit,
1819 cause := omit,
1820 cC_Capabilities := omit,
1821 streamIdentifier := omit,
1822 supportedCodecs := omit
1823 }
1824 }
1825 }
1826}
1827
1828
1829template PDU_ML3_NW_MS tr_ML3_MT_CC_SETUP(integer tid, template hexstring called := *,
1830 template hexstring calling := *,
1831 template BearerCapability_TLV bcap := *) := {
1832 discriminator := '0011'B,
1833 tiOrSkip := {
1834 transactionId := {
1835 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001836 tiFlag := c_TIF_ORIG, /* from originator */
Harald Welte812f7a42018-01-27 00:49:18 +01001837 tIExtension := omit
1838 }
1839 },
1840 msgs := {
1841 cc := {
1842 setup_NW_MS := {
1843 messageType := '000101'B,
1844 nsd := '00'B,
1845 bcRepeatIndicator := *,
1846 bearerCapability1 := bcap,
1847 bearerCapability2 := *,
1848 facility := *,
1849 progressIndicator := *,
1850 signal := *,
1851 callingPartyBCD_Number := tr_Calling(calling) ifpresent,
1852 callingPartySubAddress := *,
1853 calledPartyBCD_Number := tr_Called(called) ifpresent,
1854 calledPartySubAddress := *,
1855 redirectingPartyBCDNumber := *,
1856 redirectingPartySubaddress := *,
1857 llc_RepeatIndicator := *,
1858 lowLayerCompatibility1 := *,
1859 lowLayerCompatibility2 := *,
1860 hlc_RepeatIndicator := *,
1861 highLayerCompatibility1 := *,
1862 highLayerCompatibility2 := *,
1863 user_user := *,
1864 priority := *,
1865 alert := *,
1866 networkCCCapabilities := *,
1867 causeofNoCli := *,
1868 backupBearerCapacity := *
1869 }
1870 }
1871 }
1872}
1873
Harald Welte38575a72018-02-15 20:41:37 +01001874/***********************************************************************
Harald Welte53603962018-05-28 11:13:09 +02001875 * Supplementary Services
1876 ***********************************************************************/
1877
1878private template (value) Facility_TLV ts_FacTLV(OCTN facility) := {
1879 elementIdentifier := '1C'O,
1880 lengthIndicator := lengthof(facility),
1881 facilityInformation := facility
1882}
1883private template Facility_TLV tr_FacTLV(template OCTN facility) := {
1884 elementIdentifier := '1C'O,
1885 lengthIndicator := ?,
1886 facilityInformation := facility
1887}
1888
1889private template (value) Facility_LV ts_FacLV(OCTN facility) := {
1890 lengthIndicator := lengthof(facility),
1891 facilityInformation := facility
1892}
1893private template Facility_LV tr_FacLV(template OCTN facility) := {
1894 lengthIndicator := ?,
1895 facilityInformation := facility
1896}
1897
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001898private function f_facility_or_omit(template (omit) OCTN facility)
1899return template (omit) Facility_TLV {
1900 if (istemplatekind(facility, "omit")) {
1901 return omit;
1902 } else {
1903 return ts_FacTLV(valueof(facility));
1904 }
1905}
1906private function f_facility_or_wc(template OCTN facility)
1907return template Facility_TLV {
1908 if (istemplatekind(facility, "*")) {
1909 return *;
1910 } else if (istemplatekind(facility, "?")) {
1911 return ?;
Vadim Yanitskiy52f8b6e2018-06-19 17:32:46 +07001912 } else if (istemplatekind(facility, "omit")) {
1913 return omit;
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001914 } else {
1915 return tr_FacTLV(facility);
1916 }
1917}
1918
Harald Welte53603962018-05-28 11:13:09 +02001919template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_REGISTER(
1920 uint3_t tid, BIT1 ti_flag,
1921 OCTN facility,
1922 template (omit) SS_VersionIndicator ss_ver := omit
1923) := {
1924 discriminator := '1011'B,
1925 tiOrSkip := {
1926 transactionId := {
1927 tio := int2bit(tid, 3),
1928 tiFlag := ti_flag,
1929 tIExtension := omit
1930 }
1931 },
1932 msgs := {
1933 ss := {
1934 register := {
1935 messageType := '111011'B,
1936 nsd := '00'B,
1937 facility := ts_FacTLV(facility),
1938 ss_version := ss_ver
1939 }
1940 }
1941 }
1942}
1943template PDU_ML3_MS_NW tr_ML3_MO_SS_REGISTER(
1944 template uint3_t tid, template BIT1 ti_flag,
1945 template OCTN facility,
1946 template SS_VersionIndicator ss_ver := omit
1947) := {
1948 discriminator := '1011'B,
1949 tiOrSkip := {
1950 transactionId := {
1951 tio := f_tid_or_wc(tid),
1952 tiFlag := ti_flag,
1953 tIExtension := omit
1954 }
1955 },
1956 msgs := {
1957 ss := {
1958 register := {
1959 messageType := '111011'B,
1960 nsd := '00'B,
1961 facility := tr_FacTLV(facility),
1962 ss_version := ss_ver
1963 }
1964 }
1965 }
1966}
1967
1968template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_REGISTER(
1969 uint3_t tid, BIT1 ti_flag,
1970 OCTN facility
1971) := {
1972 discriminator := '1011'B,
1973 tiOrSkip := {
1974 transactionId := {
1975 tio := int2bit(tid, 3),
1976 tiFlag := ti_flag,
1977 tIExtension := omit
1978 }
1979 },
1980 msgs := {
1981 ss := {
1982 register := {
1983 messageType := '111011'B,
1984 nsd := '00'B,
1985 facility := ts_FacTLV(facility)
1986 }
1987 }
1988 }
1989}
1990template PDU_ML3_NW_MS tr_ML3_MT_SS_REGISTER(
1991 template uint3_t tid, template BIT1 ti_flag,
1992 template OCTN facility
1993) := {
1994 discriminator := '1011'B,
1995 tiOrSkip := {
1996 transactionId := {
1997 tio := f_tid_or_wc(tid),
1998 tiFlag := ti_flag,
1999 tIExtension := omit
2000 }
2001 },
2002 msgs := {
2003 ss := {
2004 register := {
2005 messageType := '111011'B,
2006 nsd := '00'B,
2007 facility := tr_FacTLV(facility)
2008 }
2009 }
2010 }
2011}
2012
2013template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_FACILITY(
2014 uint3_t tid, BIT1 ti_flag,
2015 OCTN facility
2016) := {
2017 discriminator := '1011'B,
2018 tiOrSkip := {
2019 transactionId := {
2020 tio := int2bit(tid, 3),
2021 tiFlag := ti_flag,
2022 tIExtension := omit
2023 }
2024 },
2025 msgs := {
2026 ss := {
2027 facility := {
2028 messageType := '111010'B,
2029 nsd := '00'B,
2030 facility := ts_FacLV(facility)
2031 }
2032 }
2033 }
2034}
2035template PDU_ML3_MS_NW tr_ML3_MO_SS_FACILITY(
2036 template uint3_t tid, template BIT1 ti_flag,
2037 template OCTN facility
2038) := {
2039 discriminator := '1011'B,
2040 tiOrSkip := {
2041 transactionId := {
2042 tio := f_tid_or_wc(tid),
2043 tiFlag := ti_flag,
2044 tIExtension := omit
2045 }
2046 },
2047 msgs := {
2048 ss := {
2049 facility := {
2050 messageType := '111010'B,
2051 nsd := '00'B,
2052 facility := tr_FacLV(facility)
2053 }
2054 }
2055 }
2056}
2057
2058template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_FACILITY(
2059 uint3_t tid, BIT1 ti_flag,
2060 OCTN facility
2061) := {
2062 discriminator := '1011'B,
2063 tiOrSkip := {
2064 transactionId := {
2065 tio := int2bit(tid, 3),
2066 tiFlag := ti_flag,
2067 tIExtension := omit
2068 }
2069 },
2070 msgs := {
2071 ss := {
2072 facility := {
2073 messageType := '111010'B,
2074 nsd := '00'B,
2075 facility := ts_FacLV(facility)
2076 }
2077 }
2078 }
2079}
2080template PDU_ML3_NW_MS tr_ML3_MT_SS_FACILITY(
2081 template uint3_t tid, template BIT1 ti_flag,
2082 template OCTN facility
2083) := {
2084 discriminator := '1011'B,
2085 tiOrSkip := {
2086 transactionId := {
2087 tio := f_tid_or_wc(tid),
2088 tiFlag := ti_flag,
2089 tIExtension := omit
2090 }
2091 },
2092 msgs := {
2093 ss := {
2094 facility := {
2095 messageType := '111010'B,
2096 nsd := '00'B,
2097 facility := tr_FacLV(facility)
2098 }
2099 }
2100 }
2101}
2102
Vadim Yanitskiy03198132018-05-29 03:35:16 +07002103template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_RELEASE_COMPLETE(
2104 uint3_t tid, BIT1 ti_flag,
2105 template (omit) ML3_Cause_TLV cause := omit,
2106 template (omit) OCTN facility := omit
2107) := {
2108 discriminator := '1011'B,
2109 tiOrSkip := {
2110 transactionId := {
2111 tio := int2bit(tid, 3),
2112 tiFlag := ti_flag,
2113 tIExtension := omit
2114 }
2115 },
2116 msgs := {
2117 ss := {
2118 releaseComplete_MS_NW := {
2119 messageType := '101010'B,
2120 nsd := '00'B,
2121 cause := cause,
2122 facility := f_facility_or_omit(facility)
2123 }
2124 }
2125 }
2126}
2127template PDU_ML3_MS_NW tr_ML3_MO_SS_RELEASE_COMPLETE(
2128 template uint3_t tid, template BIT1 ti_flag,
2129 template ML3_Cause_TLV cause := *,
2130 template OCTN facility := *
2131) := {
2132 discriminator := '1011'B,
2133 tiOrSkip := {
2134 transactionId := {
2135 tio := f_tid_or_wc(tid),
2136 tiFlag := ti_flag,
2137 tIExtension := omit
2138 }
2139 },
2140 msgs := {
2141 ss := {
2142 releaseComplete_MS_NW := {
2143 messageType := '101010'B,
2144 nsd := '00'B,
2145 cause := cause,
2146 facility := f_facility_or_wc(facility)
2147 }
2148 }
2149 }
2150}
2151
2152template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_RELEASE_COMPLETE(
2153 uint3_t tid, BIT1 ti_flag,
2154 template (omit) ML3_Cause_TLV cause := omit,
2155 template (omit) OCTN facility := omit
2156) := {
2157 discriminator := '1011'B,
2158 tiOrSkip := {
2159 transactionId := {
2160 tio := int2bit(tid, 3),
2161 tiFlag := ti_flag,
2162 tIExtension := omit
2163 }
2164 },
2165 msgs := {
2166 ss := {
2167 releaseComplete_NW_MS := {
2168 messageType := '101010'B,
2169 nsd := '00'B,
2170 cause := cause,
2171 facility := f_facility_or_omit(facility)
2172 }
2173 }
2174 }
2175}
2176template PDU_ML3_NW_MS tr_ML3_MT_SS_RELEASE_COMPLETE(
2177 template uint3_t tid, template BIT1 ti_flag,
2178 template ML3_Cause_TLV cause := *,
2179 template OCTN facility := *
2180) := {
2181 discriminator := '1011'B,
2182 tiOrSkip := {
2183 transactionId := {
2184 tio := f_tid_or_wc(tid),
2185 tiFlag := ti_flag,
2186 tIExtension := omit
2187 }
2188 },
2189 msgs := {
2190 ss := {
2191 releaseComplete_NW_MS := {
2192 messageType := '101010'B,
2193 nsd := '00'B,
2194 cause := cause,
2195 facility := f_facility_or_wc(facility)
2196 }
2197 }
2198 }
2199}
2200
Harald Welte53603962018-05-28 11:13:09 +02002201/***********************************************************************
Harald Welte38575a72018-02-15 20:41:37 +01002202 * GPRS Mobility Management
2203 ***********************************************************************/
2204
2205template (value) MSNetworkCapabilityV ts_GMM_MsNetCapV := {
2206 gea1bit := '1'B,
2207 smCapabilitiesviaDedicatedChannels := '1'B,
2208 smCapabilitiesviaGPRSChannels := '0'B,
2209 ucs2Support := '1'B,
2210 ssScreeningIndicator := '01'B,
2211 solSACapability := omit,
2212 revisionLevelIndicatior := omit,
2213 pFCFeatureMode := omit,
2214 extendedGEAbits := omit,
2215 lcsVAcapability := omit,
2216 pSInterRATHOtoUTRANIuModeCapability := omit,
2217 pSInterRATHOtoEUTRANS1ModeCapability := omit,
2218 eMMCombinedProceduresCapability := omit,
2219 iSRSupport := omit,
2220 sRVCCtoGERANUTRANCapability := omit,
2221 ePCCapability := omit,
2222 nFCapability := omit,
2223 gERANNertworkSharingCapability := omit,
2224 spare_octets := omit
2225};
2226
2227template (value) MSNetworkCapabilityLV ts_GMM_MsNetCapLV := {
2228 lengthIndicator := 0, /* overwritten */
2229 msNetworkCapabilityV := ts_GMM_MsNetCapV
2230};
2231
2232type enumerated GprsAttachType {
2233 GPRS_ATT_T_GPRS,
2234 GPRS_ATT_T_GPRS_IMSI_COMBINED
2235};
2236
2237function ts_GMM_AttachType(boolean combined := false, boolean follow_on_pending := false)
2238return AttachTypeV {
2239 var AttachTypeV att;
2240 if (combined) {
2241 att.attachType := '011'B;
2242 } else {
2243 att.attachType := '001'B;
2244 }
2245 att.for_l3 := bool2bit(combined);
2246 return att;
2247}
2248
2249type enumerated GprsUpdateType {
2250 GPRS_UPD_T_RA ('000'B),
2251 GPRS_UPD_T_RA_LA_COMBINED ('001'B),
2252 GPRS_UPD_T_RA_LA_COMBINED_IMSI_ATT ('010'B),
2253 GPRS_UPD_T_PERIODIC ('011'B)
2254};
2255
2256/* 10.5.5.18 Update Type */
2257template UpdateTypeV ts_GMM_UpdateType(GprsUpdateType upd_t, boolean combined := false,
2258 boolean follow_on_pending := false) := {
2259 valueField := int2bit(enum2int(upd_t), 3),
2260 for_l3 := bool2bit(combined)
2261}
2262
2263template (value) DRXParameterV ts_DrxParameterV := {
2264 splitPGCycleCode := '00'O, /* no DRX */
2265 nonDRXTimer := '000'B, /* no non-DRX mode */
2266 splitOnCCCH := '0'B, /* not supported */
2267 cnSpecificDRXCycleLength := '0000'B /* SI value used */
2268};
2269
Harald Welte6ce47c32020-09-13 09:58:29 +02002270private function f_presence_bit_MultislotCap_GPRS(template (omit) MultislotCap_GPRS mscap_gprs) return BIT1 {
2271 if (istemplatekind(mscap_gprs, "omit")) {
2272 return '0'B;
2273 }
2274 return '1'B;
2275}
2276private function f_presence_bit_MultislotCap_EGPRS(template (omit) MultislotCap_EGPRS mscap_egprs) return BIT1 {
2277 if (istemplatekind(mscap_egprs, "omit")) {
2278 return '0'B;
2279 }
2280 return '1'B;
2281}
2282template (value) MSRACapabilityValuesRecord ts_RaCapRec(BIT4 att := '0001'B /* E-GSM */, template (omit) MultislotCap_GPRS mscap_gprs := omit, template (omit) MultislotCap_EGPRS mscap_egprs := omit) := {
2283 mSRACapabilityValues := {
2284 mSRACapabilityValuesExclude1111 := {
2285 accessTechnType := att, /* E-GSM */
2286 accessCapabilities := {
2287 lengthIndicator := 0, /* overwritten */
2288 accessCapabilities := {
2289 rfPowerCapability := '001'B, /* FIXME */
2290 presenceBitA5 := '0'B,
2291 a5bits := omit,
2292 esind := '1'B,
2293 psbit := '0'B,
2294 vgcs := '0'B,
2295 vbs := '0'B,
2296 presenceBitMultislot := '1'B,
2297 multislotcap := {
2298 presenceBitHscsd := '0'B,
2299 hscsdmultislotclass := omit,
2300 presenceBitGprs := f_presence_bit_MultislotCap_GPRS(mscap_gprs),
2301 gprsmultislot := mscap_gprs,
2302 presenceBitSms := '0'B,
2303 multislotCap_SMS := omit,
2304 multislotCapAdditionsAfterRel97 := {
2305 presenceBitEcsdmulti := '0'B,
2306 ecsdmultislotclass := omit,
2307 presenceBitEgprsmulti := f_presence_bit_MultislotCap_EGPRS(mscap_egprs),
2308 multislotCap_EGPRS := mscap_egprs,
2309 presenceBitDtmGprsmulti := '0'B,
2310 multislotCapdtmgprsmultislotsubclass := omit
2311 }
2312 },
2313 accessCapAdditionsAfterRel97 := omit
2314 },
2315 spare_bits := omit
2316 }
2317 }
2318 },
2319 presenceBitMSRACap := '0'B
2320};
2321
Harald Welte38575a72018-02-15 20:41:37 +01002322template (value) MSRadioAccessCapabilityLV ts_MS_RaCapa := {
2323 lengthIndicator := 0, /* overwritten */
2324 msRadioAccessCapabilityV := {
2325 ts_RaCapRec('0001'B) /* E-GSM */
2326 }
2327}
2328
2329template (value) PDU_L3_MS_SGSN
2330 ts_GMM_ATTACH_REQ(MobileIdentityLV mi_lv, RoutingAreaIdentificationV old_ra,
2331 boolean combined := false, boolean follow_on_pending := false,
2332 template (omit) MobileStationClassmark2_TLV cm2_tlv,
2333 template (omit) MobileStationClassmark3_TLV cm3_tlv
2334 ) := {
2335 discriminator := '0000'B, /* overwritten */
2336 tiOrSkip := {
2337 skipIndicator := '0000'B
2338 },
2339 msgs := {
2340 gprs_mm := {
2341 attachRequest := {
2342 messageType := '00000000'B, /* overwritten */
2343 msNetworkCapability := ts_GMM_MsNetCapLV,
2344 attachType := valueof(ts_GMM_AttachType(combined, follow_on_pending)),
2345 gprsCKSN := { '111'B, '0'B },
2346 drxParam := ts_DrxParameterV,
2347 mobileIdentity := mi_lv,
2348 oldRoutingAreaID := old_ra,
2349 msRACap := ts_MS_RaCapa,
2350 ptmsiSignature := omit, /* TODO */
2351 reqGPRStimer := omit,
2352 tmsiStatus := omit,
2353 pC_LCSCapability := omit,
2354 mobileStationClassmark2 := cm2_tlv,
2355 mobileStationClassmark3 := cm3_tlv,
2356 supportedCodecs := omit,
2357 uENetworkCapability := omit,
2358 additionalMobileIdentity := omit,
2359 routingAreaIdentification2 := omit,
2360 voiceDomainandUEsUsageSetting := omit,
2361 deviceProperties := omit,
2362 p_TMSI_Type := omit,
2363 mS_NetworkFeatureSupport := omit,
2364 oldLocationAreaIdentification := omit,
2365 additionalUpdateType := omit,
2366 tMSIBasedNRIcontainer := omit,
2367 t3324 := omit,
2368 t3312_ExtendedValue := omit,
2369 extendedDRXParameters := omit
2370 }
2371 }
2372 }
2373}
2374
Harald Welteb0386df2018-02-16 18:14:28 +01002375private function tr_MI_TMSI_TLV(template OCT4 tmsi) return template MobileIdentityTLV {
2376 if (istemplatekind(tmsi, "*")) {
2377 return *;
2378 } else if (istemplatekind(tmsi, "?")) {
2379 return ?;
2380 } else {
2381 var template MobileIdentityTLV mi := {
2382 elementIdentifier := '0011000'B,
2383 spare1 := '0'B,
2384 mobileIdentityLV := {
2385 lengthIndicator := 4,
2386 mobileIdentityV := {
2387 typeOfIdentity := '100'B,
2388 oddEvenInd_identity := {
2389 tmsi_ptmsi := {
2390 oddevenIndicator := '1'B,
2391 fillerDigit := '1111'B,
2392 octets := tmsi
2393 }
2394 }
2395 }
2396 }
2397 };
2398 return mi;
2399 }
2400}
2401
2402template PDU_L3_SGSN_MS tr_GMM_ATTACH_ACCEPT(template BIT3 res := ?,
2403 template RoutingAreaIdentificationV ra := ?,
2404 template OCT4 ptmsi := *) := {
2405 discriminator := '1000'B,
2406 tiOrSkip := {
2407 skipIndicator := '0000'B
2408 },
2409 msgs := {
2410 gprs_mm := {
2411 attachAccept := {
2412 messageType := '00000010'B,
2413 attachResult := { res, ? },
2414 forceToStandby := ?,
2415 updateTimer := ?,
2416 radioPriority := ?,
2417 radioPriorityTOM8 := ?,
2418 routingAreaIdentification := ra,
2419 ptmsiSignature := *,
2420 readyTimer := *,
2421 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2422 msIdentity := *,
2423 gmmCause := *,
2424 t3302 := *,
2425 cellNotification := *,
2426 equivalentPLMNs := *,
2427 networkFeatureSupport := *,
2428 emergencyNumberList := *,
2429 requestedMSInformation := *,
2430 t3319 := *,
2431 t3323 := *,
2432 t3312_ExtendedValue := *,
2433 additionalNetworkFeatureSupport := *,
2434 t3324 := *,
2435 extendedDRXParameters := *
2436 }
2437 }
2438 }
2439}
Harald Welte38575a72018-02-15 20:41:37 +01002440
Harald Welte5b7c8122018-02-16 21:48:17 +01002441template PDU_L3_SGSN_MS tr_GMM_ATTACH_REJECT(template OCT1 cause) := {
2442 discriminator := '1000'B,
2443 tiOrSkip := {
2444 skipIndicator := '0000'B
2445 },
2446 msgs := {
2447 gprs_mm := {
2448 attachReject := {
2449 messageType := '00000100'B,
2450 gmmCause := {
2451 causeValue := cause
2452 },
2453 t3302 := *,
2454 t3346 := *
2455 }
2456 }
2457 }
2458}
2459
2460
Harald Welte38575a72018-02-15 20:41:37 +01002461template (value) PDU_L3_MS_SGSN ts_GMM_ATTACH_COMPL := {
2462 discriminator := '0000'B, /* overwritten */
2463 tiOrSkip := {
2464 skipIndicator := '0000'B
2465 },
2466 msgs := {
2467 gprs_mm := {
2468 attachComplete := {
2469 messageType := '00000000'B, /* overwritten */
2470 interRATHandoverInformation := omit,
2471 eUTRANinterRATHandoverInformation := omit
2472 }
2473 }
2474 }
2475}
2476
2477template (value) PDU_L3_MS_SGSN
2478 ts_GMM_RAU_REQ(MobileIdentityLV mi_lv, GprsUpdateType upd_type,
2479 RoutingAreaIdentificationV old_ra,
2480 boolean follow_on_pending := false,
2481 template (omit) MobileStationClassmark2_TLV cm2_tlv,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002482 template (omit) MobileStationClassmark3_TLV cm3_tlv,
2483 template (omit) OCT4 p_tmsi := omit
Harald Welte38575a72018-02-15 20:41:37 +01002484 ) := {
2485 discriminator := '0000'B, /* overwritten */
2486 tiOrSkip := {
2487 skipIndicator := '0000'B
2488 },
2489 msgs := {
2490 gprs_mm := {
2491 routingAreaUpdateRequest := {
2492 messageType := '00000000'B, /* overwritten */
2493 updateType := ts_GMM_UpdateType(upd_type, follow_on_pending),
2494 gprsCKSN := { '111'B, '0'B },
2495 oldRoutingAreaId := old_ra,
2496 msRACap := ts_MS_RaCapa,
2497 oldPTMSISignature := omit, /* TODO */
2498 readyTimerValue := omit,
2499 drxParameter := omit,
2500 tmsiStatus := omit,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002501 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
Harald Welte38575a72018-02-15 20:41:37 +01002502 mSNetworkCapability := omit,
2503 pdpContextStatus := omit, /* TODO */
2504 pC_LCSCapability := omit,
Harald Welte04683d02018-02-16 22:43:45 +01002505 mBMS_ContextStatus := omit,
Harald Welte38575a72018-02-15 20:41:37 +01002506 uENetworkCapability := omit,
2507 additionalMobileIdentity := omit,
2508 oldRoutingAreaIdentification2 := omit,
2509 mobileStationClassmark2 := cm2_tlv,
2510 mobileStationClassmark3 := cm3_tlv,
2511 supportedCodecs := omit,
2512 voiceDomainUEUsageSetting := omit,
2513 p_TMSI_Type := omit,
2514 deviceProperties := omit,
2515 mS_NetworkFeatureSupport := omit,
2516 oldLocationAreaIdentification := omit,
2517 additionalUpdateType := omit,
2518 tMSIBasedNRIcontainer := omit,
2519 t3324 := omit,
2520 t3312_ExtendedValue := omit,
2521 extendedDRXParameters := omit
2522 }
2523 }
2524 }
2525}
2526
Harald Welte04683d02018-02-16 22:43:45 +01002527template PDU_L3_SGSN_MS tr_GMM_RAU_REJECT(template OCT1 cause := ?) := {
2528 discriminator := '1000'B,
2529 tiOrSkip := {
2530 skipIndicator := '0000'B
2531 },
2532 msgs := {
2533 gprs_mm := {
2534 routingAreaUpdateReject := {
2535 messageType := '00001011'B,
2536 gmmCause := {
2537 causeValue := cause
2538 },
2539 forceToStandby := ?,
2540 spare := '0000'B,
2541 t3302 := *,
2542 t3346 := *
2543 }
2544 }
2545 }
2546}
2547
Harald Welte91636de2018-02-17 10:16:14 +01002548template PDU_L3_SGSN_MS tr_GMM_RAU_ACCEPT(template BIT3 res := ?,
2549 template RoutingAreaIdentificationV ra := ?,
2550 template OCT4 ptmsi := *) := {
2551 discriminator := '1000'B,
2552 tiOrSkip := {
2553 skipIndicator := '0000'B
2554 },
2555 msgs := {
2556 gprs_mm := {
2557 routingAreaUpdateAccept := {
2558 messageType := '00001001'B,
2559 forceToStandby := ?,
2560 updateResult := { res, ? },
2561 raUpdateTimer := ?,
2562 routingAreaId := ra,
2563 ptmsiSignature := *,
2564 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2565 msIdentity := *,
2566 receiveNPDUNumbers := *,
2567 readyTimer := *,
2568 gmmCause := *,
2569 t3302 := *,
2570 cellNotification := *,
2571 equivalentPLMNs := *,
2572 pdpContextStatus := *,
2573 networkFeatureSupport := *,
2574 emergencyNumberList := *,
2575 mBMS_ContextStatus := *,
2576 requestedMSInformation := *,
2577 t3319 := *,
2578 t3323 := *,
2579 t3312_ExtendedValue := *,
2580 additionalNetworkFeatureSupport := *,
2581 t3324 := *,
2582 extendedDRXParameters := *
2583 }
2584 }
2585 }
2586}
Harald Welte04683d02018-02-16 22:43:45 +01002587
Harald Welte38575a72018-02-15 20:41:37 +01002588template (value) PDU_L3_MS_SGSN ts_GMM_RAU_COMPL := {
2589 discriminator := '0000'B, /* overwritten */
2590 tiOrSkip := {
2591 skipIndicator := '0000'B
2592 },
2593 msgs := {
2594 gprs_mm := {
2595 routingAreaUpdateComplete := {
2596 messageType := '00000000'B, /* overwritten */
2597 receiveNPDUNumbers := omit,
2598 interRATHandoverInformation := omit,
2599 eUTRANinterRATHandoverInformation := omit
2600 }
2601 }
2602 }
2603}
2604
2605template (value) PDU_L3_MS_SGSN ts_GMM_PTMSI_REALL_COMPL := {
2606 discriminator := '0000'B, /* overwritten */
2607 tiOrSkip := {
2608 skipIndicator := '0000'B
2609 },
2610 msgs := {
2611 gprs_mm := {
2612 p_TMSIReallocationComplete := {
2613 messageType := '00000000'B /* overwritten */
2614 }
2615 }
2616 }
2617}
2618
2619template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_CIPH_COMPL(ACReferenceNumberV ref, OCT4 res) := {
2620 discriminator := '0000'B, /* overwritten */
2621 tiOrSkip := {
2622 skipIndicator := '0000'B
2623 },
2624 msgs := {
2625 gprs_mm := {
2626 authenticationAndCipheringResponse := {
2627 messageType := '00000000'B, /* overwritten */
2628 acReferenceNumber := ref,
2629 spare := '0000'B,
2630 authenticationParResp := {
2631 elementIdentifier := '22'O,
2632 valueField := res
2633 },
2634 imeisv := omit,
2635 authenticationRespParExt := omit
2636 }
2637 }
2638 }
2639}
2640
Harald Welteb0386df2018-02-16 18:14:28 +01002641template PDU_L3_SGSN_MS tr_GMM_ID_REQ(template BIT3 id_type := ?) := {
2642 discriminator := '1000'B,
2643 tiOrSkip := {
2644 skipIndicator := '0000'B
2645 },
2646 msgs := {
2647 gprs_mm := {
2648 identityRequest := {
2649 messageType := '00010101'B,
2650 identityType := { id_type, '0'B },
2651 forceToStandby := ?
2652 }
2653 }
2654 }
2655}
2656
Harald Welte38575a72018-02-15 20:41:37 +01002657template (value) PDU_L3_MS_SGSN ts_GMM_ID_RESP(MobileIdentityLV mi_lv) := {
2658 discriminator := '0000'B, /* overwritten */
2659 tiOrSkip := {
2660 skipIndicator := '0000'B
2661 },
2662 msgs := {
2663 gprs_mm := {
2664 identityResponse := {
2665 messageType := '00000000'B, /* overwritten */
2666 mobileIdentity := mi_lv
2667 }
2668 }
2669 }
2670}
2671
Harald Welteb0386df2018-02-16 18:14:28 +01002672template PDU_L3_SGSN_MS tr_GMM_AUTH_REQ(template OCT16 rand := ?, template BIT3 ciph_alg := ?) := {
2673 discriminator := '1000'B,
2674 tiOrSkip := {
2675 skipIndicator := '0000'B
2676 },
2677 msgs := {
2678 gprs_mm := {
2679 authenticationAndCipheringRequest := {
2680 messageType := '00010010'B,
2681 cipheringAlgorithm := { ciph_alg, '0'B },
2682 imeisvRequest := ?,
2683 forceToStandby := ?,
2684 acReferenceNumber := ?,
2685 authenticationParameterRAND := {
2686 elementIdentifier := '21'O,
2687 randValue := rand
2688 },
2689 cipheringKeySequenceNumber := *,
2690 authenticationParameterAUTN := *
2691 }
2692 }
2693 }
2694}
2695
2696template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_RESP_2G(BIT4 ac_ref, OCT4 sres) := {
2697 discriminator := '1000'B,
2698 tiOrSkip := {
2699 skipIndicator := '0000'B
2700 },
2701 msgs := {
2702 gprs_mm := {
2703 authenticationAndCipheringResponse := {
2704 messageType := '00010011'B,
2705 acReferenceNumber := { valueField := ac_ref },
2706 spare := '0000'B,
2707 authenticationParResp := {
2708 elementIdentifier := '22'O,
2709 valueField := sres
2710 },
2711 imeisv := omit,
2712 authenticationRespParExt := omit
2713 }
2714 }
2715 }
2716}
2717
Alexander Couzens15faf922018-09-04 15:16:26 +02002718template PDU_L3_MS_SGSN ts_GMM_AUTH_FAIL_UMTS_AKA_RESYNC(octetstring auts) := {
2719 discriminator := '1000'B,
2720 tiOrSkip := {
2721 skipIndicator := '0000'B
2722 },
2723 msgs := {
2724 gprs_mm := {
2725 authenticationAndCipheringFailure := {
2726 messageType := '00011100'B,
2727 gmmCause := {
2728 causeValue := '15'O /* GMM_CAUSE_SYNC_FAIL 10.5.3.2.2 */
2729 },
2730 authenticationFailureParam := {
2731 elementIdentifier := '30'O,
2732 lengthIndicator := 14,
2733 valueField := auts
2734 }
2735 }
2736 }
2737 }
2738}
2739
Harald Welteb0386df2018-02-16 18:14:28 +01002740
Harald Welte38575a72018-02-15 20:41:37 +01002741const BIT3 c_GMM_DTT_MO_GPRS := '001'B;
2742const BIT3 c_GMM_DTT_MO_IMSI := '010'B;
2743const BIT3 c_GMM_DTT_MO_GPRS_IMSI_COMBINED := '011'B;
2744
Alexander Couzensb6ab4562018-05-17 02:59:22 +02002745const BIT3 c_GMM_DTT_MT_REATTACH_REQUIRED := '001'B;
2746const BIT3 c_GMM_DTT_MT_REATTACH_NOT_REQUIRED := '010'B;
2747const BIT3 c_GMM_DTT_MT_IMSI_DETACH := '011'B;
2748
Harald Welte6abb9fe2018-02-17 15:24:48 +01002749template (value) DetachTypeV ts_GMM_DetType(BIT3 dtt, boolean power_off := false) := {
Harald Welte38575a72018-02-15 20:41:37 +01002750 detachType := dtt,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002751 powerOffFlag := bool2bit(power_off)
Harald Welte38575a72018-02-15 20:41:37 +01002752}
2753
Harald Welte6abb9fe2018-02-17 15:24:48 +01002754function ts_PtmsiSigTV(template (omit) OCT3 val) return template (omit) P_TMSISignatureTV {
2755 var template (omit) P_TMSISignatureTV ret;
2756 if (istemplatekind(val, "omit")) {
2757 return omit;
2758 } else {
2759 ret := {
2760 elementIdentifier := '19'O,
2761 valueField := valueof(val)
2762 }
2763 return ret;
2764 }
2765}
2766
2767function ts_PtmsiSigTLV(template (omit) OCT3 val) return template (omit) P_TMSISignature2TLV {
2768 var template (omit) P_TMSISignature2TLV ret;
2769 if (istemplatekind(val, "omit")) {
2770 return omit;
2771 } else {
2772 ret := {
2773 elementIdentifier := '19'O,
2774 lengthIndicator := 3,
2775 valueField := valueof(val)
2776 }
2777 return ret;
2778 }
2779}
2780
2781template (value) PDU_L3_MS_SGSN ts_GMM_DET_REQ_MO(BIT3 dtt := c_GMM_DTT_MO_GPRS,
2782 boolean power_off := false,
2783 template (omit) OCT4 p_tmsi := omit,
2784 template (omit) OCT3 p_tmsi_sig := omit) := {
Harald Welte38575a72018-02-15 20:41:37 +01002785 discriminator := '0000'B, /* overwritten */
2786 tiOrSkip := {
2787 skipIndicator := '0000'B
2788 },
2789 msgs := {
2790 gprs_mm := {
2791 detachRequest_MS_SGSN := {
2792 messageType := '00000000'B, /* overwritten */
Harald Welte6abb9fe2018-02-17 15:24:48 +01002793 detachType := valueof(ts_GMM_DetType(dtt, power_off)),
Harald Welte38575a72018-02-15 20:41:37 +01002794 spare := '0000'B,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002795 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
2796 ptmsiSignature := ts_PtmsiSigTLV(p_tmsi_sig)
2797 }
2798 }
2799 }
2800}
2801
2802template PDU_L3_SGSN_MS tr_GMM_DET_ACCEPT_MT := {
2803 discriminator := '1000'B,
2804 tiOrSkip := {
2805 skipIndicator := '0000'B
2806 },
2807 msgs := {
2808 gprs_mm := {
2809 detachAccept_SGSN_MS := {
2810 messageType := '00000110'B,
2811 forceToStandby := ?,
2812 spare := '0000'B
Harald Welte38575a72018-02-15 20:41:37 +01002813 }
2814 }
2815 }
2816}
Harald Welte812f7a42018-01-27 00:49:18 +01002817
Alexander Couzensd62fba52018-05-22 16:08:39 +02002818template PDU_L3_SGSN_MS tr_GMM_DET_REQ_MT(
2819 template BIT3 dtt := *,
2820 template BIT3 forceToStandby := ?,
Alexander Couzensd8604ab2018-05-29 15:46:06 +02002821 template OCT1 cause := *) := {
Harald Welte835b15f2018-02-18 14:39:11 +01002822 discriminator := '1000'B,
2823 tiOrSkip := {
2824 skipIndicator := '0000'B
2825 },
2826 msgs := {
2827 gprs_mm := {
2828 detachRequest_SGSN_MS := {
2829 messageType := '00000101'B,
Alexander Couzensd62fba52018-05-22 16:08:39 +02002830 detachType := { dtt, ? },
2831 forceToStandby := { forceToStandby, '0'B },
2832 gmmCause := {
2833 elementIdentifier := '25'O,
2834 causeValue := { cause }
2835 }
2836 }
2837 }
2838 }
2839}
2840
2841template PDU_L3_MS_SGSN ts_GMM_DET_ACCEPT_MO := {
2842 discriminator := '0000'B, /* overwritten */
2843 tiOrSkip := {
2844 skipIndicator := '0000'B
2845 },
2846 msgs := {
2847 gprs_mm := {
2848 detachAccept_MS_SGSN := {
2849 messageType := '00000000'B
Harald Welte835b15f2018-02-18 14:39:11 +01002850 }
2851 }
2852 }
2853}
Harald Welteeded9ad2018-02-17 20:57:34 +01002854
2855function ts_ApnTLV(template (omit) octetstring apn) return template (omit) AccessPointNameTLV {
2856 if (istemplatekind(apn, "omit")) {
2857 return omit;
2858 } else {
2859 var template (omit) AccessPointNameTLV ret := {
2860 elementIdentifier := '28'O,
2861 lengthIndicator := 0, /* overwritten */
2862 accessPointNameValue := apn
2863 }
2864 return ret;
2865 }
2866}
2867
2868function ts_PcoTLV(template (omit) ProtocolConfigOptionsV pco)
2869 return template (omit) ProtocolConfigOptionsTLV {
2870 if (istemplatekind(pco, "omit")) {
2871 return omit;
2872 } else {
2873 var template (omit) ProtocolConfigOptionsTLV ret := {
2874 elementIdentifier := '27'O,
2875 lengthIndicator := 0, /* overwritten */
2876 protocolConfigOptionsV := pco
2877 }
2878 return ret;
2879 }
2880}
2881
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002882function ts_TearDownIndicatorTV(in template (omit) boolean ind)
2883 return template (omit) TearDownIndicatorTV {
2884 if (istemplatekind(ind, "omit")) {
2885 return omit;
2886 } else {
2887 var template (omit) TearDownIndicatorTV ret := {
2888 tearDownIndicatorV := {
2889 tdi_flag := bool2bit(valueof(ind)),
2890 spare := '000'B
2891 },
2892 elementIdentifier := '1001'B
2893 }
2894 return ret;
2895 }
2896}
2897
Harald Welteeded9ad2018-02-17 20:57:34 +01002898template (value) PDU_L3_MS_SGSN ts_SM_ACT_PDP_REQ(BIT3 tid, BIT4 nsapi, BIT4 sapi, QoSV qos,
2899 PDPAddressV addr,
2900 template (omit) octetstring apn := omit,
2901 template (omit) ProtocolConfigOptionsV pco := omit
2902 ) := {
2903 discriminator := '0000'B, /* overwritten */
2904 tiOrSkip := {
2905 transactionId := {
2906 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002907 tiFlag := c_TIF_ORIG,
Harald Welteeded9ad2018-02-17 20:57:34 +01002908 tIExtension := omit
2909 }
2910 },
2911 msgs := {
2912 gprs_sm := {
2913 activatePDPContextRequest := {
2914 messageType := '00000000'B, /* overwritten */
2915 requestedNSAPI := { nsapi, '0000'B },
2916 requestedLLCSAPI := { sapi, '0000'B },
2917 requestedQoS := {
2918 lengthIndicator := 0, /* overwritten */
2919 qoSV := qos
2920 },
2921 requestedPDPaddress := {
2922 lengthIndicator := 0, /* overwritten */
2923 pdpAddressV := addr
2924 },
2925 accessPointName := ts_ApnTLV(apn),
2926 protocolConfigOpts := ts_PcoTLV(pco),
2927 requestType := omit,
2928 deviceProperties := omit,
2929 nBIFOM_Container := omit
2930 }
2931 }
2932 }
2933}
2934
2935template PDU_L3_SGSN_MS tr_SM_ACT_PDP_REJ(template BIT3 tid := ?, template OCT1 cause := ?) := {
2936 discriminator := '1010'B,
2937 tiOrSkip := {
2938 transactionId := {
2939 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002940 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002941 tIExtension := omit
2942 }
2943 },
2944 msgs := {
2945 gprs_sm := {
2946 activatePDPContextReject := {
Harald Welte4aacdd82018-02-18 21:24:05 +01002947 messageType := '01000011'B,
Harald Welteeded9ad2018-02-17 20:57:34 +01002948 smCause := cause,
2949 protocolConfigOpts := *,
2950 backOffTimer := *,
2951 reAttemptIndicator := *,
2952 nBIFOM_Container := *
2953 }
2954 }
2955 }
2956}
2957
2958template PDU_L3_SGSN_MS tr_SM_ACT_PDP_ACCEPT(template BIT3 tid := ?, template BIT4 sapi := ?,
2959 template QoSV qos := ?)
2960:= {
2961 discriminator := '1010'B,
2962 tiOrSkip := {
2963 transactionId := {
2964 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002965 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002966 tIExtension := omit
2967 }
2968 },
2969 msgs := {
2970 gprs_sm := {
2971 activatePDPContextAccept := {
2972 messageType := '01000010'B,
2973 negotiatedLLCSAPI := { sapi, '0000'B },
2974 negotiatedQoS := {
2975 lengthIndicator := ?,
2976 qoSV := qos
2977 },
2978 radioPriority := ?,
2979 spare := '0000'B,
2980 pdpAddress := *,
2981 protocolConfigOpts := *,
2982 packetFlowID := *,
2983 sMCause2 := *,
2984 connectivityType := *,
2985 wLANOffloadIndication := *,
2986 nBIFOM_Container := *
2987 }
2988 }
2989 }
2990}
2991
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002992template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_REQ_MO(BIT3 tid, OCT1 cause,
2993 template (omit) boolean tdown := omit,
Harald Welte6f203162018-02-18 22:04:55 +01002994 template (omit) ProtocolConfigOptionsV pco := omit
2995 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002996 discriminator := '1010'B,
Harald Welte6f203162018-02-18 22:04:55 +01002997 tiOrSkip := {
2998 transactionId := {
2999 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003000 tiFlag := c_TIF_ORIG,
Harald Welte6f203162018-02-18 22:04:55 +01003001 tIExtension := omit
3002 }
3003 },
3004 msgs := {
3005 gprs_sm := {
3006 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003007 messageType := '01000110'B,
Harald Welte6f203162018-02-18 22:04:55 +01003008 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003009 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte6f203162018-02-18 22:04:55 +01003010 protocolConfigOpts := ts_PcoTLV(pco),
3011 mBMSprotocolConfigOptions := omit,
3012 t3396 := omit,
3013 wLANOffloadIndication := omit,
3014 nBIFOM_Container := omit
3015 }
3016 }
3017 }
3018}
3019
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003020template (value) PDU_L3_SGSN_MS ts_SM_DEACT_PDP_REQ_MT(BIT3 tid, OCT1 cause,
3021 template (omit) boolean tdown := omit,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003022 template (omit) ProtocolConfigOptionsV pco := omit
3023 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003024 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003025 tiOrSkip := {
3026 transactionId := {
3027 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003028 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003029 tIExtension := omit
3030 }
3031 },
3032 msgs := {
3033 gprs_sm := {
3034 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003035 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003036 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003037 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte57b9b7f2018-02-18 22:28:13 +01003038 protocolConfigOpts := ts_PcoTLV(pco),
3039 mBMSprotocolConfigOptions := omit,
3040 t3396 := omit,
3041 wLANOffloadIndication := omit,
3042 nBIFOM_Container := omit
3043 }
3044 }
3045 }
3046}
3047
3048template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_REQ_MT(template BIT3 tid, template OCT1 cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003049 template (omit) boolean tdown := omit,
3050 template (omit) ProtocolConfigOptionsV pco := omit
3051 ) := {
3052 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003053 tiOrSkip := {
3054 transactionId := {
3055 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003056 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003057 tIExtension := omit
3058 }
3059 },
3060 msgs := {
3061 gprs_sm := {
3062 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003063 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003064 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003065 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
3066 protocolConfigOpts := ts_PcoTLV(pco),
Harald Welte57b9b7f2018-02-18 22:28:13 +01003067 mBMSprotocolConfigOptions := *,
3068 t3396 := *,
3069 wLANOffloadIndication := *,
3070 nBIFOM_Container := *
3071 }
3072 }
3073 }
3074}
3075
Harald Welte6f203162018-02-18 22:04:55 +01003076template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_ACCEPT_MT(template BIT3 tid := ?)
3077:= {
3078 discriminator := '1010'B,
3079 tiOrSkip := {
3080 transactionId := {
3081 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003082 tiFlag := c_TIF_REPL,
Harald Welte6f203162018-02-18 22:04:55 +01003083 tIExtension := omit
3084 }
3085 },
3086 msgs := {
3087 gprs_sm := {
3088 deactivatePDPContextAccept := {
3089 messageType := '01000111'B,
3090 protocolConfigOpts := *,
3091 mBMSprotocolConfigOptions := *,
3092 nBIFOM_Container := *
3093 }
3094 }
3095 }
3096}
3097
Harald Welte57b9b7f2018-02-18 22:28:13 +01003098template PDU_L3_MS_SGSN tr_SM_DEACT_PDP_ACCEPT_MO(template BIT3 tid := ?)
3099:= {
3100 discriminator := '1010'B,
3101 tiOrSkip := {
3102 transactionId := {
3103 tio := tid,
Pau Espin Pedrol55cb2ce2020-04-22 17:08:09 +02003104 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003105 tIExtension := omit
3106 }
3107 },
3108 msgs := {
3109 gprs_sm := {
3110 deactivatePDPContextAccept := {
3111 messageType := '01000111'B,
3112 protocolConfigOpts := *,
3113 mBMSprotocolConfigOptions := *,
3114 nBIFOM_Container := *
3115 }
3116 }
3117 }
3118}
3119
3120template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_ACCEPT_MO(BIT3 tid)
3121:= {
3122 discriminator := '1010'B,
3123 tiOrSkip := {
3124 transactionId := {
3125 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003126 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003127 tIExtension := omit
3128 }
3129 },
3130 msgs := {
3131 gprs_sm := {
3132 deactivatePDPContextAccept := {
3133 messageType := '01000111'B,
3134 protocolConfigOpts := omit,
3135 mBMSprotocolConfigOptions := omit,
3136 nBIFOM_Container := omit
3137 }
3138 }
3139 }
3140}
3141
Harald Welteeded9ad2018-02-17 20:57:34 +01003142
3143
Harald Welte7484fc42018-02-24 14:09:45 +01003144external function enc_MobileIdentityLV(in MobileIdentityLV si) return octetstring
3145 with { extension "prototype(convert) encode(RAW)" };
Harald Weltee5695f52018-02-16 14:46:15 +01003146
Vadim Yanitskiy322c7932020-01-01 23:03:47 +01003147external function dec_MobileIdentityV(in octetstring mi) return MobileIdentityV
3148 with { extension "prototype(convert) decode(RAW)" };
3149
Harald Weltecb6cc332018-01-21 13:59:08 +01003150
Harald Weltef45efeb2018-04-09 18:19:24 +02003151
3152/* SMS TPDU Layer */
3153
3154template (value) TPDU_RP_DATA_MS_SGSN ts_SMS_SUBMIT(OCT1 msg_ref, template (value) TP_DA dst_addr,
3155 template (value) OCT1 pid, template (value) OCT1 dcs,
3156 integer length_ind, octetstring user_data) := {
3157 sMS_SUBMIT := {
3158 tP_MTI := '01'B, /* SUBMIT */
3159 tP_RD := '1'B, /* reject duplicates */
3160 tP_VPF := '00'B, /* not present */
3161 tP_SRR := '0'B, /* no status report requested */
3162 tP_UDHI := '0'B, /* no user data header in UD */
3163 tP_RP := '0'B, /* no reply path */
3164 tP_MR := msg_ref,
3165 tP_DA := dst_addr,
3166 tP_PID := pid,
3167 tP_DCS := dcs,
3168 tP_VP := omit,
3169 tP_UDL_UD := {
3170 tP_LengthIndicator := length_ind,
3171 tP_UD := user_data
3172 }
3173 }
3174}
3175
3176template TPDU_RP_DATA_SGSN_MS tr_SMS_DELIVER(template TP_OA src_addr := ?,
3177 template octetstring user_data := ?,
3178 template OCT1 pid := ?, template OCT1 dcs := ?,
3179 template BIT1 mms := ?
3180 ) := {
3181 sMS_DELIVER := {
3182 tP_MTI := '00'B, /* DELIVER */
3183 tP_MMS := mms, /* more messages to send */
3184 tP_LP := ?, /* ?!? */
3185 tP_Spare := '0'B,
3186 tP_SRI := '0'B, /* status report indication */
3187 tP_UDHI := '0'B, /* no user data header in UD */
3188 tP_RP := '0'B, /* no reply path */
3189 tP_OA := src_addr,
3190 tP_PID := pid,
3191 tP_DCS := dcs,
3192 tP_SCTS := ?,
3193 tP_UDL_UD := {
3194 tP_LengthIndicator := ?,
3195 tP_UD := user_data
3196 }
3197 }
3198}
3199
3200/* RP Layer */
3201
3202private function ts_RpOrig(template (omit) RP_NumberingPlan_and_NumberDigits rp_orig)
3203return RP_OriginatorAddressLV {
3204 var RP_OriginatorAddressLV ret;
3205 if (istemplatekind(rp_orig, "omit")) {
3206 ret := { 0, omit };
3207 } else {
3208 ret := { 0, valueof(rp_orig) };
3209 }
3210 return ret;
3211}
3212
3213private function ts_RpDst(template (omit) RP_NumberingPlan_and_NumberDigits rp_dst)
3214return RP_DestinationAddressLV {
3215 var RP_DestinationAddressLV ret;
3216 if (istemplatekind(rp_dst, "omit")) {
3217 ret := { 0, omit };
3218 } else {
3219 ret := { 0, valueof(rp_dst) };
3220 }
3221 return ret;
3222}
3223
3224template (value) RPDU_MS_SGSN ts_RP_DATA_MO(OCT1 msg_ref,
3225 template (omit) RP_NumberingPlan_and_NumberDigits rp_orig,
3226 template (omit) RP_NumberingPlan_and_NumberDigits rp_dst,
3227 template (value) TPDU_RP_DATA_MS_SGSN tpdu) := {
3228 rP_DATA_MS_SGSN := {
3229 rP_MTI := '000'B,
3230 rP_Spare := '00000'B,
3231 rP_MessageReference := msg_ref,
3232 rP_OriginatorAddress := ts_RpOrig(rp_orig),
3233 rP_DestinationAddress := ts_RpDst(rp_dst),
3234 rP_User_Data := {
3235 rP_LengthIndicator := 0, /* overwritten */
3236 rP_TPDU := tpdu
3237 }
3238 }
3239}
3240
3241template RPDU_SGSN_MS tr_RP_DATA_MT(template OCT1 msg_ref,
3242 template RP_NumberingPlan_and_NumberDigits rp_orig,
3243 template RP_NumberingPlan_and_NumberDigits rp_dst,
3244 template TPDU_RP_DATA_SGSN_MS tpdu) := {
3245 rP_DATA_SGSN_MS := {
3246 rP_MTI := '001'B,
3247 rP_Spare := '00000'B,
3248 rP_MessageReference := msg_ref,
3249 rP_OriginatorAddress := { ?, rp_orig },
3250 rP_DestinationAddress := { ?, rp_dst },
3251 rP_User_Data := {
3252 rP_LengthIndicator := ?,
3253 rP_TPDU := tpdu
3254 }
3255
3256 }
3257}
3258
3259template (value) RPDU_MS_SGSN ts_RP_ACK_MO(OCT1 msg_ref) := {
3260 rP_ACK_MS_SGSN := {
3261 rP_MTI := '010'B,
3262 rP_Spare := '00000'B,
3263 rP_MessageReference := msg_ref,
3264 rP_User_Data := omit /* FIXME: report */
3265 }
3266}
3267
3268template RPDU_SGSN_MS tr_RP_ACK_MT(template OCT1 msg_ref) := {
3269 rP_ACK_SGSN_MS := {
3270 rP_MTI := '011'B,
3271 rP_Spare := '00000'B,
3272 rP_MessageReference := msg_ref,
3273 rP_User_Data := omit /* FIXME: report */
3274 }
3275}
3276
3277template (value) RPDU_MS_SGSN ts_RP_ERROR_MO(OCT1 msg_ref, uint7_t cause) := {
3278 rP_ERROR_MS_SGSN := {
3279 rP_MTI := '100'B,
3280 rP_Spare := '00000'B,
3281 rP_Message_Reference := msg_ref,
3282 rP_CauseLV := {
3283 rP_LengthIndicator := 0, /* overwritten */
3284 rP_CauseV := {
3285 causeValue := int2bit(cause, 7),
3286 ext := '0'B
3287 },
3288 rP_diagnisticField := omit
3289 },
3290 rP_User_Data := omit /* FIXME: report */
3291 }
3292}
3293
3294private function f_cause_or_wc(template uint7_t cause) return template BIT7 {
3295 if (istemplatekind(cause, "?")) {
3296 return ?;
3297 } else if (istemplatekind(cause, "*")) {
3298 return *;
3299 } else {
3300 return int2bit(valueof(cause), 7);
3301 }
3302}
3303
3304template RPDU_SGSN_MS tr_RP_ERROR_MT(template OCT1 msg_ref, template uint7_t cause) := {
3305 rP_ERROR_SGSN_MS := {
3306 rP_MTI := '101'B,
3307 rP_Spare := '00000'B,
3308 rP_Message_Reference := msg_ref,
3309 rP_CauseLV := {
Vadim Yanitskiye9e93012020-01-15 12:35:17 +07003310 rP_LengthIndicator := ?,
Harald Weltef45efeb2018-04-09 18:19:24 +02003311 rP_CauseV := {
3312 causeValue := f_cause_or_wc(cause),
3313 ext := '0'B
3314 },
3315 rP_diagnisticField := omit
3316 },
3317 rP_User_Data := omit /* FIXME: report */
3318 }
3319}
3320
3321
3322template (value) RPDU_MS_SGSN ts_RP_SMMA_MO(OCT1 msg_ref) := {
3323 rP_SMMA := {
3324 rP_MTI := '110'B,
3325 rP_Spare := '00000'B,
3326 rP_MessageReference := msg_ref
3327 }
3328}
3329
3330
3331
3332
3333/* CP Layer */
3334
3335template (value) L3_SMS_MS_SGSN ts_CP_DATA_MO(template (value) RPDU_MS_SGSN rpdu) := {
3336 cP_DATA := {
3337 cP_messageType := '00000001'B,
3338 cP_User_Data := {
3339 lengthIndicator := 0, /* overwritten */
3340 cP_RPDU := rpdu
3341 }
3342 }
3343}
3344
3345template (value) L3_SMS_MS_SGSN ts_CP_ACK_MO := {
3346 cP_ACK := {
3347 cP_messageType := '00000100'B
3348 }
3349}
3350
3351template (value) L3_SMS_MS_SGSN ts_CP_ERROR_MO(OCT1 cause) := {
3352 cP_ERROR := {
3353 cP_messageType := '00010000'B,
3354 cP_Cause := {
3355 causeValue := cause
3356 }
3357 }
3358}
3359
3360template L3_SMS_SGSN_MS tr_CP_DATA_MT(template RPDU_SGSN_MS rpdu) := {
3361 cP_DATA := {
3362 cP_messageType := '00000001'B,
3363 cP_User_Data := {
3364 lengthIndicator := ?,
3365 cP_RPDU := rpdu
3366 }
3367 }
3368}
3369
3370template L3_SMS_SGSN_MS tr_CP_ACK_MT := {
3371 cP_ACK := {
3372 cP_messageType := '00000100'B
3373 }
3374}
3375
3376template L3_SMS_SGSN_MS tr_CP_ERROR_MT(template OCT1 cause) := {
3377 cP_ERROR := {
3378 cP_messageType := '00010000'B,
3379 cP_Cause := {
3380 causeValue := cause
3381 }
3382 }
3383}
3384
3385/* L3 Wrapper */
3386
3387template (value) PDU_ML3_MS_NW ts_ML3_MO_SMS(uint3_t tid, BIT1 ti_flag,
3388 template (value) L3_SMS_MS_SGSN sms_mo) := {
3389 discriminator := '1001'B,
3390 tiOrSkip := {
3391 transactionId := {
3392 tio := int2bit(tid, 3),
3393 tiFlag := ti_flag,
3394 tIExtension := omit
3395 }
3396 },
3397 msgs := {
3398 sms := sms_mo
3399 }
3400}
3401
3402private function f_tid_or_wc(template uint3_t tid) return template BIT3 {
3403 var template BIT3 ret;
3404 if (istemplatekind(tid, "*")) {
3405 return *;
3406 } else if (istemplatekind(tid, "?")) {
3407 return ?;
3408 } else {
3409 return int2bit(valueof(tid), 3);
3410 }
3411}
3412
3413template PDU_ML3_NW_MS tr_ML3_MT_SMS(template uint3_t tid, template BIT1 ti_flag,
3414 template L3_SMS_SGSN_MS sms_mt) := {
3415 discriminator := '1001'B,
3416 tiOrSkip := {
3417 transactionId := {
3418 tio := f_tid_or_wc(tid),
3419 tiFlag := ti_flag,
3420 tIExtension := omit
3421 }
3422 },
3423 msgs := {
3424 sms := sms_mt
3425 }
3426}
3427
Philipp Maier9b690e42018-12-21 11:50:03 +01003428template PDU_ML3_NW_MS tr_ML3_MT_MM_Info := {
3429 discriminator := '0101'B,
3430 tiOrSkip := {
3431 skipIndicator := '0000'B
3432 },
3433 msgs := {
3434 mm := {
3435 mMInformation := {
3436 messageType := '110010'B,
3437 nsd := '00'B,
3438 fullNetworkName := *,
3439 shortNetworkName := *,
3440 localtimeZone := *,
3441 univTime := *,
3442 lSAIdentity := *,
3443 networkDST := *
3444 }
3445 }
3446 }
3447}
Harald Weltef45efeb2018-04-09 18:19:24 +02003448
Vadim Yanitskiy13c26f92020-07-04 21:15:26 +07003449template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
3450 template (value) RoutingAreaIdentificationV rai,
3451 template (value) OCT1 cause) := {
3452 discriminator := '0000'B, /* overwritten */
3453 tiOrSkip := {
3454 skipIndicator := '0000'B
3455 },
3456 msgs := {
3457 rrm := {
3458 gPRS_suspensionRequest := {
3459 messageType := '00110100'B,
3460 tLLI := tlli,
3461 routingAreaIdentification := rai,
3462 suspensionCause := cause,
3463 service_Support := omit
3464 }
3465 }
3466 }
3467}
3468
Harald Weltef45efeb2018-04-09 18:19:24 +02003469
3470
Harald Weltec76f29f2017-11-22 12:46:46 +01003471}