aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/src/Makefile.am5
-rw-r--r--openbsc/src/bsc_vty.c22
-rw-r--r--openbsc/src/common_vty.c115
-rw-r--r--openbsc/src/gprs/gb_proxy_main.c2
-rw-r--r--openbsc/src/gprs/sgsn_main.c2
-rw-r--r--openbsc/src/logging_vty.c (renamed from openbsc/src/vty_interface_cmds.c)100
-rw-r--r--openbsc/src/mgcp/mgcp_main.c2
7 files changed, 143 insertions, 105 deletions
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index eb9867a9b..942007199 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -18,7 +18,7 @@ libbsc_a_SOURCES = abis_rsl.c abis_nm.c gsm_data.c gsm_04_08_utils.c \
input/misdn.c input/ipaccess.c \
talloc_ctx.c system_information.c rest_octets.c \
rtp_proxy.c bts_siemens_bs11.c bts_ipaccess_nanobts.c \
- bts_unknown.c bsc_version.c bsc_api.c
+ bts_unknown.c bsc_version.c bsc_api.c bsc_vty.c
libmsc_a_SOURCES = gsm_subscriber.c db.c \
mncc.c gsm_04_08.c gsm_04_11.c transaction.c \
@@ -26,7 +26,8 @@ libmsc_a_SOURCES = gsm_subscriber.c db.c \
handover_logic.c handover_decision.c meas_rep.c
libvty_a_SOURCES = vty/buffer.c vty/command.c vty/vector.c vty/vty.c \
- telnet_interface.c vty_interface_cmds.c vty/utils.c
+ telnet_interface.c vty/utils.c common_vty.c \
+ logging_vty.c
libsccp_a_SOURCES = sccp/sccp.c
diff --git a/openbsc/src/bsc_vty.c b/openbsc/src/bsc_vty.c
index 41a927715..5a89af0bf 100644
--- a/openbsc/src/bsc_vty.c
+++ b/openbsc/src/bsc_vty.c
@@ -40,6 +40,7 @@
#include <openbsc/telnet_interface.h>
#include <openbsc/vty.h>
#include <openbsc/gprs_ns.h>
+#include <openbsc/debug.h>
#include "../bscconfig.h"
@@ -1995,6 +1996,24 @@ void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
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 telnet_connection *conn;
+
+ conn = (struct telnet_connection *) vty->priv;
+ if (!conn->dbg) {
+ vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ log_set_imsi_filter(conn->dbg, argv[0]);
+ return CMD_SUCCESS;
+}
+
extern int bsc_vty_init_extra(void);
extern const char *openbsc_copyright;
@@ -2006,6 +2025,7 @@ int bsc_vty_init(void)
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_e1drv_cmd);
install_element_ve(&show_e1line_cmd);
@@ -2013,7 +2033,7 @@ int bsc_vty_init(void)
install_element_ve(&show_paging_cmd);
- openbsc_vty_add_cmds();
+ logging_vty_add_cmds();
install_element(CONFIG_NODE, &cfg_net_cmd);
install_node(&net_node, config_write_net);
diff --git a/openbsc/src/common_vty.c b/openbsc/src/common_vty.c
new file mode 100644
index 000000000..1f2f93b19
--- /dev/null
+++ b/openbsc/src/common_vty.c
@@ -0,0 +1,115 @@
+/* OpenBSC VTY common helpers */
+/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2009-2010 by Holger Hans Peter Freyther
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <osmocore/talloc.h>
+
+#include <openbsc/vty.h>
+#include <openbsc/telnet_interface.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/debug.h>
+
+#include <vty/command.h>
+#include <vty/buffer.h>
+#include <vty/vty.h>
+
+
+/* Down vty node level. */
+gDEFUN(ournode_exit,
+ ournode_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
+{
+ switch (vty->node) {
+ case GSMNET_NODE:
+ vty->node = CONFIG_NODE;
+ vty->index = NULL;
+ break;
+ case BTS_NODE:
+ vty->node = GSMNET_NODE;
+ {
+ /* set vty->index correctly ! */
+ struct gsm_bts *bts = vty->index;
+ vty->index = bts->network;
+ vty->index_sub = NULL;
+ }
+ break;
+ case TRX_NODE:
+ vty->node = BTS_NODE;
+ {
+ /* set vty->index correctly ! */
+ struct gsm_bts_trx *trx = vty->index;
+ vty->index = trx->bts;
+ vty->index_sub = &trx->bts->description;
+ }
+ break;
+ case TS_NODE:
+ vty->node = TRX_NODE;
+ {
+ /* set vty->index correctly ! */
+ struct gsm_bts_trx_ts *ts = vty->index;
+ vty->index = ts->trx;
+ vty->index_sub = &ts->trx->description;
+ }
+ break;
+ case MGCP_NODE:
+ case GBPROXY_NODE:
+ case SGSN_NODE:
+ case NS_NODE:
+ vty->node = CONFIG_NODE;
+ vty->index = NULL;
+ break;
+ default:
+ break;
+ }
+ return CMD_SUCCESS;
+}
+
+/* End of configuration. */
+gDEFUN(ournode_end,
+ ournode_end_cmd, "end", "End current mode and change to enable mode.")
+{
+ switch (vty->node) {
+ case VIEW_NODE:
+ case ENABLE_NODE:
+ /* Nothing to do. */
+ break;
+ case CONFIG_NODE:
+ case GSMNET_NODE:
+ case BTS_NODE:
+ case TRX_NODE:
+ case TS_NODE:
+ case MGCP_NODE:
+ case GBPROXY_NODE:
+ case SGSN_NODE:
+ case NS_NODE:
+ case VTY_NODE:
+ vty_config_unlock(vty);
+ vty->node = ENABLE_NODE;
+ vty->index = NULL;
+ vty->index_sub = NULL;
+ break;
+ default:
+ break;
+ }
+ return CMD_SUCCESS;
+}
+
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index e450d1fe6..02b31815a 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -206,7 +206,7 @@ int main(int argc, char **argv)
log_set_all_filter(stderr_target, 1);
vty_init("Osmocom Gb Proxy", PACKAGE_VERSION, openbsc_copyright);
- openbsc_vty_add_cmds();
+ logging_vty_add_cmds();
gbproxy_vty_init();
handle_options(argc, argv);
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index aaad654e6..7aa6e139e 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -139,7 +139,7 @@ int main(int argc, char **argv)
log_set_all_filter(stderr_target, 1);
vty_init("Osmocom SGSN", PACKAGE_VERSION, openbsc_copyright);
- openbsc_vty_add_cmds();
+ logging_vty_add_cmds();
sgsn_vty_init();
rate_ctr_init(tall_bsc_ctx);
diff --git a/openbsc/src/vty_interface_cmds.c b/openbsc/src/logging_vty.c
index b7b5bf831..603975ae6 100644
--- a/openbsc/src/vty_interface_cmds.c
+++ b/openbsc/src/logging_vty.c
@@ -55,85 +55,6 @@ struct log_target *log_target_create_vty(struct vty *vty)
return target;
}
-/* Down vty node level. */
-gDEFUN(ournode_exit,
- ournode_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
-{
- switch (vty->node) {
- case GSMNET_NODE:
- vty->node = CONFIG_NODE;
- vty->index = NULL;
- break;
- case BTS_NODE:
- vty->node = GSMNET_NODE;
- {
- /* set vty->index correctly ! */
- struct gsm_bts *bts = vty->index;
- vty->index = bts->network;
- vty->index_sub = NULL;
- }
- break;
- case TRX_NODE:
- vty->node = BTS_NODE;
- {
- /* set vty->index correctly ! */
- struct gsm_bts_trx *trx = vty->index;
- vty->index = trx->bts;
- vty->index_sub = &trx->bts->description;
- }
- break;
- case TS_NODE:
- vty->node = TRX_NODE;
- {
- /* set vty->index correctly ! */
- struct gsm_bts_trx_ts *ts = vty->index;
- vty->index = ts->trx;
- vty->index_sub = &ts->trx->description;
- }
- break;
- case MGCP_NODE:
- case GBPROXY_NODE:
- case SGSN_NODE:
- case NS_NODE:
- vty->node = CONFIG_NODE;
- vty->index = NULL;
- break;
- default:
- break;
- }
- return CMD_SUCCESS;
-}
-
-/* End of configuration. */
-gDEFUN(ournode_end,
- ournode_end_cmd, "end", "End current mode and change to enable mode.")
-{
- switch (vty->node) {
- case VIEW_NODE:
- case ENABLE_NODE:
- /* Nothing to do. */
- break;
- case CONFIG_NODE:
- case GSMNET_NODE:
- case BTS_NODE:
- case TRX_NODE:
- case TS_NODE:
- case MGCP_NODE:
- case GBPROXY_NODE:
- case SGSN_NODE:
- case NS_NODE:
- case VTY_NODE:
- vty_config_unlock(vty);
- vty->node = ENABLE_NODE;
- vty->index = NULL;
- vty->index_sub = NULL;
- break;
- default:
- break;
- }
- return CMD_SUCCESS;
-}
-
DEFUN(enable_logging,
enable_logging_cmd,
"logging enable",
@@ -156,24 +77,6 @@ DEFUN(enable_logging,
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 telnet_connection *conn;
-
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- log_set_imsi_filter(conn->dbg, argv[0]);
- return CMD_SUCCESS;
-}
-
DEFUN(logging_fltr_all,
logging_fltr_all_cmd,
"logging filter all (0|1)",
@@ -429,11 +332,10 @@ gDEFUN(cfg_no_description, cfg_no_description_cmd,
return CMD_SUCCESS;
}
-void openbsc_vty_add_cmds()
+void logging_vty_add_cmds()
{
install_element_ve(&enable_logging_cmd);
install_element_ve(&disable_logging_cmd);
- install_element_ve(&logging_fltr_imsi_cmd);
install_element_ve(&logging_fltr_all_cmd);
install_element_ve(&logging_use_clr_cmd);
install_element_ve(&logging_prnt_timestamp_cmd);
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index 63955e7d5..99391223a 100644
--- a/openbsc/src/mgcp/mgcp_main.c
+++ b/openbsc/src/mgcp/mgcp_main.c
@@ -194,7 +194,7 @@ int main(int argc, char** argv)
return -1;
vty_init("OpenBSC MGCP", PACKAGE_VERSION, openbsc_copyright);
- openbsc_vty_add_cmds();
+ logging_vty_add_cmds();
mgcp_vty_init();
handle_options(argc, argv);