[layer23] DTMF support
[osmocom-bb.git] / src / host / layer23 / include / osmocom / bb / mobile / mncc.h
1 /* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface 
2  * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
3
4 /* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
5  * (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
6  * (C) 2009 by Andreas Eversberg <jolly@eversberg.eu>
7  *
8  * All Rights Reserved
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  */
25
26 #ifndef _MNCC_H
27 #define _MNCC_H
28
29 #include <osmocore/linuxlist.h>
30 #include <osmocore/mncc.h>
31
32 struct gsm_call {
33         struct llist_head       entry;
34
35         struct osmocom_ms       *ms;
36
37         uint32_t                callref;
38
39         uint8_t                 init; /* call initiated, no response yet */
40         uint8_t                 hold; /* call on hold */
41         uint8_t                 ring; /* call ringing/knocking */
42
43         struct timer_list       dtmf_timer;
44         uint8_t                 dtmf_state;
45         uint8_t                 dtmf_index;
46         char                    dtmf[32]; /* dtmf sequence */
47 };
48
49 #define DTMF_ST_IDLE            0       /* no DTMF active */
50 #define DTMF_ST_START           1       /* DTMF started, waiting for resp. */
51 #define DTMF_ST_MARK            2       /* wait tone duration */
52 #define DTMF_ST_STOP            3       /* DTMF stopped, waiting for resp. */
53 #define DTMF_ST_SPACE           4       /* wait space between tones */
54
55 #define MNCC_SETUP_REQ          0x0101
56 #define MNCC_SETUP_IND          0x0102
57 #define MNCC_SETUP_RSP          0x0103
58 #define MNCC_SETUP_CNF          0x0104
59 #define MNCC_SETUP_COMPL_REQ    0x0105
60 #define MNCC_SETUP_COMPL_IND    0x0106
61 /* MNCC_REJ_* is perfomed via MNCC_REL_* */
62 #define MNCC_CALL_CONF_IND      0x0107
63 #define MNCC_CALL_PROC_REQ      0x0108
64 #define MNCC_PROGRESS_REQ       0x0109
65 #define MNCC_ALERT_REQ          0x010a
66 #define MNCC_ALERT_IND          0x010b
67 #define MNCC_NOTIFY_REQ         0x010c
68 #define MNCC_NOTIFY_IND         0x010d
69 #define MNCC_DISC_REQ           0x010e
70 #define MNCC_DISC_IND           0x010f
71 #define MNCC_REL_REQ            0x0110
72 #define MNCC_REL_IND            0x0111
73 #define MNCC_REL_CNF            0x0112
74 #define MNCC_FACILITY_REQ       0x0113
75 #define MNCC_FACILITY_IND       0x0114
76 #define MNCC_START_DTMF_IND     0x0115
77 #define MNCC_START_DTMF_RSP     0x0116
78 #define MNCC_START_DTMF_REJ     0x0117
79 #define MNCC_STOP_DTMF_IND      0x0118
80 #define MNCC_STOP_DTMF_RSP      0x0119
81 #define MNCC_MODIFY_REQ         0x011a
82 #define MNCC_MODIFY_IND         0x011b
83 #define MNCC_MODIFY_RSP         0x011c
84 #define MNCC_MODIFY_CNF         0x011d
85 #define MNCC_MODIFY_REJ         0x011e
86 #define MNCC_HOLD_IND           0x011f
87 #define MNCC_HOLD_CNF           0x0120
88 #define MNCC_HOLD_REJ           0x0121
89 #define MNCC_RETRIEVE_IND       0x0122
90 #define MNCC_RETRIEVE_CNF       0x0123
91 #define MNCC_RETRIEVE_REJ       0x0124
92 #define MNCC_USERINFO_REQ       0x0125
93 #define MNCC_USERINFO_IND       0x0126
94 #define MNCC_REJ_REQ            0x0127
95 #define MNCC_REJ_IND            0x0128
96 #define MNCC_PROGRESS_IND       0x0129
97 #define MNCC_CALL_PROC_IND      0x012a
98 #define MNCC_CALL_CONF_REQ      0x012b
99 #define MNCC_START_DTMF_REQ     0x012c
100 #define MNCC_STOP_DTMF_REQ      0x012d
101 #define MNCC_HOLD_REQ           0x012e
102 #define MNCC_RETRIEVE_REQ       0x012f
103
104 #define MNCC_BRIDGE             0x0200
105 #define MNCC_FRAME_RECV         0x0201
106 #define MNCC_FRAME_DROP         0x0202
107 #define MNCC_LCHAN_MODIFY       0x0203
108
109 #define GSM_TCHF_FRAME          0x0300
110 #define GSM_TCHF_FRAME_EFR      0x0301
111
112 #define GSM_MAX_FACILITY        128
113 #define GSM_MAX_SSVERSION       128
114 #define GSM_MAX_USERUSER        128
115
116 #define MNCC_F_BEARER_CAP       0x0001
117 #define MNCC_F_CALLED           0x0002
118 #define MNCC_F_CALLING          0x0004
119 #define MNCC_F_REDIRECTING      0x0008
120 #define MNCC_F_CONNECTED        0x0010
121 #define MNCC_F_CAUSE            0x0020
122 #define MNCC_F_USERUSER         0x0040
123 #define MNCC_F_PROGRESS         0x0080
124 #define MNCC_F_EMERGENCY        0x0100
125 #define MNCC_F_FACILITY         0x0200
126 #define MNCC_F_SSVERSION        0x0400
127 #define MNCC_F_CCCAP            0x0800
128 #define MNCC_F_KEYPAD           0x1000
129 #define MNCC_F_SIGNAL           0x2000
130
131 struct gsm_mncc {
132         /* context based information */
133         u_int32_t       msg_type;
134         u_int32_t       callref;
135
136         /* which fields are present */
137         u_int32_t       fields;
138
139         /* data derived informations (MNCC_F_ based) */
140         struct gsm_mncc_bearer_cap      bearer_cap;
141         struct gsm_mncc_number          called;
142         struct gsm_mncc_number          calling;
143         struct gsm_mncc_number          redirecting;
144         struct gsm_mncc_number          connected;
145         struct gsm_mncc_cause           cause;
146         struct gsm_mncc_progress        progress;
147         struct gsm_mncc_useruser        useruser;
148         struct gsm_mncc_facility        facility;
149         struct gsm_mncc_cccap           cccap;
150         struct gsm_mncc_ssversion       ssversion;
151         struct  {
152                 int             sup;
153                 int             inv;
154         } clir;
155         int             signal;
156
157         /* data derived information, not MNCC_F based */
158         int             keypad;
159         int             more;
160         int             notify; /* 0..127 */
161         int             emergency;
162         char            imsi[16];
163
164         unsigned char   lchan_mode;
165 };
166
167 struct gsm_data_frame {
168         u_int32_t       msg_type;
169         u_int32_t       callref;
170         unsigned char   data[0];
171 };
172
173 const char *get_mncc_name(int value);
174 int mncc_recv(struct osmocom_ms *ms, int msg_type, void *arg);
175 void mncc_set_cause(struct gsm_mncc *data, int loc, int val);
176
177 #endif
178