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