diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-03-22 03:25:11 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-03-24 06:16:04 +0100 |
commit | 22481bf76d129d3c41d20b96b6587ef085be485b (patch) | |
tree | 8c8de852e945dd5422a83bc7e0c37548d2911fe2 /openbsc/src/bsc_hack.c | |
parent | b973955295b720b8ba7c556d0165750ed9bfb381 (diff) | |
parent | 61b4232c6363ff9d78ef73b9dbf47ec16c94d610 (diff) |
Merge remote branch 'origin/master' into on-waves/bsc-master
* Move to libosmocore
* Move to new debugging architecture
* Register the BTS types
* Has only been compile tested
Conflicts:
openbsc/include/openbsc/Makefile.am
openbsc/include/openbsc/gsm_data.h
openbsc/include/openbsc/ipaccess.h
openbsc/include/openbsc/mgcp.h
openbsc/include/openbsc/msgb.h
openbsc/include/openbsc/tlv.h
openbsc/src/Makefile.am
openbsc/src/abis_rsl.c
openbsc/src/bsc_init.c
openbsc/src/bsc_mgcp.c
openbsc/src/chan_alloc.c
openbsc/src/debug.c
openbsc/src/gsm_subscriber_base.c
openbsc/src/msgb.c
openbsc/src/rest_octets.c
openbsc/src/sccp/sccp.c
openbsc/src/vty/command.c
openbsc/src/vty_interface.c
openbsc/tests/Makefile.am
Diffstat (limited to 'openbsc/src/bsc_hack.c')
-rw-r--r-- | openbsc/src/bsc_hack.c | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index a9a5d372f..49c9d36ef 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -1,6 +1,6 @@ /* A hackish minimal BSC (+MSC +HLR) implementation */ -/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org> +/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> * All Rights Reserved * @@ -31,17 +31,23 @@ #include <getopt.h> #include <openbsc/db.h> -#include <openbsc/select.h> +#include <osmocore/select.h> #include <openbsc/debug.h> #include <openbsc/e1_input.h> -#include <openbsc/talloc.h> +#include <osmocore/talloc.h> #include <openbsc/signal.h> /* MCC and MNC for the Location Area Identifier */ +static struct debug_target *stderr_target; struct gsm_network *bsc_gsmnet = 0; static const char *database_name = "hlr.sqlite3"; static const char *config_file = "openbsc.cfg"; + +/* timer to store statistics */ +#define DB_SYNC_INTERVAL 60, 0 +static struct timer_list db_sync_timer; + extern int bsc_bootstrap_network(int (*mmc_rev)(struct gsm_network *, int, void *), const char *cfg_file); extern int bsc_shutdown_net(struct gsm_network *net); @@ -105,10 +111,10 @@ static void handle_options(int argc, char** argv) print_help(); exit(0); case 's': - debug_use_color(0); + debug_set_use_color(stderr_target, 0); break; case 'd': - debug_parse_category_mask(optarg); + debug_parse_category_mask(stderr_target, optarg); break; case 'l': database_name = strdup(optarg); @@ -120,7 +126,7 @@ static void handle_options(int argc, char** argv) create_pcap_file(optarg); break; case 'T': - debug_timestamp(1); + debug_set_print_timestamp(stderr_target, 1); break; case 'P': ipacc_rtp_direct = 0; @@ -132,6 +138,7 @@ static void handle_options(int argc, char** argv) } } +extern void *tall_vty_ctx; static void signal_handler(int signal) { fprintf(stdout, "signal %u received\n", signal); @@ -147,22 +154,53 @@ static void signal_handler(int signal) /* 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; } } +/* 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 int bts_model_unknown_init(void); +extern int bts_model_bs11_init(void); +extern int bts_model_nanobts_init(void); + int main(int argc, char **argv) { int rc; + debug_init(); tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc"); talloc_ctx_init(); on_dso_load_token(); on_dso_load_rrlp(); on_dso_load_ho_dec(); + stderr_target = debug_target_create_stderr(); + debug_add_target(stderr_target); + + bts_model_unknown_init(); + bts_model_bs11_init(); + bts_model_nanobts_init(); + + /* enable filters */ + debug_set_all_filter(stderr_target, 1); /* parse options */ handle_options(argc, argv); @@ -182,6 +220,11 @@ int main(int argc, char **argv) } 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); + rc = bsc_bootstrap_network(mncc_recv, config_file); if (rc < 0) exit(1); @@ -189,10 +232,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); while (1) { bsc_upqueue(bsc_gsmnet); + debug_reset_context(); bsc_select_main(0); } } |