summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ppp/Makefile14
-rw-r--r--usr.sbin/ppp/alias_cmd.c75
-rw-r--r--usr.sbin/ppp/alias_cmd.h6
-rw-r--r--usr.sbin/ppp/arp.c5
-rw-r--r--usr.sbin/ppp/async.c4
-rw-r--r--usr.sbin/ppp/auth.c17
-rw-r--r--usr.sbin/ppp/auth.h10
-rw-r--r--usr.sbin/ppp/ccp.c8
-rw-r--r--usr.sbin/ppp/ccp.h4
-rw-r--r--usr.sbin/ppp/chap.c8
-rw-r--r--usr.sbin/ppp/chap_ms.c3
-rw-r--r--usr.sbin/ppp/chat.c45
-rw-r--r--usr.sbin/ppp/chat.h8
-rw-r--r--usr.sbin/ppp/command.c547
-rw-r--r--usr.sbin/ppp/command.h27
-rw-r--r--usr.sbin/ppp/defs.c9
-rw-r--r--usr.sbin/ppp/defs.h3
-rw-r--r--usr.sbin/ppp/filter.c89
-rw-r--r--usr.sbin/ppp/filter.h20
-rw-r--r--usr.sbin/ppp/fsm.c12
-rw-r--r--usr.sbin/ppp/fsm.h6
-rw-r--r--usr.sbin/ppp/hdlc.c55
-rw-r--r--usr.sbin/ppp/hdlc.h7
-rw-r--r--usr.sbin/ppp/id.c19
-rw-r--r--usr.sbin/ppp/ip.c29
-rw-r--r--usr.sbin/ppp/ipcp.c12
-rw-r--r--usr.sbin/ppp/ipcp.h5
-rw-r--r--usr.sbin/ppp/lcp.c22
-rw-r--r--usr.sbin/ppp/lcp.h6
-rw-r--r--usr.sbin/ppp/loadalias.c10
-rw-r--r--usr.sbin/ppp/log.c12
-rw-r--r--usr.sbin/ppp/log.h8
-rw-r--r--usr.sbin/ppp/lqr.c16
-rw-r--r--usr.sbin/ppp/lqr.h4
-rw-r--r--usr.sbin/ppp/main.c60
-rw-r--r--usr.sbin/ppp/main.h3
-rw-r--r--usr.sbin/ppp/mbuf.c6
-rw-r--r--usr.sbin/ppp/mbuf.h4
-rw-r--r--usr.sbin/ppp/modem.c69
-rw-r--r--usr.sbin/ppp/modem.h10
-rw-r--r--usr.sbin/ppp/nat_cmd.c75
-rw-r--r--usr.sbin/ppp/nat_cmd.h6
-rw-r--r--usr.sbin/ppp/os.c6
-rw-r--r--usr.sbin/ppp/os.h4
-rw-r--r--usr.sbin/ppp/pap.c10
-rw-r--r--usr.sbin/ppp/phase.c6
-rw-r--r--usr.sbin/ppp/pred.c3
-rw-r--r--usr.sbin/ppp/route.c18
-rw-r--r--usr.sbin/ppp/route.h4
-rw-r--r--usr.sbin/ppp/server.c5
-rw-r--r--usr.sbin/ppp/sig.c5
-rw-r--r--usr.sbin/ppp/slcompress.c6
-rw-r--r--usr.sbin/ppp/slcompress.h6
-rw-r--r--usr.sbin/ppp/systems.c36
-rw-r--r--usr.sbin/ppp/systems.h12
-rw-r--r--usr.sbin/ppp/throughput.c11
-rw-r--r--usr.sbin/ppp/timer.c3
-rw-r--r--usr.sbin/ppp/timer.h4
-rw-r--r--usr.sbin/ppp/tun.c9
-rw-r--r--usr.sbin/ppp/vars.c48
-rw-r--r--usr.sbin/ppp/vars.h18
-rw-r--r--usr.sbin/ppp/vjcomp.c3
62 files changed, 823 insertions, 752 deletions
diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile
index 7736260f07ca..d3c5e2d8f06f 100644
--- a/usr.sbin/ppp/Makefile
+++ b/usr.sbin/ppp/Makefile
@@ -1,12 +1,12 @@
-# $Id: Makefile,v 1.30 1997/11/16 22:15:02 brian Exp $
+# $Id: Makefile,v 1.31 1997/11/18 14:52:03 brian Exp $
PROG= ppp
-SRCS= alias_cmd.c arp.c async.c auth.c ccp.c chap.c chat.c \
+SRCS= arp.c async.c auth.c ccp.c chap.c chat.c \
command.c defs.c filter.c fsm.c hdlc.c id.c ip.c ipcp.c lcp.c \
- loadalias.c log.c lqr.c main.c mbuf.c modem.c os.c pap.c phase.c \
+ log.c lqr.c main.c mbuf.c modem.c os.c pap.c phase.c \
pred.c route.c server.c sig.c slcompress.c systems.c throughput.c \
timer.c tun.c vars.c vjcomp.c
-CFLAGS+=-Wall -Wmissing-prototypes
+CFLAGS+=-Wall
LDADD+= -lmd -lcrypt -lutil
DPADD+= ${LIBMD} ${LIBCRYPT} ${LIBUTIL}
MAN8= ppp.8
@@ -14,6 +14,12 @@ BINMODE=4550
BINOWN= root
BINGRP= network
+.if defined(NOALIAS)
+CFLAGS+=-DNOALIAS
+.else
+SRCS+= alias_cmd.c loadalias.c
+.endif
+
.if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT) && !defined(NOSECURE)
CFLAGS+=-DHAVE_DES
SRCS+= chap_ms.c
diff --git a/usr.sbin/ppp/alias_cmd.c b/usr.sbin/ppp/alias_cmd.c
index 4b91898a2cd3..acd801e9680d 100644
--- a/usr.sbin/ppp/alias_cmd.c
+++ b/usr.sbin/ppp/alias_cmd.c
@@ -1,5 +1,5 @@
/*
- * $Id: $
+ * $Id: alias_cmd.c,v 1.6 1997/10/26 01:02:00 brian Exp $
*/
#include <sys/param.h>
@@ -13,29 +13,29 @@
#include <stdlib.h>
#include <string.h>
-#include "mbuf.h"
-#include "log.h"
#include "defs.h"
#include "command.h"
+#include "mbuf.h"
+#include "log.h"
#include "loadalias.h"
#include "vars.h"
#include "alias_cmd.h"
-static int StrToAddr(char *, struct in_addr *);
-static int StrToPort(char *, u_short *, char *);
-static int StrToAddrAndPort(char *, struct in_addr *, u_short *, char *);
+static int StrToAddr(const char *, struct in_addr *);
+static int StrToPort(const char *, u_short *, const char *);
+static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, const char *);
int
-AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
+AliasRedirectPort(struct cmdargs const *arg)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
fprintf(VarTerm, "Alias not enabled\n");
- } else if (argc == 3) {
+ } else if (arg->argc == 3) {
char proto_constant;
- char *proto;
+ const char *proto;
u_short local_port;
u_short alias_port;
int error;
@@ -43,7 +43,7 @@ AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
struct in_addr null_addr;
struct alias_link *link;
- proto = argv[0];
+ proto = arg->argv[0];
if (strcmp(proto, "tcp") == 0) {
proto_constant = IPPROTO_TCP;
} else if (strcmp(proto, "udp") == 0) {
@@ -51,25 +51,25 @@ AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
} else {
if (VarTerm) {
fprintf(VarTerm, "port redirect: protocol must be tcp or udp\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name,
- list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name,
+ arg->cmd->syntax);
}
return 1;
}
- error = StrToAddrAndPort(argv[1], &local_addr, &local_port, proto);
+ error = StrToAddrAndPort(arg->argv[1], &local_addr, &local_port, proto);
if (error) {
if (VarTerm) {
fprintf(VarTerm, "port redirect: error reading local addr:port\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
return 1;
}
- error = StrToPort(argv[2], &alias_port, proto);
+ error = StrToPort(arg->argv[2], &alias_port, proto);
if (error) {
if (VarTerm) {
fprintf(VarTerm, "port redirect: error reading alias port\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
return 1;
}
@@ -84,52 +84,52 @@ AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
fprintf(VarTerm, "port redirect: error returned by packed"
" aliasing engine (code=%d)\n", error);
} else if (VarTerm)
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
return 1;
}
int
-AliasRedirectAddr(struct cmdtab *list, int argc, char **argv, void *param)
+AliasRedirectAddr(struct cmdargs const *arg)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
fprintf(VarTerm, "alias not enabled\n");
- } else if (argc == 2) {
+ } else if (arg->argc == 2) {
int error;
struct in_addr local_addr;
struct in_addr alias_addr;
struct alias_link *link;
- error = StrToAddr(argv[0], &local_addr);
+ error = StrToAddr(arg->argv[0], &local_addr);
if (error) {
if (VarTerm)
fprintf(VarTerm, "address redirect: invalid local address\n");
return 1;
}
- error = StrToAddr(argv[1], &alias_addr);
+ error = StrToAddr(arg->argv[1], &alias_addr);
if (error) {
if (VarTerm) {
fprintf(VarTerm, "address redirect: invalid alias address\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
return 1;
}
link = VarPacketAliasRedirectAddr(local_addr, alias_addr);
if (link == NULL && VarTerm) {
fprintf(VarTerm, "address redirect: packet aliasing engine error\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
} else if (VarTerm)
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
return 1;
}
static int
-StrToAddr(char *str, struct in_addr *addr)
+StrToAddr(const char *str, struct in_addr *addr)
{
struct hostent *hp;
@@ -147,7 +147,7 @@ StrToAddr(char *str, struct in_addr *addr)
static int
-StrToPort(char *str, u_short *port, char *proto)
+StrToPort(const char *str, u_short *port, const char *proto)
{
int iport;
struct servent *sp;
@@ -169,22 +169,23 @@ StrToPort(char *str, u_short *port, char *proto)
}
-int
-StrToAddrAndPort(char *str, struct in_addr *addr, u_short *port, char *proto)
+static int
+StrToAddrAndPort(const char *str, struct in_addr *addr, u_short *port, const char *proto)
{
- char *ptr;
+ char *colon;
+ int res;
- ptr = strchr(str, ':');
- if (!ptr) {
- LogPrintf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n",
- str);
+ colon = strchr(str, ':');
+ if (!colon) {
+ LogPrintf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str);
return -1;
}
- *ptr = '\0';
- ++ptr;
- if (StrToAddr(str, addr) != 0)
+ *colon = '\0'; /* Cheat the const-ness ! */
+ res = StrToAddr(str, addr);
+ *colon = ':'; /* Cheat the const-ness ! */
+ if (res != 0)
return -1;
- return StrToPort(ptr, port, proto);
+ return StrToPort(colon+1, port, proto);
}
diff --git a/usr.sbin/ppp/alias_cmd.h b/usr.sbin/ppp/alias_cmd.h
index 49b15322de61..87a2026be2fd 100644
--- a/usr.sbin/ppp/alias_cmd.h
+++ b/usr.sbin/ppp/alias_cmd.h
@@ -1,6 +1,6 @@
/*
- * $Id: $
+ * $Id: alias_cmd.h,v 1.3 1997/10/26 01:02:01 brian Exp $
*/
-extern int AliasRedirectPort(struct cmdtab *, int, char **, void *);
-extern int AliasRedirectAddr(struct cmdtab *, int, char **, void *);
+extern int AliasRedirectPort(struct cmdargs const *);
+extern int AliasRedirectAddr(struct cmdargs const *);
diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c
index 9450511e4ac8..dc9c7f398119 100644
--- a/usr.sbin/ppp/arp.c
+++ b/usr.sbin/ppp/arp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: arp.c,v 1.16 1997/10/26 01:02:03 brian Exp $
+ * $Id: arp.c,v 1.17 1997/11/09 06:22:38 brian Exp $
*
*/
@@ -29,7 +29,9 @@
#include <sys/time.h>
#include <sys/socket.h>
#include <net/if.h>
+#ifdef __FreeBSD__
#include <net/if_var.h>
+#endif
#include <net/route.h>
#include <net/if_dl.h>
#include <netinet/in.h>
@@ -45,6 +47,7 @@
#include <sys/uio.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "id.h"
diff --git a/usr.sbin/ppp/async.c b/usr.sbin/ppp/async.c
index aa9386579f43..9d0262224e5c 100644
--- a/usr.sbin/ppp/async.c
+++ b/usr.sbin/ppp/async.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: async.c,v 1.12 1997/10/26 01:02:05 brian Exp $
+ * $Id: async.c,v 1.13 1997/10/29 01:19:38 brian Exp $
*
*/
#include <sys/param.h>
@@ -27,6 +27,7 @@
#include <string.h>
#include <termios.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -37,7 +38,6 @@
#include "lcpproto.h"
#include "modem.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "os.h"
#include "async.h"
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index 1a6758c0c5c1..1d9d1d70c9ca 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: auth.c,v 1.22 1997/11/11 22:58:09 brian Exp $
+ * $Id: auth.c,v 1.23 1997/11/17 00:42:37 brian Exp $
*
* TODO:
* o Implement check against with registered IP addresses.
@@ -29,6 +29,7 @@
#include <string.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -37,7 +38,6 @@
#include "lcpproto.h"
#include "ipcp.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "filter.h"
#include "auth.h"
@@ -67,7 +67,7 @@ LocalAuthInit()
}
LOCAL_AUTH_VALID
-LocalAuthValidate(char *fname, char *system, char *key)
+LocalAuthValidate(const char *fname, const char *system, const char *key)
{
FILE *fp;
int n;
@@ -102,7 +102,7 @@ LocalAuthValidate(char *fname, char *system, char *key)
}
int
-AuthValidate(char *fname, char *system, char *key)
+AuthValidate(const char *fname, const char *system, const char *key)
{
FILE *fp;
int n;
@@ -128,7 +128,7 @@ AuthValidate(char *fname, char *system, char *key)
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
n -= 2;
if (n > 0) {
- if (ParseAddr(n--, &vector[2],
+ if (ParseAddr(n--, (char const *const *)(vector+2),
&DefHisAddress.ipaddr,
&DefHisAddress.mask,
&DefHisAddress.width) == 0) {
@@ -145,7 +145,7 @@ AuthValidate(char *fname, char *system, char *key)
}
char *
-AuthGetSecret(char *fname, char *system, int len, int setaddr)
+AuthGetSecret(const char *fname, const char *system, int len, int setaddr)
{
FILE *fp;
int n;
@@ -172,7 +172,7 @@ AuthGetSecret(char *fname, char *system, int len, int setaddr)
n -= 2;
if (n > 0 && setaddr) {
LogPrintf(LogDEBUG, "AuthGetSecret: n = %d, %s\n", n, vector[2]);
- if (ParseAddr(n--, &vector[2],
+ if (ParseAddr(n--, (char const *const *)(vector+2),
&DefHisAddress.ipaddr,
&DefHisAddress.mask,
&DefHisAddress.width) != 0)
@@ -186,9 +186,10 @@ AuthGetSecret(char *fname, char *system, int len, int setaddr)
}
static void
-AuthTimeout(struct authinfo *authp)
+AuthTimeout(void *vauthp)
{
struct pppTimer *tp;
+ struct authinfo *authp = (struct authinfo *)vauthp;
tp = &authp->authtimer;
StopTimer(tp);
diff --git a/usr.sbin/ppp/auth.h b/usr.sbin/ppp/auth.h
index 8a81cbc48a4e..a0fa77968608 100644
--- a/usr.sbin/ppp/auth.h
+++ b/usr.sbin/ppp/auth.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: auth.h,v 1.8 1997/09/04 00:38:18 brian Exp $
+ * $Id: auth.h,v 1.9 1997/10/26 01:02:09 brian Exp $
*
* TODO:
*/
@@ -27,15 +27,15 @@ typedef enum {
} LOCAL_AUTH_VALID;
struct authinfo {
- void (*ChallengeFunc) ();
+ void (*ChallengeFunc) (int);
struct pppTimer authtimer;
int retry;
int id;
};
-extern LOCAL_AUTH_VALID LocalAuthValidate(char *, char *, char *);
+extern LOCAL_AUTH_VALID LocalAuthValidate(const char *, const char *, const char *);
extern void StopAuthTimer(struct authinfo *);
extern void StartAuthChallenge(struct authinfo *);
extern void LocalAuthInit(void);
-extern int AuthValidate(char *, char *, char *);
-extern char *AuthGetSecret(char *, char *, int, int);
+extern int AuthValidate(const char *, const char *, const char *);
+extern char *AuthGetSecret(const char *, const char *, int, int);
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index 4f76eae9806c..6fbee99c70ce 100644
--- a/usr.sbin/ppp/ccp.c
+++ b/usr.sbin/ppp/ccp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ccp.c,v 1.18 1997/11/08 00:28:06 brian Exp $
+ * $Id: ccp.c,v 1.19 1997/11/14 15:39:14 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <string.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -38,7 +39,6 @@
#include "ccp.h"
#include "phase.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "pred.h"
@@ -91,14 +91,14 @@ static char const *cftypes[] = {
"STAC", /* 17: Stac Electronics LZS */
"MSPPC", /* 18: Microsoft PPC */
"GAND", /* 19: Gandalf FZA */
- "V42BIS", /* 20: V.42bis compression */
+ "V42BIS", /* 20: ARG->DATA.42bis compression */
"BSD", /* BSD LZW Compress */
};
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
int
-ReportCcpStatus()
+ReportCcpStatus(struct cmdargs const *arg)
{
struct ccpstate *icp = &CcpInfo;
struct fsm *fp = &CcpFsm;
diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h
index dd8db0160e7d..8585f17e8c2c 100644
--- a/usr.sbin/ppp/ccp.h
+++ b/usr.sbin/ppp/ccp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ccp.h,v 1.7 1997/08/25 00:29:06 brian Exp $
+ * $Id: ccp.h,v 1.8 1997/10/26 01:02:12 brian Exp $
*
* TODO:
*/
@@ -53,4 +53,4 @@ extern void CcpInput(struct mbuf *);
extern void CcpUp(void);
extern void CcpOpen(void);
extern void CcpInit(void);
-extern int ReportCcpStatus(void);
+extern int ReportCcpStatus(struct cmdargs const *);
diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c
index 972e07169b34..1fb6d25004ea 100644
--- a/usr.sbin/ppp/chap.c
+++ b/usr.sbin/ppp/chap.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: chap.c,v 1.24 1997/10/26 01:02:16 brian Exp $
+ * $Id: chap.c,v 1.25 1997/11/09 03:55:27 brian Exp $
*
* TODO:
*/
@@ -41,6 +41,7 @@
#endif
#include <utmp.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -53,16 +54,15 @@
#include "hdlc.h"
#include "phase.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "auth.h"
-static char *chapcodes[] = {
+static const char *chapcodes[] = {
"???", "CHALLENGE", "RESPONSE", "SUCCESS", "FAILURE"
};
static void
-ChapOutput(u_int code, u_int id, u_char * ptr, int count)
+ChapOutput(u_int code, u_int id, const u_char * ptr, int count)
{
int plen;
struct fsmheader lh;
diff --git a/usr.sbin/ppp/chap_ms.c b/usr.sbin/ppp/chap_ms.c
index 90cf2daca988..bed1c3a6a320 100644
--- a/usr.sbin/ppp/chap_ms.c
+++ b/usr.sbin/ppp/chap_ms.c
@@ -19,7 +19,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: $
+ * $Id: chap_ms.c,v 1.2 1997/10/26 01:02:20 brian Exp $
*
*/
@@ -31,6 +31,7 @@
#include <sys/time.h>
#include <syslog.h>
+#include "command.h"
#include "mbuf.h"
#include "timer.h"
#include "chap.h"
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index 6870af13836f..396927ec07fd 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -18,7 +18,7 @@
* Columbus, OH 43221
* (614)451-1883
*
- * $Id: chat.c,v 1.37 1997/11/09 06:22:39 brian Exp $
+ * $Id: chat.c,v 1.38 1997/11/09 14:18:36 brian Exp $
*
* TODO:
* o Support more UUCP compatible control sequences.
@@ -43,16 +43,15 @@
#include <termios.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "chat.h"
#include "sig.h"
-#include "chat.h"
#include "modem.h"
#ifndef isblank
@@ -140,7 +139,7 @@ MakeArgs(char *script, char **pvect, int maxargs)
* \U Auth User
*/
char *
-ExpandString(char *str, char *result, int reslen, int sendmode)
+ExpandString(const char *str, char *result, int reslen, int sendmode)
{
int addcr = 0;
char *phone;
@@ -240,14 +239,14 @@ static char logbuff[MAXLOGBUFF];
static int loglen = 0;
static void
-clear_log()
+clear_log(void)
{
memset(logbuff, 0, MAXLOGBUFF);
loglen = 0;
}
static void
-flush_log()
+flush_log(void)
{
if (LogIsKept(LogCONNECT))
LogPrintf(LogCONNECT, "%s\n", logbuff);
@@ -258,7 +257,7 @@ flush_log()
}
static void
-connect_log(char *str, int single_p)
+connect_log(const char *str, int single_p)
{
int space = MAXLOGBUFF - loglen - 1;
@@ -276,7 +275,7 @@ connect_log(char *str, int single_p)
}
static int
-WaitforString(char *estr)
+WaitforString(const char *estr)
{
struct timeval timeout;
char *s, *str, ch;
@@ -292,7 +291,7 @@ WaitforString(char *estr)
omask = sigblock(sigmask(SIGALRM));
#endif
clear_log();
- (void) ExpandString(estr, buff, sizeof(buff), 0);
+ ExpandString(estr, buff, sizeof(buff), 0);
LogPrintf(LogCHAT, "Wait for (%d): %s --> %s\n", TimeoutSec, estr, buff);
str = buff;
inp = inbuff;
@@ -417,7 +416,7 @@ ExecStr(char *command, char *out)
{
int pid;
int fids[2];
- char *vector[20];
+ char *vector[MAXARGS];
int stat, nb;
char *cp;
char tmp[300];
@@ -434,7 +433,7 @@ ExecStr(char *command, char *out)
LogPrintf(LogCHAT, "Too long string to ExecStr: \"%s\"\n", command);
return;
}
- (void) MakeArgs(tmp, vector, VECSIZE(vector));
+ MakeArgs(tmp, vector, VECSIZE(vector));
if (pipe(fids) < 0) {
LogPrintf(LogCHAT, "Unable to create pipe in ExecStr: %s\n",
@@ -462,7 +461,7 @@ ExecStr(char *command, char *out)
}
setuid(geteuid());
LogPrintf(LogCHAT, "exec: %s\n", command);
- pid = execvp(command, vector);
+ pid = execvp(command, (char **)vector);
LogPrintf(LogCHAT, "execvp failed for (%d/%d): %s\n", pid, errno, command);
exit(127);
} else {
@@ -481,7 +480,7 @@ ExecStr(char *command, char *out)
}
static void
-SendString(char *str)
+SendString(const char *str)
{
char *cp;
int on;
@@ -498,10 +497,10 @@ SendString(char *str)
TimeoutSec = 30;
} else {
if (*str == '!') {
- (void) ExpandString(str + 1, buff + 2, sizeof(buff) - 2, 0);
+ ExpandString(str + 1, buff + 2, sizeof(buff) - 2, 0);
ExecStr(buff + 2, buff + 2);
} else {
- (void) ExpandString(str, buff + 2, sizeof(buff) - 2, 1);
+ ExpandString(str, buff + 2, sizeof(buff) - 2, 1);
}
if (strstr(str, "\\P")) /* Do not log the password itself. */
LogPrintf(LogCHAT, "sending: %s\n", str);
@@ -544,8 +543,10 @@ ExpectString(char *str)
}
}
if (*minus == '-') { /* We have sub-send-expect. */
- *minus++ = '\0';
+ *minus = '\0'; /* XXX: Cheat with the const string */
state = WaitforString(str);
+ *minus = '-'; /* XXX: Cheat with the const string */
+ minus++;
if (state != NOMATCH)
return (state);
@@ -560,9 +561,10 @@ ExpectString(char *str)
}
}
if (*minus == '-') {
- *minus++ = '\0';
+ *minus = '\0'; /* XXX: Cheat with the const string */
SendString(str);
- str = minus;
+ *minus = '-'; /* XXX: Cheat with the const string */
+ str = ++minus;
} else {
SendString(str);
return (MATCH);
@@ -591,8 +593,8 @@ StopDial(int sig)
int
DoChat(char *script)
{
- char *vector[40];
- char **argv;
+ char *vector[MAXARGS];
+ char *const *argv;
int argc, n, state;
if (!script || !*script)
@@ -613,8 +615,7 @@ DoChat(char *script)
numaborts = 0;
memset(vector, '\0', sizeof(vector));
- n = MakeArgs(script, vector, VECSIZE(vector));
- argc = n;
+ argc = MakeArgs(script, vector, VECSIZE(vector));
argv = vector;
TimeoutSec = 30;
while (*argv) {
diff --git a/usr.sbin/ppp/chat.h b/usr.sbin/ppp/chat.h
index 371a46880cee..53f67fa4e254 100644
--- a/usr.sbin/ppp/chat.h
+++ b/usr.sbin/ppp/chat.h
@@ -18,12 +18,12 @@
* Columbus, OH 43221
* (614)451-1883
*
- * $Id: chat.h,v 1.7 1997/08/25 00:29:07 brian Exp $
+ * $Id: chat.h,v 1.8 1997/10/26 01:02:23 brian Exp $
*
*/
#define VECSIZE(v) (sizeof(v) / sizeof(v[0]))
-extern char *ExpandString(char *, char *, int, int);
-extern int MakeArgs(char *, char **, int);
-extern int DoChat(char *);
+extern char *ExpandString(const char *, char *, int, int);
+extern int MakeArgs(char *, char **, int); /* Mangles the first arg ! */
+extern int DoChat(char *); /* passes arg to MakeArgs() */
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 5b05036f3df8..b7c6d2d1f5c4 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.103 1997/11/18 00:19:28 brian Exp $
+ * $Id: command.c,v 1.104 1997/11/18 19:38:27 brian Exp $
*
*/
#include <sys/param.h>
@@ -29,7 +29,9 @@
#include <net/route.h>
#include <netdb.h>
+#ifndef NOALIAS
#include <alias.h>
+#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -43,6 +45,7 @@
#include <time.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -52,9 +55,10 @@
#include "lcp.h"
#include "ipcp.h"
#include "modem.h"
-#include "command.h"
#include "filter.h"
+#ifndef NOALIAS
#include "alias_cmd.h"
+#endif
#include "hdlc.h"
#include "loadalias.h"
#include "vars.h"
@@ -71,28 +75,26 @@
struct in_addr ifnetmask;
-static int ShowCommand(struct cmdtab const *, int, char **);
-static int TerminalCommand(struct cmdtab const *, int, char **);
-static int QuitCommand(struct cmdtab const *, int, char **);
-static int CloseCommand(struct cmdtab const *, int, char **);
-static int DialCommand(struct cmdtab const *, int, char **);
-static int DownCommand(struct cmdtab const *, int, char **);
-static int AllowCommand(struct cmdtab const *, int, char **);
-static int SetCommand(struct cmdtab const *, int, char **);
-static int AddCommand(struct cmdtab const *, int, char **);
-static int DeleteCommand(struct cmdtab const *, int, char **);
-static int BgShellCommand(struct cmdtab const *, int, char **);
-static int FgShellCommand(struct cmdtab const *, int, char **);
-static int ShellCommand(struct cmdtab const *, int, char **, int);
-static int AliasCommand(struct cmdtab const *, int, char **);
-static int AliasEnable(struct cmdtab const *, int, char **);
-static int AliasOption(struct cmdtab const *, int, char **, void *);
+static int ShowCommand(struct cmdargs const *arg);
+static int TerminalCommand(struct cmdargs const *arg);
+static int QuitCommand(struct cmdargs const *arg);
+static int CloseCommand(struct cmdargs const *arg);
+static int DialCommand(struct cmdargs const *arg);
+static int DownCommand(struct cmdargs const *arg);
+static int AllowCommand(struct cmdargs const *arg);
+static int SetCommand(struct cmdargs const *arg);
+static int AddCommand(struct cmdargs const *arg);
+static int DeleteCommand(struct cmdargs const *arg);
+static int BgShellCommand(struct cmdargs const *arg);
+static int FgShellCommand(struct cmdargs const *arg);
+#ifndef NOALIAS
+static int AliasCommand(struct cmdargs const *arg);
+static int AliasEnable(struct cmdargs const *arg);
+static int AliasOption(struct cmdargs const *arg);
+#endif
static int
-HelpCommand(struct cmdtab const * list,
- int argc,
- char **argv,
- struct cmdtab const * plist)
+HelpCommand(struct cmdargs const *arg)
{
struct cmdtab const *cmd;
int n;
@@ -100,16 +102,16 @@ HelpCommand(struct cmdtab const * list,
if (!VarTerm)
return 0;
- if (argc > 0) {
- for (cmd = plist; cmd->name; cmd++)
- if (strcasecmp(cmd->name, *argv) == 0 && (cmd->lauth & VarLocalAuth)) {
+ if (arg->argc > 0) {
+ for (cmd = arg->cmd; cmd->name; cmd++)
+ if (strcasecmp(cmd->name, *arg->argv) == 0 && (cmd->lauth & VarLocalAuth)) {
fprintf(VarTerm, "%s\n", cmd->syntax);
return 0;
}
return -1;
}
n = 0;
- for (cmd = plist; cmd->func; cmd++)
+ for (cmd = arg->cmd; cmd->func; cmd++)
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
fprintf(VarTerm, " %-9s: %-20s\n", cmd->name, cmd->helpmes);
n++;
@@ -123,7 +125,7 @@ HelpCommand(struct cmdtab const * list,
int
IsInteractive(int Display)
{
- char *mes = NULL;
+ const char *mes = NULL;
if (mode & MODE_DDIAL)
mes = "Working in dedicated dial mode.";
@@ -144,7 +146,7 @@ IsInteractive(int Display)
}
static int
-DialCommand(struct cmdtab const * cmdlist, int argc, char **argv)
+DialCommand(struct cmdargs const *arg)
{
int tries;
int res;
@@ -155,7 +157,7 @@ DialCommand(struct cmdtab const * cmdlist, int argc, char **argv)
return 0;
}
- if (argc > 0 && (res = LoadCommand(cmdlist, argc, argv)) != 0)
+ if (arg->argc > 0 && (res = LoadCommand(arg)) != 0)
return res;
tries = 0;
@@ -169,7 +171,7 @@ DialCommand(struct cmdtab const * cmdlist, int argc, char **argv)
}
if ((res = DialModem()) == EX_DONE) {
nointr_sleep(1);
- ModemTimeout();
+ ModemTimeout(NULL);
PacketMode();
break;
} else if (res == EX_SIG)
@@ -180,14 +182,14 @@ DialCommand(struct cmdtab const * cmdlist, int argc, char **argv)
}
static int
-SetLoopback(struct cmdtab const * cmdlist, int argc, char **argv)
+SetLoopback(struct cmdargs const *arg)
{
- if (argc == 1)
- if (!strcasecmp(*argv, "on")) {
+ if (arg->argc == 1)
+ if (!strcasecmp(*arg->argv, "on")) {
VarLoopback = 1;
return 0;
}
- else if (!strcasecmp(*argv, "off")) {
+ else if (!strcasecmp(*arg->argv, "off")) {
VarLoopback = 0;
return 0;
}
@@ -195,25 +197,13 @@ SetLoopback(struct cmdtab const * cmdlist, int argc, char **argv)
}
static int
-BgShellCommand(struct cmdtab const * cmdlist, int argc, char **argv)
-{
- if (argc == 0)
- return -1;
- return ShellCommand(cmdlist, argc, argv, 1);
-}
-
-static int
-FgShellCommand(struct cmdtab const * cmdlist, int argc, char **argv)
-{
- return ShellCommand(cmdlist, argc, argv, 0);
-}
-
-static int
-ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
+ShellCommand(struct cmdargs const *arg, int bg)
{
const char *shell;
pid_t shpid;
FILE *oVarTerm;
+ int argc;
+ char *argv[MAXARGS];
#ifdef SHELL_ONLY_INTERACTIVELY
/* we're only allowed to shell when we run ppp interactively */
@@ -234,7 +224,7 @@ ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
}
#endif
- if (argc == 0)
+ if (arg->argc == 0)
if (!(mode & MODE_INTER)) {
if (VarTerm)
LogPrintf(LogWARN, "Can't start an interactive shell from"
@@ -273,19 +263,24 @@ ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
close(fd);
for (dtablesize = getdtablesize(), i = 3; i < dtablesize; i++)
- (void) close(i);
+ close(i);
TtyOldMode();
setuid(geteuid());
- if (argc > 0) {
+ if (arg->argc > 0) {
/* substitute pseudo args */
- for (i = 1; i < argc; i++)
- if (strcasecmp(argv[i], "HISADDR") == 0)
- argv[i] = strdup(inet_ntoa(IpcpInfo.his_ipaddr));
- else if (strcasecmp(argv[i], "INTERFACE") == 0)
- argv[i] = strdup(IfDevName);
- else if (strcasecmp(argv[i], "MYADDR") == 0)
- argv[i] = strdup(inet_ntoa(IpcpInfo.want_ipaddr));
+ argv[0] = strdup(arg->argv[0]);
+ for (argc = 1; argc < arg->argc; argc++) {
+ if (strcasecmp(arg->argv[argc], "HISADDR") == 0)
+ argv[argc] = strdup(inet_ntoa(IpcpInfo.his_ipaddr));
+ else if (strcasecmp(arg->argv[argc], "INTERFACE") == 0)
+ argv[argc] = strdup(IfDevName);
+ else if (strcasecmp(arg->argv[argc], "MYADDR") == 0)
+ argv[argc] = strdup(inet_ntoa(IpcpInfo.want_ipaddr));
+ else
+ argv[argc] = strdup(arg->argv[argc]);
+ }
+ argv[argc] = NULL;
if (bg) {
pid_t p;
@@ -295,15 +290,15 @@ ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
exit(1);
}
} else if (VarTerm)
- fprintf(VarTerm, "ppp: Pausing until %s finishes\n", argv[0]);
- (void) execvp(argv[0], argv);
+ fprintf(VarTerm, "ppp: Pausing until %s finishes\n", arg->argv[0]);
+ execvp(argv[0], argv);
} else {
if (VarTerm)
fprintf(VarTerm, "ppp: Pausing until %s finishes\n", shell);
- (void) execl(shell, shell, NULL);
+ execl(shell, shell, NULL);
}
- LogPrintf(LogWARN, "exec() of %s failed\n", argc > 0 ? argv[0] : shell);
+ LogPrintf(LogWARN, "exec() of %s failed\n", arg->argc > 0 ? arg->argv[0] : shell);
exit(255);
}
if (shpid == (pid_t) - 1) {
@@ -311,7 +306,7 @@ ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
} else {
int status;
- (void) waitpid(shpid, &status, 0);
+ waitpid(shpid, &status, 0);
}
TtyCommandMode(1);
@@ -319,6 +314,20 @@ ShellCommand(struct cmdtab const * cmdlist, int argc, char **argv, int bg)
return (0);
}
+static int
+BgShellCommand(struct cmdargs const *arg)
+{
+ if (arg->argc == 0)
+ return -1;
+ return ShellCommand(arg, 1);
+}
+
+static int
+FgShellCommand(struct cmdargs const *arg)
+{
+ return ShellCommand(arg, 0);
+}
+
static struct cmdtab const Commands[] = {
{"accept", NULL, AcceptCommand, LOCAL_AUTH,
"accept option request", "accept option .."},
@@ -356,19 +365,21 @@ static struct cmdtab const Commands[] = {
"Show status and statistics", "show var"},
{"term", NULL, TerminalCommand, LOCAL_AUTH,
"Enter to terminal mode", "term"},
+#ifndef NOALIAS
{"alias", NULL, AliasCommand, LOCAL_AUTH,
"alias control", "alias option [yes|no]"},
+#endif
{"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
"Quit PPP program", "quit|bye [all]"},
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "help|? [command]", (void *) Commands},
+ "Display this message", "help|? [command]", Commands},
{NULL, "down", DownCommand, LOCAL_AUTH,
"Generate down event", "down"},
{NULL, NULL, NULL},
};
static int
-ShowLoopback()
+ShowLoopback(struct cmdargs const *arg)
{
if (VarTerm)
fprintf(VarTerm, "Local loopback is %s\n", VarLoopback ? "on" : "off");
@@ -377,7 +388,7 @@ ShowLoopback()
}
static int
-ShowLogLevel()
+ShowLogLevel(struct cmdargs const *arg)
{
int i;
@@ -400,7 +411,7 @@ ShowLogLevel()
}
static int
-ShowEscape()
+ShowEscape(struct cmdargs const *arg)
{
int code, bit;
@@ -418,7 +429,7 @@ ShowEscape()
}
static int
-ShowTimeout()
+ShowTimeout(struct cmdargs const *arg)
{
if (VarTerm)
fprintf(VarTerm, " Idle Timer: %d secs LQR Timer: %d secs"
@@ -428,7 +439,7 @@ ShowTimeout()
}
static int
-ShowStopped()
+ShowStopped(struct cmdargs const *arg)
{
if (!VarTerm)
return 0;
@@ -457,7 +468,7 @@ ShowStopped()
}
static int
-ShowAuthKey()
+ShowAuthKey(struct cmdargs const *arg)
{
if (!VarTerm)
return 0;
@@ -470,7 +481,7 @@ ShowAuthKey()
}
static int
-ShowVersion()
+ShowVersion(struct cmdargs const *arg)
{
if (VarTerm)
fprintf(VarTerm, "%s - %s \n", VarVersion, VarLocalVersion);
@@ -478,7 +489,7 @@ ShowVersion()
}
static int
-ShowInitialMRU()
+ShowInitialMRU(struct cmdargs const *arg)
{
if (VarTerm)
fprintf(VarTerm, " Initial MRU: %ld\n", VarMRU);
@@ -486,7 +497,7 @@ ShowInitialMRU()
}
static int
-ShowPreferredMTU()
+ShowPreferredMTU(struct cmdargs const *arg)
{
if (VarTerm)
if (VarPrefMTU)
@@ -497,7 +508,7 @@ ShowPreferredMTU()
}
static int
-ShowReconnect()
+ShowReconnect(struct cmdargs const *arg)
{
if (VarTerm)
fprintf(VarTerm, " Reconnect Timer: %d, %d tries\n",
@@ -506,7 +517,7 @@ ShowReconnect()
}
static int
-ShowRedial()
+ShowRedial(struct cmdargs const *arg)
{
if (!VarTerm)
return 0;
@@ -536,7 +547,7 @@ ShowRedial()
#ifndef NOMSEXT
static int
-ShowMSExt()
+ShowMSExt(struct cmdargs const *arg)
{
if (VarTerm) {
fprintf(VarTerm, " MS PPP extention values \n");
@@ -604,12 +615,12 @@ static struct cmdtab const ShowCommands[] = {
{"version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH,
"Show version string", "show version"},
{"help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH,
- "Display this message", "show help|? [command]", (void *) ShowCommands},
+ "Display this message", "show help|? [command]", ShowCommands},
{NULL, NULL, NULL},
};
static struct cmdtab const *
-FindCommand(struct cmdtab const * cmds, char *str, int *pmatch)
+FindCommand(struct cmdtab const *cmds, const char *str, int *pmatch)
{
int nmatch;
int len;
@@ -641,18 +652,23 @@ FindCommand(struct cmdtab const * cmds, char *str, int *pmatch)
}
static int
-FindExec(struct cmdtab const * cmdlist, int argc, char **argv)
+FindExec(struct cmdtab const *cmds, int argc, char const *const *argv)
{
struct cmdtab const *cmd;
int val = 1;
int nmatch;
+ struct cmdargs arg;
- cmd = FindCommand(cmdlist, *argv, &nmatch);
+ cmd = FindCommand(cmds, *argv, &nmatch);
if (nmatch > 1)
LogPrintf(LogWARN, "%s: Ambiguous command\n", *argv);
- else if (cmd && (cmd->lauth & VarLocalAuth))
- val = (cmd->func) (cmd, argc-1, argv+1, cmd->args);
- else
+ else if (cmd && (cmd->lauth & VarLocalAuth)) {
+ arg.cmd = cmd;
+ arg.argc = argc-1;
+ arg.argv = argv+1;
+ arg.data = cmd->args;
+ val = (cmd->func) (&arg);
+ } else
LogPrintf(LogWARN, "%s: Invalid command\n", *argv);
if (val == -1)
@@ -668,7 +684,7 @@ int aft_cmd = 1;
void
Prompt()
{
- char *pconnect, *pauth;
+ const char *pconnect, *pauth;
if (!VarTerm || TermMode)
return;
@@ -693,7 +709,7 @@ Prompt()
void
InterpretCommand(char *buff, int nb, int *argc, char ***argv)
{
- static char *vector[40];
+ static char *vector[MAXARGS];
char *cp;
if (nb > 0) {
@@ -707,7 +723,7 @@ InterpretCommand(char *buff, int nb, int *argc, char ***argv)
}
void
-RunCommand(int argc, char **argv, const char *label)
+RunCommand(int argc, char const *const *argv, const char *label)
{
if (argc > 0) {
if (LogIsKept(LogCOMMAND)) {
@@ -739,16 +755,16 @@ DecodeCommand(char *buff, int nb, const char *label)
char **argv;
InterpretCommand(buff, nb, &argc, &argv);
- RunCommand(argc, argv, label);
+ RunCommand(argc, (char const *const *)argv, label);
}
static int
-ShowCommand(struct cmdtab const * list, int argc, char **argv)
+ShowCommand(struct cmdargs const *arg)
{
- if (argc > 0)
- FindExec(ShowCommands, argc, argv);
+ if (arg->argc > 0)
+ FindExec(ShowCommands, arg->argc, arg->argv);
else if (VarTerm)
- fprintf(VarTerm, "Use ``show ?'' to get a list.\n");
+ fprintf(VarTerm, "Use ``show ?'' to get a arg->cmd.\n");
else
LogPrintf(LogWARN, "show command must have arguments\n");
@@ -756,7 +772,7 @@ ShowCommand(struct cmdtab const * list, int argc, char **argv)
}
static int
-TerminalCommand(struct cmdtab const * list, int argc, char **argv)
+TerminalCommand(struct cmdargs const *arg)
{
if (LcpFsm.state > ST_CLOSED) {
if (VarTerm)
@@ -779,13 +795,13 @@ TerminalCommand(struct cmdtab const * list, int argc, char **argv)
}
static int
-QuitCommand(struct cmdtab const * list, int argc, char **argv)
+QuitCommand(struct cmdargs const *arg)
{
if (VarTerm) {
DropClient();
if (mode & MODE_INTER)
Cleanup(EX_NORMAL);
- else if (argc > 0 && !strcasecmp(*argv, "all") && VarLocalAuth&LOCAL_AUTH)
+ else if (arg->argc > 0 && !strcasecmp(*arg->argv, "all") && VarLocalAuth&LOCAL_AUTH)
Cleanup(EX_NORMAL);
}
@@ -793,7 +809,7 @@ QuitCommand(struct cmdtab const * list, int argc, char **argv)
}
static int
-CloseCommand(struct cmdtab const * list, int argc, char **argv)
+CloseCommand(struct cmdargs const *arg)
{
reconnect(RECON_FALSE);
LcpClose();
@@ -801,57 +817,57 @@ CloseCommand(struct cmdtab const * list, int argc, char **argv)
}
static int
-DownCommand(struct cmdtab const * list, int argc, char **argv)
+DownCommand(struct cmdargs const *arg)
{
LcpDown();
return 0;
}
static int
-SetModemSpeed(struct cmdtab const * list, int argc, char **argv)
+SetModemSpeed(struct cmdargs const *arg)
{
int speed;
- if (argc > 0) {
- if (strcasecmp(*argv, "sync") == 0) {
+ if (arg->argc > 0) {
+ if (strcasecmp(*arg->argv, "sync") == 0) {
VarSpeed = 0;
return 0;
}
- speed = atoi(*argv);
+ speed = atoi(*arg->argv);
if (IntToSpeed(speed) != B0) {
VarSpeed = speed;
return 0;
}
- LogPrintf(LogWARN, "%s: Invalid speed\n", *argv);
+ LogPrintf(LogWARN, "%s: Invalid speed\n", *arg->argv);
}
return -1;
}
static int
-SetReconnect(struct cmdtab const * list, int argc, char **argv)
+SetReconnect(struct cmdargs const *arg)
{
- if (argc == 2) {
- VarReconnectTimer = atoi(argv[0]);
- VarReconnectTries = atoi(argv[1]);
+ if (arg->argc == 2) {
+ VarReconnectTimer = atoi(arg->argv[0]);
+ VarReconnectTries = atoi(arg->argv[1]);
return 0;
}
return -1;
}
static int
-SetRedialTimeout(struct cmdtab const * list, int argc, char **argv)
+SetRedialTimeout(struct cmdargs const *arg)
{
int timeout;
int tries;
char *dot;
- if (argc == 1 || argc == 2) {
- if (strncasecmp(argv[0], "random", 6) == 0 &&
- (argv[0][6] == '\0' || argv[0][6] == '.')) {
+ if (arg->argc == 1 || arg->argc == 2) {
+ if (strncasecmp(arg->argv[0], "random", 6) == 0 &&
+ (arg->argv[0][6] == '\0' || arg->argv[0][6] == '.')) {
VarRedialTimeout = -1;
randinit();
} else {
- timeout = atoi(argv[0]);
+ timeout = atoi(arg->argv[0]);
if (timeout >= 0)
VarRedialTimeout = timeout;
@@ -861,7 +877,7 @@ SetRedialTimeout(struct cmdtab const * list, int argc, char **argv)
}
}
- dot = strchr(argv[0], '.');
+ dot = strchr(arg->argv[0], '.');
if (dot) {
if (strcasecmp(++dot, "random") == 0) {
VarRedialNextTimeout = -1;
@@ -878,8 +894,8 @@ SetRedialTimeout(struct cmdtab const * list, int argc, char **argv)
} else
VarRedialNextTimeout = NEXT_REDIAL_PERIOD; /* Default next timeout */
- if (argc == 2) {
- tries = atoi(argv[1]);
+ if (arg->argc == 2) {
+ tries = atoi(arg->argv[1]);
if (tries >= 0) {
VarDialTries = tries;
@@ -894,18 +910,18 @@ SetRedialTimeout(struct cmdtab const * list, int argc, char **argv)
}
static int
-SetStoppedTimeout(struct cmdtab const * list, int argc, char **argv)
+SetStoppedTimeout(struct cmdargs const *arg)
{
LcpFsm.StoppedTimer.load = 0;
IpcpFsm.StoppedTimer.load = 0;
CcpFsm.StoppedTimer.load = 0;
- if (argc <= 3) {
- if (argc > 0) {
- LcpFsm.StoppedTimer.load = atoi(argv[0]) * SECTICKS;
- if (argc > 1) {
- IpcpFsm.StoppedTimer.load = atoi(argv[1]) * SECTICKS;
- if (argc > 2)
- CcpFsm.StoppedTimer.load = atoi(argv[2]) * SECTICKS;
+ if (arg->argc <= 3) {
+ if (arg->argc > 0) {
+ LcpFsm.StoppedTimer.load = atoi(arg->argv[0]) * SECTICKS;
+ if (arg->argc > 1) {
+ IpcpFsm.StoppedTimer.load = atoi(arg->argv[1]) * SECTICKS;
+ if (arg->argc > 2)
+ CcpFsm.StoppedTimer.load = atoi(arg->argv[2]) * SECTICKS;
}
}
return 0;
@@ -917,26 +933,26 @@ SetStoppedTimeout(struct cmdtab const * list, int argc, char **argv)
(*x == '0' && strlen(x) == 4 && strspn(x+1, "0123456789.") == 3)
static int
-SetServer(struct cmdtab const * list, int argc, char **argv)
+SetServer(struct cmdargs const *arg)
{
int res = -1;
- if (argc > 0 && argc < 4) {
+ if (arg->argc > 0 && arg->argc < 4) {
const char *port, *passwd, *mask;
/* What's what ? */
- port = argv[0];
- if (argc == 2)
- if (ismask(argv[1])) {
+ port = arg->argv[0];
+ if (arg->argc == 2)
+ if (ismask(arg->argv[1])) {
passwd = NULL;
- mask = argv[1];
+ mask = arg->argv[1];
} else {
- passwd = argv[1];
+ passwd = arg->argv[1];
mask = NULL;
}
- else if (argc == 3) {
- passwd = argv[1];
- mask = argv[2];
+ else if (arg->argc == 3) {
+ passwd = arg->argv[1];
+ mask = arg->argv[2];
if (!ismask(mask))
return -1;
} else
@@ -998,20 +1014,23 @@ SetServer(struct cmdtab const * list, int argc, char **argv)
}
static int
-SetModemParity(struct cmdtab const * list, int argc, char **argv)
+SetModemParity(struct cmdargs const *arg)
{
- return argc > 0 ? ChangeParity(*argv) : -1;
+ return arg->argc > 0 ? ChangeParity(*arg->argv) : -1;
}
static int
-SetLogLevel(struct cmdtab const * list, int argc, char **argv)
+SetLogLevel(struct cmdargs const *arg)
{
int i;
int res;
- char *arg;
+ int argc;
+ char const *const *argv, *argp;
void (*Discard)(int), (*Keep)(int);
void (*DiscardAll)(void);
+ argc = arg->argc;
+ argv = arg->argv;
res = 0;
if (argc == 0 || strcasecmp(argv[0], "local")) {
Discard = LogDiscard;
@@ -1026,11 +1045,11 @@ SetLogLevel(struct cmdtab const * list, int argc, char **argv)
}
if (argc == 0 || (argv[0][0] != '+' && argv[0][0] != '-'))
- (*DiscardAll)();
+ DiscardAll();
while (argc--) {
- arg = **argv == '+' || **argv == '-' ? *argv + 1 : *argv;
+ argp = **argv == '+' || **argv == '-' ? *argv + 1 : *argv;
for (i = LogMIN; i <= LogMAX; i++)
- if (strcasecmp(arg, LogName(i)) == 0) {
+ if (strcasecmp(argp, LogName(i)) == 0) {
if (**argv == '-')
(*Discard)(i);
else
@@ -1038,7 +1057,7 @@ SetLogLevel(struct cmdtab const * list, int argc, char **argv)
break;
}
if (i > LogMAX) {
- LogPrintf(LogWARN, "%s: Invalid log value\n", arg);
+ LogPrintf(LogWARN, "%s: Invalid log value\n", argp);
res = -1;
}
argv++;
@@ -1047,12 +1066,15 @@ SetLogLevel(struct cmdtab const * list, int argc, char **argv)
}
static int
-SetEscape(struct cmdtab const * list, int argc, char **argv)
+SetEscape(struct cmdargs const *arg)
{
int code;
+ int argc = arg->argc;
+ char const *const *argv = arg->argv;
for (code = 0; code < 33; code++)
EscMap[code] = 0;
+
while (argc-- > 0) {
sscanf(*argv++, "%x", &code);
code &= 0xff;
@@ -1063,13 +1085,13 @@ SetEscape(struct cmdtab const * list, int argc, char **argv)
}
static int
-SetInitialMRU(struct cmdtab const * list, int argc, char **argv)
+SetInitialMRU(struct cmdargs const *arg)
{
long mru;
- char *err;
+ const char *err;
- if (argc > 0) {
- mru = atol(*argv);
+ if (arg->argc > 0) {
+ mru = atol(*arg->argv);
if (mru < MIN_MRU)
err = "Given MRU value (%ld) is too small.\n";
else if (mru > MAX_MRU)
@@ -1084,13 +1106,13 @@ SetInitialMRU(struct cmdtab const * list, int argc, char **argv)
}
static int
-SetPreferredMTU(struct cmdtab const * list, int argc, char **argv)
+SetPreferredMTU(struct cmdargs const *arg)
{
long mtu;
- char *err;
+ const char *err;
- if (argc > 0) {
- mtu = atol(*argv);
+ if (arg->argc > 0) {
+ mtu = atol(*arg->argv);
if (mtu == 0) {
VarPrefMTU = 0;
return 0;
@@ -1108,17 +1130,17 @@ SetPreferredMTU(struct cmdtab const * list, int argc, char **argv)
}
static int
-SetIdleTimeout(struct cmdtab const * list, int argc, char **argv)
+SetIdleTimeout(struct cmdargs const *arg)
{
- if (argc-- > 0) {
- VarIdleTimeout = atoi(*argv++);
+ if (arg->argc > 0) {
+ VarIdleTimeout = atoi(arg->argv[0]);
UpdateIdleTimer(); /* If we're connected, restart the idle timer */
- if (argc-- > 0) {
- VarLqrTimeout = atoi(*argv++);
+ if (arg->argc > 1) {
+ VarLqrTimeout = atoi(arg->argv[1]);
if (VarLqrTimeout < 1)
VarLqrTimeout = 30;
- if (argc > 0) {
- VarRetryTimeout = atoi(*argv);
+ if (arg->argc > 2) {
+ VarRetryTimeout = atoi(arg->argv[2]);
if (VarRetryTimeout < 1 || VarRetryTimeout > 10)
VarRetryTimeout = 3;
}
@@ -1129,7 +1151,7 @@ SetIdleTimeout(struct cmdtab const * list, int argc, char **argv)
}
static struct in_addr
-GetIpAddr(char *cp)
+GetIpAddr(const char *cp)
{
struct hostent *hp;
struct in_addr ipaddr;
@@ -1143,32 +1165,32 @@ GetIpAddr(char *cp)
}
static int
-SetInterfaceAddr(struct cmdtab const * list, int argc, char **argv)
+SetInterfaceAddr(struct cmdargs const *arg)
{
DefMyAddress.ipaddr.s_addr = DefHisAddress.ipaddr.s_addr = 0L;
- if (argc > 4)
+ if (arg->argc > 4)
return -1;
HaveTriggerAddress = 0;
ifnetmask.s_addr = 0;
- if (argc > 0) {
- if (ParseAddr(argc, argv++,
+ if (arg->argc > 0) {
+ if (ParseAddr(arg->argc, arg->argv,
&DefMyAddress.ipaddr,
&DefMyAddress.mask,
&DefMyAddress.width) == 0)
return 1;
- if (--argc > 0) {
- if (ParseAddr(argc, argv++,
+ if (arg->argc > 1) {
+ if (ParseAddr(arg->argc, arg->argv+1,
&DefHisAddress.ipaddr,
&DefHisAddress.mask,
&DefHisAddress.width) == 0)
return 2;
- if (--argc > 0) {
- ifnetmask = GetIpAddr(*argv);
- if (--argc > 0) {
- TriggerAddress = GetIpAddr(*argv);
+ if (arg->argc > 2) {
+ ifnetmask = GetIpAddr(arg->argv[2]);
+ if (arg->argc > 3) {
+ TriggerAddress = GetIpAddr(arg->argv[3]);
HaveTriggerAddress = 1;
}
}
@@ -1202,7 +1224,7 @@ static void
SetMSEXT(struct in_addr * pri_addr,
struct in_addr * sec_addr,
int argc,
- char **argv)
+ char const *const *argv)
{
int dummyint;
struct in_addr dummyaddr;
@@ -1227,78 +1249,79 @@ SetMSEXT(struct in_addr * pri_addr,
}
static int
-SetNS(struct cmdtab const * list, int argc, char **argv)
+SetNS(struct cmdargs const *arg)
{
- SetMSEXT(&ns_entries[0], &ns_entries[1], argc, argv);
+ SetMSEXT(&ns_entries[0], &ns_entries[1], arg->argc, arg->argv);
return 0;
}
static int
-SetNBNS(struct cmdtab const * list, int argc, char **argv)
+SetNBNS(struct cmdargs const *arg)
{
- SetMSEXT(&nbns_entries[0], &nbns_entries[1], argc, argv);
+ SetMSEXT(&nbns_entries[0], &nbns_entries[1], arg->argc, arg->argv);
return 0;
}
#endif /* MS_EXT */
int
-SetVariable(struct cmdtab const * list, int argc, char **argv, int param)
+SetVariable(struct cmdargs const *arg)
{
u_long map;
- char *arg;
+ const char *argp;
+ int param = (int)arg->data;
- if (argc > 0)
- arg = *argv;
+ if (arg->argc > 0)
+ argp = *arg->argv;
else
- arg = "";
+ argp = "";
switch (param) {
case VAR_AUTHKEY:
- strncpy(VarAuthKey, arg, sizeof(VarAuthKey) - 1);
+ strncpy(VarAuthKey, argp, sizeof(VarAuthKey) - 1);
VarAuthKey[sizeof(VarAuthKey) - 1] = '\0';
break;
case VAR_AUTHNAME:
- strncpy(VarAuthName, arg, sizeof(VarAuthName) - 1);
+ strncpy(VarAuthName, argp, sizeof(VarAuthName) - 1);
VarAuthName[sizeof(VarAuthName) - 1] = '\0';
break;
case VAR_DIAL:
- strncpy(VarDialScript, arg, sizeof(VarDialScript) - 1);
+ strncpy(VarDialScript, argp, sizeof(VarDialScript) - 1);
VarDialScript[sizeof(VarDialScript) - 1] = '\0';
break;
case VAR_LOGIN:
- strncpy(VarLoginScript, arg, sizeof(VarLoginScript) - 1);
+ strncpy(VarLoginScript, argp, sizeof(VarLoginScript) - 1);
VarLoginScript[sizeof(VarLoginScript) - 1] = '\0';
break;
case VAR_DEVICE:
if (modem != -1)
LogPrintf(LogWARN, "Cannot change device to \"%s\" when \"%s\" is open\n",
- arg, VarDevice);
+ argp, VarDevice);
else {
- strncpy(VarDevice, arg, sizeof(VarDevice) - 1);
+ strncpy(VarDevice, argp, sizeof(VarDevice) - 1);
VarDevice[sizeof(VarDevice) - 1] = '\0';
VarBaseDevice = strrchr(VarDevice, '/');
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
}
break;
case VAR_ACCMAP:
- sscanf(arg, "%lx", &map);
+ sscanf(argp, "%lx", &map);
VarAccmap = map;
break;
case VAR_PHONE:
- strncpy(VarPhoneList, arg, sizeof(VarPhoneList) - 1);
+ strncpy(VarPhoneList, argp, sizeof(VarPhoneList) - 1);
VarPhoneList[sizeof(VarPhoneList) - 1] = '\0';
strcpy(VarPhoneCopy, VarPhoneList);
VarNextPhone = VarPhoneCopy;
VarAltPhone = NULL;
break;
case VAR_HANGUP:
- strncpy(VarHangupScript, arg, sizeof(VarHangupScript) - 1);
+ strncpy(VarHangupScript, argp, sizeof(VarHangupScript) - 1);
VarHangupScript[sizeof(VarHangupScript) - 1] = '\0';
break;
#ifdef HAVE_DES
case VAR_ENC:
- VarMSChap = !strcasecmp(arg, "mschap");
+ VarMSChap = !strcasecmp(argp, "mschap");
break;
#endif
}
@@ -1306,12 +1329,12 @@ SetVariable(struct cmdtab const * list, int argc, char **argv, int param)
}
static int
-SetCtsRts(struct cmdtab const * list, int argc, char **argv)
+SetCtsRts(struct cmdargs const *arg)
{
- if (argc > 0) {
- if (strcmp(*argv, "on") == 0)
+ if (arg->argc > 0) {
+ if (strcmp(*arg->argv, "on") == 0)
VarCtsRts = 1;
- else if (strcmp(*argv, "off") == 0)
+ else if (strcmp(*arg->argv, "off") == 0)
VarCtsRts = 0;
else
return -1;
@@ -1322,12 +1345,12 @@ SetCtsRts(struct cmdtab const * list, int argc, char **argv)
static int
-SetOpenMode(struct cmdtab const * list, int argc, char **argv)
+SetOpenMode(struct cmdargs const *arg)
{
- if (argc > 0) {
- if (strcmp(*argv, "active") == 0)
+ if (arg->argc > 0) {
+ if (strcmp(*arg->argv, "active") == 0)
VarOpenMode = OPEN_ACTIVE;
- else if (strcmp(*argv, "passive") == 0)
+ else if (strcmp(*arg->argv, "passive") == 0)
VarOpenMode = OPEN_PASSIVE;
else
return -1;
@@ -1338,31 +1361,31 @@ SetOpenMode(struct cmdtab const * list, int argc, char **argv)
static struct cmdtab const SetCommands[] = {
{"accmap", NULL, SetVariable, LOCAL_AUTH,
- "Set accmap value", "set accmap hex-value", (void *) VAR_ACCMAP},
+ "Set accmap value", "set accmap hex-value", (const void *) VAR_ACCMAP},
{"afilter", NULL, SetAfilter, LOCAL_AUTH,
"Set keep Alive filter", "set afilter ..."},
{"authkey", "key", SetVariable, LOCAL_AUTH,
- "Set authentication key", "set authkey|key key", (void *) VAR_AUTHKEY},
+ "Set authentication key", "set authkey|key key", (const void *) VAR_AUTHKEY},
{"authname", NULL, SetVariable, LOCAL_AUTH,
- "Set authentication name", "set authname name", (void *) VAR_AUTHNAME},
+ "Set authentication name", "set authname name", (const void *) VAR_AUTHNAME},
{"ctsrts", NULL, SetCtsRts, LOCAL_AUTH,
"Use CTS/RTS modem signalling", "set ctsrts [on|off]"},
- {"device", "line", SetVariable, LOCAL_AUTH,
- "Set modem device name", "set device|line device-name", (void *) VAR_DEVICE},
+ {"device", "line", SetVariable, LOCAL_AUTH, "Set modem device name",
+ "set device|line device-name", (const void *) VAR_DEVICE},
{"dfilter", NULL, SetDfilter, LOCAL_AUTH,
"Set demand filter", "set dfilter ..."},
{"dial", NULL, SetVariable, LOCAL_AUTH,
- "Set dialing script", "set dial chat-script", (void *) VAR_DIAL},
+ "Set dialing script", "set dial chat-script", (const void *) VAR_DIAL},
#ifdef HAVE_DES
- {"encrypt", NULL, SetVariable, LOCAL_AUTH,
- "Set CHAP encryption algorithm", "set encrypt MSChap|MD5", (void *) VAR_ENC},
+ {"encrypt", NULL, SetVariable, LOCAL_AUTH, "Set CHAP encryption algorithm",
+ "set encrypt MSChap|MD5", (const void *) VAR_ENC},
#endif
{"escape", NULL, SetEscape, LOCAL_AUTH,
"Set escape characters", "set escape hex-digit ..."},
{"hangup", NULL, SetVariable, LOCAL_AUTH,
- "Set hangup script", "set hangup chat-script", (void *) VAR_HANGUP},
- {"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH,
- "Set destination address", "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"},
+ "Set hangup script", "set hangup chat-script", (const void *) VAR_HANGUP},
+ {"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH, "Set destination address",
+ "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"},
{"ifilter", NULL, SetIfilter, LOCAL_AUTH,
"Set input filter", "set ifilter ..."},
{"loopback", NULL, SetLoopback, LOCAL_AUTH,
@@ -1370,7 +1393,7 @@ static struct cmdtab const SetCommands[] = {
{"log", NULL, SetLogLevel, LOCAL_AUTH,
"Set log level", "set log [local] [+|-]value..."},
{"login", NULL, SetVariable, LOCAL_AUTH,
- "Set login script", "set login chat-script", (void *) VAR_LOGIN},
+ "Set login script", "set login chat-script", (const void *) VAR_LOGIN},
{"mru", NULL, SetInitialMRU, LOCAL_AUTH,
"Set Initial MRU value", "set mru value"},
{"mtu", NULL, SetPreferredMTU, LOCAL_AUTH,
@@ -1381,14 +1404,14 @@ static struct cmdtab const SetCommands[] = {
"Set open mode", "set openmode [active|passive]"},
{"parity", NULL, SetModemParity, LOCAL_AUTH,
"Set modem parity", "set parity [odd|even|none]"},
- {"phone", NULL, SetVariable, LOCAL_AUTH,
- "Set telephone number(s)", "set phone phone1[:phone2[...]]", (void *) VAR_PHONE},
+ {"phone", NULL, SetVariable, LOCAL_AUTH, "Set telephone number(s)",
+ "set phone phone1[:phone2[...]]", (const void *) VAR_PHONE},
{"reconnect", NULL, SetReconnect, LOCAL_AUTH,
"Set Reconnect timeout", "set reconnect value ntries"},
- {"redial", NULL, SetRedialTimeout, LOCAL_AUTH,
- "Set Redial timeout", "set redial value|random[.value|random] [dial_attempts]"},
- {"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH,
- "Set STOPPED timeouts", "set stopped [LCPseconds [IPCPseconds [CCPseconds]]]"},
+ {"redial", NULL, SetRedialTimeout, LOCAL_AUTH, "Set Redial timeout",
+ "set redial value|random[.value|random] [dial_attempts]"},
+ {"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH, "Set STOPPED timeouts",
+ "set stopped [LCPseconds [IPCPseconds [CCPseconds]]]"},
{"server", "socket", SetServer, LOCAL_AUTH,
"Set server port", "set server|socket TcpPort|LocalName|none [mask]"},
{"speed", NULL, SetModemSpeed, LOCAL_AUTH,
@@ -1402,17 +1425,17 @@ static struct cmdtab const SetCommands[] = {
"Set NetBIOS NameServer", "set nbns pri-addr [sec-addr]"},
#endif
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "set help|? [command]", (void *) SetCommands},
+ "Display this message", "set help|? [command]", SetCommands},
{NULL, NULL, NULL},
};
static int
-SetCommand(struct cmdtab const * list, int argc, char **argv)
+SetCommand(struct cmdargs const *arg)
{
- if (argc > 0)
- FindExec(SetCommands, argc, argv);
+ if (arg->argc > 0)
+ FindExec(SetCommands, arg->argc, arg->argv);
else if (VarTerm)
- fprintf(VarTerm, "Use `set ?' to get a list or `set ? <var>' for"
+ fprintf(VarTerm, "Use `set ?' to get a arg->cmd or `set ? <var>' for"
" syntax help.\n");
else
LogPrintf(LogWARN, "set command must have arguments\n");
@@ -1422,20 +1445,20 @@ SetCommand(struct cmdtab const * list, int argc, char **argv)
static int
-AddCommand(struct cmdtab const * list, int argc, char **argv)
+AddCommand(struct cmdargs const *arg)
{
struct in_addr dest, gateway, netmask;
- if (argc == 3) {
- if (strcasecmp(argv[0], "MYADDR") == 0)
+ if (arg->argc == 3) {
+ if (strcasecmp(arg->argv[0], "MYADDR") == 0)
dest = IpcpInfo.want_ipaddr;
else
- dest = GetIpAddr(argv[0]);
- netmask = GetIpAddr(argv[1]);
- if (strcasecmp(argv[2], "HISADDR") == 0)
+ dest = GetIpAddr(arg->argv[0]);
+ netmask = GetIpAddr(arg->argv[1]);
+ if (strcasecmp(arg->argv[2], "HISADDR") == 0)
gateway = IpcpInfo.his_ipaddr;
else
- gateway = GetIpAddr(argv[2]);
+ gateway = GetIpAddr(arg->argv[2]);
OsSetRoute(RTM_ADD, dest, gateway, netmask);
return 0;
}
@@ -1443,25 +1466,25 @@ AddCommand(struct cmdtab const * list, int argc, char **argv)
}
static int
-DeleteCommand(struct cmdtab const * list, int argc, char **argv)
+DeleteCommand(struct cmdargs const *arg)
{
struct in_addr dest, gateway, netmask;
- if (argc == 1 && strcasecmp(argv[0], "all") == 0)
+ if (arg->argc == 1 && strcasecmp(arg->argv[0], "all") == 0)
DeleteIfRoutes(0);
- else if (argc > 0 && argc < 4) {
- if (strcasecmp(argv[0], "MYADDR") == 0)
+ else if (arg->argc > 0 && arg->argc < 4) {
+ if (strcasecmp(arg->argv[0], "MYADDR") == 0)
dest = IpcpInfo.want_ipaddr;
else
- dest = GetIpAddr(argv[0]);
+ dest = GetIpAddr(arg->argv[0]);
netmask.s_addr = INADDR_ANY;
- if (argc > 1) {
- if (strcasecmp(argv[1], "HISADDR") == 0)
+ if (arg->argc > 1) {
+ if (strcasecmp(arg->argv[1], "HISADDR") == 0)
gateway = IpcpInfo.his_ipaddr;
else
- gateway = GetIpAddr(argv[1]);
- if (argc == 3) {
- if (inet_aton(argv[2], &netmask) == 0) {
+ gateway = GetIpAddr(arg->argv[1]);
+ if (arg->argc == 3) {
+ if (inet_aton(arg->argv[2], &netmask) == 0) {
LogPrintf(LogWARN, "Bad netmask value.\n");
return -1;
}
@@ -1475,6 +1498,7 @@ DeleteCommand(struct cmdtab const * list, int argc, char **argv)
return 0;
}
+#ifndef NOALIAS
static struct cmdtab const AliasCommands[] =
{
{"enable", NULL, AliasEnable, LOCAL_AUTH,
@@ -1485,34 +1509,33 @@ static struct cmdtab const AliasCommands[] =
"static address translation", "alias addr [addr_local addr_alias]"},
{"deny_incoming", NULL, AliasOption, LOCAL_AUTH,
"stop incoming connections", "alias deny_incoming [yes|no]",
- (void *) PKT_ALIAS_DENY_INCOMING},
+ (const void *) PKT_ALIAS_DENY_INCOMING},
{"log", NULL, AliasOption, LOCAL_AUTH,
"log aliasing link creation", "alias log [yes|no]",
- (void *) PKT_ALIAS_LOG},
+ (const void *) PKT_ALIAS_LOG},
{"same_ports", NULL, AliasOption, LOCAL_AUTH,
"try to leave port numbers unchanged", "alias same_ports [yes|no]",
- (void *) PKT_ALIAS_SAME_PORTS},
+ (const void *) PKT_ALIAS_SAME_PORTS},
{"use_sockets", NULL, AliasOption, LOCAL_AUTH,
"allocate host sockets", "alias use_sockets [yes|no]",
- (void *) PKT_ALIAS_USE_SOCKETS},
+ (const void *) PKT_ALIAS_USE_SOCKETS},
{"unregistered_only", NULL, AliasOption, LOCAL_AUTH,
"alias unregistered (private) IP address space only",
"alias unregistered_only [yes|no]",
- (void *) PKT_ALIAS_UNREGISTERED_ONLY},
+ (const void *) PKT_ALIAS_UNREGISTERED_ONLY},
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "alias help|? [command]",
- (void *) AliasCommands},
+ "Display this message", "alias help|? [command]", AliasCommands},
{NULL, NULL, NULL},
};
static int
-AliasCommand(struct cmdtab const * list, int argc, char **argv)
+AliasCommand(struct cmdargs const *arg)
{
- if (argc > 0)
- FindExec(AliasCommands, argc, argv);
+ if (arg->argc > 0)
+ FindExec(AliasCommands, arg->argc, arg->argv);
else if (VarTerm)
- fprintf(VarTerm, "Use `alias help' to get a list or `alias help <option>'"
+ fprintf(VarTerm, "Use `alias help' to get a arg->cmd or `alias help <option>'"
" for syntax help.\n");
else
LogPrintf(LogWARN, "alias command must have arguments\n");
@@ -1521,10 +1544,10 @@ AliasCommand(struct cmdtab const * list, int argc, char **argv)
}
static int
-AliasEnable(struct cmdtab const * list, int argc, char **argv)
+AliasEnable(struct cmdargs const *arg)
{
- if (argc == 1)
- if (strcasecmp(argv[0], "yes") == 0) {
+ if (arg->argc == 1)
+ if (strcasecmp(arg->argv[0], "yes") == 0) {
if (!(mode & MODE_ALIAS)) {
if (loadAliasHandlers(&VarAliasHandlers) == 0) {
mode |= MODE_ALIAS;
@@ -1534,7 +1557,7 @@ AliasEnable(struct cmdtab const * list, int argc, char **argv)
return 1;
}
return 0;
- } else if (strcasecmp(argv[0], "no") == 0) {
+ } else if (strcasecmp(arg->argv[0], "no") == 0) {
if (mode & MODE_ALIAS) {
unloadAliasHandlers();
mode &= ~MODE_ALIAS;
@@ -1546,24 +1569,26 @@ AliasEnable(struct cmdtab const * list, int argc, char **argv)
static int
-AliasOption(struct cmdtab const * list, int argc, char **argv, void *param)
+AliasOption(struct cmdargs const *arg)
{
- if (argc == 1)
- if (strcasecmp(argv[0], "yes") == 0) {
+ unsigned param = (unsigned)arg->data;
+ if (arg->argc == 1)
+ if (strcasecmp(arg->argv[0], "yes") == 0) {
if (mode & MODE_ALIAS) {
- VarPacketAliasSetMode((unsigned) param, (unsigned) param);
+ VarPacketAliasSetMode(param, param);
return 0;
}
LogPrintf(LogWARN, "alias not enabled\n");
- } else if (strcmp(argv[0], "no") == 0) {
+ } else if (strcmp(arg->argv[0], "no") == 0) {
if (mode & MODE_ALIAS) {
- VarPacketAliasSetMode(0, (unsigned) param);
+ VarPacketAliasSetMode(0, param);
return 0;
}
LogPrintf(LogWARN, "alias not enabled\n");
}
return -1;
}
+#endif /* #ifndef NOALIAS */
static struct cmdtab const AllowCommands[] = {
{"users", "user", AllowUsers, LOCAL_AUTH,
@@ -1571,17 +1596,17 @@ static struct cmdtab const AllowCommands[] = {
{"modes", "mode", AllowModes, LOCAL_AUTH,
"Only allow certain ppp modes", "allow modes mode..."},
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "allow help|? [command]", (void *)AllowCommands},
+ "Display this message", "allow help|? [command]", AllowCommands},
{NULL, NULL, NULL},
};
static int
-AllowCommand(struct cmdtab const *list, int argc, char **argv)
+AllowCommand(struct cmdargs const *arg)
{
- if (argc > 0)
- FindExec(AllowCommands, argc, argv);
+ if (arg->argc > 0)
+ FindExec(AllowCommands, arg->argc, arg->argv);
else if (VarTerm)
- fprintf(VarTerm, "Use `allow ?' to get a list or `allow ? <cmd>' for"
+ fprintf(VarTerm, "Use `allow ?' to get a arg->cmd or `allow ? <cmd>' for"
" syntax help.\n");
else
LogPrintf(LogWARN, "allow command must have arguments\n");
diff --git a/usr.sbin/ppp/command.h b/usr.sbin/ppp/command.h
index 16954eedefd2..e83114dc8d27 100644
--- a/usr.sbin/ppp/command.h
+++ b/usr.sbin/ppp/command.h
@@ -15,19 +15,28 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.h,v 1.10 1997/11/11 22:58:10 brian Exp $
+ * $Id: command.h,v 1.11 1997/11/13 14:43:15 brian Exp $
*
* TODO:
*/
+struct cmdtab;
+
+struct cmdargs {
+ struct cmdtab const *cmd;
+ int argc;
+ char const *const *argv;
+ const void *data;
+};
+
struct cmdtab {
- char *name;
- char *alias;
- int (*func) ();
+ const char *name;
+ const char *alias;
+ int (*func) (struct cmdargs const *);
u_char lauth;
- char *helpmes;
- char *syntax;
- void *args;
+ const char *helpmes;
+ const char *syntax;
+ const void *args;
};
#define VAR_AUTHKEY 0
@@ -45,9 +54,9 @@ struct cmdtab {
extern struct in_addr ifnetmask;
extern int aft_cmd;
-extern int SetVariable(struct cmdtab const *, int, char **, int);
+extern int SetVariable(struct cmdargs const *);
extern void Prompt(void);
extern int IsInteractive(int);
extern void InterpretCommand(char *, int, int *, char ***);
-extern void RunCommand(int, char **, const char *label);
+extern void RunCommand(int, char const *const *, const char *label);
extern void DecodeCommand(char *, int, const char *label);
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index 6d2f3ed6b0e9..ccfca71dc597 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -1,5 +1,5 @@
/*
- * $Id: defs.c,v 1.3 1997/11/17 00:42:38 brian Exp $
+ * $Id: defs.c,v 1.4 1997/11/18 00:19:30 brian Exp $
*/
#include <sys/param.h>
@@ -9,13 +9,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "defs.h"
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
int mode = MODE_INTER;
@@ -45,12 +46,16 @@ GetLabel()
void
randinit()
{
+#ifdef __FreeBSD__
static int initdone;
if (!initdone) {
initdone = 1;
srandomdev();
}
+#else
+ srandom(time(NULL)^getpid());
+#endif
}
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index 2f671f825614..164c88e8dadb 100644
--- a/usr.sbin/ppp/defs.h
+++ b/usr.sbin/ppp/defs.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: defs.h,v 1.26 1997/11/17 00:42:39 brian Exp $
+ * $Id: defs.h,v 1.27 1997/11/18 00:19:31 brian Exp $
*
* TODO:
*/
@@ -45,6 +45,7 @@
#define NEXT_REDIAL_PERIOD 3 /* Default Hold time to next number redial */
#define SCRIPT_LEN 512 /* Size of login scripts */
#define LINE_LEN SCRIPT_LEN /* Size of login scripts */
+#define MAXARGS 40 /* How many args per config line */
#define CONFFILE "ppp.conf"
#define LINKUPFILE "ppp.linkup"
diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c
index baa45ef030fc..b154e1abbc32 100644
--- a/usr.sbin/ppp/filter.c
+++ b/usr.sbin/ppp/filter.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: filter.c,v 1.17 1997/11/09 14:18:38 brian Exp $
+ * $Id: filter.c,v 1.18 1997/11/12 18:47:30 brian Exp $
*
* TODO: Shoud send ICMP error message when we discard packets.
*/
@@ -62,31 +62,40 @@ static u_long netmasks[33] = {
int
ParseAddr(int argc,
- char **argv,
+ char const *const *argv,
struct in_addr * paddr,
struct in_addr * pmask,
int *pwidth)
{
- int bits;
- char *cp, *wp;
+ int bits, len;
+ char *wp;
+ const char *cp;
if (argc < 1) {
LogPrintf(LogWARN, "ParseAddr: address/mask is expected.\n");
return (0);
}
pmask->s_addr = 0xffffffff; /* Assume 255.255.255.255 as default */
+
cp = strchr(*argv, '/');
- if (cp)
- *cp++ = '\0';
- if (strcasecmp(*argv, "HISADDR") == 0)
+ len = cp ? cp - *argv : strlen(*argv);
+
+ if (strncasecmp(*argv, "HISADDR", len) == 0)
*paddr = IpcpInfo.his_ipaddr;
- else if (strcasecmp(*argv, "MYADDR") == 0)
+ else if (strncasecmp(*argv, "MYADDR", len) == 0)
*paddr = IpcpInfo.want_ipaddr;
- else if (inet_aton(*argv, paddr) == 0) {
+ else if (len > 15)
LogPrintf(LogWARN, "ParseAddr: %s: Bad address\n", *argv);
- return (0);
+ else {
+ char s[16];
+ strncpy(s, *argv, len);
+ s[len] = '\0';
+ if (inet_aton(s, paddr) == 0) {
+ LogPrintf(LogWARN, "ParseAddr: %s: Bad address\n", s);
+ return (0);
+ }
}
- if (cp && *cp) {
+ if (cp && *++cp) {
bits = strtol(cp, &wp, 0);
if (cp == wp || bits < 0 || bits > 32) {
LogPrintf(LogWARN, "ParseAddr: bad mask width.\n");
@@ -104,7 +113,7 @@ ParseAddr(int argc,
}
static int
-ParseProto(int argc, char **argv)
+ParseProto(int argc, char const *const *argv)
{
int proto;
@@ -123,9 +132,10 @@ ParseProto(int argc, char **argv)
}
static int
-ParsePort(char *service, int proto)
+ParsePort(const char *service, int proto)
{
- char *protocol_name, *cp;
+ const char *protocol_name;
+ char *cp;
struct servent *servent;
int port;
@@ -157,7 +167,7 @@ ParsePort(char *service, int proto)
* ICMP Syntax: src eq icmp_message_type
*/
static int
-ParseIcmp(int argc, char **argv)
+ParseIcmp(int argc, char const *const *argv)
{
int type;
char *cp;
@@ -186,7 +196,7 @@ ParseIcmp(int argc, char **argv)
}
static int
-ParseOp(char *cp)
+ParseOp(const char *cp)
{
int op = OP_NONE;
@@ -203,7 +213,7 @@ ParseOp(char *cp)
* UDP Syntax: [src op port] [dst op port]
*/
static int
-ParseUdpOrTcp(int argc, char **argv, int proto)
+ParseUdpOrTcp(int argc, char const *const *argv, int proto)
{
filterdata.opt.srcop = filterdata.opt.dstop = OP_NONE;
filterdata.opt.estab = 0;
@@ -254,10 +264,10 @@ ParseUdpOrTcp(int argc, char **argv, int proto)
return (0);
}
-char *opname[] = {"none", "eq", "gt", NULL, "lt"};
+const char *opname[] = {"none", "eq", "gt", NULL, "lt"};
static int
-Parse(int argc, char **argv, struct filterent * ofp)
+Parse(int argc, char const *const *argv, struct filterent * ofp)
{
int action, proto;
int val;
@@ -377,52 +387,47 @@ Parse(int argc, char **argv, struct filterent * ofp)
}
int
-SetIfilter(struct cmdtab *list, int argc, char **argv)
+SetIfilter(struct cmdargs const *arg)
{
- if (argc > 0) {
- (void) Parse(argc, argv, ifilters);
+ if (arg->argc > 0) {
+ Parse(arg->argc, arg->argv, ifilters);
return 0;
}
return -1;
}
int
-SetOfilter(struct cmdtab *list, int argc, char **argv)
+SetOfilter(struct cmdargs const *arg)
{
- if (argc > 0) {
- (void) Parse(argc, argv, ofilters);
+ if (arg->argc > 0) {
+ (void) Parse(arg->argc, arg->argv, ofilters);
return 0;
}
return -1;
}
int
-SetDfilter(struct cmdtab *list, int argc, char **argv)
+SetDfilter(struct cmdargs const *arg)
{
- if (argc > 0) {
- (void) Parse(argc, argv, dfilters);
+ if (arg->argc > 0) {
+ (void) Parse(arg->argc, arg->argv, dfilters);
return 0;
}
return -1;
}
int
-SetAfilter(struct cmdtab *list, int argc, char **argv)
+SetAfilter(struct cmdargs const *arg)
{
- if (argc > 0) {
- (void) Parse(argc, argv, afilters);
+ if (arg->argc > 0) {
+ (void) Parse(arg->argc, arg->argv, afilters);
return 0;
}
return -1;
}
-static char *protoname[] = {
- "none", "tcp", "udp", "icmp",
-};
-
-static char *actname[] = {
- "none ", "permit ", "deny ",
-};
+static const char *protoname[] = { "none", "tcp", "udp", "icmp" };
+static const char *actname[] = { "none ", "permit ", "deny " };
static void
ShowFilter(struct filterent * fp)
@@ -462,28 +467,28 @@ ShowFilter(struct filterent * fp)
}
int
-ShowIfilter(struct cmdtab * list, int argc, char **argv)
+ShowIfilter(struct cmdargs const *arg)
{
ShowFilter(ifilters);
return 0;
}
int
-ShowOfilter(struct cmdtab * list, int argc, char **argv)
+ShowOfilter(struct cmdargs const *arg)
{
ShowFilter(ofilters);
return 0;
}
int
-ShowDfilter(struct cmdtab * list, int argc, char **argv)
+ShowDfilter(struct cmdargs const *arg)
{
ShowFilter(dfilters);
return 0;
}
int
-ShowAfilter(struct cmdtab * list, int argc, char **argv)
+ShowAfilter(struct cmdargs const *arg)
{
ShowFilter(afilters);
return 0;
diff --git a/usr.sbin/ppp/filter.h b/usr.sbin/ppp/filter.h
index f4ea051b3a89..1342a996664f 100644
--- a/usr.sbin/ppp/filter.h
+++ b/usr.sbin/ppp/filter.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: filter.h,v 1.9 1997/08/25 00:29:11 brian Exp $
+ * $Id: filter.h,v 1.10 1997/10/26 01:02:35 brian Exp $
*
* TODO:
*/
@@ -76,12 +76,12 @@ extern struct filterent ofilters[MAXFILTERS]; /* outgoing packet filter */
extern struct filterent dfilters[MAXFILTERS]; /* dial-out packet filter */
extern struct filterent afilters[MAXFILTERS]; /* keep-alive packet filter */
-extern int ParseAddr(int, char **, struct in_addr *, struct in_addr *, int *);
-extern int ShowIfilter(struct cmdtab *, int, char **);
-extern int ShowOfilter(struct cmdtab *, int, char **);
-extern int ShowDfilter(struct cmdtab *, int, char **);
-extern int ShowAfilter(struct cmdtab *, int, char **);
-extern int SetIfilter(struct cmdtab *, int, char **);
-extern int SetOfilter(struct cmdtab *, int, char **);
-extern int SetDfilter(struct cmdtab *, int, char **);
-extern int SetAfilter(struct cmdtab *, int, char **);
+extern int ParseAddr(int, char const *const *, struct in_addr *, struct in_addr *, int *);
+extern int ShowIfilter(struct cmdargs const *);
+extern int ShowOfilter(struct cmdargs const *);
+extern int ShowDfilter(struct cmdargs const *);
+extern int ShowAfilter(struct cmdargs const *);
+extern int SetIfilter(struct cmdargs const *);
+extern int SetOfilter(struct cmdargs const *);
+extern int SetDfilter(struct cmdargs const *);
+extern int SetAfilter(struct cmdargs const *);
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c
index 1c787dbc4e19..7bf11eb3f332 100644
--- a/usr.sbin/ppp/fsm.c
+++ b/usr.sbin/ppp/fsm.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: fsm.c,v 1.20 1997/10/26 01:02:37 brian Exp $
+ * $Id: fsm.c,v 1.21 1997/11/11 23:23:11 brian Exp $
*
* TODO:
* o Refer loglevel for log output
@@ -30,6 +30,7 @@
#include <string.h>
#include <termios.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -42,7 +43,6 @@
#include "ccp.h"
#include "modem.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "pred.h"
@@ -64,8 +64,10 @@ char const *StateNames[] = {
};
static void
-StoppedTimeout(struct fsm * fp)
+StoppedTimeout(void *v)
{
+ struct fsm *fp = (struct fsm *)v;
+
LogPrintf(fp->LogLevel, "Stopped timer expired\n");
if (modem != -1)
DownConnection();
@@ -283,8 +285,10 @@ FsmSendConfigNak(struct fsm * fp,
* Timeout actions
*/
static void
-FsmTimeout(struct fsm * fp)
+FsmTimeout(void *v)
{
+ struct fsm *fp = (struct fsm *)v;
+
if (fp->restart) {
switch (fp->state) {
case ST_CLOSING:
diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h
index 901b9621ac33..3c30f893164b 100644
--- a/usr.sbin/ppp/fsm.h
+++ b/usr.sbin/ppp/fsm.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: fsm.h,v 1.10 1997/08/25 00:29:12 brian Exp $
+ * $Id: fsm.h,v 1.11 1997/10/26 01:02:39 brian Exp $
*
* TODO:
*/
@@ -46,7 +46,7 @@
#define OPEN_PASSIVE 1
struct fsm {
- char *name; /* Name of protocol */
+ const char *name; /* Name of protocol */
u_short proto; /* Protocol number */
u_short max_code;
int open_mode;
@@ -105,7 +105,7 @@ struct fsmheader {
struct fsmcodedesc {
void (*action) (struct fsm *, struct fsmheader *, struct mbuf *);
- char *name;
+ const char *name;
};
struct fsmconfig {
diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c
index ed33038cf527..d6fe49a5af87 100644
--- a/usr.sbin/ppp/hdlc.c
+++ b/usr.sbin/ppp/hdlc.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: hdlc.c,v 1.20 1997/10/26 01:02:43 brian Exp $
+ * $Id: hdlc.c,v 1.21 1997/10/26 12:42:10 brian Exp $
*
* TODO:
*/
@@ -28,6 +28,7 @@
#include <string.h>
#include <termios.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -41,9 +42,9 @@
#include "pap.h"
#include "chap.h"
#include "lcp.h"
+#include "async.h"
#include "lqr.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "pred.h"
#include "modem.h"
@@ -64,44 +65,22 @@ static int ifInOctets;
struct protostat {
u_short number;
- char *name;
+ const char *name;
u_long in_count;
u_long out_count;
} ProtocolStat[] = {
- {
- PROTO_IP, "IP"
- },
- {
- PROTO_VJUNCOMP, "VJ_UNCOMP"
- },
- {
- PROTO_VJCOMP, "VJ_COMP"
- },
- {
- PROTO_COMPD, "COMPD"
- },
- {
- PROTO_LCP, "LCP"
- },
- {
- PROTO_IPCP, "IPCP"
- },
- {
- PROTO_CCP, "CCP"
- },
- {
- PROTO_PAP, "PAP"
- },
- {
- PROTO_LQR, "LQR"
- },
- {
- PROTO_CHAP, "CHAP"
- },
- {
- 0, "Others"
- },
+ { PROTO_IP, "IP" },
+ { PROTO_VJUNCOMP, "VJ_UNCOMP" },
+ { PROTO_VJCOMP, "VJ_COMP" },
+ { PROTO_COMPD, "COMPD" },
+ { PROTO_LCP, "LCP" },
+ { PROTO_IPCP, "IPCP" },
+ { PROTO_CCP, "CCP" },
+ { PROTO_PAP, "PAP" },
+ { PROTO_LQR, "LQR" },
+ { PROTO_CHAP, "CHAP" },
+ { 0, "Others" }
};
static u_short const fcstab[256] = {
@@ -297,7 +276,7 @@ DecodePacket(u_short proto, struct mbuf * bp)
}
int
-ReportProtStatus()
+ReportProtStatus(struct cmdargs const *arg)
{
struct protostat *statp;
int cnt;
@@ -321,7 +300,7 @@ ReportProtStatus()
}
int
-ReportHdlcStatus()
+ReportHdlcStatus(struct cmdargs const *arg)
{
struct hdlcstat *hp = &HdlcStat;
diff --git a/usr.sbin/ppp/hdlc.h b/usr.sbin/ppp/hdlc.h
index 362d05c50503..3f14cc126383 100644
--- a/usr.sbin/ppp/hdlc.h
+++ b/usr.sbin/ppp/hdlc.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: hdlc.h,v 1.10 1997/08/25 00:29:13 brian Exp $
+ * $Id: hdlc.h,v 1.11 1997/10/26 01:02:45 brian Exp $
*
* TODO:
*/
@@ -61,8 +61,7 @@ extern void HdlcInit(void);
extern void HdlcErrorCheck(void);
extern void HdlcInput(struct mbuf *);
extern void HdlcOutput(int, u_short, struct mbuf *bp);
-extern void AsyncOutput(int, struct mbuf *, int);
extern u_short HdlcFcs(u_short, u_char *, int);
extern void DecodePacket(u_short, struct mbuf *);
-extern int ReportHdlcStatus(void);
-extern int ReportProtStatus(void);
+extern int ReportHdlcStatus(struct cmdargs const *);
+extern int ReportProtStatus(struct cmdargs const *);
diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c
index 4a3d6875ea49..b807688eba57 100644
--- a/usr.sbin/ppp/id.c
+++ b/usr.sbin/ppp/id.c
@@ -1,5 +1,5 @@
/*
- * $Id: id.c,v 1.1 1997/11/09 06:22:40 brian Exp $
+ * $Id: id.c,v 1.2 1997/11/13 17:31:52 brian Exp $
*/
#include <sys/types.h>
@@ -12,6 +12,7 @@
#include <sysexits.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "main.h"
@@ -37,7 +38,7 @@ ID0init()
}
static void
-ID0setuser()
+ID0setuser(void)
{
if (seteuid(uid) == -1) {
LogPrintf(LogERROR, "ID0setuser: Unable to seteuid!\n");
@@ -52,7 +53,7 @@ ID0realuid()
}
static void
-ID0set0()
+ID0set0(void)
{
if (seteuid(euid) == -1) {
LogPrintf(LogERROR, "ID0set0: Unable to seteuid!\n");
@@ -121,25 +122,25 @@ ID0open(const char *path, int flags)
}
int
-ID0uu_lock(const char *ttyname)
+ID0uu_lock(const char *basettyname)
{
int ret;
ID0set0();
- ret = uu_lock(ttyname);
- LogPrintf(LogID0, "%d = uu_lock(\"%s\")\n", ret, ttyname);
+ ret = uu_lock(basettyname);
+ LogPrintf(LogID0, "%d = uu_lock(\"%s\")\n", ret, basettyname);
ID0setuser();
return ret;
}
int
-ID0uu_unlock(const char *ttyname)
+ID0uu_unlock(const char *basettyname)
{
int ret;
ID0set0();
- ret = uu_unlock(ttyname);
- LogPrintf(LogID0, "%d = uu_unlock(\"%s\")\n", ret, ttyname);
+ ret = uu_unlock(basettyname);
+ LogPrintf(LogID0, "%d = uu_unlock(\"%s\")\n", ret, basettyname);
ID0setuser();
return ret;
}
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index ed27692f2d15..533798f99437 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ip.c,v 1.30 1997/11/16 22:15:03 brian Exp $
+ * $Id: ip.c,v 1.31 1997/11/18 14:52:04 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@@ -35,10 +35,14 @@
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <net/if.h>
+#ifdef __FreeBSD__
#include <net/if_var.h>
+#endif
#include <net/if_tun.h>
+#ifndef NOALIAS
#include <alias.h>
+#endif
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,6 +50,7 @@
#include <termios.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -54,10 +59,8 @@
#include "lcpproto.h"
#include "hdlc.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "filter.h"
-#include "log.h"
#include "os.h"
#include "ipcp.h"
#include "vjcomp.h"
@@ -69,7 +72,7 @@
static struct pppTimer IdleTimer;
static void
-IdleTimeout()
+IdleTimeout(void *v)
{
LogPrintf(LogPHASE, "Idle timer expired.\n");
reconnect(RECON_FALSE);
@@ -109,7 +112,7 @@ StopIdleTimer()
* If any IP layer traffic is detected, refresh IdleTimer.
*/
static void
-RestartIdleTimer()
+RestartIdleTimer(void)
{
if (!(mode & (MODE_DEDICATED | MODE_DDIAL)) && ipKeepAlive) {
StartTimer(&IdleTimer);
@@ -117,18 +120,16 @@ RestartIdleTimer()
}
}
-static u_short interactive_ports[32] = {
+static const u_short interactive_ports[32] = {
544, 513, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 21, 22, 23, 0, 0, 0, 0, 0, 0, 0, 543,
};
#define INTERACTIVE(p) (interactive_ports[(p) & 0x1F] == (p))
-static char *TcpFlags[] = {
- "FIN", "SYN", "RST", "PSH", "ACK", "URG",
-};
+static const char *TcpFlags[] = { "FIN", "SYN", "RST", "PSH", "ACK", "URG" };
-static char *Direction[] = {"INP", "OUT", "OUT", "IN/OUT"};
+static const char *Direction[] = {"INP", "OUT", "OUT", "IN/OUT"};
static struct filterent *Filters[] = {ifilters, ofilters, dfilters, afilters};
static int
@@ -376,7 +377,7 @@ IpInput(struct mbuf * bp)
u_char *cp;
struct mbuf *wp;
int nb, nw;
- struct tun_data tun, *frag;
+ struct tun_data tun;
tun_fill_header(tun, AF_INET);
cp = tun.data;
@@ -387,7 +388,9 @@ IpInput(struct mbuf * bp)
nb += wp->cnt;
}
+#ifndef NOALIAS
if (mode & MODE_ALIAS) {
+ struct tun_data *frag;
int iresult;
char *fptr;
@@ -445,7 +448,9 @@ IpInput(struct mbuf * bp)
VarPacketAliasSaveFragment(frag->data);
}
}
- } else { /* no aliasing */
+ } else
+#endif /* #ifndef NOALIAS */
+ { /* no aliasing */
if (PacketCheck(tun.data, nb, FL_IN) < 0) {
pfree(bp);
return;
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
index 7f93f14a77ff..6e6a4c2a7b7e 100644
--- a/usr.sbin/ppp/ipcp.c
+++ b/usr.sbin/ppp/ipcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.c,v 1.36 1997/11/14 15:39:14 brian Exp $
+ * $Id: ipcp.c,v 1.37 1997/11/18 14:52:04 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@@ -36,6 +36,7 @@
#include <time.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -48,7 +49,6 @@
#include "os.h"
#include "phase.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "vjcomp.h"
#include "ip.h"
@@ -101,7 +101,7 @@ struct fsm IpcpFsm = {
IpcpDecodeConfig,
};
-static char *cftypes[] = {
+static const char *cftypes[] = {
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
"???",
"IPADDRS", /* 1: IP-Addresses */ /* deprecated */
@@ -111,7 +111,7 @@ static char *cftypes[] = {
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
-static char *cftypes128[] = {
+static const char *cftypes128[] = {
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
"???",
"PRIDNS", /* 129: Primary DNS Server Address */
@@ -137,7 +137,7 @@ IpcpAddOutOctets(int n)
}
int
-ReportIpcpStatus()
+ReportIpcpStatus(struct cmdargs const *arg)
{
struct ipcpstate *icp = &IpcpInfo;
struct fsm *fp = &IpcpFsm;
@@ -303,8 +303,10 @@ IpcpLayerUp(struct fsm * fp)
LogPrintf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
return;
}
+#ifndef NOALIAS
if (mode & MODE_ALIAS)
VarPacketAliasSetAddress(IpcpInfo.want_ipaddr);
+#endif
OsLinkup();
throughput_start(&throughput);
StartIdleTimer();
diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h
index 598566c17349..9d65e8e4c37e 100644
--- a/usr.sbin/ppp/ipcp.h
+++ b/usr.sbin/ppp/ipcp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.h,v 1.12 1997/10/26 12:42:11 brian Exp $
+ * $Id: ipcp.h,v 1.13 1997/11/18 14:52:05 brian Exp $
*
* TODO:
*/
@@ -68,13 +68,12 @@ extern struct in_range DefHisAddress;
extern struct in_addr TriggerAddress;
extern int HaveTriggerAddress;
extern struct fsm IpcpFsm;
-extern struct pppTimer IpcpReportTimer;
extern void IpcpInit(void);
extern void IpcpDefAddress(void);
extern void IpcpUp(void);
extern void IpcpOpen(void);
-extern int ReportIpcpStatus(void);
+extern int ReportIpcpStatus(struct cmdargs const *);
extern void IpcpInput(struct mbuf *);
extern void IpcpAddInOctets(int);
extern void IpcpAddOutOctets(int);
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index 513dbfc2148e..5bca8539e239 100644
--- a/usr.sbin/ppp/lcp.c
+++ b/usr.sbin/ppp/lcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lcp.c,v 1.46 1997/11/16 22:15:04 brian Exp $
+ * $Id: lcp.c,v 1.47 1997/11/18 14:52:05 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
@@ -30,7 +30,9 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
+#ifdef __FreeBSD__
#include <net/if_var.h>
+#endif
#include <net/if_tun.h>
#include <signal.h>
@@ -41,6 +43,7 @@
#include <termios.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -55,7 +58,6 @@
#include "lqr.h"
#include "phase.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "auth.h"
#include "pap.h"
@@ -80,7 +82,7 @@ static void LcpLayerFinish(struct fsm *);
#define REJECTED(p, x) (p->his_reject & (1<<x))
-static char *cftypes[] = {
+static const char *cftypes[] = {
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
"???",
"MRU", /* 1: Maximum-Receive-Unit */
@@ -137,7 +139,7 @@ static struct pppTimer LcpReportTimer;
static int LcpFailedMagic;
static void
-LcpReportTime()
+LcpReportTime(void *data)
{
if (LogIsKept(LogDEBUG)) {
time_t t;
@@ -152,7 +154,7 @@ LcpReportTime()
}
int
-ReportLcpStatus()
+ReportLcpStatus(struct cmdargs const *arg)
{
struct lcpstate *lcp = &LcpInfo;
struct fsm *fp = &LcpFsm;
@@ -180,7 +182,7 @@ ReportLcpStatus()
* Generate random number which will be used as magic number.
*/
static u_long
-GenerateMagic()
+GenerateMagic(void)
{
randinit();
return (random());
@@ -222,8 +224,8 @@ LcpInitRestartCounter(struct fsm * fp)
}
void
-PutConfValue(int level, u_char ** cpp, char **types, u_char type, int len,
- u_long val)
+PutConfValue(int level, u_char ** cpp, const char **types, u_char type,
+ int len, u_long val)
{
u_char *cp;
struct in_addr ina;
@@ -329,7 +331,7 @@ LcpLayerStart(struct fsm * fp)
}
static void
-StopAllTimers()
+StopAllTimers(void)
{
StopTimer(&LcpReportTimer);
StopIdleTimer();
@@ -420,7 +422,7 @@ LcpClose()
static void
LcpDecodeConfig(u_char * cp, int plen, int mode_type)
{
- char *request;
+ const char *request;
int type, length, mru, mtu;
u_long *lp, magic, accmap;
u_short *sp, proto;
diff --git a/usr.sbin/ppp/lcp.h b/usr.sbin/ppp/lcp.h
index e3b67b2140a3..ea5388c5ddcc 100644
--- a/usr.sbin/ppp/lcp.h
+++ b/usr.sbin/ppp/lcp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lcp.h,v 1.11 1997/11/08 00:28:08 brian Exp $
+ * $Id: lcp.h,v 1.12 1997/11/14 15:39:15 brian Exp $
*
* TODO:
*/
@@ -73,6 +73,6 @@ extern void LcpSendProtoRej(u_char *, int);
extern void LcpOpen(int);
extern void LcpClose(void);
extern void LcpDown(void);
-extern void PutConfValue(int, u_char **, char **, u_char, int, u_long);
-extern int ReportLcpStatus(void);
+extern void PutConfValue(int, u_char **, const char **, u_char, int, u_long);
+extern int ReportLcpStatus(struct cmdargs const *);
extern void LcpInput(struct mbuf *);
diff --git a/usr.sbin/ppp/loadalias.c b/usr.sbin/ppp/loadalias.c
index 6435f7248095..fb59ea887653 100644
--- a/usr.sbin/ppp/loadalias.c
+++ b/usr.sbin/ppp/loadalias.c
@@ -1,5 +1,5 @@
/*
- * $Id: loadalias.c,v 1.9 1997/11/09 06:22:41 brian Exp $
+ * $Id: loadalias.c,v 1.10 1997/11/09 14:18:40 brian Exp $
*/
#include <sys/param.h>
@@ -13,9 +13,9 @@
#include <unistd.h>
#include "command.h"
-#include "systems.h"
#include "mbuf.h"
#include "log.h"
+#include "systems.h"
#include "id.h"
#include "loadalias.h"
#include "defs.h"
@@ -28,7 +28,7 @@
static struct {
int offset;
- char *name;
+ const char *name;
} map[] = {
entry(PacketAliasGetFragment),
entry(PacketAliasInit),
@@ -48,8 +48,8 @@ static void *dl;
int
loadAliasHandlers(struct aliasHandlers * h)
{
- char *path;
- char *env;
+ const char *path;
+ const char *env;
int i;
path = _PATH_ALIAS;
diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c
index 4afa158e35b2..7bbd5891e992 100644
--- a/usr.sbin/ppp/log.c
+++ b/usr.sbin/ppp/log.c
@@ -1,5 +1,5 @@
/*
- * $Id: log.c,v 1.20 1997/11/09 14:18:41 brian Exp $
+ * $Id: log.c,v 1.21 1997/11/11 12:26:34 brian Exp $
*/
#include <sys/param.h>
@@ -10,14 +10,14 @@
#include <stdio.h>
#include <syslog.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
-#include "command.h"
#include "defs.h"
#include "vars.h"
-static char *LogNames[] = {
+static const char *LogNames[] = {
"Async",
"Carrier",
"CCP",
@@ -138,7 +138,7 @@ LogClose()
}
void
-LogPrintf(int lev, char *fmt,...)
+LogPrintf(int lev, const char *fmt,...)
{
va_list ap;
@@ -169,7 +169,7 @@ LogPrintf(int lev, char *fmt,...)
}
void
-LogDumpBp(int lev, char *hdr, struct mbuf * bp)
+LogDumpBp(int lev, const char *hdr, const struct mbuf * bp)
{
if (LogIsKept(lev)) {
char buf[50];
@@ -203,7 +203,7 @@ LogDumpBp(int lev, char *hdr, struct mbuf * bp)
}
void
-LogDumpBuff(int lev, char *hdr, u_char * ptr, int n)
+LogDumpBuff(int lev, const char *hdr, const u_char * ptr, int n)
{
if (LogIsKept(lev)) {
char buf[50];
diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h
index d7fefa07866a..7a84512a84b5 100644
--- a/usr.sbin/ppp/log.h
+++ b/usr.sbin/ppp/log.h
@@ -1,5 +1,5 @@
/*
- * $Id: log.h,v 1.15 1997/11/04 01:17:01 brian Exp $
+ * $Id: log.h,v 1.16 1997/11/09 06:22:42 brian Exp $
*/
#define LogMIN (1)
@@ -39,6 +39,6 @@ extern int LogIsKept(int);
extern void LogOpen(const char *);
extern void LogSetTun(int);
extern void LogClose(void);
-extern void LogPrintf(int, char *,...);
-extern void LogDumpBp(int, char *, struct mbuf *);
-extern void LogDumpBuff(int, char *, u_char *, int);
+extern void LogPrintf(int, const char *,...);
+extern void LogDumpBp(int, const char *, const struct mbuf *);
+extern void LogDumpBuff(int, const char *, const u_char *, int);
diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c
index fa60c5d144e2..bf1bf5d7292d 100644
--- a/usr.sbin/ppp/lqr.c
+++ b/usr.sbin/ppp/lqr.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lqr.c,v 1.18 1997/08/31 22:59:35 brian Exp $
+ * $Id: lqr.c,v 1.19 1997/10/26 01:03:08 brian Exp $
*
* o LQR based on RFC1333
*
@@ -30,6 +30,7 @@
#include <stdio.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -40,7 +41,6 @@
#include "hdlc.h"
#include "lcp.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "main.h"
@@ -62,7 +62,7 @@ struct echolqr {
#define SIGNATURE 0x594e4f54
static void
-SendEchoReq()
+SendEchoReq(void)
{
struct fsm *fp = &LcpFsm;
struct echolqr *lqr, lqrdata;
@@ -107,7 +107,7 @@ LqrChangeOrder(struct lqrdata * src, struct lqrdata * dst)
}
static void
-SendLqrReport()
+SendLqrReport(void *v)
{
struct mbuf *bp;
@@ -182,7 +182,7 @@ LqrInput(struct mbuf * bp)
*/
if (LqrTimer.load == 0 || lastpeerin == HisLqrData.PeerInLQRs) {
lqmmethod |= LQM_LQR;
- SendLqrReport();
+ SendLqrReport(0);
}
lastpeerin = HisLqrData.PeerInLQRs;
}
@@ -218,7 +218,7 @@ StartLqm()
LqrTimer.state = TIMER_STOPPED;
LqrTimer.load = period * SECTICKS / 100;
LqrTimer.func = SendLqrReport;
- SendLqrReport();
+ SendLqrReport(0);
StartTimer(&LqrTimer);
LogPrintf(LogLQM, "Will send LQR every %d.%d secs\n",
period / 100, period % 100);
@@ -244,13 +244,13 @@ StopLqr(int method)
LogPrintf(LogLQM, "Stop sending LCP ECHO.\n");
lqmmethod &= ~method;
if (lqmmethod)
- SendLqrReport();
+ SendLqrReport(0);
else
StopTimer(&LqrTimer);
}
void
-LqrDump(char *message, struct lqrdata * lqr)
+LqrDump(const char *message, const struct lqrdata * lqr)
{
if (LogIsKept(LogLQM)) {
LogPrintf(LogLQM, "%s:\n", message);
diff --git a/usr.sbin/ppp/lqr.h b/usr.sbin/ppp/lqr.h
index fa784e5d2302..7225fdb886c4 100644
--- a/usr.sbin/ppp/lqr.h
+++ b/usr.sbin/ppp/lqr.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lqr.h,v 1.8 1997/10/26 01:03:10 brian Exp $
+ * $Id: lqr.h,v 1.9 1997/10/26 12:42:12 brian Exp $
*
* TODO:
*/
@@ -55,7 +55,7 @@ struct lqrsave HisLqrSave;
#define LQM_LQR 1
#define LQM_ECHO 2
-extern void LqrDump(char *, struct lqrdata *);
+extern void LqrDump(const char *, const struct lqrdata *);
extern void LqrChangeOrder(struct lqrdata *, struct lqrdata *);
extern void StartLqm(void);
extern void StopLqr(int);
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index f9bbebc362c7..10add86e79fe 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.103 1997/11/18 07:33:23 brian Exp $
+ * $Id: main.c,v 1.104 1997/11/18 18:17:25 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -33,7 +33,9 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
+#ifdef __FreeBSD__
#include <net/if_var.h>
+#endif
#include <net/if_tun.h>
#include <errno.h>
@@ -49,6 +51,7 @@
#include <termios.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -62,7 +65,6 @@
#include "lcp.h"
#include "ipcp.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "auth.h"
#include "filter.h"
@@ -76,6 +78,7 @@
#include "async.h"
#include "pathnames.h"
#include "tun.h"
+#include "route.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
@@ -94,7 +97,7 @@ static int dial_up;
static void DoLoop(void);
static void TerminalStop(int);
-static char *ex_desc(int);
+static const char *ex_desc(int);
static void
TtyInit(int DontWantInt)
@@ -230,7 +233,7 @@ CloseSession(int signo)
}
static void
-TerminalCont()
+TerminalCont(int signo)
{
pending_signal(SIGCONT, SIG_DFL);
pending_signal(SIGTSTP, TerminalStop);
@@ -266,13 +269,14 @@ BringDownServer(int signo)
ServerClose();
}
-static char *
+static const char *
ex_desc(int ex)
{
static char num[12];
- static char *desc[] = {"normal", "start", "sock",
- "modem", "dial", "dead", "done", "reboot", "errdead",
- "hangup", "term", "nodial", "nologin"};
+ static const char *desc[] = {
+ "normal", "start", "sock", "modem", "dial", "dead", "done",
+ "reboot", "errdead", "hangup", "term", "nodial", "nologin"
+ };
if (ex >= 0 && ex < sizeof(desc) / sizeof(*desc))
return desc[ex];
@@ -281,10 +285,14 @@ ex_desc(int ex)
}
static void
-Usage()
+Usage(void)
{
fprintf(stderr,
- "Usage: ppp [-auto | -background | -direct | -dedicated | -ddial ] [ -alias ] [system]\n");
+ "Usage: ppp [-auto | -background | -direct | -dedicated | -ddial ]"
+#ifndef NOALIAS
+ " [ -alias ]"
+#endif
+ " [system]\n");
exit(EX_START);
}
@@ -313,12 +321,14 @@ ProcessArgs(int argc, char **argv)
} else if (strcmp(cp, "ddial") == 0) {
mode |= MODE_DDIAL;
mode &= ~MODE_INTER;
+#ifndef NOALIAS
} else if (strcmp(cp, "alias") == 0) {
if (loadAliasHandlers(&VarAliasHandlers) == 0)
mode |= MODE_ALIAS;
else
LogPrintf(LogWARN, "Cannot load alias library\n");
optc--; /* this option isn't exclusive */
+#endif
} else
Usage();
optc++;
@@ -339,7 +349,7 @@ ProcessArgs(int argc, char **argv)
}
static void
-Greetings()
+Greetings(void)
{
if (VarTerm) {
fprintf(VarTerm, "User Process PPP. Written by Toshiharu OHNO.\n");
@@ -572,7 +582,7 @@ PacketMode()
}
static void
-ShowHelp()
+ShowHelp(void)
{
fprintf(stderr, "The following commands are available:\r\n");
fprintf(stderr, " ~p\tEnter Packet mode\r\n");
@@ -585,7 +595,7 @@ ShowHelp()
}
static void
-ReadTty()
+ReadTty(void)
{
int n;
char ch;
@@ -649,7 +659,7 @@ ReadTty()
}
case 'm':
if (LogIsKept(LogDEBUG)) {
- ShowMemMap();
+ ShowMemMap(NULL);
break;
}
default:
@@ -668,7 +678,7 @@ ReadTty()
* Here, we'll try to detect HDLC frame
*/
-static char *FrameHeaders[] = {
+static const char *FrameHeaders[] = {
"\176\377\003\300\041",
"\176\377\175\043\300\041",
"\176\177\175\043\100\041",
@@ -677,10 +687,10 @@ static char *FrameHeaders[] = {
NULL,
};
-static u_char *
+static const u_char *
HdlcDetect(u_char * cp, int n)
{
- char *ptr, *fp, **hp;
+ const char *ptr, *fp, **hp;
cp[n] = '\0'; /* be sure to null terminated */
ptr = NULL;
@@ -692,13 +702,13 @@ HdlcDetect(u_char * cp, int n)
if (ptr)
break;
}
- return ((u_char *) ptr);
+ return ((const u_char *) ptr);
}
static struct pppTimer RedialTimer;
static void
-RedialTimeout()
+RedialTimeout(void *v)
{
StopTimer(&RedialTimer);
LogPrintf(LogPHASE, "Redialing timer expired.\n");
@@ -727,14 +737,14 @@ StartRedialTimer(int Timeout)
static void
-DoLoop()
+DoLoop(void)
{
fd_set rfds, wfds, efds;
int pri, i, n, wfd, nfds;
struct sockaddr_in hisaddr;
struct timeval timeout, *tp;
int ssize = sizeof(hisaddr);
- u_char *cp;
+ const u_char *cp;
int tries;
int qlen;
int res;
@@ -835,7 +845,7 @@ DoLoop()
if ((res = DialModem()) == EX_DONE) {
nointr_sleep(1); /* little pause to allow peer starts */
- ModemTimeout();
+ ModemTimeout(NULL);
PacketMode();
dial_up = 0;
reconnectState = RECON_UNKNOWN;
@@ -1031,10 +1041,12 @@ DoLoop()
if (pri >= 0) {
struct mbuf *bp;
+#ifndef NOALIAS
if (mode & MODE_ALIAS) {
VarPacketAliasIn(rbuff, sizeof rbuff);
n = ntohs(((struct ip *) rbuff)->ip_len);
}
+#endif
bp = mballoc(n, MB_IPIN);
memcpy(MBUF_CTOP(bp), rbuff, n);
IpInput(bp);
@@ -1052,10 +1064,12 @@ DoLoop()
if (LcpFsm.state <= ST_CLOSED && (mode & MODE_AUTO)) {
pri = PacketCheck(rbuff, n, FL_DIAL);
if (pri >= 0) {
+#ifndef NOALIAS
if (mode & MODE_ALIAS) {
VarPacketAliasOut(rbuff, sizeof rbuff);
n = ntohs(((struct ip *) rbuff)->ip_len);
}
+#endif
IpEnqueue(pri, rbuff, n);
dial_up = 1; /* XXX */
}
@@ -1063,10 +1077,12 @@ DoLoop()
}
pri = PacketCheck(rbuff, n, FL_OUT);
if (pri >= 0) {
+#ifndef NOALIAS
if (mode & MODE_ALIAS) {
VarPacketAliasOut(rbuff, sizeof rbuff);
n = ntohs(((struct ip *) rbuff)->ip_len);
}
+#endif
IpEnqueue(pri, rbuff, n);
}
}
diff --git a/usr.sbin/ppp/main.h b/usr.sbin/ppp/main.h
index 37820de8ea18..87512a6cb8d7 100644
--- a/usr.sbin/ppp/main.h
+++ b/usr.sbin/ppp/main.h
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.h,v 1.6 1997/09/25 00:52:35 brian Exp $
+ * $Id: main.h,v 1.7 1997/10/26 01:03:15 brian Exp $
*
*/
@@ -28,5 +28,4 @@ extern void Cleanup(int);
extern void TtyTermMode(void);
extern void PacketMode(void);
extern void TtyOldMode(void);
-extern void TtyTermMode(void);
extern void TtyCommandMode(int);
diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c
index 8a86e9092e3e..258133dbb82b 100644
--- a/usr.sbin/ppp/mbuf.c
+++ b/usr.sbin/ppp/mbuf.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: mbuf.c,v 1.9 1997/08/25 00:29:20 brian Exp $
+ * $Id: mbuf.c,v 1.10 1997/10/26 01:03:16 brian Exp $
*
*/
#include <sys/param.h>
@@ -28,11 +28,11 @@
#include <stdlib.h>
#include <string.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "server.h"
@@ -150,7 +150,7 @@ mbwrite(struct mbuf * bp, u_char * ptr, int cnt)
}
int
-ShowMemMap()
+ShowMemMap(struct cmdargs const *arg)
{
int i;
diff --git a/usr.sbin/ppp/mbuf.h b/usr.sbin/ppp/mbuf.h
index b7a246d7f6b5..cdf38afbf444 100644
--- a/usr.sbin/ppp/mbuf.h
+++ b/usr.sbin/ppp/mbuf.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: mbuf.h,v 1.7 1997/10/26 01:03:18 brian Exp $
+ * $Id: mbuf.h,v 1.8 1997/10/26 12:42:13 brian Exp $
*
* TODO:
*/
@@ -60,4 +60,4 @@ extern void mbwrite(struct mbuf *, u_char *, int);
extern struct mbuf *mbread(struct mbuf *, u_char *, int);
extern void DumpBp(struct mbuf *);
extern void LogMemory(void);
-extern int ShowMemMap(void);
+extern int ShowMemMap(struct cmdargs const *);
diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c
index 67d0ee061ddf..cef758dc457e 100644
--- a/usr.sbin/ppp/modem.c
+++ b/usr.sbin/ppp/modem.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: modem.c,v 1.65 1997/11/18 08:49:03 brian Exp $
+ * $Id: modem.c,v 1.66 1997/11/18 14:52:06 brian Exp $
*
* TODO:
*/
@@ -40,6 +40,7 @@
#include <unistd.h>
#include <utmp.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -51,7 +52,6 @@
#include "ip.h"
#include "modem.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "main.h"
#include "chat.h"
@@ -232,7 +232,7 @@ DownConnection()
*
*/
void
-ModemTimeout()
+ModemTimeout(void *data)
{
int ombits = mbits;
int change;
@@ -275,7 +275,7 @@ ModemTimeout()
}
static void
-StartModemTimer()
+StartModemTimer(void)
{
StopTimer(&ModemTimer);
ModemTimer.state = TIMER_STOPPED;
@@ -286,25 +286,18 @@ StartModemTimer()
}
struct parity {
- char *name;
- char *name1;
+ const char *name;
+ const char *name1;
int set;
-} validparity[] = {
-
- {
- "even", "P_EVEN", CS7 | PARENB
- }, {
- "odd", "P_ODD", CS7 | PARENB | PARODD
- },
- {
- "none", "P_ZERO", CS8
- }, {
- NULL, 0
- },
+} validparity[] = {
+ { "even", "P_EVEN", CS7 | PARENB },
+ { "odd", "P_ODD", CS7 | PARENB | PARODD },
+ { "none", "P_ZERO", CS8 },
+ { NULL, 0 },
};
static int
-GetParityValue(char *str)
+GetParityValue(const char *str)
{
struct parity *pp;
@@ -318,7 +311,7 @@ GetParityValue(char *str)
}
int
-ChangeParity(char *str)
+ChangeParity(const char *str)
{
struct termios rstio;
int val;
@@ -382,7 +375,7 @@ OpenConnection(char *host, char *port)
static char fn[MAXPATHLEN];
static int
-LockModem()
+LockModem(void)
{
int res;
FILE *lockfile;
@@ -411,7 +404,7 @@ LockModem()
}
static void
-UnlockModem()
+UnlockModem(void)
{
if (*VarDevice != '/')
return;
@@ -425,7 +418,7 @@ UnlockModem()
}
static void
-HaveModem()
+HaveModem(void)
{
throughput_start(&throughput);
connect_count++;
@@ -439,16 +432,22 @@ OpenModem()
{
struct termios rstio;
int oldflag;
- char *host, *cp, *port;
+ char *host, *port;
+ char *cp;
if (modem >= 0)
LogPrintf(LogDEBUG, "OpenModem: Modem is already open!\n");
/* We're going back into "term" mode */
else if (mode & MODE_DIRECT) {
+ struct cmdargs arg;
+ arg.cmd = NULL;
+ arg.data = (const void *)VAR_DEVICE;
if (isatty(0)) {
LogPrintf(LogDEBUG, "OpenModem(direct): Modem is a tty\n");
cp = ttyname(0);
- SetVariable(0, 1, &cp, VAR_DEVICE);
+ arg.argc = 1;
+ arg.argv = (char const *const *)&cp;
+ SetVariable(&arg);
if (LockModem() == -1) {
close(0);
return -1;
@@ -457,7 +456,9 @@ OpenModem()
HaveModem();
} else {
LogPrintf(LogDEBUG, "OpenModem(direct): Modem is not a tty\n");
- SetVariable(0, 0, 0, VAR_DEVICE);
+ arg.argc = 0;
+ arg.argv = NULL;
+ SetVariable(&arg);
/* We don't call ModemTimeout() with this type of connection */
HaveModem();
return modem = 0;
@@ -479,7 +480,7 @@ OpenModem()
/* PPP over TCP */
cp = strchr(VarDevice, ':');
if (cp) {
- *cp = 0;
+ *cp = '\0';
host = VarDevice;
port = cp + 1;
if (*host && *port) {
@@ -608,7 +609,7 @@ RawModem()
}
static void
-UnrawModem()
+UnrawModem(void)
{
int oldflag;
@@ -634,7 +635,7 @@ ModemAddOutOctets(int n)
}
static void
-ClosePhysicalModem()
+ClosePhysicalModem(void)
{
LogPrintf(LogDEBUG, "ClosePhysicalModem\n");
close(modem);
@@ -699,7 +700,7 @@ HangupModem(int flag)
}
static void
-CloseLogicalModem()
+CloseLogicalModem(void)
{
LogPrintf(LogDEBUG, "CloseLogicalModem\n");
if (modem >= 0) {
@@ -724,7 +725,7 @@ CloseLogicalModem()
* to the line when ModemStartOutput() is called.
*/
void
-WriteModem(int pri, char *ptr, int count)
+WriteModem(int pri, const char *ptr, int count)
{
struct mbuf *bp;
@@ -842,7 +843,7 @@ DialModem()
LogPrintf(LogWARN, "DialModem: login failed.\n");
excode = EX_NOLOGIN;
}
- ModemTimeout(); /* Dummy call to check modem status */
+ ModemTimeout(NULL); /* Dummy call to check modem status */
} else if (excode == -1)
excode = EX_SIG;
else {
@@ -854,9 +855,9 @@ DialModem()
}
int
-ShowModemStatus()
+ShowModemStatus(struct cmdargs const *arg)
{
- char *dev;
+ const char *dev;
#ifdef TIOCOUTQ
int nb;
#endif
diff --git a/usr.sbin/ppp/modem.h b/usr.sbin/ppp/modem.h
index 43541fa262aa..fae70e5aa7d9 100644
--- a/usr.sbin/ppp/modem.h
+++ b/usr.sbin/ppp/modem.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: modem.h,v 1.12 1997/10/29 01:19:45 brian Exp $
+ * $Id: modem.h,v 1.13 1997/11/08 00:28:10 brian Exp $
*
* TODO:
*/
@@ -23,19 +23,19 @@
extern int RawModem(void);
extern void UpModem(int);
extern void DownModem(int);
-extern void WriteModem(int, char *, int);
+extern void WriteModem(int, const char *, int);
extern void ModemStartOutput(int);
extern int OpenModem(void);
extern int ModemSpeed(void);
extern int ModemQlen(void);
extern int DialModem(void);
extern speed_t IntToSpeed(int);
-extern void ModemTimeout(void);
+extern void ModemTimeout(void *v);
extern void DownConnection(void);
extern void ModemOutput(int, struct mbuf *);
-extern int ChangeParity(char *);
+extern int ChangeParity(const char *);
extern void HangupModem(int);
-extern int ShowModemStatus(void);
+extern int ShowModemStatus(struct cmdargs const *);
extern void Enqueue(struct mqueue *, struct mbuf *);
extern struct mbuf *Dequeue(struct mqueue *);
extern void ModemAddInOctets(int);
diff --git a/usr.sbin/ppp/nat_cmd.c b/usr.sbin/ppp/nat_cmd.c
index 4b91898a2cd3..acd801e9680d 100644
--- a/usr.sbin/ppp/nat_cmd.c
+++ b/usr.sbin/ppp/nat_cmd.c
@@ -1,5 +1,5 @@
/*
- * $Id: $
+ * $Id: alias_cmd.c,v 1.6 1997/10/26 01:02:00 brian Exp $
*/
#include <sys/param.h>
@@ -13,29 +13,29 @@
#include <stdlib.h>
#include <string.h>
-#include "mbuf.h"
-#include "log.h"
#include "defs.h"
#include "command.h"
+#include "mbuf.h"
+#include "log.h"
#include "loadalias.h"
#include "vars.h"
#include "alias_cmd.h"
-static int StrToAddr(char *, struct in_addr *);
-static int StrToPort(char *, u_short *, char *);
-static int StrToAddrAndPort(char *, struct in_addr *, u_short *, char *);
+static int StrToAddr(const char *, struct in_addr *);
+static int StrToPort(const char *, u_short *, const char *);
+static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, const char *);
int
-AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
+AliasRedirectPort(struct cmdargs const *arg)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
fprintf(VarTerm, "Alias not enabled\n");
- } else if (argc == 3) {
+ } else if (arg->argc == 3) {
char proto_constant;
- char *proto;
+ const char *proto;
u_short local_port;
u_short alias_port;
int error;
@@ -43,7 +43,7 @@ AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
struct in_addr null_addr;
struct alias_link *link;
- proto = argv[0];
+ proto = arg->argv[0];
if (strcmp(proto, "tcp") == 0) {
proto_constant = IPPROTO_TCP;
} else if (strcmp(proto, "udp") == 0) {
@@ -51,25 +51,25 @@ AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
} else {
if (VarTerm) {
fprintf(VarTerm, "port redirect: protocol must be tcp or udp\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name,
- list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name,
+ arg->cmd->syntax);
}
return 1;
}
- error = StrToAddrAndPort(argv[1], &local_addr, &local_port, proto);
+ error = StrToAddrAndPort(arg->argv[1], &local_addr, &local_port, proto);
if (error) {
if (VarTerm) {
fprintf(VarTerm, "port redirect: error reading local addr:port\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
return 1;
}
- error = StrToPort(argv[2], &alias_port, proto);
+ error = StrToPort(arg->argv[2], &alias_port, proto);
if (error) {
if (VarTerm) {
fprintf(VarTerm, "port redirect: error reading alias port\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
return 1;
}
@@ -84,52 +84,52 @@ AliasRedirectPort(struct cmdtab *list, int argc, char **argv, void *param)
fprintf(VarTerm, "port redirect: error returned by packed"
" aliasing engine (code=%d)\n", error);
} else if (VarTerm)
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
return 1;
}
int
-AliasRedirectAddr(struct cmdtab *list, int argc, char **argv, void *param)
+AliasRedirectAddr(struct cmdargs const *arg)
{
if (!(mode & MODE_ALIAS)) {
if (VarTerm)
fprintf(VarTerm, "alias not enabled\n");
- } else if (argc == 2) {
+ } else if (arg->argc == 2) {
int error;
struct in_addr local_addr;
struct in_addr alias_addr;
struct alias_link *link;
- error = StrToAddr(argv[0], &local_addr);
+ error = StrToAddr(arg->argv[0], &local_addr);
if (error) {
if (VarTerm)
fprintf(VarTerm, "address redirect: invalid local address\n");
return 1;
}
- error = StrToAddr(argv[1], &alias_addr);
+ error = StrToAddr(arg->argv[1], &alias_addr);
if (error) {
if (VarTerm) {
fprintf(VarTerm, "address redirect: invalid alias address\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
return 1;
}
link = VarPacketAliasRedirectAddr(local_addr, alias_addr);
if (link == NULL && VarTerm) {
fprintf(VarTerm, "address redirect: packet aliasing engine error\n");
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
}
} else if (VarTerm)
- fprintf(VarTerm, "Usage: alias %s %s\n", list->name, list->syntax);
+ fprintf(VarTerm, "Usage: alias %s %s\n", arg->cmd->name, arg->cmd->syntax);
return 1;
}
static int
-StrToAddr(char *str, struct in_addr *addr)
+StrToAddr(const char *str, struct in_addr *addr)
{
struct hostent *hp;
@@ -147,7 +147,7 @@ StrToAddr(char *str, struct in_addr *addr)
static int
-StrToPort(char *str, u_short *port, char *proto)
+StrToPort(const char *str, u_short *port, const char *proto)
{
int iport;
struct servent *sp;
@@ -169,22 +169,23 @@ StrToPort(char *str, u_short *port, char *proto)
}
-int
-StrToAddrAndPort(char *str, struct in_addr *addr, u_short *port, char *proto)
+static int
+StrToAddrAndPort(const char *str, struct in_addr *addr, u_short *port, const char *proto)
{
- char *ptr;
+ char *colon;
+ int res;
- ptr = strchr(str, ':');
- if (!ptr) {
- LogPrintf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n",
- str);
+ colon = strchr(str, ':');
+ if (!colon) {
+ LogPrintf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str);
return -1;
}
- *ptr = '\0';
- ++ptr;
- if (StrToAddr(str, addr) != 0)
+ *colon = '\0'; /* Cheat the const-ness ! */
+ res = StrToAddr(str, addr);
+ *colon = ':'; /* Cheat the const-ness ! */
+ if (res != 0)
return -1;
- return StrToPort(ptr, port, proto);
+ return StrToPort(colon+1, port, proto);
}
diff --git a/usr.sbin/ppp/nat_cmd.h b/usr.sbin/ppp/nat_cmd.h
index 49b15322de61..87a2026be2fd 100644
--- a/usr.sbin/ppp/nat_cmd.h
+++ b/usr.sbin/ppp/nat_cmd.h
@@ -1,6 +1,6 @@
/*
- * $Id: $
+ * $Id: alias_cmd.h,v 1.3 1997/10/26 01:02:01 brian Exp $
*/
-extern int AliasRedirectPort(struct cmdtab *, int, char **, void *);
-extern int AliasRedirectAddr(struct cmdtab *, int, char **, void *);
+extern int AliasRedirectPort(struct cmdargs const *);
+extern int AliasRedirectAddr(struct cmdargs const *);
diff --git a/usr.sbin/ppp/os.c b/usr.sbin/ppp/os.c
index 95c66f056ff7..025a24e16112 100644
--- a/usr.sbin/ppp/os.c
+++ b/usr.sbin/ppp/os.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: os.c,v 1.33 1997/11/13 12:09:57 brian Exp $
+ * $Id: os.c,v 1.34 1997/11/16 22:15:07 brian Exp $
*
*/
#include <sys/param.h>
@@ -26,7 +26,9 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
+#ifdef __FreeBSD__
#include <net/if_var.h>
+#endif
#include <net/if_tun.h>
#include <net/route.h>
#include <arpa/inet.h>
@@ -39,6 +41,7 @@
#include <termios.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "id.h"
@@ -48,7 +51,6 @@
#include "ipcp.h"
#include "os.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "arp.h"
#include "systems.h"
diff --git a/usr.sbin/ppp/os.h b/usr.sbin/ppp/os.h
index a4041bef5d29..0c19f2e282c4 100644
--- a/usr.sbin/ppp/os.h
+++ b/usr.sbin/ppp/os.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: os.h,v 1.10 1997/10/29 01:19:48 brian Exp $
+ * $Id: os.h,v 1.11 1997/11/16 22:15:09 brian Exp $
*
* TODO:
*/
@@ -28,5 +28,3 @@ extern int OpenTunnel(int *);
extern void OsLinkup(void);
extern int OsLinkIsUp(void);
extern void OsLinkdown(void);
-extern void OsSetRoute(int, struct in_addr, struct in_addr, struct in_addr);
-extern void DeleteIfRoutes(int);
diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c
index 7b242938d909..fb986f2d3307 100644
--- a/usr.sbin/ppp/pap.c
+++ b/usr.sbin/ppp/pap.c
@@ -18,7 +18,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pap.c,v 1.17 1997/10/16 23:55:19 brian Exp $
+ * $Id: pap.c,v 1.18 1997/10/26 01:03:28 brian Exp $
*
* TODO:
*/
@@ -37,6 +37,7 @@
#endif
#include <utmp.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
@@ -45,16 +46,13 @@
#include "lcp.h"
#include "pap.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "hdlc.h"
#include "lcpproto.h"
#include "phase.h"
#include "auth.h"
-static char *papcodes[] = {
- "???", "REQUEST", "ACK", "NAK"
-};
+static const char *papcodes[] = { "???", "REQUEST", "ACK", "NAK" };
static void
SendPapChallenge(int papid)
@@ -93,7 +91,7 @@ struct authinfo AuthPapInfo = {
};
static void
-SendPapCode(int id, int code, char *message)
+SendPapCode(int id, int code, const char *message)
{
struct fsmheader lh;
struct mbuf *bp;
diff --git a/usr.sbin/ppp/phase.c b/usr.sbin/ppp/phase.c
index 61d569848ff4..63695f74cc98 100644
--- a/usr.sbin/ppp/phase.c
+++ b/usr.sbin/ppp/phase.c
@@ -1,5 +1,5 @@
/*
- * $Id: phase.c,v 1.1 1997/10/26 01:03:31 brian Exp $
+ * $Id: phase.c,v 1.2 1997/10/29 01:19:50 brian Exp $
*/
#include <sys/param.h>
@@ -7,6 +7,7 @@
#include <stdio.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "lcp.h"
@@ -20,13 +21,12 @@
#include "defs.h"
#include "main.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
#include "phase.h"
int phase = 0; /* Curent phase */
-static char *PhaseNames[] = {
+static const char *PhaseNames[] = {
"Dead", "Establish", "Authenticate", "Network", "Terminate"
};
diff --git a/usr.sbin/ppp/pred.c b/usr.sbin/ppp/pred.c
index 025120fd730c..3b4cfff61b3d 100644
--- a/usr.sbin/ppp/pred.c
+++ b/usr.sbin/ppp/pred.c
@@ -5,7 +5,7 @@
* Updated by: Carsten Bormann <cabo@cs.tu-berlin.de>
* Original : Dave Rand <dlr@bungi.com>/<dave_rand@novell.com>
*
- * $Id: pred.c,v 1.15 1997/10/26 01:03:34 brian Exp $
+ * $Id: pred.c,v 1.16 1997/11/09 06:22:46 brian Exp $
*
*/
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index 19e7a1281967..41f62db692eb 100644
--- a/usr.sbin/ppp/route.c
+++ b/usr.sbin/ppp/route.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: route.c,v 1.25 1997/11/11 22:58:13 brian Exp $
+ * $Id: route.c,v 1.26 1997/11/15 02:15:56 brian Exp $
*
*/
@@ -41,10 +41,10 @@
#include <sys/sysctl.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
-#include "command.h"
#include "defs.h"
#include "vars.h"
#include "id.h"
@@ -67,7 +67,8 @@ OsSetRoute(int cmd,
{
struct rtmsg rtmes;
int s, nb, wb;
- char *cp, *cmdstr;
+ char *cp;
+ const char *cmdstr;
u_long *lp;
struct sockaddr_in rtdata;
@@ -145,7 +146,8 @@ OsSetRoute(int cmd,
static void
p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width)
{
- char buf[29], *cp;
+ char buf[29];
+ const char *cp;
struct sockaddr_in *ihost = (struct sockaddr_in *)phost;
struct sockaddr_in *mask = (struct sockaddr_in *)pmask;
struct sockaddr_dl *dl = (struct sockaddr_dl *)phost;
@@ -244,7 +246,7 @@ struct bits {
};
static void
-p_flags(u_long f, char *format)
+p_flags(u_long f, const char *format)
{
if (VarTerm) {
char name[33], *flags;
@@ -258,7 +260,7 @@ p_flags(u_long f, char *format)
}
}
-static char *
+static const char *
Index2Nam(int idx)
{
static char ifs[50][6];
@@ -325,7 +327,7 @@ Index2Nam(int idx)
}
int
-ShowRoute()
+ShowRoute(struct cmdargs const *arg)
{
struct rt_msghdr *rtm;
struct sockaddr *sa_dst, *sa_gw, *sa_mask;
@@ -471,7 +473,7 @@ int
GetIfIndex(char *name)
{
int idx;
- char *got;
+ const char *got;
#ifdef __FreeBSD__
idx = 1; /* We start at 1, not 0 */
diff --git a/usr.sbin/ppp/route.h b/usr.sbin/ppp/route.h
index ba78987ee04d..23b56ef89e92 100644
--- a/usr.sbin/ppp/route.h
+++ b/usr.sbin/ppp/route.h
@@ -17,11 +17,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: route.h,v 1.5 1997/08/25 00:29:27 brian Exp $
+ * $Id: route.h,v 1.6 1997/10/26 01:03:38 brian Exp $
*
*/
extern int GetIfIndex(char *);
-extern int ShowRoute(void);
+extern int ShowRoute(struct cmdargs const *);
extern void OsSetRoute(int, struct in_addr, struct in_addr, struct in_addr);
extern void DeleteIfRoutes(int);
diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c
index d4bb2a197546..cb7884be21f1 100644
--- a/usr.sbin/ppp/server.c
+++ b/usr.sbin/ppp/server.c
@@ -1,5 +1,5 @@
/*
- * $Id: server.c,v 1.9 1997/11/09 22:07:29 brian Exp $
+ * $Id: server.c,v 1.10 1997/11/11 22:58:13 brian Exp $
*/
#include <sys/param.h>
@@ -16,14 +16,13 @@
#include <sys/un.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
-#include "command.h"
#include "defs.h"
#include "vars.h"
#include "server.h"
-#include "log.h"
#include "id.h"
int server = -1;
diff --git a/usr.sbin/ppp/sig.c b/usr.sbin/ppp/sig.c
index 8ca77fa56445..50c47d353e98 100644
--- a/usr.sbin/ppp/sig.c
+++ b/usr.sbin/ppp/sig.c
@@ -1,14 +1,15 @@
/*
- * $Id: $
+ * $Id: sig.c,v 1.9 1997/10/26 01:03:42 brian Exp $
*/
#include <sys/types.h>
#include <signal.h>
-#include "sig.h"
+#include "command.h"
#include "mbuf.h"
#include "log.h"
+#include "sig.h"
static caused[NSIG]; /* An array of pending signals */
static sig_type handler[NSIG]; /* all start at SIG_DFL */
diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c
index c16a22fbb279..9953f34cf40e 100644
--- a/usr.sbin/ppp/slcompress.c
+++ b/usr.sbin/ppp/slcompress.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: slcompress.c,v 1.12 1997/10/12 21:43:55 brian Exp $
+ * $Id: slcompress.c,v 1.13 1997/10/26 01:03:44 brian Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
@@ -32,12 +32,12 @@
#include <stdio.h>
#include <string.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "slcompress.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
static struct slstat {
@@ -570,7 +570,7 @@ bad:
}
int
-ReportCompress()
+ReportCompress(struct cmdargs const *arg)
{
if (!VarTerm)
return 1;
diff --git a/usr.sbin/ppp/slcompress.h b/usr.sbin/ppp/slcompress.h
index dc5173c63548..56328207863c 100644
--- a/usr.sbin/ppp/slcompress.h
+++ b/usr.sbin/ppp/slcompress.h
@@ -1,7 +1,7 @@
/*
* Definitions for tcp compression routines.
*
- * $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.8 1997/10/07 00:56:58 brian Exp $
+ * $Header: /home/ncvs/src/usr.sbin/ppp/slcompress.h,v 1.9 1997/10/26 01:03:46 brian Exp $
*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved.
@@ -18,7 +18,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: slcompress.h,v 1.8 1997/10/07 00:56:58 brian Exp $
+ * $Id: slcompress.h,v 1.9 1997/10/26 01:03:46 brian Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
@@ -131,4 +131,4 @@ extern void sl_compress_init(struct slcompress *, int);
extern u_char sl_compress_tcp
(struct mbuf *, struct ip *, struct slcompress *, int);
extern int sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *);
-extern int ReportCompress(void);
+extern int ReportCompress(struct cmdargs const *);
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index 242400c30c3d..575b8d70ca4e 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.c,v 1.26 1997/11/13 14:43:20 brian Exp $
+ * $Id: systems.c,v 1.27 1997/11/14 15:38:07 brian Exp $
*
* TODO:
*/
@@ -31,6 +31,7 @@
#include <string.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "id.h"
@@ -38,7 +39,6 @@
#include "timer.h"
#include "fsm.h"
#include "loadalias.h"
-#include "command.h"
#include "ipcp.h"
#include "pathnames.h"
#include "vars.h"
@@ -49,7 +49,7 @@
#define issep(ch) ((ch) == ' ' || (ch) == '\t')
FILE *
-OpenSecret(char *file)
+OpenSecret(const char *file)
{
FILE *fp;
char line[100];
@@ -169,7 +169,7 @@ DecodeCtrlCommand(char *line, char *arg)
static int userok;
int
-AllowUsers(struct cmdtab const *list, int argc, char **argv)
+AllowUsers(struct cmdargs const *arg)
{
int f;
char *user;
@@ -177,8 +177,8 @@ AllowUsers(struct cmdtab const *list, int argc, char **argv)
userok = 0;
user = getlogin();
if (user && *user)
- for (f = 0; f < argc; f++)
- if (!strcmp("*", argv[f]) || !strcmp(user, argv[f])) {
+ for (f = 0; f < arg->argc; f++)
+ if (!strcmp("*", arg->argv[f]) || !strcmp(user, arg->argv[f])) {
userok = 1;
break;
}
@@ -188,7 +188,7 @@ AllowUsers(struct cmdtab const *list, int argc, char **argv)
static struct {
int mode;
- char *name;
+ const char *name;
} modes[] = {
{ MODE_INTER, "interactive" },
{ MODE_AUTO, "auto" },
@@ -203,21 +203,21 @@ static struct {
static int modeok;
int
-AllowModes(struct cmdtab const *list, int argc, char **argv)
+AllowModes(struct cmdargs const *arg)
{
int f;
int m;
int allowed;
allowed = 0;
- for (f = 0; f < argc; f++) {
+ for (f = 0; f < arg->argc; f++) {
for (m = 0; modes[m].mode; m++)
- if (!strcasecmp(modes[m].name, argv[f])) {
+ if (!strcasecmp(modes[m].name, arg->argv[f])) {
allowed |= modes[m].mode;
break;
}
if (modes[m].mode == 0)
- LogPrintf(LogWARN, "%s: Invalid mode\n", argv[f]);
+ LogPrintf(LogWARN, "%s: Invalid mode\n", arg->argv[f]);
}
modeok = (mode | allowed) == allowed ? 1 : 0;
@@ -301,7 +301,7 @@ ReadSystem(const char *name, const char *file, int doexec)
olauth = VarLocalAuth;
if (VarLocalAuth == LOCAL_NO_AUTH)
VarLocalAuth = LOCAL_AUTH;
- RunCommand(argc, argv, name);
+ RunCommand(argc, (char const *const *)argv, name);
VarLocalAuth = olauth;
}
} else if (*cp == '#' || *cp == '\n' || *cp == '\0') {
@@ -340,12 +340,12 @@ SelectSystem(const char *name, const char *file)
}
int
-LoadCommand(struct cmdtab const * list, int argc, char **argv)
+LoadCommand(struct cmdargs const *arg)
{
- char *name;
+ const char *name;
- if (argc > 0)
- name = *argv;
+ if (arg->argc > 0)
+ name = *arg->argv;
else
name = "default";
@@ -356,12 +356,12 @@ LoadCommand(struct cmdtab const * list, int argc, char **argv)
LogPrintf(LogWARN, "%s: not found.\n", name);
return -1;
} else
- SetLabel(argc ? name : NULL);
+ SetLabel(arg->argc ? name : NULL);
return 0;
}
int
-SaveCommand(struct cmdtab const *list, int argc, char **argv)
+SaveCommand(struct cmdargs const *arg)
{
LogPrintf(LogWARN, "save command is not implemented (yet).\n");
return 1;
diff --git a/usr.sbin/ppp/systems.h b/usr.sbin/ppp/systems.h
index a491bd301a37..e5d0bc34f54d 100644
--- a/usr.sbin/ppp/systems.h
+++ b/usr.sbin/ppp/systems.h
@@ -17,15 +17,15 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.h,v 1.8 1997/11/09 06:22:48 brian Exp $
+ * $Id: systems.h,v 1.9 1997/11/11 22:58:14 brian Exp $
*
*/
extern int SelectSystem(const char *, const char *);
extern int ValidSystem(const char *);
-extern int AllowUsers(struct cmdtab const *, int, char **);
-extern int AllowModes(struct cmdtab const *, int, char **);
-extern FILE *OpenSecret(char *);
+extern FILE *OpenSecret(const char *);
extern void CloseSecret(FILE *);
-extern int LoadCommand(struct cmdtab const *, int, char **);
-extern int SaveCommand(struct cmdtab const *, int, char **);
+extern int AllowUsers(struct cmdargs const *);
+extern int AllowModes(struct cmdargs const *);
+extern int LoadCommand(struct cmdargs const *);
+extern int SaveCommand(struct cmdargs const *);
diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c
index d3567091e920..d7354f1be679 100644
--- a/usr.sbin/ppp/throughput.c
+++ b/usr.sbin/ppp/throughput.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: throughput.c,v 1.1 1997/11/18 14:52:07 brian Exp $
*/
#include <sys/param.h>
@@ -8,14 +8,14 @@
#include <time.h>
#include <netinet/in.h>
+#include "command.h"
+#include "mbuf.h"
+#include "log.h"
#include "timer.h"
#include "throughput.h"
#include "defs.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
-#include "mbuf.h"
-#include "log.h"
void
throughput_init(struct pppThroughput *t)
@@ -74,8 +74,9 @@ throughput_log(struct pppThroughput *t, int level, const char *title)
}
static void
-throughput_sampler(struct pppThroughput *t)
+throughput_sampler(void *v)
{
+ struct pppThroughput *t = (struct pppThroughput *)v;
u_long old;
StopTimer(&t->Timer);
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index 83ebb6d8c71c..7cd449d06e3c 100644
--- a/usr.sbin/ppp/timer.c
+++ b/usr.sbin/ppp/timer.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: timer.c,v 1.22 1997/10/26 01:03:52 brian Exp $
+ * $Id: timer.c,v 1.23 1997/11/09 06:22:49 brian Exp $
*
* TODO:
*/
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <unistd.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
diff --git a/usr.sbin/ppp/timer.h b/usr.sbin/ppp/timer.h
index 89439f5760de..51d614dc238f 100644
--- a/usr.sbin/ppp/timer.h
+++ b/usr.sbin/ppp/timer.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: timer.h,v 1.1 1997/10/26 01:03:53 brian Exp $
+ * $Id: timer.h,v 1.2 1997/10/26 12:42:13 brian Exp $
*
* TODO:
*/
@@ -27,7 +27,7 @@ struct pppTimer {
int state;
u_long rest; /* Ticks to expire */
u_long load; /* Initial load value */
- void (*func)(); /* Function called when timer is expired */
+ void (*func)(void *); /* Function called when timer is expired */
void *arg; /* Argument passed to timeout function */
struct pppTimer *next; /* Link to next timer */
struct pppTimer *enext; /* Link to next expired timer */
diff --git a/usr.sbin/ppp/tun.c b/usr.sbin/ppp/tun.c
index bee63cb66715..73b91d04e8a3 100644
--- a/usr.sbin/ppp/tun.c
+++ b/usr.sbin/ppp/tun.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: tun.c,v 1.2 1997/11/17 00:42:41 brian Exp $
*/
#include <sys/param.h>
@@ -8,7 +8,9 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
+#ifdef __FreeBSD__
#include <net/if_var.h>
+#endif
#include <net/if_tun.h>
#include <stdio.h>
@@ -16,12 +18,13 @@
#include <sys/ioctl.h>
#include <sys/errno.h>
+#include "command.h"
+#include "mbuf.h"
+#include "log.h"
#include "hdlc.h"
#include "defs.h"
#include "loadalias.h"
-#include "command.h"
#include "vars.h"
-#include "log.h"
#include "tun.h"
void
diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c
index 7b6953a35711..49550cbc455c 100644
--- a/usr.sbin/ppp/vars.c
+++ b/usr.sbin/ppp/vars.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vars.c,v 1.34 1997/11/11 22:58:14 brian Exp $
+ * $Id: vars.c,v 1.35 1997/11/18 14:52:07 brian Exp $
*
*/
#include <sys/param.h>
@@ -26,21 +26,20 @@
#include <stdio.h>
#include <string.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
-#include "command.h"
#include "hdlc.h"
#include "termios.h"
#include "loadalias.h"
#include "vars.h"
#include "auth.h"
-#include "defs.h"
char VarVersion[] = "PPP Version 1.4";
-char VarLocalVersion[] = "$Date: 1997/11/11 22:58:14 $";
+char VarLocalVersion[] = "$Date: 1997/11/18 14:52:07 $";
int Utmp = 0;
int ipInOctets = 0;
int ipOutOctets = 0;
@@ -77,7 +76,7 @@ struct pppvars pppVars = {
};
int
-DisplayCommand()
+DisplayCommand(struct cmdargs const *arg)
{
struct confdesc *vp;
@@ -98,18 +97,19 @@ DisplayCommand()
}
static int
-ConfigCommand(struct cmdtab * list, int argc, char **argv, int mine, int val)
+ConfigCommand(struct cmdargs const *arg, int mine, int val)
{
struct confdesc *vp;
int err;
+ int narg = 0;
- if (argc < 1)
+ if (arg->argc < 1)
return -1;
err = 0;
do {
for (vp = pppConfs; vp->name; vp++)
- if (strcasecmp(vp->name, *argv) == 0) {
+ if (strcasecmp(vp->name, arg->argv[narg]) == 0) {
if (mine) {
if (vp->myside == CONF_NONE) {
LogPrintf(LogWARN, "Config: %s cannot be enabled or disabled\n",
@@ -128,50 +128,48 @@ ConfigCommand(struct cmdtab * list, int argc, char **argv, int mine, int val)
break;
}
if (!vp->name) {
- LogPrintf(LogWARN, "Config: %s: No such key word\n", *argv);
+ LogPrintf(LogWARN, "Config: %s: No such key word\n", arg->argv[narg]);
err++;
}
- argc--;
- argv++;
- } while (argc > 0);
+ } while (++narg < arg->argc);
return err;
}
int
-EnableCommand(struct cmdtab * list, int argc, char **argv)
+EnableCommand(struct cmdargs const *arg)
{
- return ConfigCommand(list, argc, argv, 1, CONF_ENABLE);
+ return ConfigCommand(arg, 1, CONF_ENABLE);
}
int
-DisableCommand(struct cmdtab * list, int argc, char **argv)
+DisableCommand(struct cmdargs const *arg)
{
- return ConfigCommand(list, argc, argv, 1, CONF_DISABLE);
+ return ConfigCommand(arg, 1, CONF_DISABLE);
}
int
-AcceptCommand(struct cmdtab * list, int argc, char **argv)
+AcceptCommand(struct cmdargs const *arg)
{
- return ConfigCommand(list, argc, argv, 0, CONF_ACCEPT);
+ return ConfigCommand(arg, 0, CONF_ACCEPT);
}
int
-DenyCommand(struct cmdtab * list, int argc, char **argv)
+DenyCommand(struct cmdargs const *arg)
{
- return ConfigCommand(list, argc, argv, 0, CONF_DENY);
+ return ConfigCommand(arg, 0, CONF_DENY);
}
int
-LocalAuthCommand(struct cmdtab * list, int argc, char **argv)
+LocalAuthCommand(struct cmdargs const *arg)
{
- char *pass;
- if (argc == 0)
+ const char *pass;
+ if (arg->argc == 0)
pass = "";
- else if (argc > 1)
+ else if (arg->argc > 1)
return -1;
else
- pass = *argv;
+ pass = *arg->argv;
if (VarHaveLocalAuthKey)
VarLocalAuth = strcmp(VarLocalAuthKey, pass) ? LOCAL_NO_AUTH : LOCAL_AUTH;
diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h
index 26f391060016..79f4f82ea50a 100644
--- a/usr.sbin/ppp/vars.h
+++ b/usr.sbin/ppp/vars.h
@@ -15,13 +15,13 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vars.h,v 1.33 1997/11/09 22:07:29 brian Exp $
+ * $Id: vars.h,v 1.34 1997/11/18 14:52:08 brian Exp $
*
* TODO:
*/
struct confdesc {
- char *name;
+ const char *name;
int myside, hisside;
};
@@ -68,7 +68,7 @@ struct pppvars {
int dial_tries; /* Dial attempts before giving up, 0 == inf */
int loopback; /* Turn around packets addressed to me */
char modem_dev[40]; /* Name of device / host:port */
- char *base_modem_dev; /* Pointer to base of modem_dev */
+ const char *base_modem_dev; /* Pointer to base of modem_dev */
int open_mode; /* LCP open mode */
#define LOCAL_AUTH 0x01
#define LOCAL_NO_AUTH 0x02
@@ -196,9 +196,9 @@ extern int reconnectCount;
*
*/
-extern int EnableCommand(struct cmdtab *, int, char **);
-extern int DisableCommand(struct cmdtab *, int, char **);
-extern int AcceptCommand(struct cmdtab *, int, char **);
-extern int DenyCommand(struct cmdtab *, int, char **);
-extern int LocalAuthCommand(struct cmdtab *, int, char **);
-extern int DisplayCommand(void);
+extern int EnableCommand(struct cmdargs const *);
+extern int DisableCommand(struct cmdargs const *);
+extern int AcceptCommand(struct cmdargs const *);
+extern int DenyCommand(struct cmdargs const *);
+extern int LocalAuthCommand(struct cmdargs const *);
+extern int DisplayCommand(struct cmdargs const *);
diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c
index e614e4b7fc4b..c0fc76f7d599 100644
--- a/usr.sbin/ppp/vjcomp.c
+++ b/usr.sbin/ppp/vjcomp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vjcomp.c,v 1.11 1997/10/26 01:04:01 brian Exp $
+ * $Id: vjcomp.c,v 1.12 1997/11/09 06:22:49 brian Exp $
*
* TODO:
*/
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <string.h>
+#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"