comparison include/mncc.h @ 0:0e907d59d815

include: import from ThemWi1
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 Jun 2022 18:30:55 -0800
parents
children 5b0f685fd2ed
comparison
equal deleted inserted replaced
-1:000000000000 0:0e907d59d815
1 /*
2 * This header file defines the MNCC interface for passing call control
3 * into and out of Osmocom GSM network. It has been put together by
4 * assembling bits from several different Osmocom header files.
5 */
6
7 #ifndef __MNCC_H
8 #define __MNCC_H
9
10 #define GSM_MAX_FACILITY 128
11 #define GSM_MAX_SSVERSION 128
12 #define GSM_MAX_USERUSER 128
13
14 /* GSM 04.08 Bearer Capability: Information Transfer Capability */
15 enum gsm48_bcap_itcap {
16 GSM48_BCAP_ITCAP_SPEECH = 0,
17 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
18 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
19 GSM48_BCAP_ITCAP_FAX_G3 = 3,
20 GSM48_BCAP_ITCAP_OTHER = 5,
21 GSM48_BCAP_ITCAP_RESERVED = 7,
22 };
23
24 /* GSM 04.08 Bearer Capability: Transfer Mode */
25 enum gsm48_bcap_tmod {
26 GSM48_BCAP_TMOD_CIRCUIT = 0,
27 GSM48_BCAP_TMOD_PACKET = 1,
28 };
29
30 /* GSM 04.08 Bearer Capability: Coding Standard */
31 enum gsm48_bcap_coding {
32 GSM48_BCAP_CODING_GSM_STD = 0,
33 };
34
35 /* GSM 04.08 Bearer Capability: Radio Channel Requirements */
36 enum gsm48_bcap_rrq {
37 GSM48_BCAP_RRQ_FR_ONLY = 1,
38 GSM48_BCAP_RRQ_DUAL_HR = 2,
39 GSM48_BCAP_RRQ_DUAL_FR = 3,
40 };
41
42 /* GSM 04.08 Bearer Capability: Rate Adaption */
43 enum gsm48_bcap_ra {
44 GSM48_BCAP_RA_NONE = 0,
45 GSM48_BCAP_RA_V110_X30 = 1,
46 GSM48_BCAP_RA_X31 = 2,
47 GSM48_BCAP_RA_OTHER = 3,
48 };
49
50 /* GSM 04.08 Bearer Capability: Signalling access protocol */
51 enum gsm48_bcap_sig_access {
52 GSM48_BCAP_SA_I440_I450 = 1,
53 GSM48_BCAP_SA_X21 = 2,
54 GSM48_BCAP_SA_X28_DP_IN = 3,
55 GSM48_BCAP_SA_X28_DP_UN = 4,
56 GSM48_BCAP_SA_X28_NDP = 5,
57 GSM48_BCAP_SA_X32 = 6,
58 };
59
60 /* GSM 04.08 Bearer Capability: User Rate */
61 enum gsm48_bcap_user_rate {
62 GSM48_BCAP_UR_300 = 1,
63 GSM48_BCAP_UR_1200 = 2,
64 GSM48_BCAP_UR_2400 = 3,
65 GSM48_BCAP_UR_4800 = 4,
66 GSM48_BCAP_UR_9600 = 5,
67 GSM48_BCAP_UR_12000 = 6,
68 GSM48_BCAP_UR_1200_75 = 7,
69 };
70
71 /* GSM 04.08 Bearer Capability: Parity */
72 enum gsm48_bcap_parity {
73 GSM48_BCAP_PAR_ODD = 0,
74 GSM48_BCAP_PAR_EVEN = 2,
75 GSM48_BCAP_PAR_NONE = 3,
76 GSM48_BCAP_PAR_ZERO = 4,
77 GSM48_BCAP_PAR_ONE = 5,
78 };
79
80 /* GSM 04.08 Bearer Capability: Intermediate Rate */
81 enum gsm48_bcap_interm_rate {
82 GSM48_BCAP_IR_8k = 2,
83 GSM48_BCAP_IR_16k = 3,
84 };
85
86 /* GSM 04.08 Bearer Capability: Transparency */
87 enum gsm48_bcap_transp {
88 GSM48_BCAP_TR_TRANSP = 0,
89 GSM48_BCAP_TR_RLP = 1,
90 GSM48_BCAP_TR_TR_PREF = 2,
91 GSM48_BCAP_TR_RLP_PREF = 3,
92 };
93
94 /* GSM 04.08 Bearer Capability: Modem Type */
95 enum gsm48_bcap_modem_type {
96 GSM48_BCAP_MT_NONE = 0,
97 GSM48_BCAP_MT_V21 = 1,
98 GSM48_BCAP_MT_V22 = 2,
99 GSM48_BCAP_MT_V22bis = 3,
100 GSM48_BCAP_MT_V23 = 4,
101 GSM48_BCAP_MT_V26ter = 5,
102 GSM48_BCAP_MT_V32 = 6,
103 GSM48_BCAP_MT_UNDEF = 7,
104 GSM48_BCAP_MT_AUTO_1 = 8,
105 };
106
107 /*! GSM 04.08 Bearer Capability: Speech Version Indication
108 * (See also 3GPP TS 24.008, Table 10.5.103) */
109 enum gsm48_bcap_speech_ver {
110 GSM48_BCAP_SV_FR = 0, /*!< GSM FR V1 (GSM FR) */
111 GSM48_BCAP_SV_HR = 1, /*!< GSM HR V1 (GSM HR) */
112 GSM48_BCAP_SV_EFR = 2, /*!< GSM FR V2 (GSM EFR) */
113 GSM48_BCAP_SV_AMR_F = 4, /*!< GSM FR V3 (FR AMR) */
114 GSM48_BCAP_SV_AMR_H = 5, /*!< GSM HR V3 (HR_AMR) */
115 GSM48_BCAP_SV_AMR_OFW = 6, /*!< GSM FR V4 (OFR AMR-WB) */
116 GSM48_BCAP_SV_AMR_OHW = 7, /*!< GSM HR V4 (OHR AMR-WB) */
117 GSM48_BCAP_SV_AMR_FW = 8, /*!< GSM FR V5 (FR AMR-WB) */
118 GSM48_BCAP_SV_AMR_OH = 11, /*!< GSM HR V6 (OHR AMR) */
119 };
120
121 /* Expanded fields from GSM TS 04.08, Table 10.5.102 */
122 struct gsm_mncc_bearer_cap {
123 int transfer; /* Information Transfer Capability, see enum gsm48_bcap_itcap. */
124 int mode; /* Transfer Mode, see enum gsm48_bcap_tmod. */
125 int coding; /* Coding Standard, see enum gsm48_bcap_coding.*/
126 int radio; /* Radio Channel Requirement, see enum gsm48_bcap_rrq. */
127 int speech_ctm; /* CTM text telephony indication */
128 int speech_ver[8]; /* Speech version indication, see enum gsm48_bcap_speech_ver; -1 marks end */
129 struct {
130 enum gsm48_bcap_ra rate_adaption;
131 enum gsm48_bcap_sig_access sig_access;
132 int async;
133 int nr_stop_bits;
134 int nr_data_bits;
135 enum gsm48_bcap_user_rate user_rate;
136 enum gsm48_bcap_parity parity;
137 enum gsm48_bcap_interm_rate interm_rate;
138 enum gsm48_bcap_transp transp;
139 enum gsm48_bcap_modem_type modem_type;
140 } data;
141 };
142
143 struct gsm_mncc_number {
144 int type;
145 int plan;
146 int present;
147 int screen;
148 char number[33];
149 };
150
151 struct gsm_mncc_cause {
152 int location;
153 int coding;
154 int rec;
155 int rec_val;
156 int value;
157 int diag_len;
158 char diag[32];
159 };
160
161 struct gsm_mncc_useruser {
162 int proto;
163 char info[GSM_MAX_USERUSER + 1]; /* + termination char */
164 };
165
166 struct gsm_mncc_progress {
167 int coding;
168 int location;
169 int descr;
170 };
171
172 struct gsm_mncc_facility {
173 int len;
174 char info[GSM_MAX_FACILITY];
175 };
176
177 struct gsm_mncc_ssversion {
178 int len;
179 char info[GSM_MAX_SSVERSION];
180 };
181
182 struct gsm_mncc_cccap {
183 int dtmf;
184 int pcp;
185 };
186
187 #define MNCC_SETUP_REQ 0x0101
188 #define MNCC_SETUP_IND 0x0102
189 #define MNCC_SETUP_RSP 0x0103
190 #define MNCC_SETUP_CNF 0x0104
191 #define MNCC_SETUP_COMPL_REQ 0x0105
192 #define MNCC_SETUP_COMPL_IND 0x0106
193 /* MNCC_REJ_* is performed via MNCC_REL_* */
194 #define MNCC_CALL_CONF_IND 0x0107
195 #define MNCC_CALL_PROC_REQ 0x0108
196 #define MNCC_PROGRESS_REQ 0x0109
197 #define MNCC_ALERT_REQ 0x010a
198 #define MNCC_ALERT_IND 0x010b
199 #define MNCC_NOTIFY_REQ 0x010c
200 #define MNCC_NOTIFY_IND 0x010d
201 #define MNCC_DISC_REQ 0x010e
202 #define MNCC_DISC_IND 0x010f
203 #define MNCC_REL_REQ 0x0110
204 #define MNCC_REL_IND 0x0111
205 #define MNCC_REL_CNF 0x0112
206 #define MNCC_FACILITY_REQ 0x0113
207 #define MNCC_FACILITY_IND 0x0114
208 #define MNCC_START_DTMF_IND 0x0115
209 #define MNCC_START_DTMF_RSP 0x0116
210 #define MNCC_START_DTMF_REJ 0x0117
211 #define MNCC_STOP_DTMF_IND 0x0118
212 #define MNCC_STOP_DTMF_RSP 0x0119
213 #define MNCC_MODIFY_REQ 0x011a
214 #define MNCC_MODIFY_IND 0x011b
215 #define MNCC_MODIFY_RSP 0x011c
216 #define MNCC_MODIFY_CNF 0x011d
217 #define MNCC_MODIFY_REJ 0x011e
218 #define MNCC_HOLD_IND 0x011f
219 #define MNCC_HOLD_CNF 0x0120
220 #define MNCC_HOLD_REJ 0x0121
221 #define MNCC_RETRIEVE_IND 0x0122
222 #define MNCC_RETRIEVE_CNF 0x0123
223 #define MNCC_RETRIEVE_REJ 0x0124
224 #define MNCC_USERINFO_REQ 0x0125
225 #define MNCC_USERINFO_IND 0x0126
226 #define MNCC_REJ_REQ 0x0127
227 #define MNCC_REJ_IND 0x0128
228
229 #define MNCC_BRIDGE 0x0200
230 #define MNCC_FRAME_RECV 0x0201
231 #define MNCC_FRAME_DROP 0x0202
232 #define MNCC_LCHAN_MODIFY 0x0203
233 #define MNCC_RTP_CREATE 0x0204
234 #define MNCC_RTP_CONNECT 0x0205
235 #define MNCC_RTP_FREE 0x0206
236
237 #define GSM_TCHF_FRAME 0x0300
238 #define GSM_TCHF_FRAME_EFR 0x0301
239 #define GSM_TCHH_FRAME 0x0302
240 #define GSM_TCH_FRAME_AMR 0x0303
241 #define GSM_BAD_FRAME 0x03ff
242
243 #define MNCC_SOCKET_HELLO 0x0400
244
245 #define GSM_MAX_FACILITY 128
246 #define GSM_MAX_SSVERSION 128
247 #define GSM_MAX_USERUSER 128
248
249 #define MNCC_F_BEARER_CAP 0x0001
250 #define MNCC_F_CALLED 0x0002
251 #define MNCC_F_CALLING 0x0004
252 #define MNCC_F_REDIRECTING 0x0008
253 #define MNCC_F_CONNECTED 0x0010
254 #define MNCC_F_CAUSE 0x0020
255 #define MNCC_F_USERUSER 0x0040
256 #define MNCC_F_PROGRESS 0x0080
257 #define MNCC_F_EMERGENCY 0x0100
258 #define MNCC_F_FACILITY 0x0200
259 #define MNCC_F_SSVERSION 0x0400
260 #define MNCC_F_CCCAP 0x0800
261 #define MNCC_F_KEYPAD 0x1000
262 #define MNCC_F_SIGNAL 0x2000
263 #define MNCC_F_GCR 0x4000
264
265 struct gsm_mncc {
266 /* context based information */
267 uint32_t msg_type;
268 uint32_t callref;
269
270 /* which fields are present */
271 uint32_t fields;
272
273 /* data derived information (MNCC_F_ based) */
274 struct gsm_mncc_bearer_cap bearer_cap;
275 struct gsm_mncc_number called;
276 struct gsm_mncc_number calling;
277 struct gsm_mncc_number redirecting;
278 struct gsm_mncc_number connected;
279 struct gsm_mncc_cause cause;
280 struct gsm_mncc_progress progress;
281 struct gsm_mncc_useruser useruser;
282 struct gsm_mncc_facility facility;
283 struct gsm_mncc_cccap cccap;
284 struct gsm_mncc_ssversion ssversion;
285 struct {
286 int sup;
287 int inv;
288 } clir;
289 int signal;
290
291 /* data derived information, not MNCC_F based */
292 int keypad;
293 int more;
294 int notify; /* 0..127 */
295 int emergency;
296 char imsi[16];
297
298 unsigned char lchan_type;
299 unsigned char lchan_mode;
300
301 /* Global Call Reference (encoded as per 3GPP TS 29.205) */
302 uint8_t gcr[16];
303
304 /* A buffer to contain SDP ('\0' terminated) */
305 char sdp[1024];
306 };
307
308 struct gsm_data_frame {
309 uint32_t msg_type;
310 uint32_t callref;
311 unsigned char data[0];
312 };
313
314 #define MNCC_SOCK_VERSION 8
315 struct gsm_mncc_hello {
316 uint32_t msg_type;
317 uint32_t version;
318
319 /* send the sizes of the structs */
320 uint32_t mncc_size;
321 uint32_t data_frame_size;
322
323 /* send some offsets */
324 uint32_t called_offset;
325 uint32_t signal_offset;
326 uint32_t emergency_offset;
327 uint32_t lchan_type_offset;
328 };
329
330 struct gsm_mncc_rtp {
331 uint32_t msg_type;
332 uint32_t callref;
333 struct sockaddr_storage addr;
334 uint32_t payload_type;
335 uint32_t payload_msg_type;
336 char sdp[1024];
337 };
338
339 struct gsm_mncc_bridge {
340 uint32_t msg_type;
341 uint32_t callref[2];
342 };
343
344 union mncc_msg {
345 uint32_t msg_type;
346 struct gsm_mncc signal;
347 struct gsm_mncc_hello hello;
348 struct gsm_data_frame data_frame;
349 struct gsm_mncc_rtp rtp;
350 struct gsm_mncc_bridge bridge;
351 };
352
353 #endif /* include guard */