2010-09-15 18:14:41 +00:00
|
|
|
/*
|
|
|
|
* Handle the connection to the MSC. This include ping/timeout/reconnect
|
2018-05-26 20:42:29 +00:00
|
|
|
* (C) 2008-2018 by Harald Welte <laforge@gnumonks.org>
|
2015-04-01 16:15:48 +00:00
|
|
|
* (C) 2009-2015 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* (C) 2009-2015 by On-Waves
|
2010-09-15 18:14:41 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2010-09-15 18:14:41 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2010-09-15 18:14:41 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-15 18:14:41 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-08-20 21:47:15 +00:00
|
|
|
#include <osmocom/ctrl/control_cmd.h>
|
|
|
|
#include <osmocom/ctrl/control_if.h>
|
2015-06-08 16:02:10 +00:00
|
|
|
#include <osmocom/crypt/auth.h>
|
2017-09-04 13:15:32 +00:00
|
|
|
#include <osmocom/bsc/debug.h>
|
|
|
|
#include <osmocom/bsc/gsm_data.h>
|
|
|
|
#include <osmocom/bsc/ipaccess.h>
|
|
|
|
#include <osmocom/bsc/bsc_msc_data.h>
|
2018-05-26 20:56:59 +00:00
|
|
|
#include <osmocom/bsc/osmo_bsc_sigtran.h>
|
2017-09-04 13:15:32 +00:00
|
|
|
#include <osmocom/bsc/signal.h>
|
2010-09-15 18:14:41 +00:00
|
|
|
|
2011-02-18 13:30:25 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
2018-05-26 20:56:59 +00:00
|
|
|
#include <osmocom/core/socket.h>
|
2011-02-18 13:30:25 +00:00
|
|
|
|
2011-03-23 17:26:56 +00:00
|
|
|
#include <osmocom/gsm/gsm0808.h>
|
2010-09-15 18:14:41 +00:00
|
|
|
|
src: port openBSC over libosmo-abis
This is a big patch that ports openBSC over libosmo-abis.
Sorry, the changes that are included here are all dependent
of libosmo-abis, splitting them into smaller pieces would
leave the repository in some intermediate state, which is
not desired.
The main changes are:
- The directory libabis/ has been removed as it now lives in
libosmo-abis.
- new configuration file format for nanoBTS and HSL femto, we
need to define the virtual e1_line and attach it to the OML
link.
- all the existing BTS drivers (nanoBTS, hsl femto, Nokia site,
BS11 and rbs2000) now use the new libosmo-abis framework.
- use r232 input driver available in libosmo-abis for bs11_config.
- use ipa_msg_recv instead of old ipaccess_read_msg function.
- delete definition of gsm_e1_subslot and input_signal_data.
These structures now lives in libosmo-abis.
Most of this patch are deletions of libabis/ which has been
moved to libosmo-abis.
This patch also modifies openBSC to use all the new definitions
available in libosmocore and libosmo-abis. In order to do that,
we have replaced the following:
- DINP, DMI, DMIB and DMUX by their respective DL* correspondences.
- SS_GLOBAL by SS_L_GLOBAL
- SS_INPUT by SS_L_INPUT
- S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN
- SS_INPUT by SS_L_INPUT
- S_INP_* by S_L_INP_* sub-signals
- E1INP_NODE by L_E1INP_NODE vty node
This patch has been tested with:
- one nanoBTS
- the HSL femto with the examples available under libosmo-abis
- BS11 with both dahdi and misdn drivers.
2011-08-17 20:44:07 +00:00
|
|
|
#include <osmocom/abis/ipa.h>
|
|
|
|
|
2018-05-26 20:56:59 +00:00
|
|
|
#include <osmocom/mgcp_client/mgcp_client.h>
|
|
|
|
|
2010-09-15 18:14:41 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-05-26 20:56:59 +00:00
|
|
|
int osmo_bsc_msc_init(struct bsc_msc_data *msc)
|
2010-09-15 18:14:41 +00:00
|
|
|
{
|
2018-05-26 20:56:59 +00:00
|
|
|
struct gsm_network *net = msc->network;
|
|
|
|
uint16_t mgw_port;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (net->mgw.conf->remote_port >= 0)
|
|
|
|
mgw_port = net->mgw.conf->remote_port;
|
|
|
|
else
|
|
|
|
mgw_port = MGCP_CLIENT_REMOTE_PORT_DEFAULT;
|
|
|
|
|
|
|
|
rc = osmo_sock_init2_ofd(&msc->mgcp_ipa.ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
|
|
|
|
msc->mgcp_ipa.local_addr, msc->mgcp_ipa.local_port,
|
|
|
|
net->mgw.conf->remote_addr, mgw_port,
|
|
|
|
OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT);
|
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DMSC, LOGL_ERROR, "msc %u: Could not create/connect/bind MGCP proxy socket: %d\n",
|
|
|
|
msc->nr, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2017-04-09 10:32:51 +00:00
|
|
|
|
2010-09-15 18:14:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-06-04 17:58:26 +00:00
|
|
|
|
2017-02-23 20:57:23 +00:00
|
|
|
struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *net, int nr)
|
2011-06-04 17:58:26 +00:00
|
|
|
{
|
2017-02-23 20:57:23 +00:00
|
|
|
struct bsc_msc_data *msc_data;
|
2011-06-04 17:58:26 +00:00
|
|
|
|
|
|
|
llist_for_each_entry(msc_data, &net->bsc_data->mscs, entry)
|
|
|
|
if (msc_data->nr == nr)
|
|
|
|
return msc_data;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-02-23 20:57:23 +00:00
|
|
|
struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr)
|
2011-06-04 17:58:26 +00:00
|
|
|
{
|
2017-02-23 20:57:23 +00:00
|
|
|
struct bsc_msc_data *msc_data;
|
2018-10-05 08:29:53 +00:00
|
|
|
unsigned int i;
|
2011-06-04 17:58:26 +00:00
|
|
|
|
|
|
|
/* check if there is already one */
|
|
|
|
msc_data = osmo_msc_data_find(net, nr);
|
|
|
|
if (msc_data)
|
|
|
|
return msc_data;
|
|
|
|
|
2017-02-23 20:57:23 +00:00
|
|
|
msc_data = talloc_zero(net, struct bsc_msc_data);
|
2011-06-04 17:58:26 +00:00
|
|
|
if (!msc_data)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
llist_add_tail(&msc_data->entry, &net->bsc_data->mscs);
|
|
|
|
|
|
|
|
/* Init back pointer */
|
|
|
|
msc_data->network = net;
|
|
|
|
|
2018-03-05 01:09:40 +00:00
|
|
|
msc_data->core_plmn = (struct osmo_plmn_id){
|
|
|
|
.mcc = GSM_MCC_MNC_INVALID,
|
|
|
|
.mnc = GSM_MCC_MNC_INVALID,
|
|
|
|
};
|
2015-04-01 16:15:48 +00:00
|
|
|
msc_data->core_ci = -1;
|
|
|
|
msc_data->core_lac = -1;
|
2011-06-04 17:58:26 +00:00
|
|
|
msc_data->rtp_base = 4000;
|
|
|
|
|
|
|
|
msc_data->nr = nr;
|
2011-06-08 17:25:38 +00:00
|
|
|
msc_data->allow_emerg = 1;
|
2018-05-25 13:51:05 +00:00
|
|
|
msc_data->a.asp_proto = OSMO_SS7_ASP_PROT_M3UA;
|
2011-06-04 17:58:26 +00:00
|
|
|
|
2011-08-06 05:00:52 +00:00
|
|
|
/* Defaults for the audio setup */
|
|
|
|
msc_data->amr_conf.m5_90 = 1;
|
2019-05-15 12:57:32 +00:00
|
|
|
msc_data->amr_octet_aligned = true;
|
2011-08-06 05:00:52 +00:00
|
|
|
|
2018-10-05 08:29:53 +00:00
|
|
|
/* Allow the full set of possible codecs by default */
|
|
|
|
msc_data->audio_length = 5;
|
|
|
|
msc_data->audio_support =
|
|
|
|
talloc_zero_array(msc_data, struct gsm_audio_support *,
|
|
|
|
msc_data->audio_length);
|
|
|
|
for (i = 0; i < msc_data->audio_length; i++) {
|
|
|
|
msc_data->audio_support[i] =
|
|
|
|
talloc_zero(msc_data->audio_support,
|
|
|
|
struct gsm_audio_support);
|
|
|
|
}
|
|
|
|
msc_data->audio_support[0]->ver = 1;
|
|
|
|
msc_data->audio_support[0]->hr = 0;
|
|
|
|
msc_data->audio_support[1]->ver = 1;
|
|
|
|
msc_data->audio_support[1]->hr = 1;
|
|
|
|
msc_data->audio_support[2]->ver = 2;
|
|
|
|
msc_data->audio_support[2]->hr = 0;
|
|
|
|
msc_data->audio_support[3]->ver = 3;
|
|
|
|
msc_data->audio_support[3]->hr = 0;
|
|
|
|
msc_data->audio_support[4]->ver = 3;
|
|
|
|
msc_data->audio_support[4]->hr = 1;
|
|
|
|
|
2018-05-26 20:56:59 +00:00
|
|
|
osmo_fd_setup(&msc_data->mgcp_ipa.ofd, -1, BSC_FD_READ, &bsc_sccplite_mgcp_proxy_cb, msc_data, 0);
|
|
|
|
msc_data->mgcp_ipa.local_addr = talloc_strdup(msc_data, "0.0.0.0");
|
|
|
|
msc_data->mgcp_ipa.local_port = 0; /* dynamic */
|
|
|
|
|
2011-06-04 17:58:26 +00:00
|
|
|
return msc_data;
|
|
|
|
}
|
2017-04-09 10:32:51 +00:00
|
|
|
|
2019-03-12 17:55:57 +00:00
|
|
|
struct osmo_cell_global_id *cgi_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts)
|
|
|
|
{
|
|
|
|
static struct osmo_cell_global_id cgi;
|
|
|
|
cgi.lai.plmn = msc->network->plmn;
|
|
|
|
if (msc->core_plmn.mcc != GSM_MCC_MNC_INVALID)
|
|
|
|
cgi.lai.plmn.mcc = msc->core_plmn.mcc;
|
|
|
|
if (msc->core_plmn.mnc != GSM_MCC_MNC_INVALID) {
|
|
|
|
cgi.lai.plmn.mnc = msc->core_plmn.mnc;
|
|
|
|
cgi.lai.plmn.mnc_3_digits = msc->core_plmn.mnc_3_digits;
|
|
|
|
}
|
|
|
|
cgi.lai.lac = (msc->core_lac != -1) ? msc->core_lac : bts->location_area_code;
|
|
|
|
cgi.cell_identity = (msc->core_ci != -1) ? msc->core_ci : bts->cell_identity;
|
|
|
|
|
|
|
|
return &cgi;
|
|
|
|
}
|