Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +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 |
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 | 799e0c9 | 2010-04-30 21:49:24 +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 | 799e0c9 | 2010-04-30 21:49:24 +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 | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 21 | #include <sys/socket.h> |
| 22 | #include <netinet/in.h> |
| 23 | #include <arpa/inet.h> |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 24 | #include <string.h> |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 25 | #include <time.h> |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 26 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 27 | #include <osmocom/core/talloc.h> |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 28 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 29 | |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 30 | #include <openbsc/gsm_04_08.h> |
Harald Welte | ea34a4e | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 31 | #include <osmocom/gprs/gprs_ns.h> |
| 32 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 33 | #include <openbsc/debug.h> |
Harald Welte | b77c697 | 2010-05-01 11:28:43 +0200 | [diff] [blame] | 34 | #include <openbsc/gb_proxy.h> |
Holger Hans Peter Freyther | 7127b02 | 2014-08-04 11:52:52 +0200 | [diff] [blame] | 35 | #include <openbsc/gprs_utils.h> |
Harald Welte | 62ab20c | 2010-05-14 18:59:17 +0200 | [diff] [blame] | 36 | #include <openbsc/vty.h> |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 37 | |
Harald Welte | 4b037e4 | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 38 | #include <osmocom/vty/command.h> |
| 39 | #include <osmocom/vty/vty.h> |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 40 | #include <osmocom/vty/misc.h> |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 41 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 42 | static struct gbproxy_config *g_cfg = NULL; |
| 43 | |
| 44 | /* |
| 45 | * vty code for mgcp below |
| 46 | */ |
Harald Welte | b77c697 | 2010-05-01 11:28:43 +0200 | [diff] [blame] | 47 | static struct cmd_node gbproxy_node = { |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 48 | GBPROXY_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 49 | "%s(config-gbproxy)# ", |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 50 | 1, |
| 51 | }; |
| 52 | |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 53 | static void gbprox_vty_print_peer(struct vty *vty, struct gbproxy_peer *peer) |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 54 | { |
| 55 | struct gprs_ra_id raid; |
| 56 | gsm48_parse_ra(&raid, peer->ra); |
| 57 | |
| 58 | vty_out(vty, "NSEI %5u, PTP-BVCI %5u, " |
| 59 | "RAI %u-%u-%u-%u", |
| 60 | peer->nsei, peer->bvci, |
| 61 | raid.mcc, raid.mnc, raid.lac, raid.rac); |
| 62 | if (peer->blocked) |
| 63 | vty_out(vty, " [BVC-BLOCKED]"); |
| 64 | |
| 65 | vty_out(vty, "%s", VTY_NEWLINE); |
| 66 | } |
| 67 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 68 | static int config_write_gbproxy(struct vty *vty) |
| 69 | { |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 70 | vty_out(vty, "gbproxy%s", VTY_NEWLINE); |
| 71 | |
Harald Welte | ff3bde8 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 72 | vty_out(vty, " sgsn nsei %u%s", g_cfg->nsip_sgsn_nsei, |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 73 | VTY_NEWLINE); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 74 | |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 75 | if (g_cfg->core_mcc > 0) |
| 76 | vty_out(vty, " core-mobile-country-code %d%s", |
| 77 | g_cfg->core_mcc, VTY_NEWLINE); |
| 78 | if (g_cfg->core_mnc > 0) |
| 79 | vty_out(vty, " core-mobile-network-code %d%s", |
| 80 | g_cfg->core_mnc, VTY_NEWLINE); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 81 | |
| 82 | if (g_cfg->match_re) |
| 83 | vty_out(vty, " match-imsi %s%s", |
| 84 | g_cfg->match_re, VTY_NEWLINE); |
| 85 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 86 | if (g_cfg->core_apn != NULL) { |
| 87 | if (g_cfg->core_apn_size > 0) { |
| 88 | char str[500] = {0}; |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 89 | vty_out(vty, " core-access-point-name %s%s", |
Holger Hans Peter Freyther | 7127b02 | 2014-08-04 11:52:52 +0200 | [diff] [blame] | 90 | gprs_apn_to_str(str, g_cfg->core_apn, |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 91 | g_cfg->core_apn_size), |
| 92 | VTY_NEWLINE); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 93 | } else { |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 94 | vty_out(vty, " core-access-point-name none%s", |
| 95 | VTY_NEWLINE); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 96 | } |
| 97 | } |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 98 | |
Jacob Erlbeck | 25f98e6 | 2014-08-28 13:47:53 +0200 | [diff] [blame] | 99 | if (g_cfg->route_to_sgsn2) |
| 100 | vty_out(vty, " secondary-sgsn nsei %u%s", g_cfg->nsip_sgsn2_nsei, |
| 101 | VTY_NEWLINE); |
| 102 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 103 | if (g_cfg->tlli_max_age > 0) |
| 104 | vty_out(vty, " tlli-list max-age %d%s", |
| 105 | g_cfg->tlli_max_age, VTY_NEWLINE); |
| 106 | if (g_cfg->tlli_max_len > 0) |
| 107 | vty_out(vty, " tlli-list max-length %d%s", |
| 108 | g_cfg->tlli_max_len, VTY_NEWLINE); |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 109 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 110 | return CMD_SUCCESS; |
| 111 | } |
| 112 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 113 | DEFUN(cfg_gbproxy, |
| 114 | cfg_gbproxy_cmd, |
| 115 | "gbproxy", |
| 116 | "Configure the Gb proxy") |
| 117 | { |
| 118 | vty->node = GBPROXY_NODE; |
| 119 | return CMD_SUCCESS; |
| 120 | } |
| 121 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 122 | DEFUN(cfg_nsip_sgsn_nsei, |
| 123 | cfg_nsip_sgsn_nsei_cmd, |
Harald Welte | ff3bde8 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 124 | "sgsn nsei <0-65534>", |
Holger Hans Peter Freyther | 2eb6e2c | 2011-11-05 15:14:59 +0100 | [diff] [blame] | 125 | "SGSN information\n" |
| 126 | "NSEI to be used in the connection with the SGSN\n" |
| 127 | "The NSEI\n") |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 128 | { |
| 129 | unsigned int port = atoi(argv[0]); |
| 130 | |
| 131 | g_cfg->nsip_sgsn_nsei = port; |
| 132 | return CMD_SUCCESS; |
| 133 | } |
| 134 | |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 135 | #define GBPROXY_CORE_MNC_STR "Use this network code for the core network\n" |
| 136 | |
| 137 | DEFUN(cfg_gbproxy_core_mnc, |
| 138 | cfg_gbproxy_core_mnc_cmd, |
| 139 | "core-mobile-network-code <1-999>", |
| 140 | GBPROXY_CORE_MNC_STR "NCC value\n") |
| 141 | { |
| 142 | g_cfg->core_mnc = atoi(argv[0]); |
| 143 | return CMD_SUCCESS; |
| 144 | } |
| 145 | |
| 146 | DEFUN(cfg_gbproxy_no_core_mnc, |
| 147 | cfg_gbproxy_no_core_mnc_cmd, |
| 148 | "no core-mobile-network-code", |
| 149 | NO_STR GBPROXY_CORE_MNC_STR) |
| 150 | { |
| 151 | g_cfg->core_mnc = 0; |
| 152 | return CMD_SUCCESS; |
| 153 | } |
| 154 | |
| 155 | #define GBPROXY_CORE_MCC_STR "Use this country code for the core network\n" |
| 156 | |
| 157 | DEFUN(cfg_gbproxy_core_mcc, |
| 158 | cfg_gbproxy_core_mcc_cmd, |
| 159 | "core-mobile-country-code <1-999>", |
| 160 | GBPROXY_CORE_MCC_STR "MCC value\n") |
| 161 | { |
| 162 | g_cfg->core_mcc = atoi(argv[0]); |
| 163 | return CMD_SUCCESS; |
| 164 | } |
| 165 | |
| 166 | DEFUN(cfg_gbproxy_no_core_mcc, |
| 167 | cfg_gbproxy_no_core_mcc_cmd, |
| 168 | "no core-mobile-country-code", |
| 169 | NO_STR GBPROXY_CORE_MCC_STR) |
| 170 | { |
| 171 | g_cfg->core_mcc = 0; |
| 172 | return CMD_SUCCESS; |
| 173 | } |
| 174 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 175 | #define GBPROXY_MATCH_IMSI_STR "Restrict DTAP patching to certain IMSIs\n" |
| 176 | |
| 177 | DEFUN(cfg_gbproxy_match_imsi, |
| 178 | cfg_gbproxy_match_imsi_cmd, |
| 179 | "match-imsi .REGEXP", |
| 180 | GBPROXY_MATCH_IMSI_STR |
| 181 | "Regular expression for the match\n") |
| 182 | { |
| 183 | const char *filter = argv[0]; |
| 184 | const char *err_msg = NULL; |
| 185 | |
| 186 | if (gbproxy_set_patch_filter(g_cfg, filter, &err_msg) != 0) { |
| 187 | vty_out(vty, "Match expression invalid: %s%s", |
| 188 | err_msg, VTY_NEWLINE); |
| 189 | return CMD_WARNING; |
| 190 | } |
| 191 | talloc_free(g_cfg->match_re); |
| 192 | /* TODO: replace NULL */ |
| 193 | g_cfg->match_re = talloc_strdup(NULL, filter); |
| 194 | |
| 195 | g_cfg->acquire_imsi = 1; |
| 196 | |
| 197 | return CMD_SUCCESS; |
| 198 | } |
| 199 | |
| 200 | DEFUN(cfg_gbproxy_no_match_imsi, |
| 201 | cfg_gbproxy_no_match_imsi_cmd, |
| 202 | "no match-imsi", |
| 203 | NO_STR GBPROXY_MATCH_IMSI_STR) |
| 204 | { |
| 205 | gbproxy_clear_patch_filter(g_cfg); |
| 206 | |
| 207 | talloc_free(g_cfg->match_re); |
| 208 | g_cfg->match_re = NULL; |
| 209 | |
| 210 | g_cfg->acquire_imsi = 0; |
| 211 | |
| 212 | return CMD_SUCCESS; |
| 213 | } |
| 214 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 215 | #define GBPROXY_CORE_APN_STR "Use this access point name (APN) for the backbone\n" |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 216 | #define GBPROXY_CORE_APN_ARG_STR "Replace APN by this string\n" "Remove APN\n" |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 217 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 218 | static int set_core_apn(struct vty *vty, const char *apn) |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 219 | { |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 220 | int apn_len; |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 221 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 222 | if (!apn) { |
| 223 | talloc_free(g_cfg->core_apn); |
| 224 | g_cfg->core_apn = NULL; |
| 225 | g_cfg->core_apn_size = 0; |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 226 | return CMD_SUCCESS; |
| 227 | } |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 228 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 229 | apn_len = strlen(apn); |
| 230 | |
| 231 | if (apn_len >= 100) { |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 232 | vty_out(vty, "APN string too long (max 99 chars)%s", |
| 233 | VTY_NEWLINE); |
| 234 | return CMD_WARNING; |
| 235 | } |
| 236 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 237 | if (apn_len == 0) { |
| 238 | talloc_free(g_cfg->core_apn); |
| 239 | /* TODO: replace NULL */ |
| 240 | g_cfg->core_apn = talloc_zero_size(NULL, 2); |
| 241 | g_cfg->core_apn_size = 0; |
| 242 | } else { |
| 243 | /* TODO: replace NULL */ |
| 244 | g_cfg->core_apn = |
| 245 | talloc_realloc_size(NULL, g_cfg->core_apn, apn_len + 1); |
| 246 | g_cfg->core_apn_size = |
Holger Hans Peter Freyther | ce1b22e | 2014-08-04 14:22:13 +0200 | [diff] [blame] | 247 | gprs_str_to_apn(g_cfg->core_apn, apn_len + 1, apn); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 248 | } |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 249 | |
| 250 | return CMD_SUCCESS; |
| 251 | } |
| 252 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 253 | DEFUN(cfg_gbproxy_core_apn, |
| 254 | cfg_gbproxy_core_apn_cmd, |
| 255 | "core-access-point-name (APN|none)", |
| 256 | GBPROXY_CORE_APN_STR GBPROXY_CORE_APN_ARG_STR) |
| 257 | { |
| 258 | if (strcmp(argv[0], "none") == 0) |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 259 | return set_core_apn(vty, ""); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 260 | else |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 261 | return set_core_apn(vty, argv[0]); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 262 | } |
| 263 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 264 | DEFUN(cfg_gbproxy_no_core_apn, |
| 265 | cfg_gbproxy_no_core_apn_cmd, |
| 266 | "no core-access-point-name", |
| 267 | NO_STR GBPROXY_CORE_APN_STR) |
| 268 | { |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 269 | return set_core_apn(vty, NULL); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 270 | } |
| 271 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 272 | /* TODO: Remove the patch-ptmsi command, since P-TMSI patching is enabled |
| 273 | * automatically when needed. This command is only left for manual testing |
| 274 | * (e.g. doing P-TMSI patching without using a secondary SGSN) |
| 275 | */ |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 276 | #define GBPROXY_PATCH_PTMSI_STR "Patch P-TMSI/TLLI\n" |
| 277 | |
| 278 | DEFUN(cfg_gbproxy_patch_ptmsi, |
| 279 | cfg_gbproxy_patch_ptmsi_cmd, |
| 280 | "patch-ptmsi", |
| 281 | GBPROXY_PATCH_PTMSI_STR) |
| 282 | { |
| 283 | g_cfg->patch_ptmsi = 1; |
| 284 | |
| 285 | return CMD_SUCCESS; |
| 286 | } |
| 287 | |
| 288 | DEFUN(cfg_gbproxy_no_patch_ptmsi, |
| 289 | cfg_gbproxy_no_patch_ptmsi_cmd, |
| 290 | "no patch-ptmsi", |
| 291 | NO_STR GBPROXY_PATCH_PTMSI_STR) |
| 292 | { |
| 293 | g_cfg->patch_ptmsi = 0; |
| 294 | |
| 295 | return CMD_SUCCESS; |
| 296 | } |
| 297 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 298 | /* TODO: Remove the acquire-imsi command, since that feature is enabled |
| 299 | * automatically when IMSI matching is enabled. This command is only left for |
| 300 | * manual testing (e.g. doing IMSI acquisition without IMSI based patching) |
| 301 | */ |
Jacob Erlbeck | 5f4ef32 | 2014-08-22 17:10:01 +0200 | [diff] [blame] | 302 | #define GBPROXY_ACQUIRE_IMSI_STR "Acquire the IMSI before establishing a LLC connection (Experimental)\n" |
| 303 | |
| 304 | DEFUN(cfg_gbproxy_acquire_imsi, |
| 305 | cfg_gbproxy_acquire_imsi_cmd, |
| 306 | "acquire-imsi", |
| 307 | GBPROXY_ACQUIRE_IMSI_STR) |
| 308 | { |
| 309 | g_cfg->acquire_imsi = 1; |
| 310 | |
| 311 | return CMD_SUCCESS; |
| 312 | } |
| 313 | |
| 314 | DEFUN(cfg_gbproxy_no_acquire_imsi, |
| 315 | cfg_gbproxy_no_acquire_imsi_cmd, |
| 316 | "no acquire-imsi", |
| 317 | NO_STR GBPROXY_ACQUIRE_IMSI_STR) |
| 318 | { |
| 319 | g_cfg->acquire_imsi = 0; |
| 320 | |
| 321 | return CMD_SUCCESS; |
| 322 | } |
| 323 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 324 | #define GBPROXY_SECOND_SGSN_STR "Route matching LLC connections to a second SGSN (Experimental)\n" |
| 325 | |
| 326 | DEFUN(cfg_gbproxy_secondary_sgsn, |
| 327 | cfg_gbproxy_secondary_sgsn_cmd, |
| 328 | "secondary-sgsn nsei <0-65534>", |
| 329 | GBPROXY_SECOND_SGSN_STR |
| 330 | "NSEI to be used in the connection with the SGSN\n" |
| 331 | "The NSEI\n") |
| 332 | { |
| 333 | g_cfg->route_to_sgsn2 = 1; |
| 334 | g_cfg->nsip_sgsn2_nsei = atoi(argv[0]); |
| 335 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 336 | g_cfg->patch_ptmsi = 1; |
| 337 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 338 | return CMD_SUCCESS; |
| 339 | } |
| 340 | |
| 341 | DEFUN(cfg_gbproxy_no_secondary_sgsn, |
| 342 | cfg_gbproxy_no_secondary_sgsn_cmd, |
| 343 | "no secondary-sgsn", |
| 344 | NO_STR GBPROXY_SECOND_SGSN_STR) |
| 345 | { |
| 346 | g_cfg->route_to_sgsn2 = 0; |
| 347 | g_cfg->nsip_sgsn2_nsei = 0xFFFF; |
| 348 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 349 | g_cfg->patch_ptmsi = 0; |
| 350 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 351 | return CMD_SUCCESS; |
| 352 | } |
| 353 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 354 | #define GBPROXY_TLLI_LIST_STR "Set TLLI list parameters\n" |
| 355 | #define GBPROXY_MAX_AGE_STR "Limit maximum age\n" |
| 356 | |
| 357 | DEFUN(cfg_gbproxy_tlli_list_max_age, |
| 358 | cfg_gbproxy_tlli_list_max_age_cmd, |
| 359 | "tlli-list max-age <1-999999>", |
| 360 | GBPROXY_TLLI_LIST_STR GBPROXY_MAX_AGE_STR |
| 361 | "Maximum age in seconds\n") |
| 362 | { |
| 363 | g_cfg->tlli_max_age = atoi(argv[0]); |
| 364 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 365 | return CMD_SUCCESS; |
| 366 | } |
| 367 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 368 | DEFUN(cfg_gbproxy_tlli_list_no_max_age, |
| 369 | cfg_gbproxy_tlli_list_no_max_age_cmd, |
| 370 | "no tlli-list max-age", |
| 371 | NO_STR GBPROXY_TLLI_LIST_STR GBPROXY_MAX_AGE_STR) |
| 372 | { |
| 373 | g_cfg->tlli_max_age = 0; |
| 374 | |
| 375 | return CMD_SUCCESS; |
| 376 | } |
| 377 | |
| 378 | #define GBPROXY_MAX_LEN_STR "Limit list length\n" |
| 379 | |
| 380 | DEFUN(cfg_gbproxy_tlli_list_max_len, |
| 381 | cfg_gbproxy_tlli_list_max_len_cmd, |
| 382 | "tlli-list max-length <1-99999>", |
| 383 | GBPROXY_TLLI_LIST_STR GBPROXY_MAX_LEN_STR |
| 384 | "Maximum number of TLLIs in the list\n") |
| 385 | { |
| 386 | g_cfg->tlli_max_len = atoi(argv[0]); |
| 387 | |
| 388 | return CMD_SUCCESS; |
| 389 | } |
| 390 | |
| 391 | DEFUN(cfg_gbproxy_tlli_list_no_max_len, |
| 392 | cfg_gbproxy_tlli_list_no_max_len_cmd, |
| 393 | "no tlli-list max-length", |
| 394 | NO_STR GBPROXY_TLLI_LIST_STR GBPROXY_MAX_LEN_STR) |
| 395 | { |
| 396 | g_cfg->tlli_max_len = 0; |
| 397 | |
| 398 | return CMD_SUCCESS; |
| 399 | } |
| 400 | |
| 401 | |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 402 | DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]", |
| 403 | SHOW_STR "Display information about the Gb proxy\n" "Show statistics\n") |
| 404 | { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 405 | struct gbproxy_peer *peer; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 406 | int show_stats = argc >= 1; |
Jacob Erlbeck | 91fb680 | 2014-05-28 10:59:10 +0200 | [diff] [blame] | 407 | |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 408 | if (show_stats) |
Holger Hans Peter Freyther | eece627 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 409 | vty_out_rate_ctr_group(vty, "", g_cfg->ctrg); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 410 | |
Holger Hans Peter Freyther | eece627 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 411 | llist_for_each_entry(peer, &g_cfg->bts_peers, list) { |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 412 | gbprox_vty_print_peer(vty, peer); |
| 413 | |
| 414 | if (show_stats) |
| 415 | vty_out_rate_ctr_group(vty, " ", peer->ctrg); |
| 416 | } |
| 417 | return CMD_SUCCESS; |
| 418 | } |
| 419 | |
| 420 | DEFUN(show_gbproxy_tllis, show_gbproxy_tllis_cmd, "show gbproxy tllis", |
| 421 | SHOW_STR "Display information about the Gb proxy\n" "Show TLLIs\n") |
| 422 | { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 423 | struct gbproxy_peer *peer; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 424 | char mi_buf[200]; |
| 425 | time_t now = time(NULL); |
| 426 | |
Holger Hans Peter Freyther | eece627 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 427 | llist_for_each_entry(peer, &g_cfg->bts_peers, list) { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 428 | struct gbproxy_tlli_info *tlli_info; |
| 429 | struct gbproxy_patch_state *state = &peer->patch_state; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 430 | |
| 431 | gbprox_vty_print_peer(vty, peer); |
| 432 | |
| 433 | llist_for_each_entry(tlli_info, &state->enabled_tllis, list) { |
| 434 | time_t age = now - tlli_info->timestamp; |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 435 | int stored_msgs = 0; |
| 436 | struct llist_head *iter; |
| 437 | llist_for_each(iter, &tlli_info->stored_msgs) |
| 438 | stored_msgs++; |
| 439 | |
Jacob Erlbeck | 89d3d34 | 2014-08-06 18:55:15 +0200 | [diff] [blame] | 440 | if (tlli_info->mi_data_len > 0) { |
| 441 | snprintf(mi_buf, sizeof(mi_buf), "(invalid)"); |
| 442 | gsm48_mi_to_string(mi_buf, sizeof(mi_buf), |
| 443 | tlli_info->mi_data, |
| 444 | tlli_info->mi_data_len); |
| 445 | } else { |
| 446 | snprintf(mi_buf, sizeof(mi_buf), "(none)"); |
| 447 | } |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 448 | vty_out(vty, " TLLI %08x, IMSI %s, AGE %d", |
| 449 | tlli_info->tlli.current, mi_buf, (int)age); |
| 450 | |
| 451 | if (stored_msgs) |
| 452 | vty_out(vty, ", STORED %d", stored_msgs); |
| 453 | |
| 454 | vty_out(vty, "%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 455 | } |
| 456 | } |
| 457 | return CMD_SUCCESS; |
| 458 | } |
| 459 | |
| 460 | DEFUN(delete_gb_bvci, delete_gb_bvci_cmd, |
| 461 | "delete-gbproxy-peer <0-65534> bvci <2-65534>", |
| 462 | "Delete a GBProxy peer by NSEI and optionally BVCI\n" |
| 463 | "NSEI number\n" |
| 464 | "Only delete peer with a matching BVCI\n" |
| 465 | "BVCI number\n") |
| 466 | { |
| 467 | const uint16_t nsei = atoi(argv[0]); |
| 468 | const uint16_t bvci = atoi(argv[1]); |
| 469 | int counter; |
| 470 | |
Jacob Erlbeck | 5f1faa3 | 2014-08-21 10:01:30 +0200 | [diff] [blame] | 471 | counter = gbproxy_cleanup_peers(g_cfg, nsei, bvci); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 472 | |
| 473 | if (counter == 0) { |
| 474 | vty_out(vty, "BVC not found%s", VTY_NEWLINE); |
| 475 | return CMD_WARNING; |
| 476 | } |
| 477 | |
| 478 | return CMD_SUCCESS; |
| 479 | } |
| 480 | |
| 481 | DEFUN(delete_gb_nsei, delete_gb_nsei_cmd, |
| 482 | "delete-gbproxy-peer <0-65534> (only-bvc|only-nsvc|all) [dry-run]", |
| 483 | "Delete a GBProxy peer by NSEI and optionally BVCI\n" |
| 484 | "NSEI number\n" |
| 485 | "Only delete BSSGP connections (BVC)\n" |
| 486 | "Only delete dynamic NS connections (NS-VC)\n" |
| 487 | "Delete BVC and dynamic NS connections\n" |
| 488 | "Show what would be deleted instead of actually deleting\n" |
| 489 | ) |
| 490 | { |
| 491 | const uint16_t nsei = atoi(argv[0]); |
| 492 | const char *mode = argv[1]; |
| 493 | int dry_run = argc > 2; |
| 494 | int delete_bvc = 0; |
| 495 | int delete_nsvc = 0; |
| 496 | int counter; |
| 497 | |
| 498 | if (strcmp(mode, "only-bvc") == 0) |
| 499 | delete_bvc = 1; |
| 500 | else if (strcmp(mode, "only-nsvc") == 0) |
| 501 | delete_nsvc = 1; |
| 502 | else |
| 503 | delete_bvc = delete_nsvc = 1; |
| 504 | |
| 505 | if (delete_bvc) { |
| 506 | if (!dry_run) |
Jacob Erlbeck | 5f1faa3 | 2014-08-21 10:01:30 +0200 | [diff] [blame] | 507 | counter = gbproxy_cleanup_peers(g_cfg, nsei, 0); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 508 | else { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 509 | struct gbproxy_peer *peer; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 510 | counter = 0; |
Holger Hans Peter Freyther | eece627 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 511 | llist_for_each_entry(peer, &g_cfg->bts_peers, list) { |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 512 | if (peer->nsei != nsei) |
| 513 | continue; |
| 514 | |
| 515 | vty_out(vty, "BVC: "); |
| 516 | gbprox_vty_print_peer(vty, peer); |
| 517 | counter += 1; |
| 518 | } |
| 519 | } |
| 520 | vty_out(vty, "%sDeleted %d BVC%s", |
| 521 | dry_run ? "Not " : "", counter, VTY_NEWLINE); |
| 522 | } |
| 523 | |
| 524 | if (delete_nsvc) { |
Holger Hans Peter Freyther | eece627 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 525 | struct gprs_ns_inst *nsi = g_cfg->nsi; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 526 | struct gprs_nsvc *nsvc, *nsvc2; |
| 527 | |
| 528 | counter = 0; |
| 529 | llist_for_each_entry_safe(nsvc, nsvc2, &nsi->gprs_nsvcs, list) { |
| 530 | if (nsvc->nsei != nsei) |
| 531 | continue; |
| 532 | if (nsvc->persistent) |
| 533 | continue; |
| 534 | |
| 535 | if (!dry_run) |
| 536 | gprs_nsvc_delete(nsvc); |
| 537 | else |
| 538 | vty_out(vty, "NS-VC: NSEI %5u, NS-VCI %5u, " |
| 539 | "remote %s%s", |
| 540 | nsvc->nsei, nsvc->nsvci, |
| 541 | gprs_ns_ll_str(nsvc), VTY_NEWLINE); |
| 542 | counter += 1; |
| 543 | } |
| 544 | vty_out(vty, "%sDeleted %d NS-VC%s", |
| 545 | dry_run ? "Not " : "", counter, VTY_NEWLINE); |
| 546 | } |
| 547 | |
| 548 | return CMD_SUCCESS; |
| 549 | } |
| 550 | |
| 551 | DEFUN(delete_gb_tlli, delete_gb_tlli_cmd, |
| 552 | "delete-gbproxy-tlli <0-65534> (tlli|imsi|stale) [IDENT]", |
| 553 | "Delete a GBProxy TLLI entry by NSEI and identification\n" |
| 554 | "NSEI number\n" |
| 555 | "Delete entries with a matching TLLI (hex)\n" |
| 556 | "Delete entries with a matching IMSI\n" |
Holger Hans Peter Freyther | fcc30a3 | 2014-08-29 10:50:50 +0200 | [diff] [blame] | 557 | "Delete stale entries\n" |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 558 | "Identification to match\n") |
| 559 | { |
| 560 | const uint16_t nsei = atoi(argv[0]); |
| 561 | enum {MATCH_TLLI = 't', MATCH_IMSI = 'i', MATCH_STALE = 's'} match; |
| 562 | uint32_t tlli = 0; |
| 563 | const char *imsi = NULL; |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 564 | struct gbproxy_peer *peer = 0; |
| 565 | struct gbproxy_tlli_info *tlli_info, *nxt; |
| 566 | struct gbproxy_patch_state *state; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 567 | char mi_buf[200]; |
| 568 | int found = 0; |
| 569 | |
| 570 | match = argv[1][0]; |
| 571 | |
| 572 | switch (match) { |
| 573 | case MATCH_TLLI: |
| 574 | if (argc < 2 || !argv[2][0]) { |
| 575 | vty_out(vty, "%% Missing TLLI%s", VTY_NEWLINE); |
| 576 | return CMD_WARNING; |
| 577 | } |
| 578 | tlli = strtoll(argv[2], NULL, 16); |
| 579 | break; |
| 580 | case MATCH_IMSI: |
| 581 | if (argc < 2 || !argv[2][0]) { |
| 582 | vty_out(vty, "%% Missing IMSI%s", VTY_NEWLINE); |
| 583 | return CMD_WARNING; |
| 584 | } |
| 585 | imsi = argv[2]; |
| 586 | break; |
| 587 | default: |
| 588 | break; |
| 589 | } |
| 590 | |
Jacob Erlbeck | 5f1faa3 | 2014-08-21 10:01:30 +0200 | [diff] [blame] | 591 | peer = gbproxy_peer_by_nsei(g_cfg, nsei); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 592 | if (!peer) { |
| 593 | vty_out(vty, "Didn't find peer with NSEI %d%s", |
| 594 | nsei, VTY_NEWLINE); |
| 595 | return CMD_WARNING; |
| 596 | } |
| 597 | |
| 598 | state = &peer->patch_state; |
| 599 | |
| 600 | if (match == MATCH_STALE) { |
Jacob Erlbeck | 9114bee | 2014-08-19 12:21:01 +0200 | [diff] [blame] | 601 | found = gbproxy_remove_stale_tllis(peer, time(NULL)); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 602 | if (found) |
| 603 | vty_out(vty, "Deleted %d stale TLLI%s%s", |
| 604 | found, found == 1 ? "" : "s", VTY_NEWLINE); |
| 605 | return CMD_SUCCESS; |
| 606 | } |
| 607 | |
| 608 | llist_for_each_entry_safe(tlli_info, nxt, &state->enabled_tllis, list) { |
Jacob Erlbeck | 9057bc3 | 2014-08-12 16:30:30 +0200 | [diff] [blame] | 609 | if (match == MATCH_TLLI && tlli_info->tlli.current != tlli) |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 610 | continue; |
| 611 | |
| 612 | if (match == MATCH_IMSI) { |
| 613 | mi_buf[0] = '\0'; |
| 614 | gsm48_mi_to_string(mi_buf, sizeof(mi_buf), |
| 615 | tlli_info->mi_data, |
| 616 | tlli_info->mi_data_len); |
| 617 | |
| 618 | if (strcmp(mi_buf, imsi) != 0) |
| 619 | continue; |
| 620 | } |
Jacob Erlbeck | 9057bc3 | 2014-08-12 16:30:30 +0200 | [diff] [blame] | 621 | vty_out(vty, "Deleting TLLI %08x%s", tlli_info->tlli.current, |
| 622 | VTY_NEWLINE); |
Jacob Erlbeck | 9114bee | 2014-08-19 12:21:01 +0200 | [diff] [blame] | 623 | gbproxy_delete_tlli(peer, tlli_info); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 624 | found += 1; |
| 625 | } |
| 626 | |
| 627 | if (!found && argc >= 2) { |
| 628 | vty_out(vty, "Didn't find TLLI entry with %s %s%s", |
| 629 | argv[1], argv[2], VTY_NEWLINE); |
| 630 | } |
| 631 | |
| 632 | return CMD_SUCCESS; |
| 633 | } |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 634 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 635 | int gbproxy_vty_init(void) |
| 636 | { |
Harald Welte | 995a2d3 | 2010-05-12 16:50:52 +0000 | [diff] [blame] | 637 | install_element_ve(&show_gbproxy_cmd); |
Jacob Erlbeck | 7dd498d | 2014-06-19 10:15:27 +0200 | [diff] [blame] | 638 | install_element_ve(&show_gbproxy_tllis_cmd); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 639 | |
Jacob Erlbeck | 4211d79 | 2013-10-24 12:48:23 +0200 | [diff] [blame] | 640 | install_element(ENABLE_NODE, &delete_gb_bvci_cmd); |
| 641 | install_element(ENABLE_NODE, &delete_gb_nsei_cmd); |
Jacob Erlbeck | 7dd498d | 2014-06-19 10:15:27 +0200 | [diff] [blame] | 642 | install_element(ENABLE_NODE, &delete_gb_tlli_cmd); |
Holger Hans Peter Freyther | 90267a9 | 2013-10-23 11:24:17 +0200 | [diff] [blame] | 643 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 644 | install_element(CONFIG_NODE, &cfg_gbproxy_cmd); |
| 645 | install_node(&gbproxy_node, config_write_gbproxy); |
Jacob Erlbeck | 36722e1 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 646 | vty_install_default(GBPROXY_NODE); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 647 | install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd); |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 648 | install_element(GBPROXY_NODE, &cfg_gbproxy_core_mcc_cmd); |
| 649 | install_element(GBPROXY_NODE, &cfg_gbproxy_core_mnc_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 650 | install_element(GBPROXY_NODE, &cfg_gbproxy_match_imsi_cmd); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 651 | install_element(GBPROXY_NODE, &cfg_gbproxy_core_apn_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 652 | install_element(GBPROXY_NODE, &cfg_gbproxy_secondary_sgsn_cmd); |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 653 | install_element(GBPROXY_NODE, &cfg_gbproxy_patch_ptmsi_cmd); |
Jacob Erlbeck | 5f4ef32 | 2014-08-22 17:10:01 +0200 | [diff] [blame] | 654 | install_element(GBPROXY_NODE, &cfg_gbproxy_acquire_imsi_cmd); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 655 | install_element(GBPROXY_NODE, &cfg_gbproxy_tlli_list_max_age_cmd); |
| 656 | install_element(GBPROXY_NODE, &cfg_gbproxy_tlli_list_max_len_cmd); |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 657 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_core_mcc_cmd); |
| 658 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_core_mnc_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 659 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_match_imsi_cmd); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 660 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_core_apn_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 661 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_secondary_sgsn_cmd); |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 662 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_patch_ptmsi_cmd); |
Jacob Erlbeck | 5f4ef32 | 2014-08-22 17:10:01 +0200 | [diff] [blame] | 663 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_acquire_imsi_cmd); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 664 | install_element(GBPROXY_NODE, &cfg_gbproxy_tlli_list_no_max_age_cmd); |
| 665 | install_element(GBPROXY_NODE, &cfg_gbproxy_tlli_list_no_max_len_cmd); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 666 | |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | int gbproxy_parse_config(const char *config_file, struct gbproxy_config *cfg) |
| 671 | { |
| 672 | int rc; |
| 673 | |
| 674 | g_cfg = cfg; |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 675 | rc = vty_read_config_file(config_file, NULL); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 676 | if (rc < 0) { |
| 677 | fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); |
| 678 | return rc; |
| 679 | } |
| 680 | |
| 681 | return 0; |
| 682 | } |
| 683 | |