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