summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/src/vty
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/libosmocore/src/vty')
-rw-r--r--src/shared/libosmocore/src/vty/Makefile.am1
-rw-r--r--src/shared/libosmocore/src/vty/command.c18
-rw-r--r--src/shared/libosmocore/src/vty/telnet_interface.c9
-rw-r--r--src/shared/libosmocore/src/vty/vty.c9
4 files changed, 31 insertions, 6 deletions
diff --git a/src/shared/libosmocore/src/vty/Makefile.am b/src/shared/libosmocore/src/vty/Makefile.am
index f2859cff..7353ab84 100644
--- a/src/shared/libosmocore/src/vty/Makefile.am
+++ b/src/shared/libosmocore/src/vty/Makefile.am
@@ -10,4 +10,5 @@ lib_LTLIBRARIES = libosmovty.la
libosmovty_la_SOURCES = buffer.c command.c vty.c vector.c utils.c \
telnet_interface.c logging_vty.c
+libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la
endif
diff --git a/src/shared/libosmocore/src/vty/command.c b/src/shared/libosmocore/src/vty/command.c
index 598e63cc..7525df65 100644
--- a/src/shared/libosmocore/src/vty/command.c
+++ b/src/shared/libosmocore/src/vty/command.c
@@ -139,6 +139,18 @@ static int cmp_desc(const void *p, const void *q)
return strcmp(a->cmd, b->cmd);
}
+static int is_config(struct vty *vty)
+{
+ if (vty->node <= CONFIG_NODE)
+ return 0;
+ else if (vty->node > CONFIG_NODE && vty->node < _LAST_OSMOVTY_NODE)
+ return 1;
+ else if (host.app_info->is_config_node)
+ return host.app_info->is_config_node(vty, vty->node);
+ else
+ return vty->node > CONFIG_NODE;
+}
+
/* Sort each node's command element according to command string. */
void sort_node()
{
@@ -1947,9 +1959,9 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd,
if (vtysh)
return saved_ret;
- /* This assumes all nodes above CONFIG_NODE are childs of CONFIG_NODE */
+ /* Go to parent for config nodes to attempt to find the right command */
while (ret != CMD_SUCCESS && ret != CMD_WARNING
- && vty->node > CONFIG_NODE) {
+ && is_config(vty)) {
vty_go_parent(vty);
ret = cmd_execute_command_real(vline, vty, cmd);
tried = 1;
@@ -2097,7 +2109,7 @@ int config_from_file(struct vty *vty, FILE * fp)
/* Try again with setting node to CONFIG_NODE */
while (ret != CMD_SUCCESS && ret != CMD_WARNING
&& ret != CMD_ERR_NOTHING_TODO
- && vty->node != CONFIG_NODE) {
+ && vty->node != CONFIG_NODE && is_config(vty)) {
vty_go_parent(vty);
ret = cmd_execute_command_strict(vline, vty, NULL);
}
diff --git a/src/shared/libosmocore/src/vty/telnet_interface.c b/src/shared/libosmocore/src/vty/telnet_interface.c
index 90690960..1523a899 100644
--- a/src/shared/libosmocore/src/vty/telnet_interface.c
+++ b/src/shared/libosmocore/src/vty/telnet_interface.c
@@ -31,6 +31,7 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/buffer.h>
+#include <osmocom/vty/command.h>
/* per connection data */
LLIST_HEAD(active_connections);
@@ -89,16 +90,18 @@ int telnet_init(void *tall_ctx, void *priv, int port)
return 0;
}
-extern const char *openbsc_copyright;
+extern struct host host;
static void print_welcome(int fd)
{
int ret;
static char *msg =
- "Welcome to the OpenBSC Control interface\n";
+ "Welcome to the OpenBSC Control interface\r\n";
ret = write(fd, msg, strlen(msg));
- ret = write(fd, openbsc_copyright, strlen(openbsc_copyright));
+
+ if (host.app_info->copyright)
+ ret = write(fd, host.app_info->copyright, strlen(host.app_info->copyright));
}
int telnet_close_client(struct bsc_fd *fd)
diff --git a/src/shared/libosmocore/src/vty/vty.c b/src/shared/libosmocore/src/vty/vty.c
index ff17abf6..5c5a908d 100644
--- a/src/shared/libosmocore/src/vty/vty.c
+++ b/src/shared/libosmocore/src/vty/vty.c
@@ -248,6 +248,15 @@ int vty_out_newline(struct vty *vty)
return 0;
}
+void *vty_current_index(struct vty *vty)
+{
+ return vty->index;
+}
+int vty_current_node(struct vty *vty)
+{
+ return vty->node;
+}
+
int vty_config_lock(struct vty *vty)
{
if (vty_config == 0) {