blob: 09566b4e986ac2c00815c065d43738d640393ed8 [file] [log] [blame]
Harald Weltea082a692017-07-15 15:58:13 +02001/* Encoding/Decoding routines for GSM System Information messages
2 * according to 3GPP TS 44.018 Version 12.3.0 Release 12 */
3
4/* (C) 2017 by Harald Welte <laforge@gnumonks.org> */
5
6module GSM_Types {
7
8 import from General_Types all;
9 import from Osmocom_Types all;
10
Harald Weltebdc5dbd2017-07-16 00:00:43 +020011 type integer GsmArfcn (0..1023);
12 type integer UmtsArfcn (0..16383);
13 type integer UmtsScramblingCode (0..511);
Harald Welted2e342f2017-07-16 07:34:13 +020014 const integer GsmMaxFrameNumber := 26*51*2048;
15 type integer GsmFrameNumber (0..GsmMaxFrameNumber);
16 type integer GsmRxLev (0..63);
17 type integer GsmTsc (0..7) with { variant "FIELDLENGTH(8)" };
18 type uint32_t GsmTmsi;
Harald Welte484160b2017-07-28 13:30:24 +020019 type uint32_t GprsTlli;
Harald Weltebdc5dbd2017-07-16 00:00:43 +020020
Harald Welte1dcc3712017-08-01 00:05:52 +020021 type enumerated GprsCodingScheme {
22 CS1, CS2, CS3, CS4
23 };
24
Harald Welted2e342f2017-07-16 07:34:13 +020025 /* 10.5.2.8 */
26 type enumerated ChannelNeeded {
27 CHAN_NEED_ANY (0),
28 CHAN_NEED_SDCCH (1),
29 CHAN_NEED_TCH_F (2),
30 CHAN_NEED_TCH_H (3)
31 } with { variant "FIELDLENGTH(2)" };
32 type record ChannelNeeded12 {
33 ChannelNeeded second,
34 ChannelNeeded first
35 } with { variant "" };
36
Harald Welted2e342f2017-07-16 07:34:13 +020037
Harald Welte0c8d5c02017-07-16 18:53:58 +020038 /* TS 48.058 9.3.1 Channel Number IE */
39 type enumerated RslChanNr0 {
Harald Welte6f3c2232017-07-30 17:17:12 +020040 RSL_CHAN_NR_INVALID ('00000'B),
41 RSL_CHAN_NR_Bm_ACCH ('00001'B),
42 RSL_CHAN_NR_BCCH ('10000'B),
43 RSL_CHAN_NR_RACH ('10001'B),
44 RSL_CHAN_NR_PCH_AGCH ('10010'B),
45 RSL_CHAN_NR_OSMO_PDCH ('11000'B)
Harald Weltec84d8472017-07-30 00:49:56 +020046 } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };
Harald Welte0c8d5c02017-07-16 18:53:58 +020047
48 type record RslChanNr2 {
49 BIT4 tag ('0001'B),
50 uint1_t sub_chan
Harald Weltec84d8472017-07-30 00:49:56 +020051 } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };
Harald Welte0c8d5c02017-07-16 18:53:58 +020052
53 type record RslChanNr4 {
54 BIT3 tag ('001'B),
55 uint2_t sub_chan
Harald Weltec84d8472017-07-30 00:49:56 +020056 } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };
Harald Welte0c8d5c02017-07-16 18:53:58 +020057
58 type record RslChanNr8 {
59 BIT2 tag ('01'B),
60 uint3_t sub_chan
Harald Weltec84d8472017-07-30 00:49:56 +020061 } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };
Harald Welte0c8d5c02017-07-16 18:53:58 +020062
63 type union RslChanNrU {
64 RslChanNr0 ch0,
65 RslChanNr2 lm,
66 RslChanNr4 sdcch4,
67 RslChanNr8 sdcch8
68 } with {
69 variant "TAG(lm, tag = '0001'B;
70 sdcch4, tag = '001'B;
71 sdcch8, tag = '01'B;
72 ch0, OTHERWISE)"
73 variant "FIELDLENGTH(5)"
Harald Weltec84d8472017-07-30 00:49:56 +020074 variant "FIELDORDER(msb)"
Harald Welte0c8d5c02017-07-16 18:53:58 +020075 };
76
77 type record RslChannelNr {
78 RslChanNrU u,
79 uint3_t tn
Harald Weltec84d8472017-07-30 00:49:56 +020080 } with { variant "FIELDLENGTH(8)" variant "FIELDORDER(msb)" };
Harald Welte0c8d5c02017-07-16 18:53:58 +020081
82 template RslChannelNr t_RslChanNr0(template uint3_t tn, template RslChanNr0 cht) := {
83 u := { ch0 := cht },
84 tn := tn
85 }
86
87 template RslChannelNr t_RslChanNr_RACH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_RACH);
88 template RslChannelNr t_RslChanNr_BCCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_BCCH);
89 template RslChannelNr t_RslChanNr_PCH_AGCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_PCH_AGCH);
90 template RslChannelNr t_RslChanNr_Bm(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_Bm_ACCH);
Harald Welte1dcc3712017-08-01 00:05:52 +020091 template RslChannelNr t_RslChanNr_PDCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_OSMO_PDCH);
Harald Welte0c8d5c02017-07-16 18:53:58 +020092 template RslChannelNr t_RslChanNr_Lm(template uint3_t tn, uint1_t sub_slot) := {
93 u := { lm := { tag := '0001'B, sub_chan := sub_slot } },
94 tn := tn
95 }
96 template RslChannelNr t_RslChanNr_SDCCH4(template uint3_t tn, template uint2_t sub_slot) := {
97 u := { sdcch4 := { tag := '001'B, sub_chan := sub_slot } },
98 tn := tn
99 }
100 template RslChannelNr t_RslChanNr_SDCCH8(template uint3_t tn, template uint3_t sub_slot) := {
101 u := { sdcch8 := { tag := '01'B, sub_chan := sub_slot } },
102 tn := tn
103 }
Harald Welted2e342f2017-07-16 07:34:13 +0200104
Harald Welteb33e7272017-07-16 21:04:12 +0200105 /* TS 48.058 9.3.2 Link ID */
106 type enumerated RslLinkIdC {
107 FACCH_SDCCH (0),
108 SACCH (1)
109 } with { variant "FIELDLENGTH(2)" };
110
111 type enumerated RslSapi0Prio {
112 SAPI0_PRIO_NORMAL (0),
113 SAPI0_PRIO_HIGH (1),
114 SAPI0_PRIO_LOW (2)
115 } with { variant "FIELDLENGTH(2)" };
116
117 type uint3_t GsmSapi;
118
119 type record RslLinkId {
120 RslLinkIdC c,
121 boolean na,
122 RslSapi0Prio prio,
123 GsmSapi sapi
124 } with { variant "" };
125
126 template RslLinkId tr_RslLinkId := {
127 c := ?,
128 na := ?,
129 prio := ?,
130 sapi := ?
131 };
132
133 template RslLinkId tr_RslLinkID_DCCH(template GsmSapi sapi) modifies tr_RslLinkId := {
134 c := FACCH_SDCCH,
135 na := false,
136 sapi := sapi
137 };
138
139 template RslLinkId tr_RslLinkID_SACCH(template GsmSapi sapi) modifies tr_RslLinkId := {
140 c := SACCH,
141 na := false,
142 sapi := sapi
143 };
144
Harald Welte3b2ce022017-12-07 17:47:00 +0100145 template (value) RslLinkId ts_RslLinkID_DCCH(GsmSapi sapi) := {
Harald Welteb33e7272017-07-16 21:04:12 +0200146 c := FACCH_SDCCH,
147 na := false,
148 prio := SAPI0_PRIO_NORMAL,
149 sapi := sapi
150 };
151
Harald Welte3b2ce022017-12-07 17:47:00 +0100152 template (value) RslLinkId ts_RslLinkID_SACCH(GsmSapi sapi) := {
Harald Weltecb5d1fb2017-07-17 21:00:15 +0200153 c := SACCH,
154 na := false,
155 prio := SAPI0_PRIO_NORMAL,
156 sapi := sapi
Harald Welteb33e7272017-07-16 21:04:12 +0200157 };
158
Harald Weltea082a692017-07-15 15:58:13 +0200159} with { encode "RAW"; variant "FIELDORDER(msb)" }