+
+static int cmd_show_group(struct cli_def *cli, char *command, char **argv, int argc)
+{
+ int i;
+ groupidt g;
+
+ if (CLI_HELP_REQUESTED)
+ return cli_arg_help(cli, 1,
+ "<1-%d>", MAXGROUPE-1, "Show specific group by id",
+ NULL);
+
+ time(&time_now);
+ if (argc > 0)
+ {
+ // Show individual group
+ for (i = 0; i < argc; i++)
+ {
+ sessionidt s;
+
+ g = atoi(argv[i]);
+ if (g <= 0 || g >= MAXGROUPE)
+ {
+ cli_print(cli, "Invalid group id \"%s\"", argv[i]);
+ continue;
+ }
+
+ cli_print(cli, "\r\nGroup %d:", g);
+ cli_print(cli, "\tNb Session:\t\t%d", grpsession[g].nbsession);
+ cli_print(cli, "\tNb Routes:\t\t%d", grpsession[g].nbroutesgrp);
+ cli_print(cli, "\ttime_changed:\t\t%d\n", grpsession[g].time_changed);
+
+ for (i = 0; i < grpsession[g].nbsession; i++)
+ {
+ if ((s = grpsession[g].sesslist[i].sid))
+ {
+ cli_print(cli, "\tSession:\t%d\tTx Rate:%d Kbps\t\t\tweight:\t%d",
+ s,
+ grpsession[g].sesslist[i].tx_rate/(1024/8),
+ grpsession[g].sesslist[i].weight);
+ }
+ }
+
+ for (i = 0; i < grpsession[g].nbroutesgrp; i++)
+ {
+ if (grpsession[g].route[i].ip != 0)
+ {
+ cli_print(cli, "\tRoute:\t%s/%d", fmtaddr(htonl(grpsession[g].route[i].ip), 0), grpsession[g].route[i].prefixlen);
+ }
+ }
+ }
+ return CLI_OK;
+ }
+
+ // Show Summary
+ cli_print(cli, "%5s %7s %9s %12s",
+ "GID",
+ "Nb Sess",
+ "Nb Routes",
+ "Time changed");
+
+ for (g = gnextgrpid; g != 0; g = grpsession[g].prev)
+ {
+ cli_print(cli, "%5d %7d %9d %12d",
+ g,
+ grpsession[g].nbsession,
+ grpsession[g].nbroutesgrp,
+ grpsession[g].time_changed);
+ }
+
+ return CLI_OK;
+}
+
+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;
+ }
+
+ // lac_addremotelns(mask, IP_RemoteLNS, Port_RemoteLNS, SecretRemoteLNS)
+ ret = lac_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]);
+ if (ret == 2)
+ cli_print(cli, "%s Updated, the tunnel must be dropped", argv[0]);
+ }
+ else
+ cli_error(cli, "ERROR setforward %s %s %s %s", argv[0], argv[1], argv[2], argv[3]);
+
+ return CLI_OK;
+}
+
+static int cmd_show_rmtlnsconf(struct cli_def *cli, char *command, char **argv, int argc)
+{
+ confrlnsidt idrlns;
+ char strdisp[1024];
+
+ if (CLI_HELP_REQUESTED)
+ {
+ return cli_arg_help(cli, 0, "remotelns-conf", "Show a list of remote LNS configurations", NULL);
+ }
+
+ for (idrlns = 0; idrlns < MAXRLNSTUNNEL; idrlns++)
+ {
+ if (lac_cli_show_remotelns(idrlns, strdisp) != 0)
+ cli_print(cli, "%s", strdisp);
+ else
+ break;
+ }
+
+ return CLI_OK;
+}