summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-28 18:54:32 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-02 11:43:06 +0100
commit6995f24831b70ef64bd08976f2aecc5314fe9862 (patch)
tree2d8465b045245304156394930a4ff60ad9d6cf04
parentb7ccac4d620271e8780fdc7640cba96c275bdf85 (diff)
logging: Only compare the subscr address
Move the "logging filter imsi IMSI" into the BTS/NITB code to allow to set the gsm_subscriber and only compare it. This way we simply compare the subscriber address and don't have to care if the subscriber data is still valid.
-rw-r--r--openbsc/include/openbsc/debug.h3
-rw-r--r--openbsc/src/libbsc/bsc_vty.c18
-rw-r--r--openbsc/src/libbsc/paging.c5
-rw-r--r--openbsc/src/libcommon/debug.c18
-rw-r--r--openbsc/src/libmsc/vty_interface_layer3.c28
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c29
-rw-r--r--openbsc/src/osmo-bsc_mgcp/mgcp_main.c3
7 files changed, 71 insertions, 33 deletions
diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h
index d851181c7..bbb3ee618 100644
--- a/openbsc/include/openbsc/debug.h
+++ b/openbsc/include/openbsc/debug.h
@@ -53,8 +53,9 @@ enum {
/* we don't need a header dependency for this... */
struct gprs_nsvc;
struct bssgp_bvc_ctx;
+struct gsm_subscriber;
-void log_set_imsi_filter(struct log_target *target, const char *imsi);
+void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr);
void log_set_nsvc_filter(struct log_target *target,
struct gprs_nsvc *nsvc);
void log_set_bvc_filter(struct log_target *target,
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 3e7ac585e..2857494eb 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -3183,22 +3183,6 @@ void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
osmo_counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
}
-DEFUN(logging_fltr_imsi,
- logging_fltr_imsi_cmd,
- "logging filter imsi IMSI",
- LOGGING_STR FILTER_STR
- "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
-{
- struct log_target *tgt = osmo_log_vty2tgt(vty);
-
- if (!tgt)
- return CMD_WARNING;
-
- log_set_imsi_filter(tgt, argv[0]);
- return CMD_SUCCESS;
-}
-
-
DEFUN(drop_bts,
drop_bts_cmd,
"drop bts connection <0-65535> (oml|rsl)",
@@ -3383,13 +3367,11 @@ int bsc_vty_init(const struct log_info *cat)
install_element_ve(&show_ts_cmd);
install_element_ve(&show_lchan_cmd);
install_element_ve(&show_lchan_summary_cmd);
- install_element_ve(&logging_fltr_imsi_cmd);
install_element_ve(&show_paging_cmd);
install_element_ve(&show_paging_group_cmd);
logging_vty_add_cmds(cat);
- install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
install_element(CONFIG_NODE, &cfg_net_cmd);
install_node(&net_node, config_write_net);
diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c
index 18bb3fe09..2d08af78a 100644
--- a/openbsc/src/libbsc/paging.c
+++ b/openbsc/src/libbsc/paging.c
@@ -250,12 +250,11 @@ static int paging_pending_request(struct gsm_bts_paging_state *bts,
static void paging_T3113_expired(void *data)
{
struct gsm_paging_request *req = (struct gsm_paging_request *)data;
- struct gsm_subscriber *subscr = subscr_get(req->subscr);
void *cbfn_param;
gsm_cbfn *cbfn;
int msg;
- log_set_context(BSC_CTX_SUBSCR, subscr);
+ log_set_context(BSC_CTX_SUBSCR, req->subscr);
LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n",
req, req->subscr->imsi);
@@ -275,8 +274,6 @@ static void paging_T3113_expired(void *data)
cbfn(GSM_HOOK_RR_PAGING, msg, NULL, NULL,
cbfn_param);
- log_set_context(BSC_CTX_SUBSCR, NULL);
- subscr_put(subscr);
}
static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c
index b3685e6d2..ca7ff5da6 100644
--- a/openbsc/src/libcommon/debug.c
+++ b/openbsc/src/libcommon/debug.c
@@ -177,7 +177,7 @@ static int filter_fn(const struct log_context *ctx,
const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC];
if ((tar->filter_map & (1 << FLT_IMSI)) != 0
- && subscr && strcmp(subscr->imsi, tar->filter_data[FLT_IMSI]) == 0)
+ && subscr && subscr == tar->filter_data[FLT_IMSI])
return 1;
/* Filter on the NS Virtual Connection */
@@ -199,14 +199,18 @@ const struct log_info log_info = {
.num_cat = ARRAY_SIZE(default_categories),
};
-void log_set_imsi_filter(struct log_target *target, const char *imsi)
+void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr)
{
- if (imsi) {
+ /* free the old data */
+ if (target->filter_data[FLT_IMSI]) {
+ subscr_put(target->filter_data[FLT_IMSI]);
+ target->filter_data[FLT_IMSI] = NULL;
+ }
+
+ if (subscr) {
target->filter_map |= (1 << FLT_IMSI);
- target->filter_data[FLT_IMSI] = talloc_strdup(target, imsi);
- } else if (target->filter_data[FLT_IMSI]) {
+ target->filter_data[FLT_IMSI] = subscr_get(subscr);
+ } else {
target->filter_map &= ~(1 << FLT_IMSI);
- talloc_free(target->filter_data[FLT_IMSI]);
- target->filter_data[FLT_IMSI] = NULL;
}
}
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 06ef2d1ae..dec949412 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -49,6 +49,8 @@
#include <openbsc/mncc_int.h>
#include <openbsc/handover.h>
+#include <osmocom/vty/logging.h>
+
#include "meas_feed.h"
extern struct gsm_network *gsmnet_from_vty(struct vty *v);
@@ -1027,6 +1029,30 @@ DEFUN(meas_feed_scenario, meas_feed_scenario_cmd,
return CMD_SUCCESS;
}
+
+DEFUN(logging_fltr_imsi,
+ logging_fltr_imsi_cmd,
+ "logging filter imsi IMSI",
+ LOGGING_STR FILTER_STR
+ "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
+{
+ struct gsm_subscriber *subscr;
+ struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+
+ if (!tgt)
+ return CMD_WARNING;
+
+ subscr = subscr_get_by_imsi(gsmnet->subscr_group, argv[0]);
+ if (!subscr) {
+ vty_out(vty, "%%no subscriber with IMSI(%s)%s",
+ argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ log_set_imsi_filter(tgt, subscr);
+ return CMD_SUCCESS;
+}
int bsc_vty_init_extra(void)
{
osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL);
@@ -1045,6 +1071,7 @@ int bsc_vty_init_extra(void)
install_element_ve(&subscriber_update_cmd);
install_element_ve(&show_stats_cmd);
install_element_ve(&show_smsqueue_cmd);
+ install_element_ve(&logging_fltr_imsi_cmd);
install_element(ENABLE_NODE, &ena_subscr_delete_cmd);
install_element(ENABLE_NODE, &ena_subscr_name_cmd);
@@ -1071,6 +1098,7 @@ int bsc_vty_init_extra(void)
install_element(MNCC_INT_NODE, &mnccint_meas_feed_cmd);
install_element(CFG_LOG_NODE, &log_level_sms_cmd);
+ install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
return 0;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index 4d5a55d88..ab36e4789 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -22,8 +22,11 @@
#include <openbsc/osmo_bsc.h>
#include <openbsc/osmo_msc_data.h>
#include <openbsc/vty.h>
+#include <openbsc/gsm_subscriber.h>
+#include <openbsc/debug.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/vty/logging.h>
#include <time.h>
@@ -739,6 +742,29 @@ DEFUN(gen_position_trap,
return CMD_SUCCESS;
}
+DEFUN(logging_fltr_imsi,
+ logging_fltr_imsi_cmd,
+ "logging filter imsi IMSI",
+ LOGGING_STR FILTER_STR
+ "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
+{
+ struct gsm_subscriber *subscr;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+
+ if (!tgt)
+ return CMD_WARNING;
+
+ subscr = subscr_get_or_create(bsc_gsmnet->subscr_group, argv[0]);
+ if (!subscr) {
+ vty_out(vty, "%%no subscriber with IMSI(%s)%s",
+ argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ log_set_imsi_filter(tgt, subscr);
+ return CMD_SUCCESS;
+}
+
int bsc_vty_init_extra(void)
{
install_element(CONFIG_NODE, &cfg_net_msc_cmd);
@@ -789,8 +815,11 @@ int bsc_vty_init_extra(void)
install_element_ve(&show_statistics_cmd);
install_element_ve(&show_mscs_cmd);
install_element_ve(&show_pos_cmd);
+ install_element_ve(&logging_fltr_imsi_cmd);
install_element(ENABLE_NODE, &gen_position_trap_cmd);
+ install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
+
return 0;
}
diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c
index bee127680..5f703c290 100644
--- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c
+++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c
@@ -53,9 +53,6 @@
#include "openbsc/mgcp_transcode.h"
#endif
-/* this is here for the vty... it will never be called */
-void subscr_put() { abort(); }
-
#define _GNU_SOURCE
#include <getopt.h>