blob: 956a1aeaadce43eec638bed5852eeb7f97fb23df [file] [log] [blame]
Harald Welte474fd7d2017-12-29 16:01:39 +01001module MNCC_Types {
2
3import from Osmocom_Types all;
4
5/* for architectures where 'int' is 32bit like x86_64 */
6type integer int with { variant "FIELDLENGTH(32)" };
7
8
9/* GSM 04.08 Bearer Capability: Rate Adaption */
10type enumerated GSM48_bcap_ra {
11 GSM48_BCAP_RA_NONE (0),
12 GSM48_BCAP_RA_V110_X30 (1),
13 GSM48_BCAP_RA_X31 (2),
14 GSM48_BCAP_RA_OTHER (3)
15};
16
17/* GSM 04.08 Bearer Capability: Signalling access protocol */
18type enumerated GSM48_bcap_sig_access {
19 GSM48_BCAP_SA_I440_I450 (1),
20 GSM48_BCAP_SA_X21 (2),
21 GSM48_BCAP_SA_X28_DP_IN (3),
22 GSM48_BCAP_SA_X28_DP_UN (4),
23 GSM48_BCAP_SA_X28_NDP (5),
24 GSM48_BCAP_SA_X32 (6)
25};
26
27/* GSM 04.08 Bearer Capability: User Rate */
28type enumerated GSM48_bcap_user_rate {
29 GSM48_BCAP_UR_300 (1),
30 GSM48_BCAP_UR_1200 (2),
31 GSM48_BCAP_UR_2400 (3),
32 GSM48_BCAP_UR_4800 (4),
33 GSM48_BCAP_UR_9600 (5),
34 GSM48_BCAP_UR_12000 (6),
35 GSM48_BCAP_UR_1200_75 (7)
36};
37
38/* GSM 04.08 Bearer Capability: Parity */
39type enumerated GSM48_bcap_parity {
40 GSM48_BCAP_PAR_ODD (0),
41 GSM48_BCAP_PAR_EVEN (2),
42 GSM48_BCAP_PAR_NONE (3),
43 GSM48_BCAP_PAR_ZERO (4),
44 GSM48_BCAP_PAR_ONE (5)
45};
46
47/* GSM 04.08 Bearer Capability: Intermediate Rate */
48type enumerated GSM48_bcap_interm_rate {
49 GSM48_BCAP_IR_8k (2),
50 GSM48_BCAP_IR_16k (3)
51};
52
53/* GSM 04.08 Bearer Capability: Transparency */
54type enumerated GSM48_bcap_transp {
55 GSM48_BCAP_TR_TRANSP (0),
56 GSM48_BCAP_TR_RLP (1),
57 GSM48_BCAP_TR_TR_PREF (2),
58 GSM48_BCAP_TR_RLP_PREF (3)
59};
60
61/* GSM 04.08 Bearer Capability: Modem Type */
62type enumerated GSM48_bcap_modem_type {
63 GSM48_BCAP_MT_NONE (0),
64 GSM48_BCAP_MT_V21 (1),
65 GSM48_BCAP_MT_V22 (2),
66 GSM48_BCAP_MT_V22bis (3),
67 GSM48_BCAP_MT_V23 (4),
68 GSM48_BCAP_MT_V26ter (5),
69 GSM48_BCAP_MT_V32 (6),
70 GSM48_BCAP_MT_UNDEF (7),
71 GSM48_BCAP_MT_AUTO_1 (8)
72};
73
74type enumerated MNCC_MsgType {
75 MNCC_SETUP_REQ ('0101'O),
76 MNCC_SETUP_IND ('0102'O),
77 MNCC_SETUP_RSP ('0103'O),
78 MNCC_SETUP_CNF ('0104'O),
79 MNCC_SETUP_COMPL_REQ ('0105'O),
80 MNCC_SETUP_COMPL_IND ('0106'O),
81 MNCC_CALL_CONF_IND ('0107'O),
82 MNCC_CALL_PROC_REQ ('0108'O),
83 MNCC_PROGRESS_REQ ('0109'O),
84 MNCC_ALERT_REQ ('010a'O),
85 MNCC_ALERT_IND ('010b'O),
86 MNCC_NOTIFY_REQ ('010c'O),
87 MNCC_NOTIFY_IND ('010d'O),
88 MNCC_DISC_REQ ('010e'O),
89 MNCC_DISC_IND ('010f'O),
90 MNCC_REL_REQ ('0110'O),
91 MNCC_REL_IND ('0111'O),
92 MNCC_REL_CNF ('0112'O),
93 MNCC_FACILITY_REQ ('0113'O),
94 MNCC_FACILITY_IND ('0114'O),
95 MNCC_START_DTMF_IND ('0115'O),
96 MNCC_START_DTMF_RSP ('0116'O),
97 MNCC_START_DTMF_REJ ('0117'O),
98 MNCC_STOP_DTMF_IND ('0118'O),
99 MNCC_STOP_DTMF_RSP ('0119'O),
100 MNCC_MODIFY_REQ ('011a'O),
101 MNCC_MODIFY_IND ('011b'O),
102 MNCC_MODIFY_RSP ('011c'O),
103 MNCC_MODIFY_CNF ('011d'O),
104 MNCC_MODIFY_REJ ('011e'O),
105 MNCC_HOLD_IND ('011f'O),
106 MNCC_HOLD_CNF ('0120'O),
107 MNCC_HOLD_REJ ('0121'O),
108 MNCC_RETRIEVE_IND ('0122'O),
109 MNCC_RETRIEVE_CNF ('0123'O),
110 MNCC_RETRIEVE_REJ ('0124'O),
111 MNCC_USERINFO_REQ ('0125'O),
112 MNCC_USERINFO_IND ('0126'O),
113 MNCC_REJ_REQ ('0127'O),
114 MNCC_REJ_IND ('0128'O),
115
116 MNCC_BRIDGE ('0200'O),
117 MNCC_FRAME_RECV ('0201'O),
118 MNCC_FRAME_DROP ('0202'O),
119 MNCC_LCHAN_MODIFY ('0203'O),
120 MNCC_RTP_CREATE ('0204'O),
121 MNCC_RTP_CONNECT ('0205'O),
122 MNCC_RTP_FREE ('0206'O),
123
124 GSM_TCHF_FRAME ('0300'O),
125 GSM_TCHF_FRAME_EFR ('0301'O),
126 GSM_TCHH_FRAME ('0302'O),
127 GSM_TCH_FRAME_AMR ('0303'O),
128 GSM_BAD_FRAME ('03ff'O),
129
130 MNCC_SOCKET_HELLO ('0400'O)
131};
132
133const integer GSM_MAX_FACILITY := 128;
134const integer GSM_MAX_SSVERSION := 128;
135const integer GSM_MAX_USERUSER := 128;
136
137type record MNCC_bearer_cap_data {
138 GSM48_bcap_ra rate_adaptation,
139 GSM48_bcap_sig_access sig_access,
140 int async,
141 int nr_stop_bits,
142 int nr_data_bits,
143 GSM48_bcap_user_rate user_rate,
144 GSM48_bcap_parity parity,
145 GSM48_bcap_interm_rate interm_rate,
146 GSM48_bcap_transp transp,
147 GSM48_bcap_modem_type modem_type
148};
149
150type record length(0..8) of int MNCC_speech_vers;
151
152/* Expanded fields from GSM TS 04.08, Table 10.5.102 */
153type record MNCC_bearer_cap {
154 int transfer,
155 int mode,
156 int coding,
157 int radio,
158 int speech_ctm,
159 MNCC_speech_vers speech_ver,
160 MNCC_bearer_cap_data data optional
161};
162
163template MNCC_bearer_cap ts_MNCC_bcap_voice := {
164 transfer := 0, /* speech */
165 mode := 0, /* circuit */
166 coding := 0, /* GSM standard */
167 radio := 3, /* FR/HR, FR preferred */
168 speech_ctm := 0, /* not supported */
169 speech_ver := { 0, 2, 4, 1, 5 },
170 data := omit
171};
172
173type record MNCC_number {
174 GSM48_type_of_number number_type,
175 GSM48_num_plan_ind plan,
176 GSM48_present_ind presence,
177 GSM48_screening_ind screen,
178 charstring number
179};
180
181/* 24.008 10.5.118 */
182type enumerated GSM48_num_plan_ind {
183 GSM48_NUMPLAN_UNKNOWN (0),
184 GSM48_NUMPLAN_E164 (1),
185 GSM48_NUMPLAN_X121 (3),
186 GSM48_NUMPLAN_F69 (4),
187 GSM48_NUMPLAN_NATIONAL (8),
188 GSM48_NUMPLAN_PRIVATE (9),
189 GSM48_NUMPLAN_CTS (11),
190 GSM48_NUMPLAN_RESERVED (15)
191};
192
193/* 04.08 10.5.118 */
194type enumerated GSM48_type_of_number {
195 GSM48_TON_UNKNOWN (0),
196 GSM48_TON_INTERNATIONAL (1),
197 GSM48_TON_NATIONAL (2),
198 GSM48_TON_NETWORK_SPECIFIC (3),
199 GSM48_TON_SHORT_CODE (4)
200};
201
202/* 04.08 10.5.120 */
203type enumerated GSM48_present_ind {
204 GSM48_PRES_IND_ALLOWED (0),
205 GSM48_PRES_IND_RESTRICTED (1),
206 GSM48_PRES_IND_NUM_NOT_AVAIL (2),
207 GSM48_PRES_IND_RESERVED (3)
208};
209
210type enumerated GSM48_screening_ind {
211 GSM48_SCR_IND_NOT_SCREENED (0),
212 GSM48_SCR_IND_VERIF_PASSED (1),
213 GSM48_SCR_IND_VERIF_FAILED (2),
214 GSM48_SCR_IND_NETW_PROVIDED (3)
215};
216
217
218template MNCC_number ts_MNCC_number(charstring number,
219 GSM48_type_of_number ton := GSM48_TON_INTERNATIONAL,
220 GSM48_num_plan_ind npi := GSM48_NUMPLAN_E164,
221 GSM48_present_ind pres := GSM48_PRES_IND_ALLOWED,
222 GSM48_screening_ind screen := GSM48_SCR_IND_NOT_SCREENED) := {
223 number_type := ton,
224 plan := npi,
225 presence := pres,
226 screen := screen,
227 number := number
228}
229
230type record MNCC_cause {
231 int location,
232 int coding,
233 int rec,
234 int rec_val,
235 int val,
236 octetstring diag
237};
238
239type record MNCC_useruser {
240 int proto,
241 charstring info
242};
243
244type record MNCC_progress {
245 int coding,
246 int location,
247 int descr
248};
249
250type record MNCC_cccap {
251 int dtmf,
252 int pcp
253};
254
255type enumerated MNCC_bcap {
256 GSM_MNCC_BCAP_SPEECH (0),
257 GSM_MNCC_BCAP_UNR_DIG (1),
258 GSM_MNCC_BCAP_AUDIO (2),
259 GSM_MNCC_BCAP_FAX_G3 (3),
260 GSM_MNCC_BCAP_OTHER_ITC (4),
261 GSM_MNCC_BCAP_RESERVED (7)
262};
263
264
265type record MNCC_PDU_Signal {
266 uint32_t callref,
267
268 MNCC_bearer_cap bearer_cap optional,
269 MNCC_number called optional,
270 MNCC_number calling optional,
271 MNCC_number redirecting optional,
272 MNCC_number connected optional,
273 MNCC_cause cause optional,
274 MNCC_progress progress optional,
275 MNCC_useruser useruser optional,
276 charstring facility optional,
277 MNCC_cccap cccap optional,
278 charstring ssversion optional,
279
280 int clir_sup,
281 int clir_inv,
282 int signal optional,
283
284 int keypad optional,
285 int more,
286 int notify (0..127),
287 int emergency optional,
288 charstring imsi,
289
290 uint8_t lchan_type, /* empty in OSmoMSC */
291 uint8_t lchan_mode /* empty in OsmoMSC */
292};
293
294
295type record MNCC_PDU_Data {
296 uint32_t callref,
297 octetstring data
298};
299
300type record MNCC_PDU_Rtp {
301 uint32_t callref,
302 uint32_t ip,
303 uint16_t rtp_port,
304 uint32_t payload_type,
305 uint32_t payload_msg_type
306};
307
308type record MNCC_PDU_Hello {
309 uint32_t version,
310 uint32_t mncc_size,
311 uint32_t data_frame_size,
312 uint32_t called_offset,
313 uint32_t signal_offset,
314 uint32_t emergency_offset,
315 uint32_t lchan_type_offset
316};
317
318
319type union MNCC_MsgUnion {
320 MNCC_PDU_Signal signal,
321 MNCC_PDU_Data data,
322 MNCC_PDU_Rtp rtp,
323 MNCC_PDU_Hello hello
324};
325
326
327type record MNCC_PDU {
328 MNCC_MsgType msg_type,
329 MNCC_MsgUnion u
330} with { variant (u) "CROSSTAG(
331 hello, msg_type = MNCC_SOCKET_HELLO;
332 rtp, { msg_type = MNCC_RTP_CREATE,
333 msg_type = MNCC_RTP_CONNECT,
334 msg_type = MNCC_RTP_FREE };
335 data, { msg_type = GSM_TCHF_FRAME,
336 msg_type = GSM_TCHF_FRAME_EFR,
337 msg_type = GSM_TCHH_FRAME,
338 msg_type = GSM_TCH_FRAME_AMR,
339 msg_type = GSM_BAD_FRAME };
340 signal, OTHERWISE
341 )"
342};
343
344external function enc_MNCC_PDU(in MNCC_PDU pdu) return octetstring;
345
346external function dec_MNCC_PDU(in octetstring stream) return MNCC_PDU;
347
348
349template MNCC_PDU ts_MNCC_Sign(MNCC_MsgType msg_type, MNCC_PDU_Signal sign) := {
350 msg_type := msg_type,
351 u := {
352 signal := sign
353 }
354}
355
356template MNCC_PDU ts_MNCC_SETUP(uint32_t call_id, charstring called, charstring calling) := {
357 msg_type := MNCC_SETUP_REQ,
358 u := {
359 signal := {
360 callref := call_id,
361 bearer_cap := ts_MNCC_bcap_voice,
362 called := valueof(ts_MNCC_number(called)),
363 calling := valueof(ts_MNCC_number(calling)),
364 redirecting := omit,
365 connected := omit,
366 cause := omit,
367 progress := omit,
368 useruser := omit,
369 facility := omit,
370 cccap := omit,
371 ssversion := omit,
372 clir_sup := 0,
373 clir_inv := 0,
374 signal := omit,
375 keypad := omit,
376 more := 0,
377 notify := 0,
378 emergency := omit,
379 imsi := "1234",
380 lchan_type := 0,
381 lchan_mode := 0
382 }
383 }
384};
385
386
387} with { encode "RAW" ; variant "FIELDORDER(msb)" }