Harald Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 1 | /* 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 Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 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 |
Harald Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Harald Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 15 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 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/>. |
Harald Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <string.h> |
| 23 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 24 | #include <osmocom/core/talloc.h> |
Harald Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 25 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 26 | #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 Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 30 | |
Harald Welte | 4b037e4 | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 31 | #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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 35 | #include <osmocom/sigtran/osmo_ss7.h> |
Harald Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 36 | |
| 37 | |
Holger Hans Peter Freyther | 3e4e8cf | 2015-09-24 15:38:38 +0200 | [diff] [blame] | 38 | int bsc_vty_go_parent(struct vty *vty) |
Harald Welte | 4b037e4 | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 39 | { |
| 40 | switch (vty->node) { |
| 41 | case GSMNET_NODE: |
| 42 | vty->node = CONFIG_NODE; |
| 43 | vty->index = NULL; |
| 44 | break; |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame] | 45 | case SMPP_ESME_NODE: |
| 46 | vty->node = SMPP_NODE; |
| 47 | vty->index = NULL; |
| 48 | break; |
| 49 | case SMPP_NODE: |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 50 | case MSC_NODE: |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 51 | case MNCC_INT_NODE: |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 52 | vty->node = CONFIG_NODE; |
Jacob Erlbeck | 190acf6 | 2013-09-02 13:17:15 +0200 | [diff] [blame] | 53 | vty->index = NULL; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 54 | 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 Welte | 5bc61dc | 2010-05-16 22:02:16 +0200 | [diff] [blame] | 61 | } |
Jacob Erlbeck | 190acf6 | 2013-09-02 13:17:15 +0200 | [diff] [blame] | 62 | |
| 63 | return vty->node; |
| 64 | } |
| 65 | |
Holger Hans Peter Freyther | 7a2c86b | 2010-08-26 15:38:42 +0800 | [diff] [blame] | 66 | int bsc_vty_is_config_node(struct vty *vty, int node) |
| 67 | { |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 68 | /* 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 Freyther | 7a2c86b | 2010-08-26 15:38:42 +0800 | [diff] [blame] | 73 | switch (node) { |
| 74 | /* add items that are not config */ |
Holger Hans Peter Freyther | 7a2c86b | 2010-08-26 15:38:42 +0800 | [diff] [blame] | 75 | case SUBSCR_NODE: |
Holger Hans Peter Freyther | 6ffca13 | 2010-09-04 11:15:27 +0800 | [diff] [blame] | 76 | case CONFIG_NODE: |
Holger Hans Peter Freyther | 7a2c86b | 2010-08-26 15:38:42 +0800 | [diff] [blame] | 77 | return 0; |
| 78 | |
| 79 | default: |
| 80 | return 1; |
| 81 | } |
| 82 | } |