Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1 | /* OpenBSC NAT interface to quagga VTY */ |
| 2 | /* (C) 2010 by Holger Hans Peter Freyther |
| 3 | * (C) 2010 by On-Waves |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <vty/command.h> |
| 23 | #include <vty/buffer.h> |
| 24 | #include <vty/vty.h> |
| 25 | |
| 26 | #include <openbsc/bsc_nat.h> |
| 27 | #include <openbsc/gsm_04_08.h> |
Holger Hans Peter Freyther | 3660e4d | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 28 | #include <openbsc/mgcp.h> |
Holger Hans Peter Freyther | b372fad | 2010-04-06 12:01:15 +0200 | [diff] [blame] | 29 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | 3b96089 | 2010-06-15 19:06:18 +0800 | [diff] [blame] | 30 | |
| 31 | #include <osmocore/talloc.h> |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 32 | |
| 33 | #include <sccp/sccp.h> |
| 34 | |
| 35 | #include <stdlib.h> |
| 36 | |
| 37 | static struct bsc_nat *_nat; |
| 38 | |
| 39 | static struct cmd_node nat_node = { |
| 40 | NAT_NODE, |
| 41 | "%s(nat)#", |
| 42 | 1, |
| 43 | }; |
| 44 | |
| 45 | static struct cmd_node bsc_node = { |
| 46 | BSC_NODE, |
| 47 | "%s(bsc)#", |
| 48 | 1, |
| 49 | }; |
| 50 | |
| 51 | static int config_write_nat(struct vty *vty) |
| 52 | { |
| 53 | vty_out(vty, "nat%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 54 | if (_nat->imsi_allow) |
| 55 | vty_out(vty, " imsi allow %s%s", _nat->imsi_allow, VTY_NEWLINE); |
| 56 | if (_nat->imsi_deny) |
| 57 | vty_out(vty, " insi deny %s%s", _nat->imsi_deny, VTY_NEWLINE); |
Holger Hans Peter Freyther | 9226d70 | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 58 | vty_out(vty, " msc ip %s%s", _nat->msc_ip, VTY_NEWLINE); |
Holger Hans Peter Freyther | bace202 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 59 | vty_out(vty, " msc port %d%s", _nat->msc_port, VTY_NEWLINE); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 60 | return CMD_SUCCESS; |
| 61 | } |
| 62 | |
| 63 | static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc) |
| 64 | { |
| 65 | vty_out(vty, " bsc %u%s", bsc->nr, VTY_NEWLINE); |
| 66 | vty_out(vty, " token %s%s", bsc->token, VTY_NEWLINE); |
Holger Hans Peter Freyther | 085ea30 | 2010-04-16 16:52:20 +0200 | [diff] [blame] | 67 | vty_out(vty, " location_area_code %u%s", bsc->lac, VTY_NEWLINE); |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 68 | if (bsc->imsi_allow) |
| 69 | vty_out(vty, " imsi allow %s%s", bsc->imsi_allow, VTY_NEWLINE); |
| 70 | if (bsc->imsi_deny) |
| 71 | vty_out(vty, " imsi deny %s%s", bsc->imsi_deny, VTY_NEWLINE); |
Holger Hans Peter Freyther | 7acf462 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 72 | vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static int config_write_bsc(struct vty *vty) |
| 76 | { |
| 77 | struct bsc_config *bsc; |
| 78 | |
| 79 | llist_for_each_entry(bsc, &_nat->bsc_configs, entry) |
| 80 | config_write_bsc_single(vty, bsc); |
| 81 | return CMD_SUCCESS; |
| 82 | } |
| 83 | |
| 84 | |
Holger Hans Peter Freyther | 17f8c95 | 2010-04-19 16:06:43 +0800 | [diff] [blame] | 85 | DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", |
| 86 | SHOW_STR "Display information about current SCCP connections") |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 87 | { |
| 88 | struct sccp_connections *con; |
Holger Hans Peter Freyther | dbdd30f | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 89 | vty_out(vty, "Listing all opening SCCP connections%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 0a3a853 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 90 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 91 | llist_for_each_entry(con, &_nat->sccp_connections, list_entry) { |
Holger Hans Peter Freyther | 0a3a853 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 92 | vty_out(vty, "For BSC Nr: %d lac: %d; BSC ref: 0x%x; MUX ref: 0x%x; Network has ref: %d ref: 0x%x MSC/BSC mux: 0x%x/0x%x%s", |
Holger Hans Peter Freyther | bfcf519 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 93 | con->bsc->cfg ? con->bsc->cfg->nr : -1, |
| 94 | con->bsc->cfg ? con->bsc->cfg->lac : -1, |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 95 | sccp_src_ref_to_int(&con->real_ref), |
Holger Hans Peter Freyther | 32aba23 | 2010-04-05 10:10:33 +0200 | [diff] [blame] | 96 | sccp_src_ref_to_int(&con->patched_ref), |
Holger Hans Peter Freyther | 0a3a853 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 97 | con->has_remote_ref, |
| 98 | sccp_src_ref_to_int(&con->remote_ref), |
Holger Hans Peter Freyther | 32aba23 | 2010-04-05 10:10:33 +0200 | [diff] [blame] | 99 | con->msc_timeslot, con->bsc_timeslot, |
| 100 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | return CMD_SUCCESS; |
| 104 | } |
| 105 | |
Holger Hans Peter Freyther | 17f8c95 | 2010-04-19 16:06:43 +0800 | [diff] [blame] | 106 | DEFUN(show_bsc, show_bsc_cmd, "show bsc connections", |
| 107 | SHOW_STR "Display information about current BSCs") |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 108 | { |
| 109 | struct bsc_connection *con; |
Holger Hans Peter Freyther | 9e53e97 | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 110 | struct sockaddr_in sock; |
| 111 | socklen_t len = sizeof(sock); |
| 112 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 113 | llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { |
Holger Hans Peter Freyther | 9e53e97 | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 114 | getpeername(con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len); |
Holger Hans Peter Freyther | ffc051f | 2010-05-01 15:32:32 +0800 | [diff] [blame] | 115 | vty_out(vty, "BSC nr: %d lac: %d auth: %d fd: %d peername: %s%s", |
Holger Hans Peter Freyther | bfcf519 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 116 | con->cfg ? con->cfg->nr : -1, |
| 117 | con->cfg ? con->cfg->lac : -1, |
Holger Hans Peter Freyther | 9e53e97 | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 118 | con->authenticated, con->write_queue.bfd.fd, |
| 119 | inet_ntoa(sock.sin_addr), VTY_NEWLINE); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | return CMD_SUCCESS; |
| 123 | } |
| 124 | |
Holger Hans Peter Freyther | 936aed7 | 2010-04-22 13:36:46 +0800 | [diff] [blame] | 125 | DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config", |
| 126 | SHOW_STR "Display information about known BSC configs") |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 127 | { |
| 128 | struct bsc_config *conf; |
| 129 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
| 130 | vty_out(vty, "BSC token: '%s' lac: %u nr: %u%s", |
| 131 | conf->token, conf->lac, conf->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 132 | vty_out(vty, " imsi_allow: '%s' imsi_deny: '%s'%s", |
| 133 | conf->imsi_allow ? conf->imsi_allow: "any", |
| 134 | conf->imsi_deny ? conf->imsi_deny : "none", |
| 135 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 7acf462 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 136 | vty_out(vty, " paging forbidden: %d%s", |
| 137 | conf->forbid_paging, VTY_NEWLINE); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | return CMD_SUCCESS; |
| 141 | } |
| 142 | |
Holger Hans Peter Freyther | 02e1c7d | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 143 | DEFUN(show_stats, |
| 144 | show_stats_cmd, |
Holger Hans Peter Freyther | 44d534c | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 145 | "show statistics [NR]", |
Holger Hans Peter Freyther | dbdd30f | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 146 | SHOW_STR "Display network statistics") |
Holger Hans Peter Freyther | 02e1c7d | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 147 | { |
| 148 | struct bsc_config *conf; |
| 149 | |
Holger Hans Peter Freyther | 44d534c | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 150 | int nr = -1; |
| 151 | |
| 152 | if (argc == 1) |
| 153 | nr = atoi(argv[0]); |
| 154 | |
Holger Hans Peter Freyther | 02e1c7d | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 155 | vty_out(vty, "NAT statistics%s", VTY_NEWLINE); |
| 156 | vty_out(vty, " SCCP Connections %lu total, %lu calls%s", |
| 157 | counter_get(_nat->stats.sccp.conn), |
| 158 | counter_get(_nat->stats.sccp.calls), VTY_NEWLINE); |
| 159 | vty_out(vty, " MSC Connections %lu%s", |
| 160 | counter_get(_nat->stats.msc.reconn), VTY_NEWLINE); |
| 161 | vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s", |
| 162 | counter_get(_nat->stats.bsc.reconn), |
| 163 | counter_get(_nat->stats.bsc.auth_fail), VTY_NEWLINE); |
| 164 | |
| 165 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 44d534c | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 166 | if (argc == 1 && nr != conf->nr) |
| 167 | continue; |
| 168 | |
Holger Hans Peter Freyther | 02e1c7d | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 169 | vty_out(vty, " BSC lac: %d nr: %d%s", |
| 170 | conf->lac, conf->nr, VTY_NEWLINE); |
| 171 | vty_out(vty, " SCCP Connnections %lu total, %lu calls%s", |
| 172 | counter_get(conf->stats.sccp.conn), |
| 173 | counter_get(conf->stats.sccp.calls), VTY_NEWLINE); |
| 174 | vty_out(vty, " BSC Connections %lu total%s", |
| 175 | counter_get(conf->stats.net.reconn), VTY_NEWLINE); |
| 176 | } |
| 177 | |
| 178 | return CMD_SUCCESS; |
| 179 | } |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 180 | |
Holger Hans Peter Freyther | 1512dc2 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 181 | DEFUN(close_bsc, |
| 182 | close_bsc_cmd, |
| 183 | "close bsc connection BSC_NR", |
Holger Hans Peter Freyther | dbdd30f | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 184 | "Close the connection with the BSC identified by the config number.") |
Holger Hans Peter Freyther | 1512dc2 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 185 | { |
| 186 | struct bsc_connection *bsc; |
| 187 | int bsc_nr = atoi(argv[0]); |
| 188 | |
| 189 | llist_for_each_entry(bsc, &_nat->bsc_connections, list_entry) { |
| 190 | if (!bsc->cfg || bsc->cfg->nr != bsc_nr) |
| 191 | continue; |
| 192 | bsc_close_connection(bsc); |
| 193 | break; |
| 194 | } |
| 195 | |
| 196 | return CMD_SUCCESS; |
| 197 | } |
| 198 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 199 | DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT") |
| 200 | { |
| 201 | vty->index = _nat; |
| 202 | vty->node = NAT_NODE; |
| 203 | |
| 204 | return CMD_SUCCESS; |
| 205 | } |
| 206 | |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 207 | static void parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv) |
| 208 | { |
| 209 | if (*imsi) { |
| 210 | talloc_free(*imsi); |
| 211 | *imsi = NULL; |
| 212 | } |
| 213 | regfree(reg); |
| 214 | |
| 215 | if (argc > 0) { |
| 216 | *imsi = talloc_strdup(ctx, argv[0]); |
| 217 | regcomp(reg, argv[0], 0); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | DEFUN(cfg_nat_imsi_allow, |
| 222 | cfg_nat_imsi_allow_cmd, |
| 223 | "imsi allow [REGEXP]", |
| 224 | "Allow matching IMSIs to talk to the MSC. " |
| 225 | "The defualt is to allow everyone.") |
| 226 | { |
| 227 | parse_reg(_nat, &_nat->imsi_allow_re, &_nat->imsi_allow, argc, argv); |
| 228 | return CMD_SUCCESS; |
| 229 | } |
| 230 | |
| 231 | DEFUN(cfg_nat_imsi_deny, |
| 232 | cfg_nat_imsi_deny_cmd, |
| 233 | "imsi deny [REGEXP]", |
| 234 | "Deny matching IMSIs to talk to the MSC. " |
| 235 | "The defualt is to not deny.") |
| 236 | { |
| 237 | parse_reg(_nat, &_nat->imsi_deny_re, &_nat->imsi_deny, argc, argv); |
| 238 | return CMD_SUCCESS; |
| 239 | } |
| 240 | |
Holger Hans Peter Freyther | 9226d70 | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 241 | DEFUN(cfg_nat_msc_ip, |
| 242 | cfg_nat_msc_ip_cmd, |
| 243 | "msc ip IP", |
| 244 | "Set the IP address of the MSC.") |
| 245 | { |
| 246 | bsc_nat_set_msc_ip(_nat, argv[0]); |
| 247 | return CMD_SUCCESS; |
| 248 | } |
| 249 | |
Holger Hans Peter Freyther | bace202 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 250 | DEFUN(cfg_nat_msc_port, |
| 251 | cfg_nat_msc_port_cmd, |
| 252 | "msc port <1-65500>", |
| 253 | "Set the port of the MSC.") |
| 254 | { |
| 255 | _nat->msc_port = atoi(argv[0]); |
| 256 | return CMD_SUCCESS; |
| 257 | } |
| 258 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 259 | /* per BSC configuration */ |
Holger Hans Peter Freyther | dbdd30f | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 260 | DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure") |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 261 | { |
| 262 | int bsc_nr = atoi(argv[0]); |
| 263 | struct bsc_config *bsc; |
| 264 | |
| 265 | if (bsc_nr > _nat->num_bsc) { |
| 266 | vty_out(vty, "%% The next unused BSC number is %u%s", |
| 267 | _nat->num_bsc, VTY_NEWLINE); |
| 268 | return CMD_WARNING; |
| 269 | } else if (bsc_nr == _nat->num_bsc) { |
| 270 | /* allocate a new one */ |
| 271 | bsc = bsc_config_alloc(_nat, "unknown", 0); |
| 272 | } else |
| 273 | bsc = bsc_config_num(_nat, bsc_nr); |
| 274 | |
| 275 | if (!bsc) |
| 276 | return CMD_WARNING; |
| 277 | |
| 278 | vty->index = bsc; |
| 279 | vty->node = BSC_NODE; |
| 280 | |
| 281 | return CMD_SUCCESS; |
| 282 | } |
| 283 | |
| 284 | DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token") |
| 285 | { |
| 286 | struct bsc_config *conf = vty->index; |
| 287 | |
| 288 | if (conf->token) |
| 289 | talloc_free(conf->token); |
| 290 | conf->token = talloc_strdup(conf, argv[0]); |
| 291 | return CMD_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>", |
Holger Hans Peter Freyther | dbdd30f | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 295 | "Set the Location Area Code (LAC) of this BSC") |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 296 | { |
Holger Hans Peter Freyther | 435a5c1 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 297 | struct bsc_config *tmp; |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 298 | struct bsc_config *conf = vty->index; |
| 299 | |
| 300 | int lac = atoi(argv[0]); |
| 301 | |
| 302 | if (lac < 0 || lac > 0xffff) { |
| 303 | vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s", |
| 304 | lac, VTY_NEWLINE); |
| 305 | return CMD_WARNING; |
| 306 | } |
| 307 | |
| 308 | if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { |
| 309 | vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s", |
| 310 | lac, VTY_NEWLINE); |
| 311 | return CMD_WARNING; |
| 312 | } |
| 313 | |
Holger Hans Peter Freyther | 435a5c1 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 314 | /* verify that the LACs are unique */ |
| 315 | llist_for_each_entry(tmp, &_nat->bsc_configs, entry) { |
| 316 | if (tmp->lac == lac) { |
| 317 | vty_out(vty, "%% LAC %d is already used.%s", lac, VTY_NEWLINE); |
| 318 | return CMD_ERR_INCOMPLETE; |
| 319 | } |
| 320 | } |
| 321 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 322 | conf->lac = lac; |
| 323 | |
| 324 | return CMD_SUCCESS; |
| 325 | } |
| 326 | |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 327 | DEFUN(cfg_bsc_imsi_allow, |
| 328 | cfg_bsc_imsi_allow_cmd, |
| 329 | "imsi allow [REGEXP]", |
| 330 | "Allow IMSIs with the following network to talk to the MSC." |
| 331 | "The default is to allow everyone)") |
| 332 | { |
| 333 | struct bsc_config *conf = vty->index; |
| 334 | |
| 335 | parse_reg(conf, &conf->imsi_allow_re, &conf->imsi_allow, argc, argv); |
| 336 | return CMD_SUCCESS; |
| 337 | } |
| 338 | |
| 339 | DEFUN(cfg_bsc_imsi_deny, |
| 340 | cfg_bsc_imsi_deny_cmd, |
| 341 | "imsi deny [REGEXP]", |
| 342 | "Deny IMSIs with the following network to talk to the MSC." |
| 343 | "The default is to not deny anyone.)") |
| 344 | { |
| 345 | struct bsc_config *conf = vty->index; |
| 346 | |
| 347 | parse_reg(conf, &conf->imsi_deny_re, &conf->imsi_deny, argc, argv); |
| 348 | return CMD_SUCCESS; |
| 349 | } |
| 350 | |
Holger Hans Peter Freyther | 7acf462 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 351 | DEFUN(cfg_bsc_paging, |
| 352 | cfg_bsc_paging_cmd, |
| 353 | "paging forbidden (0|1)", |
| 354 | "Forbid sending PAGING REQUESTS to the BSC.") |
| 355 | { |
| 356 | struct bsc_config *conf = vty->index; |
| 357 | |
Holger Hans Peter Freyther | e6ac5de | 2010-04-21 20:07:07 +0800 | [diff] [blame] | 358 | if (strcmp("1", argv[0]) == 0) |
Holger Hans Peter Freyther | 7acf462 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 359 | conf->forbid_paging = 1; |
| 360 | else |
| 361 | conf->forbid_paging = 0; |
| 362 | |
| 363 | return CMD_SUCCESS; |
| 364 | } |
| 365 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 366 | int bsc_nat_vty_init(struct bsc_nat *nat) |
| 367 | { |
| 368 | _nat = nat; |
| 369 | |
| 370 | cmd_init(1); |
| 371 | vty_init(); |
| 372 | |
| 373 | /* show commands */ |
| 374 | install_element(VIEW_NODE, &show_sccp_cmd); |
| 375 | install_element(VIEW_NODE, &show_bsc_cmd); |
| 376 | install_element(VIEW_NODE, &show_bsc_cfg_cmd); |
Holger Hans Peter Freyther | 02e1c7d | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 377 | install_element(VIEW_NODE, &show_stats_cmd); |
Holger Hans Peter Freyther | 1512dc2 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 378 | install_element(VIEW_NODE, &close_bsc_cmd); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 379 | |
Holger Hans Peter Freyther | b372fad | 2010-04-06 12:01:15 +0200 | [diff] [blame] | 380 | openbsc_vty_add_cmds(); |
| 381 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 382 | /* nat group */ |
| 383 | install_element(CONFIG_NODE, &cfg_nat_cmd); |
| 384 | install_node(&nat_node, config_write_nat); |
| 385 | install_default(NAT_NODE); |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 386 | install_element(NAT_NODE, &cfg_nat_imsi_allow_cmd); |
| 387 | install_element(NAT_NODE, &cfg_nat_imsi_deny_cmd); |
Holger Hans Peter Freyther | 9226d70 | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 388 | install_element(NAT_NODE, &cfg_nat_msc_ip_cmd); |
Holger Hans Peter Freyther | bace202 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 389 | install_element(NAT_NODE, &cfg_nat_msc_port_cmd); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 390 | |
| 391 | /* BSC subgroups */ |
| 392 | install_element(NAT_NODE, &cfg_bsc_cmd); |
| 393 | install_node(&bsc_node, config_write_bsc); |
| 394 | install_default(BSC_NODE); |
| 395 | install_element(BSC_NODE, &cfg_bsc_token_cmd); |
| 396 | install_element(BSC_NODE, &cfg_bsc_lac_cmd); |
Holger Hans Peter Freyther | 4b6da56 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 397 | install_element(BSC_NODE, &cfg_bsc_imsi_allow_cmd); |
| 398 | install_element(BSC_NODE, &cfg_bsc_imsi_deny_cmd); |
Holger Hans Peter Freyther | 7acf462 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 399 | install_element(BSC_NODE, &cfg_bsc_paging_cmd); |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 400 | |
Holger Hans Peter Freyther | 3660e4d | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 401 | mgcp_vty_init(); |
| 402 | |
Holger Hans Peter Freyther | 5e54788 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 403 | return 0; |
| 404 | } |
| 405 | |
| 406 | |
| 407 | /* called by the telnet interface... we have our own init above */ |
| 408 | void bsc_vty_init() |
| 409 | {} |