2008-12-23 20:25:15 +00:00
|
|
|
/* A hackish minimal BSC (+MSC +HLR) implementation */
|
|
|
|
|
2010-01-12 09:46:27 +00:00
|
|
|
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
|
2012-05-11 21:28:19 +00:00
|
|
|
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
|
2008-12-23 20:25:15 +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
|
2008-12-23 20:25:15 +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.
|
2008-12-23 20:25:15 +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/>.
|
2008-12-23 20:25:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-12-26 00:05:11 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
2008-12-26 10:20:07 +00:00
|
|
|
#include <errno.h>
|
2009-01-01 01:50:32 +00:00
|
|
|
#include <signal.h>
|
2009-01-02 00:40:15 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2008-12-27 12:46:51 +00:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <getopt.h>
|
|
|
|
|
2008-12-28 02:26:27 +00:00
|
|
|
#include <openbsc/db.h>
|
2011-05-12 14:02:07 +00:00
|
|
|
#include <osmocom/core/application.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/select.h>
|
2015-10-26 15:25:37 +00:00
|
|
|
#include <osmocom/core/stats.h>
|
2008-12-26 20:25:35 +00:00
|
|
|
#include <openbsc/debug.h>
|
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/abis.h>
|
|
|
|
#include <osmocom/abis/e1_input.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
2009-11-30 18:37:18 +00:00
|
|
|
#include <openbsc/signal.h>
|
2010-06-30 06:30:35 +00:00
|
|
|
#include <openbsc/osmo_msc.h>
|
2014-03-06 16:20:55 +00:00
|
|
|
#include <openbsc/osmo_msc_data.h>
|
2011-02-19 15:48:17 +00:00
|
|
|
#include <openbsc/sms_queue.h>
|
2010-08-26 07:38:42 +00:00
|
|
|
#include <openbsc/vty.h>
|
bsc: on-demand setup of nanoBTS and HSL femto sockets
The daemons set up nanoBTS and HSL femto sockets by default, ie. the
three sockets to support these two drivers are open even if we have
no BTS of that kind.
This patch enables on-demand socket creation, ie. we only enable them
if we have one BTS at least that requires it.
I added two new attributes to the gsm_bts object, they are:
* the start() function includes the code that we need to run to start
the BTS. This new function contains the socket creation in the
particular case of nanoBTS and HSL femto.
* the started boolean, which is used to know if we have already
started the BTS, ie. we have already invoked start().
Note that, I have splitted the bts_model_*_init() function into two
functions, the _init() functions that register the BTS driver
and the _start() functions that start BTS driver on-demand.
While I was at it, I added several changes/cleanups to this patch:
* Group all bts_model_*_init() calls into one function bts_init(),
which is called in the initialization path of osmo-nitb and
osmo-bsc.
* Add openbsc/bss.h that contains the declaration of
bsc_bootstrap_network, bsc_shutdown_net and bts_init.
* Add missing e1inp_init() in osmo-bsc.
* Fix missing declaration of hsl_setup in openbsc/e1_input.h
2011-05-14 09:32:48 +00:00
|
|
|
#include <openbsc/bss.h>
|
2011-05-24 11:25:38 +00:00
|
|
|
#include <openbsc/mncc.h>
|
2011-09-05 22:09:48 +00:00
|
|
|
#include <openbsc/token_auth.h>
|
|
|
|
#include <openbsc/handover_decision.h>
|
|
|
|
#include <openbsc/rrlp.h>
|
2014-08-20 21:47:15 +00:00
|
|
|
#include <osmocom/ctrl/control_if.h>
|
2014-08-24 15:54:49 +00:00
|
|
|
#include <osmocom/ctrl/ports.h>
|
2016-02-23 14:10:33 +00:00
|
|
|
#include <osmocom/ctrl/control_vty.h>
|
2014-08-20 21:47:15 +00:00
|
|
|
#include <openbsc/ctrl.h>
|
2012-05-11 21:28:19 +00:00
|
|
|
#include <openbsc/osmo_bsc_rf.h>
|
2015-01-01 11:32:03 +00:00
|
|
|
#include <openbsc/smpp.h>
|
2010-05-16 18:52:23 +00:00
|
|
|
|
2011-03-04 12:53:51 +00:00
|
|
|
#include "../../bscconfig.h"
|
2010-05-16 18:52:23 +00:00
|
|
|
|
2008-12-28 14:14:56 +00:00
|
|
|
/* MCC and MNC for the Location Area Identifier */
|
2009-08-17 04:55:10 +00:00
|
|
|
struct gsm_network *bsc_gsmnet = 0;
|
2008-12-28 22:51:39 +00:00
|
|
|
static const char *database_name = "hlr.sqlite3";
|
2009-08-10 06:39:27 +00:00
|
|
|
static const char *config_file = "openbsc.cfg";
|
2016-02-23 13:57:22 +00:00
|
|
|
static const char *rf_ctrl_path = NULL;
|
2010-05-16 18:52:23 +00:00
|
|
|
extern const char *openbsc_copyright;
|
2010-08-25 17:43:54 +00:00
|
|
|
static int daemonize = 0;
|
2016-02-23 13:55:17 +00:00
|
|
|
static const char *mncc_sock_path = NULL;
|
2011-11-13 18:02:06 +00:00
|
|
|
static int use_db_counter = 1;
|
2009-12-23 04:29:04 +00:00
|
|
|
|
|
|
|
/* timer to store statistics */
|
|
|
|
#define DB_SYNC_INTERVAL 60, 0
|
2012-12-26 23:40:32 +00:00
|
|
|
#define EXPIRE_INTERVAL 10, 0
|
|
|
|
|
2011-05-06 10:11:06 +00:00
|
|
|
static struct osmo_timer_list db_sync_timer;
|
2009-12-23 04:29:04 +00:00
|
|
|
|
2009-01-02 00:40:15 +00:00
|
|
|
static void create_pcap_file(char *file)
|
|
|
|
{
|
|
|
|
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
|
|
|
int fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, mode);
|
|
|
|
|
|
|
|
if (fd < 0) {
|
|
|
|
perror("Failed to open file for pcap");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-31 12:14:16 +00:00
|
|
|
e1_set_pcap_fd(fd);
|
2009-01-02 00:40:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-27 12:46:51 +00:00
|
|
|
static void print_usage()
|
|
|
|
{
|
2013-11-27 00:28:21 +00:00
|
|
|
printf("Usage: osmo-nitb\n");
|
2008-12-27 12:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void print_help()
|
|
|
|
{
|
|
|
|
printf(" Some useful help...\n");
|
2015-09-15 09:50:50 +00:00
|
|
|
printf(" -h --help This text.\n");
|
|
|
|
printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n");
|
|
|
|
printf(" -D --daemonize Fork the process into a background daemon.\n");
|
|
|
|
printf(" -c --config-file filename The config file to use.\n");
|
2010-03-25 01:41:38 +00:00
|
|
|
printf(" -s --disable-color\n");
|
2015-09-15 09:50:50 +00:00
|
|
|
printf(" -l --database db-name The database to use.\n");
|
|
|
|
printf(" -a --authorize-everyone Authorize every new subscriber. Dangerous!\n");
|
|
|
|
printf(" -T --timestamp Prefix every log line with a timestamp.\n");
|
|
|
|
printf(" -V --version Print the version of OpenBSC.\n");
|
|
|
|
printf(" -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC.\n");
|
|
|
|
printf(" -e --log-level number Set a global loglevel.\n");
|
2016-02-23 13:55:17 +00:00
|
|
|
printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n");
|
|
|
|
printf(" -m --mncc-sock Same as `-M /tmp/bsc_mncc' (deprecated).\n");
|
2015-09-15 09:50:50 +00:00
|
|
|
printf(" -C --no-dbcounter Disable regular syncing of counters to database.\n");
|
2016-02-23 13:57:22 +00:00
|
|
|
printf(" -r --rf-ctl PATH A unix domain socket to listen for cmds.\n");
|
2008-12-27 12:46:51 +00:00
|
|
|
}
|
|
|
|
|
2010-09-17 22:44:24 +00:00
|
|
|
static void handle_options(int argc, char **argv)
|
2008-12-27 12:46:51 +00:00
|
|
|
{
|
|
|
|
while (1) {
|
2009-06-20 20:36:41 +00:00
|
|
|
int option_index = 0, c;
|
2008-12-27 12:46:51 +00:00
|
|
|
static struct option long_options[] = {
|
|
|
|
{"help", 0, 0, 'h'},
|
|
|
|
{"debug", 1, 0, 'd'},
|
2010-08-25 17:43:54 +00:00
|
|
|
{"daemonize", 0, 0, 'D'},
|
2009-08-10 06:39:27 +00:00
|
|
|
{"config-file", 1, 0, 'c'},
|
2008-12-28 14:14:56 +00:00
|
|
|
{"disable-color", 0, 0, 's'},
|
2008-12-28 22:51:39 +00:00
|
|
|
{"database", 1, 0, 'l'},
|
2008-12-30 16:18:18 +00:00
|
|
|
{"authorize-everyone", 0, 0, 'a'},
|
2009-01-02 00:40:15 +00:00
|
|
|
{"pcap", 1, 0, 'p'},
|
2009-06-09 20:21:57 +00:00
|
|
|
{"timestamp", 0, 0, 'T'},
|
2010-03-22 16:09:32 +00:00
|
|
|
{"version", 0, 0, 'V' },
|
2009-07-28 16:25:29 +00:00
|
|
|
{"rtp-proxy", 0, 0, 'P'},
|
2010-03-25 01:39:15 +00:00
|
|
|
{"log-level", 1, 0, 'e'},
|
2010-12-23 00:31:07 +00:00
|
|
|
{"mncc-sock", 0, 0, 'm'},
|
2016-02-23 13:55:17 +00:00
|
|
|
{"mncc-sock-path", 1, 0, 'M'},
|
2011-11-13 18:02:06 +00:00
|
|
|
{"no-dbcounter", 0, 0, 'C'},
|
2012-05-11 21:28:19 +00:00
|
|
|
{"rf-ctl", 1, 0, 'r'},
|
2008-12-27 12:46:51 +00:00
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2016-02-23 13:55:17 +00:00
|
|
|
c = getopt_long(argc, argv, "hd:Dsl:ar:p:TPVc:e:mCr:M:",
|
2008-12-27 12:46:51 +00:00
|
|
|
long_options, &option_index);
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 'h':
|
|
|
|
print_usage();
|
|
|
|
print_help();
|
|
|
|
exit(0);
|
2008-12-28 14:14:56 +00:00
|
|
|
case 's':
|
2011-05-12 14:02:07 +00:00
|
|
|
log_set_use_color(osmo_stderr_target, 0);
|
2008-12-27 12:46:51 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
2011-05-12 14:02:07 +00:00
|
|
|
log_parse_category_mask(osmo_stderr_target, optarg);
|
2008-12-27 12:46:51 +00:00
|
|
|
break;
|
2010-08-25 17:43:54 +00:00
|
|
|
case 'D':
|
|
|
|
daemonize = 1;
|
|
|
|
break;
|
2009-01-06 18:09:02 +00:00
|
|
|
case 'l':
|
2014-05-21 13:46:44 +00:00
|
|
|
database_name = optarg;
|
2008-12-28 22:51:39 +00:00
|
|
|
break;
|
2009-08-10 06:39:27 +00:00
|
|
|
case 'c':
|
2014-05-21 13:46:44 +00:00
|
|
|
config_file = optarg;
|
2009-08-10 06:39:27 +00:00
|
|
|
break;
|
2009-01-02 00:40:15 +00:00
|
|
|
case 'p':
|
|
|
|
create_pcap_file(optarg);
|
|
|
|
break;
|
2009-06-09 20:21:57 +00:00
|
|
|
case 'T':
|
2011-05-12 14:02:07 +00:00
|
|
|
log_set_print_timestamp(osmo_stderr_target, 1);
|
2009-06-09 20:21:57 +00:00
|
|
|
break;
|
2009-07-28 16:25:29 +00:00
|
|
|
case 'P':
|
|
|
|
ipacc_rtp_direct = 0;
|
|
|
|
break;
|
2010-03-25 01:39:15 +00:00
|
|
|
case 'e':
|
2011-05-12 14:02:07 +00:00
|
|
|
log_set_log_level(osmo_stderr_target, atoi(optarg));
|
2010-03-25 01:39:15 +00:00
|
|
|
break;
|
2016-02-23 13:55:17 +00:00
|
|
|
case 'M':
|
|
|
|
mncc_sock_path = optarg;
|
|
|
|
break;
|
2010-12-23 00:31:07 +00:00
|
|
|
case 'm':
|
2016-02-23 13:55:17 +00:00
|
|
|
mncc_sock_path = "/tmp/bsc_mncc";
|
2010-12-23 00:31:07 +00:00
|
|
|
break;
|
2011-11-13 18:02:06 +00:00
|
|
|
case 'C':
|
|
|
|
use_db_counter = 0;
|
|
|
|
break;
|
2010-03-22 16:09:32 +00:00
|
|
|
case 'V':
|
2010-05-16 17:20:24 +00:00
|
|
|
print_version(1);
|
2010-03-22 16:09:32 +00:00
|
|
|
exit(0);
|
|
|
|
break;
|
2012-05-11 21:28:19 +00:00
|
|
|
case 'r':
|
2016-02-23 13:57:22 +00:00
|
|
|
rf_ctrl_path = optarg;
|
2012-05-11 21:28:19 +00:00
|
|
|
break;
|
2008-12-27 12:46:51 +00:00
|
|
|
default:
|
2016-02-23 13:59:43 +00:00
|
|
|
/* catch unknown options *as well as* missing arguments. */
|
|
|
|
fprintf(stderr, "Error in command line options. Exiting.\n");
|
|
|
|
exit(-1);
|
2008-12-27 12:46:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-24 09:51:56 +00:00
|
|
|
extern void *tall_vty_ctx;
|
2009-01-01 01:50:32 +00:00
|
|
|
static void signal_handler(int signal)
|
|
|
|
{
|
|
|
|
fprintf(stdout, "signal %u received\n", signal);
|
|
|
|
|
|
|
|
switch (signal) {
|
2009-08-06 15:43:50 +00:00
|
|
|
case SIGINT:
|
2009-08-17 04:55:10 +00:00
|
|
|
bsc_shutdown_net(bsc_gsmnet);
|
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
|
|
|
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
|
2009-08-06 15:43:50 +00:00
|
|
|
sleep(3);
|
|
|
|
exit(0);
|
2009-01-01 01:50:32 +00:00
|
|
|
break;
|
2009-08-06 22:29:44 +00:00
|
|
|
case SIGABRT:
|
|
|
|
/* in case of abort, we want to obtain a talloc report
|
|
|
|
* and then return to the caller, who will abort the process */
|
2009-06-20 20:36:41 +00:00
|
|
|
case SIGUSR1:
|
2009-12-24 09:51:56 +00:00
|
|
|
talloc_report(tall_vty_ctx, stderr);
|
2009-06-20 20:36:41 +00:00
|
|
|
talloc_report_full(tall_bsc_ctx, stderr);
|
|
|
|
break;
|
2009-12-24 09:51:56 +00:00
|
|
|
case SIGUSR2:
|
|
|
|
talloc_report_full(tall_vty_ctx, stderr);
|
|
|
|
break;
|
2009-01-01 01:50:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-23 04:29:04 +00:00
|
|
|
/* timer handling */
|
2011-05-06 10:13:10 +00:00
|
|
|
static int _db_store_counter(struct osmo_counter *counter, void *data)
|
2009-12-23 04:29:04 +00:00
|
|
|
{
|
|
|
|
return db_store_counter(counter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void db_sync_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
/* store counters to database and re-schedule */
|
2011-05-06 10:13:10 +00:00
|
|
|
osmo_counters_for_each(_db_store_counter, NULL);
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
|
2009-12-23 04:29:04 +00:00
|
|
|
}
|
|
|
|
|
2012-12-26 23:40:32 +00:00
|
|
|
static void subscr_expire_cb(void *data)
|
|
|
|
{
|
2014-12-03 08:28:24 +00:00
|
|
|
subscr_expire(bsc_gsmnet->subscr_group);
|
2012-12-26 23:40:32 +00:00
|
|
|
osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
|
|
|
|
}
|
|
|
|
|
2011-02-19 15:48:17 +00:00
|
|
|
void talloc_ctx_init(void);
|
2010-01-10 17:01:52 +00:00
|
|
|
|
2015-09-24 13:38:38 +00:00
|
|
|
extern int bsc_vty_go_parent(struct vty *vty);
|
2010-05-25 21:31:39 +00:00
|
|
|
|
|
|
|
static struct vty_app_info vty_info = {
|
|
|
|
.name = "OpenBSC",
|
|
|
|
.version = PACKAGE_VERSION,
|
|
|
|
.go_parent_cb = bsc_vty_go_parent,
|
2010-08-26 07:38:42 +00:00
|
|
|
.is_config_node = bsc_vty_is_config_node,
|
2010-05-25 21:31:39 +00:00
|
|
|
};
|
|
|
|
|
2008-12-26 00:05:11 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2009-02-09 18:13:26 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-05-25 21:31:39 +00:00
|
|
|
vty_info.copyright = openbsc_copyright;
|
|
|
|
|
2009-06-20 20:36:41 +00:00
|
|
|
tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
|
2009-08-15 00:30:58 +00:00
|
|
|
talloc_ctx_init();
|
2009-08-13 11:52:14 +00:00
|
|
|
on_dso_load_token();
|
2009-08-16 11:18:51 +00:00
|
|
|
on_dso_load_rrlp();
|
2009-12-16 23:31:10 +00:00
|
|
|
on_dso_load_ho_dec();
|
2011-05-12 14:02:07 +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
|
|
|
libosmo_abis_init(tall_bsc_ctx);
|
2011-05-12 14:02:07 +00:00
|
|
|
osmo_init_logging(&log_info);
|
2015-10-26 15:25:37 +00:00
|
|
|
osmo_stats_init(tall_bsc_ctx);
|
bsc: on-demand setup of nanoBTS and HSL femto sockets
The daemons set up nanoBTS and HSL femto sockets by default, ie. the
three sockets to support these two drivers are open even if we have
no BTS of that kind.
This patch enables on-demand socket creation, ie. we only enable them
if we have one BTS at least that requires it.
I added two new attributes to the gsm_bts object, they are:
* the start() function includes the code that we need to run to start
the BTS. This new function contains the socket creation in the
particular case of nanoBTS and HSL femto.
* the started boolean, which is used to know if we have already
started the BTS, ie. we have already invoked start().
Note that, I have splitted the bts_model_*_init() function into two
functions, the _init() functions that register the BTS driver
and the _start() functions that start BTS driver on-demand.
While I was at it, I added several changes/cleanups to this patch:
* Group all bts_model_*_init() calls into one function bts_init(),
which is called in the initialization path of osmo-nitb and
osmo-bsc.
* Add openbsc/bss.h that contains the declaration of
bsc_bootstrap_network, bsc_shutdown_net and bts_init.
* Add missing e1inp_init() in osmo-bsc.
* Fix missing declaration of hsl_setup in openbsc/e1_input.h
2011-05-14 09:32:48 +00:00
|
|
|
bts_init();
|
2011-02-05 12:54:41 +00:00
|
|
|
|
2010-05-16 18:52:23 +00:00
|
|
|
/* This needs to precede handle_options() */
|
2010-05-25 21:31:39 +00:00
|
|
|
vty_init(&vty_info);
|
2011-03-09 12:36:32 +00:00
|
|
|
bsc_vty_init(&log_info);
|
2016-02-23 14:10:33 +00:00
|
|
|
ctrl_vty_init(tall_bsc_ctx);
|
2010-05-16 18:52:23 +00:00
|
|
|
|
2012-11-20 21:22:04 +00:00
|
|
|
#ifdef BUILD_SMPP
|
smpp: refactor initialization, add bind address
Make the SMPP bind address configurable (used to be harcoded as "0.0.0.0").
Add VTY command
smpp
local-tcp A.B.C.D <1-65535>
while keeping the old command 'local-tcp-port <1-65535>'. Both the old and the
new command immediately change the SMPP listening address and port.
Add a LOGL_NOTICE log when the SMPP listening address and/or port change.
However, to be useful, this patch has to go somewhat further: refactor the
initialization procedure, because it was impossible to run the VTY commands
without an already established connection.
The SMPP initialization procedure was weird. It would first open a connection
on the default port, and a subsequent VTY port reconfiguration while reading
the config file would try to re-establish a connection on a different port. If
that failed, smpp would switch back to the default port instead of failing the
program launch as the user would expect. If anything else ran on port 2775,
SMPP would thus refuse to launch despite the config file having a different
port: the first bind would always happen on 0.0.0.0:2775. Change that.
In the VTY commands, merely store address and port if no fd is established yet.
Introduce several SMPP initialization stages:
* allocate struct and initialize pointers,
* then read config file without immediately starting to listen,
* and once the main program is ready, start listening.
After that, the VTY command behaves as before: try to re-establish the old
connection if the newly supplied address and port don't work out. I'm not
actually sure why this switch-back behavior is needed, but fair enough.
In detail, replace the function
smpp_smsc_init()
with the various steps
smpp_smsc_alloc_init() -- prepare struct for VTY commands
smpp_smsc_conf() -- set addr an port only, for reading the config file
smpp_smsc_start() -- establish a first connection, for main()
smpp_smsc_restart() -- switch running connection, for telnet VTY
smpp_smsc_stop() -- tear down connection, used by _start() twice
And replace
smpp_openbsc_init()
smpp_openbsc_set_net()
with
smpp_openbsc_alloc_init()
smpp_openbsc_start()
I'd have picked function names like "_bind"/"_unbind", but in the SMPP protocol
there is also a bind/unbind process, so instead I chose the names "_start",
"_restart" and "_stop".
The smsc struct used to be talloc'd outside of smpp_smsc_init(). Since the smsc
code internally uses talloc anyway and employs the smsc struct as talloc
context, I decided to enforce talloc allocation within smpp_smsc_alloc_init().
Be stricter about osmo_signal_register_handler() return codes.
2016-02-24 18:15:39 +00:00
|
|
|
if (smpp_openbsc_alloc_init(tall_bsc_ctx) < 0)
|
2012-11-20 21:22:04 +00:00
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
|
2010-05-31 13:42:53 +00:00
|
|
|
/* parse options */
|
|
|
|
handle_options(argc, argv);
|
|
|
|
|
2010-12-23 00:31:07 +00:00
|
|
|
/* internal MNCC handler or MNCC socket? */
|
2016-02-23 13:55:17 +00:00
|
|
|
if (mncc_sock_path) {
|
2010-12-23 00:31:07 +00:00
|
|
|
rc = bsc_bootstrap_network(mncc_sock_from_cc, config_file);
|
|
|
|
if (rc >= 0)
|
2016-02-23 13:55:17 +00:00
|
|
|
mncc_sock_init(bsc_gsmnet, mncc_sock_path);
|
2016-04-18 21:11:18 +00:00
|
|
|
} else {
|
|
|
|
DEBUGP(DMNCC, "Using internal MNCC handler.\n");
|
2010-12-23 00:31:07 +00:00
|
|
|
rc = bsc_bootstrap_network(int_mncc_recv, config_file);
|
2016-04-18 21:11:18 +00:00
|
|
|
}
|
2010-05-16 17:20:24 +00:00
|
|
|
if (rc < 0)
|
|
|
|
exit(1);
|
2013-03-13 14:39:56 +00:00
|
|
|
#ifdef BUILD_SMPP
|
smpp: refactor initialization, add bind address
Make the SMPP bind address configurable (used to be harcoded as "0.0.0.0").
Add VTY command
smpp
local-tcp A.B.C.D <1-65535>
while keeping the old command 'local-tcp-port <1-65535>'. Both the old and the
new command immediately change the SMPP listening address and port.
Add a LOGL_NOTICE log when the SMPP listening address and/or port change.
However, to be useful, this patch has to go somewhat further: refactor the
initialization procedure, because it was impossible to run the VTY commands
without an already established connection.
The SMPP initialization procedure was weird. It would first open a connection
on the default port, and a subsequent VTY port reconfiguration while reading
the config file would try to re-establish a connection on a different port. If
that failed, smpp would switch back to the default port instead of failing the
program launch as the user would expect. If anything else ran on port 2775,
SMPP would thus refuse to launch despite the config file having a different
port: the first bind would always happen on 0.0.0.0:2775. Change that.
In the VTY commands, merely store address and port if no fd is established yet.
Introduce several SMPP initialization stages:
* allocate struct and initialize pointers,
* then read config file without immediately starting to listen,
* and once the main program is ready, start listening.
After that, the VTY command behaves as before: try to re-establish the old
connection if the newly supplied address and port don't work out. I'm not
actually sure why this switch-back behavior is needed, but fair enough.
In detail, replace the function
smpp_smsc_init()
with the various steps
smpp_smsc_alloc_init() -- prepare struct for VTY commands
smpp_smsc_conf() -- set addr an port only, for reading the config file
smpp_smsc_start() -- establish a first connection, for main()
smpp_smsc_restart() -- switch running connection, for telnet VTY
smpp_smsc_stop() -- tear down connection, used by _start() twice
And replace
smpp_openbsc_init()
smpp_openbsc_set_net()
with
smpp_openbsc_alloc_init()
smpp_openbsc_start()
I'd have picked function names like "_bind"/"_unbind", but in the SMPP protocol
there is also a bind/unbind process, so instead I chose the names "_start",
"_restart" and "_stop".
The smsc struct used to be talloc'd outside of smpp_smsc_init(). Since the smsc
code internally uses talloc anyway and employs the smsc struct as talloc
context, I decided to enforce talloc allocation within smpp_smsc_alloc_init().
Be stricter about osmo_signal_register_handler() return codes.
2016-02-24 18:15:39 +00:00
|
|
|
smpp_openbsc_start(bsc_gsmnet);
|
2013-03-13 14:39:56 +00:00
|
|
|
#endif
|
2010-06-30 06:30:35 +00:00
|
|
|
bsc_api_init(bsc_gsmnet, msc_bsc_api());
|
2010-05-16 17:20:24 +00:00
|
|
|
|
dyn TS: OS#1778 workaround: disable TCH/F on dyn TS for nitb
To avoid two phones picking mismatching TCH pchans, never pick TCH/F on dynamic
TS in osmo-nitb.
Add gsm_network flag dyn_ts_allow_tch_f, set to true by default in
gsm_network_init().
Set this flag to false in osmo-nitb's main().
See http://osmocom.org/issues/1778
Reasoning about ways to solve this:
* a compile time switch doesn't work because libbsc is first compiled and then
linked to both osmo-nitb and osmo-bsc.
* we could test net->bsc_api == msc_bsc_api(), but I have the so-called MSC
split waiting on branch sysmocom/cscn, which will result in msc_bsc_api() not
being linked in the osmo-bsc binary.
* have a function am_i_nitb() with different implementations in osmo-nitb and
osmo-bsc, but then we'd need to add implementations to all tests and other
binaries linking lchan_alloc().
* have a flag in struct bsc_api, but so far there are only function pointers
there.
Having a "global" flag in gsm_network allows to add a VTY command in case we
decide to keep this feature (#1781), has no linking implications and is nicely
explicit.
Tested that osmo-bsc still picks TCH/F on dyn TS indirectly, since I have no
standalone MSC available: when compiling osmo-nitb with the line that sets
dyn_ts_allow_tch_f = false commented out, TCH/F is picked as described in
OS#1778; and by printf-verifying that dyn_ts_allow_tch_f == true in osmo-bsc
main(), only osmo-nitb should have TCH/F disabled.
Related: OS#1778, OS#1781
Change-Id: If7e4797a72815fc6e2bbef27756ea5df69f4bde7
2016-07-23 18:15:28 +00:00
|
|
|
/*
|
|
|
|
* For osmo-nitb, skip TCH/F for now, because otherwise dyn TS
|
|
|
|
* always imply the possibility to have a mix of TCH/F and
|
|
|
|
* TCH/H channels; if two phones request a TCH/F and a TCH/H,
|
|
|
|
* respectively, they cannot call each other. If we deny TCH/F,
|
|
|
|
* they will both fall back to TCH/H, and dynamic channels are
|
|
|
|
* usable. See http://osmocom.org/issues/1778.
|
|
|
|
*
|
|
|
|
* A third-party MSC may well be able to handle a TCH/H TCH/F
|
|
|
|
* mismatch.
|
|
|
|
*/
|
|
|
|
bsc_gsmnet->dyn_ts_allow_tch_f = false;
|
|
|
|
|
2016-02-23 14:10:33 +00:00
|
|
|
/* start control interface after reading config for
|
|
|
|
* ctrl_vty_get_bind_addr() */
|
|
|
|
LOGP(DNM, LOGL_NOTICE, "CTRL at %s %d\n",
|
|
|
|
ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_NITB_BSC);
|
|
|
|
bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet,
|
|
|
|
ctrl_vty_get_bind_addr(),
|
|
|
|
OSMO_CTRL_PORT_NITB_BSC);
|
2011-08-05 10:22:35 +00:00
|
|
|
if (!bsc_gsmnet->ctrl) {
|
|
|
|
printf("Failed to initialize control interface. Exiting.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-01-09 16:03:27 +00:00
|
|
|
if (bsc_base_ctrl_cmds_install() != 0) {
|
2014-03-23 11:06:36 +00:00
|
|
|
printf("Failed to initialize the BSC control commands.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msc_ctrl_cmds_install() != 0) {
|
|
|
|
printf("Failed to initialize the MSC control commands.\n");
|
2013-01-09 16:03:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-02-24 22:36:20 +00:00
|
|
|
/* seed the PRNG */
|
|
|
|
srand(time(NULL));
|
|
|
|
|
2016-02-23 13:57:22 +00:00
|
|
|
bsc_gsmnet->bsc_data->rf_ctrl = osmo_bsc_rf_create(rf_ctrl_path, bsc_gsmnet);
|
2014-03-06 16:20:55 +00:00
|
|
|
if (!bsc_gsmnet->bsc_data->rf_ctrl) {
|
2014-02-07 19:07:51 +00:00
|
|
|
fprintf(stderr, "Failed to create the RF service.\n");
|
|
|
|
exit(1);
|
2012-05-11 21:28:19 +00:00
|
|
|
}
|
|
|
|
|
2009-08-17 04:55:10 +00:00
|
|
|
if (db_init(database_name)) {
|
|
|
|
printf("DB: Failed to init database. Please check the option settings.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
printf("DB: Database initialized.\n");
|
|
|
|
|
|
|
|
if (db_prepare()) {
|
|
|
|
printf("DB: Failed to prepare database.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
printf("DB: Database prepared.\n");
|
|
|
|
|
2009-12-23 04:29:04 +00:00
|
|
|
/* setup the timer */
|
|
|
|
db_sync_timer.cb = db_sync_timer_cb;
|
|
|
|
db_sync_timer.data = NULL;
|
2011-11-13 18:02:06 +00:00
|
|
|
if (use_db_counter)
|
|
|
|
osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
|
2009-12-23 04:29:04 +00:00
|
|
|
|
2012-12-26 23:40:32 +00:00
|
|
|
bsc_gsmnet->subscr_expire_timer.cb = subscr_expire_cb;
|
|
|
|
bsc_gsmnet->subscr_expire_timer.data = NULL;
|
|
|
|
osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
|
|
|
|
|
2009-08-06 15:43:50 +00:00
|
|
|
signal(SIGINT, &signal_handler);
|
2009-01-01 01:50:32 +00:00
|
|
|
signal(SIGABRT, &signal_handler);
|
2009-06-20 20:36:41 +00:00
|
|
|
signal(SIGUSR1, &signal_handler);
|
2009-12-24 09:51:56 +00:00
|
|
|
signal(SIGUSR2, &signal_handler);
|
2011-05-12 14:02:07 +00:00
|
|
|
osmo_init_ignore_signals();
|
2009-01-01 01:50:32 +00:00
|
|
|
|
2010-12-24 12:48:27 +00:00
|
|
|
/* start the SMS queue */
|
2010-12-25 16:43:03 +00:00
|
|
|
if (sms_queue_start(bsc_gsmnet, 20) != 0)
|
2010-12-24 12:48:27 +00:00
|
|
|
return -1;
|
2012-11-20 21:22:04 +00:00
|
|
|
|
2010-08-25 17:43:54 +00:00
|
|
|
if (daemonize) {
|
|
|
|
rc = osmo_daemonize();
|
|
|
|
if (rc < 0) {
|
|
|
|
perror("Error during daemonize");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-26 00:05:11 +00:00
|
|
|
while (1) {
|
2010-03-26 13:28:59 +00:00
|
|
|
log_reset_context();
|
2011-05-06 10:11:23 +00:00
|
|
|
osmo_select_main(0);
|
2008-12-26 00:05:11 +00:00
|
|
|
}
|
|
|
|
}
|