2001-06-13 21:52:19 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
|
|
|
|
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
|
|
|
|
* Internet Initiative Japan, Inc (IIJ)
|
|
|
|
* All rights reserved.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
2001-06-13 21:52:19 +00:00
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#include <sys/param.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#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>
|
1998-05-21 21:49:08 +00:00
|
|
|
#include <sys/un.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1998-08-29 23:02:39 +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>
|
2002-08-27 20:11:58 +00:00
|
|
|
#include <stdarg.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
1999-08-19 18:15:52 +00:00
|
|
|
#ifndef NONAT
|
2000-03-14 01:47:02 +00:00
|
|
|
#ifdef LOCALNAT
|
1999-04-26 08:54:34 +00:00
|
|
|
#include "alias.h"
|
2000-03-14 01:47:02 +00:00
|
|
|
#else
|
|
|
|
#include <alias.h>
|
1998-09-17 00:45:27 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2000-03-14 01:47:02 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "layer.h"
|
1998-06-15 19:06:25 +00:00
|
|
|
#include "defs.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 "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
1997-12-13 02:37:33 +00:00
|
|
|
#include "iplist.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "throughput.h"
|
|
|
|
#include "slcompress.h"
|
1998-08-26 17:39:37 +00:00
|
|
|
#include "lqr.h"
|
|
|
|
#include "hdlc.h"
|
2000-07-19 02:10:35 +00:00
|
|
|
#include "lcp.h"
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ncpaddr.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "ipcp.h"
|
1999-08-19 18:15:52 +00:00
|
|
|
#ifndef NONAT
|
1999-09-08 07:34:52 +00:00
|
|
|
#include "nat_cmd.h"
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1997-05-10 01:22:19 +00:00
|
|
|
#include "systems.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "filter.h"
|
|
|
|
#include "descriptor.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "route.h"
|
|
|
|
#include "ccp.h"
|
1997-11-09 18:51:23 +00:00
|
|
|
#include "auth.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "async.h"
|
|
|
|
#include "link.h"
|
|
|
|
#include "physical.h"
|
|
|
|
#include "mp.h"
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
#include "radius.h"
|
|
|
|
#endif
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ipv6cp.h"
|
|
|
|
#include "ncp.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "bundle.h"
|
|
|
|
#include "server.h"
|
|
|
|
#include "prompt.h"
|
|
|
|
#include "chat.h"
|
|
|
|
#include "chap.h"
|
1998-08-07 18:42:51 +00:00
|
|
|
#include "cbcp.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "datalink.h"
|
1998-10-22 02:32:50 +00:00
|
|
|
#include "iface.h"
|
1999-11-17 21:12:35 +00:00
|
|
|
#include "id.h"
|
2001-08-15 13:53:38 +00:00
|
|
|
#include "probe.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
/* ``set'' values */
|
|
|
|
#define VAR_AUTHKEY 0
|
|
|
|
#define VAR_DIAL 1
|
|
|
|
#define VAR_LOGIN 2
|
|
|
|
#define VAR_AUTHNAME 3
|
|
|
|
#define VAR_AUTOLOAD 4
|
|
|
|
#define VAR_WINSIZE 5
|
|
|
|
#define VAR_DEVICE 6
|
|
|
|
#define VAR_ACCMAP 7
|
|
|
|
#define VAR_MRRU 8
|
|
|
|
#define VAR_MRU 9
|
|
|
|
#define VAR_MTU 10
|
|
|
|
#define VAR_OPENMODE 11
|
|
|
|
#define VAR_PHONE 12
|
|
|
|
#define VAR_HANGUP 13
|
|
|
|
#define VAR_IDLETIMEOUT 14
|
|
|
|
#define VAR_LQRPERIOD 15
|
|
|
|
#define VAR_LCPRETRY 16
|
|
|
|
#define VAR_CHAPRETRY 17
|
|
|
|
#define VAR_PAPRETRY 18
|
|
|
|
#define VAR_CCPRETRY 19
|
|
|
|
#define VAR_IPCPRETRY 20
|
|
|
|
#define VAR_DNS 21
|
|
|
|
#define VAR_NBNS 22
|
|
|
|
#define VAR_MODE 23
|
1998-08-07 18:42:51 +00:00
|
|
|
#define VAR_CALLBACK 24
|
|
|
|
#define VAR_CBCP 25
|
1998-08-25 17:48:43 +00:00
|
|
|
#define VAR_CHOKED 26
|
1998-10-26 19:07:39 +00:00
|
|
|
#define VAR_SENDPIPE 27
|
|
|
|
#define VAR_RECVPIPE 28
|
1999-01-28 01:56:34 +00:00
|
|
|
#define VAR_RADIUS 29
|
1999-02-16 00:16:56 +00:00
|
|
|
#define VAR_CD 30
|
1999-05-08 11:07:56 +00:00
|
|
|
#define VAR_PARITY 31
|
|
|
|
#define VAR_CRTSCTS 32
|
1999-09-04 00:00:21 +00:00
|
|
|
#define VAR_URGENTPORTS 33
|
1999-10-25 13:49:44 +00:00
|
|
|
#define VAR_LOGOUT 34
|
2000-06-11 02:30:51 +00:00
|
|
|
#define VAR_IFQUEUE 35
|
2001-06-18 15:00:22 +00:00
|
|
|
#define VAR_MPPE 36
|
2002-08-29 02:44:58 +00:00
|
|
|
#define VAR_IPV6CPRETRY 37
|
2004-07-17 01:07:53 +00:00
|
|
|
#define VAR_RAD_ALIVE 38
|
2004-07-29 05:59:43 +00:00
|
|
|
#define VAR_PPPOE 39
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
/* ``accept|deny|disable|enable'' masks */
|
|
|
|
#define NEG_HISMASK (1)
|
|
|
|
#define NEG_MYMASK (2)
|
|
|
|
|
|
|
|
/* ``accept|deny|disable|enable'' values */
|
|
|
|
#define NEG_ACFCOMP 40
|
1999-02-18 00:52:15 +00:00
|
|
|
#define NEG_CHAP05 41
|
|
|
|
#define NEG_CHAP80 42
|
|
|
|
#define NEG_CHAP80LM 43
|
|
|
|
#define NEG_DEFLATE 44
|
1999-06-09 16:54:04 +00:00
|
|
|
#define NEG_DNS 45
|
2004-12-13 12:51:19 +00:00
|
|
|
#define NEG_ECHO 46
|
|
|
|
#define NEG_ENDDISC 47
|
|
|
|
#define NEG_LQR 48
|
|
|
|
#define NEG_PAP 49
|
|
|
|
#define NEG_PPPDDEFLATE 50
|
|
|
|
#define NEG_PRED1 51
|
|
|
|
#define NEG_PROTOCOMP 52
|
|
|
|
#define NEG_SHORTSEQ 53
|
|
|
|
#define NEG_VJCOMP 54
|
|
|
|
#define NEG_MPPE 55
|
|
|
|
#define NEG_CHAP81 56
|
|
|
|
|
|
|
|
const char Version[] = "3.4.2";
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
static int ShowCommand(struct cmdargs const *);
|
|
|
|
static int TerminalCommand(struct cmdargs const *);
|
|
|
|
static int QuitCommand(struct cmdargs const *);
|
|
|
|
static int OpenCommand(struct cmdargs const *);
|
|
|
|
static int CloseCommand(struct cmdargs const *);
|
|
|
|
static int DownCommand(struct cmdargs const *);
|
|
|
|
static int SetCommand(struct cmdargs const *);
|
|
|
|
static int LinkCommand(struct cmdargs const *);
|
|
|
|
static int AddCommand(struct cmdargs const *);
|
|
|
|
static int DeleteCommand(struct cmdargs const *);
|
|
|
|
static int NegotiateCommand(struct cmdargs const *);
|
1998-06-12 20:12:26 +00:00
|
|
|
static int ClearCommand(struct cmdargs const *);
|
1998-10-22 02:32:50 +00:00
|
|
|
static int RunListCommand(struct cmdargs const *);
|
|
|
|
static int IfaceAddCommand(struct cmdargs const *);
|
|
|
|
static int IfaceDeleteCommand(struct cmdargs const *);
|
|
|
|
static int IfaceClearCommand(struct cmdargs const *);
|
1998-10-27 22:53:22 +00:00
|
|
|
static int SetProcTitle(struct cmdargs const *);
|
1999-08-19 18:15:52 +00:00
|
|
|
#ifndef NONAT
|
2000-03-31 14:26:23 +00:00
|
|
|
static int NatEnable(struct cmdargs const *);
|
|
|
|
static int NatOption(struct cmdargs const *);
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static const char *
|
|
|
|
showcx(struct cmdtab const *cmd)
|
|
|
|
{
|
|
|
|
if (cmd->lauth & LOCAL_CX)
|
|
|
|
return "(c)";
|
|
|
|
else if (cmd->lauth & LOCAL_CX_OPT)
|
|
|
|
return "(o)";
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
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;
|
1998-05-21 21:49:08 +00:00
|
|
|
int n, cmax, dmax, cols, cxlen;
|
|
|
|
const char *cx;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!arg->prompt) {
|
|
|
|
log_Printf(LogWARN, "help: Cannot help without a prompt\n");
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn) {
|
|
|
|
for (cmd = arg->cmdtab; cmd->name || cmd->alias; cmd++)
|
|
|
|
if ((cmd->lauth & arg->prompt->auth) &&
|
|
|
|
((cmd->name && !strcasecmp(cmd->name, arg->argv[arg->argn])) ||
|
|
|
|
(cmd->alias && !strcasecmp(cmd->alias, arg->argv[arg->argn])))) {
|
|
|
|
prompt_Printf(arg->prompt, "%s %s\n", cmd->syntax, showcx(cmd));
|
1997-08-25 00:29:32 +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
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1997-11-23 20:05:18 +00:00
|
|
|
cmax = dmax = 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
for (cmd = arg->cmdtab; cmd->func; cmd++)
|
|
|
|
if (cmd->name && (cmd->lauth & arg->prompt->auth)) {
|
|
|
|
if ((n = strlen(cmd->name) + strlen(showcx(cmd))) > cmax)
|
1997-11-23 20:05:18 +00:00
|
|
|
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;
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "(o) = Optional context,"
|
|
|
|
" (c) = Context required\n");
|
|
|
|
for (cmd = arg->cmdtab; cmd->func; cmd++)
|
|
|
|
if (cmd->name && (cmd->lauth & arg->prompt->auth)) {
|
|
|
|
cx = showcx(cmd);
|
|
|
|
cxlen = cmax - strlen(cmd->name);
|
1998-10-17 12:28:05 +00:00
|
|
|
if (n % cols != 0)
|
|
|
|
prompt_Printf(arg->prompt, " ");
|
|
|
|
prompt_Printf(arg->prompt, "%s%-*.*s: %-*.*s",
|
1998-05-21 21:49:08 +00:00
|
|
|
cmd->name, cxlen, cxlen, cx, dmax, dmax, cmd->helpmes);
|
1997-11-23 20:05:18 +00:00
|
|
|
if (++n % cols == 0)
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-11-23 20:05:18 +00:00
|
|
|
if (n % cols != 0)
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "\n");
|
1997-06-09 03:27:43 +00:00
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
2000-07-19 02:10:35 +00:00
|
|
|
static int
|
|
|
|
IdentCommand(struct cmdargs const *arg)
|
|
|
|
{
|
2001-11-03 21:45:32 +00:00
|
|
|
Concatinate(arg->cx->physical->link.lcp.cfg.ident,
|
|
|
|
sizeof arg->cx->physical->link.lcp.cfg.ident,
|
|
|
|
arg->argc - arg->argn, arg->argv + arg->argn);
|
2000-07-19 02:10:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SendIdentification(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->cx->state < DATALINK_LCP) {
|
|
|
|
log_Printf(LogWARN, "sendident: link has not reached LCP\n");
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return lcp_SendIdentification(&arg->cx->physical->link.lcp) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static int
|
|
|
|
CloneCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
char namelist[LINE_LEN];
|
|
|
|
char *name;
|
|
|
|
int f;
|
|
|
|
|
|
|
|
if (arg->argc == arg->argn)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
namelist[sizeof namelist - 1] = '\0';
|
|
|
|
for (f = arg->argn; f < arg->argc; f++) {
|
|
|
|
strncpy(namelist, arg->argv[f], sizeof namelist - 1);
|
|
|
|
for(name = strtok(namelist, ", "); name; name = strtok(NULL,", "))
|
|
|
|
bundle_DatalinkClone(arg->bundle, arg->cx, name);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
RemoveCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc != arg->argn)
|
|
|
|
return -1;
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->cx->state != DATALINK_CLOSED) {
|
|
|
|
log_Printf(LogWARN, "remove: Cannot delete links that aren't closed\n");
|
|
|
|
return 2;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
bundle_DatalinkRemove(arg->bundle, arg->cx);
|
|
|
|
return 0;
|
|
|
|
}
|
1998-01-23 04:36:42 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static int
|
|
|
|
RenameCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->argc != arg->argn + 1)
|
|
|
|
return -1;
|
1997-11-11 22:58:14 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (bundle_RenameDatalink(arg->bundle, arg->cx, arg->argv[arg->argn]))
|
|
|
|
return 0;
|
1997-06-09 03:27:43 +00:00
|
|
|
|
2002-06-15 08:03:30 +00:00
|
|
|
log_Printf(LogWARN, "%s -> %s: target name already exists\n",
|
1998-05-21 21:49:08 +00:00
|
|
|
arg->cx->name, arg->argv[arg->argn]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-11-03 21:45:32 +00:00
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
LoadCommand(struct cmdargs const *arg)
|
|
|
|
{
|
1998-10-31 17:38:47 +00:00
|
|
|
const char *err;
|
|
|
|
int n, mode;
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1998-10-31 17:38:47 +00:00
|
|
|
mode = arg->bundle->phys_type.all;
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1998-10-31 17:38:47 +00:00
|
|
|
if (arg->argn < arg->argc) {
|
|
|
|
for (n = arg->argn; n < arg->argc; n++)
|
|
|
|
if ((err = system_IsValid(arg->argv[n], arg->prompt, mode)) != NULL) {
|
|
|
|
log_Printf(LogWARN, "%s: %s\n", arg->argv[n], err);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = arg->argn; n < arg->argc; n++) {
|
|
|
|
bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]);
|
|
|
|
system_Select(arg->bundle, arg->argv[n], CONFFILE, arg->prompt, arg->cx);
|
|
|
|
}
|
|
|
|
bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]);
|
|
|
|
} else if ((err = system_IsValid("default", arg->prompt, mode)) != NULL) {
|
|
|
|
log_Printf(LogWARN, "default: %s\n", err);
|
1998-05-21 21:49:08 +00:00
|
|
|
return 1;
|
|
|
|
} else {
|
1998-10-31 17:38:47 +00:00
|
|
|
bundle_SetLabel(arg->bundle, "default");
|
|
|
|
system_Select(arg->bundle, "default", CONFFILE, arg->prompt, arg->cx);
|
|
|
|
bundle_SetLabel(arg->bundle, "default");
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1998-10-31 17:38:47 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 21:45:32 +00:00
|
|
|
static int
|
|
|
|
LogCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
char buf[LINE_LEN];
|
|
|
|
|
|
|
|
if (arg->argn < arg->argc) {
|
|
|
|
char *argv[MAXARGS];
|
|
|
|
int argc = arg->argc - arg->argn;
|
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if (argc >= (int)(sizeof argv / sizeof argv[0])) {
|
2001-11-03 21:45:32 +00:00
|
|
|
argc = sizeof argv / sizeof argv[0] - 1;
|
|
|
|
log_Printf(LogWARN, "Truncating log command to %d args\n", argc);
|
|
|
|
}
|
2001-11-22 04:23:49 +00:00
|
|
|
command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1, getpid());
|
2001-11-03 21:45:32 +00:00
|
|
|
Concatinate(buf, sizeof buf, argc, (const char *const *)argv);
|
|
|
|
log_Printf(LogLOG, "%s\n", buf);
|
|
|
|
command_Free(argc, argv);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-09-05 01:46:52 +00:00
|
|
|
SaveCommand(struct cmdargs const *arg __unused)
|
1998-05-21 21:49:08 +00:00
|
|
|
{
|
2001-11-03 21:45:32 +00:00
|
|
|
log_Printf(LogWARN, "save command is not yet implemented.\n");
|
1998-05-21 21:49:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1997-08-21 16:21:39 +00:00
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
DialCommand(struct cmdargs const *arg)
|
1997-08-21 16:21:39 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
int res;
|
|
|
|
|
1998-05-29 18:32:11 +00:00
|
|
|
if ((arg->cx && !(arg->cx->physical->type & (PHYS_INTERACTIVE|PHYS_AUTO)))
|
|
|
|
|| (!arg->cx &&
|
1998-06-12 17:45:10 +00:00
|
|
|
(arg->bundle->phys_type.all & ~(PHYS_INTERACTIVE|PHYS_AUTO)))) {
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogWARN, "Manual dial is only available for auto and"
|
|
|
|
" interactive links\n");
|
|
|
|
return 1;
|
1998-03-13 01:36:10 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
if (arg->argc > arg->argn && (res = LoadCommand(arg)) != 0)
|
|
|
|
return res;
|
|
|
|
|
1998-07-31 19:50:24 +00:00
|
|
|
bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL, 1);
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
return 0;
|
1997-08-21 16:21:39 +00:00
|
|
|
}
|
|
|
|
|
1998-08-29 23:02:39 +00:00
|
|
|
#define isinword(ch) (isalnum(ch) || (ch) == '_')
|
|
|
|
|
|
|
|
static char *
|
|
|
|
strstrword(char *big, const char *little)
|
|
|
|
{
|
|
|
|
/* Get the first occurance of the word ``little'' in ``big'' */
|
|
|
|
char *pos;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
pos = big;
|
|
|
|
len = strlen(little);
|
|
|
|
|
|
|
|
while ((pos = strstr(pos, little)) != NULL)
|
1999-06-10 09:34:57 +00:00
|
|
|
if ((pos != big && isinword(pos[-1])) || isinword(pos[len]))
|
1998-08-29 23:02:39 +00:00
|
|
|
pos++;
|
1999-06-10 09:34:57 +00:00
|
|
|
else if (pos != big && pos[-1] == '\\')
|
|
|
|
memmove(pos - 1, pos, strlen(pos) + 1);
|
|
|
|
else
|
|
|
|
break;
|
1998-08-29 23:02:39 +00:00
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
subst(char *tgt, const char *oldstr, const char *newstr)
|
|
|
|
{
|
|
|
|
/* tgt is a malloc()d area... realloc() as necessary */
|
|
|
|
char *word, *ntgt;
|
|
|
|
int ltgt, loldstr, lnewstr, pos;
|
|
|
|
|
|
|
|
if ((word = strstrword(tgt, oldstr)) == NULL)
|
|
|
|
return tgt;
|
|
|
|
|
|
|
|
ltgt = strlen(tgt) + 1;
|
|
|
|
loldstr = strlen(oldstr);
|
|
|
|
lnewstr = strlen(newstr);
|
|
|
|
do {
|
|
|
|
pos = word - tgt;
|
|
|
|
if (loldstr > lnewstr)
|
|
|
|
bcopy(word + loldstr, word + lnewstr, ltgt - pos - loldstr);
|
|
|
|
if (loldstr != lnewstr) {
|
|
|
|
ntgt = realloc(tgt, ltgt += lnewstr - loldstr);
|
|
|
|
if (ntgt == NULL)
|
|
|
|
break; /* Oh wonderful ! */
|
|
|
|
word = ntgt + pos;
|
|
|
|
tgt = ntgt;
|
|
|
|
}
|
|
|
|
if (lnewstr > loldstr)
|
2005-02-08 10:38:24 +00:00
|
|
|
bcopy(word + loldstr, word + lnewstr, ltgt - pos - lnewstr);
|
1998-08-29 23:02:39 +00:00
|
|
|
bcopy(newstr, word, lnewstr);
|
|
|
|
} while ((word = strstrword(word, oldstr)));
|
|
|
|
|
|
|
|
return tgt;
|
|
|
|
}
|
|
|
|
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
static char *
|
|
|
|
substip(char *tgt, const char *oldstr, struct in_addr ip)
|
|
|
|
{
|
|
|
|
return subst(tgt, oldstr, inet_ntoa(ip));
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2002-05-27 23:19:53 +00:00
|
|
|
substlong(char *tgt, const char *oldstr, long l)
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
{
|
2002-05-27 23:19:53 +00:00
|
|
|
char buf[23];
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
|
2002-05-27 23:19:53 +00:00
|
|
|
snprintf(buf, sizeof buf, "%ld", l);
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
|
|
|
|
return subst(tgt, oldstr, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
substull(char *tgt, const char *oldstr, unsigned long long ull)
|
|
|
|
{
|
|
|
|
char buf[21];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof buf, "%llu", ull);
|
|
|
|
|
|
|
|
return subst(tgt, oldstr, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NOINET6
|
|
|
|
static char *
|
|
|
|
substipv6(char *tgt, const char *oldstr, const struct ncpaddr *ip)
|
|
|
|
{
|
|
|
|
return subst(tgt, oldstr, ncpaddr_ntoa(ip));
|
|
|
|
}
|
2003-06-20 16:15:59 +00:00
|
|
|
|
|
|
|
#ifndef NORADIUS
|
|
|
|
static char *
|
|
|
|
substipv6prefix(char *tgt, const char *oldstr, const uint8_t *ipv6prefix)
|
|
|
|
{
|
|
|
|
uint8_t ipv6addr[INET6_ADDRSTRLEN];
|
|
|
|
uint8_t prefix[INET6_ADDRSTRLEN + sizeof("/128") - 1];
|
|
|
|
|
|
|
|
if (ipv6prefix) {
|
|
|
|
inet_ntop(AF_INET6, &ipv6prefix[2], ipv6addr, sizeof(ipv6addr));
|
|
|
|
snprintf(prefix, sizeof(prefix), "%s/%d", ipv6addr, ipv6prefix[1]);
|
|
|
|
} else
|
|
|
|
prefix[0] = '\0';
|
|
|
|
return subst(tgt, oldstr, prefix);
|
|
|
|
}
|
|
|
|
#endif
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
#endif
|
|
|
|
|
1999-02-11 10:14:08 +00:00
|
|
|
void
|
|
|
|
command_Expand(char **nargv, int argc, char const *const *oargv,
|
1999-06-09 08:47:36 +00:00
|
|
|
struct bundle *bundle, int inc0, pid_t pid)
|
1998-08-29 23:02:39 +00:00
|
|
|
{
|
2001-11-03 21:45:32 +00:00
|
|
|
int arg, secs;
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
char uptime[20];
|
|
|
|
unsigned long long oin, oout, pin, pout;
|
1998-08-29 23:02:39 +00:00
|
|
|
|
1998-12-14 01:15:34 +00:00
|
|
|
if (inc0)
|
|
|
|
arg = 0; /* Start at arg 0 */
|
|
|
|
else {
|
|
|
|
nargv[0] = strdup(oargv[0]);
|
|
|
|
arg = 1;
|
|
|
|
}
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
|
|
|
|
secs = bundle_Uptime(bundle);
|
|
|
|
snprintf(uptime, sizeof uptime, "%d:%02d:%02d",
|
|
|
|
secs / 3600, (secs / 60) % 60, secs % 60);
|
|
|
|
oin = bundle->ncp.ipcp.throughput.OctetsIn;
|
|
|
|
oout = bundle->ncp.ipcp.throughput.OctetsOut;
|
|
|
|
pin = bundle->ncp.ipcp.throughput.PacketsIn;
|
|
|
|
pout = bundle->ncp.ipcp.throughput.PacketsOut;
|
|
|
|
#ifndef NOINET6
|
|
|
|
oin += bundle->ncp.ipv6cp.throughput.OctetsIn;
|
|
|
|
oout += bundle->ncp.ipv6cp.throughput.OctetsOut;
|
|
|
|
pin += bundle->ncp.ipv6cp.throughput.PacketsIn;
|
|
|
|
pout += bundle->ncp.ipv6cp.throughput.PacketsOut;
|
|
|
|
#endif
|
|
|
|
|
1998-12-14 01:15:34 +00:00
|
|
|
for (; arg < argc; arg++) {
|
1998-08-29 23:02:42 +00:00
|
|
|
nargv[arg] = strdup(oargv[arg]);
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
nargv[arg] = subst(nargv[arg], "AUTHNAME", bundle->cfg.auth.name);
|
|
|
|
nargv[arg] = subst(nargv[arg], "COMPILATIONDATE", __DATE__);
|
|
|
|
nargv[arg] = substip(nargv[arg], "DNS0", bundle->ncp.ipcp.ns.dns[0]);
|
|
|
|
nargv[arg] = substip(nargv[arg], "DNS1", bundle->ncp.ipcp.ns.dns[1]);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = subst(nargv[arg], "ENDDISC",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
mp_Enddisc(bundle->ncp.mp.cfg.enddisc.class,
|
|
|
|
bundle->ncp.mp.cfg.enddisc.address,
|
|
|
|
bundle->ncp.mp.cfg.enddisc.len));
|
|
|
|
nargv[arg] = substip(nargv[arg], "HISADDR", bundle->ncp.ipcp.peer_ip);
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
nargv[arg] = substipv6(nargv[arg], "HISADDR6", &bundle->ncp.ipv6cp.hisaddr);
|
2001-08-14 16:05:52 +00:00
|
|
|
#endif
|
1998-10-22 02:32:50 +00:00
|
|
|
nargv[arg] = subst(nargv[arg], "INTERFACE", bundle->iface->name);
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPOCTETSIN",
|
|
|
|
bundle->ncp.ipcp.throughput.OctetsIn);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPOCTETSOUT",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipcp.throughput.OctetsOut);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPPACKETSIN",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipcp.throughput.PacketsIn);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPPACKETSOUT",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipcp.throughput.PacketsOut);
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPV6OCTETSIN",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipv6cp.throughput.OctetsIn);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPV6OCTETSOUT",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipv6cp.throughput.OctetsOut);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPV6PACKETSIN",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipv6cp.throughput.PacketsIn);
|
2002-06-15 08:03:30 +00:00
|
|
|
nargv[arg] = substull(nargv[arg], "IPV6PACKETSOUT",
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
bundle->ncp.ipv6cp.throughput.PacketsOut);
|
2001-08-14 16:05:52 +00:00
|
|
|
#endif
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
nargv[arg] = subst(nargv[arg], "LABEL", bundle_GetLabel(bundle));
|
|
|
|
nargv[arg] = substip(nargv[arg], "MYADDR", bundle->ncp.ipcp.my_ip);
|
|
|
|
#ifndef NOINET6
|
|
|
|
nargv[arg] = substipv6(nargv[arg], "MYADDR6", &bundle->ncp.ipv6cp.myaddr);
|
2003-06-20 16:15:59 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
nargv[arg] = substipv6prefix(nargv[arg], "IPV6PREFIX",
|
|
|
|
bundle->radius.ipv6prefix);
|
|
|
|
#endif
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
#endif
|
|
|
|
nargv[arg] = substull(nargv[arg], "OCTETSIN", oin);
|
|
|
|
nargv[arg] = substull(nargv[arg], "OCTETSOUT", oout);
|
|
|
|
nargv[arg] = substull(nargv[arg], "PACKETSIN", pin);
|
|
|
|
nargv[arg] = substull(nargv[arg], "PACKETSOUT", pout);
|
1998-08-29 23:02:42 +00:00
|
|
|
nargv[arg] = subst(nargv[arg], "PEER_ENDDISC",
|
|
|
|
mp_Enddisc(bundle->ncp.mp.peer.enddisc.class,
|
|
|
|
bundle->ncp.mp.peer.enddisc.address,
|
|
|
|
bundle->ncp.mp.peer.enddisc.len));
|
2002-05-27 23:19:53 +00:00
|
|
|
nargv[arg] = substlong(nargv[arg], "PROCESSID", pid);
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
if (server.cfg.port)
|
2002-05-27 23:19:53 +00:00
|
|
|
nargv[arg] = substlong(nargv[arg], "SOCKNAME", server.cfg.port);
|
Add variable substitutions for SOCKNAME, IPOCTETSIN, IPOCTETSOUT, IPPACKETSIN,
IPPACKETSOUT, IPV6OCTETSIN, IPV6OCTETSOUT, IPV6PACKETSIN, IPV6PACKETSOUT,
OCTETSIN, OCTETSOUT, PACKETSIN, PACKETSOUT and SOCKNAME.
2002-04-17 12:38:59 +00:00
|
|
|
else
|
|
|
|
nargv[arg] = subst(nargv[arg], "SOCKNAME", server.cfg.sockname);
|
|
|
|
nargv[arg] = subst(nargv[arg], "UPTIME", uptime);
|
|
|
|
nargv[arg] = subst(nargv[arg], "USER", bundle->ncp.mp.peer.authname);
|
2000-07-19 02:10:35 +00:00
|
|
|
nargv[arg] = subst(nargv[arg], "VERSION", Version);
|
1998-08-29 23:02:39 +00:00
|
|
|
}
|
|
|
|
nargv[arg] = NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-03 21:45:32 +00:00
|
|
|
void
|
|
|
|
command_Free(int argc, char **argv)
|
|
|
|
{
|
|
|
|
while (argc) {
|
|
|
|
free(*argv);
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
1999-06-09 08:47:36 +00:00
|
|
|
pid_t shpid, pid;
|
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 */
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->prompt && arg->prompt->owner) {
|
|
|
|
log_Printf(LogWARN, "Can't start a shell from a network connection\n");
|
1997-06-09 03:27:43 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc == arg->argn) {
|
|
|
|
if (!arg->prompt) {
|
|
|
|
log_Printf(LogWARN, "Can't start an interactive shell from"
|
|
|
|
" a config file\n");
|
|
|
|
return 1;
|
|
|
|
} else if (arg->prompt->owner) {
|
|
|
|
log_Printf(LogWARN, "Can't start an interactive shell from"
|
|
|
|
" a socket connection\n");
|
1997-08-18 20:15:10 +00:00
|
|
|
return 1;
|
|
|
|
} else if (bg) {
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(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;
|
|
|
|
}
|
1998-03-13 01:36:10 +00:00
|
|
|
}
|
|
|
|
|
1999-06-09 08:47:36 +00:00
|
|
|
pid = getpid();
|
1997-08-25 00:29:32 +00:00
|
|
|
if ((shpid = fork()) == 0) {
|
1998-05-21 21:49:08 +00:00
|
|
|
int i, fd;
|
|
|
|
|
|
|
|
if ((shell = getenv("SHELL")) == 0)
|
|
|
|
shell = _PATH_BSHELL;
|
|
|
|
|
|
|
|
timer_TermService();
|
|
|
|
|
|
|
|
if (arg->prompt)
|
|
|
|
fd = arg->prompt->fd_out;
|
|
|
|
else if ((fd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
|
|
|
|
log_Printf(LogALERT, "Failed to open %s: %s\n",
|
|
|
|
_PATH_DEVNULL, strerror(errno));
|
1997-08-25 00:29:32 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1999-08-17 14:59:05 +00:00
|
|
|
dup2(fd, STDIN_FILENO);
|
|
|
|
dup2(fd, STDOUT_FILENO);
|
|
|
|
dup2(fd, STDERR_FILENO);
|
|
|
|
for (i = getdtablesize(); i > STDERR_FILENO; i--)
|
|
|
|
fcntl(i, F_SETFD, 1);
|
1997-08-25 00:29:32 +00:00
|
|
|
|
2000-08-18 00:01:44 +00:00
|
|
|
#ifndef NOSUID
|
1999-12-30 03:36:11 +00:00
|
|
|
setuid(ID0realuid());
|
2000-08-18 00:01:44 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn) {
|
1997-08-25 00:29:32 +00:00
|
|
|
/* substitute pseudo args */
|
1998-08-29 23:02:39 +00:00
|
|
|
char *argv[MAXARGS];
|
|
|
|
int argc = arg->argc - arg->argn;
|
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if (argc >= (int)(sizeof argv / sizeof argv[0])) {
|
1998-08-29 23:02:39 +00:00
|
|
|
argc = sizeof argv / sizeof argv[0] - 1;
|
|
|
|
log_Printf(LogWARN, "Truncating shell command to %d args\n", argc);
|
1997-11-22 03:37:54 +00:00
|
|
|
}
|
1999-06-09 08:47:36 +00:00
|
|
|
command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 0, pid);
|
1997-08-25 00:29:32 +00:00
|
|
|
if (bg) {
|
|
|
|
pid_t p;
|
|
|
|
|
|
|
|
p = getpid();
|
|
|
|
if (daemon(1, 1) == -1) {
|
2002-05-27 23:19:53 +00:00
|
|
|
log_Printf(LogERROR, "%ld: daemon: %s\n", (long)p, strerror(errno));
|
1997-08-25 00:29:32 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
} else if (arg->prompt)
|
|
|
|
printf("ppp: Pausing until %s finishes\n", arg->argv[arg->argn]);
|
1997-11-22 03:37:54 +00:00
|
|
|
execvp(argv[0], argv);
|
1997-10-12 01:49:37 +00:00
|
|
|
} else {
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->prompt)
|
1997-12-27 07:22:12 +00:00
|
|
|
printf("ppp: Pausing until %s finishes\n", shell);
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_TtyOldMode(arg->prompt);
|
2001-07-09 08:17:47 +00:00
|
|
|
execl(shell, shell, (char *)NULL);
|
1997-10-12 01:49:37 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1998-10-26 19:07:39 +00:00
|
|
|
log_Printf(LogWARN, "exec() of %s failed: %s\n",
|
|
|
|
arg->argc > arg->argn ? arg->argv[arg->argn] : shell,
|
|
|
|
strerror(errno));
|
1999-08-17 14:59:05 +00:00
|
|
|
_exit(255);
|
1997-08-25 00:29:32 +00:00
|
|
|
}
|
|
|
|
|
2002-05-27 23:19:53 +00:00
|
|
|
if (shpid == (pid_t)-1)
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogERROR, "Fork failed: %s\n", strerror(errno));
|
|
|
|
else {
|
|
|
|
int status;
|
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
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->prompt && !arg->prompt->owner)
|
|
|
|
prompt_TtyCommandMode(arg->prompt);
|
1996-12-22 17:29:33 +00:00
|
|
|
|
1998-05-21 21:49:08 +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)
|
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc == arg->argn)
|
1997-11-22 03:37:54 +00:00
|
|
|
return -1;
|
|
|
|
return ShellCommand(arg, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
FgShellCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
return ShellCommand(arg, 0);
|
|
|
|
}
|
|
|
|
|
2000-03-14 01:47:27 +00:00
|
|
|
static int
|
|
|
|
ResolvCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->argc == arg->argn + 1) {
|
|
|
|
if (!strcasecmp(arg->argv[arg->argn], "reload"))
|
|
|
|
ipcp_LoadDNS(&arg->bundle->ncp.ipcp);
|
|
|
|
else if (!strcasecmp(arg->argv[arg->argn], "restore"))
|
|
|
|
ipcp_RestoreDNS(&arg->bundle->ncp.ipcp);
|
|
|
|
else if (!strcasecmp(arg->argv[arg->argn], "rewrite"))
|
|
|
|
ipcp_WriteDNS(&arg->bundle->ncp.ipcp);
|
|
|
|
else if (!strcasecmp(arg->argv[arg->argn], "readonly"))
|
|
|
|
arg->bundle->ncp.ipcp.ns.writable = 0;
|
|
|
|
else if (!strcasecmp(arg->argv[arg->argn], "writable"))
|
|
|
|
arg->bundle->ncp.ipcp.ns.writable = 1;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1999-08-19 18:15:52 +00:00
|
|
|
#ifndef NONAT
|
2000-03-31 14:26:23 +00:00
|
|
|
static struct cmdtab const NatCommands[] =
|
1998-10-22 02:32:50 +00:00
|
|
|
{
|
1999-08-19 18:15:52 +00:00
|
|
|
{"addr", NULL, nat_RedirectAddr, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"static address translation", "nat addr [addr_local addr_alias]", NULL},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"deny_incoming", NULL, NatOption, LOCAL_AUTH,
|
1999-08-19 18:15:52 +00:00
|
|
|
"stop incoming connections", "nat deny_incoming yes|no",
|
1998-10-22 02:32:50 +00:00
|
|
|
(const void *) PKT_ALIAS_DENY_INCOMING},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"enable", NULL, NatEnable, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"enable NAT", "nat enable yes|no", NULL},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"log", NULL, NatOption, LOCAL_AUTH,
|
1999-08-19 18:15:52 +00:00
|
|
|
"log NAT link creation", "nat log yes|no",
|
1998-10-22 02:32:50 +00:00
|
|
|
(const void *) PKT_ALIAS_LOG},
|
1999-08-19 18:15:52 +00:00
|
|
|
{"port", NULL, nat_RedirectPort, LOCAL_AUTH, "port redirection",
|
2004-09-05 01:46:52 +00:00
|
|
|
"nat port proto localaddr:port[-port] aliasport[-aliasport]", NULL},
|
2001-07-09 00:07:56 +00:00
|
|
|
{"proto", NULL, nat_RedirectProto, LOCAL_AUTH, "protocol redirection",
|
2004-09-05 01:46:52 +00:00
|
|
|
"nat proto proto localIP [publicIP [remoteIP]]", NULL},
|
1999-08-19 18:15:52 +00:00
|
|
|
{"proxy", NULL, nat_ProxyRule, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"proxy control", "nat proxy server host[:port] ...", NULL},
|
2001-08-02 10:16:32 +00:00
|
|
|
#ifndef NO_FW_PUNCH
|
|
|
|
{"punch_fw", NULL, nat_PunchFW, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"firewall control", "nat punch_fw [base count]", NULL},
|
2001-08-02 10:16:32 +00:00
|
|
|
#endif
|
2003-09-23 07:41:55 +00:00
|
|
|
{"skinny_port", NULL, nat_SkinnyPort, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"TCP port used by Skinny Station protocol", "nat skinny_port [port]", NULL},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"same_ports", NULL, NatOption, LOCAL_AUTH,
|
1999-08-19 18:15:52 +00:00
|
|
|
"try to leave port numbers unchanged", "nat same_ports yes|no",
|
1998-10-22 02:32:50 +00:00
|
|
|
(const void *) PKT_ALIAS_SAME_PORTS},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"target", NULL, nat_SetTarget, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Default address for incoming connections", "nat target addr", NULL},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"unregistered_only", NULL, NatOption, LOCAL_AUTH,
|
1999-08-19 18:15:52 +00:00
|
|
|
"translate unregistered (private) IP address space only",
|
|
|
|
"nat unregistered_only yes|no",
|
1998-10-22 02:32:50 +00:00
|
|
|
(const void *) PKT_ALIAS_UNREGISTERED_ONLY},
|
2000-03-31 14:26:23 +00:00
|
|
|
{"use_sockets", NULL, NatOption, LOCAL_AUTH,
|
1999-08-19 18:15:52 +00:00
|
|
|
"allocate host sockets", "nat use_sockets yes|no",
|
1998-10-22 02:32:50 +00:00
|
|
|
(const void *) PKT_ALIAS_USE_SOCKETS},
|
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
2000-03-31 14:26:23 +00:00
|
|
|
"Display this message", "nat help|? [command]", NatCommands},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, NULL, NULL, NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct cmdtab const AllowCommands[] = {
|
|
|
|
{"modes", "mode", AllowModes, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Only allow certain ppp modes", "allow modes mode...", NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"users", "user", AllowUsers, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Only allow ppp access to certain users", "allow users logname...", NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
|
|
|
"Display this message", "allow help|? [command]", AllowCommands},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, NULL, NULL, NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct cmdtab const IfaceCommands[] =
|
|
|
|
{
|
|
|
|
{"add", NULL, IfaceAddCommand, LOCAL_AUTH,
|
|
|
|
"Add iface address", "iface add addr[/bits| mask] peer", NULL},
|
|
|
|
{NULL, "add!", IfaceAddCommand, LOCAL_AUTH,
|
|
|
|
"Add or change an iface address", "iface add! addr[/bits| mask] peer",
|
|
|
|
(void *)1},
|
|
|
|
{"clear", NULL, IfaceClearCommand, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Clear iface address(es)", "iface clear [INET | INET6]", NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"delete", "rm", IfaceDeleteCommand, LOCAL_AUTH,
|
|
|
|
"Delete iface address", "iface delete addr", NULL},
|
|
|
|
{NULL, "rm!", IfaceDeleteCommand, LOCAL_AUTH,
|
|
|
|
"Delete iface address", "iface delete addr", (void *)1},
|
|
|
|
{NULL, "delete!", IfaceDeleteCommand, LOCAL_AUTH,
|
|
|
|
"Delete iface address", "iface delete addr", (void *)1},
|
|
|
|
{"show", NULL, iface_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Show iface address(es)", "iface show", NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
1999-08-19 18:15:52 +00:00
|
|
|
"Display this message", "nat help|? [command]", IfaceCommands},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, NULL, NULL, NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
};
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const Commands[] = {
|
1998-05-21 21:49:08 +00:00
|
|
|
{"accept", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"accept option request", "accept option ..", NULL},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"add", NULL, AddCommand, LOCAL_AUTH,
|
1997-12-30 02:45:48 +00:00
|
|
|
"add route", "add dest mask gateway", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{NULL, "add!", AddCommand, LOCAL_AUTH,
|
1997-12-30 02:45:48 +00:00
|
|
|
"add or change route", "add! dest mask gateway", (void *)1},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"allow", "auth", RunListCommand, LOCAL_AUTH,
|
|
|
|
"Allow ppp access", "allow users|modes ....", AllowCommands},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"bg", "!bg", BgShellCommand, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Run a background command", "[!]bg command", NULL},
|
1998-06-12 20:12:26 +00:00
|
|
|
{"clear", NULL, ClearCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
1999-05-08 11:07:56 +00:00
|
|
|
"Clear throughput statistics",
|
2004-09-05 01:46:52 +00:00
|
|
|
"clear ipcp|ipv6cp|physical [current|overall|peak]...", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"clone", NULL, CloneCommand, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Clone a link", "clone newname...", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"close", NULL, CloseCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Close an FSM", "close [lcp|ccp]", NULL},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"delete", NULL, DeleteCommand, LOCAL_AUTH,
|
1997-12-30 02:45:48 +00:00
|
|
|
"delete route", "delete dest", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{NULL, "delete!", DeleteCommand, LOCAL_AUTH,
|
1997-12-30 02:45:48 +00:00
|
|
|
"delete a route if it exists", "delete! dest", (void *)1},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Deny option request", "deny option ..", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
1998-10-31 17:38:47 +00:00
|
|
|
"Dial and login", "dial|call [system ...]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Disable option", "disable option ..", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Generate a down event", "down [ccp|lcp]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Enable option", "enable option ..", NULL},
|
2000-07-19 02:10:35 +00:00
|
|
|
{"ident", NULL, IdentCommand, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Set the link identity", "ident text...", NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"iface", "interface", RunListCommand, LOCAL_AUTH,
|
|
|
|
"interface control", "iface option ...", IfaceCommands},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"link", "datalink", LinkCommand, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Link specific commands", "link name command ...", NULL},
|
1998-06-15 19:05:51 +00:00
|
|
|
{"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Load settings", "load [system ...]", NULL},
|
2001-11-03 21:45:32 +00:00
|
|
|
{"log", NULL, LogCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"log information", "log word ...", NULL},
|
1999-08-19 18:15:52 +00:00
|
|
|
#ifndef NONAT
|
|
|
|
{"nat", "alias", RunListCommand, LOCAL_AUTH,
|
2000-03-31 14:26:23 +00:00
|
|
|
"NAT control", "nat option yes|no", NatCommands},
|
1999-08-19 18:15:52 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
{"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
1998-07-29 18:21:17 +00:00
|
|
|
"Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Password for manipulation", "passwd LocalPassword", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Quit PPP program", "quit|bye [all]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Remove a link", "remove", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"rename", "mv", RenameCommand, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Rename a link", "rename name", NULL},
|
2000-03-14 01:47:27 +00:00
|
|
|
{"resolv", NULL, ResolvCommand, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Manipulate resolv.conf", "resolv readonly|reload|restore|rewrite|writable",
|
|
|
|
NULL},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"save", NULL, SaveCommand, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Save settings", "save", NULL},
|
2000-07-19 02:10:35 +00:00
|
|
|
{"sendident", NULL, SendIdentification, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Transmit the link identity", "sendident", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"set", "setup", SetCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Set parameters", "set[up] var value", NULL},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"shell", "!", FgShellCommand, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Run a subshell", "shell|! [sh command]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"show", NULL, ShowCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Show status and stats", "show var", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"term", NULL, TerminalCommand, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Enter terminal mode", "term", NULL},
|
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", "help|? [command]", Commands},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, NULL, NULL, NULL},
|
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
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->cx->physical->async.cfg.EscMap[32]) {
|
|
|
|
int code, bit;
|
|
|
|
const char *sep = "";
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
for (code = 0; code < 32; code++)
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->cx->physical->async.cfg.EscMap[code])
|
1997-08-25 00:29:32 +00:00
|
|
|
for (bit = 0; bit < 8; bit++)
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->cx->physical->async.cfg.EscMap[code] & (1 << bit)) {
|
|
|
|
prompt_Printf(arg->prompt, "%s0x%02x", sep, (code << 3) + bit);
|
|
|
|
sep = ", ";
|
|
|
|
}
|
|
|
|
prompt_Printf(arg->prompt, "\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
|
1998-05-21 21:49:08 +00:00
|
|
|
ShowTimerList(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
timer_Show(0, arg->prompt);
|
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
|
|
|
ShowStopped(struct cmdargs const *arg)
|
1997-08-17 20:45:50 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, " Stopped Timer: LCP: ");
|
|
|
|
if (!arg->cx->physical->link.lcp.fsm.StoppedTimer.load)
|
|
|
|
prompt_Printf(arg->prompt, "Disabled");
|
1997-08-20 23:47:53 +00:00
|
|
|
else
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "%ld secs",
|
|
|
|
arg->cx->physical->link.lcp.fsm.StoppedTimer.load / SECTICKS);
|
1997-08-20 23:47:53 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, ", CCP: ");
|
|
|
|
if (!arg->cx->physical->link.ccp.fsm.StoppedTimer.load)
|
|
|
|
prompt_Printf(arg->prompt, "Disabled");
|
1997-08-20 23:47:53 +00:00
|
|
|
else
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "%ld secs",
|
|
|
|
arg->cx->physical->link.ccp.fsm.StoppedTimer.load / SECTICKS);
|
1997-08-20 23:47:53 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "\n");
|
1997-08-20 23:47:53 +00:00
|
|
|
|
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
|
|
|
ShowVersion(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1999-09-06 18:11:50 +00:00
|
|
|
prompt_Printf(arg->prompt, "PPP Version %s - %s\n", Version, __DATE__);
|
1997-11-09 17:51:27 +00:00
|
|
|
return 0;
|
1997-04-21 01:02:02 +00:00
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
ShowProtocolStats(struct cmdargs const *arg)
|
1995-10-08 14:57:32 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
struct link *l = command_ChooseLink(arg);
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "%s:\n", l->name);
|
|
|
|
link_ReportProtocolStatus(l, arg->prompt);
|
1997-11-09 17:51:27 +00:00
|
|
|
return 0;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const ShowCommands[] = {
|
1998-05-21 21:49:08 +00:00
|
|
|
{"bundle", NULL, bundle_ShowStatus, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"bundle details", "show bundle", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"ccp", NULL, ccp_ReportStatus, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"CCP status", "show cpp", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"compress", NULL, sl_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"VJ compression stats", "show compress", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"escape", NULL, ShowEscape, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"escape characters", "show escape", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"filter", NULL, filter_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"packet filters", "show filter [in|out|dial|alive]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"hdlc", NULL, hdlc_ReportStatus, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"HDLC errors", "show hdlc", NULL},
|
1998-10-22 02:32:50 +00:00
|
|
|
{"iface", "interface", iface_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Interface status", "show iface", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"ipcp", NULL, ipcp_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"IPCP status", "show ipcp", NULL},
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
|
|
|
{"ipv6cp", NULL, ipv6cp_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"IPV6CP status", "show ipv6cp", NULL},
|
2001-08-14 16:05:52 +00:00
|
|
|
#endif
|
1999-05-15 02:24:18 +00:00
|
|
|
{"layers", NULL, link_ShowLayers, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Protocol layers", "show layers", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"LCP status", "show lcp", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"link", "datalink", datalink_Show, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"(high-level) link info", "show link", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"links", NULL, bundle_ShowLinks, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"available link names", "show links", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"log", NULL, log_ShowLevel, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"log levels", "show log", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"mem", NULL, mbuf_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"mbuf allocations", "show mem", NULL},
|
2001-08-14 16:05:52 +00:00
|
|
|
{"ncp", NULL, ncp_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"NCP status", "show ncp", NULL},
|
1999-05-08 11:07:56 +00:00
|
|
|
{"physical", NULL, physical_ShowStatus, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"(low-level) link info", "show physical", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"mp", "multilink", mp_ShowStatus, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"multilink setup", "show mp", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"proto", NULL, ShowProtocolStats, LOCAL_AUTH | LOCAL_CX_OPT,
|
2004-09-05 01:46:52 +00:00
|
|
|
"protocol summary", "show proto", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"route", NULL, route_Show, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"routing table", "show route", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"stopped", NULL, ShowStopped, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"STOPPED timeout", "show stopped", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"timers", NULL, ShowTimerList, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"alarm timers", "show timers", NULL},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"version string", "show version", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"who", NULL, log_ShowWho, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"client list", "show who", NULL},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH,
|
1997-11-22 03:37:54 +00:00
|
|
|
"Display this message", "show help|? [command]", ShowCommands},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, 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
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static const char *
|
|
|
|
mkPrefix(int argc, char const *const *argv, char *tgt, int sz)
|
|
|
|
{
|
|
|
|
int f, tlen, len;
|
|
|
|
|
|
|
|
tlen = 0;
|
|
|
|
for (f = 0; f < argc && tlen < sz - 2; f++) {
|
|
|
|
if (f)
|
|
|
|
tgt[tlen++] = ' ';
|
|
|
|
len = strlen(argv[f]);
|
|
|
|
if (len > sz - tlen - 1)
|
|
|
|
len = sz - tlen - 1;
|
|
|
|
strncpy(tgt+tlen, argv[f], len);
|
|
|
|
tlen += len;
|
|
|
|
}
|
|
|
|
tgt[tlen] = '\0';
|
|
|
|
return tgt;
|
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc, int argn,
|
|
|
|
char const *const *argv, struct prompt *prompt, struct datalink *cx)
|
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;
|
1998-05-21 21:49:08 +00:00
|
|
|
char prefix[100];
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
cmd = FindCommand(cmds, argv[argn], &nmatch);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (nmatch > 1)
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogWARN, "%s: Ambiguous command\n",
|
|
|
|
mkPrefix(argn+1, argv, prefix, sizeof prefix));
|
|
|
|
else if (cmd && (!prompt || (cmd->lauth & prompt->auth))) {
|
|
|
|
if ((cmd->lauth & LOCAL_CX) && !cx)
|
|
|
|
/* We've got no context, but we require it */
|
|
|
|
cx = bundle2datalink(bundle, NULL);
|
|
|
|
|
|
|
|
if ((cmd->lauth & LOCAL_CX) && !cx)
|
|
|
|
log_Printf(LogWARN, "%s: No context (use the `link' command)\n",
|
|
|
|
mkPrefix(argn+1, argv, prefix, sizeof prefix));
|
|
|
|
else {
|
|
|
|
if (cx && !(cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) {
|
|
|
|
log_Printf(LogWARN, "%s: Redundant context (%s) ignored\n",
|
|
|
|
mkPrefix(argn+1, argv, prefix, sizeof prefix), cx->name);
|
|
|
|
cx = NULL;
|
|
|
|
}
|
|
|
|
arg.cmdtab = cmds;
|
|
|
|
arg.cmd = cmd;
|
|
|
|
arg.argc = argc;
|
|
|
|
arg.argn = argn+1;
|
|
|
|
arg.argv = argv;
|
|
|
|
arg.bundle = bundle;
|
|
|
|
arg.cx = cx;
|
|
|
|
arg.prompt = prompt;
|
|
|
|
val = (*cmd->func) (&arg);
|
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
} else
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogWARN, "%s: Invalid command\n",
|
|
|
|
mkPrefix(argn+1, argv, prefix, sizeof prefix));
|
1997-06-09 03:27:43 +00:00
|
|
|
|
|
|
|
if (val == -1)
|
2002-04-22 13:44:47 +00:00
|
|
|
log_Printf(LogWARN, "usage: %s\n", cmd->syntax);
|
1997-08-25 00:29:32 +00:00
|
|
|
else if (val)
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogWARN, "%s: Failed %d\n",
|
|
|
|
mkPrefix(argn+1, argv, prefix, sizeof prefix), val);
|
1997-06-09 03:27:43 +00:00
|
|
|
|
|
|
|
return val;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
2000-03-14 01:47:31 +00:00
|
|
|
int
|
|
|
|
command_Expand_Interpret(char *buff, int nb, char *argv[MAXARGS], int offset)
|
|
|
|
{
|
|
|
|
char buff2[LINE_LEN-offset];
|
|
|
|
|
|
|
|
InterpretArg(buff, buff2);
|
|
|
|
strncpy(buff, buff2, LINE_LEN - offset - 1);
|
|
|
|
buff[LINE_LEN - offset - 1] = '\0';
|
|
|
|
|
|
|
|
return command_Interpret(buff, nb, argv);
|
|
|
|
}
|
|
|
|
|
1998-06-15 19:06:25 +00:00
|
|
|
int
|
|
|
|
command_Interpret(char *buff, int nb, char *argv[MAXARGS])
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
if (nb > 0) {
|
|
|
|
cp = buff + strcspn(buff, "\r\n");
|
|
|
|
if (cp)
|
|
|
|
*cp = '\0';
|
1999-12-27 11:43:31 +00:00
|
|
|
return MakeArgs(buff, argv, MAXARGS, PARSE_REDUCE);
|
1998-06-15 19:06:25 +00:00
|
|
|
}
|
|
|
|
return 0;
|
1997-11-11 22:58:14 +00:00
|
|
|
}
|
|
|
|
|
1997-12-17 21:21:42 +00:00
|
|
|
static int
|
2004-09-05 01:46:52 +00:00
|
|
|
arghidden(char const *const *argv, int n)
|
1997-12-17 21:21:42 +00:00
|
|
|
{
|
|
|
|
/* Is arg n of the given command to be hidden from the log ? */
|
1997-12-18 00:28:36 +00:00
|
|
|
|
|
|
|
/* set authkey xxxxx */
|
|
|
|
/* set key xxxxx */
|
1997-12-17 21:21:42 +00:00
|
|
|
if (n == 2 && !strncasecmp(argv[0], "se", 2) &&
|
|
|
|
(!strncasecmp(argv[1], "authk", 5) || !strncasecmp(argv[1], "ke", 2)))
|
|
|
|
return 1;
|
|
|
|
|
1997-12-18 00:28:36 +00:00
|
|
|
/* passwd xxxxx */
|
|
|
|
if (n == 1 && !strncasecmp(argv[0], "p", 1))
|
|
|
|
return 1;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
/* set server port xxxxx .... */
|
|
|
|
if (n == 3 && !strncasecmp(argv[0], "se", 2) &&
|
|
|
|
!strncasecmp(argv[1], "se", 2))
|
|
|
|
return 1;
|
|
|
|
|
1997-12-17 21:21:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-11-11 22:58:14 +00:00
|
|
|
void
|
1998-05-21 21:49:08 +00:00
|
|
|
command_Run(struct bundle *bundle, int argc, char const *const *argv,
|
1998-06-15 19:05:51 +00:00
|
|
|
struct prompt *prompt, const char *label, struct datalink *cx)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
1997-11-13 14:43:20 +00:00
|
|
|
if (argc > 0) {
|
1998-05-21 21:49:08 +00:00
|
|
|
if (log_IsKept(LogCOMMAND)) {
|
1999-06-08 20:12:06 +00:00
|
|
|
char buf[LINE_LEN];
|
2004-09-05 01:46:52 +00:00
|
|
|
int f;
|
|
|
|
size_t n;
|
1997-11-13 14:43:20 +00:00
|
|
|
|
|
|
|
if (label) {
|
1997-12-24 09:29:17 +00:00
|
|
|
strncpy(buf, label, sizeof buf - 3);
|
|
|
|
buf[sizeof buf - 3] = '\0';
|
1997-11-13 14:43:20 +00:00
|
|
|
strcat(buf, ": ");
|
1999-06-08 20:12:06 +00:00
|
|
|
n = strlen(buf);
|
|
|
|
} else {
|
|
|
|
*buf = '\0';
|
|
|
|
n = 0;
|
1997-11-13 14:43:20 +00:00
|
|
|
}
|
1999-06-08 20:12:06 +00:00
|
|
|
buf[sizeof buf - 1] = '\0'; /* In case we run out of room in buf */
|
|
|
|
|
1997-11-13 14:43:20 +00:00
|
|
|
for (f = 0; f < argc; f++) {
|
1997-12-24 09:29:17 +00:00
|
|
|
if (n < sizeof buf - 1 && f)
|
1997-11-13 14:43:20 +00:00
|
|
|
buf[n++] = ' ';
|
2004-09-05 01:46:52 +00:00
|
|
|
if (arghidden(argv, f))
|
1998-05-21 21:49:08 +00:00
|
|
|
strncpy(buf+n, "********", sizeof buf - n - 1);
|
1997-12-17 21:21:42 +00:00
|
|
|
else
|
1997-12-24 09:29:17 +00:00
|
|
|
strncpy(buf+n, argv[f], sizeof buf - n - 1);
|
1997-11-13 14:43:20 +00:00
|
|
|
n += strlen(buf+n);
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogCOMMAND, "%s\n", buf);
|
1997-11-13 14:43:20 +00:00
|
|
|
}
|
1998-06-15 19:05:51 +00:00
|
|
|
FindExec(bundle, Commands, argc, 0, argv, prompt, cx);
|
1997-11-13 14:43:20 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1999-12-20 20:30:02 +00:00
|
|
|
int
|
1998-05-21 21:49:08 +00:00
|
|
|
command_Decode(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
|
|
|
|
const char *label)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
|
|
|
int argc;
|
1998-06-15 19:06:25 +00:00
|
|
|
char *argv[MAXARGS];
|
1997-11-11 22:58:14 +00:00
|
|
|
|
2000-03-14 01:47:31 +00:00
|
|
|
if ((argc = command_Expand_Interpret(buff, nb, argv, 0)) < 0)
|
1999-12-20 20:30:02 +00:00
|
|
|
return 0;
|
|
|
|
|
1998-06-15 19:05:51 +00:00
|
|
|
command_Run(bundle, argc, (char const *const *)argv, prompt, label, NULL);
|
1999-12-20 20:30:02 +00:00
|
|
|
return 1;
|
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
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!arg->prompt)
|
|
|
|
log_Printf(LogWARN, "show: Cannot show without a prompt\n");
|
|
|
|
else if (arg->argc > arg->argn)
|
|
|
|
FindExec(arg->bundle, ShowCommands, arg->argc, arg->argn, arg->argv,
|
|
|
|
arg->prompt, arg->cx);
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "Use ``show ?'' to get a list.\n");
|
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
|
|
|
TerminalCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!arg->prompt) {
|
|
|
|
log_Printf(LogWARN, "term: Need a prompt\n");
|
1997-06-09 03:27:43 +00:00
|
|
|
return 1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->cx->physical->link.lcp.fsm.state > ST_CLOSED) {
|
|
|
|
prompt_Printf(arg->prompt, "LCP state is [%s]\n",
|
|
|
|
State2Nam(arg->cx->physical->link.lcp.fsm.state));
|
|
|
|
return 1;
|
1997-11-11 22:58:14 +00:00
|
|
|
}
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
datalink_Up(arg->cx, 0, 0);
|
|
|
|
prompt_TtyTermMode(arg->prompt, arg->cx);
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
QuitCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!arg->prompt || prompt_IsController(arg->prompt) ||
|
|
|
|
(arg->argc > arg->argn && !strcasecmp(arg->argv[arg->argn], "all") &&
|
|
|
|
(arg->prompt->auth & LOCAL_AUTH)))
|
2004-09-05 01:46:52 +00:00
|
|
|
Cleanup();
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->prompt)
|
|
|
|
prompt_Destroy(arg->prompt, 1);
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
OpenCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-06-25 22:33:31 +00:00
|
|
|
if (arg->argc == arg->argn)
|
1998-07-31 19:50:24 +00:00
|
|
|
bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL, 1);
|
1998-06-25 22:33:31 +00:00
|
|
|
else if (arg->argc == arg->argn + 1) {
|
|
|
|
if (!strcasecmp(arg->argv[arg->argn], "lcp")) {
|
1998-07-04 22:03:56 +00:00
|
|
|
struct datalink *cx = arg->cx ?
|
|
|
|
arg->cx : bundle2datalink(arg->bundle, NULL);
|
|
|
|
if (cx) {
|
|
|
|
if (cx->physical->link.lcp.fsm.state == ST_OPENED)
|
|
|
|
fsm_Reopen(&cx->physical->link.lcp.fsm);
|
1998-06-25 22:33:31 +00:00
|
|
|
else
|
1998-07-31 19:50:24 +00:00
|
|
|
bundle_Open(arg->bundle, cx->name, PHYS_ALL, 1);
|
1998-06-25 22:33:31 +00:00
|
|
|
} else
|
|
|
|
log_Printf(LogWARN, "open lcp: You must specify a link\n");
|
|
|
|
} else if (!strcasecmp(arg->argv[arg->argn], "ccp")) {
|
|
|
|
struct fsm *fp;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
fp = &command_ChooseLink(arg)->ccp.fsm;
|
1998-06-25 22:33:31 +00:00
|
|
|
if (fp->link->lcp.fsm.state != ST_OPENED)
|
|
|
|
log_Printf(LogWARN, "open: LCP must be open before opening CCP\n");
|
|
|
|
else if (fp->state == ST_OPENED)
|
|
|
|
fsm_Reopen(fp);
|
|
|
|
else {
|
|
|
|
fp->open_mode = 0; /* Not passive any more */
|
|
|
|
if (fp->state == ST_STOPPED) {
|
|
|
|
fsm_Down(fp);
|
|
|
|
fsm_Up(fp);
|
|
|
|
} else {
|
|
|
|
fsm_Up(fp);
|
|
|
|
fsm_Open(fp);
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1998-06-25 22:33:31 +00:00
|
|
|
} else if (!strcasecmp(arg->argv[arg->argn], "ipcp")) {
|
|
|
|
if (arg->cx)
|
|
|
|
log_Printf(LogWARN, "open ipcp: You need not specify a link\n");
|
|
|
|
if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED)
|
|
|
|
fsm_Reopen(&arg->bundle->ncp.ipcp.fsm);
|
|
|
|
else
|
1998-07-31 19:50:24 +00:00
|
|
|
bundle_Open(arg->bundle, NULL, PHYS_ALL, 1);
|
1998-06-25 22:33:31 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
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
|
1998-05-21 21:49:08 +00:00
|
|
|
CloseCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-06-15 19:05:27 +00:00
|
|
|
if (arg->argc == arg->argn)
|
|
|
|
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, CLOSE_STAYDOWN);
|
|
|
|
else if (arg->argc == arg->argn + 1) {
|
|
|
|
if (!strcasecmp(arg->argv[arg->argn], "lcp"))
|
|
|
|
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, CLOSE_LCP);
|
|
|
|
else if (!strcasecmp(arg->argv[arg->argn], "ccp") ||
|
|
|
|
!strcasecmp(arg->argv[arg->argn], "ccp!")) {
|
|
|
|
struct fsm *fp;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
fp = &command_ChooseLink(arg)->ccp.fsm;
|
1998-06-15 19:05:27 +00:00
|
|
|
if (fp->state == ST_OPENED) {
|
|
|
|
fsm_Close(fp);
|
|
|
|
if (arg->argv[arg->argn][3] == '!')
|
|
|
|
fp->open_mode = 0; /* Stay ST_CLOSED */
|
|
|
|
else
|
|
|
|
fp->open_mode = OPEN_PASSIVE; /* Wait for the peer to start */
|
|
|
|
}
|
|
|
|
} else
|
1998-05-21 21:49:08 +00:00
|
|
|
return -1;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-04-21 01:02:02 +00:00
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
DownCommand(struct cmdargs const *arg)
|
1997-04-21 01:02:02 +00:00
|
|
|
{
|
1998-06-16 19:40:28 +00:00
|
|
|
if (arg->argc == arg->argn) {
|
|
|
|
if (arg->cx)
|
|
|
|
datalink_Down(arg->cx, CLOSE_STAYDOWN);
|
|
|
|
else
|
|
|
|
bundle_Down(arg->bundle, CLOSE_STAYDOWN);
|
|
|
|
} else if (arg->argc == arg->argn + 1) {
|
|
|
|
if (!strcasecmp(arg->argv[arg->argn], "lcp")) {
|
|
|
|
if (arg->cx)
|
|
|
|
datalink_Down(arg->cx, CLOSE_LCP);
|
|
|
|
else
|
|
|
|
bundle_Down(arg->bundle, CLOSE_LCP);
|
|
|
|
} else if (!strcasecmp(arg->argv[arg->argn], "ccp")) {
|
|
|
|
struct fsm *fp = arg->cx ? &arg->cx->physical->link.ccp.fsm :
|
|
|
|
&arg->bundle->ncp.mp.link.ccp.fsm;
|
1998-06-20 00:19:42 +00:00
|
|
|
fsm2initial(fp);
|
1998-06-16 19:40:28 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
1997-04-21 01:02:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-05-21 21:49:08 +00:00
|
|
|
SetModemSpeed(struct cmdargs const *arg)
|
1995-10-08 14:57:32 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
long speed;
|
|
|
|
char *end;
|
1995-10-08 14:57:32 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn && *arg->argv[arg->argn]) {
|
|
|
|
if (arg->argc > arg->argn+1) {
|
1999-12-20 20:30:35 +00:00
|
|
|
log_Printf(LogWARN, "SetModemSpeed: Too many arguments\n");
|
1998-05-21 21:49:08 +00:00
|
|
|
return -1;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
if (strcasecmp(arg->argv[arg->argn], "sync") == 0) {
|
|
|
|
physical_SetSync(arg->cx->physical);
|
|
|
|
return 0;
|
1995-10-08 14:57:32 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
end = NULL;
|
|
|
|
speed = strtol(arg->argv[arg->argn], &end, 10);
|
2004-09-05 01:46:52 +00:00
|
|
|
if (*end || speed < 0) {
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogWARN, "SetModemSpeed: Bad argument \"%s\"",
|
|
|
|
arg->argv[arg->argn]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (physical_SetSpeed(arg->cx->physical, speed))
|
|
|
|
return 0;
|
|
|
|
log_Printf(LogWARN, "%s: Invalid speed\n", arg->argv[arg->argn]);
|
|
|
|
} else
|
|
|
|
log_Printf(LogWARN, "SetModemSpeed: No speed specified\n");
|
|
|
|
|
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
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
struct link *l = &arg->cx->physical->link;
|
|
|
|
|
|
|
|
l->lcp.fsm.StoppedTimer.load = 0;
|
|
|
|
l->ccp.fsm.StoppedTimer.load = 0;
|
|
|
|
if (arg->argc <= arg->argn+2) {
|
|
|
|
if (arg->argc > arg->argn) {
|
|
|
|
l->lcp.fsm.StoppedTimer.load = atoi(arg->argv[arg->argn]) * SECTICKS;
|
|
|
|
if (arg->argc > arg->argn+1)
|
|
|
|
l->ccp.fsm.StoppedTimer.load = atoi(arg->argv[arg->argn+1]) * SECTICKS;
|
1997-08-20 23:47:53 +00:00
|
|
|
}
|
1997-08-17 20:45:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn && arg->argc < arg->argn+4) {
|
1997-11-09 22:07:29 +00:00
|
|
|
const char *port, *passwd, *mask;
|
2004-09-05 01:46:52 +00:00
|
|
|
size_t mlen;
|
1997-11-09 22:07:29 +00:00
|
|
|
|
|
|
|
/* What's what ? */
|
1998-05-21 21:49:08 +00:00
|
|
|
port = arg->argv[arg->argn];
|
|
|
|
if (arg->argc == arg->argn + 2) {
|
|
|
|
passwd = arg->argv[arg->argn+1];
|
|
|
|
mask = NULL;
|
|
|
|
} else if (arg->argc == arg->argn + 3) {
|
|
|
|
passwd = arg->argv[arg->argn+1];
|
|
|
|
mask = arg->argv[arg->argn+2];
|
1999-11-13 16:18:40 +00:00
|
|
|
mlen = strlen(mask);
|
|
|
|
if (mlen == 0 || mlen > 4 || strspn(mask, "01234567") != mlen ||
|
|
|
|
(mlen == 4 && *mask != '0')) {
|
|
|
|
log_Printf(LogWARN, "%s %s: %s: Invalid mask\n",
|
|
|
|
arg->argv[arg->argn - 2], arg->argv[arg->argn - 1], mask);
|
1997-11-09 22:07:29 +00:00
|
|
|
return -1;
|
1999-11-13 16:18:40 +00:00
|
|
|
}
|
2001-01-29 01:35:06 +00:00
|
|
|
} else if (arg->argc != arg->argn + 1)
|
|
|
|
return -1;
|
|
|
|
else if (strcasecmp(port, "none") == 0) {
|
2001-01-26 01:41:34 +00:00
|
|
|
if (server_Clear(arg->bundle))
|
|
|
|
log_Printf(LogPHASE, "Disabled server socket\n");
|
|
|
|
return 0;
|
|
|
|
} else if (strcasecmp(port, "open") == 0) {
|
|
|
|
switch (server_Reopen(arg->bundle)) {
|
|
|
|
case SERVER_OK:
|
|
|
|
return 0;
|
|
|
|
case SERVER_FAILED:
|
2001-01-29 01:35:06 +00:00
|
|
|
log_Printf(LogWARN, "Failed to reopen server port\n");
|
2001-01-26 01:41:34 +00:00
|
|
|
return 1;
|
|
|
|
case SERVER_UNSET:
|
2001-01-29 01:35:06 +00:00
|
|
|
log_Printf(LogWARN, "Cannot reopen unset server socket\n");
|
2001-01-26 01:41:34 +00:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
} else if (strcasecmp(port, "closed") == 0) {
|
1998-05-21 21:49:08 +00:00
|
|
|
if (server_Close(arg->bundle))
|
2001-01-26 01:41:34 +00:00
|
|
|
log_Printf(LogPHASE, "Closed server socket\n");
|
|
|
|
else
|
|
|
|
log_Printf(LogWARN, "Server socket not open\n");
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
return 0;
|
1997-11-09 22:07:29 +00:00
|
|
|
} else
|
1998-05-21 21:49:08 +00:00
|
|
|
return -1;
|
1997-11-09 22:07:29 +00:00
|
|
|
|
2001-01-26 01:41:34 +00:00
|
|
|
strncpy(server.cfg.passwd, passwd, sizeof server.cfg.passwd - 1);
|
|
|
|
server.cfg.passwd[sizeof server.cfg.passwd - 1] = '\0';
|
1997-11-09 22:07:29 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (*port == '/') {
|
1997-11-09 22:07:29 +00:00
|
|
|
mode_t imask;
|
1998-05-21 21:49:08 +00:00
|
|
|
char *ptr, name[LINE_LEN + 12];
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1999-11-13 16:18:40 +00:00
|
|
|
if (mask == NULL)
|
1997-11-09 22:07:29 +00:00
|
|
|
imask = (mode_t)-1;
|
1999-11-13 16:18:40 +00:00
|
|
|
else for (imask = mlen = 0; mask[mlen]; mlen++)
|
|
|
|
imask = (imask * 8) + mask[mlen] - '0';
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
ptr = strstr(port, "%d");
|
|
|
|
if (ptr) {
|
|
|
|
snprintf(name, sizeof name, "%.*s%d%s",
|
1998-06-27 23:48:54 +00:00
|
|
|
(int)(ptr - port), port, arg->bundle->unit, ptr + 2);
|
1998-05-21 21:49:08 +00:00
|
|
|
port = name;
|
|
|
|
}
|
|
|
|
res = server_LocalOpen(arg->bundle, port, imask);
|
1997-07-12 19:22:34 +00:00
|
|
|
} else {
|
1998-05-21 21:49:08 +00:00
|
|
|
int iport, add = 0;
|
1997-11-09 22:07:29 +00:00
|
|
|
|
|
|
|
if (mask != NULL)
|
|
|
|
return -1;
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (*port == '+') {
|
|
|
|
port++;
|
|
|
|
add = 1;
|
|
|
|
}
|
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;
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(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);
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
if (iport) {
|
|
|
|
if (add)
|
|
|
|
iport += arg->bundle->unit;
|
|
|
|
res = server_TcpOpen(arg->bundle, iport);
|
|
|
|
} else
|
|
|
|
res = -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;
|
|
|
|
}
|
|
|
|
|
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;
|
1998-05-21 21:49:08 +00:00
|
|
|
int argc = arg->argc - arg->argn;
|
|
|
|
char const *const *argv = arg->argv + arg->argn;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
for (code = 0; code < 33; code++)
|
1998-05-21 21:49:08 +00:00
|
|
|
arg->cx->physical->async.cfg.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;
|
1998-05-21 21:49:08 +00:00
|
|
|
arg->cx->physical->async.cfg.EscMap[code >> 3] |= (1 << (code & 7));
|
|
|
|
arg->cx->physical->async.cfg.EscMap[32] = 1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetInterfaceAddr(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
2001-08-14 16:05:52 +00:00
|
|
|
struct ncp *ncp = &arg->bundle->ncp;
|
|
|
|
struct ncpaddr ncpaddr;
|
1998-01-05 01:35:20 +00:00
|
|
|
const char *hisaddr;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn + 4)
|
1997-08-25 00:29:32 +00:00
|
|
|
return -1;
|
1997-06-09 03:27:43 +00:00
|
|
|
|
1998-10-22 02:32:50 +00:00
|
|
|
hisaddr = NULL;
|
2001-08-14 16:05:52 +00:00
|
|
|
memset(&ncp->ipcp.cfg.my_range, '\0', sizeof ncp->ipcp.cfg.my_range);
|
|
|
|
memset(&ncp->ipcp.cfg.peer_range, '\0', sizeof ncp->ipcp.cfg.peer_range);
|
|
|
|
ncp->ipcp.cfg.HaveTriggerAddress = 0;
|
|
|
|
ncp->ipcp.cfg.netmask.s_addr = INADDR_ANY;
|
|
|
|
iplist_reset(&ncp->ipcp.cfg.peer_list);
|
1997-08-19 01:10:24 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn) {
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncprange_aton(&ncp->ipcp.cfg.my_range, ncp, arg->argv[arg->argn]))
|
1997-08-25 00:29:32 +00:00
|
|
|
return 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn+1) {
|
|
|
|
hisaddr = arg->argv[arg->argn+1];
|
|
|
|
if (arg->argc > arg->argn+2) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp->ipcp.ifmask = ncp->ipcp.cfg.netmask =
|
|
|
|
GetIpAddr(arg->argv[arg->argn+2]);
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn+3) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp->ipcp.cfg.TriggerAddress = GetIpAddr(arg->argv[arg->argn+3]);
|
|
|
|
ncp->ipcp.cfg.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
|
|
|
|
1998-10-22 02:32:50 +00:00
|
|
|
/* 0.0.0.0 means any address (0 bits) */
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_getaddr(&ncp->ipcp.cfg.my_range, &ncpaddr);
|
2004-07-15 09:42:16 +00:00
|
|
|
ncpaddr_getip4(&ncpaddr, &ncp->ipcp.my_ip);
|
2001-08-14 16:05:52 +00:00
|
|
|
if (ncp->ipcp.my_ip.s_addr == INADDR_ANY)
|
|
|
|
ncprange_setwidth(&ncp->ipcp.cfg.my_range, 0);
|
|
|
|
bundle_AdjustFilters(arg->bundle, &ncpaddr, NULL);
|
1997-08-21 17:07:30 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (hisaddr && !ipcp_UseHisaddr(arg->bundle, hisaddr,
|
1998-06-12 17:45:10 +00:00
|
|
|
arg->bundle->phys_type.all & PHYS_AUTO))
|
1998-05-21 21:49:08 +00:00
|
|
|
return 4;
|
1996-10-06 13:32:37 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1996-10-06 13:32:37 +00:00
|
|
|
}
|
|
|
|
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
static int
|
|
|
|
SetRetry(int argc, char const *const *argv, u_int *timeout, u_int *maxreq,
|
|
|
|
u_int *maxtrm, int def)
|
|
|
|
{
|
|
|
|
if (argc == 0) {
|
|
|
|
*timeout = DEF_FSMRETRY;
|
|
|
|
*maxreq = def;
|
|
|
|
if (maxtrm != NULL)
|
|
|
|
*maxtrm = def;
|
|
|
|
} else {
|
|
|
|
long l = atol(argv[0]);
|
|
|
|
|
|
|
|
if (l < MIN_FSMRETRY) {
|
|
|
|
log_Printf(LogWARN, "%ld: Invalid FSM retry period - min %d\n",
|
|
|
|
l, MIN_FSMRETRY);
|
|
|
|
return 1;
|
|
|
|
} else
|
|
|
|
*timeout = l;
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
l = atol(argv[1]);
|
|
|
|
if (l < 1) {
|
|
|
|
log_Printf(LogWARN, "%ld: Invalid FSM REQ tries - changed to 1\n", l);
|
|
|
|
l = 1;
|
|
|
|
}
|
|
|
|
*maxreq = l;
|
|
|
|
|
|
|
|
if (argc > 2 && maxtrm != NULL) {
|
|
|
|
l = atol(argv[2]);
|
|
|
|
if (l < 1) {
|
|
|
|
log_Printf(LogWARN, "%ld: Invalid FSM TRM tries - changed to 1\n", l);
|
|
|
|
l = 1;
|
|
|
|
}
|
|
|
|
*maxtrm = l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-10-06 13:32:37 +00:00
|
|
|
static int
|
1997-11-22 03:37:54 +00:00
|
|
|
SetVariable(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-06-27 23:48:54 +00:00
|
|
|
long long_val, param = (long)arg->cmd->args;
|
2001-07-03 01:02:26 +00:00
|
|
|
int mode, dummyint, f, first, res;
|
2001-06-18 14:59:36 +00:00
|
|
|
u_short *change;
|
1997-11-22 03:37:54 +00:00
|
|
|
const char *argp;
|
1998-05-21 21:49:08 +00:00
|
|
|
struct datalink *cx = arg->cx; /* LOCAL_CX uses this */
|
|
|
|
struct link *l = command_ChooseLink(arg); /* LOCAL_CX_OPT uses this */
|
2001-08-14 16:05:52 +00:00
|
|
|
struct in_addr *ipaddr;
|
|
|
|
struct ncpaddr ncpaddr[2];
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn)
|
|
|
|
argp = arg->argv[arg->argn];
|
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
|
|
|
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 0;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if ((arg->cmd->lauth & LOCAL_CX) && !cx) {
|
|
|
|
log_Printf(LogWARN, "set %s: No context (use the `link' command)\n",
|
|
|
|
arg->cmd->name);
|
|
|
|
return 1;
|
|
|
|
} else if (cx && !(arg->cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) {
|
|
|
|
log_Printf(LogWARN, "set %s: Redundant context (%s) ignored\n",
|
|
|
|
arg->cmd->name, cx->name);
|
|
|
|
cx = NULL;
|
|
|
|
}
|
|
|
|
|
1997-06-11 03:57:51 +00:00
|
|
|
switch (param) {
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_AUTHKEY:
|
1999-08-22 01:29:53 +00:00
|
|
|
strncpy(arg->bundle->cfg.auth.key, argp,
|
|
|
|
sizeof arg->bundle->cfg.auth.key - 1);
|
|
|
|
arg->bundle->cfg.auth.key[sizeof arg->bundle->cfg.auth.key - 1] = '\0';
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_AUTHNAME:
|
1998-10-24 01:08:45 +00:00
|
|
|
switch (bundle_Phase(arg->bundle)) {
|
2000-03-31 21:08:43 +00:00
|
|
|
default:
|
|
|
|
log_Printf(LogWARN, "Altering authname while at phase %s\n",
|
|
|
|
bundle_PhaseName(arg->bundle));
|
|
|
|
/* drop through */
|
1998-10-24 01:08:45 +00:00
|
|
|
case PHASE_DEAD:
|
|
|
|
case PHASE_ESTABLISH:
|
|
|
|
strncpy(arg->bundle->cfg.auth.name, argp,
|
|
|
|
sizeof arg->bundle->cfg.auth.name - 1);
|
|
|
|
arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name-1] = '\0';
|
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_AUTOLOAD:
|
1999-08-05 10:32:16 +00:00
|
|
|
if (arg->argc == arg->argn + 3) {
|
2002-06-15 08:03:30 +00:00
|
|
|
int v1, v2, v3;
|
1999-08-05 10:32:16 +00:00
|
|
|
char *end;
|
|
|
|
|
|
|
|
v1 = strtol(arg->argv[arg->argn], &end, 0);
|
|
|
|
if (v1 < 0 || *end) {
|
|
|
|
log_Printf(LogWARN, "autoload: %s: Invalid min percentage\n",
|
|
|
|
arg->argv[arg->argn]);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1999-08-05 10:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v2 = strtol(arg->argv[arg->argn + 1], &end, 0);
|
|
|
|
if (v2 < 0 || *end) {
|
|
|
|
log_Printf(LogWARN, "autoload: %s: Invalid max percentage\n",
|
|
|
|
arg->argv[arg->argn + 1]);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1999-08-05 10:32:16 +00:00
|
|
|
if (v2 < v1) {
|
|
|
|
v3 = v1;
|
|
|
|
v1 = v2;
|
|
|
|
v2 = v3;
|
|
|
|
}
|
|
|
|
|
|
|
|
v3 = strtol(arg->argv[arg->argn + 2], &end, 0);
|
|
|
|
if (v3 <= 0 || *end) {
|
|
|
|
log_Printf(LogWARN, "autoload: %s: Invalid throughput period\n",
|
|
|
|
arg->argv[arg->argn + 2]);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1999-08-05 10:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
arg->bundle->ncp.mp.cfg.autoload.min = v1;
|
|
|
|
arg->bundle->ncp.mp.cfg.autoload.max = v2;
|
|
|
|
arg->bundle->ncp.mp.cfg.autoload.period = v3;
|
|
|
|
mp_RestartAutoloadTimer(&arg->bundle->ncp.mp);
|
1998-05-21 21:49:08 +00:00
|
|
|
} else {
|
2001-07-03 01:02:26 +00:00
|
|
|
log_Printf(LogWARN, "Set autoload requires three arguments\n");
|
|
|
|
res = 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_DIAL:
|
1998-05-21 21:49:08 +00:00
|
|
|
strncpy(cx->cfg.script.dial, argp, sizeof cx->cfg.script.dial - 1);
|
|
|
|
cx->cfg.script.dial[sizeof cx->cfg.script.dial - 1] = '\0';
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_LOGIN:
|
1998-05-21 21:49:08 +00:00
|
|
|
strncpy(cx->cfg.script.login, argp, sizeof cx->cfg.script.login - 1);
|
|
|
|
cx->cfg.script.login[sizeof cx->cfg.script.login - 1] = '\0';
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_WINSIZE:
|
|
|
|
if (arg->argc > arg->argn) {
|
|
|
|
l->ccp.cfg.deflate.out.winsize = atoi(arg->argv[arg->argn]);
|
|
|
|
if (l->ccp.cfg.deflate.out.winsize < 8 ||
|
|
|
|
l->ccp.cfg.deflate.out.winsize > 15) {
|
|
|
|
log_Printf(LogWARN, "%d: Invalid outgoing window size\n",
|
|
|
|
l->ccp.cfg.deflate.out.winsize);
|
|
|
|
l->ccp.cfg.deflate.out.winsize = 15;
|
|
|
|
}
|
|
|
|
if (arg->argc > arg->argn+1) {
|
|
|
|
l->ccp.cfg.deflate.in.winsize = atoi(arg->argv[arg->argn+1]);
|
|
|
|
if (l->ccp.cfg.deflate.in.winsize < 8 ||
|
|
|
|
l->ccp.cfg.deflate.in.winsize > 15) {
|
|
|
|
log_Printf(LogWARN, "%d: Invalid incoming window size\n",
|
|
|
|
l->ccp.cfg.deflate.in.winsize);
|
|
|
|
l->ccp.cfg.deflate.in.winsize = 15;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
l->ccp.cfg.deflate.in.winsize = 0;
|
|
|
|
} else {
|
2001-07-03 01:02:26 +00:00
|
|
|
log_Printf(LogWARN, "No window size specified\n");
|
|
|
|
res = 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2001-06-18 15:00:22 +00:00
|
|
|
case VAR_MPPE:
|
2001-07-03 01:02:26 +00:00
|
|
|
if (arg->argc > arg->argn + 2) {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
2001-06-18 15:00:22 +00:00
|
|
|
|
|
|
|
if (arg->argc == arg->argn) {
|
|
|
|
l->ccp.cfg.mppe.keybits = 0;
|
|
|
|
l->ccp.cfg.mppe.state = MPPE_ANYSTATE;
|
|
|
|
l->ccp.cfg.mppe.required = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(argp, "*"))
|
|
|
|
long_val = 0;
|
|
|
|
else {
|
|
|
|
long_val = atol(argp);
|
|
|
|
if (long_val != 40 && long_val != 56 && long_val != 128) {
|
|
|
|
log_Printf(LogWARN, "%s: Invalid bits value\n", argp);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = -1;
|
|
|
|
break;
|
2000-10-30 00:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-18 15:00:22 +00:00
|
|
|
|
|
|
|
if (arg->argc == arg->argn + 2) {
|
|
|
|
if (!strcmp(arg->argv[arg->argn + 1], "*"))
|
|
|
|
l->ccp.cfg.mppe.state = MPPE_ANYSTATE;
|
|
|
|
else if (!strcasecmp(arg->argv[arg->argn + 1], "stateless"))
|
|
|
|
l->ccp.cfg.mppe.state = MPPE_STATELESS;
|
2001-07-06 23:45:32 +00:00
|
|
|
else if (!strcasecmp(arg->argv[arg->argn + 1], "stateful"))
|
2001-06-18 15:00:22 +00:00
|
|
|
l->ccp.cfg.mppe.state = MPPE_STATEFUL;
|
|
|
|
else {
|
|
|
|
log_Printf(LogWARN, "%s: Invalid state value\n",
|
|
|
|
arg->argv[arg->argn + 1]);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = -1;
|
|
|
|
break;
|
2001-06-18 15:00:22 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
l->ccp.cfg.mppe.state = MPPE_ANYSTATE;
|
|
|
|
l->ccp.cfg.mppe.keybits = long_val;
|
|
|
|
l->ccp.cfg.mppe.required = 1;
|
2000-10-30 00:15:04 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_DEVICE:
|
1998-05-21 21:49:08 +00:00
|
|
|
physical_SetDeviceList(cx->physical, arg->argc - arg->argn,
|
|
|
|
arg->argv + arg->argn);
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_ACCMAP:
|
|
|
|
if (arg->argc > arg->argn) {
|
1998-06-27 23:48:54 +00:00
|
|
|
u_long ulong_val;
|
1998-05-21 21:49:08 +00:00
|
|
|
sscanf(argp, "%lx", &ulong_val);
|
1998-06-27 23:48:54 +00:00
|
|
|
cx->physical->link.lcp.cfg.accmap = (u_int32_t)ulong_val;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else {
|
2001-07-03 01:02:26 +00:00
|
|
|
log_Printf(LogWARN, "No accmap specified\n");
|
|
|
|
res = 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_MODE:
|
|
|
|
mode = Nam2mode(argp);
|
|
|
|
if (mode == PHYS_NONE || mode == PHYS_ALL) {
|
|
|
|
log_Printf(LogWARN, "%s: Invalid mode\n", argp);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = -1;
|
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
bundle_SetMode(arg->bundle, cx, mode);
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_MRRU:
|
1998-10-24 01:08:45 +00:00
|
|
|
switch (bundle_Phase(arg->bundle)) {
|
|
|
|
case PHASE_DEAD:
|
|
|
|
break;
|
|
|
|
case PHASE_ESTABLISH:
|
|
|
|
/* Make sure none of our links are DATALINK_LCP or greater */
|
|
|
|
if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) {
|
|
|
|
log_Printf(LogWARN, "mrru: Only changable before LCP negotiations\n");
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-10-24 01:08:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log_Printf(LogWARN, "mrru: Only changable at phase DEAD/ESTABLISH\n");
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1997-09-22 00:46:56 +00:00
|
|
|
}
|
2001-07-03 01:02:26 +00:00
|
|
|
if (res != 0)
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
long_val = atol(argp);
|
|
|
|
if (long_val && long_val < MIN_MRU) {
|
|
|
|
log_Printf(LogWARN, "MRRU %ld: too small - min %d\n", long_val, MIN_MRU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
} else if (long_val > MAX_MRU) {
|
|
|
|
log_Printf(LogWARN, "MRRU %ld: too big - max %d\n", long_val, MAX_MRU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
} else
|
|
|
|
arg->bundle->ncp.mp.cfg.mrru = long_val;
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_MRU:
|
2001-07-03 22:20:06 +00:00
|
|
|
long_val = 0; /* silence gcc */
|
|
|
|
change = NULL; /* silence gcc */
|
2001-06-18 14:59:36 +00:00
|
|
|
switch(arg->argc - arg->argn) {
|
|
|
|
case 1:
|
2001-07-03 01:02:26 +00:00
|
|
|
if (argp[strspn(argp, "0123456789")] != '\0') {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*FALLTHRU*/
|
2001-06-18 14:59:36 +00:00
|
|
|
case 0:
|
|
|
|
long_val = atol(argp);
|
|
|
|
change = &l->lcp.cfg.mru;
|
|
|
|
if (long_val > l->lcp.cfg.max_mru) {
|
|
|
|
log_Printf(LogWARN, "MRU %ld: too large - max set to %d\n", long_val,
|
|
|
|
l->lcp.cfg.max_mru);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2001-07-03 01:02:26 +00:00
|
|
|
if (strcasecmp(argp, "max") && strcasecmp(argp, "maximum")) {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
2001-06-18 14:59:36 +00:00
|
|
|
long_val = atol(arg->argv[arg->argn + 1]);
|
|
|
|
change = &l->lcp.cfg.max_mru;
|
|
|
|
if (long_val > MAX_MRU) {
|
|
|
|
log_Printf(LogWARN, "MRU %ld: too large - maximum is %d\n", long_val,
|
|
|
|
MAX_MRU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = -1;
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
2001-07-03 01:02:26 +00:00
|
|
|
if (res != 0)
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
if (long_val == 0)
|
2001-07-26 11:33:53 +00:00
|
|
|
*change = 0;
|
1998-06-27 23:48:54 +00:00
|
|
|
else if (long_val < MIN_MRU) {
|
|
|
|
log_Printf(LogWARN, "MRU %ld: too small - min %d\n", long_val, MIN_MRU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
} else if (long_val > MAX_MRU) {
|
|
|
|
log_Printf(LogWARN, "MRU %ld: too big - max %d\n", long_val, MAX_MRU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
} else
|
2001-06-18 14:59:36 +00:00
|
|
|
*change = long_val;
|
|
|
|
if (l->lcp.cfg.mru > *change)
|
|
|
|
l->lcp.cfg.mru = *change;
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_MTU:
|
2001-07-03 22:20:06 +00:00
|
|
|
long_val = 0; /* silence gcc */
|
|
|
|
change = NULL; /* silence gcc */
|
2001-06-18 14:59:36 +00:00
|
|
|
switch(arg->argc - arg->argn) {
|
|
|
|
case 1:
|
2001-07-03 01:02:26 +00:00
|
|
|
if (argp[strspn(argp, "0123456789")] != '\0') {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*FALLTHRU*/
|
2001-06-18 14:59:36 +00:00
|
|
|
case 0:
|
|
|
|
long_val = atol(argp);
|
|
|
|
change = &l->lcp.cfg.mtu;
|
|
|
|
if (long_val > l->lcp.cfg.max_mtu) {
|
|
|
|
log_Printf(LogWARN, "MTU %ld: too large - max set to %d\n", long_val,
|
|
|
|
l->lcp.cfg.max_mtu);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2001-07-03 01:02:26 +00:00
|
|
|
if (strcasecmp(argp, "max") && strcasecmp(argp, "maximum")) {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
2001-06-18 14:59:36 +00:00
|
|
|
long_val = atol(arg->argv[arg->argn + 1]);
|
|
|
|
change = &l->lcp.cfg.max_mtu;
|
|
|
|
if (long_val > MAX_MTU) {
|
|
|
|
log_Printf(LogWARN, "MTU %ld: too large - maximum is %d\n", long_val,
|
|
|
|
MAX_MTU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = -1;
|
|
|
|
break;
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
|
|
|
|
2001-07-03 01:02:26 +00:00
|
|
|
if (res != 0)
|
|
|
|
break;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
if (long_val && long_val < MIN_MTU) {
|
|
|
|
log_Printf(LogWARN, "MTU %ld: too small - min %d\n", long_val, MIN_MTU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
} else if (long_val > MAX_MTU) {
|
|
|
|
log_Printf(LogWARN, "MTU %ld: too big - max %d\n", long_val, MAX_MTU);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
} else
|
2001-06-18 14:59:36 +00:00
|
|
|
*change = long_val;
|
|
|
|
if (l->lcp.cfg.mtu > *change)
|
|
|
|
l->lcp.cfg.mtu = *change;
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_OPENMODE:
|
|
|
|
if (strcasecmp(argp, "active") == 0)
|
|
|
|
cx->physical->link.lcp.cfg.openmode = arg->argc > arg->argn+1 ?
|
|
|
|
atoi(arg->argv[arg->argn+1]) : 1;
|
|
|
|
else if (strcasecmp(argp, "passive") == 0)
|
|
|
|
cx->physical->link.lcp.cfg.openmode = OPEN_PASSIVE;
|
|
|
|
else {
|
2001-07-03 01:02:26 +00:00
|
|
|
log_Printf(LogWARN, "%s: Invalid openmode\n", argp);
|
|
|
|
res = 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_PHONE:
|
1998-05-21 21:49:08 +00:00
|
|
|
strncpy(cx->cfg.phone.list, argp, sizeof cx->cfg.phone.list - 1);
|
|
|
|
cx->cfg.phone.list[sizeof cx->cfg.phone.list - 1] = '\0';
|
1998-08-07 18:42:51 +00:00
|
|
|
cx->phone.alt = cx->phone.next = NULL;
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
case VAR_HANGUP:
|
1998-05-21 21:49:08 +00:00
|
|
|
strncpy(cx->cfg.script.hangup, argp, sizeof cx->cfg.script.hangup - 1);
|
|
|
|
cx->cfg.script.hangup[sizeof cx->cfg.script.hangup - 1] = '\0';
|
1997-08-25 00:29:32 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
2000-06-11 02:30:51 +00:00
|
|
|
case VAR_IFQUEUE:
|
|
|
|
long_val = atol(argp);
|
|
|
|
arg->bundle->cfg.ifqueue = long_val < 0 ? 0 : long_val;
|
|
|
|
break;
|
|
|
|
|
1999-10-25 13:49:44 +00:00
|
|
|
case VAR_LOGOUT:
|
|
|
|
strncpy(cx->cfg.script.logout, argp, sizeof cx->cfg.script.logout - 1);
|
|
|
|
cx->cfg.script.logout[sizeof cx->cfg.script.logout - 1] = '\0';
|
|
|
|
break;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_IDLETIMEOUT:
|
2001-07-03 01:02:26 +00:00
|
|
|
if (arg->argc > arg->argn+2) {
|
|
|
|
log_Printf(LogWARN, "Too many idle timeout values\n");
|
|
|
|
res = 1;
|
|
|
|
} else if (arg->argc == arg->argn) {
|
|
|
|
log_Printf(LogWARN, "Too few idle timeout values\n");
|
|
|
|
res = 1;
|
|
|
|
} else {
|
2004-09-05 01:46:52 +00:00
|
|
|
unsigned long timeout, min;
|
1999-08-17 17:22:46 +00:00
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
timeout = strtoul(argp, NULL, 10);
|
|
|
|
min = arg->bundle->cfg.idle.min_timeout;
|
|
|
|
if (arg->argc == arg->argn + 2)
|
|
|
|
min = strtoul(arg->argv[arg->argn + 1], NULL, 10);
|
1999-08-17 17:22:46 +00:00
|
|
|
bundle_SetIdleTimer(arg->bundle, timeout, min);
|
|
|
|
}
|
1997-09-17 23:17:57 +00:00
|
|
|
break;
|
2004-07-17 01:07:53 +00:00
|
|
|
|
|
|
|
#ifndef NORADIUS
|
|
|
|
case VAR_RAD_ALIVE:
|
|
|
|
if (arg->argc > arg->argn + 2) {
|
|
|
|
log_Printf(LogWARN, "Too many RADIUS alive interval values\n");
|
|
|
|
res = 1;
|
|
|
|
} else if (arg->argc == arg->argn) {
|
|
|
|
log_Printf(LogWARN, "Too few RADIUS alive interval values\n");
|
|
|
|
res = 1;
|
|
|
|
} else {
|
|
|
|
arg->bundle->radius.alive.interval = atoi(argp);
|
|
|
|
if (arg->bundle->radius.alive.interval && !arg->bundle->radius.cfg.file) {
|
|
|
|
log_Printf(LogWARN, "rad_alive requires radius to be configured\n");
|
|
|
|
res = 1;
|
|
|
|
} else if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED) {
|
|
|
|
if (arg->bundle->radius.alive.interval)
|
|
|
|
radius_StartTimer(arg->bundle);
|
|
|
|
else
|
|
|
|
radius_StopTimer(&arg->bundle->radius);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_LQRPERIOD:
|
1998-06-27 23:48:54 +00:00
|
|
|
long_val = atol(argp);
|
|
|
|
if (long_val < MIN_LQRPERIOD) {
|
|
|
|
log_Printf(LogWARN, "%ld: Invalid lqr period - min %d\n",
|
|
|
|
long_val, MIN_LQRPERIOD);
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else
|
1998-06-27 23:48:54 +00:00
|
|
|
l->lcp.cfg.lqrperiod = long_val;
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_LCPRETRY:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = SetRetry(arg->argc - arg->argn, arg->argv + arg->argn,
|
|
|
|
&cx->physical->link.lcp.cfg.fsm.timeout,
|
|
|
|
&cx->physical->link.lcp.cfg.fsm.maxreq,
|
|
|
|
&cx->physical->link.lcp.cfg.fsm.maxtrm, DEF_FSMTRIES);
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_CHAPRETRY:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = SetRetry(arg->argc - arg->argn, arg->argv + arg->argn,
|
|
|
|
&cx->chap.auth.cfg.fsm.timeout,
|
|
|
|
&cx->chap.auth.cfg.fsm.maxreq, NULL, DEF_FSMAUTHTRIES);
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_PAPRETRY:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = SetRetry(arg->argc - arg->argn, arg->argv + arg->argn,
|
|
|
|
&cx->pap.cfg.fsm.timeout, &cx->pap.cfg.fsm.maxreq,
|
|
|
|
NULL, DEF_FSMAUTHTRIES);
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_CCPRETRY:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = SetRetry(arg->argc - arg->argn, arg->argv + arg->argn,
|
|
|
|
&l->ccp.cfg.fsm.timeout, &l->ccp.cfg.fsm.maxreq,
|
|
|
|
&l->ccp.cfg.fsm.maxtrm, DEF_FSMTRIES);
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_IPCPRETRY:
|
2001-07-03 01:02:26 +00:00
|
|
|
res = SetRetry(arg->argc - arg->argn, arg->argv + arg->argn,
|
|
|
|
&arg->bundle->ncp.ipcp.cfg.fsm.timeout,
|
|
|
|
&arg->bundle->ncp.ipcp.cfg.fsm.maxreq,
|
|
|
|
&arg->bundle->ncp.ipcp.cfg.fsm.maxtrm, DEF_FSMTRIES);
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1998-06-27 23:48:54 +00:00
|
|
|
|
2002-09-02 13:34:27 +00:00
|
|
|
#ifndef NOINET6
|
2002-08-29 02:44:58 +00:00
|
|
|
case VAR_IPV6CPRETRY:
|
|
|
|
res = SetRetry(arg->argc - arg->argn, arg->argv + arg->argn,
|
|
|
|
&arg->bundle->ncp.ipv6cp.cfg.fsm.timeout,
|
|
|
|
&arg->bundle->ncp.ipv6cp.cfg.fsm.maxreq,
|
|
|
|
&arg->bundle->ncp.ipv6cp.cfg.fsm.maxtrm, DEF_FSMTRIES);
|
|
|
|
break;
|
2002-09-02 13:34:27 +00:00
|
|
|
#endif
|
2002-08-29 02:44:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case VAR_NBNS:
|
|
|
|
case VAR_DNS:
|
2000-03-14 01:47:27 +00:00
|
|
|
if (param == VAR_DNS) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ipaddr = arg->bundle->ncp.ipcp.cfg.ns.dns;
|
|
|
|
ipaddr[0].s_addr = ipaddr[1].s_addr = INADDR_NONE;
|
2000-03-14 01:47:27 +00:00
|
|
|
} else {
|
2001-08-14 16:05:52 +00:00
|
|
|
ipaddr = arg->bundle->ncp.ipcp.cfg.ns.nbns;
|
|
|
|
ipaddr[0].s_addr = ipaddr[1].s_addr = INADDR_ANY;
|
2000-03-14 01:47:27 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
if (arg->argc > arg->argn) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncpaddr_aton(ncpaddr, &arg->bundle->ncp, arg->argv[arg->argn]);
|
|
|
|
if (!ncpaddr_getip4(ncpaddr, ipaddr))
|
|
|
|
return -1;
|
|
|
|
if (arg->argc > arg->argn+1) {
|
|
|
|
ncpaddr_aton(ncpaddr + 1, &arg->bundle->ncp, arg->argv[arg->argn + 1]);
|
|
|
|
if (!ncpaddr_getip4(ncpaddr + 1, ipaddr + 1))
|
|
|
|
return -1;
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
if (ipaddr[0].s_addr == INADDR_ANY) {
|
|
|
|
ipaddr[0] = ipaddr[1];
|
|
|
|
ipaddr[1].s_addr = INADDR_ANY;
|
2000-03-14 01:47:27 +00:00
|
|
|
}
|
2001-08-14 16:05:52 +00:00
|
|
|
if (ipaddr[0].s_addr == INADDR_NONE) {
|
|
|
|
ipaddr[0] = ipaddr[1];
|
|
|
|
ipaddr[1].s_addr = INADDR_NONE;
|
2000-03-14 01:47:27 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-08-07 18:42:51 +00:00
|
|
|
|
|
|
|
case VAR_CALLBACK:
|
|
|
|
cx->cfg.callback.opmask = 0;
|
|
|
|
for (dummyint = arg->argn; dummyint < arg->argc; dummyint++) {
|
|
|
|
if (!strcasecmp(arg->argv[dummyint], "auth"))
|
|
|
|
cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_AUTH);
|
|
|
|
else if (!strcasecmp(arg->argv[dummyint], "cbcp"))
|
|
|
|
cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_CBCP);
|
|
|
|
else if (!strcasecmp(arg->argv[dummyint], "e.164")) {
|
|
|
|
if (dummyint == arg->argc - 1)
|
|
|
|
log_Printf(LogWARN, "No E.164 arg (E.164 ignored) !\n");
|
|
|
|
else {
|
|
|
|
cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_E164);
|
|
|
|
strncpy(cx->cfg.callback.msg, arg->argv[++dummyint],
|
|
|
|
sizeof cx->cfg.callback.msg - 1);
|
|
|
|
cx->cfg.callback.msg[sizeof cx->cfg.callback.msg - 1] = '\0';
|
|
|
|
}
|
|
|
|
} else if (!strcasecmp(arg->argv[dummyint], "none"))
|
|
|
|
cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_NONE);
|
2001-07-03 01:02:26 +00:00
|
|
|
else {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
1998-08-07 18:42:51 +00:00
|
|
|
}
|
|
|
|
if (cx->cfg.callback.opmask == CALLBACK_BIT(CALLBACK_NONE))
|
|
|
|
cx->cfg.callback.opmask = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VAR_CBCP:
|
|
|
|
cx->cfg.cbcp.delay = 0;
|
|
|
|
*cx->cfg.cbcp.phone = '\0';
|
|
|
|
cx->cfg.cbcp.fsmretry = DEF_FSMRETRY;
|
|
|
|
if (arg->argc > arg->argn) {
|
|
|
|
strncpy(cx->cfg.cbcp.phone, arg->argv[arg->argn],
|
|
|
|
sizeof cx->cfg.cbcp.phone - 1);
|
|
|
|
cx->cfg.cbcp.phone[sizeof cx->cfg.cbcp.phone - 1] = '\0';
|
|
|
|
if (arg->argc > arg->argn + 1) {
|
|
|
|
cx->cfg.cbcp.delay = atoi(arg->argv[arg->argn + 1]);
|
|
|
|
if (arg->argc > arg->argn + 2) {
|
|
|
|
long_val = atol(arg->argv[arg->argn + 2]);
|
|
|
|
if (long_val < MIN_FSMRETRY)
|
|
|
|
log_Printf(LogWARN, "%ld: Invalid CBCP FSM retry period - min %d\n",
|
|
|
|
long_val, MIN_FSMRETRY);
|
|
|
|
else
|
|
|
|
cx->cfg.cbcp.fsmretry = long_val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-08-25 17:48:43 +00:00
|
|
|
|
|
|
|
case VAR_CHOKED:
|
|
|
|
arg->bundle->cfg.choked.timeout = atoi(argp);
|
|
|
|
if (arg->bundle->cfg.choked.timeout <= 0)
|
|
|
|
arg->bundle->cfg.choked.timeout = CHOKED_TIMEOUT;
|
|
|
|
break;
|
1998-10-26 19:07:39 +00:00
|
|
|
|
|
|
|
case VAR_SENDPIPE:
|
|
|
|
long_val = atol(argp);
|
2001-08-14 16:05:52 +00:00
|
|
|
arg->bundle->ncp.cfg.sendpipe = long_val;
|
1998-10-26 19:07:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VAR_RECVPIPE:
|
|
|
|
long_val = atol(argp);
|
2001-08-14 16:05:52 +00:00
|
|
|
arg->bundle->ncp.cfg.recvpipe = long_val;
|
1998-10-26 19:07:39 +00:00
|
|
|
break;
|
1999-01-28 01:56:34 +00:00
|
|
|
|
|
|
|
#ifndef NORADIUS
|
|
|
|
case VAR_RADIUS:
|
|
|
|
if (!*argp)
|
|
|
|
*arg->bundle->radius.cfg.file = '\0';
|
|
|
|
else if (access(argp, R_OK)) {
|
|
|
|
log_Printf(LogWARN, "%s: %s\n", argp, strerror(errno));
|
2001-07-03 01:02:26 +00:00
|
|
|
res = 1;
|
|
|
|
break;
|
1999-01-28 01:56:34 +00:00
|
|
|
} else {
|
|
|
|
strncpy(arg->bundle->radius.cfg.file, argp,
|
|
|
|
sizeof arg->bundle->radius.cfg.file - 1);
|
|
|
|
arg->bundle->radius.cfg.file
|
|
|
|
[sizeof arg->bundle->radius.cfg.file - 1] = '\0';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
1999-02-16 00:16:56 +00:00
|
|
|
|
|
|
|
case VAR_CD:
|
|
|
|
if (*argp) {
|
1999-09-26 23:02:18 +00:00
|
|
|
if (strcasecmp(argp, "off")) {
|
|
|
|
long_val = atol(argp);
|
|
|
|
if (long_val < 0)
|
|
|
|
long_val = 0;
|
|
|
|
cx->physical->cfg.cd.delay = long_val;
|
|
|
|
cx->physical->cfg.cd.necessity = argp[strlen(argp)-1] == '!' ?
|
|
|
|
CD_REQUIRED : CD_VARIABLE;
|
|
|
|
} else
|
|
|
|
cx->physical->cfg.cd.necessity = CD_NOTREQUIRED;
|
1999-02-16 00:16:56 +00:00
|
|
|
} else {
|
1999-11-26 22:44:33 +00:00
|
|
|
cx->physical->cfg.cd.delay = 0;
|
|
|
|
cx->physical->cfg.cd.necessity = CD_DEFAULT;
|
1999-02-16 00:16:56 +00:00
|
|
|
}
|
|
|
|
break;
|
1996-12-22 17:09:17 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
case VAR_PARITY:
|
|
|
|
if (arg->argc == arg->argn + 1)
|
2001-07-03 01:02:26 +00:00
|
|
|
res = physical_SetParity(arg->cx->physical, argp);
|
1999-05-08 11:07:56 +00:00
|
|
|
else {
|
2001-07-03 01:02:26 +00:00
|
|
|
log_Printf(LogWARN, "Parity value must be odd, even or none\n");
|
|
|
|
res = 1;
|
1999-05-08 11:07:56 +00:00
|
|
|
}
|
|
|
|
break;
|
1996-12-22 17:09:17 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
case VAR_CRTSCTS:
|
|
|
|
if (strcasecmp(argp, "on") == 0)
|
1998-05-21 21:49:08 +00:00
|
|
|
physical_SetRtsCts(arg->cx->physical, 1);
|
1999-05-08 11:07:56 +00:00
|
|
|
else if (strcasecmp(argp, "off") == 0)
|
1998-05-21 21:49:08 +00:00
|
|
|
physical_SetRtsCts(arg->cx->physical, 0);
|
1999-05-08 11:07:56 +00:00
|
|
|
else {
|
2001-07-03 01:02:26 +00:00
|
|
|
log_Printf(LogWARN, "RTS/CTS value must be on or off\n");
|
|
|
|
res = 1;
|
1999-05-08 11:07:56 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-09-04 00:00:21 +00:00
|
|
|
|
|
|
|
case VAR_URGENTPORTS:
|
1999-09-07 07:51:11 +00:00
|
|
|
if (arg->argn == arg->argc) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_SetUrgentTOS(&arg->bundle->ncp);
|
|
|
|
ncp_ClearUrgentTcpPorts(&arg->bundle->ncp);
|
|
|
|
ncp_ClearUrgentUdpPorts(&arg->bundle->ncp);
|
1999-09-07 07:51:11 +00:00
|
|
|
} else if (!strcasecmp(arg->argv[arg->argn], "udp")) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_SetUrgentTOS(&arg->bundle->ncp);
|
1999-09-07 07:51:11 +00:00
|
|
|
if (arg->argn == arg->argc - 1)
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_ClearUrgentUdpPorts(&arg->bundle->ncp);
|
1999-09-07 07:51:11 +00:00
|
|
|
else for (f = arg->argn + 1; f < arg->argc; f++)
|
|
|
|
if (*arg->argv[f] == '+')
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_AddUrgentUdpPort(&arg->bundle->ncp, atoi(arg->argv[f] + 1));
|
1999-09-07 07:51:11 +00:00
|
|
|
else if (*arg->argv[f] == '-')
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_RemoveUrgentUdpPort(&arg->bundle->ncp, atoi(arg->argv[f] + 1));
|
1999-09-07 07:51:11 +00:00
|
|
|
else {
|
|
|
|
if (f == arg->argn)
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_ClearUrgentUdpPorts(&arg->bundle->ncp);
|
|
|
|
ncp_AddUrgentUdpPort(&arg->bundle->ncp, atoi(arg->argv[f]));
|
1999-09-07 07:51:11 +00:00
|
|
|
}
|
2000-06-08 20:07:48 +00:00
|
|
|
} else if (arg->argn == arg->argc - 1 &&
|
|
|
|
!strcasecmp(arg->argv[arg->argn], "none")) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_ClearUrgentTcpPorts(&arg->bundle->ncp);
|
|
|
|
ncp_ClearUrgentUdpPorts(&arg->bundle->ncp);
|
|
|
|
ncp_ClearUrgentTOS(&arg->bundle->ncp);
|
1999-09-07 07:51:11 +00:00
|
|
|
} else {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_SetUrgentTOS(&arg->bundle->ncp);
|
1999-09-07 07:51:11 +00:00
|
|
|
first = arg->argn;
|
|
|
|
if (!strcasecmp(arg->argv[first], "tcp") && ++first == arg->argc)
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_ClearUrgentTcpPorts(&arg->bundle->ncp);
|
1999-09-07 07:51:11 +00:00
|
|
|
|
|
|
|
for (f = first; f < arg->argc; f++)
|
|
|
|
if (*arg->argv[f] == '+')
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_AddUrgentTcpPort(&arg->bundle->ncp, atoi(arg->argv[f] + 1));
|
1999-09-07 07:51:11 +00:00
|
|
|
else if (*arg->argv[f] == '-')
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_RemoveUrgentTcpPort(&arg->bundle->ncp, atoi(arg->argv[f] + 1));
|
1999-09-07 07:51:11 +00:00
|
|
|
else {
|
|
|
|
if (f == first)
|
2001-08-14 16:05:52 +00:00
|
|
|
ncp_ClearUrgentTcpPorts(&arg->bundle->ncp);
|
|
|
|
ncp_AddUrgentTcpPort(&arg->bundle->ncp, atoi(arg->argv[f]));
|
1999-09-07 07:51:11 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-04 00:00:21 +00:00
|
|
|
break;
|
2004-07-29 05:59:43 +00:00
|
|
|
|
|
|
|
case VAR_PPPOE:
|
|
|
|
if (strcasecmp(argp, "3Com") == 0)
|
|
|
|
physical_SetPPPoEnonstandard(arg->cx->physical, 1);
|
|
|
|
else if (strcasecmp(argp, "standard") == 0)
|
|
|
|
physical_SetPPPoEnonstandard(arg->cx->physical, 0);
|
|
|
|
else {
|
|
|
|
log_Printf(LogWARN, "PPPoE standard value must be \"standard\" or \"3Com\"\n");
|
|
|
|
res = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1999-05-08 11:07:56 +00:00
|
|
|
|
2001-07-03 01:02:26 +00:00
|
|
|
return res;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static struct cmdtab const SetCommands[] = {
|
1998-05-21 21:49:08 +00:00
|
|
|
{"accmap", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"accmap value", "set accmap hex-value", (const void *)VAR_ACCMAP},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"authkey", "key", SetVariable, LOCAL_AUTH,
|
1998-05-21 21:49:08 +00:00
|
|
|
"authentication key", "set authkey|key key", (const void *)VAR_AUTHKEY},
|
1997-08-25 00:29:32 +00:00
|
|
|
{"authname", NULL, SetVariable, LOCAL_AUTH,
|
1998-05-21 21:49:08 +00:00
|
|
|
"authentication name", "set authname name", (const void *)VAR_AUTHNAME},
|
|
|
|
{"autoload", NULL, SetVariable, LOCAL_AUTH,
|
|
|
|
"auto link [de]activation", "set autoload maxtime maxload mintime minload",
|
|
|
|
(const void *)VAR_AUTOLOAD},
|
1999-09-04 00:00:21 +00:00
|
|
|
{"bandwidth", NULL, mp_SetDatalinkBandwidth, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"datalink bandwidth", "set bandwidth value", NULL},
|
1998-08-07 18:42:51 +00:00
|
|
|
{"callback", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"callback control", "set callback [none|auth|cbcp|"
|
|
|
|
"E.164 *|number[,number]...]...", (const void *)VAR_CALLBACK},
|
|
|
|
{"cbcp", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
2002-06-15 08:03:30 +00:00
|
|
|
"CBCP control", "set cbcp [*|phone[,phone...] [delay [timeout]]]",
|
1998-08-07 18:42:51 +00:00
|
|
|
(const void *)VAR_CBCP},
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
{"ccpretry", "ccpretries", SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"CCP retries", "set ccpretry value [attempts]", (const void *)VAR_CCPRETRY},
|
1999-02-16 00:16:56 +00:00
|
|
|
{"cd", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Carrier delay requirement",
|
|
|
|
"set cd value[!]", (const void *)VAR_CD},
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
{"chapretry", "chapretries", SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"CHAP retries", "set chapretry value [attempts]",
|
|
|
|
(const void *)VAR_CHAPRETRY},
|
1998-08-25 17:48:43 +00:00
|
|
|
{"choked", NULL, SetVariable, LOCAL_AUTH,
|
|
|
|
"choked timeout", "set choked [secs]", (const void *)VAR_CHOKED},
|
1999-05-08 11:07:56 +00:00
|
|
|
{"ctsrts", "crtscts", SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Use hardware flow control", "set ctsrts [on|off]",
|
|
|
|
(const char *)VAR_CRTSCTS},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"deflate", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"deflate window sizes", "set deflate out-winsize in-winsize",
|
|
|
|
(const void *) VAR_WINSIZE},
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2000-10-30 00:15:04 +00:00
|
|
|
{"mppe", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
|
2002-06-15 08:03:30 +00:00
|
|
|
"MPPE key size and state", "set mppe [40|56|128|* [stateful|stateless|*]]",
|
2001-06-18 15:00:22 +00:00
|
|
|
(const void *) VAR_MPPE},
|
2000-10-30 00:15:04 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
{"device", "line", SetVariable, LOCAL_AUTH | LOCAL_CX,
|
1999-05-08 11:07:56 +00:00
|
|
|
"physical device name", "set device|line device-name[,device-name]",
|
1998-05-21 21:49:08 +00:00
|
|
|
(const void *) VAR_DEVICE},
|
|
|
|
{"dial", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"dialing script", "set dial chat-script", (const void *) VAR_DIAL},
|
|
|
|
{"dns", NULL, SetVariable, LOCAL_AUTH, "Domain Name Server",
|
|
|
|
"set dns pri-addr [sec-addr]", (const void *)VAR_DNS},
|
|
|
|
{"enddisc", NULL, mp_SetEnddisc, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Endpoint Discriminator", "set enddisc [IP|magic|label|psn value]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"escape", NULL, SetEscape, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"escape characters", "set escape hex-digit ...", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"filter", NULL, filter_Set, LOCAL_AUTH,
|
|
|
|
"packet filters", "set filter alive|dial|in|out rule-no permit|deny "
|
2001-08-14 16:05:52 +00:00
|
|
|
"[src_addr[/width]] [dst_addr[/width]] [proto "
|
2004-09-05 01:46:52 +00:00
|
|
|
"[src [lt|eq|gt port]] [dst [lt|eq|gt port]] [estab] [syn] [finrst]]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"hangup", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"hangup script", "set hangup chat-script", (const void *) VAR_HANGUP},
|
|
|
|
{"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH, "destination address",
|
2004-09-05 01:46:52 +00:00
|
|
|
"set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]", NULL},
|
2000-06-11 02:30:51 +00:00
|
|
|
{"ifqueue", NULL, SetVariable, LOCAL_AUTH, "interface queue",
|
|
|
|
"set ifqueue packets", (const void *)VAR_IFQUEUE},
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
{"ipcpretry", "ipcpretries", SetVariable, LOCAL_AUTH, "IPCP retries",
|
|
|
|
"set ipcpretry value [attempts]", (const void *)VAR_IPCPRETRY},
|
2002-08-29 02:44:58 +00:00
|
|
|
{"ipv6cpretry", "ipv6cpretries", SetVariable, LOCAL_AUTH, "IPV6CP retries",
|
|
|
|
"set ipv6cpretry value [attempts]", (const void *)VAR_IPV6CPRETRY},
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
{"lcpretry", "lcpretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "LCP retries",
|
|
|
|
"set lcpretry value [attempts]", (const void *)VAR_LCPRETRY},
|
1998-06-06 23:00:33 +00:00
|
|
|
{"log", NULL, log_SetLevel, LOCAL_AUTH, "log level",
|
2000-10-30 00:15:35 +00:00
|
|
|
"set log [local] [+|-]all|async|cbcp|ccp|chat|command|connect|debug|dns|hdlc|"
|
2004-09-05 01:46:52 +00:00
|
|
|
"id0|ipcp|lcp|lqm|phase|physical|radius|sync|tcp/ip|timer|tun...", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"login", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"login script", "set login chat-script", (const void *) VAR_LOGIN},
|
1999-10-25 13:49:44 +00:00
|
|
|
{"logout", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"logout script", "set logout chat-script", (const void *) VAR_LOGOUT},
|
2004-12-13 12:51:19 +00:00
|
|
|
{"lqrperiod", "echoperiod", SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"LQR period", "set lqr/echo period value", (const void *)VAR_LQRPERIOD},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"mode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "mode value",
|
|
|
|
"set mode interactive|auto|ddial|background", (const void *)VAR_MODE},
|
|
|
|
{"mrru", NULL, SetVariable, LOCAL_AUTH, "MRRU value",
|
|
|
|
"set mrru value", (const void *)VAR_MRRU},
|
2002-05-04 19:38:43 +00:00
|
|
|
{"mru", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
2001-06-18 14:59:36 +00:00
|
|
|
"MRU value", "set mru [max[imum]] [value]", (const void *)VAR_MRU},
|
|
|
|
{"mtu", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"interface MTU value", "set mtu [max[imum]] [value]", (const void *)VAR_MTU},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"nbns", NULL, SetVariable, LOCAL_AUTH, "NetBIOS Name Server",
|
|
|
|
"set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS},
|
|
|
|
{"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "open mode",
|
|
|
|
"set openmode active|passive [secs]", (const void *)VAR_OPENMODE},
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
{"papretry", "papretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "PAP retries",
|
|
|
|
"set papretry value [attempts]", (const void *)VAR_PAPRETRY},
|
1999-05-08 11:07:56 +00:00
|
|
|
{"parity", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "serial parity",
|
|
|
|
"set parity [odd|even|none]", (const void *)VAR_PARITY},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "telephone number(s)",
|
|
|
|
"set phone phone1[:phone2[...]]", (const void *)VAR_PHONE},
|
1998-10-27 22:53:22 +00:00
|
|
|
{"proctitle", "title", SetProcTitle, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Process title", "set proctitle [value]", NULL},
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
{"radius", NULL, SetVariable, LOCAL_AUTH,
|
|
|
|
"RADIUS Config", "set radius cfgfile", (const void *)VAR_RADIUS},
|
2004-07-17 01:07:53 +00:00
|
|
|
{"rad_alive", NULL, SetVariable, LOCAL_AUTH,
|
|
|
|
"Raduis alive interval", "set rad_alive value",
|
|
|
|
(const void *)VAR_RAD_ALIVE},
|
1999-01-28 01:56:34 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
{"reconnect", NULL, datalink_SetReconnect, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Reconnect timeout", "set reconnect value ntries", NULL},
|
1998-10-26 19:07:39 +00:00
|
|
|
{"recvpipe", NULL, SetVariable, LOCAL_AUTH,
|
|
|
|
"RECVPIPE value", "set recvpipe value", (const void *)VAR_RECVPIPE},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"redial", NULL, datalink_SetRedial, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"Redial timeout", "set redial secs[+inc[-incmax]][.next] [attempts]", NULL},
|
1998-10-26 19:07:39 +00:00
|
|
|
{"sendpipe", NULL, SetVariable, LOCAL_AUTH,
|
|
|
|
"SENDPIPE value", "set sendpipe value", (const void *)VAR_SENDPIPE},
|
2001-01-26 01:41:34 +00:00
|
|
|
{"server", "socket", SetServer, LOCAL_AUTH, "diagnostic port",
|
2004-09-05 01:46:52 +00:00
|
|
|
"set server|socket TcpPort|LocalName|none|open|closed [password [mask]]",
|
|
|
|
NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"speed", NULL, SetModemSpeed, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"physical speed", "set speed value|sync", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH | LOCAL_CX,
|
2004-09-05 01:46:52 +00:00
|
|
|
"STOPPED timeouts", "set stopped [LCPseconds [CCPseconds]]", NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"timeout", NULL, SetVariable, LOCAL_AUTH, "Idle timeout",
|
|
|
|
"set timeout idletime", (const void *)VAR_IDLETIMEOUT},
|
1999-09-07 07:51:11 +00:00
|
|
|
{"urgent", NULL, SetVariable, LOCAL_AUTH, "urgent ports",
|
|
|
|
"set urgent [tcp|udp] [+|-]port...", (const void *)VAR_URGENTPORTS},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"vj", NULL, ipcp_vjset, LOCAL_AUTH,
|
2004-09-05 01:46:52 +00:00
|
|
|
"vj values", "set vj slots|slotcomp [value]", NULL},
|
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},
|
2004-07-29 05:59:43 +00:00
|
|
|
{"pppoe", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Connect using standard/3Com mode", "set pppoe [standard|3Com]",
|
|
|
|
(const char *)VAR_PPPOE},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, 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
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc > arg->argn)
|
|
|
|
FindExec(arg->bundle, SetCommands, arg->argc, arg->argn, arg->argv,
|
|
|
|
arg->prompt, arg->cx);
|
|
|
|
else if (arg->prompt)
|
|
|
|
prompt_Printf(arg->prompt, "Use `set ?' to get a list or `set ? <var>' for"
|
2000-03-14 01:47:27 +00:00
|
|
|
" syntax help.\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogWARN, "set command must have arguments\n");
|
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
|
|
|
AddCommand(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
2001-08-14 16:05:52 +00:00
|
|
|
struct ncpaddr gw;
|
|
|
|
struct ncprange dest;
|
|
|
|
struct in_addr host;
|
2003-03-26 06:30:11 +00:00
|
|
|
#ifndef NOINET6
|
|
|
|
struct in6_addr host6;
|
|
|
|
#endif
|
2001-08-14 16:05:52 +00:00
|
|
|
int dest_default, gw_arg, addrs;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc != arg->argn+3 && arg->argc != arg->argn+2)
|
1997-12-07 04:09:15 +00:00
|
|
|
return -1;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
addrs = 0;
|
2001-08-14 16:05:52 +00:00
|
|
|
dest_default = 0;
|
|
|
|
if (arg->argc == arg->argn + 2) {
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!strcasecmp(arg->argv[arg->argn], "default"))
|
2001-08-14 16:05:52 +00:00
|
|
|
dest_default = 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
else {
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncprange_aton(&dest, &arg->bundle->ncp, arg->argv[arg->argn]))
|
1998-05-21 21:49:08 +00:00
|
|
|
return -1;
|
|
|
|
if (!strncasecmp(arg->argv[arg->argn], "MYADDR", 6))
|
|
|
|
addrs = ROUTE_DSTMYADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
else if (!strncasecmp(arg->argv[arg->argn], "MYADDR6", 7))
|
|
|
|
addrs = ROUTE_DSTMYADDR6;
|
1998-05-21 21:49:08 +00:00
|
|
|
else if (!strncasecmp(arg->argv[arg->argn], "HISADDR", 7))
|
|
|
|
addrs = ROUTE_DSTHISADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
else if (!strncasecmp(arg->argv[arg->argn], "HISADDR6", 8))
|
|
|
|
addrs = ROUTE_DSTHISADDR6;
|
2000-03-14 01:47:27 +00:00
|
|
|
else if (!strncasecmp(arg->argv[arg->argn], "DNS0", 4))
|
|
|
|
addrs = ROUTE_DSTDNS0;
|
|
|
|
else if (!strncasecmp(arg->argv[arg->argn], "DNS1", 4))
|
|
|
|
addrs = ROUTE_DSTDNS1;
|
1997-12-07 04:09:15 +00:00
|
|
|
}
|
2001-08-14 16:05:52 +00:00
|
|
|
gw_arg = 1;
|
1998-03-13 01:36:10 +00:00
|
|
|
} else {
|
1998-05-21 21:49:08 +00:00
|
|
|
if (strcasecmp(arg->argv[arg->argn], "MYADDR") == 0) {
|
|
|
|
addrs = ROUTE_DSTMYADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
host = arg->bundle->ncp.ipcp.my_ip;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "HISADDR") == 0) {
|
|
|
|
addrs = ROUTE_DSTHISADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
host = arg->bundle->ncp.ipcp.peer_ip;
|
2000-03-14 01:47:27 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "DNS0") == 0) {
|
|
|
|
addrs = ROUTE_DSTDNS0;
|
2001-08-14 16:05:52 +00:00
|
|
|
host = arg->bundle->ncp.ipcp.ns.dns[0];
|
2000-03-14 01:47:27 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "DNS1") == 0) {
|
|
|
|
addrs = ROUTE_DSTDNS1;
|
2001-08-14 16:05:52 +00:00
|
|
|
host = arg->bundle->ncp.ipcp.ns.dns[1];
|
2000-08-30 20:49:50 +00:00
|
|
|
} else {
|
2001-08-14 16:05:52 +00:00
|
|
|
host = GetIpAddr(arg->argv[arg->argn]);
|
|
|
|
if (host.s_addr == INADDR_NONE) {
|
2000-08-30 20:49:50 +00:00
|
|
|
log_Printf(LogWARN, "%s: Invalid destination address\n",
|
|
|
|
arg->argv[arg->argn]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_setip4(&dest, host, GetIpAddr(arg->argv[arg->argn + 1]));
|
|
|
|
gw_arg = 2;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
if (strcasecmp(arg->argv[arg->argn + gw_arg], "HISADDR") == 0) {
|
|
|
|
ncpaddr_setip4(&gw, arg->bundle->ncp.ipcp.peer_ip);
|
1998-05-21 21:49:08 +00:00
|
|
|
addrs |= ROUTE_GWHISADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
2001-08-18 19:07:13 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn + gw_arg], "HISADDR6") == 0) {
|
2003-03-26 06:30:11 +00:00
|
|
|
if (!ncpaddr_getip6(&arg->bundle->ncp.ipv6cp.hisaddr, &host6))
|
|
|
|
memset(&host6, '\0', sizeof host6);
|
|
|
|
ncpaddr_setip6(&gw, &host6);
|
2001-08-14 16:05:52 +00:00
|
|
|
addrs |= ROUTE_GWHISADDR6;
|
|
|
|
#endif
|
2000-08-30 20:49:50 +00:00
|
|
|
} else {
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncpaddr_aton(&gw, &arg->bundle->ncp, arg->argv[arg->argn + gw_arg])) {
|
2000-08-30 20:49:50 +00:00
|
|
|
log_Printf(LogWARN, "%s: Invalid gateway address\n",
|
2001-08-14 16:05:52 +00:00
|
|
|
arg->argv[arg->argn + gw_arg]);
|
2000-08-30 20:49:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
if (dest_default)
|
|
|
|
ncprange_setdefault(&dest, ncpaddr_family(&gw));
|
|
|
|
|
|
|
|
if (rt_Set(arg->bundle, RTM_ADD, &dest, &gw, arg->cmd->args ? 1 : 0,
|
|
|
|
((addrs & ROUTE_GWHISADDR) || (addrs & ROUTE_GWHISADDR6)) ? 1 : 0)
|
1999-01-28 01:56:34 +00:00
|
|
|
&& addrs != ROUTE_STATIC)
|
2001-08-14 16:05:52 +00:00
|
|
|
route_Add(&arg->bundle->ncp.route, addrs, &dest, &gw);
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1997-12-07 04:09:15 +00:00
|
|
|
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
|
|
|
{
|
2001-08-14 16:05:52 +00:00
|
|
|
struct ncprange dest;
|
1998-05-21 21:49:08 +00:00
|
|
|
int addrs;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc == arg->argn+1) {
|
|
|
|
if(strcasecmp(arg->argv[arg->argn], "all") == 0) {
|
|
|
|
route_IfDelete(arg->bundle, 0);
|
2001-08-14 16:05:52 +00:00
|
|
|
route_DeleteAll(&arg->bundle->ncp.route);
|
1998-05-21 21:49:08 +00:00
|
|
|
} else {
|
|
|
|
addrs = 0;
|
|
|
|
if (strcasecmp(arg->argv[arg->argn], "MYADDR") == 0) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_setip4host(&dest, arg->bundle->ncp.ipcp.my_ip);
|
1998-05-21 21:49:08 +00:00
|
|
|
addrs = ROUTE_DSTMYADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
2001-08-18 19:07:13 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "MYADDR6") == 0) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_sethost(&dest, &arg->bundle->ncp.ipv6cp.myaddr);
|
|
|
|
addrs = ROUTE_DSTMYADDR6;
|
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "HISADDR") == 0) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_setip4host(&dest, arg->bundle->ncp.ipcp.peer_ip);
|
1998-05-21 21:49:08 +00:00
|
|
|
addrs = ROUTE_DSTHISADDR;
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
2001-08-18 19:07:13 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "HISADDR6") == 0) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_sethost(&dest, &arg->bundle->ncp.ipv6cp.hisaddr);
|
|
|
|
addrs = ROUTE_DSTHISADDR6;
|
|
|
|
#endif
|
2000-03-14 01:47:27 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "DNS0") == 0) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_setip4host(&dest, arg->bundle->ncp.ipcp.ns.dns[0]);
|
2000-03-14 01:47:27 +00:00
|
|
|
addrs = ROUTE_DSTDNS0;
|
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "DNS1") == 0) {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_setip4host(&dest, arg->bundle->ncp.ipcp.ns.dns[1]);
|
2000-03-14 01:47:27 +00:00
|
|
|
addrs = ROUTE_DSTDNS1;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else {
|
2001-08-14 16:05:52 +00:00
|
|
|
ncprange_aton(&dest, &arg->bundle->ncp, arg->argv[arg->argn]);
|
1998-05-21 21:49:08 +00:00
|
|
|
addrs = ROUTE_STATIC;
|
|
|
|
}
|
2001-08-14 16:05:52 +00:00
|
|
|
rt_Set(arg->bundle, RTM_DELETE, &dest, NULL, arg->cmd->args ? 1 : 0, 0);
|
|
|
|
route_Delete(&arg->bundle->ncp.route, addrs, &dest);
|
1997-12-07 04:09:15 +00:00
|
|
|
}
|
1998-03-13 01:36:10 +00:00
|
|
|
} 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
|
|
|
|
1999-08-19 18:15:52 +00:00
|
|
|
#ifndef NONAT
|
1997-05-23 04:54:03 +00:00
|
|
|
static int
|
2000-03-31 14:26:23 +00:00
|
|
|
NatEnable(struct cmdargs const *arg)
|
1997-05-23 04:54:03 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc == arg->argn+1) {
|
|
|
|
if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
|
1999-08-19 18:15:52 +00:00
|
|
|
if (!arg->bundle->NatEnabled) {
|
1999-05-08 11:07:56 +00:00
|
|
|
if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED)
|
|
|
|
PacketAliasSetAddress(arg->bundle->ncp.ipcp.my_ip);
|
1999-08-19 18:15:52 +00:00
|
|
|
arg->bundle->NatEnabled = 1;
|
1999-05-08 11:07:56 +00:00
|
|
|
}
|
1998-06-27 14:17:28 +00:00
|
|
|
return 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "no") == 0) {
|
1999-08-19 18:15:52 +00:00
|
|
|
arg->bundle->NatEnabled = 0;
|
2004-11-29 17:11:15 +00:00
|
|
|
opt_disable(arg->bundle, OPT_IFACEALIAS);
|
1998-10-22 02:32:50 +00:00
|
|
|
/* Don't iface_Clear() - there may be manually configured addresses */
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1997-05-26 00:44:10 +00:00
|
|
|
}
|
1998-04-25 09:16:23 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1997-05-23 04:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2000-03-31 14:26:23 +00:00
|
|
|
NatOption(struct cmdargs const *arg)
|
1997-05-23 04:54:03 +00:00
|
|
|
{
|
1998-08-26 18:07:57 +00:00
|
|
|
long param = (long)arg->cmd->args;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (arg->argc == arg->argn+1) {
|
|
|
|
if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
|
1999-08-19 18:15:52 +00:00
|
|
|
if (arg->bundle->NatEnabled) {
|
1998-06-27 14:17:28 +00:00
|
|
|
PacketAliasSetMode(param, param);
|
1997-08-25 00:29:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1999-08-19 18:15:52 +00:00
|
|
|
log_Printf(LogWARN, "nat not enabled\n");
|
1998-05-21 21:49:08 +00:00
|
|
|
} else if (strcmp(arg->argv[arg->argn], "no") == 0) {
|
1999-08-19 18:15:52 +00:00
|
|
|
if (arg->bundle->NatEnabled) {
|
1998-06-27 14:17:28 +00:00
|
|
|
PacketAliasSetMode(0, param);
|
1997-08-25 00:29:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1999-08-19 18:15:52 +00:00
|
|
|
log_Printf(LogWARN, "nat not enabled\n");
|
1997-08-25 00:29:32 +00:00
|
|
|
}
|
1998-04-25 09:16:23 +00:00
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
return -1;
|
1997-05-23 04:54:03 +00:00
|
|
|
}
|
1999-08-19 18:15:52 +00:00
|
|
|
#endif /* #ifndef NONAT */
|
1997-11-11 22:58:14 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static int
|
|
|
|
LinkCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->argc > arg->argn+1) {
|
|
|
|
char namelist[LINE_LEN];
|
|
|
|
struct datalink *cx;
|
|
|
|
char *name;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
if (!strcmp(arg->argv[arg->argn], "*")) {
|
|
|
|
struct datalink *dl;
|
|
|
|
|
|
|
|
cx = arg->bundle->links;
|
|
|
|
while (cx) {
|
|
|
|
/* Watch it, the command could be a ``remove'' */
|
|
|
|
dl = cx->next;
|
|
|
|
FindExec(arg->bundle, Commands, arg->argc, arg->argn+1, arg->argv,
|
|
|
|
arg->prompt, cx);
|
|
|
|
for (cx = arg->bundle->links; cx; cx = cx->next)
|
|
|
|
if (cx == dl)
|
|
|
|
break; /* Pointer's still valid ! */
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
strncpy(namelist, arg->argv[arg->argn], sizeof namelist - 1);
|
|
|
|
namelist[sizeof namelist - 1] = '\0';
|
|
|
|
for(name = strtok(namelist, ", "); name; name = strtok(NULL,", "))
|
|
|
|
if (!bundle2datalink(arg->bundle, name)) {
|
|
|
|
log_Printf(LogWARN, "link: %s: Invalid link name\n", name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(namelist, arg->argv[arg->argn], sizeof namelist - 1);
|
|
|
|
namelist[sizeof namelist - 1] = '\0';
|
|
|
|
for(name = strtok(namelist, ", "); name; name = strtok(NULL,", ")) {
|
|
|
|
cx = bundle2datalink(arg->bundle, name);
|
|
|
|
if (cx)
|
|
|
|
FindExec(arg->bundle, Commands, arg->argc, arg->argn+1, arg->argv,
|
|
|
|
arg->prompt, cx);
|
|
|
|
else {
|
|
|
|
log_Printf(LogWARN, "link: %s: Invalidated link name !\n", name);
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2002-04-22 13:44:47 +00:00
|
|
|
log_Printf(LogWARN, "usage: %s\n", arg->cmd->syntax);
|
1998-05-21 21:49:08 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct link *
|
|
|
|
command_ChooseLink(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->cx)
|
|
|
|
return &arg->cx->physical->link;
|
1998-06-27 23:48:54 +00:00
|
|
|
else if (!arg->bundle->ncp.mp.cfg.mrru) {
|
1998-05-21 21:49:08 +00:00
|
|
|
struct datalink *dl = bundle2datalink(arg->bundle, NULL);
|
1998-06-27 23:48:54 +00:00
|
|
|
if (dl)
|
|
|
|
return &dl->physical->link;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1998-06-27 23:48:54 +00:00
|
|
|
return &arg->bundle->ncp.mp.link;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
ident_cmd(const char *cmd, unsigned *keep, unsigned *add)
|
|
|
|
{
|
|
|
|
const char *result;
|
|
|
|
|
|
|
|
switch (*cmd) {
|
|
|
|
case 'A':
|
|
|
|
case 'a':
|
|
|
|
result = "accept";
|
|
|
|
*keep = NEG_MYMASK;
|
|
|
|
*add = NEG_ACCEPTED;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
case 'd':
|
|
|
|
switch (cmd[1]) {
|
|
|
|
case 'E':
|
|
|
|
case 'e':
|
|
|
|
result = "deny";
|
|
|
|
*keep = NEG_MYMASK;
|
|
|
|
*add = 0;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
case 'i':
|
|
|
|
result = "disable";
|
|
|
|
*keep = NEG_HISMASK;
|
|
|
|
*add = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
case 'e':
|
|
|
|
result = "enable";
|
|
|
|
*keep = NEG_HISMASK;
|
|
|
|
*add = NEG_ENABLED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
OptSet(struct cmdargs const *arg)
|
|
|
|
{
|
2004-11-29 17:11:15 +00:00
|
|
|
int opt = (int)(long)arg->cmd->args;
|
|
|
|
unsigned keep; /* Keep this opt */
|
|
|
|
unsigned add; /* Add this opt */
|
1998-05-21 21:49:08 +00:00
|
|
|
|
2001-08-15 13:53:38 +00:00
|
|
|
if (ident_cmd(arg->argv[arg->argn - 2], &keep, &add) == NULL)
|
1998-05-21 21:49:08 +00:00
|
|
|
return 1;
|
|
|
|
|
2001-08-18 12:30:41 +00:00
|
|
|
#ifndef NOINET6
|
2004-11-29 17:11:15 +00:00
|
|
|
if (add == NEG_ENABLED && opt == OPT_IPV6CP && !probe.ipv6_available) {
|
2001-08-15 13:53:38 +00:00
|
|
|
log_Printf(LogWARN, "IPv6 is not available on this machine\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2001-08-18 12:30:41 +00:00
|
|
|
#endif
|
2004-11-29 17:11:15 +00:00
|
|
|
if (!add && ((opt == OPT_NAS_IP_ADDRESS &&
|
|
|
|
!Enabled(arg->bundle, OPT_NAS_IDENTIFIER)) ||
|
|
|
|
(opt == OPT_NAS_IDENTIFIER &&
|
|
|
|
!Enabled(arg->bundle, OPT_NAS_IP_ADDRESS)))) {
|
|
|
|
log_Printf(LogWARN,
|
|
|
|
"Cannot disable both NAS-IP-Address and NAS-Identifier\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2001-08-15 13:53:38 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (add)
|
2004-11-29 17:11:15 +00:00
|
|
|
opt_enable(arg->bundle, opt);
|
1998-05-21 21:49:08 +00:00
|
|
|
else
|
2004-11-29 17:11:15 +00:00
|
|
|
opt_disable(arg->bundle, opt);
|
2001-08-15 13:53:38 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-10-22 02:32:50 +00:00
|
|
|
static int
|
|
|
|
IfaceAliasOptSet(struct cmdargs const *arg)
|
|
|
|
{
|
2004-11-29 17:11:15 +00:00
|
|
|
unsigned long long save = arg->bundle->cfg.optmask;
|
1998-10-22 02:32:50 +00:00
|
|
|
int result = OptSet(arg);
|
|
|
|
|
|
|
|
if (result == 0)
|
1999-08-19 18:15:52 +00:00
|
|
|
if (Enabled(arg->bundle, OPT_IFACEALIAS) && !arg->bundle->NatEnabled) {
|
2004-11-29 17:11:15 +00:00
|
|
|
arg->bundle->cfg.optmask = save;
|
1999-08-19 18:15:52 +00:00
|
|
|
log_Printf(LogWARN, "Cannot enable iface-alias without NAT\n");
|
1998-10-22 02:32:50 +00:00
|
|
|
result = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static int
|
|
|
|
NegotiateSet(struct cmdargs const *arg)
|
|
|
|
{
|
1998-06-27 23:48:54 +00:00
|
|
|
long param = (long)arg->cmd->args;
|
1998-05-21 21:49:08 +00:00
|
|
|
struct link *l = command_ChooseLink(arg); /* LOCAL_CX_OPT uses this */
|
|
|
|
struct datalink *cx = arg->cx; /* LOCAL_CX uses this */
|
|
|
|
const char *cmd;
|
|
|
|
unsigned keep; /* Keep these bits */
|
|
|
|
unsigned add; /* Add these bits */
|
|
|
|
|
|
|
|
if ((cmd = ident_cmd(arg->argv[arg->argn-2], &keep, &add)) == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if ((arg->cmd->lauth & LOCAL_CX) && !cx) {
|
|
|
|
log_Printf(LogWARN, "%s %s: No context (use the `link' command)\n",
|
|
|
|
cmd, arg->cmd->name);
|
|
|
|
return 2;
|
|
|
|
} else if (cx && !(arg->cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) {
|
|
|
|
log_Printf(LogWARN, "%s %s: Redundant context (%s) ignored\n",
|
|
|
|
cmd, arg->cmd->name, cx->name);
|
|
|
|
cx = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case NEG_ACFCOMP:
|
|
|
|
cx->physical->link.lcp.cfg.acfcomp &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.acfcomp |= add;
|
|
|
|
break;
|
1999-02-18 00:52:15 +00:00
|
|
|
case NEG_CHAP05:
|
|
|
|
cx->physical->link.lcp.cfg.chap05 &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.chap05 |= add;
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
1999-02-18 00:52:15 +00:00
|
|
|
case NEG_CHAP80:
|
|
|
|
cx->physical->link.lcp.cfg.chap80nt &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.chap80nt |= add;
|
|
|
|
break;
|
|
|
|
case NEG_CHAP80LM:
|
|
|
|
cx->physical->link.lcp.cfg.chap80lm &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.chap80lm |= add;
|
|
|
|
break;
|
2000-10-30 00:15:04 +00:00
|
|
|
case NEG_CHAP81:
|
|
|
|
cx->physical->link.lcp.cfg.chap81 &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.chap81 |= add;
|
|
|
|
break;
|
|
|
|
case NEG_MPPE:
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_MPPE] &= keep;
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_MPPE] |= add;
|
|
|
|
break;
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
case NEG_DEFLATE:
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_DEFLATE] &= keep;
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_DEFLATE] |= add;
|
|
|
|
break;
|
|
|
|
case NEG_DNS:
|
|
|
|
arg->bundle->ncp.ipcp.cfg.ns.dns_neg &= keep;
|
|
|
|
arg->bundle->ncp.ipcp.cfg.ns.dns_neg |= add;
|
|
|
|
break;
|
2004-12-13 12:51:19 +00:00
|
|
|
case NEG_ECHO: /* probably misplaced in this function ! */
|
|
|
|
if (cx->physical->link.lcp.cfg.echo && !add) {
|
|
|
|
cx->physical->link.lcp.cfg.echo = 0;
|
|
|
|
cx->physical->hdlc.lqm.method &= ~LQM_ECHO;
|
|
|
|
if (cx->physical->hdlc.lqm.method & LQM_ECHO &&
|
|
|
|
!cx->physical->link.lcp.want_lqrperiod &&
|
|
|
|
cx->physical->hdlc.lqm.timer.load) {
|
|
|
|
cx->physical->hdlc.lqm.timer.load = 0;
|
|
|
|
lqr_StopTimer(cx->physical);
|
|
|
|
}
|
|
|
|
} else if (!cx->physical->link.lcp.cfg.echo && add) {
|
|
|
|
cx->physical->link.lcp.cfg.echo = 1;
|
|
|
|
cx->physical->hdlc.lqm.method |= LQM_ECHO;
|
|
|
|
cx->physical->hdlc.lqm.timer.load =
|
|
|
|
cx->physical->link.lcp.cfg.lqrperiod * SECTICKS;
|
|
|
|
if (cx->physical->link.lcp.fsm.state == ST_OPENED)
|
|
|
|
(*cx->physical->hdlc.lqm.timer.func)(&cx->physical->link.lcp);
|
|
|
|
}
|
|
|
|
break;
|
1999-06-09 16:54:04 +00:00
|
|
|
case NEG_ENDDISC:
|
|
|
|
arg->bundle->ncp.mp.cfg.negenddisc &= keep;
|
|
|
|
arg->bundle->ncp.mp.cfg.negenddisc |= add;
|
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
case NEG_LQR:
|
|
|
|
cx->physical->link.lcp.cfg.lqr &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.lqr |= add;
|
|
|
|
break;
|
|
|
|
case NEG_PAP:
|
|
|
|
cx->physical->link.lcp.cfg.pap &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.pap |= add;
|
|
|
|
break;
|
|
|
|
case NEG_PPPDDEFLATE:
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_DEFLATE24] &= keep;
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_DEFLATE24] |= add;
|
|
|
|
break;
|
|
|
|
case NEG_PRED1:
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_PRED1] &= keep;
|
|
|
|
l->ccp.cfg.neg[CCP_NEG_PRED1] |= add;
|
|
|
|
break;
|
|
|
|
case NEG_PROTOCOMP:
|
|
|
|
cx->physical->link.lcp.cfg.protocomp &= keep;
|
|
|
|
cx->physical->link.lcp.cfg.protocomp |= add;
|
|
|
|
break;
|
|
|
|
case NEG_SHORTSEQ:
|
1998-10-24 01:08:45 +00:00
|
|
|
switch (bundle_Phase(arg->bundle)) {
|
|
|
|
case PHASE_DEAD:
|
|
|
|
break;
|
|
|
|
case PHASE_ESTABLISH:
|
|
|
|
/* Make sure none of our links are DATALINK_LCP or greater */
|
|
|
|
if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) {
|
|
|
|
log_Printf(LogWARN, "shortseq: Only changable before"
|
|
|
|
" LCP negotiations\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log_Printf(LogWARN, "shortseq: Only changable at phase"
|
|
|
|
" DEAD/ESTABLISH\n");
|
|
|
|
return 1;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1998-10-24 01:08:45 +00:00
|
|
|
arg->bundle->ncp.mp.cfg.shortseq &= keep;
|
|
|
|
arg->bundle->ncp.mp.cfg.shortseq |= add;
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
|
|
|
case NEG_VJCOMP:
|
|
|
|
arg->bundle->ncp.ipcp.cfg.vj.neg &= keep;
|
|
|
|
arg->bundle->ncp.ipcp.cfg.vj.neg |= add;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct cmdtab const NegotiateCommands[] = {
|
2004-12-13 12:51:19 +00:00
|
|
|
{"echo", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX, "Send echo requests",
|
|
|
|
"disable|enable", (const void *)NEG_ECHO},
|
2000-07-07 14:22:08 +00:00
|
|
|
{"filter-decapsulation", NULL, OptSet, LOCAL_AUTH,
|
|
|
|
"filter on PPPoUDP payloads", "disable|enable",
|
|
|
|
(const void *)OPT_FILTERDECAP},
|
2003-03-26 02:03:08 +00:00
|
|
|
{"force-scripts", NULL, OptSet, LOCAL_AUTH,
|
|
|
|
"Force execution of the configured chat scripts", "disable|enable",
|
|
|
|
(const void *)OPT_FORCE_SCRIPTS},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"idcheck", NULL, OptSet, LOCAL_AUTH, "Check FSM reply ids",
|
|
|
|
"disable|enable", (const void *)OPT_IDCHECK},
|
1998-10-26 19:07:42 +00:00
|
|
|
{"iface-alias", NULL, IfaceAliasOptSet, LOCAL_AUTH,
|
2000-07-07 14:22:08 +00:00
|
|
|
"retain interface addresses", "disable|enable",
|
|
|
|
(const void *)OPT_IFACEALIAS},
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
|
|
|
{"ipcp", NULL, OptSet, LOCAL_AUTH, "IP Network Control Protocol",
|
|
|
|
"disable|enable", (const void *)OPT_IPCP},
|
|
|
|
{"ipv6cp", NULL, OptSet, LOCAL_AUTH, "IPv6 Network Control Protocol",
|
|
|
|
"disable|enable", (const void *)OPT_IPV6CP},
|
|
|
|
#endif
|
1999-06-02 00:46:55 +00:00
|
|
|
{"keep-session", NULL, OptSet, LOCAL_AUTH, "Retain device session leader",
|
|
|
|
"disable|enable", (const void *)OPT_KEEPSESSION},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"loopback", NULL, OptSet, LOCAL_AUTH, "Loop packets for local iface",
|
|
|
|
"disable|enable", (const void *)OPT_LOOPBACK},
|
2004-11-29 17:11:15 +00:00
|
|
|
{"nas-ip-address", NULL, OptSet, LOCAL_AUTH, "Send NAS-IP-Address to RADIUS",
|
|
|
|
"disable|enable", (const void *)OPT_NAS_IP_ADDRESS},
|
|
|
|
{"nas-identifier", NULL, OptSet, LOCAL_AUTH, "Send NAS-Identifier to RADIUS",
|
|
|
|
"disable|enable", (const void *)OPT_NAS_IDENTIFIER},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"passwdauth", NULL, OptSet, LOCAL_AUTH, "Use passwd file",
|
|
|
|
"disable|enable", (const void *)OPT_PASSWDAUTH},
|
1998-10-26 19:07:39 +00:00
|
|
|
{"proxy", NULL, OptSet, LOCAL_AUTH, "Create a proxy ARP entry",
|
1998-05-21 21:49:08 +00:00
|
|
|
"disable|enable", (const void *)OPT_PROXY},
|
1998-10-26 19:07:39 +00:00
|
|
|
{"proxyall", NULL, OptSet, LOCAL_AUTH, "Proxy ARP for all remote hosts",
|
|
|
|
"disable|enable", (const void *)OPT_PROXYALL},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"sroutes", NULL, OptSet, LOCAL_AUTH, "Use sticky routes",
|
|
|
|
"disable|enable", (const void *)OPT_SROUTES},
|
2000-11-28 13:18:35 +00:00
|
|
|
{"tcpmssfixup", "mssfixup", OptSet, LOCAL_AUTH, "Modify MSS options",
|
|
|
|
"disable|enable", (const void *)OPT_TCPMSSFIXUP},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"throughput", NULL, OptSet, LOCAL_AUTH, "Rolling throughput",
|
|
|
|
"disable|enable", (const void *)OPT_THROUGHPUT},
|
|
|
|
{"utmp", NULL, OptSet, LOCAL_AUTH, "Log connections in utmp",
|
|
|
|
"disable|enable", (const void *)OPT_UTMP},
|
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
2004-12-13 12:51:19 +00:00
|
|
|
#define NEG_OPT_MAX 17 /* accept/deny allowed below and not above */
|
2001-08-14 16:05:52 +00:00
|
|
|
#else
|
2004-12-13 12:51:19 +00:00
|
|
|
#define NEG_OPT_MAX 15
|
2001-08-14 16:05:52 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
{"acfcomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Address & Control field compression", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_ACFCOMP},
|
1999-02-18 00:52:15 +00:00
|
|
|
{"chap", "chap05", NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
1998-05-21 21:49:08 +00:00
|
|
|
"Challenge Handshake Authentication Protocol", "accept|deny|disable|enable",
|
1999-02-18 00:52:15 +00:00
|
|
|
(const void *)NEG_CHAP05},
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
1999-02-18 00:52:15 +00:00
|
|
|
{"mschap", "chap80nt", NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Microsoft (NT) CHAP", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_CHAP80},
|
|
|
|
{"LANMan", "chap80lm", NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Microsoft (NT) CHAP", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_CHAP80LM},
|
2000-10-30 00:15:04 +00:00
|
|
|
{"mschapv2", "chap81", NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Microsoft CHAP v2", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_CHAP81},
|
|
|
|
{"mppe", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"MPPE encryption", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_MPPE},
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
{"deflate", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"Deflate compression", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_DEFLATE},
|
|
|
|
{"deflate24", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"Deflate (type 24) compression", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_PPPDDEFLATE},
|
|
|
|
{"dns", NULL, NegotiateSet, LOCAL_AUTH,
|
|
|
|
"DNS specification", "accept|deny|disable|enable", (const void *)NEG_DNS},
|
1999-06-09 16:54:04 +00:00
|
|
|
{"enddisc", NULL, NegotiateSet, LOCAL_AUTH, "ENDDISC negotiation",
|
|
|
|
"accept|deny|disable|enable", (const void *)NEG_ENDDISC},
|
1998-05-21 21:49:08 +00:00
|
|
|
{"lqr", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Link Quality Reports", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_LQR},
|
|
|
|
{"pap", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Password Authentication protocol", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_PAP},
|
|
|
|
{"pred1", "predictor1", NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
|
|
|
|
"Predictor 1 compression", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_PRED1},
|
|
|
|
{"protocomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
|
|
|
|
"Protocol field compression", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_PROTOCOMP},
|
|
|
|
{"shortseq", NULL, NegotiateSet, LOCAL_AUTH,
|
|
|
|
"MP Short Sequence Numbers", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_SHORTSEQ},
|
|
|
|
{"vjcomp", NULL, NegotiateSet, LOCAL_AUTH,
|
|
|
|
"Van Jacobson header compression", "accept|deny|disable|enable",
|
|
|
|
(const void *)NEG_VJCOMP},
|
|
|
|
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
|
|
|
|
"Display this message", "accept|deny|disable|enable help|? [value]",
|
|
|
|
NegotiateCommands},
|
2004-09-05 01:46:52 +00:00
|
|
|
{NULL, NULL, NULL, 0, NULL, NULL, NULL},
|
1998-05-21 21:49:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
NegotiateCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
if (arg->argc > arg->argn) {
|
|
|
|
char const *argv[3];
|
|
|
|
unsigned keep, add;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if ((argv[0] = ident_cmd(arg->argv[arg->argn-1], &keep, &add)) == NULL)
|
|
|
|
return -1;
|
|
|
|
argv[2] = NULL;
|
|
|
|
|
|
|
|
for (n = arg->argn; n < arg->argc; n++) {
|
|
|
|
argv[1] = arg->argv[n];
|
|
|
|
FindExec(arg->bundle, NegotiateCommands + (keep == NEG_HISMASK ?
|
2004-11-29 17:11:15 +00:00
|
|
|
0 : NEG_OPT_MAX), 2, 1, argv, arg->prompt, arg->cx);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
} else if (arg->prompt)
|
|
|
|
prompt_Printf(arg->prompt, "Use `%s ?' to get a list.\n",
|
|
|
|
arg->argv[arg->argn-1]);
|
|
|
|
else
|
|
|
|
log_Printf(LogWARN, "%s command must have arguments\n",
|
|
|
|
arg->argv[arg->argn] );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
command_ShowNegval(unsigned val)
|
|
|
|
{
|
|
|
|
switch (val&3) {
|
|
|
|
case 1: return "disabled & accepted";
|
|
|
|
case 2: return "enabled & denied";
|
|
|
|
case 3: return "enabled & accepted";
|
|
|
|
}
|
|
|
|
return "disabled & denied";
|
|
|
|
}
|
1998-06-12 20:12:26 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
ClearCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
struct pppThroughput *t;
|
|
|
|
struct datalink *cx;
|
|
|
|
int i, clear_type;
|
|
|
|
|
|
|
|
if (arg->argc < arg->argn + 1)
|
|
|
|
return -1;
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
if (strcasecmp(arg->argv[arg->argn], "physical") == 0) {
|
1998-06-12 20:12:26 +00:00
|
|
|
cx = arg->cx;
|
|
|
|
if (!cx)
|
|
|
|
cx = bundle2datalink(arg->bundle, NULL);
|
|
|
|
if (!cx) {
|
1999-05-08 11:07:56 +00:00
|
|
|
log_Printf(LogWARN, "A link must be specified for ``clear physical''\n");
|
1998-06-12 20:12:26 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2000-08-15 00:59:21 +00:00
|
|
|
t = &cx->physical->link.stats.total;
|
1998-06-12 20:12:26 +00:00
|
|
|
} else if (strcasecmp(arg->argv[arg->argn], "ipcp") == 0)
|
|
|
|
t = &arg->bundle->ncp.ipcp.throughput;
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
2001-08-18 19:07:13 +00:00
|
|
|
else if (strcasecmp(arg->argv[arg->argn], "ipv6cp") == 0)
|
2001-08-14 16:05:52 +00:00
|
|
|
t = &arg->bundle->ncp.ipv6cp.throughput;
|
|
|
|
#endif
|
1998-06-12 20:12:26 +00:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (arg->argc > arg->argn + 1) {
|
|
|
|
clear_type = 0;
|
|
|
|
for (i = arg->argn + 1; i < arg->argc; i++)
|
|
|
|
if (strcasecmp(arg->argv[i], "overall") == 0)
|
|
|
|
clear_type |= THROUGHPUT_OVERALL;
|
|
|
|
else if (strcasecmp(arg->argv[i], "current") == 0)
|
|
|
|
clear_type |= THROUGHPUT_CURRENT;
|
|
|
|
else if (strcasecmp(arg->argv[i], "peak") == 0)
|
|
|
|
clear_type |= THROUGHPUT_PEAK;
|
|
|
|
else
|
|
|
|
return -1;
|
2002-06-15 08:03:30 +00:00
|
|
|
} else
|
1998-06-12 20:12:26 +00:00
|
|
|
clear_type = THROUGHPUT_ALL;
|
|
|
|
|
|
|
|
throughput_clear(t, clear_type, arg->prompt);
|
|
|
|
return 0;
|
|
|
|
}
|
1998-10-22 02:32:50 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
RunListCommand(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
const char *cmd = arg->argc ? arg->argv[arg->argc - 1] : "???";
|
|
|
|
|
2000-08-18 00:01:30 +00:00
|
|
|
#ifndef NONAT
|
|
|
|
if (arg->cmd->args == NatCommands &&
|
|
|
|
tolower(*arg->argv[arg->argn - 1]) == 'a') {
|
|
|
|
if (arg->prompt)
|
2000-09-06 21:02:06 +00:00
|
|
|
prompt_Printf(arg->prompt, "The alias command is deprecated\n");
|
2000-08-18 00:01:30 +00:00
|
|
|
else
|
2000-09-06 21:02:06 +00:00
|
|
|
log_Printf(LogWARN, "The alias command is deprecated\n");
|
2000-08-18 00:01:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-10-22 02:32:50 +00:00
|
|
|
if (arg->argc > arg->argn)
|
|
|
|
FindExec(arg->bundle, arg->cmd->args, arg->argc, arg->argn, arg->argv,
|
|
|
|
arg->prompt, arg->cx);
|
|
|
|
else if (arg->prompt)
|
|
|
|
prompt_Printf(arg->prompt, "Use `%s help' to get a list or `%s help"
|
|
|
|
" <option>' for syntax help.\n", cmd, cmd);
|
|
|
|
else
|
|
|
|
log_Printf(LogWARN, "%s command must have arguments\n", cmd);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
IfaceAddCommand(struct cmdargs const *arg)
|
|
|
|
{
|
2001-08-14 16:05:52 +00:00
|
|
|
struct ncpaddr peer, addr;
|
|
|
|
struct ncprange ifa;
|
|
|
|
struct in_addr mask;
|
|
|
|
int n, how;
|
1998-10-22 02:32:50 +00:00
|
|
|
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
if (arg->argc == arg->argn + 1) {
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncprange_aton(&ifa, NULL, arg->argv[arg->argn]))
|
1998-10-22 02:32:50 +00:00
|
|
|
return -1;
|
2001-08-14 16:05:52 +00:00
|
|
|
ncpaddr_init(&peer);
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
} else {
|
|
|
|
if (arg->argc == arg->argn + 2) {
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncprange_aton(&ifa, NULL, arg->argv[arg->argn]))
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
return -1;
|
|
|
|
n = 1;
|
|
|
|
} else if (arg->argc == arg->argn + 3) {
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncpaddr_aton(&addr, NULL, arg->argv[arg->argn]))
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
return -1;
|
2001-08-14 16:05:52 +00:00
|
|
|
if (ncpaddr_family(&addr) != AF_INET)
|
|
|
|
return -1;
|
|
|
|
ncprange_sethost(&ifa, &addr);
|
|
|
|
if (!ncpaddr_aton(&addr, NULL, arg->argv[arg->argn + 1]))
|
|
|
|
return -1;
|
|
|
|
if (!ncpaddr_getip4(&addr, &mask))
|
|
|
|
return -1;
|
|
|
|
if (!ncprange_setip4mask(&ifa, mask))
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
return -1;
|
|
|
|
n = 2;
|
|
|
|
} else
|
1998-10-22 02:32:50 +00:00
|
|
|
return -1;
|
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncpaddr_aton(&peer, NULL, arg->argv[arg->argn + n]))
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
return -1;
|
2001-08-14 16:05:52 +00:00
|
|
|
|
|
|
|
if (ncprange_family(&ifa) != ncpaddr_family(&peer)) {
|
|
|
|
log_Printf(LogWARN, "IfaceAddCommand: src and dst address families"
|
|
|
|
" differ\n");
|
|
|
|
return -1;
|
|
|
|
}
|
Fix the interface alias code. Previously, I was expecting something
like
tun0: flags=blah
10.0.0.1 -> 10.0.0.100
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 10.0.0.100
to DTRT, despite the SIOCAIFADDR for each new alias returning
-1 & EEXIST while adding the alias anyway. In real life, once
we have the second alias with the same destination, nothing will
route any more ! Also, because I was ignoring EEXIST, the
dynamic IP assignment code was assigning duplicate addresses
('cos it was being lied to by iface_inAdd()).
Now we have
tun0: flags=blah
10.0.0.1 -> 255.255.255.255
10.0.0.2 -> 10.0.0.100
10.0.0.3 -> 255.255.255.255
This works - stuff bound to 10.1 & 10.3 will be considered alive
by the kernel, and when they route back to the tun device, the
packets get aliased to 10.2 and go out to 10.100 (as with the
original plan).
We still see the EEXIST in SIOCAIFADDR, but ignore it when our
destination is 255.255.255.255, assuming that the alias *was*
actually added.
Additionally, ``iface add'' may now optionally be given only
the interface address. The mask & destination default to
255.255.255.255.
1998-10-26 19:07:36 +00:00
|
|
|
}
|
1998-10-22 02:32:50 +00:00
|
|
|
|
|
|
|
how = IFACE_ADD_LAST;
|
|
|
|
if (arg->cmd->args)
|
|
|
|
how |= IFACE_FORCE_ADD;
|
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
return !iface_Add(arg->bundle->iface, &arg->bundle->ncp, &ifa, &peer, how);
|
1998-10-22 02:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
IfaceDeleteCommand(struct cmdargs const *arg)
|
|
|
|
{
|
2001-08-14 16:05:52 +00:00
|
|
|
struct ncpaddr ifa;
|
|
|
|
struct in_addr ifa4;
|
1998-10-22 02:32:50 +00:00
|
|
|
int ok;
|
|
|
|
|
|
|
|
if (arg->argc != arg->argn + 1)
|
|
|
|
return -1;
|
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
if (!ncpaddr_aton(&ifa, NULL, arg->argv[arg->argn]))
|
1998-10-22 02:32:50 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED &&
|
2001-08-14 16:05:52 +00:00
|
|
|
ncpaddr_getip4(&ifa, &ifa4) &&
|
|
|
|
arg->bundle->ncp.ipcp.my_ip.s_addr == ifa4.s_addr) {
|
1998-10-22 02:32:50 +00:00
|
|
|
log_Printf(LogWARN, "%s: Cannot remove active interface address\n",
|
2001-08-14 16:05:52 +00:00
|
|
|
ncpaddr_ntoa(&ifa));
|
1998-10-22 02:32:50 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
ok = iface_Delete(arg->bundle->iface, &arg->bundle->ncp, &ifa);
|
1998-10-22 02:32:50 +00:00
|
|
|
if (!ok) {
|
|
|
|
if (arg->cmd->args)
|
|
|
|
ok = 1;
|
|
|
|
else if (arg->prompt)
|
2001-08-14 16:05:52 +00:00
|
|
|
prompt_Printf(arg->prompt, "%s: No such interface address\n",
|
|
|
|
ncpaddr_ntoa(&ifa));
|
1998-10-22 02:32:50 +00:00
|
|
|
else
|
2001-08-14 16:05:52 +00:00
|
|
|
log_Printf(LogWARN, "%s: No such interface address\n",
|
|
|
|
ncpaddr_ntoa(&ifa));
|
1998-10-22 02:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return !ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
IfaceClearCommand(struct cmdargs const *arg)
|
|
|
|
{
|
2001-08-14 16:05:52 +00:00
|
|
|
int family, how;
|
1998-10-22 02:32:50 +00:00
|
|
|
|
2001-08-14 16:05:52 +00:00
|
|
|
family = 0;
|
|
|
|
if (arg->argc == arg->argn + 1) {
|
|
|
|
if (strcasecmp(arg->argv[arg->argn], "inet") == 0)
|
|
|
|
family = AF_INET;
|
|
|
|
#ifndef NOINET6
|
2001-08-18 19:07:13 +00:00
|
|
|
else if (strcasecmp(arg->argv[arg->argn], "inet6") == 0)
|
2001-08-14 16:05:52 +00:00
|
|
|
family = AF_INET6;
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
} else if (arg->argc != arg->argn)
|
1998-10-22 02:32:50 +00:00
|
|
|
return -1;
|
|
|
|
|
1998-11-05 21:59:48 +00:00
|
|
|
how = arg->bundle->ncp.ipcp.fsm.state == ST_OPENED ||
|
|
|
|
arg->bundle->phys_type.all & PHYS_AUTO ?
|
1998-10-22 02:32:50 +00:00
|
|
|
IFACE_CLEAR_ALIASES : IFACE_CLEAR_ALL;
|
2001-08-14 16:05:52 +00:00
|
|
|
iface_Clear(arg->bundle->iface, &arg->bundle->ncp, family, how);
|
1998-10-22 02:32:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1998-10-27 22:53:22 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
SetProcTitle(struct cmdargs const *arg)
|
|
|
|
{
|
|
|
|
static char title[LINE_LEN];
|
2001-11-04 16:19:05 +00:00
|
|
|
char *argv[MAXARGS];
|
|
|
|
int argc = arg->argc - arg->argn;
|
1998-10-27 22:53:22 +00:00
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if (arg->argc <= arg->argn) {
|
2000-08-16 09:07:23 +00:00
|
|
|
SetTitle(NULL);
|
1998-10-27 22:53:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if ((unsigned)argc >= sizeof argv / sizeof argv[0]) {
|
1998-10-27 22:53:22 +00:00
|
|
|
argc = sizeof argv / sizeof argv[0] - 1;
|
|
|
|
log_Printf(LogWARN, "Truncating proc title to %d args\n", argc);
|
|
|
|
}
|
1999-06-09 08:47:36 +00:00
|
|
|
command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1, getpid());
|
2001-11-03 21:45:32 +00:00
|
|
|
Concatinate(title, sizeof title, argc, (const char *const *)argv);
|
2000-08-16 09:07:23 +00:00
|
|
|
SetTitle(title);
|
2001-11-03 21:45:32 +00:00
|
|
|
command_Free(argc, argv);
|
1998-10-27 22:53:22 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|