blob: 500222763ed3095aa1fab1154a1c89e55505a63c [file] [log] [blame]
Neels Hofmeyrc4628a32018-12-07 14:47:34 +01001/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface
Harald Welte4bfdfe72009-06-10 23:11:52 +08002 * 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 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +010010 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
Harald Welte4bfdfe72009-06-10 23:11:52 +080012 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * GNU Affero General Public License for more details.
Harald Welte4bfdfe72009-06-10 23:11:52 +080018 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010019 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte4bfdfe72009-06-10 23:11:52 +080021 *
22 */
23
24#ifndef _MNCC_H
25#define _MNCC_H
26
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010027#include <osmocom/core/linuxlist.h>
28#include <osmocom/gsm/mncc.h>
Keith Whytea1a70be2021-05-16 02:59:52 +020029#include <osmocom/gsm/gsm29205.h>
Harald Welte4bfdfe72009-06-10 23:11:52 +080030
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +010031#include <stdint.h>
Pau Espin Pedroleeda9e12020-09-03 22:11:03 +020032#include <netinet/in.h>
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +010033
Sylvain Munaut98b53cb2010-12-01 22:38:51 +010034struct gsm_network;
Harald Welte29b64e92010-12-23 01:07:46 +010035struct msgb;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010036struct gsm0808_channel_type;
Sylvain Munaut98b53cb2010-12-01 22:38:51 +010037
38
Harald Welte4bfdfe72009-06-10 23:11:52 +080039/* One end of a call */
40struct gsm_call {
41 struct llist_head entry;
42
43 /* network handle */
Max6b3cef02019-01-15 13:43:45 +010044 struct gsm_network *net;
Harald Welte4bfdfe72009-06-10 23:11:52 +080045
46 /* the 'local' transaction */
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +010047 uint32_t callref;
Harald Welte4bfdfe72009-06-10 23:11:52 +080048 /* the 'remote' transaction */
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +010049 uint32_t remote_ref;
Harald Welte4bfdfe72009-06-10 23:11:52 +080050};
51
52#define MNCC_SETUP_REQ 0x0101
53#define MNCC_SETUP_IND 0x0102
54#define MNCC_SETUP_RSP 0x0103
55#define MNCC_SETUP_CNF 0x0104
56#define MNCC_SETUP_COMPL_REQ 0x0105
57#define MNCC_SETUP_COMPL_IND 0x0106
Martin Hauke3f07dac2019-11-14 17:49:08 +010058/* MNCC_REJ_* is performed via MNCC_REL_* */
Harald Welte4bfdfe72009-06-10 23:11:52 +080059#define MNCC_CALL_CONF_IND 0x0107
60#define MNCC_CALL_PROC_REQ 0x0108
61#define MNCC_PROGRESS_REQ 0x0109
62#define MNCC_ALERT_REQ 0x010a
63#define MNCC_ALERT_IND 0x010b
64#define MNCC_NOTIFY_REQ 0x010c
65#define MNCC_NOTIFY_IND 0x010d
66#define MNCC_DISC_REQ 0x010e
67#define MNCC_DISC_IND 0x010f
68#define MNCC_REL_REQ 0x0110
69#define MNCC_REL_IND 0x0111
70#define MNCC_REL_CNF 0x0112
71#define MNCC_FACILITY_REQ 0x0113
72#define MNCC_FACILITY_IND 0x0114
73#define MNCC_START_DTMF_IND 0x0115
74#define MNCC_START_DTMF_RSP 0x0116
75#define MNCC_START_DTMF_REJ 0x0117
76#define MNCC_STOP_DTMF_IND 0x0118
77#define MNCC_STOP_DTMF_RSP 0x0119
78#define MNCC_MODIFY_REQ 0x011a
79#define MNCC_MODIFY_IND 0x011b
80#define MNCC_MODIFY_RSP 0x011c
81#define MNCC_MODIFY_CNF 0x011d
82#define MNCC_MODIFY_REJ 0x011e
83#define MNCC_HOLD_IND 0x011f
84#define MNCC_HOLD_CNF 0x0120
85#define MNCC_HOLD_REJ 0x0121
86#define MNCC_RETRIEVE_IND 0x0122
87#define MNCC_RETRIEVE_CNF 0x0123
88#define MNCC_RETRIEVE_REJ 0x0124
89#define MNCC_USERINFO_REQ 0x0125
90#define MNCC_USERINFO_IND 0x0126
91#define MNCC_REJ_REQ 0x0127
92#define MNCC_REJ_IND 0x0128
93
94#define MNCC_BRIDGE 0x0200
95#define MNCC_FRAME_RECV 0x0201
96#define MNCC_FRAME_DROP 0x0202
97#define MNCC_LCHAN_MODIFY 0x0203
Holger Hans Peter Freytherffbf45e2015-07-14 16:03:41 +020098#define MNCC_RTP_CREATE 0x0204
99#define MNCC_RTP_CONNECT 0x0205
100#define MNCC_RTP_FREE 0x0206
Harald Welte4bfdfe72009-06-10 23:11:52 +0800101
Harald Welteda7ab742009-12-19 22:23:05 +0100102#define GSM_TCHF_FRAME 0x0300
Harald Welteaca8f152009-12-19 23:06:41 +0100103#define GSM_TCHF_FRAME_EFR 0x0301
Andreas Eversbergf78fc4e2014-01-31 09:02:01 +0100104#define GSM_TCHH_FRAME 0x0302
105#define GSM_TCH_FRAME_AMR 0x0303
106#define GSM_BAD_FRAME 0x03ff
Harald Welte4bfdfe72009-06-10 23:11:52 +0800107
Holger Hans Peter Freyther347e7ba2011-10-21 14:12:46 +0200108#define MNCC_SOCKET_HELLO 0x0400
109
Harald Welte4bfdfe72009-06-10 23:11:52 +0800110#define GSM_MAX_FACILITY 128
111#define GSM_MAX_SSVERSION 128
112#define GSM_MAX_USERUSER 128
113
114#define MNCC_F_BEARER_CAP 0x0001
115#define MNCC_F_CALLED 0x0002
116#define MNCC_F_CALLING 0x0004
117#define MNCC_F_REDIRECTING 0x0008
118#define MNCC_F_CONNECTED 0x0010
119#define MNCC_F_CAUSE 0x0020
120#define MNCC_F_USERUSER 0x0040
121#define MNCC_F_PROGRESS 0x0080
122#define MNCC_F_EMERGENCY 0x0100
123#define MNCC_F_FACILITY 0x0200
124#define MNCC_F_SSVERSION 0x0400
125#define MNCC_F_CCCAP 0x0800
126#define MNCC_F_KEYPAD 0x1000
127#define MNCC_F_SIGNAL 0x2000
128
Harald Welte4bfdfe72009-06-10 23:11:52 +0800129struct gsm_mncc {
130 /* context based information */
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +0100131 uint32_t msg_type;
132 uint32_t callref;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800133
134 /* which fields are present */
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +0100135 uint32_t fields;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800136
Martin Hauke3f07dac2019-11-14 17:49:08 +0100137 /* data derived information (MNCC_F_ based) */
Harald Welte4bfdfe72009-06-10 23:11:52 +0800138 struct gsm_mncc_bearer_cap bearer_cap;
139 struct gsm_mncc_number called;
140 struct gsm_mncc_number calling;
141 struct gsm_mncc_number redirecting;
142 struct gsm_mncc_number connected;
143 struct gsm_mncc_cause cause;
144 struct gsm_mncc_progress progress;
145 struct gsm_mncc_useruser useruser;
146 struct gsm_mncc_facility facility;
147 struct gsm_mncc_cccap cccap;
148 struct gsm_mncc_ssversion ssversion;
149 struct {
150 int sup;
151 int inv;
152 } clir;
153 int signal;
154
155 /* data derived information, not MNCC_F based */
156 int keypad;
157 int more;
158 int notify; /* 0..127 */
159 int emergency;
Andreas Eversbergc079be42009-06-15 23:22:09 +0200160 char imsi[16];
Philipp Maierfe6acd62017-12-05 13:02:37 +0100161
162 unsigned char lchan_type;
163 unsigned char lchan_mode;
Keith Whytea1a70be2021-05-16 02:59:52 +0200164 struct osmo_gcr_parsed gcr;
Neels Hofmeyrb4552052019-10-21 03:00:26 +0200165 /* A buffer to contain SDP ('\0' terminated) */
166 char sdp[1024];
Harald Welte4bfdfe72009-06-10 23:11:52 +0800167};
168
Harald Welteda7ab742009-12-19 22:23:05 +0100169struct gsm_data_frame {
Holger Hans Peter Freyther59234a32011-01-06 14:42:15 +0100170 uint32_t msg_type;
171 uint32_t callref;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800172 unsigned char data[0];
173};
174
Keith Whytea1a70be2021-05-16 02:59:52 +0200175#define MNCC_SOCK_VERSION 8
Holger Hans Peter Freyther347e7ba2011-10-21 14:12:46 +0200176struct gsm_mncc_hello {
177 uint32_t msg_type;
178 uint32_t version;
Holger Hans Peter Freyther9e7837a2012-01-15 00:38:35 +0100179
180 /* send the sizes of the structs */
181 uint32_t mncc_size;
182 uint32_t data_frame_size;
183
184 /* send some offsets */
185 uint32_t called_offset;
186 uint32_t signal_offset;
187 uint32_t emergency_offset;
Philipp Maierfe6acd62017-12-05 13:02:37 +0100188 uint32_t lchan_type_offset;
Holger Hans Peter Freyther347e7ba2011-10-21 14:12:46 +0200189};
190
Holger Hans Peter Freytherffbf45e2015-07-14 16:03:41 +0200191struct gsm_mncc_rtp {
192 uint32_t msg_type;
193 uint32_t callref;
Pau Espin Pedroleeda9e12020-09-03 22:11:03 +0200194 struct sockaddr_storage addr;
Holger Hans Peter Freytherffbf45e2015-07-14 16:03:41 +0200195 uint32_t payload_type;
196 uint32_t payload_msg_type;
Neels Hofmeyrb4552052019-10-21 03:00:26 +0200197 char sdp[1024];
Holger Hans Peter Freytherffbf45e2015-07-14 16:03:41 +0200198};
199
Harald Welte53d51f52015-12-03 14:59:04 +0100200struct gsm_mncc_bridge {
201 uint32_t msg_type;
202 uint32_t callref[2];
203};
204
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100205union mncc_msg {
206 uint32_t msg_type;
207 struct gsm_mncc signal;
208 struct gsm_mncc_hello hello;
209 struct gsm_data_frame data_frame;
210 struct gsm_mncc_rtp rtp;
211 struct gsm_mncc_bridge bridge;
212};
213
Harald Welteda8a19f2015-12-03 14:35:05 +0100214const char *get_mncc_name(int value);
Harald Welte4bfdfe72009-06-10 23:11:52 +0800215void mncc_set_cause(struct gsm_mncc *data, int loc, int val);
Harald Weltefea236e2010-12-23 00:13:47 +0100216void cc_tx_to_mncc(struct gsm_network *net, struct msgb *msg);
Harald Welte4bfdfe72009-06-10 23:11:52 +0800217
Harald Welteea057d92010-12-23 01:26:29 +0100218/* input from CC code into mncc_builtin */
219int int_mncc_recv(struct gsm_network *net, struct msgb *msg);
220
221/* input from CC code into mncc_sock */
Holger Hans Peter Freyther1cc71842011-01-06 14:13:44 +0100222int mncc_sock_from_cc(struct gsm_network *net, struct msgb *msg);
Harald Welteea057d92010-12-23 01:26:29 +0100223
Neels Hofmeyr0ade6322016-02-23 14:55:17 +0100224int mncc_sock_init(struct gsm_network *net, const char *sock_path);
Harald Welte4d54d0b2011-02-19 16:48:17 +0100225
Andreas Eversberg9acbe4c2013-03-11 08:12:43 +0100226#define mncc_is_data_frame(msg_type) \
227 (msg_type == GSM_TCHF_FRAME \
228 || msg_type == GSM_TCHF_FRAME_EFR \
229 || msg_type == GSM_TCHH_FRAME \
230 || msg_type == GSM_TCH_FRAME_AMR \
231 || msg_type == GSM_BAD_FRAME)
232
Harald Welte57184292018-01-22 01:49:02 +0100233int mncc_prim_check(const struct gsm_mncc *mncc_prim, unsigned int len);
Neels Hofmeyrb4552052019-10-21 03:00:26 +0200234int mncc_check_sdp_termination(const char *label, const struct gsm_mncc *mncc, unsigned int len, const char *sdp);
Andreas Eversberg9acbe4c2013-03-11 08:12:43 +0100235
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100236int mncc_bearer_cap_to_channel_type(struct gsm0808_channel_type *ct, const struct gsm_mncc_bearer_cap *bc);
237
Harald Welte4bfdfe72009-06-10 23:11:52 +0800238#endif