Holger Hans Peter Freyther | 9a85ef3 | 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 | |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 22 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 23 | #include <openbsc/bsc_nat.h> |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 24 | #include <openbsc/bsc_nat_sccp.h> |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 25 | #include <openbsc/bsc_msc.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 26 | #include <openbsc/gsm_04_08.h> |
Holger Hans Peter Freyther | f7d3335 | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 27 | #include <openbsc/mgcp.h> |
Holger Hans Peter Freyther | 5f291d5 | 2010-04-06 12:01:15 +0200 | [diff] [blame] | 28 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | 6c45f2e | 2010-06-15 19:06:18 +0800 | [diff] [blame] | 29 | |
| 30 | #include <osmocore/talloc.h> |
Holger Hans Peter Freyther | b2c38eb | 2010-06-17 18:16:00 +0800 | [diff] [blame] | 31 | #include <osmocore/rate_ctr.h> |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 32 | #include <osmocore/utils.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 33 | |
Harald Welte | d5db12c | 2010-08-03 15:11:51 +0200 | [diff] [blame] | 34 | #include <osmocom/sccp/sccp.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 35 | |
| 36 | #include <stdlib.h> |
| 37 | |
| 38 | static struct bsc_nat *_nat; |
| 39 | |
| 40 | static struct cmd_node nat_node = { |
| 41 | NAT_NODE, |
| 42 | "%s(nat)#", |
| 43 | 1, |
| 44 | }; |
| 45 | |
| 46 | static struct cmd_node bsc_node = { |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 47 | NAT_BSC_NODE, |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 48 | "%s(bsc)#", |
| 49 | 1, |
| 50 | }; |
| 51 | |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 52 | static void write_acc_lst(struct vty *vty, struct bsc_nat_acc_lst *lst) |
| 53 | { |
| 54 | struct bsc_nat_acc_lst_entry *entry; |
| 55 | |
| 56 | llist_for_each_entry(entry, &lst->fltr_list, list) { |
| 57 | if (entry->imsi_allow) |
| 58 | vty_out(vty, " access-list %s imsi-allow %s%s", |
| 59 | lst->name, entry->imsi_allow, VTY_NEWLINE); |
| 60 | if (entry->imsi_deny) |
| 61 | vty_out(vty, " access-list %s imsi-deny %s%s", |
| 62 | lst->name, entry->imsi_deny, VTY_NEWLINE); |
| 63 | } |
| 64 | } |
| 65 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 66 | static int config_write_nat(struct vty *vty) |
| 67 | { |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 68 | struct bsc_nat_acc_lst *lst; |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 69 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 70 | vty_out(vty, "nat%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 71 | vty_out(vty, " msc ip %s%s", _nat->msc_ip, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 72 | vty_out(vty, " msc port %d%s", _nat->msc_port, VTY_NEWLINE); |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 73 | vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE); |
| 74 | vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE); |
| 75 | vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE); |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 76 | if (_nat->token) |
| 77 | vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE); |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 78 | vty_out(vty, " ip-dscp %d%s", _nat->bsc_ip_dscp, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 79 | if (_nat->acc_lst_name) |
| 80 | vty_out(vty, " access-list-name %s%s", _nat->acc_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 81 | if (_nat->ussd_lst_name) |
| 82 | vty_out(vty, " ussd-list-name %s%s", _nat->ussd_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame^] | 83 | if (_nat->ussd_query) |
| 84 | vty_out(vty, " ussd-query %s%s", _nat->ussd_query, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 85 | |
| 86 | llist_for_each_entry(lst, &_nat->access_lists, list) { |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 87 | write_acc_lst(vty, lst); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 88 | } |
| 89 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 90 | return CMD_SUCCESS; |
| 91 | } |
| 92 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 93 | static void dump_lac(struct vty *vty, struct bsc_config *cfg) |
| 94 | { |
| 95 | struct bsc_lac_entry *lac; |
| 96 | llist_for_each_entry(lac, &cfg->lac_list, entry) |
| 97 | vty_out(vty, " location_area_code %u%s", lac->lac, VTY_NEWLINE); |
| 98 | } |
| 99 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 100 | static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc) |
| 101 | { |
| 102 | vty_out(vty, " bsc %u%s", bsc->nr, VTY_NEWLINE); |
| 103 | vty_out(vty, " token %s%s", bsc->token, VTY_NEWLINE); |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 104 | dump_lac(vty, bsc); |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 105 | vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE); |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 106 | if (bsc->description) |
| 107 | vty_out(vty, " description %s%s", bsc->description, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 108 | if (bsc->acc_lst_name) |
Holger Hans Peter Freyther | 27d36de | 2010-06-08 11:18:26 +0800 | [diff] [blame] | 109 | vty_out(vty, " access-list-name %s%s", bsc->acc_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | static int config_write_bsc(struct vty *vty) |
| 113 | { |
| 114 | struct bsc_config *bsc; |
| 115 | |
| 116 | llist_for_each_entry(bsc, &_nat->bsc_configs, entry) |
| 117 | config_write_bsc_single(vty, bsc); |
| 118 | return CMD_SUCCESS; |
| 119 | } |
| 120 | |
| 121 | |
Holger Hans Peter Freyther | 01a0b1b | 2010-04-19 16:06:43 +0800 | [diff] [blame] | 122 | DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", |
| 123 | SHOW_STR "Display information about current SCCP connections") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 124 | { |
| 125 | struct sccp_connections *con; |
Holger Hans Peter Freyther | 85804a8 | 2010-09-15 19:01:31 +0800 | [diff] [blame] | 126 | vty_out(vty, "Listing all open SCCP connections%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 4bd2294 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 127 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 128 | llist_for_each_entry(con, &_nat->sccp_connections, list_entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 129 | vty_out(vty, "For BSC Nr: %d BSC ref: 0x%x; MUX ref: 0x%x; Network has ref: %d ref: 0x%x MSC/BSC mux: 0x%x/0x%x type: %s%s", |
Holger Hans Peter Freyther | 47dd494 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 130 | con->bsc->cfg ? con->bsc->cfg->nr : -1, |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 131 | sccp_src_ref_to_int(&con->real_ref), |
Holger Hans Peter Freyther | 32d3436 | 2010-04-05 10:10:33 +0200 | [diff] [blame] | 132 | sccp_src_ref_to_int(&con->patched_ref), |
Holger Hans Peter Freyther | 4bd2294 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 133 | con->has_remote_ref, |
| 134 | sccp_src_ref_to_int(&con->remote_ref), |
Holger Hans Peter Freyther | f4b3439 | 2010-08-28 16:08:39 +0800 | [diff] [blame] | 135 | con->msc_endp, con->bsc_endp, |
Holger Hans Peter Freyther | 234d312 | 2010-05-16 02:06:11 +0800 | [diff] [blame] | 136 | bsc_con_type_to_string(con->con_type), |
Holger Hans Peter Freyther | 32d3436 | 2010-04-05 10:10:33 +0200 | [diff] [blame] | 137 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | return CMD_SUCCESS; |
| 141 | } |
| 142 | |
Holger Hans Peter Freyther | 01a0b1b | 2010-04-19 16:06:43 +0800 | [diff] [blame] | 143 | DEFUN(show_bsc, show_bsc_cmd, "show bsc connections", |
| 144 | SHOW_STR "Display information about current BSCs") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 145 | { |
| 146 | struct bsc_connection *con; |
Holger Hans Peter Freyther | 870663a | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 147 | struct sockaddr_in sock; |
| 148 | socklen_t len = sizeof(sock); |
| 149 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 150 | llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { |
Holger Hans Peter Freyther | 870663a | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 151 | getpeername(con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len); |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 152 | vty_out(vty, "BSC nr: %d auth: %d fd: %d peername: %s%s", |
Holger Hans Peter Freyther | 47dd494 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 153 | con->cfg ? con->cfg->nr : -1, |
Holger Hans Peter Freyther | 870663a | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 154 | con->authenticated, con->write_queue.bfd.fd, |
| 155 | inet_ntoa(sock.sin_addr), VTY_NEWLINE); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | return CMD_SUCCESS; |
| 159 | } |
| 160 | |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 161 | DEFUN(show_bsc_mgcp, show_bsc_mgcp_cmd, "show bsc mgcp NR", |
| 162 | SHOW_STR "Display the MGCP status for a given BSC") |
| 163 | { |
| 164 | struct bsc_connection *con; |
| 165 | int nr = atoi(argv[0]); |
| 166 | int i; |
| 167 | |
| 168 | llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { |
| 169 | if (!con->cfg) |
| 170 | continue; |
| 171 | if (con->cfg->nr != nr) |
| 172 | continue; |
| 173 | |
| 174 | vty_out(vty, "MGCP Status for %d%s", con->cfg->nr, VTY_NEWLINE); |
| 175 | for (i = 1; i < ARRAY_SIZE(con->endpoint_status); ++i) |
| 176 | vty_out(vty, " Endpoint 0x%x %s%s", i, |
| 177 | con->endpoint_status[i] == 0 ? "free" : "allocated", |
| 178 | VTY_NEWLINE); |
| 179 | break; |
| 180 | } |
| 181 | |
| 182 | return CMD_SUCCESS; |
| 183 | } |
| 184 | |
Holger Hans Peter Freyther | ab7539c | 2010-04-22 13:36:46 +0800 | [diff] [blame] | 185 | DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config", |
| 186 | SHOW_STR "Display information about known BSC configs") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 187 | { |
| 188 | struct bsc_config *conf; |
| 189 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 190 | vty_out(vty, "BSC token: '%s' nr: %u%s", |
| 191 | conf->token, conf->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 192 | if (conf->acc_lst_name) |
| 193 | vty_out(vty, " access-list: %s%s", |
| 194 | conf->acc_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 195 | vty_out(vty, " paging forbidden: %d%s", |
| 196 | conf->forbid_paging, VTY_NEWLINE); |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 197 | if (conf->description) |
| 198 | vty_out(vty, " description: %s%s", conf->description, VTY_NEWLINE); |
| 199 | else |
| 200 | vty_out(vty, " No description.%s", VTY_NEWLINE); |
| 201 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | return CMD_SUCCESS; |
| 205 | } |
| 206 | |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 207 | static void dump_stat_total(struct vty *vty, struct bsc_nat *nat) |
| 208 | { |
| 209 | vty_out(vty, "NAT statistics%s", VTY_NEWLINE); |
| 210 | vty_out(vty, " SCCP Connections %lu total, %lu calls%s", |
| 211 | counter_get(nat->stats.sccp.conn), |
| 212 | counter_get(nat->stats.sccp.calls), VTY_NEWLINE); |
| 213 | vty_out(vty, " MSC Connections %lu%s", |
| 214 | counter_get(nat->stats.msc.reconn), VTY_NEWLINE); |
Holger Hans Peter Freyther | cbfd098 | 2010-08-04 02:34:10 +0800 | [diff] [blame] | 215 | vty_out(vty, " MSC Connected: %d%s", |
| 216 | nat->msc_con->is_connected, VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 217 | vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s", |
| 218 | counter_get(nat->stats.bsc.reconn), |
| 219 | counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE); |
| 220 | } |
| 221 | |
| 222 | static void dump_stat_bsc(struct vty *vty, struct bsc_config *conf) |
| 223 | { |
Holger Hans Peter Freyther | f21e453 | 2010-07-22 20:37:35 +0800 | [diff] [blame] | 224 | int connected = 0; |
| 225 | struct bsc_connection *con; |
| 226 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 227 | vty_out(vty, " BSC nr: %d%s", |
| 228 | conf->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 229 | vty_out_rate_ctr_group(vty, " ", conf->stats.ctrg); |
Holger Hans Peter Freyther | f21e453 | 2010-07-22 20:37:35 +0800 | [diff] [blame] | 230 | |
| 231 | llist_for_each_entry(con, &conf->nat->bsc_connections, list_entry) { |
| 232 | if (con->cfg != conf) |
| 233 | continue; |
| 234 | connected = 1; |
| 235 | break; |
| 236 | } |
| 237 | |
Holger Hans Peter Freyther | 03a0ad0 | 2010-08-04 02:29:03 +0800 | [diff] [blame] | 238 | vty_out(vty, " Connected: %d%s", connected, VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 239 | } |
| 240 | |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 241 | DEFUN(show_stats, |
| 242 | show_stats_cmd, |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 243 | "show statistics [NR]", |
Holger Hans Peter Freyther | b9af2fa | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 244 | SHOW_STR "Display network statistics") |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 245 | { |
| 246 | struct bsc_config *conf; |
| 247 | |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 248 | int nr = -1; |
| 249 | |
| 250 | if (argc == 1) |
| 251 | nr = atoi(argv[0]); |
| 252 | |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 253 | dump_stat_total(vty, _nat); |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 254 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 255 | if (argc == 1 && nr != conf->nr) |
| 256 | continue; |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 257 | dump_stat_bsc(vty, conf); |
| 258 | } |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 259 | |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 260 | return CMD_SUCCESS; |
| 261 | } |
| 262 | |
| 263 | DEFUN(show_stats_lac, |
| 264 | show_stats_lac_cmd, |
| 265 | "show statistics-by-lac <0-65535>", |
| 266 | SHOW_STR "Display network statistics by lac\n" |
| 267 | "The lac of the BSC\n") |
| 268 | { |
| 269 | int lac; |
| 270 | struct bsc_config *conf; |
| 271 | |
| 272 | lac = atoi(argv[0]); |
| 273 | |
| 274 | dump_stat_total(vty, _nat); |
| 275 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 276 | if (!bsc_config_handles_lac(conf, lac)) |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 277 | continue; |
| 278 | dump_stat_bsc(vty, conf); |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | return CMD_SUCCESS; |
| 282 | } |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 283 | |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 284 | DEFUN(show_msc, |
| 285 | show_msc_cmd, |
| 286 | "show msc connection", |
| 287 | SHOW_STR "Show the status of the MSC connection.") |
| 288 | { |
| 289 | if (!_nat->msc_con) { |
| 290 | vty_out(vty, "The MSC is not yet configured.\n"); |
| 291 | return CMD_WARNING; |
| 292 | } |
| 293 | |
| 294 | vty_out(vty, "MSC on %s:%d is connected: %d%s\n", |
| 295 | _nat->msc_con->ip, _nat->msc_con->port, |
| 296 | _nat->msc_con->is_connected, VTY_NEWLINE); |
| 297 | return CMD_SUCCESS; |
| 298 | } |
| 299 | |
Holger Hans Peter Freyther | 2f9dcf0 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 300 | DEFUN(close_bsc, |
| 301 | close_bsc_cmd, |
| 302 | "close bsc connection BSC_NR", |
Holger Hans Peter Freyther | b9af2fa | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 303 | "Close the connection with the BSC identified by the config number.") |
Holger Hans Peter Freyther | 2f9dcf0 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 304 | { |
| 305 | struct bsc_connection *bsc; |
| 306 | int bsc_nr = atoi(argv[0]); |
| 307 | |
| 308 | llist_for_each_entry(bsc, &_nat->bsc_connections, list_entry) { |
| 309 | if (!bsc->cfg || bsc->cfg->nr != bsc_nr) |
| 310 | continue; |
| 311 | bsc_close_connection(bsc); |
| 312 | break; |
| 313 | } |
| 314 | |
| 315 | return CMD_SUCCESS; |
| 316 | } |
| 317 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 318 | DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT") |
| 319 | { |
| 320 | vty->index = _nat; |
| 321 | vty->node = NAT_NODE; |
| 322 | |
| 323 | return CMD_SUCCESS; |
| 324 | } |
| 325 | |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 326 | DEFUN(cfg_nat_msc_ip, |
| 327 | cfg_nat_msc_ip_cmd, |
Holger Hans Peter Freyther | d8b8206 | 2010-05-14 02:36:42 +0800 | [diff] [blame] | 328 | "msc ip A.B.C.D", |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 329 | "Set the IP address of the MSC.") |
| 330 | { |
| 331 | bsc_nat_set_msc_ip(_nat, argv[0]); |
| 332 | return CMD_SUCCESS; |
| 333 | } |
| 334 | |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 335 | DEFUN(cfg_nat_msc_port, |
| 336 | cfg_nat_msc_port_cmd, |
| 337 | "msc port <1-65500>", |
| 338 | "Set the port of the MSC.") |
| 339 | { |
| 340 | _nat->msc_port = atoi(argv[0]); |
| 341 | return CMD_SUCCESS; |
| 342 | } |
| 343 | |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 344 | DEFUN(cfg_nat_auth_time, |
| 345 | cfg_nat_auth_time_cmd, |
| 346 | "timeout auth <1-256>", |
| 347 | "The time to wait for an auth response.") |
| 348 | { |
| 349 | _nat->auth_timeout = atoi(argv[0]); |
| 350 | return CMD_SUCCESS; |
| 351 | } |
| 352 | |
| 353 | DEFUN(cfg_nat_ping_time, |
| 354 | cfg_nat_ping_time_cmd, |
| 355 | "timeout ping NR", |
| 356 | "Send a ping every NR seconds. Negative to disable.") |
| 357 | { |
| 358 | _nat->ping_timeout = atoi(argv[0]); |
| 359 | return CMD_SUCCESS; |
| 360 | } |
| 361 | |
| 362 | DEFUN(cfg_nat_pong_time, |
| 363 | cfg_nat_pong_time_cmd, |
| 364 | "timeout pong NR", |
| 365 | "Wait NR seconds for the PONG response. Should be smaller than ping.") |
| 366 | { |
| 367 | _nat->pong_timeout = atoi(argv[0]); |
| 368 | return CMD_SUCCESS; |
| 369 | } |
| 370 | |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 371 | DEFUN(cfg_nat_token, cfg_nat_token_cmd, |
| 372 | "token TOKEN", |
| 373 | "Set a token for the NAT") |
| 374 | { |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 375 | bsc_replace_string(_nat, &_nat->token, argv[0]); |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 376 | return CMD_SUCCESS; |
| 377 | } |
| 378 | |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 379 | DEFUN(cfg_nat_bsc_ip_dscp, cfg_nat_bsc_ip_dscp_cmd, |
| 380 | "ip-dscp <0-255>", |
| 381 | "Set the IP DSCP for the BSCs to use\n" "Set the IP_TOS attribute") |
Holger Hans Peter Freyther | 078321a | 2010-05-31 10:36:35 +0800 | [diff] [blame] | 382 | { |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 383 | _nat->bsc_ip_dscp = atoi(argv[0]); |
Holger Hans Peter Freyther | 078321a | 2010-05-31 10:36:35 +0800 | [diff] [blame] | 384 | return CMD_SUCCESS; |
| 385 | } |
| 386 | |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 387 | ALIAS_DEPRECATED(cfg_nat_bsc_ip_dscp, cfg_nat_bsc_ip_tos_cmd, |
| 388 | "ip-tos <0-255>", |
| 389 | "Use ip-dscp in the future.\n" "Set the DSCP\n") |
| 390 | |
| 391 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 392 | DEFUN(cfg_nat_acc_lst_name, |
| 393 | cfg_nat_acc_lst_name_cmd, |
| 394 | "access-list-name NAME", |
| 395 | "Set the name of the access list to use.\n" |
| 396 | "The name of the to be used access list.") |
| 397 | { |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 398 | bsc_replace_string(_nat, &_nat->acc_lst_name, argv[0]); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 399 | return CMD_SUCCESS; |
| 400 | } |
| 401 | |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 402 | DEFUN(cfg_nat_ussd_lst_name, |
| 403 | cfg_nat_ussd_lst_name_cmd, |
| 404 | "ussd-list-name NAME", |
| 405 | "Set the name of the access list to check for IMSIs for USSD message\n" |
| 406 | "The name of the access list for HLR USSD handling") |
| 407 | { |
| 408 | if (_nat->ussd_lst_name) |
| 409 | talloc_free(_nat->ussd_lst_name); |
| 410 | _nat->ussd_lst_name = talloc_strdup(_nat, argv[0]); |
| 411 | return CMD_SUCCESS; |
| 412 | } |
| 413 | |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame^] | 414 | DEFUN(cfg_nat_ussd_query, |
| 415 | cfg_nat_ussd_query_cmd, |
| 416 | "ussd-query QUERY", |
| 417 | "Set the USSD query to match with the ussd-list-name\n" |
| 418 | "The query to match") |
| 419 | { |
| 420 | if (_nat->ussd_query) |
| 421 | talloc_free(_nat->ussd_query); |
| 422 | _nat->ussd_query = talloc_strdup(_nat, argv[0]); |
| 423 | return CMD_SUCCESS; |
| 424 | } |
| 425 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 426 | /* per BSC configuration */ |
Holger Hans Peter Freyther | b9af2fa | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 427 | DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 428 | { |
| 429 | int bsc_nr = atoi(argv[0]); |
| 430 | struct bsc_config *bsc; |
| 431 | |
| 432 | if (bsc_nr > _nat->num_bsc) { |
| 433 | vty_out(vty, "%% The next unused BSC number is %u%s", |
| 434 | _nat->num_bsc, VTY_NEWLINE); |
| 435 | return CMD_WARNING; |
| 436 | } else if (bsc_nr == _nat->num_bsc) { |
| 437 | /* allocate a new one */ |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 438 | bsc = bsc_config_alloc(_nat, "unknown"); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 439 | } else |
| 440 | bsc = bsc_config_num(_nat, bsc_nr); |
| 441 | |
| 442 | if (!bsc) |
| 443 | return CMD_WARNING; |
| 444 | |
| 445 | vty->index = bsc; |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 446 | vty->node = NAT_BSC_NODE; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 447 | |
| 448 | return CMD_SUCCESS; |
| 449 | } |
| 450 | |
| 451 | DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token") |
| 452 | { |
| 453 | struct bsc_config *conf = vty->index; |
| 454 | |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 455 | bsc_replace_string(conf, &conf->token, argv[0]); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 456 | return CMD_SUCCESS; |
| 457 | } |
| 458 | |
| 459 | DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>", |
Holger Hans Peter Freyther | b9af2fa | 2010-04-27 15:35:14 +0800 | [diff] [blame] | 460 | "Set the Location Area Code (LAC) of this BSC") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 461 | { |
Holger Hans Peter Freyther | 39ee877 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 462 | struct bsc_config *tmp; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 463 | struct bsc_config *conf = vty->index; |
| 464 | |
| 465 | int lac = atoi(argv[0]); |
| 466 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 467 | if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { |
| 468 | vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s", |
| 469 | lac, VTY_NEWLINE); |
| 470 | return CMD_WARNING; |
| 471 | } |
| 472 | |
Holger Hans Peter Freyther | 39ee877 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 473 | /* verify that the LACs are unique */ |
| 474 | llist_for_each_entry(tmp, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 475 | if (bsc_config_handles_lac(tmp, lac)) { |
Holger Hans Peter Freyther | 39ee877 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 476 | vty_out(vty, "%% LAC %d is already used.%s", lac, VTY_NEWLINE); |
| 477 | return CMD_ERR_INCOMPLETE; |
| 478 | } |
| 479 | } |
| 480 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 481 | bsc_config_add_lac(conf, lac); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 482 | |
| 483 | return CMD_SUCCESS; |
| 484 | } |
| 485 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 486 | DEFUN(cfg_bsc_no_lac, cfg_bsc_no_lac_cmd, |
| 487 | "no location_area_code <0-65535>", |
| 488 | NO_STR "Set the Location Area Code (LAC) of this BSC") |
| 489 | { |
| 490 | int lac = atoi(argv[0]); |
| 491 | struct bsc_config *conf = vty->index; |
| 492 | |
| 493 | bsc_config_del_lac(conf, lac); |
| 494 | return CMD_SUCCESS; |
| 495 | } |
| 496 | |
| 497 | |
| 498 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 499 | DEFUN(cfg_lst_imsi_allow, |
| 500 | cfg_lst_imsi_allow_cmd, |
| 501 | "access-list NAME imsi-allow [REGEXP]", |
| 502 | "Allow IMSIs matching the REGEXP\n" |
| 503 | "The name of the access-list\n" |
| 504 | "The regexp of allowed IMSIs\n") |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 505 | { |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 506 | struct bsc_nat_acc_lst *acc; |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 507 | struct bsc_nat_acc_lst_entry *entry; |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 508 | |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 509 | acc = bsc_nat_acc_lst_get(_nat, argv[0]); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 510 | if (!acc) |
| 511 | return CMD_WARNING; |
| 512 | |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 513 | entry = bsc_nat_acc_lst_entry_create(acc); |
| 514 | if (!entry) |
| 515 | return CMD_WARNING; |
| 516 | |
| 517 | bsc_parse_reg(acc, &entry->imsi_allow_re, &entry->imsi_allow, argc - 1, &argv[1]); |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 518 | return CMD_SUCCESS; |
| 519 | } |
| 520 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 521 | DEFUN(cfg_lst_imsi_deny, |
| 522 | cfg_lst_imsi_deny_cmd, |
| 523 | "access-list NAME imsi-deny [REGEXP]", |
| 524 | "Allow IMSIs matching the REGEXP\n" |
| 525 | "The name of the access-list\n" |
| 526 | "The regexp of to be denied IMSIs\n") |
| 527 | { |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 528 | struct bsc_nat_acc_lst *acc; |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 529 | struct bsc_nat_acc_lst_entry *entry; |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 530 | |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 531 | acc = bsc_nat_acc_lst_get(_nat, argv[0]); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 532 | if (!acc) |
| 533 | return CMD_WARNING; |
| 534 | |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 535 | entry = bsc_nat_acc_lst_entry_create(acc); |
| 536 | if (!entry) |
| 537 | return CMD_WARNING; |
| 538 | |
| 539 | bsc_parse_reg(acc, &entry->imsi_deny_re, &entry->imsi_deny, argc - 1, &argv[1]); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 540 | return CMD_SUCCESS; |
| 541 | } |
| 542 | |
Holger Hans Peter Freyther | e4900a0 | 2010-06-03 01:44:05 +0800 | [diff] [blame] | 543 | /* naming to follow Zebra... */ |
| 544 | DEFUN(cfg_lst_no, |
| 545 | cfg_lst_no_cmd, |
| 546 | "no access-list NAME", |
| 547 | NO_STR "Remove an access-list by name\n" |
| 548 | "The access-list to remove\n") |
| 549 | { |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 550 | struct bsc_nat_acc_lst *acc; |
| 551 | acc = bsc_nat_acc_lst_find(_nat, argv[0]); |
Holger Hans Peter Freyther | e4900a0 | 2010-06-03 01:44:05 +0800 | [diff] [blame] | 552 | if (!acc) |
| 553 | return CMD_WARNING; |
| 554 | |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 555 | bsc_nat_acc_lst_delete(acc); |
Holger Hans Peter Freyther | e4900a0 | 2010-06-03 01:44:05 +0800 | [diff] [blame] | 556 | return CMD_SUCCESS; |
| 557 | } |
| 558 | |
Holger Hans Peter Freyther | 520c1f1 | 2010-09-25 16:25:47 +0800 | [diff] [blame] | 559 | DEFUN(show_acc_lst, |
| 560 | show_acc_lst_cmd, |
| 561 | "show access-list NAME", |
| 562 | SHOW_STR "The name of the access list\n") |
| 563 | { |
| 564 | struct bsc_nat_acc_lst *acc; |
| 565 | acc = bsc_nat_acc_lst_find(_nat, argv[0]); |
| 566 | if (!acc) |
| 567 | return CMD_WARNING; |
| 568 | |
| 569 | vty_out(vty, "access-list %s%s", acc->name, VTY_NEWLINE); |
| 570 | vty_out_rate_ctr_group(vty, " ", acc->stats); |
| 571 | |
| 572 | return CMD_SUCCESS; |
| 573 | } |
| 574 | |
| 575 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 576 | DEFUN(cfg_bsc_acc_lst_name, |
| 577 | cfg_bsc_acc_lst_name_cmd, |
| 578 | "access-list-name NAME", |
| 579 | "Set the name of the access list to use.\n" |
| 580 | "The name of the to be used access list.") |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 581 | { |
| 582 | struct bsc_config *conf = vty->index; |
| 583 | |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 584 | bsc_replace_string(conf, &conf->acc_lst_name, argv[0]); |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 585 | return CMD_SUCCESS; |
| 586 | } |
| 587 | |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 588 | DEFUN(cfg_bsc_paging, |
| 589 | cfg_bsc_paging_cmd, |
| 590 | "paging forbidden (0|1)", |
| 591 | "Forbid sending PAGING REQUESTS to the BSC.") |
| 592 | { |
| 593 | struct bsc_config *conf = vty->index; |
| 594 | |
Holger Hans Peter Freyther | 834f1df | 2010-04-21 20:07:07 +0800 | [diff] [blame] | 595 | if (strcmp("1", argv[0]) == 0) |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 596 | conf->forbid_paging = 1; |
| 597 | else |
| 598 | conf->forbid_paging = 0; |
| 599 | |
| 600 | return CMD_SUCCESS; |
| 601 | } |
| 602 | |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 603 | DEFUN(cfg_bsc_desc, |
| 604 | cfg_bsc_desc_cmd, |
| 605 | "description DESC", |
| 606 | "Provide a description for the given BSC.") |
| 607 | { |
| 608 | struct bsc_config *conf = vty->index; |
| 609 | |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 610 | bsc_replace_string(conf, &conf->description, argv[0]); |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 611 | return CMD_SUCCESS; |
| 612 | } |
| 613 | |
Holger Hans Peter Freyther | 52c4ba0 | 2010-05-14 23:43:12 +0800 | [diff] [blame] | 614 | DEFUN(test_regex, test_regex_cmd, |
| 615 | "test regex PATTERN STRING", |
| 616 | "Check if the string is matching the current pattern.") |
| 617 | { |
| 618 | regex_t reg; |
| 619 | char *str = NULL; |
| 620 | |
| 621 | memset(®, 0, sizeof(reg)); |
| 622 | bsc_parse_reg(_nat, ®, &str, 1, argv); |
| 623 | |
| 624 | vty_out(vty, "String matches allow pattern: %d%s", |
| 625 | regexec(®, argv[1], 0, NULL, 0) == 0, VTY_NEWLINE); |
| 626 | |
| 627 | talloc_free(str); |
| 628 | regfree(®); |
| 629 | return CMD_SUCCESS; |
| 630 | } |
| 631 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 632 | int bsc_nat_vty_init(struct bsc_nat *nat) |
| 633 | { |
| 634 | _nat = nat; |
| 635 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 636 | /* show commands */ |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 637 | install_element_ve(&show_sccp_cmd); |
| 638 | install_element_ve(&show_bsc_cmd); |
| 639 | install_element_ve(&show_bsc_cfg_cmd); |
| 640 | install_element_ve(&show_stats_cmd); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 641 | install_element_ve(&show_stats_lac_cmd); |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 642 | install_element_ve(&close_bsc_cmd); |
| 643 | install_element_ve(&show_msc_cmd); |
| 644 | install_element_ve(&test_regex_cmd); |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 645 | install_element_ve(&show_bsc_mgcp_cmd); |
Holger Hans Peter Freyther | 520c1f1 | 2010-09-25 16:25:47 +0800 | [diff] [blame] | 646 | install_element_ve(&show_acc_lst_cmd); |
Holger Hans Peter Freyther | 5f291d5 | 2010-04-06 12:01:15 +0200 | [diff] [blame] | 647 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 648 | /* nat group */ |
| 649 | install_element(CONFIG_NODE, &cfg_nat_cmd); |
| 650 | install_node(&nat_node, config_write_nat); |
| 651 | install_default(NAT_NODE); |
Holger Hans Peter Freyther | 9c78697 | 2010-06-17 14:39:15 +0800 | [diff] [blame] | 652 | install_element(NAT_NODE, &ournode_exit_cmd); |
| 653 | install_element(NAT_NODE, &ournode_end_cmd); |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 654 | install_element(NAT_NODE, &cfg_nat_msc_ip_cmd); |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 655 | install_element(NAT_NODE, &cfg_nat_msc_port_cmd); |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 656 | install_element(NAT_NODE, &cfg_nat_auth_time_cmd); |
| 657 | install_element(NAT_NODE, &cfg_nat_ping_time_cmd); |
| 658 | install_element(NAT_NODE, &cfg_nat_pong_time_cmd); |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 659 | install_element(NAT_NODE, &cfg_nat_token_cmd); |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 660 | install_element(NAT_NODE, &cfg_nat_bsc_ip_dscp_cmd); |
Holger Hans Peter Freyther | 078321a | 2010-05-31 10:36:35 +0800 | [diff] [blame] | 661 | install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 662 | install_element(NAT_NODE, &cfg_nat_acc_lst_name_cmd); |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 663 | install_element(NAT_NODE, &cfg_nat_ussd_lst_name_cmd); |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame^] | 664 | install_element(NAT_NODE, &cfg_nat_ussd_query_cmd); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 665 | |
| 666 | /* access-list */ |
| 667 | install_element(NAT_NODE, &cfg_lst_imsi_allow_cmd); |
| 668 | install_element(NAT_NODE, &cfg_lst_imsi_deny_cmd); |
Holger Hans Peter Freyther | e4900a0 | 2010-06-03 01:44:05 +0800 | [diff] [blame] | 669 | install_element(NAT_NODE, &cfg_lst_no_cmd); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 670 | |
| 671 | /* BSC subgroups */ |
| 672 | install_element(NAT_NODE, &cfg_bsc_cmd); |
| 673 | install_node(&bsc_node, config_write_bsc); |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 674 | install_default(NAT_BSC_NODE); |
| 675 | install_element(NAT_BSC_NODE, &ournode_exit_cmd); |
| 676 | install_element(NAT_BSC_NODE, &ournode_end_cmd); |
| 677 | install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); |
| 678 | install_element(NAT_BSC_NODE, &cfg_bsc_lac_cmd); |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 679 | install_element(NAT_BSC_NODE, &cfg_bsc_no_lac_cmd); |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 680 | install_element(NAT_BSC_NODE, &cfg_bsc_paging_cmd); |
| 681 | install_element(NAT_BSC_NODE, &cfg_bsc_desc_cmd); |
| 682 | install_element(NAT_BSC_NODE, &cfg_bsc_acc_lst_name_cmd); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 683 | |
Holger Hans Peter Freyther | f7d3335 | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 684 | mgcp_vty_init(); |
| 685 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 686 | return 0; |
| 687 | } |
| 688 | |
| 689 | |
| 690 | /* called by the telnet interface... we have our own init above */ |
| 691 | void bsc_vty_init() |
| 692 | {} |