aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-09-15 22:29:25 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-09-15 22:29:25 +0800
commit3e8e046ee533c9a094e2e78d6bc839d650170905 (patch)
tree3ad3120cedb923e39658fa8db7672c5f8b40a542
parent85804a80d4d6cdd246a6d2ea03c6aee827417a7a (diff)
bsc: Create struct osmo_msc_data to hold MSC information, handle signals
-rw-r--r--openbsc/include/openbsc/Makefile.am3
-rw-r--r--openbsc/include/openbsc/gsm_data.h5
-rw-r--r--openbsc/include/openbsc/osmo_msc_data.h33
-rw-r--r--openbsc/src/bsc/osmo_bsc_main.c43
-rw-r--r--openbsc/src/gsm_data.c7
5 files changed, 89 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am
index 234a47c98..b16a1b576 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -10,7 +10,8 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \
crc24.h gprs_bssgp.h gprs_llc.h gprs_ns.h gprs_gmm.h \
gb_proxy.h gprs_sgsn.h gsm_04_08_gprs.h sgsn.h \
gprs_ns_frgre.h auth.h osmo_msc.h bsc_msc.h bsc_nat.h \
- osmo_bsc_rf.h osmo_bsc.h network_listen.h bsc_nat_sccp.h
+ osmo_bsc_rf.h osmo_bsc.h network_listen.h bsc_nat_sccp.h \
+ osmo_msc_data.h
openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h
openbscdir = $(includedir)/openbsc
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 31e115281..e0f7c7049 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -3,6 +3,8 @@
#include <sys/types.h>
+struct osmo_msc_data;
+
enum gsm_phys_chan_config {
GSM_PCHAN_NONE,
GSM_PCHAN_CCCH,
@@ -722,7 +724,8 @@ struct gsm_network {
/* Use a TCH for handling requests of type paging any */
int pag_any_tch;
- int msc_prio;
+ /* MSC data in case we are a true BSC */
+ struct osmo_msc_data *msc_data;
};
#define SMS_HDR_SIZE 128
diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h
new file mode 100644
index 000000000..4a84f7422
--- /dev/null
+++ b/openbsc/include/openbsc/osmo_msc_data.h
@@ -0,0 +1,33 @@
+/*
+ * Data for the true BSC
+ *
+ * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010 by On-Waves
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#ifndef _OSMO_MSC_DATA_H
+#define _OSMO_MSC_DATA_H
+
+#include "bsc_msc.h"
+
+struct osmo_msc_data {
+ struct bsc_msc_connection *msc_con;
+};
+
+#endif
diff --git a/openbsc/src/bsc/osmo_bsc_main.c b/openbsc/src/bsc/osmo_bsc_main.c
index b35d53754..062bbf80e 100644
--- a/openbsc/src/bsc/osmo_bsc_main.c
+++ b/openbsc/src/bsc/osmo_bsc_main.c
@@ -22,6 +22,8 @@
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/osmo_bsc_rf.h>
+#include <openbsc/osmo_msc_data.h>
+#include <openbsc/signal.h>
#include <openbsc/vty.h>
#include <osmocore/talloc.h>
@@ -32,9 +34,12 @@
#define _GNU_SOURCE
#include <getopt.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <unistd.h>
+
#include "bscconfig.h"
@@ -141,6 +146,38 @@ static struct vty_app_info vty_info = {
.is_config_node = bsc_vty_is_config_node,
};
+extern int bsc_shutdown_net(struct gsm_network *net);
+static void signal_handler(int signal)
+{
+ fprintf(stdout, "signal %u received\n", signal);
+
+ switch (signal) {
+ case SIGINT:
+ bsc_shutdown_net(bsc_gsmnet);
+ dispatch_signal(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
+ sleep(3);
+ exit(0);
+ break;
+ case SIGABRT:
+ /* in case of abort, we want to obtain a talloc report
+ * and then return to the caller, who will abort the process */
+ case SIGUSR1:
+ talloc_report(tall_vty_ctx, stderr);
+ talloc_report_full(tall_bsc_ctx, stderr);
+ break;
+ case SIGUSR2:
+ if (!bsc_gsmnet->msc_data)
+ return;
+ if (!bsc_gsmnet->msc_data->msc_con)
+ return;
+ if (!bsc_gsmnet->msc_data->msc_con->is_connected)
+ return;
+ bsc_msc_lost(bsc_gsmnet->msc_data->msc_con);
+ break;
+ default:
+ break;
+ }
+}
int main(int argc, char **argv)
{
@@ -189,6 +226,12 @@ int main(int argc, char **argv)
}
}
+ signal(SIGINT, &signal_handler);
+ signal(SIGABRT, &signal_handler);
+ signal(SIGUSR1, &signal_handler);
+ signal(SIGUSR2, &signal_handler);
+ signal(SIGPIPE, SIG_IGN);
+
if (daemonize) {
rc = osmo_daemonize();
if (rc < 0) {
diff --git a/openbsc/src/gsm_data.c b/openbsc/src/gsm_data.c
index 526b1777f..b7d39b4af 100644
--- a/openbsc/src/gsm_data.c
+++ b/openbsc/src/gsm_data.c
@@ -33,6 +33,7 @@
#include <osmocore/statistics.h>
#include <openbsc/gsm_data.h>
+#include <openbsc/osmo_msc_data.h>
#include <openbsc/abis_nm.h>
void *tall_bsc_ctx;
@@ -254,6 +255,12 @@ struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_c
if (!net)
return NULL;
+ net->msc_data = talloc_zero(net, struct osmo_msc_data);
+ if (!net->msc_data) {
+ talloc_free(net);
+ return NULL;
+ }
+
net->country_code = country_code;
net->network_code = network_code;
net->num_bts = 0;