nat: Attempt to update the VTY usage to the latest version

* Install the show commands to be available in the enable mode as well
* Provide a copyright header..
This commit is contained in:
Holger Hans Peter Freyther 2010-06-15 20:14:08 +08:00
parent 69d801e23a
commit 1398f13a64
2 changed files with 34 additions and 19 deletions

View File

@ -41,15 +41,20 @@
#include <openbsc/bsc_nat.h>
#include <openbsc/ipaccess.h>
#include <openbsc/abis_nm.h>
#include <openbsc/telnet_interface.h>
#include <openbsc/vty.h>
#include <osmocore/gsm0808.h>
#include <osmocore/talloc.h>
#include <osmocore/protocol/gsm_08_08.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/vty.h>
#include <sccp/sccp.h>
#include "../../bscconfig.h"
#define SCCP_CLOSE_TIME 20
#define SCCP_CLOSE_TIME_TIMEOUT 19
@ -60,6 +65,11 @@ static struct bsc_fd bsc_listen;
static const char *msc_ip = NULL;
static struct timer_list sccp_close;
const char *openbsc_copyright =
"Copyright (C) 2010 Holger Hans Peter Freyther and On-Waves\n"
"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n";
static struct bsc_nat *nat;
static void bsc_send_data(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length, int);
@ -1066,6 +1076,14 @@ static void talloc_init_ctx()
tall_ctr_ctx = talloc_named_const(tall_bsc_ctx, 0, "counter");
}
extern enum node_type bsc_vty_go_parent(struct vty *vty);
static struct vty_app_info vty_info = {
.name = "BSC NAT",
.version = PACKAGE_VERSION,
.go_parent_cb = bsc_vty_go_parent,
};
int main(int argc, char** argv)
{
talloc_init_ctx();
@ -1088,13 +1106,18 @@ int main(int argc, char** argv)
return -5;
}
vty_info.copyright = openbsc_copyright;
vty_init(&vty_info);
logging_vty_add_cmds();
bsc_nat_vty_init(nat);
/* parse options */
local_addr.s_addr = INADDR_ANY;
handle_options(argc, argv);
/* init vty and parse */
bsc_nat_vty_init(nat);
telnet_init(NULL, 4244);
telnet_init(tall_bsc_ctx, NULL, 4244);
if (mgcp_parse_config(config_file, nat->mgcp_cfg) < 0) {
fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file);
return -3;

View File

@ -19,10 +19,7 @@
*
*/
#include <vty/command.h>
#include <vty/buffer.h>
#include <vty/vty.h>
#include <openbsc/vty.h>
#include <openbsc/bsc_nat.h>
#include <openbsc/bsc_msc.h>
#include <openbsc/gsm_04_08.h>
@ -512,19 +509,14 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
{
_nat = nat;
cmd_init(1);
vty_init();
/* show commands */
install_element(VIEW_NODE, &show_sccp_cmd);
install_element(VIEW_NODE, &show_bsc_cmd);
install_element(VIEW_NODE, &show_bsc_cfg_cmd);
install_element(VIEW_NODE, &show_stats_cmd);
install_element(VIEW_NODE, &close_bsc_cmd);
install_element(VIEW_NODE, &show_msc_cmd);
install_element(VIEW_NODE, &test_regex_cmd);
openbsc_vty_add_cmds();
install_element_ve(&show_sccp_cmd);
install_element_ve(&show_bsc_cmd);
install_element_ve(&show_bsc_cfg_cmd);
install_element_ve(&show_stats_cmd);
install_element_ve(&close_bsc_cmd);
install_element_ve(&show_msc_cmd);
install_element_ve(&test_regex_cmd);
/* nat group */
install_element(CONFIG_NODE, &cfg_nat_cmd);