X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/7fd68b1daeab9a2a1a3ee8f0652c25fc37bf3549..4df24fd868177859ddd778f1f45bc825f6264cfb:/cli.c diff --git a/cli.c b/cli.c index 3f63413..5b0bcbc 100644 --- a/cli.c +++ b/cli.c @@ -31,6 +31,9 @@ #ifdef BGP #include "bgp.h" #endif +#ifdef LAC +#include "l2tplac.h" +#endif extern tunnelt *tunnel; extern bundlet *bundle; @@ -99,7 +102,9 @@ static int cmd_remove_plugin(struct cli_def *cli, char *command, char **argv, in static int cmd_uptime(struct cli_def *cli, char *command, char **argv, int argc); static int cmd_shutdown(struct cli_def *cli, char *command, char **argv, int argc); static int cmd_reload(struct cli_def *cli, char *command, char **argv, int argc); - +#ifdef LAC +static int cmd_setforward(struct cli_def *cli, char *command, char **argv, int argc); +#endif static int regular_stuff(struct cli_def *cli); @@ -222,6 +227,10 @@ void init_cli() cli_register_command(cli, NULL, "set", cmd_set, PRIVILEGE_PRIVILEGED, MODE_CONFIG, "Set a configuration variable"); +#ifdef LAC + cli_register_command(cli, NULL, "setforward", cmd_setforward, PRIVILEGE_PRIVILEGED, MODE_CONFIG, "Set the Remote LNS Forward"); +#endif + c = cli_register_command(cli, NULL, "ip", NULL, PRIVILEGE_PRIVILEGED, MODE_CONFIG, NULL); cli_register_command(cli, c, "access-list", cmd_ip_access_list, PRIVILEGE_PRIVILEGED, MODE_CONFIG, "Add named access-list"); @@ -3095,3 +3104,53 @@ static int cmd_reload(struct cli_def *cli, char *command, char **argv, int argc) kill(getppid(), SIGHUP); return CLI_OK; } + +#ifdef LAC + +static int cmd_setforward(struct cli_def *cli, char *command, char **argv, int argc) +{ + int ret; + + if (CLI_HELP_REQUESTED) + { + switch (argc) + { + case 1: + return cli_arg_help(cli, 0, + "MASK", "Users mask to forward (ex: myISP@operator.com)", NULL); + + case 2: + return cli_arg_help(cli, 0, + "IP", "IP of the remote LNS(ex: 64.64.64.64)", NULL); + + case 3: + return cli_arg_help(cli, 0, + "PORT", "Port of the remote LNS (ex: 1701)", NULL); + + case 4: + return cli_arg_help(cli, 0, + "SECRET", "l2tp secret of the remote LNS (ex: mysecretpsw)", NULL); + + default: + return cli_arg_help(cli, argc > 1, NULL); + } + } + + if (argc != 4) + { + cli_error(cli, "Specify variable and value"); + return CLI_OK; + } + + // adremotelns(mask, IP_RemoteLNS, Port_RemoteLNS, SecretRemoteLNS) + ret = addremotelns(argv[0], argv[1], argv[2], argv[3]); + + if (ret) + cli_print(cli, "setforward %s %s %s %s", argv[0], argv[1], argv[2], argv[3]); + else + cli_error(cli, "ERROR setforward %s %s %s %s", argv[0], argv[1], argv[2], argv[3]); + + return CLI_OK; +} + +#endif