summaryrefslogtreecommitdiffstats
path: root/library/SGsAP_Templates.ttcn
blob: 9526080f4745ccc590933eecd643532feb7f7faa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
module SGsAP_Templates {

/* Templates for the SGsAP protocol as per 3GPP TS 29.118
 * (C) 2018 by Harald Welte <laforg@gnumonks.org>
 * All rights reserved.
 *
 * Released under the terms of the GNU General Public License, Version 2 or
 * (at your option) any later version.
 */

import from SGsAP_Types all;
import from GSM_Types all;
import from General_Types all;
import from MobileL3_CommonIE_Types all;

/* 9.4.2 */
template (value) EPS_LocationUpdateType ts_SGsAP_IE_EpsLuType(template (value) EPS_location_update_type lut) := {
	iEI := '00001010'B,
	lengthIndicator := 1,
	locationUpdateType := lut
}
template EPS_LocationUpdateType tr_SGsAP_IE_EpsLuType(template EPS_location_update_type lut) := {
	iEI := '00001010'B,
	lengthIndicator := 1,
	locationUpdateType := lut
}

/* 9.4.3 */
template (value) ErroneousMessage ts_SGsAP_IE_ErrMsg(template (value) octetstring err_msg) := {
	iEI := '00011011'B,
	lengthIndicator := lengthof(valueof(err_msg)),
	erroneousMessage := err_msg
}
template ErroneousMessage tr_SGsAP_IE_ErrMsg(template octetstring err_msg) := {
	iEI := '00011011'B,
	lengthIndicator := ?,
	erroneousMessage := err_msg
}


/* 9.4.6 */
private function ts_SGsAP_IMSI(hexstring digits) return template (value) IMSI {
	var template (value) IMSI imsi := {
		iEI := '00000001'B,
		lengthIndicator := lengthof(digits)/2 + 1,
		iMSI := {
			field1 := '001'B,
			parity := '0'B, /* even */
			digits := digits,
			fillerDigit := '1111'B /* even */
		}
	}
	if (lengthof(digits) mod 2 == 1) {
		/* odd number of digits */
		imsi.iMSI.parity := '1'B;
		imsi.iMSI.fillerDigit := omit;
	}
	return imsi;
}
private function ts_SGsAP_IMSI_omit(template (omit) hexstring digits) return template (omit) IMSI {
	if (istemplatekind(digits, "omit")) {
		return omit;
	} else {
		return ts_SGsAP_IMSI(valueof(digits));
	}
}
private function tr_SGsAP_IMSI(template hexstring digits) return template IMSI {
	if (istemplatekind(digits, "omit")) {
		return omit;
	} else if (istemplatekind(digits, "*")) {
		return *;
	}
	var template IMSI imsi := {
		iEI := '00000001'B,
		lengthIndicator := lengthof(digits)/2 + 1,
		iMSI := {
			field1 := '001'B,
			parity := '0'B, /* even */
			digits := digits,
			fillerDigit := '1111'B /* even */
		}
	}
	if (lengthof(digits) mod 2 == 1) {
		/* odd number of digits */
		/* odd number of digits */
		imsi.iMSI.parity := '1'B;
		imsi.iMSI.fillerDigit := omit;
	}
	return imsi;
}

/* 9.4.7 */
template (value) IMSI_DetachFromEPS_ServiceType ts_SGsAP_IE_DetServiceType(template (value) IMSI_detachFromEPS_serviceType st) := {
	iEI := '00010000'B,
	lengthIndicator := 1,
	serviceType := st
}
template IMSI_DetachFromEPS_ServiceType tr_SGsAP_IE_DetServiceType(template IMSI_detachFromEPS_serviceType st) := {
	iEI := '00010000'B,
	lengthIndicator := 1,
	serviceType := st
}

/* 9.4.8 */
template (value) IMSI_DetachFromNonEPS_ServiceType ts_SGsAP_IE_DetNonEpsServiceType(template (value) IMSI_detachFromNonEPS_serviceType st) := {
	iEI := '00010001'B,
	lengthIndicator := 1,
	serviceType := st
}
template IMSI_DetachFromNonEPS_ServiceType tr_SGsAP_IE_DetNonEpsServiceType(template IMSI_detachFromNonEPS_serviceType st) := {
	iEI := '00010001'B,
	lengthIndicator := 1,
	serviceType := st
}

/* 9.4.11 */
private function f_enc_mnc_digit3(GsmMnc mnc) return HEX1 {
	if (lengthof(mnc) == 2) {
		return 'F'H;
	} else {
		return mnc[2];
	}
}
template (value) LocationAreaIdValue ts_SGsAP_LAI(GsmMcc mcc, GsmMnc mnc, GsmLac lac) := {
	mccDigit1 := mcc[0],
	mccDigit2 := mcc[1],
	mccDigit3 := mcc[2],
	mncDigit3 := f_enc_mnc_digit3(mnc),
	mncDigit1 := mnc[0],
	mncDigit2 := mnc[1],
	lac := int2oct(lac, 2)
}
template (value) LocationAreaId ts_SGsAP_IE_Lai(template (value) LocationAreaIdValue lai) := {
	iEI := '00000100'B,
	lengthIndicator := 5,
	locationAreaId := lai
}
template LocationAreaId tr_SGsAP_IE_Lai(template LocationAreaIdValue lai) := {
	iEI := '00000100'B,
	lengthIndicator := 5,
	locationAreaId := lai
}
function ts_SGsAP_IE_Lai_omit(template (omit) LocationAreaIdValue lai) return template (omit) LocationAreaId {
	if (istemplatekind(lai, "omit")) {
		return omit;
	} else {
		return ts_SGsAP_IE_Lai(lai);
	}
}
function tr_SGsAP_IE_Lai_omit(template LocationAreaIdValue lai) return template LocationAreaId {
	if (istemplatekind(lai, "omit")) {
		return omit;
	} else if (istemplatekind(lai, "*")) {
		return *;
	} else {
		return tr_SGsAP_IE_Lai(lai);
	}
}



/* 9.4.12 */
template (value) MM_Information ts_SGsAP_IE_MmInfo(template (value) octetstring mm_info) := {
	iEI := '00010111'B,
	lengthIndicator := lengthof(valueof(mm_info)),
	information := mm_info
}
template MM_Information tr_SGsAP_IE_MmInfo(template octetstring mm_info) := {
	iEI := '00010111'B,
	lengthIndicator := ?,
	information := mm_info
}



/* 9.4.13 */
template (value) MME_Name ts_SGsAP_IE_MmeName(template (value) octetstring name) := {
	iEI := '00001001'B,
	lengthIndicator := lengthof(valueof(name)),
	name := name
};
template MME_Name tr_SGsAP_IE_MmeName(template octetstring name) := {
	iEI := '00001001'B,
	lengthIndicator := ?,
	name := name
};

/* 9.4.14 */
function f_l3_to_sgs_id(MobileIdentityLV l3) return MobileIdentityValue {
	var OddEvenInd_Identity l3v := l3.mobileIdentityV.oddEvenInd_identity;
	var MobileIdentityValue ret;
	ret.typeOfIdentity := l3.mobileIdentityV.typeOfIdentity;
	if (ischosen(l3v.imei)) {
		ret.iD.imei.oddevenIndicator := l3v.imei.oddevenIndicator;
		ret.iD.imei.digits := l3v.imei.digits;
	} else if (ischosen(l3v.imsi)) {
		ret.iD.imsi.oddevenIndicator := l3v.imsi.oddevenIndicator;
		ret.iD.imsi.digits := l3v.imsi.digits;
		ret.iD.imsi.fillerDigit := l3v.imsi.fillerDigit;
	} else if (ischosen(l3v.imei_sv)) {
		ret.iD.imei_sv.oddevenIndicator := l3v.imei_sv.oddevenIndicator;
		ret.iD.imei_sv.digits := l3v.imei_sv.digits;
		ret.iD.imei_sv.fillerDigit := l3v.imei_sv.fillerDigit;
	} else if (ischosen(l3v.tmsi_ptmsi)) {
		ret.iD.tmsi_ptmsi.oddevenIndicator := l3v.tmsi_ptmsi.oddevenIndicator;
		ret.iD.tmsi_ptmsi.fillerDigit := l3v.tmsi_ptmsi.fillerDigit;
		ret.iD.tmsi_ptmsi.octets := l3v.tmsi_ptmsi.octets;
	} else if (ischosen(l3v.tmgi_and_MBMS_SessionID)) {
		ret.iD.tmgi_and_MBMS_SessionID.oddevenIndicator := l3v.tmgi_and_MBMS_SessionID.oddevenIndicator;
		ret.iD.tmgi_and_MBMS_SessionID.mCC_MNCIndicator := l3v.tmgi_and_MBMS_SessionID.mCC_MNCIndicator;
		ret.iD.tmgi_and_MBMS_SessionID.mBMS_SessionIdentityIndicator := l3v.tmgi_and_MBMS_SessionID.mBMS_SessionIdentityIndicator;
		ret.iD.tmgi_and_MBMS_SessionID.spare := l3v.tmgi_and_MBMS_SessionID.spare;
		ret.iD.tmgi_and_MBMS_SessionID.mBMS_ServiceID := l3v.tmgi_and_MBMS_SessionID.mBMS_ServiceID;
		ret.iD.tmgi_and_MBMS_SessionID.mccDigit1 := l3v.tmgi_and_MBMS_SessionID.mccDigit1;
		ret.iD.tmgi_and_MBMS_SessionID.mccDigit2 := l3v.tmgi_and_MBMS_SessionID.mccDigit2;
		ret.iD.tmgi_and_MBMS_SessionID.mccDigit3 := l3v.tmgi_and_MBMS_SessionID.mccDigit3;
		ret.iD.tmgi_and_MBMS_SessionID.mccDigit3 := l3v.tmgi_and_MBMS_SessionID.mccDigit3;
		ret.iD.tmgi_and_MBMS_SessionID.mccDigit1 := l3v.tmgi_and_MBMS_SessionID.mccDigit1;
		ret.iD.tmgi_and_MBMS_SessionID.mccDigit2 := l3v.tmgi_and_MBMS_SessionID.mccDigit2;
		ret.iD.tmgi_and_MBMS_SessionID.mBMS_SessionIdentity := l3v.tmgi_and_MBMS_SessionID.mBMS_SessionIdentity;
	} else if (ischosen(l3v.no_identity)) {
		ret.iD.no_identity.oddevenIndicator := l3v.no_identity.oddevenIndicator;
		ret.iD.no_identity.fillerDigits := l3v.no_identity.fillerDigits;
	}
	return ret;
}
template MobileIdentity ts_SGsAP_IE_MobileID(template (value) MobileIdentityLV l3_mi) := {
	iEI := '00001110'B,
	lengthIndicator := 0, /* overwritten */
	iD := f_l3_to_sgs_id(valueof(l3_mi))
}


/* 9.4.15 */
template (value) NAS_MessageContainer ts_SGsAP_NasContainer(template (value) octetstring nas_pdu) := {
	iEI := '00010110'B,
	lengthIndicator := lengthof(valueof(nas_pdu)),
	nAS_MessageContainer := nas_pdu
}
template NAS_MessageContainer tr_SGsAP_NasContainer(template octetstring nas_pdu) := {
	iEI := '00010110'B,
	lengthIndicator := ?,
	nAS_MessageContainer := nas_pdu
}

/* 9.4.16 */
template (value) RejectCause ts_SGsAP_IE_RejCause(template (value) Reject_Cause cause) := {
	iEI := '00001111'B,
	lengthIndicator := 1,
	cause := cause
}
template RejectCause tr_SGsAP_IE_RejCause(template Reject_Cause cause) := {
	iEI := '00001111'B,
	lengthIndicator := 1,
	cause := cause
}

/* 9.4.17 */
template (value) ServiceIndicator ts_SGsAP_ServiceInd(template (value) Service_Indicator si) := {
	iEI := '00100000'B,
	lengthIndicator := 1,
	indicator := si
}
template ServiceIndicator tr_SGsAP_ServiceInd(template Service_Indicator si) := {
	iEI := '00100000'B,
	lengthIndicator := 1,
	indicator := si
}


/* 9.4.18 */
template (value) SGsCause ts_SGsAP_IE_SgsCause(template (value) SGs_Cause cause) := {
	iEI := '00001000'B,
	lengthIndicator := 1,
	cause := cause
}
function tr_SGsAP_IE_SgsCause(template SGs_Cause cause) return template SGsCause {
	if (istemplatekind(cause, "omit")) {
		return omit;
	} else if (istemplatekind(cause, "*")) {
		return *;
	} else {
		var template SGsCause ret := {
			iEI := '00001000'B,
			lengthIndicator := 1,
			cause := cause
		}
		return ret;
	}
}

/* 9.4.21c */
template (value) UE_EMM_Mode ts_SGsAP_IE_UeEmmMode(template (value) UE_EMM_mode mode) := {
	iEI := '00100101'B,
	lengthIndicator := 1,
	mode := mode
}
template UE_EMM_Mode tr_SGsAP_IE_UeEmmMode(template UE_EMM_mode mode) := {
	iEI := '00100101'B,
	lengthIndicator := 1,
	mode := mode
}


/* 9.4.22 */
template (value) VLR_Name ts_SGsAP_IE_VlrName(template (value) octetstring name) := {
	iEI := '00000010'B,
	lengthIndicator := lengthof(name),
	name := name
}
template VLR_Name tr_SGsAP_IE_VlrName(template octetstring name) := {
	iEI := '00000010'B,
	lengthIndicator := ?,
	name := name
}





/* 3GPP TS 29.118 Section 8.1 */
template (value) PDU_SGsAP ts_SGsAP_ALERT_ACK(hexstring imsi) := {
	sGsAP_ALERT_ACK := {
		messageType := '00001110'B,
		iMSI := ts_SGsAP_IMSI(imsi)
	}
}
template PDU_SGsAP tr_SGsAP_ALERT_ACK(template hexstring imsi) := {
	sGsAP_ALERT_ACK := {
		messageType := '00001110'B,
		iMSI := tr_SGsAP_IMSI(imsi)
	}
}

/* 3GPP TS 29.118 Section 8.2 */
template PDU_SGsAP ts_SGsAP_ALERT_REJECT(hexstring imsi,
					 template (value) SGs_Cause cause) := {
	sGsAP_ALERT_REJECT := {
		messageType := '00001111'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		sGsCause := ts_SGsAP_IE_SgsCause(cause)
	}
}
template PDU_SGsAP tr_SGsAP_ALERT_REJECT(template hexstring imsi,
					 template SGs_Cause cause := ?) := {
	sGsAP_ALERT_REJECT := {
		messageType := '00001111'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		sGsCause := tr_SGsAP_IE_SgsCause(cause)
	}
}

/* 3GPP TS 29.118 Section 8.3 */
template (value) PDU_SGsAP ts_SGsAP_ALERT_REQ(hexstring imsi) := {
	sGsAP_ALERT_REQUEST := {
		messageType := '00001101'B,
		iMSI := ts_SGsAP_IMSI(imsi)
	}
}
template PDU_SGsAP tr_SGsAP_ALERT_REQ(template hexstring imsi) := {
	sGsAP_ALERT_REQUEST := {
		messageType := '00001101'B,
		iMSI := tr_SGsAP_IMSI(imsi)
	}
}

/* 3GPP TS 29.118 Section 8.4 */
template (value) PDU_SGsAP ts_SGsAP_DL_UD(hexstring imsi,
					  template (value) octetstring nas_pdu) := {
	sGsAP_DOWNLINK_UNITDATA := {
		messageType := '00000111'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		nAS_MessageContainer := ts_SGsAP_NasContainer(nas_pdu)
	}
}
template PDU_SGsAP tr_SGsAP_DL_UD(template hexstring imsi, template octetstring nas_pdu := ?) := {
	sGsAP_DOWNLINK_UNITDATA := {
		messageType := '00000111'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		nAS_MessageContainer := tr_SGsAP_NasContainer(nas_pdu)
	}
}

/* 8.5 */
template (value) PDU_SGsAP ts_SGsAP_EPS_DETACH_ACK(hexstring imsi) := {
	sGsAP_EPS_DETACH_ACK:= {
		messageType := '00010010'B,
		iMSI := ts_SGsAP_IMSI(imsi)
	}
}
template PDU_SGsAP tr_SGsAP_EPS_DETACH_ACK(template hexstring imsi) := {
	sGsAP_EPS_DETACH_ACK:= {
		messageType := '00010010'B,
		iMSI := tr_SGsAP_IMSI(valueof(imsi))
	}
}

/* 8.6 */
template (value) PDU_SGsAP ts_SGsAP_EPS_DETACH_IND(hexstring imsi,
						   template (value) octetstring mme_name,
						   template (value) IMSI_detachFromEPS_serviceType det_serv_typ) := {
	sGsAP_EPS_DETACH_INDICATION:= {
		messageType := '00010001'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		mME_Name := ts_SGsAP_IE_MmeName(mme_name),
		iMSI_DetachFromEPS_ServiceType := ts_SGsAP_IE_DetServiceType(det_serv_typ)
	}
}
template PDU_SGsAP tr_SGsAP_EPS_DETACH_IND(template hexstring imsi,
					   template octetstring mme_name,
					   template IMSI_detachFromEPS_serviceType det_serv_typ) := {
	sGsAP_EPS_DETACH_INDICATION:= {
		messageType := '00010001'B,
		iMSI := tr_SGsAP_IMSI(valueof(imsi)),
		mME_Name := tr_SGsAP_IE_MmeName(mme_name),
		iMSI_DetachFromEPS_ServiceType := tr_SGsAP_IE_DetServiceType(det_serv_typ)
	}
}

/* 8.7 */
template (value) PDU_SGsAP ts_SGsAP_IMSI_DETACH_ACK(hexstring imsi) := {
	sGsAP_IMSI_DETACH_ACK := {
		messageType := '00010100'B,
		iMSI := ts_SGsAP_IMSI(imsi)
	}
}
template PDU_SGsAP tr_SGsAP_IMSI_DETACH_ACK(template hexstring imsi) := {
	sGsAP_IMSI_DETACH_ACK := {
		messageType := '00010100'B,
		iMSI := tr_SGsAP_IMSI(imsi)
	}
}

/* 8.8 */
template (value) PDU_SGsAP ts_SGsAP_IMSI_DETACH_IND(hexstring imsi,
						    template (value) octetstring mme_name,
						    template (value) IMSI_detachFromNonEPS_serviceType det_serv_typ) := {
	sGsAP_IMSI_DETACH_INDICATION := {
		messageType := '00010011'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		mME_Name := ts_SGsAP_IE_MmeName(mme_name),
		iMSI_DetachFromNonEPS_ServiceType := ts_SGsAP_IE_DetNonEpsServiceType(det_serv_typ)
	}
}
template PDU_SGsAP tr_SGsAP_IMSI_DETACH_IND(template hexstring imsi,
					    template octetstring mme_name := ?,
					    template IMSI_detachFromNonEPS_serviceType det_serv_typ := ?) := {
	sGsAP_IMSI_DETACH_INDICATION := {
		messageType := '00010011'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		mME_Name := tr_SGsAP_IE_MmeName(mme_name),
		iMSI_DetachFromNonEPS_ServiceType := tr_SGsAP_IE_DetNonEpsServiceType(det_serv_typ)
	}
}

/* 8.9 */
template (value) PDU_SGsAP ts_SGsAP_LU_ACCEPT(hexstring imsi,
					      template (value) LocationAreaIdValue lai,
					      template (value) MobileIdentityLV mobile_id) := {
	sGsAP_LOCATION_UPDATE_ACCEPT := {
		messageType := '00001010'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		locationAreaId := ts_SGsAP_IE_Lai(lai),
		newTMSIorIMSI := ts_SGsAP_IE_MobileID(mobile_id)
	}
}
template PDU_SGsAP tr_SGsAP_LU_ACCEPT(template hexstring imsi,
				      template LocationAreaIdValue lai := ?) := {
	sGsAP_LOCATION_UPDATE_ACCEPT := {
		messageType := '00001010'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		locationAreaId := tr_SGsAP_IE_Lai(lai),
		newTMSIorIMSI := *
	}
}

/* 8.10 */
template (value) PDU_SGsAP ts_SGsAP_LU_REJECT(hexstring imsi,
					      template (value) Reject_Cause rej_cause,
					      template (omit) LocationAreaIdValue lai) := {
	sGsAP_LOCATION_UPDATE_REJECT := {
		messageType := '00001011'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		rejectCause := ts_SGsAP_IE_RejCause(rej_cause),
		locationAreaId := ts_SGsAP_IE_Lai_omit(lai)
	}
}
template PDU_SGsAP tr_SGsAP_LU_REJECT(template hexstring imsi,
				      template Reject_Cause rej_cause,
				      template LocationAreaIdValue lai) := {
	sGsAP_LOCATION_UPDATE_REJECT := {
		messageType := '00001011'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		rejectCause := tr_SGsAP_IE_RejCause(rej_cause),
		locationAreaId := tr_SGsAP_IE_Lai_omit(lai)
	}
}

/* 8.11 */
template (value) PDU_SGsAP ts_SGsAP_LU_REQ(hexstring imsi,
					   template (value) octetstring mme_name,
					   template (value) EPS_location_update_type eps_lu_type,
					   template (value) LocationAreaIdValue new_lai) := {
	sGsAP_LOCATION_UPDATE_REQUEST := {
		messageType := '00001001'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		mME_Name := ts_SGsAP_IE_MmeName(mme_name),
		ePS_LocationUpdateType := ts_SGsAP_IE_EpsLuType(eps_lu_type),
		newLocationAreaId := ts_SGsAP_IE_Lai(new_lai),
		oldLocationAreaId := omit,
		tMSI_Status := omit,
		iMEI_SV := omit,
		tAI := omit,
		eCGI := omit,
		tMSI_NRI := omit,
		cS_DomainOperator := omit
	}
}
template PDU_SGsAP tr_SGsAP_LU_REQ(template hexstring imsi,
				   template octetstring mme_name := ?,
				   template EPS_location_update_type eps_lu_type := ?,
				   template LocationAreaIdValue new_lai := ?) := {
	sGsAP_LOCATION_UPDATE_REQUEST := {
		messageType := '00001001'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		mME_Name := tr_SGsAP_IE_MmeName(mme_name),
		ePS_LocationUpdateType := tr_SGsAP_IE_EpsLuType(eps_lu_type),
		newLocationAreaId := tr_SGsAP_IE_Lai_omit(new_lai),
		oldLocationAreaId := *,
		tMSI_Status := *,
		iMEI_SV := *,
		tAI := *,
		eCGI := *,
		tMSI_NRI := *,
		cS_DomainOperator := *
	}
}

/* 8.12 */
template (value) PDU_SGsAP ts_SGsAP_MM_INFO_REQ(hexstring imsi,
						template (value) octetstring mm_info) := {
	sGsAP_MM_INFORMATION_REQUEST := {
		messageType := '00011010'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		mM_Information := ts_SGsAP_IE_MmInfo(mm_info)
	}
}
template PDU_SGsAP tr_SGsAP_MM_INFO_REQ(template hexstring imsi,
					template octetstring mm_info :=?) := {
	sGsAP_MM_INFORMATION_REQUEST := {
		messageType := '00011010'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		mM_Information := tr_SGsAP_IE_MmInfo(mm_info)
	}
}

/* 8.13 */
template (value) PDU_SGsAP ts_SGsAP_PAGING_REJ(hexstring imsi,
						template (value) SGs_Cause cause) := {
	sGsAP_PAGING_REJECT := {
		messageType := '00000010'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		sGsCause := ts_SGsAP_IE_SgsCause(cause)
	}
}
template PDU_SGsAP tr_SGsAP_PAGING_REJ(template hexstring imsi,
					template SGs_Cause cause := ?) := {
	sGsAP_PAGING_REJECT := {
		messageType := '00000010'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		sGsCause := tr_SGsAP_IE_SgsCause(cause)
	}
}

/* 8.14 */
template (value) PDU_SGsAP ts_SGsAP_PAGING_REQ(hexstring imsi,
						template (value) octetstring vlr_name,
						template (value) Service_Indicator serv_ind,
						template (omit) OCT4 tmsi) :=
{
	sGsAP_PAGING_REQUEST := {
		messageType := '00000001'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		vLR_Name := ts_SGsAP_IE_VlrName(vlr_name),
		serviceIndicator := ts_SGsAP_ServiceInd(serv_ind),
		tMSI := omit,
		cLI := omit,
		locationAreaId := omit,
		globalCN_Id := omit,
		sS_Code := omit,
		lCS_Indicator := omit,
		lCS_ClientIdentity := omit,
		channelNeeded := omit,
		eMLPP_Priority := omit,
		additionalPagingIndicator := omit
	}
}
template PDU_SGsAP tr_SGsAP_PAGING_REQ(template hexstring imsi,
					template octetstring vlr_name,
					template Service_Indicator serv_ind,
					template OCT4 tmsi) :=
{
	sGsAP_PAGING_REQUEST := {
		messageType := '00000001'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		vLR_Name := tr_SGsAP_IE_VlrName(vlr_name),
		serviceIndicator := tr_SGsAP_ServiceInd(serv_ind),
		tMSI := *,
		cLI := *,
		locationAreaId := *,
		globalCN_Id := *,
		sS_Code := *,
		lCS_Indicator := *,
		lCS_ClientIdentity := *,
		channelNeeded := *,
		eMLPP_Priority := *,
		additionalPagingIndicator := *
	}
}

/* 8.15 */
template (value) PDU_SGsAP ts_SGsAP_RESET_ACK_MME(template (value) octetstring mme_name) := {
	sGsAP_RESET_ACK := {
		messageType := '00010110'B,
		mME_Name := ts_SGsAP_IE_MmeName(mme_name),
		vLR_Name := omit
	}
}
template (value) PDU_SGsAP ts_SGsAP_RESET_ACK_VLR(template (value) octetstring vlr_name) := {
	sGsAP_RESET_ACK := {
		messageType := '00010110'B,
		mME_Name := omit,
		vLR_Name := ts_SGsAP_IE_VlrName(vlr_name)
	}
}
template PDU_SGsAP tr_SGsAP_RESET_ACK(template octetstring mme_name, template octetstring vlr_name) := {
	sGsAP_RESET_ACK := {
		messageType := '00010110'B,
		mME_Name := tr_SGsAP_IE_MmeName(mme_name),
		vLR_Name := tr_SGsAP_IE_VlrName(vlr_name)
	}
}

/* 8.16 */
template (value) PDU_SGsAP ts_SGsAP_RESET_IND_MME(template (value) octetstring mme_name) := {
	sGsAP_RESET_INDICATION := {
		messageType := '00010101'B,
		mME_Name := ts_SGsAP_IE_MmeName(mme_name),
		vLR_Name := omit
	}
}
template (value) PDU_SGsAP ts_SGsAP_RESET_IND_VLR(template (value) octetstring vlr_name) := {
	sGsAP_RESET_INDICATION := {
		messageType := '00010101'B,
		mME_Name := omit,
		vLR_Name := ts_SGsAP_IE_VlrName(vlr_name)
	}
}
template PDU_SGsAP tr_SGsAP_RESET_IND(template octetstring mme_name, template octetstring vlr_name) := {
	sGsAP_RESET_INDICATION := {
		messageType := '00010101'B,
		mME_Name := tr_SGsAP_IE_MmeName(mme_name),
		vLR_Name := tr_SGsAP_IE_VlrName(vlr_name)
	}
}

/* 8.17 */
template (value) PDU_SGsAP ts_SGsAP_SERVICE_REQ(hexstring imsi,
						template (value) Service_Indicator serv_ind,
					        template (value) UE_EMM_mode emm_mode) := {
	sGsAP_SERVICE_REQUEST := {
		messageType := '00000110'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		serviceIndicator := ts_SGsAP_ServiceInd(serv_ind),
		iMEI_SV := omit,
		uE_TimeZone := omit,
		mobileStationClassmark2 := omit,
		tAI := omit,
		eCGI := omit,
		/* optional, but "the MME shall include this IE." */
		uE_EMM_Mode := ts_SGsAP_IE_UeEmmMode(emm_mode)
	}
}
template PDU_SGsAP tr_SGsAP_SERVICE_REQ(template hexstring imsi,
					template Service_Indicator serv_ind := ?,
				        template UE_EMM_mode emm_mode := ?) := {
	sGsAP_SERVICE_REQUEST := {
		messageType := '00000110'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		serviceIndicator := tr_SGsAP_ServiceInd(serv_ind),
		iMEI_SV := *,
		uE_TimeZone := *,
		mobileStationClassmark2 := *,
		tAI := *,
		eCGI := *,
		/* optional, but "the MME shall include this IE." */
		uE_EMM_Mode := tr_SGsAP_IE_UeEmmMode(emm_mode)
	}
}


/* 8.18 */
template (value) PDU_SGsAP ts_SGsAP_STATUS(template (omit) hexstring imsi,
					   template (value) SGs_Cause cause,
					   template (value) octetstring err_msg) := {
	sGsAP_STATUS := {
		messageType := '00011101'B,
		iMSI := ts_SGsAP_IMSI_omit(imsi),
		sGsCause := ts_SGsAP_IE_SgsCause(cause),
		erroneousMessage := ts_SGsAP_IE_ErrMsg(err_msg)
	}
}
template PDU_SGsAP tr_SGsAP_STATUS(template hexstring imsi,
				   template SGs_Cause cause,
				   template octetstring err_msg) := {
	sGsAP_STATUS := {
		messageType := '00011101'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		sGsCause := tr_SGsAP_IE_SgsCause(cause),
		erroneousMessage := tr_SGsAP_IE_ErrMsg(err_msg)
	}
}


/* 8.19 */
template (value) PDU_SGsAP ts_SGsAP_TMSI_REALL_CMPL(hexstring imsi) := {
	sGsAP_TMSI_REALLOCATION_COMPLETE := {
		messageType := '00001100'B,
		iMSI := ts_SGsAP_IMSI(imsi)
	}
}
template PDU_SGsAP tr_SGsAP_TMSI_REALL_CMPL(template hexstring imsi) := {
	sGsAP_TMSI_REALLOCATION_COMPLETE := {
		messageType := '00001100'B,
		iMSI := tr_SGsAP_IMSI(imsi)
	}
}

/* 8.20 */
template (value) PDU_SGsAP ts_SGsAP_UE_ACT_IND(hexstring imsi) := {
	sGsAP_UE_ACTIVITY_INDICATION := {
		messageType := '00010000'B,
		iMSI := ts_SGsAP_IMSI(imsi)
		/* Rel 14: Max UE Avail Time */
	}
}
template PDU_SGsAP tr_SGsAP_UE_ACT_IND(template hexstring imsi) := {
	sGsAP_UE_ACTIVITY_INDICATION := {
		messageType := '00010000'B,
		iMSI := tr_SGsAP_IMSI(imsi)
		/* Rel 14: Max UE Avail Time */
	}
}

/* 8.21 */
template (value) PDU_SGsAP ts_SGsAP_UE_UNREACHABLE(hexstring imsi,
						   template (value) SGs_Cause cause) := {
	sGsAP_UE_UNREACHABLE := {
		messageType := '00011111'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		sGsCause := ts_SGsAP_IE_SgsCause(cause)
		/* Rel 14: Requested Retransmission Time */
		/* Rel 14: Additional UE Unreachable indicators */
	}
}
template PDU_SGsAP tr_SGsAP_UE_UNREACHABLE(template hexstring imsi,
					   template SGs_Cause cause := ?) := {
	sGsAP_UE_UNREACHABLE := {
		messageType := '00011111'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		sGsCause := tr_SGsAP_IE_SgsCause(cause)
		/* Rel 14: Requested Retransmission Time */
		/* Rel 14: Additional UE Unreachable indicators */
	}
}

/* 8.22 */
template (value) PDU_SGsAP ts_SGsAP_UL_UD(hexstring imsi,
					  template (value) octetstring nas_msg) := {
	sGsAP_UPLINK_UNITDATA := {
		messageType := '00001000'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		nAS_MessageContainer := ts_SGsAP_NasContainer(nas_msg),
		iMEI_SV := omit,
		uE_TimeZone := omit,
		mobileStationClassmark2 := omit,
		tAI := omit,
		eCGI := omit
	}
}
template PDU_SGsAP tr_SGsAP_UL_UD(template hexstring imsi,
				  template octetstring nas_msg := ?) := {
	sGsAP_UPLINK_UNITDATA := {
		messageType := '00001000'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		nAS_MessageContainer := tr_SGsAP_NasContainer(nas_msg),
		iMEI_SV := *,
		uE_TimeZone := *,
		mobileStationClassmark2 := *,
		tAI := *,
		eCGI := *
	}
}

/* 8.23 */
template (value) PDU_SGsAP ts_SGsAP_RELEASE_REQ(hexstring imsi,
						template (value) SGs_Cause cause) := {
	sGsAP_RELEASE_REQUEST := {
		messageType := '00011011'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		sGsCause := ts_SGsAP_IE_SgsCause(cause)
	}
}
template PDU_SGsAP tr_SGsAP_RELEASE_REQ(template hexstring imsi,
					template SGs_Cause cause) := {
	sGsAP_RELEASE_REQUEST := {
		messageType := '00011011'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		sGsCause := tr_SGsAP_IE_SgsCause(cause)
	}
}

/* 8.24 */
template (value) PDU_SGsAP ts_SGsAP_SERVICE_ABORT_REQ(hexstring imsi) := {
	sGsAP_SERVICE_ABORT_REQUEST := {
		messageType := '00010111'B,
		iMSI := ts_SGsAP_IMSI(imsi)
	}
}
template PDU_SGsAP tr_SGsAP_SERVICE_ABORT_REQ(template hexstring imsi) := {
	sGsAP_SERVICE_ABORT_REQUEST := {
		messageType := '00010111'B,
		iMSI := tr_SGsAP_IMSI(imsi)
	}
}

/* 8.25 */
template (value) PDU_SGsAP ts_SGsAP_MO_CSFB_IND(hexstring imsi) := {
	sGsAP_MO_CSFB_INDICATION := {
		messageType := '00011000'B,
		iMSI := ts_SGsAP_IMSI(imsi),
		tAI := omit,
		eCGI := omit
	}
}
template PDU_SGsAP tr_SGsAP_MO_CSFB_IND(template hexstring imsi) := {
	sGsAP_MO_CSFB_INDICATION := {
		messageType := '00011000'B,
		iMSI := tr_SGsAP_IMSI(imsi),
		tAI := *,
		eCGI := *
	}
}






}