blob: ef433caedd602756204bef36d601738c51fd675f [file] [log] [blame]
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +08001/* OpenBSC NAT interface to quagga VTY */
Holger Hans Peter Freythera18b1162011-04-01 17:32:21 +02002/* (C) 2010-2011 by Holger Hans Peter Freyther
3 * (C) 2010-2011 by On-Waves
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +08004 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01007 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +08009 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010014 * GNU Affero General Public License for more details.
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080015 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010016 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080018 *
19 */
20
Holger Hans Peter Freyther1398f132010-06-15 20:14:08 +080021#include <openbsc/vty.h>
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080022#include <openbsc/bsc_nat.h>
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080023#include <openbsc/bsc_nat_sccp.h>
Holger Hans Peter Freytheraad82ce2010-05-11 19:07:39 +080024#include <openbsc/bsc_msc.h>
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080025#include <openbsc/gsm_04_08.h>
Holger Hans Peter Freytherf7d33352010-06-15 18:50:26 +080026#include <openbsc/mgcp.h>
Holger Hans Peter Freyther5f291d52010-04-06 12:01:15 +020027#include <openbsc/vty.h>
Holger Hans Peter Freyther6c45f2e2010-06-15 19:06:18 +080028
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010029#include <osmocom/core/talloc.h>
30#include <osmocom/core/rate_ctr.h>
31#include <osmocom/core/utils.h>
Pablo Neira Ayuso739a5662011-03-09 13:36:32 +010032#include <osmocom/vty/logging.h>
Pablo Neira Ayuso6110a3f2011-03-28 19:35:00 +020033#include <osmocom/vty/misc.h>
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080034
Harald Welted5db12c2010-08-03 15:11:51 +020035#include <osmocom/sccp/sccp.h>
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080036
37#include <stdlib.h>
38
39static struct bsc_nat *_nat;
40
41static struct cmd_node nat_node = {
42 NAT_NODE,
43 "%s(nat)#",
44 1,
45};
46
47static struct cmd_node bsc_node = {
Holger Hans Peter Freyther7b4a53d2010-06-17 14:42:20 +080048 NAT_BSC_NODE,
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080049 "%s(bsc)#",
50 1,
51};
52
Holger Hans Peter Freytherd77c8172010-06-08 10:53:39 +080053static void write_acc_lst(struct vty *vty, struct bsc_nat_acc_lst *lst)
54{
55 struct bsc_nat_acc_lst_entry *entry;
56
57 llist_for_each_entry(entry, &lst->fltr_list, list) {
58 if (entry->imsi_allow)
59 vty_out(vty, " access-list %s imsi-allow %s%s",
60 lst->name, entry->imsi_allow, VTY_NEWLINE);
61 if (entry->imsi_deny)
62 vty_out(vty, " access-list %s imsi-deny %s%s",
63 lst->name, entry->imsi_deny, VTY_NEWLINE);
64 }
65}
66
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080067static int config_write_nat(struct vty *vty)
68{
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +080069 struct bsc_nat_acc_lst *lst;
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +080070
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080071 vty_out(vty, "nat%s", VTY_NEWLINE);
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +080072 vty_out(vty, " msc ip %s%s", _nat->msc_ip, VTY_NEWLINE);
Holger Hans Peter Freyther81395532010-04-17 07:48:45 +020073 vty_out(vty, " msc port %d%s", _nat->msc_port, VTY_NEWLINE);
Holger Hans Peter Freytherda35a8d2010-05-05 16:57:38 +080074 vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE);
75 vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE);
76 vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE);
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +080077 if (_nat->token)
78 vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE);
Holger Hans Peter Freyther6b771072010-07-27 19:21:53 +080079 vty_out(vty, " ip-dscp %d%s", _nat->bsc_ip_dscp, VTY_NEWLINE);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +080080 if (_nat->acc_lst_name)
81 vty_out(vty, " access-list-name %s%s", _nat->acc_lst_name, VTY_NEWLINE);
Holger Hans Peter Freytherd1effd82010-10-10 17:29:20 +020082 if (_nat->ussd_lst_name)
83 vty_out(vty, " ussd-list-name %s%s", _nat->ussd_lst_name, VTY_NEWLINE);
Holger Hans Peter Freytherc1578bc2010-10-11 10:06:39 +020084 if (_nat->ussd_query)
85 vty_out(vty, " ussd-query %s%s", _nat->ussd_query, VTY_NEWLINE);
Holger Hans Peter Freythere393f272010-10-12 18:25:52 +020086 if (_nat->ussd_token)
87 vty_out(vty, " ussd-token %s%s", _nat->ussd_token, VTY_NEWLINE);
88 if (_nat->ussd_local)
89 vty_out(vty, " ussd-local-ip %s%s", _nat->ussd_local, VTY_NEWLINE);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +080090
Holger Hans Peter Freyther76424392010-10-21 10:59:54 +020091 if (_nat->num_rewr_name)
92 vty_out(vty, " number-rewrite %s%s", _nat->num_rewr_name, VTY_NEWLINE);
93
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +080094 llist_for_each_entry(lst, &_nat->access_lists, list) {
Holger Hans Peter Freytherd77c8172010-06-08 10:53:39 +080095 write_acc_lst(vty, lst);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +080096 }
97
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080098 return CMD_SUCCESS;
99}
100
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800101static void dump_lac(struct vty *vty, struct bsc_config *cfg)
102{
103 struct bsc_lac_entry *lac;
104 llist_for_each_entry(lac, &cfg->lac_list, entry)
105 vty_out(vty, " location_area_code %u%s", lac->lac, VTY_NEWLINE);
106}
107
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800108static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc)
109{
110 vty_out(vty, " bsc %u%s", bsc->nr, VTY_NEWLINE);
111 vty_out(vty, " token %s%s", bsc->token, VTY_NEWLINE);
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800112 dump_lac(vty, bsc);
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800113 vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE);
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800114 if (bsc->description)
115 vty_out(vty, " description %s%s", bsc->description, VTY_NEWLINE);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800116 if (bsc->acc_lst_name)
Holger Hans Peter Freyther27d36de2010-06-08 11:18:26 +0800117 vty_out(vty, " access-list-name %s%s", bsc->acc_lst_name, VTY_NEWLINE);
Holger Hans Peter Freyther9ec030d2011-02-27 11:04:27 +0100118 vty_out(vty, " max-endpoints %d%s", bsc->max_endpoints, VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800119}
120
121static int config_write_bsc(struct vty *vty)
122{
123 struct bsc_config *bsc;
124
125 llist_for_each_entry(bsc, &_nat->bsc_configs, entry)
126 config_write_bsc_single(vty, bsc);
127 return CMD_SUCCESS;
128}
129
130
Holger Hans Peter Freyther01a0b1b2010-04-19 16:06:43 +0800131DEFUN(show_sccp, show_sccp_cmd, "show sccp connections",
132 SHOW_STR "Display information about current SCCP connections")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800133{
134 struct sccp_connections *con;
Holger Hans Peter Freyther85804a82010-09-15 19:01:31 +0800135 vty_out(vty, "Listing all open SCCP connections%s", VTY_NEWLINE);
Holger Hans Peter Freyther4bd22942010-04-27 13:11:18 +0800136
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800137 llist_for_each_entry(con, &_nat->sccp_connections, list_entry) {
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800138 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 Freyther47dd4942010-04-06 15:11:34 +0200139 con->bsc->cfg ? con->bsc->cfg->nr : -1,
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800140 sccp_src_ref_to_int(&con->real_ref),
Holger Hans Peter Freyther32d34362010-04-05 10:10:33 +0200141 sccp_src_ref_to_int(&con->patched_ref),
Holger Hans Peter Freyther4bd22942010-04-27 13:11:18 +0800142 con->has_remote_ref,
143 sccp_src_ref_to_int(&con->remote_ref),
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +0800144 con->msc_endp, con->bsc_endp,
Holger Hans Peter Freyther234d3122010-05-16 02:06:11 +0800145 bsc_con_type_to_string(con->con_type),
Holger Hans Peter Freyther32d34362010-04-05 10:10:33 +0200146 VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800147 }
148
149 return CMD_SUCCESS;
150}
151
Holger Hans Peter Freyther01a0b1b2010-04-19 16:06:43 +0800152DEFUN(show_bsc, show_bsc_cmd, "show bsc connections",
153 SHOW_STR "Display information about current BSCs")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800154{
155 struct bsc_connection *con;
Holger Hans Peter Freyther870663a2010-04-08 10:35:20 +0200156 struct sockaddr_in sock;
157 socklen_t len = sizeof(sock);
158
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800159 llist_for_each_entry(con, &_nat->bsc_connections, list_entry) {
Holger Hans Peter Freyther870663a2010-04-08 10:35:20 +0200160 getpeername(con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len);
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800161 vty_out(vty, "BSC nr: %d auth: %d fd: %d peername: %s%s",
Holger Hans Peter Freyther47dd4942010-04-06 15:11:34 +0200162 con->cfg ? con->cfg->nr : -1,
Holger Hans Peter Freyther870663a2010-04-08 10:35:20 +0200163 con->authenticated, con->write_queue.bfd.fd,
164 inet_ntoa(sock.sin_addr), VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800165 }
166
167 return CMD_SUCCESS;
168}
169
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800170DEFUN(show_bsc_mgcp, show_bsc_mgcp_cmd, "show bsc mgcp NR",
171 SHOW_STR "Display the MGCP status for a given BSC")
172{
173 struct bsc_connection *con;
174 int nr = atoi(argv[0]);
Holger Hans Peter Freythera9e93312011-02-26 11:38:00 +0100175 int i, j, endp;
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800176
177 llist_for_each_entry(con, &_nat->bsc_connections, list_entry) {
Holger Hans Peter Freyther9ec030d2011-02-27 11:04:27 +0100178 int max;
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800179 if (!con->cfg)
180 continue;
181 if (con->cfg->nr != nr)
182 continue;
183
Holger Hans Peter Freythered500e32011-02-25 17:09:07 +0100184 /* this bsc has no audio endpoints yet */
185 if (!con->_endpoint_status)
186 continue;
187
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800188 vty_out(vty, "MGCP Status for %d%s", con->cfg->nr, VTY_NEWLINE);
Holger Hans Peter Freyther9ec030d2011-02-27 11:04:27 +0100189 max = bsc_mgcp_nr_multiplexes(con->max_endpoints);
190 for (i = 0; i < max; ++i) {
Holger Hans Peter Freythera9e93312011-02-26 11:38:00 +0100191 for (j = 0; j < 32; ++j) {
192 endp = mgcp_timeslot_to_endpoint(i, j);
193 vty_out(vty, " Endpoint 0x%x %s%s", endp,
194 con->_endpoint_status[endp] == 0
195 ? "free" : "allocated",
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800196 VTY_NEWLINE);
Holger Hans Peter Freythera9e93312011-02-26 11:38:00 +0100197 }
198 }
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800199 break;
200 }
201
202 return CMD_SUCCESS;
203}
204
Holger Hans Peter Freytherab7539c2010-04-22 13:36:46 +0800205DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config",
206 SHOW_STR "Display information about known BSC configs")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800207{
208 struct bsc_config *conf;
209 llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800210 vty_out(vty, "BSC token: '%s' nr: %u%s",
211 conf->token, conf->nr, VTY_NEWLINE);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800212 if (conf->acc_lst_name)
213 vty_out(vty, " access-list: %s%s",
214 conf->acc_lst_name, VTY_NEWLINE);
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800215 vty_out(vty, " paging forbidden: %d%s",
216 conf->forbid_paging, VTY_NEWLINE);
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800217 if (conf->description)
218 vty_out(vty, " description: %s%s", conf->description, VTY_NEWLINE);
219 else
220 vty_out(vty, " No description.%s", VTY_NEWLINE);
221
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800222 }
223
224 return CMD_SUCCESS;
225}
226
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800227static void dump_stat_total(struct vty *vty, struct bsc_nat *nat)
228{
229 vty_out(vty, "NAT statistics%s", VTY_NEWLINE);
230 vty_out(vty, " SCCP Connections %lu total, %lu calls%s",
231 counter_get(nat->stats.sccp.conn),
232 counter_get(nat->stats.sccp.calls), VTY_NEWLINE);
233 vty_out(vty, " MSC Connections %lu%s",
234 counter_get(nat->stats.msc.reconn), VTY_NEWLINE);
Holger Hans Peter Freythercbfd0982010-08-04 02:34:10 +0800235 vty_out(vty, " MSC Connected: %d%s",
236 nat->msc_con->is_connected, VTY_NEWLINE);
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800237 vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s",
238 counter_get(nat->stats.bsc.reconn),
239 counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE);
240}
241
242static void dump_stat_bsc(struct vty *vty, struct bsc_config *conf)
243{
Holger Hans Peter Freytherf21e4532010-07-22 20:37:35 +0800244 int connected = 0;
245 struct bsc_connection *con;
246
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800247 vty_out(vty, " BSC nr: %d%s",
248 conf->nr, VTY_NEWLINE);
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800249 vty_out_rate_ctr_group(vty, " ", conf->stats.ctrg);
Holger Hans Peter Freytherf21e4532010-07-22 20:37:35 +0800250
251 llist_for_each_entry(con, &conf->nat->bsc_connections, list_entry) {
252 if (con->cfg != conf)
253 continue;
254 connected = 1;
255 break;
256 }
257
Holger Hans Peter Freyther03a0ad02010-08-04 02:29:03 +0800258 vty_out(vty, " Connected: %d%s", connected, VTY_NEWLINE);
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800259}
260
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200261DEFUN(show_stats,
262 show_stats_cmd,
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800263 "show statistics [NR]",
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800264 SHOW_STR "Display network statistics")
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200265{
266 struct bsc_config *conf;
267
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800268 int nr = -1;
269
270 if (argc == 1)
271 nr = atoi(argv[0]);
272
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800273 dump_stat_total(vty, _nat);
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200274 llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800275 if (argc == 1 && nr != conf->nr)
276 continue;
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800277 dump_stat_bsc(vty, conf);
278 }
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800279
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800280 return CMD_SUCCESS;
281}
282
283DEFUN(show_stats_lac,
284 show_stats_lac_cmd,
285 "show statistics-by-lac <0-65535>",
286 SHOW_STR "Display network statistics by lac\n"
287 "The lac of the BSC\n")
288{
289 int lac;
290 struct bsc_config *conf;
291
292 lac = atoi(argv[0]);
293
294 dump_stat_total(vty, _nat);
295 llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800296 if (!bsc_config_handles_lac(conf, lac))
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800297 continue;
298 dump_stat_bsc(vty, conf);
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200299 }
300
301 return CMD_SUCCESS;
302}
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800303
Holger Hans Peter Freytheraad82ce2010-05-11 19:07:39 +0800304DEFUN(show_msc,
305 show_msc_cmd,
306 "show msc connection",
307 SHOW_STR "Show the status of the MSC connection.")
308{
309 if (!_nat->msc_con) {
310 vty_out(vty, "The MSC is not yet configured.\n");
311 return CMD_WARNING;
312 }
313
314 vty_out(vty, "MSC on %s:%d is connected: %d%s\n",
315 _nat->msc_con->ip, _nat->msc_con->port,
316 _nat->msc_con->is_connected, VTY_NEWLINE);
317 return CMD_SUCCESS;
318}
319
Holger Hans Peter Freyther2f9dcf02010-04-27 13:21:39 +0800320DEFUN(close_bsc,
321 close_bsc_cmd,
322 "close bsc connection BSC_NR",
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800323 "Close the connection with the BSC identified by the config number.")
Holger Hans Peter Freyther2f9dcf02010-04-27 13:21:39 +0800324{
325 struct bsc_connection *bsc;
326 int bsc_nr = atoi(argv[0]);
327
328 llist_for_each_entry(bsc, &_nat->bsc_connections, list_entry) {
329 if (!bsc->cfg || bsc->cfg->nr != bsc_nr)
330 continue;
331 bsc_close_connection(bsc);
332 break;
333 }
334
335 return CMD_SUCCESS;
336}
337
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800338DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT")
339{
340 vty->index = _nat;
341 vty->node = NAT_NODE;
342
343 return CMD_SUCCESS;
344}
345
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +0800346DEFUN(cfg_nat_msc_ip,
347 cfg_nat_msc_ip_cmd,
Holger Hans Peter Freytherd8b82062010-05-14 02:36:42 +0800348 "msc ip A.B.C.D",
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +0800349 "Set the IP address of the MSC.")
350{
351 bsc_nat_set_msc_ip(_nat, argv[0]);
352 return CMD_SUCCESS;
353}
354
Holger Hans Peter Freyther81395532010-04-17 07:48:45 +0200355DEFUN(cfg_nat_msc_port,
356 cfg_nat_msc_port_cmd,
357 "msc port <1-65500>",
358 "Set the port of the MSC.")
359{
360 _nat->msc_port = atoi(argv[0]);
361 return CMD_SUCCESS;
362}
363
Holger Hans Peter Freytherda35a8d2010-05-05 16:57:38 +0800364DEFUN(cfg_nat_auth_time,
365 cfg_nat_auth_time_cmd,
366 "timeout auth <1-256>",
367 "The time to wait for an auth response.")
368{
369 _nat->auth_timeout = atoi(argv[0]);
370 return CMD_SUCCESS;
371}
372
373DEFUN(cfg_nat_ping_time,
374 cfg_nat_ping_time_cmd,
375 "timeout ping NR",
376 "Send a ping every NR seconds. Negative to disable.")
377{
378 _nat->ping_timeout = atoi(argv[0]);
379 return CMD_SUCCESS;
380}
381
382DEFUN(cfg_nat_pong_time,
383 cfg_nat_pong_time_cmd,
384 "timeout pong NR",
385 "Wait NR seconds for the PONG response. Should be smaller than ping.")
386{
387 _nat->pong_timeout = atoi(argv[0]);
388 return CMD_SUCCESS;
389}
390
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +0800391DEFUN(cfg_nat_token, cfg_nat_token_cmd,
392 "token TOKEN",
393 "Set a token for the NAT")
394{
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200395 bsc_replace_string(_nat, &_nat->token, argv[0]);
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +0800396 return CMD_SUCCESS;
397}
398
Holger Hans Peter Freyther6b771072010-07-27 19:21:53 +0800399DEFUN(cfg_nat_bsc_ip_dscp, cfg_nat_bsc_ip_dscp_cmd,
400 "ip-dscp <0-255>",
401 "Set the IP DSCP for the BSCs to use\n" "Set the IP_TOS attribute")
Holger Hans Peter Freyther078321a2010-05-31 10:36:35 +0800402{
Holger Hans Peter Freyther6b771072010-07-27 19:21:53 +0800403 _nat->bsc_ip_dscp = atoi(argv[0]);
Holger Hans Peter Freyther078321a2010-05-31 10:36:35 +0800404 return CMD_SUCCESS;
405}
406
Holger Hans Peter Freyther6b771072010-07-27 19:21:53 +0800407ALIAS_DEPRECATED(cfg_nat_bsc_ip_dscp, cfg_nat_bsc_ip_tos_cmd,
408 "ip-tos <0-255>",
409 "Use ip-dscp in the future.\n" "Set the DSCP\n")
410
411
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800412DEFUN(cfg_nat_acc_lst_name,
413 cfg_nat_acc_lst_name_cmd,
414 "access-list-name NAME",
415 "Set the name of the access list to use.\n"
416 "The name of the to be used access list.")
417{
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200418 bsc_replace_string(_nat, &_nat->acc_lst_name, argv[0]);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800419 return CMD_SUCCESS;
420}
421
Holger Hans Peter Freyther6a7babd2011-03-29 17:14:34 +0200422DEFUN(cfg_nat_no_acc_lst_name,
423 cfg_nat_no_acc_lst_name_cmd,
424 "no access-list-name",
425 NO_STR "Remove the access list from the NAT.\n")
426{
427 if (_nat->acc_lst_name) {
428 talloc_free(_nat->acc_lst_name);
429 _nat->acc_lst_name = NULL;
430 }
431
Holger Hans Peter Freyther9e7e55f2011-04-01 16:22:51 +0200432 return CMD_SUCCESS;
Holger Hans Peter Freyther6a7babd2011-03-29 17:14:34 +0200433}
434
Holger Hans Peter Freyther76424392010-10-21 10:59:54 +0200435DEFUN(cfg_nat_number_rewrite,
436 cfg_nat_number_rewrite_cmd,
437 "number-rewrite FILENAME",
438 "Set the file with rewriting rules.\n" "Filename")
439{
440 bsc_replace_string(_nat, &_nat->num_rewr_name, argv[0]);
441 if (_nat->num_rewr_name) {
442 if (_nat->num_rewr)
443 talloc_free(_nat->num_rewr);
444 _nat->num_rewr = msg_entry_parse(_nat, _nat->num_rewr_name);
445 return _nat->num_rewr == NULL ? CMD_WARNING : CMD_SUCCESS;
446 } else {
447 if (_nat->num_rewr)
448 talloc_free(_nat->num_rewr);
449 _nat->num_rewr = NULL;
450 return CMD_SUCCESS;
451 }
452}
453
Holger Hans Peter Freytherd1effd82010-10-10 17:29:20 +0200454DEFUN(cfg_nat_ussd_lst_name,
455 cfg_nat_ussd_lst_name_cmd,
456 "ussd-list-name NAME",
457 "Set the name of the access list to check for IMSIs for USSD message\n"
458 "The name of the access list for HLR USSD handling")
459{
Holger Hans Peter Freyther64b12922010-10-12 21:31:02 +0200460 bsc_replace_string(_nat, &_nat->ussd_lst_name, argv[0]);
Holger Hans Peter Freytherd1effd82010-10-10 17:29:20 +0200461 return CMD_SUCCESS;
462}
463
Holger Hans Peter Freytherc1578bc2010-10-11 10:06:39 +0200464DEFUN(cfg_nat_ussd_query,
465 cfg_nat_ussd_query_cmd,
Holger Hans Peter Freythera18b1162011-04-01 17:32:21 +0200466 "ussd-query REGEXP",
Holger Hans Peter Freytherc1578bc2010-10-11 10:06:39 +0200467 "Set the USSD query to match with the ussd-list-name\n"
468 "The query to match")
469{
Holger Hans Peter Freyther4c9557e2011-04-04 19:19:26 +0200470 if (bsc_parse_reg(_nat, &_nat->ussd_query_re, &_nat->ussd_query, argc, argv) != 0)
471 return CMD_WARNING;
Holger Hans Peter Freytherc1578bc2010-10-11 10:06:39 +0200472 return CMD_SUCCESS;
473}
474
Holger Hans Peter Freythere393f272010-10-12 18:25:52 +0200475DEFUN(cfg_nat_ussd_token,
476 cfg_nat_ussd_token_cmd,
477 "ussd-token TOKEN",
478 "Set the token used to identify the USSD module\n" "Secret key\n")
479{
Holger Hans Peter Freyther64b12922010-10-12 21:31:02 +0200480 bsc_replace_string(_nat, &_nat->ussd_token, argv[0]);
Holger Hans Peter Freythere393f272010-10-12 18:25:52 +0200481 return CMD_SUCCESS;
482}
483
484DEFUN(cfg_nat_ussd_local,
485 cfg_nat_ussd_local_cmd,
486 "ussd-local-ip A.B.C.D",
487 "Set the IP to listen for the USSD Provider\n" "IP Address\n")
488{
Holger Hans Peter Freyther64b12922010-10-12 21:31:02 +0200489 bsc_replace_string(_nat, &_nat->ussd_local, argv[0]);
Holger Hans Peter Freythere393f272010-10-12 18:25:52 +0200490 return CMD_SUCCESS;
491}
492
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800493/* per BSC configuration */
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800494DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800495{
496 int bsc_nr = atoi(argv[0]);
497 struct bsc_config *bsc;
498
499 if (bsc_nr > _nat->num_bsc) {
500 vty_out(vty, "%% The next unused BSC number is %u%s",
501 _nat->num_bsc, VTY_NEWLINE);
502 return CMD_WARNING;
503 } else if (bsc_nr == _nat->num_bsc) {
504 /* allocate a new one */
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800505 bsc = bsc_config_alloc(_nat, "unknown");
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800506 } else
507 bsc = bsc_config_num(_nat, bsc_nr);
508
509 if (!bsc)
510 return CMD_WARNING;
511
512 vty->index = bsc;
Holger Hans Peter Freyther7b4a53d2010-06-17 14:42:20 +0800513 vty->node = NAT_BSC_NODE;
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800514
515 return CMD_SUCCESS;
516}
517
518DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token")
519{
520 struct bsc_config *conf = vty->index;
521
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200522 bsc_replace_string(conf, &conf->token, argv[0]);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800523 return CMD_SUCCESS;
524}
525
526DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>",
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800527 "Set the Location Area Code (LAC) of this BSC")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800528{
Holger Hans Peter Freyther39ee8772010-03-30 06:08:56 +0200529 struct bsc_config *tmp;
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800530 struct bsc_config *conf = vty->index;
531
532 int lac = atoi(argv[0]);
533
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800534 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
535 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
536 lac, VTY_NEWLINE);
537 return CMD_WARNING;
538 }
539
Holger Hans Peter Freyther39ee8772010-03-30 06:08:56 +0200540 /* verify that the LACs are unique */
541 llist_for_each_entry(tmp, &_nat->bsc_configs, entry) {
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800542 if (bsc_config_handles_lac(tmp, lac)) {
Holger Hans Peter Freyther39ee8772010-03-30 06:08:56 +0200543 vty_out(vty, "%% LAC %d is already used.%s", lac, VTY_NEWLINE);
544 return CMD_ERR_INCOMPLETE;
545 }
546 }
547
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800548 bsc_config_add_lac(conf, lac);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800549
550 return CMD_SUCCESS;
551}
552
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800553DEFUN(cfg_bsc_no_lac, cfg_bsc_no_lac_cmd,
554 "no location_area_code <0-65535>",
555 NO_STR "Set the Location Area Code (LAC) of this BSC")
556{
557 int lac = atoi(argv[0]);
558 struct bsc_config *conf = vty->index;
559
560 bsc_config_del_lac(conf, lac);
561 return CMD_SUCCESS;
562}
563
564
565
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800566DEFUN(cfg_lst_imsi_allow,
567 cfg_lst_imsi_allow_cmd,
568 "access-list NAME imsi-allow [REGEXP]",
Holger Hans Peter Freythera64037c2011-04-13 20:58:14 +0200569 "Add the regexp to the allowed list\n"
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800570 "The name of the access-list\n"
571 "The regexp of allowed IMSIs\n")
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200572{
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +0800573 struct bsc_nat_acc_lst *acc;
Holger Hans Peter Freytherd77c8172010-06-08 10:53:39 +0800574 struct bsc_nat_acc_lst_entry *entry;
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200575
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +0800576 acc = bsc_nat_acc_lst_get(_nat, argv[0]);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800577 if (!acc)
578 return CMD_WARNING;
579
Holger Hans Peter Freytherd77c8172010-06-08 10:53:39 +0800580 entry = bsc_nat_acc_lst_entry_create(acc);
581 if (!entry)
582 return CMD_WARNING;
583
Holger Hans Peter Freyther4c9557e2011-04-04 19:19:26 +0200584 if (bsc_parse_reg(acc, &entry->imsi_allow_re, &entry->imsi_allow, argc - 1, &argv[1]) != 0)
585 return CMD_WARNING;
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200586 return CMD_SUCCESS;
587}
588
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800589DEFUN(cfg_lst_imsi_deny,
590 cfg_lst_imsi_deny_cmd,
591 "access-list NAME imsi-deny [REGEXP]",
Holger Hans Peter Freythera64037c2011-04-13 20:58:14 +0200592 "Add the regexp to the deny list\n"
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800593 "The name of the access-list\n"
594 "The regexp of to be denied IMSIs\n")
595{
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +0800596 struct bsc_nat_acc_lst *acc;
Holger Hans Peter Freytherd77c8172010-06-08 10:53:39 +0800597 struct bsc_nat_acc_lst_entry *entry;
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800598
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +0800599 acc = bsc_nat_acc_lst_get(_nat, argv[0]);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800600 if (!acc)
601 return CMD_WARNING;
602
Holger Hans Peter Freytherd77c8172010-06-08 10:53:39 +0800603 entry = bsc_nat_acc_lst_entry_create(acc);
604 if (!entry)
605 return CMD_WARNING;
606
Holger Hans Peter Freyther4c9557e2011-04-04 19:19:26 +0200607 if (bsc_parse_reg(acc, &entry->imsi_deny_re, &entry->imsi_deny, argc - 1, &argv[1]) != 0)
608 return CMD_WARNING;
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800609 return CMD_SUCCESS;
610}
611
Holger Hans Peter Freythere4900a02010-06-03 01:44:05 +0800612/* naming to follow Zebra... */
613DEFUN(cfg_lst_no,
614 cfg_lst_no_cmd,
615 "no access-list NAME",
616 NO_STR "Remove an access-list by name\n"
617 "The access-list to remove\n")
618{
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +0800619 struct bsc_nat_acc_lst *acc;
620 acc = bsc_nat_acc_lst_find(_nat, argv[0]);
Holger Hans Peter Freythere4900a02010-06-03 01:44:05 +0800621 if (!acc)
622 return CMD_WARNING;
623
Holger Hans Peter Freyther29c67032010-06-08 10:14:44 +0800624 bsc_nat_acc_lst_delete(acc);
Holger Hans Peter Freythere4900a02010-06-03 01:44:05 +0800625 return CMD_SUCCESS;
626}
627
Holger Hans Peter Freyther520c1f12010-09-25 16:25:47 +0800628DEFUN(show_acc_lst,
629 show_acc_lst_cmd,
630 "show access-list NAME",
631 SHOW_STR "The name of the access list\n")
632{
633 struct bsc_nat_acc_lst *acc;
634 acc = bsc_nat_acc_lst_find(_nat, argv[0]);
635 if (!acc)
636 return CMD_WARNING;
637
638 vty_out(vty, "access-list %s%s", acc->name, VTY_NEWLINE);
639 vty_out_rate_ctr_group(vty, " ", acc->stats);
640
641 return CMD_SUCCESS;
642}
643
644
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800645DEFUN(cfg_bsc_acc_lst_name,
646 cfg_bsc_acc_lst_name_cmd,
647 "access-list-name NAME",
648 "Set the name of the access list to use.\n"
649 "The name of the to be used access list.")
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200650{
651 struct bsc_config *conf = vty->index;
652
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200653 bsc_replace_string(conf, &conf->acc_lst_name, argv[0]);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200654 return CMD_SUCCESS;
655}
656
Holger Hans Peter Freyther6a7babd2011-03-29 17:14:34 +0200657DEFUN(cfg_bsc_no_acc_lst_name,
658 cfg_bsc_no_acc_lst_name_cmd,
659 "no access-list-name",
Holger Hans Peter Freythera64037c2011-04-13 20:58:14 +0200660 NO_STR "Do not use an access-list for the BSC.\n")
Holger Hans Peter Freyther6a7babd2011-03-29 17:14:34 +0200661{
662 struct bsc_config *conf = vty->index;
663
664 if (conf->acc_lst_name) {
665 talloc_free(conf->acc_lst_name);
666 conf->acc_lst_name = NULL;
667 }
668
669 return CMD_SUCCESS;
670}
671
Holger Hans Peter Freyther9ec030d2011-02-27 11:04:27 +0100672DEFUN(cfg_bsc_max_endps, cfg_bsc_max_endps_cmd,
673 "max-endpoints <1-1024>",
674 "Highest endpoint to use (exclusively)\n" "Number of ports\n")
Holger Hans Peter Freyther7b07b2d2011-02-25 20:38:15 +0100675{
676 struct bsc_config *conf = vty->index;
677
Holger Hans Peter Freyther9ec030d2011-02-27 11:04:27 +0100678 conf->max_endpoints = atoi(argv[0]);
Holger Hans Peter Freyther7b07b2d2011-02-25 20:38:15 +0100679 return CMD_SUCCESS;
680}
681
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800682DEFUN(cfg_bsc_paging,
683 cfg_bsc_paging_cmd,
684 "paging forbidden (0|1)",
685 "Forbid sending PAGING REQUESTS to the BSC.")
686{
687 struct bsc_config *conf = vty->index;
688
Holger Hans Peter Freyther834f1df2010-04-21 20:07:07 +0800689 if (strcmp("1", argv[0]) == 0)
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800690 conf->forbid_paging = 1;
691 else
692 conf->forbid_paging = 0;
693
694 return CMD_SUCCESS;
695}
696
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800697DEFUN(cfg_bsc_desc,
698 cfg_bsc_desc_cmd,
699 "description DESC",
700 "Provide a description for the given BSC.")
701{
702 struct bsc_config *conf = vty->index;
703
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200704 bsc_replace_string(conf, &conf->description, argv[0]);
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800705 return CMD_SUCCESS;
706}
707
Holger Hans Peter Freyther52c4ba02010-05-14 23:43:12 +0800708DEFUN(test_regex, test_regex_cmd,
709 "test regex PATTERN STRING",
710 "Check if the string is matching the current pattern.")
711{
712 regex_t reg;
713 char *str = NULL;
714
715 memset(&reg, 0, sizeof(reg));
Holger Hans Peter Freyther4c9557e2011-04-04 19:19:26 +0200716 if (bsc_parse_reg(_nat, &reg, &str, 1, argv) != 0)
717 return CMD_WARNING;
Holger Hans Peter Freyther52c4ba02010-05-14 23:43:12 +0800718
719 vty_out(vty, "String matches allow pattern: %d%s",
720 regexec(&reg, argv[1], 0, NULL, 0) == 0, VTY_NEWLINE);
721
722 talloc_free(str);
723 regfree(&reg);
724 return CMD_SUCCESS;
725}
726
Holger Hans Peter Freytherdfdf8d92011-02-28 01:07:13 +0100727DEFUN(set_last_endp, set_last_endp_cmd,
728 "set bsc last-used-endpoint <0-9999999999> <0-1024>",
729 "Set a value\n" "Operate on a BSC\n"
730 "Last used endpoint for an assignment\n" "BSC configuration number\n"
731 "Endpoint number used\n")
732{
733 struct bsc_connection *con;
734 int nr = atoi(argv[0]);
735 int endp = atoi(argv[1]);
736
737
738 llist_for_each_entry(con, &_nat->bsc_connections, list_entry) {
739 if (!con->cfg)
740 continue;
741 if (con->cfg->nr != nr)
742 continue;
743
744 con->last_endpoint = endp;
745 vty_out(vty, "Updated the last endpoint for %d to %d.%s",
746 con->cfg->nr, con->last_endpoint, VTY_NEWLINE);
747 }
748
749 return CMD_SUCCESS;
750}
751
Holger Hans Peter Freytherde2b8602011-04-23 23:55:14 +0200752DEFUN(block_new_conn, block_new_conn_cmd,
753 "nat-block (block|unblock)",
754 "Block the NAT for new connections\n"
755 "Block\n" "Unblock\n")
756{
757 _nat->blocked = argv[0][0] == 'b';
758 vty_out(vty, "%%Going to %s the NAT.%s",
759 _nat->blocked ? "block" : "unblock", VTY_NEWLINE);
760 return CMD_SUCCESS;
761}
762
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800763int bsc_nat_vty_init(struct bsc_nat *nat)
764{
765 _nat = nat;
766
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800767 /* show commands */
Holger Hans Peter Freyther1398f132010-06-15 20:14:08 +0800768 install_element_ve(&show_sccp_cmd);
769 install_element_ve(&show_bsc_cmd);
770 install_element_ve(&show_bsc_cfg_cmd);
771 install_element_ve(&show_stats_cmd);
Holger Hans Peter Freytherc95cfda2010-07-22 20:26:10 +0800772 install_element_ve(&show_stats_lac_cmd);
Holger Hans Peter Freyther1398f132010-06-15 20:14:08 +0800773 install_element_ve(&close_bsc_cmd);
774 install_element_ve(&show_msc_cmd);
775 install_element_ve(&test_regex_cmd);
Holger Hans Peter Freyther0d8330c2010-08-28 18:33:34 +0800776 install_element_ve(&show_bsc_mgcp_cmd);
Holger Hans Peter Freyther520c1f12010-09-25 16:25:47 +0800777 install_element_ve(&show_acc_lst_cmd);
Holger Hans Peter Freyther5f291d52010-04-06 12:01:15 +0200778
Holger Hans Peter Freytherdfdf8d92011-02-28 01:07:13 +0100779 install_element(ENABLE_NODE, &set_last_endp_cmd);
Holger Hans Peter Freytherde2b8602011-04-23 23:55:14 +0200780 install_element(ENABLE_NODE, &block_new_conn_cmd);
Holger Hans Peter Freytherdfdf8d92011-02-28 01:07:13 +0100781
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800782 /* nat group */
783 install_element(CONFIG_NODE, &cfg_nat_cmd);
784 install_node(&nat_node, config_write_nat);
785 install_default(NAT_NODE);
Holger Hans Peter Freyther9c786972010-06-17 14:39:15 +0800786 install_element(NAT_NODE, &ournode_exit_cmd);
787 install_element(NAT_NODE, &ournode_end_cmd);
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +0800788 install_element(NAT_NODE, &cfg_nat_msc_ip_cmd);
Holger Hans Peter Freyther81395532010-04-17 07:48:45 +0200789 install_element(NAT_NODE, &cfg_nat_msc_port_cmd);
Holger Hans Peter Freytherda35a8d2010-05-05 16:57:38 +0800790 install_element(NAT_NODE, &cfg_nat_auth_time_cmd);
791 install_element(NAT_NODE, &cfg_nat_ping_time_cmd);
792 install_element(NAT_NODE, &cfg_nat_pong_time_cmd);
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +0800793 install_element(NAT_NODE, &cfg_nat_token_cmd);
Holger Hans Peter Freyther6b771072010-07-27 19:21:53 +0800794 install_element(NAT_NODE, &cfg_nat_bsc_ip_dscp_cmd);
Holger Hans Peter Freyther078321a2010-05-31 10:36:35 +0800795 install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800796 install_element(NAT_NODE, &cfg_nat_acc_lst_name_cmd);
Holger Hans Peter Freyther6a7babd2011-03-29 17:14:34 +0200797 install_element(NAT_NODE, &cfg_nat_no_acc_lst_name_cmd);
Holger Hans Peter Freytherd1effd82010-10-10 17:29:20 +0200798 install_element(NAT_NODE, &cfg_nat_ussd_lst_name_cmd);
Holger Hans Peter Freytherc1578bc2010-10-11 10:06:39 +0200799 install_element(NAT_NODE, &cfg_nat_ussd_query_cmd);
Holger Hans Peter Freythere393f272010-10-12 18:25:52 +0200800 install_element(NAT_NODE, &cfg_nat_ussd_token_cmd);
801 install_element(NAT_NODE, &cfg_nat_ussd_local_cmd);
Holger Hans Peter Freyther8affef52010-06-01 01:03:13 +0800802
803 /* access-list */
804 install_element(NAT_NODE, &cfg_lst_imsi_allow_cmd);
805 install_element(NAT_NODE, &cfg_lst_imsi_deny_cmd);
Holger Hans Peter Freythere4900a02010-06-03 01:44:05 +0800806 install_element(NAT_NODE, &cfg_lst_no_cmd);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800807
Holger Hans Peter Freyther76424392010-10-21 10:59:54 +0200808 /* number rewriting */
809 install_element(NAT_NODE, &cfg_nat_number_rewrite_cmd);
810
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800811 /* BSC subgroups */
812 install_element(NAT_NODE, &cfg_bsc_cmd);
813 install_node(&bsc_node, config_write_bsc);
Holger Hans Peter Freyther7b4a53d2010-06-17 14:42:20 +0800814 install_default(NAT_BSC_NODE);
815 install_element(NAT_BSC_NODE, &ournode_exit_cmd);
816 install_element(NAT_BSC_NODE, &ournode_end_cmd);
817 install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd);
818 install_element(NAT_BSC_NODE, &cfg_bsc_lac_cmd);
Holger Hans Peter Freyther0bd60f32010-10-08 22:08:29 +0800819 install_element(NAT_BSC_NODE, &cfg_bsc_no_lac_cmd);
Holger Hans Peter Freyther7b4a53d2010-06-17 14:42:20 +0800820 install_element(NAT_BSC_NODE, &cfg_bsc_paging_cmd);
821 install_element(NAT_BSC_NODE, &cfg_bsc_desc_cmd);
822 install_element(NAT_BSC_NODE, &cfg_bsc_acc_lst_name_cmd);
Holger Hans Peter Freyther6a7babd2011-03-29 17:14:34 +0200823 install_element(NAT_BSC_NODE, &cfg_bsc_no_acc_lst_name_cmd);
Holger Hans Peter Freyther9ec030d2011-02-27 11:04:27 +0100824 install_element(NAT_BSC_NODE, &cfg_bsc_max_endps_cmd);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800825
Holger Hans Peter Freytherf7d33352010-06-15 18:50:26 +0800826 mgcp_vty_init();
827
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800828 return 0;
829}
830
831
832/* called by the telnet interface... we have our own init above */
Pablo Neira Ayuso739a5662011-03-09 13:36:32 +0100833int bsc_vty_init(const struct log_info *cat)
Holger Hans Peter Freyther6c79a682011-02-24 14:33:09 +0100834{
Pablo Neira Ayuso739a5662011-03-09 13:36:32 +0100835 logging_vty_add_cmds(cat);
Holger Hans Peter Freyther6c79a682011-02-24 14:33:09 +0100836 return 0;
837}