blob: c41929e7b1c3d004a22a82aeb84385c9ea7ade04 [file] [log] [blame]
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +08001/* OpenBSC NAT interface to quagga VTY */
2/* (C) 2010 by Holger Hans Peter Freyther
3 * (C) 2010 by On-Waves
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22#include <vty/command.h>
23#include <vty/buffer.h>
24#include <vty/vty.h>
25
26#include <openbsc/bsc_nat.h>
Holger Hans Peter Freytheraad82ce2010-05-11 19:07:39 +080027#include <openbsc/bsc_msc.h>
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080028#include <openbsc/gsm_04_08.h>
Holger Hans Peter Freytherf7d33352010-06-15 18:50:26 +080029#include <openbsc/mgcp.h>
Holger Hans Peter Freyther5f291d52010-04-06 12:01:15 +020030#include <openbsc/vty.h>
Holger Hans Peter Freyther6c45f2e2010-06-15 19:06:18 +080031
32#include <osmocore/talloc.h>
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080033
34#include <sccp/sccp.h>
35
36#include <stdlib.h>
37
38static struct bsc_nat *_nat;
39
40static struct cmd_node nat_node = {
41 NAT_NODE,
42 "%s(nat)#",
43 1,
44};
45
46static struct cmd_node bsc_node = {
47 BSC_NODE,
48 "%s(bsc)#",
49 1,
50};
51
52static int config_write_nat(struct vty *vty)
53{
54 vty_out(vty, "nat%s", VTY_NEWLINE);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +020055 if (_nat->imsi_allow)
56 vty_out(vty, " imsi allow %s%s", _nat->imsi_allow, VTY_NEWLINE);
57 if (_nat->imsi_deny)
Holger Hans Peter Freyther3df02332010-05-14 23:06:09 +080058 vty_out(vty, " imsi deny %s%s", _nat->imsi_deny, VTY_NEWLINE);
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +080059 vty_out(vty, " msc ip %s%s", _nat->msc_ip, VTY_NEWLINE);
Holger Hans Peter Freyther81395532010-04-17 07:48:45 +020060 vty_out(vty, " msc port %d%s", _nat->msc_port, VTY_NEWLINE);
Holger Hans Peter Freytherda35a8d2010-05-05 16:57:38 +080061 vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE);
62 vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE);
63 vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE);
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +080064 if (_nat->token)
65 vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080066 return CMD_SUCCESS;
67}
68
69static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc)
70{
71 vty_out(vty, " bsc %u%s", bsc->nr, VTY_NEWLINE);
72 vty_out(vty, " token %s%s", bsc->token, VTY_NEWLINE);
Holger Hans Peter Freytherd1278c12010-04-16 16:52:20 +020073 vty_out(vty, " location_area_code %u%s", bsc->lac, VTY_NEWLINE);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +020074 if (bsc->imsi_allow)
75 vty_out(vty, " imsi allow %s%s", bsc->imsi_allow, VTY_NEWLINE);
76 if (bsc->imsi_deny)
77 vty_out(vty, " imsi deny %s%s", bsc->imsi_deny, VTY_NEWLINE);
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +080078 vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE);
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +080079 if (bsc->description)
80 vty_out(vty, " description %s%s", bsc->description, VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080081}
82
83static int config_write_bsc(struct vty *vty)
84{
85 struct bsc_config *bsc;
86
87 llist_for_each_entry(bsc, &_nat->bsc_configs, entry)
88 config_write_bsc_single(vty, bsc);
89 return CMD_SUCCESS;
90}
91
92
Holger Hans Peter Freyther01a0b1b2010-04-19 16:06:43 +080093DEFUN(show_sccp, show_sccp_cmd, "show sccp connections",
94 SHOW_STR "Display information about current SCCP connections")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080095{
96 struct sccp_connections *con;
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +080097 vty_out(vty, "Listing all opening SCCP connections%s", VTY_NEWLINE);
Holger Hans Peter Freyther4bd22942010-04-27 13:11:18 +080098
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +080099 llist_for_each_entry(con, &_nat->sccp_connections, list_entry) {
Holger Hans Peter Freyther4bd22942010-04-27 13:11:18 +0800100 vty_out(vty, "For BSC Nr: %d lac: %d; BSC ref: 0x%x; MUX ref: 0x%x; Network has ref: %d ref: 0x%x MSC/BSC mux: 0x%x/0x%x%s",
Holger Hans Peter Freyther47dd4942010-04-06 15:11:34 +0200101 con->bsc->cfg ? con->bsc->cfg->nr : -1,
102 con->bsc->cfg ? con->bsc->cfg->lac : -1,
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800103 sccp_src_ref_to_int(&con->real_ref),
Holger Hans Peter Freyther32d34362010-04-05 10:10:33 +0200104 sccp_src_ref_to_int(&con->patched_ref),
Holger Hans Peter Freyther4bd22942010-04-27 13:11:18 +0800105 con->has_remote_ref,
106 sccp_src_ref_to_int(&con->remote_ref),
Holger Hans Peter Freyther32d34362010-04-05 10:10:33 +0200107 con->msc_timeslot, con->bsc_timeslot,
108 VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800109 }
110
111 return CMD_SUCCESS;
112}
113
Holger Hans Peter Freyther01a0b1b2010-04-19 16:06:43 +0800114DEFUN(show_bsc, show_bsc_cmd, "show bsc connections",
115 SHOW_STR "Display information about current BSCs")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800116{
117 struct bsc_connection *con;
Holger Hans Peter Freyther870663a2010-04-08 10:35:20 +0200118 struct sockaddr_in sock;
119 socklen_t len = sizeof(sock);
120
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800121 llist_for_each_entry(con, &_nat->bsc_connections, list_entry) {
Holger Hans Peter Freyther870663a2010-04-08 10:35:20 +0200122 getpeername(con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len);
Holger Hans Peter Freyther3b879812010-05-01 15:32:32 +0800123 vty_out(vty, "BSC nr: %d lac: %d auth: %d fd: %d peername: %s%s",
Holger Hans Peter Freyther47dd4942010-04-06 15:11:34 +0200124 con->cfg ? con->cfg->nr : -1,
125 con->cfg ? con->cfg->lac : -1,
Holger Hans Peter Freyther870663a2010-04-08 10:35:20 +0200126 con->authenticated, con->write_queue.bfd.fd,
127 inet_ntoa(sock.sin_addr), VTY_NEWLINE);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800128 }
129
130 return CMD_SUCCESS;
131}
132
Holger Hans Peter Freytherab7539c2010-04-22 13:36:46 +0800133DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config",
134 SHOW_STR "Display information about known BSC configs")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800135{
136 struct bsc_config *conf;
137 llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
138 vty_out(vty, "BSC token: '%s' lac: %u nr: %u%s",
139 conf->token, conf->lac, conf->nr, VTY_NEWLINE);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200140 vty_out(vty, " imsi_allow: '%s' imsi_deny: '%s'%s",
141 conf->imsi_allow ? conf->imsi_allow: "any",
142 conf->imsi_deny ? conf->imsi_deny : "none",
143 VTY_NEWLINE);
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800144 vty_out(vty, " paging forbidden: %d%s",
145 conf->forbid_paging, VTY_NEWLINE);
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800146 if (conf->description)
147 vty_out(vty, " description: %s%s", conf->description, VTY_NEWLINE);
148 else
149 vty_out(vty, " No description.%s", VTY_NEWLINE);
150
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800151 }
152
153 return CMD_SUCCESS;
154}
155
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200156DEFUN(show_stats,
157 show_stats_cmd,
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800158 "show statistics [NR]",
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800159 SHOW_STR "Display network statistics")
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200160{
161 struct bsc_config *conf;
162
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800163 int nr = -1;
164
165 if (argc == 1)
166 nr = atoi(argv[0]);
167
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200168 vty_out(vty, "NAT statistics%s", VTY_NEWLINE);
169 vty_out(vty, " SCCP Connections %lu total, %lu calls%s",
170 counter_get(_nat->stats.sccp.conn),
171 counter_get(_nat->stats.sccp.calls), VTY_NEWLINE);
172 vty_out(vty, " MSC Connections %lu%s",
173 counter_get(_nat->stats.msc.reconn), VTY_NEWLINE);
174 vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s",
175 counter_get(_nat->stats.bsc.reconn),
176 counter_get(_nat->stats.bsc.auth_fail), VTY_NEWLINE);
177
178 llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
Holger Hans Peter Freyther314191d2010-05-02 18:59:24 +0800179 if (argc == 1 && nr != conf->nr)
180 continue;
181
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200182 vty_out(vty, " BSC lac: %d nr: %d%s",
183 conf->lac, conf->nr, VTY_NEWLINE);
184 vty_out(vty, " SCCP Connnections %lu total, %lu calls%s",
185 counter_get(conf->stats.sccp.conn),
186 counter_get(conf->stats.sccp.calls), VTY_NEWLINE);
187 vty_out(vty, " BSC Connections %lu total%s",
188 counter_get(conf->stats.net.reconn), VTY_NEWLINE);
189 }
190
191 return CMD_SUCCESS;
192}
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800193
Holger Hans Peter Freytheraad82ce2010-05-11 19:07:39 +0800194DEFUN(show_msc,
195 show_msc_cmd,
196 "show msc connection",
197 SHOW_STR "Show the status of the MSC connection.")
198{
199 if (!_nat->msc_con) {
200 vty_out(vty, "The MSC is not yet configured.\n");
201 return CMD_WARNING;
202 }
203
204 vty_out(vty, "MSC on %s:%d is connected: %d%s\n",
205 _nat->msc_con->ip, _nat->msc_con->port,
206 _nat->msc_con->is_connected, VTY_NEWLINE);
207 return CMD_SUCCESS;
208}
209
Holger Hans Peter Freyther2f9dcf02010-04-27 13:21:39 +0800210DEFUN(close_bsc,
211 close_bsc_cmd,
212 "close bsc connection BSC_NR",
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800213 "Close the connection with the BSC identified by the config number.")
Holger Hans Peter Freyther2f9dcf02010-04-27 13:21:39 +0800214{
215 struct bsc_connection *bsc;
216 int bsc_nr = atoi(argv[0]);
217
218 llist_for_each_entry(bsc, &_nat->bsc_connections, list_entry) {
219 if (!bsc->cfg || bsc->cfg->nr != bsc_nr)
220 continue;
221 bsc_close_connection(bsc);
222 break;
223 }
224
225 return CMD_SUCCESS;
226}
227
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800228DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT")
229{
230 vty->index = _nat;
231 vty->node = NAT_NODE;
232
233 return CMD_SUCCESS;
234}
235
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200236DEFUN(cfg_nat_imsi_allow,
237 cfg_nat_imsi_allow_cmd,
238 "imsi allow [REGEXP]",
239 "Allow matching IMSIs to talk to the MSC. "
240 "The defualt is to allow everyone.")
241{
Holger Hans Peter Freyther12dc89a2010-05-14 18:38:29 +0800242 bsc_parse_reg(_nat, &_nat->imsi_allow_re, &_nat->imsi_allow, argc, argv);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200243 return CMD_SUCCESS;
244}
245
246DEFUN(cfg_nat_imsi_deny,
247 cfg_nat_imsi_deny_cmd,
248 "imsi deny [REGEXP]",
249 "Deny matching IMSIs to talk to the MSC. "
250 "The defualt is to not deny.")
251{
Holger Hans Peter Freyther12dc89a2010-05-14 18:38:29 +0800252 bsc_parse_reg(_nat, &_nat->imsi_deny_re, &_nat->imsi_deny, argc, argv);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200253 return CMD_SUCCESS;
254}
255
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +0800256DEFUN(cfg_nat_msc_ip,
257 cfg_nat_msc_ip_cmd,
Holger Hans Peter Freytherd8b82062010-05-14 02:36:42 +0800258 "msc ip A.B.C.D",
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +0800259 "Set the IP address of the MSC.")
260{
261 bsc_nat_set_msc_ip(_nat, argv[0]);
262 return CMD_SUCCESS;
263}
264
Holger Hans Peter Freyther81395532010-04-17 07:48:45 +0200265DEFUN(cfg_nat_msc_port,
266 cfg_nat_msc_port_cmd,
267 "msc port <1-65500>",
268 "Set the port of the MSC.")
269{
270 _nat->msc_port = atoi(argv[0]);
271 return CMD_SUCCESS;
272}
273
Holger Hans Peter Freytherda35a8d2010-05-05 16:57:38 +0800274DEFUN(cfg_nat_auth_time,
275 cfg_nat_auth_time_cmd,
276 "timeout auth <1-256>",
277 "The time to wait for an auth response.")
278{
279 _nat->auth_timeout = atoi(argv[0]);
280 return CMD_SUCCESS;
281}
282
283DEFUN(cfg_nat_ping_time,
284 cfg_nat_ping_time_cmd,
285 "timeout ping NR",
286 "Send a ping every NR seconds. Negative to disable.")
287{
288 _nat->ping_timeout = atoi(argv[0]);
289 return CMD_SUCCESS;
290}
291
292DEFUN(cfg_nat_pong_time,
293 cfg_nat_pong_time_cmd,
294 "timeout pong NR",
295 "Wait NR seconds for the PONG response. Should be smaller than ping.")
296{
297 _nat->pong_timeout = atoi(argv[0]);
298 return CMD_SUCCESS;
299}
300
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +0800301DEFUN(cfg_nat_token, cfg_nat_token_cmd,
302 "token TOKEN",
303 "Set a token for the NAT")
304{
305 if (_nat->token)
306 talloc_free(_nat->token);
307 _nat->token = talloc_strdup(_nat, argv[0]);
308 return CMD_SUCCESS;
309}
310
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800311/* per BSC configuration */
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800312DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800313{
314 int bsc_nr = atoi(argv[0]);
315 struct bsc_config *bsc;
316
317 if (bsc_nr > _nat->num_bsc) {
318 vty_out(vty, "%% The next unused BSC number is %u%s",
319 _nat->num_bsc, VTY_NEWLINE);
320 return CMD_WARNING;
321 } else if (bsc_nr == _nat->num_bsc) {
322 /* allocate a new one */
323 bsc = bsc_config_alloc(_nat, "unknown", 0);
324 } else
325 bsc = bsc_config_num(_nat, bsc_nr);
326
327 if (!bsc)
328 return CMD_WARNING;
329
330 vty->index = bsc;
331 vty->node = BSC_NODE;
332
333 return CMD_SUCCESS;
334}
335
336DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token")
337{
338 struct bsc_config *conf = vty->index;
339
340 if (conf->token)
341 talloc_free(conf->token);
342 conf->token = talloc_strdup(conf, argv[0]);
343 return CMD_SUCCESS;
344}
345
346DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>",
Holger Hans Peter Freytherb9af2fa2010-04-27 15:35:14 +0800347 "Set the Location Area Code (LAC) of this BSC")
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800348{
Holger Hans Peter Freyther39ee8772010-03-30 06:08:56 +0200349 struct bsc_config *tmp;
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800350 struct bsc_config *conf = vty->index;
351
352 int lac = atoi(argv[0]);
353
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800354 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
355 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
356 lac, VTY_NEWLINE);
357 return CMD_WARNING;
358 }
359
Holger Hans Peter Freyther39ee8772010-03-30 06:08:56 +0200360 /* verify that the LACs are unique */
361 llist_for_each_entry(tmp, &_nat->bsc_configs, entry) {
362 if (tmp->lac == lac) {
363 vty_out(vty, "%% LAC %d is already used.%s", lac, VTY_NEWLINE);
364 return CMD_ERR_INCOMPLETE;
365 }
366 }
367
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800368 conf->lac = lac;
369
370 return CMD_SUCCESS;
371}
372
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200373DEFUN(cfg_bsc_imsi_allow,
374 cfg_bsc_imsi_allow_cmd,
375 "imsi allow [REGEXP]",
376 "Allow IMSIs with the following network to talk to the MSC."
377 "The default is to allow everyone)")
378{
379 struct bsc_config *conf = vty->index;
380
Holger Hans Peter Freyther12dc89a2010-05-14 18:38:29 +0800381 bsc_parse_reg(conf, &conf->imsi_allow_re, &conf->imsi_allow, argc, argv);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200382 return CMD_SUCCESS;
383}
384
385DEFUN(cfg_bsc_imsi_deny,
386 cfg_bsc_imsi_deny_cmd,
387 "imsi deny [REGEXP]",
388 "Deny IMSIs with the following network to talk to the MSC."
389 "The default is to not deny anyone.)")
390{
391 struct bsc_config *conf = vty->index;
392
Holger Hans Peter Freyther12dc89a2010-05-14 18:38:29 +0800393 bsc_parse_reg(conf, &conf->imsi_deny_re, &conf->imsi_deny, argc, argv);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200394 return CMD_SUCCESS;
395}
396
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800397DEFUN(cfg_bsc_paging,
398 cfg_bsc_paging_cmd,
399 "paging forbidden (0|1)",
400 "Forbid sending PAGING REQUESTS to the BSC.")
401{
402 struct bsc_config *conf = vty->index;
403
Holger Hans Peter Freyther834f1df2010-04-21 20:07:07 +0800404 if (strcmp("1", argv[0]) == 0)
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800405 conf->forbid_paging = 1;
406 else
407 conf->forbid_paging = 0;
408
409 return CMD_SUCCESS;
410}
411
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800412DEFUN(cfg_bsc_desc,
413 cfg_bsc_desc_cmd,
414 "description DESC",
415 "Provide a description for the given BSC.")
416{
417 struct bsc_config *conf = vty->index;
418
419 if (conf->description)
420 talloc_free(conf->description);
421 conf->description = talloc_strdup(conf, argv[0]);
422 return CMD_SUCCESS;
423}
424
Holger Hans Peter Freyther52c4ba02010-05-14 23:43:12 +0800425DEFUN(test_regex, test_regex_cmd,
426 "test regex PATTERN STRING",
427 "Check if the string is matching the current pattern.")
428{
429 regex_t reg;
430 char *str = NULL;
431
432 memset(&reg, 0, sizeof(reg));
433 bsc_parse_reg(_nat, &reg, &str, 1, argv);
434
435 vty_out(vty, "String matches allow pattern: %d%s",
436 regexec(&reg, argv[1], 0, NULL, 0) == 0, VTY_NEWLINE);
437
438 talloc_free(str);
439 regfree(&reg);
440 return CMD_SUCCESS;
441}
442
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800443int bsc_nat_vty_init(struct bsc_nat *nat)
444{
445 _nat = nat;
446
447 cmd_init(1);
448 vty_init();
449
450 /* show commands */
451 install_element(VIEW_NODE, &show_sccp_cmd);
452 install_element(VIEW_NODE, &show_bsc_cmd);
453 install_element(VIEW_NODE, &show_bsc_cfg_cmd);
Holger Hans Peter Freytherbcfebb22010-04-12 12:33:27 +0200454 install_element(VIEW_NODE, &show_stats_cmd);
Holger Hans Peter Freyther2f9dcf02010-04-27 13:21:39 +0800455 install_element(VIEW_NODE, &close_bsc_cmd);
Holger Hans Peter Freytheraad82ce2010-05-11 19:07:39 +0800456 install_element(VIEW_NODE, &show_msc_cmd);
Holger Hans Peter Freyther52c4ba02010-05-14 23:43:12 +0800457 install_element(VIEW_NODE, &test_regex_cmd);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800458
Holger Hans Peter Freyther5f291d52010-04-06 12:01:15 +0200459 openbsc_vty_add_cmds();
460
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800461 /* nat group */
462 install_element(CONFIG_NODE, &cfg_nat_cmd);
463 install_node(&nat_node, config_write_nat);
464 install_default(NAT_NODE);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200465 install_element(NAT_NODE, &cfg_nat_imsi_allow_cmd);
466 install_element(NAT_NODE, &cfg_nat_imsi_deny_cmd);
Holger Hans Peter Freythera88742c2010-06-15 18:51:04 +0800467 install_element(NAT_NODE, &cfg_nat_msc_ip_cmd);
Holger Hans Peter Freyther81395532010-04-17 07:48:45 +0200468 install_element(NAT_NODE, &cfg_nat_msc_port_cmd);
Holger Hans Peter Freytherda35a8d2010-05-05 16:57:38 +0800469 install_element(NAT_NODE, &cfg_nat_auth_time_cmd);
470 install_element(NAT_NODE, &cfg_nat_ping_time_cmd);
471 install_element(NAT_NODE, &cfg_nat_pong_time_cmd);
Holger Hans Peter Freythere635dab2010-05-15 00:14:58 +0800472 install_element(NAT_NODE, &cfg_nat_token_cmd);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800473
474 /* BSC subgroups */
475 install_element(NAT_NODE, &cfg_bsc_cmd);
476 install_node(&bsc_node, config_write_bsc);
477 install_default(BSC_NODE);
478 install_element(BSC_NODE, &cfg_bsc_token_cmd);
479 install_element(BSC_NODE, &cfg_bsc_lac_cmd);
Holger Hans Peter Freytherc16cf272010-04-13 09:24:37 +0200480 install_element(BSC_NODE, &cfg_bsc_imsi_allow_cmd);
481 install_element(BSC_NODE, &cfg_bsc_imsi_deny_cmd);
Holger Hans Peter Freyther62e58432010-04-21 19:05:14 +0800482 install_element(BSC_NODE, &cfg_bsc_paging_cmd);
Holger Hans Peter Freytherb6061012010-05-14 22:06:28 +0800483 install_element(BSC_NODE, &cfg_bsc_desc_cmd);
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800484
Holger Hans Peter Freytherf7d33352010-06-15 18:50:26 +0800485 mgcp_vty_init();
486
Holger Hans Peter Freyther9a85ef32010-06-15 18:46:11 +0800487 return 0;
488}
489
490
491/* called by the telnet interface... we have our own init above */
492void bsc_vty_init()
493{}