blob: 269df8cd443197ac3422f13cf0f99c47d4a315e9 [file] [log] [blame]
Harald Welte4f5883b2012-06-16 16:54:06 +08001/* OpenBSC VTY common helpers */
2/* (C) 2009-2012 by Harald Welte <laforge@gnumonks.org>
3 * (C) 2009-2010 by Holger Hans Peter Freyther
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <stdlib.h>
22#include <string.h>
23
24#include <osmocom/core/talloc.h>
25
26#include <osmocom/vty/telnet_interface.h>
27#include <osmocom/vty/command.h>
28#include <osmocom/vty/buffer.h>
29#include <osmocom/vty/vty.h>
30
31/* Down vty node level. */
32gDEFUN(libgb_exit,
33 libgb_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
34{
35 switch (vty->node) {
36 case L_NS_NODE:
37 case L_BSSGP_NODE:
38 vty->node = CONFIG_NODE;
39 vty->index = NULL;
40 break;
41 default:
42 break;
43 }
44 return CMD_SUCCESS;
45}
46
47/* End of configuration. */
48gDEFUN(libgb_end,
49 libgb_end_cmd, "end", "End current mode and change to enable mode.")
50{
51 switch (vty->node) {
52 case L_NS_NODE:
53 case L_BSSGP_NODE:
54 vty_config_unlock(vty);
55 vty->node = ENABLE_NODE;
56 vty->index = NULL;
57 vty->index_sub = NULL;
58 break;
59 default:
60 break;
61 }
62 return CMD_SUCCESS;
63}