blob: 6037dda6f0c9ea98c859504c4c8938ea7ba1201a [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 Welte5bc61dc2010-05-16 22:02:16 +020045 case TS_NODE:
46 vty->node = TRX_NODE;
47 {
48 /* set vty->index correctly ! */
49 struct gsm_bts_trx_ts *ts = vty->index;
50 vty->index = ts->trx;
51 vty->index_sub = &ts->trx->description;
52 }
53 break;
Jacob Erlbeck190acf62013-09-02 13:17:15 +020054 case TRUNK_NODE:
55 vty->node = MGCP_NODE;
56 vty->index = NULL;
Holger Hans Peter Freyther6860c442011-05-02 19:16:13 +020057 break;
Harald Welte338e3b32012-11-20 22:22:04 +010058 case SMPP_ESME_NODE:
59 vty->node = SMPP_NODE;
60 vty->index = NULL;
61 break;
62 case SMPP_NODE:
Harald Welte5bc61dc2010-05-16 22:02:16 +020063 case MGCP_NODE:
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080064 case MSC_NODE:
Harald Welteab386e62011-09-01 18:18:43 +020065 case MNCC_INT_NODE:
Philipp Maierfbf66102017-04-09 12:32:51 +020066 vty->node = CONFIG_NODE;
Jacob Erlbeck190acf62013-09-02 13:17:15 +020067 vty->index = NULL;
Philipp Maierfbf66102017-04-09 12:32:51 +020068 break;
69 case SUBSCR_NODE:
70 vty->node = ENABLE_NODE;
71 vty->index = NULL;
72 break;
73 default:
74 osmo_ss7_vty_go_parent(vty);
Harald Welte5bc61dc2010-05-16 22:02:16 +020075 }
Jacob Erlbeck190acf62013-09-02 13:17:15 +020076
77 return vty->node;
78}
79
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080080int bsc_vty_is_config_node(struct vty *vty, int node)
81{
Philipp Maierfbf66102017-04-09 12:32:51 +020082 /* Check if libosmo-sccp declares the node in
83 * question as config node */
84 if (osmo_ss7_is_config_node(vty, node))
85 return 1;
86
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080087 switch (node) {
88 /* add items that are not config */
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080089 case SUBSCR_NODE:
Holger Hans Peter Freyther6ffca132010-09-04 11:15:27 +080090 case CONFIG_NODE:
Holger Hans Peter Freyther7a2c86b2010-08-26 15:38:42 +080091 return 0;
92
93 default:
94 return 1;
95 }
96}