blob: a5a6bf8eba5d53106efd1011edf3d228a65aad3c [file] [log] [blame]
Harald Weltef6543322017-07-16 07:35:10 +02001/* Data Types / Encoding / Decoding for OsmocomBB L1CTL interface */
2/* (C) 2017 by Harald Welte <laforge@gnumonks.org>, derived from l1ctl_proto.h
3 * (C) 2010 by Harald Welte + Holger Hans Peter Freyther */
4module L1CTL_Types {
5
6 import from General_Types all;
7 import from GSM_Types all;
8 import from Osmocom_Types all;
9
10 type enumerated L1ctlMsgType {
11 L1CTL_NONE,
12 L1CTL_FBSB_REQ,
13 L1CTL_FBSB_CONF,
14 L1CTL_DATA_IND,
15 L1CTL_RACH_REQ,
16 L1CTL_DM_EST_REQ,
17 L1CTL_DATA_REQ,
18 L1CTL_RESET_IND,
19 L1CTL_PM_REQ, /* power measurement */
20 L1CTL_PM_CONF, /* power measurement */
21 L1CTL_ECHO_REQ,
22 L1CTL_ECHO_CONF,
23 L1CTL_RACH_CONF,
24 L1CTL_RESET_REQ,
25 L1CTL_RESET_CONF,
26 L1CTL_DATA_CONF,
27 L1CTL_CCCH_MODE_REQ,
28 L1CTL_CCCH_MODE_CONF,
29 L1CTL_DM_REL_REQ,
30 L1CTL_PARAM_REQ,
31 L1CTL_DM_FREQ_REQ,
32 L1CTL_CRYPTO_REQ,
33 L1CTL_SIM_REQ,
34 L1CTL_SIM_CONF,
35 L1CTL_TCH_MODE_REQ,
36 L1CTL_TCH_MODE_CONF,
37 L1CTL_NEIGH_PM_REQ,
38 L1CTL_NEIGH_PM_IND,
39 L1CTL_TRAFFIC_REQ,
40 L1CTL_TRAFFIC_CONF,
41 L1CTL_TRAFFIC_IND
42 } with { variant "FIELDLENGTH(8)" };
43
44 type enumerated L1ctlCcchMode {
45 CCCH_MODE_NONE (0),
46 CCCH_MODE_NON_COMBINED,
47 CCCH_MODE_COMBINED
48 } with { variant "FIELDLENGTH(8)" };
49
50 type enumerated L1ctlNeighMode {
51 NEIGH_MODE_NONE (0),
52 NEIGH_MODE_PM,
53 NEIGH_MODE_SB
54 } with { variant "FIELDLENGTH(8)" };
55
56 type enumerated L1ctlResetType {
57 L1CTL_RES_T_BOOT (0),
58 L1CTL_RES_T_FULL,
59 L1CTL_RES_T_SCHED
60 } with { variant "FIELDLENGTH(8)" };
61
62 const integer TRAFFIC_DATA_LEN := 40;
63
64 type record L1ctlHdrFlags {
65 BIT7 padding,
66 boolean f_done
67 } with { variant "" };
68
69 type record L1ctlHeader {
70 L1ctlMsgType msg_type,
71 L1ctlHdrFlags flags,
72 OCT2 padding
73 } with { variant "" };
74
Harald Welte52c713c2017-07-16 15:44:44 +020075 template L1ctlHeader t_L1ctlHeader(template L1ctlMsgType msg_type) := {
76 msg_type := msg_type,
77 flags := { padding := '0000000'B, f_done := false },
78 padding := '0000'O
79 };
80
Harald Weltef6543322017-07-16 07:35:10 +020081 type uint8_t RslLinkId;
82
83 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +020084 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +020085 RslLinkId link_id,
86 Arfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +020087 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +020088 GsmRxLev rx_level,
89 uint8_t snr,
90 uint8_t num_biterr,
91 uint8_t fire_crc
92 } with { variant "" };
93
94 type record L1ctlFbsbConf {
95 int16_t initial_freq_err,
96 uint8_t result,
97 uint8_t bsic
98 } with { variant "" };
99
100 type record L1ctlCcchModeConf {
101 L1ctlCcchMode ccch_mode,
102 OCT3 padding
103 } with { variant "" };
104
105 /* gsm48_chan_mode */
106 type uint8_t L1ctlTchMode;
107
108 type record L1ctlAudioMode {
109 BIT4 padding,
110 boolean tx_microphone,
111 boolean tx_traffic_req,
112 boolean rx_speaker,
113 boolean rx_traffic_ind
114 } with { variant "" };
115
116 type record L1ctlTchModeConf {
117 L1ctlTchMode tch_mode,
118 L1ctlAudioMode audio_mode,
119 OCT2 padding
120 } with { variant "" };
121
122 type record L1ctlDataInd {
123 octetstring payload length(23)
124 } with { variant "" };
125
126 type union L1ctlDlPayload {
127 L1ctlFbsbConf fbsb_conf,
128 L1ctlCcchModeConf ccch_mode_conf,
129 L1ctlTchModeConf tch_mode_conf,
130 L1ctlDataInd data_ind,
131 L1ctlTrafficReq traffic_ind,
132 octetstring other
133 } with { variant "" };
134
135 type record L1ctlDlMessage {
136 L1ctlHeader header,
137 L1ctlDlInfo dl_info optional,
138 L1ctlDlPayload payload
139 } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
140 header.msg_type = L1CTL_RACH_CONF,
141 header.msg_type = L1CTL_DATA_IND,
142 header.msg_type = L1CTL_DATA_CONF,
143 header.msg_type = L1CTL_TRAFFIC_IND)"
144 variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
145 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
146 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
147 data_ind, header.msg_type = L1CTL_DATA_IND;
148 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
149 other, OTHERWISE;
150 )" };
151
152 external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring
153 with { extension "prototype(convert) encode(RAW)" };
154 external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage
155 with { extension "prototype(convert) decode(RAW)" };
156
157
158 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200159 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200160 RslLinkId link_id,
161 OCT2 padding
162 } with { variant "" };
163
164 type record L1ctlFbsbFlags {
165 BIT5 padding,
166 boolean sb,
167 boolean fb1,
168 boolean fb0
169 } with { variant "" };
170
171 type record L1ctlFbsbReq {
172 Arfcn arfcn,
173 uint16_t timeout_tdma_frames,
174 uint16_t freq_err_thresh1,
175 uint16_t freq_err_thresh2,
176 uint8_t num_freqerr_avg,
177 L1ctlFbsbFlags flags,
178 uint8_t sync_info_idx,
179 L1ctlCcchMode ccch_mode,
180 GsmRxLev rxlev_exp
181 } with { variant "" };
182
183 type record L1ctlCcchModeReq {
184 L1ctlTchMode tch_mode,
185 L1ctlAudioMode audio_mode,
186 OCT2 padding
187 } with { variant "" };
188
189 type record L1ctlTchModeReq {
190 L1ctlTchMode tch_mode,
191 L1ctlAudioMode audio_mode,
192 OCT2 padding
193 } with { variant "" };
194
195 type record L1ctlRachReq {
196 uint8_t ra,
197 uint8_t combined,
198 uint16_t offset
199 } with { variant "" };
200
201 type record L1ctlParReq {
202 int8_t ta,
203 uint8_t tx_power,
204 OCT2 padding
205 } with { variant "" };
206
207 type record L1ctlH1 {
208 uint8_t hsn,
209 uint8_t maio,
210 uint8_t n,
211 OCT1 padding,
212 bitstring ma length(64)
213 } with { variant "" };
214
215 type record L1ctlDmEstReq {
216 GsmTsc tsc,
217 uint8_t h,
218 Arfcn arfcn optional,
219 L1ctlH1 hopping optional,
220 L1ctlTchMode tch_mode,
221 L1ctlAudioMode audio_mode
222 } with { variant (arfcn) "PRESENCE(h = 0)"
223 variant (hopping) "PRESENCE(h = 1)" };
224
225 type record L1ctlReset {
226 L1ctlResetType reset_type,
227 OCT3 padding
228 } with { variant "" };
229
230
231 type record L1ctlTrafficReq {
232 octetstring data length(TRAFFIC_DATA_LEN)
233 } with { variant "" };
234
235 type union L1ctlUlPayload {
236 L1ctlFbsbReq fbsb_req,
237 L1ctlCcchModeReq ccch_mode_req,
238 L1ctlTchModeReq tch_mode_req,
239 L1ctlRachReq rach_req,
240 L1ctlParReq par_req,
241 L1ctlDmEstReq dm_est_req,
242 L1ctlReset reset_req,
243 //L1ctlNeighPmReq neigh_pm_req,
244 L1ctlTrafficReq traffic_req,
245 octetstring other
246 } with { variant "" };
247
248 type record L1ctlUlMessage {
249 L1ctlHeader header,
250 L1ctlUlInfo ul_info optional,
251 L1ctlUlPayload payload
252 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
253 header.msg_type = L1CTL_PARAM_REQ,
254 header.msg_type = L1CTL_CRYPTO_REQ,
255 header.msg_type = L1CTL_DATA_REQ,
256 header.msg_type = L1CTL_DM_EST_REQ,
257 header.msg_type = L1CTL_DM_FREQ_REQ,
258 header.msg_type = L1CTL_DM_REL_REQ,
259 header.msg_type = L1CTL_TRAFFIC_REQ)"
260 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
261 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
262 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
263 rach_req, header.msg_type = L1CTL_RACH_REQ;
264 par_req, header.msg_type = L1CTL_PARAM_REQ;
265 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
266 reset_req, header.msg_type = L1CTL_RESET_REQ;
267 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
268 other, OTHERWISE;
269 )" };
270
271 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
272 with { extension "prototype(convert) encode(RAW)" };
273 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
274 with { extension "prototype(convert) decode(RAW)" };
275
Harald Welte52c713c2017-07-16 15:44:44 +0200276 type record L1ctlUlMessageLV {
277 uint16_t len,
278 L1ctlUlMessage msg
279 } with { variant (len) "LENGTHTO(msg)" };
280
281 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
282 with { extension "prototype(convert) encode(RAW)" };
283 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
284 with { extension "prototype(convert) decode(RAW)" };
285
286 type record L1ctlDlMessageLV {
287 uint16_t len,
288 L1ctlDlMessage msg
289 } with { variant (len) "LENGTHTO(msg)" };
290
291 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
292 with { extension "prototype(convert) encode(RAW)" };
293 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
294 with { extension "prototype(convert) decode(RAW)" };
295
296
Harald Weltef6543322017-07-16 07:35:10 +0200297} with { encode "RAW" };