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