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