aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-04-17 11:18:44 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-04-17 11:18:44 +0200
commit07ab5e47b10bc6c84fb749811ab8c3d366ff9eee (patch)
treef1a58a43c694cfa0782973d8caabd8ec3b0ac9e9
parent55ef2d362a043082280a5012707ae2d7b5e2cb1b (diff)
msc: Start compiling a MSC only applicationzecke/osmo-msc
This application has no support for Abis but will use the A-link to communicate with a BSC. Right now a lot of symbols are stubbed out.
-rw-r--r--openbsc/configure.in11
-rw-r--r--openbsc/src/Makefile.am3
-rw-r--r--openbsc/src/osmo-msc/Makefile.am12
-rw-r--r--openbsc/src/osmo-msc/osmo_msc_main.c191
-rw-r--r--openbsc/src/osmo-msc/osmo_msc_stubs.c127
5 files changed, 344 insertions, 0 deletions
diff --git a/openbsc/configure.in b/openbsc/configure.in
index ef2be591f..a65e1a389 100644
--- a/openbsc/configure.in
+++ b/openbsc/configure.in
@@ -43,6 +43,16 @@ AC_ARG_ENABLE([osmo-bsc], [AS_HELP_STRING([--enable-osmo-bsc], [Build the Osmo B
])
AM_CONDITIONAL(BUILD_BSC, test "x$osmo_ac_build_bsc" = "xyes")
+AC_ARG_ENABLE([osmo-msc], [AS_HELP_STRING([--enable-osmo-msc], [Build the Osmo MSC])],
+ [
+ PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.2)
+ osmo_ac_build_msc="yes"
+ ],
+ [
+ osmo_ac_build_msc="no"
+ ])
+AM_CONDITIONAL(BUILD_MSC, test "x$osmo_ac_build_msc" = "xyes")
+
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.2.0)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.2.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.2.0)
@@ -99,6 +109,7 @@ AC_OUTPUT(
src/osmo-bsc/Makefile
src/osmo-bsc_nat/Makefile
src/osmo-bsc_mgcp/Makefile
+ src/osmo-msc/Makefile
src/ipaccess/Makefile
src/utils/Makefile
src/libgb/Makefile
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index df7b936e7..3cd8dce08 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -11,3 +11,6 @@ endif
if BUILD_BSC
SUBDIRS += osmo-bsc
endif
+if BUILD_MSC
+SUBDIRS += osmo-msc
+endif
diff --git a/openbsc/src/osmo-msc/Makefile.am b/openbsc/src/osmo-msc/Makefile.am
new file mode 100644
index 000000000..250000048
--- /dev/null
+++ b/openbsc/src/osmo-msc/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
+
+bin_PROGRAMS = osmo-nitb
+
+osmo_nitb_SOURCES = osmo_msc_main.c osmo_msc_stubs.c \
+ $(top_srcdir)/src/libbsc/gsm_subscriber_base.c \
+ $(top_srcdir)/src/libbsc/transaction.c
+osmo_nitb_LDADD = -ldl -ldbi $(LIBCRYPT) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libcommon/libcommon.a
diff --git a/openbsc/src/osmo-msc/osmo_msc_main.c b/openbsc/src/osmo-msc/osmo_msc_main.c
new file mode 100644
index 000000000..ae85b1790
--- /dev/null
+++ b/openbsc/src/osmo-msc/osmo_msc_main.c
@@ -0,0 +1,191 @@
+/* A MSC (+HLR +VLR) in a box without MAP */
+
+/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2011 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 Affero General Public License as published by
+ * the Free Software Foundation; either version 3 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 Affero General Public License for more details.
+ *
+ * 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/>.
+ *
+ */
+
+#include <unistd.h>
+#include <time.h>
+#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#define _GNU_SOURCE
+#include <getopt.h>
+
+#include <osmocom/core/select.h>
+#include <osmocom/core/process.h>
+#include <osmocom/core/talloc.h>
+
+#include <openbsc/db.h>
+#include <openbsc/debug.h>
+#include <openbsc/signal.h>
+#include <openbsc/osmo_msc.h>
+#include <openbsc/sms_queue.h>
+#include <openbsc/vty.h>
+
+#include "../../bscconfig.h"
+
+extern enum node_type bsc_vty_go_parent(struct vty *vty);
+
+static const char *database_name = "hlr.sqlite3";
+static const char *config_file = "openbsc.cfg";
+extern const char *openbsc_copyright;
+
+static struct vty_app_info vty_info = {
+ .name = "OsmoMSC",
+ .version = PACKAGE_VERSION,
+ .go_parent_cb = bsc_vty_go_parent,
+ .is_config_node = bsc_vty_is_config_node,
+};
+
+/* timer to store statistics */
+#define DB_SYNC_INTERVAL 60, 0
+static struct timer_list db_sync_timer;
+
+static struct log_target *stderr_target;
+struct gsm_network *bsc_gsmnet = 0;
+
+static int daemonize = 0;
+static int use_mncc_sock = 0;
+
+/* timer handling */
+static int _db_store_counter(struct counter *counter, void *data)
+{
+ return db_store_counter(counter);
+}
+
+static void db_sync_timer_cb(void *data)
+{
+ /* store counters to database and re-schedule */
+ counters_for_each(_db_store_counter, NULL);
+ bsc_schedule_timer(&db_sync_timer, DB_SYNC_INTERVAL);
+}
+
+extern void *tall_vty_ctx;
+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:
+ talloc_report_full(tall_vty_ctx, stderr);
+ break;
+ default:
+ break;
+ }
+}
+
+static void handle_options(char **argv, int argc)
+{
+}
+
+int main(int argc, char **argv)
+{
+ int rc;
+
+ vty_info.copyright = openbsc_copyright;
+
+ log_init(&log_info);
+ tall_bsc_ctx = talloc_named_const(NULL, 1, "osmomsc");
+ talloc_ctx_init();
+ on_dso_load_token();
+ on_dso_load_rrlp();
+ on_dso_load_ho_dec();
+ stderr_target = log_target_create_stderr();
+ log_add_target(stderr_target);
+
+
+ /* enable filters */
+ log_set_all_filter(stderr_target, 1);
+
+ /* This needs to precede handle_options() */
+ vty_init(&vty_info);
+ bsc_vty_init(&log_info);
+
+ /* parse options */
+ handle_options(argc, argv);
+
+ /* internal MNCC handler or MNCC socket? */
+ if (use_mncc_sock) {
+ rc = bsc_bootstrap_network(mncc_sock_from_cc, config_file);
+ if (rc >= 0)
+ mncc_sock_init(bsc_gsmnet);
+ } else
+ rc = bsc_bootstrap_network(int_mncc_recv, config_file);
+ if (rc < 0)
+ exit(1);
+ bsc_api_init(bsc_gsmnet, msc_bsc_api());
+
+ /* seed the PRNG */
+ srand(time(NULL));
+
+ 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");
+
+ /* setup the timer */
+ db_sync_timer.cb = db_sync_timer_cb;
+ db_sync_timer.data = NULL;
+ bsc_schedule_timer(&db_sync_timer, DB_SYNC_INTERVAL);
+
+ signal(SIGINT, &signal_handler);
+ signal(SIGABRT, &signal_handler);
+ signal(SIGUSR1, &signal_handler);
+ signal(SIGUSR2, &signal_handler);
+ signal(SIGPIPE, SIG_IGN);
+
+ /* start the SMS queue */
+ if (sms_queue_start(bsc_gsmnet, 20) != 0)
+ return -1;
+
+ if (daemonize) {
+ rc = osmo_daemonize();
+ if (rc < 0) {
+ perror("Error during daemonize");
+ exit(1);
+ }
+ }
+
+ while (1) {
+ log_reset_context();
+ bsc_select_main(0);
+ }
+}
diff --git a/openbsc/src/osmo-msc/osmo_msc_stubs.c b/openbsc/src/osmo-msc/osmo_msc_stubs.c
new file mode 100644
index 000000000..9935ad4b7
--- /dev/null
+++ b/openbsc/src/osmo-msc/osmo_msc_stubs.c
@@ -0,0 +1,127 @@
+/* Stubs to make it compile */
+
+/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2011 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 Affero General Public License as published by
+ * the Free Software Foundation; either version 3 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 Affero General Public License for more details.
+ *
+ * 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/>.
+ *
+ */
+
+#include <osmocom/gsm/tlv.h>
+
+#include <openbsc/gsm_data.h>
+
+#include <stdlib.h>
+
+/* For talloc_context */
+void *tall_fle_ctx;
+void *tall_paging_ctx;
+void *tall_tqe_ctx;
+void *tall_map_ctx;
+void *tall_upq_ctx;
+
+/* For gsm_bts_model_register */
+const struct tlv_definition nm_att_tlvdef = {};
+
+
+/* BSC API */
+int bsc_api_init(struct gsm_network *network, struct bsc_api *api)
+{
+ abort();
+}
+
+int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn,
+ struct msgb *msg, int link_id, int allow_sach)
+{
+ abort();
+}
+
+int gsm0808_assign_req(struct gsm_subscriber_connection *conn,
+ int chan_mode, int full_rate)
+{
+ abort();
+}
+
+int gsm0808_clear(struct gsm_subscriber_connection *conn)
+{
+ abort();
+}
+
+int gsm0808_cipher_mode(struct gsm_subscriber_connection *conn,
+ int cipher, const uint8_t *key, int len,
+ int include_imeisv)
+{
+ abort();
+}
+
+int gsm0808_page(struct gsm_bts *bts, unsigned int page_group,
+ unsigned int mi_len, uint8_t *mi, int chan_type)
+{
+ abort();
+}
+
+/* paging handling */
+int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr,
+ int type, gsm_cbfn *cbfn, void *data)
+{
+ abort();
+}
+
+int paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr,
+ struct gsm_subscriber_connection *conn, struct msgb *msg)
+{
+ abort();
+}
+
+/* subscriber con handling */
+struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr)
+{
+ abort();
+}
+
+void subscr_con_free(struct gsm_subscriber_connection *conn)
+{
+ abort();
+}
+
+
+/* misc stubs */
+int ipacc_rtp_direct = 0;
+
+void bsc_bootstrap_network() { abort(); }
+void bsc_shutdown_net() { abort(); }
+void bsc_vty_init() { abort(); }
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause) { abort(); }
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value val) { abort(); }
+int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr) { abort();}
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, u_int8_t *mi_type) { abort(); }
+int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg) { abort(); }
+void gsm_net_update_ctype(struct gsm_network *net) { abort(); }
+void on_dso_load_ho_dec() { abort(); }
+void rsl_ipacc_mdcx() { abort(); }
+void rsl_ipacc_mdcx_to_rtpsock() { abort(); }
+void rtp_send_frame() { abort(); }
+void rtp_socket_connect() { abort(); }
+void rtp_socket_create() { abort(); }
+void rtp_socket_free() { abort(); }
+void rtp_socket_proxy() { abort(); }
+void rtp_socket_upstream() { abort(); }
+int send_siemens_mrpci(struct gsm_lchan *lchan, u_int8_t *classmark2_lv) { abort(); }
+void trau_mux_map_lchan() { abort(); }
+void trau_mux_unmap() { abort(); }
+void trau_recv_lchan() { abort(); }
+void trau_send_frame() { abort(); }
+
+