Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file gprs_ns_vty.c |
| 2 | * VTY interface for our GPRS Networks Service (NS) implementation. */ |
| 3 | /* |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 4 | * (C) 2009-2014 by Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2016-2017 by sysmocom - s.f.m.c. GmbH |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 6 | * |
| 7 | * All Rights Reserved |
| 8 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
| 10 | * |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 11 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 7fa89c2 | 2014-10-26 20:33:09 +0100 | [diff] [blame] | 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 7fa89c2 | 2014-10-26 20:33:09 +0100 | [diff] [blame] | 19 | * GNU General Public License for more details. |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 20 | * |
Harald Welte | 7fa89c2 | 2014-10-26 20:33:09 +0100 | [diff] [blame] | 21 | * You should have received a copy of the GNU General Public License |
Harald Welte | e4cbb3f | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <stdlib.h> |
| 27 | #include <unistd.h> |
| 28 | #include <errno.h> |
| 29 | #include <stdint.h> |
| 30 | |
| 31 | #include <arpa/inet.h> |
| 32 | |
Pablo Neira Ayuso | ff66323 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 33 | #include <osmocom/core/msgb.h> |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 34 | #include <osmocom/core/byteswap.h> |
Pablo Neira Ayuso | ff66323 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 35 | #include <osmocom/gsm/tlv.h> |
| 36 | #include <osmocom/core/talloc.h> |
| 37 | #include <osmocom/core/select.h> |
| 38 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 73952e3 | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 39 | #include <osmocom/gprs/gprs_ns.h> |
| 40 | #include <osmocom/gprs/gprs_bssgp.h> |
Max | 37f465e | 2017-10-24 16:04:55 +0200 | [diff] [blame] | 41 | #include <osmocom/core/socket.h> |
Harald Welte | ac1a715 | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 42 | #include <osmocom/vty/vty.h> |
| 43 | #include <osmocom/vty/command.h> |
| 44 | #include <osmocom/vty/logging.h> |
| 45 | #include <osmocom/vty/telnet_interface.h> |
Pablo Neira Ayuso | 167281e | 2011-03-28 19:35:00 +0200 | [diff] [blame] | 46 | #include <osmocom/vty/misc.h> |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 47 | |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 48 | #include "common_vty.h" |
Harald Welte | 047f387 | 2018-07-01 21:04:45 +0200 | [diff] [blame] | 49 | #include "gb_internal.h" |
Harald Welte | 73952e3 | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 50 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 51 | static struct gprs_ns_inst *vty_nsi = NULL; |
| 52 | |
| 53 | /* FIXME: this should go to some common file as it is copied |
| 54 | * in vty_interface.c of the BSC */ |
| 55 | static const struct value_string gprs_ns_timer_strs[] = { |
| 56 | { 0, "tns-block" }, |
| 57 | { 1, "tns-block-retries" }, |
| 58 | { 2, "tns-reset" }, |
| 59 | { 3, "tns-reset-retries" }, |
| 60 | { 4, "tns-test" }, |
| 61 | { 5, "tns-alive" }, |
| 62 | { 6, "tns-alive-retries" }, |
Harald Welte | 047f387 | 2018-07-01 21:04:45 +0200 | [diff] [blame] | 63 | { 7, "tsns-prov" }, |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 64 | { 0, NULL } |
| 65 | }; |
| 66 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 67 | static void log_set_nsvc_filter(struct log_target *target, |
| 68 | struct gprs_nsvc *nsvc) |
| 69 | { |
| 70 | if (nsvc) { |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 71 | target->filter_map |= (1 << LOG_FLT_GB_NSVC); |
| 72 | target->filter_data[LOG_FLT_GB_NSVC] = nsvc; |
| 73 | } else if (target->filter_data[LOG_FLT_GB_NSVC]) { |
| 74 | target->filter_map = ~(1 << LOG_FLT_GB_NSVC); |
| 75 | target->filter_data[LOG_FLT_GB_NSVC] = NULL; |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 79 | static struct cmd_node ns_node = { |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 80 | L_NS_NODE, |
Jacob Erlbeck | 35fe87c | 2013-10-24 01:33:20 +0200 | [diff] [blame] | 81 | "%s(config-ns)# ", |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 82 | 1, |
| 83 | }; |
| 84 | |
| 85 | static int config_write_ns(struct vty *vty) |
| 86 | { |
| 87 | struct gprs_nsvc *nsvc; |
| 88 | unsigned int i; |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 89 | struct in_addr ia; |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 90 | |
| 91 | vty_out(vty, "ns%s", VTY_NEWLINE); |
| 92 | |
Harald Welte | 057122e | 2020-06-06 22:04:20 +0200 | [diff] [blame] | 93 | /* global configuration must be written first, as some of it may be |
| 94 | * relevant when creating the NSE/NSVC later below */ |
| 95 | |
| 96 | if (vty_nsi->nsip.local_ip) { |
| 97 | ia.s_addr = osmo_htonl(vty_nsi->nsip.local_ip); |
| 98 | vty_out(vty, " encapsulation udp local-ip %s%s", |
| 99 | inet_ntoa(ia), VTY_NEWLINE); |
| 100 | } |
| 101 | if (vty_nsi->nsip.local_port) |
| 102 | vty_out(vty, " encapsulation udp local-port %u%s", |
| 103 | vty_nsi->nsip.local_port, VTY_NEWLINE); |
| 104 | if (vty_nsi->nsip.dscp) |
| 105 | vty_out(vty, " encapsulation udp dscp %d%s", |
| 106 | vty_nsi->nsip.dscp, VTY_NEWLINE); |
| 107 | |
| 108 | vty_out(vty, " encapsulation udp use-reset-block-unblock %s%s", |
| 109 | vty_nsi->nsip.use_reset_block_unblock ? "enabled" : "disabled", VTY_NEWLINE); |
| 110 | |
| 111 | vty_out(vty, " encapsulation framerelay-gre enabled %u%s", |
| 112 | vty_nsi->frgre.enabled ? 1 : 0, VTY_NEWLINE); |
| 113 | if (vty_nsi->frgre.local_ip) { |
| 114 | ia.s_addr = osmo_htonl(vty_nsi->frgre.local_ip); |
| 115 | vty_out(vty, " encapsulation framerelay-gre local-ip %s%s", |
| 116 | inet_ntoa(ia), VTY_NEWLINE); |
| 117 | } |
| 118 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 119 | llist_for_each_entry(nsvc, &vty_nsi->gprs_nsvcs, list) { |
| 120 | if (!nsvc->persistent) |
| 121 | continue; |
| 122 | vty_out(vty, " nse %u nsvci %u%s", |
| 123 | nsvc->nsei, nsvc->nsvci, VTY_NEWLINE); |
| 124 | vty_out(vty, " nse %u remote-role %s%s", |
| 125 | nsvc->nsei, nsvc->remote_end_is_sgsn ? "sgsn" : "bss", |
| 126 | VTY_NEWLINE); |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 127 | switch (nsvc->ll) { |
| 128 | case GPRS_NS_LL_UDP: |
| 129 | vty_out(vty, " nse %u encapsulation udp%s", nsvc->nsei, |
| 130 | VTY_NEWLINE); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 131 | vty_out(vty, " nse %u remote-ip %s%s", |
| 132 | nsvc->nsei, |
| 133 | inet_ntoa(nsvc->ip.bts_addr.sin_addr), |
| 134 | VTY_NEWLINE); |
| 135 | vty_out(vty, " nse %u remote-port %u%s", |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 136 | nsvc->nsei, osmo_ntohs(nsvc->ip.bts_addr.sin_port), |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 137 | VTY_NEWLINE); |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 138 | break; |
| 139 | case GPRS_NS_LL_FR_GRE: |
| 140 | vty_out(vty, " nse %u encapsulation framerelay-gre%s", |
| 141 | nsvc->nsei, VTY_NEWLINE); |
| 142 | vty_out(vty, " nse %u remote-ip %s%s", |
| 143 | nsvc->nsei, |
| 144 | inet_ntoa(nsvc->frgre.bts_addr.sin_addr), |
| 145 | VTY_NEWLINE); |
| 146 | vty_out(vty, " nse %u fr-dlci %u%s", |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 147 | nsvc->nsei, osmo_ntohs(nsvc->frgre.bts_addr.sin_port), |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 148 | VTY_NEWLINE); |
| 149 | default: |
| 150 | break; |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
| 154 | for (i = 0; i < ARRAY_SIZE(vty_nsi->timeout); i++) |
| 155 | vty_out(vty, " timer %s %u%s", |
| 156 | get_value_string(gprs_ns_timer_strs, i), |
| 157 | vty_nsi->timeout[i], VTY_NEWLINE); |
| 158 | |
| 159 | return CMD_SUCCESS; |
| 160 | } |
| 161 | |
| 162 | DEFUN(cfg_ns, cfg_ns_cmd, |
| 163 | "ns", |
| 164 | "Configure the GPRS Network Service") |
| 165 | { |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 166 | vty->node = L_NS_NODE; |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 167 | return CMD_SUCCESS; |
| 168 | } |
| 169 | |
Max | cbf5cdf | 2017-10-24 18:18:55 +0200 | [diff] [blame] | 170 | static void dump_nse(struct vty *vty, const struct gprs_nsvc *nsvc, bool stats, bool persistent_only) |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 171 | { |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 172 | if (persistent_only) |
| 173 | if (!nsvc->persistent) |
| 174 | return; |
| 175 | |
Max | 37f465e | 2017-10-24 16:04:55 +0200 | [diff] [blame] | 176 | vty_out(vty, "NSEI %5u, NS-VC %5u, %5s %9s, ", |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 177 | nsvc->nsei, nsvc->nsvci, |
Max | 4ce24c4 | 2017-10-23 15:09:23 +0200 | [diff] [blame] | 178 | NS_DESC_A(nsvc->state), |
Max | 37f465e | 2017-10-24 16:04:55 +0200 | [diff] [blame] | 179 | NS_DESC_B(nsvc->state)); |
| 180 | |
| 181 | if (nsvc->ll == GPRS_NS_LL_UDP) { |
| 182 | char local[INET6_ADDRSTRLEN + 1]; |
| 183 | int rc = osmo_sock_local_ip((char *)&local, inet_ntoa(nsvc->ip.bts_addr.sin_addr)); |
| 184 | vty_out(vty, "%s:%u ", (rc < 0) ? "unknown" : local, nsvc->nsi->nsip.local_port); |
| 185 | } |
| 186 | |
| 187 | vty_out(vty, "Remote: %-4s, %5s %9s, %s ", |
Max | 32f9971 | 2017-10-20 12:27:49 +0200 | [diff] [blame] | 188 | nsvc->remote_end_is_sgsn ? "SGSN" : "BSS", |
Max | 4ce24c4 | 2017-10-23 15:09:23 +0200 | [diff] [blame] | 189 | NS_DESC_A(nsvc->remote_state), |
Max | 37f465e | 2017-10-24 16:04:55 +0200 | [diff] [blame] | 190 | NS_DESC_B(nsvc->remote_state), gprs_ns_ll_str(nsvc)); |
Max | 9530859 | 2017-10-24 15:54:28 +0200 | [diff] [blame] | 191 | |
Max | 37f465e | 2017-10-24 16:04:55 +0200 | [diff] [blame] | 192 | vty_out(vty, "%s%s", nsvc->ll == GPRS_NS_LL_UDP ? "UDP" : "FR-GRE", VTY_NEWLINE); |
Max | 9530859 | 2017-10-24 15:54:28 +0200 | [diff] [blame] | 193 | |
Jacob Erlbeck | 0a1400f | 2015-10-06 15:23:25 +0200 | [diff] [blame] | 194 | if (stats) { |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 195 | vty_out_rate_ctr_group(vty, " ", nsvc->ctrg); |
Jacob Erlbeck | 0a1400f | 2015-10-06 15:23:25 +0200 | [diff] [blame] | 196 | vty_out_stat_item_group(vty, " ", nsvc->statg); |
| 197 | } |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 198 | } |
| 199 | |
Max | cbf5cdf | 2017-10-24 18:18:55 +0200 | [diff] [blame] | 200 | static void dump_ns(struct vty *vty, const struct gprs_ns_inst *nsi, bool stats, bool persistent_only) |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 201 | { |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 202 | struct gprs_nsvc *nsvc; |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 203 | struct in_addr ia; |
| 204 | |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 205 | ia.s_addr = osmo_htonl(vty_nsi->nsip.local_ip); |
Harald Welte | ce4ccbc | 2010-05-19 17:02:57 +0200 | [diff] [blame] | 206 | vty_out(vty, "Encapsulation NS-UDP-IP Local IP: %s, UDP Port: %u%s", |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 207 | inet_ntoa(ia), vty_nsi->nsip.local_port, VTY_NEWLINE); |
| 208 | |
Harald Welte | dc80281 | 2019-02-23 11:10:08 +0100 | [diff] [blame] | 209 | if (nsi->frgre.enabled) { |
| 210 | ia.s_addr = osmo_htonl(vty_nsi->frgre.local_ip); |
| 211 | vty_out(vty, "Encapsulation NS-FR-GRE-IP Local IP: %s%s", inet_ntoa(ia), VTY_NEWLINE); |
| 212 | } |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 213 | |
| 214 | llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) { |
Harald Welte | dd1c83c | 2010-05-13 13:58:08 +0200 | [diff] [blame] | 215 | if (nsvc == nsi->unknown_nsvc) |
| 216 | continue; |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 217 | dump_nse(vty, nsvc, stats, persistent_only); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 218 | } |
Harald Welte | 047f387 | 2018-07-01 21:04:45 +0200 | [diff] [blame] | 219 | |
| 220 | gprs_sns_dump_vty(vty, nsi, stats); |
Harald Welte | af1d4cb | 2010-05-13 12:32:30 +0200 | [diff] [blame] | 221 | } |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 222 | |
Harald Welte | af1d4cb | 2010-05-13 12:32:30 +0200 | [diff] [blame] | 223 | DEFUN(show_ns, show_ns_cmd, "show ns", |
| 224 | SHOW_STR "Display information about the NS protocol") |
| 225 | { |
| 226 | struct gprs_ns_inst *nsi = vty_nsi; |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 227 | dump_ns(vty, nsi, false, false); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 228 | return CMD_SUCCESS; |
| 229 | } |
| 230 | |
Harald Welte | af1d4cb | 2010-05-13 12:32:30 +0200 | [diff] [blame] | 231 | DEFUN(show_ns_stats, show_ns_stats_cmd, "show ns stats", |
| 232 | SHOW_STR |
| 233 | "Display information about the NS protocol\n" |
| 234 | "Include statistics\n") |
| 235 | { |
| 236 | struct gprs_ns_inst *nsi = vty_nsi; |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 237 | dump_ns(vty, nsi, true, false); |
| 238 | return CMD_SUCCESS; |
| 239 | } |
| 240 | |
| 241 | DEFUN(show_ns_pers, show_ns_pers_cmd, "show ns persistent", |
| 242 | SHOW_STR |
| 243 | "Display information about the NS protocol\n" |
| 244 | "Show only persistent NS\n") |
| 245 | { |
| 246 | struct gprs_ns_inst *nsi = vty_nsi; |
| 247 | dump_ns(vty, nsi, true, true); |
Harald Welte | af1d4cb | 2010-05-13 12:32:30 +0200 | [diff] [blame] | 248 | return CMD_SUCCESS; |
| 249 | } |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 250 | |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 251 | DEFUN(show_nse, show_nse_cmd, "show ns (nsei|nsvc) <0-65535> [stats]", |
| 252 | SHOW_STR "Display information about the NS protocol\n" |
| 253 | "Select one NSE by its NSE Identifier\n" |
| 254 | "Select one NSE by its NS-VC Identifier\n" |
| 255 | "The Identifier of selected type\n" |
| 256 | "Include Statistics\n") |
| 257 | { |
| 258 | struct gprs_ns_inst *nsi = vty_nsi; |
| 259 | struct gprs_nsvc *nsvc; |
| 260 | uint16_t id = atoi(argv[1]); |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 261 | bool show_stats = false; |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 262 | |
| 263 | if (!strcmp(argv[0], "nsei")) |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 264 | nsvc = gprs_nsvc_by_nsei(nsi, id); |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 265 | else |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 266 | nsvc = gprs_nsvc_by_nsvci(nsi, id); |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 267 | |
| 268 | if (!nsvc) { |
| 269 | vty_out(vty, "No such NS Entity%s", VTY_NEWLINE); |
| 270 | return CMD_WARNING; |
| 271 | } |
| 272 | |
| 273 | if (argc >= 3) |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 274 | show_stats = true; |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 275 | |
Max | 296511b | 2017-10-24 18:05:35 +0200 | [diff] [blame] | 276 | dump_nse(vty, nsvc, show_stats, false); |
Harald Welte | 9288334 | 2010-05-15 23:04:03 +0200 | [diff] [blame] | 277 | return CMD_SUCCESS; |
| 278 | } |
| 279 | |
Harald Welte | 24133c3 | 2010-05-15 23:06:26 +0200 | [diff] [blame] | 280 | #define NSE_CMD_STR "Persistent NS Entity\n" "NS Entity ID (NSEI)\n" |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 281 | |
| 282 | DEFUN(cfg_nse_nsvc, cfg_nse_nsvci_cmd, |
| 283 | "nse <0-65535> nsvci <0-65534>", |
| 284 | NSE_CMD_STR |
| 285 | "NS Virtual Connection\n" |
| 286 | "NS Virtual Connection ID (NSVCI)\n" |
| 287 | ) |
| 288 | { |
| 289 | uint16_t nsei = atoi(argv[0]); |
| 290 | uint16_t nsvci = atoi(argv[1]); |
| 291 | struct gprs_nsvc *nsvc; |
| 292 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 293 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 294 | if (!nsvc) { |
Harald Welte | 6894496 | 2020-06-07 10:31:48 +0200 | [diff] [blame] | 295 | nsvc = gprs_nsvc_create2(vty_nsi, nsvci, 1, 1); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 296 | nsvc->nsei = nsei; |
| 297 | } |
| 298 | nsvc->nsvci = nsvci; |
| 299 | /* All NSVCs that are explicitly configured by VTY are |
| 300 | * marked as persistent so we can write them to the config |
| 301 | * file at some later point */ |
| 302 | nsvc->persistent = 1; |
| 303 | |
| 304 | return CMD_SUCCESS; |
| 305 | } |
| 306 | |
| 307 | DEFUN(cfg_nse_remoteip, cfg_nse_remoteip_cmd, |
| 308 | "nse <0-65535> remote-ip A.B.C.D", |
| 309 | NSE_CMD_STR |
| 310 | "Remote IP Address\n" |
| 311 | "Remote IP Address\n") |
| 312 | { |
| 313 | uint16_t nsei = atoi(argv[0]); |
| 314 | struct gprs_nsvc *nsvc; |
| 315 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 316 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 317 | if (!nsvc) { |
| 318 | vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE); |
| 319 | return CMD_WARNING; |
| 320 | } |
Harald Welte | 78af6ba | 2020-06-26 16:17:56 +0200 | [diff] [blame] | 321 | nsvc->ip.bts_addr.sin_family = AF_INET; |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 322 | inet_aton(argv[1], &nsvc->ip.bts_addr.sin_addr); |
| 323 | |
| 324 | return CMD_SUCCESS; |
| 325 | |
| 326 | } |
| 327 | |
| 328 | DEFUN(cfg_nse_remoteport, cfg_nse_remoteport_cmd, |
| 329 | "nse <0-65535> remote-port <0-65535>", |
| 330 | NSE_CMD_STR |
| 331 | "Remote UDP Port\n" |
| 332 | "Remote UDP Port Number\n") |
| 333 | { |
| 334 | uint16_t nsei = atoi(argv[0]); |
| 335 | uint16_t port = atoi(argv[1]); |
| 336 | struct gprs_nsvc *nsvc; |
| 337 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 338 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 339 | if (!nsvc) { |
| 340 | vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE); |
| 341 | return CMD_WARNING; |
| 342 | } |
| 343 | |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 344 | if (nsvc->ll != GPRS_NS_LL_UDP) { |
| 345 | vty_out(vty, "Cannot set UDP Port on non-UDP NSE%s", |
| 346 | VTY_NEWLINE); |
| 347 | return CMD_WARNING; |
| 348 | } |
| 349 | |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 350 | nsvc->ip.bts_addr.sin_port = osmo_htons(port); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 351 | |
| 352 | return CMD_SUCCESS; |
| 353 | } |
| 354 | |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 355 | DEFUN(cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd, |
Harald Welte | 188bda6 | 2010-05-28 14:11:49 +0200 | [diff] [blame] | 356 | "nse <0-65535> fr-dlci <16-1007>", |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 357 | NSE_CMD_STR |
| 358 | "Frame Relay DLCI\n" |
| 359 | "Frame Relay DLCI Number\n") |
| 360 | { |
| 361 | uint16_t nsei = atoi(argv[0]); |
| 362 | uint16_t dlci = atoi(argv[1]); |
| 363 | struct gprs_nsvc *nsvc; |
| 364 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 365 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 366 | if (!nsvc) { |
| 367 | vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE); |
| 368 | return CMD_WARNING; |
| 369 | } |
| 370 | |
| 371 | if (nsvc->ll != GPRS_NS_LL_FR_GRE) { |
| 372 | vty_out(vty, "Cannot set FR DLCI on non-FR NSE%s", |
| 373 | VTY_NEWLINE); |
| 374 | return CMD_WARNING; |
| 375 | } |
| 376 | |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 377 | nsvc->frgre.bts_addr.sin_port = osmo_htons(dlci); |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 378 | |
| 379 | return CMD_SUCCESS; |
| 380 | } |
| 381 | |
| 382 | DEFUN(cfg_nse_encaps, cfg_nse_encaps_cmd, |
| 383 | "nse <0-65535> encapsulation (udp|framerelay-gre)", |
| 384 | NSE_CMD_STR |
| 385 | "Encapsulation for NS\n" |
| 386 | "UDP/IP Encapsulation\n" "Frame-Relay/GRE/IP Encapsulation\n") |
| 387 | { |
| 388 | uint16_t nsei = atoi(argv[0]); |
| 389 | struct gprs_nsvc *nsvc; |
| 390 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 391 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | b3ee265 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 392 | if (!nsvc) { |
| 393 | vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE); |
| 394 | return CMD_WARNING; |
| 395 | } |
| 396 | |
| 397 | if (!strcmp(argv[1], "udp")) |
| 398 | nsvc->ll = GPRS_NS_LL_UDP; |
| 399 | else |
| 400 | nsvc->ll = GPRS_NS_LL_FR_GRE; |
| 401 | |
| 402 | return CMD_SUCCESS; |
| 403 | } |
| 404 | |
| 405 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 406 | DEFUN(cfg_nse_remoterole, cfg_nse_remoterole_cmd, |
| 407 | "nse <0-65535> remote-role (sgsn|bss)", |
| 408 | NSE_CMD_STR |
| 409 | "Remote NSE Role\n" |
| 410 | "Remote Peer is SGSN\n" |
| 411 | "Remote Peer is BSS\n") |
| 412 | { |
| 413 | uint16_t nsei = atoi(argv[0]); |
| 414 | struct gprs_nsvc *nsvc; |
| 415 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 416 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 417 | if (!nsvc) { |
| 418 | vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE); |
| 419 | return CMD_WARNING; |
| 420 | } |
| 421 | |
| 422 | if (!strcmp(argv[1], "sgsn")) |
| 423 | nsvc->remote_end_is_sgsn = 1; |
| 424 | else |
| 425 | nsvc->remote_end_is_sgsn = 0; |
| 426 | |
| 427 | return CMD_SUCCESS; |
| 428 | } |
| 429 | |
| 430 | DEFUN(cfg_no_nse, cfg_no_nse_cmd, |
| 431 | "no nse <0-65535>", |
Harald Welte | 24133c3 | 2010-05-15 23:06:26 +0200 | [diff] [blame] | 432 | "Delete Persistent NS Entity\n" |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 433 | "Delete " NSE_CMD_STR) |
| 434 | { |
| 435 | uint16_t nsei = atoi(argv[0]); |
| 436 | struct gprs_nsvc *nsvc; |
| 437 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 438 | nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 439 | if (!nsvc) { |
| 440 | vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE); |
| 441 | return CMD_WARNING; |
| 442 | } |
| 443 | |
Harald Welte | 24133c3 | 2010-05-15 23:06:26 +0200 | [diff] [blame] | 444 | if (!nsvc->persistent) { |
| 445 | vty_out(vty, "NSEI %u is not a persistent NSE%s", |
| 446 | nsei, VTY_NEWLINE); |
| 447 | return CMD_WARNING; |
| 448 | } |
| 449 | |
| 450 | nsvc->persistent = 0; |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 451 | |
| 452 | return CMD_SUCCESS; |
| 453 | } |
| 454 | |
| 455 | DEFUN(cfg_ns_timer, cfg_ns_timer_cmd, |
| 456 | "timer " NS_TIMERS " <0-65535>", |
| 457 | "Network Service Timer\n" |
| 458 | NS_TIMERS_HELP "Timer Value\n") |
| 459 | { |
| 460 | int idx = get_string_value(gprs_ns_timer_strs, argv[0]); |
| 461 | int val = atoi(argv[1]); |
| 462 | |
| 463 | if (idx < 0 || idx >= ARRAY_SIZE(vty_nsi->timeout)) |
| 464 | return CMD_WARNING; |
| 465 | |
| 466 | vty_nsi->timeout[idx] = val; |
| 467 | |
| 468 | return CMD_SUCCESS; |
| 469 | } |
| 470 | |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 471 | #define ENCAPS_STR "NS encapsulation options\n" |
| 472 | |
| 473 | DEFUN(cfg_nsip_local_ip, cfg_nsip_local_ip_cmd, |
| 474 | "encapsulation udp local-ip A.B.C.D", |
| 475 | ENCAPS_STR "NS over UDP Encapsulation\n" |
| 476 | "Set the IP address on which we listen for NS/UDP\n" |
| 477 | "IP Address\n") |
| 478 | { |
| 479 | struct in_addr ia; |
| 480 | |
| 481 | inet_aton(argv[0], &ia); |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 482 | vty_nsi->nsip.local_ip = osmo_ntohl(ia.s_addr); |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 483 | |
| 484 | return CMD_SUCCESS; |
| 485 | } |
| 486 | |
| 487 | DEFUN(cfg_nsip_local_port, cfg_nsip_local_port_cmd, |
| 488 | "encapsulation udp local-port <0-65535>", |
| 489 | ENCAPS_STR "NS over UDP Encapsulation\n" |
| 490 | "Set the UDP port on which we listen for NS/UDP\n" |
| 491 | "UDP port number\n") |
| 492 | { |
| 493 | unsigned int port = atoi(argv[0]); |
| 494 | |
| 495 | vty_nsi->nsip.local_port = port; |
| 496 | |
| 497 | return CMD_SUCCESS; |
| 498 | } |
| 499 | |
Holger Hans Peter Freyther | 2c3393d | 2013-03-25 11:59:58 +0100 | [diff] [blame] | 500 | DEFUN(cfg_nsip_dscp, cfg_nsip_dscp_cmd, |
| 501 | "encapsulation udp dscp <0-255>", |
| 502 | ENCAPS_STR "NS over UDP Encapsulation\n" |
| 503 | "Set DSCP/TOS on the UDP socket\n" "DSCP Value\n") |
| 504 | { |
| 505 | int dscp = atoi(argv[0]); |
| 506 | vty_nsi->nsip.dscp = dscp; |
| 507 | return CMD_SUCCESS; |
| 508 | } |
| 509 | |
Harald Welte | 057122e | 2020-06-06 22:04:20 +0200 | [diff] [blame] | 510 | DEFUN(cfg_nsip_res_block_unblock, cfg_nsip_res_block_unblock_cmd, |
| 511 | "encapsulation udp use-reset-block-unblock (enabled|disabled)", |
| 512 | ENCAPS_STR "NS over UDP Encapsulation\n" |
| 513 | "Use NS-{RESET,BLOCK,UNBLOCK} procedures in violation of 3GPP TS 48.016\n" |
| 514 | "Enable NS-{RESET,BLOCK,UNBLOCK}\n" |
| 515 | "Disable NS-{RESET,BLOCK,UNBLOCK}\n") |
| 516 | { |
| 517 | if (!strcmp(argv[0], "enabled")) |
| 518 | vty_nsi->nsip.use_reset_block_unblock = true; |
| 519 | else |
| 520 | vty_nsi->nsip.use_reset_block_unblock = false; |
| 521 | |
| 522 | return CMD_SUCCESS; |
| 523 | } |
| 524 | |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 525 | DEFUN(cfg_frgre_local_ip, cfg_frgre_local_ip_cmd, |
| 526 | "encapsulation framerelay-gre local-ip A.B.C.D", |
| 527 | ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n" |
| 528 | "Set the IP address on which we listen for NS/FR/GRE\n" |
| 529 | "IP Address\n") |
| 530 | { |
| 531 | struct in_addr ia; |
| 532 | |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 533 | inet_aton(argv[0], &ia); |
Harald Welte | bfe62e5 | 2017-05-15 12:48:30 +0200 | [diff] [blame] | 534 | vty_nsi->frgre.local_ip = osmo_ntohl(ia.s_addr); |
Harald Welte | 7fb0523 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 535 | |
| 536 | return CMD_SUCCESS; |
| 537 | } |
| 538 | |
| 539 | DEFUN(cfg_frgre_enable, cfg_frgre_enable_cmd, |
| 540 | "encapsulation framerelay-gre enabled (1|0)", |
| 541 | ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n" |
| 542 | "Enable or disable Frame Relay over GRE\n" |
| 543 | "Enable\n" "Disable\n") |
| 544 | { |
| 545 | int enabled = atoi(argv[0]); |
| 546 | |
| 547 | vty_nsi->frgre.enabled = enabled; |
| 548 | |
| 549 | return CMD_SUCCESS; |
| 550 | } |
| 551 | |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 552 | DEFUN(nsvc_nsei, nsvc_nsei_cmd, |
Jacob Erlbeck | 687b690 | 2013-10-24 01:33:19 +0200 | [diff] [blame] | 553 | "nsvc (nsei|nsvci) <0-65535> (block|unblock|reset)", |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 554 | "Perform an operation on a NSVC\n" |
Holger Hans Peter Freyther | 887934e | 2011-11-05 15:14:59 +0100 | [diff] [blame] | 555 | "NSEI to identify NS-VC Identifier (NS-VCI)\n" |
Jacob Erlbeck | 687b690 | 2013-10-24 01:33:19 +0200 | [diff] [blame] | 556 | "NS-VC Identifier (NS-VCI)\n" |
Holger Hans Peter Freyther | 887934e | 2011-11-05 15:14:59 +0100 | [diff] [blame] | 557 | "The NSEI\n" |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 558 | "Initiate BLOCK procedure\n" |
| 559 | "Initiate UNBLOCK procedure\n" |
| 560 | "Initiate RESET procedure\n") |
| 561 | { |
Jacob Erlbeck | 687b690 | 2013-10-24 01:33:19 +0200 | [diff] [blame] | 562 | const char *id_type = argv[0]; |
| 563 | uint16_t id = atoi(argv[1]); |
| 564 | const char *operation = argv[2]; |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 565 | struct gprs_nsvc *nsvc; |
| 566 | |
Jacob Erlbeck | 687b690 | 2013-10-24 01:33:19 +0200 | [diff] [blame] | 567 | if (!strcmp(id_type, "nsei")) |
| 568 | nsvc = gprs_nsvc_by_nsei(vty_nsi, id); |
| 569 | else if (!strcmp(id_type, "nsvci")) |
| 570 | nsvc = gprs_nsvc_by_nsvci(vty_nsi, id); |
| 571 | else { |
| 572 | vty_out(vty, "%%No such id_type '%s'%s", id_type, VTY_NEWLINE); |
| 573 | return CMD_WARNING; |
| 574 | } |
| 575 | |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 576 | if (!nsvc) { |
Jacob Erlbeck | 687b690 | 2013-10-24 01:33:19 +0200 | [diff] [blame] | 577 | vty_out(vty, "No such %s (%u)%s", id_type, id, VTY_NEWLINE); |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 578 | return CMD_WARNING; |
| 579 | } |
| 580 | |
Harald Welte | 047f387 | 2018-07-01 21:04:45 +0200 | [diff] [blame] | 581 | if (nsvc->nsi->bss_sns_fi) { |
| 582 | vty_out(vty, "A NS Instance using the IP Sub-Network doesn't use BLOCK/UNBLOCK/RESET%s", |
| 583 | VTY_NEWLINE); |
| 584 | return CMD_WARNING; |
| 585 | } |
| 586 | |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 587 | if (!strcmp(operation, "block")) |
| 588 | gprs_ns_tx_block(nsvc, NS_CAUSE_OM_INTERVENTION); |
| 589 | else if (!strcmp(operation, "unblock")) |
| 590 | gprs_ns_tx_unblock(nsvc); |
| 591 | else if (!strcmp(operation, "reset")) |
| 592 | gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION); |
| 593 | else |
| 594 | return CMD_WARNING; |
| 595 | |
| 596 | return CMD_SUCCESS; |
| 597 | } |
| 598 | |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 599 | DEFUN(logging_fltr_nsvc, |
| 600 | logging_fltr_nsvc_cmd, |
| 601 | "logging filter nsvc (nsei|nsvci) <0-65535>", |
Harald Welte | 6703bf7 | 2010-05-16 00:00:04 +0200 | [diff] [blame] | 602 | LOGGING_STR FILTER_STR |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 603 | "Filter based on NS Virtual Connection\n" |
| 604 | "Identify NS-VC by NSEI\n" |
| 605 | "Identify NS-VC by NSVCI\n" |
| 606 | "Numeric identifier\n") |
| 607 | { |
Pau Espin Pedrol | d12f698 | 2019-09-17 18:38:58 +0200 | [diff] [blame] | 608 | struct log_target *tgt; |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 609 | struct gprs_nsvc *nsvc; |
| 610 | uint16_t id = atoi(argv[1]); |
| 611 | |
Pau Espin Pedrol | d12f698 | 2019-09-17 18:38:58 +0200 | [diff] [blame] | 612 | log_tgt_mutex_lock(); |
| 613 | tgt = osmo_log_vty2tgt(vty); |
| 614 | if (!tgt) { |
| 615 | log_tgt_mutex_unlock(); |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 616 | return CMD_WARNING; |
Pau Espin Pedrol | d12f698 | 2019-09-17 18:38:58 +0200 | [diff] [blame] | 617 | } |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 618 | |
| 619 | if (!strcmp(argv[0], "nsei")) |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 620 | nsvc = gprs_nsvc_by_nsei(vty_nsi, id); |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 621 | else |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 622 | nsvc = gprs_nsvc_by_nsvci(vty_nsi, id); |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 623 | |
| 624 | if (!nsvc) { |
| 625 | vty_out(vty, "No NS-VC by that identifier%s", VTY_NEWLINE); |
Pau Espin Pedrol | d12f698 | 2019-09-17 18:38:58 +0200 | [diff] [blame] | 626 | log_tgt_mutex_unlock(); |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 627 | return CMD_WARNING; |
| 628 | } |
| 629 | |
Harald Welte | 43ae94e | 2011-02-18 21:10:05 +0100 | [diff] [blame] | 630 | log_set_nsvc_filter(tgt, nsvc); |
Pau Espin Pedrol | d12f698 | 2019-09-17 18:38:58 +0200 | [diff] [blame] | 631 | log_tgt_mutex_unlock(); |
Harald Welte | 91f7f4b | 2010-05-15 23:52:02 +0200 | [diff] [blame] | 632 | return CMD_SUCCESS; |
| 633 | } |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 634 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 635 | int gprs_ns_vty_init(struct gprs_ns_inst *nsi) |
| 636 | { |
Neels Hofmeyr | c32bfd5 | 2017-01-12 22:32:19 +0100 | [diff] [blame] | 637 | static bool vty_elements_installed = false; |
| 638 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 639 | vty_nsi = nsi; |
| 640 | |
Neels Hofmeyr | c32bfd5 | 2017-01-12 22:32:19 +0100 | [diff] [blame] | 641 | /* Regression test code may call this function repeatedly, so make sure |
| 642 | * that VTY elements are not duplicated, which would assert. */ |
| 643 | if (vty_elements_installed) |
| 644 | return 0; |
| 645 | vty_elements_installed = true; |
| 646 | |
Vadim Yanitskiy | 8e7c496 | 2020-10-04 15:37:31 +0700 | [diff] [blame] | 647 | install_lib_element_ve(&show_ns_cmd); |
| 648 | install_lib_element_ve(&show_ns_stats_cmd); |
| 649 | install_lib_element_ve(&show_ns_pers_cmd); |
| 650 | install_lib_element_ve(&show_nse_cmd); |
| 651 | install_lib_element_ve(&logging_fltr_nsvc_cmd); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 652 | |
Vadim Yanitskiy | 8e7c496 | 2020-10-04 15:37:31 +0700 | [diff] [blame] | 653 | install_lib_element(CFG_LOG_NODE, &logging_fltr_nsvc_cmd); |
Harald Welte | 43ae94e | 2011-02-18 21:10:05 +0100 | [diff] [blame] | 654 | |
Vadim Yanitskiy | 8e7c496 | 2020-10-04 15:37:31 +0700 | [diff] [blame] | 655 | install_lib_element(CONFIG_NODE, &cfg_ns_cmd); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 656 | install_node(&ns_node, config_write_ns); |
Vadim Yanitskiy | 8e7c496 | 2020-10-04 15:37:31 +0700 | [diff] [blame] | 657 | install_lib_element(L_NS_NODE, &cfg_nse_nsvci_cmd); |
| 658 | install_lib_element(L_NS_NODE, &cfg_nse_remoteip_cmd); |
| 659 | install_lib_element(L_NS_NODE, &cfg_nse_remoteport_cmd); |
| 660 | install_lib_element(L_NS_NODE, &cfg_nse_fr_dlci_cmd); |
| 661 | install_lib_element(L_NS_NODE, &cfg_nse_encaps_cmd); |
| 662 | install_lib_element(L_NS_NODE, &cfg_nse_remoterole_cmd); |
| 663 | install_lib_element(L_NS_NODE, &cfg_no_nse_cmd); |
| 664 | install_lib_element(L_NS_NODE, &cfg_ns_timer_cmd); |
| 665 | install_lib_element(L_NS_NODE, &cfg_nsip_local_ip_cmd); |
| 666 | install_lib_element(L_NS_NODE, &cfg_nsip_local_port_cmd); |
| 667 | install_lib_element(L_NS_NODE, &cfg_nsip_dscp_cmd); |
| 668 | install_lib_element(L_NS_NODE, &cfg_nsip_res_block_unblock_cmd); |
| 669 | install_lib_element(L_NS_NODE, &cfg_frgre_enable_cmd); |
| 670 | install_lib_element(L_NS_NODE, &cfg_frgre_local_ip_cmd); |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 671 | |
Vadim Yanitskiy | 8e7c496 | 2020-10-04 15:37:31 +0700 | [diff] [blame] | 672 | install_lib_element(ENABLE_NODE, &nsvc_nsei_cmd); |
Harald Welte | 43f3b69 | 2010-05-14 19:36:59 +0200 | [diff] [blame] | 673 | |
Harald Welte | 144e029 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 674 | return 0; |
| 675 | } |