blob: 71c607ec2fb4afd893fd02ccb4ed70c17e1c21ea [file] [log] [blame]
Harald Welte5bc61dc2010-05-16 22:02:16 +02001/* OpenBSC VTY common helpers */
2/* (C) 2009-2010 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
Harald Welte9af6ddf2011-01-01 15:25:50 +01007 * 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
Harald Welte5bc61dc2010-05-16 22:02:16 +02009 * (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
Harald Welte9af6ddf2011-01-01 15:25:50 +010014 * GNU Affero General Public License for more details.
Harald Welte5bc61dc2010-05-16 22:02:16 +020015 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010016 * 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/>.
Harald Welte5bc61dc2010-05-16 22:02:16 +020018 *
19 */
20
21#include <stdlib.h>
22#include <string.h>
23
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010024#include <osmocom/core/talloc.h>
Harald Welte5bc61dc2010-05-16 22:02:16 +020025
Neels Hofmeyr90843962017-09-04 15:04:35 +020026#include <osmocom/msc/vty.h>
27#include <osmocom/msc/gsm_data.h>
28#include <osmocom/msc/debug.h>
29#include <osmocom/msc/gsm_subscriber.h>
Harald Welte5bc61dc2010-05-16 22:02:16 +020030
Harald Welte4b037e42010-05-19 19:45:32 +020031#include <osmocom/vty/telnet_interface.h>
32#include <osmocom/vty/command.h>
33#include <osmocom/vty/buffer.h>
34#include <osmocom/vty/vty.h>
Philipp Maierfbf66102017-04-09 12:32:51 +020035#include <osmocom/sigtran/osmo_ss7.h>
Harald Welte5bc61dc2010-05-16 22:02:16 +020036
37
Holger Hans Peter Freyther3e4e8cf2015-09-24 15:38:38 +020038int bsc_vty_go_parent(struct vty *vty)
Harald Welte4b037e42010-05-19 19:45:32 +020039{
40 switch (vty->node) {
41 case GSMNET_NODE:
42 vty->node = CONFIG_NODE;
43 vty->index = NULL;
44 break;
Harald Welte338e3b32012-11-20 22:22:04 +010045 case SMPP_ESME_NODE:
46 vty->node = SMPP_NODE;
47 vty->index = NULL;
48 break;
49 case SMPP_NODE:
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080050 case MSC_NODE:
Harald Welteab386e62011-09-01 18:18:43 +020051 case MNCC_INT_NODE:
Philipp Maierfbf66102017-04-09 12:32:51 +020052 vty->node = CONFIG_NODE;
Jacob Erlbeck190acf62013-09-02 13:17:15 +020053 vty->index = NULL;
Philipp Maierfbf66102017-04-09 12:32:51 +020054 break;
55 case SUBSCR_NODE:
56 vty->node = ENABLE_NODE;
57 vty->index = NULL;
58 break;
59 default:
60 osmo_ss7_vty_go_parent(vty);
Harald Welte5bc61dc2010-05-16 22:02:16 +020061 }
Jacob Erlbeck190acf62013-09-02 13:17:15 +020062
63 return vty->node;
64}
65
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080066int bsc_vty_is_config_node(struct vty *vty, int node)
67{
Philipp Maierfbf66102017-04-09 12:32:51 +020068 /* Check if libosmo-sccp declares the node in
69 * question as config node */
70 if (osmo_ss7_is_config_node(vty, node))
71 return 1;
72
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080073 switch (node) {
74 /* add items that are not config */
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080075 case SUBSCR_NODE:
Holger Hans Peter Freyther6ffca132010-09-04 11:15:27 +080076 case CONFIG_NODE:
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080077 return 0;
78
79 default:
80 return 1;
81 }
82}