summaryrefslogtreecommitdiffstats
path: root/openbsc/src/libgb
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-06-16 16:54:06 +0800
committerHarald Welte <laforge@gnumonks.org>2012-06-16 16:59:50 +0800
commitfdd8b3b40dd4499a15558afc10f8d7cfd0041157 (patch)
tree1e5538ed8b9b35b590618f303dec41f79e48082a /openbsc/src/libgb
parenta6a20b4ff6e2f921b913295556a1cafed4ce71e8 (diff)
libgb: remove dependencies to openbsc/vty.h and openbsc/gsm_data.h
Rather than using openbsc internal data/functions, we now use only internal and libosmocore-provided ones.
Diffstat (limited to 'openbsc/src/libgb')
-rw-r--r--openbsc/src/libgb/Makefile.am4
-rw-r--r--openbsc/src/libgb/common_vty.c63
-rw-r--r--openbsc/src/libgb/common_vty.h5
-rw-r--r--openbsc/src/libgb/gprs_bssgp_vty.c15
-rw-r--r--openbsc/src/libgb/gprs_ns_vty.c38
5 files changed, 96 insertions, 29 deletions
diff --git a/openbsc/src/libgb/Makefile.am b/openbsc/src/libgb/Makefile.am
index fc1847f6f..eafbc3437 100644
--- a/openbsc/src/libgb/Makefile.am
+++ b/openbsc/src/libgb/Makefile.am
@@ -5,5 +5,5 @@ AM_CFLAGS=-Wall -fno-strict-aliasing $(LIBOSMOCORE_CFLAGS) \
noinst_LIBRARIES = libgb.a
libgb_a_SOURCES = gprs_ns.c gprs_ns_frgre.c gprs_ns_vty.c \
- gprs_bssgp.c gprs_bssgp_util.c gprs_bssgp_vty.c gprs_bssgp_bss.c
-#gprs_llc.c gprs_llc_vty.c crc24.c
+ gprs_bssgp.c gprs_bssgp_util.c gprs_bssgp_vty.c \
+ gprs_bssgp_bss.c common_vty.c
diff --git a/openbsc/src/libgb/common_vty.c b/openbsc/src/libgb/common_vty.c
new file mode 100644
index 000000000..269df8cd4
--- /dev/null
+++ b/openbsc/src/libgb/common_vty.c
@@ -0,0 +1,63 @@
+/* OpenBSC VTY common helpers */
+/* (C) 2009-2012 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 Affero General Public License as published by
+ * the Free Software Foundation; either version 3 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <osmocom/core/talloc.h>
+
+#include <osmocom/vty/telnet_interface.h>
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/buffer.h>
+#include <osmocom/vty/vty.h>
+
+/* Down vty node level. */
+gDEFUN(libgb_exit,
+ libgb_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
+{
+ switch (vty->node) {
+ case L_NS_NODE:
+ case L_BSSGP_NODE:
+ vty->node = CONFIG_NODE;
+ vty->index = NULL;
+ break;
+ default:
+ break;
+ }
+ return CMD_SUCCESS;
+}
+
+/* End of configuration. */
+gDEFUN(libgb_end,
+ libgb_end_cmd, "end", "End current mode and change to enable mode.")
+{
+ switch (vty->node) {
+ case L_NS_NODE:
+ case L_BSSGP_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/libgb/common_vty.h b/openbsc/src/libgb/common_vty.h
new file mode 100644
index 000000000..a2782663d
--- /dev/null
+++ b/openbsc/src/libgb/common_vty.h
@@ -0,0 +1,5 @@
+#include <osmocom/vty/command.h>
+
+extern struct cmd_element libgb_exit_cmd;
+extern struct cmd_element libgb_end_cmd;
+
diff --git a/openbsc/src/libgb/gprs_bssgp_vty.c b/openbsc/src/libgb/gprs_bssgp_vty.c
index 256e8af7f..37919e669 100644
--- a/openbsc/src/libgb/gprs_bssgp_vty.c
+++ b/openbsc/src/libgb/gprs_bssgp_vty.c
@@ -40,10 +40,9 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
-#include <openbsc/vty.h>
-#include <openbsc/gsm_data.h>
#include <openbsc/debug.h>
+#include "common_vty.h"
/* FIXME: this should go to some common file as it is copied
* in vty_interface.c of the BSC */
@@ -52,7 +51,7 @@ static const struct value_string gprs_bssgp_timer_strs[] = {
};
static struct cmd_node bssgp_node = {
- BSSGP_NODE,
+ L_BSSGP_NODE,
"%s(bssgp)#",
1,
};
@@ -68,7 +67,7 @@ DEFUN(cfg_bssgp, cfg_bssgp_cmd,
"bssgp",
"Configure the GPRS BSS Gateway Protocol")
{
- vty->node = BSSGP_NODE;
+ vty->node = L_BSSGP_NODE;
return CMD_SUCCESS;
}
@@ -169,10 +168,10 @@ int gprs_bssgp_vty_init(void)
install_element(CONFIG_NODE, &cfg_bssgp_cmd);
install_node(&bssgp_node, config_write_bssgp);
- install_default(BSSGP_NODE);
- install_element(BSSGP_NODE, &ournode_exit_cmd);
- install_element(BSSGP_NODE, &ournode_end_cmd);
- //install_element(BSSGP_NODE, &cfg_bssgp_timer_cmd);
+ install_default(L_BSSGP_NODE);
+ install_element(L_BSSGP_NODE, &libgb_exit_cmd);
+ install_element(L_BSSGP_NODE, &libgb_end_cmd);
+ //install_element(L_BSSGP_NODE, &cfg_bssgp_timer_cmd);
return 0;
}
diff --git a/openbsc/src/libgb/gprs_ns_vty.c b/openbsc/src/libgb/gprs_ns_vty.c
index a33e754b5..0ae314197 100644
--- a/openbsc/src/libgb/gprs_ns_vty.c
+++ b/openbsc/src/libgb/gprs_ns_vty.c
@@ -40,9 +40,9 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
-#include <openbsc/gsm_data.h>
#include <openbsc/debug.h>
-#include <openbsc/vty.h>
+
+#include "common_vty.h"
static struct gprs_ns_inst *vty_nsi = NULL;
@@ -60,7 +60,7 @@ static const struct value_string gprs_ns_timer_strs[] = {
};
static struct cmd_node ns_node = {
- NS_NODE,
+ L_NS_NODE,
"%s(ns)#",
1,
};
@@ -137,7 +137,7 @@ DEFUN(cfg_ns, cfg_ns_cmd,
"ns",
"Configure the GPRS Network Service")
{
- vty->node = NS_NODE;
+ vty->node = L_NS_NODE;
return CMD_SUCCESS;
}
@@ -549,21 +549,21 @@ int gprs_ns_vty_init(struct gprs_ns_inst *nsi)
install_element(CONFIG_NODE, &cfg_ns_cmd);
install_node(&ns_node, config_write_ns);
- install_default(NS_NODE);
- install_element(NS_NODE, &ournode_exit_cmd);
- install_element(NS_NODE, &ournode_end_cmd);
- install_element(NS_NODE, &cfg_nse_nsvci_cmd);
- install_element(NS_NODE, &cfg_nse_remoteip_cmd);
- install_element(NS_NODE, &cfg_nse_remoteport_cmd);
- install_element(NS_NODE, &cfg_nse_fr_dlci_cmd);
- install_element(NS_NODE, &cfg_nse_encaps_cmd);
- install_element(NS_NODE, &cfg_nse_remoterole_cmd);
- install_element(NS_NODE, &cfg_no_nse_cmd);
- install_element(NS_NODE, &cfg_ns_timer_cmd);
- install_element(NS_NODE, &cfg_nsip_local_ip_cmd);
- install_element(NS_NODE, &cfg_nsip_local_port_cmd);
- install_element(NS_NODE, &cfg_frgre_enable_cmd);
- install_element(NS_NODE, &cfg_frgre_local_ip_cmd);
+ install_default(L_NS_NODE);
+ install_element(L_NS_NODE, &libgb_exit_cmd);
+ install_element(L_NS_NODE, &libgb_end_cmd);
+ install_element(L_NS_NODE, &cfg_nse_nsvci_cmd);
+ install_element(L_NS_NODE, &cfg_nse_remoteip_cmd);
+ install_element(L_NS_NODE, &cfg_nse_remoteport_cmd);
+ install_element(L_NS_NODE, &cfg_nse_fr_dlci_cmd);
+ install_element(L_NS_NODE, &cfg_nse_encaps_cmd);
+ install_element(L_NS_NODE, &cfg_nse_remoterole_cmd);
+ install_element(L_NS_NODE, &cfg_no_nse_cmd);
+ install_element(L_NS_NODE, &cfg_ns_timer_cmd);
+ install_element(L_NS_NODE, &cfg_nsip_local_ip_cmd);
+ install_element(L_NS_NODE, &cfg_nsip_local_port_cmd);
+ install_element(L_NS_NODE, &cfg_frgre_enable_cmd);
+ install_element(L_NS_NODE, &cfg_frgre_local_ip_cmd);
install_element(ENABLE_NODE, &nsvc_nsei_cmd);