aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/vty
diff options
context:
space:
mode:
authorHarald Welte <laforge@netfilter.org>2009-08-08 16:12:58 +0200
committerHarald Welte <laforge@netfilter.org>2009-08-08 16:12:58 +0200
commit42581829ec2a79ef82c813b8212da76f514aa4f4 (patch)
tree0fb73c2964b6a6a97e998cd361389fa8887c1eca /openbsc/src/vty
parent3c5cb256c2937d3671fda0daeb2c324105b0627c (diff)
the actual config file code (not just config files)
this was missing from commit a08a9acdb6bff0ee4fdf0f58b78b6525017a1f9f
Diffstat (limited to 'openbsc/src/vty')
-rw-r--r--openbsc/src/vty/command.c104
-rw-r--r--openbsc/src/vty/vty.c32
2 files changed, 47 insertions, 89 deletions
diff --git a/openbsc/src/vty/command.c b/openbsc/src/vty/command.c
index 16e0dfb36..f03dcbb4e 100644
--- a/openbsc/src/vty/command.c
+++ b/openbsc/src/vty/command.c
@@ -1909,27 +1909,49 @@ char **cmd_complete_command(vector vline, struct vty *vty, int *status)
/* return parent node */
/* MUST eventually converge on CONFIG_NODE */
-enum node_type node_parent(enum node_type node)
+enum node_type vty_go_parent(struct vty *vty)
{
- enum node_type ret;
+ assert(vty->node > CONFIG_NODE);
- assert(node > CONFIG_NODE);
-
- switch (node) {
- case BGP_VPNV4_NODE:
- case BGP_IPV4_NODE:
- case BGP_IPV4M_NODE:
- case BGP_IPV6_NODE:
- ret = BGP_NODE;
+ 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;
+ }
+ break;
+ case TRX_NODE:
+ vty->node = BTS_NODE;
+ {
+ /* set vty->index correctly ! */
+ struct gsm_bts_trx *trx = vty->index;
+ vty->index = trx->bts;
+ }
break;
- case KEYCHAIN_KEY_NODE:
- ret = KEYCHAIN_NODE;
+ case TS_NODE:
+ vty->node = TRX_NODE;
+ {
+ /* set vty->index correctly ! */
+ struct gsm_bts_trx_ts *ts = vty->index;
+ vty->index = ts->trx;
+ }
+ break;
+ case SUBSCR_NODE:
+ vty->node = VIEW_NODE;
+ subscr_put(vty->index);
+ vty->index = NULL;
break;
default:
- ret = CONFIG_NODE;
+ vty->node = CONFIG_NODE;
}
- return ret;
+ return vty->node;
}
/* Execute command by argument vline vector. */
@@ -2052,9 +2074,11 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd,
int vtysh)
{
int ret, saved_ret, tried = 0;
- enum node_type onode, try_node;
+ enum node_type onode;
+ void *oindex;
- onode = try_node = vty->node;
+ onode = vty->node;
+ oindex = vty->index;
if (cmd_try_do_shortcut(vty->node, vector_slot(vline, 0))) {
vector shifted_vline;
@@ -2085,8 +2109,7 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd,
/* This assumes all nodes above CONFIG_NODE are childs of CONFIG_NODE */
while (ret != CMD_SUCCESS && ret != CMD_WARNING
&& vty->node > CONFIG_NODE) {
- try_node = node_parent(try_node);
- vty->node = try_node;
+ vty_go_parent(vty);
ret = cmd_execute_command_real(vline, vty, cmd);
tried = 1;
if (ret == CMD_SUCCESS || ret == CMD_WARNING) {
@@ -2096,8 +2119,10 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd,
}
/* no command succeeded, reset the vty to the original node and
return the error for this node */
- if (tried)
+ if (tried) {
vty->node = onode;
+ vty->index = oindex;
+ }
return saved_ret;
}
@@ -2232,7 +2257,7 @@ int config_from_file(struct vty *vty, FILE * fp)
while (ret != CMD_SUCCESS && ret != CMD_WARNING
&& ret != CMD_ERR_NOTHING_TODO
&& vty->node != CONFIG_NODE) {
- vty->node = node_parent(vty->node);
+ vty_go_parent(vty);
ret = cmd_execute_command_strict(vline, vty, NULL);
}
@@ -2332,29 +2357,9 @@ DEFUN(config_exit,
vty->node = ENABLE_NODE;
vty_config_unlock(vty);
break;
- case INTERFACE_NODE:
- case ZEBRA_NODE:
- case BGP_NODE:
- case RIP_NODE:
- case RIPNG_NODE:
- case OSPF_NODE:
- case OSPF6_NODE:
- case ISIS_NODE:
- case KEYCHAIN_NODE:
- case MASC_NODE:
- case RMAP_NODE:
case VTY_NODE:
vty->node = CONFIG_NODE;
break;
- case BGP_VPNV4_NODE:
- case BGP_IPV4_NODE:
- case BGP_IPV4M_NODE:
- case BGP_IPV6_NODE:
- vty->node = BGP_NODE;
- break;
- case KEYCHAIN_KEY_NODE:
- vty->node = KEYCHAIN_NODE;
- break;
default:
break;
}
@@ -2375,22 +2380,6 @@ ALIAS(config_exit,
/* Nothing to do. */
break;
case CONFIG_NODE:
- case INTERFACE_NODE:
- case ZEBRA_NODE:
- case RIP_NODE:
- case RIPNG_NODE:
- case BGP_NODE:
- case BGP_VPNV4_NODE:
- case BGP_IPV4_NODE:
- case BGP_IPV4M_NODE:
- case BGP_IPV6_NODE:
- case RMAP_NODE:
- case OSPF_NODE:
- case OSPF6_NODE:
- case ISIS_NODE:
- case KEYCHAIN_NODE:
- case KEYCHAIN_KEY_NODE:
- case MASC_NODE:
case VTY_NODE:
vty_config_unlock(vty);
vty->node = ENABLE_NODE;
@@ -3350,8 +3339,7 @@ void cmd_init(int terminal)
/* Default host value settings. */
host.name = NULL;
- //host.password = NULL;
- host.password = "foo";
+ host.password = NULL;
host.enable = NULL;
host.logfile = NULL;
host.config = NULL;
diff --git a/openbsc/src/vty/vty.c b/openbsc/src/vty/vty.c
index 5472fa05a..b403a7b2c 100644
--- a/openbsc/src/vty/vty.c
+++ b/openbsc/src/vty/vty.c
@@ -743,22 +743,6 @@ static void vty_end_config(struct vty *vty)
/* Nothing to do. */
break;
case CONFIG_NODE:
- case INTERFACE_NODE:
- case ZEBRA_NODE:
- case RIP_NODE:
- case RIPNG_NODE:
- case BGP_NODE:
- case BGP_VPNV4_NODE:
- case BGP_IPV4_NODE:
- case BGP_IPV4M_NODE:
- case BGP_IPV6_NODE:
- case RMAP_NODE:
- case OSPF_NODE:
- case OSPF6_NODE:
- case ISIS_NODE:
- case KEYCHAIN_NODE:
- case KEYCHAIN_KEY_NODE:
- case MASC_NODE:
case VTY_NODE:
vty_config_unlock(vty);
vty->node = ENABLE_NODE;
@@ -1125,18 +1109,6 @@ static void vty_stop_input(struct vty *vty)
/* Nothing to do. */
break;
case CONFIG_NODE:
- case INTERFACE_NODE:
- case ZEBRA_NODE:
- case RIP_NODE:
- case RIPNG_NODE:
- case BGP_NODE:
- case RMAP_NODE:
- case OSPF_NODE:
- case OSPF6_NODE:
- case ISIS_NODE:
- case KEYCHAIN_NODE:
- case KEYCHAIN_KEY_NODE:
- case MASC_NODE:
case VTY_NODE:
vty_config_unlock(vty);
vty->node = ENABLE_NODE;
@@ -1393,7 +1365,7 @@ vty_read_file(FILE *confp)
fprintf(stderr, "Ambiguous command.\n");
break;
case CMD_ERR_NO_MATCH:
- fprintf(stderr, "Ther is no such command.\n");
+ fprintf(stderr, "There is no such command.\n");
break;
}
fprintf(stderr, "Error occurred during reading below "
@@ -1675,10 +1647,8 @@ void vty_init()
install_element(ENABLE_NODE, &show_history_cmd);
install_default(VTY_NODE);
-#if 0
install_element(VTY_NODE, &vty_login_cmd);
install_element(VTY_NODE, &no_vty_login_cmd);
-#endif
}
int vty_read_config_file(const char *file_name)