Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2010 by Harald Welte <laforge@gnumonks.org> |
| 3 | * (C) 2010 by On-Waves |
| 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 <sys/socket.h> |
| 22 | #include <netinet/in.h> |
| 23 | #include <arpa/inet.h> |
| 24 | #include <string.h> |
| 25 | #include <time.h> |
| 26 | #include <inttypes.h> |
| 27 | |
| 28 | #include <osmocom/core/talloc.h> |
Alexander Couzens | 951e133 | 2020-09-22 13:21:46 +0200 | [diff] [blame] | 29 | #include <osmocom/core/timer.h> |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 30 | #include <osmocom/core/rate_ctr.h> |
| 31 | #include <osmocom/gsm/gsm48.h> |
| 32 | |
Alexander Couzens | 951e133 | 2020-09-22 13:21:46 +0200 | [diff] [blame] | 33 | #include <osmocom/gprs/gprs_ns2.h> |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 34 | #include <osmocom/gprs/bssgp_bvc_fsm.h> |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 35 | #include <osmocom/gsm/apn.h> |
| 36 | |
| 37 | #include <osmocom/sgsn/debug.h> |
| 38 | #include <osmocom/sgsn/gb_proxy.h> |
| 39 | #include <osmocom/sgsn/gprs_utils.h> |
| 40 | #include <osmocom/sgsn/vty.h> |
| 41 | |
| 42 | #include <osmocom/vty/command.h> |
Daniel Willmann | 8f407b1 | 2020-12-02 19:33:50 +0100 | [diff] [blame] | 43 | #include <osmocom/vty/logging.h> |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 44 | #include <osmocom/vty/vty.h> |
| 45 | #include <osmocom/vty/misc.h> |
| 46 | |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 47 | |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 48 | static struct gbproxy_config *g_cfg = NULL; |
| 49 | |
| 50 | /* |
| 51 | * vty code for gbproxy below |
| 52 | */ |
| 53 | static struct cmd_node gbproxy_node = { |
| 54 | GBPROXY_NODE, |
| 55 | "%s(config-gbproxy)# ", |
| 56 | 1, |
| 57 | }; |
| 58 | |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 59 | static void gbprox_vty_print_bvc(struct vty *vty, struct gbproxy_bvc *bvc) |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 60 | { |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 61 | |
Harald Welte | c6ecfad | 2020-12-12 14:17:51 +0100 | [diff] [blame] | 62 | if (bvc->bvci == 0) { |
| 63 | vty_out(vty, "NSEI %5u, SIG-BVCI %5u [%s]%s", bvc->nse->nsei, bvc->bvci, |
| 64 | osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE); |
| 65 | } else { |
| 66 | struct gprs_ra_id raid; |
| 67 | gsm48_parse_ra(&raid, bvc->ra); |
| 68 | vty_out(vty, "NSEI %5u, PTP-BVCI %5u, RAI %s [%s]%s", bvc->nse->nsei, bvc->bvci, |
| 69 | osmo_rai_name(&raid), osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE); |
| 70 | } |
| 71 | } |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 72 | |
Harald Welte | c6ecfad | 2020-12-12 14:17:51 +0100 | [diff] [blame] | 73 | static void gbproxy_vty_print_nse(struct vty *vty, struct gbproxy_nse *nse, bool show_stats) |
| 74 | { |
| 75 | struct gbproxy_bvc *bvc; |
| 76 | int j; |
| 77 | |
| 78 | hash_for_each(nse->bvcs, j, bvc, list) { |
| 79 | gbprox_vty_print_bvc(vty, bvc); |
| 80 | |
| 81 | if (show_stats) |
| 82 | vty_out_rate_ctr_group(vty, " ", bvc->ctrg); |
| 83 | } |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | static int config_write_gbproxy(struct vty *vty) |
| 87 | { |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 88 | struct gbproxy_nse *nse; |
| 89 | int i; |
| 90 | |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 91 | vty_out(vty, "gbproxy%s", VTY_NEWLINE); |
| 92 | |
Harald Welte | 209dc9f | 2020-12-12 19:02:16 +0100 | [diff] [blame] | 93 | if (g_cfg->pool.bvc_fc_ratio != 100) |
| 94 | vty_out(vty, " pool bvc-flow-control-ratio %u%s", g_cfg->pool.bvc_fc_ratio, VTY_NEWLINE); |
| 95 | |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 96 | hash_for_each(g_cfg->sgsn_nses, i, nse, list) { |
| 97 | vty_out(vty, " sgsn nsei %u%s", nse->nsei, VTY_NEWLINE); |
| 98 | } |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 99 | |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 100 | return CMD_SUCCESS; |
| 101 | } |
| 102 | |
| 103 | DEFUN(cfg_gbproxy, |
| 104 | cfg_gbproxy_cmd, |
| 105 | "gbproxy", |
| 106 | "Configure the Gb proxy") |
| 107 | { |
| 108 | vty->node = GBPROXY_NODE; |
| 109 | return CMD_SUCCESS; |
| 110 | } |
| 111 | |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 112 | extern const struct bssgp_bvc_fsm_ops sgsn_sig_bvc_fsm_ops; |
| 113 | #include <osmocom/gprs/protocol/gsm_08_18.h> |
| 114 | |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 115 | DEFUN(cfg_nsip_sgsn_nsei, |
| 116 | cfg_nsip_sgsn_nsei_cmd, |
| 117 | "sgsn nsei <0-65534>", |
| 118 | "SGSN information\n" |
| 119 | "NSEI to be used in the connection with the SGSN\n" |
| 120 | "The NSEI\n") |
| 121 | { |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 122 | uint32_t features = 0; // FIXME: make configurable |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 123 | unsigned int nsei = atoi(argv[0]); |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 124 | struct gbproxy_nse *nse; |
| 125 | struct gbproxy_bvc *bvc; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 126 | |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 127 | nse = gbproxy_nse_by_nsei_or_new(g_cfg, nsei, true); |
| 128 | if (!nse) |
| 129 | goto free_nothing; |
| 130 | |
| 131 | if (!gbproxy_bvc_by_bvci(nse, 0)) { |
| 132 | uint8_t cause = BSSGP_CAUSE_OML_INTERV; |
| 133 | bvc = gbproxy_bvc_alloc(nse, 0); |
| 134 | if (!bvc) |
| 135 | goto free_nse; |
| 136 | bvc->fi = bssgp_bvc_fsm_alloc_sig_bss(bvc, nse->cfg->nsi, nsei, features); |
| 137 | if (!bvc->fi) |
| 138 | goto free_bvc; |
| 139 | bssgp_bvc_fsm_set_ops(bvc->fi, &sgsn_sig_bvc_fsm_ops, bvc); |
| 140 | osmo_fsm_inst_dispatch(bvc->fi, BSSGP_BVCFSM_E_REQ_RESET, &cause); |
| 141 | } |
| 142 | |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 143 | return CMD_SUCCESS; |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 144 | |
| 145 | free_bvc: |
| 146 | gbproxy_bvc_free(bvc); |
| 147 | free_nse: |
| 148 | gbproxy_nse_free(nse); |
| 149 | free_nothing: |
| 150 | vty_out(vty, "%% Unable to create NSE for NSEI=%05u%s", nsei, VTY_NEWLINE); |
| 151 | return CMD_WARNING; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 152 | } |
| 153 | |
Harald Welte | 209dc9f | 2020-12-12 19:02:16 +0100 | [diff] [blame] | 154 | DEFUN(cfg_pool_bvc_fc_ratio, |
| 155 | cfg_pool_bvc_fc_ratio_cmd, |
| 156 | "pool bvc-flow-control-ratio <1-100>", |
| 157 | "SGSN Pool related configuration\n" |
| 158 | "Ratio of BSS-advertised bucket size + leak rate advertised to each SGSN\n" |
| 159 | "Ratio of BSS-advertised bucket size + leak rate advertised to each SGSN (Percent)\n") |
| 160 | { |
| 161 | g_cfg->pool.bvc_fc_ratio = atoi(argv[0]); |
| 162 | return CMD_SUCCESS; |
| 163 | } |
| 164 | |
Daniel Willmann | 8f407b1 | 2020-12-02 19:33:50 +0100 | [diff] [blame] | 165 | static void log_set_bvc_filter(struct log_target *target, |
| 166 | const uint16_t *bvci) |
| 167 | { |
| 168 | if (bvci) { |
| 169 | uintptr_t bvci_filter = *bvci | BVC_LOG_CTX_FLAG; |
| 170 | target->filter_map |= (1 << LOG_FLT_GB_BVC); |
| 171 | target->filter_data[LOG_FLT_GB_BVC] = (void *)bvci_filter; |
| 172 | } else if (target->filter_data[LOG_FLT_GB_BVC]) { |
| 173 | target->filter_map = ~(1 << LOG_FLT_GB_BVC); |
| 174 | target->filter_data[LOG_FLT_GB_BVC] = NULL; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | DEFUN(logging_fltr_bvc, |
| 179 | logging_fltr_bvc_cmd, |
| 180 | "logging filter bvc bvci <0-65535>", |
| 181 | LOGGING_STR FILTER_STR |
| 182 | "Filter based on BSSGP VC\n" |
| 183 | "Identify BVC by BVCI\n" |
| 184 | "Numeric identifier\n") |
| 185 | { |
| 186 | struct log_target *tgt; |
| 187 | uint16_t id = atoi(argv[0]); |
| 188 | |
| 189 | log_tgt_mutex_lock(); |
| 190 | tgt = osmo_log_vty2tgt(vty); |
| 191 | if (!tgt) { |
| 192 | log_tgt_mutex_unlock(); |
| 193 | return CMD_WARNING; |
| 194 | } |
| 195 | |
| 196 | log_set_bvc_filter(tgt, &id); |
| 197 | log_tgt_mutex_unlock(); |
| 198 | return CMD_SUCCESS; |
| 199 | } |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 200 | |
Harald Welte | befe1c3 | 2020-12-12 15:15:34 +0100 | [diff] [blame^] | 201 | DEFUN(show_gbproxy_bvc, show_gbproxy_bvc_cmd, "show gbproxy bvc (bss|sgsn) [stats]", |
Harald Welte | c6ecfad | 2020-12-12 14:17:51 +0100 | [diff] [blame] | 202 | SHOW_STR "Display information about the Gb proxy\n" |
Harald Welte | befe1c3 | 2020-12-12 15:15:34 +0100 | [diff] [blame^] | 203 | "Show BSSGP Virtual Connections\n" |
Harald Welte | c6ecfad | 2020-12-12 14:17:51 +0100 | [diff] [blame] | 204 | "Display BSS-side BVCs\n" |
| 205 | "Display SGSN-side BVCs\n" |
| 206 | "Show statistics\n") |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 207 | { |
Daniel Willmann | e50550e | 2020-11-26 18:19:21 +0100 | [diff] [blame] | 208 | struct gbproxy_nse *nse; |
Harald Welte | c6ecfad | 2020-12-12 14:17:51 +0100 | [diff] [blame] | 209 | bool show_stats = argc >= 2; |
| 210 | int i; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 211 | |
| 212 | if (show_stats) |
| 213 | vty_out_rate_ctr_group(vty, "", g_cfg->ctrg); |
| 214 | |
Harald Welte | c6ecfad | 2020-12-12 14:17:51 +0100 | [diff] [blame] | 215 | if (!strcmp(argv[0], "bss")) { |
| 216 | hash_for_each(g_cfg->bss_nses, i, nse, list) |
| 217 | gbproxy_vty_print_nse(vty, nse, show_stats); |
| 218 | } else { |
| 219 | hash_for_each(g_cfg->sgsn_nses, i, nse, list) |
| 220 | gbproxy_vty_print_nse(vty, nse, show_stats); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 221 | } |
| 222 | return CMD_SUCCESS; |
| 223 | } |
| 224 | |
| 225 | DEFUN(show_gbproxy_links, show_gbproxy_links_cmd, "show gbproxy links", |
| 226 | SHOW_STR "Display information about the Gb proxy\n" "Show logical links\n") |
| 227 | { |
Daniel Willmann | e50550e | 2020-11-26 18:19:21 +0100 | [diff] [blame] | 228 | struct gbproxy_nse *nse; |
Harald Welte | 8b4c794 | 2020-12-05 10:14:49 +0100 | [diff] [blame] | 229 | int i, j; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 230 | |
Harald Welte | d2fef95 | 2020-12-05 00:31:07 +0100 | [diff] [blame] | 231 | hash_for_each(g_cfg->bss_nses, i, nse, list) { |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 232 | struct gbproxy_bvc *bvc; |
Harald Welte | 8b4c794 | 2020-12-05 10:14:49 +0100 | [diff] [blame] | 233 | hash_for_each(nse->bvcs, j, bvc, list) { |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 234 | gbprox_vty_print_bvc(vty, bvc); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | return CMD_SUCCESS; |
| 238 | } |
| 239 | |
| 240 | DEFUN(delete_gb_bvci, delete_gb_bvci_cmd, |
| 241 | "delete-gbproxy-peer <0-65534> bvci <2-65534>", |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 242 | "Delete a GBProxy bvc by NSEI and optionally BVCI\n" |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 243 | "NSEI number\n" |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 244 | "Only delete bvc with a matching BVCI\n" |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 245 | "BVCI number\n") |
| 246 | { |
| 247 | const uint16_t nsei = atoi(argv[0]); |
| 248 | const uint16_t bvci = atoi(argv[1]); |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 249 | struct gbproxy_nse *nse = gbproxy_nse_by_nsei(g_cfg, nsei, NSE_F_BSS); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 250 | int counter; |
| 251 | |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 252 | if (!nse) { |
| 253 | vty_out(vty, "NSE not found%s", VTY_NEWLINE); |
| 254 | return CMD_WARNING; |
| 255 | } |
| 256 | |
| 257 | counter = gbproxy_cleanup_bvcs(nse, bvci); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 258 | |
| 259 | if (counter == 0) { |
| 260 | vty_out(vty, "BVC not found%s", VTY_NEWLINE); |
| 261 | return CMD_WARNING; |
| 262 | } |
| 263 | |
| 264 | return CMD_SUCCESS; |
| 265 | } |
| 266 | |
| 267 | DEFUN(delete_gb_nsei, delete_gb_nsei_cmd, |
| 268 | "delete-gbproxy-peer <0-65534> (only-bvc|only-nsvc|all) [dry-run]", |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 269 | "Delete a GBProxy bvc by NSEI and optionally BVCI\n" |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 270 | "NSEI number\n" |
| 271 | "Only delete BSSGP connections (BVC)\n" |
| 272 | "Only delete dynamic NS connections (NS-VC)\n" |
| 273 | "Delete BVC and dynamic NS connections\n" |
| 274 | "Show what would be deleted instead of actually deleting\n" |
| 275 | ) |
| 276 | { |
| 277 | const uint16_t nsei = atoi(argv[0]); |
| 278 | const char *mode = argv[1]; |
| 279 | int dry_run = argc > 2; |
| 280 | int delete_bvc = 0; |
| 281 | int delete_nsvc = 0; |
| 282 | int counter; |
| 283 | |
| 284 | if (strcmp(mode, "only-bvc") == 0) |
| 285 | delete_bvc = 1; |
| 286 | else if (strcmp(mode, "only-nsvc") == 0) |
| 287 | delete_nsvc = 1; |
| 288 | else |
| 289 | delete_bvc = delete_nsvc = 1; |
| 290 | |
| 291 | if (delete_bvc) { |
Daniel Willmann | 5b89771 | 2020-12-04 17:43:27 +0100 | [diff] [blame] | 292 | if (!dry_run) { |
Harald Welte | e520964 | 2020-12-05 19:59:45 +0100 | [diff] [blame] | 293 | struct gbproxy_nse *nse = gbproxy_nse_by_nsei(g_cfg, nsei, NSE_F_BSS); |
| 294 | counter = gbproxy_cleanup_bvcs(nse, 0); |
Daniel Willmann | 5b89771 | 2020-12-04 17:43:27 +0100 | [diff] [blame] | 295 | gbproxy_nse_free(nse); |
| 296 | } else { |
Daniel Willmann | e50550e | 2020-11-26 18:19:21 +0100 | [diff] [blame] | 297 | struct gbproxy_nse *nse; |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 298 | struct gbproxy_bvc *bvc; |
Harald Welte | 8b4c794 | 2020-12-05 10:14:49 +0100 | [diff] [blame] | 299 | int i, j; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 300 | counter = 0; |
Harald Welte | d2fef95 | 2020-12-05 00:31:07 +0100 | [diff] [blame] | 301 | hash_for_each(g_cfg->bss_nses, i, nse, list) { |
Daniel Willmann | e50550e | 2020-11-26 18:19:21 +0100 | [diff] [blame] | 302 | if (nse->nsei != nsei) |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 303 | continue; |
Harald Welte | 8b4c794 | 2020-12-05 10:14:49 +0100 | [diff] [blame] | 304 | hash_for_each(nse->bvcs, j, bvc, list) { |
Daniel Willmann | e50550e | 2020-11-26 18:19:21 +0100 | [diff] [blame] | 305 | vty_out(vty, "BVC: "); |
Harald Welte | 560bdb3 | 2020-12-04 22:24:47 +0100 | [diff] [blame] | 306 | gbprox_vty_print_bvc(vty, bvc); |
Daniel Willmann | e50550e | 2020-11-26 18:19:21 +0100 | [diff] [blame] | 307 | counter += 1; |
| 308 | } |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | vty_out(vty, "%sDeleted %d BVC%s", |
| 312 | dry_run ? "Not " : "", counter, VTY_NEWLINE); |
| 313 | } |
| 314 | |
| 315 | if (delete_nsvc) { |
Alexander Couzens | 951e133 | 2020-09-22 13:21:46 +0200 | [diff] [blame] | 316 | struct gprs_ns2_inst *nsi = g_cfg->nsi; |
| 317 | struct gprs_ns2_nse *nse; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 318 | |
Alexander Couzens | 951e133 | 2020-09-22 13:21:46 +0200 | [diff] [blame] | 319 | nse = gprs_ns2_nse_by_nsei(nsi, nsei); |
| 320 | if (!nse) { |
| 321 | vty_out(vty, "NSEI not found%s", VTY_NEWLINE); |
| 322 | return CMD_WARNING; |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 323 | } |
Alexander Couzens | 951e133 | 2020-09-22 13:21:46 +0200 | [diff] [blame] | 324 | |
| 325 | /* TODO: We should NOT delete a persistent NSEI/NSVC as soon as we can check for these */ |
| 326 | if (!dry_run) |
| 327 | gprs_ns2_free_nse(nse); |
| 328 | |
| 329 | vty_out(vty, "%sDeleted NS-VCs for NSEI %d%s", |
| 330 | dry_run ? "Not " : "", nsei, VTY_NEWLINE); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | return CMD_SUCCESS; |
| 334 | } |
| 335 | |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 336 | int gbproxy_vty_init(void) |
| 337 | { |
Harald Welte | befe1c3 | 2020-12-12 15:15:34 +0100 | [diff] [blame^] | 338 | install_element_ve(&show_gbproxy_bvc_cmd); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 339 | install_element_ve(&show_gbproxy_links_cmd); |
Daniel Willmann | 8f407b1 | 2020-12-02 19:33:50 +0100 | [diff] [blame] | 340 | install_element_ve(&logging_fltr_bvc_cmd); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 341 | |
| 342 | install_element(ENABLE_NODE, &delete_gb_bvci_cmd); |
| 343 | install_element(ENABLE_NODE, &delete_gb_nsei_cmd); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 344 | |
| 345 | install_element(CONFIG_NODE, &cfg_gbproxy_cmd); |
| 346 | install_node(&gbproxy_node, config_write_gbproxy); |
| 347 | install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd); |
Harald Welte | 209dc9f | 2020-12-12 19:02:16 +0100 | [diff] [blame] | 348 | install_element(GBPROXY_NODE, &cfg_pool_bvc_fc_ratio_cmd); |
Pau Espin Pedrol | 1ddefb1 | 2019-08-30 19:48:34 +0200 | [diff] [blame] | 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | int gbproxy_parse_config(const char *config_file, struct gbproxy_config *cfg) |
| 354 | { |
| 355 | int rc; |
| 356 | |
| 357 | g_cfg = cfg; |
| 358 | rc = vty_read_config_file(config_file, NULL); |
| 359 | if (rc < 0) { |
| 360 | fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); |
| 361 | return rc; |
| 362 | } |
| 363 | |
| 364 | return 0; |
| 365 | } |