summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@openbsd.org>1996-03-25 15:54:43 +0000
committerniklas <niklas@openbsd.org>1996-03-25 15:54:43 +0000
commit608f9123c07c9d36cb7dc72475917fe9c0211e1c (patch)
tree657129c9341e229037351e728f032c066edba94e
parentSomewhat better support for building lint library (diff)
downloadwireguard-openbsd-608f9123c07c9d36cb7dc72475917fe9c0211e1c.tar.xz
wireguard-openbsd-608f9123c07c9d36cb7dc72475917fe9c0211e1c.zip
From NetBSD: merge of 960317
-rw-r--r--usr.sbin/amd/amd/afs_ops.c8
-rw-r--r--usr.sbin/amd/amd/host_ops.c12
-rw-r--r--usr.sbin/amd/amd/map.c8
-rw-r--r--usr.sbin/amd/amd/nfs_ops.c43
-rw-r--r--usr.sbin/amd/amd/ufs_ops.c5
-rw-r--r--usr.sbin/amd/config/mtab_bsd.c6
-rw-r--r--usr.sbin/amd/config/os-bsd44.h7
-rw-r--r--usr.sbin/amd/include/am.h14
-rw-r--r--usr.sbin/amd/rpcx/mount.h30
-rw-r--r--usr.sbin/amd/rpcx/mount_xdr.c63
-rw-r--r--usr.sbin/amd/rpcx/nfs_prot.h76
-rw-r--r--usr.sbin/config/Makefile3
-rw-r--r--usr.sbin/config/config.84
-rw-r--r--usr.sbin/config/config.h4
-rw-r--r--usr.sbin/config/files.c4
-rw-r--r--usr.sbin/config/gram.y3
-rw-r--r--usr.sbin/config/hash.c4
-rw-r--r--usr.sbin/config/main.c4
-rw-r--r--usr.sbin/config/mkheaders.c4
-rw-r--r--usr.sbin/config/mkioconf.c4
-rw-r--r--usr.sbin/config/mkmakefile.c8
-rw-r--r--usr.sbin/config/mkswap.c4
-rw-r--r--usr.sbin/config/pack.c4
-rw-r--r--usr.sbin/config/scan.l4
-rw-r--r--usr.sbin/config/sem.c4
-rw-r--r--usr.sbin/config/sem.h4
-rw-r--r--usr.sbin/config/util.c4
-rw-r--r--usr.sbin/eeprom/defs.h41
-rw-r--r--usr.sbin/eeprom/eehandlers.c41
-rw-r--r--usr.sbin/eeprom/eeprom.839
-rw-r--r--usr.sbin/eeprom/main.c41
-rw-r--r--usr.sbin/eeprom/ophandlers.c41
-rw-r--r--usr.sbin/inetd/inetd.c17
-rw-r--r--usr.sbin/pppd/Makefile6
-rw-r--r--usr.sbin/pppd/auth.c313
-rw-r--r--usr.sbin/pppd/bpf_compile.h72
-rw-r--r--usr.sbin/pppd/ccp.c364
-rw-r--r--usr.sbin/pppd/ccp.h12
-rw-r--r--usr.sbin/pppd/chap.c15
-rw-r--r--usr.sbin/pppd/chap.h6
-rw-r--r--usr.sbin/pppd/demand.c312
-rw-r--r--usr.sbin/pppd/fsm.c32
-rw-r--r--usr.sbin/pppd/fsm.h8
-rw-r--r--usr.sbin/pppd/gencode.c1303
-rw-r--r--usr.sbin/pppd/gencode.h168
-rw-r--r--usr.sbin/pppd/grammar.y238
-rw-r--r--usr.sbin/pppd/ipcp.c300
-rw-r--r--usr.sbin/pppd/ipcp.h15
-rw-r--r--usr.sbin/pppd/lcp.c277
-rw-r--r--usr.sbin/pppd/lcp.h8
-rw-r--r--usr.sbin/pppd/magic.c9
-rw-r--r--usr.sbin/pppd/main.c485
-rw-r--r--usr.sbin/pppd/nametoaddr.c214
-rw-r--r--usr.sbin/pppd/options.c502
-rw-r--r--usr.sbin/pppd/patchlevel.h9
-rw-r--r--usr.sbin/pppd/pathnames.h9
-rw-r--r--usr.sbin/pppd/pppd.8132
-rw-r--r--usr.sbin/pppd/pppd.h194
-rw-r--r--usr.sbin/pppd/pppstats/Makefile3
-rw-r--r--usr.sbin/pppd/pppstats/pppstats.863
-rw-r--r--usr.sbin/pppd/pppstats/pppstats.c76
-rw-r--r--usr.sbin/pppd/scanner.l178
-rw-r--r--usr.sbin/pppd/sys-bsd.c590
-rw-r--r--usr.sbin/pppd/upap.c10
-rw-r--r--usr.sbin/pppd/upap.h6
-rw-r--r--usr.sbin/pstat/pstat.c13
-rw-r--r--usr.sbin/rdate/Makefile3
-rw-r--r--usr.sbin/rdate/rdate.84
-rw-r--r--usr.sbin/rdate/rdate.c11
-rw-r--r--usr.sbin/screenblank/pathnames.h41
-rw-r--r--usr.sbin/screenblank/screenblank.139
-rw-r--r--usr.sbin/screenblank/screenblank.c41
-rw-r--r--usr.sbin/ypbind/ypbind.840
-rw-r--r--usr.sbin/yppoll/yppoll.840
-rw-r--r--usr.sbin/ypset/ypset.840
75 files changed, 5581 insertions, 1178 deletions
diff --git a/usr.sbin/amd/amd/afs_ops.c b/usr.sbin/amd/amd/afs_ops.c
index e9dcf6a689d..6e8ac41b935 100644
--- a/usr.sbin/amd/amd/afs_ops.c
+++ b/usr.sbin/amd/amd/afs_ops.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: afs_ops.c,v 1.2 1996/03/25 15:54:43 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,7 +38,6 @@
* SUCH DAMAGE.
*
* from: @(#)afs_ops.c 8.1 (Berkeley) 6/6/93
- * $Id: afs_ops.c,v 1.1.1.1 1995/10/18 08:47:09 deraadt Exp $
*/
#include "am.h"
@@ -51,7 +52,6 @@ typedef nfs_fh fhandle_t;
#ifdef NFS_HDR
#include NFS_HDR
#endif /* NFS_HDR */
-#include <sys/mount.h>
#include "mount.h"
/*
@@ -141,6 +141,10 @@ char *opts;
return EINVAL;
}
+#if NFS_PROTOCOL_VERSION >= 3
+ nfs_args.fhsize = NFSX_V2FH;
+ nfs_args.version = NFS_ARGSVERSION;
+#endif
NFS_FH_DREF(nfs_args.fh, (NFS_FH_TYPE) fhp);
/*
diff --git a/usr.sbin/amd/amd/host_ops.c b/usr.sbin/amd/amd/host_ops.c
index 89fd06a42c6..f105d28ab15 100644
--- a/usr.sbin/amd/amd/host_ops.c
+++ b/usr.sbin/amd/amd/host_ops.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: host_ops.c,v 1.2 1996/03/25 15:54:46 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,7 +38,6 @@
* SUCH DAMAGE.
*
* from: @(#)host_ops.c 8.1 (Berkeley) 6/6/93
- * $Id: host_ops.c,v 1.1.1.1 1995/10/18 08:47:10 deraadt Exp $
*/
#include "am.h"
@@ -185,6 +186,9 @@ fhstatus *fhp;
* Call the mount daemon on the remote host to
* get the filehandle.
*/
+#if NFS_PROTOCOL_VERSION >= 3
+ fhp->fhs_vers = MOUNTVERS;
+#endif
clnt_stat = clnt_call(client, MOUNTPROC_MNT, xdr_dirpath, &dir, xdr_fhstatus, fhp, tv);
if (clnt_stat != RPC_SUCCESS) {
extern char *clnt_sperrno();
@@ -195,12 +199,12 @@ fhstatus *fhp;
/*
* Check status of filehandle
*/
- if (fhp->fhs_status) {
+ if (fhp->fhs_stat) {
#ifdef DEBUG
- errno = fhp->fhs_status;
+ errno = fhp->fhs_stat;
dlog("fhandle fetch failed: %m");
#endif /* DEBUG */
- return fhp->fhs_status;
+ return fhp->fhs_stat;
}
return 0;
}
diff --git a/usr.sbin/amd/amd/map.c b/usr.sbin/amd/amd/map.c
index d1978715286..3d28fde1a2a 100644
--- a/usr.sbin/amd/amd/map.c
+++ b/usr.sbin/amd/amd/map.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: map.c,v 1.2 1996/03/25 15:54:48 niklas Exp $ */
+
/*-
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -38,7 +40,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)map.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$Id: map.c,v 1.1.1.1 1995/10/18 08:47:10 deraadt Exp $";
+static char *rcsid = "$OpenBSD: map.c,v 1.2 1996/03/25 15:54:48 niklas Exp $";
#endif /* not lint */
#include "am.h"
@@ -283,10 +285,10 @@ am_node *mp;
mp->am_ttl += mp->am_timeo; /* sun's -tl option */
}
-void mk_fattr P((am_node *mp, ftype vntype));
+void mk_fattr P((am_node *mp, int vntype));
void mk_fattr(mp, vntype)
am_node *mp;
-ftype vntype;
+int vntype;
{
switch (vntype) {
case NFDIR:
diff --git a/usr.sbin/amd/amd/nfs_ops.c b/usr.sbin/amd/amd/nfs_ops.c
index 41e52fe035e..ae7e78b5530 100644
--- a/usr.sbin/amd/amd/nfs_ops.c
+++ b/usr.sbin/amd/amd/nfs_ops.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: nfs_ops.c,v 1.3 1996/03/25 15:54:48 niklas Exp $ */
+
/*-
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -38,7 +40,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)nfs_ops.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$Id: nfs_ops.c,v 1.2 1996/02/17 02:55:19 dm Exp $";
+static char *rcsid = "$OpenBSD: nfs_ops.c,v 1.3 1996/03/25 15:54:48 niklas Exp $";
#endif /* not lint */
#include "am.h"
@@ -54,7 +56,6 @@ typedef nfs_fh fhandle_t;
#ifdef NFS_HDR
#include NFS_HDR
#endif /* NFS_HDR */
-#include <sys/mount.h>
#include "mount.h"
/*
@@ -96,7 +97,7 @@ struct fh_cache {
int fh_error; /* Valid data? */
int fh_id; /* Unique id */
int fh_cid; /* Callout id */
- struct fhstatus fh_handle; /* Handle on filesystem */
+ fhstatus fh_handle; /* Handle on filesystem */
struct sockaddr_in fh_sin; /* Address of mountd */
fserver *fh_fs; /* Server holding filesystem */
char *fh_path; /* Filesystem on host */
@@ -163,6 +164,9 @@ voidp idv;
int done;
{
fh_cache *fp = find_nfs_fhandle_cache(idv, done);
+#if NFS_PROTOCOL_VERSION >= 3
+ fp->fh_handle.fhs_vers = MOUNTVERS;
+#endif
if (fp) {
fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &fp->fh_handle, xdr_fhstatus);
if (!fp->fh_error) {
@@ -211,11 +215,11 @@ fh_cache *fp;
/*
* Determine the file handle for a node
*/
-static int prime_nfs_fhandle_cache P((char *path, fserver *fs, struct fhstatus *fhbuf, voidp wchan));
+static int prime_nfs_fhandle_cache P((char *path, fserver *fs, fhstatus *fhbuf, voidp wchan));
static int prime_nfs_fhandle_cache(path, fs, fhbuf, wchan)
char *path;
fserver *fs;
-struct fhstatus *fhbuf;
+fhstatus *fhbuf;
voidp wchan;
{
fh_cache *fp, *fp_save = 0;
@@ -233,7 +237,7 @@ voidp wchan;
if (fs == fp->fh_fs && strcmp(path, fp->fh_path) == 0) {
switch (fp->fh_error) {
case 0:
- error = fp->fh_error = unx_error(fp->fh_handle.fhs_status);
+ error = fp->fh_error = unx_error(fp->fh_handle.fhs_stat);
if (error == 0) {
if (fhbuf)
bcopy((voidp) &fp->fh_handle, (voidp) fhbuf,
@@ -446,7 +450,7 @@ mntfs *mf;
{
if (!mf->mf_private) {
int error;
- struct fhstatus fhs;
+ fhstatus fhs;
char *colon = strchr(mf->mf_info, ':');
if (colon == 0)
@@ -464,9 +468,9 @@ mntfs *mf;
return 0;
}
-int mount_nfs_fh P((struct fhstatus *fhp, char *dir, char *fs_name, char *opts, mntfs *mf));
+int mount_nfs_fh P((fhstatus *fhp, char *dir, char *fs_name, char *opts, mntfs *mf));
int mount_nfs_fh(fhp, dir, fs_name, opts, mf)
-struct fhstatus *fhp;
+fhstatus *fhp;
char *dir;
char *fs_name;
char *opts;
@@ -527,8 +531,12 @@ mntfs *mf;
/*
* set mount args
*/
- NFS_FH_DREF(nfs_args.fh, (NFS_FH_TYPE) fhp->fhstatus_u.fhs_fhandle);
+ NFS_FH_DREF(nfs_args.fh, (NFS_FH_TYPE) fhp->fhs_fhandle);
+#if NFS_PROTOCOL_VERSION >= 3
+ nfs_args.fhsize = fhp->fhs_size;
+ nfs_args.version = NFS_ARGSVERSION;
+#endif
#ifdef ULTRIX_HACK
nfs_args.optstr = mnt.mnt_opts;
#endif /* ULTRIX_HACK */
@@ -546,6 +554,15 @@ mntfs *mf;
if (nfs_args.rsize = hasmntval(&mnt, "rsize"))
nfs_args.flags |= NFSMNT_RSIZE;
+#ifdef NFSMNT_READDIRSIZE
+ if (nfs_args.readdirsize = hasmntval(&mnt, "readdirsize")) {
+ nfs_args.flags |= NFSMNT_READDIRSIZE;
+ } else if (nfs_args.rsize) {
+ nfs_args.readdirsize = nfs_args.rsize;
+ nfs_args.flags |= NFSMNT_READDIRSIZE;
+ }
+#endif
+
if (nfs_args.wsize = hasmntval(&mnt, "wsize"))
nfs_args.flags |= NFSMNT_WSIZE;
@@ -672,7 +689,7 @@ mntfs *mf;
{
#ifdef notdef
int error;
- struct fhstatus fhs;
+ fhstatus fhs;
char *colon;
if (!(colon = strchr(fs_name, ':')))
@@ -693,7 +710,7 @@ mntfs *mf;
return EINVAL;
}
- return mount_nfs_fh((struct fhstatus *) mf->mf_private, dir, fs_name, opts, mf);
+ return mount_nfs_fh((fhstatus *) mf->mf_private, dir, fs_name, opts, mf);
}
static int nfs_fmount(mf)
@@ -765,7 +782,7 @@ am_node *mp;
f.fh_fs = fs;
f.fh_id = 0;
f.fh_error = 0;
- (void) prime_nfs_fhandle_cache(colon+1, mf->mf_server, (struct fhstatus *) 0, (voidp) mf);
+ (void) prime_nfs_fhandle_cache(colon+1, mf->mf_server, (fhstatus *) 0, (voidp) mf);
(void) call_mountd(&f, MOUNTPROC_UMNT, (fwd_fun) 0, (voidp) 0);
*colon = ':';
}
diff --git a/usr.sbin/amd/amd/ufs_ops.c b/usr.sbin/amd/amd/ufs_ops.c
index 510f55f5391..658b5d7c018 100644
--- a/usr.sbin/amd/amd/ufs_ops.c
+++ b/usr.sbin/amd/amd/ufs_ops.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: ufs_ops.c,v 1.2 1996/03/25 15:54:50 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,7 +38,6 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_ops.c 8.1 (Berkeley) 6/6/93
- * $Id: ufs_ops.c,v 1.1.1.1 1995/10/18 08:47:12 deraadt Exp $
*/
#include "am.h"
@@ -52,8 +53,6 @@ typedef nfs_fh fhandle_t;
#include UFS_HDR
#endif /* UFS_HDR */
-#include <sys/mount.h>
-
/*
* UN*X file system
*/
diff --git a/usr.sbin/amd/config/mtab_bsd.c b/usr.sbin/amd/config/mtab_bsd.c
index 8a79eb21e14..6d2bb72b8fd 100644
--- a/usr.sbin/amd/config/mtab_bsd.c
+++ b/usr.sbin/amd/config/mtab_bsd.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: mtab_bsd.c,v 1.2 1996/03/25 15:54:52 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,16 +38,12 @@
* SUCH DAMAGE.
*
* from: @(#)mtab_bsd.c 8.1 (Berkeley) 6/6/93
- * $Id: mtab_bsd.c,v 1.1.1.1 1995/10/18 08:47:14 deraadt Exp $
- *
*/
#include "am.h"
#ifdef READ_MTAB_BSD_STYLE
-#include <sys/mount.h>
-
static struct mntent *mnt_dup(mp)
struct statfs *mp;
{
diff --git a/usr.sbin/amd/config/os-bsd44.h b/usr.sbin/amd/config/os-bsd44.h
index e83eef83272..21d4d3ef310 100644
--- a/usr.sbin/amd/config/os-bsd44.h
+++ b/usr.sbin/amd/config/os-bsd44.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: os-bsd44.h,v 1.4 1996/03/25 15:54:53 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,7 +38,6 @@
* SUCH DAMAGE.
*
* from: @(#)os-bsd44.h 8.1 (Berkeley) 6/6/93
- * $Id: os-bsd44.h,v 1.3 1996/02/17 02:55:22 dm Exp $
*
* 4.4 BSD definitions for Amd (automounter)
*/
@@ -177,7 +178,9 @@ struct mntent {
* Type of a file handle
*/
#undef NFS_FH_TYPE
-#define NFS_FH_TYPE nfsv2fh_t *
+#if __NetBSD__
+#define NFS_FH_TYPE void *
+#endif
/*
* How to get a mount list
diff --git a/usr.sbin/amd/include/am.h b/usr.sbin/amd/include/am.h
index 7d6b5b6ba1b..48aa07706e3 100644
--- a/usr.sbin/amd/include/am.h
+++ b/usr.sbin/amd/include/am.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: am.h,v 1.2 1996/03/25 15:54:54 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,8 +38,6 @@
* SUCH DAMAGE.
*
* from: @(#)am.h 5.6 (Berkeley) 6/6/93
- * $Id: am.h,v 1.1.1.1 1995/10/18 08:47:21 deraadt Exp $
- *
*/
#include "config.h"
@@ -48,10 +48,16 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <rpc/rpc.h>
-#include "nfs_prot.h"
+#include <sys/mount.h>
#ifdef MNTENT_HDR
#include MNTENT_HDR
#endif /* MNTENT_HDR */
+#ifndef NFS_PROTOCOL_VERSION
+#if NFS_ARGSVERSION >= 3
+#define NFS_PROTOCOL_VERSION 3
+#endif /* NFS_ARGSVERSION >= 3 */
+#endif /* NFS_PROTOCOL_VERSION */
+#include "nfs_prot.h"
#include <assert.h>
#ifdef DEBUG_MEM
@@ -268,7 +274,7 @@ extern int mapc_search P((mnt_map*, char*, char**));
extern void mapc_reload(P_void);
extern void mapc_showtypes P((FILE*));
extern int mkdirs P((char*, int));
-extern void mk_fattr P((am_node*, enum ftype));
+extern void mk_fattr P((am_node*, int));
extern void mnt_free P((struct mntent*));
extern int mount_auto_node P((char*, voidp));
extern int mount_automounter P((int));
diff --git a/usr.sbin/amd/rpcx/mount.h b/usr.sbin/amd/rpcx/mount.h
index f7d1c71e290..4e9f16ac433 100644
--- a/usr.sbin/amd/rpcx/mount.h
+++ b/usr.sbin/amd/rpcx/mount.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: mount.h,v 1.2 1996/03/25 15:54:56 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,25 +38,33 @@
* SUCH DAMAGE.
*
* from: @(#)mount.h 8.1 (Berkeley) 6/6/93
- * $Id: mount.h,v 1.1.1.1 1995/10/18 08:47:23 deraadt Exp $
- *
*/
#define MNTPATHLEN 1024
#define MNTNAMLEN 255
-#define FHSIZE 32
+#if NFS_PROTOCOL_VERSION < 3
+#define FHSIZE 32
typedef char fhandle[FHSIZE];
+typedef struct fhstatus {
+ u_int fhs_stat;
+ fhandle fhs_fhandle;
+} fhstatus;
+#else
+#define FHSIZE NFSX_V3FHMAX
+typedef char fhandle[NFSX_V3FHMAX];
+typedef struct fhstatus {
+ u_long fhs_stat;
+ long fhs_vers;
+ long fhs_auth;
+ long fhs_size;
+ fhandle fhs_fhandle;
+} fhstatus;
+#endif
+
bool_t xdr_fhandle();
-struct fhstatus {
- u_int fhs_status;
- union {
- fhandle fhs_fhandle;
- } fhstatus_u;
-};
-typedef struct fhstatus fhstatus;
bool_t xdr_fhstatus();
diff --git a/usr.sbin/amd/rpcx/mount_xdr.c b/usr.sbin/amd/rpcx/mount_xdr.c
index 20e25931145..1ad64c69916 100644
--- a/usr.sbin/amd/rpcx/mount_xdr.c
+++ b/usr.sbin/amd/rpcx/mount_xdr.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: mount_xdr.c,v 1.2 1996/03/25 15:54:57 niklas Exp $ */
+
/*
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
@@ -36,14 +38,13 @@
* SUCH DAMAGE.
*
* from: @(#)mount_xdr.c 8.1 (Berkeley) 6/6/93
- * $Id: mount_xdr.c,v 1.1.1.1 1995/10/18 08:47:23 deraadt Exp $
- *
*/
#include "am.h"
#include "mount.h"
+#if NFS_PROTOCOL_VERSION < 3
bool_t
xdr_fhandle(xdrs, objp)
XDR *xdrs;
@@ -55,20 +56,17 @@ xdr_fhandle(xdrs, objp)
return (TRUE);
}
-
-
-
bool_t
xdr_fhstatus(xdrs, objp)
XDR *xdrs;
fhstatus *objp;
{
- if (!xdr_u_int(xdrs, &objp->fhs_status)) {
+ if (!xdr_u_int(xdrs, &objp->fhs_stat)) {
return (FALSE);
}
- switch (objp->fhs_status) {
+ switch (objp->fhs_stat) {
case 0:
- if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) {
+ if (!xdr_fhandle(xdrs, objp->fhs_fhandle)) {
return (FALSE);
}
break;
@@ -76,6 +74,55 @@ xdr_fhstatus(xdrs, objp)
return (TRUE);
}
+#else
+#include <nfs/rpcv2.h>
+
+int
+xdr_fhstatus(xdrsp, objp)
+ XDR *xdrsp;
+ fhstatus *objp;
+{
+ register int i;
+ long auth, authcnt, authfnd = 0;
+
+
+ if (!xdr_u_long(xdrsp, &objp->fhs_stat))
+ return (0);
+ if (objp->fhs_stat)
+ return (1);
+ switch (objp->fhs_vers) {
+ case 1:
+ objp->fhs_size = NFSX_V2FH;
+ return (xdr_opaque(xdrsp, (caddr_t)objp->fhs_fhandle, NFSX_V2FH));
+ case 3:
+ if (!xdr_long(xdrsp, &objp->fhs_size))
+ return (0);
+ if (objp->fhs_size <= 0 || objp->fhs_size > NFSX_V3FHMAX)
+ return (0);
+ if (!xdr_opaque(xdrsp, (caddr_t)objp->fhs_fhandle, objp->fhs_size))
+ return (0);
+ if (!xdr_long(xdrsp, &authcnt))
+ return (0);
+ for (i = 0; i < authcnt; i++) {
+ if (!xdr_long(xdrsp, &auth))
+ return (0);
+ if (auth == objp->fhs_auth)
+ authfnd++;
+ }
+ /*
+ * Some servers, such as DEC's OSF/1 return a nil authenticator
+ * list to indicate RPCAUTH_UNIX.
+ */
+ if (!authfnd && (authcnt > 0 || objp->fhs_auth != RPCAUTH_UNIX))
+ objp->fhs_stat = EAUTH;
+ return (1);
+ default:
+ return (0);
+ };
+}
+#endif
+
+
diff --git a/usr.sbin/amd/rpcx/nfs_prot.h b/usr.sbin/amd/rpcx/nfs_prot.h
index 9e1424a6ca8..21c6a389cd5 100644
--- a/usr.sbin/amd/rpcx/nfs_prot.h
+++ b/usr.sbin/amd/rpcx/nfs_prot.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: nfs_prot.h,v 1.2 1996/03/25 15:54:58 niklas Exp $ */
+
/*
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
@@ -36,15 +38,19 @@
* SUCH DAMAGE.
*
* from: @(#)nfs_prot.h 8.1 (Berkeley) 6/6/93
- * $Id: nfs_prot.h,v 1.1.1.1 1995/10/18 08:47:23 deraadt Exp $
- *
*/
+#if NFS_PROTOCOL_VERSION >= 3
+#include <nfs/nfsproto.h>
+#endif
+
#define xdr_nfsstat xdr_enum
#define xdr_ftype xdr_enum
#define NFS_PORT 2049
+#ifndef NFS_MAXDATA
#define NFS_MAXDATA 8192
+#endif
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
#define NFS_FHSIZE 32
@@ -59,6 +65,7 @@
#define NFSMODE_SOCK 0140000
#define NFSMODE_FIFO 0010000
+#if NFS_PROTOCOL_VERSION < 3
enum nfsstat {
NFS_OK = 0,
NFSERR_PERM = 1,
@@ -80,9 +87,14 @@ enum nfsstat {
NFSERR_WFLUSH = 99
};
typedef enum nfsstat nfsstat;
+#else
+typedef int nfsstat;
+#endif
+
bool_t xdr_nfsstat();
+#if NFS_PROTOCOL_VERSION < 3
enum ftype {
NFNON = 0,
NFREG = 1,
@@ -95,6 +107,10 @@ enum ftype {
NFFIFO = 8
};
typedef enum ftype ftype;
+#else
+typedef int ftype;
+#endif
+
/* static bool_t xdr_ftype(); */
@@ -349,40 +365,60 @@ bool_t xdr_statfsres();
#define NFS_PROGRAM ((u_long)100003)
#define NFS_VERSION ((u_long)2)
+
+/* Undef the version 3 ones, and define the v2 ones */
+#undef NFSPROC_NULL
#define NFSPROC_NULL ((u_long)0)
-extern voidp nfsproc_null_2();
+#undef NFSPROC_GETATTR
#define NFSPROC_GETATTR ((u_long)1)
-extern attrstat *nfsproc_getattr_2();
+#undef NFSPROC_SETATTR
#define NFSPROC_SETATTR ((u_long)2)
-extern attrstat *nfsproc_setattr_2();
+#undef NFSPROC_ROOT
#define NFSPROC_ROOT ((u_long)3)
-extern voidp nfsproc_root_2();
+#undef NFSPROC_LOOKUP
#define NFSPROC_LOOKUP ((u_long)4)
-extern diropres *nfsproc_lookup_2();
+#undef NFSPROC_READLINK
#define NFSPROC_READLINK ((u_long)5)
-extern readlinkres *nfsproc_readlink_2();
+#undef NFSPROC_READ
#define NFSPROC_READ ((u_long)6)
-extern readres *nfsproc_read_2();
+#undef NFSPROC_WRITECACHE
#define NFSPROC_WRITECACHE ((u_long)7)
-extern voidp nfsproc_writecache_2();
+#undef NFSPROC_WRITE
#define NFSPROC_WRITE ((u_long)8)
-extern attrstat *nfsproc_write_2();
+#undef NFSPROC_CREATE
#define NFSPROC_CREATE ((u_long)9)
-extern diropres *nfsproc_create_2();
+#undef NFSPROC_REMOVE
#define NFSPROC_REMOVE ((u_long)10)
-extern nfsstat *nfsproc_remove_2();
+#undef NFSPROC_RENAME
#define NFSPROC_RENAME ((u_long)11)
-extern nfsstat *nfsproc_rename_2();
+#undef NFSPROC_LINK
#define NFSPROC_LINK ((u_long)12)
-extern nfsstat *nfsproc_link_2();
+#undef NFSPROC_SYMLINK
#define NFSPROC_SYMLINK ((u_long)13)
-extern nfsstat *nfsproc_symlink_2();
+#undef NFSPROC_MKDIR
#define NFSPROC_MKDIR ((u_long)14)
-extern diropres *nfsproc_mkdir_2();
+#undef NFSPROC_RMDIR
#define NFSPROC_RMDIR ((u_long)15)
-extern nfsstat *nfsproc_rmdir_2();
+#undef NFSPROC_READDIR
#define NFSPROC_READDIR ((u_long)16)
-extern readdirres *nfsproc_readdir_2();
+#undef NFSPROC_STATFS
#define NFSPROC_STATFS ((u_long)17)
-extern statfsres *nfsproc_statfs_2();
+extern voidp nfsproc_null_2();
+extern attrstat *nfsproc_getattr_2();
+extern attrstat *nfsproc_setattr_2();
+extern voidp nfsproc_root_2();
+extern diropres *nfsproc_lookup_2();
+extern readlinkres *nfsproc_readlink_2();
+extern readres *nfsproc_read_2();
+extern voidp nfsproc_writecache_2();
+extern attrstat *nfsproc_write_2();
+extern diropres *nfsproc_create_2();
+extern nfsstat *nfsproc_remove_2();
+extern nfsstat *nfsproc_rename_2();
+extern nfsstat *nfsproc_link_2();
+extern nfsstat *nfsproc_symlink_2();
+extern diropres *nfsproc_mkdir_2();
+extern nfsstat *nfsproc_rmdir_2();
+extern readdirres *nfsproc_readdir_2();
+extern statfsres *nfsproc_statfs_2();
diff --git a/usr.sbin/config/Makefile b/usr.sbin/config/Makefile
index 0a643a86dfc..bb77cdf432e 100644
--- a/usr.sbin/config/Makefile
+++ b/usr.sbin/config/Makefile
@@ -1,5 +1,6 @@
+# $OpenBSD: Makefile,v 1.2 1996/03/25 15:55:00 niklas Exp $
+# $NetBSD: Makefile,v 1.11 1996/03/03 17:28:02 thorpej Exp $
# from: @(#)Makefile 8.2 (Berkeley) 4/19/94
-# $Id: Makefile,v 1.1.1.1 1995/10/18 08:48:33 deraadt Exp $
PROG= config
BINDIR= /usr/sbin
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8
index a4bec2e1f90..b93276db33d 100644
--- a/usr.sbin/config/config.8
+++ b/usr.sbin/config/config.8
@@ -1,3 +1,6 @@
+.\" $OpenBSD: config.8,v 1.2 1996/03/25 15:55:01 niklas Exp $
+.\" $NetBSD: config.8,v 1.8 1996/03/03 17:28:05 thorpej Exp $
+.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +33,6 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)config.8 8.2 (Berkeley) 4/19/94
-.\" $Id: config.8,v 1.1.1.1 1995/10/18 08:48:33 deraadt Exp $
.\"
.Dd April 19, 1994
.Dt CONFIG 8
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 745e34a179f..116503b51a8 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -1,3 +1,6 @@
+/* $OpenBSD: config.h,v 1.2 1996/03/25 15:55:02 niklas Exp $ */
+/* $NetBSD: config.h,v 1.19 1996/03/03 17:28:08 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)config.h 8.1 (Berkeley) 6/6/93
- * $Id: config.h,v 1.1.1.1 1995/10/18 08:48:33 deraadt Exp $
*/
/*
diff --git a/usr.sbin/config/files.c b/usr.sbin/config/files.c
index a010ee37400..61574f5b004 100644
--- a/usr.sbin/config/files.c
+++ b/usr.sbin/config/files.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: files.c,v 1.3 1996/03/25 15:55:03 niklas Exp $ */
+/* $NetBSD: files.c,v 1.3 1996/03/03 17:28:10 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)files.c 8.1 (Berkeley) 6/6/93
- * $Id: files.c,v 1.2 1996/02/22 00:32:55 niklas Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y
index d7d030b53ad..3b197a85745 100644
--- a/usr.sbin/config/gram.y
+++ b/usr.sbin/config/gram.y
@@ -1,4 +1,6 @@
%{
+/* $OpenBSD: gram.y,v 1.2 1996/03/25 15:55:04 niklas Exp $ */
+/* $NetBSD: gram.y,v 1.3 1996/03/03 17:28:13 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -42,7 +44,6 @@
* SUCH DAMAGE.
*
* from: @(#)gram.y 8.1 (Berkeley) 6/6/93
- * $Id: gram.y,v 1.1.1.1 1995/10/18 08:48:33 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c
index 86df34a776b..e1290fd9456 100644
--- a/usr.sbin/config/hash.c
+++ b/usr.sbin/config/hash.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: hash.c,v 1.2 1996/03/25 15:55:05 niklas Exp $ */
+/* $NetBSD: hash.c,v 1.2 1996/03/03 17:28:15 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)hash.c 8.1 (Berkeley) 6/6/93
- * $Id: hash.c,v 1.1.1.1 1995/10/18 08:48:33 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 0830434a5ce..5a2539a6e5b 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: main.c,v 1.3 1996/03/25 15:55:06 niklas Exp $ */
+/* $NetBSD: main.c,v 1.13 1996/03/03 17:28:17 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)main.c 8.1 (Berkeley) 6/6/93
- * $Id: main.c,v 1.2 1995/12/15 18:54:35 deraadt Exp $
*/
#ifndef lint
diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c
index 12de3a7606f..91ddb8c28ac 100644
--- a/usr.sbin/config/mkheaders.c
+++ b/usr.sbin/config/mkheaders.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: mkheaders.c,v 1.2 1996/03/25 15:55:07 niklas Exp $ */
+/* $NetBSD: mkheaders.c,v 1.8 1996/03/03 17:28:20 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)mkheaders.c 8.1 (Berkeley) 6/6/93
- * $Id: mkheaders.c,v 1.1.1.1 1995/10/18 08:48:33 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c
index 593aa7892d8..56c40015a2e 100644
--- a/usr.sbin/config/mkioconf.c
+++ b/usr.sbin/config/mkioconf.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: mkioconf.c,v 1.2 1996/03/25 15:55:08 niklas Exp $ */
+/* $NetBSD: mkioconf.c,v 1.36 1996/03/03 17:28:23 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)mkioconf.c 8.1 (Berkeley) 6/6/93
- * $Id: mkioconf.c,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 042b00aa95b..237ea6c1a17 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: mkmakefile.c,v 1.2 1996/03/25 15:55:09 niklas Exp $ */
+/* $NetBSD: mkmakefile.c,v 1.27 1996/03/03 17:28:26 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)mkmakefile.c 8.1 (Berkeley) 6/6/93
- * $Id: mkmakefile.c,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <sys/param.h>
@@ -194,7 +196,7 @@ emitobjs(fp)
lpos += len + 1;
sp = ' ';
}
- if (lpos != 7 && putc('\n', fp) < 0)
+ if (putc('\n', fp) < 0)
return (1);
return (0);
}
@@ -276,7 +278,7 @@ emitfiles(fp, suffix)
sp = ' ';
}
}
- if (lpos != 7 && putc('\n', fp) < 0)
+ if (putc('\n', fp) < 0)
return (1);
return (0);
}
diff --git a/usr.sbin/config/mkswap.c b/usr.sbin/config/mkswap.c
index 01f3b00b458..83e86bb106c 100644
--- a/usr.sbin/config/mkswap.c
+++ b/usr.sbin/config/mkswap.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: mkswap.c,v 1.2 1996/03/25 15:55:10 niklas Exp $ */
+/* $NetBSD: mkswap.c,v 1.2 1996/03/03 17:28:29 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)mkswap.c 8.1 (Berkeley) 6/6/93
- * $Id: mkswap.c,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/pack.c b/usr.sbin/config/pack.c
index 4bb82796238..9e0b6330004 100644
--- a/usr.sbin/config/pack.c
+++ b/usr.sbin/config/pack.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: pack.c,v 1.2 1996/03/25 15:55:11 niklas Exp $ */
+/* $NetBSD: pack.c,v 1.2 1996/03/03 17:28:32 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)pack.c 8.1 (Berkeley) 6/6/93
- * $Id: pack.c,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l
index a4a2c0b1e23..9f211c640b1 100644
--- a/usr.sbin/config/scan.l
+++ b/usr.sbin/config/scan.l
@@ -1,4 +1,7 @@
%{
+/* $OpenBSD: scan.l,v 1.2 1996/03/25 15:55:12 niklas Exp $ */
+/* $NetBSD: scan.l,v 1.2 1996/03/03 17:28:34 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -41,7 +44,6 @@
* SUCH DAMAGE.
*
* from: @(#)scan.l 8.1 (Berkeley) 6/6/93
- * $Id: scan.l,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c
index 01a53f519ad..d0a69b5bfb1 100644
--- a/usr.sbin/config/sem.c
+++ b/usr.sbin/config/sem.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: sem.c,v 1.2 1996/03/25 15:55:13 niklas Exp $ */
+/* $NetBSD: sem.c,v 1.2 1996/03/03 17:28:37 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)sem.c 8.1 (Berkeley) 6/6/93
- * $Id: sem.c,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <sys/param.h>
diff --git a/usr.sbin/config/sem.h b/usr.sbin/config/sem.h
index 87b75e395e3..131762f7a47 100644
--- a/usr.sbin/config/sem.h
+++ b/usr.sbin/config/sem.h
@@ -1,3 +1,6 @@
+/* $OpenBSD: sem.h,v 1.2 1996/03/25 15:55:14 niklas Exp $ */
+/* $NetBSD: sem.h,v 1.2 1996/03/03 17:28:39 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)sem.h 8.1 (Berkeley) 6/6/93
- * $Id: sem.h,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
void enddefs __P((const char *));
diff --git a/usr.sbin/config/util.c b/usr.sbin/config/util.c
index 095a7763bdf..ca6b2eddb22 100644
--- a/usr.sbin/config/util.c
+++ b/usr.sbin/config/util.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: util.c,v 1.2 1996/03/25 15:55:16 niklas Exp $ */
+/* $NetBSD: util.c,v 1.2 1996/03/03 17:28:41 thorpej Exp $ */
+
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +43,6 @@
* SUCH DAMAGE.
*
* from: @(#)util.c 8.1 (Berkeley) 6/6/93
- * $Id: util.c,v 1.1.1.1 1995/10/18 08:48:34 deraadt Exp $
*/
#include <ctype.h>
diff --git a/usr.sbin/eeprom/defs.h b/usr.sbin/eeprom/defs.h
index 2b0edbe378a..35870dee007 100644
--- a/usr.sbin/eeprom/defs.h
+++ b/usr.sbin/eeprom/defs.h
@@ -1,9 +1,13 @@
-/* $NetBSD: defs.h,v 1.1 1995/07/13 18:08:56 thorpej Exp $ */
+/* $OpenBSD: defs.h,v 1.2 1996/03/25 15:55:18 niklas Exp $ */
+/* $NetBSD: defs.h,v 1.2 1996/02/28 01:13:20 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#undef BUFSIZE
diff --git a/usr.sbin/eeprom/eehandlers.c b/usr.sbin/eeprom/eehandlers.c
index 37f94a870fb..8dd5dd1f568 100644
--- a/usr.sbin/eeprom/eehandlers.c
+++ b/usr.sbin/eeprom/eehandlers.c
@@ -1,9 +1,13 @@
-/* $NetBSD: eehandlers.c,v 1.1 1995/07/13 18:10:29 thorpej Exp $ */
+/* $OpenBSD: eehandlers.c,v 1.3 1996/03/25 15:55:18 niklas Exp $ */
+/* $NetBSD: eehandlers.c,v 1.2 1996/02/28 01:13:22 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
diff --git a/usr.sbin/eeprom/eeprom.8 b/usr.sbin/eeprom/eeprom.8
index c8d9a002d10..7e05205cb59 100644
--- a/usr.sbin/eeprom/eeprom.8
+++ b/usr.sbin/eeprom/eeprom.8
@@ -1,8 +1,12 @@
-.\" $NetBSD: eeprom.8,v 1.1 1995/07/13 18:12:09 thorpej Exp $
+.\" $OpenBSD: eeprom.8,v 1.2 1996/03/25 15:55:20 niklas Exp $
+.\" $NetBSD: eeprom.8,v 1.2 1996/02/28 01:13:24 thorpej Exp $
.\"
-.\" Copyright (c) 1995 Jason R. Thorpe.
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jason R. Thorpe.
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -13,22 +17,23 @@
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
-.\" This product includes software developed for the NetBSD Project
-.\" by Jason R. Thorpe.
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 25, 1995
.Dt EEPROM 8
diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c
index 2bebe79f978..6d46a3643e4 100644
--- a/usr.sbin/eeprom/main.c
+++ b/usr.sbin/eeprom/main.c
@@ -1,9 +1,13 @@
-/* $NetBSD: main.c,v 1.1 1995/07/13 18:15:44 thorpej Exp $ */
+/* $OpenBSD: main.c,v 1.2 1996/03/25 15:55:21 niklas Exp $ */
+/* $NetBSD: main.c,v 1.2 1996/02/28 01:13:26 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
diff --git a/usr.sbin/eeprom/ophandlers.c b/usr.sbin/eeprom/ophandlers.c
index f1bd663570b..209f1353144 100644
--- a/usr.sbin/eeprom/ophandlers.c
+++ b/usr.sbin/eeprom/ophandlers.c
@@ -1,9 +1,13 @@
-/* $NetBSD: ophandlers.c,v 1.1 1995/07/13 18:17:28 thorpej Exp $ */
+/* $OpenBSD: ophandlers.c,v 1.2 1996/03/25 15:55:22 niklas Exp $ */
+/* $NetBSD: ophandlers.c,v 1.2 1996/02/28 01:13:30 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 0528607832c..986bd1d6b54 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -1,4 +1,5 @@
-/* $NetBSD: inetd.c,v 1.10 1995/06/02 15:02:18 pk Exp $ */
+/* $OpenBSD: inetd.c,v 1.2 1996/03/25 15:55:24 niklas Exp $ */
+/* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */
/*
* Copyright (c) 1983,1991 The Regents of the University of California.
* All rights reserved.
@@ -40,7 +41,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/
-static char rcsid[] = "$Id: inetd.c,v 1.1.1.1 1995/10/18 08:47:36 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: inetd.c,v 1.2 1996/03/25 15:55:24 niklas Exp $";
#endif /* not lint */
/*
@@ -561,14 +562,10 @@ config()
if (cp->se_bi == 0 &&
(sep->se_wait == 1 || cp->se_wait == 0))
sep->se_wait = cp->se_wait;
- if (cp->se_max != sep->se_max)
- SWAP(int, cp->se_max, sep->se_max);
- if (cp->se_user)
- SWAP(char *, sep->se_user, cp->se_user);
- if (cp->se_group)
- SWAP(char *, sep->se_group, cp->se_group);
- if (cp->se_server)
- SWAP(char *, sep->se_server, cp->se_server);
+ SWAP(int, cp->se_max, sep->se_max);
+ SWAP(char *, sep->se_user, cp->se_user);
+ SWAP(char *, sep->se_group, cp->se_group);
+ SWAP(char *, sep->se_server, cp->se_server);
for (i = 0; i < MAXARGV; i++)
SWAP(char *, sep->se_argv[i], cp->se_argv[i]);
#undef SWAP
diff --git a/usr.sbin/pppd/Makefile b/usr.sbin/pppd/Makefile
index 5b789228ff0..c171acc470a 100644
--- a/usr.sbin/pppd/Makefile
+++ b/usr.sbin/pppd/Makefile
@@ -1,8 +1,10 @@
-# $Id: Makefile,v 1.2 1996/02/15 04:18:02 etheisen Exp $
+# $OpenBSD: Makefile,v 1.3 1996/03/25 15:55:29 niklas Exp $
PROG= pppd
SRCS= main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
- auth.c options.c sys-bsd.c
+ auth.c options.c sys-bsd.c demand.c gencode.c grammar.c scanner.c \
+ nametoaddr.c optimize.c bpf_filter.c
+.PATH: ${.CURDIR}/../../lib/libpcap ${.CURDIR}/../../sys/net
MAN= pppd.8
SUBDIR= pppstats chat
BINMODE=4555
diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c
index 620199ff851..ca66c3cb161 100644
--- a/usr.sbin/pppd/auth.c
+++ b/usr.sbin/pppd/auth.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: auth.c,v 1.2 1996/03/25 15:55:30 niklas Exp $ */
+
/*
* auth.c - PPP authentication and phase control.
*
@@ -33,17 +35,19 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: auth.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: auth.c,v 1.2 1996/03/25 15:55:30 niklas Exp $";
#endif
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
+#include <unistd.h>
#include <syslog.h>
#include <pwd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
@@ -60,10 +64,9 @@ static char rcsid[] = "$Id: auth.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
#include "pppd.h"
#include "fsm.h"
#include "lcp.h"
+#include "ipcp.h"
#include "upap.h"
#include "chap.h"
-#include "ipcp.h"
-#include "ccp.h"
#include "pathnames.h"
#if defined(sun) && defined(sparc)
@@ -87,31 +90,40 @@ struct wordlist {
/* Records which authentication operations haven't completed yet. */
static int auth_pending[NUM_PPP];
+
+/* Set if we have successfully called login() */
static int logged_in;
+
+/* List of addresses which the peer may use. */
static struct wordlist *addresses[NUM_PPP];
+/* Number of network protocols which we have opened. */
+static int num_np_open;
+
+/* Number of network protocols which have come up. */
+static int num_np_up;
+
/* Bits in auth_pending[] */
#define UPAP_WITHPEER 1
#define UPAP_PEER 2
#define CHAP_WITHPEER 4
#define CHAP_PEER 8
-/* Prototypes */
-void check_access __P((FILE *, char *));
+/* Prototypes for procedures local to this file. */
static void network_phase __P((int));
+static void check_idle __P((caddr_t));
static int login __P((char *, char *, char **, int *));
static void logout __P((void));
static int null_login __P((int));
static int get_upap_passwd __P((void));
static int have_upap_secret __P((void));
-static int have_chap_secret __P((char *, char *));
-static int scan_authfile __P((FILE *, char *, char *, char *,
- struct wordlist **, char *));
+static int have_chap_secret __P((char *, char *, u_int32_t));
+static int ip_addr_check __P((u_int32_t, struct wordlist *));
+static int scan_authfile __P((FILE *, char *, char *, u_int32_t, char *,
+ struct wordlist **, char *));
static void free_wordlist __P((struct wordlist *));
-extern char *crypt __P((char *, char *));
-
/*
* An Open on LCP has requested a change from Dead to Establish phase.
* Do what's necessary to bring the physical layer up.
@@ -145,8 +157,19 @@ void
link_down(unit)
int unit;
{
- ipcp_close(0);
- ccp_close(0);
+ int i;
+ struct protent *protp;
+
+ for (i = 0; (protp = protocols[i]) != NULL; ++i) {
+ if (!protp->enabled_flag)
+ continue;
+ if (protp->protocol != PPP_LCP && protp->lowerdown != NULL)
+ (*protp->lowerdown)(unit);
+ if (protp->protocol < 0xC000 && protp->close != NULL)
+ (*protp->close)(unit);
+ }
+ num_np_open = 0;
+ num_np_up = 0;
phase = PHASE_TERMINATE;
}
@@ -162,6 +185,16 @@ link_established(unit)
lcp_options *wo = &lcp_wantoptions[unit];
lcp_options *go = &lcp_gotoptions[unit];
lcp_options *ho = &lcp_hisoptions[unit];
+ int i;
+ struct protent *protp;
+
+ /*
+ * Tell higher-level protocols that LCP is up.
+ */
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->protocol != PPP_LCP && protp->enabled_flag
+ && protp->lowerup != NULL)
+ (*protp->lowerup)(unit);
if (auth_required && !(go->neg_chap || go->neg_upap)) {
/*
@@ -171,7 +204,7 @@ link_established(unit)
*/
if (!wo->neg_upap || !null_login(unit)) {
syslog(LOG_WARNING, "peer refused to authenticate");
- lcp_close(unit);
+ lcp_close(unit, "peer refused to authenticate");
phase = PHASE_TERMINATE;
return;
}
@@ -206,9 +239,19 @@ static void
network_phase(unit)
int unit;
{
+ int i;
+ struct protent *protp;
+
phase = PHASE_NETWORK;
- ipcp_open(unit);
- ccp_open(unit);
+ if (!demand)
+ set_filters(&pass_filter, &active_filter);
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->protocol < 0xC000 && protp->enabled_flag
+ && protp->open != NULL) {
+ (*protp->open)(unit);
+ if (protp->protocol != PPP_CCP)
+ ++num_np_open;
+ }
}
/*
@@ -221,7 +264,7 @@ auth_peer_fail(unit, protocol)
/*
* Authentication failure: take the link down
*/
- lcp_close(unit);
+ lcp_close(unit, "Authentication failed");
phase = PHASE_TERMINATE;
}
@@ -251,11 +294,8 @@ auth_peer_success(unit, protocol)
* If there is no more authentication still to be done,
* proceed to the network phase.
*/
- if ((auth_pending[unit] &= ~bit) == 0) {
- phase = PHASE_NETWORK;
- ipcp_open(unit);
- ccp_open(unit);
- }
+ if ((auth_pending[unit] &= ~bit) == 0)
+ network_phase(unit);
}
/*
@@ -304,13 +344,76 @@ auth_withpeer_success(unit, protocol)
/*
- * check_auth_options - called to check authentication options.
+ * np_up - a network protocol has come up.
+ */
+void
+np_up(unit, proto)
+ int unit, proto;
+{
+ if (num_np_up == 0 && idle_time_limit > 0) {
+ TIMEOUT(check_idle, NULL, idle_time_limit);
+ }
+ ++num_np_up;
+}
+
+/*
+ * np_down - a network protocol has gone down.
+ */
+void
+np_down(unit, proto)
+ int unit, proto;
+{
+ if (--num_np_up == 0 && idle_time_limit > 0) {
+ UNTIMEOUT(check_idle, NULL);
+ }
+}
+
+/*
+ * np_finished - a network protocol has finished using the link.
+ */
+void
+np_finished(unit, proto)
+ int unit, proto;
+{
+ if (--num_np_open <= 0) {
+ /* no further use for the link: shut up shop. */
+ lcp_close(0, "No network protocols running");
+ }
+}
+
+/*
+ * check_idle - check whether the link has been idle for long
+ * enough that we can shut it down.
+ */
+static void
+check_idle(arg)
+ caddr_t arg;
+{
+ struct ppp_idle idle;
+ time_t itime;
+
+ if (!get_idle_time(0, &idle))
+ return;
+ itime = MIN(idle.xmit_idle, idle.recv_idle);
+ if (itime >= idle_time_limit) {
+ /* link is idle: shut it down. */
+ syslog(LOG_INFO, "Terminating connection due to lack of activity.");
+ lcp_close(0, "Link inactive");
+ } else {
+ TIMEOUT(check_idle, NULL, idle_time_limit - itime);
+ }
+}
+
+/*
+ * auth_check_options - called to check authentication options.
*/
void
-check_auth_options()
+auth_check_options()
{
lcp_options *wo = &lcp_wantoptions[0];
lcp_options *ao = &lcp_allowoptions[0];
+ ipcp_options *ipwo = &ipcp_wantoptions[0];
+ u_int32_t remote;
/* Default our_name to hostname, and user to our_name */
if (our_name[0] == 0 || usehostname)
@@ -332,14 +435,17 @@ check_auth_options()
ao->neg_upap = 0;
if (wo->neg_upap && !uselogin && !have_upap_secret())
wo->neg_upap = 0;
- if (ao->neg_chap && !have_chap_secret(our_name, remote_name))
+ if (ao->neg_chap && !have_chap_secret(our_name, remote_name, (u_int32_t)0))
ao->neg_chap = 0;
- if (wo->neg_chap && !have_chap_secret(remote_name, our_name))
- wo->neg_chap = 0;
+ if (wo->neg_chap) {
+ remote = ipwo->accept_remote? 0: ipwo->hisaddr;
+ if (!have_chap_secret(remote_name, our_name, remote))
+ wo->neg_chap = 0;
+ }
if (auth_required && !wo->neg_chap && !wo->neg_upap) {
fprintf(stderr, "\
-pppd: peer authentication required but no authentication files accessible\n");
+pppd: peer authentication required but no suitable secret(s) found\n");
exit(1);
}
@@ -370,6 +476,8 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen)
char *filename;
FILE *f;
struct wordlist *addrs;
+ u_int32_t remote;
+ ipcp_options *ipwo = &ipcp_wantoptions[unit];
char passwd[256], user[256];
char secret[MAXWORDLEN];
static int attempts = 0;
@@ -392,16 +500,18 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen)
f = fopen(filename, "r");
if (f == NULL) {
if (!uselogin) {
- syslog(LOG_ERR, "Can't open upap password file %s: %m", filename);
+ syslog(LOG_ERR, "Can't open PAP password file %s: %m", filename);
ret = UPAP_AUTHNAK;
}
} else {
check_access(f, filename);
- if (scan_authfile(f, user, our_name, secret, &addrs, filename) < 0
+ remote = ipwo->accept_remote? 0: ipwo->hisaddr;
+ if (scan_authfile(f, user, our_name, remote,
+ secret, &addrs, filename) < 0
|| (secret[0] != 0 && (cryptpap || strcmp(passwd, secret) != 0)
&& strcmp(crypt(passwd, secret), secret) != 0)) {
- syslog(LOG_WARNING, "upap authentication failure for %s", user);
+ syslog(LOG_WARNING, "PAP authentication failure for %s", user);
ret = UPAP_AUTHNAK;
}
fclose(f);
@@ -410,7 +520,7 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen)
if (uselogin && ret == UPAP_AUTHACK) {
ret = login(user, passwd, msg, msglen);
if (ret == UPAP_AUTHNAK) {
- syslog(LOG_WARNING, "upap login failure for %s", user);
+ syslog(LOG_WARNING, "PAP login failure for %s", user);
}
}
@@ -510,7 +620,7 @@ login(user, passwd, msg, msglen)
tty = devnam;
if (strncmp(tty, "/dev/", 5) == 0)
tty += 5;
- logwtmp(tty, user, ""); /* Add wtmp login entry */
+ logwtmp(tty, user, remote_name); /* Add wtmp login entry */
logged_in = TRUE;
return (UPAP_AUTHACK);
@@ -558,7 +668,7 @@ null_login(unit)
return 0;
check_access(f, filename);
- i = scan_authfile(f, "", our_name, secret, &addrs, filename);
+ i = scan_authfile(f, "", our_name, (u_int32_t)0, secret, &addrs, filename);
ret = i >= 0 && (i & NONWILD_CLIENT) != 0 && secret[0] == 0;
if (ret) {
@@ -591,7 +701,8 @@ get_upap_passwd()
if (f == NULL)
return 0;
check_access(f, filename);
- if (scan_authfile(f, user, remote_name, secret, NULL, filename) < 0)
+ if (scan_authfile(f, user, remote_name, (u_int32_t)0,
+ secret, NULL, filename) < 0)
return 0;
strncpy(passwd, secret, MAXSECRETLEN);
passwd[MAXSECRETLEN-1] = 0;
@@ -609,13 +720,16 @@ have_upap_secret()
FILE *f;
int ret;
char *filename;
+ ipcp_options *ipwo = &ipcp_wantoptions[0];
+ u_int32_t remote;
filename = _PATH_UPAPFILE;
f = fopen(filename, "r");
if (f == NULL)
return 0;
- ret = scan_authfile(f, NULL, our_name, NULL, NULL, filename);
+ remote = ipwo->accept_remote? 0: ipwo->hisaddr;
+ ret = scan_authfile(f, NULL, our_name, remote, NULL, NULL, filename);
fclose(f);
if (ret < 0)
return 0;
@@ -631,9 +745,10 @@ have_upap_secret()
* know the identity yet.
*/
static int
-have_chap_secret(client, server)
+have_chap_secret(client, server, remote)
char *client;
char *server;
+ u_int32_t remote;
{
FILE *f;
int ret;
@@ -649,7 +764,7 @@ have_chap_secret(client, server)
else if (server[0] == 0)
server = NULL;
- ret = scan_authfile(f, client, server, NULL, NULL, filename);
+ ret = scan_authfile(f, client, server, remote, NULL, NULL, filename);
fclose(f);
if (ret < 0)
return 0;
@@ -689,7 +804,8 @@ get_secret(unit, client, server, secret, secret_len, save_addrs)
}
check_access(f, filename);
- ret = scan_authfile(f, client, server, secbuf, &addrs, filename);
+ ret = scan_authfile(f, client, server, (u_int32_t)0,
+ secbuf, &addrs, filename);
fclose(f);
if (ret < 0)
return 0;
@@ -720,31 +836,87 @@ auth_ip_addr(unit, addr)
int unit;
u_int32_t addr;
{
- u_int32_t a;
- struct hostent *hp;
+ return ip_addr_check(addr, addresses[unit]);
+}
+
+static int
+ip_addr_check(addr, addrs)
+ u_int32_t addr;
struct wordlist *addrs;
+{
+ u_int32_t a, mask, ah;
+ int accept;
+ char *ptr_word, *ptr_mask;
+ struct hostent *hp;
+ struct netent *np;
/* don't allow loopback or multicast address */
if (bad_ip_adrs(addr))
return 0;
- if ((addrs = addresses[unit]) == NULL)
+ if (addrs == NULL)
return 1; /* no restriction */
for (; addrs != NULL; addrs = addrs->next) {
/* "-" means no addresses authorized */
- if (strcmp(addrs->word, "-") == 0)
+ ptr_word = addrs->word;
+ if (strcmp(ptr_word, "-") == 0)
break;
- if ((a = inet_addr(addrs->word)) == -1) {
- if ((hp = gethostbyname(addrs->word)) == NULL) {
- syslog(LOG_WARNING, "unknown host %s in auth. address list",
- addrs->word);
+
+ accept = 1;
+ if (*ptr_word == '!') {
+ accept = 0;
+ ++ptr_word;
+ }
+
+ mask = ~ (u_int32_t) 0;
+ ptr_mask = strchr (ptr_word, '/');
+ if (ptr_mask != NULL) {
+ int bit_count;
+
+ bit_count = (int) strtol (ptr_mask+1, (char **) 0, 10);
+ if (bit_count <= 0 || bit_count > 32) {
+ syslog (LOG_WARNING,
+ "invalid address length %s in auth. address list",
+ ptr_mask);
continue;
- } else
- a = *(u_int32_t *)hp->h_addr;
+ }
+ *ptr_mask = '\0';
+ mask <<= 32 - bit_count;
+ }
+
+ hp = gethostbyname(ptr_word);
+ if (hp != NULL && hp->h_addrtype == AF_INET) {
+ a = *(u_int32_t *)hp->h_addr;
+ mask = ~ (u_int32_t) 0; /* are we sure we want this? */
+ } else {
+ np = getnetbyname (ptr_word);
+ if (np != NULL && np->n_addrtype == AF_INET)
+ a = htonl (*(u_int32_t *)np->n_net);
+ else
+ a = inet_addr (ptr_word);
+ if (ptr_mask == NULL) {
+ /* calculate appropriate mask for net */
+ ah = ntohl(a);
+ if (IN_CLASSA(ah))
+ mask = IN_CLASSA_NET;
+ else if (IN_CLASSB(ah))
+ mask = IN_CLASSB_NET;
+ else if (IN_CLASSC(ah))
+ mask = IN_CLASSC_NET;
+ }
}
- if (addr == a)
- return 1;
+
+ if (ptr_mask != NULL)
+ *ptr_mask = '/';
+
+ if (a == -1L)
+ syslog (LOG_WARNING,
+ "unknown host %s in auth. address list",
+ addrs->word);
+ else
+ if (((addr ^ a) & htonl(mask)) == 0)
+ return accept;
}
return 0; /* not in list => can't have it */
}
@@ -791,10 +963,11 @@ check_access(f, filename)
* info) are placed in a wordlist and returned in *addrs.
*/
static int
-scan_authfile(f, client, server, secret, addrs, filename)
+scan_authfile(f, client, server, ipaddr, secret, addrs, filename)
FILE *f;
char *client;
char *server;
+ u_int32_t ipaddr;
char *secret;
struct wordlist **addrs;
char *filename;
@@ -802,9 +975,10 @@ scan_authfile(f, client, server, secret, addrs, filename)
int newline, xxx;
int got_flag, best_flag;
FILE *sf;
- struct wordlist *ap, *addr_list, *addr_last;
+ struct wordlist *ap, *addr_list, *alist, *alast;
char word[MAXWORDLEN];
char atfile[MAXWORDLEN];
+ char lsecret[MAXWORDLEN];
if (addrs != NULL)
*addrs = NULL;
@@ -880,16 +1054,12 @@ scan_authfile(f, client, server, secret, addrs, filename)
fclose(sf);
}
if (secret != NULL)
- strcpy(secret, word);
-
- best_flag = got_flag;
+ strcpy(lsecret, word);
/*
* Now read address authorization info and make a wordlist.
*/
- if (addr_list)
- free_wordlist(addr_list);
- addr_list = addr_last = NULL;
+ alist = alast = NULL;
for (;;) {
if (!getword(f, word, &newline, filename) || newline)
break;
@@ -899,12 +1069,31 @@ scan_authfile(f, client, server, secret, addrs, filename)
novm("authorized addresses");
ap->next = NULL;
strcpy(ap->word, word);
- if (addr_list == NULL)
- addr_list = ap;
+ if (alist == NULL)
+ alist = ap;
else
- addr_last->next = ap;
- addr_last = ap;
+ alast->next = ap;
+ alast = ap;
}
+
+ /*
+ * Check if the given IP address is allowed by the wordlist.
+ */
+ if (ipaddr != 0 && !ip_addr_check(ipaddr, alist)) {
+ free_wordlist(alist);
+ continue;
+ }
+
+ /*
+ * This is the best so far; remember it.
+ */
+ best_flag = got_flag;
+ if (addr_list)
+ free_wordlist(addr_list);
+ addr_list = alist;
+ if (secret != NULL)
+ strcpy(secret, lsecret);
+
if (!newline)
break;
}
diff --git a/usr.sbin/pppd/bpf_compile.h b/usr.sbin/pppd/bpf_compile.h
new file mode 100644
index 00000000000..583e6781d5d
--- /dev/null
+++ b/usr.sbin/pppd/bpf_compile.h
@@ -0,0 +1,72 @@
+/* $OpenBSD: bpf_compile.h,v 1.1 1996/03/25 15:55:31 niklas Exp $ */
+
+/*
+ * Copyright (c) 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Computer Systems
+ * Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: NetBSD: pcap.h,v 1.2 1995/03/06 11:39:07 mycroft Exp
+ * from: @(#) Header: pcap.h,v 1.15 94/06/14 20:03:34 leres Exp (LBL)
+ */
+
+#ifndef _BPF_COMPILE_H
+#define _BPF_COMPILE_H
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <net/bpf.h>
+
+#define PCAP_ERRBUF_SIZE 256
+
+int bpf_compile __P((struct bpf_program *, char *, int));
+char *bpf_geterr __P((void));
+
+unsigned int bpf_filter __P((struct bpf_insn *, unsigned char *,
+ unsigned int, unsigned int));
+
+unsigned long **pcap_nametoaddr __P((const char *));
+unsigned long pcap_nametonetaddr __P((const char *));
+
+int pcap_nametoport __P((const char *, int *, int *));
+int pcap_nametoproto __P((const char *));
+int pcap_nametopppproto __P((const char *));
+
+/*
+ * If a protocol is unknown, PROTO_UNDEF is returned.
+ * Also, pcap_nametoport() returns the protocol along with the port number.
+ * If there are ambiguous entries in /etc/services (i.e. domain
+ * can be either tcp or udp) PROTO_UNDEF is returned.
+ */
+#define PROTO_UNDEF -1
+
+unsigned long __pcap_atoin __P((const char *));
+
+#endif /* _BPF_COMPILE_H */
diff --git a/usr.sbin/pppd/ccp.c b/usr.sbin/pppd/ccp.c
index ca14b6ed9a8..5effc67caf0 100644
--- a/usr.sbin/pppd/ccp.c
+++ b/usr.sbin/pppd/ccp.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: ccp.c,v 1.2 1996/03/25 15:55:32 niklas Exp $ */
+
/*
* ccp.c - PPP Compression Control Protocol.
*
@@ -26,7 +28,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: ccp.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ccp.c,v 1.2 1996/03/25 15:55:32 niklas Exp $";
#endif
#include <string.h>
@@ -38,6 +40,12 @@ static char rcsid[] = "$Id: ccp.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
#include "fsm.h"
#include "ccp.h"
+struct protent ccp_protent = {
+ PPP_CCP, ccp_init, ccp_input, ccp_protrej,
+ ccp_lowerup, ccp_lowerdown, ccp_open, ccp_close,
+ ccp_printpkt, ccp_datainput, 1, "CCP", NULL, NULL
+};
+
fsm ccp_fsm[NUM_PPP];
ccp_options ccp_wantoptions[NUM_PPP]; /* what to request the peer to use */
ccp_options ccp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
@@ -80,10 +88,11 @@ static fsm_callbacks ccp_callbacks = {
/*
* Do we want / did we get any compression?
*/
-#define ANY_COMPRESS(opt) ((opt).bsd_compress)
+#define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
+ || (opt).predictor_1 || (opt).predictor_2)
/*
- * Local state (mainly for handling reset-reqs and reset-acks
+ * Local state (mainly for handling reset-reqs and reset-acks).
*/
static int ccp_localstate[NUM_PPP];
#define RACK_PENDING 1 /* waiting for reset-ack */
@@ -91,6 +100,8 @@ static int ccp_localstate[NUM_PPP];
#define RACKTIMEOUT 1 /* second */
+static int all_rejected[NUM_PPP]; /* we rejected all peer's options */
+
/*
* ccp_init - initialize CCP.
*/
@@ -110,11 +121,17 @@ ccp_init(unit)
memset(&ccp_allowoptions[unit], 0, sizeof(ccp_options));
memset(&ccp_hisoptions[unit], 0, sizeof(ccp_options));
- ccp_wantoptions[0].bsd_compress = 1;
- ccp_wantoptions[0].bsd_bits = 12; /* default value */
+ ccp_wantoptions[0].deflate = 1;
+ ccp_wantoptions[0].deflate_size = DEFLATE_MAX_SIZE;
+ ccp_allowoptions[0].deflate = 1;
+ ccp_allowoptions[0].deflate_size = DEFLATE_MAX_SIZE;
+ ccp_wantoptions[0].bsd_compress = 1;
+ ccp_wantoptions[0].bsd_bits = BSD_MAX_BITS;
ccp_allowoptions[0].bsd_compress = 1;
ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
+
+ ccp_allowoptions[0].predictor_1 = 1;
}
/*
@@ -137,11 +154,12 @@ ccp_open(unit)
* ccp_close - Terminate CCP.
*/
void
-ccp_close(unit)
+ccp_close(unit, reason)
int unit;
+ char *reason;
{
ccp_flags_set(unit, 0, 0);
- fsm_close(&ccp_fsm[unit]);
+ fsm_close(&ccp_fsm[unit], reason);
}
/*
@@ -190,7 +208,7 @@ ccp_input(unit, p, len)
*/
if (oldstate == REQSENT && p[0] == TERMACK
&& !ANY_COMPRESS(ccp_gotoptions[unit]))
- ccp_close(unit);
+ ccp_close(unit, "No compression negotiated");
}
/*
@@ -248,13 +266,39 @@ ccp_resetci(f)
u_char opt_buf[16];
*go = ccp_wantoptions[f->unit];
+ all_rejected[f->unit] = 0;
+
+ /*
+ * Check whether the kernel knows about the various
+ * compression methods we might request.
+ */
if (go->bsd_compress) {
opt_buf[0] = CI_BSD_COMPRESS;
opt_buf[1] = CILEN_BSD_COMPRESS;
- opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
- if (!ccp_test(f->unit, opt_buf, CILEN_BSD_COMPRESS, 0))
+ opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, BSD_MIN_BITS);
+ if (ccp_test(f->unit, opt_buf, CILEN_BSD_COMPRESS, 0) <= 0)
go->bsd_compress = 0;
}
+ if (go->deflate) {
+ opt_buf[0] = CI_DEFLATE;
+ opt_buf[1] = CILEN_DEFLATE;
+ opt_buf[2] = DEFLATE_MAKE_OPT(DEFLATE_MIN_SIZE);
+ opt_buf[3] = DEFLATE_CHK_SEQUENCE;
+ if (ccp_test(f->unit, opt_buf, CILEN_DEFLATE, 0) <= 0)
+ go->deflate = 0;
+ }
+ if (go->predictor_1) {
+ opt_buf[0] = CI_PREDICTOR_1;
+ opt_buf[1] = CILEN_PREDICTOR_1;
+ if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_1, 0) <= 0)
+ go->predictor_1 = 0;
+ }
+ if (go->predictor_2) {
+ opt_buf[0] = CI_PREDICTOR_2;
+ opt_buf[1] = CILEN_PREDICTOR_2;
+ if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_2, 0) <= 0)
+ go->predictor_2 = 0;
+ }
}
/*
@@ -266,7 +310,10 @@ ccp_cilen(f)
{
ccp_options *go = &ccp_gotoptions[f->unit];
- return (go->bsd_compress? CILEN_BSD_COMPRESS: 0);
+ return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
+ + (go->deflate? CILEN_DEFLATE: 0)
+ + (go->predictor_1? CILEN_PREDICTOR_1: 0)
+ + (go->predictor_2? CILEN_PREDICTOR_2: 0);
}
/*
@@ -278,18 +325,76 @@ ccp_addci(f, p, lenp)
u_char *p;
int *lenp;
{
+ int res;
ccp_options *go = &ccp_gotoptions[f->unit];
u_char *p0 = p;
+ /*
+ * Add the compression types that we can receive, in decreasing
+ * preference order. Get the kernel to allocate the first one
+ * in case it gets Acked.
+ */
+ if (go->deflate) {
+ p[0] = CI_DEFLATE;
+ p[1] = CILEN_DEFLATE;
+ p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
+ p[3] = DEFLATE_CHK_SEQUENCE;
+ for (;;) {
+ res = ccp_test(f->unit, p, CILEN_DEFLATE, 0);
+ if (res > 0) {
+ p += CILEN_DEFLATE;
+ break;
+ }
+ if (res < 0 || go->deflate_size <= DEFLATE_MIN_SIZE) {
+ go->deflate = 0;
+ break;
+ }
+ --go->deflate_size;
+ p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
+ }
+ }
if (go->bsd_compress) {
p[0] = CI_BSD_COMPRESS;
p[1] = CILEN_BSD_COMPRESS;
p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
- if (ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 0))
- p += CILEN_BSD_COMPRESS;
- else
- go->bsd_compress = 0;
+ if (p != p0) {
+ p += CILEN_BSD_COMPRESS; /* not the first option */
+ } else {
+ for (;;) {
+ res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 0);
+ if (res > 0) {
+ p += CILEN_BSD_COMPRESS;
+ break;
+ }
+ if (res < 0 || go->bsd_bits <= BSD_MIN_BITS) {
+ go->bsd_compress = 0;
+ break;
+ }
+ --go->bsd_bits;
+ p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
+ }
+ }
+ }
+ /* XXX Should Predictor 2 be preferable to Predictor 1? */
+ if (go->predictor_1) {
+ p[0] = CI_PREDICTOR_1;
+ p[1] = CILEN_PREDICTOR_1;
+ if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 0) <= 0) {
+ go->predictor_1 = 0;
+ } else {
+ p += CILEN_PREDICTOR_1;
+ }
+ }
+ if (go->predictor_2) {
+ p[0] = CI_PREDICTOR_2;
+ p[1] = CILEN_PREDICTOR_2;
+ if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 0) <= 0) {
+ go->predictor_2 = 0;
+ } else {
+ p += CILEN_PREDICTOR_2;
+ }
}
+
*lenp = p - p0;
}
@@ -304,7 +409,20 @@ ccp_ackci(f, p, len)
int len;
{
ccp_options *go = &ccp_gotoptions[f->unit];
+ u_char *p0 = p;
+ if (go->deflate) {
+ if (len < CILEN_DEFLATE
+ || p[0] != CI_DEFLATE || p[1] != CILEN_DEFLATE
+ || p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
+ || p[3] != DEFLATE_CHK_SEQUENCE)
+ return 0;
+ p += CILEN_DEFLATE;
+ len -= CILEN_DEFLATE;
+ /* XXX Cope with first/fast ack */
+ if (len == 0)
+ return 1;
+ }
if (go->bsd_compress) {
if (len < CILEN_BSD_COMPRESS
|| p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS
@@ -312,7 +430,31 @@ ccp_ackci(f, p, len)
return 0;
p += CILEN_BSD_COMPRESS;
len -= CILEN_BSD_COMPRESS;
+ /* XXX Cope with first/fast ack */
+ if (p == p0 && len == 0)
+ return 1;
+ }
+ if (go->predictor_1) {
+ if (len < CILEN_PREDICTOR_1
+ || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1)
+ return 0;
+ p += CILEN_PREDICTOR_1;
+ len -= CILEN_PREDICTOR_1;
+ /* XXX Cope with first/fast ack */
+ if (p == p0 && len == 0)
+ return 1;
}
+ if (go->predictor_2) {
+ if (len < CILEN_PREDICTOR_2
+ || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2)
+ return 0;
+ p += CILEN_PREDICTOR_2;
+ len -= CILEN_PREDICTOR_2;
+ /* XXX Cope with first/fast ack */
+ if (p == p0 && len == 0)
+ return 1;
+ }
+
if (len != 0)
return 0;
return 1;
@@ -335,7 +477,24 @@ ccp_nakci(f, p, len)
memset(&no, 0, sizeof(no));
try = *go;
- if (go->bsd_compress && !no.bsd_compress && len >= CILEN_BSD_COMPRESS
+ if (go->deflate && len >= CILEN_DEFLATE
+ && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
+ no.deflate = 1;
+ /*
+ * Peer wants us to use a different code size or something.
+ * Stop asking for Deflate if we don't understand his suggestion.
+ */
+ if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
+ || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_SIZE
+ || p[3] != DEFLATE_CHK_SEQUENCE)
+ try.deflate = 0;
+ else if (DEFLATE_SIZE(p[2]) < go->deflate_size)
+ go->deflate_size = DEFLATE_SIZE(p[2]);
+ p += CILEN_DEFLATE;
+ len -= CILEN_DEFLATE;
+ }
+
+ if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
&& p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
no.bsd_compress = 1;
/*
@@ -351,7 +510,9 @@ ccp_nakci(f, p, len)
}
/*
- * Have a look at any remaining options...???
+ * Predictor-1 and 2 have no options, so they can't be Naked.
+ *
+ * XXX What should we do with any remaining options?
*/
if (len != 0)
@@ -376,6 +537,22 @@ ccp_rejci(f, p, len)
try = *go;
+ /*
+ * Cope with empty configure-rejects by ceasing to send
+ * configure-requests.
+ */
+ if (len == 0 && all_rejected[f->unit])
+ return -1;
+
+ if (go->deflate && len >= CILEN_DEFLATE
+ && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
+ if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
+ || p[3] != DEFLATE_CHK_SEQUENCE)
+ return 0; /* Rej is bad */
+ try.deflate = 0;
+ p += CILEN_DEFLATE;
+ len -= CILEN_DEFLATE;
+ }
if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
&& p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
@@ -384,6 +561,18 @@ ccp_rejci(f, p, len)
p += CILEN_BSD_COMPRESS;
len -= CILEN_BSD_COMPRESS;
}
+ if (go->predictor_1 && len >= CILEN_PREDICTOR_1
+ && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) {
+ try.predictor_1 = 0;
+ p += CILEN_PREDICTOR_1;
+ len -= CILEN_PREDICTOR_1;
+ }
+ if (go->predictor_2 && len >= CILEN_PREDICTOR_2
+ && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) {
+ try.predictor_2 = 0;
+ p += CILEN_PREDICTOR_2;
+ len -= CILEN_PREDICTOR_2;
+ }
if (len != 0)
return 0;
@@ -406,7 +595,7 @@ ccp_reqci(f, p, lenp, dont_nak)
int *lenp;
int dont_nak;
{
- int ret, newret;
+ int ret, newret, res;
u_char *p0, *retp;
int len, clen, type, nb;
ccp_options *ho = &ccp_hisoptions[f->unit];
@@ -430,6 +619,48 @@ ccp_reqci(f, p, lenp, dont_nak)
clen = p[1];
switch (type) {
+ case CI_DEFLATE:
+ if (!ao->deflate || clen != CILEN_DEFLATE) {
+ newret = CONFREJ;
+ break;
+ }
+
+ ho->deflate = 1;
+ ho->deflate_size = nb = DEFLATE_SIZE(p[2]);
+ if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
+ || p[3] != DEFLATE_CHK_SEQUENCE
+ || nb > ao->deflate_size || nb < DEFLATE_MIN_SIZE) {
+ newret = CONFNAK;
+ if (!dont_nak) {
+ p[2] = DEFLATE_MAKE_OPT(ao->deflate_size);
+ p[3] = DEFLATE_CHK_SEQUENCE;
+ }
+ break;
+ }
+
+ /*
+ * Check whether we can do Deflate with the window
+ * size they want. If the window is too big, reduce
+ * it until the kernel can cope and nak with that.
+ * We only check this for the first option.
+ */
+ if (p == p0) {
+ for (;;) {
+ res = ccp_test(f->unit, p, CILEN_DEFLATE, 1);
+ if (res > 0)
+ break; /* it's OK now */
+ if (res < 0 || nb == DEFLATE_MIN_SIZE || dont_nak) {
+ newret = CONFREJ;
+ p[2] = DEFLATE_MAKE_OPT(ho->deflate_size);
+ break;
+ }
+ newret = CONFNAK;
+ --nb;
+ p[2] = DEFLATE_MAKE_OPT(nb);
+ }
+ }
+ break;
+
case CI_BSD_COMPRESS:
if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) {
newret = CONFREJ;
@@ -439,22 +670,61 @@ ccp_reqci(f, p, lenp, dont_nak)
ho->bsd_compress = 1;
ho->bsd_bits = nb = BSD_NBITS(p[2]);
if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION
- || nb > ao->bsd_bits) {
+ || nb > ao->bsd_bits || nb < BSD_MIN_BITS) {
newret = CONFNAK;
- nb = ao->bsd_bits;
- } else if (nb < BSD_MIN_BITS) {
- newret = CONFREJ;
- } else if (!ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 1)) {
- if (nb > BSD_MIN_BITS) {
- --nb;
+ if (!dont_nak)
+ p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits);
+ break;
+ }
+
+ /*
+ * Check whether we can do BSD-Compress with the code
+ * size they want. If the code size is too big, reduce
+ * it until the kernel can cope and nak with that.
+ * We only check this for the first option.
+ */
+ if (p == p0) {
+ for (;;) {
+ res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 1);
+ if (res > 0)
+ break;
+ if (res < 0 || nb == BSD_MIN_BITS || dont_nak) {
+ newret = CONFREJ;
+ p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION,
+ ho->bsd_bits);
+ break;
+ }
newret = CONFNAK;
- } else
- newret = CONFREJ;
+ --nb;
+ p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb);
+ }
+ }
+ break;
+
+ case CI_PREDICTOR_1:
+ if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) {
+ newret = CONFREJ;
+ break;
+ }
+
+ ho->predictor_1 = 1;
+ if (p == p0
+ && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 1) <= 0) {
+ newret = CONFREJ;
}
- if (newret == CONFNAK && !dont_nak) {
- p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb);
+ break;
+
+ case CI_PREDICTOR_2:
+ if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) {
+ newret = CONFREJ;
+ break;
}
+ ho->predictor_2 = 1;
+ if (p == p0
+ && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 1) <= 0) {
+ newret = CONFREJ;
+ }
break;
default:
@@ -478,8 +748,12 @@ ccp_reqci(f, p, lenp, dont_nak)
len -= clen;
}
- if (ret != CONFACK)
- *lenp = retp - p0;
+ if (ret != CONFACK) {
+ if (ret == CONFREJ && *lenp == retp - p0)
+ all_rejected[f->unit] = 1;
+ else
+ *lenp = retp - p0;
+ }
return ret;
}
@@ -494,9 +768,9 @@ ccp_up(f)
ccp_options *ho = &ccp_hisoptions[f->unit];
ccp_flags_set(f->unit, 1, 1);
- if (go->bsd_compress || ho->bsd_compress)
+ if (ANY_COMPRESS(*go) || ANY_COMPRESS(*ho))
syslog(LOG_NOTICE, "%s enabled",
- go->bsd_compress? ho->bsd_compress? "Compression":
+ ANY_COMPRESS(*go)? ANY_COMPRESS(*ho)? "Compression":
"Receive compression": "Transmit compression");
}
@@ -567,6 +841,16 @@ ccp_printpkt(p, plen, printer, arg)
len -= optlen;
optend = p + optlen;
switch (code) {
+ case CI_DEFLATE:
+ if (optlen >= CILEN_DEFLATE) {
+ printer(arg, "deflate %d", DEFLATE_SIZE(p[2]));
+ if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL)
+ printer(arg, " method %d", DEFLATE_METHOD(p[2]));
+ if (p[3] != DEFLATE_CHK_SEQUENCE)
+ printer(arg, " check %d", p[3]);
+ p += CILEN_DEFLATE;
+ }
+ break;
case CI_BSD_COMPRESS:
if (optlen >= CILEN_BSD_COMPRESS) {
printer(arg, "bsd v%d %d", BSD_VERSION(p[2]),
@@ -574,6 +858,18 @@ ccp_printpkt(p, plen, printer, arg)
p += CILEN_BSD_COMPRESS;
}
break;
+ case CI_PREDICTOR_1:
+ if (optlen >= CILEN_PREDICTOR_1) {
+ printer(arg, "predictor 1");
+ p += CILEN_PREDICTOR_1;
+ }
+ break;
+ case CI_PREDICTOR_2:
+ if (optlen >= CILEN_PREDICTOR_2) {
+ printer(arg, "predictor 2");
+ p += CILEN_PREDICTOR_2;
+ }
+ break;
}
while (p < optend)
printer(arg, " %.2x", *p++);
@@ -616,7 +912,7 @@ ccp_datainput(unit, pkt, len)
* Disable compression by taking CCP down.
*/
syslog(LOG_ERR, "Lost compression sync: disabling compression");
- ccp_close(unit);
+ ccp_close(unit, "Lost compression sync");
} else {
/*
* Send a reset-request to reset the peer's compressor.
diff --git a/usr.sbin/pppd/ccp.h b/usr.sbin/pppd/ccp.h
index e703a200469..4907e636098 100644
--- a/usr.sbin/pppd/ccp.h
+++ b/usr.sbin/pppd/ccp.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: ccp.h,v 1.2 1996/03/25 15:55:33 niklas Exp $ */
+
/*
* ccp.h - Definitions for PPP Compression Control Protocol.
*
@@ -23,13 +25,15 @@
* ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
- *
- * $Id: ccp.h,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $
*/
typedef struct ccp_options {
u_int bsd_compress: 1; /* do BSD Compress? */
+ u_int deflate: 1; /* do Deflate? */
+ u_int predictor_1: 1; /* do Predictor-1? */
+ u_int predictor_2: 1; /* do Predictor-2? */
u_short bsd_bits; /* # bits/code for BSD Compress */
+ u_short deflate_size; /* lg(window size) for Deflate */
} ccp_options;
extern fsm ccp_fsm[];
@@ -40,7 +44,7 @@ extern ccp_options ccp_hisoptions[];
void ccp_init __P((int unit));
void ccp_open __P((int unit));
-void ccp_close __P((int unit));
+void ccp_close __P((int unit, char *));
void ccp_lowerup __P((int unit));
void ccp_lowerdown __P((int));
void ccp_input __P((int unit, u_char *pkt, int len));
@@ -49,3 +53,5 @@ int ccp_printpkt __P((u_char *pkt, int len,
void (*printer) __P((void *, char *, ...)),
void *arg));
void ccp_datainput __P((int unit, u_char *pkt, int len));
+
+extern struct protent ccp_protent;
diff --git a/usr.sbin/pppd/chap.c b/usr.sbin/pppd/chap.c
index f8e538d7de6..fa081cc7ae4 100644
--- a/usr.sbin/pppd/chap.c
+++ b/usr.sbin/pppd/chap.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: chap.c,v 1.2 1996/03/25 15:55:35 niklas Exp $ */
+
/*
* chap.c - Crytographic Handshake Authentication Protocol.
*
@@ -19,7 +21,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: chap.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: chap.c,v 1.2 1996/03/25 15:55:35 niklas Exp $";
#endif
/*
@@ -36,6 +38,12 @@ static char rcsid[] = "$Id: chap.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
#include "chap.h"
#include "md5.h"
+struct protent chap_protent = {
+ PPP_CHAP, ChapInit, ChapInput, ChapProtocolReject,
+ ChapLowerUp, ChapLowerDown, NULL, NULL,
+ ChapPrintPkt, NULL, 1, "CHAP", NULL, NULL
+};
+
chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */
static void ChapChallengeTimeout __P((caddr_t));
@@ -424,9 +432,7 @@ ChapReceiveResponse(cstate, inp, id, len)
int secret_len, old_state;
int code;
char rhostname[256];
- u_char buf[256];
MD5_CTX mdContext;
- u_char msg[256];
char secret[MAXSECRETLEN];
CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: Rcvd id %d.", id));
@@ -578,9 +584,6 @@ ChapReceiveFailure(cstate, inp, id, len)
u_char id;
int len;
{
- u_char msglen;
- u_char *msg;
-
CHAPDEBUG((LOG_INFO, "ChapReceiveFailure: Rcvd id %d.", id));
if (cstate->clientstate != CHAPCS_RESPONSE) {
diff --git a/usr.sbin/pppd/chap.h b/usr.sbin/pppd/chap.h
index 41ad8b73eb0..ea63f2b9729 100644
--- a/usr.sbin/pppd/chap.h
+++ b/usr.sbin/pppd/chap.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: chap.h,v 1.2 1996/03/25 15:55:36 niklas Exp $ */
+
/*
* chap.h - Cryptographic Handshake Authentication Protocol definitions.
*
@@ -14,8 +16,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Id: chap.h,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $
*/
#ifndef __CHAP_INCLUDE__
@@ -108,5 +108,7 @@ void ChapProtocolReject __P((int));
int ChapPrintPkt __P((u_char *, int,
void (*) __P((void *, char *, ...)), void *));
+extern struct protent chap_protent;
+
#define __CHAP_INCLUDE__
#endif /* __CHAP_INCLUDE__ */
diff --git a/usr.sbin/pppd/demand.c b/usr.sbin/pppd/demand.c
new file mode 100644
index 00000000000..0292ca43020
--- /dev/null
+++ b/usr.sbin/pppd/demand.c
@@ -0,0 +1,312 @@
+/* $OpenBSD: demand.c,v 1.1 1996/03/25 15:55:37 niklas Exp $ */
+
+/*
+ * demand.c - Dial on demand support.
+ *
+ * Copyright (c) 1993 The Australian National University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Australian National University. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char rcsid[] = "$OpenBSD: demand.c,v 1.1 1996/03/25 15:55:37 niklas Exp $";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <netdb.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/bpf.h>
+
+#include "pppd.h"
+#include "fsm.h"
+#include "ipcp.h"
+#include "lcp.h"
+#include "bpf_compile.h"
+
+char *frame;
+int framelen;
+int framemax;
+int escape_flag;
+int flush_flag;
+int fcs;
+
+struct packet {
+ int length;
+ struct packet *next;
+ unsigned char data[1];
+};
+
+struct packet *pend_q;
+struct packet *pend_qtail;
+
+/*
+ * demand_conf - configure the interface for doing dial-on-demand.
+ */
+void
+demand_conf()
+{
+ int i;
+ struct protent *protp;
+
+/* framemax = lcp_allowoptions[0].mru;
+ if (framemax < PPP_MRU) */
+ framemax = PPP_MRU;
+ framemax += PPP_HDRLEN + PPP_FCSLEN;
+ frame = malloc(framemax);
+ if (frame == NULL)
+ novm("demand frame");
+ framelen = 0;
+ pend_q = NULL;
+ escape_flag = 0;
+ flush_flag = 0;
+ fcs = PPP_INITFCS;
+
+ ppp_send_config(0, PPP_MRU, (u_int32_t) 0, 0, 0);
+ ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0);
+
+ set_filters(&pass_filter, &active_filter);
+
+ /*
+ * Call the demand_conf procedure for each protocol that's got one.
+ */
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->enabled_flag && protp->demand_conf != NULL)
+ if (!((*protp->demand_conf)(0)))
+ die(1);
+}
+
+
+/*
+ * demand_block - set each network protocol to block further packets.
+ */
+void
+demand_block()
+{
+ int i;
+ struct protent *protp;
+
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->enabled_flag && protp->demand_conf != NULL)
+ sifnpmode(0, protp->protocol & ~0x8000, NPMODE_QUEUE);
+ get_loop_output();
+}
+
+/*
+ * demand_discard - set each network protocol to discard packets
+ * with an error.
+ */
+void
+demand_discard()
+{
+ struct packet *pkt, *nextpkt;
+ int i;
+ struct protent *protp;
+
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->enabled_flag && protp->demand_conf != NULL)
+ sifnpmode(0, protp->protocol & ~0x8000, NPMODE_ERROR);
+ get_loop_output();
+
+ /* discard all saved packets */
+ for (pkt = pend_q; pkt != NULL; pkt = nextpkt) {
+ nextpkt = pkt->next;
+ free(pkt);
+ }
+ pend_q = NULL;
+ framelen = 0;
+ flush_flag = 0;
+ escape_flag = 0;
+ fcs = PPP_INITFCS;
+}
+
+/*
+ * demand_unblock - set each enabled network protocol to pass packets.
+ */
+void
+demand_unblock()
+{
+ int i;
+ struct protent *protp;
+
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->enabled_flag && protp->demand_conf != NULL)
+ sifnpmode(0, protp->protocol & ~0x8000, NPMODE_PASS);
+}
+
+/*
+ * FCS lookup table as calculated by genfcstab.
+ */
+static u_short fcstab[256] = {
+ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
+ 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
+ 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
+ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
+ 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
+ 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
+ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
+ 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
+ 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
+ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
+ 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
+ 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
+ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
+ 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
+ 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
+ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
+ 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
+ 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
+ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
+ 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
+ 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
+ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
+ 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
+ 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
+ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
+ 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
+ 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
+ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
+ 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
+ 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
+ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
+ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
+};
+
+/*
+ * loop_chars - process characters received from the loopback.
+ * Calls loop_frame when a complete frame has been accumulated.
+ * Return value is 1 if we need to bring up the link, 0 otherwise.
+ */
+int
+loop_chars(p, n)
+ unsigned char *p;
+ int n;
+{
+ int c, rv;
+
+ rv = 0;
+ for (; n > 0; --n) {
+ c = *p++;
+ if (c == PPP_FLAG) {
+ if (!escape_flag && !flush_flag
+ && framelen > 2 && fcs == PPP_GOODFCS) {
+ framelen -= 2;
+ if (loop_frame(frame, framelen))
+ rv = 1;
+ }
+ framelen = 0;
+ flush_flag = 0;
+ escape_flag = 0;
+ fcs = PPP_INITFCS;
+ continue;
+ }
+ if (flush_flag)
+ continue;
+ if (escape_flag) {
+ c ^= PPP_TRANS;
+ escape_flag = 0;
+ } else if (c == PPP_ESCAPE) {
+ escape_flag = 1;
+ continue;
+ }
+ if (framelen >= framemax) {
+ flush_flag = 1;
+ continue;
+ }
+ frame[framelen++] = c;
+ fcs = PPP_FCS(fcs, c);
+ }
+ return rv;
+}
+
+/*
+ * loop_frame - given a frame obtained from the loopback,
+ * decide whether to bring up the link or not, and, if we want
+ * to transmit this frame later, put it on the pending queue.
+ * Return value is 1 if we need to bring up the link, 0 otherwise.
+ * We assume that the kernel driver has already applied the
+ * pass_filter, so we won't get packets it rejected.
+ * We apply the active_filter to see if we want this packet to
+ * bring up the link.
+ */
+int
+loop_frame(frame, len)
+ unsigned char *frame;
+ int len;
+{
+ struct packet *pkt;
+
+ if (len < PPP_HDRLEN)
+ return 0;
+ if ((PPP_PROTOCOL(frame) & 0x8000) != 0)
+ return 0; /* shouldn't get any of these anyway */
+ if (active_filter.bf_len != 0
+ && bpf_filter(active_filter.bf_insns, frame, len, len) == 0)
+ return 0;
+
+ pkt = (struct packet *) malloc(sizeof(struct packet) + len);
+ if (pkt != NULL) {
+ pkt->length = len;
+ pkt->next = NULL;
+ memcpy(pkt->data, frame, len);
+ if (pend_q == NULL)
+ pend_q = pkt;
+ else
+ pend_qtail->next = pkt;
+ pend_qtail = pkt;
+ }
+ return 1;
+}
+
+/*
+ * demand_rexmit - Resend all those frames which we got via the
+ * loopback, now that the real serial link is up.
+ */
+void
+demand_rexmit(proto)
+ int proto;
+{
+ struct packet *pkt, *prev, *nextpkt;
+
+ prev = NULL;
+ pkt = pend_q;
+ pend_q = NULL;
+ for (; pkt != NULL; pkt = nextpkt) {
+ nextpkt = pkt->next;
+ if (PPP_PROTOCOL(pkt->data) == proto) {
+ output(0, pkt->data, pkt->length);
+ free(pkt);
+ } else {
+ if (prev == NULL)
+ pend_q = pkt;
+ else
+ prev->next = pkt;
+ prev = pkt;
+ }
+ }
+ pend_qtail = prev;
+ if (prev != NULL)
+ prev->next = NULL;
+}
diff --git a/usr.sbin/pppd/fsm.c b/usr.sbin/pppd/fsm.c
index 3dfeb347a85..1347659263a 100644
--- a/usr.sbin/pppd/fsm.c
+++ b/usr.sbin/pppd/fsm.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: fsm.c,v 1.2 1996/03/25 15:55:38 niklas Exp $ */
+
/*
* fsm.c - {Link, IP} Control Protocol Finite State Machine.
*
@@ -18,7 +20,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: fsm.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: fsm.c,v 1.2 1996/03/25 15:55:38 niklas Exp $";
#endif
/*
@@ -67,6 +69,7 @@ fsm_init(f)
f->maxconfreqtransmits = DEFMAXCONFREQS;
f->maxtermtransmits = DEFMAXTERMREQS;
f->maxnakloops = DEFMAXNAKLOOPS;
+ f->term_reason_len = 0;
}
@@ -190,9 +193,12 @@ fsm_open(f)
* the CLOSED state.
*/
void
-fsm_close(f)
+fsm_close(f, reason)
fsm *f;
+ char *reason;
{
+ f->term_reason = reason;
+ f->term_reason_len = (reason == NULL? 0: strlen(reason));
switch( f->state ){
case STARTING:
f->state = INITIAL;
@@ -215,7 +221,8 @@ fsm_close(f)
/* Init restart counter, send Terminate-Request */
f->retransmits = f->maxtermtransmits;
- fsm_sdata(f, TERMREQ, f->reqid = ++f->id, NULL, 0);
+ fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
+ (u_char *) f->term_reason, f->term_reason_len);
TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime);
--f->retransmits;
@@ -246,7 +253,8 @@ fsm_timeout(arg)
(*f->callbacks->finished)(f);
} else {
/* Send Terminate-Request */
- fsm_sdata(f, TERMREQ, f->reqid = ++f->id, NULL, 0);
+ fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
+ (u_char *) f->term_reason, f->term_reason_len);
TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime);
--f->retransmits;
}
@@ -288,7 +296,7 @@ fsm_input(f, inpacket, l)
u_char *inpacket;
int l;
{
- u_char *inp, *outp;
+ u_char *inp;
u_char code, id;
int len;
@@ -371,7 +379,6 @@ fsm_rconfreq(f, id, inp, len)
u_char *inp;
int len;
{
- u_char *outp;
int code, reject_if_disagree;
FSMDEBUG((LOG_INFO, "fsm_rconfreq(%s): Rcvd id %d.", PROTO_NAME(f), id));
@@ -505,6 +512,7 @@ fsm_rconfnakrej(f, code, id, inp, len)
int len;
{
int (*proc)();
+ int ret;
FSMDEBUG((LOG_INFO, "fsm_rconfnakrej(%s): Rcvd id %d.",
PROTO_NAME(f), id));
@@ -512,7 +520,7 @@ fsm_rconfnakrej(f, code, id, inp, len)
if (id != f->reqid || f->seen_ack) /* Expected id? */
return; /* Nope, toss... */
proc = (code == CONFNAK)? f->callbacks->nakci: f->callbacks->rejci;
- if (!proc || !proc(f, inp, len)) {
+ if (!proc || !(ret = proc(f, inp, len))) {
/* Nak/reject is bad - ignore it */
FSMDEBUG((LOG_INFO, "%s: received bad %s (length %d)",
PROTO_NAME(f), (code==CONFNAK? "Nak": "reject"), len));
@@ -530,7 +538,10 @@ fsm_rconfnakrej(f, code, id, inp, len)
case ACKSENT:
/* They didn't agree to what we wanted - try another request */
UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */
- fsm_sconfreq(f, 0); /* Send Configure-Request */
+ if (ret < 0)
+ f->state = STOPPED; /* kludge for stopping CCP */
+ else
+ fsm_sconfreq(f, 0); /* Send Configure-Request */
break;
case ACKRCVD:
@@ -682,7 +693,8 @@ fsm_protreject(f)
/* Init restart counter, send Terminate-Request */
f->retransmits = f->maxtermtransmits;
- fsm_sdata(f, TERMREQ, f->reqid = ++f->id, NULL, 0);
+ fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
+ (u_char *) f->term_reason, f->term_reason_len);
TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime);
--f->retransmits;
@@ -705,7 +717,7 @@ fsm_sconfreq(f, retransmit)
int retransmit;
{
u_char *outp;
- int outlen, cilen;
+ int cilen;
if( f->state != REQSENT && f->state != ACKRCVD && f->state != ACKSENT ){
/* Not currently negotiating - reset options */
diff --git a/usr.sbin/pppd/fsm.h b/usr.sbin/pppd/fsm.h
index fc3a5dcc179..bf54f43ec84 100644
--- a/usr.sbin/pppd/fsm.h
+++ b/usr.sbin/pppd/fsm.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: fsm.h,v 1.2 1996/03/25 15:55:39 niklas Exp $ */
+
/*
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
*
@@ -15,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Id: fsm.h,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $
*/
/*
@@ -74,6 +74,8 @@ typedef struct fsm {
int nakloops; /* Number of nak loops since last ack */
int maxnakloops; /* Maximum number of nak loops tolerated */
fsm_callbacks *callbacks; /* Callback routines */
+ char *term_reason; /* Reason for closing protocol */
+ int term_reason_len; /* Length of term_reason */
} fsm;
@@ -116,7 +118,7 @@ void fsm_init __P((fsm *));
void fsm_lowerup __P((fsm *));
void fsm_lowerdown __P((fsm *));
void fsm_open __P((fsm *));
-void fsm_close __P((fsm *));
+void fsm_close __P((fsm *, char *));
void fsm_input __P((fsm *, u_char *, int));
void fsm_protreject __P((fsm *));
void fsm_sdata __P((fsm *, int, int, u_char *, int));
diff --git a/usr.sbin/pppd/gencode.c b/usr.sbin/pppd/gencode.c
new file mode 100644
index 00000000000..f7f2e94aa21
--- /dev/null
+++ b/usr.sbin/pppd/gencode.c
@@ -0,0 +1,1303 @@
+/* $OpenBSD: gencode.c,v 1.1 1996/03/25 15:55:40 niklas Exp $ */
+/* From NetBSD: gencode.c,v 1.2 1995/03/06 11:38:21 mycroft Exp */
+
+/*
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+#ifndef lint
+#if 0
+from: static char rcsid[] =
+ "@(#) Header: gencode.c,v 1.55 94/06/20 19:07:53 leres Exp (LBL)";
+#else
+static char rcsid[] = "$OpenBSD: gencode.c,v 1.1 1996/03/25 15:55:40 niklas Exp $";
+#endif
+#endif
+
+#include <stdio.h>
+#include <memory.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <net/ppp_defs.h>
+#include <netinet/in.h>
+
+#include "bpf_compile.h"
+#include "gencode.h"
+
+#include <setjmp.h>
+#ifdef __STDC__
+#include <stdarg.h>
+#include <stdlib.h>
+#else
+#include <varargs.h>
+#endif
+
+#ifndef __GNUC__
+#define inline
+#endif
+
+#define JMP(c) ((c)|BPF_JMP|BPF_K)
+
+static jmp_buf top_ctx;
+static char errbuf[PCAP_ERRBUF_SIZE];
+
+/* VARARGS */
+volatile void
+#ifdef __STDC__
+bpf_error(char *fmt, ...)
+#else
+bpf_error(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
+{
+ va_list ap;
+
+#ifdef __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+ vsprintf(errbuf, fmt, ap);
+ va_end(ap);
+ longjmp(top_ctx, 1);
+ /* NOTREACHED */
+}
+
+char *
+bpf_geterr()
+{
+ return errbuf;
+}
+
+static void init_linktype();
+
+static int alloc_reg(void);
+static void free_reg(int);
+
+static struct block *root;
+
+/*
+ * We divy out chunks of memory rather than call malloc each time so
+ * we don't have to worry about leaking memory. It's probably
+ * not a big deal if all this memory was wasted but it this ever
+ * goes into a library that would probably not be a good idea.
+ */
+#define NCHUNKS 16
+#define CHUNK0SIZE 1024
+struct chunk {
+ u_int n_left;
+ void *m;
+};
+
+static struct chunk chunks[NCHUNKS];
+static int cur_chunk = -1;
+
+static void *newchunk(u_int);
+static void freechunks(void);
+static inline struct block *new_block(int);
+static inline struct slist *new_stmt(int);
+static struct block *gen_retblk(int);
+static inline void syntax(void);
+
+static void backpatch(struct block *, struct block *);
+static void merge(struct block *, struct block *);
+static struct block *gen_cmp(u_int, u_int, long);
+static struct block *gen_mcmp(u_int, u_int, long, u_long);
+#if 0
+static struct block *gen_bcmp(u_int, u_int, u_char *);
+#endif
+static struct block *gen_uncond(int);
+static inline struct block *gen_true(void);
+static inline struct block *gen_false(void);
+static struct block *gen_linktype(int);
+static struct block *gen_hostop(u_long, u_long, int, int, u_int, u_int);
+static struct block *gen_host(u_long, u_long, int, int);
+static struct block *gen_ipfrag(void);
+static struct block *gen_portatom(int, long);
+struct block *gen_portop(int, int, int);
+static struct block *gen_port(int, int, int);
+static int lookup_proto(char *, int);
+static struct block *gen_proto(int, int, int);
+static u_long net_mask(u_long *);
+static u_long net_mask(u_long *);
+static struct slist *xfer_to_x(struct arth *);
+static struct slist *xfer_to_a(struct arth *);
+static struct block *gen_len(int, int);
+
+static void *
+newchunk(n)
+ u_int n;
+{
+ struct chunk *cp;
+ int size;
+
+ /* XXX Round up to nearest long. */
+ n = (n + sizeof(long) - 1) & ~(sizeof(long) - 1);
+
+ cp = &chunks[cur_chunk];
+ if (cur_chunk < 0 || n > cp->n_left) {
+ if (++cur_chunk >= NCHUNKS)
+ bpf_error("out of memory");
+ cp = &chunks[cur_chunk];
+ size = CHUNK0SIZE << cur_chunk;
+ cp->m = (void *)malloc(size);
+ if (cp->m == 0 || n > size)
+ bpf_error("out of memory");
+ memset((char *)cp->m, 0, size);
+ cp->n_left = size;
+ }
+ cp->n_left -= n;
+ return (void *)((char *)cp->m + cp->n_left);
+}
+
+static void
+freechunks()
+{
+ int i;
+
+ for (i = 0; i < NCHUNKS; ++i)
+ if (chunks[i].m)
+ free(chunks[i].m);
+ cur_chunk = -1;
+}
+
+/*
+ * A strdup whose allocations are freed after code generation is over.
+ */
+char *
+sdup(s)
+ char *s;
+{
+ int n = strlen(s) + 1;
+ char *cp = newchunk(n);
+ strcpy(cp, s);
+ return (cp);
+}
+
+static inline struct block *
+new_block(code)
+ int code;
+{
+ struct block *p;
+
+ p = (struct block *)newchunk(sizeof(*p));
+ p->s.code = code;
+ p->head = p;
+
+ return p;
+}
+
+static inline struct slist *
+new_stmt(code)
+ int code;
+{
+ struct slist *p;
+
+ p = (struct slist *)newchunk(sizeof(*p));
+ p->s.code = code;
+
+ return p;
+}
+
+static struct block *
+gen_retblk(v)
+ int v;
+{
+ struct block *b = new_block(BPF_RET|BPF_K);
+
+ b->s.k = v;
+ return b;
+}
+
+static inline void
+syntax()
+{
+ bpf_error("syntax error in filter expression");
+}
+
+static int snaplen;
+
+int
+bpf_compile(program, buf, optimize)
+ struct bpf_program *program;
+ char *buf;
+ int optimize;
+{
+ extern int n_errors;
+ int len;
+
+ if (setjmp(top_ctx))
+ return (-1);
+
+ snaplen = PPP_HDRLEN;
+
+ lex_init(buf ? buf : "");
+ init_linktype();
+ pcap_parse();
+
+ if (n_errors)
+ syntax();
+
+ if (root == NULL)
+ root = gen_retblk(snaplen);
+
+ if (optimize) {
+ bpf_optimize(&root);
+ if (root == NULL ||
+ (root->s.code == (BPF_RET|BPF_K) && root->s.k == 0))
+ bpf_error("expression rejects all packets");
+ }
+ program->bf_insns = icode_to_fcode(root, &len);
+ program->bf_len = len;
+
+ freechunks();
+ return (0);
+}
+
+/*
+ * Backpatch the blocks in 'list' to 'target'. The 'sense' field indicates
+ * which of the jt and jf fields has been resolved and which is a pointer
+ * back to another unresolved block (or nil). At least one of the fields
+ * in each block is already resolved.
+ */
+static void
+backpatch(list, target)
+ struct block *list, *target;
+{
+ struct block *next;
+
+ while (list) {
+ if (!list->sense) {
+ next = JT(list);
+ JT(list) = target;
+ } else {
+ next = JF(list);
+ JF(list) = target;
+ }
+ list = next;
+ }
+}
+
+/*
+ * Merge the lists in b0 and b1, using the 'sense' field to indicate
+ * which of jt and jf is the link.
+ */
+static void
+merge(b0, b1)
+ struct block *b0, *b1;
+{
+ register struct block **p = &b0;
+
+ /* Find end of list. */
+ while (*p)
+ p = !((*p)->sense) ? &JT(*p) : &JF(*p);
+
+ /* Concatenate the lists. */
+ *p = b1;
+}
+
+void
+finish_parse(p)
+ struct block *p;
+{
+ backpatch(p, gen_retblk(snaplen));
+ p->sense = !p->sense;
+ backpatch(p, gen_retblk(0));
+ root = p->head;
+}
+
+void
+gen_and(b0, b1)
+ struct block *b0, *b1;
+{
+ backpatch(b0, b1->head);
+ b0->sense = !b0->sense;
+ b1->sense = !b1->sense;
+ merge(b1, b0);
+ b1->sense = !b1->sense;
+ b1->head = b0->head;
+}
+
+void
+gen_or(b0, b1)
+ struct block *b0, *b1;
+{
+ b0->sense = !b0->sense;
+ backpatch(b0, b1->head);
+ b0->sense = !b0->sense;
+ merge(b1, b0);
+ b1->head = b0->head;
+}
+
+void
+gen_not(b)
+ struct block *b;
+{
+ b->sense = !b->sense;
+}
+
+static struct block *
+gen_cmp(offset, size, v)
+ unsigned int offset, size;
+ long v;
+{
+ struct slist *s;
+ struct block *b;
+
+ s = new_stmt(BPF_LD|BPF_ABS|size);
+ s->s.k = offset;
+
+ b = new_block(JMP(BPF_JEQ));
+ b->stmts = s;
+ b->s.k = v;
+
+ return b;
+}
+
+static struct block *
+gen_mcmp(offset, size, v, mask)
+ unsigned int offset, size;
+ long v;
+ unsigned long mask;
+{
+ struct block *b = gen_cmp(offset, size, v);
+ struct slist *s;
+
+ if (mask != 0xffffffff) {
+ s = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s->s.k = mask;
+ b->stmts->next = s;
+ }
+ return b;
+}
+
+#if 0
+static struct block *
+gen_bcmp(offset, size, v)
+ unsigned int offset, size;
+ unsigned char *v;
+{
+ struct block *b, *tmp;
+
+ b = NULL;
+ while (size >= 4) {
+ unsigned char *p = &v[size - 4];
+ long w = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+ tmp = gen_cmp(offset + size - 4, BPF_W, w);
+ if (b != NULL)
+ gen_and(b, tmp);
+ b = tmp;
+ size -= 4;
+ }
+ while (size >= 2) {
+ unsigned char *p = &v[size - 2];
+ long w = (p[0] << 8) | p[1];
+ tmp = gen_cmp(offset + size - 2, BPF_H, w);
+ if (b != NULL)
+ gen_and(b, tmp);
+ b = tmp;
+ size -= 2;
+ }
+ if (size > 0) {
+ tmp = gen_cmp(offset, BPF_B, (long)v[0]);
+ if (b != NULL)
+ gen_and(b, tmp);
+ b = tmp;
+ }
+ return b;
+}
+#endif
+
+/*
+ * Various code constructs need to know the layout of the data link
+ * layer. These variables give the necessary offsets. off_linktype
+ * is set to -1 for no encapsulation, in which case, IP is assumed.
+ */
+static unsigned int off_linktype;
+static unsigned int off_nl;
+
+static void
+init_linktype()
+{
+ off_linktype = 2;
+ off_nl = 4;
+}
+
+static struct block *
+gen_uncond(rsense)
+ int rsense;
+{
+ struct block *b;
+ struct slist *s;
+
+ s = new_stmt(BPF_LD|BPF_IMM);
+ s->s.k = !rsense;
+ b = new_block(JMP(BPF_JEQ));
+ b->stmts = s;
+
+ return b;
+}
+
+static inline struct block *
+gen_true()
+{
+ return gen_uncond(1);
+}
+
+static inline struct block *
+gen_false()
+{
+ return gen_uncond(0);
+}
+
+static struct block *
+gen_linktype(proto)
+ int proto;
+{
+ return gen_cmp(off_linktype, BPF_H, (long)proto);
+}
+
+static struct block *
+gen_hostop(addr, mask, dir, proto, src_off, dst_off)
+ unsigned long addr;
+ unsigned long mask;
+ int dir, proto;
+ unsigned int src_off, dst_off;
+{
+ struct block *b0, *b1;
+ unsigned int offset;
+
+ switch (dir) {
+
+ case Q_SRC:
+ offset = src_off;
+ break;
+
+ case Q_DST:
+ offset = dst_off;
+ break;
+
+ case Q_AND:
+ b0 = gen_hostop(addr, mask, Q_SRC, proto, src_off, dst_off);
+ b1 = gen_hostop(addr, mask, Q_DST, proto, src_off, dst_off);
+ gen_and(b0, b1);
+ return b1;
+
+ case Q_OR:
+ case Q_DEFAULT:
+ b0 = gen_hostop(addr, mask, Q_SRC, proto, src_off, dst_off);
+ b1 = gen_hostop(addr, mask, Q_DST, proto, src_off, dst_off);
+ gen_or(b0, b1);
+ return b1;
+
+ default:
+ abort();
+ }
+ b0 = gen_linktype(proto);
+ b1 = gen_mcmp(offset, BPF_W, (long)addr, mask);
+ gen_and(b0, b1);
+ return b1;
+}
+
+static struct block *
+gen_host(addr, mask, proto, dir)
+ unsigned long addr;
+ unsigned long mask;
+ int proto;
+ int dir;
+{
+ struct block *b0;
+
+ switch (proto) {
+
+ case Q_DEFAULT:
+ b0 = gen_host(addr, mask, Q_IP, dir);
+ return b0;
+
+ case Q_IP:
+ return gen_hostop(addr, mask, dir, PPP_IP,
+ off_nl + 12, off_nl + 16);
+
+ case Q_TCP:
+ bpf_error("'tcp' modifier applied to host");
+
+ case Q_UDP:
+ bpf_error("'udp' modifier applied to host");
+
+ case Q_ICMP:
+ bpf_error("'icmp' modifier applied to host");
+
+ default:
+ abort();
+ }
+ /* NOTREACHED */
+}
+
+struct block *
+gen_proto_abbrev(proto)
+ int proto;
+{
+ struct block *b0, *b1;
+
+ switch (proto) {
+
+ case Q_TCP:
+ b0 = gen_linktype(PPP_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_TCP);
+ gen_and(b0, b1);
+ break;
+
+ case Q_UDP:
+ b0 = gen_linktype(PPP_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_UDP);
+ gen_and(b0, b1);
+ break;
+
+ case Q_ICMP:
+ b0 = gen_linktype(PPP_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_ICMP);
+ gen_and(b0, b1);
+ break;
+
+ case Q_IP:
+ b1 = gen_linktype(PPP_IP);
+ break;
+
+ case Q_LINK:
+ bpf_error("link layer applied in wrong context");
+
+ default:
+ abort();
+ }
+ return b1;
+}
+
+static struct block *
+gen_ipfrag()
+{
+ struct slist *s;
+ struct block *b;
+
+ /* not ip frag */
+ s = new_stmt(BPF_LD|BPF_H|BPF_ABS);
+ s->s.k = off_nl + 6;
+ b = new_block(JMP(BPF_JSET));
+ b->s.k = 0x1fff;
+ b->stmts = s;
+ gen_not(b);
+
+ return b;
+}
+
+static struct block *
+gen_portatom(off, v)
+ int off;
+ long v;
+{
+ struct slist *s;
+ struct block *b;
+
+ s = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
+ s->s.k = off_nl;
+
+ s->next = new_stmt(BPF_LD|BPF_IND|BPF_H);
+ s->next->s.k = off_nl + off;
+
+ b = new_block(JMP(BPF_JEQ));
+ b->stmts = s;
+ b->s.k = v;
+
+ return b;
+}
+
+struct block *
+gen_portop(port, proto, dir)
+ int port, proto, dir;
+{
+ struct block *b0, *b1, *tmp;
+
+ /* ip proto 'proto' */
+ tmp = gen_cmp(off_nl + 9, BPF_B, (long)proto);
+ b0 = gen_ipfrag();
+ gen_and(tmp, b0);
+
+ switch (dir) {
+ case Q_SRC:
+ b1 = gen_portatom(0, (long)port);
+ break;
+
+ case Q_DST:
+ b1 = gen_portatom(2, (long)port);
+ break;
+
+ case Q_OR:
+ case Q_DEFAULT:
+ tmp = gen_portatom(0, (long)port);
+ b1 = gen_portatom(2, (long)port);
+ gen_or(tmp, b1);
+ break;
+
+ case Q_AND:
+ tmp = gen_portatom(0, (long)port);
+ b1 = gen_portatom(2, (long)port);
+ gen_and(tmp, b1);
+ break;
+
+ default:
+ abort();
+ }
+ gen_and(b0, b1);
+
+ return b1;
+}
+
+static struct block *
+gen_port(port, ip_proto, dir)
+ int port;
+ int ip_proto;
+ int dir;
+{
+ struct block *b0, *b1, *tmp;
+
+ /* PPP proto ip */
+ b0 = gen_linktype(PPP_IP);
+
+ switch (ip_proto) {
+ case IPPROTO_UDP:
+ case IPPROTO_TCP:
+ b1 = gen_portop(port, ip_proto, dir);
+ break;
+
+ case PROTO_UNDEF:
+ tmp = gen_portop(port, IPPROTO_TCP, dir);
+ b1 = gen_portop(port, IPPROTO_UDP, dir);
+ gen_or(tmp, b1);
+ break;
+
+ default:
+ abort();
+ }
+ gen_and(b0, b1);
+ return b1;
+}
+
+static int
+lookup_proto(name, proto)
+ char *name;
+ int proto;
+{
+ int v;
+
+ switch (proto) {
+ case Q_DEFAULT:
+ case Q_IP:
+ v = pcap_nametoproto(name);
+ if (v == PROTO_UNDEF)
+ bpf_error("unknown ip proto '%s'", name);
+ break;
+
+ case Q_LINK:
+ /* XXX should look up h/w protocol type based on linktype */
+ v = pcap_nametopppproto(name);
+ if (v == PROTO_UNDEF)
+ bpf_error("unknown PPP proto '%s'", name);
+ break;
+
+ default:
+ v = PROTO_UNDEF;
+ break;
+ }
+ return v;
+}
+
+static struct block *
+gen_proto(v, proto, dir)
+ int v;
+ int proto;
+ int dir;
+{
+ struct block *b0, *b1;
+
+ if (dir != Q_DEFAULT)
+ bpf_error("direction applied to 'proto'");
+
+ switch (proto) {
+ case Q_DEFAULT:
+ case Q_IP:
+ b0 = gen_linktype(PPP_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (long)v);
+ gen_and(b0, b1);
+ return b1;
+
+ case Q_LINK:
+ return gen_linktype(v);
+
+ case Q_UDP:
+ bpf_error("'udp proto' is bogus");
+ /* NOTREACHED */
+
+ case Q_TCP:
+ bpf_error("'tcp proto' is bogus");
+ /* NOTREACHED */
+
+ case Q_ICMP:
+ bpf_error("'icmp proto' is bogus");
+ /* NOTREACHED */
+
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+ /* NOTREACHED */
+}
+
+/*
+ * Left justify 'addr' and return its resulting network mask.
+ */
+static unsigned long
+net_mask(addr)
+ unsigned long *addr;
+{
+ register unsigned long m = 0xffffffff;
+
+ if (*addr)
+ while ((*addr & 0xff000000) == 0)
+ *addr <<= 8, m <<= 8;
+
+ return m;
+}
+
+struct block *
+gen_scode(name, q)
+ char *name;
+ struct qual q;
+{
+ int proto = q.proto;
+ int dir = q.dir;
+ unsigned long mask, addr, **alist;
+ struct block *b, *tmp;
+ int port, real_proto;
+
+ switch (q.addr) {
+
+ case Q_NET:
+ addr = pcap_nametonetaddr(name);
+ if (addr == 0)
+ bpf_error("unknown network '%s'", name);
+ mask = net_mask(&addr);
+ return gen_host(addr, mask, proto, dir);
+
+ case Q_DEFAULT:
+ case Q_HOST:
+ if (proto == Q_LINK) {
+ bpf_error("link-level host name not supported");
+ break;
+ } else {
+ alist = pcap_nametoaddr(name);
+ if (alist == NULL || *alist == NULL)
+ bpf_error("unknown host '%s'", name);
+ b = gen_host(**alist++, 0xffffffffL, proto, dir);
+ while (*alist) {
+ tmp = gen_host(**alist++, 0xffffffffL,
+ proto, dir);
+ gen_or(b, tmp);
+ b = tmp;
+ }
+ return b;
+ }
+
+ case Q_PORT:
+ if (proto != Q_DEFAULT && proto != Q_UDP && proto != Q_TCP)
+ bpf_error("illegal qualifier of 'port'");
+ if (pcap_nametoport(name, &port, &real_proto) == 0)
+ bpf_error("unknown port '%s'", name);
+ if (proto == Q_UDP) {
+ if (real_proto == IPPROTO_TCP)
+ bpf_error("port '%s' is tcp", name);
+ else
+ /* override PROTO_UNDEF */
+ real_proto = IPPROTO_UDP;
+ }
+ if (proto == Q_TCP) {
+ if (real_proto == IPPROTO_UDP)
+ bpf_error("port '%s' is udp", name);
+ else
+ /* override PROTO_UNDEF */
+ real_proto = IPPROTO_TCP;
+ }
+ return gen_port(port, real_proto, dir);
+
+ case Q_PROTO:
+ real_proto = lookup_proto(name, proto);
+ if (real_proto >= 0)
+ return gen_proto(real_proto, proto, dir);
+ else
+ bpf_error("unknown protocol: %s", name);
+
+ case Q_UNDEF:
+ syntax();
+ /* NOTREACHED */
+ }
+ abort();
+ /* NOTREACHED */
+}
+
+struct block *
+gen_ncode(v, q)
+ unsigned long v;
+ struct qual q;
+{
+ unsigned long mask;
+ int proto = q.proto;
+ int dir = q.dir;
+
+ switch (q.addr) {
+
+ case Q_DEFAULT:
+ case Q_HOST:
+ case Q_NET:
+ if (proto == Q_LINK) {
+ bpf_error("illegal link layer address");
+ } else {
+ mask = net_mask(&v);
+ return gen_host(v, mask, proto, dir);
+ }
+
+ case Q_PORT:
+ if (proto == Q_UDP)
+ proto = IPPROTO_UDP;
+ else if (proto == Q_TCP)
+ proto = IPPROTO_TCP;
+ else if (proto == Q_DEFAULT)
+ proto = PROTO_UNDEF;
+ else
+ bpf_error("illegal qualifier of 'port'");
+
+ return gen_port((int)v, proto, dir);
+
+ case Q_PROTO:
+ return gen_proto((int)v, proto, dir);
+
+ case Q_UNDEF:
+ syntax();
+ /* NOTREACHED */
+
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+ /* NOTREACHED */
+}
+
+void
+sappend(s0, s1)
+ struct slist *s0, *s1;
+{
+ /*
+ * This is definitely not the best way to do this, but the
+ * lists will rarely get long.
+ */
+ while (s0->next)
+ s0 = s0->next;
+ s0->next = s1;
+}
+
+static struct slist *
+xfer_to_x(a)
+ struct arth *a;
+{
+ struct slist *s;
+
+ s = new_stmt(BPF_LDX|BPF_MEM);
+ s->s.k = a->regno;
+ return s;
+}
+
+static struct slist *
+xfer_to_a(a)
+ struct arth *a;
+{
+ struct slist *s;
+
+ s = new_stmt(BPF_LD|BPF_MEM);
+ s->s.k = a->regno;
+ return s;
+}
+
+struct arth *
+gen_load(proto, index, size)
+ int proto;
+ struct arth *index;
+ int size;
+{
+ struct slist *s, *tmp;
+ struct block *b;
+ int regno = alloc_reg();
+
+ free_reg(index->regno);
+ switch (size) {
+
+ default:
+ bpf_error("data size must be 1, 2, or 4");
+
+ case 1:
+ size = BPF_B;
+ break;
+
+ case 2:
+ size = BPF_H;
+ break;
+
+ case 4:
+ size = BPF_W;
+ break;
+ }
+ switch (proto) {
+ default:
+ bpf_error("unsupported index operation");
+
+ case Q_LINK:
+ s = xfer_to_x(index);
+ tmp = new_stmt(BPF_LD|BPF_IND|size);
+ sappend(s, tmp);
+ sappend(index->s, s);
+ break;
+
+ case Q_IP:
+ /* XXX Note that we assume a fixed link link header here. */
+ s = xfer_to_x(index);
+ tmp = new_stmt(BPF_LD|BPF_IND|size);
+ tmp->s.k = off_nl;
+ sappend(s, tmp);
+ sappend(index->s, s);
+
+ b = gen_proto_abbrev(proto);
+ if (index->b)
+ gen_and(index->b, b);
+ index->b = b;
+ break;
+
+ case Q_TCP:
+ case Q_UDP:
+ case Q_ICMP:
+ s = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
+ s->s.k = off_nl;
+ sappend(s, xfer_to_a(index));
+ sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X));
+ sappend(s, new_stmt(BPF_MISC|BPF_TAX));
+ sappend(s, tmp = new_stmt(BPF_LD|BPF_IND|size));
+ tmp->s.k = off_nl;
+ sappend(index->s, s);
+
+ gen_and(gen_proto_abbrev(proto), b = gen_ipfrag());
+ if (index->b)
+ gen_and(index->b, b);
+ index->b = b;
+ break;
+ }
+ index->regno = regno;
+ s = new_stmt(BPF_ST);
+ s->s.k = regno;
+ sappend(index->s, s);
+
+ return index;
+}
+
+struct block *
+gen_relation(code, a0, a1, reversed)
+ int code;
+ struct arth *a0, *a1;
+ int reversed;
+{
+ struct slist *s0, *s1, *s2;
+ struct block *b, *tmp;
+
+ s0 = xfer_to_x(a1);
+ s1 = xfer_to_a(a0);
+ s2 = new_stmt(BPF_ALU|BPF_SUB|BPF_X);
+ b = new_block(JMP(code));
+ if (reversed)
+ gen_not(b);
+
+ sappend(s1, s2);
+ sappend(s0, s1);
+ sappend(a1->s, s0);
+ sappend(a0->s, a1->s);
+
+ b->stmts = a0->s;
+
+ free_reg(a0->regno);
+ free_reg(a1->regno);
+
+ /* 'and' together protocol checks */
+ if (a0->b) {
+ if (a1->b) {
+ gen_and(a0->b, tmp = a1->b);
+ }
+ else
+ tmp = a0->b;
+ } else
+ tmp = a1->b;
+
+ if (tmp)
+ gen_and(tmp, b);
+
+ return b;
+}
+
+struct arth *
+gen_loadlen()
+{
+ int regno = alloc_reg();
+ struct arth *a = (struct arth *)newchunk(sizeof(*a));
+ struct slist *s;
+
+ s = new_stmt(BPF_LD|BPF_LEN);
+ s->next = new_stmt(BPF_ST);
+ s->next->s.k = regno;
+ a->s = s;
+ a->regno = regno;
+
+ return a;
+}
+
+struct arth *
+gen_loadi(val)
+ int val;
+{
+ struct arth *a;
+ struct slist *s;
+ int reg;
+
+ a = (struct arth *)newchunk(sizeof(*a));
+
+ reg = alloc_reg();
+
+ s = new_stmt(BPF_LD|BPF_IMM);
+ s->s.k = val;
+ s->next = new_stmt(BPF_ST);
+ s->next->s.k = reg;
+ a->s = s;
+ a->regno = reg;
+
+ return a;
+}
+
+struct arth *
+gen_neg(a)
+ struct arth *a;
+{
+ struct slist *s;
+
+ s = xfer_to_a(a);
+ sappend(a->s, s);
+ s = new_stmt(BPF_ALU|BPF_NEG);
+ s->s.k = 0;
+ sappend(a->s, s);
+ s = new_stmt(BPF_ST);
+ s->s.k = a->regno;
+ sappend(a->s, s);
+
+ return a;
+}
+
+struct arth *
+gen_arth(code, a0, a1)
+ int code;
+ struct arth *a0, *a1;
+{
+ struct slist *s0, *s1, *s2;
+
+ s0 = xfer_to_x(a1);
+ s1 = xfer_to_a(a0);
+ s2 = new_stmt(BPF_ALU|BPF_X|code);
+
+ sappend(s1, s2);
+ sappend(s0, s1);
+ sappend(a1->s, s0);
+ sappend(a0->s, a1->s);
+
+ free_reg(a1->regno);
+
+ s0 = new_stmt(BPF_ST);
+ a0->regno = s0->s.k = alloc_reg();
+ sappend(a0->s, s0);
+
+ return a0;
+}
+
+/*
+ * Here we handle simple allocation of the scratch registers.
+ * If too many registers are alloc'd, the allocator punts.
+ */
+static int regused[BPF_MEMWORDS];
+static int curreg;
+
+/*
+ * Return the next free register.
+ */
+static int
+alloc_reg()
+{
+ int n = BPF_MEMWORDS;
+
+ while (--n >= 0) {
+ if (regused[curreg])
+ curreg = (curreg + 1) % BPF_MEMWORDS;
+ else {
+ regused[curreg] = 1;
+ return curreg;
+ }
+ }
+ bpf_error("too many registers needed to evaluate expression");
+ /* NOTREACHED */
+}
+
+/*
+ * Return a register to the table so it can
+ * be used later.
+ */
+static void
+free_reg(n)
+ int n;
+{
+ regused[n] = 0;
+}
+
+static struct block *
+gen_len(jmp, n)
+ int jmp, n;
+{
+ struct slist *s;
+ struct block *b;
+
+ s = new_stmt(BPF_LD|BPF_LEN);
+ s->next = new_stmt(BPF_ALU|BPF_SUB|BPF_K);
+ s->next->s.k = n;
+ b = new_block(JMP(jmp));
+ b->stmts = s;
+
+ return b;
+}
+
+struct block *
+gen_greater(n)
+ int n;
+{
+ return gen_len(BPF_JGE, n);
+}
+
+struct block *
+gen_less(n)
+ int n;
+{
+ struct block *b;
+
+ b = gen_len(BPF_JGT, n);
+ gen_not(b);
+
+ return b;
+}
+
+struct block *
+gen_byteop(op, idx, val)
+ int op, idx, val;
+{
+ struct block *b;
+ struct slist *s;
+
+ switch (op) {
+ default:
+ abort();
+
+ case '=':
+ return gen_cmp((unsigned int)idx, BPF_B, (long)val);
+
+ case '<':
+ b = gen_cmp((unsigned int)idx, BPF_B, (long)val);
+ b->s.code = JMP(BPF_JGE);
+ gen_not(b);
+ return b;
+
+ case '>':
+ b = gen_cmp((unsigned int)idx, BPF_B, (long)val);
+ b->s.code = JMP(BPF_JGT);
+ return b;
+
+ case '|':
+ s = new_stmt(BPF_ALU|BPF_OR|BPF_K);
+ break;
+
+ case '&':
+ s = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ break;
+ }
+ s->s.k = val;
+ b = new_block(JMP(BPF_JEQ));
+ b->stmts = s;
+ gen_not(b);
+
+ return b;
+}
+
+struct block *
+gen_broadcast(proto)
+ int proto;
+{
+ bpf_error("broadcast not supported");
+}
+
+struct block *
+gen_multicast(proto)
+ int proto;
+{
+ register struct block *b0, *b1;
+
+ switch (proto) {
+ case Q_DEFAULT:
+ case Q_IP:
+ b0 = gen_linktype(PPP_IP);
+ b1 = gen_cmp(off_nl + 16, BPF_B, (long)224);
+ b1->s.code = JMP(BPF_JGE);
+ gen_and(b0, b1);
+ return b1;
+ }
+ bpf_error("only IP multicast filters supported");
+}
+
+/*
+ * generate command for inbound/outbound. It's here so we can
+ * make it link-type specific. 'dir' = 0 implies "inbound",
+ * = 1 implies "outbound".
+ */
+struct block *
+gen_inbound(dir)
+ int dir;
+{
+ register struct block *b0;
+
+ b0 = gen_relation(BPF_JEQ,
+ gen_load(Q_LINK, gen_loadi(0), 1),
+ gen_loadi(0),
+ dir);
+ return (b0);
+}
diff --git a/usr.sbin/pppd/gencode.h b/usr.sbin/pppd/gencode.h
new file mode 100644
index 00000000000..9b3b99cad19
--- /dev/null
+++ b/usr.sbin/pppd/gencode.h
@@ -0,0 +1,168 @@
+/* $OpenBSD: gencode.h,v 1.1 1996/03/25 15:55:41 niklas Exp $ */
+/* $NetBSD: gencode.h,v 1.1 1996/03/15 03:09:12 paulus Exp $ */
+
+/*
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#) Header: gencode.h,v 1.20 94/06/12 14:29:30 leres Exp (LBL)
+ */
+
+/*
+ * filter.h must be included before this file.
+ */
+
+/* Address qualifers. */
+
+#define Q_HOST 1
+#define Q_NET 2
+#define Q_PORT 3
+#define Q_PROTO 4
+
+/* Protocol qualifiers. */
+
+#define Q_LINK 1
+#define Q_IP 2
+#define Q_TCP 3
+#define Q_UDP 4
+#define Q_ICMP 5
+
+/* Directional qualifers. */
+
+#define Q_SRC 1
+#define Q_DST 2
+#define Q_OR 3
+#define Q_AND 4
+
+#define Q_DEFAULT 0
+#define Q_UNDEF 255
+
+struct stmt {
+ int code;
+ long k;
+};
+
+struct slist {
+ struct stmt s;
+ struct slist *next;
+};
+
+/*
+ * A bit vector to represent definition sets. We assume TOT_REGISTERS
+ * is smaller than 8*sizeof(atomset).
+ */
+typedef unsigned long atomset;
+#define ATOMMASK(n) (1 << (n))
+#define ATOMELEM(d, n) (d & ATOMMASK(n))
+
+/*
+ * An unbounded set.
+ */
+typedef unsigned long *uset;
+
+/*
+ * Total number of atomic entities, including accumulator (A) and index (X).
+ * We treat all these guys similarly during flow analysis.
+ */
+#define N_ATOMS (BPF_MEMWORDS+2)
+
+struct edge {
+ int id;
+ int code;
+ uset edom;
+ struct block *succ;
+ struct block *pred;
+ struct edge *next; /* link list of incoming edges for a node */
+};
+
+struct block {
+ int id;
+ struct slist *stmts; /* side effect stmts */
+ struct stmt s; /* branch stmt */
+ int mark;
+ int level;
+ int offset;
+ int sense;
+ struct edge et;
+ struct edge ef;
+ struct block *head;
+ struct block *link; /* link field used by optimizer */
+ uset dom;
+ uset closure;
+ struct edge *in_edges;
+ atomset def, kill;
+ atomset in_use;
+ atomset out_use;
+ long oval;
+ long val[N_ATOMS];
+};
+
+struct arth {
+ struct block *b; /* protocol checks */
+ struct slist *s; /* stmt list */
+ int regno; /* virtual register number of result */
+};
+
+struct qual {
+ unsigned char addr;
+ unsigned char proto;
+ unsigned char dir;
+ unsigned char pad;
+};
+
+#ifndef __GNUC__
+#define volatile
+#endif
+
+struct arth *gen_loadi __P((int));
+struct arth *gen_load __P((int, struct arth *, int));
+struct arth *gen_loadlen __P((void));
+struct arth *gen_neg __P((struct arth *));
+struct arth *gen_arth __P((int, struct arth *, struct arth *));
+
+void gen_and __P((struct block *, struct block *));
+void gen_or __P((struct block *, struct block *));
+void gen_not __P((struct block *));
+
+struct block *gen_scode __P((char *, struct qual));
+struct block *gen_ecode __P((unsigned char *, struct qual));
+struct block *gen_ncode __P((unsigned long, struct qual));
+struct block *gen_proto_abbrev __P((int));
+struct block *gen_relation __P((int, struct arth *, struct arth *, int));
+struct block *gen_less __P((int));
+struct block *gen_greater __P((int));
+struct block *gen_byteop __P((int, int, int));
+struct block *gen_broadcast __P((int));
+struct block *gen_multicast __P((int));
+struct block *gen_inbound __P((int));
+
+void bpf_optimize __P((struct block **));
+volatile void bpf_error __P((char *, ...));
+
+void finish_parse __P((struct block *));
+char *sdup __P((char *));
+
+struct bpf_insn *icode_to_fcode __P((struct block *, int *));
+int pcap_parse __P((void));
+void lex_init __P((char *));
+void sappend __P((struct slist *, struct slist *));
+
+/* XXX */
+#define JT(b) ((b)->et.succ)
+#define JF(b) ((b)->ef.succ)
diff --git a/usr.sbin/pppd/grammar.y b/usr.sbin/pppd/grammar.y
new file mode 100644
index 00000000000..95f00bf4a8f
--- /dev/null
+++ b/usr.sbin/pppd/grammar.y
@@ -0,0 +1,238 @@
+%{
+/* $OpenBSD: grammar.y,v 1.1 1996/03/25 15:55:41 niklas Exp $ */
+/* From NetBSD: grammar.y,v 1.2 1995/03/06 11:38:27 mycroft Exp */
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#ifndef lint
+#if 0
+from: static char rcsid[] =
+ "@(#) Header: grammar.y,v 1.39 94/06/14 20:09:25 leres Exp (LBL)";
+#else
+static char rcsid[] = "$OpenBSD: grammar.y,v 1.1 1996/03/25 15:55:41 niklas Exp $";
+#endif
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#include <net/ppp_defs.h>
+#include "bpf_compile.h"
+#include "gencode.h"
+
+#define QSET(q, p, d, a) (q).proto = (p),\
+ (q).dir = (d),\
+ (q).addr = (a)
+
+int n_errors = 0;
+
+static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
+
+static void
+yyerror(char *msg)
+{
+ ++n_errors;
+ bpf_error(msg);
+ /* NOTREACHED */
+}
+
+#ifndef YYBISON
+int
+pcap_parse()
+{
+ extern int yyparse();
+ return (yyparse());
+}
+#endif
+
+%}
+
+%union {
+ int i;
+ unsigned long h;
+ char *s;
+ struct stmt *stmt;
+ struct arth *a;
+ struct {
+ struct qual q;
+ struct block *b;
+ } blk;
+ struct block *rblk;
+}
+
+%type <blk> expr id nid pid term rterm qid
+%type <blk> head
+%type <i> pqual dqual aqual
+%type <a> arth narth
+%type <i> byteop pname pnum relop irelop
+%type <blk> and or paren not null prog
+%type <rblk> other
+
+%token DST SRC HOST
+%token NET PORT LESS GREATER PROTO BYTE
+%token IP TCP UDP ICMP
+%token TK_BROADCAST TK_MULTICAST
+%token NUM INBOUND OUTBOUND
+%token LINK
+%token GEQ LEQ NEQ
+%token ID HID
+%token LSH RSH
+%token LEN
+
+%type <s> ID
+%type <h> HID
+%type <i> NUM
+
+%left OR AND
+%nonassoc '!'
+%left '|'
+%left '&'
+%left LSH RSH
+%left '+' '-'
+%left '*' '/'
+%nonassoc UMINUS
+%%
+prog: null expr
+{
+ finish_parse($2.b);
+}
+ | null
+ ;
+null: /* null */ { $$.q = qerr; }
+ ;
+expr: term
+ | expr and term { gen_and($1.b, $3.b); $$ = $3; }
+ | expr and id { gen_and($1.b, $3.b); $$ = $3; }
+ | expr or term { gen_or($1.b, $3.b); $$ = $3; }
+ | expr or id { gen_or($1.b, $3.b); $$ = $3; }
+ ;
+and: AND { $$ = $<blk>0; }
+ ;
+or: OR { $$ = $<blk>0; }
+ ;
+id: nid
+ | pnum { $$.b = gen_ncode((unsigned long)$1,
+ $$.q = $<blk>0.q); }
+ | paren pid ')' { $$ = $2; }
+ ;
+nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
+ | HID { $$.b = gen_ncode(__pcap_atoin((char *)$1),
+ $$.q); }
+ | not id { gen_not($2.b); $$ = $2; }
+ ;
+not: '!' { $$ = $<blk>0; }
+ ;
+paren: '(' { $$ = $<blk>0; }
+ ;
+pid: nid
+ | qid and id { gen_and($1.b, $3.b); $$ = $3; }
+ | qid or id { gen_or($1.b, $3.b); $$ = $3; }
+ ;
+qid: pnum { $$.b = gen_ncode((unsigned long)$1,
+ $$.q = $<blk>0.q); }
+ | pid
+ ;
+term: rterm
+ | not term { gen_not($2.b); $$ = $2; }
+ ;
+head: pqual dqual aqual { QSET($$.q, $1, $2, $3); }
+ | pqual dqual { QSET($$.q, $1, $2, Q_DEFAULT); }
+ | pqual aqual { QSET($$.q, $1, Q_DEFAULT, $2); }
+ | pqual PROTO { QSET($$.q, $1, Q_DEFAULT, Q_PROTO); }
+ ;
+rterm: head id { $$ = $2; }
+ | paren expr ')' { $$.b = $2.b; $$.q = $1.q; }
+ | pname { $$.b = gen_proto_abbrev($1); $$.q = qerr; }
+ | arth relop arth { $$.b = gen_relation($2, $1, $3, 0);
+ $$.q = qerr; }
+ | arth irelop arth { $$.b = gen_relation($2, $1, $3, 1);
+ $$.q = qerr; }
+ | other { $$.b = $1; $$.q = qerr; }
+ ;
+/* protocol level qualifiers */
+pqual: pname
+ | { $$ = Q_DEFAULT; }
+ ;
+/* 'direction' qualifiers */
+dqual: SRC { $$ = Q_SRC; }
+ | DST { $$ = Q_DST; }
+ | SRC OR DST { $$ = Q_OR; }
+ | DST OR SRC { $$ = Q_OR; }
+ | SRC AND DST { $$ = Q_AND; }
+ | DST AND SRC { $$ = Q_AND; }
+ ;
+/* address type qualifiers */
+aqual: HOST { $$ = Q_HOST; }
+ | NET { $$ = Q_NET; }
+ | PORT { $$ = Q_PORT; }
+ ;
+pname: LINK { $$ = Q_LINK; }
+ | IP { $$ = Q_IP; }
+ | TCP { $$ = Q_TCP; }
+ | UDP { $$ = Q_UDP; }
+ | ICMP { $$ = Q_ICMP; }
+ ;
+other: pqual TK_BROADCAST { $$ = gen_broadcast($1); }
+ | pqual TK_MULTICAST { $$ = gen_multicast($1); }
+ | LESS NUM { $$ = gen_less($2); }
+ | GREATER NUM { $$ = gen_greater($2); }
+ | BYTE NUM byteop NUM { $$ = gen_byteop($3, $2, $4); }
+ | INBOUND { $$ = gen_inbound(0); }
+ | OUTBOUND { $$ = gen_inbound(1); }
+ ;
+relop: '>' { $$ = BPF_JGT; }
+ | GEQ { $$ = BPF_JGE; }
+ | '=' { $$ = BPF_JEQ; }
+ ;
+irelop: LEQ { $$ = BPF_JGT; }
+ | '<' { $$ = BPF_JGE; }
+ | NEQ { $$ = BPF_JEQ; }
+ ;
+arth: pnum { $$ = gen_loadi($1); }
+ | narth
+ ;
+narth: pname '[' arth ']' { $$ = gen_load($1, $3, 1); }
+ | pname '[' arth ':' NUM ']' { $$ = gen_load($1, $3, $5); }
+ | arth '+' arth { $$ = gen_arth(BPF_ADD, $1, $3); }
+ | arth '-' arth { $$ = gen_arth(BPF_SUB, $1, $3); }
+ | arth '*' arth { $$ = gen_arth(BPF_MUL, $1, $3); }
+ | arth '/' arth { $$ = gen_arth(BPF_DIV, $1, $3); }
+ | arth '&' arth { $$ = gen_arth(BPF_AND, $1, $3); }
+ | arth '|' arth { $$ = gen_arth(BPF_OR, $1, $3); }
+ | arth LSH arth { $$ = gen_arth(BPF_LSH, $1, $3); }
+ | arth RSH arth { $$ = gen_arth(BPF_RSH, $1, $3); }
+ | '-' arth %prec UMINUS { $$ = gen_neg($2); }
+ | paren narth ')' { $$ = $2; }
+ | LEN { $$ = gen_loadlen(); }
+ ;
+byteop: '&' { $$ = '&'; }
+ | '|' { $$ = '|'; }
+ | '<' { $$ = '<'; }
+ | '>' { $$ = '>'; }
+ | '=' { $$ = '='; }
+ ;
+pnum: NUM
+ | paren pnum ')' { $$ = $2; }
+ ;
+%%
diff --git a/usr.sbin/pppd/ipcp.c b/usr.sbin/pppd/ipcp.c
index 1aacdecf3e2..2ad4123751b 100644
--- a/usr.sbin/pppd/ipcp.c
+++ b/usr.sbin/pppd/ipcp.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: ipcp.c,v 1.2 1996/03/25 15:55:43 niklas Exp $ */
+
/*
* ipcp.c - PPP IP Control Protocol.
*
@@ -18,7 +20,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: ipcp.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ipcp.c,v 1.2 1996/03/25 15:55:43 niklas Exp $";
#endif
/*
@@ -28,6 +30,7 @@ static char rcsid[] = "$Id: ipcp.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
#include <stdio.h>
#include <string.h>
#include <syslog.h>
+#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -44,7 +47,9 @@ ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */
/* local vars */
-static int cis_received[NUM_PPP]; /* # Conf-Reqs received */
+static int cis_received[NUM_PPP]; /* # Conf-Reqs received */
+static int default_route_set[NUM_PPP]; /* Have set up a default route */
+static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */
/*
* Callbacks for fsm code. (CI = Configuration Information)
@@ -59,6 +64,7 @@ static int ipcp_reqci __P((fsm *, u_char *, int *, int)); /* Rcv CI */
static void ipcp_up __P((fsm *)); /* We're UP */
static void ipcp_down __P((fsm *)); /* We're DOWN */
static void ipcp_script __P((fsm *, char *)); /* Run an up/down script */
+static void ipcp_finished __P((fsm *)); /* Don't need lower layer */
fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */
@@ -73,13 +79,20 @@ static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */
ipcp_up, /* Called when fsm reaches OPENED state */
ipcp_down, /* Called when fsm leaves OPENED state */
NULL, /* Called when we want the lower layer up */
- NULL, /* Called when we want the lower layer down */
+ ipcp_finished, /* Called when we want the lower layer down */
NULL, /* Called when Protocol-Reject received */
NULL, /* Retransmission is necessary */
NULL, /* Called to handle protocol-specific codes */
"IPCP" /* String name of protocol */
};
+struct protent ipcp_protent = {
+ PPP_IPCP, ipcp_init, ipcp_input, ipcp_protrej,
+ ipcp_lowerup, ipcp_lowerdown, ipcp_open, ipcp_close,
+ ipcp_printpkt, NULL, 1, "IPCP",
+ ip_check_options, ip_demand_conf,
+};
+
/*
* Lengths of configuration options.
*/
@@ -130,13 +143,11 @@ ipcp_init(unit)
f->callbacks = &ipcp_callbacks;
fsm_init(&ipcp_fsm[unit]);
- wo->neg_addr = 1;
- wo->old_addrs = 0;
- wo->ouraddr = 0;
- wo->hisaddr = 0;
+ memset(wo, 0, sizeof(*wo));
+ memset(ao, 0, sizeof(*ao));
+ wo->neg_addr = 1;
wo->neg_vj = 1;
- wo->old_vj = 0;
wo->vj_protocol = IPCP_VJ_COMP;
wo->maxslotindex = MAX_STATES - 1; /* really max index */
wo->cflag = 1;
@@ -174,10 +185,11 @@ ipcp_open(unit)
* ipcp_close - Take IPCP down.
*/
void
-ipcp_close(unit)
+ipcp_close(unit, reason)
int unit;
+ char *reason;
{
- fsm_close(&ipcp_fsm[unit]);
+ fsm_close(&ipcp_fsm[unit], reason);
}
@@ -256,10 +268,36 @@ ipcp_cilen(f)
fsm *f;
{
ipcp_options *go = &ipcp_gotoptions[f->unit];
+ ipcp_options *wo = &ipcp_wantoptions[f->unit];
+ ipcp_options *ho = &ipcp_hisoptions[f->unit];
#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0)
#define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0)
+ /*
+ * First see if we want to change our options to the old
+ * forms because we have received old forms from the peer.
+ */
+ if (wo->neg_addr && !go->neg_addr && !go->old_addrs) {
+ /* use the old style of address negotiation */
+ go->neg_addr = 1;
+ go->old_addrs = 1;
+ }
+ if (wo->neg_vj && !go->neg_vj && !go->old_vj) {
+ /* try an older style of VJ negotiation */
+ if (cis_received[f->unit] == 0) {
+ /* keep trying the new style until we see some CI from the peer */
+ go->neg_vj = 1;
+ } else {
+ /* use the old style only if the peer did */
+ if (ho->neg_vj && ho->old_vj) {
+ go->neg_vj = 1;
+ go->old_vj = 1;
+ go->vj_protocol = ho->vj_protocol;
+ }
+ }
+ }
+
return (LENCIADDR(go->neg_addr, go->old_addrs) +
LENCIVJ(go->neg_vj, go->old_vj));
}
@@ -274,9 +312,7 @@ ipcp_addci(f, ucp, lenp)
u_char *ucp;
int *lenp;
{
- ipcp_options *wo = &ipcp_wantoptions[f->unit];
ipcp_options *go = &ipcp_gotoptions[f->unit];
- ipcp_options *ho = &ipcp_hisoptions[f->unit];
int len = *lenp;
#define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \
@@ -313,30 +349,6 @@ ipcp_addci(f, ucp, lenp)
neg = 0; \
}
- /*
- * First see if we want to change our options to the old
- * forms because we have received old forms from the peer.
- */
- if (wo->neg_addr && !go->neg_addr && !go->old_addrs) {
- /* use the old style of address negotiation */
- go->neg_addr = 1;
- go->old_addrs = 1;
- }
- if (wo->neg_vj && !go->neg_vj && !go->old_vj) {
- /* try an older style of VJ negotiation */
- if (cis_received[f->unit] == 0) {
- /* keep trying the new style until we see some CI from the peer */
- go->neg_vj = 1;
- } else {
- /* use the old style only if the peer did */
- if (ho->neg_vj && ho->old_vj) {
- go->neg_vj = 1;
- go->old_vj = 1;
- go->vj_protocol = ho->vj_protocol;
- }
- }
- }
-
ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr,
go->old_addrs, go->ouraddr, go->hisaddr);
@@ -731,6 +743,9 @@ ipcp_reqci(f, inp, len, reject_if_disagree)
u_char *ucp = inp; /* Pointer to current output char */
int l = *len; /* Length left */
u_char maxslotindex, cflag;
+ int d;
+
+ cis_received[f->unit] = 1;
/*
* Reset all his options.
@@ -857,6 +872,27 @@ ipcp_reqci(f, inp, len, reject_if_disagree)
ho->neg_addr = 1;
ho->hisaddr = ciaddr1;
break;
+
+ case CI_MS_DNS1:
+ case CI_MS_DNS2:
+ /* Microsoft primary or secondary DNS request */
+ d = citype == CI_MS_DNS2;
+ IPCPDEBUG((LOG_INFO, "ipcp: received DNS%d Request ", d+1));
+
+ /* If we do not have a DNS address then we cannot send it */
+ if (ao->dnsaddr[d] == 0 ||
+ cilen != CILEN_ADDR) { /* Check CI length */
+ orc = CONFREJ; /* Reject CI */
+ break;
+ }
+ GETLONG(tl, p);
+ if (htonl(tl) != ao->dnsaddr[d]) {
+ DECPTR(sizeof(u_int32_t), p);
+ tl = ntohl(ao->dnsaddr[d]);
+ PUTLONG(tl, p);
+ orc = CONFNAK;
+ }
+ break;
case CI_COMPRESSTYPE:
IPCPDEBUG((LOG_INFO, "ipcp: received COMPRESSTYPE "));
@@ -968,6 +1004,78 @@ endswitch:
/*
+ * ip_check_options - check that any IP-related options are OK,
+ * and assign appropriate defaults.
+ */
+void
+ip_check_options()
+{
+ struct hostent *hp;
+ u_int32_t local;
+ ipcp_options *wo = &ipcp_wantoptions[0];
+
+ /*
+ * Default our local IP address based on our hostname.
+ * If local IP address already given, don't bother.
+ */
+ if (wo->ouraddr == 0 && !disable_defaultip) {
+ /*
+ * Look up our hostname (possibly with domain name appended)
+ * and take the first IP address as our local IP address.
+ * If there isn't an IP address for our hostname, too bad.
+ */
+ wo->accept_local = 1; /* don't insist on this default value */
+ if ((hp = gethostbyname(hostname)) != NULL) {
+ local = *(u_int32_t *)hp->h_addr;
+ if (local != 0 && !bad_ip_adrs(local))
+ wo->ouraddr = local;
+ }
+ }
+
+ if (demand && wo->hisaddr == 0) {
+ fprintf(stderr, "%s: remote IP address required for demand-dialling\n",
+ progname);
+ exit(1);
+ }
+ if (demand && wo->accept_remote) {
+ fprintf(stderr, "%s: ipcp-accept-remote is incompatible with demand\n",
+ progname);
+ exit(1);
+ }
+}
+
+
+/*
+ * ip_demand_conf - configure the interface as though
+ * IPCP were up, for use with dial-on-demand.
+ */
+int
+ip_demand_conf(u)
+ int u;
+{
+ ipcp_options *wo = &ipcp_wantoptions[u];
+
+ if (!sifaddr(u, wo->ouraddr, wo->hisaddr, GetMask(wo->ouraddr)))
+ return 0;
+ if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
+ return 0;
+ if (!sifup(u))
+ return 0;
+ if (wo->default_route)
+ if (sifdefaultroute(u, wo->hisaddr))
+ default_route_set[u] = 1;
+ if (wo->proxy_arp)
+ if (sifproxyarp(u, wo->hisaddr))
+ proxy_arp_set[u] = 1;
+
+ syslog(LOG_NOTICE, "local IP address %s", ip_ntoa(wo->ouraddr));
+ syslog(LOG_NOTICE, "remote IP address %s", ip_ntoa(wo->hisaddr));
+
+ return 1;
+}
+
+
+/*
* ipcp_up - IPCP has come UP.
*
* Configure the IP network interface appropriately and bring it up.
@@ -979,25 +1087,25 @@ ipcp_up(f)
u_int32_t mask;
ipcp_options *ho = &ipcp_hisoptions[f->unit];
ipcp_options *go = &ipcp_gotoptions[f->unit];
+ ipcp_options *wo = &ipcp_wantoptions[f->unit];
+ np_up(f->unit, PPP_IP);
IPCPDEBUG((LOG_INFO, "ipcp: up"));
- go->default_route = 0;
- go->proxy_arp = 0;
/*
* We must have a non-zero IP address for both ends of the link.
*/
if (!ho->neg_addr)
- ho->hisaddr = ipcp_wantoptions[f->unit].hisaddr;
+ ho->hisaddr = wo->hisaddr;
if (ho->hisaddr == 0) {
syslog(LOG_ERR, "Could not determine remote IP address");
- ipcp_close(f->unit);
+ ipcp_close(f->unit, "Could not determine remote IP address");
return;
}
if (go->ouraddr == 0) {
syslog(LOG_ERR, "Could not determine local IP address");
- ipcp_close(f->unit);
+ ipcp_close(f->unit, "Could not determine local IP address");
return;
}
@@ -1007,42 +1115,59 @@ ipcp_up(f)
if (!auth_ip_addr(f->unit, ho->hisaddr)) {
syslog(LOG_ERR, "Peer is not authorized to use remote address %s",
ip_ntoa(ho->hisaddr));
- ipcp_close(f->unit);
+ ipcp_close(f->unit, "Unauthorized remote IP address");
return;
}
- syslog(LOG_NOTICE, "local IP address %s", ip_ntoa(go->ouraddr));
- syslog(LOG_NOTICE, "remote IP address %s", ip_ntoa(ho->hisaddr));
+ /* set tcp compression */
+ sifvjcomp(f->unit, ho->neg_vj, ho->cflag, ho->maxslotindex);
/*
- * Set IP addresses and (if specified) netmask.
+ * If we are doing dial-on-demand, the interface is already
+ * configured, so we put out any saved-up packets, then set the
+ * interface to pass IP packets.
*/
- mask = GetMask(go->ouraddr);
- if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
- IPCPDEBUG((LOG_WARNING, "sifaddr failed"));
- ipcp_close(f->unit);
- return;
- }
+ if (demand) {
+ if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
+ syslog(LOG_ERR, "Failed to negotiate desired IP addresses");
+ ipcp_close(f->unit, "Wrong IP addresses");
+ return;
+ }
+ demand_rexmit(PPP_IP);
+ sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
+
+ } else {
+
+ /*
+ * Set IP addresses and (if specified) netmask.
+ */
+ mask = GetMask(go->ouraddr);
+ if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
+ IPCPDEBUG((LOG_WARNING, "sifaddr failed"));
+ ipcp_close(f->unit, "Interface configuration failed");
+ return;
+ }
- /* set tcp compression */
- sifvjcomp(f->unit, ho->neg_vj, ho->cflag, ho->maxslotindex);
+ /* bring the interface up for IP */
+ if (!sifup(f->unit)) {
+ IPCPDEBUG((LOG_WARNING, "sifup failed"));
+ ipcp_close(f->unit, "Interface configuration failed");
+ return;
+ }
- /* bring the interface up for IP */
- if (!sifup(f->unit)) {
- IPCPDEBUG((LOG_WARNING, "sifup failed"));
- ipcp_close(f->unit);
- return;
- }
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
+ if (sifdefaultroute(f->unit, ho->hisaddr))
+ default_route_set[f->unit] = 1;
- /* assign a default route through the interface if required */
- if (ipcp_wantoptions[f->unit].default_route)
- if (sifdefaultroute(f->unit, ho->hisaddr))
- go->default_route = 1;
+ /* Make a proxy ARP entry if requested. */
+ if (ipcp_wantoptions[f->unit].proxy_arp)
+ if (sifproxyarp(f->unit, ho->hisaddr))
+ proxy_arp_set[f->unit] = 1;
- /* Make a proxy ARP entry if requested. */
- if (ipcp_wantoptions[f->unit].proxy_arp)
- if (sifproxyarp(f->unit, ho->hisaddr))
- go->proxy_arp = 1;
+ syslog(LOG_NOTICE, "local IP address %s", ip_ntoa(go->ouraddr));
+ syslog(LOG_NOTICE, "remote IP address %s", ip_ntoa(ho->hisaddr));
+ }
/*
* Execute the ip-up script, like this:
@@ -1065,16 +1190,30 @@ ipcp_down(f)
{
u_int32_t ouraddr, hisaddr;
+ np_down(f->unit, PPP_IP);
IPCPDEBUG((LOG_INFO, "ipcp: down"));
- ouraddr = ipcp_gotoptions[f->unit].ouraddr;
- hisaddr = ipcp_hisoptions[f->unit].hisaddr;
- if (ipcp_gotoptions[f->unit].proxy_arp)
- cifproxyarp(f->unit, hisaddr);
- if (ipcp_gotoptions[f->unit].default_route)
- cifdefaultroute(f->unit, hisaddr);
- sifdown(f->unit);
- cifaddr(f->unit, ouraddr, hisaddr);
+ /*
+ * If we are doing dial-on-demand, set the interface
+ * to queue up outgoing packets (for now).
+ */
+ if (demand) {
+ sifnpmode(f->unit, PPP_IP, NPMODE_QUEUE);
+
+ } else {
+ ouraddr = ipcp_gotoptions[f->unit].ouraddr;
+ hisaddr = ipcp_hisoptions[f->unit].hisaddr;
+ if (proxy_arp_set[f->unit]) {
+ cifproxyarp(f->unit, hisaddr);
+ proxy_arp_set[f->unit] = 0;
+ }
+ if (default_route_set[f->unit]) {
+ cifdefaultroute(f->unit, hisaddr);
+ default_route_set[f->unit] = 0;
+ }
+ sifdown(f->unit);
+ cifaddr(f->unit, ouraddr, hisaddr);
+ }
/* Execute the ip-down script */
ipcp_script(f, _PATH_IPDOWN);
@@ -1082,6 +1221,17 @@ ipcp_down(f)
/*
+ * ipcp_finished - possibly shut down the lower layers.
+ */
+static void
+ipcp_finished(f)
+ fsm *f;
+{
+ np_finished(f->unit, PPP_IP);
+}
+
+
+/*
* ipcp_script - Execute a script with arguments
* interface-name tty-name speed local-IP remote-IP.
*/
diff --git a/usr.sbin/pppd/ipcp.h b/usr.sbin/pppd/ipcp.h
index 706d3f5a124..ce7fe8ba7ef 100644
--- a/usr.sbin/pppd/ipcp.h
+++ b/usr.sbin/pppd/ipcp.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: ipcp.h,v 1.2 1996/03/25 15:55:44 niklas Exp $ */
+
/*
* ipcp.h - IP Control Protocol definitions.
*
@@ -15,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Id: ipcp.h,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $
*/
/*
@@ -26,6 +26,9 @@
#define CI_COMPRESSTYPE 2 /* Compression Type */
#define CI_ADDR 3
+#define CI_MS_DNS1 129 /* Primary DNS value */
+#define CI_MS_DNS2 131 /* Secondary DNS value */
+
#define MAX_STATES 16 /* from slcompress.h */
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
@@ -50,6 +53,7 @@ typedef struct ipcp_options {
u_short vj_protocol; /* protocol value to use in VJ option */
u_char maxslotindex, cflag; /* values for RFC1332 VJ compression neg. */
u_int32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
+ u_int32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
} ipcp_options;
extern fsm ipcp_fsm[];
@@ -60,9 +64,14 @@ extern ipcp_options ipcp_hisoptions[];
void ipcp_init __P((int));
void ipcp_open __P((int));
-void ipcp_close __P((int));
+void ipcp_close __P((int, char *));
void ipcp_lowerup __P((int));
void ipcp_lowerdown __P((int));
void ipcp_input __P((int, u_char *, int));
void ipcp_protrej __P((int));
int ipcp_printpkt __P((u_char *, int, void (*)(), void *));
+void ip_check_options __P((void));
+int ip_demand_conf __P((int));
+char *ip_ntoa __P((u_int32_t));
+
+extern struct protent ipcp_protent;
diff --git a/usr.sbin/pppd/lcp.c b/usr.sbin/pppd/lcp.c
index 97c53df775f..dd04e02fde2 100644
--- a/usr.sbin/pppd/lcp.c
+++ b/usr.sbin/pppd/lcp.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: lcp.c,v 1.2 1996/03/25 15:55:46 niklas Exp $ */
+
/*
* lcp.c - PPP Link Control Protocol.
*
@@ -18,7 +20,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: lcp.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lcp.c,v 1.2 1996/03/25 15:55:46 niklas Exp $";
#endif
/*
@@ -38,15 +40,8 @@ static char rcsid[] = "$Id: lcp.c,v 1.1.1.1 1995/10/18 08:47:58 deraadt Exp $";
#include "pppd.h"
#include "fsm.h"
#include "lcp.h"
-#include "magic.h"
#include "chap.h"
-#include "upap.h"
-#include "ipcp.h"
-
-#ifdef _linux_ /* Needs ppp ioctls */
-#include <net/if.h>
-#include <linux/if_ppp.h>
-#endif
+#include "magic.h"
/* global vars */
fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/
@@ -62,11 +57,6 @@ static u_int32_t lcp_echo_timer_running = 0; /* TRUE if a timer is running */
static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */
-#ifdef _linux_
-u_int32_t idle_timer_running = 0;
-extern int idle_time_limit;
-#endif
-
/*
* Callbacks for fsm code. (CI = Configuration Information)
*/
@@ -113,6 +103,12 @@ static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
"LCP" /* String name of protocol */
};
+struct protent lcp_protent = {
+ PPP_LCP, lcp_init, lcp_input, lcp_protrej,
+ lcp_lowerup, lcp_lowerdown, lcp_open, lcp_close,
+ lcp_printpkt, NULL, 1, "LCP", NULL, NULL
+};
+
int lcp_loopbackfail = DEFLOOPBACKFAIL;
/*
@@ -201,8 +197,9 @@ lcp_open(unit)
* lcp_close - Take LCP down.
*/
void
-lcp_close(unit)
+lcp_close(unit, reason)
int unit;
+ char *reason;
{
fsm *f = &lcp_fsm[unit];
@@ -210,68 +207,16 @@ lcp_close(unit)
/*
* This action is not strictly according to the FSM in RFC1548,
* but it does mean that the program terminates if you do a
- * lcp_close(0) in passive/silent mode when a connection hasn't
+ * lcp_close() in passive/silent mode when a connection hasn't
* been established.
*/
f->state = CLOSED;
lcp_finished(f);
} else
- fsm_close(&lcp_fsm[unit]);
+ fsm_close(&lcp_fsm[unit], reason);
}
-#ifdef _linux_
-static void IdleTimeCheck __P((caddr_t));
-
-/*
- * Timer expired for the LCP echo requests from this process.
- */
-
-static void
-RestartIdleTimer (f)
- fsm *f;
-{
- u_long delta;
- struct ppp_idle ddinfo;
-/*
- * Read the time since the last packet was received.
- */
- if (ioctl (fd, PPPIOCGIDLE, &ddinfo) < 0) {
- syslog (LOG_ERR, "ioctl(PPPIOCGIDLE): %m");
- die (1);
- }
-/*
- * Compute the time since the last packet was received. If the timer
- * has expired then disconnect the line.
- */
- delta = idle_time_limit - (u_long) ddinfo.recv_idle;
- if (((int) delta <= 0L) && (f->state == OPENED)) {
- syslog (LOG_NOTICE, "No IP frames received within idle time limit");
- lcp_close(f->unit); /* Reset connection */
- phase = PHASE_TERMINATE; /* Mark it down */
- } else {
- if ((int) delta <= 0L)
- delta = (u_long) idle_time_limit;
- assert (idle_timer_running==0);
- TIMEOUT (IdleTimeCheck, (caddr_t) f, delta);
- idle_timer_running = 1;
- }
-}
-
-/*
- * IdleTimeCheck - Timer expired on the IDLE detection for IP frames
- */
-
-static void
-IdleTimeCheck (arg)
- caddr_t arg;
-{
- if (idle_timer_running != 0) {
- idle_timer_running = 0;
- RestartIdleTimer ((fsm *) arg);
- }
-}
-#endif
/*
* lcp_lowerup - The lower layer is up.
@@ -280,10 +225,17 @@ void
lcp_lowerup(unit)
int unit;
{
- sifdown(unit);
+ lcp_options *wo = &lcp_wantoptions[unit];
+
+ /*
+ * Don't use A/C or protocol compression on transmission,
+ * but accept A/C and protocol compressed packets
+ * if we are going to ask for A/C and protocol compression.
+ */
ppp_set_xaccm(unit, xmit_accm[unit]);
ppp_send_config(unit, PPP_MRU, 0xffffffff, 0, 0);
- ppp_recv_config(unit, PPP_MRU, 0x00000000, 0, 0);
+ ppp_recv_config(unit, PPP_MRU, 0x00000000,
+ wo->neg_pcompression, wo->neg_accompression);
peer_mru[unit] = PPP_MRU;
lcp_allowoptions[unit].asyncmap = xmit_accm[unit][0];
@@ -311,23 +263,9 @@ lcp_input(unit, p, len)
u_char *p;
int len;
{
- int oldstate;
fsm *f = &lcp_fsm[unit];
- lcp_options *go = &lcp_gotoptions[f->unit];
- oldstate = f->state;
fsm_input(f, p, len);
- if (oldstate == REQSENT && f->state == ACKSENT) {
- /*
- * The peer will probably send us an ack soon and then
- * immediately start sending packets with the negotiated
- * options. So as to be ready when that happens, we set
- * our receive side to accept packets as negotiated now.
- */
- ppp_recv_config(f->unit, PPP_MRU,
- go->neg_asyncmap? go->asyncmap: 0x00000000,
- go->neg_pcompression, go->neg_accompression);
- }
}
@@ -382,6 +320,8 @@ lcp_rprotrej(f, inp, len)
u_char *inp;
int len;
{
+ int i;
+ struct protent *protp;
u_short prot;
LCPDEBUG((LOG_INFO, "lcp_rprotrej."));
@@ -408,7 +348,17 @@ lcp_rprotrej(f, inp, len)
return;
}
- DEMUXPROTREJ(f->unit, prot); /* Inform protocol */
+ /*
+ * Upcall the proper Protocol-Reject routine.
+ */
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->protocol == prot && protp->enabled_flag) {
+ (*protp->protrej)(f->unit);
+ return;
+ }
+
+ syslog(LOG_WARNING, "Protocol-Reject for unsupported protocol 0x%x",
+ prot);
}
@@ -454,8 +404,8 @@ lcp_sprotrej(unit, p, len)
* lcp_resetci - Reset our CI.
*/
static void
- lcp_resetci(f)
-fsm *f;
+lcp_resetci(f)
+ fsm *f;
{
lcp_wantoptions[f->unit].magicnumber = magic();
lcp_wantoptions[f->unit].numloops = 0;
@@ -473,17 +423,17 @@ lcp_cilen(f)
{
lcp_options *go = &lcp_gotoptions[f->unit];
-#define LENCIVOID(neg) (neg ? CILEN_VOID : 0)
-#define LENCICHAP(neg) (neg ? CILEN_CHAP : 0)
-#define LENCISHORT(neg) (neg ? CILEN_SHORT : 0)
-#define LENCILONG(neg) (neg ? CILEN_LONG : 0)
-#define LENCILQR(neg) (neg ? CILEN_LQR: 0)
+#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0)
+#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0)
+#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0)
+#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0)
+#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0)
/*
* NB: we only ask for one of CHAP and UPAP, even if we will
* accept either.
*/
- return (LENCISHORT(go->neg_mru) +
- LENCILONG(go->neg_asyncmap) +
+ return (LENCISHORT(go->neg_mru && go->mru != DEFMRU) +
+ LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) +
LENCICHAP(go->neg_chap) +
LENCISHORT(!go->neg_chap && go->neg_upap) +
LENCILQR(go->neg_lqr) +
@@ -537,8 +487,9 @@ lcp_addci(f, ucp, lenp)
PUTLONG(val, ucp); \
}
- ADDCISHORT(CI_MRU, go->neg_mru, go->mru);
- ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap, go->asyncmap);
+ ADDCISHORT(CI_MRU, go->neg_mru && go->mru != DEFMRU, go->mru);
+ ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF,
+ go->asyncmap);
ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
@@ -646,8 +597,9 @@ lcp_ackci(f, p, len)
goto bad; \
}
- ACKCISHORT(CI_MRU, go->neg_mru, go->mru);
- ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap, go->asyncmap);
+ ACKCISHORT(CI_MRU, go->neg_mru && go->mru != DEFMRU, go->mru);
+ ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF,
+ go->asyncmap);
ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
@@ -764,17 +716,21 @@ lcp_nakci(f, p, len)
* If they send us a bigger MRU than what we asked, accept it, up to
* the limit of the default MRU we'd get if we didn't negotiate.
*/
- NAKCISHORT(CI_MRU, neg_mru,
- if (cishort <= wo->mru || cishort < DEFMRU)
- try.mru = cishort;
- );
+ if (go->neg_mru && go->mru != DEFMRU) {
+ NAKCISHORT(CI_MRU, neg_mru,
+ if (cishort <= wo->mru || cishort < DEFMRU)
+ try.mru = cishort;
+ );
+ }
/*
* Add any characters they want to our (receive-side) asyncmap.
*/
- NAKCILONG(CI_ASYNCMAP, neg_asyncmap,
- try.asyncmap = go->asyncmap | cilong;
- );
+ if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) {
+ NAKCILONG(CI_ASYNCMAP, neg_asyncmap,
+ try.asyncmap = go->asyncmap | cilong;
+ );
+ }
/*
* If they've nak'd our authentication-protocol, check whether
@@ -890,11 +846,16 @@ lcp_nakci(f, p, len)
switch (citype) {
case CI_MRU:
- if (go->neg_mru || no.neg_mru || cilen != CILEN_SHORT)
+ if (go->neg_mru && go->mru != DEFMRU
+ || no.neg_mru || cilen != CILEN_SHORT)
goto bad;
+ GETSHORT(cishort, p);
+ if (cishort < DEFMRU)
+ try.mru = cishort;
break;
case CI_ASYNCMAP:
- if (go->neg_asyncmap || no.neg_asyncmap || cilen != CILEN_LONG)
+ if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF
+ || no.neg_asyncmap || cilen != CILEN_LONG)
goto bad;
break;
case CI_AUTHTYPE:
@@ -935,7 +896,7 @@ lcp_nakci(f, p, len)
if (looped_back) {
if (++try.numloops >= lcp_loopbackfail) {
syslog(LOG_NOTICE, "Serial line is looped back.");
- lcp_close(f->unit);
+ lcp_close(f->unit, "Loopback detected");
}
} else
try.numloops = 0;
@@ -969,8 +930,6 @@ lcp_rejci(f, p, len)
u_char cichar;
u_short cishort;
u_int32_t cilong;
- u_char *start = p;
- int plen = len;
lcp_options try; /* options to request next time */
try = *go;
@@ -1075,8 +1034,6 @@ lcp_rejci(f, p, len)
bad:
LCPDEBUG((LOG_WARNING, "lcp_rejci: received bad Reject!"));
- LCPDEBUG((LOG_WARNING, "lcp_rejci: plen %d len %d off %d",
- plen, len, p - start));
return 0;
}
@@ -1130,6 +1087,7 @@ lcp_reqci(f, inp, lenp, reject_if_disagree)
orc = CONFREJ; /* Reject bad CI */
cilen = l; /* Reject till end of packet */
l = 0; /* Don't loop again */
+ citype = 0;
goto endswitch;
}
GETCHAR(citype, p); /* Parse CI type */
@@ -1412,8 +1370,6 @@ endswitch:
/*
* lcp_up - LCP has come UP.
- *
- * Start UPAP, IPCP, etc.
*/
static void
lcp_up(f)
@@ -1450,10 +1406,6 @@ lcp_up(f)
if (ho->neg_mru)
peer_mru[f->unit] = ho->mru;
- ChapLowerUp(f->unit); /* Enable CHAP */
- upap_lowerup(f->unit); /* Enable UPAP */
- ipcp_lowerup(f->unit); /* Enable IPCP */
- ccp_lowerup(f->unit); /* Enable CCP */
lcp_echo_lowerup(f->unit); /* Enable echo messages */
link_established(f->unit);
@@ -1469,18 +1421,17 @@ static void
lcp_down(f)
fsm *f;
{
+ lcp_options *go = &lcp_gotoptions[f->unit];
+
lcp_echo_lowerdown(f->unit);
- ccp_lowerdown(f->unit);
- ipcp_lowerdown(f->unit);
- ChapLowerDown(f->unit);
- upap_lowerdown(f->unit);
- sifdown(f->unit);
+ link_down(f->unit);
+
ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0);
- ppp_recv_config(f->unit, PPP_MRU, 0x00000000, 0, 0);
+ ppp_recv_config(f->unit, PPP_MRU,
+ (go->neg_asyncmap? go->asyncmap: 0x00000000),
+ go->neg_pcompression, go->neg_accompression);
peer_mru[f->unit] = PPP_MRU;
-
- link_down(f->unit);
}
@@ -1580,7 +1531,7 @@ lcp_printpkt(p, plen, printer, arg)
GETSHORT(cishort, p);
switch (cishort) {
case PPP_PAP:
- printer(arg, "upap");
+ printer(arg, "pap");
break;
case PPP_CHAP:
printer(arg, "chap");
@@ -1651,8 +1602,10 @@ void LcpLinkFailure (f)
fsm *f;
{
if (f->state == OPENED) {
- syslog (LOG_NOTICE, "Excessive lack of response to LCP echo frames.");
- lcp_close(f->unit); /* Reset connection */
+ syslog(LOG_INFO, "No response to %d echo-requests", lcp_echos_pending);
+ syslog(LOG_NOTICE, "Serial link appears to be disconnected.");
+ lcp_close(f->unit, "Peer not responding");
+ phase = PHASE_TERMINATE;
}
}
@@ -1664,36 +1617,13 @@ static void
LcpEchoCheck (f)
fsm *f;
{
- long int delta;
-#ifdef __linux__
- struct ppp_idle ddinfo;
-/*
- * Read the time since the last packet was received.
- */
- if (ioctl (fd, PPPIOCGIDLE, &ddinfo) < 0) {
- syslog (LOG_ERR, "ioctl(PPPIOCGIDLE): %m");
- die (1);
- }
-/*
- * Compute the time since the last packet was received. If the timer
- * has expired then send the echo request and reset the timer to maximum.
- */
- delta = (long int) lcp_echo_interval - (long int) ddinfo.recv_idle;
- if (delta < 0L) {
- LcpSendEchoRequest (f);
- delta = (int) lcp_echo_interval;
- }
-
-#else /* Other implementations do not have ability to find delta */
LcpSendEchoRequest (f);
- delta = (int) lcp_echo_interval;
-#endif
-/*
- * Start the timer for the next interval.
- */
+ /*
+ * Start the timer for the next interval.
+ */
assert (lcp_echo_timer_running==0);
- TIMEOUT (LcpEchoTimeout, (caddr_t) f, (u_int32_t) delta);
+ TIMEOUT (LcpEchoTimeout, (caddr_t) f, lcp_echo_interval);
lcp_echo_timer_running = 1;
}
@@ -1749,27 +1679,24 @@ LcpSendEchoRequest (f)
u_int32_t lcp_magic;
u_char pkt[4], *pktp;
-/*
- * Detect the failure of the peer at this point.
- */
+ /*
+ * Detect the failure of the peer at this point.
+ */
if (lcp_echo_fails != 0) {
if (lcp_echos_pending++ >= lcp_echo_fails) {
LcpLinkFailure(f);
lcp_echos_pending = 0;
}
}
-/*
- * Make and send the echo request frame.
- */
+
+ /*
+ * Make and send the echo request frame.
+ */
if (f->state == OPENED) {
- lcp_magic = lcp_gotoptions[f->unit].neg_magicnumber
- ? lcp_gotoptions[f->unit].magicnumber
- : 0L;
+ lcp_magic = lcp_gotoptions[f->unit].magicnumber;
pktp = pkt;
PUTLONG(lcp_magic, pktp);
-
- fsm_sdata(f, ECHOREQ,
- lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
+ fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
}
}
@@ -1791,11 +1718,6 @@ lcp_echo_lowerup (unit)
/* If a timeout interval is specified then start the timer */
if (lcp_echo_interval != 0)
LcpEchoCheck (f);
-#ifdef _linux_
- /* If a idle time limit is given then start it */
- if (idle_time_limit != 0)
- RestartIdleTimer (f);
-#endif
}
/*
@@ -1812,11 +1734,4 @@ lcp_echo_lowerdown (unit)
UNTIMEOUT (LcpEchoTimeout, (caddr_t) f);
lcp_echo_timer_running = 0;
}
-#ifdef _linux_
- /* If a idle time limit is running then stop it */
- if (idle_timer_running != 0) {
- UNTIMEOUT (IdleTimeCheck, (caddr_t) f);
- idle_timer_running = 0;
- }
-#endif
}
diff --git a/usr.sbin/pppd/lcp.h b/usr.sbin/pppd/lcp.h
index b7a4936aeec..196a15ce10f 100644
--- a/usr.sbin/pppd/lcp.h
+++ b/usr.sbin/pppd/lcp.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: lcp.h,v 1.2 1996/03/25 15:55:47 niklas Exp $ */
+
/*
* lcp.h - Link Control Protocol definitions.
*
@@ -15,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Id: lcp.h,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp $
*/
/*
@@ -74,7 +74,7 @@ extern u_int32_t xmit_accm[][8];
void lcp_init __P((int));
void lcp_open __P((int));
-void lcp_close __P((int));
+void lcp_close __P((int, char *));
void lcp_lowerup __P((int));
void lcp_lowerdown __P((int));
void lcp_input __P((int, u_char *, int));
@@ -83,6 +83,8 @@ void lcp_sprotrej __P((int, u_char *, int));
int lcp_printpkt __P((u_char *, int,
void (*) __P((void *, char *, ...)), void *));
+extern struct protent lcp_protent;
+
/* Default number of times we receive our magic number from the peer
before deciding the link is looped-back. */
#define DEFLOOPBACKFAIL 5
diff --git a/usr.sbin/pppd/magic.c b/usr.sbin/pppd/magic.c
index c44c10b1477..ab84ff70ad3 100644
--- a/usr.sbin/pppd/magic.c
+++ b/usr.sbin/pppd/magic.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: magic.c,v 1.2 1996/03/25 15:55:48 niklas Exp $ */
+
/*
* magic.c - PPP Magic Number routines.
*
@@ -18,23 +20,20 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: magic.c,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: magic.c,v 1.2 1996/03/25 15:55:48 niklas Exp $";
#endif
#include <stdio.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include "pppd.h"
#include "magic.h"
-static u_int32_t next; /* Next value to return */
-
-extern int gethostid __P((void));
extern long mrand48 __P((void));
extern void srand48 __P((long));
-
/*
* magic_init - Initialize the magic number generator.
*
diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c
index 9dd44b7dd3b..527cb2913fd 100644
--- a/usr.sbin/pppd/main.c
+++ b/usr.sbin/pppd/main.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: main.c,v 1.5 1996/03/25 15:55:49 niklas Exp $ */
+
/*
* main.c - Point-to-Point Protocol main module
*
@@ -18,12 +20,13 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.4 1996/02/04 19:39:39 hannken Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.5 1996/03/25 15:55:49 niklas Exp $";
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
@@ -51,6 +54,10 @@ static char rcsid[] = "$Id: main.c,v 1.4 1996/02/04 19:39:39 hannken Exp $";
#include "pathnames.h"
#include "patchlevel.h"
+#ifdef IPX_CHANGE
+#include "ipxcp.h"
+#endif /* IPX_CHANGE */
+
/*
* If REQ_SYSOPTIONS is defined to 1, pppd will not run unless
* /etc/ppp/options exists.
@@ -67,50 +74,45 @@ char *progname; /* Name of this program */
char hostname[MAXNAMELEN]; /* Our hostname */
static char pidfilename[MAXPATHLEN]; /* name of pid file */
static char default_devnam[MAXPATHLEN]; /* name of default device */
-static pid_t pid; /* Our pid */
-static pid_t pgrpid; /* Process Group ID */
+static pid_t pid; /* Our pid */
static uid_t uid; /* Our real user-id */
-int fd = -1; /* Device file descriptor */
+int ttyfd = -1; /* Serial port file descriptor */
int phase; /* where the link is at */
int kill_link;
int open_ccp_flag;
-static int initfdflags = -1; /* Initial file descriptor flags */
-
u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */
-static u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
+u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
int hungup; /* terminal has been hung up */
static int n_children; /* # child processes still running */
-int baud_rate;
+int baud_rate; /* Actual bits/second for serial device */
+
+static int locked; /* lock() has succeeded */
char *no_ppp_msg = "Sorry - this system lacks PPP kernel support\n";
-/* prototypes */
+/* Prototypes for procedures local to this file. */
+
+static void cleanup __P((void));
+static void close_tty __P((void));
+static void get_input __P((void));
+static void connect_time_expired __P((caddr_t));
+static void calltimeout __P((void));
+static struct timeval *timeleft __P((struct timeval *));
static void hup __P((int));
static void term __P((int));
static void chld __P((int));
static void toggle_debug __P((int));
static void open_ccp __P((int));
static void bad_signal __P((int));
-
-static void get_input __P((void));
-void establish_ppp __P((void));
-void calltimeout __P((void));
-struct timeval *timeleft __P((struct timeval *));
-void reap_kids __P((void));
-void cleanup __P((int, caddr_t));
-void close_fd __P((void));
-void die __P((int));
-void novm __P((char *));
-
-void log_packet __P((u_char *, int, char *));
-void format_packet __P((u_char *, int,
- void (*) (void *, char *, ...), void *));
-void pr_log __P((void *, char *, ...));
+static void holdoff_end __P((void *));
+static int device_script __P((char *, int, int));
+static void reap_kids __P((void));
+static void pr_log __P((void *, char *, ...));
extern char *ttyname __P((int));
extern char *getlogin __P((void));
@@ -123,42 +125,33 @@ extern char *getlogin __P((void));
/*
* PPP Data Link Layer "protocol" table.
* One entry per supported protocol.
+ * The last entry must be NULL.
*/
-static struct protent {
- u_short protocol;
- void (*init)();
- void (*input)();
- void (*protrej)();
- int (*printpkt)();
- void (*datainput)();
- char *name;
-} prottbl[] = {
- { PPP_LCP, lcp_init, lcp_input, lcp_protrej,
- lcp_printpkt, NULL, "LCP" },
- { PPP_IPCP, ipcp_init, ipcp_input, ipcp_protrej,
- ipcp_printpkt, NULL, "IPCP" },
- { PPP_PAP, upap_init, upap_input, upap_protrej,
- upap_printpkt, NULL, "PAP" },
- { PPP_CHAP, ChapInit, ChapInput, ChapProtocolReject,
- ChapPrintPkt, NULL, "CHAP" },
- { PPP_CCP, ccp_init, ccp_input, ccp_protrej,
- ccp_printpkt, ccp_datainput, "CCP" },
+struct protent *protocols[] = {
+ &lcp_protent,
+ &pap_protent,
+ &chap_protent,
+ &ipcp_protent,
+ &ccp_protent,
+#ifdef IPX_CHANGE
+ &ipxcp_protent,
+#endif
+ NULL
};
-#define N_PROTO (sizeof(prottbl) / sizeof(prottbl[0]))
-
+void
main(argc, argv)
int argc;
char *argv[];
{
- int i, nonblock;
+ int i, nonblock, fdflags;
struct sigaction sa;
- struct cmd *cmdp;
FILE *pidfile;
char *p;
struct passwd *pw;
struct timeval timo;
sigset_t mask;
+ struct protent *protp;
p = ttyname(0);
if (p)
@@ -173,28 +166,40 @@ main(argc, argv)
uid = getuid();
- if (!ppp_available()) {
- fprintf(stderr, no_ppp_msg);
- exit(1);
- }
-
/*
* Initialize to the standard option set, then parse, in order,
* the system options file, the user's options file, and the command
* line arguments.
*/
- for (i = 0; i < N_PROTO; i++)
- (*prottbl[i].init)(0);
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ (*protp->init)(0);
progname = *argv;
if (!options_from_file(_PATH_SYSOPTIONS, REQ_SYSOPTIONS, 0) ||
+ !options_for_tty() ||
!options_from_user() ||
- !parse_args(argc-1, argv+1) ||
- !options_for_tty())
- die(1);
- check_auth_options();
- setipdefault();
+ !parse_args(argc-1, argv+1))
+ exit(1);
+
+ if (!ppp_available()) {
+ fprintf(stderr, no_ppp_msg);
+ exit(1);
+ }
+
+ /*
+ * Check that the options given are valid and consistent.
+ */
+ sys_check_options();
+ auth_check_options();
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (protp->check_options != NULL)
+ (*protp->check_options)();
+ if (demand && connector == 0) {
+ fprintf(stderr, "%s: connect script required for demand-dialling\n",
+ progname);
+ exit(1);
+ }
/*
* If the user has specified the default device name explicitly,
@@ -298,13 +303,70 @@ main(argc, argv)
#endif
/*
- * Lock the device if we've been asked to.
+ * If we're doing dial-on-demand, set up the interface now.
*/
- if (lockflag && !default_device)
- if (lock(devnam) < 0)
- die(1);
+ if (demand) {
+ /*
+ * Open the loopback channel and set it up to be the ppp interface.
+ */
+ open_ppp_loopback();
- do {
+ syslog(LOG_INFO, "Using interface ppp%d", ifunit);
+ (void) sprintf(ifname, "ppp%d", ifunit);
+
+ /* write pid to file */
+ (void) sprintf(pidfilename, "%s%s.pid", _PATH_VARRUN, ifname);
+ if ((pidfile = fopen(pidfilename, "w")) != NULL) {
+ fprintf(pidfile, "%d\n", pid);
+ (void) fclose(pidfile);
+ } else {
+ syslog(LOG_ERR, "Failed to create pid file %s: %m", pidfilename);
+ pidfilename[0] = 0;
+ }
+
+ /*
+ * Configure the interface and mark it up, etc.
+ */
+ demand_conf();
+ }
+
+ for (;;) {
+
+ if (demand) {
+ /*
+ * Don't do anything until we see some activity.
+ */
+ phase = PHASE_DORMANT;
+ kill_link = 0;
+ demand_unblock();
+ for (;;) {
+ wait_loop_output(timeleft(&timo));
+ calltimeout();
+ if (kill_link) {
+ if (!persist)
+ die(0);
+ kill_link = 0;
+ }
+ if (get_loop_output())
+ break;
+ reap_kids();
+ }
+
+ /*
+ * Now we want to bring up the link.
+ */
+ demand_block();
+ syslog(LOG_INFO, "Starting link");
+ }
+
+ /*
+ * Lock the device if we've been asked to.
+ */
+ if (lockflag && !default_device) {
+ if (lock(devnam) < 0)
+ goto fail;
+ locked = 1;
+ }
/*
* Open the serial device and set it up to be the ppp interface.
@@ -313,17 +375,15 @@ main(argc, argv)
* the non-blocking I/O bit.
*/
nonblock = (connector || !modem)? O_NONBLOCK: 0;
- if ((fd = open(devnam, nonblock | O_RDWR, 0)) < 0) {
+ if ((ttyfd = open(devnam, nonblock | O_RDWR, 0)) < 0) {
syslog(LOG_ERR, "Failed to open %s: %m", devnam);
- die(1);
- }
- if ((initfdflags = fcntl(fd, F_GETFL)) == -1) {
- syslog(LOG_ERR, "Couldn't get device fd flags: %m");
- die(1);
+ goto fail;
}
if (nonblock) {
- initfdflags &= ~O_NONBLOCK;
- fcntl(fd, F_SETFL, initfdflags);
+ if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
+ || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
+ syslog(LOG_WARNING,
+ "Couldn't reset non-blocking mode on device: %m");
}
hungup = 0;
kill_link = 0;
@@ -333,19 +393,19 @@ main(argc, argv)
MAINDEBUG((LOG_INFO, "Connecting with <%s>", connector));
/* set line speed, flow control, etc.; set CLOCAL for now */
- set_up_tty(fd, 1);
+ set_up_tty(ttyfd, 1);
/* drop dtr to hang up in case modem is off hook */
if (!default_device && modem) {
- setdtr(fd, FALSE);
+ setdtr(ttyfd, FALSE);
sleep(1);
- setdtr(fd, TRUE);
+ setdtr(ttyfd, TRUE);
}
- if (device_script(connector, fd, fd) < 0) {
+ if (device_script(connector, ttyfd, ttyfd) < 0) {
syslog(LOG_ERR, "Connect script failed");
- setdtr(fd, FALSE);
- die(1);
+ setdtr(ttyfd, FALSE);
+ goto fail;
}
syslog(LOG_INFO, "Serial connection established.");
@@ -353,34 +413,43 @@ main(argc, argv)
}
/* set line speed, flow control, etc.; clear CLOCAL if modem option */
- set_up_tty(fd, 0);
-
- /* set up the serial device as a ppp interface */
- establish_ppp();
+ set_up_tty(ttyfd, 0);
- syslog(LOG_INFO, "Using interface ppp%d", ifunit);
- (void) sprintf(ifname, "ppp%d", ifunit);
+ /* run welcome script, if any */
+ if (welcomer && welcomer[0]) {
+ if (device_script(welcomer, ttyfd, ttyfd) < 0)
+ syslog(LOG_WARNING, "Welcome script failed");
+ }
- /* write pid to file */
- (void) sprintf(pidfilename, "%s%s.pid", _PATH_VARRUN, ifname);
- if ((pidfile = fopen(pidfilename, "w")) != NULL) {
- fprintf(pidfile, "%d\n", pid);
- (void) fclose(pidfile);
- } else {
- syslog(LOG_ERR, "Failed to create pid file %s: %m", pidfilename);
- pidfilename[0] = 0;
+ /* set up the serial device as a ppp interface */
+ establish_ppp(ttyfd);
+
+ if (!demand) {
+
+ syslog(LOG_INFO, "Using interface ppp%d", ifunit);
+ (void) sprintf(ifname, "ppp%d", ifunit);
+
+ /* write pid to file */
+ (void) sprintf(pidfilename, "%s%s.pid", _PATH_VARRUN, ifname);
+ if ((pidfile = fopen(pidfilename, "w")) != NULL) {
+ fprintf(pidfile, "%d\n", pid);
+ (void) fclose(pidfile);
+ } else {
+ syslog(LOG_ERR, "Failed to create pid file %s: %m",
+ pidfilename);
+ pidfilename[0] = 0;
+ }
}
/*
- * Set device for non-blocking reads.
+ * Set a timeout to close the connection once the maximum
+ * connect time has expired.
*/
- if (fcntl(fd, F_SETFL, initfdflags | O_NONBLOCK) == -1) {
- syslog(LOG_ERR, "Couldn't set device to non-blocking mode: %m");
- die(1);
- }
-
+ if (maxconnect > 0)
+ TIMEOUT(connect_time_expired, 0, maxconnect);
+
/*
- * Block all signals, start opening the connection, and wait for
+ * Start opening the connection and wait for
* incoming events (reply, timeout, etc.).
*/
syslog(LOG_NOTICE, "Connect: %s <--> %s", ifname, devnam);
@@ -391,7 +460,8 @@ main(argc, argv)
calltimeout();
get_input();
if (kill_link) {
- lcp_close(0);
+ lcp_close(0, "User request");
+ phase = PHASE_TERMINATE;
kill_link = 0;
}
if (open_ccp_flag) {
@@ -405,32 +475,75 @@ main(argc, argv)
}
/*
+ * If we may want to bring the link up again, transfer
+ * the ppp unit back to the loopback. Set the
+ * real serial device back to its normal mode of operation.
+ */
+ clean_check();
+ if (demand)
+ restore_loop();
+ disestablish_ppp(ttyfd);
+
+ /*
* Run disconnector script, if requested.
- * First we need to reset non-blocking mode.
* XXX we may not be able to do this if the line has hung up!
*/
- if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) >= 0)
- initfdflags = -1;
- disestablish_ppp();
- if (disconnector) {
- set_up_tty(fd, 1);
- if (device_script(disconnector, fd, fd) < 0) {
+ if (disconnector && !hungup) {
+ set_up_tty(ttyfd, 1);
+ if (device_script(disconnector, ttyfd, ttyfd) < 0) {
syslog(LOG_WARNING, "disconnect script failed");
} else {
syslog(LOG_INFO, "Serial link disconnected.");
}
}
- close_fd();
- if (unlink(pidfilename) < 0 && errno != ENOENT)
- syslog(LOG_WARNING, "unable to delete pid file: %m");
- pidfilename[0] = 0;
+ fail:
+ close_tty();
+ if (locked) {
+ unlock();
+ locked = 0;
+ }
+
+ if (!demand) {
+ if (unlink(pidfilename) < 0 && errno != ENOENT)
+ syslog(LOG_WARNING, "unable to delete pid file: %m");
+ pidfilename[0] = 0;
+ }
- } while (persist);
+ if (!persist)
+ break;
+
+ if (demand)
+ demand_discard();
+ if (holdoff > 0) {
+ phase = PHASE_HOLDOFF;
+ TIMEOUT(holdoff_end, NULL, holdoff);
+ do {
+ wait_time(timeleft(&timo));
+ calltimeout();
+ if (kill_link) {
+ if (!persist)
+ die(0);
+ kill_link = 0;
+ phase = PHASE_DORMANT; /* allow signal to end holdoff */
+ }
+ reap_kids();
+ } while (phase == PHASE_HOLDOFF);
+ }
+ }
die(0);
}
+/*
+ * holdoff_end - called via a timeout when the holdoff period ends.
+ */
+static void
+holdoff_end(arg)
+ void *arg;
+{
+ phase = PHASE_DORMANT;
+}
/*
* get_input - called when incoming data is available.
@@ -441,6 +554,7 @@ get_input()
int len, i;
u_char *p;
u_short protocol;
+ struct protent *protp;
p = inpacket_buf; /* point to beginning of packet buffer */
@@ -452,7 +566,7 @@ get_input()
syslog(LOG_NOTICE, "Modem hangup");
hungup = 1;
lcp_lowerdown(0); /* serial link is no longer available */
- phase = PHASE_DEAD;
+ link_terminated(0);
return;
}
@@ -480,61 +594,25 @@ get_input()
/*
* Upcall the proper protocol input routine.
*/
- for (i = 0; i < sizeof (prottbl) / sizeof (struct protent); i++) {
- if (prottbl[i].protocol == protocol) {
- (*prottbl[i].input)(0, p, len);
+ for (i = 0; (protp = protocols[i]) != NULL; ++i) {
+ if (protp->protocol == protocol && protp->enabled_flag) {
+ (*protp->input)(0, p, len);
return;
}
- if (protocol == (prottbl[i].protocol & ~0x8000)
- && prottbl[i].datainput != NULL) {
- (*prottbl[i].datainput)(0, p, len);
+ if (protocol == (protp->protocol & ~0x8000) && protp->enabled_flag
+ && protp->datainput != NULL) {
+ (*protp->datainput)(0, p, len);
return;
}
}
if (debug)
- syslog(LOG_WARNING, "Unknown protocol (0x%x) received", protocol);
+ syslog(LOG_WARNING, "Unsupported protocol (0x%x) received", protocol);
lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN);
}
/*
- * demuxprotrej - Demultiplex a Protocol-Reject.
- */
-void
-demuxprotrej(unit, protocol)
- int unit;
- u_short protocol;
-{
- int i;
-
- /*
- * Upcall the proper Protocol-Reject routine.
- */
- for (i = 0; i < sizeof (prottbl) / sizeof (struct protent); i++)
- if (prottbl[i].protocol == protocol) {
- (*prottbl[i].protrej)(unit);
- return;
- }
-
- syslog(LOG_WARNING,
- "demuxprotrej: Unrecognized Protocol-Reject for protocol 0x%x",
- protocol);
-}
-
-
-/*
- * bad_signal - We've caught a fatal signal. Clean up state and exit.
- */
-static void
-bad_signal(sig)
- int sig;
-{
- syslog(LOG_ERR, "Fatal signal %d", sig);
- die(1);
-}
-
-/*
* quit - Clean up state and exit (with an error indication).
*/
void
@@ -550,53 +628,66 @@ void
die(status)
int status;
{
- cleanup(0, NULL);
+ cleanup();
syslog(LOG_INFO, "Exit.");
exit(status);
}
/*
+ * connect_time_expired - log a message and close the connection.
+ */
+static void
+connect_time_expired(arg)
+ caddr_t arg;
+{
+ syslog(LOG_INFO, "Connect time expired");
+
+ phase = PHASE_TERMINATE;
+ lcp_close(0, "Connect time expired"); /* Close connection */
+}
+
+/*
* cleanup - restore anything which needs to be restored before we exit
*/
/* ARGSUSED */
-void
-cleanup(status, arg)
- int status;
- caddr_t arg;
+static void
+cleanup()
{
- if (fd >= 0)
- close_fd();
+ sys_cleanup();
+
+ if (ttyfd >= 0)
+ close_tty();
if (pidfilename[0] != 0 && unlink(pidfilename) < 0 && errno != ENOENT)
syslog(LOG_WARNING, "unable to delete pid file: %m");
pidfilename[0] = 0;
- if (lockflag && !default_device)
+ if (locked)
unlock();
}
/*
- * close_fd - restore the terminal device and close it.
+ * close_tty - restore the terminal device and close it.
*/
-void
-close_fd()
+static void
+close_tty()
{
- disestablish_ppp();
+ disestablish_ppp(ttyfd);
/* drop dtr to hang up */
if (modem) {
- setdtr(fd, FALSE);
+ setdtr(ttyfd, FALSE);
+ /*
+ * This sleep is in case the serial port has CLOCAL set by default,
+ * and consequently will reassert DTR when we close the device.
+ */
sleep(1);
}
- if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
- syslog(LOG_WARNING, "Couldn't restore device fd flags: %m");
- initfdflags = -1;
+ restore_tty(ttyfd);
- restore_tty();
-
- close(fd);
- fd = -1;
+ close(ttyfd);
+ ttyfd = -1;
}
@@ -661,9 +752,7 @@ untimeout(func, arg)
void (*func)();
caddr_t arg;
{
- struct itimerval itv;
struct callout **copp, *freep;
- int reschedule = 0;
MAINDEBUG((LOG_DEBUG, "Untimeout %lx:%lx.", (long) func, (long) arg));
@@ -682,7 +771,7 @@ untimeout(func, arg)
/*
* calltimeout - Call any timeout routines which are now due.
*/
-void
+static void
calltimeout()
{
struct callout *p;
@@ -710,7 +799,7 @@ calltimeout()
/*
* timeleft - return the length of time until the next timeout is due.
*/
-struct timeval *
+static struct timeval *
timeleft(tvp)
struct timeval *tvp;
{
@@ -805,10 +894,22 @@ open_ccp(sig)
/*
+ * bad_signal - We've caught a fatal signal. Clean up state and exit.
+ */
+static void
+bad_signal(sig)
+ int sig;
+{
+ syslog(LOG_ERR, "Fatal signal %d", sig);
+ die(1);
+}
+
+
+/*
* device_script - run a program to connect or disconnect the
* serial device.
*/
-int
+static int
device_script(program, in, out)
char *program;
int in, out;
@@ -825,6 +926,7 @@ device_script(program, in, out)
}
if (pid == 0) {
+ sys_close();
dup2(in, 0);
dup2(out, 1);
errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0644);
@@ -879,11 +981,11 @@ run_program(prog, args, must_exist)
setgid(getegid());
/* Ensure that nothing of our device environment is inherited. */
+ sys_close();
close (0);
close (1);
close (2);
- close (fd); /* tty interface to the ppp device */
- /* XXX should call sysdep cleanup procedure here */
+ close (ttyfd); /* tty interface to the ppp device */
/* Don't pass handles to the PPP device, even by accident. */
new_fd = open (_PATH_DEVNULL, O_RDWR);
@@ -919,7 +1021,7 @@ run_program(prog, args, must_exist)
* reap_kids - get status from any dead child processes,
* and log a message for abnormal terminations.
*/
-void
+static void
reap_kids()
{
int pid, status;
@@ -975,17 +1077,18 @@ format_packet(p, len, printer, arg)
int i, n;
u_short proto;
u_char x;
+ struct protent *protp;
if (len >= PPP_HDRLEN && p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) {
p += 2;
GETSHORT(proto, p);
len -= PPP_HDRLEN;
- for (i = 0; i < N_PROTO; ++i)
- if (proto == prottbl[i].protocol)
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+ if (proto == protp->protocol)
break;
- if (i < N_PROTO) {
- printer(arg, "[%s", prottbl[i].name);
- n = (*prottbl[i].printpkt)(p, len, printer, arg);
+ if (protp != NULL) {
+ printer(arg, "[%s", protp->name);
+ n = (*protp->printpkt)(p, len, printer, arg);
printer(arg, "]");
p += n;
len -= n;
@@ -1003,7 +1106,7 @@ format_packet(p, len, printer, arg)
#ifdef __STDC__
#include <stdarg.h>
-void
+static void
pr_log(void *arg, char *fmt, ...)
{
int n;
@@ -1026,7 +1129,7 @@ pr_log(void *arg, char *fmt, ...)
#else /* __STDC__ */
#include <varargs.h>
-void
+static void
pr_log(arg, fmt, va_alist)
void *arg;
char *fmt;
diff --git a/usr.sbin/pppd/nametoaddr.c b/usr.sbin/pppd/nametoaddr.c
new file mode 100644
index 00000000000..8f8110c3aba
--- /dev/null
+++ b/usr.sbin/pppd/nametoaddr.c
@@ -0,0 +1,214 @@
+/* $OpenBSD: nametoaddr.c,v 1.1 1996/03/25 15:55:50 niklas Exp $ */
+/* From NetBSD: nametoaddr.c,v 1.3 1995/04/29 05:42:23 cgd Exp */
+
+/*
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Name to id translation routines used by the scanner.
+ * These functions are not time critical.
+ */
+
+#ifndef lint
+#if 0
+from: static char rcsid[] =
+ "@(#) Header: nametoaddr.c,v 1.21 94/06/20 19:07:54 leres Exp (LBL)";
+#else
+static char rcsid[] = "$OpenBSD: nametoaddr.c,v 1.1 1996/03/25 15:55:50 niklas Exp $";
+#endif
+#endif
+
+#include <stdio.h>
+#ifdef __NetBSD__
+#include <stdlib.h>
+#include <string.h>
+#endif
+#include <ctype.h>
+#include <errno.h>
+#include <netdb.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <net/ppp_defs.h>
+
+#include "bpf_compile.h"
+#include "gencode.h"
+
+#ifndef __GNUC__
+#define inline
+#endif
+
+#ifndef NTOHL
+#define NTOHL(x) (x) = ntohl(x)
+#define NTOHS(x) (x) = ntohs(x)
+#endif
+
+/*
+ * Convert host name to internet address.
+ * Return 0 upon failure.
+ */
+u_long **
+pcap_nametoaddr(const char *name)
+{
+#ifndef h_addr
+ static u_long *hlist[2];
+#endif
+ u_long **p;
+ struct hostent *hp;
+
+ if ((hp = gethostbyname(name)) != NULL) {
+#ifndef h_addr
+ hlist[0] = (u_long *)hp->h_addr;
+ NTOHL(hp->h_addr);
+ return hlist;
+#else
+ for (p = (u_long **)hp->h_addr_list; *p; ++p)
+ NTOHL(**p);
+ return (u_long **)hp->h_addr_list;
+#endif
+ }
+ else
+ return 0;
+}
+
+/*
+ * Convert net name to internet address.
+ * Return 0 upon failure.
+ */
+u_long
+pcap_nametonetaddr(const char *name)
+{
+ struct netent *np;
+
+ if ((np = getnetbyname(name)) != NULL)
+ return np->n_net;
+ else
+ return 0;
+}
+
+/*
+ * Convert a port name to its port and protocol numbers.
+ * We assume only TCP or UDP.
+ * Return 0 upon failure.
+ */
+int
+pcap_nametoport(const char *name, int *port, int *proto)
+{
+ struct servent *sp;
+ char *other;
+
+ sp = getservbyname(name, (char *)0);
+ if (sp != NULL) {
+ NTOHS(sp->s_port);
+ *port = sp->s_port;
+ *proto = pcap_nametoproto(sp->s_proto);
+ /*
+ * We need to check /etc/services for ambiguous entries.
+ * If we find the ambiguous entry, and it has the
+ * same port number, change the proto to PROTO_UNDEF
+ * so both TCP and UDP will be checked.
+ */
+ if (*proto == IPPROTO_TCP)
+ other = "udp";
+ else
+ other = "tcp";
+
+ sp = getservbyname(name, other);
+ if (sp != 0) {
+ NTOHS(sp->s_port);
+ if (*port != sp->s_port)
+ /* Can't handle ambiguous names that refer
+ to different port numbers. */
+#ifdef notdef
+ warning("ambiguous port %s in /etc/services",
+ name);
+#else
+ ;
+#endif
+ *proto = PROTO_UNDEF;
+ }
+ return 1;
+ }
+#if defined(ultrix) || defined(__osf__)
+ /* Special hack in case NFS isn't in /etc/services */
+ if (strcmp(name, "nfs") == 0) {
+ *port = 2049;
+ *proto = PROTO_UNDEF;
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+int
+pcap_nametoproto(const char *str)
+{
+ struct protoent *p;
+
+ p = getprotobyname(str);
+ if (p != 0)
+ return p->p_proto;
+ else
+ return PROTO_UNDEF;
+}
+
+u_long
+__pcap_atoin(const char *s)
+{
+ u_long addr = 0;
+ u_int n;
+
+ while (1) {
+ n = 0;
+ while (*s && *s != '.')
+ n = n * 10 + *s++ - '0';
+ addr <<= 8;
+ addr |= n & 0xff;
+ if (*s == '\0')
+ return addr;
+ ++s;
+ }
+ /* NOTREACHED */
+}
+
+struct pppproto {
+ char *s;
+ u_short p;
+};
+
+/* Static data base of PPP protocol types. */
+struct pppproto pppproto_db[] = {
+ { "ip", PPP_IP },
+ { (char *)0, 0 }
+};
+
+int
+pcap_nametopppproto(const char *s)
+{
+ struct pppproto *p = pppproto_db;
+
+ while (p->s != 0) {
+ if (strcmp(p->s, s) == 0)
+ return p->p;
+ p += 1;
+ }
+ return PROTO_UNDEF;
+}
diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c
index 86389dd5f9a..fe87b40de0b 100644
--- a/usr.sbin/pppd/options.c
+++ b/usr.sbin/pppd/options.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: options.c,v 1.2 1996/03/25 15:55:51 niklas Exp $ */
+
/*
* options.c - handles option processing for PPP.
*
@@ -18,9 +20,10 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: options.c,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: options.c,v 1.2 1996/03/25 15:55:51 niklas Exp $";
#endif
+#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
@@ -34,6 +37,7 @@ static char rcsid[] = "$Id: options.c,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp
#include <sys/types.h>
#include <sys/stat.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include "pppd.h"
#include "pathnames.h"
@@ -44,6 +48,11 @@ static char rcsid[] = "$Id: options.c,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp
#include "upap.h"
#include "chap.h"
#include "ccp.h"
+#include "bpf_compile.h"
+
+#ifdef IPX_CHANGE
+#include "ipxcp.h"
+#endif /* IPX_CHANGE */
#include <net/ppp-comp.h>
@@ -73,6 +82,8 @@ int lockflag = 0; /* Create lock file to lock the serial dev */
int nodetach = 0; /* Don't detach from controlling tty */
char *connector = NULL; /* Script to establish physical link */
char *disconnector = NULL; /* Script to disestablish physical link */
+char *welcomer = NULL; /* Script to run after phys link estab. */
+int maxconnect = 0; /* Maximum connect time */
char user[MAXNAMELEN]; /* Username for PAP */
char passwd[MAXSECRETLEN]; /* Password for PAP */
int auth_required = 0; /* Peer is required to authenticate */
@@ -86,17 +97,19 @@ char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
int usehostname = 0; /* Use hostname for our_name */
int disable_defaultip = 0; /* Don't use hostname for default IP adrs */
+int demand = 0; /* do dial-on-demand */
char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
int cryptpap; /* Passwords in pap-secrets are encrypted */
-
-#ifdef _linux_
-int idle_time_limit = 0;
-static int setidle __P((char **));
-#endif
+int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
+int holdoff = 30; /* # seconds to pause before reconnecting */
+struct bpf_program pass_filter;/* Filter program for packets to pass */
+struct bpf_program active_filter; /* Filter program for link-active pkts */
/*
* Prototypes
*/
+static int setdevname __P((char *));
+static int setipaddr __P((char *));
static int setdebug __P((void));
static int setkdebug __P((char **));
static int setpassive __P((void));
@@ -113,7 +126,7 @@ static int reqchap __P((void));
static int setspeed __P((char *));
static int noaccomp __P((void));
static int noasyncmap __P((void));
-static int noipaddr __P((void));
+static int noip __P((void));
static int nomagicnumber __P((void));
static int setasyncmap __P((char **));
static int setescape __P((char **));
@@ -123,6 +136,8 @@ static int nomru __P((void));
static int nopcomp __P((void));
static int setconnector __P((char **));
static int setdisconnector __P((char **));
+static int setwelcomer __P((char **));
+static int setmaxconnect __P((char **));
static int setdomain __P((char **));
static int setnetmask __P((char **));
static int setcrtscts __P((void));
@@ -165,8 +180,37 @@ static int setlcpechointv __P((char **));
static int setlcpechofails __P((char **));
static int setbsdcomp __P((char **));
static int setnobsdcomp __P((void));
+static int setdeflate __P((char **));
+static int setnodeflate __P((void));
+static int setdemand __P((void));
+static int setpred1comp __P((void));
+static int setnopred1comp __P((void));
static int setipparam __P((char **));
static int setpapcrypt __P((void));
+static int setidle __P((char **));
+static int setholdoff __P((char **));
+static int setpassfilter __P((char **));
+static int setactivefilter __P((char **));
+
+#ifdef IPX_CHANGE
+static int setipxproto __P((void));
+static int resetipxproto __P((void));
+static int setipxanet __P((void));
+static int setipxalcl __P((void));
+static int setipxarmt __P((void));
+static int setipxnetwork __P((char **));
+static int setipxnode __P((char **));
+static int setipxrouter __P((char **));
+static int setipxname __P((char **));
+static int setipxcptimeout __P((char **));
+static int setipxcpterm __P((char **));
+static int setipxcpconf __P((char **));
+static int setipxcpfails __P((char **));
+#endif /* IPX_CHANGE */
+
+#ifdef USE_MS_DNS
+static int setdnsaddr __P((char **));
+#endif
static int number_option __P((char *, u_int32_t *, int));
static int readable __P((int fd));
@@ -187,7 +231,7 @@ static struct cmd {
{"-as", 1, setasyncmap}, /* set the desired async map */
{"-d", 0, setdebug}, /* Increase debugging level */
{"-detach", 0, setnodetach}, /* don't fork */
- {"-ip", 0, noipaddr}, /* Disable IP address negotiation */
+ {"-ip", 0, noip}, /* Disable IP and IPCP */
{"-mn", 0, nomagicnumber}, /* Disable magic number negotiation */
{"-mru", 0, nomru}, /* Disable mru negotiation */
{"-p", 0, setpassive}, /* Set passive mode */
@@ -204,6 +248,8 @@ static struct cmd {
{"escape", 1, setescape}, /* set chars to escape on transmission */
{"connect", 1, setconnector}, /* A program to set up a connection */
{"disconnect", 1, setdisconnector}, /* program to disconnect serial dev. */
+ {"welcome", 1, setwelcomer},/* Script to welcome client */
+ {"maxconnect", 1, setmaxconnect}, /* specify a maximum connect time */
{"crtscts", 0, setcrtscts}, /* set h/w flow control */
{"-crtscts", 0, setnocrtscts}, /* clear h/w flow control */
{"xonxoff", 0, setxonxoff}, /* set s/w flow control */
@@ -229,6 +275,7 @@ static struct cmd {
{"proxyarp", 0, setproxyarp}, /* Add proxy ARP entry */
{"-proxyarp", 0, setnoproxyarp}, /* disable proxyarp option */
{"persist", 0, setpersist}, /* Keep on reopening connection after close */
+ {"demand", 0, setdemand}, /* Dial on demand */
{"login", 0, setdologin}, /* Use system password database for UPAP */
{"noipdefault", 0, setnoipdflt}, /* Don't use name for default IP adrs */
{"lcp-echo-failure", 1, setlcpechofails}, /* consecutive echo failures */
@@ -251,11 +298,44 @@ static struct cmd {
{"ipcp-accept-remote", 0, setipcpaccr}, /* Accept peer's address for it */
{"bsdcomp", 1, setbsdcomp}, /* request BSD-Compress */
{"-bsdcomp", 0, setnobsdcomp}, /* don't allow BSD-Compress */
+ {"deflate", 1, setdeflate}, /* request Deflate compression */
+ {"-deflate", 0, setnodeflate}, /* don't allow Deflate compression */
+ {"predictor1", 0, setpred1comp}, /* request Predictor-1 */
+ {"-predictor1", 0, setnopred1comp}, /* don't allow Predictor-1 */
{"ipparam", 1, setipparam}, /* set ip script parameter */
{"papcrypt", 0, setpapcrypt}, /* PAP passwords encrypted */
+ {"idle", 1, setidle}, /* idle time limit (seconds) */
+ {"holdoff", 1, setholdoff}, /* set holdoff time (seconds) */
+ {"pass-filter", 1, setpassfilter}, /* set filter for packets to pass */
+ {"active-filter", 1, setactivefilter}, /* set filter for active pkts */
+
+#ifdef IPX_CHANGE
+ {"ipx-network", 1, setipxnetwork}, /* IPX network number */
+ {"ipxcp-accept-network", 0, setipxanet}, /* Accept peer netowrk */
+ {"ipx-node", 1, setipxnode}, /* IPX node number */
+ {"ipxcp-accept-local", 0, setipxalcl}, /* Accept our address */
+ {"ipxcp-accept-remote", 0, setipxarmt}, /* Accept peer's address */
+ {"ipx-routing", 1, setipxrouter}, /* IPX routing proto number */
+ {"ipx-router-name", 1, setipxname}, /* IPX router name */
+ {"ipxcp-restart", 1, setipxcptimeout}, /* Set timeout for IPXCP */
+ {"ipxcp-max-terminate", 1, setipxcpterm}, /* max #xmits for term-reqs */
+ {"ipxcp-max-configure", 1, setipxcpconf}, /* max #xmits for conf-reqs */
+ {"ipxcp-max-failure", 1, setipxcpfails}, /* max #conf-naks for IPXCP */
+#if 0
+ {"ipx-compression", 1, setipxcompression}, /* IPX compression number */
+#endif
+ {"+ipx", 0, setipxproto}, /* Enable IPXCP (and IPX) */
+ {"-ipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
+#endif /* IPX_CHANGE */
+
#ifdef _linux_
{"idle-disconnect", 1, setidle}, /* seconds for disconnect of idle IP */
#endif
+
+#ifdef USE_MS_DNS
+ {"ms-dns", 1, setdnsaddr}, /* DNS address(es) for the peer's use */
+#endif
+
{NULL, 0, NULL}
};
@@ -293,7 +373,7 @@ parse_args(argc, argv)
int argc;
char **argv;
{
- char *arg, *val;
+ char *arg;
struct cmd *cmdp;
int ret;
@@ -451,21 +531,22 @@ options_from_user()
int
options_for_tty()
{
- char *dev, *path;
+ char *dev, *path, *p;
int ret;
- dev = strrchr(devnam, '/');
- if (dev == NULL)
- dev = devnam;
- else
- ++dev;
+ dev = devnam;
+ if (strncmp(dev, "/dev/", 5) == 0)
+ dev += 5;
if (strcmp(dev, "tty") == 0)
return 1; /* don't look for /etc/ppp/options.tty */
path = malloc(strlen(_PATH_TTYOPT) + strlen(dev) + 1);
if (path == NULL)
novm("tty init file name");
strcpy(path, _PATH_TTYOPT);
- strcat(path, dev);
+ /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */
+ for (p = path + strlen(path); *dev != 0; ++dev)
+ *p++ = (*dev == '/'? '.': *dev);
+ *p = 0;
ret = options_from_file(path, 0, 0);
free(path);
return ret;
@@ -505,7 +586,6 @@ readable(fd)
* Quotes, white-space and \ may be escaped with \.
* \<newline> is ignored.
*/
-
int
getword(f, word, newlinep, filename)
FILE *f;
@@ -829,6 +909,12 @@ noopt()
BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
+
+#ifdef IPX_CHANGE
+ BZERO((char *) &ipxcp_wantoptions[0], sizeof (struct ipxcp_options));
+ BZERO((char *) &ipxcp_allowoptions[0], sizeof (struct ipxcp_options));
+#endif /* IPX_CHANGE */
+
return (1);
}
@@ -857,13 +943,12 @@ noasyncmap()
/*
- * noipaddr - Disable IP address negotiation.
+ * noip - Disable IP and IPCP.
*/
static int
-noipaddr()
+noip()
{
- ipcp_wantoptions[0].neg_addr = 0;
- ipcp_allowoptions[0].neg_addr = 0;
+ ipcp_protent.enabled_flag = 0;
return (1);
}
@@ -1109,7 +1194,7 @@ setconnector(argv)
{
connector = strdup(*argv);
if (connector == NULL)
- novm("connector string");
+ novm("connect script");
return (1);
}
@@ -1123,11 +1208,43 @@ setdisconnector(argv)
{
disconnector = strdup(*argv);
if (disconnector == NULL)
- novm("disconnector string");
+ novm("disconnect script");
return (1);
}
+/*
+ * setwelcomer - Set a program to welcome a client after connection
+ */
+static int
+setwelcomer(argv)
+ char **argv;
+{
+ welcomer = strdup(*argv);
+ if (welcomer == NULL)
+ novm("welcome script");
+
+ return (1);
+}
+
+/*
+ * setmaxconnect - Set the maximum connect time
+ */
+static int
+setmaxconnect(argv)
+ char **argv;
+{
+ int value;
+
+ if (!int_option(*argv, &value))
+ return 0;
+ if (value < 0) {
+ fprintf(stderr, "pppd: maxconnect time must be positive\n");
+ return 0;
+ }
+ maxconnect = value;
+ return 1;
+}
/*
* setdomain - Set domain name to append to hostname
@@ -1216,12 +1333,11 @@ setspeed(arg)
/*
* setdevname - Set the device name.
*/
-int
+static int
setdevname(cp)
char *cp;
{
struct stat statbuf;
- char *tty, *ttyname();
char dev[MAXPATHLEN];
if (strncmp("/dev/", cp, 5) != 0) {
@@ -1252,7 +1368,7 @@ setdevname(cp)
/*
* setipaddr - Set the IP address
*/
-int
+static int
setipaddr(arg)
char *arg;
{
@@ -1355,36 +1471,6 @@ setipcpaccr()
/*
- * setipdefault - default our local IP address based on our hostname.
- */
-void
-setipdefault()
-{
- struct hostent *hp;
- u_int32_t local;
- ipcp_options *wo = &ipcp_wantoptions[0];
-
- /*
- * If local IP address already given, don't bother.
- */
- if (wo->ouraddr != 0 || disable_defaultip)
- return;
-
- /*
- * Look up our hostname (possibly with domain name appended)
- * and take the first IP address as our local IP address.
- * If there isn't an IP address for our hostname, too bad.
- */
- wo->accept_local = 1; /* don't insist on this default value */
- if ((hp = gethostbyname(hostname)) == NULL)
- return;
- local = *(u_int32_t *)hp->h_addr;
- if (local != 0 && !bad_ip_adrs(local))
- wo->ouraddr = local;
-}
-
-
-/*
* setnetmask - set the netmask to be used on the interface.
*/
static int
@@ -1422,7 +1508,7 @@ setxonxoff()
lcp_wantoptions[0].asyncmap |= 0x000A0000; /* escape ^S and ^Q */
lcp_wantoptions[0].neg_asyncmap = 1;
- crtscts = 2;
+ crtscts = -2;
return (1);
}
@@ -1434,6 +1520,13 @@ setnodetach()
}
static int
+setdemand()
+{
+ demand = 1;
+ return 1;
+}
+
+static int
setmodem()
{
modem = 1;
@@ -1714,6 +1807,68 @@ setnobsdcomp()
}
static int
+setdeflate(argv)
+ char **argv;
+{
+ int rbits, abits;
+ char *str, *endp;
+
+ str = *argv;
+ abits = rbits = strtol(str, &endp, 0);
+ if (endp != str && *endp == ',') {
+ str = endp + 1;
+ abits = strtol(str, &endp, 0);
+ }
+ if (*endp != 0 || endp == str) {
+ fprintf(stderr, "%s: invalid argument format for deflate option\n",
+ progname);
+ return 0;
+ }
+ if (rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE)
+ || abits != 0 && (abits < DEFLATE_MIN_SIZE
+ || abits > DEFLATE_MAX_SIZE)) {
+ fprintf(stderr, "%s: deflate option values must be 0 or %d .. %d\n",
+ progname, DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE);
+ return 0;
+ }
+ if (rbits > 0) {
+ ccp_wantoptions[0].deflate = 1;
+ ccp_wantoptions[0].deflate_size = rbits;
+ } else
+ ccp_wantoptions[0].deflate = 0;
+ if (abits > 0) {
+ ccp_allowoptions[0].deflate = 1;
+ ccp_allowoptions[0].deflate_size = abits;
+ } else
+ ccp_allowoptions[0].deflate = 0;
+ return 1;
+}
+
+static int
+setnodeflate()
+{
+ ccp_wantoptions[0].deflate = 0;
+ ccp_allowoptions[0].deflate = 0;
+ return 1;
+}
+
+static int
+setpred1comp()
+{
+ ccp_wantoptions[0].predictor_1 = 1;
+ ccp_allowoptions[0].predictor_1 = 1;
+ return 1;
+}
+
+static int
+setnopred1comp()
+{
+ ccp_wantoptions[0].predictor_1 = 0;
+ ccp_allowoptions[0].predictor_1 = 0;
+ return 1;
+}
+
+static int
setipparam(argv)
char **argv;
{
@@ -1731,10 +1886,237 @@ setpapcrypt()
return 1;
}
-#ifdef _linux_
-static int setidle (argv)
+static int
+setidle(argv)
char **argv;
{
return int_option(*argv, &idle_time_limit);
}
-#endif
+
+static int
+setholdoff(argv)
+ char **argv;
+{
+ return int_option(*argv, &holdoff);
+}
+
+static int
+setpassfilter(argv)
+ char **argv;
+{
+ if (bpf_compile(&pass_filter, *argv, 1) == 0)
+ return 1;
+ fprintf(stderr, "%s: error in pass-filter expression: %s\n",
+ progname, bpf_geterr());
+ return 0;
+}
+
+static int
+setactivefilter(argv)
+ char **argv;
+{
+ if (bpf_compile(&active_filter, *argv, 1) == 0)
+ return 1;
+ fprintf(stderr, "%s: error in active-filter expression: %s\n",
+ progname, bpf_geterr());
+ return 0;
+}
+
+#ifdef IPX_CHANGE
+static int
+setipxrouter (argv)
+ char **argv;
+{
+ ipxcp_wantoptions[0].neg_router = 1;
+ ipxcp_allowoptions[0].neg_router = 1;
+ return int_option(*argv, &ipxcp_wantoptions[0].router);
+}
+
+static int
+setipxname (argv)
+ char **argv;
+{
+ char *dest = ipxcp_wantoptions[0].name;
+ char *src = *argv;
+ int count;
+ char ch;
+
+ ipxcp_wantoptions[0].neg_name = 1;
+ ipxcp_allowoptions[0].neg_name = 1;
+ memset (dest, '\0', sizeof (ipxcp_wantoptions[0].name));
+
+ count = 0;
+ while (*src) {
+ ch = *src++;
+ if (! isalnum (ch) && ch != '_') {
+ fprintf (stderr,
+ "%s: IPX router name must be alphanumeric or _\n",
+ progname);
+ return 0;
+ }
+
+ if (count >= sizeof (ipxcp_wantoptions[0].name)) {
+ fprintf (stderr,
+ "%s: IPX router name is limited to %d characters\n",
+ progname,
+ sizeof (ipxcp_wantoptions[0].name) - 1);
+ return 0;
+ }
+
+ dest[count++] = toupper (ch);
+ }
+
+ return 1;
+}
+
+static int
+setipxcptimeout (argv)
+ char **argv;
+{
+ return int_option(*argv, &ipxcp_fsm[0].timeouttime);
+}
+
+static int
+setipxcpterm (argv)
+ char **argv;
+{
+ return int_option(*argv, &ipxcp_fsm[0].maxtermtransmits);
+}
+
+static int
+setipxcpconf (argv)
+ char **argv;
+{
+ return int_option(*argv, &ipxcp_fsm[0].maxconfreqtransmits);
+}
+
+static int
+setipxcpfails (argv)
+ char **argv;
+{
+ return int_option(*argv, &ipxcp_fsm[0].maxnakloops);
+}
+
+static int
+setipxnetwork(argv)
+ char **argv;
+{
+ ipxcp_wantoptions[0].neg_nn = 1;
+ return int_option(*argv, &ipxcp_wantoptions[0].our_network);
+}
+
+static int
+setipxanet()
+{
+ ipxcp_wantoptions[0].accept_network = 1;
+ ipxcp_allowoptions[0].accept_network = 1;
+}
+
+static int
+setipxalcl()
+{
+ ipxcp_wantoptions[0].accept_local = 1;
+ ipxcp_allowoptions[0].accept_local = 1;
+}
+
+static int
+setipxarmt()
+{
+ ipxcp_wantoptions[0].accept_remote = 1;
+ ipxcp_allowoptions[0].accept_remote = 1;
+}
+
+static u_char *
+setipxnodevalue(src,dst)
+u_char *src, *dst;
+{
+ int indx;
+ int item;
+
+ for (;;) {
+ if (!isxdigit (*src))
+ break;
+
+ for (indx = 0; indx < 5; ++indx) {
+ dst[indx] <<= 4;
+ dst[indx] |= (dst[indx + 1] >> 4) & 0x0F;
+ }
+
+ item = toupper (*src) - '0';
+ if (item > 9)
+ item -= 7;
+
+ dst[5] = (dst[5] << 4) | item;
+ ++src;
+ }
+ return src;
+}
+
+static int
+setipxnode(argv)
+ char **argv;
+{
+ char *end;
+
+ memset (&ipxcp_wantoptions[0].our_node[0], 0, 6);
+ memset (&ipxcp_wantoptions[0].his_node[0], 0, 6);
+
+ end = setipxnodevalue (*argv, &ipxcp_wantoptions[0].our_node[0]);
+ if (*end == ':')
+ end = setipxnodevalue (++end, &ipxcp_wantoptions[0].his_node[0]);
+
+ if (*end == '\0') {
+ ipxcp_wantoptions[0].neg_node = 1;
+ return 1;
+ }
+
+ fprintf(stderr, "%s: invalid argument for ipx-node option\n",
+ progname);
+ return 0;
+}
+
+static int
+setipxproto()
+{
+ ipx_enabled = 1; /* Enable IPXCP and IPX protocol */
+ return 1;
+}
+
+static int
+resetipxproto()
+{
+ ipx_enabled = 0; /* Disable IPXCP and IPX protocol */
+ return 1;
+}
+#endif /* IPX_CHANGE */
+
+#ifdef USE_MS_DNS
+/*
+ * setdnsaddr - set the dns address(es)
+ */
+
+static int
+setdnsaddr(argv)
+ char **argv;
+{
+ u_int32_t dns;
+ struct hostent *hp;
+
+ dns = inet_addr(*argv);
+ if (dns == -1) {
+ if ((hp = gethostbyname(*argv)) == NULL) {
+ fprintf(stderr, "Invalid DNS Address %s\n", *argv);
+ return 0;
+ }
+ dns = *(u_int32_t *)hp->h_addr;
+ }
+
+ if (ipcp_allowoptions[0].dnsaddr[0] == 0) {
+ ipcp_allowoptions[0].dnsaddr[0] = dns;
+ } else {
+ ipcp_allowoptions[0].dnsaddr[1] = dns;
+ }
+
+ return (1);
+}
+#endif /* USE_MS_DNS */
diff --git a/usr.sbin/pppd/patchlevel.h b/usr.sbin/pppd/patchlevel.h
index 8c33cd91a78..4855a1f2bd4 100644
--- a/usr.sbin/pppd/patchlevel.h
+++ b/usr.sbin/pppd/patchlevel.h
@@ -1,6 +1,7 @@
-/* $Id: patchlevel.h,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp $ */
+/* $OpenBSD: patchlevel.h,v 1.2 1996/03/25 15:55:52 niklas Exp $ */
+
#define PATCHLEVEL 0
-#define VERSION "2.2"
-#define IMPLEMENTATION ""
-#define DATE "17 August 95"
+#define VERSION "2.3"
+#define IMPLEMENTATION "alpha2"
+#define DATE "6 March 96"
diff --git a/usr.sbin/pppd/pathnames.h b/usr.sbin/pppd/pathnames.h
index fb0a2ede371..152ff75b110 100644
--- a/usr.sbin/pppd/pathnames.h
+++ b/usr.sbin/pppd/pathnames.h
@@ -1,7 +1,7 @@
+/* $OpenBSD: pathnames.h,v 1.2 1996/03/25 15:55:53 niklas Exp $ */
+
/*
* define path names
- *
- * $Id: pathnames.h,v 1.1.1.1 1995/10/18 08:47:59 deraadt Exp $
*/
#ifdef HAVE_PATHS_H
@@ -20,3 +20,8 @@
#define _PATH_TTYOPT "/etc/ppp/options."
#define _PATH_CONNERRS "/etc/ppp/connect-errors"
#define _PATH_USEROPT ".ppprc"
+
+#ifdef IPX_CHANGE
+#define _PATH_IPXUP "/etc/ppp/ipx-up"
+#define _PATH_IPXDOWN "/etc/ppp/ipx-down"
+#endif /* IPX_CHANGE */
diff --git a/usr.sbin/pppd/pppd.8 b/usr.sbin/pppd/pppd.8
index 284a72abc8b..db7abfd61ee 100644
--- a/usr.sbin/pppd/pppd.8
+++ b/usr.sbin/pppd/pppd.8
@@ -1,5 +1,5 @@
+.\" $OpenBSD: pppd.8,v 1.3 1996/03/25 15:55:54 niklas Exp $
.\" manual page [] for pppd 2.0
-.\" $Id: pppd.8,v 1.2 1996/02/22 00:12:46 niklas Exp $
.\" SH section heading
.\" SS subsection heading
.\" LP paragraph
@@ -167,6 +167,20 @@ options are given, respectively.
Disable Address/Control compression negotiation (use default, i.e.
address/control field compression disabled).
.TP
+.B active-filter \fIfilter-expression
+Specifies a packet filter to be applied to data packets to determine
+which packets are to be regarded as link activity, and therefore reset
+the idle timer, or cause the link to be brought up in demand-dialling
+mode. This option is useful in conjunction with the
+\fBidle\fR option if there are packets being sent or received
+regularly over the link (for example, routing information packets)
+which would otherwise prevent the link from ever appearing to be idle.
+The \fIfilter-expression\fR syntax is as described for tcpdump(1),
+except that qualifiers which are inappropriate for a PPP link, such as
+\fBether\fR and \fBarp\fR, are not permitted. Generally the filter
+expression should be enclosed in single-quotes to prevent whitespace
+in the expression from being interpreted by the shell.
+.TP
.B -all
Don't request or allow negotiation of any options for LCP and IPCP (use
default values).
@@ -191,8 +205,8 @@ Alternatively, a value of 0 for \fInr\fR or \fInt\fR disables
compression in the corresponding direction.
.TP
.B \-bsdcomp
-Disables compression; \fBpppd\fR will not request or agree to compress
-packets using the BSD-Compress scheme.
+Disables BSD-Compress compression; \fBpppd\fR will not request or
+agree to compress packets using the BSD-Compress scheme.
.TP
.B +chap
Require the peer to authenticate itself using CHAP [Cryptographic
@@ -225,34 +239,86 @@ Increase debugging level (same as the \fBdebug\fR option).
.TP
.B debug
Increase debugging level (same as \fB\-d\fR).
-If this
-option is given, \fIpppd\fR will log the contents of all control
-packets sent or received in a readable form. The packets are logged
-through syslog with facility \fIdaemon\fR and level \fIdebug\fR. This
-information can be directed to a file by setting up /etc/syslog.conf
-appropriately (see syslog.conf(5)).
+If this option is given, \fIpppd\fR will log the contents of all
+control packets sent or received in a readable form. The packets are
+logged through syslog with facility \fIdaemon\fR and level
+\fIdebug\fR. This information can be directed to a file by setting up
+/etc/syslog.conf appropriately (see syslog.conf(5)).
.TP
.B \-defaultroute
Disable the \fBdefaultroute\fR option. The system administrator who
wishes to prevent users from creating default routes with \fIpppd\fR
can do so by placing this option in the /etc/ppp/options file.
.TP
+.B deflate \fInr,nt
+Request that the peer compress packets that it sends, using the
+Deflate scheme, with a maximum window size of \fI2**nr\fR bits, and
+agree to compress packets sent to the peer with a maximum window size of
+\fI2**nt\fR bits. If \fInt\fR is not specified, it defaults to the value
+given for \fInr\fR. Values in the range 8 to 15 may be used for
+\fInr\fR and \fInt\fR; larger values give better compression but
+consume more kernel memory for compression dictionaries.
+Alternatively, a value of 0 for \fInr\fR or \fInt\fR disables
+compression in the corresponding direction. (Note: \fBpppd\fR
+requests Deflate compression in preference to BSD-Compress
+if the peer can do either.)
+.TP
+.B \-deflate
+Disables Deflate compression; \fBpppd\fR will not request or agree to
+compress packets using the Deflate scheme.
+.TP
+.B demand
+Initiate the link only on demand, i.e. when data traffic is present.
+With this option, the remote IP address must be specific by the user
+on the command line or in an options file. \fBpppd\fR will initially
+configure the interface and enable it for IP traffic without
+connecting to the peer. When traffic is available, \fBpppd\fR will
+connect to the peer and perform negotiation, authentication, etc.
+When this is completed, \fBpppd\fR will commence passing data packets
+(i.e., IP packets) across the link. The persist, idle and holdoff
+options are often useful in conjuction with this option.
+.TP
.B -detach
Don't fork to become a background process (otherwise
.I pppd
will do so if a serial device other than its controlling terminal is
specified).
.TP
+.B ms-dns \fI<addr>
+If
+.I pppd
+is acting as a server for Microsoft Windows clients, this option
+allows
+.I pppd
+to supply one or two DNS (Domain Name Server) addresses to the
+clients. The first instance of this option specifies the primary DNS
+address; the second instance (if given) specifies the secondary DNS
+address.
+.TP
.B domain \fI<d>
Append the domain name <d> to the local host name for authentication
purposes. For example, if gethostname() returns the name porsche, but the
fully qualified domain name is porsche.Quotron.COM, you would use the
domain option to set the domain name to Quotron.COM.
.TP
+.B holdoff \fI<n>
+Specifies how many seconds to wait before re-initiating the link after
+it terminates. This option only has effect if the persist option is
+used.
+.TP
+.B idle \fI<n>
+Specifies that \fBpppd\fR should disconnect if it is idle for
+\fI<n>\fR seconds. The link is idle when no data packets (i.e. IP
+packets) are being sent or received. If the \fBactive-filter\fR
+option is given, data packets which are rejected by the specified
+activity filter also count as the link being idle.
+.TP
.B -ip
-Disable IP address negotiation. If this option is used, the remote IP
-address must be specified with an option on the command line or in an
-options file.
+Disable IPCP negotiation and IP communication. This option should
+only be required if the peer is buggy and gets confused by requests
+from
+.I pppd
+for IPCP negotiation.
.TP
.B ipcp-accept-local
With this option,
@@ -401,6 +467,20 @@ Set the maximum time that
will wait for the peer to authenticate itself with PAP to
<n> seconds (0 means no limit).
.TP
+.B pass-filter \fIfilter-expression
+Specifies a packet filter to applied to data packets being sent or
+received to determine which packets should be allowed to pass.
+Packets which are rejected by the filter are silently discarded. This
+option can be used to provide protection against IP address spoofing
+and other attacks.
+The \fIfilter-expression\fR syntax is as described for tcpdump(1),
+except that qualifiers which are inappropriate for a PPP link, such as
+\fBether\fR and \fBarp\fR, are not permitted. Generally the filter
+expression should be enclosed in single-quotes to prevent whitespace
+in the expression from being interpreted by the shell. Note that it
+is possible to apply different constraints to incoming and outgoing
+packets using the \fBinbound\fR and \fBoutbound\fR qualifiers.
+.TP
.B -pc
Disable protocol field compression negotiation (use default, i.e.
protocol field compression disabled).
@@ -733,38 +813,41 @@ User default options, read before command-line options.
.TP
.B /etc/ppp/options.\fIttyname
System default options for the serial port being used, read after
-command-line options.
+command-line options. In forming the \fIttyname\fR part of this
+filename, an initial /dev/ is stripped from the port name (if
+present), and any slashes in the remaining part are converted to
+dots.
.SH SEE ALSO
.TP
.B RFC1144
Jacobson, V.
.I Compressing TCP/IP headers for low-speed serial links.
-1990 February.
+February 1990.
.TP
.B RFC1321
Rivest, R.
.I The MD5 Message-Digest Algorithm.
-1992 April.
+April 1992.
.TP
.B RFC1332
McGregor, G.
.I PPP Internet Protocol Control Protocol (IPCP).
-1992 May.
+May 1992.
.TP
.B RFC1334
Lloyd, B.; Simpson, W.A.
.I PPP authentication protocols.
-1992 October.
+October 1992.
.TP
-.B RFC1548
+.B RFC1661
Simpson, W.A.
.I The Point\-to\-Point Protocol (PPP).
-1993 December.
+July 1994.
.TP
-.B RFC1549
+.B RFC1662
Simpson, W.A.
-.I PPP in HDLC Framing.
-1993 December
+.I PPP in HDLC-like Framing.
+July 1994.
.SH NOTES
The following signals have the specified effect when sent to the
.I pppd
@@ -791,9 +874,10 @@ decompression errors generally indicate a bug in one or other
implementation.
.SH AUTHORS
+Paul Mackerras (paulus@cs.anu.edu.au), based on earlier work by
Drew Perkins,
Brad Clements,
Karl Fox,
Greg Christy,
-Brad Parker,
-Paul Mackerras (paulus@cs.anu.edu.au).
+and
+Brad Parker.
diff --git a/usr.sbin/pppd/pppd.h b/usr.sbin/pppd/pppd.h
index 403262fa085..33061b389ba 100644
--- a/usr.sbin/pppd/pppd.h
+++ b/usr.sbin/pppd/pppd.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: pppd.h,v 1.2 1996/03/25 15:55:55 niklas Exp $ */
+
/*
* pppd.h - PPP daemon global declarations.
*
@@ -15,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Id: pppd.h,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp $
*/
/*
@@ -26,9 +26,12 @@
#ifndef __PPPD_H__
#define __PPPD_H__
+#include <stdio.h> /* for FILE */
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
#include <sys/types.h> /* for u_int32_t, if defined */
+#include <sys/time.h> /* for struct timeval */
#include <net/ppp_defs.h>
+#include <net/bpf.h>
#define NUM_PPP 1 /* One PPP interface supported (per process) */
@@ -48,7 +51,7 @@
extern int hungup; /* Physical layer has disconnected */
extern int ifunit; /* Interface unit number */
extern char ifname[]; /* Interface name */
-extern int fd; /* Serial device file descriptor */
+extern int ttyfd; /* Serial device file descriptor */
extern char hostname[]; /* Our hostname */
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
extern int phase; /* Current state of link - see values below */
@@ -71,6 +74,8 @@ extern int lockflag; /* Create lock file to lock the serial dev */
extern int nodetach; /* Don't detach from controlling tty */
extern char *connector; /* Script to establish physical link */
extern char *disconnector; /* Script to disestablish physical link */
+extern char *welcomer; /* Script to welcome client after connection */
+extern int maxconnect; /* maximum number of seconds for a connection */
extern char user[]; /* Username for PAP */
extern char passwd[]; /* Password for PAP */
extern int auth_required; /* Peer is required to authenticate */
@@ -83,36 +88,183 @@ extern char our_name[]; /* Our name for authentication purposes */
extern char remote_name[]; /* Peer's name for authentication */
extern int usehostname; /* Use hostname for our_name */
extern int disable_defaultip; /* Don't use hostname for default IP adrs */
+extern int demand; /* Do dial-on-demand */
extern char *ipparam; /* Extra parameter for ip up/down scripts */
extern int cryptpap; /* Others' PAP passwords are encrypted */
+extern int idle_time_limit;/* Shut down link if idle for this long */
+extern int holdoff; /* Dead time before restarting */
+extern struct bpf_program pass_filter; /* Filter for pkts to pass */
+extern struct bpf_program active_filter; /* Filter for link-active pkts */
/*
* Values for phase.
*/
#define PHASE_DEAD 0
-#define PHASE_ESTABLISH 1
-#define PHASE_AUTHENTICATE 2
-#define PHASE_NETWORK 3
-#define PHASE_TERMINATE 4
+#define PHASE_DORMANT 1
+#define PHASE_ESTABLISH 2
+#define PHASE_AUTHENTICATE 3
+#define PHASE_NETWORK 4
+#define PHASE_TERMINATE 5
+#define PHASE_HOLDOFF 6
+
+/*
+ * The following struct gives the addresses of procedures to call
+ * for a particular protocol.
+ */
+struct protent {
+ u_short protocol; /* PPP protocol number */
+ void (*init)(); /* Initialization procedure */
+ void (*input)(); /* Process a received packet */
+ void (*protrej)(); /* Process a received protocol-reject */
+ void (*lowerup)(); /* Lower layer has come up */
+ void (*lowerdown)(); /* Lower layer has gone down */
+ void (*open)(); /* Open the protocol */
+ void (*close)(); /* Close the protocol */
+ int (*printpkt)(); /* Print a packet in readable form */
+ void (*datainput)(); /* Process a received data packet */
+ int enabled_flag; /* 0 iff protocol is disabled */
+ char *name; /* Text name of protocol */
+ void (*check_options)(); /* Check requested options, assign dflts */
+ int (*demand_conf)(); /* Configure interface for demand-dial */
+};
+
+/* Table of pointers to supported protocols */
+extern struct protent *protocols[];
/*
* Prototypes.
*/
-void quit __P((void)); /* Cleanup and exit */
-void timeout __P((void (*)(), caddr_t, int));
- /* Look-alike of kernel's timeout() */
-void untimeout __P((void (*)(), caddr_t));
- /* Look-alike of kernel's untimeout() */
-void output __P((int, u_char *, int));
- /* Output a PPP packet */
+
+/* Procedures exported from main.c. */
+void die __P((int)); /* Cleanup and exit */
+void quit __P((void)); /* like die(1) */
+void novm __P((char *)); /* Say we ran out of memory, and die */
+void timeout __P((void (*func)(), caddr_t arg, int t));
+ /* Call func(arg) after t seconds */
+void untimeout __P((void (*func)(), caddr_t arg));
+ /* Cancel call to func(arg) */
+int run_program __P((char *prog, char **args, int must_exist));
+ /* Run program prog with args in child */
void demuxprotrej __P((int, int));
/* Demultiplex a Protocol-Reject */
+void format_packet __P((u_char *, int, void (*) (void *, char *, ...),
+ void *)); /* Format a packet in human-readable form */
+void log_packet __P((u_char *, int, char *));
+ /* Format a packet and log it with syslog */
+void print_string __P((char *, int, void (*) (void *, char *, ...),
+ void *)); /* Format a string for output */
+
+/* Procedures exported from auth.c */
+void link_required __P((int)); /* we are starting to use the link */
+void link_terminated __P((int)); /* we are finished with the link */
+void link_down __P((int)); /* the LCP layer has left the Opened state */
+void link_established __P((int)); /* the link is up; authenticate now */
+void np_up __P((int, int)); /* a network protocol has come up */
+void np_down __P((int, int)); /* a network protocol has gone down */
+void np_finished __P((int, int)); /* a network protocol no longer needs link */
+void auth_peer_fail __P((int, int));
+ /* peer failed to authenticate itself */
+void auth_peer_success __P((int, int));
+ /* peer successfully authenticated itself */
+void auth_withpeer_fail __P((int, int));
+ /* we failed to authenticate ourselves */
+void auth_withpeer_success __P((int, int));
+ /* we successfully authenticated ourselves */
+void auth_check_options __P((void));
+ /* check authentication options supplied */
int check_passwd __P((int, char *, int, char *, int, char **, int *));
/* Check peer-supplied username/password */
int get_secret __P((int, char *, char *, char *, int *, int));
/* get "secret" for chap */
-u_int32_t GetMask __P((u_int32_t)); /* get netmask for address */
-void die __P((int));
+int auth_ip_addr __P((int, u_int32_t));
+ /* check if IP address is authorized */
+int bad_ip_adrs __P((u_int32_t));
+ /* check if IP address is unreasonable */
+void check_access __P((FILE *, char *));
+ /* check permissions on secrets file */
+
+/* Procedures exported from demand.c */
+void demand_conf __P((void)); /* config interface(s) for demand-dial */
+void demand_block __P((void)); /* set all NPs to queue up packets */
+void demand_unblock __P((void)); /* set all NPs to pass packets */
+void demand_discard __P((void)); /* set all NPs to discard packets */
+void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
+int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
+int loop_frame __P((unsigned char *, int)); /* process frame from loopback */
+
+/* Procedures exported from sys-*.c */
+void sys_init __P((void)); /* Do system-dependent initialization */
+void sys_cleanup __P((void)); /* Restore system state before exiting */
+void sys_check_options __P((void)); /* Check options specified */
+void sys_close __P((void)); /* Clean up in a child before execing */
+void note_debug_level __P((void)); /* Note change in debug level */
+int ppp_available __P((void)); /* Test whether ppp kernel support exists */
+void open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
+void establish_ppp __P((int)); /* Turn serial port into a ppp interface */
+void restore_loop __P((void)); /* Transfer ppp unit back to loopback */
+void disestablish_ppp __P((int)); /* Restore port to normal operation */
+void clean_check __P((void)); /* Check if line was 8-bit clean */
+void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
+void restore_tty __P((int)); /* Restore port's original parameters */
+void setdtr __P((int, int)); /* Raise or lower port's DTR line */
+void output __P((int, u_char *, int)); /* Output a PPP packet */
+void wait_input __P((struct timeval *));
+ /* Wait for input, with timeout */
+void wait_loop_output __P((struct timeval *));
+ /* Wait for pkt from loopback, with timeout */
+void wait_time __P((struct timeval *)); /* Wait for given length of time */
+int read_packet __P((u_char *)); /* Read PPP packet */
+int get_loop_output __P((void)); /* Read pkts from loopback */
+void ppp_send_config __P((int, int, u_int32_t, int, int));
+ /* Configure i/f transmit parameters */
+void ppp_set_xaccm __P((int, ext_accm));
+ /* Set extended transmit ACCM */
+void ppp_recv_config __P((int, int, u_int32_t, int, int));
+ /* Configure i/f receive parameters */
+int ccp_test __P((int, u_char *, int, int));
+ /* Test support for compression scheme */
+void ccp_flags_set __P((int, int, int));
+ /* Set kernel CCP state */
+int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
+int get_idle_time __P((int, struct ppp_idle *));
+ /* Find out how long link has been idle */
+int sifvjcomp __P((int, int, int, int));
+ /* Configure VJ TCP header compression */
+int sifup __P((int)); /* Configure i/f up (for IP) */
+int sifnpmode __P((int u, int proto, enum NPmode mode));
+ /* Set mode for handling packets for proto */
+int sifdown __P((int)); /* Configure i/f down (for IP) */
+int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
+ /* Configure IP addresses for i/f */
+int cifaddr __P((int, u_int32_t, u_int32_t));
+ /* Reset i/f IP addresses */
+int sifdefaultroute __P((int, u_int32_t));
+ /* Create default route through i/f */
+int cifdefaultroute __P((int, u_int32_t));
+ /* Delete default route through i/f */
+int sifproxyarp __P((int, u_int32_t));
+ /* Add proxy ARP entry for peer */
+int cifproxyarp __P((int, u_int32_t));
+ /* Delete proxy ARP entry for peer */
+u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
+int lock __P((char *)); /* Create lock file for device */
+void unlock __P((void)); /* Delete previously-created lock file */
+int daemon __P((int, int)); /* Detach us from terminal session */
+int logwtmp __P((char *, char *, char *));
+ /* Write entry to wtmp file */
+int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
+ /* Set filter programs in kernel */
+
+/* Procedures exported from options.c */
+int parse_args __P((int argc, char **argv));
+ /* Parse options from arguments given */
+void usage __P((void)); /* Print a usage message */
+int options_from_file __P((char *filename, int must_exist, int check_prot));
+ /* Parse options from an options file */
+int options_from_user __P((void)); /* Parse options from user's .ppprc */
+int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
+int getword __P((FILE *f, char *word, int *newlinep, char *filename));
+ /* Read a word from a file */
/*
* Inline versions of get/put char/short/long.
@@ -192,9 +344,9 @@ void die __P((int));
#endif
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
-#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUG) \
+#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
- || defined(DEBUGCHAP)
+ || defined(DEBUGCHAP) || defined(DEBUG)
#define LOG_PPP LOG_LOCAL2
#else
#define LOG_PPP LOG_DAEMON
@@ -207,6 +359,12 @@ void die __P((int));
#define MAINDEBUG(x)
#endif
+#ifdef DEBUGSYS
+#define SYSDEBUG(x) if (debug) syslog x
+#else
+#define SYSDEBUG(x)
+#endif
+
#ifdef DEBUGFSM
#define FSMDEBUG(x) if (debug) syslog x
#else
diff --git a/usr.sbin/pppd/pppstats/Makefile b/usr.sbin/pppd/pppstats/Makefile
index 2593ca6b521..67909877094 100644
--- a/usr.sbin/pppd/pppstats/Makefile
+++ b/usr.sbin/pppd/pppstats/Makefile
@@ -1,9 +1,8 @@
-# $Id: Makefile,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp $
+# $OpenBSD: Makefile,v 1.2 1996/03/25 15:56:03 niklas Exp $
PROG= pppstats
SRCS= pppstats.c
MAN= pppstats.8
-MLINKS= pppstats.8 slstats.8
BINDIR= /usr/sbin
.include <bsd.prog.mk>
diff --git a/usr.sbin/pppd/pppstats/pppstats.8 b/usr.sbin/pppd/pppstats/pppstats.8
index d599994c8c3..b8a2ee9f232 100644
--- a/usr.sbin/pppd/pppstats/pppstats.8
+++ b/usr.sbin/pppd/pppstats/pppstats.8
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /home/cvs/src/usr.sbin/pppd/pppstats/pppstats.8,v 1.1.1.1 1995/10/18 08:48:01 deraadt Exp $ (LBL)
+.\" $OpenBSD: pppstats.8,v 1.2 1996/03/25 15:56:04 niklas Exp $
.Dd November 15, 1994
.Dt PPPSTATS 8
.Sh NAME
@@ -9,6 +9,7 @@
.Op Fl v
.Op Fl r
.Op Fl z
+.Op Fl a
.Op Fl c Ar count
.Op Fl w Ar wait
.Op Ar interface
@@ -27,17 +28,27 @@ into input and output sections containing columns of statistics
describing the properties and volume of packets received and
transmitted by the interface.
.Pp
-The first report will consist of a snapshot of the interface's
-statistics. Further output, if any, will describe activity between
-report intervals.
-.Pp
The options are as follows:
.Bl -tag -width Ds
+.It Fl a
+Display absolute values rather than deltas. If this option is
+specified with the
+.Fl c
+and/or
+.Fl w
+options, the second and subsequent reports (as well as the first) will
+show statistics for the time since the link was initiated.
.It Fl c Ar count
Repeat the display
.Ar count
-times. The first display is for the time since a reboot and each
-subsequent report is for the time period since the last display.
+times. The first display is for the time since the link was initiated
+(that is, since the corresponding
+.Xr pppd 8
+was started), and each
+subsequent report is for the time period since the last display
+(unless the
+.Fl a
+option is specified).
If this option is not specified, the default repeat
.Ar count
is 1 if the
@@ -73,8 +84,14 @@ The total number of packets received by this interface.
The number of compressed TCP packets received by this interface.
.It Li VJUNC
The number of uncompressed TCP packets received by this interface.
+Not reported when the
+.Fl r
+option is specified.
.It Li VJERR
-The number of corrupted or bogus packets received by this interface.
+The number of corrupted or bogus TCP packets received by this interface.
+Not reported when the
+.Fl r
+option is specified.
.It Li VJTOSS
The number of VJ header-compressed TCP packets dropped on reception by
this interface. Only reported when the
@@ -86,11 +103,10 @@ reported when the
.Fl v
option is specified.
.It Li RATIO
-The overall compression ratio achieved for received packets by the
-packet compression scheme in use, as a number between 0.0 and 1.0,
-representing the average proportionate reduction in the size of the
-packets achieved by the use of packet compression (thus 0.0 indicates
-that the data is incompressible). Only reported when the
+The compression ratio achieved for received packets by the
+packet compression scheme in use, defined as the uncompressed size
+divided by the compressed size.
+Only reported when the
.Fl r
option is specified.
.It Li UBYTE
@@ -112,8 +128,14 @@ VJ-compressed TCP headers.
.It Li VJUNC
The number of TCP packets transmitted from this interface with
VJ-uncompressed TCP headers.
+Not reported when the
+.Fl r
+option is specified.
.It Li NON-VJ
The total number of non-TCP packets transmitted from this interface.
+Not reported when the
+.Fl r
+option is specified.
.It Li VJSRCH
The number of searches for the cached header entry for a VJ header
compressed TCP packet. Only reported when the
@@ -125,15 +147,16 @@ VJ header compressed TCP packet. Only reported when the
.Fl v
option is specified.
.It Li RATIO
-The overall compression ratio achieved for transmitted packets by the
-packet compression scheme in use, as a number between 0.0 and 1.0.
+The compression ratio achieved for transmitted packets by the
+packet compression scheme in use, defined as the size
+before compression divided by the compressed size.
Only reported when the
.Fl r
option is specified.
.It Li UBYTE
The total number of bytes to be transmitted, before packet compression
is applied. Only reported when the
-.Fl v
+.Fl r
option is specified.
.El
.Pp
@@ -156,8 +179,9 @@ were transmitted in uncompressed form) received.
.It Li INCOMPRESSIBLE PACK
The number of incompressible packets received.
.It Li COMP RATIO
-The recent compression ratio for incoming packets, as a number between
-0.0 and 1.0.
+The recent compression ratio for incoming packets, defined as the
+uncompressed size divided by the compressed size (including both
+compressible and incompressible packets).
.El
.Pp
The fields displayed on the output side are:
@@ -172,8 +196,7 @@ those which were transmitted in uncompressed form).
.It Li INCOMPRESSIBLE PACK
The number of incompressible packets transmitted.
.It Li COMP RATIO
-The recent compression ratio for outgoing packets, as a number between
-0.0 and 1.0.
+The recent compression ratio for outgoing packets.
.El
.Sh SEE ALSO
.Xr pppd 8
diff --git a/usr.sbin/pppd/pppstats/pppstats.c b/usr.sbin/pppd/pppstats/pppstats.c
index a2e43db580b..fc6a541bcc8 100644
--- a/usr.sbin/pppd/pppstats/pppstats.c
+++ b/usr.sbin/pppd/pppstats/pppstats.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: pppstats.c,v 1.2 1996/03/25 15:56:05 niklas Exp $ */
+
/*
* print PPP statistics:
* pppstats [-v] [-r] [-z] [-c count] [-w wait] [interface]
@@ -28,7 +30,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: pppstats.c,v 1.1.1.1 1995/10/18 08:48:01 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pppstats.c,v 1.2 1996/03/25 15:56:05 niklas Exp $";
#endif
#include <stdio.h>
@@ -39,6 +41,8 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1.1.1 1995/10/18 08:48:01 deraadt Exp
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
+#include <err.h>
+#include <unistd.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -48,6 +52,7 @@ static char rcsid[] = "$Id: pppstats.c,v 1.1.1.1 1995/10/18 08:48:01 deraadt Exp
#include <net/if_ppp.h>
int vflag, rflag, zflag; /* select type of display */
+int aflag; /* print absolute values, not deltas */
int interval, count;
int infinite;
int unit;
@@ -59,7 +64,7 @@ char interface[IFNAMSIZ];
void
usage()
{
- fprintf(stderr, "Usage: %s [-v|-r|-z] [-c count] [-w wait] [interface]\n",
+ fprintf(stderr, "Usage: %s [-v|-r|-z] [-a] [-c count] [-w wait] [interface]\n",
progname);
exit(1);
}
@@ -93,6 +98,7 @@ get_ppp_stats(curp)
err(1, "couldn't get PPP statistics");
}
+void
get_ppp_cstats(csp)
struct ppp_comp_stats *csp;
{
@@ -116,9 +122,8 @@ get_ppp_cstats(csp)
#define V(offset) (cur.offset - old.offset)
#define W(offset) (ccs.offset - ocs.offset)
-#define CRATE(x) ((x).unc_bytes == 0? 0.0: \
- 1.0 - ((double)((x).comp_bytes + (x).inc_bytes) \
- / (x).unc_bytes))
+#define RATIO(c, i, u) ((c) == 0? 1.0: (u) / ((double)(c) + (i)))
+#define CRATE(x) RATIO(W(x.comp_bytes), W(x.inc_bytes), W(x.unc_bytes))
/*
* Print a running summary of interface statistics.
@@ -130,7 +135,7 @@ void
intpr()
{
register int line = 0;
- sigset_t oldmask, mask;
+ sigset_t oldmask;
struct ppp_stats cur, old;
struct ppp_comp_stats ccs, ocs;
@@ -153,47 +158,53 @@ intpr()
printf(" BYTE PACK BYTE PACK RATIO | ");
printf(" BYTE PACK BYTE PACK RATIO");
} else {
- printf("%8.8s %6.6s %6.6s %6.6s %6.6s",
- "IN", "PACK", "VJCOMP", "VJUNC", "VJERR");
+ printf("%8.8s %6.6s %6.6s",
+ "IN", "PACK", "VJCOMP");
+
+ if (!rflag)
+ printf(" %6.6s %6.6s", "VJUNC", "VJERR");
if (vflag)
printf(" %6.6s %6.6s", "VJTOSS", "NON-VJ");
if (rflag)
printf(" %6.6s %6.6s", "RATIO", "UBYTE");
- printf(" | %8.8s %6.6s %6.6s %6.6s %6.6s",
- "OUT", "PACK", "VJCOMP", "VJUNC", "NON-VJ");
+ printf(" | %8.8s %6.6s %6.6s",
+ "OUT", "PACK", "VJCOMP");
+
+ if (!rflag)
+ printf(" %6.6s %6.6s", "VJUNC", "NON-VJ");
if (vflag)
printf(" %6.6s %6.6s", "VJSRCH", "VJMISS");
- if(rflag)
+ if (rflag)
printf(" %6.6s %6.6s", "RATIO", "UBYTE");
}
putchar('\n');
}
-
+
if (zflag) {
printf("%8u %6u %8u %6u %6.2f",
W(d.comp_bytes),
W(d.comp_packets),
W(d.inc_bytes),
W(d.inc_packets),
- ccs.d.ratio == 0? 0.0:
- 1 - 1.0 / ccs.d.ratio * 256.0);
+ ccs.d.ratio * 256.0);
printf(" | %8u %6u %8u %6u %6.2f",
W(c.comp_bytes),
W(c.comp_packets),
W(c.inc_bytes),
W(c.inc_packets),
- ccs.c.ratio == 0? 0.0:
- 1 - 1.0 / ccs.c.ratio * 256.0);
+ ccs.c.ratio * 256.0);
} else {
- printf("%8u %6u %6u %6u %6u",
+ printf("%8u %6u %6u",
V(p.ppp_ibytes),
V(p.ppp_ipackets),
- V(vj.vjs_compressedin),
- V(vj.vjs_uncompressedin),
- V(vj.vjs_errorin));
+ V(vj.vjs_compressedin));
+ if (!rflag)
+ printf(" %6u %6u",
+ V(vj.vjs_uncompressedin),
+ V(vj.vjs_errorin));
if (vflag)
printf(" %6u %6u",
V(vj.vjs_tossed),
@@ -203,14 +214,16 @@ intpr()
V(vj.vjs_errorin));
if (rflag)
printf(" %6.2f %6u",
- CRATE(ccs.d),
+ CRATE(d),
W(d.unc_bytes));
- printf(" | %8u %6u %6u %6u %6u",
+ printf(" | %8u %6u %6u",
V(p.ppp_obytes),
V(p.ppp_opackets),
- V(vj.vjs_compressed),
- V(vj.vjs_packets) - V(vj.vjs_compressed),
- V(p.ppp_opackets) - V(vj.vjs_packets));
+ V(vj.vjs_compressed));
+ if (!rflag)
+ printf(" %6u %6u",
+ V(vj.vjs_packets) - V(vj.vjs_compressed),
+ V(p.ppp_opackets) - V(vj.vjs_packets));
if (vflag)
printf(" %6u %6u",
V(vj.vjs_searches),
@@ -218,7 +231,7 @@ intpr()
if (rflag)
printf(" %6.2f %6u",
- CRATE(ccs.c),
+ CRATE(c),
W(c.unc_bytes));
}
@@ -237,8 +250,10 @@ intpr()
sigsetmask(oldmask);
signalled = 0;
(void)alarm(interval);
- old = cur;
- ocs = ccs;
+ if (!aflag) {
+ old = cur;
+ ocs = ccs;
+ }
}
}
@@ -256,8 +271,11 @@ main(argc, argv)
else
++progname;
- while ((c = getopt(argc, argv, "vrzc:w:")) != -1) {
+ while ((c = getopt(argc, argv, "avrzc:w:")) != -1) {
switch (c) {
+ case 'a':
+ ++aflag;
+ break;
case 'v':
++vflag;
break;
diff --git a/usr.sbin/pppd/scanner.l b/usr.sbin/pppd/scanner.l
new file mode 100644
index 00000000000..24980b5ef95
--- /dev/null
+++ b/usr.sbin/pppd/scanner.l
@@ -0,0 +1,178 @@
+%{
+/* $OpenBSD: scanner.l,v 1.1 1996/03/25 15:55:56 niklas Exp $ */
+/* $NetBSD: scanner.l,v 1.1 1996/03/15 03:09:15 paulus Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+#if 0
+from: static char rcsid[] =
+ "@(#) Header: scanner.l,v 1.40 94/06/10 17:21:44 mccanne Exp (LBL)";
+#else
+static char rcsid[] = "$OpenBSD: scanner.l,v 1.1 1996/03/25 15:55:56 niklas Exp $";
+#endif
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <ctype.h>
+
+#include <net/ppp_defs.h>
+#include "pcap.h"
+#include "pcap-namedb.h"
+
+#include "gencode.h"
+#include "y.tab.h"
+
+#ifndef __GNUC__
+#define inline
+#endif
+
+static int stoi(char *);
+static inline int xdtoi(int);
+
+#ifndef FLEX_SCANNER
+static char *in_buffer;
+
+#undef getc
+#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
+#endif
+
+extern YYSTYPE yylval;
+
+%}
+
+N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
+B ([0-9A-Fa-f][0-9A-Fa-f]?)
+
+%a 3000
+
+%%
+dst return DST;
+src return SRC;
+
+link|ppp return LINK;
+ip return IP;
+tcp return TCP;
+udp return UDP;
+icmp return ICMP;
+
+host return HOST;
+net return NET;
+port return PORT;
+proto return PROTO;
+
+less return LESS;
+greater return GREATER;
+byte return BYTE;
+broadcast return TK_BROADCAST;
+multicast return TK_MULTICAST;
+
+and|"&&" return AND;
+or|"||" return OR;
+not return '!';
+
+len|length return LEN;
+inbound return INBOUND;
+outbound return OUTBOUND;
+
+[ \n\t] ;
+[+\-*/:\[\]!<>()&|=] return yytext[0];
+">=" return GEQ;
+"<=" return LEQ;
+"!=" return NEQ;
+"==" return '=';
+"<<" return LSH;
+">>" return RSH;
+{N} { yylval.i = stoi((char *)yytext); return NUM; }
+({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N}) {
+ yylval.s = sdup((char *)yytext); return HID;
+}
+[A-Za-z][-_.A-Za-z0-9]* { yylval.s = sdup((char *)yytext); return ID; }
+"\\"[^ !()\n\t]+ { yylval.s = sdup((char *)yytext + 1); return ID; }
+[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+ { bpf_error("illegal token: %s\n", yytext); }
+. { bpf_error("illegal char '%c'", *yytext); }
+%%
+void
+lex_init(buf)
+ char *buf;
+{
+#ifdef FLEX_SCANNER
+ if (yy_current_buffer)
+ yy_delete_buffer(yy_current_buffer);
+ yy_switch_to_buffer(yy_scan_string(buf));
+#else
+ in_buffer = buf;
+#endif
+}
+
+/*
+ * Also define a yywrap. Note that if we're using flex, it will
+ * define a macro to map this identifier to pcap_wrap.
+ */
+int
+yywrap()
+{
+ return 1;
+}
+
+/* Hex digit to integer. */
+static inline int
+xdtoi(c)
+ register int c;
+{
+ if (isdigit(c))
+ return c - '0';
+ else if (islower(c))
+ return c - 'a' + 10;
+ else
+ return c - 'A' + 10;
+}
+
+/*
+ * Convert string to integer. Just like atoi(), but checks for
+ * preceding 0x or 0 and uses hex or octal instead of decimal.
+ */
+static int
+stoi(s)
+ char *s;
+{
+ int base = 10;
+ int n = 0;
+
+ if (*s == '0') {
+ if (s[1] == 'x' || s[1] == 'X') {
+ s += 2;
+ base = 16;
+ }
+ else {
+ base = 8;
+ s += 1;
+ }
+ }
+ while (*s)
+ n = n * base + xdtoi(*s++);
+
+ return n;
+}
+
diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c
index 8ff8e7cd5b9..d4912257164 100644
--- a/usr.sbin/pppd/sys-bsd.c
+++ b/usr.sbin/pppd/sys-bsd.c
@@ -1,8 +1,11 @@
+/* $OpenBSD: sys-bsd.c,v 1.2 1996/03/25 15:55:57 niklas Exp $ */
+
/*
* sys-bsd.c - System-dependent procedures for setting up
* PPP interfaces on bsd-4.4-ish systems (including 386BSD, NetBSD, etc.)
*
* Copyright (c) 1989 Carnegie Mellon University.
+ * Copyright (c) 1995 The Australian National University.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
@@ -10,16 +13,17 @@
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * by Carnegie Mellon University and The Australian National University.
+ * The names of the Universities may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
-static char rcsid[] = "$Id: sys-bsd.c,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.2 1996/03/25 15:55:57 niklas Exp $";
#endif
/*
@@ -30,9 +34,11 @@ static char rcsid[] = "$Id: sys-bsd.c,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp
#include <syslog.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <termios.h>
+#include <signal.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -52,16 +58,33 @@ static char rcsid[] = "$Id: sys-bsd.c,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp
#include "pppd.h"
-static int initdisc = -1; /* Initial TTY discipline */
+static int initdisc = -1; /* Initial TTY discipline for ppp_fd */
+static int initfdflags = -1; /* Initial file descriptor flags for ppp_fd */
+static int ppp_fd = -1; /* fd which is set to PPP discipline */
static int rtm_seq;
-static int restore_term; /* 1 => we've munged the terminal */
+static int restore_term; /* 1 => we've munged the terminal */
static struct termios inittermios; /* Initial TTY termios */
static struct winsize wsinfo; /* Initial window size info */
static char *lock_file; /* name of lock file created */
-int sockfd; /* socket for doing interface ioctls */
+static int loop_slave = -1;
+static int loop_master;
+static char loop_name[20];
+
+static unsigned char inbuf[512]; /* buffer for chars read from loopback */
+
+static int sockfd; /* socket for doing interface ioctls */
+
+static int if_is_up; /* the interface is currently up */
+static u_int32_t default_route_gateway; /* gateway addr for default route */
+static u_int32_t proxy_arp_addr; /* remote addr for proxy arp */
+
+/* Prototypes for procedures local to this file. */
+static int dodefaultroute __P((u_int32_t, int));
+static int get_ether_addr __P((u_int32_t, struct sockaddr_dl *));
+
/*
* sys_init - System-dependent initialization.
@@ -82,6 +105,54 @@ sys_init()
}
/*
+ * sys_cleanup - restore any system state we modified before exiting:
+ * mark the interface down, delete default route and/or proxy arp entry.
+ * This should call die() because it's called from die().
+ */
+void
+sys_cleanup()
+{
+ struct ifreq ifr;
+
+ if (if_is_up) {
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) >= 0
+ && ((ifr.ifr_flags & IFF_UP) != 0)) {
+ ifr.ifr_flags &= ~IFF_UP;
+ ioctl(sockfd, SIOCSIFFLAGS, &ifr);
+ }
+ }
+
+ if (default_route_gateway)
+ cifdefaultroute(0, default_route_gateway);
+ if (proxy_arp_addr)
+ cifproxyarp(0, proxy_arp_addr);
+}
+
+/*
+ * sys_close - Clean up in a child process before execing.
+ */
+void
+sys_close()
+{
+ close(sockfd);
+ if (loop_slave >= 0) {
+ close(loop_slave);
+ close(loop_master);
+ }
+ closelog();
+}
+
+/*
+ * sys_check_options - check the options that the user specified
+ */
+void
+sys_check_options()
+{
+}
+
+
+/*
* note_debug_level - note a change in the debug level.
*/
void
@@ -124,11 +195,25 @@ file in the ppp-2.2 distribution.\n";
* establish_ppp - Turn the serial port into a ppp interface.
*/
void
-establish_ppp()
+establish_ppp(fd)
+ int fd;
{
int pppdisc = PPPDISC;
int x;
+ if (demand) {
+ /*
+ * Demand mode - prime the old ppp device to relinquish the unit.
+ */
+ if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0) {
+ syslog(LOG_ERR, "ioctl(transfer ppp unit): %m");
+ die(1);
+ }
+ }
+
+ /*
+ * Save the old line discipline of fd, and set it to PPP.
+ */
if (ioctl(fd, TIOCGETD, &initdisc) < 0) {
syslog(LOG_ERR, "ioctl(TIOCGETD): %m");
die(1);
@@ -138,14 +223,33 @@ establish_ppp()
die(1);
}
- /*
- * Find out which interface we were given.
- */
- if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0) {
- syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m");
- die(1);
+ if (!demand) {
+ /*
+ * Find out which interface we were given.
+ */
+ if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0) {
+ syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m");
+ die(1);
+ }
+ } else {
+ /*
+ * Check that we got the same unit again.
+ */
+ if (ioctl(fd, PPPIOCGUNIT, &x) < 0) {
+ syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m");
+ die(1);
+ }
+ if (x != ifunit) {
+ syslog(LOG_ERR, "transfer_ppp failed: wanted unit %d, got %d",
+ ifunit, x);
+ die(1);
+ }
+ x = TTYDISC;
+ ioctl(loop_slave, TIOCSETD, &x);
}
+ ppp_fd = fd;
+
/*
* Enable debug in the driver if requested.
*/
@@ -158,6 +262,50 @@ establish_ppp()
syslog(LOG_WARNING, "ioctl(PPPIOCSFLAGS): %m");
}
}
+
+ /*
+ * Set device for non-blocking reads.
+ */
+ if ((initfdflags = fcntl(fd, F_GETFL)) == -1
+ || fcntl(fd, F_SETFL, initfdflags | O_NONBLOCK) == -1) {
+ syslog(LOG_WARNING, "Couldn't set device to non-blocking mode: %m");
+ }
+}
+
+/*
+ * restore_loop - reattach the ppp unit to the loopback.
+ */
+void
+restore_loop()
+{
+ int x;
+
+ /*
+ * Transfer the ppp interface back to the loopback.
+ */
+ if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0) {
+ syslog(LOG_ERR, "ioctl(transfer ppp unit): %m");
+ die(1);
+ }
+ x = PPPDISC;
+ if (ioctl(loop_slave, TIOCSETD, &x) < 0) {
+ syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
+ die(1);
+ }
+
+ /*
+ * Check that we got the same unit again.
+ */
+ if (ioctl(loop_slave, PPPIOCGUNIT, &x) < 0) {
+ syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m");
+ die(1);
+ }
+ if (x != ifunit) {
+ syslog(LOG_ERR, "transfer_ppp failed: wanted unit %d, got %d",
+ ifunit, x);
+ die(1);
+ }
+ ppp_fd = loop_slave;
}
@@ -166,42 +314,55 @@ establish_ppp()
* This shouldn't call die() because it's called from die().
*/
void
-disestablish_ppp()
+disestablish_ppp(fd)
+ int fd;
+{
+ /* Reset non-blocking mode on fd. */
+ if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
+ syslog(LOG_WARNING, "Couldn't restore device fd flags: %m");
+ initfdflags = -1;
+
+ /* Restore old line discipline. */
+ if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) < 0)
+ syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
+ initdisc = -1;
+
+ if (fd == ppp_fd)
+ ppp_fd = -1;
+}
+
+/*
+ * Check whether the link seems not to be 8-bit clean.
+ */
+void
+clean_check()
{
int x;
char *s;
- if (initdisc >= 0) {
- /*
- * Check whether the link seems not to be 8-bit clean.
- */
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) == 0) {
- s = NULL;
- switch (~x & (SC_RCV_B7_0|SC_RCV_B7_1|SC_RCV_EVNP|SC_RCV_ODDP)) {
- case SC_RCV_B7_0:
- s = "bit 7 set to 1";
- break;
- case SC_RCV_B7_1:
- s = "bit 7 set to 0";
- break;
- case SC_RCV_EVNP:
- s = "odd parity";
- break;
- case SC_RCV_ODDP:
- s = "even parity";
- break;
- }
- if (s != NULL) {
- syslog(LOG_WARNING, "Serial link is not 8-bit clean:");
- syslog(LOG_WARNING, "All received characters had %s", s);
- }
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) == 0) {
+ s = NULL;
+ switch (~x & (SC_RCV_B7_0|SC_RCV_B7_1|SC_RCV_EVNP|SC_RCV_ODDP)) {
+ case SC_RCV_B7_0:
+ s = "bit 7 set to 1";
+ break;
+ case SC_RCV_B7_1:
+ s = "bit 7 set to 0";
+ break;
+ case SC_RCV_EVNP:
+ s = "odd parity";
+ break;
+ case SC_RCV_ODDP:
+ s = "even parity";
+ break;
+ }
+ if (s != NULL) {
+ syslog(LOG_WARNING, "Serial link is not 8-bit clean:");
+ syslog(LOG_WARNING, "All received characters had %s", s);
}
- if (ioctl(fd, TIOCSETD, &initdisc) < 0)
- syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
}
}
-
/*
* set_up_tty: Set up the serial port on `fd' for 8 bits, no parity,
* at the requested speed, etc. If `local' is true, set CLOCAL
@@ -209,6 +370,7 @@ disestablish_ppp()
*
* For *BSD, we assume that speed_t values numerically equal bits/second.
*/
+void
set_up_tty(fd, local)
int fd, local;
{
@@ -225,7 +387,7 @@ set_up_tty(fd, local)
}
tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
- if (crtscts > 0)
+ if (crtscts > 0 && !local)
tios.c_cflag |= CRTSCTS;
else if (crtscts < 0)
tios.c_cflag &= ~CRTSCTS;
@@ -239,8 +401,8 @@ set_up_tty(fd, local)
tios.c_cc[VMIN] = 1;
tios.c_cc[VTIME] = 0;
- if (crtscts == 2) {
- tios.c_iflag |= IXOFF;
+ if (crtscts == -2) {
+ tios.c_iflag |= IXON | IXOFF;
tios.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
tios.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
}
@@ -274,7 +436,8 @@ set_up_tty(fd, local)
* restore_tty - restore the terminal to the saved settings.
*/
void
-restore_tty()
+restore_tty(fd)
+ int fd;
{
if (restore_term) {
if (!default_device) {
@@ -298,6 +461,7 @@ restore_tty()
* setdtr - control the DTR line on the serial port.
* This is called from die(), so it shouldn't call die().
*/
+void
setdtr(fd, on)
int fd, on;
{
@@ -308,6 +472,68 @@ int fd, on;
/*
+ * open_ppp_loopback - open the device we use for getting
+ * packets in demand mode, and connect it to a ppp interface.
+ * Here we use a pty.
+ */
+void
+open_ppp_loopback()
+{
+ int flags;
+ struct termios tios;
+ int pppdisc = PPPDISC;
+
+ if (openpty(&loop_master, &loop_slave, loop_name, NULL, NULL) < 0) {
+ syslog(LOG_ERR, "No free pty for loopback");
+ die(1);
+ }
+ SYSDEBUG((LOG_DEBUG, "using %s for loopback", loop_name));
+
+ if (tcgetattr(loop_slave, &tios) == 0) {
+ tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
+ tios.c_cflag |= CS8 | CREAD;
+ tios.c_iflag = IGNPAR;
+ tios.c_oflag = 0;
+ tios.c_lflag = 0;
+ if (tcsetattr(loop_slave, TCSAFLUSH, &tios) < 0)
+ syslog(LOG_WARNING, "couldn't set attributes on loopback: %m");
+ }
+
+ if ((flags = fcntl(loop_master, F_GETFL)) != -1)
+ if (fcntl(loop_master, F_SETFL, flags | O_NONBLOCK) == -1)
+ syslog(LOG_WARNING, "couldn't set loopback to nonblock: %m");
+
+ ppp_fd = loop_slave;
+ if (ioctl(ppp_fd, TIOCSETD, &pppdisc) < 0) {
+ syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
+ die(1);
+ }
+
+ /*
+ * Find out which interface we were given.
+ */
+ if (ioctl(ppp_fd, PPPIOCGUNIT, &ifunit) < 0) {
+ syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m");
+ die(1);
+ }
+
+ /*
+ * Enable debug in the driver if requested.
+ */
+ if (kdebugflag) {
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &flags) < 0) {
+ syslog(LOG_WARNING, "ioctl (PPPIOCGFLAGS): %m");
+ } else {
+ flags |= (kdebugflag & 0xFF) * SC_DEBUG;
+ if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &flags) < 0)
+ syslog(LOG_WARNING, "ioctl(PPPIOCSFLAGS): %m");
+ }
+ }
+
+}
+
+
+/*
* output - Output PPP packet.
*/
void
@@ -316,23 +542,22 @@ output(unit, p, len)
u_char *p;
int len;
{
- if (unit != 0)
- MAINDEBUG((LOG_WARNING, "output: unit != 0!"));
if (debug)
log_packet(p, len, "sent ");
- if (write(fd, p, len) < 0) {
- syslog(LOG_ERR, "write: %m");
- die(1);
+ if (write(ttyfd, p, len) < 0) {
+ if (errno != EIO)
+ syslog(LOG_ERR, "write: %m");
}
}
/*
- * wait_input - wait until there is data available on fd,
+ * wait_input - wait until there is data available on ttyfd,
* for the length of time specified by *timo (indefinite
* if timo is NULL).
*/
+void
wait_input(timo)
struct timeval *timo;
{
@@ -340,8 +565,48 @@ wait_input(timo)
int n;
FD_ZERO(&ready);
- FD_SET(fd, &ready);
- n = select(fd+1, &ready, NULL, &ready, timo);
+ FD_SET(ttyfd, &ready);
+ n = select(ttyfd+1, &ready, NULL, &ready, timo);
+ if (n < 0 && errno != EINTR) {
+ syslog(LOG_ERR, "select: %m");
+ die(1);
+ }
+}
+
+
+/*
+ * wait_loop_output - wait until there is data available on the
+ * loopback, for the length of time specified by *timo (indefinite
+ * if timo is NULL).
+ */
+void
+wait_loop_output(timo)
+ struct timeval *timo;
+{
+ fd_set ready;
+ int n;
+
+ FD_ZERO(&ready);
+ FD_SET(loop_master, &ready);
+ n = select(loop_master + 1, &ready, NULL, &ready, timo);
+ if (n < 0 && errno != EINTR) {
+ syslog(LOG_ERR, "select: %m");
+ die(1);
+ }
+}
+
+
+/*
+ * wait_time - wait for a given length of time or until a
+ * signal is received.
+ */
+void
+wait_time(timo)
+ struct timeval *timo;
+{
+ int n;
+
+ n = select(0, NULL, NULL, NULL, timo);
if (n < 0 && errno != EINTR) {
syslog(LOG_ERR, "select: %m");
die(1);
@@ -358,10 +623,10 @@ read_packet(buf)
{
int len;
- if ((len = read(fd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
+ if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
if (errno == EWOULDBLOCK || errno == EINTR)
return -1;
- syslog(LOG_ERR, "read(fd): %m");
+ syslog(LOG_ERR, "read: %m");
die(1);
}
return len;
@@ -369,6 +634,34 @@ read_packet(buf)
/*
+ * get_loop_output - read characters from the loopback, form them
+ * into frames, and detect when we want to bring the real link up.
+ * Return value is 1 if we need to bring up the link, 0 otherwise.
+ */
+int
+get_loop_output()
+{
+ int rv = 0;
+ int n;
+
+ while ((n = read(loop_master, inbuf, sizeof(inbuf))) >= 0) {
+ if (loop_chars(inbuf, n))
+ rv = 1;
+ }
+
+ if (n == 0) {
+ syslog(LOG_ERR, "eof on loopback");
+ die(1);
+ } else if (errno != EWOULDBLOCK){
+ syslog(LOG_ERR, "read from loopback: %m");
+ die(1);
+ }
+
+ return rv;
+}
+
+
+/*
* ppp_send_config - configure the transmit characteristics of
* the ppp interface.
*/
@@ -388,18 +681,18 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
quit();
}
- if (ioctl(fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSASYNCMAP): %m");
quit();
}
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
quit();
}
x = pcomp? x | SC_COMP_PROT: x &~ SC_COMP_PROT;
x = accomp? x | SC_COMP_AC: x &~ SC_COMP_AC;
- if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
quit();
}
@@ -414,7 +707,7 @@ ppp_set_xaccm(unit, accm)
int unit;
ext_accm accm;
{
- if (ioctl(fd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY)
+ if (ioctl(ppp_fd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY)
syslog(LOG_WARNING, "ioctl(set extended ACCM): %m");
}
@@ -431,20 +724,20 @@ ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
{
int x;
- if (ioctl(fd, PPPIOCSMRU, (caddr_t) &mru) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSMRU): %m");
quit();
}
- if (ioctl(fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSRASYNCMAP): %m");
quit();
}
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
quit();
}
x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC;
- if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
quit();
}
@@ -452,8 +745,11 @@ ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
/*
* ccp_test - ask kernel whether a given compression method
- * is acceptable for use.
+ * is acceptable for use. Returns 1 if the method and parameters
+ * are OK, 0 if the method is known but the parameters are not OK
+ * (e.g. code size should be reduced), or -1 if the method is unknown.
*/
+int
ccp_test(unit, opt_ptr, opt_len, for_transmit)
int unit, opt_len, for_transmit;
u_char *opt_ptr;
@@ -463,7 +759,9 @@ ccp_test(unit, opt_ptr, opt_len, for_transmit)
data.ptr = opt_ptr;
data.length = opt_len;
data.transmit = for_transmit;
- return ioctl(fd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0;
+ if (ioctl(ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
+ return 1;
+ return (errno == ENOBUFS)? 0: -1;
}
/*
@@ -475,13 +773,13 @@ ccp_flags_set(unit, isopen, isup)
{
int x;
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
return;
}
x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN;
x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP;
- if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
+ if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
}
@@ -496,7 +794,7 @@ ccp_fatal_error(unit)
{
int x;
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCGFLAGS): %m");
return 0;
}
@@ -504,6 +802,43 @@ ccp_fatal_error(unit)
}
/*
+ * get_idle_time - return how long the link has been idle.
+ */
+int
+get_idle_time(u, ip)
+ int u;
+ struct ppp_idle *ip;
+{
+ return ioctl(ppp_fd, PPPIOCGIDLE, ip) >= 0;
+}
+
+
+/*
+ * set_filters - transfer the pass and active filters to the kernel.
+ */
+int
+set_filters(pass, active)
+ struct bpf_program *pass, *active;
+{
+ int ret = 1;
+
+ if (pass->bf_len > 0) {
+ if (ioctl(ppp_fd, PPPIOCSPASS, pass) < 0) {
+ syslog(LOG_ERR, "Couldn't set pass-filter in kernel: %m");
+ ret = 0;
+ }
+ }
+ if (active->bf_len > 0) {
+ if (ioctl(ppp_fd, PPPIOCSACTIVE, active) < 0) {
+ syslog(LOG_ERR, "Couldn't set active-filter in kernel: %m");
+ ret = 0;
+ }
+ }
+ return ret;
+}
+
+
+/*
* sifvjcomp - config tcp header compression
*/
int
@@ -512,17 +847,17 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid)
{
u_int x;
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
return 0;
}
x = vjcomp ? x | SC_COMP_TCP: x &~ SC_COMP_TCP;
x = cidcomp? x & ~SC_NO_TCP_CCID: x | SC_NO_TCP_CCID;
- if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
return 0;
}
- if (ioctl(fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
+ if (ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
return 0;
}
@@ -532,16 +867,11 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid)
/*
* sifup - Config the interface up and enable IP packets to pass.
*/
-#ifndef SC_ENABLE_IP
-#define SC_ENABLE_IP 0x100 /* compat for old versions of kernel code */
-#endif
-
int
sifup(u)
int u;
{
struct ifreq ifr;
- u_int x;
struct npioctl npi;
strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
@@ -554,23 +884,32 @@ sifup(u)
syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m");
return 0;
}
+ if_is_up = 1;
npi.protocol = PPP_IP;
npi.mode = NPMODE_PASS;
- if (ioctl(fd, PPPIOCSNPMODE, &npi) < 0) {
- if (errno != ENOTTY) {
- syslog(LOG_ERR, "ioctl(PPPIOCSNPMODE): %m");
- return 0;
- }
- /* for backwards compatibility */
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
- syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
- return 0;
- }
- x |= SC_ENABLE_IP;
- if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
- syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
- return 0;
- }
+ if (ioctl(ppp_fd, PPPIOCSNPMODE, &npi) < 0) {
+ syslog(LOG_ERR, "ioctl(set IP mode to PASS): %m");
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * sifnpmode - Set the mode for handling packets for a given NP.
+ */
+int
+sifnpmode(u, proto, mode)
+ int u;
+ int proto;
+ enum NPmode mode;
+{
+ struct npioctl npi;
+
+ npi.protocol = proto;
+ npi.mode = mode;
+ if (ioctl(ppp_fd, PPPIOCSNPMODE, &npi) < 0) {
+ syslog(LOG_ERR, "ioctl(set NP %d mode to %d): %m", proto, mode);
+ return 0;
}
return 1;
}
@@ -583,31 +922,14 @@ sifdown(u)
int u;
{
struct ifreq ifr;
- u_int x;
int rv;
struct npioctl npi;
rv = 1;
npi.protocol = PPP_IP;
npi.mode = NPMODE_ERROR;
- if (ioctl(fd, PPPIOCSNPMODE, (caddr_t) &npi) < 0) {
- if (errno != ENOTTY) {
- syslog(LOG_ERR, "ioctl(PPPIOCSNPMODE): %m");
- rv = 0;
- } else {
- /* backwards compatibility */
- if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
- syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
- rv = 0;
- } else {
- x &= ~SC_ENABLE_IP;
- if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
- syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
- rv = 0;
- }
- }
- }
- }
+ ioctl(ppp_fd, PPPIOCSNPMODE, (caddr_t) &npi);
+ /* ignore errors, because ppp_fd might have been closed by now. */
strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
@@ -618,7 +940,8 @@ sifdown(u)
if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m");
rv = 0;
- }
+ } else
+ if_is_up = 0;
}
return rv;
}
@@ -654,10 +977,11 @@ sifaddr(u, o, h, m)
BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask));
if (ioctl(sockfd, SIOCAIFADDR, (caddr_t) &ifra) < 0) {
if (errno != EEXIST) {
- syslog(LOG_ERR, "ioctl(SIOCAIFADDR): %m");
+ syslog(LOG_ERR, "Couldn't set interface address: %m");
return 0;
}
- syslog(LOG_WARNING, "ioctl(SIOCAIFADDR): Address already exists");
+ syslog(LOG_WARNING,
+ "Couldn't set interface address: Address already exists");
}
return 1;
}
@@ -680,7 +1004,8 @@ cifaddr(u, o, h)
((struct sockaddr_in *) &ifra.ifra_broadaddr)->sin_addr.s_addr = h;
BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask));
if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifra) < 0) {
- syslog(LOG_WARNING, "ioctl(SIOCDIFADDR): %m");
+ if (errno != EADDRNOTAVAIL)
+ syslog(LOG_WARNING, "Couldn't delete interface address: %m");
return 0;
}
return 1;
@@ -711,7 +1036,7 @@ cifdefaultroute(u, g)
/*
* dodefaultroute - talk to a routing socket to add/delete a default route.
*/
-int
+static int
dodefaultroute(g, cmd)
u_int32_t g;
int cmd;
@@ -725,7 +1050,8 @@ dodefaultroute(g, cmd)
} rtmsg;
if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
- syslog(LOG_ERR, "%cifdefaultroute: opening routing socket: %m", cmd);
+ syslog(LOG_ERR, "Couldn't %s default route: socket: %m",
+ cmd=='s'? "add": "delete");
return 0;
}
@@ -745,12 +1071,14 @@ dodefaultroute(g, cmd)
rtmsg.hdr.rtm_msglen = sizeof(rtmsg);
if (write(routes, &rtmsg, sizeof(rtmsg)) < 0) {
- syslog(LOG_ERR, "%s default route: %m", cmd=='s'? "add": "delete");
+ syslog(LOG_ERR, "Couldn't %s default route: %m",
+ cmd=='s'? "add": "delete");
close(routes);
return 0;
}
close(routes);
+ default_route_gateway = (cmd == 's')? g: 0;
return 1;
}
@@ -774,7 +1102,6 @@ sifproxyarp(unit, hisaddr)
u_int32_t hisaddr;
{
int routes;
- int l;
/*
* Get the hardware address of an interface on the same subnet
@@ -787,7 +1114,7 @@ sifproxyarp(unit, hisaddr)
}
if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
- syslog(LOG_ERR, "sifproxyarp: opening routing socket: %m");
+ syslog(LOG_ERR, "Couldn't add proxy arp entry: socket: %m");
return 0;
}
@@ -805,13 +1132,14 @@ sifproxyarp(unit, hisaddr)
arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
+ arpmsg.hwa.sdl_len;
if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
- syslog(LOG_ERR, "add proxy arp entry: %m");
+ syslog(LOG_ERR, "Couldn't add proxy arp entry: %m");
close(routes);
return 0;
}
close(routes);
arpmsg_valid = 1;
+ proxy_arp_addr = hisaddr;
return 1;
}
@@ -833,17 +1161,18 @@ cifproxyarp(unit, hisaddr)
arpmsg.hdr.rtm_seq = ++rtm_seq;
if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
- syslog(LOG_ERR, "sifproxyarp: opening routing socket: %m");
+ syslog(LOG_ERR, "Couldn't delete proxy arp entry: socket: %m");
return 0;
}
if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
- syslog(LOG_ERR, "delete proxy arp entry: %m");
+ syslog(LOG_ERR, "Couldn't delete proxy arp entry: %m");
close(routes);
return 0;
}
close(routes);
+ proxy_arp_addr = 0;
return 1;
}
@@ -881,10 +1210,11 @@ sifproxyarp(unit, hisaddr)
((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
arpreq.arp_flags = ATF_PERM | ATF_PUBL;
if (ioctl(sockfd, SIOCSARP, (caddr_t)&arpreq) < 0) {
- syslog(LOG_ERR, "ioctl(SIOCSARP): %m");
+ syslog(LOG_ERR, "Couldn't add proxy arp entry: %m");
return 0;
}
+ proxy_arp_addr = hisaddr;
return 1;
}
@@ -902,9 +1232,10 @@ cifproxyarp(unit, hisaddr)
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
if (ioctl(sockfd, SIOCDARP, (caddr_t)&arpreq) < 0) {
- syslog(LOG_WARNING, "ioctl(SIOCDARP): %m");
+ syslog(LOG_WARNING, "Couldn't delete proxy arp entry: %m");
return 0;
}
+ proxy_arp_addr = 0;
return 1;
}
#endif /* RTM_VERSION */
@@ -916,7 +1247,7 @@ cifproxyarp(unit, hisaddr)
*/
#define MAX_IFS 32
-int
+static int
get_ether_addr(ipaddr, hwaddr)
u_int32_t ipaddr;
struct sockaddr_dl *hwaddr;
@@ -1085,14 +1416,12 @@ lock(dev)
&& (fd = open(lock_file, O_RDONLY, 0)) >= 0) {
/* Read the lock file to find out who has the device locked */
n = read(fd, hdb_lock_buffer, 11);
- if (n > 0) {
- hdb_lock_buffer[n] = 0;
- pid = atoi(hdb_lock_buffer);
- }
if (n <= 0) {
syslog(LOG_ERR, "Can't read pid from lock file %s", lock_file);
close(fd);
} else {
+ hdb_lock_buffer[n] = 0;
+ pid = atoi(hdb_lock_buffer);
if (kill(pid, 0) == -1 && errno == ESRCH) {
/* pid no longer exists - remove the lock file */
if (unlink(lock_file) == 0) {
@@ -1125,6 +1454,7 @@ lock(dev)
/*
* unlock - remove our lockfile
*/
+void
unlock()
{
if (lock_file) {
diff --git a/usr.sbin/pppd/upap.c b/usr.sbin/pppd/upap.c
index 6d4e0658076..ac6725fd86b 100644
--- a/usr.sbin/pppd/upap.c
+++ b/usr.sbin/pppd/upap.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: upap.c,v 1.2 1996/03/25 15:55:58 niklas Exp $ */
+
/*
* upap.c - User/Password Authentication Protocol.
*
@@ -18,7 +20,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: upap.c,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: upap.c,v 1.2 1996/03/25 15:55:58 niklas Exp $";
#endif
/*
@@ -34,10 +36,14 @@ static char rcsid[] = "$Id: upap.c,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp $";
#include "pppd.h"
#include "upap.h"
+struct protent pap_protent = {
+ PPP_PAP, upap_init, upap_input, upap_protrej,
+ upap_lowerup, upap_lowerdown, NULL, NULL,
+ upap_printpkt, NULL, 1, "PAP", NULL, NULL
+};
upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */
-
static void upap_timeout __P((caddr_t));
static void upap_reqtimeout __P((caddr_t));
static void upap_rauthreq __P((upap_state *, u_char *, int, int));
diff --git a/usr.sbin/pppd/upap.h b/usr.sbin/pppd/upap.h
index c0eb75070f5..30c1a676b58 100644
--- a/usr.sbin/pppd/upap.h
+++ b/usr.sbin/pppd/upap.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: upap.h,v 1.2 1996/03/25 15:55:59 niklas Exp $ */
+
/*
* upap.h - User/Password Authentication Protocol definitions.
*
@@ -15,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Id: upap.h,v 1.1.1.1 1995/10/18 08:48:00 deraadt Exp $
*/
/*
@@ -91,3 +91,5 @@ void upap_input __P((int, u_char *, int));
void upap_protrej __P((int));
int upap_printpkt __P((u_char *, int,
void (*) __P((void *, char *, ...)), void *));
+
+extern struct protent pap_protent;
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c
index a032fa9cf63..e41f8a32a3f 100644
--- a/usr.sbin/pstat/pstat.c
+++ b/usr.sbin/pstat/pstat.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: pstat.c,v 1.3 1996/03/25 15:56:06 niklas Exp $ */
+/* $NetBSD: pstat.c,v 1.17 1996/02/21 02:27:57 cgd Exp $ */
+
/*-
* Copyright (c) 1980, 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -38,8 +41,12 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-/* from: static char sccsid[] = "@(#)pstat.c 8.9 (Berkeley) 2/16/94"; */
-static char *rcsid = "$Id: pstat.c,v 1.2 1995/11/06 21:19:02 deraadt Exp $";
+#if 0
+from: static char sccsid[] = "@(#)pstat.c 8.9 (Berkeley) 2/16/94";
+from: static char *rcsid = "$NetBSD: pstat.c,v 1.17 1996/02/21 02:27:57 cgd Exp $";
+#else
+static char *rcsid = "$OpenBSD: pstat.c,v 1.3 1996/03/25 15:56:06 niklas Exp $";
+#endif
#endif /* not lint */
#include <sys/param.h>
@@ -56,6 +63,8 @@ static char *rcsid = "$Id: pstat.c,v 1.2 1995/11/06 21:19:02 deraadt Exp $";
#undef NFS
#undef _KERNEL
#include <sys/stat.h>
+#include <nfs/nfsproto.h>
+#include <nfs/rpcv2.h>
#include <nfs/nfsnode.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
diff --git a/usr.sbin/rdate/Makefile b/usr.sbin/rdate/Makefile
index 7059458f0f9..3988a056acf 100644
--- a/usr.sbin/rdate/Makefile
+++ b/usr.sbin/rdate/Makefile
@@ -1,4 +1,5 @@
-# @(#) $Id: Makefile,v 1.1.1.1 1995/10/18 08:48:04 deraadt Exp $
+# $OpenBSD: Makefile,v 1.2 1996/03/25 15:56:08 niklas Exp $
+# $NetBSD: Makefile,v 1.3 1996/02/22 06:59:15 thorpej Exp $
PROG= rdate
SRCS= rdate.c
diff --git a/usr.sbin/rdate/rdate.8 b/usr.sbin/rdate/rdate.8
index c3f352c5282..1492764717a 100644
--- a/usr.sbin/rdate/rdate.8
+++ b/usr.sbin/rdate/rdate.8
@@ -1,3 +1,5 @@
+.\" $OpenBSD: rdate.8,v 1.3 1996/03/25 15:56:09 niklas Exp $
+.\" $NetBSD: rdate.8,v 1.3 1996/02/22 06:59:17 thorpej Exp $
.\"
.\" Copyright (c) 1994 Christos Zoulas
.\" All rights reserved.
@@ -27,8 +29,6 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: rdate.8,v 1.2 1996/02/22 00:17:04 niklas Exp $
-.\"
.Dd April 30, 1994
.Dt RDATE 8
.Os
diff --git a/usr.sbin/rdate/rdate.c b/usr.sbin/rdate/rdate.c
index d195f5934db..77353e392fb 100644
--- a/usr.sbin/rdate/rdate.c
+++ b/usr.sbin/rdate/rdate.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: rdate.c,v 1.3 1996/03/25 15:56:10 niklas Exp $ */
+/* $NetBSD: rdate.c,v 1.3 1996/02/22 06:59:18 thorpej Exp $ */
+
/*
* Copyright (c) 1994 Christos Zoulas
* All rights reserved.
@@ -26,8 +29,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: rdate.c,v 1.2 1996/02/22 00:17:06 niklas Exp $
*/
/*
@@ -38,7 +39,11 @@
* midnight January 1st 1900.
*/
#ifndef lint
-static char rcsid[] = "$Id: rdate.c,v 1.2 1996/02/22 00:17:06 niklas Exp $";
+#if 0
+from: static char rcsid[] = "$NetBSD: rdate.c,v 1.3 1996/02/22 06:59:18 thorpej Exp $";
+#else
+static char rcsid[] = "$OpenBSD: rdate.c,v 1.3 1996/03/25 15:56:10 niklas Exp $";
+#endif
#endif /* lint */
#include <sys/types.h>
diff --git a/usr.sbin/screenblank/pathnames.h b/usr.sbin/screenblank/pathnames.h
index 5446d7073b9..9028a34bfcf 100644
--- a/usr.sbin/screenblank/pathnames.h
+++ b/usr.sbin/screenblank/pathnames.h
@@ -1,9 +1,13 @@
-/* $NetBSD: pathnames.h,v 1.1 1995/07/12 04:57:48 thorpej Exp $ */
+/* $OpenBSD: pathnames.h,v 1.2 1996/03/25 15:56:12 niklas Exp $ */
+/* $NetBSD: pathnames.h,v 1.2 1996/02/28 01:18:30 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#define _PATH_SCREENBLANKPID "/var/run/screenblank.pid"
diff --git a/usr.sbin/screenblank/screenblank.1 b/usr.sbin/screenblank/screenblank.1
index b61b727fcdc..1dcf40124a9 100644
--- a/usr.sbin/screenblank/screenblank.1
+++ b/usr.sbin/screenblank/screenblank.1
@@ -1,8 +1,12 @@
-.\" $NetBSD: screenblank.1,v 1.1 1995/07/12 04:57:50 thorpej Exp $
+.\" $OpenBSD: screenblank.1,v 1.2 1996/03/25 15:56:13 niklas Exp $
+.\" $NetBSD: screenblank.1,v 1.2 1996/02/28 01:18:32 thorpej Exp $
.\"
-.\" Copyright (c) 1995 Jason R. Thorpe.
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jason R. Thorpe.
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -13,22 +17,23 @@
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
-.\" This product includes software developed for the NetBSD Project
-.\" by Jason R. Thorpe.
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd June 7, 1995
.Dt SCREENBLANK 1
diff --git a/usr.sbin/screenblank/screenblank.c b/usr.sbin/screenblank/screenblank.c
index dcd5d59ad6c..d56ebf731e3 100644
--- a/usr.sbin/screenblank/screenblank.c
+++ b/usr.sbin/screenblank/screenblank.c
@@ -1,9 +1,13 @@
-/* $NetBSD: screenblank.c,v 1.1 1995/07/12 04:57:51 thorpej Exp $ */
+/* $OpenBSD: screenblank.c,v 1.2 1996/03/25 15:56:14 niklas Exp $ */
+/* $NetBSD: screenblank.c,v 1.2 1996/02/28 01:18:34 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
diff --git a/usr.sbin/ypbind/ypbind.8 b/usr.sbin/ypbind/ypbind.8
index 2263e66a681..e23235fb403 100644
--- a/usr.sbin/ypbind/ypbind.8
+++ b/usr.sbin/ypbind/ypbind.8
@@ -1,7 +1,12 @@
+.\" $OpenBSD: ypbind.8,v 1.3 1996/03/25 15:56:19 niklas Exp $
+.\" $NetBSD: ypbind.8,v 1.2 1996/02/28 01:21:00 thorpej Exp $
.\"
-.\" Copyright (c) 1994 Jason R. Thorpe
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jason R. Thorpe.
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -12,24 +17,23 @@
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
-.\" This product includes software developed by Jason Thorpe.
-.\" 4. Neither the name of the author nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
.\"
-.\" $Id: ypbind.8,v 1.2 1995/10/18 10:58:56 deraadt Exp $
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 25, 1994
.Dt YPBIND 8
diff --git a/usr.sbin/yppoll/yppoll.8 b/usr.sbin/yppoll/yppoll.8
index bb61e1c3010..3cd58884f31 100644
--- a/usr.sbin/yppoll/yppoll.8
+++ b/usr.sbin/yppoll/yppoll.8
@@ -1,7 +1,12 @@
+.\" $OpenBSD: yppoll.8,v 1.2 1996/03/25 15:56:21 niklas Exp $
+.\" $NetBSD: yppoll.8,v 1.3 1996/02/28 01:23:12 thorpej Exp $
.\"
-.\" Copyright (c) 1994 Jason R. Thorpe
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jason R. Thorpe.
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -12,24 +17,23 @@
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
-.\" This product includes software developed by Jason Thorpe.
-.\" 4. Neither the name of the author nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
.\"
-.\" $Id: yppoll.8,v 1.1.1.1 1995/10/18 08:48:32 deraadt Exp $
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 25, 1994
.Dt YPPOLL 8
diff --git a/usr.sbin/ypset/ypset.8 b/usr.sbin/ypset/ypset.8
index 6448a69bffc..4d57cf08793 100644
--- a/usr.sbin/ypset/ypset.8
+++ b/usr.sbin/ypset/ypset.8
@@ -1,7 +1,12 @@
+.\" $OpenBSD: ypset.8,v 1.2 1996/03/25 15:56:23 niklas Exp $
+.\" $NetBSD: ypset.8,v 1.2 1996/02/28 01:25:08 thorpej Exp $
.\"
-.\" Copyright (c) 1994 Jason R. Thorpe
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jason R. Thorpe.
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -12,24 +17,23 @@
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
-.\" This product includes software developed by Jason Thorpe.
-.\" 4. Neither the name of the author nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
.\"
-.\" $Id: ypset.8,v 1.1.1.1 1995/10/18 08:48:32 deraadt Exp $
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 25, 1994
.Dt YPSET 8