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