blob: c6ebeb43270833203901bc60e5f655437d6e23a9 [file] [log] [blame]
Harald Weltec76f29f2017-11-22 12:46:46 +01001module L3_Templates {
2
Harald Welte35bb7162018-01-03 21:07:52 +01003/* L3 Templates, building on top of MobileL3*_Types from Ericsson.
4 *
Harald Weltef45efeb2018-04-09 18:19:24 +02005 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte35bb7162018-01-03 21:07:52 +01006 * All rights reserved.
7 *
8 * Released under the terms of GNU General Public License, Version 2 or
9 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +020010 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
Harald Welte35bb7162018-01-03 21:07:52 +010012 */
13
Harald Weltec76f29f2017-11-22 12:46:46 +010014import from General_Types all;
Harald Welte38575a72018-02-15 20:41:37 +010015import from Osmocom_Types all;
Harald Weltec76f29f2017-11-22 12:46:46 +010016import from MobileL3_Types all;
17import from MobileL3_CommonIE_Types all;
18import from MobileL3_MM_Types all;
19import from MobileL3_RRM_Types all;
Harald Weltecb6cc332018-01-21 13:59:08 +010020import from MobileL3_CC_Types all;
Harald Welte38575a72018-02-15 20:41:37 +010021import from MobileL3_GMM_SM_Types all;
Harald Weltef45efeb2018-04-09 18:19:24 +020022import from MobileL3_SMS_Types all;
Harald Weltecb6cc332018-01-21 13:59:08 +010023
Harald Welte51affb62018-04-09 14:17:45 +020024/* TS 24.007 Table 11.3 TI Flag */
25const BIT1 c_TIF_ORIG := '0'B;
26const BIT1 c_TIF_REPL := '1'B;
Harald Weltec76f29f2017-11-22 12:46:46 +010027
28type enumerated CmServiceType {
29 CM_TYPE_MO_CALL ('0001'B),
30 CM_TYPE_EMERG_CALL ('0010'B),
31 CM_TYPE_MO_SMS ('0100'B),
Harald Welte6ed6bf92018-01-24 21:09:15 +010032 CM_TYPE_SS_ACT ('1000'B),
33 CM_TYPE_VGCS ('1001'B),
34 CM_TYPE_VBS ('1010'B),
35 CM_TYPE_LCS ('1011'B)
Harald Weltec76f29f2017-11-22 12:46:46 +010036}
37
Oliver Smith32898452019-07-09 12:32:35 +020038/* TS 24.008 10.5.3.4 Identity Type */
39type enumerated CmIdentityType {
40 CM_ID_TYPE_IMSI ('001'B),
41 CM_ID_TYPE_IMEI ('010'B),
42 CM_ID_TYPE_IMEISV ('011'B),
43 CM_ID_TYPE_TMSI ('100'B),
44 CM_ID_TYPE_PTMSI_RAI_PTMSI_SIG ('101'B)
45}
46
Harald Welte33ec09b2018-02-10 15:34:46 +010047template ML3_Cause_TLV ts_ML3_Cause(BIT7 cause, BIT4 loc := '0001'B, BIT2 std := '11'B) := {
48 elementIdentifier := '08'O,
49 lengthIndicator := 0, /* overwritten */
50 oct3 := {
51 location := loc,
52 spare1_1 := '0'B,
53 codingStandard := std,
54 ext1 := '0'B,
55 recommendation := omit,
56 ext2 := omit
57 },
58 oct4 := {
59 causeValue := cause,
60 ext3 := '1'B
61 },
62 diagnostics := omit
63}
64
Harald Weltec76f29f2017-11-22 12:46:46 +010065
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +070066/* 3GPP TS 24.008, section 10.5.1.4 "Mobile Identity" */
67template (value) MobileIdentityTLV ts_MI_TLV(template (value) MobileIdentityV mi) := {
68 elementIdentifier := '0010111'B,
69 spare1 := '0'B,
70 mobileIdentityLV := ts_MI_LV(mi)
71};
72template MobileIdentityTLV tr_MI_TLV(template MobileIdentityV mi) := {
73 elementIdentifier := '0010111'B,
74 spare1 := '0'B,
75 mobileIdentityLV := tr_MI_LV(mi)
76};
77
78template (value) MobileIdentityLV ts_MI_LV(template (value) MobileIdentityV mi) := {
79 lengthIndicator := 0, /* overwritten */
80 mobileIdentityV := mi
81};
82template MobileIdentityLV tr_MI_LV(template MobileIdentityV mi) := {
83 lengthIndicator := ?,
84 mobileIdentityV := mi
85};
86
87/* Universal (send & receive) template for No Identity */
88template MobileIdentityV t_MI_NoIdentity(template (present) hexstring filler := 'F'H) := {
89 typeOfIdentity := '000'B,
90 oddEvenInd_identity := {
91 no_identity := {
92 /* Always old, since length can be 1, 3, or 5 */
93 oddevenIndicator := '0'B,
94 fillerDigits := filler
95 }
96 }
97};
98
99/* Universal (send & receive) template for TMSI/P-TMSI */
100template MobileIdentityV t_MI_TMSI(template (present) OCT4 tmsi) := {
101 typeOfIdentity := '100'B,
102 oddEvenInd_identity := {
103 tmsi_ptmsi := {
104 oddevenIndicator := '0'B,
105 fillerDigit := '1111'B,
106 octets := tmsi
107 }
108 }
109};
110
111private function f_tr_MI_IMSI(template (present) hexstring digits)
112return template (present) IMSI_L3 {
113 if (istemplatekind(digits, "?")) {
114 return ?;
115 } else {
116 return f_enc_IMSI_L3(valueof(digits))
117 }
118}
Harald Weltebd982952020-08-21 12:34:16 +0200119template MobileIdentityV tr_MI_IMSI(template (present) hexstring imsi) := {
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +0700120 typeOfIdentity := '001'B,
121 oddEvenInd_identity := {
122 imsi := f_tr_MI_IMSI(imsi)
123 }
124};
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +0700125template (value) MobileIdentityV ts_MI_IMSI(hexstring imsi) := {
126 typeOfIdentity := '001'B,
127 oddEvenInd_identity := {
128 imsi := f_enc_IMSI_L3(imsi)
129 }
130};
Vadim Yanitskiyc94c5722020-03-28 05:17:23 +0700131
132
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200133/* send template for Mobile Identity (TMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100134template MobileIdentityLV ts_MI_TMSI_LV(OCT4 tmsi) := {
135 lengthIndicator := 0, /* overwritten */
136 mobileIdentityV := {
137 typeOfIdentity := '000'B, /* overwritten */
138 oddEvenInd_identity := {
139 tmsi_ptmsi := {
140 oddevenIndicator := '0'B,
141 fillerDigit := '1111'B,
142 octets := tmsi
143 }
144 }
145 }
146}
147
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200148/* send template for Mobile Identity (TMSI) */
Harald Welte6abb9fe2018-02-17 15:24:48 +0100149function ts_MI_TMSI_TLV(template (omit) OCT4 tmsi) return template (omit) MobileIdentityTLV {
150 var template (omit) MobileIdentityTLV ret;
151 if (istemplatekind(tmsi, "omit")) {
152 return omit;
153 } else {
154 ret := {
155 elementIdentifier := '0100011'B,
156 spare1 := '0'B,
157 mobileIdentityLV := ts_MI_TMSI_LV(valueof(tmsi))
158 }
159 return ret;
160 }
Harald Welte38575a72018-02-15 20:41:37 +0100161}
162
Harald Welteb0386df2018-02-16 18:14:28 +0100163template MobileIdentityTLV ts_MI_IMEISV_TLV(hexstring imeisv) := {
164 elementIdentifier := '0100011'B,
165 spare1 := '0'B,
166 mobileIdentityLV := ts_MI_IMEISV_LV(imeisv)
167}
168
Harald Weltec76f29f2017-11-22 12:46:46 +0100169private function f_enc_IMSI_L3(hexstring digits) return IMSI_L3 {
170 var IMSI_L3 l3;
171 var integer len := lengthof(digits);
172 if (len rem 2 == 1) { /* modulo remainder */
Harald Welte365f4ed2017-11-23 00:00:43 +0100173 l3.oddevenIndicator := '1'B;
Harald Welteae136252018-01-24 20:53:21 +0100174 l3.fillerDigit := omit;
Harald Weltec76f29f2017-11-22 12:46:46 +0100175 } else {
Harald Welte365f4ed2017-11-23 00:00:43 +0100176 l3.oddevenIndicator := '0'B;
Harald Welteae136252018-01-24 20:53:21 +0100177 l3.fillerDigit := '1111'B;
Harald Weltec76f29f2017-11-22 12:46:46 +0100178 }
179 l3.digits := digits;
180 return l3;
181}
182
Harald Welteba7b6d92018-01-23 21:32:34 +0100183private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {
184 var IMEI_L3 l3;
185 var integer len := lengthof(digits);
Neels Hofmeyr16617812020-06-10 17:31:18 +0200186 /* IMEI_L3 is always 15 digits. That is actually a 14 digit IMEI + a Luhn checksum digit (see
187 * libosmocore/include/osmocom/gsm/protocol/gsm_23_003.h)
188 *
189 * Here, we must not make the oddevenIndicator depend on the 'digits' parameter, because:
190 * - The IMEI_L3 template assumes always 15 digits.
191 * - The 'digits' parameter, however, may also contain less digits, 14 in the case of
192 * f_gen_imei().
193 * - The IMEI_L3 template will then fill up with zeros to make 15 digits.
194 * Hence oddevenIndicator must always indicate 'odd' == '1'B.
195 *
196 * FIXME: if the caller passes less than 15 digits, the Luhn checksum digit then ends up zero == most probably
197 * wrong.
198 */
199 l3.oddevenIndicator := '1'B;
Harald Welteba7b6d92018-01-23 21:32:34 +0100200 l3.digits := digits;
201 return l3;
202}
203
Harald Welteb0386df2018-02-16 18:14:28 +0100204private function f_enc_IMEI_SV(hexstring digits) return IMEI_SV {
205 var IMEI_SV l3;
206 var integer len := lengthof(digits);
207 if (len rem 2 == 1) { /* modulo remainder */
208 l3.oddevenIndicator := '1'B;
209 } else {
210 l3.oddevenIndicator := '0'B;
211 }
212 l3.digits := digits;
213 l3.fillerDigit := '1111'B;
214 return l3;
215}
216
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200217/* send template for Mobile Identity (IMSI) */
Harald Weltec76f29f2017-11-22 12:46:46 +0100218template (value) MobileIdentityLV ts_MI_IMSI_LV(hexstring imsi_digits) := {
219 lengthIndicator := 0, /* overwritten */
220 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100221 typeOfIdentity := '001'B,
Harald Weltec76f29f2017-11-22 12:46:46 +0100222 oddEvenInd_identity := {
223 imsi := f_enc_IMSI_L3(imsi_digits)
224 }
225 }
226}
227
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200228/* send template for Mobile Identity (IMEI) */
Harald Welteba7b6d92018-01-23 21:32:34 +0100229template (value) MobileIdentityLV ts_MI_IMEI_LV(hexstring imei_digits) := {
230 lengthIndicator := 0, /* overwritten */
231 mobileIdentityV := {
Harald Welte519db892018-02-16 18:15:22 +0100232 typeOfIdentity := '010'B,
Harald Welteba7b6d92018-01-23 21:32:34 +0100233 oddEvenInd_identity := {
234 imei := f_enc_IMEI_L3(imei_digits)
235 }
236 }
237}
238
Oliver Smithb4bf2b22019-07-09 11:55:15 +0200239/* send template for Mobile Identity (IMEISV) */
Harald Welteb0386df2018-02-16 18:14:28 +0100240template (value) MobileIdentityLV ts_MI_IMEISV_LV(hexstring imei_digits) := {
241 lengthIndicator := 0, /* overwritten */
242 mobileIdentityV := {
243 typeOfIdentity := '011'B,
244 oddEvenInd_identity := {
245 imei_sv := f_enc_IMEI_SV(imei_digits)
246 }
247 }
248}
249
Harald Welteba7b6d92018-01-23 21:32:34 +0100250
Harald Weltec76f29f2017-11-22 12:46:46 +0100251/* Send template for Classmark 2 */
252template (value) MobileStationClassmark2_LV ts_CM2 := {
253 lengthIndicator := 0,
254 rf_PowerCapability := '000'B,
255 a5_1 := '0'B,
256 esind := '1'B,
257 revisionLevel := '10'B,
258 spare1_1 := '0'B,
Harald Welte898113b2018-01-31 18:32:21 +0100259 mobileStationClassmark2_oct4 := {
260 fc := '1'B,
261 vgcs := '0'B,
262 vbs := '0'B,
263 sm_Capability := '1'B,
264 ss_ScreenIndicator := '01'B,
265 ps_Capability := '1'B,
266 spare2_1 := '0'B
267 },
268 mobileStationClassmark2_oct5 := {
269 a5_2 := '0'B,
270 a5_3 := '1'B,
271 cmsp := '0'B,
272 solsa := '0'B,
273 ucs2 := '0'B,
274 lcsva_cap := '0'B,
275 spare5_7 :='0'B,
276 cm3 := '0'B
277 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100278};
279
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200280template LocationUpdatingType LU_Type_Normal := {
281 lut := '00'B,
282 spare1_1 := '0'B,
283 fop := '0'B
284};
285
286template LocationUpdatingType LU_Type_Periodic := {
287 lut := '01'B,
288 spare1_1 := '0'B,
289 fop := '0'B
290};
291
292template LocationUpdatingType LU_Type_IMSI_Attach := {
293 lut := '10'B,
294 spare1_1 := '0'B,
295 fop := '0'B
296};
297
298/* Send template for LOCATION UPDATING REQUEST */
299template PDU_ML3_MS_NW ts_LU_REQ(template LocationUpdatingType lu_type, MobileIdentityLV mi_lv,
300 OCT3 mcc_mnc := '123456'O) := {
301 discriminator := '0000'B, /* overwritten */
302 tiOrSkip := {
303 skipIndicator := '0000'B
304 },
305 msgs := {
306 mm := {
307 locationUpdateRequest := {
308 messageType := '000000'B, /* overwritten */
309 nsd := '00'B,
310 locationUpdatingType := lu_type,
311 cipheringKeySequenceNumber := { '000'B, '0'B },
312 locationAreaIdentification := {
313 mcc_mnc := mcc_mnc,
314 lac := '172A'O
315 },
316 mobileStationClassmark1 := ts_CM1,
317 mobileIdentityLV := mi_lv,
318 classmarkInformationType2_forUMTS := omit,
319 additionalUpdateParameterTV := omit,
320 deviceProperties := omit,
321 mS_NetworkFeatureSupport := omit
322 }
323 }
324 }
325}
326
327template PDU_ML3_NW_MS ts_LU_ACCEPT(template MobileIdentityTLV mi_tlv := omit) := {
328 discriminator := '0000'B, /* overwritten */
329 tiOrSkip := {
330 skipIndicator := '0000'B
331 },
332 msgs := {
333 mm := {
334 locationUpdateAccept := {
335 messageType := '000000'B, /* overwritten */
336 nsd := '00'B,
337 locationAreaIdentification := {
338 mcc_mnc := '123456'O,
339 lac := '172A'O
340 },
341 mobileIdentityTLV := mi_tlv,
342 followOnProceed := omit,
343 cTS_Permission := omit,
344 equivalentPLMNs := omit,
345 emergencyNumberList := omit,
346 perMS_T3212 := omit
347 }
348 }
349 }
350}
351
Harald Weltec76f29f2017-11-22 12:46:46 +0100352/* Send template for CM SERVICE REQUEST */
Harald Welte6ed6bf92018-01-24 21:09:15 +0100353template (value) PDU_ML3_MS_NW ts_CM_SERV_REQ(CmServiceType serv_type, MobileIdentityLV mi_lv) := {
Harald Weltec76f29f2017-11-22 12:46:46 +0100354 discriminator := '0000'B, /* overwritten */
355 tiOrSkip := {
356 skipIndicator := '0000'B
357 },
358 msgs := {
359 mm := {
360 cMServiceRequest := {
361 messageType := '000000'B, /* overwritten */
362 nsd := '00'B,
Harald Welte6ed6bf92018-01-24 21:09:15 +0100363 cm_ServiceType := int2bit(enum2int(serv_type), 4),
Harald Weltec76f29f2017-11-22 12:46:46 +0100364 cipheringKeySequenceNumber := { '000'B, '0'B },
365 mobileStationClassmark2 := ts_CM2,
366 mobileIdentity := mi_lv,
367 priorityLevel := omit,
368 additionalUpdateParameterTV := omit,
369 deviceProperties := omit
370 }
371 }
372 }
373}
374
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +0200375template (value) PDU_ML3_MS_NW ts_CM_REESTABL_REQ(MobileIdentityLV mi_lv) := {
376 discriminator := '0000'B, /* overwritten */
377 tiOrSkip := {
378 skipIndicator := '0000'B
379 },
380 msgs := {
381 mm := {
382 cMReEstablReq := {
383 messageType := '000000'B, /* overwritten */
384 nsd := '00'B,
385 cipheringKeySequenceNumber := { '000'B, '0'B },
386 spare := '0000'B,
387 mobileStationClassmark2 := ts_CM2,
388 mobileIdentityLV := mi_lv,
389 locationAreaIdentification := omit,
390 deviceProperties := omit
391 }
392 }
393 }
394}
395
Harald Welte0195ab12018-01-24 21:50:20 +0100396template (value) CipheringKeySequenceNumberV ts_CKSN(integer key_seq) := {
397 keySequence := int2bit(key_seq, 3),
398 spare := '0'B
399}
400
401/* Send template for CM RE-ESTABLISH REQUEST */
402template (value) PDU_ML3_MS_NW ts_CM_REEST_REQ(integer cksn, MobileIdentityLV mi_lv) := {
403 discriminator := '0000'B, /* overwritten */
404 tiOrSkip := {
405 skipIndicator := '0000'B
406 },
407 msgs := {
408 mm := {
409 cMReEstablReq := {
410 messageType := '101000'B, /* overwritten */
411 nsd := '00'B,
412 cipheringKeySequenceNumber := ts_CKSN(cksn),
413 spare := '0000'B,
414 mobileStationClassmark2 := ts_CM2,
415 mobileIdentityLV := mi_lv,
416 locationAreaIdentification := omit,
417 deviceProperties := omit
418 }
419 }
420 }
421}
422
423
Harald Welte6ff81902018-01-21 19:09:08 +0100424template PDU_ML3_NW_MS tr_MT_simple(template BIT4 discr := ?) := {
425 discriminator := discr,
426 tiOrSkip := {
427 skipIndicator := '0000'B
428 },
429 msgs := ?
430}
431
432
433template PDU_ML3_NW_MS tr_CM_SERV_ACC := {
434 discriminator := '0101'B,
435 tiOrSkip := {
436 skipIndicator := '0000'B
437 },
438 msgs := {
439 mm := {
440 cMServiceAccept := {
441 messageType := '100001'B,
442 nsd := ?
443 }
444 }
445 }
446}
447
448
Harald Weltecb6cc332018-01-21 13:59:08 +0100449template PDU_ML3_NW_MS tr_CM_SERV_REJ(template OCT1 rej_cause := ?) := {
450 discriminator := '0101'B,
451 tiOrSkip := {
452 skipIndicator := '0000'B
453 },
454 msgs := {
455 mm := {
456 cMServiceReject := {
457 messageType := '100010'B,
458 nsd := ?,
459 rejectCause := rej_cause,
460 t3246_Value := *
461 }
462 }
463 }
464}
465
Harald Welte68e495b2018-02-25 00:05:57 +0100466template PDU_ML3_NW_MS tr_PAGING_REQ1(template MobileIdentityLV mi1 := ?,
467 template MobileIdentityTLV mi2 := *) := {
468 discriminator := '0110'B,
469 tiOrSkip := {
470 skipIndicator := '0000'B
471 },
472 msgs := {
473 rrm := {
474 pagingReq_Type1 := {
475 messageType := '00100001'B,
476 pageMode := ?,
477 channelNeeded := ?,
478 mobileIdentity1 := mi1,
479 mobileIdentity2 := mi2,
480 p1RestOctets := ?
481 }
482 }
483 }
484}
485
486template PDU_ML3_NW_MS tr_PAGING_REQ2(template TMSIP_TMSI_V mi1 := ?,
487 template TMSIP_TMSI_V mi2 := ?,
488 template MobileIdentityTLV mi3 := *) := {
489 discriminator := '0110'B,
490 tiOrSkip := {
491 skipIndicator := '0000'B
492 },
493 msgs := {
494 rrm := {
495 pagingReq_Type2 := {
496 messageType := '00100010'B,
497 pageMode := ?,
498 channelNeeded := ?,
499 mobileIdentity1 := mi1,
500 mobileIdentity2 := mi2,
501 mobileIdentity3 := mi3,
502 p2RestOctets := ?
503 }
504 }
505 }
506}
507
508template PDU_ML3_NW_MS tr_PAGING_REQ3(template TMSIP_TMSI_V mi1 := ?,
509 template TMSIP_TMSI_V mi2 := ?,
510 template TMSIP_TMSI_V mi3 := ?,
511 template TMSIP_TMSI_V mi4 := ?) := {
512 discriminator := '0110'B,
513 tiOrSkip := {
514 skipIndicator := '0000'B
515 },
516 msgs := {
517 rrm := {
518 pagingReq_Type3 := {
519 messageType := '00100100'B,
520 pageMode := ?,
521 channelNeeded := ?,
522 mobileIdentity1 := mi1,
523 mobileIdentity2 := mi2,
524 mobileIdentity3 := mi3,
525 mobileIdentity4 := mi4,
526 p3RestOctets := ?
527 }
528 }
529 }
530}
531
532
533
Harald Weltec76f29f2017-11-22 12:46:46 +0100534/* Send template for PAGING RESPONSE */
535template (value) PDU_ML3_MS_NW ts_PAG_RESP(MobileIdentityLV mi_lv) := {
536 discriminator := '0000'B, /* overwritten */
537 tiOrSkip := {
538 skipIndicator := '0000'B
539 },
540 msgs := {
541 rrm := {
542 pagingResponse := {
543 messageType := '00000000'B, /* overwritten */
544 cipheringKeySequenceNumber := { '000'B, '0'B },
545 spare1_4 := '0000'B,
546 mobileStationClassmark := ts_CM2,
547 mobileIdentity := mi_lv,
548 additionalUpdateParameters := omit
549 }
550 }
551 }
552}
553
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200554template ChannelDescription2_V tr_ChannelDescription2_V(template BIT3 timeslotNumber := ?,
555 template BIT5 channelTypeandTDMAOffset := ?) := {
556 timeslotNumber := timeslotNumber,
557 channelTypeandTDMAOffset := channelTypeandTDMAOffset,
558 octet3 := ?,
559 octet4 := ?
560}
561
562template ChannelMode_V tr_ChannelMode_V(template OCT1 mode) := {
563 mode := mode
564}
565
566template ExtendedTSCSet_TV tr_ExtendedTSCSet_TV(template BIT2 cSDomainTSCSet := ?) := {
567 elementIdentifier := '6D'O,
568 cSDomainTSCSet := cSDomainTSCSet,
569 secondPSDomainTSCAssigned := ?,
570 primaryPSDomainTSCSet := ?,
571 secondaryPSDomainTSCSet := ?,
572 secondaryPSDomainTSCValue := ?
573}
574
575template PDU_ML3_NW_MS tr_RRM_ModeModify(template ChannelDescription2_V desc := ?,
576 template ChannelMode_V mode := ?,
577 template ExtendedTSCSet_TV extendedTSCSet) := {
578 discriminator := '0110'B,
579 tiOrSkip := {
580 skipIndicator := '0000'B
581 },
582 msgs := {
583 rrm := {
584 channelModeModify := {
585 messageType := '00010000'B,
586 channelDescription := desc,
587 channelMode := mode,
588 vGCS_TargetModeIndication := omit,
589 multiRateConfiguration := omit,
590 vGCS_Ciphering_Parameters := omit,
591 extendedTSCSet := extendedTSCSet
592 }
593 }
594 }
595}
596
597template (value) PDU_ML3_MS_NW ts_RRM_ModeModifyAck(ChannelDescription2_V desc, ChannelMode_V mode,
598 template (omit) ExtendedTSCSet_TV extendedTSCSet := omit) := {
Harald Welte15166142017-12-16 23:02:08 +0100599 discriminator := '0000'B, /* overwritten */
600 tiOrSkip := {
601 skipIndicator := '0000'B
602 },
603 msgs := {
604 rrm := {
605 channelModeModifyAck := {
606 messageType := '00010111'B,
607 channelDescription := desc,
608 channelMode := mode,
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200609 extendedTSCSet := extendedTSCSet
Harald Welte15166142017-12-16 23:02:08 +0100610 }
611 }
612 }
613}
614
Harald Weltee613f962018-04-18 22:38:16 +0200615template (value) PDU_ML3_NW_MS ts_RRM_CiphModeCmd(BIT3 alg_id) := {
616 discriminator := '0000'B, /* overwritten */
617 tiOrSkip := {
618 skipIndicator := '0000'B
619 },
620 msgs := {
621 rrm := {
622 cipheringModeCommand := {
623 messageType := '00110101'B,
624 cipherModeSetting := {
625 sC := '1'B,
626 algorithmIdentifier := alg_id
627 },
628 cipherModeResponse := {
629 cR := '0'B,
630 spare := '000'B
631 }
632 }
633 }
634 }
635}
636
Harald Welte73cd2712017-12-17 00:44:52 +0100637template (value) PDU_ML3_MS_NW ts_RRM_CiphModeCompl := {
638 discriminator := '0000'B, /* overwritten */
639 tiOrSkip := {
640 skipIndicator := '0000'B
641 },
642 msgs := {
643 rrm := {
644 cipheringModeComplete := {
645 messageType := '00110010'B,
646 mobileEquipmentIdentity := omit
647 }
648 }
649 }
650}
651
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200652template ChannelMode_TV tr_ChannelMode_TV(template OCT1 mode) := {
653 elementIdentifier := '63'O,
654 mode := mode
655}
656
657template (present) PDU_ML3_NW_MS tr_RR_AssignmentCommand(
658 template ChannelDescription2_V desc := ?,
659 template ChannelMode_TV mode := ?,
660 template ExtendedTSCSet_TV extendedTSCSet := omit
661) := {
662 discriminator := '0110'B,
663 tiOrSkip := {
664 skipIndicator := '0000'B
665 },
666 msgs := {
667 rrm := {
668 assignmentCommand := {
669 messageType := '00101110'B,
670 descrOf1stChAfterTime := desc,
671 PowerCommand := ?,
672 frequencyList_at := omit,
673 cellChannelDescr := omit,
674 descrMultislotAllocation := omit,
675 modeOf1stChannel := mode,
676 channelSet2 := omit,
677 channelSet3 := omit,
678 channelSet4 := omit,
679 channelSet5 := omit,
680 channelSet6 := omit,
681 channelSet7 := omit,
682 channelSet8 := omit,
683 descrOf2ndChAfterTime := omit,
684 modeOf2ndChannel := omit,
685 mobileAllocation_at := omit,
686 startingTime := omit,
687 frequencyList_bt := omit,
688 descrOf1stCh_bt := omit,
689 descrOf2ndCh_bt := omit,
690 frequencyChannelSequence := omit,
691 mobileAllocation_bt := omit,
692 cipherModeSetting := omit,
693 vGCS_TargetModeIndication := omit,
694 multiRateConfiguration := omit,
695 vGCS_Ciphering_Parameters := omit,
696 extendedTSCSet_afterTime := extendedTSCSet,
697 extendedTSCSet_beforeTime := omit
698 }
699 }
700 }
701}
702
Harald Welteecb254b2018-01-29 22:01:54 +0100703template (value) PDU_ML3_MS_NW ts_RRM_AssignmentComplete(OCT1 cause) := {
704 discriminator := '0000'B, /* overwritten */
705 tiOrSkip := {
706 skipIndicator := '0000'B
707 },
708 msgs := {
709 rrm := {
710 assignmentComplete := {
711 messageType := '00101001'B,
712 rR_Cause := {
713 valuePart := cause
714 }
715 }
716 }
717 }
718}
Harald Welte15166142017-12-16 23:02:08 +0100719
Harald Welte898113b2018-01-31 18:32:21 +0100720template (value) PDU_ML3_MS_NW ts_RRM_AssignmentFailure(OCT1 cause) := {
721 discriminator := '0000'B, /* overwritten */
722 tiOrSkip := {
723 skipIndicator := '0000'B
724 },
725 msgs := {
726 rrm := {
727 assignmentFailure := {
728 messageType := '00101111'B,
729 rR_Cause := {
730 valuePart := cause
731 }
732 }
733 }
734 }
735}
736
Harald Weltefbf9b5e2018-01-31 20:41:23 +0100737template (value) PDU_ML3_MS_NW ts_RRM_HandoverFailure(OCT1 cause) := {
738 discriminator := '0000'B, /* overwritten */
739 tiOrSkip := {
740 skipIndicator := '0000'B
741 },
742 msgs := {
743 rrm := {
744 handoverFailure := {
745 messageType := '00101000'B,
746 rRCause := {
747 valuePart := cause
748 },
749 pSCause := omit
750 }
751 }
752 }
753}
Harald Welte898113b2018-01-31 18:32:21 +0100754
Harald Welte261af4b2018-02-12 21:20:39 +0100755template (value) PDU_ML3_MS_NW ts_RRM_HandoverComplete(OCT1 cause) := {
756 discriminator := '0000'B, /* overwritten */
757 tiOrSkip := {
758 skipIndicator := '0000'B
759 },
760 msgs := {
761 rrm := {
762 handoverComplete := {
763 messageType := '00101100'B,
764 rRCause := {
765 valuePart := cause
766 },
767 mobileObsservedTimeDiff := omit,
768 mobileTimeDifferenceHyperframe := omit
769 }
770 }
771 }
772}
773
Harald Welte187f7a92019-09-05 11:15:20 +0200774template (present) PDU_ML3_NW_MS tr_RR_APP_INFO(template (present) BIT4 apdu_id,
775 template (present) octetstring data,
776 template (present) APDU_Flags_V flags := ?) := {
777 discriminator := '0000'B, /* overwritten */
778 tiOrSkip := {
779 skipIndicator := '0000'B
780 },
781 msgs := {
782 rrm := {
783 applicationInformation := {
784 messageType := '00111000'B,
785 aPDU_ID := apdu_id,
786 aPDU_Flags := flags,
787 aPDU_Data := {
788 lengthIndicator := ?,
789 aPDU_DataValue := data
790 }
791 }
792 }
793 }
794}
795
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +0100796template (value) PDU_ML3_NW_MS ts_RR_HandoverCommand := {
797 discriminator := '0110'B,
798 tiOrSkip := {
799 skipIndicator := '0000'B
800 },
801 msgs := {
802 rrm := {
803 handoverCommand := {
804 messageType := '00101011'B,
805 cellDescription := {
806 bcc := '001'B,
807 ncc := '010'B,
808 BCCHArfcn_HighPart := '11'B,
809 BCCHArfcn_LowPart := '04'O
810 },
811 channelDescription2 := {
812 timeslotNumber := '110'B,
813 channelTypeandTDMAOffset := '00001'B,
814 octet3 := '00'O,
815 octet4 := '09'O
816 },
817 handoverReference := {
818 handoverReferenceValue := '00'O
819 },
820 powerCommandAndAccesstype := {
821 powerlevel := '00000'B,
822 fPC_EP := '0'B,
823 ePC_Mode := '0'B,
824 aTC := '0'B
825 },
826 synchronizationIndication := omit,
827 frequencyShortListAfterTime := omit,
828 frequencyListAfterTime := omit,
829 cellChannelDescription := omit,
830 multislotAllocation := omit,
831 modeOfChannelSet1 := omit,
832 modeOfChannelSet2 := omit,
833 modeOfChannelSet3 := omit,
834 modeOfChannelSet4 := omit,
835 modeOfChannelSet5 := omit,
836 modeOfChannelSet6 := omit,
837 modeOfChannelSet7 := omit,
838 modeOfChannelSet8 := omit,
839 descrOf2ndCh_at := omit,
840 modeOf2ndChannel := omit,
841 frequencyChannelSequence_at := omit,
842 mobileAllocation_at := omit,
843 startingTime := omit,
844 timeDifference := omit,
845 timingAdvance := omit,
846 frequencyShortListBeforeTime := omit,
847 frequencyListBeforeTime := omit,
848 descrOf1stCh_bt := omit,
849 descrOf2ndCh_bt := omit,
850 frequencyChannelSequence_bt := omit,
851 mobileAllocation_bt := omit,
852 cipherModeSetting := omit,
853 vGCS_TargetModeIndication := omit,
854 multiRateConfiguration := omit,
855 dynamicARFCN_Mapping := omit,
856 vGCS_Ciphering_Parameters := omit,
857 dedicatedServiceInformation := omit,
858 pLMNIndex := omit,
859 extendedTSCSet_afterTime := omit,
860 extendedTSCSet_beforeTime := omit
861 }
862 }
863 }
864}
865
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200866template PDU_ML3_NW_MS tr_RR_HandoverCommand := {
867 discriminator := '0110'B,
868 tiOrSkip := {
869 skipIndicator := '0000'B
870 },
871 msgs := {
872 rrm := {
873 handoverCommand := {
874 messageType := '00101011'B,
875 cellDescription := ?,
876 channelDescription2 := ?,
877 handoverReference := ?,
878 powerCommandAndAccesstype := ?,
879 synchronizationIndication := *,
880 frequencyShortListAfterTime := *,
881 frequencyListAfterTime := *,
882 cellChannelDescription := *,
883 multislotAllocation := *,
884 modeOfChannelSet1 := *,
885 modeOfChannelSet2 := *,
886 modeOfChannelSet3 := *,
887 modeOfChannelSet4 := *,
888 modeOfChannelSet5 := *,
889 modeOfChannelSet6 := *,
890 modeOfChannelSet7 := *,
891 modeOfChannelSet8 := *,
892 descrOf2ndCh_at := *,
893 modeOf2ndChannel := *,
894 frequencyChannelSequence_at := *,
895 mobileAllocation_at := *,
896 startingTime := *,
897 timeDifference := *,
898 timingAdvance := *,
899 frequencyShortListBeforeTime := *,
900 frequencyListBeforeTime := *,
901 descrOf1stCh_bt := *,
902 descrOf2ndCh_bt := *,
903 frequencyChannelSequence_bt := *,
904 mobileAllocation_bt := *,
905 cipherModeSetting := *,
906 vGCS_TargetModeIndication := *,
907 multiRateConfiguration := *,
908 dynamicARFCN_Mapping := *,
909 vGCS_Ciphering_Parameters := *,
910 dedicatedServiceInformation := *,
911 pLMNIndex := *,
912 extendedTSCSet_afterTime := *,
913 extendedTSCSet_beforeTime := *
914 }
915 }
916 }
917}
918
Harald Welte898113b2018-01-31 18:32:21 +0100919function ts_CM3_TLV(template (omit) OCTN cm3) return template MobileStationClassmark3_TLV {
920 if (not isvalue(cm3)) {
921 return omit;
922 }
923 var template MobileStationClassmark3_TLV ret := {
924 elementIdentifier := '20'O,
925 lengthIndicator := 0, /* overwritten */
926 valuePart := cm3
927 }
928 return ret;
929}
930
931template (value) PDU_ML3_MS_NW ts_RRM_CM_CHG(MobileStationClassmark2_LV cm2,
932 template (omit) MobileStationClassmark3_TLV cm3 := omit) := {
933 discriminator := '0110'B,
934 tiOrSkip := {
935 skipIndicator := '0000'B
936 },
937 msgs := {
938 rrm := {
939 classmarkChange := {
940 messageType := '00010110'B,
941 mobileStationClassmark2 := cm2,
942 mobileStationClassmark3 := cm3
943 }
944 }
945 }
946}
947
Neels Hofmeyr92b12b72018-09-18 14:30:23 +0200948template PDU_ML3_NW_MS tr_RRM_CM_ENQUIRY := {
949 discriminator := '0110'B,
950 tiOrSkip := {
951 skipIndicator := '0000'B
952 },
953 msgs := {
954 rrm := {
955 classmarkEnquiry := {
956 messageType := '00010011'B,
957 classmarkEnquiryMask := *
958 }
959 }
960 }
961}
962
Harald Weltee3bd6582018-01-31 22:51:25 +0100963template (value) PDU_ML3_MS_NW ts_RRM_UL_REL(OCT1 cause) := {
964 discriminator := '0110'B,
965 tiOrSkip := {
966 skipIndicator := '0000'B
967 },
968 msgs := {
969 rrm := {
970 uplinkRelease := {
971 messageType := '00001110'B,
972 rR_Cause := {
973 valuePart := cause
974 }
975 }
976 }
977 }
978}
979
980template PDU_ML3_MS_NW tr_RRM_RR_STATUS(template OCT1 cause := ?) := {
981 discriminator := '0110'B,
982 tiOrSkip := {
983 skipIndicator := '0000'B
984 },
985 msgs := {
986 rrm := {
987 rR_Status := {
988 messageType := '00010010'B,
989 rR_Cause := {
990 valuePart := cause
991 }
992 }
993 }
994 }
995}
996
Harald Welte924b6ea2019-02-04 01:05:34 +0100997template PDU_ML3_NW_MS tr_RRM_RR_RELEASE(template OCT1 cause := ?) := {
998 discriminator := '0110'B,
999 tiOrSkip := {
1000 skipIndicator := '0000'B
1001 },
1002 msgs := {
1003 rrm := {
1004 channelRelease := {
1005 messageType := '00001101'B,
1006 rRCause := {
1007 valuePart := cause
1008 },
1009 bARange := *,
1010 groupChannelDescription := *,
1011 groupCipherKeyNumber := *,
1012 gPRSResumption := *,
1013 bAListPref := *,
1014 uTRANFrequencyList := *,
1015 cellChannelDescr := *,
1016 cellSelectionIndicator := *,
1017 enhanced_DTM_CS_Release_Indication := *,
1018 vGCS_Ciphering_Parameters := *,
1019 group_Channel_Description_2 := *,
1020 talkerIdentity := *,
1021 talkerPriorityStatus := *,
1022 vGCS_AMR_Configuration := *,
1023 individual_Priorities := *
1024 }
1025 }
1026 }
1027}
Harald Weltee3bd6582018-01-31 22:51:25 +01001028
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001029template PDU_ML3_NW_MS tr_RRM_RR_RELEASE_CellSelectInd(template OCT1 cause := ?) modifies tr_RRM_RR_RELEASE := {
Harald Welte99787102019-02-04 10:41:36 +01001030 msgs := {
1031 rrm := {
1032 channelRelease := {
1033 cellSelectionIndicator := {
1034 elementIdentifier := '77'O,
1035 lengthIndicator := ?,
1036 cellSelectionIndicatorValue := ?
1037 }
1038 }
1039 }
1040 }
1041}
Harald Weltee3bd6582018-01-31 22:51:25 +01001042
Harald Weltecb6cc332018-01-21 13:59:08 +01001043template PDU_ML3_MS_NW ts_ML3_MO := {
1044 discriminator := '0000'B,
1045 tiOrSkip := {
1046 skipIndicator := '0000'B
1047 },
1048 msgs := ?
1049}
1050
1051template LocationUpdatingType ts_ML3_IE_LuType := {
1052 lut := ?,
1053 spare1_1 := '0'B,
1054 fop := '0'B
1055}
1056
1057template LocationUpdatingType ts_ML3_IE_LuType_Normal modifies ts_ML3_IE_LuType := {
1058 lut := '00'B
1059}
1060
1061template LocationUpdatingType ts_ML3_IE_LuType_Periodic modifies ts_ML3_IE_LuType := {
1062 lut := '01'B
1063}
1064
1065template LocationUpdatingType ts_ML3_IE_LuType_Attach modifies ts_ML3_IE_LuType := {
1066 lut := '10'B
1067}
1068
1069template CipheringKeySequenceNumberV ts_ML3_IE_CKSN(integer cksn) := {
1070 keySequence := int2bit(cksn, 3),
1071 spare := '0'B
1072}
1073
1074template PDU_ML3_MS_NW ts_ML3_MO_LU_Req(LocationUpdatingType lu_type, LocationAreaIdentification_V lai,
1075 MobileIdentityLV mi, MobileStationClassmark1_V cm1)
1076modifies ts_ML3_MO := {
1077 msgs := {
1078 mm := {
1079 locationUpdateRequest := {
1080 messageType := '001000'B,
1081 nsd := '00'B, /* ? */
1082 locationUpdatingType := lu_type,
1083 cipheringKeySequenceNumber := ts_ML3_IE_CKSN(0),
1084 locationAreaIdentification := lai,
1085 mobileStationClassmark1 := cm1,
1086 mobileIdentityLV := mi,
1087 classmarkInformationType2_forUMTS := omit,
1088 additionalUpdateParameterTV := omit,
1089 deviceProperties := omit,
1090 mS_NetworkFeatureSupport := omit
1091 }
1092 }
1093 }
1094}
1095
Harald Welte6ff81902018-01-21 19:09:08 +01001096template PDU_ML3_MS_NW ts_ML3_MO_TmsiRealloc_Cmpl modifies ts_ML3_MO := {
1097 msgs := {
1098 mm := {
1099 tmsiReallocComplete := {
1100 messageType := '011011'B,
1101 nsd := '00'B
1102 }
1103 }
1104 }
1105}
1106
1107template PDU_ML3_NW_MS tr_ML3_MT_LU_Acc := {
1108 discriminator := '0101'B,
1109 tiOrSkip := {
1110 skipIndicator := '0000'B
1111 },
1112 msgs := {
1113 mm := {
1114 locationUpdateAccept := {
1115 messageType := '000010'B,
1116 nsd := '00'B,
1117 locationAreaIdentification := ?,
1118 mobileIdentityTLV := *,
1119 followOnProceed := *,
1120 cTS_Permission := *,
1121 equivalentPLMNs := *,
1122 emergencyNumberList := *,
1123 perMS_T3212 := *
1124 }
1125 }
1126 }
1127}
1128
1129template PDU_ML3_NW_MS tr_ML3_MT_LU_Rej(template OCT1 cause := ?) := {
1130 discriminator := '0101'B,
1131 tiOrSkip := {
1132 skipIndicator := '0000'B
1133 },
1134 msgs := {
1135 mm := {
1136 locationUpdateReject := {
1137 messageType := '000100'B,
1138 nsd := '00'B,
1139 rejectCause := cause,
1140 t3246_Value := *
1141 }
1142 }
1143 }
1144}
1145
Oliver Smithaf2f1f82019-07-19 12:33:12 +02001146private function f_id_type_or_any(template CmIdentityType id_type) return template bitstring {
1147 if (istemplatekind(id_type, "?")) {
1148 return ?;
1149 } else {
1150 return int2bit(enum2int(valueof(id_type)), 3);
1151 }
1152}
1153
Oliver Smith32898452019-07-09 12:32:35 +02001154template PDU_ML3_NW_MS tr_ML3_MT_MM_ID_Req(template CmIdentityType id_type := ?) := {
Harald Welteba7b6d92018-01-23 21:32:34 +01001155 discriminator := '0101'B,
1156 tiOrSkip := {
1157 skipIndicator := '0000'B
1158 },
1159 msgs := {
1160 mm := {
1161 identityRequest := {
1162 messageType := '011000'B,
1163 nsd := '00'B,
Oliver Smithaf2f1f82019-07-19 12:33:12 +02001164 identityType := f_id_type_or_any(id_type),
Harald Welteba7b6d92018-01-23 21:32:34 +01001165 spare1_5 := ?
1166 }
1167 }
1168 }
1169}
1170
1171template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp(MobileIdentityLV mi) modifies ts_ML3_MO := {
1172 msgs := {
1173 mm := {
1174 identityResponse := {
1175 messageType := '011001'B,
1176 nsd := '00'B,
1177 mobileIdentityLV := mi,
1178 p_TMSI_TypeTV := omit,
1179 routingAreaIdentification2TLV := omit,
1180 p_TMSISignature2TLV := omit
1181 }
1182 }
1183 }
1184}
1185template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMSI(hexstring imsi) :=
1186 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMSI_LV(imsi)));
1187template PDU_ML3_MS_NW ts_ML3_MO_MM_ID_Rsp_IMEI(hexstring imei) :=
1188 ts_ML3_MO_MM_ID_Rsp(valueof(ts_MI_IMEI_LV(imei)));
1189
1190
Neels Hofmeyr63382472018-03-01 19:57:44 +01001191template (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 +01001192 rf_PowerCapability := '010'B,
1193 a5_1 := a5_1_unavail,
Neels Hofmeyr63382472018-03-01 19:57:44 +01001194 esind := esind,
Harald Welte45164da2018-01-24 12:51:27 +01001195 revisionLevel := rev,
1196 spare1_1 := '0'B
1197}
1198
1199template PDU_ML3_MS_NW ts_ML3_MO_MM_IMSI_DET_Ind(MobileIdentityLV mi,
1200 template MobileStationClassmark1_V cm1 := ts_CM1)
1201modifies ts_ML3_MO := {
1202 msgs := {
1203 mm := {
1204 imsiDetachIndication := {
1205 messageType := '000001'B,
1206 nsd := '00'B,
1207 mobileStationClassmark1 := cm1,
1208 mobileIdentityLV := mi
1209 }
1210 }
1211 }
1212}
1213
Harald Welted748a052018-01-22 02:59:24 +01001214template PDU_ML3_MS_NW ts_ML3_MO_CC(integer tid) := {
1215 discriminator := '0011'B,
1216 tiOrSkip := {
1217 transactionId := {
Daniel Willmanndcf9eb92018-02-02 20:07:52 +01001218 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001219 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001220 tIExtension := omit
1221 }
Harald Welte9bf43cc2020-08-21 12:33:18 +02001222 },
1223 msgs := -
Harald Welted748a052018-01-22 02:59:24 +01001224}
1225
1226template (value) CalledPartyBCD_Number ts_Called(hexstring digits) := {
1227 elementIdentifier := '5E'O,
1228 lengthIndicator := 0, /* overwritten */
1229 numberingPlanIdentification := '0000'B,
1230 typeOfNumber := '000'B, /* unknown */
Vadim Yanitskiy559f5dc2021-02-05 03:08:11 +01001231 ext1 := '1'B, /* no extension */
Harald Welted748a052018-01-22 02:59:24 +01001232 digits := digits
1233}
1234
Harald Welte812f7a42018-01-27 00:49:18 +01001235template CalledPartyBCD_Number tr_Called(template hexstring digits) := {
1236 elementIdentifier := '5E'O,
1237 lengthIndicator := ?,
1238 numberingPlanIdentification := ?,
1239 typeOfNumber := ?,
Vadim Yanitskiy559f5dc2021-02-05 03:08:11 +01001240 ext1 := '1'B, /* no extension */
Harald Welte812f7a42018-01-27 00:49:18 +01001241 digits := digits
1242}
1243
Stefan Sperling26d57be2018-11-12 17:03:26 +01001244private function f_pad_digits(hexstring digits) return hexstring {
1245 if (lengthof(digits) mod 2 != 0) {
1246 /* Add trailing nibble of 1-bit padding, like the CallingPartyBCD_Number encoder would do.
1247 * Otherwise our template won't match the data received (see OS#2930). */
1248 return digits & 'F'H;
1249 }
1250 return digits;
1251}
1252
Harald Welte812f7a42018-01-27 00:49:18 +01001253template CallingPartyBCD_Number tr_Calling(template hexstring digits) := {
1254 elementIdentifier := '5C'O,
1255 lengthIndicator := ?,
1256 oct3 := ?,
Stefan Sperling26d57be2018-11-12 17:03:26 +01001257 digits := f_pad_digits(valueof(digits))
Harald Welte812f7a42018-01-27 00:49:18 +01001258}
1259
Harald Welte4b2b3a62018-01-26 10:32:39 +01001260type integer SpeechVer;
1261
1262template (value) Speech_AuxiliarySpeech ts_SpeechAux(SpeechVer ver, BIT1 suffix) := {
1263 speechVersionIndication := int2bit(ver-1,3) & suffix,
1264 spare1_1 := '0'B,
1265 cTM_or_Spare := '0'B,
1266 coding := '0'B,
1267 extension_octet_3a_3b := '0'B
1268}
1269
1270template (value) Speech_AuxiliarySpeech ts_SpeechAuxFR(SpeechVer ver) := ts_SpeechAux(ver, '0'B);
1271template (value) Speech_AuxiliarySpeech ts_SpeechAuxHR(SpeechVer ver) := ts_SpeechAux(ver, '1'B);
1272
Harald Welted748a052018-01-22 02:59:24 +01001273template (value) BearerCapability_TLV ts_Bcap_voice := {
1274 elementIdentifier := '04'O,
1275 lengthIndicator := 0, /* overwritten */
1276 octet3 := {
1277 informationTransferCapability := '000'B,
1278 transferMode := '0'B,
1279 codingStandard := '0'B,
1280 radioChannelRequirement := '11'B, /* FR preferred */
1281 extension_octet_3 := '0'B, /* overwritten */
Harald Welte4b2b3a62018-01-26 10:32:39 +01001282 speech_aux_3a_3b := {
1283 valueof(ts_SpeechAuxHR(3)),
1284 valueof(ts_SpeechAuxFR(3)),
1285 valueof(ts_SpeechAuxFR(2)),
1286 valueof(ts_SpeechAuxFR(1)),
1287 valueof(ts_SpeechAuxHR(1))
1288 }
Harald Welted748a052018-01-22 02:59:24 +01001289 },
1290 octet4 := omit,
1291 octet5 := omit,
1292 octet6 := omit,
1293 octet7 := omit
1294}
1295
1296template PDU_ML3_MS_NW ts_ML3_MO_CC_SETUP(integer tid, hexstring called, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1297 discriminator := '0011'B,
1298 tiOrSkip := {
1299 transactionId := {
1300 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001301 tiFlag := c_TIF_ORIG,
Harald Welted748a052018-01-22 02:59:24 +01001302 tIExtension := omit
1303 }
1304 },
1305 msgs := {
1306 cc := {
1307 setup_MS_NW := {
1308 messageType := '000101'B,
1309 nsd := '00'B,
1310 bcRepeatIndicator := omit,
1311 bearerCapability1 := bcap,
1312 bearerCapability2 := omit,
1313 facility := omit,
1314 callingPartySubAddress := omit,
1315 calledPartyBCD_Number := ts_Called(called),
1316 calledPartySubAddress := omit,
1317 llc_RepeatIndicator := omit,
1318 lowLayerCompatibility1 := omit,
1319 lowLayerCompatibility2 := omit,
1320 hlc_RepeatIndicator := omit,
1321 highLayerCompatibility1 := omit,
1322 highLayerCompatibility2 := omit,
1323 user_user := omit,
1324 ss_VersionIndicator := omit,
1325 clir_Suppression := omit,
1326 clir_Invocation := omit,
1327 cC_Capabilities := omit,
1328 facility_ccbs1 := omit,
1329 facility_ccbs2 := omit,
1330 streamIdentifier := omit,
1331 supportedCodecs := omit,
1332 redial := omit
1333 }
1334 }
1335 }
1336}
1337
Harald Welte45164da2018-01-24 12:51:27 +01001338template PDU_ML3_MS_NW ts_ML3_MO_CC_EMERG_SETUP(integer tid, template BearerCapability_TLV bcap := ts_Bcap_voice) := {
1339 discriminator := '0011'B,
1340 tiOrSkip := {
1341 transactionId := {
1342 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001343 tiFlag := c_TIF_ORIG,
Harald Welte45164da2018-01-24 12:51:27 +01001344 tIExtension := omit
1345 }
1346 },
1347 msgs := {
1348 cc := {
1349 emergencySetup := {
1350 messageType := '001110'B,
1351 nsd := '00'B,
1352 bearerCapability := bcap,
1353 streamIdentifier := omit,
1354 supportedCodecs := omit,
1355 emergencyCategory := omit
1356 }
1357 }
1358 }
1359}
1360
1361
Harald Welted748a052018-01-22 02:59:24 +01001362template PDU_ML3_NW_MS tr_ML3_MT_CC_CALL_PROC(integer tid) := {
1363 discriminator := '0011'B,
1364 tiOrSkip := {
1365 transactionId := {
1366 tio := int2bit(tid, 3),
1367 tiFlag := ?,
1368 tIExtension := omit
1369 }
1370 },
1371 msgs := {
1372 cc := {
1373 callProceeding := {
1374 messageType := '000010'B,
1375 nsd := '00'B,
1376 repeatIndicator := *,
1377 bearerCapability1 := *,
1378 bearerCapability2 := *,
1379 facility := *,
1380 progressIndicator := *,
1381 priorityGranted := *,
1382 networkCCCapabilities := *
1383 }
1384 }
1385 }
1386}
1387
1388template PDU_ML3_NW_MS tr_ML3_MT_CC_ALERTING(integer tid) := {
1389 discriminator := '0011'B,
1390 tiOrSkip := {
1391 transactionId := {
1392 tio := int2bit(tid, 3),
1393 tiFlag := ?,
1394 tIExtension := omit
1395 }
1396 },
1397 msgs := {
1398 cc := {
1399 alerting_NW_MS := {
1400 messageType := '000001'B,
1401 nsd := '00'B,
1402 facility := *,
1403 progressIndicator := *,
1404 user_user := *
1405 }
1406 }
1407 }
1408}
1409
Harald Welte33ec09b2018-02-10 15:34:46 +01001410template PDU_ML3_MS_NW ts_ML3_MO_CC_ALERTING(integer tid) := {
1411 discriminator := '0011'B,
1412 tiOrSkip := {
1413 transactionId := {
1414 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001415 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001416 tIExtension := omit
1417 }
1418 },
1419 msgs := {
1420 cc := {
1421 alerting_MS_NW := {
1422 messageType := '000001'B,
1423 nsd := '00'B,
1424 facility := omit,
1425 user_user := omit,
1426 ss_VersionIndicator := omit
1427 }
1428 }
1429 }
1430}
1431
1432template PDU_ML3_MS_NW ts_ML3_MT_CC_ALERTING(integer tid) := {
1433 discriminator := '0011'B,
1434 tiOrSkip := {
1435 transactionId := {
1436 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001437 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001438 tIExtension := omit
1439 }
1440 },
1441 msgs := {
1442 cc := {
1443 alerting_MS_NW := {
1444 messageType := '000001'B,
1445 nsd := '00'B,
1446 facility := omit,
1447 user_user := omit,
1448 ss_VersionIndicator := omit
1449 }
1450 }
1451 }
1452}
1453
1454template PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT(integer tid) := {
1455 discriminator := '0011'B,
1456 tiOrSkip := {
1457 transactionId := {
1458 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001459 tiFlag := c_TIF_REPL,
Harald Welte33ec09b2018-02-10 15:34:46 +01001460 tIExtension := omit
1461 }
1462 },
1463 msgs := {
1464 cc := {
1465 connect_MS_NW := {
1466 messageType := '000111'B,
1467 nsd := '00'B,
1468 facility := omit,
1469 connectedSubAddress := omit,
1470 user_user := omit,
1471 ss_VersionIndicator := omit,
1472 streamIdentifier := omit
1473 }
1474 }
1475 }
1476}
1477
Harald Welte4017d552018-01-26 21:40:05 +01001478template PDU_ML3_NW_MS tr_ML3_MT_CC_CONNECT(integer tid) := {
1479 discriminator := '0011'B,
1480 tiOrSkip := {
1481 transactionId := {
1482 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001483 tiFlag := c_TIF_REPL,
Harald Welte4017d552018-01-26 21:40:05 +01001484 tIExtension := omit
1485 }
1486 },
1487 msgs := {
1488 cc := {
1489 connect_NW_MS := {
1490 messageType := '000111'B,
1491 nsd := '00'B,
1492 facility := *,
1493 progressIndicator := *,
1494 connectedNumber := *,
1495 connectedSubAddress := *,
1496 user_user := *
1497 }
1498 }
1499 }
1500}
1501
1502template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_CONNECT_ACK(integer tid) := {
1503 discriminator := '0011'B,
1504 tiOrSkip := {
1505 transactionId := {
1506 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001507 tiFlag := c_TIF_ORIG,
Harald Welte4017d552018-01-26 21:40:05 +01001508 tIExtension := omit
1509 }
1510 },
1511 msgs := {
1512 cc := {
1513 connectAck := {
1514 messageType := '001111'B,
1515 nsd := '00'B
1516 }
1517 }
1518 }
1519}
1520
Daniel Willmann8b084372018-02-04 13:35:26 +01001521template (value) PDU_ML3_MS_NW ts_ML3_MO_CC_START_DTMF(integer tid, charstring number) := {
1522 discriminator := '0011'B,
1523 tiOrSkip := {
1524 transactionId := {
1525 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001526 tiFlag := c_TIF_ORIG,
Daniel Willmann8b084372018-02-04 13:35:26 +01001527 tIExtension := omit
1528 }
1529 },
1530 msgs := {
1531 cc := {
1532 startDTMF := {
1533 messageType := '110101'B,
1534 nsd := '00'B,
1535 keypadFacility := {
1536 elementIdentifier := '2C'O,
1537 keypadInformation := int2bit(char2int(number), 7),
1538 spare_1 := '0'B
1539 }
1540 }
1541 }
1542 }
1543}
1544
Harald Welte2bb825f2018-01-22 11:31:18 +01001545template PDU_ML3_NW_MS tr_ML3_MT_CC_DISC(integer tid) := {
1546 discriminator := '0011'B,
1547 tiOrSkip := {
1548 transactionId := {
1549 tio := int2bit(tid, 3),
1550 tiFlag := ?,
1551 tIExtension := omit
1552 }
1553 },
1554 msgs := {
1555 cc := {
1556 disconnect_NW_MS := {
1557 messageType := '100101'B,
1558 nsd := '00'B,
1559 cause := ?,
1560 facility := *,
1561 progressIndicator := *,
1562 user_user := *,
1563 allowedActions := *
1564 }
1565 }
1566 }
1567}
1568
1569template PDU_ML3_NW_MS tr_ML3_MT_CC_RELEASE(integer tid) := {
1570 discriminator := '0011'B,
1571 tiOrSkip := {
1572 transactionId := {
1573 tio := int2bit(tid, 3),
1574 tiFlag := ?,
1575 tIExtension := omit
1576 }
1577 },
1578 msgs := {
1579 cc := {
1580 release_NW_MS := {
1581 messageType := '101101'B,
1582 nsd := '00'B,
1583 cause := ?,
1584 secondCause := *,
1585 facility := *,
1586 user_user := *
1587 }
1588 }
1589 }
1590}
Harald Welted748a052018-01-22 02:59:24 +01001591
Harald Welte33ec09b2018-02-10 15:34:46 +01001592template PDU_ML3_MS_NW ts_ML3_MO_CC_RELEASE(integer tid, BIT1 tid_remote, BIT7 cause) := {
1593 discriminator := '0011'B,
1594 tiOrSkip := {
1595 transactionId := {
1596 tio := int2bit(tid, 3),
1597 tiFlag := tid_remote,
1598 tIExtension := omit
1599 }
1600 },
1601 msgs := {
1602 cc := {
1603 release_MS_NW := {
1604 messageType := '101101'B,
1605 nsd := '00'B,
1606 cause := ts_ML3_Cause(cause),
1607 secondCause := omit,
1608 facility := omit,
1609 user_user := omit,
1610 ss_VersionIndicator := omit
1611 }
1612 }
1613 }
1614}
1615
1616
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001617template (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 +01001618 discriminator := '0011'B,
1619 tiOrSkip := {
1620 transactionId := {
1621 tio := int2bit(tid, 3),
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001622 tiFlag := tid_remote,
Harald Welteb71901a2018-01-26 19:16:05 +01001623 tIExtension := omit
1624 }
1625 },
1626 msgs := {
1627 cc := {
1628 releaseComplete_MS_NW := {
1629 messageType := '101010'B,
1630 nsd := '00'B,
1631 cause := omit,
1632 facility := omit,
1633 user_user := omit,
1634 ss_VersionIndicator := omit
1635 }
1636 }
1637 }
1638}
1639
Harald Welte33ec09b2018-02-10 15:34:46 +01001640template PDU_ML3_NW_MS tr_ML3_MT_CC_REL_COMPL(integer tid) := {
1641 discriminator := '0011'B,
1642 tiOrSkip := {
1643 transactionId := {
1644 tio := int2bit(tid, 3),
1645 tiFlag := ?,
1646 tIExtension := omit
1647 }
1648 },
1649 msgs := {
1650 cc := {
1651 releaseComplete_NW_MS := {
1652 messageType := '101010'B,
1653 nsd := '00'B,
1654 cause := *,
1655 facility := *,
1656 user_user := *
1657 }
1658 }
1659 }
1660}
1661
1662
Harald Welteb71901a2018-01-26 19:16:05 +01001663
Harald Welte77a8eba2018-01-22 21:22:32 +01001664template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ(template OCT16 rand := ?) := {
1665 discriminator := '0101'B,
1666 tiOrSkip := {
1667 skipIndicator := '0000'B
1668 },
1669 msgs := {
1670 mm := {
1671 authenticationRequest := {
1672 messageType := '010010'B,
1673 nsd := '00'B,
1674 cipheringKeySequenceNumber := ?,
1675 spare2_4 := ?,
1676 authenticationParRAND := rand,
1677 authenticationParAUTN := *
1678 }
1679 }
1680 }
1681}
1682
Harald Welte0cedf2c2018-10-28 23:28:35 +01001683template PDU_ML3_NW_MS tr_ML3_MT_MM_AUTH_REQ_3G(template OCT16 rand := ?, template OCT16 autn) := {
1684 discriminator := '0101'B,
1685 tiOrSkip := {
1686 skipIndicator := '0000'B
1687 },
1688 msgs := {
1689 mm := {
1690 authenticationRequest := {
1691 messageType := '010010'B,
1692 nsd := '00'B,
1693 cipheringKeySequenceNumber := ?,
1694 spare2_4 := ?,
1695 authenticationParRAND := rand,
1696 authenticationParAUTN := {
1697 elementIdentifier := '20'O,
1698 lengthIndicator := ?,
1699 autnValue := autn
1700 }
1701 }
1702 }
1703 }
1704}
1705
Harald Welte77a8eba2018-01-22 21:22:32 +01001706template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_2G(OCT4 sres) := {
1707 discriminator := '0101'B,
1708 tiOrSkip := {
1709 skipIndicator := '0000'B
1710 },
1711 msgs := {
1712 mm := {
1713 authenticationResponse := {
1714 messageType := '010100'B,
1715 nsd := '00'B,
1716 authenticationParSRES := sres,
1717 authenticationParSRESext := omit
1718 }
1719 }
1720 }
1721}
1722
1723template (value) PDU_ML3_MS_NW ts_ML3_MT_MM_AUTH_RESP_3G(OCT4 sres, octetstring res) := {
1724 discriminator := '0101'B,
1725 tiOrSkip := {
1726 skipIndicator := '0000'B
1727 },
1728 msgs := {
1729 mm := {
1730 authenticationResponse := {
1731 messageType := '010100'B,
1732 nsd := '00'B,
1733 authenticationParSRES := sres,
1734 authenticationParSRESext := {
1735 elementIdentifier := '21'O,
1736 lengthIndicator := 0, /* overwritten */
1737 valueField := res
1738 }
1739 }
1740 }
1741 }
1742}
Harald Weltecb6cc332018-01-21 13:59:08 +01001743
Harald Welte812f7a42018-01-27 00:49:18 +01001744template PDU_ML3_MS_NW ts_ML3_MO_CC_CALL_CONF(integer tid,
1745 template BearerCapability_TLV bcap := omit) := {
1746 discriminator := '0011'B,
1747 tiOrSkip := {
1748 transactionId := {
1749 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001750 tiFlag := c_TIF_REPL, /* response from destination */
Harald Welte812f7a42018-01-27 00:49:18 +01001751 tIExtension := omit
1752 }
1753 },
1754 msgs := {
1755 cc := {
1756 callConfirmed := {
1757 messageType := '001000'B,
1758 nsd := '00'B,
1759 repeatIndicator := omit,
1760 bearerCapability1 := bcap,
1761 bearerCapability2 := omit,
1762 cause := omit,
1763 cC_Capabilities := omit,
1764 streamIdentifier := omit,
1765 supportedCodecs := omit
1766 }
1767 }
1768 }
1769}
1770
1771
1772template PDU_ML3_NW_MS tr_ML3_MT_CC_SETUP(integer tid, template hexstring called := *,
1773 template hexstring calling := *,
1774 template BearerCapability_TLV bcap := *) := {
1775 discriminator := '0011'B,
1776 tiOrSkip := {
1777 transactionId := {
1778 tio := int2bit(tid, 3),
Harald Welte51affb62018-04-09 14:17:45 +02001779 tiFlag := c_TIF_ORIG, /* from originator */
Harald Welte812f7a42018-01-27 00:49:18 +01001780 tIExtension := omit
1781 }
1782 },
1783 msgs := {
1784 cc := {
1785 setup_NW_MS := {
1786 messageType := '000101'B,
1787 nsd := '00'B,
1788 bcRepeatIndicator := *,
1789 bearerCapability1 := bcap,
1790 bearerCapability2 := *,
1791 facility := *,
1792 progressIndicator := *,
1793 signal := *,
1794 callingPartyBCD_Number := tr_Calling(calling) ifpresent,
1795 callingPartySubAddress := *,
1796 calledPartyBCD_Number := tr_Called(called) ifpresent,
1797 calledPartySubAddress := *,
1798 redirectingPartyBCDNumber := *,
1799 redirectingPartySubaddress := *,
1800 llc_RepeatIndicator := *,
1801 lowLayerCompatibility1 := *,
1802 lowLayerCompatibility2 := *,
1803 hlc_RepeatIndicator := *,
1804 highLayerCompatibility1 := *,
1805 highLayerCompatibility2 := *,
1806 user_user := *,
1807 priority := *,
1808 alert := *,
1809 networkCCCapabilities := *,
1810 causeofNoCli := *,
1811 backupBearerCapacity := *
1812 }
1813 }
1814 }
1815}
1816
Harald Welte38575a72018-02-15 20:41:37 +01001817/***********************************************************************
Harald Welte53603962018-05-28 11:13:09 +02001818 * Supplementary Services
1819 ***********************************************************************/
1820
1821private template (value) Facility_TLV ts_FacTLV(OCTN facility) := {
1822 elementIdentifier := '1C'O,
1823 lengthIndicator := lengthof(facility),
1824 facilityInformation := facility
1825}
1826private template Facility_TLV tr_FacTLV(template OCTN facility) := {
1827 elementIdentifier := '1C'O,
1828 lengthIndicator := ?,
1829 facilityInformation := facility
1830}
1831
1832private template (value) Facility_LV ts_FacLV(OCTN facility) := {
1833 lengthIndicator := lengthof(facility),
1834 facilityInformation := facility
1835}
1836private template Facility_LV tr_FacLV(template OCTN facility) := {
1837 lengthIndicator := ?,
1838 facilityInformation := facility
1839}
1840
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001841private function f_facility_or_omit(template (omit) OCTN facility)
1842return template (omit) Facility_TLV {
1843 if (istemplatekind(facility, "omit")) {
1844 return omit;
1845 } else {
1846 return ts_FacTLV(valueof(facility));
1847 }
1848}
1849private function f_facility_or_wc(template OCTN facility)
1850return template Facility_TLV {
1851 if (istemplatekind(facility, "*")) {
1852 return *;
1853 } else if (istemplatekind(facility, "?")) {
1854 return ?;
Vadim Yanitskiy52f8b6e2018-06-19 17:32:46 +07001855 } else if (istemplatekind(facility, "omit")) {
1856 return omit;
Vadim Yanitskiy03198132018-05-29 03:35:16 +07001857 } else {
1858 return tr_FacTLV(facility);
1859 }
1860}
1861
Harald Welte53603962018-05-28 11:13:09 +02001862template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_REGISTER(
1863 uint3_t tid, BIT1 ti_flag,
1864 OCTN facility,
1865 template (omit) SS_VersionIndicator ss_ver := omit
1866) := {
1867 discriminator := '1011'B,
1868 tiOrSkip := {
1869 transactionId := {
1870 tio := int2bit(tid, 3),
1871 tiFlag := ti_flag,
1872 tIExtension := omit
1873 }
1874 },
1875 msgs := {
1876 ss := {
1877 register := {
1878 messageType := '111011'B,
1879 nsd := '00'B,
1880 facility := ts_FacTLV(facility),
1881 ss_version := ss_ver
1882 }
1883 }
1884 }
1885}
1886template PDU_ML3_MS_NW tr_ML3_MO_SS_REGISTER(
1887 template uint3_t tid, template BIT1 ti_flag,
1888 template OCTN facility,
1889 template SS_VersionIndicator ss_ver := omit
1890) := {
1891 discriminator := '1011'B,
1892 tiOrSkip := {
1893 transactionId := {
1894 tio := f_tid_or_wc(tid),
1895 tiFlag := ti_flag,
1896 tIExtension := omit
1897 }
1898 },
1899 msgs := {
1900 ss := {
1901 register := {
1902 messageType := '111011'B,
1903 nsd := '00'B,
1904 facility := tr_FacTLV(facility),
1905 ss_version := ss_ver
1906 }
1907 }
1908 }
1909}
1910
1911template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_REGISTER(
1912 uint3_t tid, BIT1 ti_flag,
1913 OCTN facility
1914) := {
1915 discriminator := '1011'B,
1916 tiOrSkip := {
1917 transactionId := {
1918 tio := int2bit(tid, 3),
1919 tiFlag := ti_flag,
1920 tIExtension := omit
1921 }
1922 },
1923 msgs := {
1924 ss := {
1925 register := {
1926 messageType := '111011'B,
1927 nsd := '00'B,
1928 facility := ts_FacTLV(facility)
1929 }
1930 }
1931 }
1932}
1933template PDU_ML3_NW_MS tr_ML3_MT_SS_REGISTER(
1934 template uint3_t tid, template BIT1 ti_flag,
1935 template OCTN facility
1936) := {
1937 discriminator := '1011'B,
1938 tiOrSkip := {
1939 transactionId := {
1940 tio := f_tid_or_wc(tid),
1941 tiFlag := ti_flag,
1942 tIExtension := omit
1943 }
1944 },
1945 msgs := {
1946 ss := {
1947 register := {
1948 messageType := '111011'B,
1949 nsd := '00'B,
1950 facility := tr_FacTLV(facility)
1951 }
1952 }
1953 }
1954}
1955
1956template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_FACILITY(
1957 uint3_t tid, BIT1 ti_flag,
1958 OCTN facility
1959) := {
1960 discriminator := '1011'B,
1961 tiOrSkip := {
1962 transactionId := {
1963 tio := int2bit(tid, 3),
1964 tiFlag := ti_flag,
1965 tIExtension := omit
1966 }
1967 },
1968 msgs := {
1969 ss := {
1970 facility := {
1971 messageType := '111010'B,
1972 nsd := '00'B,
1973 facility := ts_FacLV(facility)
1974 }
1975 }
1976 }
1977}
1978template PDU_ML3_MS_NW tr_ML3_MO_SS_FACILITY(
1979 template uint3_t tid, template BIT1 ti_flag,
1980 template OCTN facility
1981) := {
1982 discriminator := '1011'B,
1983 tiOrSkip := {
1984 transactionId := {
1985 tio := f_tid_or_wc(tid),
1986 tiFlag := ti_flag,
1987 tIExtension := omit
1988 }
1989 },
1990 msgs := {
1991 ss := {
1992 facility := {
1993 messageType := '111010'B,
1994 nsd := '00'B,
1995 facility := tr_FacLV(facility)
1996 }
1997 }
1998 }
1999}
2000
2001template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_FACILITY(
2002 uint3_t tid, BIT1 ti_flag,
2003 OCTN facility
2004) := {
2005 discriminator := '1011'B,
2006 tiOrSkip := {
2007 transactionId := {
2008 tio := int2bit(tid, 3),
2009 tiFlag := ti_flag,
2010 tIExtension := omit
2011 }
2012 },
2013 msgs := {
2014 ss := {
2015 facility := {
2016 messageType := '111010'B,
2017 nsd := '00'B,
2018 facility := ts_FacLV(facility)
2019 }
2020 }
2021 }
2022}
2023template PDU_ML3_NW_MS tr_ML3_MT_SS_FACILITY(
2024 template uint3_t tid, template BIT1 ti_flag,
2025 template OCTN facility
2026) := {
2027 discriminator := '1011'B,
2028 tiOrSkip := {
2029 transactionId := {
2030 tio := f_tid_or_wc(tid),
2031 tiFlag := ti_flag,
2032 tIExtension := omit
2033 }
2034 },
2035 msgs := {
2036 ss := {
2037 facility := {
2038 messageType := '111010'B,
2039 nsd := '00'B,
2040 facility := tr_FacLV(facility)
2041 }
2042 }
2043 }
2044}
2045
Vadim Yanitskiy03198132018-05-29 03:35:16 +07002046template (value) PDU_ML3_MS_NW ts_ML3_MO_SS_RELEASE_COMPLETE(
2047 uint3_t tid, BIT1 ti_flag,
2048 template (omit) ML3_Cause_TLV cause := omit,
2049 template (omit) OCTN facility := omit
2050) := {
2051 discriminator := '1011'B,
2052 tiOrSkip := {
2053 transactionId := {
2054 tio := int2bit(tid, 3),
2055 tiFlag := ti_flag,
2056 tIExtension := omit
2057 }
2058 },
2059 msgs := {
2060 ss := {
2061 releaseComplete_MS_NW := {
2062 messageType := '101010'B,
2063 nsd := '00'B,
2064 cause := cause,
2065 facility := f_facility_or_omit(facility)
2066 }
2067 }
2068 }
2069}
2070template PDU_ML3_MS_NW tr_ML3_MO_SS_RELEASE_COMPLETE(
2071 template uint3_t tid, template BIT1 ti_flag,
2072 template ML3_Cause_TLV cause := *,
2073 template OCTN facility := *
2074) := {
2075 discriminator := '1011'B,
2076 tiOrSkip := {
2077 transactionId := {
2078 tio := f_tid_or_wc(tid),
2079 tiFlag := ti_flag,
2080 tIExtension := omit
2081 }
2082 },
2083 msgs := {
2084 ss := {
2085 releaseComplete_MS_NW := {
2086 messageType := '101010'B,
2087 nsd := '00'B,
2088 cause := cause,
2089 facility := f_facility_or_wc(facility)
2090 }
2091 }
2092 }
2093}
2094
2095template (value) PDU_ML3_NW_MS ts_ML3_MT_SS_RELEASE_COMPLETE(
2096 uint3_t tid, BIT1 ti_flag,
2097 template (omit) ML3_Cause_TLV cause := omit,
2098 template (omit) OCTN facility := omit
2099) := {
2100 discriminator := '1011'B,
2101 tiOrSkip := {
2102 transactionId := {
2103 tio := int2bit(tid, 3),
2104 tiFlag := ti_flag,
2105 tIExtension := omit
2106 }
2107 },
2108 msgs := {
2109 ss := {
2110 releaseComplete_NW_MS := {
2111 messageType := '101010'B,
2112 nsd := '00'B,
2113 cause := cause,
2114 facility := f_facility_or_omit(facility)
2115 }
2116 }
2117 }
2118}
2119template PDU_ML3_NW_MS tr_ML3_MT_SS_RELEASE_COMPLETE(
2120 template uint3_t tid, template BIT1 ti_flag,
2121 template ML3_Cause_TLV cause := *,
2122 template OCTN facility := *
2123) := {
2124 discriminator := '1011'B,
2125 tiOrSkip := {
2126 transactionId := {
2127 tio := f_tid_or_wc(tid),
2128 tiFlag := ti_flag,
2129 tIExtension := omit
2130 }
2131 },
2132 msgs := {
2133 ss := {
2134 releaseComplete_NW_MS := {
2135 messageType := '101010'B,
2136 nsd := '00'B,
2137 cause := cause,
2138 facility := f_facility_or_wc(facility)
2139 }
2140 }
2141 }
2142}
2143
Harald Welte53603962018-05-28 11:13:09 +02002144/***********************************************************************
Harald Welte38575a72018-02-15 20:41:37 +01002145 * GPRS Mobility Management
2146 ***********************************************************************/
2147
2148template (value) MSNetworkCapabilityV ts_GMM_MsNetCapV := {
2149 gea1bit := '1'B,
2150 smCapabilitiesviaDedicatedChannels := '1'B,
2151 smCapabilitiesviaGPRSChannels := '0'B,
2152 ucs2Support := '1'B,
2153 ssScreeningIndicator := '01'B,
2154 solSACapability := omit,
2155 revisionLevelIndicatior := omit,
2156 pFCFeatureMode := omit,
2157 extendedGEAbits := omit,
2158 lcsVAcapability := omit,
2159 pSInterRATHOtoUTRANIuModeCapability := omit,
2160 pSInterRATHOtoEUTRANS1ModeCapability := omit,
2161 eMMCombinedProceduresCapability := omit,
2162 iSRSupport := omit,
2163 sRVCCtoGERANUTRANCapability := omit,
2164 ePCCapability := omit,
2165 nFCapability := omit,
2166 gERANNertworkSharingCapability := omit,
2167 spare_octets := omit
2168};
2169
2170template (value) MSNetworkCapabilityLV ts_GMM_MsNetCapLV := {
2171 lengthIndicator := 0, /* overwritten */
2172 msNetworkCapabilityV := ts_GMM_MsNetCapV
2173};
2174
2175type enumerated GprsAttachType {
2176 GPRS_ATT_T_GPRS,
2177 GPRS_ATT_T_GPRS_IMSI_COMBINED
2178};
2179
2180function ts_GMM_AttachType(boolean combined := false, boolean follow_on_pending := false)
2181return AttachTypeV {
2182 var AttachTypeV att;
2183 if (combined) {
2184 att.attachType := '011'B;
2185 } else {
2186 att.attachType := '001'B;
2187 }
2188 att.for_l3 := bool2bit(combined);
2189 return att;
2190}
2191
2192type enumerated GprsUpdateType {
2193 GPRS_UPD_T_RA ('000'B),
2194 GPRS_UPD_T_RA_LA_COMBINED ('001'B),
2195 GPRS_UPD_T_RA_LA_COMBINED_IMSI_ATT ('010'B),
2196 GPRS_UPD_T_PERIODIC ('011'B)
2197};
2198
2199/* 10.5.5.18 Update Type */
2200template UpdateTypeV ts_GMM_UpdateType(GprsUpdateType upd_t, boolean combined := false,
2201 boolean follow_on_pending := false) := {
2202 valueField := int2bit(enum2int(upd_t), 3),
2203 for_l3 := bool2bit(combined)
2204}
2205
2206template (value) DRXParameterV ts_DrxParameterV := {
2207 splitPGCycleCode := '00'O, /* no DRX */
2208 nonDRXTimer := '000'B, /* no non-DRX mode */
2209 splitOnCCCH := '0'B, /* not supported */
2210 cnSpecificDRXCycleLength := '0000'B /* SI value used */
2211};
2212
Harald Welte6ce47c32020-09-13 09:58:29 +02002213private function f_presence_bit_MultislotCap_GPRS(template (omit) MultislotCap_GPRS mscap_gprs) return BIT1 {
2214 if (istemplatekind(mscap_gprs, "omit")) {
2215 return '0'B;
2216 }
2217 return '1'B;
2218}
2219private function f_presence_bit_MultislotCap_EGPRS(template (omit) MultislotCap_EGPRS mscap_egprs) return BIT1 {
2220 if (istemplatekind(mscap_egprs, "omit")) {
2221 return '0'B;
2222 }
2223 return '1'B;
2224}
2225template (value) MSRACapabilityValuesRecord ts_RaCapRec(BIT4 att := '0001'B /* E-GSM */, template (omit) MultislotCap_GPRS mscap_gprs := omit, template (omit) MultislotCap_EGPRS mscap_egprs := omit) := {
2226 mSRACapabilityValues := {
2227 mSRACapabilityValuesExclude1111 := {
2228 accessTechnType := att, /* E-GSM */
2229 accessCapabilities := {
2230 lengthIndicator := 0, /* overwritten */
2231 accessCapabilities := {
2232 rfPowerCapability := '001'B, /* FIXME */
2233 presenceBitA5 := '0'B,
2234 a5bits := omit,
2235 esind := '1'B,
2236 psbit := '0'B,
2237 vgcs := '0'B,
2238 vbs := '0'B,
2239 presenceBitMultislot := '1'B,
2240 multislotcap := {
2241 presenceBitHscsd := '0'B,
2242 hscsdmultislotclass := omit,
2243 presenceBitGprs := f_presence_bit_MultislotCap_GPRS(mscap_gprs),
2244 gprsmultislot := mscap_gprs,
2245 presenceBitSms := '0'B,
2246 multislotCap_SMS := omit,
2247 multislotCapAdditionsAfterRel97 := {
2248 presenceBitEcsdmulti := '0'B,
2249 ecsdmultislotclass := omit,
2250 presenceBitEgprsmulti := f_presence_bit_MultislotCap_EGPRS(mscap_egprs),
2251 multislotCap_EGPRS := mscap_egprs,
2252 presenceBitDtmGprsmulti := '0'B,
2253 multislotCapdtmgprsmultislotsubclass := omit
2254 }
2255 },
2256 accessCapAdditionsAfterRel97 := omit
2257 },
2258 spare_bits := omit
2259 }
2260 }
2261 },
2262 presenceBitMSRACap := '0'B
2263};
2264
Harald Welte38575a72018-02-15 20:41:37 +01002265template (value) MSRadioAccessCapabilityLV ts_MS_RaCapa := {
2266 lengthIndicator := 0, /* overwritten */
2267 msRadioAccessCapabilityV := {
2268 ts_RaCapRec('0001'B) /* E-GSM */
2269 }
2270}
2271
2272template (value) PDU_L3_MS_SGSN
2273 ts_GMM_ATTACH_REQ(MobileIdentityLV mi_lv, RoutingAreaIdentificationV old_ra,
2274 boolean combined := false, boolean follow_on_pending := false,
2275 template (omit) MobileStationClassmark2_TLV cm2_tlv,
2276 template (omit) MobileStationClassmark3_TLV cm3_tlv
2277 ) := {
2278 discriminator := '0000'B, /* overwritten */
2279 tiOrSkip := {
2280 skipIndicator := '0000'B
2281 },
2282 msgs := {
2283 gprs_mm := {
2284 attachRequest := {
2285 messageType := '00000000'B, /* overwritten */
2286 msNetworkCapability := ts_GMM_MsNetCapLV,
2287 attachType := valueof(ts_GMM_AttachType(combined, follow_on_pending)),
2288 gprsCKSN := { '111'B, '0'B },
2289 drxParam := ts_DrxParameterV,
2290 mobileIdentity := mi_lv,
2291 oldRoutingAreaID := old_ra,
2292 msRACap := ts_MS_RaCapa,
2293 ptmsiSignature := omit, /* TODO */
2294 reqGPRStimer := omit,
2295 tmsiStatus := omit,
2296 pC_LCSCapability := omit,
2297 mobileStationClassmark2 := cm2_tlv,
2298 mobileStationClassmark3 := cm3_tlv,
2299 supportedCodecs := omit,
2300 uENetworkCapability := omit,
2301 additionalMobileIdentity := omit,
2302 routingAreaIdentification2 := omit,
2303 voiceDomainandUEsUsageSetting := omit,
2304 deviceProperties := omit,
2305 p_TMSI_Type := omit,
2306 mS_NetworkFeatureSupport := omit,
2307 oldLocationAreaIdentification := omit,
2308 additionalUpdateType := omit,
2309 tMSIBasedNRIcontainer := omit,
2310 t3324 := omit,
2311 t3312_ExtendedValue := omit,
2312 extendedDRXParameters := omit
2313 }
2314 }
2315 }
2316}
2317
Harald Welteb0386df2018-02-16 18:14:28 +01002318private function tr_MI_TMSI_TLV(template OCT4 tmsi) return template MobileIdentityTLV {
2319 if (istemplatekind(tmsi, "*")) {
2320 return *;
2321 } else if (istemplatekind(tmsi, "?")) {
2322 return ?;
2323 } else {
2324 var template MobileIdentityTLV mi := {
2325 elementIdentifier := '0011000'B,
2326 spare1 := '0'B,
2327 mobileIdentityLV := {
2328 lengthIndicator := 4,
2329 mobileIdentityV := {
2330 typeOfIdentity := '100'B,
2331 oddEvenInd_identity := {
2332 tmsi_ptmsi := {
2333 oddevenIndicator := '1'B,
2334 fillerDigit := '1111'B,
2335 octets := tmsi
2336 }
2337 }
2338 }
2339 }
2340 };
2341 return mi;
2342 }
2343}
2344
2345template PDU_L3_SGSN_MS tr_GMM_ATTACH_ACCEPT(template BIT3 res := ?,
2346 template RoutingAreaIdentificationV ra := ?,
2347 template OCT4 ptmsi := *) := {
2348 discriminator := '1000'B,
2349 tiOrSkip := {
2350 skipIndicator := '0000'B
2351 },
2352 msgs := {
2353 gprs_mm := {
2354 attachAccept := {
2355 messageType := '00000010'B,
2356 attachResult := { res, ? },
2357 forceToStandby := ?,
2358 updateTimer := ?,
2359 radioPriority := ?,
2360 radioPriorityTOM8 := ?,
2361 routingAreaIdentification := ra,
2362 ptmsiSignature := *,
2363 readyTimer := *,
2364 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2365 msIdentity := *,
2366 gmmCause := *,
2367 t3302 := *,
2368 cellNotification := *,
2369 equivalentPLMNs := *,
2370 networkFeatureSupport := *,
2371 emergencyNumberList := *,
2372 requestedMSInformation := *,
2373 t3319 := *,
2374 t3323 := *,
2375 t3312_ExtendedValue := *,
2376 additionalNetworkFeatureSupport := *,
2377 t3324 := *,
2378 extendedDRXParameters := *
2379 }
2380 }
2381 }
2382}
Harald Welte38575a72018-02-15 20:41:37 +01002383
Harald Welte5b7c8122018-02-16 21:48:17 +01002384template PDU_L3_SGSN_MS tr_GMM_ATTACH_REJECT(template OCT1 cause) := {
2385 discriminator := '1000'B,
2386 tiOrSkip := {
2387 skipIndicator := '0000'B
2388 },
2389 msgs := {
2390 gprs_mm := {
2391 attachReject := {
2392 messageType := '00000100'B,
2393 gmmCause := {
2394 causeValue := cause
2395 },
2396 t3302 := *,
2397 t3346 := *
2398 }
2399 }
2400 }
2401}
2402
2403
Harald Welte38575a72018-02-15 20:41:37 +01002404template (value) PDU_L3_MS_SGSN ts_GMM_ATTACH_COMPL := {
2405 discriminator := '0000'B, /* overwritten */
2406 tiOrSkip := {
2407 skipIndicator := '0000'B
2408 },
2409 msgs := {
2410 gprs_mm := {
2411 attachComplete := {
2412 messageType := '00000000'B, /* overwritten */
2413 interRATHandoverInformation := omit,
2414 eUTRANinterRATHandoverInformation := omit
2415 }
2416 }
2417 }
2418}
2419
2420template (value) PDU_L3_MS_SGSN
2421 ts_GMM_RAU_REQ(MobileIdentityLV mi_lv, GprsUpdateType upd_type,
2422 RoutingAreaIdentificationV old_ra,
2423 boolean follow_on_pending := false,
2424 template (omit) MobileStationClassmark2_TLV cm2_tlv,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002425 template (omit) MobileStationClassmark3_TLV cm3_tlv,
2426 template (omit) OCT4 p_tmsi := omit
Harald Welte38575a72018-02-15 20:41:37 +01002427 ) := {
2428 discriminator := '0000'B, /* overwritten */
2429 tiOrSkip := {
2430 skipIndicator := '0000'B
2431 },
2432 msgs := {
2433 gprs_mm := {
2434 routingAreaUpdateRequest := {
2435 messageType := '00000000'B, /* overwritten */
2436 updateType := ts_GMM_UpdateType(upd_type, follow_on_pending),
2437 gprsCKSN := { '111'B, '0'B },
2438 oldRoutingAreaId := old_ra,
2439 msRACap := ts_MS_RaCapa,
2440 oldPTMSISignature := omit, /* TODO */
2441 readyTimerValue := omit,
2442 drxParameter := omit,
2443 tmsiStatus := omit,
Alexander Couzensbfcb3202019-09-03 12:34:21 +02002444 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
Harald Welte38575a72018-02-15 20:41:37 +01002445 mSNetworkCapability := omit,
2446 pdpContextStatus := omit, /* TODO */
2447 pC_LCSCapability := omit,
Harald Welte04683d02018-02-16 22:43:45 +01002448 mBMS_ContextStatus := omit,
Harald Welte38575a72018-02-15 20:41:37 +01002449 uENetworkCapability := omit,
2450 additionalMobileIdentity := omit,
2451 oldRoutingAreaIdentification2 := omit,
2452 mobileStationClassmark2 := cm2_tlv,
2453 mobileStationClassmark3 := cm3_tlv,
2454 supportedCodecs := omit,
2455 voiceDomainUEUsageSetting := omit,
2456 p_TMSI_Type := omit,
2457 deviceProperties := omit,
2458 mS_NetworkFeatureSupport := omit,
2459 oldLocationAreaIdentification := omit,
2460 additionalUpdateType := omit,
2461 tMSIBasedNRIcontainer := omit,
2462 t3324 := omit,
2463 t3312_ExtendedValue := omit,
2464 extendedDRXParameters := omit
2465 }
2466 }
2467 }
2468}
2469
Harald Welte04683d02018-02-16 22:43:45 +01002470template PDU_L3_SGSN_MS tr_GMM_RAU_REJECT(template OCT1 cause := ?) := {
2471 discriminator := '1000'B,
2472 tiOrSkip := {
2473 skipIndicator := '0000'B
2474 },
2475 msgs := {
2476 gprs_mm := {
2477 routingAreaUpdateReject := {
2478 messageType := '00001011'B,
2479 gmmCause := {
2480 causeValue := cause
2481 },
2482 forceToStandby := ?,
2483 spare := '0000'B,
2484 t3302 := *,
2485 t3346 := *
2486 }
2487 }
2488 }
2489}
2490
Harald Welte91636de2018-02-17 10:16:14 +01002491template PDU_L3_SGSN_MS tr_GMM_RAU_ACCEPT(template BIT3 res := ?,
2492 template RoutingAreaIdentificationV ra := ?,
2493 template OCT4 ptmsi := *) := {
2494 discriminator := '1000'B,
2495 tiOrSkip := {
2496 skipIndicator := '0000'B
2497 },
2498 msgs := {
2499 gprs_mm := {
2500 routingAreaUpdateAccept := {
2501 messageType := '00001001'B,
2502 forceToStandby := ?,
2503 updateResult := { res, ? },
2504 raUpdateTimer := ?,
2505 routingAreaId := ra,
2506 ptmsiSignature := *,
2507 allocatedPTMSI := tr_MI_TMSI_TLV(ptmsi),
2508 msIdentity := *,
2509 receiveNPDUNumbers := *,
2510 readyTimer := *,
2511 gmmCause := *,
2512 t3302 := *,
2513 cellNotification := *,
2514 equivalentPLMNs := *,
2515 pdpContextStatus := *,
2516 networkFeatureSupport := *,
2517 emergencyNumberList := *,
2518 mBMS_ContextStatus := *,
2519 requestedMSInformation := *,
2520 t3319 := *,
2521 t3323 := *,
2522 t3312_ExtendedValue := *,
2523 additionalNetworkFeatureSupport := *,
2524 t3324 := *,
2525 extendedDRXParameters := *
2526 }
2527 }
2528 }
2529}
Harald Welte04683d02018-02-16 22:43:45 +01002530
Harald Welte38575a72018-02-15 20:41:37 +01002531template (value) PDU_L3_MS_SGSN ts_GMM_RAU_COMPL := {
2532 discriminator := '0000'B, /* overwritten */
2533 tiOrSkip := {
2534 skipIndicator := '0000'B
2535 },
2536 msgs := {
2537 gprs_mm := {
2538 routingAreaUpdateComplete := {
2539 messageType := '00000000'B, /* overwritten */
2540 receiveNPDUNumbers := omit,
2541 interRATHandoverInformation := omit,
2542 eUTRANinterRATHandoverInformation := omit
2543 }
2544 }
2545 }
2546}
2547
2548template (value) PDU_L3_MS_SGSN ts_GMM_PTMSI_REALL_COMPL := {
2549 discriminator := '0000'B, /* overwritten */
2550 tiOrSkip := {
2551 skipIndicator := '0000'B
2552 },
2553 msgs := {
2554 gprs_mm := {
2555 p_TMSIReallocationComplete := {
2556 messageType := '00000000'B /* overwritten */
2557 }
2558 }
2559 }
2560}
2561
2562template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_CIPH_COMPL(ACReferenceNumberV ref, OCT4 res) := {
2563 discriminator := '0000'B, /* overwritten */
2564 tiOrSkip := {
2565 skipIndicator := '0000'B
2566 },
2567 msgs := {
2568 gprs_mm := {
2569 authenticationAndCipheringResponse := {
2570 messageType := '00000000'B, /* overwritten */
2571 acReferenceNumber := ref,
2572 spare := '0000'B,
2573 authenticationParResp := {
2574 elementIdentifier := '22'O,
2575 valueField := res
2576 },
2577 imeisv := omit,
2578 authenticationRespParExt := omit
2579 }
2580 }
2581 }
2582}
2583
Harald Welteb0386df2018-02-16 18:14:28 +01002584template PDU_L3_SGSN_MS tr_GMM_ID_REQ(template BIT3 id_type := ?) := {
2585 discriminator := '1000'B,
2586 tiOrSkip := {
2587 skipIndicator := '0000'B
2588 },
2589 msgs := {
2590 gprs_mm := {
2591 identityRequest := {
2592 messageType := '00010101'B,
2593 identityType := { id_type, '0'B },
2594 forceToStandby := ?
2595 }
2596 }
2597 }
2598}
2599
Harald Welte38575a72018-02-15 20:41:37 +01002600template (value) PDU_L3_MS_SGSN ts_GMM_ID_RESP(MobileIdentityLV mi_lv) := {
2601 discriminator := '0000'B, /* overwritten */
2602 tiOrSkip := {
2603 skipIndicator := '0000'B
2604 },
2605 msgs := {
2606 gprs_mm := {
2607 identityResponse := {
2608 messageType := '00000000'B, /* overwritten */
2609 mobileIdentity := mi_lv
2610 }
2611 }
2612 }
2613}
2614
Harald Welteb0386df2018-02-16 18:14:28 +01002615template PDU_L3_SGSN_MS tr_GMM_AUTH_REQ(template OCT16 rand := ?, template BIT3 ciph_alg := ?) := {
2616 discriminator := '1000'B,
2617 tiOrSkip := {
2618 skipIndicator := '0000'B
2619 },
2620 msgs := {
2621 gprs_mm := {
2622 authenticationAndCipheringRequest := {
2623 messageType := '00010010'B,
2624 cipheringAlgorithm := { ciph_alg, '0'B },
2625 imeisvRequest := ?,
2626 forceToStandby := ?,
2627 acReferenceNumber := ?,
2628 authenticationParameterRAND := {
2629 elementIdentifier := '21'O,
2630 randValue := rand
2631 },
2632 cipheringKeySequenceNumber := *,
2633 authenticationParameterAUTN := *
2634 }
2635 }
2636 }
2637}
2638
2639template (value) PDU_L3_MS_SGSN ts_GMM_AUTH_RESP_2G(BIT4 ac_ref, OCT4 sres) := {
2640 discriminator := '1000'B,
2641 tiOrSkip := {
2642 skipIndicator := '0000'B
2643 },
2644 msgs := {
2645 gprs_mm := {
2646 authenticationAndCipheringResponse := {
2647 messageType := '00010011'B,
2648 acReferenceNumber := { valueField := ac_ref },
2649 spare := '0000'B,
2650 authenticationParResp := {
2651 elementIdentifier := '22'O,
2652 valueField := sres
2653 },
2654 imeisv := omit,
2655 authenticationRespParExt := omit
2656 }
2657 }
2658 }
2659}
2660
Alexander Couzens15faf922018-09-04 15:16:26 +02002661template PDU_L3_MS_SGSN ts_GMM_AUTH_FAIL_UMTS_AKA_RESYNC(octetstring auts) := {
2662 discriminator := '1000'B,
2663 tiOrSkip := {
2664 skipIndicator := '0000'B
2665 },
2666 msgs := {
2667 gprs_mm := {
2668 authenticationAndCipheringFailure := {
2669 messageType := '00011100'B,
2670 gmmCause := {
2671 causeValue := '15'O /* GMM_CAUSE_SYNC_FAIL 10.5.3.2.2 */
2672 },
2673 authenticationFailureParam := {
2674 elementIdentifier := '30'O,
2675 lengthIndicator := 14,
2676 valueField := auts
2677 }
2678 }
2679 }
2680 }
2681}
2682
Harald Welteb0386df2018-02-16 18:14:28 +01002683
Harald Welte38575a72018-02-15 20:41:37 +01002684const BIT3 c_GMM_DTT_MO_GPRS := '001'B;
2685const BIT3 c_GMM_DTT_MO_IMSI := '010'B;
2686const BIT3 c_GMM_DTT_MO_GPRS_IMSI_COMBINED := '011'B;
2687
Alexander Couzensb6ab4562018-05-17 02:59:22 +02002688const BIT3 c_GMM_DTT_MT_REATTACH_REQUIRED := '001'B;
2689const BIT3 c_GMM_DTT_MT_REATTACH_NOT_REQUIRED := '010'B;
2690const BIT3 c_GMM_DTT_MT_IMSI_DETACH := '011'B;
2691
Harald Welte6abb9fe2018-02-17 15:24:48 +01002692template (value) DetachTypeV ts_GMM_DetType(BIT3 dtt, boolean power_off := false) := {
Harald Welte38575a72018-02-15 20:41:37 +01002693 detachType := dtt,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002694 powerOffFlag := bool2bit(power_off)
Harald Welte38575a72018-02-15 20:41:37 +01002695}
2696
Harald Welte6abb9fe2018-02-17 15:24:48 +01002697function ts_PtmsiSigTV(template (omit) OCT3 val) return template (omit) P_TMSISignatureTV {
2698 var template (omit) P_TMSISignatureTV ret;
2699 if (istemplatekind(val, "omit")) {
2700 return omit;
2701 } else {
2702 ret := {
2703 elementIdentifier := '19'O,
2704 valueField := valueof(val)
2705 }
2706 return ret;
2707 }
2708}
2709
2710function ts_PtmsiSigTLV(template (omit) OCT3 val) return template (omit) P_TMSISignature2TLV {
2711 var template (omit) P_TMSISignature2TLV ret;
2712 if (istemplatekind(val, "omit")) {
2713 return omit;
2714 } else {
2715 ret := {
2716 elementIdentifier := '19'O,
2717 lengthIndicator := 3,
2718 valueField := valueof(val)
2719 }
2720 return ret;
2721 }
2722}
2723
2724template (value) PDU_L3_MS_SGSN ts_GMM_DET_REQ_MO(BIT3 dtt := c_GMM_DTT_MO_GPRS,
2725 boolean power_off := false,
2726 template (omit) OCT4 p_tmsi := omit,
2727 template (omit) OCT3 p_tmsi_sig := omit) := {
Harald Welte38575a72018-02-15 20:41:37 +01002728 discriminator := '0000'B, /* overwritten */
2729 tiOrSkip := {
2730 skipIndicator := '0000'B
2731 },
2732 msgs := {
2733 gprs_mm := {
2734 detachRequest_MS_SGSN := {
2735 messageType := '00000000'B, /* overwritten */
Harald Welte6abb9fe2018-02-17 15:24:48 +01002736 detachType := valueof(ts_GMM_DetType(dtt, power_off)),
Harald Welte38575a72018-02-15 20:41:37 +01002737 spare := '0000'B,
Harald Welte6abb9fe2018-02-17 15:24:48 +01002738 ptmsi := ts_MI_TMSI_TLV(p_tmsi),
2739 ptmsiSignature := ts_PtmsiSigTLV(p_tmsi_sig)
2740 }
2741 }
2742 }
2743}
2744
2745template PDU_L3_SGSN_MS tr_GMM_DET_ACCEPT_MT := {
2746 discriminator := '1000'B,
2747 tiOrSkip := {
2748 skipIndicator := '0000'B
2749 },
2750 msgs := {
2751 gprs_mm := {
2752 detachAccept_SGSN_MS := {
2753 messageType := '00000110'B,
2754 forceToStandby := ?,
2755 spare := '0000'B
Harald Welte38575a72018-02-15 20:41:37 +01002756 }
2757 }
2758 }
2759}
Harald Welte812f7a42018-01-27 00:49:18 +01002760
Alexander Couzensd62fba52018-05-22 16:08:39 +02002761template PDU_L3_SGSN_MS tr_GMM_DET_REQ_MT(
2762 template BIT3 dtt := *,
2763 template BIT3 forceToStandby := ?,
Alexander Couzensd8604ab2018-05-29 15:46:06 +02002764 template OCT1 cause := *) := {
Harald Welte835b15f2018-02-18 14:39:11 +01002765 discriminator := '1000'B,
2766 tiOrSkip := {
2767 skipIndicator := '0000'B
2768 },
2769 msgs := {
2770 gprs_mm := {
2771 detachRequest_SGSN_MS := {
2772 messageType := '00000101'B,
Alexander Couzensd62fba52018-05-22 16:08:39 +02002773 detachType := { dtt, ? },
2774 forceToStandby := { forceToStandby, '0'B },
2775 gmmCause := {
2776 elementIdentifier := '25'O,
2777 causeValue := { cause }
2778 }
2779 }
2780 }
2781 }
2782}
2783
2784template PDU_L3_MS_SGSN ts_GMM_DET_ACCEPT_MO := {
2785 discriminator := '0000'B, /* overwritten */
2786 tiOrSkip := {
2787 skipIndicator := '0000'B
2788 },
2789 msgs := {
2790 gprs_mm := {
2791 detachAccept_MS_SGSN := {
2792 messageType := '00000000'B
Harald Welte835b15f2018-02-18 14:39:11 +01002793 }
2794 }
2795 }
2796}
Harald Welteeded9ad2018-02-17 20:57:34 +01002797
2798function ts_ApnTLV(template (omit) octetstring apn) return template (omit) AccessPointNameTLV {
2799 if (istemplatekind(apn, "omit")) {
2800 return omit;
2801 } else {
2802 var template (omit) AccessPointNameTLV ret := {
2803 elementIdentifier := '28'O,
2804 lengthIndicator := 0, /* overwritten */
2805 accessPointNameValue := apn
2806 }
2807 return ret;
2808 }
2809}
2810
2811function ts_PcoTLV(template (omit) ProtocolConfigOptionsV pco)
2812 return template (omit) ProtocolConfigOptionsTLV {
2813 if (istemplatekind(pco, "omit")) {
2814 return omit;
2815 } else {
2816 var template (omit) ProtocolConfigOptionsTLV ret := {
2817 elementIdentifier := '27'O,
2818 lengthIndicator := 0, /* overwritten */
2819 protocolConfigOptionsV := pco
2820 }
2821 return ret;
2822 }
2823}
2824
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002825function ts_TearDownIndicatorTV(in template (omit) boolean ind)
2826 return template (omit) TearDownIndicatorTV {
2827 if (istemplatekind(ind, "omit")) {
2828 return omit;
2829 } else {
2830 var template (omit) TearDownIndicatorTV ret := {
2831 tearDownIndicatorV := {
2832 tdi_flag := bool2bit(valueof(ind)),
2833 spare := '000'B
2834 },
2835 elementIdentifier := '1001'B
2836 }
2837 return ret;
2838 }
2839}
2840
Harald Welteeded9ad2018-02-17 20:57:34 +01002841template (value) PDU_L3_MS_SGSN ts_SM_ACT_PDP_REQ(BIT3 tid, BIT4 nsapi, BIT4 sapi, QoSV qos,
2842 PDPAddressV addr,
2843 template (omit) octetstring apn := omit,
2844 template (omit) ProtocolConfigOptionsV pco := omit
2845 ) := {
2846 discriminator := '0000'B, /* overwritten */
2847 tiOrSkip := {
2848 transactionId := {
2849 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002850 tiFlag := c_TIF_ORIG,
Harald Welteeded9ad2018-02-17 20:57:34 +01002851 tIExtension := omit
2852 }
2853 },
2854 msgs := {
2855 gprs_sm := {
2856 activatePDPContextRequest := {
2857 messageType := '00000000'B, /* overwritten */
2858 requestedNSAPI := { nsapi, '0000'B },
2859 requestedLLCSAPI := { sapi, '0000'B },
2860 requestedQoS := {
2861 lengthIndicator := 0, /* overwritten */
2862 qoSV := qos
2863 },
2864 requestedPDPaddress := {
2865 lengthIndicator := 0, /* overwritten */
2866 pdpAddressV := addr
2867 },
2868 accessPointName := ts_ApnTLV(apn),
2869 protocolConfigOpts := ts_PcoTLV(pco),
2870 requestType := omit,
2871 deviceProperties := omit,
2872 nBIFOM_Container := omit
2873 }
2874 }
2875 }
2876}
2877
2878template PDU_L3_SGSN_MS tr_SM_ACT_PDP_REJ(template BIT3 tid := ?, template OCT1 cause := ?) := {
2879 discriminator := '1010'B,
2880 tiOrSkip := {
2881 transactionId := {
2882 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002883 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002884 tIExtension := omit
2885 }
2886 },
2887 msgs := {
2888 gprs_sm := {
2889 activatePDPContextReject := {
Harald Welte4aacdd82018-02-18 21:24:05 +01002890 messageType := '01000011'B,
Harald Welteeded9ad2018-02-17 20:57:34 +01002891 smCause := cause,
2892 protocolConfigOpts := *,
2893 backOffTimer := *,
2894 reAttemptIndicator := *,
2895 nBIFOM_Container := *
2896 }
2897 }
2898 }
2899}
2900
2901template PDU_L3_SGSN_MS tr_SM_ACT_PDP_ACCEPT(template BIT3 tid := ?, template BIT4 sapi := ?,
2902 template QoSV qos := ?)
2903:= {
2904 discriminator := '1010'B,
2905 tiOrSkip := {
2906 transactionId := {
2907 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002908 tiFlag := c_TIF_REPL,
Harald Welteeded9ad2018-02-17 20:57:34 +01002909 tIExtension := omit
2910 }
2911 },
2912 msgs := {
2913 gprs_sm := {
2914 activatePDPContextAccept := {
2915 messageType := '01000010'B,
2916 negotiatedLLCSAPI := { sapi, '0000'B },
2917 negotiatedQoS := {
2918 lengthIndicator := ?,
2919 qoSV := qos
2920 },
2921 radioPriority := ?,
2922 spare := '0000'B,
2923 pdpAddress := *,
2924 protocolConfigOpts := *,
2925 packetFlowID := *,
2926 sMCause2 := *,
2927 connectivityType := *,
2928 wLANOffloadIndication := *,
2929 nBIFOM_Container := *
2930 }
2931 }
2932 }
2933}
2934
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002935template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_REQ_MO(BIT3 tid, OCT1 cause,
2936 template (omit) boolean tdown := omit,
Harald Welte6f203162018-02-18 22:04:55 +01002937 template (omit) ProtocolConfigOptionsV pco := omit
2938 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002939 discriminator := '1010'B,
Harald Welte6f203162018-02-18 22:04:55 +01002940 tiOrSkip := {
2941 transactionId := {
2942 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002943 tiFlag := c_TIF_ORIG,
Harald Welte6f203162018-02-18 22:04:55 +01002944 tIExtension := omit
2945 }
2946 },
2947 msgs := {
2948 gprs_sm := {
2949 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002950 messageType := '01000110'B,
Harald Welte6f203162018-02-18 22:04:55 +01002951 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002952 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte6f203162018-02-18 22:04:55 +01002953 protocolConfigOpts := ts_PcoTLV(pco),
2954 mBMSprotocolConfigOptions := omit,
2955 t3396 := omit,
2956 wLANOffloadIndication := omit,
2957 nBIFOM_Container := omit
2958 }
2959 }
2960 }
2961}
2962
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002963template (value) PDU_L3_SGSN_MS ts_SM_DEACT_PDP_REQ_MT(BIT3 tid, OCT1 cause,
2964 template (omit) boolean tdown := omit,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002965 template (omit) ProtocolConfigOptionsV pco := omit
2966 ) := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002967 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002968 tiOrSkip := {
2969 transactionId := {
2970 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002971 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002972 tIExtension := omit
2973 }
2974 },
2975 msgs := {
2976 gprs_sm := {
2977 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002978 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002979 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002980 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
Harald Welte57b9b7f2018-02-18 22:28:13 +01002981 protocolConfigOpts := ts_PcoTLV(pco),
2982 mBMSprotocolConfigOptions := omit,
2983 t3396 := omit,
2984 wLANOffloadIndication := omit,
2985 nBIFOM_Container := omit
2986 }
2987 }
2988 }
2989}
2990
2991template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_REQ_MT(template BIT3 tid, template OCT1 cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02002992 template (omit) boolean tdown := omit,
2993 template (omit) ProtocolConfigOptionsV pco := omit
2994 ) := {
2995 discriminator := '1010'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01002996 tiOrSkip := {
2997 transactionId := {
2998 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02002999 tiFlag := c_TIF_REPL,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003000 tIExtension := omit
3001 }
3002 },
3003 msgs := {
3004 gprs_sm := {
3005 deactivatePDPContextRequest := {
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003006 messageType := '01000110'B,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003007 smCause := cause,
Pau Espin Pedrol67e47dd2018-07-13 15:07:43 +02003008 tearDownIndicator := ts_TearDownIndicatorTV(tdown),
3009 protocolConfigOpts := ts_PcoTLV(pco),
Harald Welte57b9b7f2018-02-18 22:28:13 +01003010 mBMSprotocolConfigOptions := *,
3011 t3396 := *,
3012 wLANOffloadIndication := *,
3013 nBIFOM_Container := *
3014 }
3015 }
3016 }
3017}
3018
Harald Welte6f203162018-02-18 22:04:55 +01003019template PDU_L3_SGSN_MS tr_SM_DEACT_PDP_ACCEPT_MT(template BIT3 tid := ?)
3020:= {
3021 discriminator := '1010'B,
3022 tiOrSkip := {
3023 transactionId := {
3024 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003025 tiFlag := c_TIF_REPL,
Harald Welte6f203162018-02-18 22:04:55 +01003026 tIExtension := omit
3027 }
3028 },
3029 msgs := {
3030 gprs_sm := {
3031 deactivatePDPContextAccept := {
3032 messageType := '01000111'B,
3033 protocolConfigOpts := *,
3034 mBMSprotocolConfigOptions := *,
3035 nBIFOM_Container := *
3036 }
3037 }
3038 }
3039}
3040
Harald Welte57b9b7f2018-02-18 22:28:13 +01003041template PDU_L3_MS_SGSN tr_SM_DEACT_PDP_ACCEPT_MO(template BIT3 tid := ?)
3042:= {
3043 discriminator := '1010'B,
3044 tiOrSkip := {
3045 transactionId := {
3046 tio := tid,
Pau Espin Pedrol55cb2ce2020-04-22 17:08:09 +02003047 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003048 tIExtension := omit
3049 }
3050 },
3051 msgs := {
3052 gprs_sm := {
3053 deactivatePDPContextAccept := {
3054 messageType := '01000111'B,
3055 protocolConfigOpts := *,
3056 mBMSprotocolConfigOptions := *,
3057 nBIFOM_Container := *
3058 }
3059 }
3060 }
3061}
3062
3063template (value) PDU_L3_MS_SGSN ts_SM_DEACT_PDP_ACCEPT_MO(BIT3 tid)
3064:= {
3065 discriminator := '1010'B,
3066 tiOrSkip := {
3067 transactionId := {
3068 tio := tid,
Harald Welte51affb62018-04-09 14:17:45 +02003069 tiFlag := c_TIF_ORIG,
Harald Welte57b9b7f2018-02-18 22:28:13 +01003070 tIExtension := omit
3071 }
3072 },
3073 msgs := {
3074 gprs_sm := {
3075 deactivatePDPContextAccept := {
3076 messageType := '01000111'B,
3077 protocolConfigOpts := omit,
3078 mBMSprotocolConfigOptions := omit,
3079 nBIFOM_Container := omit
3080 }
3081 }
3082 }
3083}
3084
Harald Welteeded9ad2018-02-17 20:57:34 +01003085
3086
Harald Welte7484fc42018-02-24 14:09:45 +01003087external function enc_MobileIdentityLV(in MobileIdentityLV si) return octetstring
3088 with { extension "prototype(convert) encode(RAW)" };
Harald Weltee5695f52018-02-16 14:46:15 +01003089
Vadim Yanitskiy322c7932020-01-01 23:03:47 +01003090external function dec_MobileIdentityV(in octetstring mi) return MobileIdentityV
3091 with { extension "prototype(convert) decode(RAW)" };
3092
Harald Weltecb6cc332018-01-21 13:59:08 +01003093
Harald Weltef45efeb2018-04-09 18:19:24 +02003094
3095/* SMS TPDU Layer */
3096
3097template (value) TPDU_RP_DATA_MS_SGSN ts_SMS_SUBMIT(OCT1 msg_ref, template (value) TP_DA dst_addr,
3098 template (value) OCT1 pid, template (value) OCT1 dcs,
3099 integer length_ind, octetstring user_data) := {
3100 sMS_SUBMIT := {
3101 tP_MTI := '01'B, /* SUBMIT */
3102 tP_RD := '1'B, /* reject duplicates */
3103 tP_VPF := '00'B, /* not present */
3104 tP_SRR := '0'B, /* no status report requested */
3105 tP_UDHI := '0'B, /* no user data header in UD */
3106 tP_RP := '0'B, /* no reply path */
3107 tP_MR := msg_ref,
3108 tP_DA := dst_addr,
3109 tP_PID := pid,
3110 tP_DCS := dcs,
3111 tP_VP := omit,
3112 tP_UDL_UD := {
3113 tP_LengthIndicator := length_ind,
3114 tP_UD := user_data
3115 }
3116 }
3117}
3118
3119template TPDU_RP_DATA_SGSN_MS tr_SMS_DELIVER(template TP_OA src_addr := ?,
3120 template octetstring user_data := ?,
3121 template OCT1 pid := ?, template OCT1 dcs := ?,
3122 template BIT1 mms := ?
3123 ) := {
3124 sMS_DELIVER := {
3125 tP_MTI := '00'B, /* DELIVER */
3126 tP_MMS := mms, /* more messages to send */
3127 tP_LP := ?, /* ?!? */
3128 tP_Spare := '0'B,
3129 tP_SRI := '0'B, /* status report indication */
3130 tP_UDHI := '0'B, /* no user data header in UD */
3131 tP_RP := '0'B, /* no reply path */
3132 tP_OA := src_addr,
3133 tP_PID := pid,
3134 tP_DCS := dcs,
3135 tP_SCTS := ?,
3136 tP_UDL_UD := {
3137 tP_LengthIndicator := ?,
3138 tP_UD := user_data
3139 }
3140 }
3141}
3142
3143/* RP Layer */
3144
3145private function ts_RpOrig(template (omit) RP_NumberingPlan_and_NumberDigits rp_orig)
3146return RP_OriginatorAddressLV {
3147 var RP_OriginatorAddressLV ret;
3148 if (istemplatekind(rp_orig, "omit")) {
3149 ret := { 0, omit };
3150 } else {
3151 ret := { 0, valueof(rp_orig) };
3152 }
3153 return ret;
3154}
3155
3156private function ts_RpDst(template (omit) RP_NumberingPlan_and_NumberDigits rp_dst)
3157return RP_DestinationAddressLV {
3158 var RP_DestinationAddressLV ret;
3159 if (istemplatekind(rp_dst, "omit")) {
3160 ret := { 0, omit };
3161 } else {
3162 ret := { 0, valueof(rp_dst) };
3163 }
3164 return ret;
3165}
3166
3167template (value) RPDU_MS_SGSN ts_RP_DATA_MO(OCT1 msg_ref,
3168 template (omit) RP_NumberingPlan_and_NumberDigits rp_orig,
3169 template (omit) RP_NumberingPlan_and_NumberDigits rp_dst,
3170 template (value) TPDU_RP_DATA_MS_SGSN tpdu) := {
3171 rP_DATA_MS_SGSN := {
3172 rP_MTI := '000'B,
3173 rP_Spare := '00000'B,
3174 rP_MessageReference := msg_ref,
3175 rP_OriginatorAddress := ts_RpOrig(rp_orig),
3176 rP_DestinationAddress := ts_RpDst(rp_dst),
3177 rP_User_Data := {
3178 rP_LengthIndicator := 0, /* overwritten */
3179 rP_TPDU := tpdu
3180 }
3181 }
3182}
3183
3184template RPDU_SGSN_MS tr_RP_DATA_MT(template OCT1 msg_ref,
3185 template RP_NumberingPlan_and_NumberDigits rp_orig,
3186 template RP_NumberingPlan_and_NumberDigits rp_dst,
3187 template TPDU_RP_DATA_SGSN_MS tpdu) := {
3188 rP_DATA_SGSN_MS := {
3189 rP_MTI := '001'B,
3190 rP_Spare := '00000'B,
3191 rP_MessageReference := msg_ref,
3192 rP_OriginatorAddress := { ?, rp_orig },
3193 rP_DestinationAddress := { ?, rp_dst },
3194 rP_User_Data := {
3195 rP_LengthIndicator := ?,
3196 rP_TPDU := tpdu
3197 }
3198
3199 }
3200}
3201
3202template (value) RPDU_MS_SGSN ts_RP_ACK_MO(OCT1 msg_ref) := {
3203 rP_ACK_MS_SGSN := {
3204 rP_MTI := '010'B,
3205 rP_Spare := '00000'B,
3206 rP_MessageReference := msg_ref,
3207 rP_User_Data := omit /* FIXME: report */
3208 }
3209}
3210
3211template RPDU_SGSN_MS tr_RP_ACK_MT(template OCT1 msg_ref) := {
3212 rP_ACK_SGSN_MS := {
3213 rP_MTI := '011'B,
3214 rP_Spare := '00000'B,
3215 rP_MessageReference := msg_ref,
3216 rP_User_Data := omit /* FIXME: report */
3217 }
3218}
3219
3220template (value) RPDU_MS_SGSN ts_RP_ERROR_MO(OCT1 msg_ref, uint7_t cause) := {
3221 rP_ERROR_MS_SGSN := {
3222 rP_MTI := '100'B,
3223 rP_Spare := '00000'B,
3224 rP_Message_Reference := msg_ref,
3225 rP_CauseLV := {
3226 rP_LengthIndicator := 0, /* overwritten */
3227 rP_CauseV := {
3228 causeValue := int2bit(cause, 7),
3229 ext := '0'B
3230 },
3231 rP_diagnisticField := omit
3232 },
3233 rP_User_Data := omit /* FIXME: report */
3234 }
3235}
3236
3237private function f_cause_or_wc(template uint7_t cause) return template BIT7 {
3238 if (istemplatekind(cause, "?")) {
3239 return ?;
3240 } else if (istemplatekind(cause, "*")) {
3241 return *;
3242 } else {
3243 return int2bit(valueof(cause), 7);
3244 }
3245}
3246
3247template RPDU_SGSN_MS tr_RP_ERROR_MT(template OCT1 msg_ref, template uint7_t cause) := {
3248 rP_ERROR_SGSN_MS := {
3249 rP_MTI := '101'B,
3250 rP_Spare := '00000'B,
3251 rP_Message_Reference := msg_ref,
3252 rP_CauseLV := {
Vadim Yanitskiye9e93012020-01-15 12:35:17 +07003253 rP_LengthIndicator := ?,
Harald Weltef45efeb2018-04-09 18:19:24 +02003254 rP_CauseV := {
3255 causeValue := f_cause_or_wc(cause),
3256 ext := '0'B
3257 },
3258 rP_diagnisticField := omit
3259 },
3260 rP_User_Data := omit /* FIXME: report */
3261 }
3262}
3263
3264
3265template (value) RPDU_MS_SGSN ts_RP_SMMA_MO(OCT1 msg_ref) := {
3266 rP_SMMA := {
3267 rP_MTI := '110'B,
3268 rP_Spare := '00000'B,
3269 rP_MessageReference := msg_ref
3270 }
3271}
3272
3273
3274
3275
3276/* CP Layer */
3277
3278template (value) L3_SMS_MS_SGSN ts_CP_DATA_MO(template (value) RPDU_MS_SGSN rpdu) := {
3279 cP_DATA := {
3280 cP_messageType := '00000001'B,
3281 cP_User_Data := {
3282 lengthIndicator := 0, /* overwritten */
3283 cP_RPDU := rpdu
3284 }
3285 }
3286}
3287
3288template (value) L3_SMS_MS_SGSN ts_CP_ACK_MO := {
3289 cP_ACK := {
3290 cP_messageType := '00000100'B
3291 }
3292}
3293
3294template (value) L3_SMS_MS_SGSN ts_CP_ERROR_MO(OCT1 cause) := {
3295 cP_ERROR := {
3296 cP_messageType := '00010000'B,
3297 cP_Cause := {
3298 causeValue := cause
3299 }
3300 }
3301}
3302
3303template L3_SMS_SGSN_MS tr_CP_DATA_MT(template RPDU_SGSN_MS rpdu) := {
3304 cP_DATA := {
3305 cP_messageType := '00000001'B,
3306 cP_User_Data := {
3307 lengthIndicator := ?,
3308 cP_RPDU := rpdu
3309 }
3310 }
3311}
3312
3313template L3_SMS_SGSN_MS tr_CP_ACK_MT := {
3314 cP_ACK := {
3315 cP_messageType := '00000100'B
3316 }
3317}
3318
3319template L3_SMS_SGSN_MS tr_CP_ERROR_MT(template OCT1 cause) := {
3320 cP_ERROR := {
3321 cP_messageType := '00010000'B,
3322 cP_Cause := {
3323 causeValue := cause
3324 }
3325 }
3326}
3327
3328/* L3 Wrapper */
3329
3330template (value) PDU_ML3_MS_NW ts_ML3_MO_SMS(uint3_t tid, BIT1 ti_flag,
3331 template (value) L3_SMS_MS_SGSN sms_mo) := {
3332 discriminator := '1001'B,
3333 tiOrSkip := {
3334 transactionId := {
3335 tio := int2bit(tid, 3),
3336 tiFlag := ti_flag,
3337 tIExtension := omit
3338 }
3339 },
3340 msgs := {
3341 sms := sms_mo
3342 }
3343}
3344
3345private function f_tid_or_wc(template uint3_t tid) return template BIT3 {
3346 var template BIT3 ret;
3347 if (istemplatekind(tid, "*")) {
3348 return *;
3349 } else if (istemplatekind(tid, "?")) {
3350 return ?;
3351 } else {
3352 return int2bit(valueof(tid), 3);
3353 }
3354}
3355
3356template PDU_ML3_NW_MS tr_ML3_MT_SMS(template uint3_t tid, template BIT1 ti_flag,
3357 template L3_SMS_SGSN_MS sms_mt) := {
3358 discriminator := '1001'B,
3359 tiOrSkip := {
3360 transactionId := {
3361 tio := f_tid_or_wc(tid),
3362 tiFlag := ti_flag,
3363 tIExtension := omit
3364 }
3365 },
3366 msgs := {
3367 sms := sms_mt
3368 }
3369}
3370
Philipp Maier9b690e42018-12-21 11:50:03 +01003371template PDU_ML3_NW_MS tr_ML3_MT_MM_Info := {
3372 discriminator := '0101'B,
3373 tiOrSkip := {
3374 skipIndicator := '0000'B
3375 },
3376 msgs := {
3377 mm := {
3378 mMInformation := {
3379 messageType := '110010'B,
3380 nsd := '00'B,
3381 fullNetworkName := *,
3382 shortNetworkName := *,
3383 localtimeZone := *,
3384 univTime := *,
3385 lSAIdentity := *,
3386 networkDST := *
3387 }
3388 }
3389 }
3390}
Harald Weltef45efeb2018-04-09 18:19:24 +02003391
Vadim Yanitskiy13c26f92020-07-04 21:15:26 +07003392template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
3393 template (value) RoutingAreaIdentificationV rai,
3394 template (value) OCT1 cause) := {
3395 discriminator := '0000'B, /* overwritten */
3396 tiOrSkip := {
3397 skipIndicator := '0000'B
3398 },
3399 msgs := {
3400 rrm := {
3401 gPRS_suspensionRequest := {
3402 messageType := '00110100'B,
3403 tLLI := tlli,
3404 routingAreaIdentification := rai,
3405 suspensionCause := cause,
3406 service_Support := omit
3407 }
3408 }
3409 }
3410}
3411
Harald Weltef45efeb2018-04-09 18:19:24 +02003412
3413
Harald Weltec76f29f2017-11-22 12:46:46 +01003414}