1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* PPP User command processing module
|
|
|
|
*
|
|
|
|
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
* by the Internet Initiative Japan, Inc. The name of the
|
|
|
|
* IIJ may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1997-12-08 20:09:10 +00:00
|
|
|
* $Id: command.c,v 1.107 1997/12/07 04:09:10 brian Exp $
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <netinet/in_systm.h>
|
1997-05-23 04:54:03 +00:00
|
|
|
#include <netinet/in.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <netinet/ip.h>
|
1997-05-23 04:54:03 +00:00
|
|
|
#include <arpa/inet.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <sys/socket.h>
|
1997-05-23 04:54:03 +00:00
|
|
|
#include <net/route.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <netdb.h>
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifndef NOALIAS
|
1997-05-23 04:54:03 +00:00
|
|
|
#include <alias.h>
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <ctype.h>
|
1997-06-09 03:27:43 +00:00
|
|
|
#include <errno.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <paths.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
#include "command.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
|
|
|
#include "phase.h"
|
|
|
|
#include "lcp.h"
|
|
|
|
#include "ipcp.h"
|
|
|
|
#include "modem.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "filter.h"
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifndef NOALIAS
|
1997-05-23 04:54:03 +00:00
|
|
|
#include "alias_cmd.h"
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "hdlc.h"
|
1997-05-26 00:44:10 +00:00
|
|
|
#include "loadalias.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "vars.h"
|
1997-05-10 01:22:19 +00:00
|
|
|
#include "systems.h"
|
|
|
|
#include "chat.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "os.h"
|
1997-06-25 19:30:05 +00:00
|
|
|
#include "server.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "route.h"
|
|
|
|
#include "ccp.h"
|
1997-10-26 12:42:13 +00:00
|
|
|
#include "ip.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "slcompress.h"
|
1997-11-09 18:51:23 +00:00
|
|
|
#include "auth.h"
|
1997-02-22 09:12:36 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
struct in_addr ifnetmask;
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
static int ShowCommand(struct cmdargs const *arg);
|
|
|
|
static int TerminalCommand(struct cmdargs const *arg);
|
|
|
|
static int QuitCommand(struct cmdargs const *arg);
|
|
|
|
static int CloseCommand(struct cmdargs const *arg);
|
|
|
|
static int DialCommand(struct cmdargs const *arg);
|
|
|
|
static int DownCommand(struct cmdargs const *arg);
|
|
|
|
static int AllowCommand(struct cmdargs const *arg);
|
|
|
|
static int SetCommand(struct cmdargs const *arg);
|
|
|
|
static int AddCommand(struct cmdargs const *arg);
|
|
|
|
static int DeleteCommand(struct cmdargs const *arg);
|
|
|
|
static int BgShellCommand(struct cmdargs const *arg);
|
|
|
|
static int FgShellCommand(struct cmdargs const *arg);
|
|
|
|
#ifndef NOALIAS
|
|
|
|
static int AliasCommand(struct cmdargs const *arg);
|
|
|
|
static int AliasEnable(struct cmdargs const *arg);
|
|
|
|
static int AliasOption(struct cmdargs const *arg);
|
|
|
|
#endif
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
HelpCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-08-25 00:29:32 +00:00
|
|
|
struct cmdtab const *cmd;
|
1997-11-23 20:05:18 +00:00
|
|
|
int n, cmax, dmax, cols;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!VarTerm)
|
|
|
|
return 0;
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
for (cmd = arg->cmd; cmd->name; cmd++)
|
1997-11-23 20:05:18 +00:00
|
|
|
if (strcasecmp(cmd->name, *arg->argv) == 0 &&
|
|
|
|
(cmd->lauth & VarLocalAuth)) {
|
1997-08-25 00:29:32 +00:00
|
|
|
fprintf(VarTerm, "%s\n", cmd->syntax);
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-11-23 20:05:18 +00:00
|
|
|
cmax = dmax = 0;
|
|
|
|
for (cmd = arg->cmd; cmd->func; cmd++)
|
|
|
|
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
|
|
|
|
if ((n = strlen(cmd->name)) > cmax)
|
|
|
|
cmax = n;
|
|
|
|
if ((n = strlen(cmd->helpmes)) > dmax)
|
|
|
|
dmax = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
cols = 80 / (dmax + cmax + 3);
|
1995-01-31 06:29:58 +00:00
|
|
|
n = 0;
|
1997-11-22 03:37:54 +00:00
|
|
|
for (cmd = arg->cmd; cmd->func; cmd++)
|
1995-02-27 10:57:54 +00:00
|
|
|
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
|
1997-11-23 20:05:18 +00:00
|
|
|
fprintf(VarTerm, " %-*.*s: %-*.*s",
|
|
|
|
cmax, cmax, cmd->name, dmax, dmax, cmd->helpmes);
|
|
|
|
if (++n % cols == 0)
|
|
|
|
fprintf(VarTerm, "\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-11-23 20:05:18 +00:00
|
|
|
if (n % cols != 0)
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "\n");
|
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-11-04 01:17:05 +00:00
|
|
|
IsInteractive(int Display)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
const char *mes = NULL;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1996-12-03 21:38:52 +00:00
|
|
|
if (mode & MODE_DDIAL)
|
|
|
|
mes = "Working in dedicated dial mode.";
|
1997-05-19 02:00:16 +00:00
|
|
|
else if (mode & MODE_BACKGROUND)
|
|
|
|
mes = "Working in background mode.";
|
1996-12-03 21:38:52 +00:00
|
|
|
else if (mode & MODE_AUTO)
|
1995-09-02 17:20:54 +00:00
|
|
|
mes = "Working in auto mode.";
|
1995-01-31 06:29:58 +00:00
|
|
|
else if (mode & MODE_DIRECT)
|
1995-09-02 17:20:54 +00:00
|
|
|
mes = "Working in direct mode.";
|
1995-01-31 06:29:58 +00:00
|
|
|
else if (mode & MODE_DEDICATED)
|
1995-09-02 17:20:54 +00:00
|
|
|
mes = "Working in dedicated mode.";
|
1995-01-31 06:29:58 +00:00
|
|
|
if (mes) {
|
1997-11-04 01:17:05 +00:00
|
|
|
if (Display && VarTerm)
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "%s\n", mes);
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return 1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
DialCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1995-10-08 14:57:32 +00:00
|
|
|
int tries;
|
1997-06-23 23:10:13 +00:00
|
|
|
int res;
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
if (LcpFsm.state > ST_CLOSED) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "LCP state is [%s]\n", StateNames[LcpFsm.state]);
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0 && (res = LoadCommand(arg)) != 0)
|
1997-11-12 16:34:51 +00:00
|
|
|
return res;
|
1997-11-11 22:58:14 +00:00
|
|
|
|
1995-10-08 14:57:32 +00:00
|
|
|
tries = 0;
|
|
|
|
do {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "Dial attempt %u of %d\n", ++tries, VarDialTries);
|
1997-11-08 00:28:11 +00:00
|
|
|
if (OpenModem() < 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (VarTerm)
|
1997-08-25 00:29:32 +00:00
|
|
|
fprintf(VarTerm, "Failed to open modem.\n");
|
1995-10-08 14:57:32 +00:00
|
|
|
break;
|
|
|
|
}
|
1997-06-23 23:10:13 +00:00
|
|
|
if ((res = DialModem()) == EX_DONE) {
|
1997-10-24 22:36:31 +00:00
|
|
|
nointr_sleep(1);
|
1997-11-22 03:37:54 +00:00
|
|
|
ModemTimeout(NULL);
|
1995-10-08 14:57:32 +00:00
|
|
|
PacketMode();
|
|
|
|
break;
|
1997-06-23 23:10:13 +00:00
|
|
|
} else if (res == EX_SIG)
|
|
|
|
return 1;
|
1995-10-08 14:57:32 +00:00
|
|
|
} while (VarDialTries == 0 || tries < VarDialTries);
|
1997-06-09 03:27:43 +00:00
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-21 16:21:39 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetLoopback(struct cmdargs const *arg)
|
1997-08-21 16:21:39 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc == 1)
|
|
|
|
if (!strcasecmp(*arg->argv, "on")) {
|
1997-08-21 16:21:39 +00:00
|
|
|
VarLoopback = 1;
|
1997-11-12 18:47:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
else if (!strcasecmp(*arg->argv, "off")) {
|
1997-08-21 16:21:39 +00:00
|
|
|
VarLoopback = 0;
|
1997-11-12 18:47:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1997-08-21 16:21:39 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1995-09-02 17:20:54 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShellCommand(struct cmdargs const *arg, int bg)
|
1995-09-02 17:20:54 +00:00
|
|
|
{
|
|
|
|
const char *shell;
|
|
|
|
pid_t shpid;
|
1997-06-09 03:27:43 +00:00
|
|
|
FILE *oVarTerm;
|
1997-11-22 03:37:54 +00:00
|
|
|
int argc;
|
|
|
|
char *argv[MAXARGS];
|
1996-12-22 17:29:33 +00:00
|
|
|
|
1996-10-10 11:27:35 +00:00
|
|
|
#ifdef SHELL_ONLY_INTERACTIVELY
|
1997-06-25 02:04:35 +00:00
|
|
|
/* we're only allowed to shell when we run ppp interactively */
|
1997-06-09 03:27:43 +00:00
|
|
|
if (mode != MODE_INTER) {
|
|
|
|
LogPrintf(LogWARN, "Can only start a shell in interactive mode\n");
|
|
|
|
return 1;
|
1995-09-02 17:20:54 +00:00
|
|
|
}
|
1997-06-25 02:04:35 +00:00
|
|
|
#endif
|
|
|
|
#ifdef NO_SHELL_IN_AUTO_INTERACTIVE
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-06-25 02:04:35 +00:00
|
|
|
/*
|
1997-08-25 00:29:32 +00:00
|
|
|
* we want to stop shell commands when we've got a telnet connection to an
|
|
|
|
* auto mode ppp
|
1997-06-25 02:04:35 +00:00
|
|
|
*/
|
1997-11-11 22:58:14 +00:00
|
|
|
if (VarTerm && !(mode & MODE_INTER)) {
|
1997-08-25 00:29:32 +00:00
|
|
|
LogPrintf(LogWARN, "Shell is not allowed interactively in auto mode\n");
|
1997-06-09 03:27:43 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc == 0)
|
1997-08-18 20:15:10 +00:00
|
|
|
if (!(mode & MODE_INTER)) {
|
1997-11-11 22:58:14 +00:00
|
|
|
if (VarTerm)
|
|
|
|
LogPrintf(LogWARN, "Can't start an interactive shell from"
|
|
|
|
" a telnet session\n");
|
|
|
|
else
|
|
|
|
LogPrintf(LogWARN, "Can only start an interactive shell in"
|
|
|
|
" interactive mode\n");
|
1997-08-18 20:15:10 +00:00
|
|
|
return 1;
|
|
|
|
} else if (bg) {
|
|
|
|
LogPrintf(LogWARN, "Can only start an interactive shell in"
|
1997-08-25 00:29:32 +00:00
|
|
|
" the foreground mode\n");
|
1997-08-18 20:15:10 +00:00
|
|
|
return 1;
|
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
if ((shell = getenv("SHELL")) == 0)
|
1997-06-09 03:27:43 +00:00
|
|
|
shell = _PATH_BSHELL;
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
if ((shpid = fork()) == 0) {
|
|
|
|
int dtablesize, i, fd;
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fd = fileno(VarTerm);
|
|
|
|
else if ((fd = open("/dev/null", O_RDWR)) == -1) {
|
|
|
|
LogPrintf(LogALERT, "Failed to open /dev/null: %s\n", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
dup2(fd, i);
|
|
|
|
|
|
|
|
if (fd > 2)
|
|
|
|
if (VarTerm) {
|
|
|
|
oVarTerm = VarTerm;
|
|
|
|
VarTerm = 0;
|
|
|
|
if (oVarTerm && oVarTerm != stdout)
|
|
|
|
fclose(oVarTerm);
|
|
|
|
} else
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
for (dtablesize = getdtablesize(), i = 3; i < dtablesize; i++)
|
1997-11-22 03:37:54 +00:00
|
|
|
close(i);
|
1997-08-25 00:29:32 +00:00
|
|
|
|
|
|
|
TtyOldMode();
|
1997-11-09 06:22:49 +00:00
|
|
|
setuid(geteuid());
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
1997-08-25 00:29:32 +00:00
|
|
|
/* substitute pseudo args */
|
1997-11-22 03:37:54 +00:00
|
|
|
argv[0] = strdup(arg->argv[0]);
|
|
|
|
for (argc = 1; argc < arg->argc; argc++) {
|
|
|
|
if (strcasecmp(arg->argv[argc], "HISADDR") == 0)
|
|
|
|
argv[argc] = strdup(inet_ntoa(IpcpInfo.his_ipaddr));
|
|
|
|
else if (strcasecmp(arg->argv[argc], "INTERFACE") == 0)
|
|
|
|
argv[argc] = strdup(IfDevName);
|
|
|
|
else if (strcasecmp(arg->argv[argc], "MYADDR") == 0)
|
|
|
|
argv[argc] = strdup(inet_ntoa(IpcpInfo.want_ipaddr));
|
|
|
|
else
|
|
|
|
argv[argc] = strdup(arg->argv[argc]);
|
|
|
|
}
|
|
|
|
argv[argc] = NULL;
|
1997-08-25 00:29:32 +00:00
|
|
|
if (bg) {
|
|
|
|
pid_t p;
|
|
|
|
|
|
|
|
p = getpid();
|
|
|
|
if (daemon(1, 1) == -1) {
|
1997-08-31 22:59:49 +00:00
|
|
|
LogPrintf(LogERROR, "%d: daemon: %s\n", p, strerror(errno));
|
1997-08-25 00:29:32 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1997-11-12 02:10:05 +00:00
|
|
|
} else if (VarTerm)
|
1997-11-22 03:37:54 +00:00
|
|
|
fprintf(VarTerm, "ppp: Pausing until %s finishes\n", arg->argv[0]);
|
|
|
|
execvp(argv[0], argv);
|
1997-10-12 01:49:37 +00:00
|
|
|
} else {
|
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "ppp: Pausing until %s finishes\n", shell);
|
1997-11-22 03:37:54 +00:00
|
|
|
execl(shell, shell, NULL);
|
1997-10-12 01:49:37 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
LogPrintf(LogWARN, "exec() of %s failed\n", arg->argc > 0 ? arg->argv[0] : shell);
|
1997-08-25 00:29:32 +00:00
|
|
|
exit(255);
|
|
|
|
}
|
|
|
|
if (shpid == (pid_t) - 1) {
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogERROR, "Fork failed: %s\n", strerror(errno));
|
1995-09-02 17:20:54 +00:00
|
|
|
} else {
|
|
|
|
int status;
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
waitpid(shpid, &status, 0);
|
1995-09-02 17:20:54 +00:00
|
|
|
}
|
1996-12-22 17:29:33 +00:00
|
|
|
|
1995-09-02 17:20:54 +00:00
|
|
|
TtyCommandMode(1);
|
1996-12-22 17:29:33 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
return (0);
|
1995-09-02 17:20:54 +00:00
|
|
|
}
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
static int
|
|
|
|
BgShellCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->argc == 0)
|
|
|
|
return -1;
|
|
|
|
return ShellCommand(arg, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
FgShellCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
return ShellCommand(arg, 0);
|
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const Commands[] = {
|
1997-08-25 00:29:32 +00:00
|
|
|
{"accept", NULL, AcceptCommand, LOCAL_AUTH,
|
|
|
|
"accept option request", "accept option .."},
|
|
|
|
{"add", NULL, AddCommand, LOCAL_AUTH,
|
|
|
|
"add route", "add dest mask gateway"},
|
1997-11-11 22:58:14 +00:00
|
|
|
{"allow", "auth", AllowCommand, LOCAL_AUTH,
|
|
|
|
"Allow ppp access", "allow users|modes ...."},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"bg", "!bg", BgShellCommand, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Run a background command", "[!]bg command"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"close", NULL, CloseCommand, LOCAL_AUTH,
|
|
|
|
"Close connection", "close"},
|
|
|
|
{"delete", NULL, DeleteCommand, LOCAL_AUTH,
|
1997-12-08 20:09:10 +00:00
|
|
|
"delete route", "delete dest"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"deny", NULL, DenyCommand, LOCAL_AUTH,
|
|
|
|
"Deny option request", "deny option .."},
|
|
|
|
{"dial", "call", DialCommand, LOCAL_AUTH,
|
|
|
|
"Dial and login", "dial|call [remote]"},
|
|
|
|
{"disable", NULL, DisableCommand, LOCAL_AUTH,
|
|
|
|
"Disable option", "disable option .."},
|
|
|
|
{"display", NULL, DisplayCommand, LOCAL_AUTH,
|
|
|
|
"Display option configs", "display"},
|
|
|
|
{"enable", NULL, EnableCommand, LOCAL_AUTH,
|
|
|
|
"Enable option", "enable option .."},
|
|
|
|
{"passwd", NULL, LocalAuthCommand, LOCAL_NO_AUTH,
|
1997-09-04 00:38:22 +00:00
|
|
|
"Password for manipulation", "passwd LocalPassword"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"load", NULL, LoadCommand, LOCAL_AUTH,
|
|
|
|
"Load settings", "load [remote]"},
|
|
|
|
{"save", NULL, SaveCommand, LOCAL_AUTH,
|
|
|
|
"Save settings", "save"},
|
|
|
|
{"set", "setup", SetCommand, LOCAL_AUTH,
|
|
|
|
"Set parameters", "set[up] var value"},
|
|
|
|
{"shell", "!", FgShellCommand, LOCAL_AUTH,
|
|
|
|
"Run a subshell", "shell|! [sh command]"},
|
|
|
|
{"show", NULL, ShowCommand, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show status and stats", "show var"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"term", NULL, TerminalCommand, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Enter terminal mode", "term"},
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifndef NOALIAS
|
1997-08-25 00:29:32 +00:00
|
|
|
{"alias", NULL, AliasCommand, LOCAL_AUTH,
|
|
|
|
"alias control", "alias option [yes|no]"},
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1997-08-25 00:29:32 +00:00
|
|
|
{"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
|
|
|
"Quit PPP program", "quit|bye [all]"},
|
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Display this message", "help|? [command]", Commands},
|
1997-08-25 00:29:32 +00:00
|
|
|
{NULL, "down", DownCommand, LOCAL_AUTH,
|
|
|
|
"Generate down event", "down"},
|
|
|
|
{NULL, NULL, NULL},
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
1997-08-21 16:21:39 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowLoopback(struct cmdargs const *arg)
|
1997-08-21 16:21:39 +00:00
|
|
|
{
|
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "Local loopback is %s\n", VarLoopback ? "on" : "off");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowLogLevel(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!VarTerm)
|
|
|
|
return 0;
|
1997-11-04 01:17:05 +00:00
|
|
|
|
|
|
|
fprintf(VarTerm, "Log: ");
|
|
|
|
for (i = LogMIN; i <= LogMAX; i++)
|
|
|
|
if (LogIsKept(i) & LOG_KEPT_SYSLOG)
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, " %s", LogName(i));
|
1997-11-04 01:17:05 +00:00
|
|
|
|
|
|
|
fprintf(VarTerm, "\nLocal:");
|
|
|
|
for (i = LogMIN; i <= LogMAX; i++)
|
|
|
|
if (LogIsKept(i) & LOG_KEPT_LOCAL)
|
|
|
|
fprintf(VarTerm, " %s", LogName(i));
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "\n");
|
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowEscape(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
int code, bit;
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!VarTerm)
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
if (EscMap[32]) {
|
1997-06-09 03:27:43 +00:00
|
|
|
for (code = 0; code < 32; code++)
|
|
|
|
if (EscMap[code])
|
1997-08-25 00:29:32 +00:00
|
|
|
for (bit = 0; bit < 8; bit++)
|
|
|
|
if (EscMap[code] & (1 << bit))
|
|
|
|
fprintf(VarTerm, " 0x%02x", (code << 3) + bit);
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-11-09 17:51:27 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowTimeout(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-09 17:51:27 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, " Idle Timer: %d secs LQR Timer: %d secs"
|
|
|
|
" Retry Timer: %d secs\n", VarIdleTimeout, VarLqrTimeout,
|
|
|
|
VarRetryTimeout);
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowStopped(struct cmdargs const *arg)
|
1997-08-17 20:45:50 +00:00
|
|
|
{
|
|
|
|
if (!VarTerm)
|
|
|
|
return 0;
|
1997-08-20 23:47:53 +00:00
|
|
|
|
|
|
|
fprintf(VarTerm, " Stopped Timer: LCP: ");
|
|
|
|
if (!LcpFsm.StoppedTimer.load)
|
|
|
|
fprintf(VarTerm, "Disabled");
|
|
|
|
else
|
|
|
|
fprintf(VarTerm, "%ld secs", LcpFsm.StoppedTimer.load / SECTICKS);
|
|
|
|
|
|
|
|
fprintf(VarTerm, ", IPCP: ");
|
|
|
|
if (!IpcpFsm.StoppedTimer.load)
|
|
|
|
fprintf(VarTerm, "Disabled");
|
|
|
|
else
|
|
|
|
fprintf(VarTerm, "%ld secs", IpcpFsm.StoppedTimer.load / SECTICKS);
|
|
|
|
|
|
|
|
fprintf(VarTerm, ", CCP: ");
|
|
|
|
if (!CcpFsm.StoppedTimer.load)
|
|
|
|
fprintf(VarTerm, "Disabled");
|
1997-08-17 20:45:50 +00:00
|
|
|
else
|
1997-08-20 23:47:53 +00:00
|
|
|
fprintf(VarTerm, "%ld secs", CcpFsm.StoppedTimer.load / SECTICKS);
|
|
|
|
|
|
|
|
fprintf(VarTerm, "\n");
|
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
return 0;
|
1997-08-17 20:45:50 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowAuthKey(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!VarTerm)
|
|
|
|
return 0;
|
|
|
|
fprintf(VarTerm, "AuthName = %s\n", VarAuthName);
|
|
|
|
fprintf(VarTerm, "AuthKey = %s\n", VarAuthKey);
|
1997-09-25 00:52:37 +00:00
|
|
|
#ifdef HAVE_DES
|
|
|
|
fprintf(VarTerm, "Encrypt = %s\n", VarMSChap ? "MSChap" : "MD5" );
|
|
|
|
#endif
|
1997-11-09 17:51:27 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowVersion(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-09 17:51:27 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "%s - %s \n", VarVersion, VarLocalVersion);
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowInitialMRU(struct cmdargs const *arg)
|
1997-06-01 01:13:04 +00:00
|
|
|
{
|
1997-11-09 17:51:27 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, " Initial MRU: %ld\n", VarMRU);
|
|
|
|
return 0;
|
1997-06-01 01:13:04 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowPreferredMTU(struct cmdargs const *arg)
|
1997-06-01 01:13:04 +00:00
|
|
|
{
|
1997-11-09 17:51:27 +00:00
|
|
|
if (VarTerm)
|
|
|
|
if (VarPrefMTU)
|
|
|
|
fprintf(VarTerm, " Preferred MTU: %ld\n", VarPrefMTU);
|
|
|
|
else
|
|
|
|
fprintf(VarTerm, " Preferred MTU: unspecified\n");
|
|
|
|
return 0;
|
1997-06-01 01:13:04 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowReconnect(struct cmdargs const *arg)
|
1997-04-21 01:02:02 +00:00
|
|
|
{
|
1997-11-09 17:51:27 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, " Reconnect Timer: %d, %d tries\n",
|
|
|
|
VarReconnectTimer, VarReconnectTries);
|
|
|
|
return 0;
|
1997-04-21 01:02:02 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowRedial(struct cmdargs const *arg)
|
1995-10-08 14:57:32 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!VarTerm)
|
|
|
|
return 0;
|
|
|
|
fprintf(VarTerm, " Redial Timer: ");
|
1995-10-08 14:57:32 +00:00
|
|
|
|
|
|
|
if (VarRedialTimeout >= 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, " %d seconds, ", VarRedialTimeout);
|
1997-08-25 00:29:32 +00:00
|
|
|
} else {
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, " Random 0 - %d seconds, ", REDIAL_PERIOD);
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, " Redial Next Timer: ");
|
1997-04-14 23:48:20 +00:00
|
|
|
|
|
|
|
if (VarRedialNextTimeout >= 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, " %d seconds, ", VarRedialNextTimeout);
|
1997-08-25 00:29:32 +00:00
|
|
|
} else {
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, " Random 0 - %d seconds, ", REDIAL_PERIOD);
|
1997-04-14 23:48:20 +00:00
|
|
|
}
|
|
|
|
|
1995-10-08 14:57:32 +00:00
|
|
|
if (VarDialTries)
|
1997-08-25 00:29:32 +00:00
|
|
|
fprintf(VarTerm, "%d dial tries", VarDialTries);
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "\n");
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
return 0;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
#ifndef NOMSEXT
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowMSExt(struct cmdargs const *arg)
|
1996-10-06 13:32:37 +00:00
|
|
|
{
|
1997-11-09 17:51:27 +00:00
|
|
|
if (VarTerm) {
|
|
|
|
fprintf(VarTerm, " MS PPP extention values \n");
|
|
|
|
fprintf(VarTerm, " Primary NS : %s\n", inet_ntoa(ns_entries[0]));
|
|
|
|
fprintf(VarTerm, " Secondary NS : %s\n", inet_ntoa(ns_entries[1]));
|
|
|
|
fprintf(VarTerm, " Primary NBNS : %s\n", inet_ntoa(nbns_entries[0]));
|
|
|
|
fprintf(VarTerm, " Secondary NBNS : %s\n", inet_ntoa(nbns_entries[1]));
|
|
|
|
}
|
|
|
|
return 0;
|
1996-10-06 13:32:37 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
#endif
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const ShowCommands[] = {
|
1997-08-25 00:29:32 +00:00
|
|
|
{"afilter", NULL, ShowAfilter, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show keep-alive filters", "show afilter option .."},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"auth", NULL, ShowAuthKey, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show auth details", "show auth"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"ccp", NULL, ReportCcpStatus, LOCAL_AUTH,
|
|
|
|
"Show CCP status", "show cpp"},
|
|
|
|
{"compress", NULL, ReportCompress, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show compression stats", "show compress"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"dfilter", NULL, ShowDfilter, LOCAL_AUTH,
|
|
|
|
"Show Demand filters", "show dfilteroption .."},
|
|
|
|
{"escape", NULL, ShowEscape, LOCAL_AUTH,
|
|
|
|
"Show escape characters", "show escape"},
|
|
|
|
{"hdlc", NULL, ReportHdlcStatus, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show HDLC errors", "show hdlc"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"ifilter", NULL, ShowIfilter, LOCAL_AUTH,
|
|
|
|
"Show Input filters", "show ifilter option .."},
|
|
|
|
{"ipcp", NULL, ReportIpcpStatus, LOCAL_AUTH,
|
|
|
|
"Show IPCP status", "show ipcp"},
|
|
|
|
{"lcp", NULL, ReportLcpStatus, LOCAL_AUTH,
|
|
|
|
"Show LCP status", "show lcp"},
|
|
|
|
{"loopback", NULL, ShowLoopback, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show loopback setting", "show loopback"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"log", NULL, ShowLogLevel, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show log levels", "show log"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"mem", NULL, ShowMemMap, LOCAL_AUTH,
|
|
|
|
"Show memory map", "show mem"},
|
|
|
|
{"modem", NULL, ShowModemStatus, LOCAL_AUTH,
|
|
|
|
"Show modem setups", "show modem"},
|
|
|
|
{"mru", NULL, ShowInitialMRU, LOCAL_AUTH,
|
|
|
|
"Show Initial MRU", "show mru"},
|
|
|
|
{"mtu", NULL, ShowPreferredMTU, LOCAL_AUTH,
|
|
|
|
"Show Preferred MTU", "show mtu"},
|
|
|
|
{"ofilter", NULL, ShowOfilter, LOCAL_AUTH,
|
|
|
|
"Show Output filters", "show ofilter option .."},
|
|
|
|
{"proto", NULL, ReportProtStatus, LOCAL_AUTH,
|
|
|
|
"Show protocol summary", "show proto"},
|
|
|
|
{"reconnect", NULL, ShowReconnect, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show reconnect timer", "show reconnect"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"redial", NULL, ShowRedial, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show Redial timeout", "show redial"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"route", NULL, ShowRoute, LOCAL_AUTH,
|
|
|
|
"Show routing table", "show route"},
|
|
|
|
{"timeout", NULL, ShowTimeout, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show Idle timeout", "show timeout"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"stopped", NULL, ShowStopped, LOCAL_AUTH,
|
1997-11-23 20:05:18 +00:00
|
|
|
"Show STOPPED timeout", "show stopped"},
|
1997-06-09 03:27:43 +00:00
|
|
|
#ifndef NOMSEXT
|
1997-08-25 00:29:32 +00:00
|
|
|
{"msext", NULL, ShowMSExt, LOCAL_AUTH,
|
|
|
|
"Show MS PPP extentions", "show msext"},
|
1997-06-09 03:27:43 +00:00
|
|
|
#endif
|
1997-08-25 00:29:32 +00:00
|
|
|
{"version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH,
|
|
|
|
"Show version string", "show version"},
|
|
|
|
{"help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Display this message", "show help|? [command]", ShowCommands},
|
1997-08-25 00:29:32 +00:00
|
|
|
{NULL, NULL, NULL},
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const *
|
1997-11-22 03:37:54 +00:00
|
|
|
FindCommand(struct cmdtab const *cmds, const char *str, int *pmatch)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
int nmatch;
|
|
|
|
int len;
|
1997-08-25 00:29:32 +00:00
|
|
|
struct cmdtab const *found;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
found = NULL;
|
|
|
|
len = strlen(str);
|
|
|
|
nmatch = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
while (cmds->func) {
|
1997-05-08 01:26:31 +00:00
|
|
|
if (cmds->name && strncasecmp(str, cmds->name, len) == 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (cmds->name[len] == '\0') {
|
1997-08-25 00:29:32 +00:00
|
|
|
*pmatch = 1;
|
|
|
|
return cmds;
|
1997-06-09 03:27:43 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
nmatch++;
|
|
|
|
found = cmds;
|
1997-08-25 00:29:32 +00:00
|
|
|
} else if (cmds->alias && strncasecmp(str, cmds->alias, len) == 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (cmds->alias[len] == '\0') {
|
1997-08-25 00:29:32 +00:00
|
|
|
*pmatch = 1;
|
|
|
|
return cmds;
|
1997-06-09 03:27:43 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
nmatch++;
|
|
|
|
found = cmds;
|
|
|
|
}
|
|
|
|
cmds++;
|
|
|
|
}
|
|
|
|
*pmatch = nmatch;
|
1997-06-09 03:27:43 +00:00
|
|
|
return found;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
FindExec(struct cmdtab const *cmds, int argc, char const *const *argv)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-08-25 00:29:32 +00:00
|
|
|
struct cmdtab const *cmd;
|
1995-01-31 06:29:58 +00:00
|
|
|
int val = 1;
|
|
|
|
int nmatch;
|
1997-11-22 03:37:54 +00:00
|
|
|
struct cmdargs arg;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
cmd = FindCommand(cmds, *argv, &nmatch);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (nmatch > 1)
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogWARN, "%s: Ambiguous command\n", *argv);
|
1997-11-22 03:37:54 +00:00
|
|
|
else if (cmd && (cmd->lauth & VarLocalAuth)) {
|
1997-11-23 20:05:18 +00:00
|
|
|
arg.cmd = cmds;
|
1997-11-22 03:37:54 +00:00
|
|
|
arg.argc = argc-1;
|
|
|
|
arg.argv = argv+1;
|
|
|
|
arg.data = cmd->args;
|
|
|
|
val = (cmd->func) (&arg);
|
|
|
|
} else
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogWARN, "%s: Invalid command\n", *argv);
|
|
|
|
|
|
|
|
if (val == -1)
|
|
|
|
LogPrintf(LogWARN, "Usage: %s\n", cmd->syntax);
|
1997-08-25 00:29:32 +00:00
|
|
|
else if (val)
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogCOMMAND, "%s: Failed %d\n", *argv, val);
|
|
|
|
|
|
|
|
return val;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1996-10-12 16:20:34 +00:00
|
|
|
int aft_cmd = 1;
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
void
|
1996-10-12 16:20:34 +00:00
|
|
|
Prompt()
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
const char *pconnect, *pauth;
|
1995-02-26 12:18:08 +00:00
|
|
|
|
1997-11-11 22:58:14 +00:00
|
|
|
if (!VarTerm || TermMode)
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
1995-02-26 12:18:08 +00:00
|
|
|
|
1996-10-12 16:20:34 +00:00
|
|
|
if (!aft_cmd)
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "\n");
|
1996-10-12 16:20:34 +00:00
|
|
|
else
|
|
|
|
aft_cmd = 0;
|
1995-02-26 12:18:08 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
if (VarLocalAuth == LOCAL_AUTH)
|
1995-02-26 12:18:08 +00:00
|
|
|
pauth = " ON ";
|
|
|
|
else
|
|
|
|
pauth = " on ";
|
1995-01-31 06:29:58 +00:00
|
|
|
if (IpcpFsm.state == ST_OPENED && phase == PHASE_NETWORK)
|
1995-02-26 12:18:08 +00:00
|
|
|
pconnect = "PPP";
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1995-02-26 12:18:08 +00:00
|
|
|
pconnect = "ppp";
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "%s%s%s> ", pconnect, pauth, VarShortHost);
|
|
|
|
fflush(VarTerm);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-11 22:58:14 +00:00
|
|
|
InterpretCommand(char *buff, int nb, int *argc, char ***argv)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
static char *vector[MAXARGS];
|
1995-01-31 06:29:58 +00:00
|
|
|
char *cp;
|
|
|
|
|
|
|
|
if (nb > 0) {
|
|
|
|
cp = buff + strcspn(buff, "\r\n");
|
|
|
|
if (cp)
|
|
|
|
*cp = '\0';
|
1997-11-11 22:58:14 +00:00
|
|
|
*argc = MakeArgs(buff, vector, VECSIZE(vector));
|
|
|
|
*argv = vector;
|
|
|
|
} else
|
|
|
|
*argc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-22 03:37:54 +00:00
|
|
|
RunCommand(int argc, char const *const *argv, const char *label)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
1997-11-13 14:43:20 +00:00
|
|
|
if (argc > 0) {
|
|
|
|
if (LogIsKept(LogCOMMAND)) {
|
|
|
|
static char buf[LINE_LEN];
|
|
|
|
int f, n;
|
|
|
|
|
|
|
|
*buf = '\0';
|
|
|
|
if (label) {
|
|
|
|
strcpy(buf, label);
|
|
|
|
strcat(buf, ": ");
|
|
|
|
}
|
|
|
|
n = strlen(buf);
|
|
|
|
for (f = 0; f < argc; f++) {
|
|
|
|
if (n < sizeof(buf)-1 && f)
|
|
|
|
buf[n++] = ' ';
|
|
|
|
strncpy(buf+n, argv[f], sizeof(buf)-n-1);
|
|
|
|
n += strlen(buf+n);
|
|
|
|
}
|
|
|
|
LogPrintf(LogCOMMAND, "%s\n", buf);
|
|
|
|
}
|
1997-11-11 22:58:14 +00:00
|
|
|
FindExec(Commands, argc, argv);
|
1997-11-13 14:43:20 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-11-11 22:58:14 +00:00
|
|
|
void
|
1997-11-13 14:43:20 +00:00
|
|
|
DecodeCommand(char *buff, int nb, const char *label)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
|
|
|
|
InterpretCommand(buff, nb, &argc, &argv);
|
1997-11-22 03:37:54 +00:00
|
|
|
RunCommand(argc, (char const *const *)argv, label);
|
1997-11-11 22:58:14 +00:00
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
ShowCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0)
|
|
|
|
FindExec(ShowCommands, arg->argc, arg->argv);
|
1997-06-09 03:27:43 +00:00
|
|
|
else if (VarTerm)
|
1997-11-22 03:37:54 +00:00
|
|
|
fprintf(VarTerm, "Use ``show ?'' to get a arg->cmd.\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogWARN, "show command must have arguments\n");
|
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
TerminalCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
if (LcpFsm.state > ST_CLOSED) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "LCP state is [%s]\n", StateNames[LcpFsm.state]);
|
|
|
|
return 1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-11-04 01:17:05 +00:00
|
|
|
if (!IsInteractive(1))
|
1997-08-25 00:29:32 +00:00
|
|
|
return (1);
|
1997-11-08 00:28:11 +00:00
|
|
|
if (OpenModem() < 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (VarTerm)
|
|
|
|
fprintf(VarTerm, "Failed to open modem.\n");
|
1997-08-25 00:29:32 +00:00
|
|
|
return (1);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
if (VarTerm) {
|
|
|
|
fprintf(VarTerm, "Enter to terminal mode.\n");
|
|
|
|
fprintf(VarTerm, "Type `~?' for help.\n");
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
TtyTermMode();
|
1997-08-25 00:29:32 +00:00
|
|
|
return (0);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
QuitCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-18 00:19:34 +00:00
|
|
|
if (VarTerm) {
|
|
|
|
DropClient();
|
|
|
|
if (mode & MODE_INTER)
|
|
|
|
Cleanup(EX_NORMAL);
|
1997-11-22 03:37:54 +00:00
|
|
|
else if (arg->argc > 0 && !strcasecmp(*arg->argv, "all") && VarLocalAuth&LOCAL_AUTH)
|
1997-11-18 00:19:34 +00:00
|
|
|
Cleanup(EX_NORMAL);
|
1997-11-11 22:58:14 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
CloseCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-05-24 17:32:42 +00:00
|
|
|
reconnect(RECON_FALSE);
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpClose();
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
DownCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
LcpDown();
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-04-21 01:02:02 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetModemSpeed(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
int speed;
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
if (strcasecmp(*arg->argv, "sync") == 0) {
|
1995-02-26 12:18:08 +00:00
|
|
|
VarSpeed = 0;
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
speed = atoi(*arg->argv);
|
1995-02-26 12:18:08 +00:00
|
|
|
if (IntToSpeed(speed) != B0) {
|
|
|
|
VarSpeed = speed;
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
LogPrintf(LogWARN, "%s: Invalid speed\n", *arg->argv);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-04-21 01:02:02 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetReconnect(struct cmdargs const *arg)
|
1997-04-21 01:02:02 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc == 2) {
|
|
|
|
VarReconnectTimer = atoi(arg->argv[0]);
|
|
|
|
VarReconnectTries = atoi(arg->argv[1]);
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
1997-04-21 01:02:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetRedialTimeout(struct cmdargs const *arg)
|
1995-10-08 14:57:32 +00:00
|
|
|
{
|
|
|
|
int timeout;
|
|
|
|
int tries;
|
1997-04-14 23:48:20 +00:00
|
|
|
char *dot;
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc == 1 || arg->argc == 2) {
|
|
|
|
if (strncasecmp(arg->argv[0], "random", 6) == 0 &&
|
|
|
|
(arg->argv[0][6] == '\0' || arg->argv[0][6] == '.')) {
|
1995-10-08 14:57:32 +00:00
|
|
|
VarRedialTimeout = -1;
|
1997-10-26 01:04:02 +00:00
|
|
|
randinit();
|
1997-06-09 03:27:43 +00:00
|
|
|
} else {
|
1997-11-22 03:37:54 +00:00
|
|
|
timeout = atoi(arg->argv[0]);
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
if (timeout >= 0)
|
1995-10-08 14:57:32 +00:00
|
|
|
VarRedialTimeout = timeout;
|
|
|
|
else {
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogWARN, "Invalid redial timeout\n");
|
1997-08-25 00:29:32 +00:00
|
|
|
return -1;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
|
|
|
}
|
1997-04-14 23:48:20 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
dot = strchr(arg->argv[0], '.');
|
1997-04-14 23:48:20 +00:00
|
|
|
if (dot) {
|
|
|
|
if (strcasecmp(++dot, "random") == 0) {
|
1997-08-25 00:29:32 +00:00
|
|
|
VarRedialNextTimeout = -1;
|
1997-10-26 01:04:02 +00:00
|
|
|
randinit();
|
1997-08-25 00:29:32 +00:00
|
|
|
} else {
|
|
|
|
timeout = atoi(dot);
|
|
|
|
if (timeout >= 0)
|
|
|
|
VarRedialNextTimeout = timeout;
|
|
|
|
else {
|
|
|
|
LogPrintf(LogWARN, "Invalid next redial timeout\n");
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1997-08-25 00:29:32 +00:00
|
|
|
}
|
1997-04-14 23:48:20 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
} else
|
|
|
|
VarRedialNextTimeout = NEXT_REDIAL_PERIOD; /* Default next timeout */
|
1997-04-14 23:48:20 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc == 2) {
|
|
|
|
tries = atoi(arg->argv[1]);
|
1995-10-08 14:57:32 +00:00
|
|
|
|
|
|
|
if (tries >= 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
VarDialTries = tries;
|
|
|
|
} else {
|
|
|
|
LogPrintf(LogWARN, "Invalid retry value\n");
|
|
|
|
return 1;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
|
|
|
|
1997-08-17 20:45:50 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetStoppedTimeout(struct cmdargs const *arg)
|
1997-08-17 20:45:50 +00:00
|
|
|
{
|
1997-08-20 23:47:53 +00:00
|
|
|
LcpFsm.StoppedTimer.load = 0;
|
|
|
|
IpcpFsm.StoppedTimer.load = 0;
|
|
|
|
CcpFsm.StoppedTimer.load = 0;
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc <= 3) {
|
|
|
|
if (arg->argc > 0) {
|
|
|
|
LcpFsm.StoppedTimer.load = atoi(arg->argv[0]) * SECTICKS;
|
|
|
|
if (arg->argc > 1) {
|
|
|
|
IpcpFsm.StoppedTimer.load = atoi(arg->argv[1]) * SECTICKS;
|
|
|
|
if (arg->argc > 2)
|
|
|
|
CcpFsm.StoppedTimer.load = atoi(arg->argv[2]) * SECTICKS;
|
1997-08-20 23:47:53 +00:00
|
|
|
}
|
|
|
|
}
|
1997-08-17 20:45:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1997-11-09 22:07:29 +00:00
|
|
|
#define ismask(x) \
|
|
|
|
(*x == '0' && strlen(x) == 4 && strspn(x+1, "0123456789.") == 3)
|
|
|
|
|
1997-06-25 19:30:05 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetServer(struct cmdargs const *arg)
|
1997-06-25 19:30:05 +00:00
|
|
|
{
|
|
|
|
int res = -1;
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0 && arg->argc < 4) {
|
1997-11-09 22:07:29 +00:00
|
|
|
const char *port, *passwd, *mask;
|
|
|
|
|
|
|
|
/* What's what ? */
|
1997-11-22 03:37:54 +00:00
|
|
|
port = arg->argv[0];
|
|
|
|
if (arg->argc == 2)
|
|
|
|
if (ismask(arg->argv[1])) {
|
1997-11-09 22:07:29 +00:00
|
|
|
passwd = NULL;
|
1997-11-22 03:37:54 +00:00
|
|
|
mask = arg->argv[1];
|
1997-11-09 22:07:29 +00:00
|
|
|
} else {
|
1997-11-22 03:37:54 +00:00
|
|
|
passwd = arg->argv[1];
|
1997-11-09 22:07:29 +00:00
|
|
|
mask = NULL;
|
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
else if (arg->argc == 3) {
|
|
|
|
passwd = arg->argv[1];
|
|
|
|
mask = arg->argv[2];
|
1997-11-09 22:07:29 +00:00
|
|
|
if (!ismask(mask))
|
|
|
|
return -1;
|
|
|
|
} else
|
|
|
|
passwd = mask = NULL;
|
|
|
|
|
|
|
|
if (passwd == NULL)
|
|
|
|
VarHaveLocalAuthKey = 0;
|
|
|
|
else {
|
|
|
|
strncpy(VarLocalAuthKey, passwd, sizeof VarLocalAuthKey);
|
|
|
|
VarLocalAuthKey[sizeof VarLocalAuthKey - 1] = '\0';
|
|
|
|
VarHaveLocalAuthKey = 1;
|
|
|
|
}
|
|
|
|
LocalAuthInit();
|
|
|
|
|
|
|
|
if (strcasecmp(port, "none") == 0) {
|
|
|
|
int oserver;
|
|
|
|
|
|
|
|
if (mask != NULL || passwd != NULL)
|
|
|
|
return -1;
|
|
|
|
oserver = server;
|
1997-06-25 19:30:05 +00:00
|
|
|
ServerClose();
|
1997-11-09 22:07:29 +00:00
|
|
|
if (oserver != -1)
|
|
|
|
LogPrintf(LogPHASE, "Disabling server port.\n");
|
1997-06-25 19:30:05 +00:00
|
|
|
res = 0;
|
1997-11-09 22:07:29 +00:00
|
|
|
} else if (*port == '/') {
|
|
|
|
mode_t imask;
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-11-09 22:07:29 +00:00
|
|
|
if (mask != NULL) {
|
1997-08-25 00:29:32 +00:00
|
|
|
unsigned m;
|
|
|
|
|
1997-11-09 22:07:29 +00:00
|
|
|
if (sscanf(mask, "%o", &m) == 1)
|
|
|
|
imask = m;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
} else
|
|
|
|
imask = (mode_t)-1;
|
|
|
|
res = ServerLocalOpen(port, imask);
|
1997-07-12 19:22:34 +00:00
|
|
|
} else {
|
1997-11-09 22:07:29 +00:00
|
|
|
int iport;
|
|
|
|
|
|
|
|
if (mask != NULL)
|
|
|
|
return -1;
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-11-09 22:07:29 +00:00
|
|
|
if (strspn(port, "0123456789") != strlen(port)) {
|
|
|
|
struct servent *s;
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1997-11-09 22:07:29 +00:00
|
|
|
if ((s = getservbyname(port, "tcp")) == NULL) {
|
|
|
|
iport = 0;
|
|
|
|
LogPrintf(LogWARN, "%s: Invalid port or service\n", port);
|
1997-08-25 00:29:32 +00:00
|
|
|
} else
|
1997-11-09 22:07:29 +00:00
|
|
|
iport = ntohs(s->s_port);
|
1997-07-12 19:22:34 +00:00
|
|
|
} else
|
1997-11-09 22:07:29 +00:00
|
|
|
iport = atoi(port);
|
|
|
|
res = iport ? ServerTcpOpen(iport) : -1;
|
1997-07-12 19:22:34 +00:00
|
|
|
}
|
1997-11-09 22:07:29 +00:00
|
|
|
}
|
1997-06-25 19:30:05 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1997-04-21 01:02:02 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetModemParity(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
return arg->argc > 0 ? ChangeParity(*arg->argv) : -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetLogLevel(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
int i;
|
|
|
|
int res;
|
1997-11-22 03:37:54 +00:00
|
|
|
int argc;
|
|
|
|
char const *const *argv, *argp;
|
1997-11-04 01:17:05 +00:00
|
|
|
void (*Discard)(int), (*Keep)(int);
|
|
|
|
void (*DiscardAll)(void);
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
argc = arg->argc;
|
|
|
|
argv = arg->argv;
|
1997-06-09 03:27:43 +00:00
|
|
|
res = 0;
|
1997-11-18 19:38:27 +00:00
|
|
|
if (argc == 0 || strcasecmp(argv[0], "local")) {
|
1997-11-04 01:17:05 +00:00
|
|
|
Discard = LogDiscard;
|
|
|
|
Keep = LogKeep;
|
|
|
|
DiscardAll = LogDiscardAll;
|
|
|
|
} else {
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
Discard = LogDiscardLocal;
|
|
|
|
Keep = LogKeepLocal;
|
|
|
|
DiscardAll = LogDiscardAllLocal;
|
|
|
|
}
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
if (argc == 0 || (argv[0][0] != '+' && argv[0][0] != '-'))
|
1997-11-22 03:37:54 +00:00
|
|
|
DiscardAll();
|
1997-06-09 03:27:43 +00:00
|
|
|
while (argc--) {
|
1997-11-22 03:37:54 +00:00
|
|
|
argp = **argv == '+' || **argv == '-' ? *argv + 1 : *argv;
|
1997-06-09 03:27:43 +00:00
|
|
|
for (i = LogMIN; i <= LogMAX; i++)
|
1997-11-22 03:37:54 +00:00
|
|
|
if (strcasecmp(argp, LogName(i)) == 0) {
|
1997-08-25 00:29:32 +00:00
|
|
|
if (**argv == '-')
|
1997-11-04 01:17:05 +00:00
|
|
|
(*Discard)(i);
|
1997-08-25 00:29:32 +00:00
|
|
|
else
|
1997-11-04 01:17:05 +00:00
|
|
|
(*Keep)(i);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
if (i > LogMAX) {
|
1997-11-22 03:37:54 +00:00
|
|
|
LogPrintf(LogWARN, "%s: Invalid log value\n", argp);
|
1997-06-09 03:27:43 +00:00
|
|
|
res = -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
argv++;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return res;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetEscape(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
int code;
|
1997-11-22 03:37:54 +00:00
|
|
|
int argc = arg->argc;
|
|
|
|
char const *const *argv = arg->argv;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
for (code = 0; code < 33; code++)
|
|
|
|
EscMap[code] = 0;
|
1997-11-22 03:37:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
while (argc-- > 0) {
|
|
|
|
sscanf(*argv++, "%x", &code);
|
|
|
|
code &= 0xff;
|
1997-08-25 00:29:32 +00:00
|
|
|
EscMap[code >> 3] |= (1 << (code & 7));
|
1995-01-31 06:29:58 +00:00
|
|
|
EscMap[32] = 1;
|
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetInitialMRU(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-01 01:13:04 +00:00
|
|
|
long mru;
|
1997-11-22 03:37:54 +00:00
|
|
|
const char *err;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
mru = atol(*arg->argv);
|
1997-06-01 01:13:04 +00:00
|
|
|
if (mru < MIN_MRU)
|
1997-06-09 03:27:43 +00:00
|
|
|
err = "Given MRU value (%ld) is too small.\n";
|
1995-01-31 06:29:58 +00:00
|
|
|
else if (mru > MAX_MRU)
|
1997-06-09 03:27:43 +00:00
|
|
|
err = "Given MRU value (%ld) is too big.\n";
|
|
|
|
else {
|
1995-01-31 06:29:58 +00:00
|
|
|
VarMRU = mru;
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
LogPrintf(LogWARN, err, mru);
|
|
|
|
}
|
|
|
|
return -1;
|
1997-06-01 01:13:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetPreferredMTU(struct cmdargs const *arg)
|
1997-06-01 01:13:04 +00:00
|
|
|
{
|
|
|
|
long mtu;
|
1997-11-22 03:37:54 +00:00
|
|
|
const char *err;
|
1997-06-01 01:13:04 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
mtu = atol(*arg->argv);
|
1997-06-09 03:27:43 +00:00
|
|
|
if (mtu == 0) {
|
1997-06-01 01:13:04 +00:00
|
|
|
VarPrefMTU = 0;
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
|
|
|
} else if (mtu < MIN_MTU)
|
|
|
|
err = "Given MTU value (%ld) is too small.\n";
|
1997-06-01 01:13:04 +00:00
|
|
|
else if (mtu > MAX_MTU)
|
1997-06-09 03:27:43 +00:00
|
|
|
err = "Given MTU value (%ld) is too big.\n";
|
|
|
|
else {
|
1997-06-01 01:13:04 +00:00
|
|
|
VarPrefMTU = mtu;
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
LogPrintf(LogWARN, err, mtu);
|
|
|
|
}
|
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetIdleTimeout(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
VarIdleTimeout = atoi(arg->argv[0]);
|
1997-08-25 00:29:32 +00:00
|
|
|
UpdateIdleTimer(); /* If we're connected, restart the idle timer */
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 1) {
|
|
|
|
VarLqrTimeout = atoi(arg->argv[1]);
|
1995-02-26 12:18:08 +00:00
|
|
|
if (VarLqrTimeout < 1)
|
|
|
|
VarLqrTimeout = 30;
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 2) {
|
|
|
|
VarRetryTimeout = atoi(arg->argv[2]);
|
1995-02-26 12:18:08 +00:00
|
|
|
if (VarRetryTimeout < 1 || VarRetryTimeout > 10)
|
|
|
|
VarRetryTimeout = 3;
|
|
|
|
}
|
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct in_addr
|
1997-11-22 03:37:54 +00:00
|
|
|
GetIpAddr(const char *cp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
struct hostent *hp;
|
|
|
|
struct in_addr ipaddr;
|
|
|
|
|
|
|
|
hp = gethostbyname(cp);
|
|
|
|
if (hp && hp->h_addrtype == AF_INET)
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(&ipaddr, hp->h_addr, hp->h_length);
|
1995-01-31 06:29:58 +00:00
|
|
|
else if (inet_aton(cp, &ipaddr) == 0)
|
|
|
|
ipaddr.s_addr = 0;
|
1997-08-25 00:29:32 +00:00
|
|
|
return (ipaddr);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetInterfaceAddr(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
DefMyAddress.ipaddr.s_addr = DefHisAddress.ipaddr.s_addr = 0L;
|
1997-08-19 01:10:24 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 4)
|
1997-08-25 00:29:32 +00:00
|
|
|
return -1;
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1997-08-19 01:10:24 +00:00
|
|
|
HaveTriggerAddress = 0;
|
|
|
|
ifnetmask.s_addr = 0;
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
if (ParseAddr(arg->argc, arg->argv,
|
1997-08-25 00:29:32 +00:00
|
|
|
&DefMyAddress.ipaddr,
|
|
|
|
&DefMyAddress.mask,
|
|
|
|
&DefMyAddress.width) == 0)
|
|
|
|
return 1;
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 1) {
|
|
|
|
if (ParseAddr(arg->argc, arg->argv+1,
|
1997-05-10 01:22:19 +00:00
|
|
|
&DefHisAddress.ipaddr,
|
|
|
|
&DefHisAddress.mask,
|
|
|
|
&DefHisAddress.width) == 0)
|
1997-08-25 00:29:32 +00:00
|
|
|
return 2;
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 2) {
|
|
|
|
ifnetmask = GetIpAddr(arg->argv[2]);
|
|
|
|
if (arg->argc > 3) {
|
|
|
|
TriggerAddress = GetIpAddr(arg->argv[3]);
|
1997-08-25 00:29:32 +00:00
|
|
|
HaveTriggerAddress = 1;
|
1995-07-08 08:28:10 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-08-19 01:10:24 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* For backwards compatibility, 0.0.0.0 means any address.
|
|
|
|
*/
|
|
|
|
if (DefMyAddress.ipaddr.s_addr == 0) {
|
|
|
|
DefMyAddress.mask.s_addr = 0;
|
|
|
|
DefMyAddress.width = 0;
|
|
|
|
}
|
|
|
|
if (DefHisAddress.ipaddr.s_addr == 0) {
|
|
|
|
DefHisAddress.mask.s_addr = 0;
|
|
|
|
DefHisAddress.width = 0;
|
|
|
|
}
|
1997-08-21 17:07:30 +00:00
|
|
|
IpcpInfo.want_ipaddr.s_addr = DefMyAddress.ipaddr.s_addr;
|
|
|
|
IpcpInfo.his_ipaddr.s_addr = DefHisAddress.ipaddr.s_addr;
|
|
|
|
|
1997-11-11 22:58:14 +00:00
|
|
|
if ((mode & MODE_AUTO) &&
|
|
|
|
OsSetIpaddress(DefMyAddress.ipaddr, DefHisAddress.ipaddr, ifnetmask) < 0)
|
|
|
|
return 4;
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
#ifndef NOMSEXT
|
1996-10-06 13:32:37 +00:00
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
SetMSEXT(struct in_addr * pri_addr,
|
|
|
|
struct in_addr * sec_addr,
|
|
|
|
int argc,
|
1997-11-22 03:37:54 +00:00
|
|
|
char const *const *argv)
|
1996-10-06 13:32:37 +00:00
|
|
|
{
|
|
|
|
int dummyint;
|
|
|
|
struct in_addr dummyaddr;
|
|
|
|
|
|
|
|
pri_addr->s_addr = sec_addr->s_addr = 0L;
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
if (argc > 0) {
|
1996-10-06 13:32:37 +00:00
|
|
|
ParseAddr(argc, argv++, pri_addr, &dummyaddr, &dummyint);
|
1997-08-25 00:29:32 +00:00
|
|
|
if (--argc > 0)
|
1996-10-06 13:32:37 +00:00
|
|
|
ParseAddr(argc, argv++, sec_addr, &dummyaddr, &dummyint);
|
|
|
|
else
|
|
|
|
sec_addr->s_addr = pri_addr->s_addr;
|
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
/*
|
|
|
|
* if the primary/secondary ns entries are 0.0.0.0 we should set them to
|
|
|
|
* either the localhost's ip, or the values in /etc/resolv.conf ??
|
|
|
|
*
|
|
|
|
* up to you if you want to implement this...
|
|
|
|
*/
|
1996-10-06 13:32:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetNS(struct cmdargs const *arg)
|
1996-10-06 13:32:37 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
SetMSEXT(&ns_entries[0], &ns_entries[1], arg->argc, arg->argv);
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1996-10-06 13:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetNBNS(struct cmdargs const *arg)
|
1996-10-06 13:32:37 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
SetMSEXT(&nbns_entries[0], &nbns_entries[1], arg->argc, arg->argv);
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1996-10-06 13:32:37 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
#endif /* MS_EXT */
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-09-22 00:46:56 +00:00
|
|
|
int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetVariable(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
u_long map;
|
1997-11-22 03:37:54 +00:00
|
|
|
const char *argp;
|
|
|
|
int param = (int)arg->data;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0)
|
|
|
|
argp = *arg->argv;
|
1997-06-11 03:57:51 +00:00
|
|
|
else
|
1997-11-22 03:37:54 +00:00
|
|
|
argp = "";
|
1997-06-11 03:57:51 +00:00
|
|
|
|
|
|
|
switch (param) {
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_AUTHKEY:
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarAuthKey, argp, sizeof(VarAuthKey) - 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarAuthKey[sizeof(VarAuthKey) - 1] = '\0';
|
|
|
|
break;
|
|
|
|
case VAR_AUTHNAME:
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarAuthName, argp, sizeof(VarAuthName) - 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarAuthName[sizeof(VarAuthName) - 1] = '\0';
|
|
|
|
break;
|
|
|
|
case VAR_DIAL:
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarDialScript, argp, sizeof(VarDialScript) - 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarDialScript[sizeof(VarDialScript) - 1] = '\0';
|
|
|
|
break;
|
|
|
|
case VAR_LOGIN:
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarLoginScript, argp, sizeof(VarLoginScript) - 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarLoginScript[sizeof(VarLoginScript) - 1] = '\0';
|
|
|
|
break;
|
|
|
|
case VAR_DEVICE:
|
1997-09-22 00:46:56 +00:00
|
|
|
if (modem != -1)
|
|
|
|
LogPrintf(LogWARN, "Cannot change device to \"%s\" when \"%s\" is open\n",
|
1997-11-22 03:37:54 +00:00
|
|
|
argp, VarDevice);
|
1997-09-22 00:46:56 +00:00
|
|
|
else {
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarDevice, argp, sizeof(VarDevice) - 1);
|
1997-09-22 00:46:56 +00:00
|
|
|
VarDevice[sizeof(VarDevice) - 1] = '\0';
|
1997-10-26 01:04:02 +00:00
|
|
|
VarBaseDevice = strrchr(VarDevice, '/');
|
1997-09-22 00:46:56 +00:00
|
|
|
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
|
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
|
|
|
case VAR_ACCMAP:
|
1997-11-22 03:37:54 +00:00
|
|
|
sscanf(argp, "%lx", &map);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarAccmap = map;
|
|
|
|
break;
|
|
|
|
case VAR_PHONE:
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarPhoneList, argp, sizeof(VarPhoneList) - 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarPhoneList[sizeof(VarPhoneList) - 1] = '\0';
|
|
|
|
strcpy(VarPhoneCopy, VarPhoneList);
|
|
|
|
VarNextPhone = VarPhoneCopy;
|
1997-11-09 22:56:15 +00:00
|
|
|
VarAltPhone = NULL;
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
|
|
|
case VAR_HANGUP:
|
1997-11-22 03:37:54 +00:00
|
|
|
strncpy(VarHangupScript, argp, sizeof(VarHangupScript) - 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
VarHangupScript[sizeof(VarHangupScript) - 1] = '\0';
|
|
|
|
break;
|
1997-09-25 00:52:37 +00:00
|
|
|
#ifdef HAVE_DES
|
1997-09-17 23:17:57 +00:00
|
|
|
case VAR_ENC:
|
1997-11-22 03:37:54 +00:00
|
|
|
VarMSChap = !strcasecmp(argp, "mschap");
|
1997-09-17 23:17:57 +00:00
|
|
|
break;
|
1997-09-25 00:52:37 +00:00
|
|
|
#endif
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetCtsRts(struct cmdargs const *arg)
|
1996-12-22 17:09:17 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
if (strcmp(*arg->argv, "on") == 0)
|
1997-10-26 01:04:02 +00:00
|
|
|
VarCtsRts = 1;
|
1997-11-22 03:37:54 +00:00
|
|
|
else if (strcmp(*arg->argv, "off") == 0)
|
1997-10-26 01:04:02 +00:00
|
|
|
VarCtsRts = 0;
|
1996-12-22 17:09:17 +00:00
|
|
|
else
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
1996-12-22 17:09:17 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1996-12-22 17:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetOpenMode(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0) {
|
|
|
|
if (strcmp(*arg->argv, "active") == 0)
|
1995-01-31 06:29:58 +00:00
|
|
|
VarOpenMode = OPEN_ACTIVE;
|
1997-11-22 03:37:54 +00:00
|
|
|
else if (strcmp(*arg->argv, "passive") == 0)
|
1995-01-31 06:29:58 +00:00
|
|
|
VarOpenMode = OPEN_PASSIVE;
|
|
|
|
else
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const SetCommands[] = {
|
1997-08-25 00:29:32 +00:00
|
|
|
{"accmap", NULL, SetVariable, LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Set accmap value", "set accmap hex-value", (const void *) VAR_ACCMAP},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"afilter", NULL, SetAfilter, LOCAL_AUTH,
|
|
|
|
"Set keep Alive filter", "set afilter ..."},
|
|
|
|
{"authkey", "key", SetVariable, LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Set authentication key", "set authkey|key key", (const void *) VAR_AUTHKEY},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"authname", NULL, SetVariable, LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Set authentication name", "set authname name", (const void *) VAR_AUTHNAME},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"ctsrts", NULL, SetCtsRts, LOCAL_AUTH,
|
|
|
|
"Use CTS/RTS modem signalling", "set ctsrts [on|off]"},
|
1997-11-22 03:37:54 +00:00
|
|
|
{"device", "line", SetVariable, LOCAL_AUTH, "Set modem device name",
|
|
|
|
"set device|line device-name", (const void *) VAR_DEVICE},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"dfilter", NULL, SetDfilter, LOCAL_AUTH,
|
|
|
|
"Set demand filter", "set dfilter ..."},
|
|
|
|
{"dial", NULL, SetVariable, LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Set dialing script", "set dial chat-script", (const void *) VAR_DIAL},
|
1997-09-25 00:52:37 +00:00
|
|
|
#ifdef HAVE_DES
|
1997-11-22 03:37:54 +00:00
|
|
|
{"encrypt", NULL, SetVariable, LOCAL_AUTH, "Set CHAP encryption algorithm",
|
|
|
|
"set encrypt MSChap|MD5", (const void *) VAR_ENC},
|
1997-09-25 00:52:37 +00:00
|
|
|
#endif
|
1997-08-25 00:29:32 +00:00
|
|
|
{"escape", NULL, SetEscape, LOCAL_AUTH,
|
|
|
|
"Set escape characters", "set escape hex-digit ..."},
|
|
|
|
{"hangup", NULL, SetVariable, LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Set hangup script", "set hangup chat-script", (const void *) VAR_HANGUP},
|
|
|
|
{"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH, "Set destination address",
|
|
|
|
"set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"ifilter", NULL, SetIfilter, LOCAL_AUTH,
|
|
|
|
"Set input filter", "set ifilter ..."},
|
|
|
|
{"loopback", NULL, SetLoopback, LOCAL_AUTH,
|
|
|
|
"Set loopback facility", "set loopback on|off"},
|
|
|
|
{"log", NULL, SetLogLevel, LOCAL_AUTH,
|
1997-11-04 01:17:05 +00:00
|
|
|
"Set log level", "set log [local] [+|-]value..."},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"login", NULL, SetVariable, LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Set login script", "set login chat-script", (const void *) VAR_LOGIN},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"mru", NULL, SetInitialMRU, LOCAL_AUTH,
|
|
|
|
"Set Initial MRU value", "set mru value"},
|
|
|
|
{"mtu", NULL, SetPreferredMTU, LOCAL_AUTH,
|
|
|
|
"Set Preferred MTU value", "set mtu value"},
|
|
|
|
{"ofilter", NULL, SetOfilter, LOCAL_AUTH,
|
|
|
|
"Set output filter", "set ofilter ..."},
|
|
|
|
{"openmode", NULL, SetOpenMode, LOCAL_AUTH,
|
|
|
|
"Set open mode", "set openmode [active|passive]"},
|
|
|
|
{"parity", NULL, SetModemParity, LOCAL_AUTH,
|
|
|
|
"Set modem parity", "set parity [odd|even|none]"},
|
1997-11-22 03:37:54 +00:00
|
|
|
{"phone", NULL, SetVariable, LOCAL_AUTH, "Set telephone number(s)",
|
|
|
|
"set phone phone1[:phone2[...]]", (const void *) VAR_PHONE},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"reconnect", NULL, SetReconnect, LOCAL_AUTH,
|
|
|
|
"Set Reconnect timeout", "set reconnect value ntries"},
|
1997-11-22 03:37:54 +00:00
|
|
|
{"redial", NULL, SetRedialTimeout, LOCAL_AUTH, "Set Redial timeout",
|
|
|
|
"set redial value|random[.value|random] [dial_attempts]"},
|
|
|
|
{"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH, "Set STOPPED timeouts",
|
|
|
|
"set stopped [LCPseconds [IPCPseconds [CCPseconds]]]"},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"server", "socket", SetServer, LOCAL_AUTH,
|
|
|
|
"Set server port", "set server|socket TcpPort|LocalName|none [mask]"},
|
|
|
|
{"speed", NULL, SetModemSpeed, LOCAL_AUTH,
|
|
|
|
"Set modem speed", "set speed value"},
|
|
|
|
{"timeout", NULL, SetIdleTimeout, LOCAL_AUTH,
|
|
|
|
"Set Idle timeout", "set timeout value"},
|
1997-06-09 03:27:43 +00:00
|
|
|
#ifndef NOMSEXT
|
1997-08-25 00:29:32 +00:00
|
|
|
{"ns", NULL, SetNS, LOCAL_AUTH,
|
|
|
|
"Set NameServer", "set ns pri-addr [sec-addr]"},
|
|
|
|
{"nbns", NULL, SetNBNS, LOCAL_AUTH,
|
|
|
|
"Set NetBIOS NameServer", "set nbns pri-addr [sec-addr]"},
|
1997-06-09 03:27:43 +00:00
|
|
|
#endif
|
1997-08-25 00:29:32 +00:00
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Display this message", "set help|? [command]", SetCommands},
|
1997-08-25 00:29:32 +00:00
|
|
|
{NULL, NULL, NULL},
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0)
|
|
|
|
FindExec(SetCommands, arg->argc, arg->argv);
|
1997-06-09 03:27:43 +00:00
|
|
|
else if (VarTerm)
|
1997-11-22 03:37:54 +00:00
|
|
|
fprintf(VarTerm, "Use `set ?' to get a arg->cmd or `set ? <var>' for"
|
1997-06-09 03:27:43 +00:00
|
|
|
" syntax help.\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogWARN, "set command must have arguments\n");
|
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
AddCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
struct in_addr dest, gateway, netmask;
|
1997-12-07 04:09:15 +00:00
|
|
|
int gw;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-12-07 04:09:15 +00:00
|
|
|
if (arg->argc != 3 && arg->argc != 2)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (arg->argc == 2)
|
|
|
|
if (strcasecmp(arg->argv[0], "default"))
|
|
|
|
return -1;
|
|
|
|
else {
|
|
|
|
dest.s_addr = netmask.s_addr = INADDR_ANY;
|
|
|
|
gw = 1;
|
|
|
|
}
|
|
|
|
else {
|
1997-11-22 03:37:54 +00:00
|
|
|
if (strcasecmp(arg->argv[0], "MYADDR") == 0)
|
1997-06-28 01:34:03 +00:00
|
|
|
dest = IpcpInfo.want_ipaddr;
|
|
|
|
else
|
1997-11-22 03:37:54 +00:00
|
|
|
dest = GetIpAddr(arg->argv[0]);
|
|
|
|
netmask = GetIpAddr(arg->argv[1]);
|
1997-12-07 04:09:15 +00:00
|
|
|
gw = 2;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-12-07 04:09:15 +00:00
|
|
|
if (strcasecmp(arg->argv[gw], "HISADDR") == 0)
|
|
|
|
gateway = IpcpInfo.his_ipaddr;
|
|
|
|
else if (strcasecmp(arg->argv[gw], "INTERFACE") == 0)
|
|
|
|
gateway.s_addr = INADDR_ANY;
|
|
|
|
else
|
|
|
|
gateway = GetIpAddr(arg->argv[gw]);
|
|
|
|
OsSetRoute(RTM_ADD, dest, gateway, netmask);
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
DeleteCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-12-07 04:09:15 +00:00
|
|
|
struct in_addr dest, none;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-12-07 04:09:15 +00:00
|
|
|
if (arg->argc == 1)
|
|
|
|
if(strcasecmp(arg->argv[0], "all") == 0)
|
|
|
|
DeleteIfRoutes(0);
|
|
|
|
else {
|
|
|
|
if (strcasecmp(arg->argv[0], "MYADDR") == 0)
|
|
|
|
dest = IpcpInfo.want_ipaddr;
|
|
|
|
else if (strcasecmp(arg->argv[0], "default") == 0)
|
|
|
|
dest.s_addr = INADDR_ANY;
|
1997-06-13 03:59:36 +00:00
|
|
|
else
|
1997-12-07 04:09:15 +00:00
|
|
|
dest = GetIpAddr(arg->argv[0]);
|
|
|
|
none.s_addr = INADDR_ANY;
|
|
|
|
OsSetRoute(RTM_DELETE, dest, none, none);
|
|
|
|
}
|
|
|
|
else
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1997-05-23 04:54:03 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifndef NOALIAS
|
1997-05-23 04:54:03 +00:00
|
|
|
static struct cmdtab const AliasCommands[] =
|
|
|
|
{
|
1997-08-25 00:29:32 +00:00
|
|
|
{"enable", NULL, AliasEnable, LOCAL_AUTH,
|
|
|
|
"enable IP aliasing", "alias enable [yes|no]"},
|
|
|
|
{"port", NULL, AliasRedirectPort, LOCAL_AUTH,
|
|
|
|
"port redirection", "alias port [proto addr_local:port_local port_alias]"},
|
|
|
|
{"addr", NULL, AliasRedirectAddr, LOCAL_AUTH,
|
|
|
|
"static address translation", "alias addr [addr_local addr_alias]"},
|
|
|
|
{"deny_incoming", NULL, AliasOption, LOCAL_AUTH,
|
|
|
|
"stop incoming connections", "alias deny_incoming [yes|no]",
|
1997-11-22 03:37:54 +00:00
|
|
|
(const void *) PKT_ALIAS_DENY_INCOMING},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"log", NULL, AliasOption, LOCAL_AUTH,
|
|
|
|
"log aliasing link creation", "alias log [yes|no]",
|
1997-11-22 03:37:54 +00:00
|
|
|
(const void *) PKT_ALIAS_LOG},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"same_ports", NULL, AliasOption, LOCAL_AUTH,
|
|
|
|
"try to leave port numbers unchanged", "alias same_ports [yes|no]",
|
1997-11-22 03:37:54 +00:00
|
|
|
(const void *) PKT_ALIAS_SAME_PORTS},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"use_sockets", NULL, AliasOption, LOCAL_AUTH,
|
|
|
|
"allocate host sockets", "alias use_sockets [yes|no]",
|
1997-11-22 03:37:54 +00:00
|
|
|
(const void *) PKT_ALIAS_USE_SOCKETS},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"unregistered_only", NULL, AliasOption, LOCAL_AUTH,
|
|
|
|
"alias unregistered (private) IP address space only",
|
|
|
|
"alias unregistered_only [yes|no]",
|
1997-11-22 03:37:54 +00:00
|
|
|
(const void *) PKT_ALIAS_UNREGISTERED_ONLY},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Display this message", "alias help|? [command]", AliasCommands},
|
1997-08-25 00:29:32 +00:00
|
|
|
{NULL, NULL, NULL},
|
1997-05-23 04:54:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
AliasCommand(struct cmdargs const *arg)
|
1997-05-23 04:54:03 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0)
|
|
|
|
FindExec(AliasCommands, arg->argc, arg->argv);
|
1997-06-09 03:27:43 +00:00
|
|
|
else if (VarTerm)
|
1997-11-22 03:37:54 +00:00
|
|
|
fprintf(VarTerm, "Use `alias help' to get a arg->cmd or `alias help <option>'"
|
1997-06-09 03:27:43 +00:00
|
|
|
" for syntax help.\n");
|
1997-05-23 04:54:03 +00:00
|
|
|
else
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogWARN, "alias command must have arguments\n");
|
1997-05-23 04:54:03 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1997-05-23 04:54:03 +00:00
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
AliasEnable(struct cmdargs const *arg)
|
1997-05-23 04:54:03 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc == 1)
|
|
|
|
if (strcasecmp(arg->argv[0], "yes") == 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!(mode & MODE_ALIAS)) {
|
1997-08-25 00:29:32 +00:00
|
|
|
if (loadAliasHandlers(&VarAliasHandlers) == 0) {
|
|
|
|
mode |= MODE_ALIAS;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
LogPrintf(LogWARN, "Cannot load alias library\n");
|
|
|
|
return 1;
|
1997-06-09 03:27:43 +00:00
|
|
|
}
|
|
|
|
return 0;
|
1997-11-22 03:37:54 +00:00
|
|
|
} else if (strcasecmp(arg->argv[0], "no") == 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
if (mode & MODE_ALIAS) {
|
1997-08-25 00:29:32 +00:00
|
|
|
unloadAliasHandlers();
|
|
|
|
mode &= ~MODE_ALIAS;
|
1997-06-09 03:27:43 +00:00
|
|
|
}
|
|
|
|
return 0;
|
1997-05-26 00:44:10 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1997-05-23 04:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
AliasOption(struct cmdargs const *arg)
|
1997-05-23 04:54:03 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
unsigned param = (unsigned)arg->data;
|
|
|
|
if (arg->argc == 1)
|
|
|
|
if (strcasecmp(arg->argv[0], "yes") == 0) {
|
1997-08-25 00:29:32 +00:00
|
|
|
if (mode & MODE_ALIAS) {
|
1997-11-22 03:37:54 +00:00
|
|
|
VarPacketAliasSetMode(param, param);
|
1997-08-25 00:29:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
LogPrintf(LogWARN, "alias not enabled\n");
|
1997-11-22 03:37:54 +00:00
|
|
|
} else if (strcmp(arg->argv[0], "no") == 0) {
|
1997-08-25 00:29:32 +00:00
|
|
|
if (mode & MODE_ALIAS) {
|
1997-11-22 03:37:54 +00:00
|
|
|
VarPacketAliasSetMode(0, param);
|
1997-08-25 00:29:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
LogPrintf(LogWARN, "alias not enabled\n");
|
|
|
|
}
|
|
|
|
return -1;
|
1997-05-23 04:54:03 +00:00
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif /* #ifndef NOALIAS */
|
1997-11-11 22:58:14 +00:00
|
|
|
|
|
|
|
static struct cmdtab const AllowCommands[] = {
|
|
|
|
{"users", "user", AllowUsers, LOCAL_AUTH,
|
|
|
|
"Allow users access to ppp", "allow users logname..."},
|
|
|
|
{"modes", "mode", AllowModes, LOCAL_AUTH,
|
|
|
|
"Only allow certain ppp modes", "allow modes mode..."},
|
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Display this message", "allow help|? [command]", AllowCommands},
|
1997-11-11 22:58:14 +00:00
|
|
|
{NULL, NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
AllowCommand(struct cmdargs const *arg)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
if (arg->argc > 0)
|
|
|
|
FindExec(AllowCommands, arg->argc, arg->argv);
|
1997-11-11 22:58:14 +00:00
|
|
|
else if (VarTerm)
|
1997-11-22 03:37:54 +00:00
|
|
|
fprintf(VarTerm, "Use `allow ?' to get a arg->cmd or `allow ? <cmd>' for"
|
1997-11-11 22:58:14 +00:00
|
|
|
" syntax help.\n");
|
|
|
|
else
|
|
|
|
LogPrintf(LogWARN, "allow command must have arguments\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|