aboutsummaryrefslogtreecommitdiffstats
path: root/library/RSL_Types.ttcn
blob: fa1d928595791f08e97051883403d3ddf8eb506d (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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
module RSL_Types {

/* RSL types defining abstract TTCN-3 data types for the A-bis RSL protocol.
 *
 * RSL is a 3GPP standard protocol used between BTS and BSC in a GSM network.
 *
 * (C) 2017-2023 by Harald Welte <laforge@gnumonks.org>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

	import from General_Types all;
	import from Osmocom_Types all;
	import from GSM_RR_Types all;
	import from GSM_Types all;
	import from MobileL3_CommonIE_Types all;
	import from L3_Templates all;

	/* Section 9.1 */
	type enumerated RSL_MessageGroup {
		RSL_MDISC_RESERVED	('0000000'B),
		RSL_MDISC_RLL		('0000001'B),
		RSL_MDISC_DCHAN		('0000100'B),
		RSL_MDISC_CCHAN		('0000110'B),
		RSL_MDISC_TRX_MGMT	('0001000'B),
		RSL_MDISC_LCS		('0010000'B),
		RSL_MDISC_IPACCESS	('0111111'B)
	} with { variant "FIELDLENGTH(7)" };

	/* Section 9.1 */
	type record RSL_MessageDiscriminator {
		RSL_MessageGroup	msg_group,
		boolean			transparent
	} with { variant "FIELDORDER(msb)" };

	template (value) RSL_MessageDiscriminator ts_RSL_MsgDisc(RSL_MessageGroup mg, boolean t := true) := {
		msg_group := mg,
		transparent := t
	}
	template RSL_MessageDiscriminator tr_RSL_MsgDisc(template RSL_MessageGroup mg, boolean t := true) := {
		msg_group := mg,
		transparent := t
	}


	/* Section 9.2 */
	type enumerated RSL_MessageType {
		/* Radio Link Layer Management */
		RSL_MT_DATA_REQ		('00000001'B),
		RSL_MT_DATA_IND		('00000010'B),
		RSL_MT_ERROR_IND	('00000011'B),
		RSL_MT_EST_REQ		('00000100'B),
		RSL_MT_EST_CONF		('00000101'B),
		RSL_MT_EST_IND		('00000110'B),
		RSL_MT_REL_REQ		('00000111'B),
		RSL_MT_REL_CONF		('00001000'B),
		RSL_MT_REL_IND		('00001001'B),
		RSL_MT_UNIT_DATA_REQ	('00001010'B),
		RSL_MT_UNIT_DATA_IND	('00001011'B),

		/* non-standard below */
		RSL_MT_SUSP_REQ		('00001100'B),
		RSL_MT_SUSP_CONF	('00001101'B),
		RSL_MT_RES_REQ		('00001110'B),
		RSL_MT_RECON_REQ	('00001111'B),

		/* Common Channel Management / TRX Management */
		RSL_MT_BCCH_INFO	('00010001'B),
		RSL_MT_CCCH_LOAD_IND	('00010010'B),
		RSL_MT_CHAN_RQD		('00010011'B),
		RSL_MT_DELETE_IND	('00010100'B),
		RSL_MT_PAGING_CMD	('00010101'B),
		RSL_MT_IMMEDIATE_ASSIGN_CMD ('00010110'B),
		RSL_MT_SMS_BC_REQ	('00010111'B),
		RSL_MT_CHAN_CONF	('00011000'B),	/* non-standard element */
		/* empty */
		RSL_MT_RF_RES_IND	('00011001'B),
		RSL_MT_SACCH_FILL	('00011010'B),
		RSL_MT_OVERLOAD		('00011011'B),
		RSL_MT_ERROR_REPORT	('00011100'B),
		RSL_MT_SMS_BC_CMD	('00011101'B),
		RSL_MT_CBCH_LOAD_IND	('00011110'B),
		RSL_MT_NOT_CMD		('00011111'B),

		/* Dedicate Channel Management */
		RSL_MT_CHAN_ACTIV	('00100001'B),
		RSL_MT_CHAN_ACTIV_ACK	('00100010'B),
		RSL_MT_CHAN_ACTIV_NACK	('00100011'B),
		RSL_MT_CONN_FAIL	('00100100'B),
		RSL_MT_DEACTIVATE_SACCH	('00100101'B),
		RSL_MT_ENCR_CMD		('00100110'B),
		RSL_MT_HANDO_DET	('00100111'B),
		RSL_MT_MEAS_RES		('00101000'B),
		RSL_MT_MODE_MODIFY_REQ	('00101001'B),
		RSL_MT_MODE_MODIFY_ACK	('00101010'B),
		RSL_MT_MODE_MODIFY_NACK	('00101011'B),
		RSL_MT_PHY_CONTEXT_REQ	('00101100'B),
		RSL_MT_PHY_CONTEXT_CONF	('00101101'B),
		RSL_MT_RF_CHAN_REL	('00101110'B),
		RSL_MT_MS_POWER_CONTROL ('00101111'B),
		RSL_MT_BS_POWER_CONTROL	('00110000'B),		/* 0x30 */
		RSL_MT_PREPROC_CONFIG	('00110001'B),
		RSL_MT_PREPROC_MEAS_RES	('00110010'B),
		RSL_MT_RF_CHAN_REL_ACK	('00110011'B),
		RSL_MT_SACCH_INFO_MODIFY('00110100'B),
		RSL_MT_TALKER_DET	('00110101'B),
		RSL_MT_LISTENER_DET	('00110110'B),
		RSL_MT_REMOTE_CODEC_CONF_REP ('00110111'B),
		RSL_MT_RTD_REP		('00111000'B),
		RSL_MT_PRE_HANDO_NOTIF	('00111001'B),
		RSL_MT_MR_CODEC_MOD_REQ	('00111010'B),
		RSL_MT_MR_CODEC_MOD_ACK	('00111011'B),
		RSL_MT_MR_CODEC_MOD_NACK ('00111100'B),
		RSL_MT_MR_CODEC_MOD_PER	('00111101'B),
		RSL_MT_TFO_REP		('00111110'B),
		RSL_MT_TFO_MOD_REQ	('00111111'B),		/* 0x3f */

		RSL_MT_LOCATION_INFO		('01000001'B),

		/* ip.access specific RSL message types */
		RSL_MT_IPAC_DIR_RETR_ENQ	('01000000'B),

		RSL_MT_IPAC_PDCH_ACT		('01001000'B),
		RSL_MT_IPAC_PDCH_ACT_ACK	('01001001'B),
		RSL_MT_IPAC_PDCH_ACT_NACK	('01001010'B),
		RSL_MT_IPAC_PDCH_DEACT		('01001011'B),
		RSL_MT_IPAC_PDCH_DEACT_ACK	('01001100'B),
		RSL_MT_IPAC_PDCH_DEACT_NACK	('01001101'B),

		RSL_MT_IPAC_CONNECT_MUX		('01010000'B),
		RSL_MT_IPAC_CONNECT_MUX_ACK	('01010001'B),
		RSL_MT_IPAC_CONNECT_MUX_NACK	('01010010'B),
		RSL_MT_IPAC_BIND_MUX		('01010011'B),
		RSL_MT_IPAC_BIND_MUX_ACK	('01010100'B),
		RSL_MT_IPAC_BIND_MUX_NACK	('01010101'B),
		RSL_MT_IPAC_DISC_MUX		('01010110'B),
		RSL_MT_IPAC_DISC_MUX_ACK	('01010111'B),
		RSL_MT_IPAC_DISC_MUX_NACK	('01011000'B),
		RSL_MT_IPAC_MEAS_PREPROC_DFT 	('01100000'B),
		RSL_MT_IPAC_HO_CAN_ENQ		('01100001'B),
		RSL_MT_IPAC_HO_CAN_RES		('01100010'B),
		RSL_MT_IPAC_CRCX		('01110000'B),
		RSL_MT_IPAC_CRCX_ACK		('01110001'B),
		RSL_MT_IPAC_CRCX_NACK		('01110010'B),
		RSL_MT_IPAC_MDCX		('01110011'B),
		RSL_MT_IPAC_MDCX_ACK		('01110100'B),
		RSL_MT_IPAC_MDCX_NACK		('01110101'B),
		RSL_MT_IPAC_DLCX_IND		('01110110'B),
		RSL_MT_IPAC_DLCX		('01110111'B),
		RSL_MT_IPAC_DLCX_ACK		('01111000'B),
		RSL_MT_IPAC_DLCX_NACK		('01111001'B),

		RSL_MT_OSMO_ETWS_CMD		('01111111'B)
	} with { variant "FIELDLENGTH(8)" };

	/*! RSL Information Element Identifiers (Chapter 9.3) */
	type enumerated RSL_IE_Type {
		RSL_IE_CHAN_NR			('00000001'B),
		RSL_IE_LINK_IDENT		('00000010'B),
		RSL_IE_ACT_TYPE			('00000011'B),
		RSL_IE_BS_POWER			('00000100'B),
		RSL_IE_CHAN_IDENT		('00000101'B),
		RSL_IE_CHAN_MODE		('00000110'B),
		RSL_IE_ENCR_INFO		('00000111'B),
		RSL_IE_FRAME_NUMBER		('00001000'B),
		RSL_IE_HANDO_REF		('00001001'B),
		RSL_IE_L1_INFO			('00001010'B),
		RSL_IE_L3_INFO			('00001011'B),
		RSL_IE_MS_IDENTITY		('00001100'B),
		RSL_IE_MS_POWER			('00001101'B),
		RSL_IE_PAGING_GROUP		('00001110'B),
		RSL_IE_PAGING_LOAD		('00001111'B),
		RSL_IE_PYHS_CONTEXT		('00010000'B),
		RSL_IE_ACCESS_DELAY		('00010001'B),
		RSL_IE_RACH_LOAD		('00010010'B),
		RSL_IE_REQ_REFERENCE		('00010011'B),
		RSL_IE_RELEASE_MODE		('00010100'B),
		RSL_IE_RESOURCE_INFO		('00010101'B),
		RSL_IE_RLM_CAUSE		('00010110'B),
		RSL_IE_STARTNG_TIME		('00010111'B),
		RSL_IE_TIMING_ADVANCE		('00011000'B),
		RSL_IE_UPLINK_MEAS		('00011001'B),
		RSL_IE_CAUSE			('00011010'B),
		RSL_IE_MEAS_RES_NR		('00011011'B),
		RSL_IE_MSG_ID			('00011100'B),
		/* reserved */
		RSL_IE_SYSINFO_TYPE		('00011110'B),
		RSL_IE_MS_POWER_PARAM		('00011111'B),
		RSL_IE_BS_POWER_PARAM		('00100000'B),
		RSL_IE_PREPROC_PARAM		('00100001'B),
		RSL_IE_PREPROC_MEAS		('00100010'B),
		RSL_IE_IMM_ASS_INFO		('00100011'B),/* Phase 1 (3.6.0), later Full below */
		RSL_IE_SMSCB_INFO		('00100100'B),
		RSL_IE_MS_TIMING_OFFSET		('00100101'B),
		RSL_IE_ERR_MSG			('00100110'B),
		RSL_IE_FULL_BCCH_INFO		('00100111'B),
		RSL_IE_CHAN_NEEDED		('00101000'B),
		RSL_IE_CB_CMD_TYPE		('00101001'B),
		RSL_IE_SMSCB_MSG		('00101010'B),
		RSL_IE_FULL_IMM_ASS_INFO	('00101011'B),
		RSL_IE_SACCH_INFO		('00101100'B),
		RSL_IE_CBCH_LOAD_INFO		('00101101'B),
		RSL_IE_SMSCB_CHAN_INDICATOR	('00101110'B),
		RSL_IE_GROUP_CALL_REF		('00101111'B),
		RSL_IE_GROUP_CHAN_DESC		('00110000'B),
		RSL_IE_NCH_DRX_INFO		('00110001'B),
		RSL_IE_CMD_INDICATOR		('00110010'B),
		RSL_IE_EMLPP_PRIO		('00110011'B),
		RSL_IE_UIC			('00110100'B),
		RSL_IE_MAIN_CHAN_REF		('00110101'B),
		RSL_IE_MR_CONFIG		('00110110'B),
		RSL_IE_MR_CONTROL		('00110111'B),
		RSL_IE_SUP_CODEC_TYPES		('00111000'B),
		RSL_IE_CODEC_CONFIG		('00111001'B),
		RSL_IE_RTD			('00111010'B),
		RSL_IE_TFO_STATUS		('00111011'B),
		RSL_IE_LLP_APDU			('00111100'B),

		/* Osmocom extensions */
		RSL_IE_OSMO_REP_ACCH_CAP	('01100000'B),
		RSL_IE_OSMO_TRAINING_SEQUENCE	('01100001'B),
		RSL_IE_OSMO_TOP_ACCH_CAP	('01100010'B),
		RSL_IE_OSMO_OSMUX_CID		('01100011'B),

		/* ip.access */
		RSL_IE_IPAC_SRTP_CONFIG		('11100000'B),
		RSL_IE_IPAC_PROXY_UDP		('11100001'B),
		RSL_IE_IPAC_BSCMPL_TOUT		('11100010'B),

		RSL_IE_IPAC_REMOTE_IP		('11110000'B),
		RSL_IE_IPAC_REMOTE_PORT		('11110001'B),
		RSL_IE_IPAC_RTP_PAYLOAD		('11110010'B),
		RSL_IE_IPAC_LOCAL_PORT		('11110011'B),
		RSL_IE_IPAC_SPEECH_MODE		('11110100'B),
		RSL_IE_IPAC_LOCAL_IP		('11110101'B),
		RSL_IE_IPAC_CONN_STAT		('11110110'B),
		RSL_IE_IPAC_HO_C_PARMS		('11110111'B),
		RSL_IE_IPAC_CONN_ID		('11111000'B),
		RSL_IE_IPAC_RTP_CSD_FMT		('11111001'B),
		RSL_IE_IPAC_RTP_JIT_BUF		('11111010'B),
		RSL_IE_IPAC_RTP_COMPR		('11111011'B),
		RSL_IE_IPAC_RTP_PAYLOAD2	('11111100'B),
		RSL_IE_IPAC_RTP_MPLEX		('11111101'B),
		RSL_IE_IPAC_RTP_MPLEX_ID	('11111110'B)
	} with { variant "FIELDLENGTH(8)" };

	type record RSL_LV {
		uint8_t		len,
		octetstring	payload
	} with { variant (len) "LENGTHTO(payload)" }

	template (value) RSL_LV ts_RSL_LV(template (value) octetstring pl) := {
		len := 0,
		payload := pl
	}

	template RSL_LV tr_RSL_LV(template octetstring pl) := {
		len := ?,
		payload := pl
	}

	type record RSL_L16V {
		uint16_t	len,
		octetstring	payload
	} with { variant (len) "LENGTHTO(payload)" }

	template (value) RSL_L16V ts_RSL_L16V(template (value) octetstring pl) := {
		len := 0,
		payload := pl
	}

	template RSL_L16V tr_RSL_L16V(template octetstring pl) := {
		len := ?,
		payload := pl
	}

	type record RSL_IE_V {
		uint8_t		val
	}

	/* 9.3.3 */
	type record RSL_IE_ActivationType {
		boolean		reactivation,
		uint4_t		reserved,
		RSL_ActivationAbits a_bits
	};
	type enumerated RSL_ActivationAbits {
		ACT_REL_TO_IMM_ASSIGN		('000'B),
		ACT_REL_TO_NORM_ASSIGN		('001'B),
		ACT_REL_TO_ASYNC_HANDOVER	('010'B),
		ACT_REL_TO_SYNC_HANDOVER	('011'B),
		ACT_REL_TO_ADDL_ASSIGN		('100'B),
		ACT_REL_TO_MSLOT_CONFIG		('101'B),
		ACT_REL_TO_OSMO_PDCH		('111'B)
	} with { variant "FIELDLENGTH(3)" };

	const RSL_IE_ActivationType t_RSL_IE_ActType_IA := {
		reactivation := false,
		reserved := 0,
		a_bits := ACT_REL_TO_IMM_ASSIGN
	}
	const RSL_IE_ActivationType t_RSL_IE_ActType_ASS := {
		reactivation := false,
		reserved := 0,
		a_bits := ACT_REL_TO_NORM_ASSIGN
	}
	const RSL_IE_ActivationType t_RSL_IE_ActType_HO_ASYNC := {
		reactivation := false,
		reserved := 0,
		a_bits := ACT_REL_TO_ASYNC_HANDOVER
	}
	const RSL_IE_ActivationType t_RSL_IE_ActType_HO_SYNC := {
		reactivation := false,
		reserved := 0,
		a_bits := ACT_REL_TO_SYNC_HANDOVER
	}

	/* osmocom-style dynamic PDCH */
	const RSL_IE_ActivationType c_RSL_IE_ActType_PDCH := {
		reactivation := false,
		reserved := 1,
		a_bits := ACT_REL_TO_OSMO_PDCH
	}

	/* 9.3.5 */
	type record RSL_IE_ChannelIdent {
		uint8_t			len,
		/* 3GPP TS 44.018 Channel Description IE (TV) */
		ChannelDescriptionTV	ch_desc,
		/* 3GPP TS 44.018 Mobile Allocation IE (shall be empty) */
		MobileAllocationTLV	ma
	} with { variant (len) "LENGTHTO(ch_desc,ma)" };

	template (value) RSL_IE_ChannelIdent
	ts_RSL_ChannelIdent(template (value) ChannelDescription ch_desc) := {
		len := 0, /* overwritten */
		ch_desc := {
			iei := '64'O,
			v := ch_desc
		},
		/* Shall be included but empty */
		ma := {
			iei := '72'O,
			v := {
				len := 0,
				ma := ''B
			}
		}
	};

	template RSL_IE_ChannelIdent
	tr_RSL_ChannelIdent(template (present) ChannelDescription ch_desc := ?,
			    template (present) MobileAllocationLV ma := ?) := {
		len := ?,
		ch_desc := {
			iei := '64'O,
			v := ch_desc
		},
		/* Shall be included but empty */
		ma := {
			iei := '72'O,
			v := ma
		}
	};

	/* 9.3.6 */
	type enumerated RSL_SpeechDataInd {
		RSL_SPDI_SPEECH		('00000001'B),
		RSL_SPDI_DATA		('00000010'B),
		RSL_SPDI_SIGN		('00000011'B)
	} with { variant "FIELDLENGTH(8)" };
	type enumerated RSL_ChanRateType {
		RSL_CHRT_SDCCH		('00000001'B),
		RSL_CHRT_TCH_F		('00001000'B),
		RSL_CHRT_TCH_H		('00001001'B),
		RSL_CHRT_TCH_F_BD_MSLOT	('00001010'B),
		RSL_CHRT_TCH_F_DL_MSLOT	('00011010'B),
		RSL_CHRT_TCH_F_GROUP	('00011000'B),
		RSL_CHRT_TCH_H_GROUP	('00011001'B),
		RSL_CHRT_TCH_F_BCAST	('00101000'B),
		RSL_CHRT_TCH_H_BCAST	('00101001'B),
		RSL_CHRT_OSMO_TCH_F_VAMOS	('10001000'B),
		RSL_CHRT_OSMO_TCH_H_VAMOS	('10001001'B)
	} with { variant "FIELDLENGTH(8)" };
	type enumerated RSL_ChanModeOct6Signalling {
		RSL_CMOD_NO_RESOURCE	('00000000'B)
	} with { variant "FIELDLENGTH(8)" };
	type enumerated RSL_ChanModeOct6SpeechAlgo {
		RSL_CMOD_SP_GSM1	('00000001'B),
		RSL_CMOD_SP_GSM2	('00010001'B),
		RSL_CMOD_SP_GSM3	('00100001'B),
		RSL_CMOD_SP_GSM4	('00110001'B),
		RSL_CMOD_SP_GSM5	('00001001'B),
		RSL_CMOD_SP_GSM6	('00001101'B)
	} with { variant "FIELDLENGTH(8)" };
	type enumerated RSL_ChanModeOct6DataRate {
		RSL_CMOD_CSD_NTA_43k5_14k5	('01100001'B),
		RSL_CMOD_CSD_NTA_29k0_14k5	('01100010'B),
		RSL_CMOD_CSD_NTA_43k5_29k0	('01100011'B),
		RSL_CMOD_CSD_NTA_14k5_43k5	('01101001'B),
		RSL_CMOD_CSD_NTA_14k5_29k0	('01101010'B),
		RSL_CMOD_CSD_NTA_29k0_43k5	('01101011'B),
		RSL_CMOD_CSD_NT_43k5		('01110100'B),
		RSL_CMOD_CSD_NT_28k8		('01110001'B),
		RSL_CMOD_CSD_NT_14k5		('01011000'B),
		RSL_CMOD_CSD_NT_12k0		('01010000'B),
		RSL_CMOD_CSD_NT_6k0		('01010001'B),
		RSL_CMOD_CSD_T_32k0		('00111000'B),
		RSL_CMOD_CSD_T_29k0		('00111001'B),
		RSL_CMOD_CSD_T_14k4		('00011000'B),
		RSL_CMOD_CSD_T_9k6		('00010000'B),
		RSL_CMOD_CSD_T_4k8		('00010001'B),
		RSL_CMOD_CSD_T_2k4		('00010010'B),
		RSL_CMOD_CSD_T_1k2		('00010011'B),
		RSL_CMOD_CSD_T_600		('00010100'B),
		RSL_CMOD_CSD_T_1200_75		('00010101'B)
	} with { variant "FIELDLENGTH(8)" };
	type union RSL_ChanModeOct6 {
		RSL_ChanModeOct6Signalling sign,
		RSL_ChanModeOct6SpeechAlgo speech,
		RSL_ChanModeOct6DataRate data
	};
	type record RSL_IE_ChannelMode {
		uint8_t		len,
		BIT6		reserved,
		boolean		dtx_d,
		boolean		dtx_u,
		RSL_SpeechDataInd spd_ind,
		RSL_ChanRateType  ch_rate_type,
		RSL_ChanModeOct6  u
	} with { variant (len) "LENGTHTO(reserved,dtx_d,dtx_u,spd_ind,ch_rate_type,u)"
		 variant (u) "CROSSTAG(
				sign, spd_ind = RSL_SPDI_SIGN;
				speech, spd_ind = RSL_SPDI_SPEECH;
				data, spd_ind = RSL_SPDI_DATA;
			      )"}

	template (value) RSL_IE_ChannelMode
	ts_RSL_ChanMode_SIGN(template (value) RSL_ChanRateType t := RSL_CHRT_SDCCH,
			     template (value) boolean dtxd := false,
			     template (value) boolean dtxu := false) := {
		len := 0,	/* overwritten */
		reserved := '000000'B,
		dtx_d := dtxd,
		dtx_u := dtxu,
		spd_ind := RSL_SPDI_SIGN,
		ch_rate_type := t,
		u := { sign := RSL_CMOD_NO_RESOURCE }
	}
	template RSL_IE_ChannelMode
	tr_RSL_ChanMode_SIGN(template (present) RSL_ChanRateType t := ?,
			     template (present) boolean dtxd := ?,
			     template (present) boolean dtxu := ?) := {
		len := ?,
		reserved := ?,
		dtx_d := dtxd,
		dtx_u := dtxu,
		spd_ind := RSL_SPDI_SIGN,
		ch_rate_type := t,
		u := { sign := RSL_CMOD_NO_RESOURCE }
	}

	template (value) RSL_IE_ChannelMode
	ts_RSL_ChanMode_DATA(template (value) RSL_ChanRateType t,
			     template (value) RSL_ChanModeOct6DataRate r,
			     template (value) boolean dtxd := false,
			     template (value) boolean dtxu := false) := {
		len := 0,	/* overwritten */
		reserved := '000000'B,
		dtx_d := dtxd,
		dtx_u := dtxu,
		spd_ind := RSL_SPDI_DATA,
		ch_rate_type := t,
		u := { data := r }
	}
	template RSL_IE_ChannelMode
	tr_RSL_ChanMode_DATA(template (present) RSL_ChanRateType t := ?,
			     template (present) RSL_ChanModeOct6DataRate r := ?,
			     template (present) boolean dtxd := ?,
			     template (present) boolean dtxu := ?) := {
		len := ?,
		reserved := ?,
		dtx_d := dtxd,
		dtx_u := dtxu,
		spd_ind := RSL_SPDI_DATA,
		ch_rate_type := t,
		u := { data := r }
	}

	template (value) RSL_IE_ChannelMode ts_RSL_ChanMode(RSL_ChanRateType t, RSL_ChanModeOct6SpeechAlgo alg,
							    boolean dtx_downlink := false) := {
		len := 0,	/* overwritten */
		reserved := '000000'B,
		dtx_d := dtx_downlink,
		dtx_u := false,
		spd_ind := RSL_SPDI_SPEECH,
		ch_rate_type := t,
		u := { speech := alg }
	}
	template RSL_IE_ChannelMode tr_RSL_ChanMode(template RSL_ChanRateType t,
						    template RSL_ChanModeOct6SpeechAlgo alg) := {
		len := ?,
		reserved := '000000'B,
		dtx_d := ?,
		dtx_u := ?,
		spd_ind := RSL_SPDI_SPEECH,
		ch_rate_type := t,
		u := { speech := alg }
	}

	/* 9.3.4 BS Power IE */
	type record RSL_IE_BS_Power {
		uint2_t 	reserved,
		boolean		epc,
		boolean		fpc,
		uint4_t		power_level
	}

	template (value) RSL_IE_BS_Power ts_RSL_IE_BS_Power(uint4_t power_level,
							    boolean epc := false, boolean fpc := false) := {
		reserved := 0,
		epc := epc,
		fpc := fpc,
		power_level := power_level
	}
	template RSL_IE_BS_Power
	tr_RSL_IE_BS_Power(template (present) uint4_t power_level,
			   template (present) boolean epc := ?,
			   template (present) boolean fpc := ?) := {
		reserved := ?,
		epc := epc,
		fpc := fpc,
		power_level := power_level
	}

	/* 9.3.7 */
	type enumerated RSL_AlgId {
		RSL_ALG_ID_A5_0 ('00000001'B),
		RSL_ALG_ID_A5_1 ('00000010'B),
		RSL_ALG_ID_A5_2 ('00000011'B),
		RSL_ALG_ID_A5_3 ('00000100'B),
		RSL_ALG_ID_A5_4 ('00000101'B),
		RSL_ALG_ID_A5_5 ('00000110'B),
		RSL_ALG_ID_A5_6 ('00000111'B),
		RSL_ALG_ID_A5_7 ('00001000'B)
	} with { variant "FIELDLENGTH(8)" };
	type record RSL_IE_EncryptionInfo {
		uint8_t		len,
		RSL_AlgId	alg_id,
		octetstring	key
	} with { variant (len) "LENGTHTO(alg_id,key)" };

	template RSL_IE_EncryptionInfo tr_RSL_IE_EncrInfo(template RSL_AlgId alg,
							  template octetstring key) := {
		len := ?,
		alg_id := alg,
		key := key
	}
	template (value) RSL_IE_EncryptionInfo ts_RSL_IE_EncrInfo(template (value) RSL_AlgId alg,
								  octetstring key) := {
		len := 0, /* overwritten */
		alg_id := alg,
		key := key
	}



	/* 9.3.8 */
	type record RSL_IE_FrameNumber {
		uint5_t		t1_p,
		uint6_t		t3,
		uint5_t		t2
	}
	type RSL_IE_FrameNumber RSL_IE_StartingTime;

	/* 9.3.10 */
	type record RSL_IE_L1Info {
		uint5_t		ms_power_lvl,
		boolean		fpc,
		uint2_t		reserved,
		uint8_t		actual_ta
	}

	template (value) RSL_IE_L1Info ts_RSL_IE_L1Info := {
		ms_power_lvl := 0,
		fpc := false,
		reserved := 0,
		actual_ta := 0
	};

	/* 9.3.13 */
	type record RSL_IE_MS_Power {
		uint2_t		reserved,
		boolean		fpc_epc,
		uint5_t		power_level
	}
	template RSL_IE_MS_Power tr_RSL_IE_MS_Power(template uint5_t power_level := ?,
							    template boolean fpc_epc := false) := {
		reserved := 0,
		fpc_epc := fpc_epc,
		power_level := power_level
	}
	template (value) RSL_IE_MS_Power ts_RSL_IE_MS_Power(uint5_t power_level,
							    boolean fpc_epc := false) := {
		reserved := 0,
		fpc_epc := fpc_epc,
		power_level := power_level
	}

	/* 9.3.18 */
	type record RSL_IE_RachLoad {
		uint8_t		len,
		uint16_t	slot_count,
		uint16_t	busy_count,
		uint16_t	access_count
	} with { variant (len) "LENGTHTO(slot_count,busy_count,access_count)" }

	template (value) RSL_IE_RachLoad ts_RSL_IE_RachLoad(uint16_t slot, uint16_t busy, uint16_t acc) := {
		len := 0, /* overwritten */
		slot_count := slot,
		busy_count := busy,
		access_count := acc
	}

	template RSL_IE_RachLoad tr_RSL_IE_RachLoad(template uint16_t slot,
						    template uint16_t busy,
						    template uint16_t acc) := {
		len := ?, /* overwritten */
		slot_count := slot,
		busy_count := busy,
		access_count := acc
	}

	/* 9.3.19 */
	type record RSL_IE_RequestRef {
		OCT1		ra,
		RSL_IE_FrameNumber frame_nr
	}

	/* 3GPP TS 44.018 / 10.5.2.38 Starting Time */
	template (value) RSL_IE_FrameNumber ts_RSL_IE_FrameNumber(GsmFrameNumber fn) := {
		t1_p := (fn / 1326) mod 32,
		t3 := fn mod 51,
		t2 := fn mod 26
	}

	function tr_RSL_IE_FrameNumber(template GsmFrameNumber fn) return template RSL_IE_FrameNumber {
		if (istemplatekind(fn, "?")) {
			return ?;
		} else {
			return ts_RSL_IE_FrameNumber(valueof(fn));
		}
	}

	template (value) RSL_IE_RequestRef ts_RSL_IE_ReqRef(OCT1 ra, GsmFrameNumber frame_nr) := {
		ra := ra,
		frame_nr := ts_RSL_IE_FrameNumber(frame_nr)
	}

	template RSL_IE_RequestRef tr_RSL_IE_ReqRef(template OCT1 ra, template GsmFrameNumber frame_nr) := {
		ra := ra,
		frame_nr := tr_RSL_IE_FrameNumber(frame_nr)
	}

	/* 9.3.21 Resource Information */
	type record RSL_IE_ResourceInfo {
		uint8_t len,
		RSL_ResourceInfo info
	} with { variant (len) "LENGTHTO(info)" };

	type record of RSL_ResourceInfoItem RSL_ResourceInfo;
	type record RSL_ResourceInfoItem {
		RslChannelNr chan_nr,
		uint3_t interf_band,
		BIT5 rfu ('00000'B)
	};

	template (value) RSL_ResourceInfoItem
	ts_RSL_ResourceInfoItem(template (value) RslChannelNr chan_nr,
				template (value) uint3_t interf_band := 0) := {
		chan_nr := chan_nr,
		interf_band := interf_band,
		rfu := '00000'B
	}
	template RSL_ResourceInfoItem
	tr_RSL_ResourceInfoItem(template (present) RslChannelNr chan_nr := ?,
				template (present) uint3_t interf_band := ?) := {
		chan_nr := chan_nr,
		interf_band := interf_band,
		rfu := ? /* Tolerate unknown values */
	}

	/* Osmocom Extension */
	type record RSL_IE_UplinkMeasSuppMeasInfo {
		int16_t toa256_mean,
		int16_t toa256_min,
		int16_t toa256_max,
		uint16_t toa256_std_dev
	};

	/* 9.3.25 */
	type record RSL_IE_UplinkMeas {
		uint8_t len,
		BIT1 rfu,
		boolean dtx_d,
		uint6_t rxlev_f_u,
		BIT2 reserved1,
		uint6_t rxlev_s_u,
		BIT2 reserved2,
		uint3_t rxq_f_u,
		uint3_t rxq_s_u,
		RSL_IE_UplinkMeasSuppMeasInfo supp_meas_info optional
	} with { variant (len) "LENGTHTO(rfu,dtx_d,rxlev_f_u,reserved1,rxlev_s_u,reserved2,rxq_f_u,rxq_s_u,supp_meas_info)" };

	template (value) RSL_IE_UplinkMeas ts_RSL_IE_UplinkMeas(uint6_t rxlev := 12, uint3_t rxqual := 0) := {
		len := 0, /* overwritten */
		rfu := '0'B,
		dtx_d := false,
		rxlev_f_u := rxlev,
		reserved1 := '00'B,
		rxlev_s_u := rxlev,
		reserved2 := '00'B,
		rxq_f_u := rxqual,
		rxq_s_u := rxqual,
		supp_meas_info := omit
	};

	/* 9.3.26 */
	type enumerated RSL_Cause {
		/* normal event */
		RSL_ERR_RADIO_IF_FAIL		('00'O),
		RSL_ERR_RADIO_LINK_FAIL		('01'O),
		RSL_ERR_HANDOVER_ACC_FAIL	('02'O),
		RSL_ERR_TALKER_ACC_FAIL		('03'O),
		RSL_ERR_OM_INTERVENTION		('07'O),
		RSL_ERR_NORMAL_UNSPEC		('0f'O),
		RSL_ERR_T_MSRFPCI_EXP		('18'O),
		/* resource unavailable */
		RSL_ERR_EQUIPMENT_FAIL		('20'O),
		RSL_ERR_RR_UNAVAIL		('21'O),
		RSL_ERR_TERR_CH_FAIL		('22'O),
		RSL_ERR_CCCH_OVERLOAD		('23'O),
		RSL_ERR_ACCH_OVERLOAD		('24'O),
		RSL_ERR_PROCESSOR_OVERLOAD	('25'O),
		RSL_ERR_BTS_NOT_EQUIPPED	('27'O),
		RSL_ERR_REMOTE_TRAU_FAILURE	('28'O),
		RSL_ERR_NOTIF_OVERFLOW		('29'O),
		RSL_ERR_RES_UNAVAIL		('2f'O),
		/* service or option not available */
		RSL_ERR_TRANSC_UNAVAIL		('30'O),
		RSL_ERR_SERV_OPT_UNAVAIL	('3f'O),
		/* service or option not implemented */
		RSL_ERR_ENCR_UNIMPL		('40'O),
		RSL_ERR_SERV_OPT_UNIMPL		('4f'O),
		/* invalid message */
		RSL_ERR_RCH_ALR_ACTV_ALLOC	('50'O),
		RSL_ERR_IPA_RCH_NOT_ACTV_ALLOC	('51'O),
		RSL_ERR_IPA_CONN_INVALID	('52'O),
		RSL_ERR_IPA_CONN_IN_USE		('53'O),
		RSL_ERR_IPA_CONN_ALREADY_EXISTS	('54'O),
		RSL_ERR_INVALID_MESSAGE		('5f'O),
		/* protocol error */
		RSL_ERR_MSG_DISCR		('60'O),
		RSL_ERR_MSG_TYPE		('61'O),
		RSL_ERR_MSG_SEQ			('62'O),
		RSL_ERR_IE_ERROR		('63'O),
		RSL_ERR_MAND_IE_ERROR		('64'O),
		RSL_ERR_OPT_IE_ERROR		('65'O),
		RSL_ERR_IE_NONEXIST		('66'O),
		RSL_ERR_IE_LENGTH		('67'O),
		RSL_ERR_IE_CONTENT		('68'O),
		RSL_ERR_PROTO			('6f'O),
		/* interworking */
		RSL_ERR_INTERWORKING		('7f'O)
	};
	type record RSL_IE_Cause {
		uint8_t		len,
		uint1_t		e,
		RSL_Cause	cause,
		octetstring	cause_ext optional
	} with { variant (len) "LENGTHTO(e,cause,cause_ext)" }

	template (value) RSL_IE_Cause ts_RSL_IE_Cause(RSL_Cause cause) := {
		len := 0, /* overwritten */
		e := 0,
		cause := cause,
		cause_ext := omit
	}

	template RSL_IE_Cause tr_RSL_IE_Cause(template RSL_Cause cause) := {
		len := ?,
		e := 0,
		cause := cause,
		cause_ext := omit
	}

	/* 9.3.29 */
	type record RSL_SacchInfo {
		uint8_t len,
		uint8_t num_msgs,
		RSL_SacchInfoElements elems
	} with {
		variant (len) "LENGTHTO(num_msgs,elems)";
		variant (num_msgs) "LENGTHTO(elems)";
		variant (num_msgs) "UNIT(elements)"
	};
	type record RSL_SacchInfoElement {
		RSL_IE_SysinfoType si_type,
		uint8_t len,
		octetstring msg
	} with {
		variant (len) "LENGTHTO(msg)";
	};
	type record of RSL_SacchInfoElement RSL_SacchInfoElements;
	template (value) RSL_SacchInfo ts_RSL_SacchInfo(template (value) RSL_SacchInfoElements elems) := {
		len := 0, /* overwritten */
		num_msgs := 0, /* overwritten */
		elems := elems
	}
	template (value) RSL_SacchInfoElement ts_RSL_SacchInfoElem(RSL_IE_SysinfoType tp, octetstring msg) := {
		si_type := tp,
		len := lengthof(msg),
		msg := msg
	}

	/* 9.3.31 */
	type record RSL_IE_MS_Power_Parameters {
		uint8_t len,
		octetstring params
	} with {
		variant (len) "LENGTHTO(params)";
	};
	template (value) RSL_IE_MS_Power_Parameters ts_RSL_IE_MS_Power_Parameters(octetstring params) := {
		len := 0, /* overwritten */
		params := params
	}

	/* 9.3.40 */
	type enumerated RSL_ChanNeeded {
		RSL_CHANNEED_ANY	('00'B),
		RSL_CHANNEED_SDCCH	('01'B),
		RSL_CHANNEED_TCH_F	('10'B),
		RSL_CHANNEED_TCH_ForH	('11'B)
	} with { variant "FIELDLENGTH(2)" };
	type record RSL_IE_ChanNeeded {
		uint6_t		reserved,
		RSL_ChanNeeded	chan_needed
	}

	/* 9.3.41 CB Command Type */
	type enumerated RSL_CbCommand {
		RSL_CB_CMD_NORMAL	('0000'B),
		RSL_CB_CMD_SCHEDULE	('1000'B),
		RSL_CB_CMD_DEFAULT	('1110'B),
		RSL_CB_CMD_NULL		('1111'B)
	} with { variant "FIELDLENGTH(4)" };
	type record RSL_IE_CbCommandType {
		RSL_CbCommand	command,
		boolean		default_bcast_null,
		BIT1		spare,
		uint2_t		last_block
	};
	template (value) RSL_IE_CbCommandType ts_RSL_IE_CbCmdType(RSL_CbCommand cmd := RSL_CB_CMD_NORMAL,
								  uint2_t last_block := 1,
								  boolean def_bcast_null := true) := {
		command := cmd,
		default_bcast_null := def_bcast_null,
		spare := '0'B,
		last_block := last_block
	}

	/* 9.4.43 CBCH Load Information */
	type record RSL_IE_CbchLoadInfo {
		boolean		overflow,
		BIT3		spare,
		uint4_t		slot_count
	};
	template RSL_IE_CbchLoadInfo tr_CbchLoadInfo(template boolean overflow,
					    template uint4_t slot_count) := {
		overflow := overflow,
		spare := ?,
		slot_count := slot_count
	}
	template (value) RSL_IE_CbchLoadInfo ts_CbchLoadInfo(boolean overflow, uint4_t slot_count) := {
		overflow := overflow,
		spare := '000'B,
		slot_count := slot_count
	}

	/* 9.3.45 Group Call Reference */
	type record RSL_IE_GroupCallReference {
		uint8_t		len,
		GroupCallRef	group_or_bcast_call_ref
	} with {
		variant (len) "LENGTHTO(group_or_bcast_call_ref)"
	};
	template (value) RSL_IE_GroupCallReference ts_GroupCallRef(template (value) GroupCallRef gcr) := {
		len := 0, // overwritten
		group_or_bcast_call_ref := gcr
	}
	template (present) RSL_IE_GroupCallReference tr_GroupCallRef(template (present) GroupCallRef gcr := ?) := {
		len := ?,
		group_or_bcast_call_ref := gcr
	}

	/* 9.3.46 Channel description */
	type record RSL_IE_GroupChannelDescription {
		uint8_t 	len,
		octetstring 	chan_desc
	} with {
		variant (len) "LENGTHTO(chan_desc)"
	};
	template (value) RSL_IE_GroupChannelDescription ts_GroupChanDesc(template (value) octetstring cd) := {
		len := 0, // overwritten
		chan_desc := cd
	}
	template (present) RSL_IE_GroupChannelDescription tr_GroupChanDesc(template (present) octetstring cd) := {
		len := ?,
		chan_desc := cd
	}

	/* 9.3.47 NCH DRX Information */
	type record RSL_IE_NchDrxInformation {
		uint8_t 	len,
		BIT2		spare,
		BIT1		nln_status,
		BIT3		emlpp_priority,
		BIT2		nln
	} with {
		variant (len) "LENGTHTO(spare,nln_status,emlpp_priority,nln)"
	};

	/* 9.3.48 Command Indicator */
	type enumerated RSL_CommandIndicator {
		CMD_IND_START		(0),
		CMD_IND_STOP		(1)
	} with { variant "FIELDLENGTH(8)" };
	type record RSL_IE_CommandIndicator {
		uint8_t			len,
		RSL_CommandIndicator	command_value
	} with {
		variant (len) "LENGTHTO(command_value)"
	};
	template (value) RSL_IE_CommandIndicator ts_CommandInd(template (value) RSL_CommandIndicator ci) := {
		len := 0, // overwritten
		command_value := ci
	}
	template (present) RSL_IE_CommandIndicator tr_CommandInd(template (present) RSL_CommandIndicator ci) := {
		len := ?,
		command_value := ci
	}

	/* 9.3.50 UIC */
	type record RSL_IE_Uic {
		uint8_t		len,
		BIT2		spare,
		uint6_t		uic
	} with {
		variant (len) "LENGTHTO(spare,uic)"
	};

	/* 9.3.52, 3GPP TS 44.018 10.5.2.21aa  */
	type record RSL_IE_MultirateCfg {
		uint8_t 	len,
		uint3_t		mr_speech_ver,
		boolean		nscb,
		boolean		icmi,
		BIT1		spare,
		uint2_t		start_mode,
		BIT8		codec_modes,
		octetstring	parameters
	} with {
		variant (len) "LENGTHTO(mr_speech_ver,nscb,icmi,spare,start_mode,codec_modes,parameters)"
	};
	template (value) RSL_IE_MultirateCfg ts_RSL_MultirateCfg(boolean icmi := true, uint2_t start_mode := 0,
								 BIT8 codec_modes := '00000100'B /* 5,90k */,
								 octetstring params := ''O) := {
		len := 2 + lengthof(params),
		mr_speech_ver := 1,
		nscb := false,
		icmi := icmi,
		spare := '0'B,
		start_mode := start_mode,
		codec_modes := codec_modes,
		parameters := params
	}

	/* 9.3.53 */
	type record RSL_IE_MultirateCtrl {
		uint3_t		spare,
		boolean		od,
		boolean		pre,
		uint2_t		rae,
		boolean		tfo
	}

	type enumerated RSL_IE_SysinfoType {
		RSL_SYSTEM_INFO_8	('00000000'B),
		RSL_SYSTEM_INFO_1	('00000001'B),
		RSL_SYSTEM_INFO_2	('00000010'B),
		RSL_SYSTEM_INFO_3	('00000011'B),
		RSL_SYSTEM_INFO_4	('00000100'B),
		RSL_SYSTEM_INFO_5	('00000101'B),
		RSL_SYSTEM_INFO_6	('00000110'B),
		RSL_SYSTEM_INFO_7	('00000111'B),
		RSL_SYSTEM_INFO_16	('00001000'B),
		RSL_SYSTEM_INFO_17	('00001001'B),
		RSL_SYSTEM_INFO_2bis	('00001010'B),
		RSL_SYSTEM_INFO_2ter	('00001011'B),
		RSL_SYSTEM_INFO_5bis	('00001101'B),
		RSL_SYSTEM_INFO_5ter	('00001110'B),
		RSL_SYSTEM_INFO_10	('00001111'B),
		RSL_EXT_MEAS_ORDER	('01000111'B),
		RSL_MEAS_INFO		('01001000'B),
		RSL_SYSTEM_INFO_13	('00101000'B),
		RSL_ERIC_SYSTEM_INFO_13 ('00001100'B),
		RSL_SYSTEM_INFO_2quater ('00101001'B),
		RSL_SYSTEM_INFO_9	('00101010'B),
		RSL_SYSTEM_INFO_18	('00101011'B),
		RSL_SYSTEM_INFO_19	('00101100'B),
		RSL_SYSTEM_INFO_20	('00101101'B)
	} with { variant "FIELDLENGTH(8)" }

	type record RSL_IE_IPA_ConnectionStats {
		uint8_t			len,
		uint32_t		tx_packets,
		uint32_t		tx_octets,
		uint32_t		rx_packets,
		uint32_t		rx_octets,
		uint32_t		lost_packets,
		uint32_t		jitter,
		uint32_t		avg_delay
	} with { variant (len) "LENGTHTO(tx_packets,tx_octets,rx_packets,rx_octets,lost_packets,jitter,avg_delay)" }

	type enumerated RSL_IPA_SpeechMode {
		RSL_IPA_SPM_SENDRECV	('00'B),
		RSL_IPA_SPM_RECVONLY	('01'B),
		RSL_IPA_SPM_SENDONLY	('10'B),
		RSL_IPA_SPM_RESERVED	('11'B)
	} with { variant "FIELDLENGTH(2)" }

	type enumerated RSL_IPA_Codec {
		RSL_IPA_CODEC_FR	('0000'B),
		RSL_IPA_CODEC_EFR	('0001'B),
		RSL_IPA_CODEC_AMR_F	('0010'B),
		RSL_IPA_CODEC_HR	('0011'B),
		RSL_IPA_CODEC_AMR_H	('0101'B),
		RSL_IPA_CODEC_RTP_PT	('1111'B)
	} with { variant "FIELDLENGTH(4)" }

	type record RSL_IE_IPA_SpeechMode {
		BIT2			reserved,
		RSL_IPA_SpeechMode	mode,
		RSL_IPA_Codec		codec
	}

	type enumerated RSL_IPA_RTP_CSD_FMT_D {
		RSL_IPA_RTP_CSD_EXT_TRAU	('0000'B),
		RSL_IPA_RTP_CSD_NON_TRAU	('0001'B),
		RSL_IPA_RTP_CSD_TRAU_BTS	('0010'B),
		RSL_IPA_RTP_CSD_IWF_FREE	('0011'B)
	} with { variant "FIELDLENGTH(4)" }

	type enumerated RSL_IPA_RTP_CSD_FMT_IR {
		RSL_IPA_RTP_CSD_8k	('0000'B),
		RSL_IPA_RTP_CSD_16k	('0001'B),
		RSL_IPA_RTP_CSD_32k	('0010'B),
		RSL_IPA_RTP_CSD_64	('0011'B)
	} with { variant "FIELDLENGTH(4)" }

	type record RSL_IE_IPA_RTP_CSD_FMT {
		RSL_IPA_RTP_CSD_FMT_IR	ir,
		RSL_IPA_RTP_CSD_FMT_D	d
	}

	/* 9.3.20 */
	type enumerated RSL_IE_ReleaseMode {
		RSL_REL_MODE_NORMAL	('00'B),
		RSL_REL_MODE_LOCAL	('01'B)
	}

	type record RSL_IE_OSMO_TrainingSequence {
		uint8_t			len,
		uint8_t			tsc_set,
		uint8_t			tsc
	} with { variant (len) "LENGTHTO(tsc_set,tsc)" }

	type record RSL_IE_OSMO_RepAcchCap {
		uint8_t			len,
		BIT1			rfu ('0'B),
		uint3_t			rxqual,
		boolean			ul_sacch,
		boolean			dl_sacch,
		boolean			dl_facch_all,
		boolean			dl_facch_cmd
	} with { variant (len) "LENGTHTO(rfu,rxqual,ul_sacch,dl_sacch,dl_facch_all,dl_facch_cmd)" }

	type record RSL_IE_OSMO_TopAcchCap {
		uint8_t			len,
		boolean			sacch_enable,
		boolean			facch_enable,
		uint3_t			rxqual,
		uint3_t			overpower_db
	} with { variant (len) "LENGTHTO(sacch_enable,facch_enable,rxqual,overpower_db)" }

	template (value) RSL_IE_OSMO_TopAcchCap
	ts_RSL_IE_OSMO_TopAcchCap(template (value) uint3_t overpower := 2,
				  template (value) uint3_t rxqual := 4,
				  boolean facch_enable := true,
				  boolean sacch_enable := true) := {
		len := 0, /* overwritten */
		sacch_enable := sacch_enable,
		facch_enable := facch_enable,
		rxqual := rxqual,
		overpower_db := overpower
	};
	template RSL_IE_OSMO_TopAcchCap
	tr_RSL_IE_OSMO_TopAcchCap(template (present) uint3_t overpower := ?,
				  template (present) uint3_t rxqual := ?,
				  template (present) boolean facch_enable := ?,
				  template (present) boolean sacch_enable := ?) := {
		len := ?, /* overwritten */
		sacch_enable := sacch_enable,
		facch_enable := facch_enable,
		rxqual := rxqual,
		overpower_db := overpower
	};

	type record RSL_IE_OSMO_Osmux_CID {
		uint8_t			len,
		uint8_t			cid
	} with { variant (len) "LENGTHTO(cid)" }

	template (present) RSL_IE_OSMO_Osmux_CID
	tr_RSL_IE_OSMO_Osmux_CID(template (present) uint8_t osmux_cid := ?) := {
		len := ?, /* overwritten */
		cid := osmux_cid
	};
	function f_tr_RSL_IE_OSMO_Osmux_CID(template uint8_t osmux_cid := *)
	return template RSL_IE_OSMO_Osmux_CID {
		var template RSL_IE_OSMO_Osmux_CID ie := omit;
		if (not istemplatekind(osmux_cid, "omit")) {
			ie := tr_RSL_IE_OSMO_Osmux_CID(osmux_cid);
		}
		return ie;
	}
	template (value) RSL_IE_OSMO_Osmux_CID
	ts_RSL_IE_OSMO_Osmux_CID(template (value) uint8_t osmux_cid) := {
		len := 0, /* overwritten */
		cid := osmux_cid
	};


	/* union of all IE bodies */
	type union RSL_IE_Body {
		RslChannelNr		chan_nr,
		RslLinkId		link_id,
		RSL_L16V		l3_info,
		RSL_LV			rlm_cause,
		RSL_IE_ReleaseMode	release_mode,
		RSL_IE_ActivationType	act_type,
		RSL_IE_ChannelIdent	chan_ident,
		RSL_IE_ChannelMode	chan_mode,
		uint8_t			handover_ref,
		RSL_IE_BS_Power		bs_power,
		RSL_LV			bs_power_params,
		RSL_IE_MS_Power		ms_power,
		RSL_IE_MS_Power_Parameters ms_power_params,
		uint8_t			timing_adv,
		RSL_IE_MultirateCfg	multirate_cfg,
		RSL_IE_MultirateCtrl	multirate_ctrl,
		uint8_t			msg_id,
		RSL_IE_FrameNumber	frame_nr,
		RSL_IE_Cause		cause,
		uint8_t			access_delay,
		RSL_IE_RachLoad		rach_load,
		uint8_t			meas_res_nr,
		uint8_t			ms_timing_offset,
		RSL_IE_UplinkMeas	uplink_meas,
		RSL_IE_L1Info		l1_info,
		RSL_IE_SysinfoType	sysinfo_type,
		uint16_t		paging_load,
		uint8_t			paging_group,
		RSL_IE_ChanNeeded	chan_needed,
		RSL_IE_CbCommandType	cb_cmd_type,
		RSL_LV			smscb_message,
		RSL_IE_CbchLoadInfo	cbch_load_info,
		RSL_IE_ResourceInfo	resource_info,
		RSL_SacchInfo		sacch_info,

		RSL_IE_StartingTime	starting_time,
		RSL_IE_EncryptionInfo	encr_info,
		uint8_t			smscb_chan_ind,
		RSL_IE_RequestRef	req_ref,
		RSL_LV			full_imm_ass_info,
		MobileIdentityLV	ms_identity,

		RSL_IE_GroupCallReference group_call_ref,
		RSL_IE_GroupChannelDescription group_chan_desc,
		RSL_IE_NchDrxInformation nch_drx_info,
		RSL_IE_CommandIndicator	cmd_indicator,
		RSL_IE_Uic		uic,

		uint16_t		ipa_conn_id,
		uint16_t		ipa_local_port,
		uint16_t		ipa_remote_port,
		OCT4			ipa_local_ip,
		OCT4			ipa_remote_ip,
		uint8_t			ipa_rtp_pt,
		uint8_t			ipa_rtp_pt2,
		RSL_IE_IPA_ConnectionStats ipa_stats,
		RSL_IE_IPA_SpeechMode	ipa_speech_mode,
		RSL_IE_IPA_RTP_CSD_FMT	ipa_rtp_csd_fmt,

		RSL_IE_OSMO_TrainingSequence osmo_training_sequence,
		RSL_IE_OSMO_RepAcchCap	rep_acch_cap,
		RSL_IE_OSMO_TopAcchCap	top_acch_cap,
		RSL_IE_OSMO_Osmux_CID	osmux_cid,

		RSL_LV		other
	}

	type record RSL_IE {
		RSL_IE_Type	iei,
		RSL_IE_Body	body
	} with { variant (body) "CROSSTAG(
					chan_nr, iei = RSL_IE_CHAN_NR;
					link_id, iei = RSL_IE_LINK_IDENT;
					l3_info, iei = RSL_IE_L3_INFO;
					rlm_cause, iei = RSL_IE_RLM_CAUSE;
					release_mode, iei = RSL_IE_RELEASE_MODE;
					act_type, iei = RSL_IE_ACT_TYPE;
					chan_ident, iei = RSL_IE_CHAN_IDENT;
					chan_mode, iei = RSL_IE_CHAN_MODE;
					handover_ref, iei = RSL_IE_HANDO_REF;
					bs_power, iei = RSL_IE_BS_POWER;
					bs_power_params, iei = RSL_IE_BS_POWER_PARAM;
					ms_power, iei = RSL_IE_MS_POWER;
					ms_power_params, iei = RSL_IE_MS_POWER_PARAM;
					timing_adv, iei = RSL_IE_TIMING_ADVANCE;
					multirate_cfg, iei = RSL_IE_MR_CONFIG;
					multirate_ctrl, iei = RSL_IE_MR_CONTROL;
					msg_id, iei = RSL_IE_MSG_ID;

					frame_nr, iei = RSL_IE_FRAME_NUMBER;
					cause, iei = RSL_IE_CAUSE;
					access_delay, iei = RSL_IE_ACCESS_DELAY;
					rach_load, iei = RSL_IE_RACH_LOAD;
					meas_res_nr, iei = RSL_IE_MEAS_RES_NR;
					ms_timing_offset, iei = RSL_IE_MS_TIMING_OFFSET;
					uplink_meas, iei = RSL_IE_UPLINK_MEAS;
					l1_info, iei = RSL_IE_L1_INFO;
					sysinfo_type, iei = RSL_IE_SYSINFO_TYPE;
					paging_load, iei = RSL_IE_PAGING_LOAD;
					paging_group, iei = RSL_IE_PAGING_GROUP;
					chan_needed, iei = RSL_IE_CHAN_NEEDED;
					cb_cmd_type, iei = RSL_IE_CB_CMD_TYPE;
					smscb_message, iei = RSL_IE_SMSCB_MSG;
					cbch_load_info, iei = RSL_IE_CBCH_LOAD_INFO;
					resource_info, iei = RSL_IE_RESOURCE_INFO;
					sacch_info, iei = RSL_IE_SACCH_INFO;
					starting_time, iei = RSL_IE_STARTNG_TIME;
					encr_info, iei = RSL_IE_ENCR_INFO;
					smscb_chan_ind, iei = RSL_IE_SMSCB_CHAN_INDICATOR;

					req_ref, iei = RSL_IE_REQ_REFERENCE;
					full_imm_ass_info, iei = RSL_IE_FULL_IMM_ASS_INFO;
					ms_identity, iei =  RSL_IE_MS_IDENTITY;
					other, iei = RSL_IE_FULL_BCCH_INFO;

					group_call_ref, iei = RSL_IE_GROUP_CALL_REF;
					group_chan_desc, iei = RSL_IE_GROUP_CHAN_DESC;
					nch_drx_info, iei = RSL_IE_NCH_DRX_INFO;
					cmd_indicator, iei = RSL_IE_CMD_INDICATOR;
					uic, iei = RSL_IE_UIC;

					ipa_conn_id, iei = RSL_IE_IPAC_CONN_ID;
					ipa_remote_ip, iei = RSL_IE_IPAC_REMOTE_IP;
					ipa_remote_port, iei = RSL_IE_IPAC_REMOTE_PORT;
					ipa_local_ip, iei = RSL_IE_IPAC_LOCAL_IP;
					ipa_local_port, iei = RSL_IE_IPAC_LOCAL_PORT;
					ipa_rtp_pt, iei = RSL_IE_IPAC_RTP_PAYLOAD;
					ipa_rtp_pt2, iei = RSL_IE_IPAC_RTP_PAYLOAD2;
					ipa_stats, iei = RSL_IE_IPAC_CONN_STAT;
					ipa_speech_mode, iei = RSL_IE_IPAC_SPEECH_MODE;
					ipa_rtp_csd_fmt, iei = RSL_IE_IPAC_RTP_CSD_FMT;

					osmo_training_sequence, iei = RSL_IE_OSMO_TRAINING_SEQUENCE;
					rep_acch_cap, iei = RSL_IE_OSMO_REP_ACCH_CAP;
					top_acch_cap, iei = RSL_IE_OSMO_TOP_ACCH_CAP;
					osmux_cid, iei = RSL_IE_OSMO_OSMUX_CID;

					other, OTHERWISE;
		)" };

	/* For some reason the TTCN-3 RAW codec cannot automatically figure out the IEI
	 * that it needs to set for a given union-choice (body).  So we have to explicitly
	 * specify the IEI by the caller :( */
	template (value) RSL_IE t_RSL_IE(RSL_IE_Type iei, template (value) RSL_IE_Body body) := {
		iei := iei,
		body := body
	}

	template RSL_IE tr_RSL_IE(template RSL_IE_Body body) := {
		iei := ?, /* overwritten? */
		body := body
	}


	type record of RSL_IE RSL_IE_List;

	type record RSL_Message {
		RSL_MessageDiscriminator	msg_disc,
		RSL_MessageType			msg_type,
		RSL_IE_List			ies optional
	}

	external function enc_RSL_Message(in RSL_Message msg) return octetstring
		with { extension "prototype(convert) encode(RAW)" };
	external function dec_RSL_Message(in octetstring stream) return RSL_Message
		with { extension "prototype(convert) decode(RAW)" };

	template RSL_Message tr_RSL_MsgDiscType(template RSL_MessageDiscriminator m_disc,
				RSL_MessageType m_type) := {
		msg_disc := m_disc,
		msg_type := m_type,
		ies := *
	}

	template (value) RSL_Message ts_RSL_MsgDiscType(template (value) RSL_MessageDiscriminator m_disc,
							template (value) RSL_MessageType msg_type,
							template (omit) RSL_IE_List ies := omit) := {
		msg_disc := m_disc,
		msg_type := msg_type,
		ies := ies
	}

template RSL_Message tr_RSL_MsgType(template RSL_MessageType msg_type) := {
	msg_disc := ?,
	msg_type := msg_type,
	ies := *
}

/* Common Channel Management */
template RSL_Message tr_RSL_MsgTypeC(template RSL_MessageType msg_type) modifies tr_RSL_MsgType := {
	msg_disc := { RSL_MDISC_CCHAN, ? }
}

/* RLL */
template RSL_Message tr_RSL_MsgTypeR(template RSL_MessageType msg_type) modifies tr_RSL_MsgType := {
	msg_disc := { RSL_MDISC_RLL, true }
}

/* Dedicated Channel Management */
template RSL_Message tr_RSL_MsgTypeD(template RSL_MessageType msg_type) modifies tr_RSL_MsgType := {
	msg_disc := { RSL_MDISC_DCHAN, ? }
}

/* TRX Management */
template RSL_Message tr_RSL_MsgTypeT(template RSL_MessageType msg_type) modifies tr_RSL_MsgType := {
	msg_disc := { RSL_MDISC_TRX_MGMT, ? }
}


/* dedicated channel or RLL */
template RSL_Message tr_RSL_MsgTypeDR(template RSL_MessageType msg_type) modifies tr_RSL_MsgType := {
	msg_disc := ({RSL_MDISC_DCHAN,?}, {RSL_MDISC_RLL,?}, {RSL_MDISC_IPACCESS,false})
}


	/* 8.3.1 BSC -> BTS */
	template (value) RSL_Message ts_RSL_DATA_REQ(template (value) RslChannelNr chan_nr,
						     template (value) RslLinkId link_id,
						     octetstring l3_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, true),
		msg_type := RSL_MT_DATA_REQ,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)})
		}
	}

	template RSL_Message tr_RSL_DATA_REQ(template RslChannelNr chan_nr :=?,
					     template RslLinkId link_id := ?,
					     template octetstring l3_info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, true),
		msg_type := RSL_MT_DATA_REQ,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
			tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)})
		}
	}


	/* 8.3.2 BTS -> BSC */
	template (value) RSL_Message ts_RSL_DATA_IND(template (value) RslChannelNr chan_nr,
						     template (value) RslLinkId link_id,
						     octetstring l3_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, true),
		msg_type := RSL_MT_DATA_IND,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)})
		}
	}
	template RSL_Message tr_RSL_DATA_IND(template RslChannelNr chan_nr, template RslLinkId link_id,
					     template octetstring l3_info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, true),
		msg_type := RSL_MT_DATA_IND,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
			tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)})
		}
	}

	/* 8.3.3 BTS -> BSC */
	template (value) RSL_Message ts_RSL_ERROR_IND(template (value) RslChannelNr chan_nr,
						      template (value) RslLinkId link_id,
						      template (value) octetstring rlm_cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_ERROR_IND,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{rlm_cause := ts_RSL_LV(rlm_cause)})
		}
	}
	template RSL_Message tr_RSL_ERROR_IND(template RslChannelNr chan_nr, template RslLinkId link_id,
					      template octetstring rlm_cause := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_ERROR_IND,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
			tr_RSL_IE(RSL_IE_Body:{rlm_cause := tr_RSL_LV(rlm_cause)})
		}
	}

	/* 8.3.4 BTS <- BSC */
	template (value) RSL_Message ts_RSL_EST_REQ(template (value) RslChannelNr chan_nr,
						    template (value) RslLinkId link_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_REQ,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id})
		}
	}
	template RSL_Message tr_RSL_EST_REQ(template RslChannelNr chan_nr, template RslLinkId link_id) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_REQ,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id})
		}
	}

	/* 8.3.5 BTS -> BSC */
	template (value) RSL_Message ts_RSL_EST_CONF(template (value) RslChannelNr chan_nr,
						     template (value) RslLinkId link_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_CONF,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id})
		}
	}
	template RSL_Message tr_RSL_EST_CONF(template RslChannelNr chan_nr, template RslLinkId link_id) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_CONF,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id})
		}
	}

	/* 8.3.6 BTS -> BSC */
	template (value) RSL_Message ts_RSL_EST_IND(template (value) RslChannelNr chan_nr,
						    template (value) RslLinkId link_id,
						    octetstring l3_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)})
		}
	}
	template RSL_Message tr_RSL_EST_IND(template RslChannelNr chan_nr, template RslLinkId link_id,
						template octetstring l3_info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
			tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)})
		}
	}
	template RSL_Message tr_RSL_EST_IND_NOL3(template RslChannelNr chan_nr, template RslLinkId link_id) :=
{
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_EST_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id})
		}
	}


	/* 8.3.7 BSC -> BTS */
	template (value) RSL_Message ts_RSL_REL_REQ(template (value) RslChannelNr chan_nr,
						    template (value) RslLinkId link_id,
						    template (value) RSL_IE_ReleaseMode rel_mode := RSL_REL_MODE_NORMAL) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_REL_REQ,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id}),
			t_RSL_IE(RSL_IE_RELEASE_MODE, RSL_IE_Body:{release_mode := rel_mode})
		}
	}
	template RSL_Message tr_RSL_REL_REQ(template RslChannelNr chan_nr,
					    template RslLinkId link_id,
					    template RSL_IE_ReleaseMode rel_mode := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_REL_REQ,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
			tr_RSL_IE(RSL_IE_Body:{release_mode := rel_mode})
		}
	}

	/* 8.3.8 BTS -> BSC */
	template (value) RSL_Message ts_RSL_REL_CONF(template (value) RslChannelNr chan_nr,
						     template (value) RslLinkId link_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_REL_CONF,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id})
		}
	}
	template RSL_Message tr_RSL_REL_CONF(template RslChannelNr chan_nr, template RslLinkId link_id) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_REL_CONF,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id})
		}
	}

	/* 8.3.9 BTS -> BSC */
	template (value) RSL_Message ts_RSL_REL_IND(template (value) RslChannelNr chan_nr,
						    template (value) RslLinkId link_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_REL_IND,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id})
		}
	}
	template RSL_Message tr_RSL_REL_IND(template RslChannelNr chan_nr, template RslLinkId link_id) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_RLL, false),
		msg_type := RSL_MT_REL_IND,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id})
		}
	}

	/* 8.3.10 BSC -> BTS */
	template (value) RSL_Message ts_RSL_UNITDATA_REQ(template (value) RslChannelNr chan_nr,
							 template (value) RslLinkId link_id,
							 octetstring l3_info)
	modifies ts_RSL_DATA_REQ := {
		msg_type := RSL_MT_UNIT_DATA_REQ
	}
	template RSL_Message tr_RSL_UNITDATA_REQ(template RslChannelNr chan_nr,
						 template RslLinkId link_id,
						 template octetstring l3_info := ?)
	modifies tr_RSL_DATA_REQ := {
		msg_type := RSL_MT_UNIT_DATA_REQ
	}


	/* 8.3.11 BTS -> BSC */
	template (value) RSL_Message ts_RSL_UNITDATA_IND(template (value) RslChannelNr chan_nr,
							 template (value) RslLinkId link_id,
							 octetstring l3_info)
	modifies ts_RSL_DATA_IND := {
		msg_type := RSL_MT_UNIT_DATA_IND
	}
	template RSL_Message tr_RSL_UNITDATA_IND(template RslChannelNr chan_nr,
						 template RslLinkId link_id,
						 template octetstring l3_info := ?)
	modifies tr_RSL_DATA_IND := {
		msg_type := RSL_MT_UNIT_DATA_IND
	}




	/* DEDICATED CANNEL MANAGEMENT MESSAGES */

	/* 8.4.1 BSC -> BTS */
	template (value) RSL_Message ts_RSL_CHAN_ACT(template (value) RslChannelNr chan_nr,
						     template (value) RSL_IE_ChannelMode mode,
						     template (value) RSL_IE_ActivationType at := t_RSL_IE_ActType_IA) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_ACT_TYPE, RSL_IE_Body:{act_type := at}),
			t_RSL_IE(RSL_IE_CHAN_MODE, RSL_IE_Body:{chan_mode := mode})
			/* lots of optional IEs */
		}
	}
	template RSL_Message tr_RSL_CHAN_ACT(template RslChannelNr chan_nr,
					     template RSL_IE_ChannelMode mode,
					     template (value) RSL_IE_ActivationType at := t_RSL_IE_ActType_IA) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{act_type := at}),
			tr_RSL_IE(RSL_IE_Body:{chan_mode := mode}),
			/* lots of optional IEs */
			*
		}
	}

	template (value) RSL_Message
	ts_RSL_CHAN_ACT_PDCH(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_ACT_TYPE, RSL_IE_Body:{act_type := c_RSL_IE_ActType_PDCH})
		}
	}
	template RSL_Message
	tr_RSL_CHAN_ACT_PDCH(template (present) RslChannelNr chan_nr) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{act_type := c_RSL_IE_ActType_PDCH}),
			/* lots of optional IEs */
			*
		}
	}


	/* 8.4.2 BTS -> BSC */
	template (value) RSL_Message ts_RSL_CHAN_ACT_ACK(template (value) RslChannelNr chan_nr,
							 GsmFrameNumber fn) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV_ACK,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_FRAME_NUMBER, RSL_IE_Body:{frame_nr := ts_RSL_IE_FrameNumber(fn)})
		}
	}
	template RSL_Message tr_RSL_CHAN_ACT_ACK(template RslChannelNr chan_nr) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV_ACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{frame_nr := ?})
		}
	}

	/* 8.4.3 BTS -> BSC */
	template (value) RSL_Message ts_RSL_CHAN_ACT_NACK(template (value) RslChannelNr chan_nr,
							  RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV_NACK,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_CHAN_ACT_NACK(template RslChannelNr chan_nr,
						  template RSL_Cause cause := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CHAN_ACTIV_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cause := ?})
		}
	}

	/* 8.4.4 BTS -> BSC */
	template (value) RSL_Message ts_RSL_CONN_FAIL_IND(RslChannelNr chan_nr, RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CONN_FAIL,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_CONN_FAIL_IND(template RslChannelNr chan_nr,
						  template RSL_Cause cause := ?) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_CONN_FAIL,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}

	/* 8.4.5 BSC -> BTS */
	template RSL_Message tr_RSL_DEACT_SACCH(template RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_DEACTIVATE_SACCH,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template (value) RSL_Message ts_RSL_DEACT_SACCH(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_DEACTIVATE_SACCH,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}


	/* 8.4.6 BSC ->BTS */
	template RSL_Message tr_RSL_ENCR_CMD(template RslChannelNr chan_nr,
					     template RslLinkId link_id := ?,
					     template RSL_AlgId alg := ?,
					     template octetstring key := ?,
					     template octetstring l3_info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_ENCR_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{encr_info := tr_RSL_IE_EncrInfo(alg, key)}),
			tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
			tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)})
		}
	}
	template (value) RSL_Message ts_RSL_ENCR_CMD(template (value) RslChannelNr chan_nr,
						     template (value) RslLinkId link_id,
						     template (value) RSL_AlgId alg, octetstring key,
						     octetstring l3_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_ENCR_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := ts_RSL_IE_EncrInfo(alg, key)}),
			t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := link_id}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)})
		}
	}

	template RSL_Message tr_RSL_MEAS_RES(template RslChannelNr chan_nr,
					     template uint8_t meas_res_nr := ?,
					     template RSL_IE_UplinkMeas ul_meas := ?,
					     template RSL_IE_BS_Power bs_power := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MEAS_RES,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{meas_res_nr := meas_res_nr}),
			tr_RSL_IE(RSL_IE_Body:{uplink_meas := ul_meas}),
			tr_RSL_IE(RSL_IE_Body:{bs_power := bs_power}),
			*
		}
	}

	/* Templates for a measurement report that lacks the measurement report
	 * from the MS (l1_info, l3_info and ms timing offset */
	template (value) RSL_Message
	ts_RSL_MEAS_RES_EMPTY(template (value) RslChannelNr chan_nr,
			      template (value) uint8_t meas_res_nr,
			      template (value) RSL_IE_UplinkMeas ul_meas,
			      template (value) RSL_IE_BS_Power bs_power) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MEAS_RES,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_MEAS_RES_NR, RSL_IE_Body:{meas_res_nr := meas_res_nr}),
			t_RSL_IE(RSL_IE_UPLINK_MEAS, RSL_IE_Body:{uplink_meas := ul_meas}),
			t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power})
		}
	}
	template RSL_Message
	tr_RSL_MEAS_RES_EMPTY(template (present) RslChannelNr chan_nr,
			      template uint8_t meas_res_nr := ?,
			      template RSL_IE_UplinkMeas ul_meas := ?,
			      template RSL_IE_BS_Power bs_power := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MEAS_RES,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{meas_res_nr := meas_res_nr}),
			tr_RSL_IE(RSL_IE_Body:{uplink_meas := ul_meas}),
			tr_RSL_IE(RSL_IE_Body:{bs_power := bs_power})
		}
	}

	/* Osmocom specific template, require lots of optional fields to be present */
	template RSL_Message tr_RSL_MEAS_RES_OSMO(template RslChannelNr chan_nr,
					     template uint8_t meas_res_nr := ?,
					     template RSL_IE_UplinkMeas ul_meas := ?,
					     template RSL_IE_BS_Power bs_power := ?,
					     template RSL_IE_L1Info l1_info := ?,
					     template octetstring l3_info := ?,
					     template uint8_t ms_to := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MEAS_RES,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{meas_res_nr := meas_res_nr}),
			tr_RSL_IE(RSL_IE_Body:{uplink_meas := ul_meas}),
			tr_RSL_IE(RSL_IE_Body:{bs_power := bs_power}),
			tr_RSL_IE(RSL_IE_Body:{l1_info := l1_info}),
			tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)}),
			tr_RSL_IE(RSL_IE_Body:{ms_timing_offset := ms_to})
		}
	}

	template (value) RSL_Message ts_RSL_MEAS_RES(template (value) RslChannelNr chan_nr,
					     uint8_t meas_res_nr,
					     template (value) RSL_IE_UplinkMeas ul_meas,
					     template (value) RSL_IE_BS_Power bs_power,
					     template (value) RSL_IE_L1Info l1_info,
					     octetstring l3_info,
					     uint8_t ms_to) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MEAS_RES,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_MEAS_RES_NR, RSL_IE_Body:{meas_res_nr := meas_res_nr}),
			t_RSL_IE(RSL_IE_UPLINK_MEAS, RSL_IE_Body:{uplink_meas := ul_meas}),
			t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}),
			t_RSL_IE(RSL_IE_L1_INFO, RSL_IE_Body:{l1_info := l1_info}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)}),
			t_RSL_IE(RSL_IE_MS_TIMING_OFFSET, RSL_IE_Body:{ms_timing_offset := ms_to})
		}
	}

	/* 8.4.9 BSC -> BTS */
	template (value) RSL_Message ts_RSL_MODE_MODIFY_REQ(template (value) RslChannelNr chan_nr,
						     template (value) RSL_IE_ChannelMode mode) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_REQ,
		ies :={
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CHAN_MODE, RSL_IE_Body:{chan_mode := mode})
			/* lots of optional IEs */
		}
	}
	template RSL_Message tr_RSL_MODE_MODIFY_REQ(template RslChannelNr chan_nr,
					     template RSL_IE_ChannelMode mode) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_REQ,
		ies :={
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{chan_mode := mode}),
			/* lots of optional IEs */
			*
		}
	}

	template RSL_Message tr_RSL_MODE_MODIFY_REQ_with_OSMO_TSC(template RslChannelNr chan_nr,
								  template RSL_IE_ChannelMode mode,
								  template uint8_t tsc_set := ?,
								  template uint8_t tsc := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_REQ,
		ies := {
		    tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
		    tr_RSL_IE(RSL_IE_Body:{chan_mode := mode}),
		    tr_RSL_IE(RSL_IE_Body:{osmo_training_sequence := {
							len := ?,
							tsc_set := tsc_set,
							tsc := tsc
						  }
					  })
		}
	};

	/* 8.4.10 BTS -> BSC */
	template (value) RSL_Message ts_RSL_MODE_MODIFY_ACK(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_ACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message tr_RSL_MODE_MODIFY_ACK(template RslChannelNr chan_nr) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_ACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}

	/* 8.4.11 BTS -> BSC */
	template (value) RSL_Message ts_RSL_MODE_MODIFY_NACK(template (value) RslChannelNr chan_nr,
							     RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_NACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_MODE_MODIFY_NACK(template RslChannelNr chan_nr,
							template RSL_Cause cause) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MODE_MODIFY_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}


	/* 8.4.14: BTS <- BSC */
	template RSL_Message tr_RSL_RF_CHAN_REL(template RslChannelNr chan_nr) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_RF_CHAN_REL,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template (value) RSL_Message ts_RSL_RF_CHAN_REL(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_RF_CHAN_REL,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}

	/* 8.4.15: BTS <- BSC */
	template (value) RSL_Message ts_RSL_MS_PWR_CTRL(template (value) RslChannelNr chan_nr,
							template (value) RSL_IE_MS_Power ms_power) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MS_POWER_CONTROL,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power})
			/* One optional IE: MS POWER PARAMETERS */
		}
	}

	template (value) RSL_Message ts_RSL_MS_PWR_CTRL_with_pp(template (value) RslChannelNr chan_nr,
							integer pwr_level) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_MS_POWER_CONTROL,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_level)}),
			t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params :=
			ts_RSL_IE_MS_Power_Parameters(''O)})
		}
	}

	/* 8.4.16: BTS <- BSC */
	template (value) RSL_Message ts_RSL_BS_PWR_CTRL(template (value) RslChannelNr chan_nr,
							template (value) RSL_IE_BS_Power bs_power) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_BS_POWER_CONTROL,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power})
			/* One optional IE: BS POWER PARAMETERS */
		}
	}
	template RSL_Message tr_RSL_BS_PWR_CTRL(template (present) RslChannelNr chan_nr,
						template (present) RSL_IE_BS_Power bs_power) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_BS_POWER_CONTROL,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{bs_power := bs_power})
			/* One optional IE: BS POWER PARAMETERS */
		}
	}

	/* 8.4.19 BTS -> BSC */
	template (value) RSL_Message ts_RSL_RF_CHAN_REL_ACK(template (value) RslChannelNr chan_nr) :=
		ts_RSL_MsgDiscType(ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
				   RSL_MT_RF_CHAN_REL_ACK,
				   { t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}) });

	template RSL_Message tr_RSL_RF_CHAN_REL_ACK(template RslChannelNr chan_nr) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_RF_CHAN_REL_ACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}

	/* 8.6.20 BTS <- BSC */
	template (value) RSL_Message ts_RSL_SACCH_INF_MOD(template (value) RslChannelNr chan_nr,
							  RSL_IE_SysinfoType si_type,
							  octetstring l3_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_SACCH_INFO_MODIFY,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_SYSINFO_TYPE, RSL_IE_Body:{sysinfo_type := si_type}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)})
		}
	}

	/* 8.4.7 BTS -> BSC */
	template (value) RSL_Message ts_RSL_HANDO_DET(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_HANDO_DET,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message tr_RSL_HANDO_DET(template RslChannelNr chan_nr,
					      template uint8_t acc_delay := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_HANDO_DET,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{access_delay := acc_delay})
		}
	}

	/* 8.4.21 BTS -> BSC */
	template (value) RSL_Message ts_RSL_TALKER_DET(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_TALKER_DET,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message tr_RSL_TALKER_DET(template RslChannelNr chan_nr,
					      template uint8_t acc_delay := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_TALKER_DET,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{access_delay := acc_delay})
		}
	}

	/* 8.4.22 BTS -> BSC */
	template (value) RSL_Message ts_RSL_LISTENER_DET(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_LISTENER_DET,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message tr_RSL_LISTENER_DET(template RslChannelNr chan_nr,
					      template uint8_t acc_delay := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_LISTENER_DET,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{access_delay := acc_delay})
		}
	}


	/* COMMON CHANNEL MANAGEMENT MESSAGES */

	/* 8.5.1 BTS <- BSC */
	template (value) RSL_Message ts_RSL_BCCH_INFO(RSL_IE_SysinfoType si_type,
						      octetstring full_bcch_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_BCCH_INFO,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_BCCH(0)}),
			t_RSL_IE(RSL_IE_SYSINFO_TYPE, RSL_IE_Body:{sysinfo_type := si_type}),
			t_RSL_IE(RSL_IE_FULL_BCCH_INFO, RSL_IE_Body:{other := ts_RSL_LV(full_bcch_info)})
		}
	}
	template RSL_Message tr_RSL_NO_BCCH_INFO(template RSL_IE_SysinfoType si_type := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_BCCH_INFO,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := ts_RslChanNr_BCCH(0)}),
			tr_RSL_IE(RSL_IE_Body:{sysinfo_type := si_type})
		}
	}
	template RSL_Message tr_RSL_BCCH_INFO(template RSL_IE_SysinfoType si_type := ?,
					      template octetstring full_bcch_info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_BCCH_INFO,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := ts_RslChanNr_BCCH(0)}),
			tr_RSL_IE(RSL_IE_Body:{sysinfo_type := si_type}),
			tr_RSL_IE(RSL_IE_Body:{other := tr_RSL_LV(full_bcch_info)}),
			*
		}
	}

	/* 8.5.2 BTS -> BSC */
	template (value) RSL_Message ts_RSL_RACH_LOAD_IND(uint16_t slot_ct, uint16_t busy_ct,
							  uint16_t acc_ct) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CCCH_LOAD_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_RACH(0)}),
			t_RSL_IE(RSL_IE_RACH_LOAD, RSL_IE_Body:{rach_load := ts_RSL_IE_RachLoad(slot_ct, busy_ct, acc_ct)})
		}
	}
	template RSL_Message tr_RSL_RACH_LOAD_IND(template uint16_t slot_ct := ?,
						  template uint16_t busy_ct := ?,
						  template uint16_t acc_ct := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CCCH_LOAD_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_RACH(0)}),
			tr_RSL_IE(RSL_IE_Body:{rach_load := tr_RSL_IE_RachLoad(slot_ct, busy_ct, acc_ct)})
		}
	}

	template (value) RSL_Message ts_RSL_PAGING_LOAD_IND(uint16_t buffer_space) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CCCH_LOAD_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_PCH_AGCH(0)}),
			t_RSL_IE(RSL_IE_PAGING_LOAD, RSL_IE_Body:{paging_load := buffer_space})
		}
	}
	template RSL_Message tr_RSL_PAGING_LOAD_IND(template uint16_t buffer_space := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CCCH_LOAD_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_PCH_AGCH(0)}),
			tr_RSL_IE(RSL_IE_Body:{paging_load := buffer_space})
		}
	}


	/* 8.5.3 BTS -> BSC */
	template (value) RSL_Message ts_RSL_CHAN_RQD(OCT1 ra, GsmFrameNumber fn,
						     template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
						     uint8_t acc_del := 0) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CHAN_RQD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			/* TODO: we may need to have optional RSL_IE_LINK_IDENT IE here */
			t_RSL_IE(RSL_IE_REQ_REFERENCE, RSL_IE_Body:{req_ref := ts_RSL_IE_ReqRef(ra, fn)}),
			t_RSL_IE(RSL_IE_ACCESS_DELAY, RSL_IE_Body:{access_delay := acc_del})
		}
	}
	template RSL_Message tr_RSL_CHAN_RQD(template OCT1 ra, template GsmFrameNumber fn := ?,
					     template RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
					     template uint8_t acc_del := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CHAN_RQD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			/* TODO: we may need to have optional RSL_IE_LINK_IDENT IE here */
			tr_RSL_IE(RSL_IE_Body:{req_ref := tr_RSL_IE_ReqRef(ra, fn)}),
			tr_RSL_IE(RSL_IE_Body:{access_delay := acc_del})
		}
	}

	/* 8.5.4 BTS -> BSC */
	template (value) RSL_Message ts_DELETE_IND(template (value) RslChannelNr chan_nr,
						   octetstring imm_ass) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_DELETE_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_FULL_IMM_ASS_INFO, RSL_IE_Body:{full_imm_ass_info := ts_RSL_LV(imm_ass)})
		}
	}
	template RSL_Message tr_RSL_DELETE_IND(template octetstring imm_ass := ?, template uint3_t tn) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_DELETE_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_PCH_AGCH(tn)}),
			tr_RSL_IE(RSL_IE_Body:{full_imm_ass_info := tr_RSL_LV(imm_ass)}),
			*
		}
	}

	/* 8.5.5 BSC -> BTS */
	template RSL_Message tr_RSL_PAGING_CMD(template MobileIdentityV mi, template uint3_t tn := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_PAGING_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_PCH_AGCH(tn)}),
			tr_RSL_IE(RSL_IE_Body:{paging_group := ?}),
			tr_RSL_IE(RSL_IE_Body:{ms_identity := tr_MI_LV(mi)}),
			* /* opt: channel needed, eMLPP prio */
		}
	}
	template (value) RSL_Message ts_RSL_PAGING_CMD(MobileIdentityV mi, uint8_t pg, uint3_t tn := 0) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_PAGING_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_PCH_AGCH(tn)}),
			t_RSL_IE(RSL_IE_PAGING_GROUP, RSL_IE_Body:{paging_group := pg}),
			t_RSL_IE(RSL_IE_MS_IDENTITY, RSL_IE_Body:{ms_identity := ts_MI_LV(mi)})
		}
	}

	/* 8.5.6 BSC -> BTS */
	template RSL_Message tr_RSL_IMM_ASSIGN(template uint3_t tn := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_IMMEDIATE_ASSIGN_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_PCH_AGCH(tn)}),
			tr_RSL_IE(RSL_IE_Body:{full_imm_ass_info := ?})
		}
	}
	template (value) RSL_Message ts_RSL_IMM_ASSIGN(octetstring f_ass_inf, uint3_t tn := 0) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_IMMEDIATE_ASSIGN_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_PCH_AGCH(tn)}),
			t_RSL_IE(RSL_IE_FULL_IMM_ASS_INFO, RSL_IE_Body:{full_imm_ass_info := ts_RSL_LV(f_ass_inf)})
		}
	}

	/* 8.5.8 BTS <- BSC SMS BROADCAST COMMAND */
	template RSL_Message tr_RSL_SMSCB_CMD(template RSL_IE_CbCommandType cb_cmd := ?,
					      template octetstring msg := ?,
					      template RslChannelNr chan_nr := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_SMS_BC_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cb_cmd_type := cb_cmd}),
			tr_RSL_IE(RSL_IE_Body:{smscb_message := tr_RSL_LV(msg)}),
			*
		}
	}
	template (value) RSL_Message ts_RSL_SMSCB_CMD(template (value) RSL_IE_CbCommandType cb_cmd,
						      template (value) octetstring msg,
						      template (value) RslChannelNr chan_nr :=
									ts_RslChanNr_SDCCH4(0, 2)) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_SMS_BC_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CB_CMD_TYPE, RSL_IE_Body:{cb_cmd_type := cb_cmd}),
			t_RSL_IE(RSL_IE_SMSCB_MSG, RSL_IE_Body:{smscb_message := ts_RSL_LV(msg)})
			/* optional channel type for extended CBCH */
		}
	}

	/* 8.5.9 BTS -> BSC CBCH LOAD INDICATION */
	template RSL_Message tr_RSL_CBCH_LOAD_IND_BASIC(template boolean overflow := ?,
							template uint4_t slot_count := ?,
							template RslChannelNr chan_nr := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CBCH_LOAD_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cbch_load_info := tr_CbchLoadInfo(overflow, slot_count)})
		}
	}
	template (value) RSL_Message ts_RSL_CBCH_LOAD_IND_BASIC(boolean overflow, uint4_t slot_count,
								template (value) RslChannelNr chan_nr :=
									ts_RslChanNr_SDCCH4(0, 2)) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CBCH_LOAD_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CBCH_LOAD_INFO, RSL_IE_Body:{cbch_load_info := ts_CbchLoadInfo(overflow, slot_count)})
		}
	}
	template RSL_Message tr_RSL_CBCH_LOAD_IND_EXTD(template boolean overflow := ?,
							template uint4_t slot_count := ?,
							template RslChannelNr chan_nr := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CBCH_LOAD_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cbch_load_info := tr_CbchLoadInfo(overflow, slot_count)}),
			tr_RSL_IE(RSL_IE_Body:{smscb_chan_ind := 1})
		}
	}
	template (value) RSL_Message ts_RSL_CBCH_LOAD_IND_EXTD(boolean overflow, uint4_t slot_count,
								template (value) RslChannelNr chan_nr :=
									ts_RslChanNr_SDCCH4(0, 2)) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_CBCH_LOAD_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CBCH_LOAD_INFO, RSL_IE_Body:{cbch_load_info := ts_CbchLoadInfo(overflow, slot_count)}),
			t_RSL_IE(RSL_IE_SMSCB_CHAN_INDICATOR, RSL_IE_Body:{smscb_chan_ind := 1})
		}
	}


	/* 8.6.1 BTS -> BSC */
	template (value) RSL_Message
	ts_RSL_RF_RES_IND(template (value) RSL_ResourceInfo info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_RF_RES_IND,
		ies := {
			t_RSL_IE(RSL_IE_RESOURCE_INFO, RSL_IE_Body:{
				resource_info := {
					len := 0, /* overwritten */
					info := info
				}
			})
		}
	}
	template RSL_Message
	tr_RSL_RF_RES_IND(template (present) RSL_ResourceInfo info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_RF_RES_IND,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{
				resource_info := {
					len := ?,
					info := info
				}
			})
		}
	}


	/* 8.6.2 BTS <- BSC */
	template (value) RSL_Message ts_RSL_SACCH_FILL(RSL_IE_SysinfoType si_type, octetstring l3_info) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_SACCH_FILL,
		ies := {
			t_RSL_IE(RSL_IE_SYSINFO_TYPE, RSL_IE_Body:{sysinfo_type := si_type}),
			t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := ts_RSL_L16V(l3_info)})
		}
	}
	template RSL_Message tr_RSL_NO_SACCH_FILL(template RSL_IE_SysinfoType si_type := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_SACCH_FILL,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{sysinfo_type := si_type})
		}
	}
	template RSL_Message tr_RSL_SACCH_FILL(template RSL_IE_SysinfoType si_type := ?,
						template octetstring l3_info := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_SACCH_FILL,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{sysinfo_type := si_type}),
			tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)}),
			*
		}
	}


	/* 8.6.4 BTS -> BSC */
	template (value) RSL_Message ts_RSL_ERROR_REPORT(RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_ERROR_REPORT,
		ies := {
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_ERROR_REPORT(template RSL_Cause cause := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_TRX_MGMT, false),
		msg_type := RSL_MT_ERROR_REPORT,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)}),
			*
		}
	}



	/* Abis/IP specific messages */

	private function f_ts_RSL_IPA_CRCX_IEs(template (value) RslChannelNr chan_nr,
					       template (omit) OCT4 remote_ip,
					       template (omit) uint16_t remote_port,
					       template (omit) uint8_t osmux_cid)
	return RSL_IE_List {
		var RSL_IE_List ies;

		/* Channel Number is a mandatory IE */
		ies := {
			valueof(RSL_IE:{
				iei := RSL_IE_CHAN_NR,
				body := { chan_nr := chan_nr }
			})
		};
		/* Remote IP / Port are optional IEs */
		if (not istemplatekind(remote_ip, "omit")) {
			ies := ies & {
				valueof(RSL_IE:{
					iei := RSL_IE_IPAC_REMOTE_IP,
					body := { ipa_remote_ip := remote_ip }
				})
			};
		}
		if (not istemplatekind(remote_port, "omit")) {
			ies := ies & {
				valueof(RSL_IE:{
					iei := RSL_IE_IPAC_REMOTE_PORT,
					body := { ipa_remote_port := remote_port }
				})
			};
		}
		/* Osmux CID extension IE is optional: */
		if (not istemplatekind(osmux_cid, "omit")) {
			ies := ies & {
				valueof(RSL_IE:{
					iei := RSL_IE_OSMO_OSMUX_CID,
					body := { osmux_cid := ts_RSL_IE_OSMO_Osmux_CID(osmux_cid) }
				})
			};
		}

		return ies;
	}
	template RSL_Message tr_RSL_IPA_CRCX(template RslChannelNr chan_nr) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_CRCX,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			*
		}
	}
	template (value) RSL_Message
	ts_RSL_IPA_CRCX(template (value) RslChannelNr chan_nr,
			template (omit) OCT4 remote_ip := omit,
			template (omit) uint16_t remote_port := omit,
			template (omit) uint8_t osmux_cid := omit) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_CRCX,
		ies := f_ts_RSL_IPA_CRCX_IEs(chan_nr, remote_ip, remote_port, osmux_cid)
	}

	function ts_RSL_IPA_CRCX_ACK(template (value) RslChannelNr chan_nr,
				     uint16_t ipa_conn_id, OCT4 local_ip,
				     uint16_t local_port, uint7_t rtp_pt2,
				     template (omit) uint8_t osmux_cid := omit)
	return template (value) RSL_Message {
		var template (value) RSL_Message msg := {
			msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
			msg_type := RSL_MT_IPAC_CRCX_ACK,
			ies := {
				t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
				t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
				t_RSL_IE(RSL_IE_IPAC_LOCAL_IP, RSL_IE_Body:{ipa_local_ip := local_ip}),
				t_RSL_IE(RSL_IE_IPAC_LOCAL_PORT, RSL_IE_Body:{ipa_local_port := local_port}),
				t_RSL_IE(RSL_IE_IPAC_RTP_PAYLOAD2, RSL_IE_Body:{ipa_rtp_pt2 := rtp_pt2})
			}
		}
		if (not istemplatekind(osmux_cid, "omit")) {
			msg.ies[lengthof(msg.ies)] := t_RSL_IE(RSL_IE_OSMO_OSMUX_CID, RSL_IE_Body:{osmux_cid := ts_RSL_IE_OSMO_Osmux_CID(osmux_cid)});
		}
		return msg;
	}

	function tr_RSL_IPA_CRCX_ACK(template RslChannelNr chan_nr,
				     template uint16_t ipa_conn_id,
				     template OCT4 local_ip,
				     template uint16_t local_port,
				     template uint8_t osmux_cid := omit)
	return template RSL_Message {
		var template RSL_Message msg := {
			msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
			msg_type := RSL_MT_IPAC_CRCX_ACK,
			ies := {
				tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
				tr_RSL_IE(RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
				tr_RSL_IE(RSL_IE_Body:{ipa_local_ip := local_ip}),
				tr_RSL_IE(RSL_IE_Body:{ipa_local_port := local_port})
				/* Optional: RTP Payload Type 2 IE */
			}
		}
		if (not istemplatekind(osmux_cid, "omit")) {
			msg.ies[lengthof(msg.ies)] := tr_RSL_IE(RSL_IE_Body:{osmux_cid := f_tr_RSL_IE_OSMO_Osmux_CID(osmux_cid)});
		}
		return msg;
	}

	template (value) RSL_Message ts_RSL_IPA_CRCX_NACK(template (value) RslChannelNr chan_nr,
							  RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_CRCX_NACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_IPA_CRCX_NACK(template RslChannelNr chan_nr,
						  template RSL_Cause cause := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_CRCX_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}

	function ts_RSL_IPA_MDCX(template (value) RslChannelNr chan_nr,
				 uint16_t ipa_conn_id,
				 OCT4 remote_ip, uint16_t remote_port,
				 uint7_t rtp_pt2,
				 template (omit) uint8_t osmux_cid := omit)
	return template (value) RSL_Message {
		var template (value) RSL_Message msg := {
			msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
			msg_type := RSL_MT_IPAC_MDCX,
			ies := {
				t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
				t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
				t_RSL_IE(RSL_IE_IPAC_REMOTE_IP, RSL_IE_Body:{ipa_remote_ip := remote_ip}),
				t_RSL_IE(RSL_IE_IPAC_REMOTE_PORT, RSL_IE_Body:{ipa_remote_port := remote_port}),
				/* optional: RTP Payload Type */
				t_RSL_IE(RSL_IE_IPAC_RTP_PAYLOAD2, RSL_IE_Body:{ipa_rtp_pt2 := rtp_pt2})
			}
		}
		if (not istemplatekind(osmux_cid, "omit")) {
			msg.ies[lengthof(msg.ies)] := t_RSL_IE(RSL_IE_OSMO_OSMUX_CID, RSL_IE_Body:{osmux_cid := ts_RSL_IE_OSMO_Osmux_CID(osmux_cid)});
		}
		return msg;
	}
	template RSL_Message tr_RSL_IPA_MDCX(template RslChannelNr chan_nr,
					     template uint16_t ipa_conn_id) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_MDCX,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			*
		}
	}

	function ts_RSL_IPA_MDCX_ACK(template (value) RslChannelNr chan_nr,
				     uint16_t ipa_conn_id,
				     OCT4 local_ip, uint16_t local_port,
				     uint7_t rtp_pt2,
				     template (omit) uint8_t osmux_cid := omit)
	return template (value) RSL_Message {
		var template (value) RSL_Message msg := {
			msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
			msg_type := RSL_MT_IPAC_MDCX_ACK,
			ies := {
				t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
				/* optional */
				t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
				t_RSL_IE(RSL_IE_IPAC_LOCAL_IP, RSL_IE_Body:{ipa_local_ip := local_ip}),
				t_RSL_IE(RSL_IE_IPAC_LOCAL_PORT, RSL_IE_Body:{ipa_local_port := local_port}),
				/* optional: RTP Payload Type */
				t_RSL_IE(RSL_IE_IPAC_RTP_PAYLOAD2, RSL_IE_Body:{ipa_rtp_pt2 := rtp_pt2})
			}
		}
		if (not istemplatekind(osmux_cid, "omit")) {
			msg.ies[lengthof(msg.ies)] := t_RSL_IE(RSL_IE_OSMO_OSMUX_CID, RSL_IE_Body:{osmux_cid := ts_RSL_IE_OSMO_Osmux_CID(osmux_cid)});
		}
		return msg;
	}
	function tr_RSL_IPA_MDCX_ACK(template RslChannelNr chan_nr,
				     template uint16_t ipa_conn_id,
				     template OCT4 local_ip,
				     template uint16_t local_port,
				     template uint7_t rtp_pt2,
				     template uint8_t osmux_cid := omit)
	return template RSL_Message {
		var template RSL_Message msg := {
			msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
			msg_type := RSL_MT_IPAC_MDCX_ACK,
			ies := {
				tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
				/* optional */
				tr_RSL_IE(RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
				tr_RSL_IE(RSL_IE_Body:{ipa_local_ip := local_ip}),
				tr_RSL_IE(RSL_IE_Body:{ipa_local_port := local_port}),
				/* optional: RTP Payload Type */
				tr_RSL_IE(RSL_IE_Body:{ipa_rtp_pt2 := rtp_pt2})
			}
		}
		if (not istemplatekind(osmux_cid, "omit")) {
			msg.ies[lengthof(msg.ies)] := tr_RSL_IE(RSL_IE_Body:{osmux_cid := f_tr_RSL_IE_OSMO_Osmux_CID(osmux_cid)});
		}
		return msg;
	}

	template (value) RSL_Message ts_RSL_IPA_MDCX_NACK(template (value) RslChannelNr chan_nr,
							  RSL_Cause cause,
							  template (value) uint16_t ipa_conn_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_MDCX_NACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			/* optional connection ID */
			t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_IPA_MDCX_NACK(template RslChannelNr chan_nr,
						  template RSL_Cause cause,
						  template uint16_t ipa_conn_id) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_MDCX_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			/* optional connection ID */
			tr_RSL_IE(RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}


	template (value) RSL_Message ts_RSL_IPA_DLCX_IND(template (value) RslChannelNr chan_nr,
							 uint16_t ipa_conn_id,
							 template (value) RSL_IE_IPA_ConnectionStats stats,
							 RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX_IND,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			t_RSL_IE(RSL_IE_IPAC_CONN_STAT, RSL_IE_Body:{ipa_stats := stats}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}

	template (value) RSL_Message ts_RSL_IPA_DLCX(template (value) RslChannelNr chan_nr,
						     uint16_t ipa_conn_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id})
		}
	}
	template RSL_Message tr_RSL_IPA_DLCX(template RslChannelNr chan_nr,
					     template uint16_t ipa_conn_id := omit) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			/* FIXME: optional conn_id */
			*
		}
	}

	template (value) RSL_Message ts_RSL_IPA_DLCX_ACK(template (value) RslChannelNr chan_nr,
							 uint16_t ipa_conn_id,
							 RSL_IE_IPA_ConnectionStats stats) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX_ACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			t_RSL_IE(RSL_IE_IPAC_CONN_STAT, RSL_IE_Body:{ipa_stats := stats})
		}
	}
	template RSL_Message tr_RSL_IPA_DLCX_ACK(template RslChannelNr chan_nr,
						 template uint16_t ipa_conn_id,
						 template RSL_IE_IPA_ConnectionStats stats) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX_ACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			tr_RSL_IE(RSL_IE_Body:{ipa_stats := stats})
		}
	}



	template (value) RSL_Message ts_RSL_IPA_DLCX_NACK(template (value) RslChannelNr chan_nr,
							  RSL_Cause cause, uint16_t ipa_conn_id) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX_NACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			/* optional connection ID */
			t_RSL_IE(RSL_IE_IPAC_CONN_ID, RSL_IE_Body:{ipa_conn_id := ipa_conn_id}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_IPA_DLCX_NACK(template RslChannelNr chan_nr,
						  template RSL_Cause cause) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_IPACCESS, false),
		msg_type := RSL_MT_IPAC_DLCX_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			/* optional connection ID */
			*,
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}


	template (value) RSL_Message
	ts_RSL_IPA_PDCH_ACT(template (value) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_ACT,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message
	tr_RSL_IPA_PDCH_ACT(template (present) RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_ACT,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}


	template RSL_Message ts_RSL_IPA_PDCH_ACT_ACK(RslChannelNr chan_nr,
						     template (value) RSL_IE_FrameNumber fn) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_ACT_ACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_FRAME_NUMBER, RSL_IE_Body:{frame_nr := fn})
		}
	}
	template RSL_Message tr_RSL_IPA_PDCH_ACT_ACK(template RslChannelNr chan_nr,
						     template RSL_IE_FrameNumber fn) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_ACT_ACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{frame_nr := fn})
		}
	}

	template RSL_Message ts_RSL_IPA_PDCH_ACT_NACK(RslChannelNr chan_nr, RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_ACT_NACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_IPA_PDCH_ACT_NACK(template RslChannelNr chan_nr,
						      template RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_ACT_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}

	template RSL_Message ts_RSL_IPA_PDCH_DEACT(RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_DEACT,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message tr_RSL_IPA_PDCH_DEACT(template RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_DEACT,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}

	template RSL_Message ts_RSL_IPA_PDCH_DEACT_ACK(RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_DEACT_ACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr})
		}
	}
	template RSL_Message tr_RSL_IPA_PDCH_DEACT_ACK(template RslChannelNr chan_nr) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_DEACT_ACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr})
		}
	}

	template RSL_Message ts_RSL_IPA_PDCH_DEACT_NACK(RslChannelNr chan_nr, RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_DEACT_NACK,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := ts_RSL_IE_Cause(cause)})
		}
	}
	template RSL_Message tr_RSL_IPA_PDCH_DEACT_NACK(template RslChannelNr chan_nr,
							template RSL_Cause cause) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_DCHAN, false),
		msg_type := RSL_MT_IPAC_PDCH_DEACT_NACK,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
		}
	}

	template (value) RSL_Message ts_RSL_OSMO_ETWS_CMD(template (value) octetstring msg,
							  template (value) RslChannelNr chan_nr := ts_RslChanNr_PCH_AGCH(0)) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_OSMO_ETWS_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := chan_nr}),
			t_RSL_IE(RSL_IE_SMSCB_MSG, RSL_IE_Body:{smscb_message := ts_RSL_LV(msg)})
		}
	}
	template RSL_Message tr_RSL_OSMO_ETWS_CMD(template RslChannelNr chan_nr := ?,
						  template octetstring msg := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_OSMO_ETWS_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
			tr_RSL_IE(RSL_IE_Body:{smscb_message := tr_RSL_LV(msg)})
		}
	}

	template (value) RSL_Message ts_RSL_NOTIF_CMD_START(template (value) GroupCallRef group_call_ref,
							    template (value) octetstring chan_desc) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_NOT_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_PCH_AGCH(0)}),
			t_RSL_IE(RSL_IE_CMD_INDICATOR, RSL_IE_Body:{cmd_indicator := ts_CommandInd(CMD_IND_START)}),
			t_RSL_IE(RSL_IE_GROUP_CALL_REF, RSL_IE_Body:{group_call_ref := ts_GroupCallRef(group_call_ref)}),
			t_RSL_IE(RSL_IE_GROUP_CHAN_DESC, RSL_IE_Body:{group_chan_desc := ts_GroupChanDesc(chan_desc)})
		}
	}
	template RSL_Message tr_RSL_NOTIF_CMD_START(template (present) GroupCallRef group_call_ref,
						    template (present) octetstring chan_desc := ?) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_NOT_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_PCH_AGCH(0)}),
			tr_RSL_IE(RSL_IE_Body:{cmd_indicator := tr_CommandInd(CMD_IND_START)}),
			tr_RSL_IE(RSL_IE_Body:{group_call_ref := tr_GroupCallRef(group_call_ref)}),
			tr_RSL_IE(RSL_IE_Body:{group_chan_desc := tr_GroupChanDesc(chan_desc)}),
			*
		}
	}

	template (value) RSL_Message ts_RSL_NOTIF_CMD_STOP(template (value) GroupCallRef group_call_ref) := {
		msg_disc := ts_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_NOT_CMD,
		ies := {
			t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := ts_RslChanNr_PCH_AGCH(0)}),
			t_RSL_IE(RSL_IE_CMD_INDICATOR, RSL_IE_Body:{cmd_indicator := ts_CommandInd(CMD_IND_STOP)}),
			t_RSL_IE(RSL_IE_GROUP_CALL_REF, RSL_IE_Body:{group_call_ref := ts_GroupCallRef(group_call_ref)})
		}
	}
	template RSL_Message tr_RSL_NOTIF_CMD_STOP(template (present) GroupCallRef group_call_ref) := {
		msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false),
		msg_type := RSL_MT_NOT_CMD,
		ies := {
			tr_RSL_IE(RSL_IE_Body:{chan_nr := t_RslChanNr_PCH_AGCH(0)}),
			tr_RSL_IE(RSL_IE_Body:{cmd_indicator := tr_CommandInd(CMD_IND_STOP)}),
			tr_RSL_IE(RSL_IE_Body:{group_call_ref := tr_GroupCallRef(group_call_ref)}),
			*
		}
	}



	function f_rsl_find_ie(RSL_Message msg, RSL_IE_Type iei, out RSL_IE_Body ret) return boolean {
		for (var integer i := 0; i < sizeof(msg.ies); i := i+1) {
			if (msg.ies[i].iei == iei) {
				ret := msg.ies[i].body;
				return true;
			}
		}
		return false;
	}



} with { encode "RAW" ; variant "FIELDORDER(msb)" }