blob: 4a283d165b7123043982e1a9de49fd45945edf6e [file] [log] [blame]
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +08001/*
2 * Data for the true BSC
3 *
Holger Hans Peter Freyther32dd2f32015-04-01 18:15:48 +02004 * (C) 2010-2015 by Holger Hans Peter Freyther <zecke@selfish.org>
5 * (C) 2010-2015 by On-Waves
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +08006 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01009 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080011 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010016 * GNU Affero General Public License for more details.
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080017 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010018 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080020 *
21 */
22
Neels Hofmeyr9762b4c2017-02-23 21:41:20 +010023/*
24 * NOTE: This is about a *remote* MSC for OsmoBSC and is not part of libmsc.
25 */
26
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080027#ifndef _OSMO_MSC_DATA_H
28#define _OSMO_MSC_DATA_H
29
30#include "bsc_msc.h"
31
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010032#include <osmocom/core/timer.h>
Holger Hans Peter Freyther25aa7492011-08-06 07:00:52 +020033#include <osmocom/gsm/protocol/gsm_04_08.h>
Holger Hans Peter Freyther5832b3e2010-09-16 02:14:41 +080034
Philipp Maierfbf66102017-04-09 12:32:51 +020035
36#include <osmocom/sigtran/osmo_ss7.h>
37#include <osmocom/sigtran/sccp_sap.h>
38#include <osmocom/sigtran/sccp_helpers.h>
39#include <osmocom/sigtran/protocol/sua.h>
40#include <osmocom/sigtran/protocol/m3ua.h>
41#include <osmocom/core/fsm.h>
42
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +020043#include <regex.h>
44
Holger Hans Peter Freyther9a8b5ae2010-09-15 23:53:54 +080045struct osmo_bsc_rf;
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010046struct gsm_network;
Holger Hans Peter Freyther9a8b5ae2010-09-15 23:53:54 +080047
Holger Hans Peter Freyther7bf66c52010-11-03 13:55:49 +010048struct gsm_audio_support {
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010049 uint8_t hr : 1,
50 ver : 7;
Holger Hans Peter Freyther7bf66c52010-11-03 13:55:49 +010051};
52
Holger Hans Peter Freyther210565e2011-06-07 20:56:18 +020053enum {
54 MSC_CON_TYPE_NORMAL,
55 MSC_CON_TYPE_LOCAL,
56};
57
Neels Hofmeyr9762b4c2017-02-23 21:41:20 +010058/*! /brief Information on a remote MSC for libbsc.
59 */
Neels Hofmeyra369e242017-02-23 21:57:23 +010060struct bsc_msc_data {
Holger Hans Peter Freyther20fea242011-06-04 19:58:26 +020061 struct llist_head entry;
62
Daniel Willmann163f6122011-03-03 13:48:28 +010063 /* Back pointer */
64 struct gsm_network *network;
65
Holger Hans Peter Freyther18fa70a2011-06-08 19:25:38 +020066 int allow_emerg;
Holger Hans Peter Freyther210565e2011-06-07 20:56:18 +020067 int type;
68
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +020069 /* local call routing */
70 char *local_pref;
71 regex_t local_pref_reg;
72
73
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080074 /* Connection data */
75 char *bsc_token;
Holger Hans Peter Freythere2ac6b72015-06-08 18:02:10 +020076 uint8_t bsc_key[16];
77 uint8_t bsc_key_present;
78
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080079 int ping_timeout;
80 int pong_timeout;
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020081 struct osmo_timer_list ping_timer;
82 struct osmo_timer_list pong_timer;
Holger Hans Peter Freyther56cb7292014-09-02 17:28:40 +020083 int advanced_ping;
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080084 struct bsc_msc_connection *msc_con;
Holger Hans Peter Freyther1e365472015-07-13 11:06:10 +020085 int core_mnc;
Holger Hans Peter Freyther2a8675e2010-11-05 19:43:07 +010086 int core_mcc;
Holger Hans Peter Freyther32dd2f32015-04-01 18:15:48 +020087 int core_lac;
88 int core_ci;
Holger Hans Peter Freytherfe166222010-11-03 13:32:48 +010089 int rtp_base;
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080090
Holger Hans Peter Freyther7bf66c52010-11-03 13:55:49 +010091 /* audio codecs */
Holger Hans Peter Freyther25aa7492011-08-06 07:00:52 +020092 struct gsm48_multi_rate_conf amr_conf;
Holger Hans Peter Freyther7bf66c52010-11-03 13:55:49 +010093 struct gsm_audio_support **audio_support;
94 int audio_length;
95
Holger Hans Peter Freythere18801052011-04-23 23:31:31 +020096 /* destinations */
97 struct llist_head dests;
98
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020099 /* ussd welcome text */
100 char *ussd_welcome_txt;
Holger Hans Peter Freyther7bf66c52010-11-03 13:55:49 +0100101
Holger Hans Peter Freyther5832b3e2010-09-16 02:14:41 +0800102 /* mgcp agent */
Pablo Neira Ayusoe1273b12011-05-06 12:09:47 +0200103 struct osmo_wqueue mgcp_agent;
Holger Hans Peter Freyther20fea242011-06-04 19:58:26 +0200104
105 int nr;
Jacob Erlbeck1b894022013-08-28 10:16:54 +0200106
107 /* ussd msc connection lost text */
108 char *ussd_msc_lost_txt;
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200109
110 /* ussd text when MSC has entered the grace period */
111 char *ussd_grace_txt;
Holger Hans Peter Freytherd6332802015-04-05 19:46:20 +0200112
113 char *acc_lst_name;
Philipp Maierfbf66102017-04-09 12:32:51 +0200114
115 /* Sigtran connection data */
116 struct {
117 uint32_t cs7_instance;
118 bool cs7_instance_valid;
119 struct osmo_sccp_instance *sccp;
120 struct osmo_sccp_user *sccp_user;
121
122 /* Holds a copy of the our local MSC address,
123 * this will be the sccp-address that is associated
124 * with the A interface of this particular BSC,
125 * this address is filled up by the VTY interface */
126 struct osmo_sccp_addr bsc_addr;
127 char *bsc_addr_name;
128
129 /* Holds a copy of the MSC address. This is the
130 * address of the MSC that handles the calls of
131 * this BSC. The address is configured via the
132 * VTY interface */
133 struct osmo_sccp_addr msc_addr;
134 char *msc_addr_name;
135
136 struct a_reset_ctx *reset;
137 } a;
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +0200138};
139
140/*
141 * Per BSC data.
142 */
143struct osmo_bsc_data {
144 struct gsm_network *network;
145
146 /* msc configuration */
Holger Hans Peter Freyther20fea242011-06-04 19:58:26 +0200147 struct llist_head mscs;
Holger Hans Peter Freyther5832b3e2010-09-16 02:14:41 +0800148
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800149 /* rf ctl related bits */
Holger Hans Peter Freytherbb62b3f2010-11-22 18:30:21 +0100150 char *mid_call_txt;
151 int mid_call_timeout;
Holger Hans Peter Freyther55ef5fb2011-04-07 23:23:27 +0200152 char *rf_ctrl_name;
Holger Hans Peter Freyther5e3bbba2011-06-04 09:32:35 +0200153 struct osmo_bsc_rf *rf_ctrl;
Holger Hans Peter Freyther2a896072011-08-16 19:47:39 +0200154 int auto_off_timeout;
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200155
156 /* ussd text when there is no MSC available */
157 char *ussd_no_msc_txt;
Holger Hans Peter Freytherd6332802015-04-05 19:46:20 +0200158
159 char *acc_lst_name;
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800160};
161
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +0200162
Neels Hofmeyra369e242017-02-23 21:57:23 +0100163int osmo_bsc_msc_init(struct bsc_msc_data *msc);
Holger Hans Peter Freytherf3d1ae72010-11-03 16:40:03 +0100164int osmo_bsc_sccp_init(struct gsm_network *gsmnet);
Holger Hans Peter Freyther60980382010-09-16 02:22:20 +0800165int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto);
Holger Hans Peter Freyther56cb7292014-09-02 17:28:40 +0200166int msc_queue_write_with_ping(struct bsc_msc_connection *, struct msgb *msg, int proto);
Holger Hans Peter Freyther5832b3e2010-09-16 02:14:41 +0800167
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +0100168int osmo_bsc_audio_init(struct gsm_network *network);
169
Neels Hofmeyra369e242017-02-23 21:57:23 +0100170struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *, int);
171struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *, int);
Holger Hans Peter Freyther20fea242011-06-04 19:58:26 +0200172
173
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800174#endif