- if (sscanf(string, "%02x%02x.%02x%02x.%02x%02x", (unsigned int *)&mac[0], (unsigned int *)&mac[1], (unsigned int *)&mac[2], (unsigned int *)&mac[3], (unsigned int *)&mac[4], (unsigned int *)&mac[5]) == 6)
- return;
- if (sscanf(string, "%02x%02x:%02x%02x:%02x%02x", (unsigned int *)&mac[0], (unsigned int *)&mac[1], (unsigned int *)&mac[2], (unsigned int *)&mac[3], (unsigned int *)&mac[4], (unsigned int *)&mac[5]) == 6)
- return;
- memset(mac, 0, 6);
+ if (CLI_HELP_REQUESTED)
+ return CLI_HELP_NO_ARGS;
+
+ kill(getppid(), SIGQUIT);
+ return CLI_OK;
+}
+
+static int cmd_reload(struct cli_def *cli, char *command, char **argv, int argc)
+{
+ if (CLI_HELP_REQUESTED)
+ return CLI_HELP_NO_ARGS;
+
+ 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;
+ }
+
+ // 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;