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> |
Harald Welte | 586e681 | 2017-08-12 13:43:54 +0200 | [diff] [blame^] | 32 | #include <osmocom/gsm/apn.h> |
Harald Welte | ea34a4e | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 33 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 34 | #include <openbsc/debug.h> |
Harald Welte | b77c697 | 2010-05-01 11:28:43 +0200 | [diff] [blame] | 35 | #include <openbsc/gb_proxy.h> |
Holger Hans Peter Freyther | 7127b02 | 2014-08-04 11:52:52 +0200 | [diff] [blame] | 36 | #include <openbsc/gprs_utils.h> |
Harald Welte | 62ab20c | 2010-05-14 18:59:17 +0200 | [diff] [blame] | 37 | #include <openbsc/vty.h> |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 38 | |
Harald Welte | 4b037e4 | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 39 | #include <osmocom/vty/command.h> |
| 40 | #include <osmocom/vty/vty.h> |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 41 | #include <osmocom/vty/misc.h> |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 42 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 43 | static struct gbproxy_config *g_cfg = NULL; |
| 44 | |
| 45 | /* |
| 46 | * vty code for mgcp below |
| 47 | */ |
Harald Welte | b77c697 | 2010-05-01 11:28:43 +0200 | [diff] [blame] | 48 | static struct cmd_node gbproxy_node = { |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 49 | GBPROXY_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 50 | "%s(config-gbproxy)# ", |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 51 | 1, |
| 52 | }; |
| 53 | |
Jacob Erlbeck | 7430da6 | 2014-09-12 15:09:56 +0200 | [diff] [blame] | 54 | static const struct value_string keep_modes[] = { |
| 55 | {GBPROX_KEEP_NEVER, "never"}, |
| 56 | {GBPROX_KEEP_REATTACH, "re-attach"}, |
| 57 | {GBPROX_KEEP_IDENTIFIED, "identified"}, |
| 58 | {GBPROX_KEEP_ALWAYS, "always"}, |
| 59 | {0, NULL} |
| 60 | }; |
| 61 | |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 62 | static const struct value_string match_ids[] = { |
| 63 | {GBPROX_MATCH_PATCHING, "patching"}, |
Jacob Erlbeck | b36032c | 2014-09-25 13:21:48 +0200 | [diff] [blame] | 64 | {GBPROX_MATCH_ROUTING, "routing"}, |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 65 | {0, NULL} |
| 66 | }; |
| 67 | |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 68 | 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] | 69 | { |
| 70 | struct gprs_ra_id raid; |
| 71 | gsm48_parse_ra(&raid, peer->ra); |
| 72 | |
| 73 | vty_out(vty, "NSEI %5u, PTP-BVCI %5u, " |
| 74 | "RAI %u-%u-%u-%u", |
| 75 | peer->nsei, peer->bvci, |
| 76 | raid.mcc, raid.mnc, raid.lac, raid.rac); |
| 77 | if (peer->blocked) |
| 78 | vty_out(vty, " [BVC-BLOCKED]"); |
| 79 | |
| 80 | vty_out(vty, "%s", VTY_NEWLINE); |
| 81 | } |
| 82 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 83 | static int config_write_gbproxy(struct vty *vty) |
| 84 | { |
Jacob Erlbeck | 9a83d7a | 2014-09-25 11:17:31 +0200 | [diff] [blame] | 85 | enum gbproxy_match_id match_id; |
| 86 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 87 | vty_out(vty, "gbproxy%s", VTY_NEWLINE); |
| 88 | |
Harald Welte | ff3bde8 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 89 | vty_out(vty, " sgsn nsei %u%s", g_cfg->nsip_sgsn_nsei, |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 90 | VTY_NEWLINE); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 91 | |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 92 | if (g_cfg->core_mcc > 0) |
| 93 | vty_out(vty, " core-mobile-country-code %d%s", |
| 94 | g_cfg->core_mcc, VTY_NEWLINE); |
| 95 | if (g_cfg->core_mnc > 0) |
| 96 | vty_out(vty, " core-mobile-network-code %d%s", |
| 97 | g_cfg->core_mnc, VTY_NEWLINE); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 98 | |
Jacob Erlbeck | 9a83d7a | 2014-09-25 11:17:31 +0200 | [diff] [blame] | 99 | for (match_id = 0; match_id < ARRAY_SIZE(g_cfg->matches); ++match_id) { |
| 100 | struct gbproxy_match *match = &g_cfg->matches[match_id]; |
| 101 | if (match->re_str) |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 102 | vty_out(vty, " match-imsi %s %s%s", |
| 103 | get_value_string(match_ids, match_id), |
Jacob Erlbeck | 9a83d7a | 2014-09-25 11:17:31 +0200 | [diff] [blame] | 104 | match->re_str, VTY_NEWLINE); |
| 105 | } |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 106 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 107 | if (g_cfg->core_apn != NULL) { |
| 108 | if (g_cfg->core_apn_size > 0) { |
| 109 | char str[500] = {0}; |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 110 | vty_out(vty, " core-access-point-name %s%s", |
Harald Welte | 586e681 | 2017-08-12 13:43:54 +0200 | [diff] [blame^] | 111 | osmo_apn_to_str(str, g_cfg->core_apn, |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 112 | g_cfg->core_apn_size), |
| 113 | VTY_NEWLINE); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 114 | } else { |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 115 | vty_out(vty, " core-access-point-name none%s", |
| 116 | VTY_NEWLINE); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 117 | } |
| 118 | } |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 119 | |
Jacob Erlbeck | 25f98e6 | 2014-08-28 13:47:53 +0200 | [diff] [blame] | 120 | if (g_cfg->route_to_sgsn2) |
| 121 | vty_out(vty, " secondary-sgsn nsei %u%s", g_cfg->nsip_sgsn2_nsei, |
| 122 | VTY_NEWLINE); |
| 123 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 124 | if (g_cfg->tlli_max_age > 0) |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 125 | vty_out(vty, " link-list max-age %d%s", |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 126 | g_cfg->tlli_max_age, VTY_NEWLINE); |
| 127 | if (g_cfg->tlli_max_len > 0) |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 128 | vty_out(vty, " link-list max-length %d%s", |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 129 | g_cfg->tlli_max_len, VTY_NEWLINE); |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 130 | vty_out(vty, " link-list keep-mode %s%s", |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 131 | get_value_string(keep_modes, g_cfg->keep_link_infos), |
Jacob Erlbeck | 7430da6 | 2014-09-12 15:09:56 +0200 | [diff] [blame] | 132 | VTY_NEWLINE); |
| 133 | |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 134 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 135 | return CMD_SUCCESS; |
| 136 | } |
| 137 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 138 | DEFUN(cfg_gbproxy, |
| 139 | cfg_gbproxy_cmd, |
| 140 | "gbproxy", |
| 141 | "Configure the Gb proxy") |
| 142 | { |
| 143 | vty->node = GBPROXY_NODE; |
| 144 | return CMD_SUCCESS; |
| 145 | } |
| 146 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 147 | DEFUN(cfg_nsip_sgsn_nsei, |
| 148 | cfg_nsip_sgsn_nsei_cmd, |
Harald Welte | ff3bde8 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 149 | "sgsn nsei <0-65534>", |
Holger Hans Peter Freyther | 2eb6e2c | 2011-11-05 15:14:59 +0100 | [diff] [blame] | 150 | "SGSN information\n" |
| 151 | "NSEI to be used in the connection with the SGSN\n" |
| 152 | "The NSEI\n") |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 153 | { |
Jacob Erlbeck | cc8856f | 2014-10-08 13:37:28 +0200 | [diff] [blame] | 154 | unsigned int nsei = atoi(argv[0]); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 155 | |
Jacob Erlbeck | cc8856f | 2014-10-08 13:37:28 +0200 | [diff] [blame] | 156 | if (g_cfg->route_to_sgsn2 && g_cfg->nsip_sgsn2_nsei == nsei) { |
| 157 | vty_out(vty, "SGSN NSEI %d conflicts with secondary SGSN NSEI%s", |
| 158 | nsei, VTY_NEWLINE); |
| 159 | return CMD_WARNING; |
| 160 | } |
| 161 | |
| 162 | g_cfg->nsip_sgsn_nsei = nsei; |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 163 | return CMD_SUCCESS; |
| 164 | } |
| 165 | |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 166 | #define GBPROXY_CORE_MNC_STR "Use this network code for the core network\n" |
| 167 | |
| 168 | DEFUN(cfg_gbproxy_core_mnc, |
| 169 | cfg_gbproxy_core_mnc_cmd, |
| 170 | "core-mobile-network-code <1-999>", |
| 171 | GBPROXY_CORE_MNC_STR "NCC value\n") |
| 172 | { |
| 173 | g_cfg->core_mnc = atoi(argv[0]); |
| 174 | return CMD_SUCCESS; |
| 175 | } |
| 176 | |
| 177 | DEFUN(cfg_gbproxy_no_core_mnc, |
| 178 | cfg_gbproxy_no_core_mnc_cmd, |
| 179 | "no core-mobile-network-code", |
| 180 | NO_STR GBPROXY_CORE_MNC_STR) |
| 181 | { |
| 182 | g_cfg->core_mnc = 0; |
| 183 | return CMD_SUCCESS; |
| 184 | } |
| 185 | |
| 186 | #define GBPROXY_CORE_MCC_STR "Use this country code for the core network\n" |
| 187 | |
| 188 | DEFUN(cfg_gbproxy_core_mcc, |
| 189 | cfg_gbproxy_core_mcc_cmd, |
| 190 | "core-mobile-country-code <1-999>", |
| 191 | GBPROXY_CORE_MCC_STR "MCC value\n") |
| 192 | { |
| 193 | g_cfg->core_mcc = atoi(argv[0]); |
| 194 | return CMD_SUCCESS; |
| 195 | } |
| 196 | |
| 197 | DEFUN(cfg_gbproxy_no_core_mcc, |
| 198 | cfg_gbproxy_no_core_mcc_cmd, |
| 199 | "no core-mobile-country-code", |
| 200 | NO_STR GBPROXY_CORE_MCC_STR) |
| 201 | { |
| 202 | g_cfg->core_mcc = 0; |
| 203 | return CMD_SUCCESS; |
| 204 | } |
| 205 | |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 206 | #define GBPROXY_MATCH_IMSI_STR "Restrict actions to certain IMSIs\n" |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 207 | |
| 208 | DEFUN(cfg_gbproxy_match_imsi, |
| 209 | cfg_gbproxy_match_imsi_cmd, |
Jacob Erlbeck | b36032c | 2014-09-25 13:21:48 +0200 | [diff] [blame] | 210 | "match-imsi (patching|routing) .REGEXP", |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 211 | GBPROXY_MATCH_IMSI_STR |
Jacob Erlbeck | b36032c | 2014-09-25 13:21:48 +0200 | [diff] [blame] | 212 | "Patch MS related information elements on match only\n" |
| 213 | "Route to the secondary SGSN on match only\n" |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 214 | "Regular expression for the IMSI match\n") |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 215 | { |
Jacob Erlbeck | b36032c | 2014-09-25 13:21:48 +0200 | [diff] [blame] | 216 | const char *filter = argv[1]; |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 217 | const char *err_msg = NULL; |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 218 | struct gbproxy_match *match; |
Jacob Erlbeck | b36032c | 2014-09-25 13:21:48 +0200 | [diff] [blame] | 219 | enum gbproxy_match_id match_id = get_string_value(match_ids, argv[0]); |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 220 | |
| 221 | OSMO_ASSERT(match_id >= GBPROX_MATCH_PATCHING && |
| 222 | match_id < GBPROX_MATCH_LAST); |
| 223 | match = &g_cfg->matches[match_id]; |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 224 | |
Jacob Erlbeck | 9a83d7a | 2014-09-25 11:17:31 +0200 | [diff] [blame] | 225 | if (gbproxy_set_patch_filter(match, filter, &err_msg) != 0) { |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 226 | vty_out(vty, "Match expression invalid: %s%s", |
| 227 | err_msg, VTY_NEWLINE); |
| 228 | return CMD_WARNING; |
| 229 | } |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 230 | |
| 231 | g_cfg->acquire_imsi = 1; |
| 232 | |
| 233 | return CMD_SUCCESS; |
| 234 | } |
| 235 | |
| 236 | DEFUN(cfg_gbproxy_no_match_imsi, |
| 237 | cfg_gbproxy_no_match_imsi_cmd, |
| 238 | "no match-imsi", |
| 239 | NO_STR GBPROXY_MATCH_IMSI_STR) |
| 240 | { |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 241 | enum gbproxy_match_id match_id; |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 242 | |
Jacob Erlbeck | 6c3fdc1 | 2014-09-25 13:39:06 +0200 | [diff] [blame] | 243 | for (match_id = 0; match_id < ARRAY_SIZE(g_cfg->matches); ++match_id) |
| 244 | gbproxy_clear_patch_filter(&g_cfg->matches[match_id]); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 245 | |
| 246 | g_cfg->acquire_imsi = 0; |
| 247 | |
| 248 | return CMD_SUCCESS; |
| 249 | } |
| 250 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 251 | #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] | 252 | #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] | 253 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 254 | static int set_core_apn(struct vty *vty, const char *apn) |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 255 | { |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 256 | int apn_len; |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 257 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 258 | if (!apn) { |
| 259 | talloc_free(g_cfg->core_apn); |
| 260 | g_cfg->core_apn = NULL; |
| 261 | g_cfg->core_apn_size = 0; |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 262 | return CMD_SUCCESS; |
| 263 | } |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 264 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 265 | apn_len = strlen(apn); |
| 266 | |
| 267 | if (apn_len >= 100) { |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 268 | vty_out(vty, "APN string too long (max 99 chars)%s", |
| 269 | VTY_NEWLINE); |
| 270 | return CMD_WARNING; |
| 271 | } |
| 272 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 273 | if (apn_len == 0) { |
| 274 | talloc_free(g_cfg->core_apn); |
| 275 | /* TODO: replace NULL */ |
| 276 | g_cfg->core_apn = talloc_zero_size(NULL, 2); |
| 277 | g_cfg->core_apn_size = 0; |
| 278 | } else { |
| 279 | /* TODO: replace NULL */ |
| 280 | g_cfg->core_apn = |
| 281 | talloc_realloc_size(NULL, g_cfg->core_apn, apn_len + 1); |
| 282 | g_cfg->core_apn_size = |
Holger Hans Peter Freyther | ce1b22e | 2014-08-04 14:22:13 +0200 | [diff] [blame] | 283 | gprs_str_to_apn(g_cfg->core_apn, apn_len + 1, apn); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 284 | } |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 285 | |
| 286 | return CMD_SUCCESS; |
| 287 | } |
| 288 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 289 | DEFUN(cfg_gbproxy_core_apn, |
| 290 | cfg_gbproxy_core_apn_cmd, |
| 291 | "core-access-point-name (APN|none)", |
| 292 | GBPROXY_CORE_APN_STR GBPROXY_CORE_APN_ARG_STR) |
| 293 | { |
| 294 | if (strcmp(argv[0], "none") == 0) |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 295 | return set_core_apn(vty, ""); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 296 | else |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 297 | return set_core_apn(vty, argv[0]); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 300 | DEFUN(cfg_gbproxy_no_core_apn, |
| 301 | cfg_gbproxy_no_core_apn_cmd, |
| 302 | "no core-access-point-name", |
| 303 | NO_STR GBPROXY_CORE_APN_STR) |
| 304 | { |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 305 | return set_core_apn(vty, NULL); |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 306 | } |
| 307 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 308 | /* TODO: Remove the patch-ptmsi command, since P-TMSI patching is enabled |
| 309 | * automatically when needed. This command is only left for manual testing |
| 310 | * (e.g. doing P-TMSI patching without using a secondary SGSN) |
| 311 | */ |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 312 | #define GBPROXY_PATCH_PTMSI_STR "Patch P-TMSI/TLLI\n" |
| 313 | |
| 314 | DEFUN(cfg_gbproxy_patch_ptmsi, |
| 315 | cfg_gbproxy_patch_ptmsi_cmd, |
| 316 | "patch-ptmsi", |
| 317 | GBPROXY_PATCH_PTMSI_STR) |
| 318 | { |
| 319 | g_cfg->patch_ptmsi = 1; |
| 320 | |
| 321 | return CMD_SUCCESS; |
| 322 | } |
| 323 | |
| 324 | DEFUN(cfg_gbproxy_no_patch_ptmsi, |
| 325 | cfg_gbproxy_no_patch_ptmsi_cmd, |
| 326 | "no patch-ptmsi", |
| 327 | NO_STR GBPROXY_PATCH_PTMSI_STR) |
| 328 | { |
| 329 | g_cfg->patch_ptmsi = 0; |
| 330 | |
| 331 | return CMD_SUCCESS; |
| 332 | } |
| 333 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 334 | /* TODO: Remove the acquire-imsi command, since that feature is enabled |
| 335 | * automatically when IMSI matching is enabled. This command is only left for |
| 336 | * manual testing (e.g. doing IMSI acquisition without IMSI based patching) |
| 337 | */ |
Jacob Erlbeck | 5f4ef32 | 2014-08-22 17:10:01 +0200 | [diff] [blame] | 338 | #define GBPROXY_ACQUIRE_IMSI_STR "Acquire the IMSI before establishing a LLC connection (Experimental)\n" |
| 339 | |
| 340 | DEFUN(cfg_gbproxy_acquire_imsi, |
| 341 | cfg_gbproxy_acquire_imsi_cmd, |
| 342 | "acquire-imsi", |
| 343 | GBPROXY_ACQUIRE_IMSI_STR) |
| 344 | { |
| 345 | g_cfg->acquire_imsi = 1; |
| 346 | |
| 347 | return CMD_SUCCESS; |
| 348 | } |
| 349 | |
| 350 | DEFUN(cfg_gbproxy_no_acquire_imsi, |
| 351 | cfg_gbproxy_no_acquire_imsi_cmd, |
| 352 | "no acquire-imsi", |
| 353 | NO_STR GBPROXY_ACQUIRE_IMSI_STR) |
| 354 | { |
| 355 | g_cfg->acquire_imsi = 0; |
| 356 | |
| 357 | return CMD_SUCCESS; |
| 358 | } |
| 359 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 360 | #define GBPROXY_SECOND_SGSN_STR "Route matching LLC connections to a second SGSN (Experimental)\n" |
| 361 | |
| 362 | DEFUN(cfg_gbproxy_secondary_sgsn, |
| 363 | cfg_gbproxy_secondary_sgsn_cmd, |
| 364 | "secondary-sgsn nsei <0-65534>", |
| 365 | GBPROXY_SECOND_SGSN_STR |
| 366 | "NSEI to be used in the connection with the SGSN\n" |
| 367 | "The NSEI\n") |
| 368 | { |
Jacob Erlbeck | cc8856f | 2014-10-08 13:37:28 +0200 | [diff] [blame] | 369 | unsigned int nsei = atoi(argv[0]); |
| 370 | |
| 371 | if (g_cfg->nsip_sgsn_nsei == nsei) { |
| 372 | vty_out(vty, "Secondary SGSN NSEI %d conflicts with primary SGSN NSEI%s", |
| 373 | nsei, VTY_NEWLINE); |
| 374 | return CMD_WARNING; |
| 375 | } |
| 376 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 377 | g_cfg->route_to_sgsn2 = 1; |
Jacob Erlbeck | cc8856f | 2014-10-08 13:37:28 +0200 | [diff] [blame] | 378 | g_cfg->nsip_sgsn2_nsei = nsei; |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 379 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 380 | g_cfg->patch_ptmsi = 1; |
| 381 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 382 | return CMD_SUCCESS; |
| 383 | } |
| 384 | |
| 385 | DEFUN(cfg_gbproxy_no_secondary_sgsn, |
| 386 | cfg_gbproxy_no_secondary_sgsn_cmd, |
| 387 | "no secondary-sgsn", |
| 388 | NO_STR GBPROXY_SECOND_SGSN_STR) |
| 389 | { |
| 390 | g_cfg->route_to_sgsn2 = 0; |
| 391 | g_cfg->nsip_sgsn2_nsei = 0xFFFF; |
| 392 | |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 393 | g_cfg->patch_ptmsi = 0; |
| 394 | |
Jacob Erlbeck | f4d60c8 | 2014-08-26 14:47:15 +0200 | [diff] [blame] | 395 | return CMD_SUCCESS; |
| 396 | } |
| 397 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 398 | #define GBPROXY_LINK_LIST_STR "Set TLLI list parameters\n" |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 399 | #define GBPROXY_MAX_AGE_STR "Limit maximum age\n" |
| 400 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 401 | DEFUN(cfg_gbproxy_link_list_max_age, |
| 402 | cfg_gbproxy_link_list_max_age_cmd, |
| 403 | "link-list max-age <1-999999>", |
| 404 | GBPROXY_LINK_LIST_STR GBPROXY_MAX_AGE_STR |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 405 | "Maximum age in seconds\n") |
| 406 | { |
| 407 | g_cfg->tlli_max_age = atoi(argv[0]); |
| 408 | |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 409 | return CMD_SUCCESS; |
| 410 | } |
| 411 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 412 | DEFUN(cfg_gbproxy_link_list_no_max_age, |
| 413 | cfg_gbproxy_link_list_no_max_age_cmd, |
| 414 | "no link-list max-age", |
| 415 | NO_STR GBPROXY_LINK_LIST_STR GBPROXY_MAX_AGE_STR) |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 416 | { |
| 417 | g_cfg->tlli_max_age = 0; |
| 418 | |
| 419 | return CMD_SUCCESS; |
| 420 | } |
| 421 | |
| 422 | #define GBPROXY_MAX_LEN_STR "Limit list length\n" |
| 423 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 424 | DEFUN(cfg_gbproxy_link_list_max_len, |
| 425 | cfg_gbproxy_link_list_max_len_cmd, |
| 426 | "link-list max-length <1-99999>", |
| 427 | GBPROXY_LINK_LIST_STR GBPROXY_MAX_LEN_STR |
| 428 | "Maximum number of logical links in the list\n") |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 429 | { |
| 430 | g_cfg->tlli_max_len = atoi(argv[0]); |
| 431 | |
| 432 | return CMD_SUCCESS; |
| 433 | } |
| 434 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 435 | DEFUN(cfg_gbproxy_link_list_no_max_len, |
| 436 | cfg_gbproxy_link_list_no_max_len_cmd, |
| 437 | "no link-list max-length", |
| 438 | NO_STR GBPROXY_LINK_LIST_STR GBPROXY_MAX_LEN_STR) |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 439 | { |
| 440 | g_cfg->tlli_max_len = 0; |
| 441 | |
| 442 | return CMD_SUCCESS; |
| 443 | } |
| 444 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 445 | DEFUN(cfg_gbproxy_link_list_keep_mode, |
| 446 | cfg_gbproxy_link_list_keep_mode_cmd, |
| 447 | "link-list keep-mode (never|re-attach|identified|always)", |
| 448 | GBPROXY_LINK_LIST_STR "How to keep entries for detached logical links\n" |
Jacob Erlbeck | 7430da6 | 2014-09-12 15:09:56 +0200 | [diff] [blame] | 449 | "Discard entry immediately after detachment\n" |
| 450 | "Keep entry if a re-attachment has be requested\n" |
| 451 | "Keep entry if it associated with an IMSI\n" |
| 452 | "Don't discard entries after detachment\n") |
| 453 | { |
| 454 | int val = get_string_value(keep_modes, argv[0]); |
| 455 | OSMO_ASSERT(val >= GBPROX_KEEP_NEVER && val <= GBPROX_KEEP_ALWAYS); |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 456 | g_cfg->keep_link_infos = val; |
Jacob Erlbeck | 7430da6 | 2014-09-12 15:09:56 +0200 | [diff] [blame] | 457 | |
| 458 | return CMD_SUCCESS; |
| 459 | } |
| 460 | |
Jacob Erlbeck | 7c101d9 | 2014-06-06 18:49:23 +0200 | [diff] [blame] | 461 | |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 462 | DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]", |
| 463 | SHOW_STR "Display information about the Gb proxy\n" "Show statistics\n") |
| 464 | { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 465 | struct gbproxy_peer *peer; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 466 | int show_stats = argc >= 1; |
Jacob Erlbeck | 91fb680 | 2014-05-28 10:59:10 +0200 | [diff] [blame] | 467 | |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 468 | if (show_stats) |
Holger Hans Peter Freyther | eece6277 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 469 | vty_out_rate_ctr_group(vty, "", g_cfg->ctrg); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 470 | |
Holger Hans Peter Freyther | eece6277 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 471 | llist_for_each_entry(peer, &g_cfg->bts_peers, list) { |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 472 | gbprox_vty_print_peer(vty, peer); |
| 473 | |
| 474 | if (show_stats) |
| 475 | vty_out_rate_ctr_group(vty, " ", peer->ctrg); |
| 476 | } |
| 477 | return CMD_SUCCESS; |
| 478 | } |
| 479 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 480 | DEFUN(show_gbproxy_links, show_gbproxy_links_cmd, "show gbproxy links", |
| 481 | SHOW_STR "Display information about the Gb proxy\n" "Show logical links\n") |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 482 | { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 483 | struct gbproxy_peer *peer; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 484 | char mi_buf[200]; |
Jacob Erlbeck | c6807c4 | 2014-09-19 16:34:01 +0200 | [diff] [blame] | 485 | time_t now; |
| 486 | struct timespec ts = {0,}; |
| 487 | |
| 488 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 489 | now = ts.tv_sec; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 490 | |
Holger Hans Peter Freyther | eece6277 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 491 | llist_for_each_entry(peer, &g_cfg->bts_peers, list) { |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 492 | struct gbproxy_link_info *link_info; |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 493 | struct gbproxy_patch_state *state = &peer->patch_state; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 494 | |
| 495 | gbprox_vty_print_peer(vty, peer); |
| 496 | |
Jacob Erlbeck | f8562e3 | 2014-09-19 16:03:07 +0200 | [diff] [blame] | 497 | llist_for_each_entry(link_info, &state->logical_links, list) { |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 498 | time_t age = now - link_info->timestamp; |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 499 | int stored_msgs = 0; |
| 500 | struct llist_head *iter; |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 501 | llist_for_each(iter, &link_info->stored_msgs) |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 502 | stored_msgs++; |
| 503 | |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 504 | if (link_info->imsi > 0) { |
Jacob Erlbeck | 89d3d34 | 2014-08-06 18:55:15 +0200 | [diff] [blame] | 505 | snprintf(mi_buf, sizeof(mi_buf), "(invalid)"); |
| 506 | gsm48_mi_to_string(mi_buf, sizeof(mi_buf), |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 507 | link_info->imsi, |
| 508 | link_info->imsi_len); |
Jacob Erlbeck | 89d3d34 | 2014-08-06 18:55:15 +0200 | [diff] [blame] | 509 | } else { |
| 510 | snprintf(mi_buf, sizeof(mi_buf), "(none)"); |
| 511 | } |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 512 | vty_out(vty, " TLLI %08x, IMSI %s, AGE %d", |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 513 | link_info->tlli.current, mi_buf, (int)age); |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 514 | |
| 515 | if (stored_msgs) |
| 516 | vty_out(vty, ", STORED %d", stored_msgs); |
| 517 | |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 518 | if (g_cfg->route_to_sgsn2) |
| 519 | vty_out(vty, ", SGSN NSEI %d", |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 520 | link_info->sgsn_nsei); |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 521 | |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 522 | if (link_info->is_deregistered) |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 523 | vty_out(vty, ", DE-REGISTERED"); |
| 524 | |
Jacob Erlbeck | 146e307 | 2014-09-02 14:09:01 +0200 | [diff] [blame] | 525 | vty_out(vty, "%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 526 | } |
| 527 | } |
| 528 | return CMD_SUCCESS; |
| 529 | } |
| 530 | |
| 531 | DEFUN(delete_gb_bvci, delete_gb_bvci_cmd, |
| 532 | "delete-gbproxy-peer <0-65534> bvci <2-65534>", |
| 533 | "Delete a GBProxy peer by NSEI and optionally BVCI\n" |
| 534 | "NSEI number\n" |
| 535 | "Only delete peer with a matching BVCI\n" |
| 536 | "BVCI number\n") |
| 537 | { |
| 538 | const uint16_t nsei = atoi(argv[0]); |
| 539 | const uint16_t bvci = atoi(argv[1]); |
| 540 | int counter; |
| 541 | |
Jacob Erlbeck | 5f1faa3 | 2014-08-21 10:01:30 +0200 | [diff] [blame] | 542 | counter = gbproxy_cleanup_peers(g_cfg, nsei, bvci); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 543 | |
| 544 | if (counter == 0) { |
| 545 | vty_out(vty, "BVC not found%s", VTY_NEWLINE); |
| 546 | return CMD_WARNING; |
| 547 | } |
| 548 | |
| 549 | return CMD_SUCCESS; |
| 550 | } |
| 551 | |
| 552 | DEFUN(delete_gb_nsei, delete_gb_nsei_cmd, |
| 553 | "delete-gbproxy-peer <0-65534> (only-bvc|only-nsvc|all) [dry-run]", |
| 554 | "Delete a GBProxy peer by NSEI and optionally BVCI\n" |
| 555 | "NSEI number\n" |
| 556 | "Only delete BSSGP connections (BVC)\n" |
| 557 | "Only delete dynamic NS connections (NS-VC)\n" |
| 558 | "Delete BVC and dynamic NS connections\n" |
| 559 | "Show what would be deleted instead of actually deleting\n" |
| 560 | ) |
| 561 | { |
| 562 | const uint16_t nsei = atoi(argv[0]); |
| 563 | const char *mode = argv[1]; |
| 564 | int dry_run = argc > 2; |
| 565 | int delete_bvc = 0; |
| 566 | int delete_nsvc = 0; |
| 567 | int counter; |
| 568 | |
| 569 | if (strcmp(mode, "only-bvc") == 0) |
| 570 | delete_bvc = 1; |
| 571 | else if (strcmp(mode, "only-nsvc") == 0) |
| 572 | delete_nsvc = 1; |
| 573 | else |
| 574 | delete_bvc = delete_nsvc = 1; |
| 575 | |
| 576 | if (delete_bvc) { |
| 577 | if (!dry_run) |
Jacob Erlbeck | 5f1faa3 | 2014-08-21 10:01:30 +0200 | [diff] [blame] | 578 | counter = gbproxy_cleanup_peers(g_cfg, nsei, 0); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 579 | else { |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 580 | struct gbproxy_peer *peer; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 581 | counter = 0; |
Holger Hans Peter Freyther | eece6277 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 582 | llist_for_each_entry(peer, &g_cfg->bts_peers, list) { |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 583 | if (peer->nsei != nsei) |
| 584 | continue; |
| 585 | |
| 586 | vty_out(vty, "BVC: "); |
| 587 | gbprox_vty_print_peer(vty, peer); |
| 588 | counter += 1; |
| 589 | } |
| 590 | } |
| 591 | vty_out(vty, "%sDeleted %d BVC%s", |
| 592 | dry_run ? "Not " : "", counter, VTY_NEWLINE); |
| 593 | } |
| 594 | |
| 595 | if (delete_nsvc) { |
Holger Hans Peter Freyther | eece6277 | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 596 | struct gprs_ns_inst *nsi = g_cfg->nsi; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 597 | struct gprs_nsvc *nsvc, *nsvc2; |
| 598 | |
| 599 | counter = 0; |
| 600 | llist_for_each_entry_safe(nsvc, nsvc2, &nsi->gprs_nsvcs, list) { |
| 601 | if (nsvc->nsei != nsei) |
| 602 | continue; |
| 603 | if (nsvc->persistent) |
| 604 | continue; |
| 605 | |
| 606 | if (!dry_run) |
| 607 | gprs_nsvc_delete(nsvc); |
| 608 | else |
| 609 | vty_out(vty, "NS-VC: NSEI %5u, NS-VCI %5u, " |
| 610 | "remote %s%s", |
| 611 | nsvc->nsei, nsvc->nsvci, |
| 612 | gprs_ns_ll_str(nsvc), VTY_NEWLINE); |
| 613 | counter += 1; |
| 614 | } |
| 615 | vty_out(vty, "%sDeleted %d NS-VC%s", |
| 616 | dry_run ? "Not " : "", counter, VTY_NEWLINE); |
| 617 | } |
| 618 | |
| 619 | return CMD_SUCCESS; |
| 620 | } |
| 621 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 622 | #define GBPROXY_DELETE_LINK_STR \ |
| 623 | "Delete a GBProxy logical link entry by NSEI and identification\nNSEI number\n" |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 624 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 625 | DEFUN(delete_gb_link_by_id, delete_gb_link_by_id_cmd, |
| 626 | "delete-gbproxy-link <0-65534> (tlli|imsi|sgsn-nsei) IDENT", |
| 627 | GBPROXY_DELETE_LINK_STR |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 628 | "Delete entries with a matching TLLI (hex)\n" |
| 629 | "Delete entries with a matching IMSI\n" |
Jacob Erlbeck | de74e72 | 2014-10-28 11:29:43 +0100 | [diff] [blame] | 630 | "Delete entries with a matching SGSN NSEI\n" |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 631 | "Identification to match\n") |
| 632 | { |
| 633 | const uint16_t nsei = atoi(argv[0]); |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 634 | enum {MATCH_TLLI = 't', MATCH_IMSI = 'i', MATCH_SGSN = 's'} match; |
| 635 | uint32_t ident = 0; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 636 | const char *imsi = NULL; |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 637 | struct gbproxy_peer *peer = 0; |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 638 | struct gbproxy_link_info *link_info, *nxt; |
Holger Hans Peter Freyther | 1ddd9e5 | 2014-08-04 11:35:32 +0200 | [diff] [blame] | 639 | struct gbproxy_patch_state *state; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 640 | char mi_buf[200]; |
| 641 | int found = 0; |
| 642 | |
| 643 | match = argv[1][0]; |
| 644 | |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 645 | switch (match) { |
| 646 | case MATCH_TLLI: ident = strtoll(argv[2], NULL, 16); break; |
| 647 | case MATCH_IMSI: imsi = argv[2]; break; |
| 648 | case MATCH_SGSN: ident = strtoll(argv[2], NULL, 0); break; |
| 649 | }; |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 650 | |
| 651 | peer = gbproxy_peer_by_nsei(g_cfg, nsei); |
| 652 | if (!peer) { |
| 653 | vty_out(vty, "Didn't find peer with NSEI %d%s", |
| 654 | nsei, VTY_NEWLINE); |
| 655 | return CMD_WARNING; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 656 | } |
| 657 | |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 658 | state = &peer->patch_state; |
| 659 | |
Jacob Erlbeck | f8562e3 | 2014-09-19 16:03:07 +0200 | [diff] [blame] | 660 | llist_for_each_entry_safe(link_info, nxt, &state->logical_links, list) { |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 661 | switch (match) { |
| 662 | case MATCH_TLLI: |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 663 | if (link_info->tlli.current != ident) |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 664 | continue; |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 665 | break; |
| 666 | case MATCH_SGSN: |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 667 | if (link_info->sgsn_nsei != ident) |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 668 | continue; |
| 669 | break; |
| 670 | case MATCH_IMSI: |
Jacob Erlbeck | 6a1d428 | 2014-10-20 17:22:36 +0200 | [diff] [blame] | 671 | if (!link_info->imsi) |
| 672 | continue; |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 673 | mi_buf[0] = '\0'; |
| 674 | gsm48_mi_to_string(mi_buf, sizeof(mi_buf), |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 675 | link_info->imsi, |
| 676 | link_info->imsi_len); |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 677 | |
| 678 | if (strcmp(mi_buf, imsi) != 0) |
| 679 | continue; |
Jacob Erlbeck | 91a0e86 | 2014-09-17 10:56:38 +0200 | [diff] [blame] | 680 | break; |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 681 | } |
| 682 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 683 | vty_out(vty, "Deleting link with TLLI %08x%s", link_info->tlli.current, |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 684 | VTY_NEWLINE); |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 685 | gbproxy_delete_link_info(peer, link_info); |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 686 | found += 1; |
| 687 | } |
| 688 | |
| 689 | if (!found && argc >= 2) { |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 690 | vty_out(vty, "Didn't find link entry with %s %s%s", |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 691 | argv[1], argv[2], VTY_NEWLINE); |
| 692 | } |
| 693 | |
| 694 | return CMD_SUCCESS; |
| 695 | } |
| 696 | |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 697 | DEFUN(delete_gb_link, delete_gb_link_cmd, |
| 698 | "delete-gbproxy-link <0-65534> (stale|de-registered)", |
| 699 | GBPROXY_DELETE_LINK_STR |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 700 | "Delete stale entries\n" |
| 701 | "Delete de-registered entries\n") |
| 702 | { |
| 703 | const uint16_t nsei = atoi(argv[0]); |
| 704 | enum {MATCH_STALE = 's', MATCH_DEREGISTERED = 'd'} match; |
| 705 | struct gbproxy_peer *peer = 0; |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 706 | struct gbproxy_link_info *link_info, *nxt; |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 707 | struct gbproxy_patch_state *state; |
Jacob Erlbeck | c6807c4 | 2014-09-19 16:34:01 +0200 | [diff] [blame] | 708 | time_t now; |
| 709 | struct timespec ts = {0,}; |
| 710 | |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 711 | int found = 0; |
| 712 | |
| 713 | match = argv[1][0]; |
| 714 | |
Jacob Erlbeck | 5f1faa3 | 2014-08-21 10:01:30 +0200 | [diff] [blame] | 715 | peer = gbproxy_peer_by_nsei(g_cfg, nsei); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 716 | if (!peer) { |
| 717 | vty_out(vty, "Didn't find peer with NSEI %d%s", |
| 718 | nsei, VTY_NEWLINE); |
| 719 | return CMD_WARNING; |
| 720 | } |
| 721 | |
| 722 | state = &peer->patch_state; |
| 723 | |
Jacob Erlbeck | c6807c4 | 2014-09-19 16:34:01 +0200 | [diff] [blame] | 724 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 725 | now = ts.tv_sec; |
| 726 | |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 727 | if (match == MATCH_STALE) { |
Jacob Erlbeck | c6807c4 | 2014-09-19 16:34:01 +0200 | [diff] [blame] | 728 | found = gbproxy_remove_stale_link_infos(peer, now); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 729 | if (found) |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 730 | vty_out(vty, "Deleted %d stale logical link%s%s", |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 731 | found, found == 1 ? "" : "s", VTY_NEWLINE); |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 732 | } else { |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 733 | llist_for_each_entry_safe(link_info, nxt, |
Jacob Erlbeck | f8562e3 | 2014-09-19 16:03:07 +0200 | [diff] [blame] | 734 | &state->logical_links, list) { |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 735 | if (!link_info->is_deregistered) |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 736 | continue; |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 737 | |
Jacob Erlbeck | 91d2f8a | 2014-09-19 15:07:27 +0200 | [diff] [blame] | 738 | gbproxy_delete_link_info(peer, link_info); |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 739 | found += 1; |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 740 | } |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 741 | } |
| 742 | |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 743 | if (found) |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 744 | vty_out(vty, "Deleted %d %s logical link%s%s", |
Jacob Erlbeck | cdd3783 | 2014-09-16 08:56:26 +0200 | [diff] [blame] | 745 | found, argv[1], found == 1 ? "" : "s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 18739ea | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 746 | |
| 747 | return CMD_SUCCESS; |
| 748 | } |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 749 | |
Holger Hans Peter Freyther | 925504b | 2015-09-24 10:21:40 +0200 | [diff] [blame] | 750 | /* |
| 751 | * legacy commands to provide an upgrade path from "broken" releases |
| 752 | * or pre-releases |
| 753 | */ |
| 754 | DEFUN_DEPRECATED(cfg_gbproxy_broken_apn_match, |
| 755 | cfg_gbproxy_broken_apn_match_cmd, |
| 756 | "core-access-point-name none match-imsi .REGEXP", |
| 757 | GBPROXY_CORE_APN_STR GBPROXY_MATCH_IMSI_STR "Remove APN\n" |
| 758 | "Patch MS related information elements on match only\n" |
| 759 | "Route to the secondary SGSN on match only\n" |
| 760 | "Regular expression for the IMSI match\n") |
| 761 | { |
| 762 | const char *filter = argv[0]; |
| 763 | const char *err_msg = NULL; |
| 764 | struct gbproxy_match *match; |
| 765 | enum gbproxy_match_id match_id = get_string_value(match_ids, "patching"); |
| 766 | |
| 767 | /* apply APN none */ |
| 768 | set_core_apn(vty, ""); |
| 769 | |
| 770 | /* do the matching... with copy and paste */ |
| 771 | OSMO_ASSERT(match_id >= GBPROX_MATCH_PATCHING && |
| 772 | match_id < GBPROX_MATCH_LAST); |
| 773 | match = &g_cfg->matches[match_id]; |
| 774 | |
| 775 | if (gbproxy_set_patch_filter(match, filter, &err_msg) != 0) { |
| 776 | vty_out(vty, "Match expression invalid: %s%s", |
| 777 | err_msg, VTY_NEWLINE); |
| 778 | return CMD_WARNING; |
| 779 | } |
| 780 | |
| 781 | g_cfg->acquire_imsi = 1; |
| 782 | |
| 783 | return CMD_SUCCESS; |
| 784 | } |
| 785 | |
| 786 | #define GBPROXY_TLLI_LIST_STR "Set TLLI list parameters\n" |
| 787 | #define GBPROXY_MAX_LEN_STR "Limit list length\n" |
| 788 | DEFUN_DEPRECATED(cfg_gbproxy_depr_tlli_list_max_len, |
| 789 | cfg_gbproxy_depr_tlli_list_max_len_cmd, |
| 790 | "tlli-list max-length <1-99999>", |
| 791 | GBPROXY_TLLI_LIST_STR GBPROXY_MAX_LEN_STR |
| 792 | "Maximum number of TLLIs in the list\n") |
| 793 | { |
| 794 | g_cfg->tlli_max_len = atoi(argv[0]); |
| 795 | |
| 796 | return CMD_SUCCESS; |
| 797 | } |
| 798 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 799 | int gbproxy_vty_init(void) |
| 800 | { |
Harald Welte | 995a2d3 | 2010-05-12 16:50:52 +0000 | [diff] [blame] | 801 | install_element_ve(&show_gbproxy_cmd); |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 802 | install_element_ve(&show_gbproxy_links_cmd); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 803 | |
Jacob Erlbeck | 4211d79 | 2013-10-24 12:48:23 +0200 | [diff] [blame] | 804 | install_element(ENABLE_NODE, &delete_gb_bvci_cmd); |
| 805 | install_element(ENABLE_NODE, &delete_gb_nsei_cmd); |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 806 | install_element(ENABLE_NODE, &delete_gb_link_by_id_cmd); |
| 807 | install_element(ENABLE_NODE, &delete_gb_link_cmd); |
Holger Hans Peter Freyther | 90267a9 | 2013-10-23 11:24:17 +0200 | [diff] [blame] | 808 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 809 | install_element(CONFIG_NODE, &cfg_gbproxy_cmd); |
| 810 | install_node(&gbproxy_node, config_write_gbproxy); |
Jacob Erlbeck | 36722e1 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 811 | vty_install_default(GBPROXY_NODE); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 812 | install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd); |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 813 | install_element(GBPROXY_NODE, &cfg_gbproxy_core_mcc_cmd); |
| 814 | install_element(GBPROXY_NODE, &cfg_gbproxy_core_mnc_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 815 | install_element(GBPROXY_NODE, &cfg_gbproxy_match_imsi_cmd); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 816 | install_element(GBPROXY_NODE, &cfg_gbproxy_core_apn_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 817 | install_element(GBPROXY_NODE, &cfg_gbproxy_secondary_sgsn_cmd); |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 818 | install_element(GBPROXY_NODE, &cfg_gbproxy_patch_ptmsi_cmd); |
Jacob Erlbeck | 5f4ef32 | 2014-08-22 17:10:01 +0200 | [diff] [blame] | 819 | install_element(GBPROXY_NODE, &cfg_gbproxy_acquire_imsi_cmd); |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 820 | install_element(GBPROXY_NODE, &cfg_gbproxy_link_list_max_age_cmd); |
| 821 | install_element(GBPROXY_NODE, &cfg_gbproxy_link_list_max_len_cmd); |
| 822 | install_element(GBPROXY_NODE, &cfg_gbproxy_link_list_keep_mode_cmd); |
Jacob Erlbeck | 67a4445 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 823 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_core_mcc_cmd); |
| 824 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_core_mnc_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 825 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_match_imsi_cmd); |
Jacob Erlbeck | 7368528 | 2014-05-23 20:48:07 +0200 | [diff] [blame] | 826 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_core_apn_cmd); |
Jacob Erlbeck | cd9e1c9 | 2014-09-02 13:57:19 +0200 | [diff] [blame] | 827 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_secondary_sgsn_cmd); |
Jacob Erlbeck | 0d4236b | 2014-08-18 14:54:37 +0200 | [diff] [blame] | 828 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_patch_ptmsi_cmd); |
Jacob Erlbeck | 5f4ef32 | 2014-08-22 17:10:01 +0200 | [diff] [blame] | 829 | install_element(GBPROXY_NODE, &cfg_gbproxy_no_acquire_imsi_cmd); |
Jacob Erlbeck | d4c79a4 | 2014-09-19 15:36:44 +0200 | [diff] [blame] | 830 | install_element(GBPROXY_NODE, &cfg_gbproxy_link_list_no_max_age_cmd); |
| 831 | install_element(GBPROXY_NODE, &cfg_gbproxy_link_list_no_max_len_cmd); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 832 | |
Holger Hans Peter Freyther | 925504b | 2015-09-24 10:21:40 +0200 | [diff] [blame] | 833 | /* broken or deprecated to allow an upgrade path */ |
| 834 | install_element(GBPROXY_NODE, &cfg_gbproxy_broken_apn_match_cmd); |
| 835 | install_element(GBPROXY_NODE, &cfg_gbproxy_depr_tlli_list_max_len_cmd); |
| 836 | |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | int gbproxy_parse_config(const char *config_file, struct gbproxy_config *cfg) |
| 841 | { |
| 842 | int rc; |
| 843 | |
| 844 | g_cfg = cfg; |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 845 | rc = vty_read_config_file(config_file, NULL); |
Harald Welte | 799e0c9 | 2010-04-30 21:49:24 +0200 | [diff] [blame] | 846 | if (rc < 0) { |
| 847 | fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); |
| 848 | return rc; |
| 849 | } |
| 850 | |
| 851 | return 0; |
| 852 | } |
| 853 | |