From b61e3b21580afc6381a6c72618d51697c7ce9771 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 22 Dec 2009 22:32:51 +0100 Subject: Import the new logging architecture This is the new logging architecture, including * support for multiuple logging targets like stderr and vty * log levels in addition to categories/subsystems * filtering based on imsi, i.e. only see events for one subscriber * dynamically change log level for each category for each vty --- openbsc/src/bsc_hack.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index a9a5d372f..0d20d43d3 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -38,6 +38,7 @@ #include /* 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"; @@ -105,10 +106,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 +121,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; @@ -158,11 +159,17 @@ 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); + + /* enable filters */ + debug_set_all_filter(stderr_target, 1); /* parse options */ handle_options(argc, argv); @@ -193,6 +200,7 @@ int main(int argc, char **argv) while (1) { bsc_upqueue(bsc_gsmnet); + debug_reset_context(); bsc_select_main(0); } } -- cgit v1.2.3 From 079353ad1f894853b80cda4db8ee0ce08d682b28 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 23 Dec 2009 05:29:04 +0100 Subject: [statistics] Do the syncing to db from within the bsc_hack Change the counters_store_db function to be a generic for_each function taking a function pointer and data. Use that in bsc_hack to store it to the DB. This is removing the DB requirement and will allow to handle the counter values in different ways without making the counter list public. I verified that the syncing is still taking place. --- openbsc/src/bsc_hack.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index 0d20d43d3..8792cc36c 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -43,6 +43,11 @@ 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); @@ -155,6 +160,19 @@ static void signal_handler(int signal) } } +/* 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); +} + int main(int argc, char **argv) { int rc; @@ -189,6 +207,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); -- cgit v1.2.3 From 3cefa9aaa0832b9cf99f3599f7cc1c0499e78cbb Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 24 Dec 2009 10:51:56 +0100 Subject: vty: sub-divide talloc contexts and include them in talloc report The VTY code makes so many allocations that a full report is simply too long to provide any useful information. So we sub-divide it in multiple contexts, and report only one level deep at SIGURS1. We also introduce SIGUSR2 for the full detailed VTY report. --- openbsc/src/bsc_hack.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index 8792cc36c..3122fae9c 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -138,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); @@ -153,8 +154,12 @@ 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; } @@ -219,6 +224,7 @@ 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) { -- cgit v1.2.3 From 39315c47989326275823d1589425ee62d15bc823 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 10 Jan 2010 18:01:52 +0100 Subject: [OML] parse attributes depending on BTS type Some NM attributes are defined differently depending on the BTS type. Having one big nm_att_tlvdef[] table for all BTS types is no longer sufficient. This patch * introduces 'struct gsm_bts_model' to describe a BTS model * adds definitions of gsm_bts_model for BS-11 and nanoBTS * changes the abis_nm_tlv_parse() function: include a bts pointer --- openbsc/src/bsc_hack.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index 3122fae9c..581e9be4d 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -178,6 +178,9 @@ static void db_sync_timer_cb(void *data) bsc_schedule_timer(&db_sync_timer, DB_SYNC_INTERVAL); } +extern int bts_model_bs11_init(void); +extern int bts_model_nanobts_init(void); + int main(int argc, char **argv) { int rc; @@ -191,6 +194,9 @@ int main(int argc, char **argv) stderr_target = debug_target_create_stderr(); debug_add_target(stderr_target); + bts_model_bs11_init(); + bts_model_nanobts_init(); + /* enable filters */ debug_set_all_filter(stderr_target, 1); -- cgit v1.2.3 From 06770617570340bd171be7e067d77c3e07b2c787 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 12 Jan 2010 10:46:27 +0100 Subject: update copyright statements * include 2010 * add Andreas Eversberg and Sylvain --- openbsc/src/bsc_hack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index 581e9be4d..e7db3c733 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 +/* (C) 2008-2010 by Harald Welte * (C) 2009 by Holger Hans Peter Freyther * All Rights Reserved * -- cgit v1.2.3 From 604d851b89d2d62f024223d333c833ebebd42060 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Mon, 11 Jan 2010 13:50:44 +0100 Subject: Register GSM_BTS_TYPE_UNKNOWN in bsc_hack.c The way the VTY configuration sytem works is that it first registers a BTS of type GSM_BTS_TYPE_UNKNOWN and then sets the type correctly (after encountering the type statement). This makes sure that registering a BTS of type UNKNOWN succeeds. --- openbsc/src/bsc_hack.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index e7db3c733..7755726c9 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -178,6 +178,7 @@ static void db_sync_timer_cb(void *data) 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); @@ -194,6 +195,7 @@ int main(int argc, char **argv) stderr_target = debug_target_create_stderr(); debug_add_target(stderr_target); + bts_model_unknown_init(); bts_model_bs11_init(); bts_model_nanobts_init(); -- cgit v1.2.3 From dfe6c7d910edbba238751d0cfddbb627bb08ef54 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 20 Feb 2010 16:24:02 +0100 Subject: split 'libosmocore' from openbsc codebase This library is intended to collect all generic/common funcitionality of all Osmocom.org projects, including OpenBSC but also OsmocomBB The library currently includes the following modules: bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer, tlv_parse, linuxlist msgb allocation error debugging had to be temporarily disabled as it depends on 'debug.c' functionality which at the moment remains in OpenBSC --- openbsc/src/bsc_hack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbsc/src/bsc_hack.c') diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c index 7755726c9..49c9d36ef 100644 --- a/openbsc/src/bsc_hack.c +++ b/openbsc/src/bsc_hack.c @@ -31,10 +31,10 @@ #include #include -#include +#include #include #include -#include +#include #include /* MCC and MNC for the Location Area Identifier */ -- cgit v1.2.3