blob: 997b433f3cfb465d980237a621357491dc530b4a [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 Hofmeyrfeda88e2021-07-19 13:51:29 +0200392template (value) PDU_ML3_MS_NW ts_CM_REESTABL_REQ(MobileIdentityLV mi_lv) := {
393 discriminator := '0000'B, /* overwritten */
394 tiOrSkip := {
395 skipIndicator := '0000'B
396 },
397 msgs := {
398 mm := {
399 cMReEstablReq := {
400 messageType := '000000'B, /* overwritten */
401 nsd := '00'B,
402 cipheringKeySequenceNumber := { '000'B, '0'B },
403 spare := '0000'B,
404 mobileStationClassmark2 := ts_CM2,
405 mobileIdentityLV := mi_lv,
406 locationAreaIdentification := omit,
407 deviceProperties := omit
408 }
409 }
410 }
411}
412
Harald Welte0195ab12018-01-24 21:50:20 +0100413template (value) CipheringKeySequenceNumberV ts_CKSN(integer key_seq) := {
414 keySequence := int2bit(key_seq, 3),
415 spare := '0'B
416}
417
418/* Send template for CM RE-ESTABLISH REQUEST */
419template (value) PDU_ML3_MS_NW ts_CM_REEST_REQ(integer cksn, MobileIdentityLV mi_lv) := {
420 discriminator := '0000'B, /* overwritten */
421 tiOrSkip := {
422 skipIndicator := '0000'B
423 },
424 msgs := {
425 mm := {
426 cMReEstablReq := {
427 messageType := '101000'B, /* overwritten */
428 nsd := '00'B,
429 cipheringKeySequenceNumber := ts_CKSN(cksn),
430 spare := '0000'B,
431 mobileStationClassmark2 := ts_CM2,
432 mobileIdentityLV := mi_lv,
433 locationAreaIdentification := omit,
434 deviceProperties := omit
435 }
436 }
437 }
438}
439
440
Harald Welte6ff81902018-01-21 19:09:08 +0100441template PDU_ML3_NW_MS tr_MT_simple(template BIT4 discr := ?) := {
442 discriminator := discr,
443 tiOrSkip := {
444 skipIndicator := '0000'B
445 },
446 msgs := ?
447}
448
449
450template PDU_ML3_NW_MS tr_CM_SERV_ACC := {
451 discriminator := '0101'B,
452 tiOrSkip := {
453 skipIndicator := '0000'B
454 },
455 msgs := {
456 mm := {
457 cMServiceAccept := {
458 messageType := '100001'B,
459 nsd := ?
460 }
461 }
462 }
463}
464
465
Harald Weltecb6cc332018-01-21 13:59:08 +0100466template PDU_ML3_NW_MS tr_CM_SERV_REJ(template OCT1 rej_cause := ?) := {
467 discriminator := '0101'B,
468 tiOrSkip := {
469 skipIndicator := '0000'B
470 },
471 msgs := {
472 mm := {
473 cMServiceReject := {
474 messageType := '100010'B,
475 nsd := ?,
476 rejectCause := rej_cause,
477 t3246_Value := *
478 }
479 }
480 }
481}
482
Harald Welte68e495b2018-02-25 00:05:57 +0100483template PDU_ML3_NW_MS tr_PAGING_REQ1(template MobileIdentityLV mi1 := ?,
484 template MobileIdentityTLV mi2 := *) := {
485 discriminator := '0110'B,
486 tiOrSkip := {
487 skipIndicator := '0000'B
488 },
489 msgs := {
490 rrm := {
491 pagingReq_Type1 := {
492 messageType := '00100001'B,
493 pageMode := ?,
494 channelNeeded := ?,
495 mobileIdentity1 := mi1,
496 mobileIdentity2 := mi2,
497 p1RestOctets := ?
498 }
499 }
500 }
501}
502
503template PDU_ML3_NW_MS tr_PAGING_REQ2(template TMSIP_TMSI_V mi1 := ?,
504 template TMSIP_TMSI_V mi2 := ?,
505 template MobileIdentityTLV mi3 := *) := {
506 discriminator := '0110'B,
507 tiOrSkip := {
508 skipIndicator := '0000'B
509 },
510 msgs := {
511 rrm := {
512 pagingReq_Type2 := {
513 messageType := '00100010'B,
514 pageMode := ?,
515 channelNeeded := ?,
516 mobileIdentity1 := mi1,
517 mobileIdentity2 := mi2,
518 mobileIdentity3 := mi3,
519 p2RestOctets := ?
520 }
521 }
522 }
523}
524
525template PDU_ML3_NW_MS tr_PAGING_REQ3(template TMSIP_TMSI_V mi1 := ?,
526 template TMSIP_TMSI_V mi2 := ?,
527 template TMSIP_TMSI_V mi3 := ?,
528 template TMSIP_TMSI_V mi4 := ?) := {
529 discriminator := '0110'B,
530 tiOrSkip := {
531 skipIndicator := '0000'B
532 },
533 msgs := {
534 rrm := {
535 pagingReq_Type3 := {
536 messageType := '00100100'B,
537 pageMode := ?,
538 channelNeeded := ?,
539 mobileIdentity1 := mi1,
540 mobileIdentity2 := mi2,
541 mobileIdentity3 := mi3,
542 mobileIdentity4 := mi4,
543 p3RestOctets := ?
544 }
545 }
546 }
547}
548
549
550
Harald Weltec76f29f2017-11-22 12:46:46 +0100551/* Send template for PAGING RESPONSE */
552template (value) PDU_ML3_MS_NW ts_PAG_RESP(MobileIdentityLV mi_lv) := {
553 discriminator := '0000'B, /* overwritten */
554 tiOrSkip := {
555 skipIndicator := '0000'B
556 },
557 msgs := {
558 rrm := {
559 pagingResponse := {
560 messageType := '00000000'B, /* overwritten */
561 cipheringKeySequenceNumber := { '000'B, '0'B },
562 spare1_4 := '0000'B,
563 mobileStationClassmark := ts_CM2,
564 mobileIdentity := mi_lv,
565 additionalUpdateParameters := omit
566 }
567 }
568 }
569}
570
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200571template ChannelDescription2_V tr_ChannelDescription2_V(template BIT3 timeslotNumber := ?,
572 template BIT5 channelTypeandTDMAOffset := ?) := {
573 timeslotNumber := timeslotNumber,
574 channelTypeandTDMAOffset := channelTypeandTDMAOffset,
575 octet3 := ?,
576 octet4 := ?
577}
578
579template ChannelMode_V tr_ChannelMode_V(template OCT1 mode) := {
580 mode := mode
581}
582
583template ExtendedTSCSet_TV tr_ExtendedTSCSet_TV(template BIT2 cSDomainTSCSet := ?) := {
584 elementIdentifier := '6D'O,
585 cSDomainTSCSet := cSDomainTSCSet,
586 secondPSDomainTSCAssigned := ?,
587 primaryPSDomainTSCSet := ?,
588 secondaryPSDomainTSCSet := ?,
589 secondaryPSDomainTSCValue := ?
590}
591
592template PDU_ML3_NW_MS tr_RRM_ModeModify(template ChannelDescription2_V desc := ?,
593 template ChannelMode_V mode := ?,
594 template ExtendedTSCSet_TV extendedTSCSet) := {
595 discriminator := '0110'B,
596 tiOrSkip := {
597 skipIndicator := '0000'B
598 },
599 msgs := {
600 rrm := {
601 channelModeModify := {
602 messageType := '00010000'B,
603 channelDescription := desc,
604 channelMode := mode,
605 vGCS_TargetModeIndication := omit,
606 multiRateConfiguration := omit,
607 vGCS_Ciphering_Parameters := omit,
608 extendedTSCSet := extendedTSCSet
609 }
610 }
611 }
612}
613
614template (value) PDU_ML3_MS_NW ts_RRM_ModeModifyAck(ChannelDescription2_V desc, ChannelMode_V mode,
615 template (omit) ExtendedTSCSet_TV extendedTSCSet := omit) := {
Harald Welte15166142017-12-16 23:02:08 +0100616 discriminator := '0000'B, /* overwritten */
617 tiOrSkip := {
618 skipIndicator := '0000'B
619 },
620 msgs := {
621 rrm := {
622 channelModeModifyAck := {
623 messageType := '00010111'B,
624 channelDescription := desc,
625 channelMode := mode,
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200626 extendedTSCSet := extendedTSCSet
Harald Welte15166142017-12-16 23:02:08 +0100627 }
628 }
629 }
630}
631
Harald Weltee613f962018-04-18 22:38:16 +0200632template (value) PDU_ML3_NW_MS ts_RRM_CiphModeCmd(BIT3 alg_id) := {
633 discriminator := '0000'B, /* overwritten */
634 tiOrSkip := {
635 skipIndicator := '0000'B
636 },
637 msgs := {
638 rrm := {
639 cipheringModeCommand := {
640 messageType := '00110101'B,
641 cipherModeSetting := {
642 sC := '1'B,
643 algorithmIdentifier := alg_id
644 },
645 cipherModeResponse := {
646 cR := '0'B,
647 spare := '000'B
648 }
649 }
650 }
651 }
652}
653
Harald Welte73cd2712017-12-17 00:44:52 +0100654template (value) PDU_ML3_MS_NW ts_RRM_CiphModeCompl := {
655 discriminator := '0000'B, /* overwritten */
656 tiOrSkip := {
657 skipIndicator := '0000'B
658 },
659 msgs := {
660 rrm := {
661 cipheringModeComplete := {
662 messageType := '00110010'B,
663 mobileEquipmentIdentity := omit
664 }
665 }
666 }
667}
668
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200669template ChannelMode_TV tr_ChannelMode_TV(template OCT1 mode) := {
670 elementIdentifier := '63'O,
671 mode := mode
672}
673
674template (present) PDU_ML3_NW_MS tr_RR_AssignmentCommand(
675 template ChannelDescription2_V desc := ?,
676 template ChannelMode_TV mode := ?,
677 template ExtendedTSCSet_TV extendedTSCSet := omit
678) := {
679 discriminator := '0110'B,
680 tiOrSkip := {
681 skipIndicator := '0000'B
682 },
683 msgs := {
684 rrm := {
685 assignmentCommand := {
686 messageType := '00101110'B,
687 descrOf1stChAfterTime := desc,
688 PowerCommand := ?,
689 frequencyList_at := omit,
690 cellChannelDescr := omit,
691 descrMultislotAllocation := omit,
692 modeOf1stChannel := mode,
693 channelSet2 := omit,
694 channelSet3 := omit,
695 channelSet4 := omit,
696 channelSet5 := omit,
697 channelSet6 := omit,
698 channelSet7 := omit,
699 channelSet8 := omit,
700 descrOf2ndChAfterTime := omit,
701 modeOf2ndChannel := omit,
702 mobileAllocation_at := omit,
703 startingTime := omit,
704 frequencyList_bt := omit,
705 descrOf1stCh_bt := omit,
706 descrOf2ndCh_bt := omit,
707 frequencyChannelSequence := omit,
708 mobileAllocation_bt := omit,
709 cipherModeSetting := omit,
710 vGCS_TargetModeIndication := omit,
711 multiRateConfiguration := omit,
712 vGCS_Ciphering_Parameters := omit,
713 extendedTSCSet_afterTime := extendedTSCSet,
714 extendedTSCSet_beforeTime := omit
715 }
716 }
717 }
718}
719
Harald Welteecb254b2018-01-29 22:01:54 +0100720template (value) PDU_ML3_MS_NW ts_RRM_AssignmentComplete(OCT1 cause) := {
721 discriminator := '0000'B, /* overwritten */
722 tiOrSkip := {
723 skipIndicator := '0000'B
724 },
725 msgs := {
726 rrm := {
727 assignmentComplete := {
728 messageType := '00101001'B,
729 rR_Cause := {
730 valuePart := cause
731 }
732 }
733 }
734 }
735}
Harald Welte15166142017-12-16 23:02:08 +0100736
Harald Welte898113b2018-01-31 18:32:21 +0100737template (value) PDU_ML3_MS_NW ts_RRM_AssignmentFailure(OCT1 cause) := {
738 discriminator := '0000'B, /* overwritten */
739 tiOrSkip := {
740 skipIndicator := '0000'B
741 },
742 msgs := {
743 rrm := {
744 assignmentFailure := {
745 messageType := '00101111'B,
746 rR_Cause := {
747 valuePart := cause
748 }
749 }
750 }
751 }
752}
753
Harald Weltefbf9b5e2018-01-31 20:41:23 +0100754template (value) PDU_ML3_MS_NW ts_RRM_HandoverFailure(OCT1 cause) := {
755 discriminator := '0000'B, /* overwritten */
756 tiOrSkip := {
757 skipIndicator := '0000'B
758 },
759 msgs := {
760 rrm := {
761 handoverFailure := {
762 messageType := '00101000'B,
763 rRCause := {
764 valuePart := cause
765 },
766 pSCause := omit
767 }
768 }
769 }
770}
Harald Welte898113b2018-01-31 18:32:21 +0100771
Harald Welte261af4b2018-02-12 21:20:39 +0100772template (value) PDU_ML3_MS_NW ts_RRM_HandoverComplete(OCT1 cause) := {
773 discriminator := '0000'B, /* overwritten */
774 tiOrSkip := {
775 skipIndicator := '0000'B
776 },
777 msgs := {
778 rrm := {
779 handoverComplete := {
780 messageType := '00101100'B,
781 rRCause := {
782 valuePart := cause
783 },
784 mobileObsservedTimeDiff := omit,
785 mobileTimeDifferenceHyperframe := omit
786 }
787 }
788 }
789}
790
Harald Welte187f7a92019-09-05 11:15:20 +0200791template (present) PDU_ML3_NW_MS tr_RR_APP_INFO(template (present) BIT4 apdu_id,
792 template (present) octetstring data,
793 template (present) APDU_Flags_V flags := ?) := {
794 discriminator := '0000'B, /* overwritten */
795 tiOrSkip := {
796 skipIndicator := '0000'B
797 },
798 msgs := {
799 rrm := {
800 applicationInformation := {
801 messageType := '00111000'B,
802 aPDU_ID := apdu_id,
803 aPDU_Flags := flags,
804 aPDU_Data := {
805 lengthIndicator := ?,
806 aPDU_DataValue := data
807 }
808 }
809 }
810 }
811}
812
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100813template (value) PDU_ML3_NW_MS ts_RR_HandoverCommand := {
814 discriminator := '0110'B,
815 tiOrSkip := {
816 skipIndicator := '0000'B
817 },
818 msgs := {
819 rrm := {
820 handoverCommand := {
821 messageType := '00101011'B,
822 cellDescription := {
823 bcc := '001'B,
824 ncc := '010'B,
825 BCCHArfcn_HighPart := '11'B,
826 BCCHArfcn_LowPart := '04'O
827 },
828 channelDescription2 := {
829 timeslotNumber := '110'B,
830 channelTypeandTDMAOffset := '00001'B,
831 octet3 := '00'O,
832 octet4 := '09'O
833 },
834 handoverReference := {
835 handoverReferenceValue := '00'O
836 },
837 powerCommandAndAccesstype := {
838 powerlevel := '00000'B,
839 fPC_EP := '0'B,
840 ePC_Mode := '0'B,
841 aTC := '0'B
842 },
843 synchronizationIndication := omit,
844 frequencyShortListAfterTime := omit,
845 frequencyListAfterTime := omit,
846 cellChannelDescription := omit,
847 multislotAllocation := omit,
848 modeOfChannelSet1 := omit,
849 modeOfChannelSet2 := omit,
850 modeOfChannelSet3 := omit,
851 modeOfChannelSet4 := omit,
852 modeOfChannelSet5 := omit,
853 modeOfChannelSet6 := omit,
854 modeOfChannelSet7 := omit,
855 modeOfChannelSet8 := omit,
856 descrOf2ndCh_at := omit,
857 modeOf2ndChannel := omit,
858 frequencyChannelSequence_at := omit,
859 mobileAllocation_at := omit,
860 startingTime := omit,
861 timeDifference := omit,
862 timingAdvance := omit,
863 frequencyShortListBeforeTime := omit,
864 frequencyListBeforeTime := omit,
865 descrOf1stCh_bt := omit,
866 descrOf2ndCh_bt := omit,
867 frequencyChannelSequence_bt := omit,
868 mobileAllocation_bt := omit,
869 cipherModeSetting := omit,
870 vGCS_TargetModeIndication := omit,
871 multiRateConfiguration := omit,
872 dynamicARFCN_Mapping := omit,
873 vGCS_Ciphering_Parameters := omit,
874 dedicatedServiceInformation := omit,
875 pLMNIndex := omit,
876 extendedTSCSet_afterTime := omit,
877 extendedTSCSet_beforeTime := omit
878 }
879 }
880 }
881}
882
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200883template PDU_ML3_NW_MS tr_RR_HandoverCommand := {
884 discriminator := '0110'B,
885 tiOrSkip := {
886 skipIndicator := '0000'B
887 },
888 msgs := {
889 rrm := {
890 handoverCommand := {
891 messageType := '00101011'B,
892 cellDescription := ?,
893 channelDescription2 := ?,
894 handoverReference := ?,
895 powerCommandAndAccesstype := ?,
896 synchronizationIndication := *,
897 frequencyShortListAfterTime := *,
898 frequencyListAfterTime := *,
899 cellChannelDescription := *,
900 multislotAllocation := *,
901 modeOfChannelSet1 := *,
902 modeOfChannelSet2 := *,
903 modeOfChannelSet3 := *,
904 modeOfChannelSet4 := *,
905 modeOfChannelSet5 := *,
906 modeOfChannelSet6 := *,
907 modeOfChannelSet7 := *,
908 modeOfChannelSet8 := *,
909 descrOf2ndCh_at := *,
910 modeOf2ndChannel := *,
911 frequencyChannelSequence_at := *,
912 mobileAllocation_at := *,
913 startingTime := *,
914 timeDifference := *,
915 timingAdvance := *,
916 frequencyShortListBeforeTime := *,
917 frequencyListBeforeTime := *,
918 descrOf1stCh_bt := *,
919 descrOf2ndCh_bt := *,
920 frequencyChannelSequence_bt := *,
921 mobileAllocation_bt := *,
922 cipherModeSetting := *,
923 vGCS_TargetModeIndication := *,
924 multiRateConfiguration := *,
925 dynamicARFCN_Mapping := *,
926 vGCS_Ciphering_Parameters := *,
927 dedicatedServiceInformation := *,
928 pLMNIndex := *,
929 extendedTSCSet_afterTime := *,
930 extendedTSCSet_beforeTime := *
931 }
932 }
933 }
934}
935
Harald Welte898113b2018-01-31 18:32:21 +0100936function ts_CM3_TLV(template (omit) OCTN cm3) return template MobileStationClassmark3_TLV {
937 if (not isvalue(cm3)) {
938 return omit;
939 }
940 var template MobileStationClassmark3_TLV ret := {
941 elementIdentifier := '20'O,
942 lengthIndicator := 0, /* overwritten */
943 valuePart := cm3
944 }
945 return ret;
946}
947
948template (value) PDU_ML3_MS_NW ts_RRM_CM_CHG(MobileStationClassmark2_LV cm2,
949 template (omit) MobileStationClassmark3_TLV cm3 := omit) := {
950 discriminator := '0110'B,
951 tiOrSkip := {
952 skipIndicator := '0000'B
953 },
954 msgs := {
955 rrm := {
956 classmarkChange := {
957 messageType := '00010110'B,
958 mobileStationClassmark2 := cm2,
959 mobileStationClassmark3 := cm3
960 }
961 }
962 }
963}
964
Neels Hofmeyr92b12b72018-09-18 14:30:23 +0200965template PDU_ML3_NW_MS tr_RRM_CM_ENQUIRY := {
966 discriminator := '0110'B,
967 tiOrSkip := {
968 skipIndicator := '0000'B
969 },
970 msgs := {
971 rrm := {
972 classmarkEnquiry := {
973 messageType := '00010011'B,
974 classmarkEnquiryMask := *
975 }
976 }
977 }
978}
979
Harald Weltee3bd6582018-01-31 22:51:25 +0100980template (value) PDU_ML3_MS_NW ts_RRM_UL_REL(OCT1 cause) := {
981 discriminator := '0110'B,
982 tiOrSkip := {
983 skipIndicator := '0000'B
984 },
985 msgs := {
986 rrm := {
987 uplinkRelease := {
988 messageType := '00001110'B,
989 rR_Cause := {
990 valuePart := cause
991 }
992 }
993 }
994 }
995}
996
997template PDU_ML3_MS_NW tr_RRM_RR_STATUS(template OCT1 cause := ?) := {
998 discriminator := '0110'B,
999 tiOrSkip := {
1000 skipIndicator := '0000'B
1001 },
1002 msgs := {
1003 rrm := {
1004 rR_Status := {
1005 messageType := '00010010'B,
1006 rR_Cause := {
1007 valuePart := cause
1008 }
1009 }
1010 }
1011 }
1012}
1013
Harald Welte924b6ea2019-02-04 01:05:34 +01001014template PDU_ML3_NW_MS tr_RRM_RR_RELEASE(template OCT1 cause := ?) := {
1015 discriminator := '0110'B,
1016 tiOrSkip := {
1017 skipIndicator := '0000'B
1018 },
1019 msgs := {
1020 rrm := {
1021 channelRelease := {
1022 messageType := '00001101'B,
1023 rRCause := {
1024 valuePart := cause
1025 },
1026 bARange := *,
1027 groupChannelDescription := *,
1028 groupCipherKeyNumber := *,
1029 gPRSResumption := *,
1030 bAListPref := *,
1031 uTRANFrequencyList := *,
1032 cellChannelDescr := *,
1033 cellSelectionIndicator := *,
1034 enhanced_DTM_CS_Release_Indication := *,
1035 vGCS_Ciphering_Parameters := *,
1036 group_Channel_Description_2 := *,
1037 talkerIdentity := *,
1038 talkerPriorityStatus := *,
1039 vGCS_AMR_Configuration := *,
1040 individual_Priorities := *
1041 }
1042 }
1043 }
1044}
Harald Weltee3bd6582018-01-31 22:51:25 +01001045
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001046template PDU_ML3_NW_MS tr_RRM_RR_RELEASE_CellSelectInd(template OCT1 cause := ?) modifies tr_RRM_RR_RELEASE := {
Harald Welte99787102019-02-04 10:41:36 +01001047 msgs := {
1048 rrm := {
1049 channelRelease := {
1050 cellSelectionIndicator := {
1051 elementIdentifier := '77'O,
1052 lengthIndicator := ?,
1053 cellSelectionIndicatorValue := ?
1054 }
1055 }
1056 }
1057 }
1058}
Harald Weltee3bd6582018-01-31 22:51:25 +01001059
Harald Weltecb6cc332018-01-21 13:59:08 +01001060template PDU_ML3_MS_NW ts_ML3_MO := {
1061 discriminator := '0000'B,
1062 tiOrSkip := {
1063 skipIndicator := '0000'B
1064 },
1065 msgs := ?
1066}
1067
1068template LocationUpdatingType ts_ML3_IE_LuType := {
1069 lut := ?,
1070 spare1_1 := '0'B,
1071 fop := '0'B
1072}
1073
1074template LocationUpdatingType ts_ML3_IE_LuType_Normal modifies ts_ML3_IE_LuType := {
1075 lut := '00'B
1076}
1077
1078template LocationUpdatingType ts_ML3_IE_LuType_Periodic modifies ts_ML3_IE_LuType := {
1079 lut := '01'B
1080}
1081
1082template LocationUpdatingType ts_ML3_IE_LuType_Attach modifies ts_ML3_IE_LuType := {
1083 lut := '10'B
1084}
1085
1086template CipheringKeySequenceNumberV ts_ML3_IE_CKSN(integer cksn) := {
1087 keySequence := int2bit(cksn, 3),
1088 spare := '0'B
1089}
1090
1091template PDU_ML3_MS_NW ts_ML3_MO_LU_Req(LocationUpdatingType lu_type, LocationAreaIdentification_V lai,
1092 MobileIdentityLV mi, MobileStationClassmark1_V cm1)
1093modifies ts_ML3_MO := {
1094 msgs := {
1095 mm := {
1096 locationUpdateRequest := {
1097 messageType := '001000'B,
1098 nsd := '00'B, /* ? */
1099 locationUpdatingType := lu_type,
1100 cipheringKeySequenceNumber := ts_ML3_IE_CKSN(0),
1101 locationAreaIdentification := lai,
1102 mobileStationClassmark1 := cm1,
1103 mobileIdentityLV := mi,
1104 classmarkInformationType2_forUMTS := omit,
1105 additionalUpdateParameterTV := omit,
1106 deviceProperties := omit,
1107 mS_NetworkFeatureSupport := omit
1108 }
1109 }
1110 }
1111}
1112
Harald Welte6ff81902018-01-21 19:09:08 +01001113template PDU_ML3_MS_NW ts_ML3_MO_TmsiRealloc_Cmpl modifies ts_ML3_MO := {
1114 msgs := {
1115 mm := {
1116 tmsiReallocComplete := {
1117 messageType := '011011'B,
1118 nsd := '00'B
1119 }
1120 }
1121 }
1122}
1123
1124template PDU_ML3_NW_MS tr_ML3_MT_LU_Acc := {
1125 discriminator := '0101'B,
1126 tiOrSkip := {
1127 skipIndicator := '0000'B
1128 },
1129 msgs := {
1130 mm := {
1131 locationUpdateAccept := {
1132 messageType := '000010'B,
1133 nsd := '00'B,
1134 locationAreaIdentification := ?,
1135 mobileIdentityTLV := *,
1136 followOnProceed := *,
1137 cTS_Permission := *,
1138 equivalentPLMNs := *,
1139 emergencyNumberList := *,
1140 perMS_T3212 := *
1141 }
1142 }
1143 }
1144}
1145
1146template PDU_ML3_NW_MS tr_ML3_MT_LU_Rej(template OCT1 cause := ?) := {
1147 discriminator := '0101'B,
1148 tiOrSkip := {
1149 skipIndicator := '0000'B
1150 },
1151 msgs := {
1152 mm := {
1153 locationUpdateReject := {
1154 messageType := '000100'B,
1155 nsd := '00'B,
1156 rejectCause := cause,
1157 t3246_Value := *
1158 }
1159 }
1160 }
1161}
1162
Oliver Smithaf2f1f82019-07-19 12:33:12 +02001163private function f_id_type_or_any(template CmIdentityType id_type) return template bitstring {
1164 if (istemplatekind(id_type, "?")) {
1165 return ?;
1166 } else {
1167 return int2bit(enum2int(valueof(id_type)), 3);
1168 }
1169}
1170
Oliver Smith32898452019-07-09 12:32:35 +02001171template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
Harald Welteba7b6d92018-01-23 21:32:34 +01001172 discriminator := '0101'B,
1173 tiOrSkip := {
1174 skipIndicator := '0000'B
1175 },
1176 msgs := {
1177 mm := {
1178 identityRequest := {
1179 messageType := '011000'B,
1180 nsd := '00'B,
Oliver Smithaf2f1f82019-07-19 12:33:12 +02001181 identityType := f_id_type_or_any(id_type),
Harald Welteba7b6d92018-01-23 21:32:34 +01001182 spare1_5 := ?
1183 }
1184 }
1185 }
1186}
1187
1188template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp(MobileIdentityLV mi) modifies ts_ML3_MO := {
1189 msgs := {
1190 mm := {
1191 identityResponse := {
1192 messageType := '011001'B,
1193 nsd := '00'B,
1194 mobileIdentityLV := mi,
1195 p_TMSI_TypeTV := omit,
1196 routingAreaIdentification2TLV := omit,
1197 p_TMSISignature2TLV := omit
1198 }
1199 }
1200 }
1201}
1202template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMSI(hexstring imsi) :=
1203 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMSI_LV(imsi)));
1204template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMEI(hexstring imei) :=
1205 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMEI_LV(imei)));
1206
1207
Neels Hofmeyr63382472018-03-01 19:57:44 +01001208template (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 +01001209 rf_PowerCapability := '010'B,
1210 a5_1 := a5_1_unavail,
Neels Hofmeyr63382472018-03-01 19:57:44 +01001211 esind := esind,
Harald Welte45164da2018-01-24 12:51:27 +01001212 revisionLevel := rev,
1213 spare1_1 := '0'B
1214}
1215
1216template PDU_ML3_MS_NW ts_ML3_MO_MM_IMSI_DET_Ind(MobileIdentityLV mi,
1217 template MobileStationClassmark1_V cm1 := ts_CM1)
1218modifies ts_ML3_MO := {
1219 msgs := {
1220 mm := {
1221 imsiDetachIndication := {
1222 messageType := '000001'B,
1223 nsd := '00'B,
1224 mobileStationClassmark1 := cm1,
1225 mobileIdentityLV := mi
1226 }
1227 }
1228 }
1229}
1230
Harald Welted748a052018-01-22 02:59:24 +01001231template PDU_ML3_MS_NW ts_ML3_MO_CC(integer tid) := {
1232 discriminator := '0011'B,
1233 tiOrSkip := {
1234 transactionId := {
Daniel Willmanndcf9eb92018-02-02 20:07:52 +01001235 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001236 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001237 tIExtension := omit
1238 }
Harald Welte9bf43cc2020-08-21 12:33:18 +02001239 },
1240 msgs := -
Harald Welted748a052018-01-22 02:59:24 +01001241}
1242
1243template (value) CalledPartyBCD_Number ts_Called(hexstring digits) := {
1244 elementIdentifier := '5E'O,
1245 lengthIndicator := 0, /* overwritten */
1246 numberingPlanIdentification := '0000'B,
1247 typeOfNumber := '000'B, /* unknown */
Vadim Yanitskiy559f5dc2021-02-05 03:08:11 +01001248 ext1 := '1'B, /* no extension */
Harald Welted748a052018-01-22 02:59:24 +01001249 digits := digits
1250}
1251
Harald Welte812f7a42018-01-27 00:49:18 +01001252template CalledPartyBCD_Number tr_Called(template hexstring digits) := {
1253 elementIdentifier := '5E'O,
1254 lengthIndicator := ?,
1255 numberingPlanIdentification := ?,
1256 typeOfNumber := ?,
Vadim Yanitskiy559f5dc2021-02-05 03:08:11 +01001257 ext1 := '1'B, /* no extension */
Harald Welte812f7a42018-01-27 00:49:18 +01001258 digits := digits
1259}
1260
Stefan Sperling26d57be2018-11-12 17:03:26 +01001261private function f_pad_digits(hexstring digits) return hexstring {
1262 if (lengthof(digits) mod 2 != 0) {
1263 /* Add trailing nibble of 1-bit padding, like the CallingPartyBCD_Number encoder would do.
1264 * Otherwise our template won't match the data received (see OS#2930). */
1265 return digits & 'F'H;
1266 }
1267 return digits;
1268}
1269
Harald Welte812f7a42018-01-27 00:49:18 +01001270template CallingPartyBCD_Number tr_Calling(template hexstring digits) := {
1271 elementIdentifier := '5C'O,
1272 lengthIndicator := ?,
1273 oct3 := ?,
Stefan Sperling26d57be2018-11-12 17:03:26 +01001274 digits := f_pad_digits(valueof(digits))
Harald Welte812f7a42018-01-27 00:49:18 +01001275}
1276
Harald Welte4b2b3a62018-01-26 10:32:39 +01001277type integer SpeechVer;
1278
1279template (value) Speech_AuxiliarySpeech ts_SpeechAux(SpeechVer ver, BIT1 suffix) := {
1280 speechVersionIndication := int2bit(ver-1,3) & suffix,
1281 spare1_1 := '0'B,
1282 cTM_or_Spare := '0'B,
1283 coding := '0'B,
1284 extension_octet_3a_3b := '0'B
1285}
1286
1287template (value) Speech_AuxiliarySpeech ts_SpeechAuxFR(SpeechVer ver) := ts_SpeechAux(ver, '0'B);
1288template (value) Speech_AuxiliarySpeech ts_SpeechAuxHR(SpeechVer ver) := ts_SpeechAux(ver, '1'B);
1289
Harald Welted748a052018-01-22 02:59:24 +01001290template (value) BearerCapability_TLV ts_Bcap_voice := {
1291 elementIdentifier := '04'O,
1292 lengthIndicator := 0, /* overwritten */
1293 octet3 := {
1294 informationTransferCapability := '000'B,
1295 transferMode := '0'B,
1296 codingStandard := '0'B,
1297 radioChannelRequirement := '11'B, /* FR preferred */
1298 extension_octet_3 := '0'B, /* overwritten */
Harald Welte4b2b3a62018-01-26 10:32:39 +01001299 speech_aux_3a_3b := {
1300 valueof(ts_SpeechAuxHR(3)),
1301 valueof(ts_SpeechAuxFR(3)),
1302 valueof(ts_SpeechAuxFR(2)),
1303 valueof(ts_SpeechAuxFR(1)),
1304 valueof(ts_SpeechAuxHR(1))
1305 }
Harald Welted748a052018-01-22 02:59:24 +01001306 },
1307 octet4 := omit,
1308 octet5 := omit,
1309 octet6 := omit,
1310 octet7 := omit
1311}
1312
1313template PDU_ML3_MS_NW ts_ML3_MO_CC_SETUP(integer tid, hexstring called, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1314 discriminator := '0011'B,
1315 tiOrSkip := {
1316 transactionId := {
1317 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001318 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001319 tIExtension := omit
1320 }
1321 },
1322 msgs := {
1323 cc := {
1324 setup_MS_NW := {
1325 messageType := '000101'B,
1326 nsd := '00'B,
1327 bcRepeatIndicator := omit,
1328 bearerCapability1 := bcap,
1329 bearerCapability2 := omit,
1330 facility := omit,
1331 callingPartySubAddress := omit,
1332 calledPartyBCD_Number := ts_Called(called),
1333 calledPartySubAddress := omit,
1334 llc_RepeatIndicator := omit,
1335 lowLayerCompatibility1 := omit,
1336 lowLayerCompatibility2 := omit,
1337 hlc_RepeatIndicator := omit,
1338 highLayerCompatibility1 := omit,
1339 highLayerCompatibility2 := omit,
1340 user_user := omit,
1341 ss_VersionIndicator := omit,
1342 clir_Suppression := omit,
1343 clir_Invocation := omit,
1344 cC_Capabilities := omit,
1345 facility_ccbs1 := omit,
1346 facility_ccbs2 := omit,
1347 streamIdentifier := omit,
1348 supportedCodecs := omit,
1349 redial := omit
1350 }
1351 }
1352 }
1353}
1354
Harald Welte45164da2018-01-24 12:51:27 +01001355template PDU_ML3_MS_NW ts_ML3_MO_CC_EMERG_SETUP(integer tid, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1356 discriminator := '0011'B,
1357 tiOrSkip := {
1358 transactionId := {
1359 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001360 tiFlag := c_TIF_ORIG,
Harald Welte45164da2018-01-24 12:51:27 +01001361 tIExtension := omit
1362 }
1363 },
1364 msgs := {
1365 cc := {
1366 emergencySetup := {
1367 messageType := '001110'B,
1368 nsd := '00'B,
1369 bearerCapability := bcap,
1370 streamIdentifier := omit,
1371 supportedCodecs := omit,
1372 emergencyCategory := omit
1373 }
1374 }
1375 }
1376}
1377
1378
Harald Welted748a052018-01-22 02:59:24 +01001379template PDU_ML3_NW_MS tr_ML3_MT_CC_CALL_PROC(integer tid) := {
1380 discriminator := '0011'B,
1381 tiOrSkip := {
1382 transactionId := {
1383 tio := int2bit(tid, 3),
1384 tiFlag := ?,
1385 tIExtension := omit
1386 }
1387 },
1388 msgs := {
1389 cc := {
1390 callProceeding := {
1391 messageType := '000010'B,
1392 nsd := '00'B,
1393 repeatIndicator := *,
1394 bearerCapability1 := *,
1395 bearerCapability2 := *,
1396 facility := *,
1397 progressIndicator := *,
1398 priorityGranted := *,
1399 networkCCCapabilities := *
1400 }
1401 }
1402 }
1403}
1404
1405template PDU_ML3_NW_MS tr_ML3_MT_CC_ALERTING(integer tid) := {
1406 discriminator := '0011'B,
1407 tiOrSkip := {
1408 transactionId := {
1409 tio := int2bit(tid, 3),
1410 tiFlag := ?,
1411 tIExtension := omit
1412 }
1413 },
1414 msgs := {
1415 cc := {
1416 alerting_NW_MS := {
1417 messageType := '000001'B,
1418 nsd := '00'B,
1419 facility := *,
1420 progressIndicator := *,
1421 user_user := *
1422 }
1423 }
1424 }
1425}
1426
Harald Welte33ec09b2018-02-10 15:34:46 +01001427template PDU_ML3_MS_NW ts_ML3_MO_CC_ALERTING(integer tid) := {
1428 discriminator := '0011'B,
1429 tiOrSkip := {
1430 transactionId := {
1431 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001432 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001433 tIExtension := omit
1434 }
1435 },
1436 msgs := {
1437 cc := {
1438 alerting_MS_NW := {
1439 messageType := '000001'B,
1440 nsd := '00'B,
1441 facility := omit,
1442 user_user := omit,
1443 ss_VersionIndicator := omit
1444 }
1445 }
1446 }
1447}
1448
1449template PDU_ML3_MS_NW ts_ML3_MT_CC_ALERTING(integer tid) := {
1450 discriminator := '0011'B,
1451 tiOrSkip := {
1452 transactionId := {
1453 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001454 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001455 tIExtension := omit
1456 }
1457 },
1458 msgs := {
1459 cc := {
1460 alerting_MS_NW := {
1461 messageType := '000001'B,
1462 nsd := '00'B,
1463 facility := omit,
1464 user_user := omit,
1465 ss_VersionIndicator := omit
1466 }
1467 }
1468 }
1469}
1470
1471template PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT(integer tid) := {
1472 discriminator := '0011'B,
1473 tiOrSkip := {
1474 transactionId := {
1475 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001476 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001477 tIExtension := omit
1478 }
1479 },
1480 msgs := {
1481 cc := {
1482 connect_MS_NW := {
1483 messageType := '000111'B,
1484 nsd := '00'B,
1485 facility := omit,
1486 connectedSubAddress := omit,
1487 user_user := omit,
1488 ss_VersionIndicator := omit,
1489 streamIdentifier := omit
1490 }
1491 }
1492 }
1493}
1494
Harald Welte4017d552018-01-26 21:40:05 +01001495template PDU_ML3_NW_MS tr_ML3_MT_CC_CONNECT(integer tid) := {
1496 discriminator := '0011'B,
1497 tiOrSkip := {
1498 transactionId := {
1499 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001500 tiFlag := c_TIF_REPL,
Harald Welte4017d552018-01-26 21:40:05 +01001501 tIExtension := omit
1502 }
1503 },
1504 msgs := {
1505 cc := {
1506 connect_NW_MS := {
1507 messageType := '000111'B,
1508 nsd := '00'B,
1509 facility := *,
1510 progressIndicator := *,
1511 connectedNumber := *,
1512 connectedSubAddress := *,
1513 user_user := *
1514 }
1515 }
1516 }
1517}
1518
1519template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT_ACK(integer tid) := {
1520 discriminator := '0011'B,
1521 tiOrSkip := {
1522 transactionId := {
1523 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001524 tiFlag := c_TIF_ORIG,
Harald Welte4017d552018-01-26 21:40:05 +01001525 tIExtension := omit
1526 }
1527 },
1528 msgs := {
1529 cc := {
1530 connectAck := {
1531 messageType := '001111'B,
1532 nsd := '00'B
1533 }
1534 }
1535 }
1536}
1537
Daniel Willmann8b084372018-02-04 13:35:26 +01001538template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_START_DTMF(integer tid, charstring number) := {
1539 discriminator := '0011'B,
1540 tiOrSkip := {
1541 transactionId := {
1542 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001543 tiFlag := c_TIF_ORIG,
Daniel Willmann8b084372018-02-04 13:35:26 +01001544 tIExtension := omit
1545 }
1546 },
1547 msgs := {
1548 cc := {
1549 startDTMF := {
1550 messageType := '110101'B,
1551 nsd := '00'B,
1552 keypadFacility := {
1553 elementIdentifier := '2C'O,
1554 keypadInformation := int2bit(char2int(number), 7),
1555 spare_1 := '0'B
1556 }
1557 }
1558 }
1559 }
1560}
1561
Harald Welte2bb825f2018-01-22 11:31:18 +01001562template PDU_ML3_NW_MS tr_ML3_MT_CC_DISC(integer tid) := {
1563 discriminator := '0011'B,
1564 tiOrSkip := {
1565 transactionId := {
1566 tio := int2bit(tid, 3),
1567 tiFlag := ?,
1568 tIExtension := omit
1569 }
1570 },
1571 msgs := {
1572 cc := {
1573 disconnect_NW_MS := {
1574 messageType := '100101'B,
1575 nsd := '00'B,
1576 cause := ?,
1577 facility := *,
1578 progressIndicator := *,
1579 user_user := *,
1580 allowedActions := *
1581 }
1582 }
1583 }
1584}
1585
Neels Hofmeyre51ce492021-07-27 22:30:08 +02001586template PDU_ML3_MS_NW ts_ML3_MO_CC_DISC(integer tid, BIT1 tid_remote, BIT7 cause) := {
1587 discriminator := '0011'B,
1588 tiOrSkip := {
1589 transactionId := {
1590 tio := int2bit(tid, 3),
1591 tiFlag := tid_remote,
1592 tIExtension := omit
1593 }
1594 },
1595 msgs := {
1596 cc := {
1597 disconnect_MS_NW := {
1598 messageType := '100101'B,
1599 nsd := '00'B,
1600 cause := ts_ML3_Cause_LV(cause),
1601 facility := omit,
1602 user_user := omit,
1603 ss_VersionIndicator := omit
1604 }
1605 }
1606 }
1607}
1608
Harald Welte2bb825f2018-01-22 11:31:18 +01001609template PDU_ML3_NW_MS tr_ML3_MT_CC_RELEASE(integer tid) := {
1610 discriminator := '0011'B,
1611 tiOrSkip := {
1612 transactionId := {
1613 tio := int2bit(tid, 3),
1614 tiFlag := ?,
1615 tIExtension := omit
1616 }
1617 },
1618 msgs := {
1619 cc := {
1620 release_NW_MS := {
1621 messageType := '101101'B,
1622 nsd := '00'B,
1623 cause := ?,
1624 secondCause := *,
1625 facility := *,
1626 user_user := *
1627 }
1628 }
1629 }
1630}
Harald Welted748a052018-01-22 02:59:24 +01001631
Harald Welte33ec09b2018-02-10 15:34:46 +01001632template PDU_ML3_MS_NW ts_ML3_MO_CC_RELEASE(integer tid, BIT1 tid_remote, BIT7 cause) := {
1633 discriminator := '0011'B,
1634 tiOrSkip := {
1635 transactionId := {
1636 tio := int2bit(tid, 3),
1637 tiFlag := tid_remote,
1638 tIExtension := omit
1639 }
1640 },
1641 msgs := {
1642 cc := {
1643 release_MS_NW := {
1644 messageType := '101101'B,
1645 nsd := '00'B,
1646 cause := ts_ML3_Cause(cause),
1647 secondCause := omit,
1648 facility := omit,
1649 user_user := omit,
1650 ss_VersionIndicator := omit
1651 }
1652 }
1653 }
1654}
1655
1656
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001657template (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 +01001658 discriminator := '0011'B,
1659 tiOrSkip := {
1660 transactionId := {
1661 tio := int2bit(tid, 3),
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001662 tiFlag := tid_remote,
Harald Welteb71901a2018-01-26 19:16:05 +01001663 tIExtension := omit
1664 }
1665 },
1666 msgs := {
1667 cc := {
1668 releaseComplete_MS_NW := {
1669 messageType := '101010'B,
1670 nsd := '00'B,
1671 cause := omit,
1672 facility := omit,
1673 user_user := omit,
1674 ss_VersionIndicator := omit
1675 }
1676 }
1677 }
1678}
1679
Harald Welte33ec09b2018-02-10 15:34:46 +01001680template PDU_ML3_NW_MS tr_ML3_MT_CC_REL_COMPL(integer tid) := {
1681 discriminator := '0011'B,
1682 tiOrSkip := {
1683 transactionId := {
1684 tio := int2bit(tid, 3),
1685 tiFlag := ?,
1686 tIExtension := omit
1687 }
1688 },
1689 msgs := {
1690 cc := {
1691 releaseComplete_NW_MS := {
1692 messageType := '101010'B,
1693 nsd := '00'B,
1694 cause := *,
1695 facility := *,
1696 user_user := *
1697 }
1698 }
1699 }
1700}
1701
1702
Harald Welteb71901a2018-01-26 19:16:05 +01001703
Harald Welte77a8eba2018-01-22 21:22:32 +01001704template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ(template OCT16 rand := ?) := {
1705 discriminator := '0101'B,
1706 tiOrSkip := {
1707 skipIndicator := '0000'B
1708 },
1709 msgs := {
1710 mm := {
1711 authenticationRequest := {
1712 messageType := '010010'B,
1713 nsd := '00'B,
1714 cipheringKeySequenceNumber := ?,
1715 spare2_4 := ?,
1716 authenticationParRAND := rand,
1717 authenticationParAUTN := *
1718 }
1719 }
1720 }
1721}
1722
Harald Welte0cedf2c2018-10-28 23:28:35 +01001723template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ_3G(template OCT16 rand := ?, template OCT16 autn) := {
1724 discriminator := '0101'B,
1725 tiOrSkip := {
1726 skipIndicator := '0000'B
1727 },
1728 msgs := {
1729 mm := {
1730 authenticationRequest := {
1731 messageType := '010010'B,
1732 nsd := '00'B,
1733 cipheringKeySequenceNumber := ?,
1734 spare2_4 := ?,
1735 authenticationParRAND := rand,
1736 authenticationParAUTN := {
1737 elementIdentifier := '20'O,
1738 lengthIndicator := ?,
1739 autnValue := autn
1740 }
1741 }
1742 }
1743 }
1744}
1745
Harald Welte77a8eba2018-01-22 21:22:32 +01001746template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_2G(OCT4 sres) := {
1747 discriminator := '0101'B,
1748 tiOrSkip := {
1749 skipIndicator := '0000'B
1750 },
1751 msgs := {
1752 mm := {
1753 authenticationResponse := {
1754 messageType := '010100'B,
1755 nsd := '00'B,
1756 authenticationParSRES := sres,
1757 authenticationParSRESext := omit
1758 }
1759 }
1760 }
1761}
1762
1763template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_3G(OCT4 sres, octetstring res) := {
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 := {
1775 elementIdentifier := '21'O,
1776 lengthIndicator := 0, /* overwritten */
1777 valueField := res
1778 }
1779 }
1780 }
1781 }
1782}
Harald Weltecb6cc332018-01-21 13:59:08 +01001783
Harald Welte812f7a42018-01-27 00:49:18 +01001784template PDU_ML3_MS_NW ts_ML3_MO_CC_CALL_CONF(integer tid,
1785 template BearerCapability_TLV bcap := omit) := {
1786 discriminator := '0011'B,
1787 tiOrSkip := {
1788 transactionId := {
1789 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001790 tiFlag := c_TIF_REPL, /* response from destination */
Harald Welte812f7a42018-01-27 00:49:18 +01001791 tIExtension := omit
1792 }
1793 },
1794 msgs := {
1795 cc := {
1796 callConfirmed := {
1797 messageType := '001000'B,
1798 nsd := '00'B,
1799 repeatIndicator := omit,
1800 bearerCapability1 := bcap,
1801 bearerCapability2 := omit,
1802 cause := omit,
1803 cC_Capabilities := omit,
1804 streamIdentifier := omit,
1805 supportedCodecs := omit
1806 }
1807 }
1808 }
1809}
1810
1811
1812template PDU_ML3_NW_MS tr_ML3_MT_CC_SETUP(integer tid, template hexstring called := *,
1813 template hexstring calling := *,
1814 template BearerCapability_TLV bcap := *) := {
1815 discriminator := '0011'B,
1816 tiOrSkip := {
1817 transactionId := {
1818 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001819 tiFlag := c_TIF_ORIG, /* from originator */
Harald Welte812f7a42018-01-27 00:49:18 +01001820 tIExtension := omit
1821 }
1822 },
1823 msgs := {
1824 cc := {
1825 setup_NW_MS := {
1826 messageType := '000101'B,
1827 nsd := '00'B,
1828 bcRepeatIndicator := *,
1829 bearerCapability1 := bcap,
1830 bearerCapability2 := *,
1831 facility := *,
1832 progressIndicator := *,
1833 signal := *,
1834 callingPartyBCD_Number := tr_Calling(calling) ifpresent,
1835 callingPartySubAddress := *,
1836 calledPartyBCD_Number := tr_Called(called) ifpresent,
1837 calledPartySubAddress := *,
1838 redirectingPartyBCDNumber := *,
1839 redirectingPartySubaddress := *,
1840 llc_RepeatIndicator := *,
1841 lowLayerCompatibility1 := *,
1842 lowLayerCompatibility2 := *,
1843 hlc_RepeatIndicator := *,
1844 highLayerCompatibility1 := *,
1845 highLayerCompatibility2 := *,
1846 user_user := *,
1847 priority := *,
1848 alert := *,
1849 networkCCCapabilities := *,
1850 causeofNoCli := *,
1851 backupBearerCapacity := *
1852 }
1853 }
1854 }
1855}
1856
Harald Welte38575a72018-02-15 20:41:37 +01001857/***********************************************************************
Harald Welte53603962018-05-28 11:13:09 +02001858 * Supplementary Services
1859 ***********************************************************************/
1860
1861private template (value) Facility_TLV ts_FacTLV(OCTN facility) := {
1862 elementIdentifier := '1C'O,
1863 lengthIndicator := lengthof(facility),
1864 facilityInformation := facility
1865}
1866private template Facility_TLV tr_FacTLV(template OCTN facility) := {
1867 elementIdentifier := '1C'O,
1868 lengthIndicator := ?,
1869 facilityInformation := facility
1870}
1871
1872private template (value) Facility_LV ts_FacLV(OCTN facility) := {
1873 lengthIndicator := lengthof(facility),
1874 facilityInformation := facility
1875}
1876private template Facility_LV tr_FacLV(template OCTN facility) := {
1877 lengthIndicator := ?,
1878 facilityInformation := facility
1879}
1880
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001881private function f_facility_or_omit(template (omit) OCTN facility)
1882return template (omit) Facility_TLV {
1883 if (istemplatekind(facility, "omit")) {
1884 return omit;
1885 } else {
1886 return ts_FacTLV(valueof(facility));
1887 }
1888}
1889private function f_facility_or_wc(template OCTN facility)
1890return template Facility_TLV {
1891 if (istemplatekind(facility, "*")) {
1892 return *;
1893 } else if (istemplatekind(facility, "?")) {
1894 return ?;
Vadim Yanitskiy52f8b6e2018-06-19 17:32:46 +07001895 } else if (istemplatekind(facility, "omit")) {
1896 return omit;
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001897 } else {
1898 return tr_FacTLV(facility);
1899 }
1900}
1901
Harald Welte53603962018-05-28 11:13:09 +02001902template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_REGISTER(
1903 uint3_t tid, BIT1 ti_flag,
1904 OCTN facility,
1905 template (omit) SS_VersionIndicator ss_ver := omit
1906) := {
1907 discriminator := '1011'B,
1908 tiOrSkip := {
1909 transactionId := {
1910 tio := int2bit(tid, 3),
1911 tiFlag := ti_flag,
1912 tIExtension := omit
1913 }
1914 },
1915 msgs := {
1916 ss := {
1917 register := {
1918 messageType := '111011'B,
1919 nsd := '00'B,
1920 facility := ts_FacTLV(facility),
1921 ss_version := ss_ver
1922 }
1923 }
1924 }
1925}
1926template PDU_ML3_MS_NW tr_ML3_MO_SS_REGISTER(
1927 template uint3_t tid, template BIT1 ti_flag,
1928 template OCTN facility,
1929 template SS_VersionIndicator ss_ver := omit
1930) := {
1931 discriminator := '1011'B,
1932 tiOrSkip := {
1933 transactionId := {
1934 tio := f_tid_or_wc(tid),
1935 tiFlag := ti_flag,
1936 tIExtension := omit
1937 }
1938 },
1939 msgs := {
1940 ss := {
1941 register := {
1942 messageType := '111011'B,
1943 nsd := '00'B,
1944 facility := tr_FacTLV(facility),
1945 ss_version := ss_ver
1946 }
1947 }
1948 }
1949}
1950
1951template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_REGISTER(
1952 uint3_t tid, BIT1 ti_flag,
1953 OCTN facility
1954) := {
1955 discriminator := '1011'B,
1956 tiOrSkip := {
1957 transactionId := {
1958 tio := int2bit(tid, 3),
1959 tiFlag := ti_flag,
1960 tIExtension := omit
1961 }
1962 },
1963 msgs := {
1964 ss := {
1965 register := {
1966 messageType := '111011'B,
1967 nsd := '00'B,
1968 facility := ts_FacTLV(facility)
1969 }
1970 }
1971 }
1972}
1973template PDU_ML3_NW_MS tr_ML3_MT_SS_REGISTER(
1974 template uint3_t tid, template BIT1 ti_flag,
1975 template OCTN facility
1976) := {
1977 discriminator := '1011'B,
1978 tiOrSkip := {
1979 transactionId := {
1980 tio := f_tid_or_wc(tid),
1981 tiFlag := ti_flag,
1982 tIExtension := omit
1983 }
1984 },
1985 msgs := {
1986 ss := {
1987 register := {
1988 messageType := '111011'B,
1989 nsd := '00'B,
1990 facility := tr_FacTLV(facility)
1991 }
1992 }
1993 }
1994}
1995
1996template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_FACILITY(
1997 uint3_t tid, BIT1 ti_flag,
1998 OCTN facility
1999) := {
2000 discriminator := '1011'B,
2001 tiOrSkip := {
2002 transactionId := {
2003 tio := int2bit(tid, 3),
2004 tiFlag := ti_flag,
2005 tIExtension := omit
2006 }
2007 },
2008 msgs := {
2009 ss := {
2010 facility := {
2011 messageType := '111010'B,
2012 nsd := '00'B,
2013 facility := ts_FacLV(facility)
2014 }
2015 }
2016 }
2017}
2018template PDU_ML3_MS_NW tr_ML3_MO_SS_FACILITY(
2019 template uint3_t tid, template BIT1 ti_flag,
2020 template OCTN facility
2021) := {
2022 discriminator := '1011'B,
2023 tiOrSkip := {
2024 transactionId := {
2025 tio := f_tid_or_wc(tid),
2026 tiFlag := ti_flag,
2027 tIExtension := omit
2028 }
2029 },
2030 msgs := {
2031 ss := {
2032 facility := {
2033 messageType := '111010'B,
2034 nsd := '00'B,
2035 facility := tr_FacLV(facility)
2036 }
2037 }
2038 }
2039}
2040
2041template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_FACILITY(
2042 uint3_t tid, BIT1 ti_flag,
2043 OCTN facility
2044) := {
2045 discriminator := '1011'B,
2046 tiOrSkip := {
2047 transactionId := {
2048 tio := int2bit(tid, 3),
2049 tiFlag := ti_flag,
2050 tIExtension := omit
2051 }
2052 },
2053 msgs := {
2054 ss := {
2055 facility := {
2056 messageType := '111010'B,
2057 nsd := '00'B,
2058 facility := ts_FacLV(facility)
2059 }
2060 }
2061 }
2062}
2063template PDU_ML3_NW_MS tr_ML3_MT_SS_FACILITY(
2064 template uint3_t tid, template BIT1 ti_flag,
2065 template OCTN facility
2066) := {
2067 discriminator := '1011'B,
2068 tiOrSkip := {
2069 transactionId := {
2070 tio := f_tid_or_wc(tid),
2071 tiFlag := ti_flag,
2072 tIExtension := omit
2073 }
2074 },
2075 msgs := {
2076 ss := {
2077 facility := {
2078 messageType := '111010'B,
2079 nsd := '00'B,
2080 facility := tr_FacLV(facility)
2081 }
2082 }
2083 }
2084}
2085
Vadim Yanitskiy03198132018-05-29 03:35:16 +07002086template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_RELEASE_COMPLETE(
2087 uint3_t tid, BIT1 ti_flag,
2088 template (omit) ML3_Cause_TLV cause := omit,
2089 template (omit) OCTN facility := omit
2090) := {
2091 discriminator := '1011'B,
2092 tiOrSkip := {
2093 transactionId := {
2094 tio := int2bit(tid, 3),
2095 tiFlag := ti_flag,
2096 tIExtension := omit
2097 }
2098 },
2099 msgs := {
2100 ss := {
2101 releaseComplete_MS_NW := {
2102 messageType := '101010'B,
2103 nsd := '00'B,
2104 cause := cause,
2105 facility := f_facility_or_omit(facility)
2106 }
2107 }
2108 }
2109}
2110template PDU_ML3_MS_NW tr_ML3_MO_SS_RELEASE_COMPLETE(
2111 template uint3_t tid, template BIT1 ti_flag,
2112 template ML3_Cause_TLV cause := *,
2113 template OCTN facility := *
2114) := {
2115 discriminator := '1011'B,
2116 tiOrSkip := {
2117 transactionId := {
2118 tio := f_tid_or_wc(tid),
2119 tiFlag := ti_flag,
2120 tIExtension := omit
2121 }
2122 },
2123 msgs := {
2124 ss := {
2125 releaseComplete_MS_NW := {
2126 messageType := '101010'B,
2127 nsd := '00'B,
2128 cause := cause,
2129 facility := f_facility_or_wc(facility)
2130 }
2131 }
2132 }
2133}
2134
2135template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_RELEASE_COMPLETE(
2136 uint3_t tid, BIT1 ti_flag,
2137 template (omit) ML3_Cause_TLV cause := omit,
2138 template (omit) OCTN facility := omit
2139) := {
2140 discriminator := '1011'B,
2141 tiOrSkip := {
2142 transactionId := {
2143 tio := int2bit(tid, 3),
2144 tiFlag := ti_flag,
2145 tIExtension := omit
2146 }
2147 },
2148 msgs := {
2149 ss := {
2150 releaseComplete_NW_MS := {
2151 messageType := '101010'B,
2152 nsd := '00'B,
2153 cause := cause,
2154 facility := f_facility_or_omit(facility)
2155 }
2156 }
2157 }
2158}
2159template PDU_ML3_NW_MS tr_ML3_MT_SS_RELEASE_COMPLETE(
2160 template uint3_t tid, template BIT1 ti_flag,
2161 template ML3_Cause_TLV cause := *,
2162 template OCTN facility := *
2163) := {
2164 discriminator := '1011'B,
2165 tiOrSkip := {
2166 transactionId := {
2167 tio := f_tid_or_wc(tid),
2168 tiFlag := ti_flag,
2169 tIExtension := omit
2170 }
2171 },
2172 msgs := {
2173 ss := {
2174 releaseComplete_NW_MS := {
2175 messageType := '101010'B,
2176 nsd := '00'B,
2177 cause := cause,
2178 facility := f_facility_or_wc(facility)
2179 }
2180 }
2181 }
2182}
2183
Harald Welte53603962018-05-28 11:13:09 +02002184/***********************************************************************
Harald Welte38575a72018-02-15 20:41:37 +01002185 * GPRS Mobility Management
2186 ***********************************************************************/
2187
2188template (value) MSNetworkCapabilityV ts_GMM_MsNetCapV := {
2189 gea1bit := '1'B,
2190 smCapabilitiesviaDedicatedChannels := '1'B,
2191 smCapabilitiesviaGPRSChannels := '0'B,
2192 ucs2Support := '1'B,
2193 ssScreeningIndicator := '01'B,
2194 solSACapability := omit,
2195 revisionLevelIndicatior := omit,
2196 pFCFeatureMode := omit,
2197 extendedGEAbits := omit,
2198 lcsVAcapability := omit,
2199 pSInterRATHOtoUTRANIuModeCapability := omit,
2200 pSInterRATHOtoEUTRANS1ModeCapability := omit,
2201 eMMCombinedProceduresCapability := omit,
2202 iSRSupport := omit,
2203 sRVCCtoGERANUTRANCapability := omit,
2204 ePCCapability := omit,
2205 nFCapability := omit,
2206 gERANNertworkSharingCapability := omit,
2207 spare_octets := omit
2208};
2209
2210template (value) MSNetworkCapabilityLV ts_GMM_MsNetCapLV := {
2211 lengthIndicator := 0, /* overwritten */
2212 msNetworkCapabilityV := ts_GMM_MsNetCapV
2213};
2214
2215type enumerated GprsAttachType {
2216 GPRS_ATT_T_GPRS,
2217 GPRS_ATT_T_GPRS_IMSI_COMBINED
2218};
2219
2220function ts_GMM_AttachType(boolean combined := false, boolean follow_on_pending := false)
2221return AttachTypeV {
2222 var AttachTypeV att;
2223 if (combined) {
2224 att.attachType := '011'B;
2225 } else {
2226 att.attachType := '001'B;
2227 }
2228 att.for_l3 := bool2bit(combined);
2229 return att;
2230}
2231
2232type enumerated GprsUpdateType {
2233 GPRS_UPD_T_RA ('000'B),
2234 GPRS_UPD_T_RA_LA_COMBINED ('001'B),
2235 GPRS_UPD_T_RA_LA_COMBINED_IMSI_ATT ('010'B),
2236 GPRS_UPD_T_PERIODIC ('011'B)
2237};
2238
2239/* 10.5.5.18 Update Type */
2240template UpdateTypeV ts_GMM_UpdateType(GprsUpdateType upd_t, boolean combined := false,
2241 boolean follow_on_pending := false) := {
2242 valueField := int2bit(enum2int(upd_t), 3),
2243 for_l3 := bool2bit(combined)
2244}
2245
2246template (value) DRXParameterV ts_DrxParameterV := {
2247 splitPGCycleCode := '00'O, /* no DRX */
2248 nonDRXTimer := '000'B, /* no non-DRX mode */
2249 splitOnCCCH := '0'B, /* not supported */
2250 cnSpecificDRXCycleLength := '0000'B /* SI value used */
2251};
2252
Harald Welte6ce47c32020-09-13 09:58:29 +02002253private function f_presence_bit_MultislotCap_GPRS(template (omit) MultislotCap_GPRS mscap_gprs) return BIT1 {
2254 if (istemplatekind(mscap_gprs, "omit")) {
2255 return '0'B;
2256 }
2257 return '1'B;
2258}
2259private function f_presence_bit_MultislotCap_EGPRS(template (omit) MultislotCap_EGPRS mscap_egprs) return BIT1 {
2260 if (istemplatekind(mscap_egprs, "omit")) {
2261 return '0'B;
2262 }
2263 return '1'B;
2264}
2265template (value) MSRACapabilityValuesRecord ts_RaCapRec(BIT4 att := '0001'B /* E-GSM */, template (omit) MultislotCap_GPRS mscap_gprs := omit, template (omit) MultislotCap_EGPRS mscap_egprs := omit) := {
2266 mSRACapabilityValues := {
2267 mSRACapabilityValuesExclude1111 := {
2268 accessTechnType := att, /* E-GSM */
2269 accessCapabilities := {
2270 lengthIndicator := 0, /* overwritten */
2271 accessCapabilities := {
2272 rfPowerCapability := '001'B, /* FIXME */
2273 presenceBitA5 := '0'B,
2274 a5bits := omit,
2275 esind := '1'B,
2276 psbit := '0'B,
2277 vgcs := '0'B,
2278 vbs := '0'B,
2279 presenceBitMultislot := '1'B,
2280 multislotcap := {
2281 presenceBitHscsd := '0'B,
2282 hscsdmultislotclass := omit,
2283 presenceBitGprs := f_presence_bit_MultislotCap_GPRS(mscap_gprs),
2284 gprsmultislot := mscap_gprs,
2285 presenceBitSms := '0'B,
2286 multislotCap_SMS := omit,
2287 multislotCapAdditionsAfterRel97 := {
2288 presenceBitEcsdmulti := '0'B,
2289 ecsdmultislotclass := omit,
2290 presenceBitEgprsmulti := f_presence_bit_MultislotCap_EGPRS(mscap_egprs),
2291 multislotCap_EGPRS := mscap_egprs,
2292 presenceBitDtmGprsmulti := '0'B,
2293 multislotCapdtmgprsmultislotsubclass := omit
2294 }
2295 },
2296 accessCapAdditionsAfterRel97 := omit
2297 },
2298 spare_bits := omit
2299 }
2300 }
2301 },
2302 presenceBitMSRACap := '0'B
2303};
2304
Harald Welte38575a72018-02-15 20:41:37 +01002305template (value) MSRadioAccessCapabilityLV ts_MS_RaCapa := {
2306 lengthIndicator := 0, /* overwritten */
2307 msRadioAccessCapabilityV := {
2308 ts_RaCapRec('0001'B) /* E-GSM */
2309 }
2310}
2311
2312template (value) PDU_L3_MS_SGSN
2313 ts_GMM_ATTACH_REQ(MobileIdentityLV mi_lv, RoutingAreaIdentificationV old_ra,
2314 boolean combined := false, boolean follow_on_pending := false,
2315 template (omit) MobileStationClassmark2_TLV cm2_tlv,
2316 template (omit) MobileStationClassmark3_TLV cm3_tlv
2317 ) := {
2318 discriminator := '0000'B, /* overwritten */
2319 tiOrSkip := {
2320 skipIndicator := '0000'B
2321 },
2322 msgs := {
2323 gprs_mm := {
2324 attachRequest := {
2325 messageType := '00000000'B, /* overwritten */
2326 msNetworkCapability := ts_GMM_MsNetCapLV,
2327 attachType := valueof(ts_GMM_AttachType(combined, follow_on_pending)),
2328 gprsCKSN := { '111'B, '0'B },
2329 drxParam := ts_DrxParameterV,
2330 mobileIdentity := mi_lv,
2331 oldRoutingAreaID := old_ra,
2332 msRACap := ts_MS_RaCapa,
2333 ptmsiSignature := omit, /* TODO */
2334 reqGPRStimer := omit,
2335 tmsiStatus := omit,
2336 pC_LCSCapability := omit,
2337 mobileStationClassmark2 := cm2_tlv,
2338 mobileStationClassmark3 := cm3_tlv,
2339 supportedCodecs := omit,
2340 uENetworkCapability := omit,
2341 additionalMobileIdentity := omit,
2342 routingAreaIdentification2 := omit,
2343 voiceDomainandUEsUsageSetting := omit,
2344 deviceProperties := omit,
2345 p_TMSI_Type := omit,
2346 mS_NetworkFeatureSupport := omit,
2347 oldLocationAreaIdentification := omit,
2348 additionalUpdateType := omit,
2349 tMSIBasedNRIcontainer := omit,
2350 t3324 := omit,
2351 t3312_ExtendedValue := omit,
2352 extendedDRXParameters := omit
2353 }
2354 }
2355 }
2356}
2357
Harald Welteb0386df2018-02-16 18:14:28 +01002358private function tr_MI_TMSI_TLV(template OCT4 tmsi) return template MobileIdentityTLV {
2359 if (istemplatekind(tmsi, "*")) {
2360 return *;
2361 } else if (istemplatekind(tmsi, "?")) {
2362 return ?;
2363 } else {
2364 var template MobileIdentityTLV mi := {
2365 elementIdentifier := '0011000'B,
2366 spare1 := '0'B,
2367 mobileIdentityLV := {
2368 lengthIndicator := 4,
2369 mobileIdentityV := {
2370 typeOfIdentity := '100'B,
2371 oddEvenInd_identity := {
2372 tmsi_ptmsi := {
2373 oddevenIndicator := '1'B,
2374 fillerDigit := '1111'B,
2375 octets := tmsi
2376 }
2377 }
2378 }
2379 }
2380 };
2381 return mi;
2382 }
2383}
2384
2385template PDU_L3_SGSN_MS tr_GMM_ATTACH_ACCEPT(template BIT3 res := ?,
2386 template RoutingAreaIdentificationV ra := ?,
2387 template OCT4 ptmsi := *) := {
2388 discriminator := '1000'B,
2389 tiOrSkip := {
2390 skipIndicator := '0000'B
2391 },
2392 msgs := {
2393 gprs_mm := {
2394 attachAccept := {
2395 messageType := '00000010'B,
2396 attachResult := { res, ? },
2397 forceToStandby := ?,
2398 updateTimer := ?,
2399 radioPriority := ?,
2400 radioPriorityTOM8 := ?,
2401 routingAreaIdentification := ra,
2402 ptmsiSignature := *,
2403 readyTimer := *,
2404 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2405 msIdentity := *,
2406 gmmCause := *,
2407 t3302 := *,
2408 cellNotification := *,
2409 equivalentPLMNs := *,
2410 networkFeatureSupport := *,
2411 emergencyNumberList := *,
2412 requestedMSInformation := *,
2413 t3319 := *,
2414 t3323 := *,
2415 t3312_ExtendedValue := *,
2416 additionalNetworkFeatureSupport := *,
2417 t3324 := *,
2418 extendedDRXParameters := *
2419 }
2420 }
2421 }
2422}
Harald Welte38575a72018-02-15 20:41:37 +01002423
Harald Welte5b7c8122018-02-16 21:48:17 +01002424template PDU_L3_SGSN_MS tr_GMM_ATTACH_REJECT(template OCT1 cause) := {
2425 discriminator := '1000'B,
2426 tiOrSkip := {
2427 skipIndicator := '0000'B
2428 },
2429 msgs := {
2430 gprs_mm := {
2431 attachReject := {
2432 messageType := '00000100'B,
2433 gmmCause := {
2434 causeValue := cause
2435 },
2436 t3302 := *,
2437 t3346 := *
2438 }
2439 }
2440 }
2441}
2442
2443
Harald Welte38575a72018-02-15 20:41:37 +01002444template (value) PDU_L3_MS_SGSN ts_GMM_ATTACH_COMPL := {
2445 discriminator := '0000'B, /* overwritten */
2446 tiOrSkip := {
2447 skipIndicator := '0000'B
2448 },
2449 msgs := {
2450 gprs_mm := {
2451 attachComplete := {
2452 messageType := '00000000'B, /* overwritten */
2453 interRATHandoverInformation := omit,
2454 eUTRANinterRATHandoverInformation := omit
2455 }
2456 }
2457 }
2458}
2459
2460template (value) PDU_L3_MS_SGSN
2461 ts_GMM_RAU_REQ(MobileIdentityLV mi_lv, GprsUpdateType upd_type,
2462 RoutingAreaIdentificationV old_ra,
2463 boolean follow_on_pending := false,
2464 template (omit) MobileStationClassmark2_TLV cm2_tlv,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002465 template (omit) MobileStationClassmark3_TLV cm3_tlv,
2466 template (omit) OCT4 p_tmsi := omit
Harald Welte38575a72018-02-15 20:41:37 +01002467 ) := {
2468 discriminator := '0000'B, /* overwritten */
2469 tiOrSkip := {
2470 skipIndicator := '0000'B
2471 },
2472 msgs := {
2473 gprs_mm := {
2474 routingAreaUpdateRequest := {
2475 messageType := '00000000'B, /* overwritten */
2476 updateType := ts_GMM_UpdateType(upd_type, follow_on_pending),
2477 gprsCKSN := { '111'B, '0'B },
2478 oldRoutingAreaId := old_ra,
2479 msRACap := ts_MS_RaCapa,
2480 oldPTMSISignature := omit, /* TODO */
2481 readyTimerValue := omit,
2482 drxParameter := omit,
2483 tmsiStatus := omit,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002484 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
Harald Welte38575a72018-02-15 20:41:37 +01002485 mSNetworkCapability := omit,
2486 pdpContextStatus := omit, /* TODO */
2487 pC_LCSCapability := omit,
Harald Welte04683d02018-02-16 22:43:45 +01002488 mBMS_ContextStatus := omit,
Harald Welte38575a72018-02-15 20:41:37 +01002489 uENetworkCapability := omit,
2490 additionalMobileIdentity := omit,
2491 oldRoutingAreaIdentification2 := omit,
2492 mobileStationClassmark2 := cm2_tlv,
2493 mobileStationClassmark3 := cm3_tlv,
2494 supportedCodecs := omit,
2495 voiceDomainUEUsageSetting := omit,
2496 p_TMSI_Type := omit,
2497 deviceProperties := omit,
2498 mS_NetworkFeatureSupport := omit,
2499 oldLocationAreaIdentification := omit,
2500 additionalUpdateType := omit,
2501 tMSIBasedNRIcontainer := omit,
2502 t3324 := omit,
2503 t3312_ExtendedValue := omit,
2504 extendedDRXParameters := omit
2505 }
2506 }
2507 }
2508}
2509
Harald Welte04683d02018-02-16 22:43:45 +01002510template PDU_L3_SGSN_MS tr_GMM_RAU_REJECT(template OCT1 cause := ?) := {
2511 discriminator := '1000'B,
2512 tiOrSkip := {
2513 skipIndicator := '0000'B
2514 },
2515 msgs := {
2516 gprs_mm := {
2517 routingAreaUpdateReject := {
2518 messageType := '00001011'B,
2519 gmmCause := {
2520 causeValue := cause
2521 },
2522 forceToStandby := ?,
2523 spare := '0000'B,
2524 t3302 := *,
2525 t3346 := *
2526 }
2527 }
2528 }
2529}
2530
Harald Welte91636de2018-02-17 10:16:14 +01002531template PDU_L3_SGSN_MS tr_GMM_RAU_ACCEPT(template BIT3 res := ?,
2532 template RoutingAreaIdentificationV ra := ?,
2533 template OCT4 ptmsi := *) := {
2534 discriminator := '1000'B,
2535 tiOrSkip := {
2536 skipIndicator := '0000'B
2537 },
2538 msgs := {
2539 gprs_mm := {
2540 routingAreaUpdateAccept := {
2541 messageType := '00001001'B,
2542 forceToStandby := ?,
2543 updateResult := { res, ? },
2544 raUpdateTimer := ?,
2545 routingAreaId := ra,
2546 ptmsiSignature := *,
2547 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2548 msIdentity := *,
2549 receiveNPDUNumbers := *,
2550 readyTimer := *,
2551 gmmCause := *,
2552 t3302 := *,
2553 cellNotification := *,
2554 equivalentPLMNs := *,
2555 pdpContextStatus := *,
2556 networkFeatureSupport := *,
2557 emergencyNumberList := *,
2558 mBMS_ContextStatus := *,
2559 requestedMSInformation := *,
2560 t3319 := *,
2561 t3323 := *,
2562 t3312_ExtendedValue := *,
2563 additionalNetworkFeatureSupport := *,
2564 t3324 := *,
2565 extendedDRXParameters := *
2566 }
2567 }
2568 }
2569}
Harald Welte04683d02018-02-16 22:43:45 +01002570
Harald Welte38575a72018-02-15 20:41:37 +01002571template (value) PDU_L3_MS_SGSN ts_GMM_RAU_COMPL := {
2572 discriminator := '0000'B, /* overwritten */
2573 tiOrSkip := {
2574 skipIndicator := '0000'B
2575 },
2576 msgs := {
2577 gprs_mm := {
2578 routingAreaUpdateComplete := {
2579 messageType := '00000000'B, /* overwritten */
2580 receiveNPDUNumbers := omit,
2581 interRATHandoverInformation := omit,
2582 eUTRANinterRATHandoverInformation := omit
2583 }
2584 }
2585 }
2586}
2587
2588template (value) PDU_L3_MS_SGSN ts_GMM_PTMSI_REALL_COMPL := {
2589 discriminator := '0000'B, /* overwritten */
2590 tiOrSkip := {
2591 skipIndicator := '0000'B
2592 },
2593 msgs := {
2594 gprs_mm := {
2595 p_TMSIReallocationComplete := {
2596 messageType := '00000000'B /* overwritten */
2597 }
2598 }
2599 }
2600}
2601
2602template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_CIPH_COMPL(ACReferenceNumberV ref, OCT4 res) := {
2603 discriminator := '0000'B, /* overwritten */
2604 tiOrSkip := {
2605 skipIndicator := '0000'B
2606 },
2607 msgs := {
2608 gprs_mm := {
2609 authenticationAndCipheringResponse := {
2610 messageType := '00000000'B, /* overwritten */
2611 acReferenceNumber := ref,
2612 spare := '0000'B,
2613 authenticationParResp := {
2614 elementIdentifier := '22'O,
2615 valueField := res
2616 },
2617 imeisv := omit,
2618 authenticationRespParExt := omit
2619 }
2620 }
2621 }
2622}
2623
Harald Welteb0386df2018-02-16 18:14:28 +01002624template PDU_L3_SGSN_MS tr_GMM_ID_REQ(template BIT3 id_type := ?) := {
2625 discriminator := '1000'B,
2626 tiOrSkip := {
2627 skipIndicator := '0000'B
2628 },
2629 msgs := {
2630 gprs_mm := {
2631 identityRequest := {
2632 messageType := '00010101'B,
2633 identityType := { id_type, '0'B },
2634 forceToStandby := ?
2635 }
2636 }
2637 }
2638}
2639
Harald Welte38575a72018-02-15 20:41:37 +01002640template (value) PDU_L3_MS_SGSN ts_GMM_ID_RESP(MobileIdentityLV mi_lv) := {
2641 discriminator := '0000'B, /* overwritten */
2642 tiOrSkip := {
2643 skipIndicator := '0000'B
2644 },
2645 msgs := {
2646 gprs_mm := {
2647 identityResponse := {
2648 messageType := '00000000'B, /* overwritten */
2649 mobileIdentity := mi_lv
2650 }
2651 }
2652 }
2653}
2654
Harald Welteb0386df2018-02-16 18:14:28 +01002655template PDU_L3_SGSN_MS tr_GMM_AUTH_REQ(template OCT16 rand := ?, template BIT3 ciph_alg := ?) := {
2656 discriminator := '1000'B,
2657 tiOrSkip := {
2658 skipIndicator := '0000'B
2659 },
2660 msgs := {
2661 gprs_mm := {
2662 authenticationAndCipheringRequest := {
2663 messageType := '00010010'B,
2664 cipheringAlgorithm := { ciph_alg, '0'B },
2665 imeisvRequest := ?,
2666 forceToStandby := ?,
2667 acReferenceNumber := ?,
2668 authenticationParameterRAND := {
2669 elementIdentifier := '21'O,
2670 randValue := rand
2671 },
2672 cipheringKeySequenceNumber := *,
2673 authenticationParameterAUTN := *
2674 }
2675 }
2676 }
2677}
2678
2679template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_RESP_2G(BIT4 ac_ref, OCT4 sres) := {
2680 discriminator := '1000'B,
2681 tiOrSkip := {
2682 skipIndicator := '0000'B
2683 },
2684 msgs := {
2685 gprs_mm := {
2686 authenticationAndCipheringResponse := {
2687 messageType := '00010011'B,
2688 acReferenceNumber := { valueField := ac_ref },
2689 spare := '0000'B,
2690 authenticationParResp := {
2691 elementIdentifier := '22'O,
2692 valueField := sres
2693 },
2694 imeisv := omit,
2695 authenticationRespParExt := omit
2696 }
2697 }
2698 }
2699}
2700
Alexander Couzens15faf922018-09-04 15:16:26 +02002701template PDU_L3_MS_SGSN ts_GMM_AUTH_FAIL_UMTS_AKA_RESYNC(octetstring auts) := {
2702 discriminator := '1000'B,
2703 tiOrSkip := {
2704 skipIndicator := '0000'B
2705 },
2706 msgs := {
2707 gprs_mm := {
2708 authenticationAndCipheringFailure := {
2709 messageType := '00011100'B,
2710 gmmCause := {
2711 causeValue := '15'O /* GMM_CAUSE_SYNC_FAIL 10.5.3.2.2 */
2712 },
2713 authenticationFailureParam := {
2714 elementIdentifier := '30'O,
2715 lengthIndicator := 14,
2716 valueField := auts
2717 }
2718 }
2719 }
2720 }
2721}
2722
Harald Welteb0386df2018-02-16 18:14:28 +01002723
Harald Welte38575a72018-02-15 20:41:37 +01002724const BIT3 c_GMM_DTT_MO_GPRS := '001'B;
2725const BIT3 c_GMM_DTT_MO_IMSI := '010'B;
2726const BIT3 c_GMM_DTT_MO_GPRS_IMSI_COMBINED := '011'B;
2727
Alexander Couzensb6ab4562018-05-17 02:59:22 +02002728const BIT3 c_GMM_DTT_MT_REATTACH_REQUIRED := '001'B;
2729const BIT3 c_GMM_DTT_MT_REATTACH_NOT_REQUIRED := '010'B;
2730const BIT3 c_GMM_DTT_MT_IMSI_DETACH := '011'B;
2731
Harald Welte6abb9fe2018-02-17 15:24:48 +01002732template (value) DetachTypeV ts_GMM_DetType(BIT3 dtt, boolean power_off := false) := {
Harald Welte38575a72018-02-15 20:41:37 +01002733 detachType := dtt,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002734 powerOffFlag := bool2bit(power_off)
Harald Welte38575a72018-02-15 20:41:37 +01002735}
2736
Harald Welte6abb9fe2018-02-17 15:24:48 +01002737function ts_PtmsiSigTV(template (omit) OCT3 val) return template (omit) P_TMSISignatureTV {
2738 var template (omit) P_TMSISignatureTV ret;
2739 if (istemplatekind(val, "omit")) {
2740 return omit;
2741 } else {
2742 ret := {
2743 elementIdentifier := '19'O,
2744 valueField := valueof(val)
2745 }
2746 return ret;
2747 }
2748}
2749
2750function ts_PtmsiSigTLV(template (omit) OCT3 val) return template (omit) P_TMSISignature2TLV {
2751 var template (omit) P_TMSISignature2TLV ret;
2752 if (istemplatekind(val, "omit")) {
2753 return omit;
2754 } else {
2755 ret := {
2756 elementIdentifier := '19'O,
2757 lengthIndicator := 3,
2758 valueField := valueof(val)
2759 }
2760 return ret;
2761 }
2762}
2763
2764template (value) PDU_L3_MS_SGSN ts_GMM_DET_REQ_MO(BIT3 dtt := c_GMM_DTT_MO_GPRS,
2765 boolean power_off := false,
2766 template (omit) OCT4 p_tmsi := omit,
2767 template (omit) OCT3 p_tmsi_sig := omit) := {
Harald Welte38575a72018-02-15 20:41:37 +01002768 discriminator := '0000'B, /* overwritten */
2769 tiOrSkip := {
2770 skipIndicator := '0000'B
2771 },
2772 msgs := {
2773 gprs_mm := {
2774 detachRequest_MS_SGSN := {
2775 messageType := '00000000'B, /* overwritten */
Harald Welte6abb9fe2018-02-17 15:24:48 +01002776 detachType := valueof(ts_GMM_DetType(dtt, power_off)),
Harald Welte38575a72018-02-15 20:41:37 +01002777 spare := '0000'B,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002778 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
2779 ptmsiSignature := ts_PtmsiSigTLV(p_tmsi_sig)
2780 }
2781 }
2782 }
2783}
2784
2785template PDU_L3_SGSN_MS tr_GMM_DET_ACCEPT_MT := {
2786 discriminator := '1000'B,
2787 tiOrSkip := {
2788 skipIndicator := '0000'B
2789 },
2790 msgs := {
2791 gprs_mm := {
2792 detachAccept_SGSN_MS := {
2793 messageType := '00000110'B,
2794 forceToStandby := ?,
2795 spare := '0000'B
Harald Welte38575a72018-02-15 20:41:37 +01002796 }
2797 }
2798 }
2799}
Harald Welte812f7a42018-01-27 00:49:18 +01002800
Alexander Couzensd62fba52018-05-22 16:08:39 +02002801template PDU_L3_SGSN_MS tr_GMM_DET_REQ_MT(
2802 template BIT3 dtt := *,
2803 template BIT3 forceToStandby := ?,
Alexander Couzensd8604ab2018-05-29 15:46:06 +02002804 template OCT1 cause := *) := {
Harald Welte835b15f2018-02-18 14:39:11 +01002805 discriminator := '1000'B,
2806 tiOrSkip := {
2807 skipIndicator := '0000'B
2808 },
2809 msgs := {
2810 gprs_mm := {
2811 detachRequest_SGSN_MS := {
2812 messageType := '00000101'B,
Alexander Couzensd62fba52018-05-22 16:08:39 +02002813 detachType := { dtt, ? },
2814 forceToStandby := { forceToStandby, '0'B },
2815 gmmCause := {
2816 elementIdentifier := '25'O,
2817 causeValue := { cause }
2818 }
2819 }
2820 }
2821 }
2822}
2823
2824template PDU_L3_MS_SGSN ts_GMM_DET_ACCEPT_MO := {
2825 discriminator := '0000'B, /* overwritten */
2826 tiOrSkip := {
2827 skipIndicator := '0000'B
2828 },
2829 msgs := {
2830 gprs_mm := {
2831 detachAccept_MS_SGSN := {
2832 messageType := '00000000'B
Harald Welte835b15f2018-02-18 14:39:11 +01002833 }
2834 }
2835 }
2836}
Harald Welteeded9ad2018-02-17 20:57:34 +01002837
2838function ts_ApnTLV(template (omit) octetstring apn) return template (omit) AccessPointNameTLV {
2839 if (istemplatekind(apn, "omit")) {
2840 return omit;
2841 } else {
2842 var template (omit) AccessPointNameTLV ret := {
2843 elementIdentifier := '28'O,
2844 lengthIndicator := 0, /* overwritten */
2845 accessPointNameValue := apn
2846 }
2847 return ret;
2848 }
2849}
2850
2851function ts_PcoTLV(template (omit) ProtocolConfigOptionsV pco)
2852 return template (omit) ProtocolConfigOptionsTLV {
2853 if (istemplatekind(pco, "omit")) {
2854 return omit;
2855 } else {
2856 var template (omit) ProtocolConfigOptionsTLV ret := {
2857 elementIdentifier := '27'O,
2858 lengthIndicator := 0, /* overwritten */
2859 protocolConfigOptionsV := pco
2860 }
2861 return ret;
2862 }
2863}
2864
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002865function ts_TearDownIndicatorTV(in template (omit) boolean ind)
2866 return template (omit) TearDownIndicatorTV {
2867 if (istemplatekind(ind, "omit")) {
2868 return omit;
2869 } else {
2870 var template (omit) TearDownIndicatorTV ret := {
2871 tearDownIndicatorV := {
2872 tdi_flag := bool2bit(valueof(ind)),
2873 spare := '000'B
2874 },
2875 elementIdentifier := '1001'B
2876 }
2877 return ret;
2878 }
2879}
2880
Harald Welteeded9ad2018-02-17 20:57:34 +01002881template (value) PDU_L3_MS_SGSN ts_SM_ACT_PDP_REQ(BIT3 tid, BIT4 nsapi, BIT4 sapi, QoSV qos,
2882 PDPAddressV addr,
2883 template (omit) octetstring apn := omit,
2884 template (omit) ProtocolConfigOptionsV pco := omit
2885 ) := {
2886 discriminator := '0000'B, /* overwritten */
2887 tiOrSkip := {
2888 transactionId := {
2889 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002890 tiFlag := c_TIF_ORIG,
Harald Welteeded9ad2018-02-17 20:57:34 +01002891 tIExtension := omit
2892 }
2893 },
2894 msgs := {
2895 gprs_sm := {
2896 activatePDPContextRequest := {
2897 messageType := '00000000'B, /* overwritten */
2898 requestedNSAPI := { nsapi, '0000'B },
2899 requestedLLCSAPI := { sapi, '0000'B },
2900 requestedQoS := {
2901 lengthIndicator := 0, /* overwritten */
2902 qoSV := qos
2903 },
2904 requestedPDPaddress := {
2905 lengthIndicator := 0, /* overwritten */
2906 pdpAddressV := addr
2907 },
2908 accessPointName := ts_ApnTLV(apn),
2909 protocolConfigOpts := ts_PcoTLV(pco),
2910 requestType := omit,
2911 deviceProperties := omit,
2912 nBIFOM_Container := omit
2913 }
2914 }
2915 }
2916}
2917
2918template PDU_L3_SGSN_MS tr_SM_ACT_PDP_REJ(template BIT3 tid := ?, template OCT1 cause := ?) := {
2919 discriminator := '1010'B,
2920 tiOrSkip := {
2921 transactionId := {
2922 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002923 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002924 tIExtension := omit
2925 }
2926 },
2927 msgs := {
2928 gprs_sm := {
2929 activatePDPContextReject := {
Harald Welte4aacdd82018-02-18 21:24:05 +01002930 messageType := '01000011'B,
Harald Welteeded9ad2018-02-17 20:57:34 +01002931 smCause := cause,
2932 protocolConfigOpts := *,
2933 backOffTimer := *,
2934 reAttemptIndicator := *,
2935 nBIFOM_Container := *
2936 }
2937 }
2938 }
2939}
2940
2941template PDU_L3_SGSN_MS tr_SM_ACT_PDP_ACCEPT(template BIT3 tid := ?, template BIT4 sapi := ?,
2942 template QoSV qos := ?)
2943:= {
2944 discriminator := '1010'B,
2945 tiOrSkip := {
2946 transactionId := {
2947 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002948 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002949 tIExtension := omit
2950 }
2951 },
2952 msgs := {
2953 gprs_sm := {
2954 activatePDPContextAccept := {
2955 messageType := '01000010'B,
2956 negotiatedLLCSAPI := { sapi, '0000'B },
2957 negotiatedQoS := {
2958 lengthIndicator := ?,
2959 qoSV := qos
2960 },
2961 radioPriority := ?,
2962 spare := '0000'B,
2963 pdpAddress := *,
2964 protocolConfigOpts := *,
2965 packetFlowID := *,
2966 sMCause2 := *,
2967 connectivityType := *,
2968 wLANOffloadIndication := *,
2969 nBIFOM_Container := *
2970 }
2971 }
2972 }
2973}
2974
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002975template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_REQ_MO(BIT3 tid, OCT1 cause,
2976 template (omit) boolean tdown := omit,
Harald Welte6f203162018-02-18 22:04:55 +01002977 template (omit) ProtocolConfigOptionsV pco := omit
2978 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002979 discriminator := '1010'B,
Harald Welte6f203162018-02-18 22:04:55 +01002980 tiOrSkip := {
2981 transactionId := {
2982 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002983 tiFlag := c_TIF_ORIG,
Harald Welte6f203162018-02-18 22:04:55 +01002984 tIExtension := omit
2985 }
2986 },
2987 msgs := {
2988 gprs_sm := {
2989 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002990 messageType := '01000110'B,
Harald Welte6f203162018-02-18 22:04:55 +01002991 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002992 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte6f203162018-02-18 22:04:55 +01002993 protocolConfigOpts := ts_PcoTLV(pco),
2994 mBMSprotocolConfigOptions := omit,
2995 t3396 := omit,
2996 wLANOffloadIndication := omit,
2997 nBIFOM_Container := omit
2998 }
2999 }
3000 }
3001}
3002
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003003template (value) PDU_L3_SGSN_MS ts_SM_DEACT_PDP_REQ_MT(BIT3 tid, OCT1 cause,
3004 template (omit) boolean tdown := omit,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003005 template (omit) ProtocolConfigOptionsV pco := omit
3006 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003007 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003008 tiOrSkip := {
3009 transactionId := {
3010 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003011 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003012 tIExtension := omit
3013 }
3014 },
3015 msgs := {
3016 gprs_sm := {
3017 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003018 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003019 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003020 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte57b9b7f2018-02-18 22:28:13 +01003021 protocolConfigOpts := ts_PcoTLV(pco),
3022 mBMSprotocolConfigOptions := omit,
3023 t3396 := omit,
3024 wLANOffloadIndication := omit,
3025 nBIFOM_Container := omit
3026 }
3027 }
3028 }
3029}
3030
3031template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_REQ_MT(template BIT3 tid, template OCT1 cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003032 template (omit) boolean tdown := omit,
3033 template (omit) ProtocolConfigOptionsV pco := omit
3034 ) := {
3035 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003036 tiOrSkip := {
3037 transactionId := {
3038 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003039 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003040 tIExtension := omit
3041 }
3042 },
3043 msgs := {
3044 gprs_sm := {
3045 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003046 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003047 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003048 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
3049 protocolConfigOpts := ts_PcoTLV(pco),
Harald Welte57b9b7f2018-02-18 22:28:13 +01003050 mBMSprotocolConfigOptions := *,
3051 t3396 := *,
3052 wLANOffloadIndication := *,
3053 nBIFOM_Container := *
3054 }
3055 }
3056 }
3057}
3058
Harald Welte6f203162018-02-18 22:04:55 +01003059template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_ACCEPT_MT(template BIT3 tid := ?)
3060:= {
3061 discriminator := '1010'B,
3062 tiOrSkip := {
3063 transactionId := {
3064 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003065 tiFlag := c_TIF_REPL,
Harald Welte6f203162018-02-18 22:04:55 +01003066 tIExtension := omit
3067 }
3068 },
3069 msgs := {
3070 gprs_sm := {
3071 deactivatePDPContextAccept := {
3072 messageType := '01000111'B,
3073 protocolConfigOpts := *,
3074 mBMSprotocolConfigOptions := *,
3075 nBIFOM_Container := *
3076 }
3077 }
3078 }
3079}
3080
Harald Welte57b9b7f2018-02-18 22:28:13 +01003081template PDU_L3_MS_SGSN tr_SM_DEACT_PDP_ACCEPT_MO(template BIT3 tid := ?)
3082:= {
3083 discriminator := '1010'B,
3084 tiOrSkip := {
3085 transactionId := {
3086 tio := tid,
Pau Espin Pedrol55cb2ce2020-04-22 17:08:09 +02003087 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003088 tIExtension := omit
3089 }
3090 },
3091 msgs := {
3092 gprs_sm := {
3093 deactivatePDPContextAccept := {
3094 messageType := '01000111'B,
3095 protocolConfigOpts := *,
3096 mBMSprotocolConfigOptions := *,
3097 nBIFOM_Container := *
3098 }
3099 }
3100 }
3101}
3102
3103template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_ACCEPT_MO(BIT3 tid)
3104:= {
3105 discriminator := '1010'B,
3106 tiOrSkip := {
3107 transactionId := {
3108 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003109 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003110 tIExtension := omit
3111 }
3112 },
3113 msgs := {
3114 gprs_sm := {
3115 deactivatePDPContextAccept := {
3116 messageType := '01000111'B,
3117 protocolConfigOpts := omit,
3118 mBMSprotocolConfigOptions := omit,
3119 nBIFOM_Container := omit
3120 }
3121 }
3122 }
3123}
3124
Harald Welteeded9ad2018-02-17 20:57:34 +01003125
3126
Harald Welte7484fc42018-02-24 14:09:45 +01003127external function enc_MobileIdentityLV(in MobileIdentityLV si) return octetstring
3128 with { extension "prototype(convert) encode(RAW)" };
Harald Weltee5695f52018-02-16 14:46:15 +01003129
Vadim Yanitskiy322c7932020-01-01 23:03:47 +01003130external function dec_MobileIdentityV(in octetstring mi) return MobileIdentityV
3131 with { extension "prototype(convert) decode(RAW)" };
3132
Harald Weltecb6cc332018-01-21 13:59:08 +01003133
Harald Weltef45efeb2018-04-09 18:19:24 +02003134
3135/* SMS TPDU Layer */
3136
3137template (value) TPDU_RP_DATA_MS_SGSN ts_SMS_SUBMIT(OCT1 msg_ref, template (value) TP_DA dst_addr,
3138 template (value) OCT1 pid, template (value) OCT1 dcs,
3139 integer length_ind, octetstring user_data) := {
3140 sMS_SUBMIT := {
3141 tP_MTI := '01'B, /* SUBMIT */
3142 tP_RD := '1'B, /* reject duplicates */
3143 tP_VPF := '00'B, /* not present */
3144 tP_SRR := '0'B, /* no status report requested */
3145 tP_UDHI := '0'B, /* no user data header in UD */
3146 tP_RP := '0'B, /* no reply path */
3147 tP_MR := msg_ref,
3148 tP_DA := dst_addr,
3149 tP_PID := pid,
3150 tP_DCS := dcs,
3151 tP_VP := omit,
3152 tP_UDL_UD := {
3153 tP_LengthIndicator := length_ind,
3154 tP_UD := user_data
3155 }
3156 }
3157}
3158
3159template TPDU_RP_DATA_SGSN_MS tr_SMS_DELIVER(template TP_OA src_addr := ?,
3160 template octetstring user_data := ?,
3161 template OCT1 pid := ?, template OCT1 dcs := ?,
3162 template BIT1 mms := ?
3163 ) := {
3164 sMS_DELIVER := {
3165 tP_MTI := '00'B, /* DELIVER */
3166 tP_MMS := mms, /* more messages to send */
3167 tP_LP := ?, /* ?!? */
3168 tP_Spare := '0'B,
3169 tP_SRI := '0'B, /* status report indication */
3170 tP_UDHI := '0'B, /* no user data header in UD */
3171 tP_RP := '0'B, /* no reply path */
3172 tP_OA := src_addr,
3173 tP_PID := pid,
3174 tP_DCS := dcs,
3175 tP_SCTS := ?,
3176 tP_UDL_UD := {
3177 tP_LengthIndicator := ?,
3178 tP_UD := user_data
3179 }
3180 }
3181}
3182
3183/* RP Layer */
3184
3185private function ts_RpOrig(template (omit) RP_NumberingPlan_and_NumberDigits rp_orig)
3186return RP_OriginatorAddressLV {
3187 var RP_OriginatorAddressLV ret;
3188 if (istemplatekind(rp_orig, "omit")) {
3189 ret := { 0, omit };
3190 } else {
3191 ret := { 0, valueof(rp_orig) };
3192 }
3193 return ret;
3194}
3195
3196private function ts_RpDst(template (omit) RP_NumberingPlan_and_NumberDigits rp_dst)
3197return RP_DestinationAddressLV {
3198 var RP_DestinationAddressLV ret;
3199 if (istemplatekind(rp_dst, "omit")) {
3200 ret := { 0, omit };
3201 } else {
3202 ret := { 0, valueof(rp_dst) };
3203 }
3204 return ret;
3205}
3206
3207template (value) RPDU_MS_SGSN ts_RP_DATA_MO(OCT1 msg_ref,
3208 template (omit) RP_NumberingPlan_and_NumberDigits rp_orig,
3209 template (omit) RP_NumberingPlan_and_NumberDigits rp_dst,
3210 template (value) TPDU_RP_DATA_MS_SGSN tpdu) := {
3211 rP_DATA_MS_SGSN := {
3212 rP_MTI := '000'B,
3213 rP_Spare := '00000'B,
3214 rP_MessageReference := msg_ref,
3215 rP_OriginatorAddress := ts_RpOrig(rp_orig),
3216 rP_DestinationAddress := ts_RpDst(rp_dst),
3217 rP_User_Data := {
3218 rP_LengthIndicator := 0, /* overwritten */
3219 rP_TPDU := tpdu
3220 }
3221 }
3222}
3223
3224template RPDU_SGSN_MS tr_RP_DATA_MT(template OCT1 msg_ref,
3225 template RP_NumberingPlan_and_NumberDigits rp_orig,
3226 template RP_NumberingPlan_and_NumberDigits rp_dst,
3227 template TPDU_RP_DATA_SGSN_MS tpdu) := {
3228 rP_DATA_SGSN_MS := {
3229 rP_MTI := '001'B,
3230 rP_Spare := '00000'B,
3231 rP_MessageReference := msg_ref,
3232 rP_OriginatorAddress := { ?, rp_orig },
3233 rP_DestinationAddress := { ?, rp_dst },
3234 rP_User_Data := {
3235 rP_LengthIndicator := ?,
3236 rP_TPDU := tpdu
3237 }
3238
3239 }
3240}
3241
3242template (value) RPDU_MS_SGSN ts_RP_ACK_MO(OCT1 msg_ref) := {
3243 rP_ACK_MS_SGSN := {
3244 rP_MTI := '010'B,
3245 rP_Spare := '00000'B,
3246 rP_MessageReference := msg_ref,
3247 rP_User_Data := omit /* FIXME: report */
3248 }
3249}
3250
3251template RPDU_SGSN_MS tr_RP_ACK_MT(template OCT1 msg_ref) := {
3252 rP_ACK_SGSN_MS := {
3253 rP_MTI := '011'B,
3254 rP_Spare := '00000'B,
3255 rP_MessageReference := msg_ref,
3256 rP_User_Data := omit /* FIXME: report */
3257 }
3258}
3259
3260template (value) RPDU_MS_SGSN ts_RP_ERROR_MO(OCT1 msg_ref, uint7_t cause) := {
3261 rP_ERROR_MS_SGSN := {
3262 rP_MTI := '100'B,
3263 rP_Spare := '00000'B,
3264 rP_Message_Reference := msg_ref,
3265 rP_CauseLV := {
3266 rP_LengthIndicator := 0, /* overwritten */
3267 rP_CauseV := {
3268 causeValue := int2bit(cause, 7),
3269 ext := '0'B
3270 },
3271 rP_diagnisticField := omit
3272 },
3273 rP_User_Data := omit /* FIXME: report */
3274 }
3275}
3276
3277private function f_cause_or_wc(template uint7_t cause) return template BIT7 {
3278 if (istemplatekind(cause, "?")) {
3279 return ?;
3280 } else if (istemplatekind(cause, "*")) {
3281 return *;
3282 } else {
3283 return int2bit(valueof(cause), 7);
3284 }
3285}
3286
3287template RPDU_SGSN_MS tr_RP_ERROR_MT(template OCT1 msg_ref, template uint7_t cause) := {
3288 rP_ERROR_SGSN_MS := {
3289 rP_MTI := '101'B,
3290 rP_Spare := '00000'B,
3291 rP_Message_Reference := msg_ref,
3292 rP_CauseLV := {
Vadim Yanitskiye9e93012020-01-15 12:35:17 +07003293 rP_LengthIndicator := ?,
Harald Weltef45efeb2018-04-09 18:19:24 +02003294 rP_CauseV := {
3295 causeValue := f_cause_or_wc(cause),
3296 ext := '0'B
3297 },
3298 rP_diagnisticField := omit
3299 },
3300 rP_User_Data := omit /* FIXME: report */
3301 }
3302}
3303
3304
3305template (value) RPDU_MS_SGSN ts_RP_SMMA_MO(OCT1 msg_ref) := {
3306 rP_SMMA := {
3307 rP_MTI := '110'B,
3308 rP_Spare := '00000'B,
3309 rP_MessageReference := msg_ref
3310 }
3311}
3312
3313
3314
3315
3316/* CP Layer */
3317
3318template (value) L3_SMS_MS_SGSN ts_CP_DATA_MO(template (value) RPDU_MS_SGSN rpdu) := {
3319 cP_DATA := {
3320 cP_messageType := '00000001'B,
3321 cP_User_Data := {
3322 lengthIndicator := 0, /* overwritten */
3323 cP_RPDU := rpdu
3324 }
3325 }
3326}
3327
3328template (value) L3_SMS_MS_SGSN ts_CP_ACK_MO := {
3329 cP_ACK := {
3330 cP_messageType := '00000100'B
3331 }
3332}
3333
3334template (value) L3_SMS_MS_SGSN ts_CP_ERROR_MO(OCT1 cause) := {
3335 cP_ERROR := {
3336 cP_messageType := '00010000'B,
3337 cP_Cause := {
3338 causeValue := cause
3339 }
3340 }
3341}
3342
3343template L3_SMS_SGSN_MS tr_CP_DATA_MT(template RPDU_SGSN_MS rpdu) := {
3344 cP_DATA := {
3345 cP_messageType := '00000001'B,
3346 cP_User_Data := {
3347 lengthIndicator := ?,
3348 cP_RPDU := rpdu
3349 }
3350 }
3351}
3352
3353template L3_SMS_SGSN_MS tr_CP_ACK_MT := {
3354 cP_ACK := {
3355 cP_messageType := '00000100'B
3356 }
3357}
3358
3359template L3_SMS_SGSN_MS tr_CP_ERROR_MT(template OCT1 cause) := {
3360 cP_ERROR := {
3361 cP_messageType := '00010000'B,
3362 cP_Cause := {
3363 causeValue := cause
3364 }
3365 }
3366}
3367
3368/* L3 Wrapper */
3369
3370template (value) PDU_ML3_MS_NW ts_ML3_MO_SMS(uint3_t tid, BIT1 ti_flag,
3371 template (value) L3_SMS_MS_SGSN sms_mo) := {
3372 discriminator := '1001'B,
3373 tiOrSkip := {
3374 transactionId := {
3375 tio := int2bit(tid, 3),
3376 tiFlag := ti_flag,
3377 tIExtension := omit
3378 }
3379 },
3380 msgs := {
3381 sms := sms_mo
3382 }
3383}
3384
3385private function f_tid_or_wc(template uint3_t tid) return template BIT3 {
3386 var template BIT3 ret;
3387 if (istemplatekind(tid, "*")) {
3388 return *;
3389 } else if (istemplatekind(tid, "?")) {
3390 return ?;
3391 } else {
3392 return int2bit(valueof(tid), 3);
3393 }
3394}
3395
3396template PDU_ML3_NW_MS tr_ML3_MT_SMS(template uint3_t tid, template BIT1 ti_flag,
3397 template L3_SMS_SGSN_MS sms_mt) := {
3398 discriminator := '1001'B,
3399 tiOrSkip := {
3400 transactionId := {
3401 tio := f_tid_or_wc(tid),
3402 tiFlag := ti_flag,
3403 tIExtension := omit
3404 }
3405 },
3406 msgs := {
3407 sms := sms_mt
3408 }
3409}
3410
Philipp Maier9b690e42018-12-21 11:50:03 +01003411template PDU_ML3_NW_MS tr_ML3_MT_MM_Info := {
3412 discriminator := '0101'B,
3413 tiOrSkip := {
3414 skipIndicator := '0000'B
3415 },
3416 msgs := {
3417 mm := {
3418 mMInformation := {
3419 messageType := '110010'B,
3420 nsd := '00'B,
3421 fullNetworkName := *,
3422 shortNetworkName := *,
3423 localtimeZone := *,
3424 univTime := *,
3425 lSAIdentity := *,
3426 networkDST := *
3427 }
3428 }
3429 }
3430}
Harald Weltef45efeb2018-04-09 18:19:24 +02003431
Vadim Yanitskiy13c26f92020-07-04 21:15:26 +07003432template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
3433 template (value) RoutingAreaIdentificationV rai,
3434 template (value) OCT1 cause) := {
3435 discriminator := '0000'B, /* overwritten */
3436 tiOrSkip := {
3437 skipIndicator := '0000'B
3438 },
3439 msgs := {
3440 rrm := {
3441 gPRS_suspensionRequest := {
3442 messageType := '00110100'B,
3443 tLLI := tlli,
3444 routingAreaIdentification := rai,
3445 suspensionCause := cause,
3446 service_Support := omit
3447 }
3448 }
3449 }
3450}
3451
Harald Weltef45efeb2018-04-09 18:19:24 +02003452
3453
Harald Weltec76f29f2017-11-22 12:46:46 +01003454}