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