From 8dcebd3e7f787d1badb78d3b8ffb98543adca5c9 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 18 Feb 2011 21:10:05 +0100 Subject: LOGGING: make sure to make the 'logging filter' compatible with vty log cfg Recent libosmocore introdues a way how log targets can be configured from the VTY. This commit makes the 'log filter (imsi|nsvc|bvc)' compatible with it. --- openbsc/src/bsc_vty.c | 11 +++++------ openbsc/src/gprs/gprs_bssgp_vty.c | 11 +++++------ openbsc/src/gprs/gprs_ns_vty.c | 11 +++++------ 3 files changed, 15 insertions(+), 18 deletions(-) (limited to 'openbsc') diff --git a/openbsc/src/bsc_vty.c b/openbsc/src/bsc_vty.c index 55a667cdf..6e07a6b7f 100644 --- a/openbsc/src/bsc_vty.c +++ b/openbsc/src/bsc_vty.c @@ -2504,18 +2504,16 @@ DEFUN(logging_fltr_imsi, LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct telnet_connection *conn; + struct log_target *tgt = osmo_log_vty2tgt(vty); - conn = (struct telnet_connection *) vty->priv; - if (!conn->dbg) { - vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE); + if (!tgt) return CMD_WARNING; - } - log_set_imsi_filter(conn->dbg, argv[0]); + log_set_imsi_filter(tgt, argv[0]); return CMD_SUCCESS; } + DEFUN(drop_bts, drop_bts_cmd, "drop bts connection <0-65535> (oml|rsl)", @@ -2635,6 +2633,7 @@ int bsc_vty_init(void) install_element_ve(&show_paging_cmd); logging_vty_add_cmds(); + 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/gprs/gprs_bssgp_vty.c b/openbsc/src/gprs/gprs_bssgp_vty.c index 6208ae3c1..9ebd09004 100644 --- a/openbsc/src/gprs/gprs_bssgp_vty.c +++ b/openbsc/src/gprs/gprs_bssgp_vty.c @@ -138,16 +138,13 @@ DEFUN(logging_fltr_bvc, "BVCI of the BVC to be filtered\n" "BSSGP Virtual Connection Identifier (BVCI)\n") { - struct telnet_connection *conn; + struct log_target *tgt = osmo_log_vty2tgt(vty); struct bssgp_bvc_ctx *bvc; uint16_t nsei = atoi(argv[0]); uint16_t bvci = atoi(argv[1]); - conn = (struct telnet_connection *) vty->priv; - if (!conn->dbg) { - vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE); + if (!tgt) return CMD_WARNING; - } bvc = btsctx_by_bvci_nsei(bvci, nsei); if (!bvc) { @@ -155,7 +152,7 @@ DEFUN(logging_fltr_bvc, return CMD_WARNING; } - log_set_bvc_filter(conn->dbg, bvc); + log_set_bvc_filter(tgt, bvc); return CMD_SUCCESS; } @@ -166,6 +163,8 @@ int gprs_bssgp_vty_init(void) install_element_ve(&show_bvc_cmd); install_element_ve(&logging_fltr_bvc_cmd); + install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd); + install_element(CONFIG_NODE, &cfg_bssgp_cmd); install_node(&bssgp_node, config_write_bssgp); install_default(BSSGP_NODE); diff --git a/openbsc/src/gprs/gprs_ns_vty.c b/openbsc/src/gprs/gprs_ns_vty.c index 42fc02560..39277fc71 100644 --- a/openbsc/src/gprs/gprs_ns_vty.c +++ b/openbsc/src/gprs/gprs_ns_vty.c @@ -513,15 +513,12 @@ DEFUN(logging_fltr_nsvc, "Identify NS-VC by NSVCI\n" "Numeric identifier\n") { - struct telnet_connection *conn; + struct log_target *tgt = osmo_log_vty2tgt(vty); struct gprs_nsvc *nsvc; uint16_t id = atoi(argv[1]); - conn = (struct telnet_connection *) vty->priv; - if (!conn->dbg) { - vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE); + if (!tgt) return CMD_WARNING; - } if (!strcmp(argv[0], "nsei")) nsvc = nsvc_by_nsei(vty_nsi, id); @@ -533,7 +530,7 @@ DEFUN(logging_fltr_nsvc, return CMD_WARNING; } - log_set_nsvc_filter(conn->dbg, nsvc); + log_set_nsvc_filter(tgt, nsvc); return CMD_SUCCESS; } @@ -546,6 +543,8 @@ int gprs_ns_vty_init(struct gprs_ns_inst *nsi) install_element_ve(&show_nse_cmd); install_element_ve(&logging_fltr_nsvc_cmd); + install_element(CFG_LOG_NODE, &logging_fltr_nsvc_cmd); + install_element(CONFIG_NODE, &cfg_ns_cmd); install_node(&ns_node, config_write_ns); install_default(NS_NODE); -- cgit v1.2.3