summaryrefslogtreecommitdiff
path: root/net/pppd
diff options
context:
space:
mode:
authorcube <cube>2005-01-02 02:51:40 +0000
committercube <cube>2005-01-02 02:51:40 +0000
commit1c3ade80aa3491bdd798fc8fb449b5a7903f1f6e (patch)
treeb76aa88f42b440cfb17fc25332b40488fe8a010c /net/pppd
parent1d2937adfe5e9d433b9b50c7debc6fcfd2c68d1e (diff)
downloadpkgsrc-1c3ade80aa3491bdd798fc8fb449b5a7903f1f6e.tar.gz
Initial import of pppd, version 2.4.3, into the NetBSD Package Collection.
The PPP Daemon is the userland part of the Point-to-Point Protocol. It works in combination with a dedicated kernel network interface usually named ppp. PPP is a very extensible protocol and pppd supports a large number of options, including compression (through various algorithms), cryptography (Microsoft's MPPE) and authentication (PAP, CHAP, Microsoft CHAP), provided the kernel has the relevant back-ends in some cases.
Diffstat (limited to 'net/pppd')
-rw-r--r--net/pppd/DESCR6
-rw-r--r--net/pppd/Makefile26
-rw-r--r--net/pppd/PLIST29
-rw-r--r--net/pppd/PLIST.Linux12
-rw-r--r--net/pppd/distinfo45
-rw-r--r--net/pppd/patches/patch-aa13
-rw-r--r--net/pppd/patches/patch-ab34
-rw-r--r--net/pppd/patches/patch-ac155
-rw-r--r--net/pppd/patches/patch-ad211
-rw-r--r--net/pppd/patches/patch-ae25
-rw-r--r--net/pppd/patches/patch-af44
-rw-r--r--net/pppd/patches/patch-ag15
-rw-r--r--net/pppd/patches/patch-ah71
-rw-r--r--net/pppd/patches/patch-ai13
-rw-r--r--net/pppd/patches/patch-aj227
-rw-r--r--net/pppd/patches/patch-ak52
-rw-r--r--net/pppd/patches/patch-al35
-rw-r--r--net/pppd/patches/patch-am25
-rw-r--r--net/pppd/patches/patch-an30
-rw-r--r--net/pppd/patches/patch-ao17
-rw-r--r--net/pppd/patches/patch-ap13
-rw-r--r--net/pppd/patches/patch-aq85
-rw-r--r--net/pppd/patches/patch-ar82
-rw-r--r--net/pppd/patches/patch-as30
-rw-r--r--net/pppd/patches/patch-at13
-rw-r--r--net/pppd/patches/patch-au273
-rw-r--r--net/pppd/patches/patch-av13
-rw-r--r--net/pppd/patches/patch-aw349
-rw-r--r--net/pppd/patches/patch-ax61
-rw-r--r--net/pppd/patches/patch-ay12
-rw-r--r--net/pppd/patches/patch-az2152
-rw-r--r--net/pppd/patches/patch-ba30
-rw-r--r--net/pppd/patches/patch-bb87
-rw-r--r--net/pppd/patches/patch-bc71
-rw-r--r--net/pppd/patches/patch-bd12
-rw-r--r--net/pppd/patches/patch-be26
-rw-r--r--net/pppd/patches/patch-bf177
-rw-r--r--net/pppd/patches/patch-bg122
-rw-r--r--net/pppd/patches/patch-bh37
-rw-r--r--net/pppd/patches/patch-bi99
-rw-r--r--net/pppd/patches/patch-bj49
-rw-r--r--net/pppd/patches/patch-bk13
-rw-r--r--net/pppd/patches/patch-bl40
-rw-r--r--net/pppd/patches/patch-bm26
-rw-r--r--net/pppd/patches/patch-bn13
-rw-r--r--net/pppd/patches/patch-bo13
46 files changed, 4983 insertions, 0 deletions
diff --git a/net/pppd/DESCR b/net/pppd/DESCR
new file mode 100644
index 00000000000..833f0f2c813
--- /dev/null
+++ b/net/pppd/DESCR
@@ -0,0 +1,6 @@
+The PPP Daemon is the userland part of the Point-to-Point Protocol. It works
+in combination with a dedicated kernel network interface usually named ppp.
+PPP is a very extensible protocol and pppd supports a large number of options,
+including compression (through various algorithms), cryptography (Microsoft's
+MPPE) and authentication (PAP, CHAP, Microsoft CHAP), provided the kernel has
+the relevant back-ends in some cases.
diff --git a/net/pppd/Makefile b/net/pppd/Makefile
new file mode 100644
index 00000000000..fcd332aef3f
--- /dev/null
+++ b/net/pppd/Makefile
@@ -0,0 +1,26 @@
+# $NetBSD: Makefile,v 1.1.1.1 2005/01/02 02:51:40 cube Exp $
+
+DISTNAME= ppp-${PPPD_VERSION}
+PKGNAME= ${DISTNAME:S/ppp/&d/}
+CATEGORIES= net
+MASTER_SITES= ftp://ftp.samba.org/pub/ppp/
+
+MAINTAINER= cube@NetBSD.org
+HOMEPAGE= http://ppp.samba.org/
+COMMENT= PPP Daemon
+
+USE_BUILDLINK3= yes
+USE_PKGLOCALEDIR= yes
+HAS_CONFIGURE= yes
+USE_GNU_TOOLS+= make
+USE_PKGINSTALL= yes
+
+ONLY_FOR_PLATFORM+= NetBSD-*-* Linux-*-*
+
+PKG_SYSCONFSUBDIR= ppp
+CONFIGURE_ENV+= PREFIX=${PREFIX} PKGSYSCONFDIR=${PKG_SYSCONFDIR}
+
+PPPD_VERSION= 2.4.3
+PLIST_SUBST+= PPPD_VERSION=${PPPD_VERSION}
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/net/pppd/PLIST b/net/pppd/PLIST
new file mode 100644
index 00000000000..4d025c11972
--- /dev/null
+++ b/net/pppd/PLIST
@@ -0,0 +1,29 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+include/pppd/ccp.h
+include/pppd/chap-new.h
+include/pppd/chap_ms.h
+include/pppd/eap.h
+include/pppd/ecp.h
+include/pppd/fsm.h
+include/pppd/ipcp.h
+include/pppd/ipxcp.h
+include/pppd/lcp.h
+include/pppd/magic.h
+include/pppd/md5.h
+include/pppd/patchlevel.h
+include/pppd/pathnames.h
+include/pppd/pppcrypt.h
+include/pppd/pppd.h
+include/pppd/sha1.h
+include/pppd/spinlock.h
+include/pppd/tdb.h
+include/pppd/upap.h
+man/man8/chat.8
+man/man8/pppd.8
+man/man8/pppdump.8
+man/man8/pppstats.8
+sbin/chat
+sbin/pppd
+sbin/pppdump
+sbin/pppstats
+@dirrm include/pppd
diff --git a/net/pppd/PLIST.Linux b/net/pppd/PLIST.Linux
new file mode 100644
index 00000000000..835f9531e56
--- /dev/null
+++ b/net/pppd/PLIST.Linux
@@ -0,0 +1,12 @@
+@comment $NetBSD: PLIST.Linux,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+include/pppd/md4.h
+lib/pppd/${PPPD_VERSION}/pppoatm.so
+lib/pppd/${PPPD_VERSION}/radius.so
+lib/pppd/${PPPD_VERSION}/radattr.so
+lib/pppd/${PPPD_VERSION}/radrealms.so
+lib/pppd/${PPPD_VERSION}/rp-pppoe.so
+man/man8/pppd-radius.8
+man/man8/pppd-radattr.8
+sbin/pppoe-discovery
+@dirrm lib/pppd/${PPPD_VERSION}
+@dirrm lib/pppd
diff --git a/net/pppd/distinfo b/net/pppd/distinfo
new file mode 100644
index 00000000000..0cb623a40bf
--- /dev/null
+++ b/net/pppd/distinfo
@@ -0,0 +1,45 @@
+$NetBSD: distinfo,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+
+SHA1 (ppp-2.4.3.tar.gz) = 5e2789f4dedc81943fa9f94c840cccc2407056f7
+Size (ppp-2.4.3.tar.gz) = 688092 bytes
+SHA1 (patch-aa) = 8814f0f389971d07368bef95fbadbb5d7562d0a9
+SHA1 (patch-ab) = 1cd0d99dac316b1c5a48c9a41104c2c25e9bb920
+SHA1 (patch-ac) = 9bc88cfcd7b1a09e92aaa919f35e39afb3b45803
+SHA1 (patch-ad) = c196817c32c9b8c8d367d5cb54c4c792d53b78f8
+SHA1 (patch-ae) = 3cb3f64ad7c209a8283a92c50bdb4071c6f8ad38
+SHA1 (patch-af) = 178a2a2a716d6ff8e9bd0cc36ff72d8a138f6989
+SHA1 (patch-ag) = f989f71dbb164e53157ba2677f29737862e137f2
+SHA1 (patch-ah) = 6bca5470590c5a9c9aa9de64abf21e44c770d1b5
+SHA1 (patch-ai) = a0e5fcd766980e20ee3737273833e743dee58bf5
+SHA1 (patch-aj) = 01f7b864769f98d65d24294307932c3fb02162f4
+SHA1 (patch-ak) = d38d646fad05418d1271918af53569bb40f12812
+SHA1 (patch-al) = 1c76f6c2fa6a9a3ea4d79e23d4ecf449c5260d8d
+SHA1 (patch-am) = 4d017c416611ca3bc91f1292d7fad2bffffa638d
+SHA1 (patch-an) = 34993cb35793f3dd6749df21b3c9fce2a5b25eb9
+SHA1 (patch-ao) = 2c41e874876b13e510ab0337981d24fc0ec37257
+SHA1 (patch-ap) = 28e69eccad8c480322de9e9b50a0c6ee47586a94
+SHA1 (patch-aq) = e6ba0533fb4135ab6d1055694e9e8ec27cd19f38
+SHA1 (patch-ar) = 5070283e0b66c5e085770451c8a0f82b764f0be2
+SHA1 (patch-as) = b6774585d995d5871bc13a6430ce99192d0405ab
+SHA1 (patch-at) = ab5d74511ff1b83953f3595b6d71b0c130bdc966
+SHA1 (patch-au) = b74e19ee4f9e09bfbb0f8be15b1baa80a7e11ce4
+SHA1 (patch-av) = 6ae49e8f2d5d74fa437e100b27a021451feb8f28
+SHA1 (patch-aw) = 7fb53f72216ffe34720b76fc122e87f4762a6696
+SHA1 (patch-ax) = 3641654b6b158ad65e9dd95247836fa8c07ec66e
+SHA1 (patch-ay) = 93ccd90f6efa58bfe31105526499308ed35b9522
+SHA1 (patch-az) = 250ce38e56be6e05719463c5a93b4b8acae78a43
+SHA1 (patch-ba) = 4293edb8b490fe31e07268a6d7001e1c9db8f323
+SHA1 (patch-bb) = 9b17b12b45d9857eea42c2a6dc3704392c4df7c0
+SHA1 (patch-bc) = d53a2226166e84fa9ea049cdbfb52c1dcd0f1ed9
+SHA1 (patch-bd) = 142545e81f05f5efbc35629bf6cf1e791f3dc4f9
+SHA1 (patch-be) = 2685b1c382506c746e18b9047fdd1816d1af96b8
+SHA1 (patch-bf) = 16788a1508cd981ff8967915a86a1fb02e55330c
+SHA1 (patch-bg) = 29c0880b6a30ab16b62a538c42cdbb6296add506
+SHA1 (patch-bh) = 8136e968fadbc2cc08006651772b943313cb6641
+SHA1 (patch-bi) = 56d8389724807a8317b16219fbfb81b6da623d10
+SHA1 (patch-bj) = ad5618b6243414ce2649b200096a53194f48c735
+SHA1 (patch-bk) = 2ebb4e4133c22775e374990a6e05390f826d3e91
+SHA1 (patch-bl) = 31525cf95919a534804c95121f7e69289c4220cb
+SHA1 (patch-bm) = 27743760f1a5c385b5b17c0568e0736d5c3b08bb
+SHA1 (patch-bn) = 2527e7f82874ad3ffaa2585bb7939fbd62ee291a
+SHA1 (patch-bo) = 58edaa6a2a9d542da32f2fab678a01132235a9e0
diff --git a/net/pppd/patches/patch-aa b/net/pppd/patches/patch-aa
new file mode 100644
index 00000000000..1566cdbe912
--- /dev/null
+++ b/net/pppd/patches/patch-aa
@@ -0,0 +1,13 @@
+$NetBSD: patch-aa,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+
+--- chat/Makefile.linux.orig 2004-11-03 12:51:47.000000000 +0100
++++ chat/Makefile.linux
+@@ -2,7 +2,7 @@
+
+ DESTDIR = @DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+-MANDIR = $(DESTDIR)/share/man/man8
++MANDIR = $(DESTDIR)/man/man8
+
+ CDEF1= -DTERMIOS # Use the termios structure
+ CDEF2= -DSIGTYPE=void # Standard definition
diff --git a/net/pppd/patches/patch-ab b/net/pppd/patches/patch-ab
new file mode 100644
index 00000000000..1e0f5a62092
--- /dev/null
+++ b/net/pppd/patches/patch-ab
@@ -0,0 +1,34 @@
+$NetBSD: patch-ab,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+
+--- chat/Makefile.netbsd.orig 2004-12-31 23:50:59.000000000 +0100
++++ chat/Makefile.netbsd
+@@ -0,0 +1,29 @@
++DESTDIR = @DESTDIR@
++BINDIR = $(DESTDIR)/sbin
++MANDIR = $(DESTDIR)/man/man8
++
++CDEF1= -DTERMIOS # Use the termios structure
++CDEF2= -DSIGTYPE=void # Standard definition
++CDEF3= -DHAS_STRLFUNCS # strlcat and strlcpy
++CDEFS= $(CDEF1) $(CDEF2) $(CDEF3)
++
++COPTS= -O2 -g -pipe
++CFLAGS= $(COPTS) $(CDEFS)
++
++INSTALL= install
++
++all: chat
++
++chat: chat.o
++ $(CC) -o chat chat.o
++
++chat.o: chat.c
++ $(CC) -c $(CFLAGS) -o chat.o chat.c
++
++install: chat
++ mkdir -p $(BINDIR)
++ $(INSTALL) -s -c chat $(BINDIR)
++ $(INSTALL) -c -m 644 chat.8 $(MANDIR)
++
++clean:
++ rm -f chat.o chat *~
diff --git a/net/pppd/patches/patch-ac b/net/pppd/patches/patch-ac
new file mode 100644
index 00000000000..bbf87acc8dc
--- /dev/null
+++ b/net/pppd/patches/patch-ac
@@ -0,0 +1,155 @@
+$NetBSD: patch-ac,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+
+--- chat/chat.8.orig 2004-11-13 13:22:49.000000000 +0100
++++ chat/chat.8
+@@ -23,21 +23,21 @@ connection between the Point-to-Point Pr
+ the remote's \fIpppd\fR process.
+ .SH OPTIONS
+ .TP
+-.B \-f \fI<chat file>
++.B \-f \fI\*[Lt]chat file\*[Gt]
+ Read the chat script from the chat \fIfile\fR. The use of this option
+ is mutually exclusive with the chat script parameters. The user must
+ have read access to the file. Multiple lines are permitted in the
+ file. Space or horizontal tab characters should be used to separate
+ the strings.
+ .TP
+-.B \-t \fI<timeout>
++.B \-t \fI\*[Lt]timeout\*[Gt]
+ Set the timeout for the expected string to be received. If the string
+ is not received within the time limit then the reply string is not
+ sent. An alternate reply may be sent or the script will fail if there
+ is no alternate reply string. A failed script will cause the
+ \fIchat\fR program to terminate with a non-zero error code.
+ .TP
+-.B \-r \fI<report file>
++.B \-r \fI\*[Lt]report file\*[Gt]
+ Set the file for output of the report strings. If you use the keyword
+ \fIREPORT\fR, the resulting strings are written to this file. If this
+ option is not used and you still use \fIREPORT\fR keywords, the
+@@ -50,7 +50,7 @@ keyword. When echoing is enabled, all ou
+ to \fIstderr\fR.
+ .TP
+ .B \-E
+-Enables environment variable substituion within chat scripts using the
++Enables environment variable substitution within chat scripts using the
+ standard \fI$xxx\fR syntax.
+ .TP
+ .B \-v
+@@ -58,7 +58,8 @@ Request that the \fIchat\fR script be ex
+ \fIchat\fR program will then log the execution state of the chat
+ script as well as all text received from the modem and the output
+ strings sent to the modem. The default is to log through the SYSLOG;
+-the logging method may be altered with the \-S and \-s flags.
++the logging method may be altered with the \-S and \-s flags. SYSLOGs
++are logged to facility LOG_LOCAL2.
+ .TP
+ .B \-V
+ Request that the \fIchat\fR script be executed in a stderr verbose
+@@ -74,16 +75,16 @@ sent to stderr.
+ .B \-S
+ Do not use the SYSLOG. By default, error messages are sent to the
+ SYSLOG. The use of \-S will prevent both log messages from '\-v' and
+-error messages from being sent to the SYSLOG.
++error messages from being sent to the SYSLOG (to facility LOG_LOCAL2).
+ .TP
+-.B \-T \fI<phone number>
++.B \-T \fI\*[Lt]phone number\*[Gt]
+ Pass in an arbitary string, usually a phone number, that will be
+ substituted for the \\T substitution metacharacter in a send string.
+ .TP
+-.B \-U \fI<phone number 2>
++.B \-U \fI\*[Lt]phone number 2\*[Gt]
+ Pass in a second string, usually a phone number, that will be
+ substituted for the \\U substitution metacharacter in a send string.
+-This is useful when dialing an ISDN terminal adapter that requires two
++This is useful when dialing an ISDN terminal adapter that requires two
+ numbers.
+ .TP
+ .B script
+@@ -204,25 +205,25 @@ terminal), standard error will normally
+ .LP
+ \fBSAY\fR strings must be enclosed in single or double quotes. If
+ carriage return and line feed are needed in the string to be output,
+-you must explicitely add them to your string.
++you must explicitly add them to your string.
+ .LP
+ The SAY strings could be used to give progress messages in sections of
+ the script where you want to have 'ECHO OFF' but still let the user
+ know what is happening. An example is:
+ .IP
+-ABORT BUSY
++ABORT BUSY
+ .br
+-ECHO OFF
++ECHO OFF
+ .br
+-SAY "Dialling your ISP...\\n"
++SAY "Dialling your ISP...\\n"
+ .br
+-\&'' ATDT5551212
++\&'' ATDT5551212
+ .br
+ TIMEOUT 120
+ .br
+ SAY "Waiting up to 2 minutes for connection ... "
+ .br
+-CONNECT ''
++CONNECT ''
+ .br
+ SAY "Connected, now logging in ...\n"
+ .br
+@@ -238,7 +239,7 @@ This sequence will only present the SAY
+ the details of the script will remain hidden. For example, if the
+ above script works, the user will see:
+ .IP
+-Dialling your ISP...
++Dialing your ISP...
+ .br
+ Waiting up to 2 minutes for connection ... Connected, now logging in ...
+ .br
+@@ -305,7 +306,7 @@ but starting with the \fICONNECT\fR (or
+ will be echoed.
+ .SH HANGUP
+ The HANGUP options control whether a modem hangup should be considered
+-as an error or not. This option is useful in scripts for dialling
++as an error or not. This option is useful in scripts for dialing
+ systems which will hang up and call your system back. The HANGUP
+ options can be \fBON\fR or \fBOFF\fR.
+ .br
+@@ -418,7 +419,7 @@ Pause for a fraction of a second. The de
+ .I (not valid in expect.)
+ .TP
+ .B \\\\q
+-Suppress writing the string to the SYSLOG file. The string ?????? is
++Suppress writing the string to the SYSLOG. The string ?????? is
+ written to the log in its place.
+ .I (not valid in expect.)
+ .TP
+@@ -428,7 +429,7 @@ Send or expect a carriage return.
+ .B \\\\s
+ Represents a space character in the string. This may be used when it
+ is not desirable to quote the strings which contains spaces. The
+-sequence 'HI TIM' and HI\\sTIM are the same.
++sequence 'HI\ TIM' and HI\\sTIM are the same.
+ .TP
+ .B \\\\t
+ Send or expect a tab character.
+@@ -457,7 +458,7 @@ For example, the character DC1 (17) is s
+ Environment variables are available within chat scripts, if the \fI\-E\fR
+ option was specified in the command line. The metacharacter \fI$\fR is used
+ to introduce the name of the environment variable to substitute. If the
+-substition fails, because the requested environment variable is not set,
++substitution fails, because the requested environment variable is not set,
+ \fInothing\fR is replaced for the variable.
+ .SH TERMINATION CODES
+ The \fIchat\fR program will terminate with the following completion
+@@ -509,7 +510,7 @@ Additional information about \fIchat\fR
+ documentation. The \fIchat\fR script was taken from the ideas proposed
+ by the scripts used by the \fIuucico\fR program.
+ .LP
+-uucico(1), uucp(1)
++uucp(1), uucico(8)
+ .SH COPYRIGHT
+ The \fIchat\fR program is in public domain. This is not the GNU public
+ license. If it breaks then you get to keep both pieces.
diff --git a/net/pppd/patches/patch-ad b/net/pppd/patches/patch-ad
new file mode 100644
index 00000000000..5ed6b099f33
--- /dev/null
+++ b/net/pppd/patches/patch-ad
@@ -0,0 +1,211 @@
+$NetBSD: patch-ad,v 1.1.1.1 2005/01/02 02:51:41 cube Exp $
+
+--- chat/chat.c.orig 2004-02-02 04:36:46.000000000 +0100
++++ chat/chat.c
+@@ -147,20 +147,9 @@ extern char *sys_errlist[];
+ "unknown error")
+ #endif
+
+-/*************** Micro getopt() *********************************************/
+-#define OPTION(c,v) (_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
+- (--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
+- &&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
+-#define OPTARG(c,v) (_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
+- (_O=4,(char*)0):(char*)0)
+-#define OPTONLYARG(c,v) (_O&2&&**v?(_O=1,--c,*v++):(char*)0)
+-#define ARG(c,v) (c?(--c,*v++):(char*)0)
+-
+-static int _O = 0; /* Internal state */
+-/*************** Micro getopt() *********************************************/
+-
+ char *program_name;
+
++#define BUFFER_SIZE 256
+ #define MAX_ABORTS 50
+ #define MAX_REPORTS 50
+ #define DEFAULT_CHAT_TIMEOUT 45
+@@ -198,12 +187,12 @@ struct termios saved_tty_parameters;
+ #endif
+
+ char *abort_string[MAX_ABORTS], *fail_reason = (char *)0,
+- fail_buffer[50];
++ fail_buffer[BUFFER_SIZE];
+ int n_aborts = 0, abort_next = 0, timeout_next = 0, echo_next = 0;
+ int clear_abort_next = 0;
+
+ char *report_string[MAX_REPORTS] ;
+-char report_buffer[256] ;
++char report_buffer[BUFFER_SIZE] ;
+ int n_reports = 0, report_next = 0, report_gathering = 0 ;
+ int clear_report_next = 0;
+
+@@ -289,12 +278,12 @@ main(argc, argv)
+ char **argv;
+ {
+ int option;
+- char *arg;
++ int i;
+
+ program_name = *argv;
+ tzset();
+
+- while ((option = OPTION(argc, argv)) != 0) {
++ while ((option = getopt(argc, argv, ":eEvVf:t:r:sST:U:")) != -1) {
+ switch (option) {
+ case 'e':
+ ++echo;
+@@ -321,25 +310,24 @@ main(argc, argv)
+ break;
+
+ case 'f':
+- if ((arg = OPTARG(argc, argv)) != NULL)
+- chat_file = copy_of(arg);
++ if (optarg != NULL)
++ chat_file = copy_of(optarg);
+ else
+ usage();
+ break;
+
+ case 't':
+- if ((arg = OPTARG(argc, argv)) != NULL)
+- timeout = atoi(arg);
++ if (optarg != NULL)
++ timeout = atoi(optarg);
+ else
+ usage();
+ break;
+
+ case 'r':
+- arg = OPTARG (argc, argv);
+- if (arg) {
++ if (optarg) {
+ if (report_fp != NULL)
+ fclose (report_fp);
+- report_file = copy_of (arg);
++ report_file = copy_of (optarg);
+ report_fp = fopen (report_file, "a");
+ if (report_fp != NULL) {
+ if (verbose)
+@@ -351,15 +339,15 @@ main(argc, argv)
+ break;
+
+ case 'T':
+- if ((arg = OPTARG(argc, argv)) != NULL)
+- phone_num = copy_of(arg);
++ if (optarg != NULL)
++ phone_num = copy_of(optarg);
+ else
+ usage();
+ break;
+
+ case 'U':
+- if ((arg = OPTARG(argc, argv)) != NULL)
+- phone_num2 = copy_of(arg);
++ if (optarg != NULL)
++ phone_num2 = copy_of(optarg);
+ else
+ usage();
+ break;
+@@ -369,6 +357,8 @@ main(argc, argv)
+ break;
+ }
+ }
++ argc -= optind;
++ argv += optind;
+ /*
+ * Default the report file to the stderr location
+ */
+@@ -391,17 +381,15 @@ main(argc, argv)
+ init();
+
+ if (chat_file != NULL) {
+- arg = ARG(argc, argv);
+- if (arg != NULL)
++ if (argc)
+ usage();
+ else
+ do_file (chat_file);
+ } else {
+- while ((arg = ARG(argc, argv)) != NULL) {
+- chat_expect(arg);
+-
+- if ((arg = ARG(argc, argv)) != NULL)
+- chat_send(arg);
++ for (i = 0; i < argc; i++) {
++ chat_expect(argv[i]);
++ if (++i < argc)
++ chat_send(argv[i]);
+ }
+ }
+
+@@ -508,6 +496,7 @@ void msgf __V((const char *fmt, ...))
+ #endif
+
+ vfmtmsg(line, sizeof(line), fmt, args);
++ va_end(args);
+ if (to_log)
+ syslog(LOG_INFO, "%s", line);
+ if (to_stderr)
+@@ -533,6 +522,7 @@ void fatal __V((int code, const char *fm
+ #endif
+
+ vfmtmsg(line, sizeof(line), fmt, args);
++ va_end(args);
+ if (to_log)
+ syslog(LOG_ERR, "%s", line);
+ if (to_stderr)
+@@ -614,7 +604,7 @@ void set_tty_parameters()
+ have_tty_parameters = 1;
+
+ t.c_iflag |= IGNBRK | ISTRIP | IGNPAR;
+- t.c_oflag = 0;
++ t.c_oflag |= OPOST | ONLCR;
+ t.c_lflag = 0;
+ t.c_cc[VERASE] =
+ t.c_cc[VKILL] = 0;
+@@ -1022,11 +1012,11 @@ int c;
+ c &= 0x7F;
+
+ if (c < 32)
+- sprintf(string, "%s^%c", meta, (int)c + '@');
++ snprintf(string, sizeof(string), "%s^%c", meta, (int)c + '@');
+ else if (c == 127)
+- sprintf(string, "%s^?", meta);
++ snprintf(string, sizeof(string), "%s^?", meta);
+ else
+- sprintf(string, "%s%c", meta, c);
++ snprintf(string, sizeof(string), "%s%c", meta, c);
+
+ return (string);
+ }
+@@ -1445,7 +1435,14 @@ register char *string;
+ struct tm* tm_now = localtime (&time_now);
+
+ strftime (report_buffer, 20, "%b %d %H:%M:%S ", tm_now);
+- strcat (report_buffer, report_string[n]);
++#ifdef HAS_STRLFUNCS
++ strlcat(report_buffer, report_string[n],
++ sizeof(report_buffer));
++#else
++ strncat(report_buffer, report_string[n],
++ sizeof(report_buffer)-1);
++ report_buffer[sizeof(report_buffer)-1] = '\0';
++#endif
+
+ report_string[n] = (char *) NULL;
+ report_gathering = 1;
+@@ -1491,7 +1488,13 @@ register char *string;
+ alarm(0);
+ alarmed = 0;
+ exit_code = n + 4;
+- strcpy(fail_reason = fail_buffer, abort_string[n]);
++#ifdef HAS_STRLFUNCS
++ strlcpy(fail_buffer, abort_string[n], sizeof(fail_buffer));
++#else
++ strncpy(fail_buffer, abort_string[n], sizeof(fail_buffer)-1);
++ fail_buffer[sizeof(fail_buffer)-1] = '\0';
++#endif
++ fail_reason = fail_buffer;
+ return (0);
+ }
+ }
diff --git a/net/pppd/patches/patch-ae b/net/pppd/patches/patch-ae
new file mode 100644
index 00000000000..418b29ec9e8
--- /dev/null
+++ b/net/pppd/patches/patch-ae
@@ -0,0 +1,25 @@
+$NetBSD: patch-ae,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- configure.orig 2004-11-06 12:36:54.000000000 +0100
++++ configure
+@@ -3,6 +3,6 @@
+
+ # Where to install stuff by default
+-DESTDIR=/usr/local
+-SYSCONF=/etc
++DESTDIR=${PREFIX}
++SYSCONF=${PKGSYSCONFDIR}
+
+ # if [ -d /NextApps ]; then
+@@ -51,5 +51,10 @@ case $system in
+ echo "C compiler not found; hoping for the best."
+ fi;;
+- NetBSD|FreeBSD|ULTRIX|OSF1|NeXTStep|SINIX-?|UNIX_SV|UNIX_System_V)
++ NetBSD)
++ case $release in
++ [01].*) state="notincluded";;
++ *) state="known"; ksrc="netbsd"; makext="netbsd";;
++ esac;;
++ FreeBSD|ULTRIX|OSF1|NeXTStep|SINIX-?|UNIX_SV|UNIX_System_V)
+ state="notincluded";;
+ # NetBSD)
diff --git a/net/pppd/patches/patch-af b/net/pppd/patches/patch-af
new file mode 100644
index 00000000000..a2ed7f69588
--- /dev/null
+++ b/net/pppd/patches/patch-af
@@ -0,0 +1,44 @@
+$NetBSD: patch-af,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- include/net/if_ppp.h.orig 2002-12-06 10:49:15.000000000 +0100
++++ include/net/if_ppp.h
+@@ -108,10 +108,16 @@ struct ifpppcstatsreq {
+ struct ppp_comp_stats stats;
+ };
+
++struct ppp_rawin {
++ u_char buf[63];
++ u_char count;
++};
++
+ /*
+ * Ioctl definitions.
+ */
+
++#define PPPIOCGRAWIN _IOR('t', 91, struct ppp_rawin) /* get raw input */
+ #define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
+ #define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
+ #define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
+@@ -130,8 +136,22 @@ struct ifpppcstatsreq {
+ #define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
+ #define PPPIOCGIDLE _IOR('t', 74, struct ppp_idle) /* get idle time */
+ #ifdef PPP_FILTER
++/*
++ * XXX These are deprecated; they can no longer be used, because they
++ * XXX don't play well with multiple encaps. The defs are here so that
++ * XXX we can return decent errors to old pppds, and so that new pppds
++ * XXX will work with old kernels.
++ */
+ #define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */
+ #define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */
++
++/*
++ * Use these instead.
++ */
++#define PPPIOCSIPASS _IOW('t', 69, struct bpf_program) /* set in pass flt */
++#define PPPIOCSOPASS _IOW('t', 68, struct bpf_program) /* set out pass flt */
++#define PPPIOCSIACTIVE _IOW('t', 67, struct bpf_program) /* set in act flt */
++#define PPPIOCSOACTIVE _IOW('t', 66, struct bpf_program) /* set out act flt */
+ #endif /* PPP_FILTER */
+
+ /* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */
diff --git a/net/pppd/patches/patch-ag b/net/pppd/patches/patch-ag
new file mode 100644
index 00000000000..f91760aa012
--- /dev/null
+++ b/net/pppd/patches/patch-ag
@@ -0,0 +1,15 @@
+$NetBSD: patch-ag,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- linux/Makefile.top.orig 2004-10-31 23:25:16.000000000 +0100
++++ linux/Makefile.top
+@@ -3,8 +3,8 @@
+ DESTDIR = @DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ INCDIR = $(DESTDIR)/include
+-MANDIR = $(DESTDIR)/share/man
+-ETCDIR = @SYSCONF@/ppp
++MANDIR = $(DESTDIR)/man
++ETCDIR = @SYSCONF@
+
+ # uid 0 = root
+ INSTALL= install
diff --git a/net/pppd/patches/patch-ah b/net/pppd/patches/patch-ah
new file mode 100644
index 00000000000..2c12ea0db2b
--- /dev/null
+++ b/net/pppd/patches/patch-ah
@@ -0,0 +1,71 @@
+$NetBSD: patch-ah,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- netbsd/Makefile.top.orig 2004-12-31 23:50:59.000000000 +0100
++++ netbsd/Makefile.top
+@@ -0,0 +1,66 @@
++# PPP top-level Makefile for Linux.
++
++DESTDIR = @DESTDIR@
++BINDIR = $(DESTDIR)/sbin
++INCDIR = $(DESTDIR)/include
++MANDIR = $(DESTDIR)/man
++ETCDIR = @SYSCONF@
++
++# uid 0 = root
++INSTALL= install
++
++all:
++ cd chat; $(MAKE) $(MFLAGS) all
++# cd pppd/plugins; $(MAKE) $(MFLAGS) all
++ cd pppd; $(MAKE) $(MFLAGS) all
++ cd pppstats; $(MAKE) $(MFLAGS) all
++ cd pppdump; $(MAKE) $(MFLAGS) all
++
++install: $(BINDIR) $(MANDIR)/man8 install-progs install-devel
++
++install-progs:
++ cd chat; $(MAKE) $(MFLAGS) install
++# cd pppd/plugins; $(MAKE) $(MFLAGS) install
++ cd pppd; $(MAKE) $(MFLAGS) install
++ cd pppstats; $(MAKE) $(MFLAGS) install
++ cd pppdump; $(MAKE) $(MFLAGS) install
++
++install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
++ $(ETCDIR)/chap-secrets
++
++install-devel:
++ cd pppd; $(MAKE) $(MFLAGS) install-devel
++
++$(ETCDIR)/options:
++ $(INSTALL) -c -m 644 etc.ppp/options $@
++$(ETCDIR)/pap-secrets:
++ $(INSTALL) -c -m 600 etc.ppp/pap-secrets $@
++$(ETCDIR)/chap-secrets:
++ $(INSTALL) -c -m 600 etc.ppp/chap-secrets $@
++
++$(BINDIR):
++ $(INSTALL) -d -m 755 $@
++$(MANDIR)/man8:
++ $(INSTALL) -d -m 755 $@
++$(ETCDIR):
++ $(INSTALL) -d -m 755 $@
++
++clean:
++ rm -f `find . -name '*.[oas]' -print`
++ rm -f `find . -name 'core' -print`
++ rm -f `find . -name '*~' -print`
++ cd chat; $(MAKE) clean
++# cd pppd/plugins; $(MAKE) clean
++ cd pppd; $(MAKE) clean
++ cd pppstats; $(MAKE) clean
++ cd pppdump; $(MAKE) clean
++
++dist-clean: clean
++ rm -f Makefile `find . -name Makefile -print`
++
++#kernel:
++# cd linux; ./kinstall.sh
++
++# no tests yet, one day...
++installcheck:
++ true
diff --git a/net/pppd/patches/patch-ai b/net/pppd/patches/patch-ai
new file mode 100644
index 00000000000..23936d2bf60
--- /dev/null
+++ b/net/pppd/patches/patch-ai
@@ -0,0 +1,13 @@
+$NetBSD: patch-ai,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/Makefile.linux.orig 2004-11-13 13:02:22.000000000 +0100
++++ pppd/Makefile.linux
+@@ -6,7 +6,7 @@
+ # Default installation locations
+ DESTDIR = @DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+-MANDIR = $(DESTDIR)/share/man/man8
++MANDIR = $(DESTDIR)/man/man8
+ INCDIR = $(DESTDIR)/include
+
+ TARGETS = pppd
diff --git a/net/pppd/patches/patch-aj b/net/pppd/patches/patch-aj
new file mode 100644
index 00000000000..c14e1771274
--- /dev/null
+++ b/net/pppd/patches/patch-aj
@@ -0,0 +1,227 @@
+$NetBSD: patch-aj,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/Makefile.netbsd.orig 2004-12-31 23:50:59.000000000 +0100
++++ pppd/Makefile.netbsd
+@@ -0,0 +1,222 @@
++#
++# pppd makefile for NetBSD
++#
++
++# Default installation locations
++DESTDIR = @DESTDIR@
++BINDIR = $(DESTDIR)/sbin
++MANDIR = $(DESTDIR)/man/man8
++INCDIR = $(DESTDIR)/include
++
++TARGETS = pppd
++
++PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
++ ecp.c ipxcp.c auth.c options.c sys-bsd.c chap_ms.c \
++ demand.c utils.c tty.c eap.c chap-md5.c
++
++HEADERS = ccp.h chap-new.h ecp.h fsm.h ipcp.h \
++ ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \
++ upap.h eap.h
++
++MANPAGES = pppd.8
++PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \
++ ecp.o auth.o options.o demand.o utils.o sys-bsd.o ipxcp.o tty.o \
++ eap.o chap-md5.o
++
++#
++# include dependencies if present
++ifeq (.depend,$(wildcard .depend))
++include .depend
++endif
++
++# CC = gcc
++#
++COPTS = -O2 -pipe -Wall -g
++LIBS = -lutil
++
++# Uncomment the next 2 lines to include support for Microsoft's
++# MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux.
++CHAPMS=y
++USE_CRYPT=y
++# Don't use MSLANMAN unless you really know what you're doing.
++#MSLANMAN=y
++# Uncomment the next line to include support for MPPE. CHAPMS (above) must
++# also be enabled. Also, edit plugins/radius/Makefile.linux.
++MPPE=y
++
++# Uncomment the next line to include support for PPP packet filtering.
++# This requires that the libpcap library and headers be installed
++# and that the kernel driver support PPP packet filtering.
++FILTER=y
++
++# Uncomment the next line to enable multilink PPP (enabled by default)
++# Linux distributions: Please leave multilink ENABLED in your builds
++# of pppd!
++HAVE_MULTILINK=y
++
++# Uncomment the next line to enable the TDB database (enabled by default.)
++# If you enable multilink, then TDB is automatically enabled also.
++# Linux distributions: Please leave TDB ENABLED in your builds.
++USE_TDB=y
++
++#HAS_SHADOW=y
++#USE_PAM=y
++#HAVE_INET6=y
++
++# Enable plugins
++PLUGIN=y
++
++# Enable Microsoft proprietary Callback Control Protocol
++#CBCP=y
++
++# Enable EAP SRP-SHA1 authentication (requires libsrp)
++#USE_SRP=y
++
++MAXOCTETS=y
++
++INCLUDE_DIRS= -I../include
++
++COMPILE_FLAGS= -DHAVE_PATHS_H -DHAVE_MMAP -DHAS_STRLFUNCS
++
++CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
++
++ifdef CHAPMS
++CFLAGS += -DCHAPMS=1
++NEEDDES=y
++PPPDOBJS += chap_ms.o
++HEADERS += chap_ms.h
++ifdef MSLANMAN
++CFLAGS += -DMSLANMAN=1
++endif
++ifdef MPPE
++CFLAGS += -DMPPE=1
++endif
++endif
++
++# EAP SRP-SHA1
++ifdef USE_SRP
++CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
++LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
++TARGETS += srp-entry
++EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
++MANPAGES += srp-entry.8
++EXTRACLEAN += srp-entry.o
++NEEDDES=y
++else
++# OpenSSL has an integrated version of SHA-1, and its implementation
++# is incompatible with this local SHA-1 implementation. We must use
++# one or the other, not both.
++PPPDSRCS += sha1.c
++HEADERS += sha1.h
++PPPDOBJS += sha1.o
++endif
++
++ifdef HAS_SHADOW
++CFLAGS += -DHAS_SHADOW
++#LIBS += -lshadow $(LIBS)
++endif
++
++ifneq ($(wildcard /usr/include/crypt.h),)
++CFLAGS += -DHAVE_CRYPT_H=1
++endif
++ifneq ($(wildcard /usr/lib/libcrypt.*),)
++LIBS += -lcrypt
++endif
++
++ifdef NEEDDES
++ifndef USE_CRYPT
++LIBS += -ldes $(LIBS)
++else
++CFLAGS += -DUSE_CRYPT=1
++endif
++PPPDOBJS += pppcrypt.o
++HEADERS += pppcrypt.h
++endif
++
++# For "Pluggable Authentication Modules", see ftp.redhat.com:/pub/pam/.
++ifdef USE_PAM
++CFLAGS += -DUSE_PAM
++LIBS += -lpam
++endif
++
++# Multi-linnk
++ifdef HAVE_MULTILINK
++ # Multilink implies the use of TDB
++ USE_TDB=y
++
++ CFLAGS += -DHAVE_MULTILINK
++ PPPDSRCS += multilink.c
++ PPPDOBJS += multilink.o
++endif
++
++# TDB
++ifdef USE_TDB
++ CFLAGS += -DUSE_TDB=1
++ PPPDSRCS += tdb.c spinlock.c
++ PPPDOBJS += tdb.o spinlock.o
++ HEADERS += tdb.h spinlock.h
++endif
++
++# Lock library binary for Linux is included in 'linux' subdirectory.
++ifdef LOCKLIB
++LIBS += -llock
++CFLAGS += -DLOCKLIB=1
++endif
++
++ifdef PLUGIN
++CFLAGS += -DPLUGIN
++LDFLAGS += -Wl,-E
++endif
++
++ifdef FILTER
++ifneq ($(wildcard /usr/include/pcap-bpf.h),)
++LIBS += -lpcap
++CFLAGS += -DPPP_FILTER
++endif
++endif
++
++ifdef HAVE_INET6
++ PPPDSRCS += ipv6cp.c eui64.c
++ HEADERS += ipv6cp.h eui64.h
++ PPPDOBJS += ipv6cp.o eui64.o
++ CFLAGS += -DINET6=1
++endif
++
++ifdef CBCP
++ PPPDSRCS += cbcp.c
++ PPPDOBJS += cbcp.o
++ CFLAGS += -DCBCP_SUPPORT
++ HEADERS += cbcp.h
++endif
++
++ifdef MAXOCTETS
++ CFLAGS += -DMAXOCTETS
++endif
++
++INSTALL= install
++
++all: $(TARGETS)
++
++install: pppd
++ mkdir -p $(BINDIR) $(MANDIR)
++ $(EXTRAINSTALL)
++ $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
++ if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
++ chmod o-rx,u+s $(BINDIR)/pppd; fi
++ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)
++
++pppd: $(PPPDOBJS)
++ $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
++
++srp-entry: srp-entry.c
++ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS)
++
++install-devel:
++ mkdir -p $(INCDIR)/pppd
++ $(INSTALL) -c -m 644 $(HEADERS) $(INCDIR)/pppd
++
++clean:
++ rm -f $(PPPDOBJS) $(EXTRACLEAN) $(TARGETS) *~ #* core
++
++depend:
++ $(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
diff --git a/net/pppd/patches/patch-ak b/net/pppd/patches/patch-ak
new file mode 100644
index 00000000000..3485dfb91f2
--- /dev/null
+++ b/net/pppd/patches/patch-ak
@@ -0,0 +1,52 @@
+$NetBSD: patch-ak,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/auth.c.orig 2004-11-12 11:30:51.000000000 +0100
++++ pppd/auth.c
+@@ -81,11 +81,14 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
+-#include <utmp.h>
+ #include <fcntl.h>
++#include <paths.h>
+ #if defined(_PATH_LASTLOG) && defined(__linux__)
+ #include <lastlog.h>
+ #endif
++#ifdef __NetBSD__
++#include <util.h>
++#endif
+
+ #include <netdb.h>
+ #include <netinet/in.h>
+@@ -844,7 +847,8 @@ start_networks(unit)
+
+ #ifdef PPP_FILTER
+ if (!demand)
+- set_filters(&pass_filter, &active_filter);
++ set_filters(&pass_filter_in, &pass_filter_out,
++ &active_filter_in, &active_filter_out);
+ #endif
+ /* Start CCP and ECP */
+ for (i = 0; (protp = protocols[i]) != NULL; ++i)
+@@ -1664,7 +1668,12 @@ plogout()
+ tty = devnam;
+ if (strncmp(tty, "/dev/", 5) == 0)
+ tty += 5;
++#ifdef SUPPORT_UTMP
+ logwtmp(tty, "", ""); /* Wipe out utmp logout entry */
++#endif
++#ifdef SUPPORT_UTMPX
++ logwtmpx(tty, "", "", 0, DEAD_PROCESS); /* Wipe out utmp logout entry */
++#endif
+ #endif /* ! USE_PAM */
+ logged_in = 0;
+ }
+@@ -2416,7 +2425,7 @@ scan_authfile(f, client, server, secret,
+ if (ap == NULL)
+ novm("authorized addresses");
+ ap->word = (char *) (ap + 1);
+- strcpy(ap->word, word);
++ strlcpy(ap->word, word, strlen(word) + 1);
+ *app = ap;
+ app = &ap->next;
+ }
diff --git a/net/pppd/patches/patch-al b/net/pppd/patches/patch-al
new file mode 100644
index 00000000000..3267f102220
--- /dev/null
+++ b/net/pppd/patches/patch-al
@@ -0,0 +1,35 @@
+$NetBSD: patch-al,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/cbcp.c.orig 2004-10-28 02:15:36.000000000 +0200
++++ pppd/cbcp.c
+@@ -166,7 +166,7 @@ cbcp_input(unit, inpacket, pktlen)
+
+ if (pktlen < CBCP_MINLEN) {
+ if (debug)
+- dbglog("CBCP packet is too small");
++ dbglog("CBCP packet is too short (%d)", pktlen);
+ return;
+ }
+
+@@ -176,7 +176,7 @@ cbcp_input(unit, inpacket, pktlen)
+
+ if (len > pktlen || len < CBCP_MINLEN) {
+ if (debug)
+- dbglog("CBCP packet: invalid length %d", len);
++ dbglog("CBCP packet: invalid length %d/%d", len, pktlen);
+ return;
+ }
+
+@@ -321,6 +321,12 @@ cbcp_recvreq(us, pckt, pcktlen)
+ if (opt_len < 2 || opt_len > len)
+ break;
+
++ /* seriously malformed, stop processing */
++ if (opt_len > len) {
++ error("CBCP: Malformed option length (%d/%d)", opt_len, len);
++ break;
++ }
++
+ if (opt_len > 2)
+ GETCHAR(delay, pckt);
+
diff --git a/net/pppd/patches/patch-am b/net/pppd/patches/patch-am
new file mode 100644
index 00000000000..8f89c586fc2
--- /dev/null
+++ b/net/pppd/patches/patch-am
@@ -0,0 +1,25 @@
+$NetBSD: patch-am,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/chap_ms.c.orig 2004-11-12 10:57:43.000000000 +0100
++++ pppd/chap_ms.c
+@@ -89,7 +89,11 @@
+ #include "pppd.h"
+ #include "chap-new.h"
+ #include "chap_ms.h"
++#ifdef __NetBSD__
++#include <md4.h>
++#else
+ #include "md4.h"
++#endif
+ #include "sha1.h"
+ #include "pppcrypt.h"
+ #include "magic.h"
+@@ -574,7 +578,7 @@ ChapMS_LANMan(u_char *rchallenge, char *
+ /* LANMan password is case insensitive */
+ BZERO(UcasePassword, sizeof(UcasePassword));
+ for (i = 0; i < secret_len; i++)
+- UcasePassword[i] = (u_char)toupper(secret[i]);
++ UcasePassword[i] = (u_char)toupper((unsigned char)secret[i]);
+ (void) DesSetkey(UcasePassword + 0);
+ DesEncrypt( StdText, PasswordHash + 0 );
+ (void) DesSetkey(UcasePassword + 7);
diff --git a/net/pppd/patches/patch-an b/net/pppd/patches/patch-an
new file mode 100644
index 00000000000..4b02bad81b1
--- /dev/null
+++ b/net/pppd/patches/patch-an
@@ -0,0 +1,30 @@
+$NetBSD: patch-an,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/demand.c.orig 2004-11-04 11:02:26.000000000 +0100
++++ pppd/demand.c
+@@ -100,7 +100,8 @@ demand_conf()
+ fatal("Couldn't set up demand-dialled PPP interface: %m");
+
+ #ifdef PPP_FILTER
+- set_filters(&pass_filter, &active_filter);
++ set_filters(&pass_filter_in, &pass_filter_out,
++ &active_filter_in, &active_filter_out);
+ #endif
+
+ /*
+@@ -341,11 +342,11 @@ active_packet(p, len)
+ return 0;
+ proto = PPP_PROTOCOL(p);
+ #ifdef PPP_FILTER
+- if (pass_filter.bf_len != 0
+- && bpf_filter(pass_filter.bf_insns, p, len, len) == 0)
++ if (pass_filter_out.bf_len != 0
++ && bpf_filter(pass_filter_out.bf_insns, p, len, len) == 0)
+ return 0;
+- if (active_filter.bf_len != 0
+- && bpf_filter(active_filter.bf_insns, p, len, len) == 0)
++ if (active_filter_out.bf_len != 0
++ && bpf_filter(active_filter_out.bf_insns, p, len, len) == 0)
+ return 0;
+ #endif
+ for (i = 0; (protp = protocols[i]) != NULL; ++i) {
diff --git a/net/pppd/patches/patch-ao b/net/pppd/patches/patch-ao
new file mode 100644
index 00000000000..17b4ace92ca
--- /dev/null
+++ b/net/pppd/patches/patch-ao
@@ -0,0 +1,17 @@
+$NetBSD: patch-ao,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/eui64.c.orig 2002-12-05 00:03:32.000000000 +0100
++++ pppd/eui64.c
+@@ -41,6 +41,7 @@
+
+ static const char rcsid[] = RCSID;
+
++#ifdef INET6
+ /*
+ * eui64_ntoa - Make an ascii representation of an interface identifier
+ */
+@@ -55,3 +56,4 @@ eui64_ntoa(e)
+ e.e8[4], e.e8[5], e.e8[6], e.e8[7]);
+ return buf;
+ }
++#endif
diff --git a/net/pppd/patches/patch-ap b/net/pppd/patches/patch-ap
new file mode 100644
index 00000000000..851436bab9c
--- /dev/null
+++ b/net/pppd/patches/patch-ap
@@ -0,0 +1,13 @@
+$NetBSD: patch-ap,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/fsm.c.orig 2004-11-13 03:28:15.000000000 +0100
++++ pppd/fsm.c
+@@ -306,7 +306,7 @@ fsm_timeout(arg)
+ case ACKRCVD:
+ case ACKSENT:
+ if (f->retransmits <= 0) {
+- warn("%s: timeout sending Config-Requests\n", PROTO_NAME(f));
++ warn("%s: timeout sending Config-Requests", PROTO_NAME(f));
+ f->state = STOPPED;
+ if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished )
+ (*f->callbacks->finished)(f);
diff --git a/net/pppd/patches/patch-aq b/net/pppd/patches/patch-aq
new file mode 100644
index 00000000000..2556bbfe3a5
--- /dev/null
+++ b/net/pppd/patches/patch-aq
@@ -0,0 +1,85 @@
+$NetBSD: patch-aq,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/ipv6cp.c.orig 2004-11-13 03:28:15.000000000 +0100
++++ pppd/ipv6cp.c
+@@ -151,6 +151,7 @@
+ */
+
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <netdb.h>
+@@ -163,12 +164,17 @@
+ #include "pppd.h"
+ #include "fsm.h"
+ #include "ipcp.h"
++#ifdef INET6
+ #include "ipv6cp.h"
++#endif
+ #include "magic.h"
+ #include "pathnames.h"
+
++#ifdef RCSID
+ static const char rcsid[] = RCSID;
++#endif
+
++#ifdef INET6
+ /* global vars */
+ ipv6cp_options ipv6cp_wantoptions[NUM_PPP]; /* Options that we want to request */
+ ipv6cp_options ipv6cp_gotoptions[NUM_PPP]; /* Options that peer ack'd */
+@@ -192,6 +198,7 @@ static int ipv6cp_reqci __P((fsm *, u_c
+ static void ipv6cp_up __P((fsm *)); /* We're UP */
+ static void ipv6cp_down __P((fsm *)); /* We're DOWN */
+ static void ipv6cp_finished __P((fsm *)); /* Don't need lower layer */
++static char *llv6_ntoa __P((eui64_t));
+
+ fsm ipv6cp_fsm[NUM_PPP]; /* IPV6CP fsm structure */
+
+@@ -328,9 +335,10 @@ setifaceid(argv)
+ struct in6_addr addr;
+ static int prio_local, prio_remote;
+
++#define s6_addr32 __u6_addr.__u6_addr32 /* non-standard */
+ #define VALIDID(a) ( (((a).s6_addr32[0] == 0) && ((a).s6_addr32[1] == 0)) && \
+ (((a).s6_addr32[2] != 0) || ((a).s6_addr32[3] != 0)) )
+-
++
+ arg = *argv;
+ if ((comma = strchr(arg, ',')) == NULL)
+ comma = arg + strlen(arg);
+@@ -395,13 +403,13 @@ printifaceid(opt, printer, arg)
+ /*
+ * Make a string representation of a network address.
+ */
+-char *
++static char *
+ llv6_ntoa(ifaceid)
+ eui64_t ifaceid;
+ {
+ static char b[64];
+
+- sprintf(b, "fe80::%s", eui64_ntoa(ifaceid));
++ snprintf(b, sizeof(b), "fe80::%s", eui64_ntoa(ifaceid));
+ return b;
+ }
+
+@@ -1406,9 +1414,10 @@ ipv6cp_script(script)
+ char strspeed[32], strlocal[32], strremote[32];
+ char *argv[8];
+
+- sprintf(strspeed, "%d", baud_rate);
+- strcpy(strlocal, llv6_ntoa(ipv6cp_gotoptions[0].ourid));
+- strcpy(strremote, llv6_ntoa(ipv6cp_hisoptions[0].hisid));
++ snprintf(strspeed, sizeof(strspeed), "%d", baud_rate);
++ strlcpy(strlocal, llv6_ntoa(ipv6cp_gotoptions[0].ourid), sizeof(strlocal));
++ strlcpy(strremote, llv6_ntoa(ipv6cp_hisoptions[0].hisid),
++ sizeof(strremote));
+
+ argv[0] = script;
+ argv[1] = ifname;
+@@ -1559,3 +1568,4 @@ ipv6_active_pkt(pkt, len)
+ return 0;
+ return 1;
+ }
++#endif
diff --git a/net/pppd/patches/patch-ar b/net/pppd/patches/patch-ar
new file mode 100644
index 00000000000..4a159e7616c
--- /dev/null
+++ b/net/pppd/patches/patch-ar
@@ -0,0 +1,82 @@
+$NetBSD: patch-ar,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/lcp.c.orig 2004-11-13 03:28:15.000000000 +0100
++++ pppd/lcp.c
+@@ -193,6 +193,18 @@ lcp_options lcp_gotoptions[NUM_PPP]; /*
+ lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
+ lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */
+
++/* Hook for LCP up */
++void (*lcp_up_hook) __P((void)) = NULL;
++
++/* Hook for LCP down */
++void (*lcp_down_hook) __P((void)) = NULL;
++
++/* Hook for sending an LCP echo request, argument is pending count */
++void (*lcp_echo_hook) __P((int)) = NULL;
++
++/* Hook for receiving an LCP echo reply, argument is whether it's ours */
++void (*lcp_echoreply_hook) __P((int)) = NULL;
++
+ static int lcp_echos_pending = 0; /* Number of outstanding echo msgs */
+ static int lcp_echo_number = 0; /* ID number of next echo frame */
+ static int lcp_echo_timer_running = 0; /* set if a timer is running */
+@@ -1907,6 +1919,8 @@ lcp_up(f)
+ if (ho->neg_mru)
+ peer_mru[f->unit] = ho->mru;
+
++ if (lcp_up_hook) (*lcp_up_hook)();
++
+ lcp_echo_lowerup(f->unit); /* Enable echo messages */
+
+ link_established(f->unit);
+@@ -1928,6 +1942,8 @@ lcp_down(f)
+
+ link_down(f->unit);
+
++ if (lcp_down_hook) (*lcp_down_hook)();
++
+ ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0);
+ ppp_recv_config(f->unit, PPP_MRU,
+ (go->neg_asyncmap? go->asyncmap: 0xffffffff),
+@@ -2260,8 +2276,10 @@ lcp_received_echo_reply (f, id, inp, len
+ if (lcp_gotoptions[f->unit].neg_magicnumber
+ && magic == lcp_gotoptions[f->unit].magicnumber) {
+ warn("appear to have received our own echo-reply!");
++ if (lcp_echoreply_hook) (*lcp_echoreply_hook)(1);
+ return;
+ }
++ if (lcp_echoreply_hook) (*lcp_echoreply_hook)(0);
+
+ /* Reset the number of outstanding echo frames */
+ lcp_echos_pending = 0;
+@@ -2278,6 +2296,9 @@ LcpSendEchoRequest (f)
+ u_int32_t lcp_magic;
+ u_char pkt[4], *pktp;
+
++ if (f->state != OPENED)
++ return;
++
+ /*
+ * Detect the failure of the peer at this point.
+ */
+@@ -2291,13 +2312,12 @@ LcpSendEchoRequest (f)
+ /*
+ * Make and send the echo request frame.
+ */
+- if (f->state == OPENED) {
+- lcp_magic = lcp_gotoptions[f->unit].magicnumber;
+- pktp = pkt;
+- PUTLONG(lcp_magic, pktp);
+- fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
+- ++lcp_echos_pending;
+- }
++ if (lcp_echo_hook) (*lcp_echo_hook)(lcp_echos_pending);
++ lcp_magic = lcp_gotoptions[f->unit].magicnumber;
++ pktp = pkt;
++ PUTLONG(lcp_magic, pktp);
++ fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
++ ++lcp_echos_pending;
+ }
+
+ /*
diff --git a/net/pppd/patches/patch-as b/net/pppd/patches/patch-as
new file mode 100644
index 00000000000..e0fc8ba8f1b
--- /dev/null
+++ b/net/pppd/patches/patch-as
@@ -0,0 +1,30 @@
+$NetBSD: patch-as,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/main.c.orig 2004-11-13 13:05:48.000000000 +0100
++++ pppd/main.c
+@@ -232,6 +232,7 @@ static void create_pidfile __P((int pid)
+ static void create_linkpidfile __P((int pid));
+ static void cleanup __P((void));
+ static void get_input __P((void));
++static const char *protocol_name __P((int));
+ static void calltimeout __P((void));
+ static struct timeval *timeleft __P((struct timeval *));
+ static void kill_my_pg __P((int));
+@@ -933,7 +934,7 @@ struct protocol_list {
+ /*
+ * protocol_name - find a name for a PPP protocol.
+ */
+-const char *
++static const char *
+ protocol_name(proto)
+ int proto;
+ {
+@@ -1660,7 +1661,7 @@ run_program(prog, args, must_exist, done
+ syslog(LOG_ERR, "Can't execute %s: %m", prog);
+ closelog();
+ }
+- _exit(-1);
++ _exit(1);
+ }
+
+
diff --git a/net/pppd/patches/patch-at b/net/pppd/patches/patch-at
new file mode 100644
index 00000000000..ac52f25a4d4
--- /dev/null
+++ b/net/pppd/patches/patch-at
@@ -0,0 +1,13 @@
+$NetBSD: patch-at,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/multilink.c.orig 2004-11-13 09:57:36.000000000 +0100
++++ pppd/multilink.c
+@@ -570,7 +570,7 @@ str_to_epdisc(ep, str)
+ if (*str == 0)
+ break;
+ if (p <= str)
+- for (p = str; isxdigit(*p); ++p)
++ for (p = str; isxdigit((unsigned char)*p); ++p)
+ ;
+ i = p - str;
+ if (i == 0)
diff --git a/net/pppd/patches/patch-au b/net/pppd/patches/patch-au
new file mode 100644
index 00000000000..8707b986869
--- /dev/null
+++ b/net/pppd/patches/patch-au
@@ -0,0 +1,273 @@
+$NetBSD: patch-au,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/options.c.orig 2004-11-09 23:33:35.000000000 +0100
++++ pppd/options.c
+@@ -126,8 +126,13 @@ extern option_t auth_options[];
+ extern struct stat devstat;
+
+ #ifdef PPP_FILTER
+-struct bpf_program pass_filter;/* Filter program for packets to pass */
+-struct bpf_program active_filter; /* Filter program for link-active pkts */
++/* Filter program for packets to pass */
++struct bpf_program pass_filter_in;
++struct bpf_program pass_filter_out;
++
++/* Filter program for link-active packets */
++struct bpf_program active_filter_in;
++struct bpf_program active_filter_out;
+ #endif
+
+ char *current_option; /* the name of the option being parsed */
+@@ -154,18 +159,25 @@ static int loadplugin __P((char **));
+ #endif
+
+ #ifdef PPP_FILTER
+-static int setpassfilter __P((char **));
+-static int setactivefilter __P((char **));
++static int setpassfilter_in __P((char **));
++static int setpassfilter_out __P((char **));
++static int setactivefilter_in __P((char **));
++static int setactivefilter_out __P((char **));
+ #endif
+
+ #ifdef MAXOCTETS
+ static int setmodir __P((char **));
+ #endif
+
++static int match_option __P((const char *, option_t *, int));
+ static option_t *find_option __P((const char *name));
+ static int process_option __P((option_t *, char *, char **));
+ static int n_arguments __P((option_t *));
+ static int number_option __P((char *, u_int32_t *, int));
++static void print_option __P((option_t *, option_t *, void (*)(void *, char *,
++ ...), void *));
++static void print_option_list __P((option_t *, void (*)(void *, char *, ...),
++ void *));
+
+ /*
+ * Structure to store extra lists of options.
+@@ -296,11 +308,15 @@ option_t general_options[] = {
+ #endif
+
+ #ifdef PPP_FILTER
+- { "pass-filter", 1, setpassfilter,
+- "set filter for packets to pass", OPT_PRIO },
+-
+- { "active-filter", 1, setactivefilter,
+- "set filter for active pkts", OPT_PRIO },
++ { "pass-filter-in", 1, setpassfilter_in,
++ "set filter for packets to pass inwards", OPT_PRIO },
++ { "pass-filter-out", 1, setpassfilter_out,
++ "set filter for packets to pass outwards", OPT_PRIO },
++
++ { "active-filter-in", 1, setactivefilter_in,
++ "set filter for active pkts inwards", OPT_PRIO },
++ { "active-filter-out", 1, setactivefilter_out,
++ "set filter for active pkts outwards", OPT_PRIO },
+ #endif
+
+ #ifdef MAXOCTETS
+@@ -323,7 +339,7 @@ option_t general_options[] = {
+ #define IMPLEMENTATION ""
+ #endif
+
+-static char *usage_string = "\
++static const char usage_string[] = "\
+ pppd version %s\n\
+ Usage: %s [ options ], where options are:\n\
+ <device> Communicate over the named device\n\
+@@ -334,6 +350,7 @@ Usage: %s [ options ], where options are
+ auth Require authentication from peer\n\
+ connect <p> Invoke shell command <p> to set up the serial line\n\
+ crtscts Use hardware RTS/CTS flow control\n\
++ cdtrcts Use hardware DTR/CTS flow control (if supported)\n\
+ defaultroute Add default route through interface\n\
+ file <f> Take options from file <f>\n\
+ modem Use modem control lines\n\
+@@ -564,17 +581,17 @@ err:
+ */
+ static int
+ match_option(name, opt, dowild)
+- char *name;
++ const char *name;
+ option_t *opt;
+ int dowild;
+ {
+- int (*match) __P((char *, char **, int));
++ int (*match) __P((const char *, char **, int));
+
+ if (dowild != (opt->type == o_wild))
+ return 0;
+ if (!dowild)
+ return strcmp(name, opt->name) == 0;
+- match = (int (*) __P((char *, char **, int))) opt->addr;
++ match = (int (*) __P((const char *, char **, int))) opt->addr;
+ return (*match)(name, NULL, 0);
+ }
+
+@@ -766,7 +783,7 @@ process_option(opt, cmd, argv)
+
+ ovp = malloc(sizeof(*ovp) + strlen(*argv));
+ if (ovp != 0) {
+- strcpy(ovp->value, *argv);
++ strlcpy(ovp->value, *argv, sizeof(ovp->value));
+ ovp->source = option_source;
+ ovp->next = NULL;
+ pp = (struct option_value **) &opt->addr2;
+@@ -909,7 +926,7 @@ print_option(opt, mainopt, printer, arg)
+
+ case o_string:
+ if (opt->flags & OPT_HIDE) {
+- p = "??????";
++ p = "\?\?\?\?\?\?";
+ } else {
+ p = (char *) opt->addr;
+ if ((opt->flags & OPT_STATIC) == 0)
+@@ -1171,7 +1188,7 @@ getword(f, word, newlinep, filename)
+ /*
+ * A non-whitespace character is the start of a word.
+ */
+- if (!isspace(c))
++ if (!isspace((unsigned char)c))
+ break;
+ }
+
+@@ -1225,12 +1242,12 @@ getword(f, word, newlinep, filename)
+ break;
+
+ default:
+- if (isoctal(c)) {
++ if (isoctal((unsigned char)c)) {
+ /*
+ * \ddd octal sequence
+ */
+ value = 0;
+- for (n = 0; n < 3 && isoctal(c); ++n) {
++ for (n = 0; n < 3 && isoctal((unsigned char)c); ++n) {
+ value = (value << 3) + (c & 07);
+ c = getc(f);
+ }
+@@ -1244,7 +1261,7 @@ getword(f, word, newlinep, filename)
+ */
+ value = 0;
+ c = getc(f);
+- for (n = 0; n < 2 && isxdigit(c); ++n) {
++ for (n = 0; n < 2 && isxdigit((unsigned char)c); ++n) {
+ digit = toupper(c) - '0';
+ if (digit > 10)
+ digit += '0' + 10 - 'A';
+@@ -1282,7 +1299,7 @@ getword(f, word, newlinep, filename)
+ if (c == quoted)
+ break;
+ } else {
+- if (isspace(c) || c == '#') {
++ if (isspace((unsigned char)c) || c == '#') {
+ ungetc (c, f);
+ break;
+ }
+@@ -1440,18 +1457,60 @@ callfile(argv)
+
+ #ifdef PPP_FILTER
+ /*
+- * setpassfilter - Set the pass filter for packets
++ * setpassfilter_in - Set the pass filter for incoming packets
++ */
++static int
++setpassfilter_in(argv)
++ char **argv;
++{
++ pcap_t *pc;
++ int ret = 0;
++
++ pc = pcap_open_dead(DLT_PPP_WITH_DIRECTION, 65535);
++ if (pcap_compile(pc, &pass_filter_in, *argv, 1, netmask) == -1) {
++ option_error("error in pass-filter-in expression: %s\n",
++ pcap_geterr(pc));
++ ret = 1;
++ }
++ pcap_close(pc);
++
++ return ret;
++}
++
++/*
++ * setpassfilter_out - Set the pass filter for outgoing packets
++ */
++static int
++setpassfilter_out(argv)
++ char **argv;
++{
++ pcap_t *pc;
++ int ret = 0;
++
++ pc = pcap_open_dead(DLT_PPP_WITH_DIRECTION, 65535);
++ if (pcap_compile(pc, &pass_filter_out, *argv, 1, netmask) == -1) {
++ option_error("error in pass-filter-out expression: %s\n",
++ pcap_geterr(pc));
++ ret = 1;
++ }
++ pcap_close(pc);
++
++ return ret;
++}
++
++/*
++ * setactivefilter_in - Set the active filter for incoming packets
+ */
+ static int
+-setpassfilter(argv)
++setactivefilter_in(argv)
+ char **argv;
+ {
+ pcap_t *pc;
+ int ret = 0;
+
+ pc = pcap_open_dead(DLT_PPP_WITH_DIRECTION, 65535);
+- if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == -1) {
+- option_error("error in pass-filter expression: %s\n",
++ if (pcap_compile(pc, &active_filter_in, *argv, 1, netmask) == -1) {
++ option_error("error in active-filter-in expression: %s\n",
+ pcap_geterr(pc));
+ ret = 1;
+ }
+@@ -1461,18 +1520,18 @@ setpassfilter(argv)
+ }
+
+ /*
+- * setactivefilter - Set the active filter for packets
++ * setactivefilter_out - Set the active filter for outgoing packets
+ */
+ static int
+-setactivefilter(argv)
++setactivefilter_out(argv)
+ char **argv;
+ {
+ pcap_t *pc;
+ int ret = 0;
+
+ pc = pcap_open_dead(DLT_PPP_WITH_DIRECTION, 65535);
+- if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == -1) {
+- option_error("error in active-filter expression: %s\n",
++ if (pcap_compile(pc, &active_filter_out, *argv, 1, netmask) == -1) {
++ option_error("error in active-filter-out expression: %s\n",
+ pcap_geterr(pc));
+ ret = 1;
+ }
+@@ -1489,14 +1548,13 @@ static int
+ setdomain(argv)
+ char **argv;
+ {
+- gethostname(hostname, MAXNAMELEN);
++ gethostname(hostname, sizeof(hostname));
+ if (**argv != 0) {
+ if (**argv != '.')
+- strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
++ strlcat(hostname, ".", sizeof(hostname));
+ domain = hostname + strlen(hostname);
+- strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
++ strlcat(hostname, *argv, sizeof(hostname));
+ }
+- hostname[MAXNAMELEN-1] = 0;
+ return (1);
+ }
+
diff --git a/net/pppd/patches/patch-av b/net/pppd/patches/patch-av
new file mode 100644
index 00000000000..4fadf26fc76
--- /dev/null
+++ b/net/pppd/patches/patch-av
@@ -0,0 +1,13 @@
+$NetBSD: patch-av,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/plugins/radius/Makefile.linux.orig 2004-11-14 08:02:31.000000000 +0100
++++ pppd/plugins/radius/Makefile.linux
+@@ -4,7 +4,7 @@
+ #
+
+ DESTDIR = @DESTDIR@
+-MANDIR = $(DESTDIR)/share/man/man8
++MANDIR = $(DESTDIR)/man/man8
+ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
+
+ VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
diff --git a/net/pppd/patches/patch-aw b/net/pppd/patches/patch-aw
new file mode 100644
index 00000000000..f9a484d1083
--- /dev/null
+++ b/net/pppd/patches/patch-aw
@@ -0,0 +1,349 @@
+$NetBSD: patch-aw,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/pppd.8.orig 2004-11-13 13:22:49.000000000 +0100
++++ pppd/pppd.8
+@@ -57,6 +57,24 @@ for the serial device. On systems such
+ 4.4BSD and NetBSD, any speed can be specified. Other systems
+ (e.g. Linux, SunOS) only support the commonly-used baud rates.
+ .TP
++.B active-filter-in \fIfilter-expression
++.TP
++.B active-filter-out \fIfilter-expression
++Specifies an incoming and outgoing 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-dialing 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(8),
++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. This option
++is currently only available under NetBSD, and then only
++if both the kernel and pppd were compiled with PPP_FILTER defined.
++.TP
+ .B asyncmap \fImap
+ This option sets the Async-Control-Character-Map (ACCM) for this end
+ of the link. The ACCM is a set of 32 bits, one for each of the
+@@ -167,7 +185,7 @@ Note that for the IPv6 protocol, the MRU
+ Set the MTU [Maximum Transmit Unit] value to \fIn\fR. Unless the
+ peer requests a smaller value via MRU negotiation, pppd will
+ request that the kernel networking code send data packets of no more
+-than \fIn\fR bytes through the PPP network interface. Note that for
++than \fIn\fR bytes through the PPP network interface. Note that for
+ the IPv6 protocol, the MTU must be at least 1280.
+ .TP
+ .B passive
+@@ -177,11 +195,11 @@ peer, pppd will then just wait passively
+ the peer, instead of exiting, as it would without this option.
+ .SH OPTIONS
+ .TP
+-.I <local_IP_address>\fB:\fI<remote_IP_address>
++.I \*[Lt]local_IP_address\*[Gt]\fB:\fI\*[Lt]remote_IP_address\*[Gt]
+ Set the local and/or remote interface IP addresses. Either one may be
+ omitted. The IP addresses can be specified with a host name or in
+ decimal dot notation (e.g. 150.234.56.78). The default local
+-address is the (first) IP address of the system (unless the
++address is the (first) IP address of the hostname of the system (unless the
+ \fInoipdefault\fR
+ option is given). The remote address will be obtained from the peer
+ if not specified in any option. Thus, in simple cases, this option is
+@@ -191,7 +209,7 @@ will not accept a different value from t
+ negotiation, unless the \fIipcp\-accept\-local\fR and/or
+ \fIipcp\-accept\-remote\fR options are given, respectively.
+ .TP
+-.B ipv6 \fI<local_interface_identifier>\fR,\fI<remote_interface_identifier>
++.B ipv6 \fI\*[Lt]local_interface_identifier\*[Gt]\fR,\fI\*[Lt]remote_interface_identifier\*[Gt]
+ Set the local and/or remote 64-bit interface identifier. Either one may be
+ omitted. The identifier must be specified in standard ascii notation of
+ IPv6 addresses (e.g. ::dead:beef). If the
+@@ -199,18 +217,18 @@ IPv6 addresses (e.g. ::dead:beef). If th
+ option is given, the local identifier is the local IPv4 address (see above).
+ On systems which supports a unique persistent id, such as EUI\-48 derived
+ from the Ethernet MAC address, \fIipv6cp\-use\-persistent\fR option can be
+-used to replace the \fIipv6 <local>,<remote>\fR option. Otherwise the
++used to replace the \fIipv6 \*[Lt]local\*[Gt],\*[Lt]remote\*[Gt]\fR option. Otherwise the
+ identifier is randomized.
+ .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
++the idle timer, or cause the link to be brought up in demand-dialing
+ 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),
++The \fIfilter\-expression\fR syntax is as described for tcpdump(8),
+ 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
+@@ -243,6 +261,12 @@ Alternatively, a value of 0 for \fInr\fR
+ compression in the corresponding direction. Use \fInobsdcomp\fR or
+ \fIbsdcomp 0\fR to disable BSD-Compress compression entirely.
+ .TP
++.B callback \fIphone_number
++Request a call-back to the \fIphone-number\fR. This only works if the peer
++is speaking the Call Back Configuration Protocol. Don't put this into the
++main options file if you sometimes connect to servers that don't support
++it.
++.TP
+ .B cdtrcts
+ Use a non-standard hardware flow control (i.e. DTR/CTS) to control
+ the flow of data on the serial port. If neither the \fIcrtscts\fR,
+@@ -324,9 +348,9 @@ When this is completed, pppd will commen
+ (i.e., IP packets) across the link.
+
+ The \fIdemand\fR option implies the \fIpersist\fR option. If this
+-behaviour is not desired, use the \fInopersist\fR option after the
++behavior is not desired, use the \fInopersist\fR option after the
+ \fIdemand\fR option. The \fIidle\fR and \fIholdoff\fR
+-options are also useful in conjuction with the \fIdemand\fR option.
++options are also useful in conjunction with the \fIdemand\fR option.
+ .TP
+ .B domain \fId
+ Append the domain name \fId\fR to the local host name for authentication
+@@ -350,9 +374,9 @@ With the \fBdump\fR option, pppd will pr
+ which have been set. This option is like the \fBdryrun\fR option
+ except that pppd proceeds as normal rather than exiting.
+ .TP
+-.B endpoint \fI<epdisc>
++.B endpoint \fI\*[Lt]epdisc\*[Gt]
+ Sets the endpoint discriminator sent by the local machine to the peer
+-during multilink negotiation to \fI<epdisc>\fR. The default is to use
++during multilink negotiation to \fI\*[Lt]epdisc\*[Gt]\fR. The default is to use
+ the MAC address of the first ethernet interface on the system, if any,
+ otherwise the IPv4 address corresponding to the hostname, if any,
+ provided it is not in the multicast or locally-assigned IP address
+@@ -403,8 +427,8 @@ Specifies that pppd should disconnect if
+ seconds. The link is idle when no data packets (i.e. IP packets) are
+ being sent or received. Note: it is not advisable to use this option
+ with the \fIpersist\fR option without the \fIdemand\fR option.
+-If the \fBactive\-filter\fR
+-option is given, data packets which are rejected by the specified
++If the \fBactive\-filter-in\fR and/or \fBactive-filter-out\fR
++options are given, data packets which are rejected by the specified
+ activity filter also count as the link being idle.
+ .TP
+ .B ipcp\-accept\-local
+@@ -436,6 +460,23 @@ Provides an extra parameter to the ip\-u
+ option is given, the \fIstring\fR supplied is given as the 6th
+ parameter to those scripts.
+ .TP
++.B +ipv6
++Enable IPv6CP negotiation and IPv6 communication.
++It needs to be explicitly specified if you want IPv6CP.
++.TP
++.B -ipv6
++Disable IPv6CP negotiation and IPv6 communication.
++.TP
++.B ipv6cp-accept-local
++With this option, pppd will accept the peer's idea of our local IPv6
++address, even if the local IPv6 address was specified in an option.
++.TP
++.B ipv6cp-use-ipaddr
++Use the local IPv4 address as the local interface address.
++.TP
++.B ipv6cp-use-persistent
++Use uniquely-available persistent value for link local address (Solaris 2 only).
++.TP
+ .B ipv6cp\-max\-configure \fIn
+ Set the maximum number of IPv6CP configure-request transmissions to
+ \fIn\fR (default 10).
+@@ -473,7 +514,7 @@ numbers on the ipx\-network must be uniq
+ default. If this option is not specified then the node numbers are
+ obtained from the peer.
+ .TP
+-.B ipx\-router\-name \fI<string>
++.B ipx\-router\-name \fI\*[Lt]string\*[Gt]
+ Set the name of the router. This is a string and is sent to the peer
+ as information data.
+ .TP
+@@ -512,7 +553,7 @@ Set the maximum number of IPXCP NAK fram
+ send before it rejects the options. The default value is 3.
+ .TP
+ .B ipxcp\-max\-terminate \fIn
+-Set the maximum nuber of IPXCP terminate request frames before the
++Set the maximum number of IPXCP terminate request frames before the
+ local system considers that the peer is not listening to them. The
+ default value is 3.
+ .TP
+@@ -526,7 +567,7 @@ bits: 1 to
+ enable general debug messages, 2 to request that the contents of
+ received packets be printed, and 4 to request that the contents of
+ transmitted packets be printed. On most systems, messages printed by
+-the kernel are logged by syslog(1) to a file as directed in the
++the kernel are logged by syslogd(8) to a file as directed in the
+ /etc/syslog.conf configuration file.
+ .TP
+ .B ktune
+@@ -615,7 +656,7 @@ option, pppd will wait for the CD (Carri
+ modem to be asserted when opening the serial device (unless a connect
+ script is specified), and it will drop the DTR (Data Terminal Ready)
+ signal briefly when the connection is terminated and before executing
+-the connect script. On Ultrix, this option implies hardware flow
++the connect script. On ULTRIX, this option implies hardware flow
+ control, as for the \fIcrtscts\fR option.
+ .TP
+ .B mp
+@@ -639,7 +680,7 @@ analogous to the MRU for the individual
+ currently only available under Linux, and only has any effect if
+ multilink is enabled (see the multilink option).
+ .TP
+-.B ms\-dns \fI<addr>
++.B ms\-dns \fI\*[Lt]addr\*[Gt]
+ If pppd is acting as a server for Microsoft Windows clients, this
+ option allows pppd to supply one or two DNS (Domain Name Server)
+ addresses to the clients. The first instance of this option specifies
+@@ -647,7 +688,7 @@ the primary DNS address; the second inst
+ secondary DNS address. (This option was present in some older
+ versions of pppd under the name \fBdns\-addr\fR.)
+ .TP
+-.B ms\-wins \fI<addr>
++.B ms\-wins \fI\*[Lt]addr\*[Gt]
+ If pppd is acting as a server for Microsoft Windows or "Samba"
+ clients, this option allows pppd to supply one or two WINS (Windows
+ Internet Name Services) server addresses to the clients. The first
+@@ -724,12 +765,11 @@ only be required if the peer is buggy an
+ from pppd for IPCP negotiation.
+ .TP
+ .B noipv6
+-Disable IPv6CP negotiation and IPv6 communication. This option should
+-only be required if the peer is buggy and gets confused by requests
+-from pppd for IPv6CP negotiation.
++An alias for
++.B -ipv6.
+ .TP
+ .B noipdefault
+-Disables the default behaviour when no local IP address is specified,
++Disables the default behavior when no local IP address is specified,
+ which is to determine (if possible) the local IP address from the
+ hostname. With this option, the peer will have to supply the local IP
+ address during IPCP negotiation (unless it specified explicitly on the
+@@ -837,22 +877,25 @@ seconds (default 3).
+ Set the maximum time that pppd will wait for the peer to authenticate
+ itself with PAP to \fIn\fR 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 prevent specific network daemons (such as
+-routed) using up link bandwidth, or to provide a very basic firewall
++.B pass-filter-in \fIfilter-expression
++.TP
++.B pass-filter-out \fIfilter-expression
++Specifies an incoming and outgoing 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 prevent specific network daemons
++(such as routed) using up link bandwidth, or to provide a basic firewall
+ capability.
+-The \fIfilter\-expression\fR syntax is as described for tcpdump(1),
++The \fIfilter-expression\fR syntax is as described for tcpdump(8),
+ 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. This
+-option is currently only available under Linux, and requires that the
+-kernel was configured to include PPP filtering support (CONFIG_PPP_FILTER).
++option is currently only available under Linux and NetBSD, and requires
++that the kernel was configured to include PPP filtering support
++(CONFIG_PPP_FILTER in Linux, PPP_FILTER in NetBSD).
+ .TP
+ .B password \fIpassword\-string
+ Specifies the password to use for authenticating to the peer. Use
+@@ -897,7 +940,7 @@ pseudo-tty master/slave pair and use the
+ device. The \fIscript\fR will be run in a child process with the
+ pseudo-tty master as its standard input and output. An explicit
+ device name may not be given if this option is used. (Note: if the
+-\fIrecord\fR option is used in conjuction with the \fIpty\fR option,
++\fIrecord\fR option is used in conjunction with the \fIpty\fR option,
+ the child process will have pipes on its standard input and output.)
+ .TP
+ .B receive\-all
+@@ -1085,7 +1128,7 @@ those which permit potentially insecure
+ are only accepted in files which are under the control of the system
+ administrator, or if pppd is being run by root.
+ .PP
+-The default behaviour of pppd is to allow an unauthenticated peer to
++The default behavior of pppd is to allow an unauthenticated peer to
+ use a given IP address only if the system does not already have a
+ route to that IP address. For example, a system with a
+ permanent connection to the wider internet will normally have a
+@@ -1148,7 +1191,7 @@ independent authentication exchanges wil
+ could use different authentication protocols, and in principle,
+ different names could be used in the two exchanges.
+ .LP
+-The default behaviour of pppd is to agree to authenticate if
++The default behavior of pppd is to agree to authenticate if
+ requested, and to not require authentication from the peer. However,
+ pppd will not agree to authenticate itself with a particular protocol
+ if it has no secrets which could be used to do so.
+@@ -1289,7 +1332,7 @@ been able to negotiate the same addresse
+ the interface (for example when the peer is an ISP that uses dynamic
+ IP address assignment), pppd has to change the interface IP addresses
+ to the negotiated addresses. This may disrupt existing connections,
+-and the use of demand dialling with peers that do dynamic IP address
++and the use of demand dialing with peers that do dynamic IP address
+ assignment is not recommended.
+ .SH MULTILINK
+ Multilink PPP provides the capability to combine two or more PPP links
+@@ -1356,7 +1399,7 @@ connect '/usr/sbin/chat \-v \-f /etc/ppp
+ noauth
+ .LP
+ In this example, we are using chat to dial the ISP's modem and go
+-through any logon sequence required. The /etc/ppp/chat\-isp file
++through any log on sequence required. The /etc/ppp/chat\-isp file
+ contains the script used by chat; it could for example contain
+ something like this:
+ .IP
+@@ -1374,7 +1417,7 @@ ABORT "Username/Password Incorrect"
+ .br
+ "" "at"
+ .br
+-OK "at&d0&c1"
++OK "at\*[Am]d0\*[Am]c1"
+ .br
+ OK "atdt2468135"
+ .br
+@@ -1617,7 +1660,7 @@ invoked in the same manner and with the
+ script.
+ .TP
+ .B /etc/ppp/ipv6\-up
+-Like /etc/ppp/ip\-up, except that it is executed when the link is available
++Like /etc/ppp/ip\-up, except that it is executed when the link is available
+ for sending and receiving IPv6 packets. It is executed with the parameters
+ .IP
+ \fIinterface\-name tty\-device speed local\-link\-local\-address
+@@ -1625,7 +1668,7 @@ remote\-link\-local\-address ipparam\fR
+ .TP
+ .B /etc/ppp/ipv6\-down
+ Similar to /etc/ppp/ip\-down, but it is executed when IPv6 packets can no
+-longer be transmitted on the link. It is executed with the same parameters
++longer be transmitted on the link. It is executed with the same parameters
+ as the ipv6\-up script.
+ .TP
+ .B /etc/ppp/ipx\-up
+@@ -1635,7 +1678,7 @@ executed with the parameters
+ .IP
+ \fIinterface\-name tty\-device speed network\-number local\-IPX\-node\-address
+ remote\-IPX\-node\-address local\-IPX\-routing\-protocol remote\-IPX\-routing\-protocol
+-local\-IPX\-router\-name remote\-IPX\-router\-name ipparam pppd\-pid\fR
++local\-IPX\-router\-name remote\-IPX\-router\-name ipparam pppd\-pid\fR
+ .IP
+ The local\-IPX\-routing\-protocol and remote\-IPX\-routing\-protocol field
+ may be one of the following:
+@@ -1786,7 +1829,6 @@ This signal causes pppd to renegotiate c
+ useful to re-enable compression after it has been disabled as a result
+ of a fatal decompression error. (Fatal decompression errors generally
+ indicate a bug in one or other implementation.)
+-
+ .SH AUTHORS
+ Paul Mackerras (paulus@samba.org), based on earlier work by
+ Drew Perkins,
diff --git a/net/pppd/patches/patch-ax b/net/pppd/patches/patch-ax
new file mode 100644
index 00000000000..1bae7c6f768
--- /dev/null
+++ b/net/pppd/patches/patch-ax
@@ -0,0 +1,61 @@
+$NetBSD: patch-ax,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
+
+--- pppd/pppd.h.orig 2004-11-13 13:02:22.000000000 +0100
++++ pppd/pppd.h
+@@ -213,7 +213,7 @@ struct notifier {
+ extern int hungup; /* Physical layer has disconnected */
+ extern int ifunit; /* Interface unit number */
+ extern char ifname[]; /* Interface name */
+-extern char hostname[]; /* Our hostname */
++extern char hostname[MAXNAMELEN]; /* Our hostname */
+ extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
+ extern int devfd; /* fd of underlying device */
+ extern int fd_ppp; /* fd for talking PPP */
+@@ -336,8 +336,13 @@ extern int maxoctets_timeout; /*
+ #endif
+
+ #ifdef PPP_FILTER
+-extern struct bpf_program pass_filter; /* Filter for pkts to pass */
+-extern struct bpf_program active_filter; /* Filter for link-active pkts */
++/* Filter for packets to pass */
++extern struct bpf_program pass_filter_in;
++extern struct bpf_program pass_filter_out;
++
++/* Filter for link-active packets */
++extern struct bpf_program active_filter_in;
++extern struct bpf_program active_filter_out;
+ #endif
+
+ #ifdef MSLANMAN
+@@ -506,8 +511,10 @@ void print_string __P((char *, int, voi
+ void *)); /* Format a string for output */
+ int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
+ int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
++#ifndef HAS_STRLFUNCS
+ size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
+ size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
++#endif
+ void dbglog __P((char *, ...)); /* log a debug message */
+ void info __P((char *, ...)); /* log an informational message */
+ void notice __P((char *, ...)); /* log a notice-level message */
+@@ -657,7 +664,8 @@ void logwtmp __P((const char *, const ch
+ int get_host_seed __P((void)); /* Get host-dependent random number seed */
+ int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
+ #ifdef PPP_FILTER
+-int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
++int set_filters __P((struct bpf_program *pass_in, struct bpf_program *pass_out,
++ struct bpf_program *active_in, struct bpf_program *active_out));
+ /* Set filter programs in kernel */
+ #endif
+ #ifdef IPX_CHANGE
+@@ -709,6 +717,10 @@ extern int (*allowed_address_hook) __P((
+ extern void (*ip_up_hook) __P((void));
+ extern void (*ip_down_hook) __P((void));
+ extern void (*ip_choose_hook) __P((u_int32_t *));
++void (*lcp_up_hook) __P((void));
++void (*lcp_down_hook) __P((void));
++void (*lcp_echo_hook) __P((int));
++void (*lcp_echoreply_hook) __P((int));
+
+ extern int (*chap_check_hook) __P((void));
+ extern int (*chap_passwd_hook) __P((char *user, char *passwd));
diff --git a/net/pppd/patches/patch-ay b/net/pppd/patches/patch-ay
new file mode 100644
index 00000000000..77086826efd
--- /dev/null
+++ b/net/pppd/patches/patch-ay
@@ -0,0 +1,12 @@
+$NetBSD: patch-ay,v 1.1.1.1 2005/01/02 02:51:43 cube Exp $
+
+--- pppd/sha1.c.orig 2004-10-25 01:28:02.000000000 +0200
++++ pppd/sha1.c
+@@ -16,6 +16,7 @@
+
+ /* #define SHA1HANDSOFF * Copies data before messing with it. */
+
++#include <sys/types.h>
+ #include <string.h>
+ #include <netinet/in.h> /* htonl() */
+ #include "sha1.h"
diff --git a/net/pppd/patches/patch-az b/net/pppd/patches/patch-az
new file mode 100644
index 00000000000..3e5d9c56ee8
--- /dev/null
+++ b/net/pppd/patches/patch-az
@@ -0,0 +1,2152 @@
+$NetBSD: patch-az,v 1.1.1.1 2005/01/02 02:51:43 cube Exp $
+
+--- pppd/sys-bsd.c.orig 2004-12-31 23:51:00.000000000 +0100
++++ pppd/sys-bsd.c
+@@ -0,0 +1,2147 @@
++/* NetBSD: sys-bsd.c,v 1.49 2004/02/28 19:27:49 itojun Exp */
++
++/*
++ * sys-bsd.c - System-dependent procedures for setting up
++ * PPP interfaces on bsd-4.4-ish systems (including 386BSD, NetBSD, etc.)
++ *
++ * Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
++ * endorse or promote products derived from this software without
++ * prior written permission. For permission or any legal
++ * details, please contact
++ * Office of Technology Transfer
++ * Carnegie Mellon University
++ * 5000 Forbes Avenue
++ * Pittsburgh, PA 15213-3890
++ * (412) 268-4387, fax: (412) 268-7395
++ * tech-transfer@andrew.cmu.edu
++ *
++ * 4. Redistributions of any form whatsoever must retain the following
++ * acknowledgment:
++ * "This product includes software developed by Computing Services
++ * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
++ *
++ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
++ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
++ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
++ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
++ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
++ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ *
++ * Copyright (c) 1989-2002 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
++ * endorse or promote products derived from this software without
++ * prior written permission.
++ *
++ * 4. Redistributions of any form whatsoever must retain the following
++ * acknowledgment:
++ * "This product includes software developed by Paul Mackerras
++ * <paulus@samba.org>".
++ *
++ * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
++ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
++ * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
++ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
++ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
++ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#include <sys/cdefs.h>
++#ifndef lint
++#if 0
++#define RCSID "Id: sys-bsd.c,v 1.47 2000/04/13 12:04:23 paulus Exp "
++#else
++__RCSID("NetBSD: sys-bsd.c,v 1.49 2004/02/28 19:27:49 itojun Exp ");
++#endif
++#endif
++
++/*
++ * TODO:
++ */
++
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <termios.h>
++#include <signal.h>
++#include <vis.h>
++#include <sys/ioctl.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <sys/time.h>
++#include <sys/stat.h>
++#include <sys/param.h>
++#if defined(NetBSD1_2) || defined(__NetBSD_Version__)
++#include <util.h>
++#endif
++#ifdef PPP_FILTER
++#include <net/bpf.h>
++#endif
++
++#include <net/if.h>
++#include <net/ppp_defs.h>
++#include <net/if_ppp.h>
++#include <net/route.h>
++#include <net/if_dl.h>
++#include <netinet/in.h>
++#ifdef __KAME__
++#include <netinet6/in6_var.h>
++#include <netinet6/nd6.h>
++#endif
++#include <ifaddrs.h>
++
++#if RTM_VERSION >= 3
++#include <sys/param.h>
++#if defined(NetBSD) && (NetBSD >= 199703)
++#include <netinet/if_inarp.h>
++#else /* NetBSD 1.2D or later */
++#ifdef __FreeBSD__
++#include <netinet/if_ether.h>
++#else
++#include <net/if_ether.h>
++#endif
++#endif
++#endif
++
++#include "pppd.h"
++#include "fsm.h"
++#include "ipcp.h"
++
++#ifdef RCSID
++static const char rcsid[] = RCSID;
++#endif
++
++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 struct termios inittermios; /* Initial TTY termios */
++static struct winsize wsinfo; /* Initial window size info */
++
++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 sock_fd; /* socket for doing interface ioctls */
++#ifdef INET6
++static int sock6_fd = -1; /* socket for doing ipv6 interface ioctls */
++#endif /* INET6 */
++static int ttyfd = -1; /* the file descriptor of the tty */
++
++static fd_set in_fds; /* set of fds that wait_input waits for */
++static int max_in_fd; /* highest fd set in in_fds */
++
++static int if_is_up; /* the interface is currently up */
++static u_int32_t ifaddrs[2]; /* local and remote addresses we set */
++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 get_flags __P((int));
++static void set_flags __P((int, int));
++static int dodefaultroute __P((u_int32_t, int));
++static int get_ether_addr __P((u_int32_t, struct sockaddr_dl *));
++static void restore_loop(void); /* Transfer ppp unit back to loopback */
++
++
++/********************************************************************
++ *
++ * Functions to read and set the flags value in the device driver
++ */
++
++static int
++get_flags(fd)
++ int fd;
++{
++ int flags;
++
++ if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &flags) == -1)
++ fatal("ioctl(PPPIOCGFLAGS): %m");
++
++ SYSDEBUG((LOG_DEBUG, "get flags = %x\n", flags));
++ return flags;
++}
++
++/********************************************************************/
++
++static void
++set_flags(fd, flags)
++ int fd, flags;
++{
++ SYSDEBUG((LOG_DEBUG, "set flags = %x\n", flags));
++
++ if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &flags) == -1)
++ fatal("ioctl(PPPIOCSFLAGS, %x): %m", flags, errno);
++}
++
++/*
++ * sys_init - System-dependent initialization.
++ */
++void
++sys_init()
++{
++ /* Get an internet socket for doing socket ioctl's on. */
++ if ((sock_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
++ fatal("Couldn't create IP socket: %m");
++
++#ifdef INET6
++ if ((sock6_fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
++ /* check it at runtime */
++ sock6_fd = -1;
++ }
++#endif
++
++ FD_ZERO(&in_fds);
++ max_in_fd = 0;
++}
++
++/*
++ * 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) {
++ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++ if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) >= 0
++ && ((ifr.ifr_flags & IFF_UP) != 0)) {
++ ifr.ifr_flags &= ~IFF_UP;
++ ioctl(sock_fd, SIOCSIFFLAGS, &ifr);
++ }
++ }
++ if (ifaddrs[0] != 0)
++ cifaddr(0, ifaddrs[0], ifaddrs[1]);
++ if (default_route_gateway)
++ cifdefaultroute(0, 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(sock_fd);
++ if (loop_slave >= 0) {
++ close(loop_slave);
++ close(loop_master);
++ }
++}
++
++/*
++ * sys_check_options - check the options that the user specified
++ */
++int
++sys_check_options()
++{
++#ifndef CDTRCTS
++ if (crtscts == 2) {
++ warn("DTR/CTS flow control is not supported on this system");
++ return 0;
++ }
++#endif
++ return 1;
++}
++
++/*
++ * ppp_available - check whether the system has any ppp interfaces
++ * (in fact we check whether we can do an ioctl on ppp0).
++ */
++int
++ppp_available()
++{
++ int s, ok;
++ struct ifreq ifr;
++ extern char *no_ppp_msg;
++
++ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
++ return 1; /* can't tell */
++
++ strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
++ ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
++ close(s);
++
++#ifdef __NetBSD__
++ no_ppp_msg = "\
++This system lacks kernel support for PPP. To include PPP support\n\
++in the kernel, please read the ppp(4) manual page.\n";
++#else
++ no_ppp_msg = "\
++This system lacks kernel support for PPP. To include PPP support\n\
++in the kernel, please follow the steps detailed in the README.bsd\n\
++file in the ppp-2.2 distribution.\n";
++#endif
++ return ok;
++}
++
++/*
++ * tty_establish_ppp - Turn the serial port into a ppp interface.
++ */
++int
++tty_establish_ppp(fd)
++ int fd;
++{
++ int pppdisc = PPPDISC;
++ int x;
++ ttyfd = fd;
++
++ if (demand) {
++ /*
++ * Demand mode - prime the old ppp device to relinquish the unit.
++ */
++ if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0)
++ fatal("ioctl(transfer ppp unit): %m");
++ }
++
++ /*
++ * Save the old line discipline of fd, and set it to PPP.
++ */
++ if (ioctl(fd, TIOCGETD, &initdisc) < 0)
++ fatal("ioctl(TIOCGETD): %m");
++ if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
++ fatal("ioctl(TIOCSETD): %m");
++
++ if (!demand) {
++ /*
++ * Find out which interface we were given.
++ */
++ if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0)
++ fatal("ioctl(PPPIOCGUNIT): %m");
++ } else {
++ /*
++ * Check that we got the same unit again.
++ */
++ if (ioctl(fd, PPPIOCGUNIT, &x) < 0)
++ fatal("ioctl(PPPIOCGUNIT): %m");
++ if (x != ifunit)
++ fatal("transfer_ppp failed: wanted unit %d, got %d", ifunit, x);
++ x = TTYDISC;
++ ioctl(loop_slave, TIOCSETD, &x);
++ }
++
++ ppp_fd = fd;
++
++ /*
++ * Enable debug in the driver if requested.
++ */
++ if (kdebugflag) {
++ x = get_flags(fd);
++ x |= (kdebugflag & 0xFF) * SC_DEBUG;
++ set_flags(fd, x);
++ }
++
++ /*
++ * Set device for non-blocking reads.
++ */
++ if ((initfdflags = fcntl(fd, F_GETFL)) == -1
++ || fcntl(fd, F_SETFL, initfdflags | O_NONBLOCK) == -1) {
++ warn("Couldn't set device to non-blocking mode: %m");
++ }
++
++ return fd;
++}
++
++/*
++ * restore_loop - reattach the ppp unit to the loopback.
++ */
++static void
++restore_loop()
++{
++ int x;
++
++ /*
++ * Transfer the ppp interface back to the loopback.
++ */
++ if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0)
++ fatal("ioctl(transfer ppp unit): %m");
++ x = PPPDISC;
++ if (ioctl(loop_slave, TIOCSETD, &x) < 0)
++ fatal("ioctl(TIOCSETD): %m");
++
++ /*
++ * Check that we got the same unit again.
++ */
++ if (ioctl(loop_slave, PPPIOCGUNIT, &x) < 0)
++ fatal("ioctl(PPPIOCGUNIT): %m");
++ if (x != ifunit)
++ fatal("transfer_ppp failed: wanted unit %d, got %d", ifunit, x);
++ ppp_fd = loop_slave;
++}
++
++
++/*
++ * Determine if the PPP connection should still be present.
++ */
++extern int hungup;
++
++/*
++ * tty_disestablish_ppp - Restore the serial port to normal operation.
++ * and reconnect the ppp unit to the loopback if in demand mode.
++ * This shouldn't call die() because it's called from die().
++ */
++void
++tty_disestablish_ppp(fd)
++ int fd;
++{
++ if (demand)
++ restore_loop();
++
++ if (!hungup) {
++
++
++ /* Flush the tty output buffer so that the TIOCSETD doesn't hang. */
++ if (tcflush(fd, TCIOFLUSH) < 0)
++ warn("tcflush failed: %m");
++
++ /* Restore old line discipline. */
++ if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) < 0)
++ error("ioctl(TIOCSETD): %m");
++ initdisc = -1;
++
++ /* Reset non-blocking mode on fd. */
++ if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
++ warn("Couldn't restore device fd flags: %m");
++ }
++ initfdflags = -1;
++
++ if (fd == ppp_fd)
++ ppp_fd = -1;
++}
++
++/*
++ * cfg_bundle - configure the existing bundle.
++ * Used in demand mode.
++ */
++void
++cfg_bundle(mrru, mtru, rssn, tssn)
++ int mrru, mtru, rssn, tssn;
++{
++ abort();
++#ifdef notyet
++ int flags;
++ struct ifreq ifr;
++
++ if (!new_style_driver)
++ return;
++
++ /* set the mrru, mtu and flags */
++ if (ioctl(ppp_dev_fd, PPPIOCSMRRU, &mrru) < 0)
++ error("Couldn't set MRRU: %m");
++ flags = get_flags(ppp_dev_fd);
++ flags &= ~(SC_MP_SHORTSEQ | SC_MP_XSHORTSEQ);
++ flags |= (rssn? SC_MP_SHORTSEQ: 0) | (tssn? SC_MP_XSHORTSEQ: 0)
++ | (mrru? SC_MULTILINK: 0);
++
++ set_flags(ppp_dev_fd, flags);
++
++ /* connect up the channel */
++ if (ioctl(ppp_fd, PPPIOCCONNECT, &ifunit) < 0)
++ fatal("Couldn't attach to PPP unit %d: %m", ifunit);
++ add_fd(ppp_dev_fd);
++#endif
++}
++
++/*
++ * make_new_bundle - create a new PPP unit (i.e. a bundle)
++ * and connect our channel to it. This should only get called
++ * if `multilink' was set at the time establish_ppp was called.
++ * In demand mode this uses our existing bundle instead of making
++ * a new one.
++ */
++void
++make_new_bundle(mrru, mtru, rssn, tssn)
++ int mrru, mtru, rssn, tssn;
++{
++ abort();
++#ifdef notyet
++ if (!new_style_driver)
++ return;
++
++ /* make us a ppp unit */
++ if (make_ppp_unit() < 0)
++ die(1);
++
++ /* set the mrru, mtu and flags */
++ cfg_bundle(mrru, mtru, rssn, tssn);
++#endif
++}
++
++/*
++ * bundle_attach - attach our link to a given PPP unit.
++ * We assume the unit is controlled by another pppd.
++ */
++int
++bundle_attach(ifnum)
++ int ifnum;
++{
++ abort();
++#ifdef notyet
++ if (!new_style_driver)
++ return -1;
++
++ if (ioctl(ppp_dev_fd, PPPIOCATTACH, &ifnum) < 0) {
++ if (errno == ENXIO)
++ return 0; /* doesn't still exist */
++ fatal("Couldn't attach to interface unit %d: %m\n", ifnum);
++ }
++ if (ioctl(ppp_fd, PPPIOCCONNECT, &ifnum) < 0)
++ fatal("Couldn't connect to interface unit %d: %m", ifnum);
++ set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) | SC_MULTILINK);
++
++ ifunit = ifnum;
++#endif
++ return 1;
++}
++
++/*
++ * destroy_bundle - tell the driver to destroy our bundle.
++ */
++void destroy_bundle(void)
++{
++#if notyet
++ if (ppp_dev_fd >= 0) {
++ close(ppp_dev_fd);
++ remove_fd(ppp_dev_fd);
++ ppp_dev_fd = -1;
++ }
++#endif
++}
++
++
++/*
++ * Check whether the link seems not to be 8-bit clean.
++ */
++void
++clean_check()
++{
++ int x;
++ char *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) {
++ struct ppp_rawin win;
++ char buf[4 * sizeof(win.buf) + 1];
++ int i;
++ warn("Serial link is not 8-bit clean:");
++ warn("All received characters had %s", s);
++ if (ioctl(ppp_fd, PPPIOCGRAWIN, &win) == -1) {
++ warn("ioctl(PPPIOCGRAWIN): %s", strerror(errno));
++ return;
++ }
++ for (i = 0; i < sizeof(win.buf); i++)
++ win.buf[i] = win.buf[i] & 0x7f;
++ strvisx(buf, (char *)win.buf, win.count, VIS_CSTYLE);
++ warn("Last %d characters were: %s", (int)win.count, buf);
++ }
++ }
++}
++
++/*
++ * 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
++ * regardless of whether the modem option was specified.
++ *
++ * For *BSD, we assume that speed_t values numerically equal bits/second.
++ */
++void
++set_up_tty(fd, local)
++ int fd, local;
++{
++ struct termios tios;
++
++ if (tcgetattr(fd, &tios) < 0)
++ fatal("tcgetattr: %m");
++
++ if (!restore_term) {
++ inittermios = tios;
++ ioctl(fd, TIOCGWINSZ, &wsinfo);
++ }
++
++ tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
++ if (crtscts > 0 && !local) {
++ if (crtscts == 2) {
++#ifdef CDTRCTS
++ tios.c_cflag |= CDTRCTS;
++#endif
++ } else
++ tios.c_cflag |= CRTSCTS;
++ } else if (crtscts < 0) {
++ tios.c_cflag &= ~CRTSCTS;
++#ifdef CDTRCTS
++ tios.c_cflag &= ~CDTRCTS;
++#endif
++ }
++
++ tios.c_cflag |= CS8 | CREAD | HUPCL;
++ if (local || !modem)
++ tios.c_cflag |= CLOCAL;
++ tios.c_iflag = IGNBRK | IGNPAR;
++ tios.c_oflag = 0;
++ tios.c_lflag = 0;
++ tios.c_cc[VMIN] = 1;
++ tios.c_cc[VTIME] = 0;
++
++ if (crtscts == -2) {
++ tios.c_iflag |= IXON | IXOFF;
++ tios.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
++ tios.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
++ }
++
++ if (inspeed) {
++ cfsetospeed(&tios, inspeed);
++ cfsetispeed(&tios, inspeed);
++ } else {
++ inspeed = cfgetospeed(&tios);
++ /*
++ * We can't proceed if the serial port speed is 0,
++ * since that implies that the serial port is disabled.
++ */
++ if (inspeed == 0)
++ fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
++ }
++ baud_rate = inspeed;
++
++ if (tcsetattr(fd, TCSAFLUSH, &tios) < 0)
++ fatal("tcsetattr: %m");
++
++ restore_term = 1;
++}
++
++/*
++ * restore_tty - restore the terminal to the saved settings.
++ */
++void
++restore_tty(fd)
++ int fd;
++{
++ if (restore_term) {
++ if (!default_device) {
++ /*
++ * Turn off echoing, because otherwise we can get into
++ * a loop with the tty and the modem echoing to each other.
++ * We presume we are the sole user of this tty device, so
++ * when we close it, it will revert to its defaults anyway.
++ */
++ inittermios.c_lflag &= ~(ECHO | ECHONL);
++ }
++ if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
++ if (errno != ENXIO)
++ warn("tcsetattr: %m");
++ ioctl(fd, TIOCSWINSZ, &wsinfo);
++ restore_term = 0;
++ }
++}
++
++/*
++ * 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;
++{
++ int modembits = TIOCM_DTR;
++
++ ioctl(fd, (on? TIOCMBIS: TIOCMBIC), &modembits);
++}
++
++#ifdef INET6
++/*
++ * sif6addr - Config the interface with an IPv6 link-local address
++ */
++int
++sif6addr(unit, our_eui64, his_eui64)
++ int unit;
++ eui64_t our_eui64, his_eui64;
++{
++#ifdef __KAME__
++ int ifindex;
++ struct in6_aliasreq addreq6;
++
++ if (sock6_fd < 0) {
++ fatal("No IPv6 socket available");
++ /*NOTREACHED*/
++ }
++
++ /* actually, this part is not kame local - RFC2553 conformant */
++ ifindex = if_nametoindex(ifname);
++ if (ifindex == 0) {
++ error("sifaddr6: no interface %s", ifname);
++ return 0;
++ }
++
++ memset(&addreq6, 0, sizeof(addreq6));
++ strlcpy(addreq6.ifra_name, ifname, sizeof(addreq6.ifra_name));
++
++ /* my addr */
++ addreq6.ifra_addr.sin6_family = AF_INET6;
++ addreq6.ifra_addr.sin6_len = sizeof(struct sockaddr_in6);
++ addreq6.ifra_addr.sin6_addr.s6_addr[0] = 0xfe;
++ addreq6.ifra_addr.sin6_addr.s6_addr[1] = 0x80;
++ memcpy(&addreq6.ifra_addr.sin6_addr.s6_addr[8], &our_eui64,
++ sizeof(our_eui64));
++ /* KAME ifindex hack */
++ *(u_int16_t *)&addreq6.ifra_addr.sin6_addr.s6_addr[2] = htons(ifindex);
++
++ /* his addr */
++ addreq6.ifra_dstaddr.sin6_family = AF_INET6;
++ addreq6.ifra_dstaddr.sin6_len = sizeof(struct sockaddr_in6);
++ addreq6.ifra_dstaddr.sin6_addr.s6_addr[0] = 0xfe;
++ addreq6.ifra_dstaddr.sin6_addr.s6_addr[1] = 0x80;
++ memcpy(&addreq6.ifra_dstaddr.sin6_addr.s6_addr[8], &his_eui64,
++ sizeof(our_eui64));
++ /* KAME ifindex hack */
++ *(u_int16_t *)&addreq6.ifra_dstaddr.sin6_addr.s6_addr[2] = htons(ifindex);
++
++ /* prefix mask: 128bit */
++ addreq6.ifra_prefixmask.sin6_family = AF_INET6;
++ addreq6.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6);
++ memset(&addreq6.ifra_prefixmask.sin6_addr, 0xff,
++ sizeof(addreq6.ifra_prefixmask.sin6_addr));
++
++ /* address lifetime (infty) */
++ addreq6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
++ addreq6.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME;
++
++ if (ioctl(sock6_fd, SIOCAIFADDR_IN6, &addreq6) < 0) {
++ error("sif6addr: ioctl(SIOCAIFADDR_IN6): %m");
++ return 0;
++ }
++
++ return 1;
++#else
++ struct in6_ifreq ifr6;
++ struct ifreq ifr;
++ struct in6_rtmsg rt6;
++
++ if (sock6_fd < 0) {
++ fatal("No IPv6 socket available");
++ /*NOTREACHED*/
++ }
++
++ memset(&ifr, 0, sizeof (ifr));
++ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++ if (ioctl(sock6_fd, SIOCGIFINDEX, (caddr_t) &ifr) < 0) {
++ error("sif6addr: ioctl(SIOCGIFINDEX): %m");
++ return 0;
++ }
++
++ /* Local interface */
++ memset(&ifr6, 0, sizeof(ifr6));
++ IN6_LLADDR_FROM_EUI64(ifr6.ifr6_addr, our_eui64);
++ ifr6.ifr6_ifindex = ifindex;
++ ifr6.ifr6_prefixlen = 10;
++
++ if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6) < 0) {
++ error("sif6addr: ioctl(SIOCSIFADDR): %m");
++ return 0;
++ }
++
++ /* Route to remote host */
++ memset(&rt6, 0, sizeof(rt6));
++ IN6_LLADDR_FROM_EUI64(rt6.rtmsg_dst, his_eui64);
++ rt6.rtmsg_flags = RTF_UP | RTF_HOST;
++ rt6.rtmsg_dst_len = 128;
++ rt6.rtmsg_ifindex = ifr.ifr_ifindex;
++ rt6.rtmsg_metric = 1;
++
++ if (ioctl(sock6_fd, SIOCADDRT, &rt6) < 0) {
++ error("sif6addr: ioctl(SIOCADDRT): %m");
++ return 0;
++ }
++
++ return 1;
++#endif
++}
++
++
++/*
++ * cif6addr - Remove IPv6 address from interface
++ */
++int
++cif6addr(unit, our_eui64, his_eui64)
++ int unit;
++ eui64_t our_eui64, his_eui64;
++{
++#ifdef __KAME__
++ int ifindex;
++ struct in6_ifreq delreq6;
++
++ if (sock6_fd < 0) {
++ fatal("No IPv6 socket available");
++ /*NOTREACHED*/
++ }
++
++ /* actually, this part is not kame local - RFC2553 conformant */
++ ifindex = if_nametoindex(ifname);
++ if (ifindex == 0) {
++ error("cifaddr6: no interface %s", ifname);
++ return 0;
++ }
++
++ memset(&delreq6, 0, sizeof(delreq6));
++ strlcpy(delreq6.ifr_name, ifname, sizeof(delreq6.ifr_name));
++
++ /* my addr */
++ delreq6.ifr_ifru.ifru_addr.sin6_family = AF_INET6;
++ delreq6.ifr_ifru.ifru_addr.sin6_len = sizeof(struct sockaddr_in6);
++ delreq6.ifr_ifru.ifru_addr.sin6_addr.s6_addr[0] = 0xfe;
++ delreq6.ifr_ifru.ifru_addr.sin6_addr.s6_addr[1] = 0x80;
++ memcpy(&delreq6.ifr_ifru.ifru_addr.sin6_addr.s6_addr[8], &our_eui64,
++ sizeof(our_eui64));
++ /* KAME ifindex hack */
++ *(u_int16_t *)&delreq6.ifr_ifru.ifru_addr.sin6_addr.s6_addr[2] =
++ htons(ifindex);
++
++ if (ioctl(sock6_fd, SIOCDIFADDR_IN6, &delreq6) < 0) {
++ error("cif6addr: ioctl(SIOCDIFADDR_IN6): %m");
++ return 0;
++ }
++
++ return 1;
++#else
++ struct ifreq ifr;
++ struct in6_ifreq ifr6;
++
++ if (sock6_fd < 0) {
++ fatal("No IPv6 socket available");
++ /*NOTREACHED*/
++ }
++
++ memset(&ifr, 0, sizeof(ifr));
++ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++ if (ioctl(sock6_fd, SIOCGIFINDEX, (caddr_t) &ifr) < 0) {
++ error("cif6addr: ioctl(SIOCGIFINDEX): %m");
++ return 0;
++ }
++
++ memset(&ifr6, 0, sizeof(ifr6));
++ IN6_LLADDR_FROM_EUI64(ifr6.ifr6_addr, our_eui64);
++ ifr6.ifr6_ifindex = ifr.ifr_ifindex;
++ ifr6.ifr6_prefixlen = 10;
++
++ if (ioctl(sock6_fd, SIOCDIFADDR, &ifr6) < 0) {
++ if (errno != EADDRNOTAVAIL) {
++ if (! ok_error (errno))
++ error("cif6addr: ioctl(SIOCDIFADDR): %m");
++ }
++ else {
++ warn("cif6addr: ioctl(SIOCDIFADDR): No such address");
++ }
++ return (0);
++ }
++ return 1;
++#endif
++}
++#endif /* INET6 */
++
++/*
++ * get_pty - get a pty master/slave pair and chown the slave side
++ * to the uid given. Assumes slave_name points to >= 12 bytes of space.
++ */
++int
++get_pty(master_fdp, slave_fdp, slave_name, uid)
++ int *master_fdp;
++ int *slave_fdp;
++ char *slave_name;
++ int uid;
++{
++ struct termios tios;
++
++ if (openpty(master_fdp, slave_fdp, slave_name, NULL, NULL) < 0)
++ return 0;
++
++ fchown(*slave_fdp, uid, -1);
++ fchmod(*slave_fdp, S_IRUSR | S_IWUSR);
++ if (tcgetattr(*slave_fdp, &tios) == 0) {
++ tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
++ tios.c_cflag |= CS8 | CREAD;
++ tios.c_iflag = IGNPAR | CLOCAL;
++ tios.c_oflag = 0;
++ tios.c_lflag = 0;
++ if (tcsetattr(*slave_fdp, TCSAFLUSH, &tios) < 0)
++ warn("couldn't set attributes on pty: %m");
++ } else
++ warn("couldn't get attributes on pty: %m");
++
++ return 1;
++}
++
++
++/*
++ * 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.
++ */
++int
++open_ppp_loopback()
++{
++ int flags;
++ struct termios tios;
++ int pppdisc = PPPDISC;
++
++ if (openpty(&loop_master, &loop_slave, loop_name, NULL, NULL) < 0)
++ fatal("No free pty for loopback");
++ SYSDEBUG(("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)
++ warn("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)
++ warn("couldn't set loopback to nonblock: %m");
++
++ ppp_fd = loop_slave;
++ if (ioctl(ppp_fd, TIOCSETD, &pppdisc) < 0)
++ fatal("ioctl(TIOCSETD): %m");
++
++ /*
++ * Find out which interface we were given.
++ */
++ if (ioctl(ppp_fd, PPPIOCGUNIT, &ifunit) < 0)
++ fatal("ioctl(PPPIOCGUNIT): %m");
++
++ /*
++ * Enable debug in the driver if requested.
++ */
++ if (kdebugflag) {
++ flags = get_flags(ppp_fd);
++ flags |= (kdebugflag & 0xFF) * SC_DEBUG;
++ set_flags(ppp_fd, flags);
++ }
++
++ return loop_master;
++}
++
++
++/*
++ * output - Output PPP packet.
++ */
++void
++output(unit, p, len)
++ int unit;
++ u_char *p;
++ int len;
++{
++ if (debug)
++ dbglog("sent %P", p, len);
++
++ if (write(ttyfd, p, len) < 0) {
++ if (errno != EIO)
++ error("write: %m");
++ }
++}
++
++
++/*
++ * wait_input - wait until there is data available,
++ * for the length of time specified by *timo (indefinite
++ * if timo is NULL).
++ */
++void
++wait_input(timo)
++ struct timeval *timo;
++{
++ fd_set ready;
++ int n;
++
++ ready = in_fds;
++ n = select(max_in_fd + 1, &ready, NULL, &ready, timo);
++ if (n < 0 && errno != EINTR)
++ fatal("select: %m");
++}
++
++
++/*
++ * add_fd - add an fd to the set that wait_input waits for.
++ */
++void add_fd(fd)
++ int fd;
++{
++ if (fd >= FD_SETSIZE)
++ fatal("descriptor too big");
++ FD_SET(fd, &in_fds);
++ if (fd > max_in_fd)
++ max_in_fd = fd;
++}
++
++/*
++ * remove_fd - remove an fd from the set that wait_input waits for.
++ */
++void remove_fd(fd)
++ int fd;
++{
++ FD_CLR(fd, &in_fds);
++}
++
++#if 0
++/*
++ * 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);
++ if (loop_master >= FD_SETSIZE)
++ fatal("descriptor too big");
++ FD_SET(loop_master, &ready);
++ n = select(loop_master + 1, &ready, NULL, &ready, timo);
++ if (n < 0 && errno != EINTR)
++ fatal("select: %m");
++}
++
++
++/*
++ * 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)
++ fatal("select: %m");
++}
++#endif
++
++
++/*
++ * read_packet - get a PPP packet from the serial device.
++ */
++int
++read_packet(buf)
++ u_char *buf;
++{
++ int len;
++
++ if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
++ if (errno == EWOULDBLOCK || errno == EINTR)
++ return -1;
++ fatal("read: %m");
++ }
++ return len;
++}
++
++
++/*
++ * 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)
++ fatal("eof on loopback");
++ if (errno != EWOULDBLOCK)
++ fatal("read from loopback: %m");
++
++ return rv;
++}
++
++
++/*
++ * netif_set_mtu - set the MTU on the PPP network interface.
++ */
++void
++netif_set_mtu(unit, mtu)
++ int unit, mtu;
++{
++ struct ifreq ifr;
++
++ SYSDEBUG((LOG_DEBUG, "netif_set_mtu: mtu = %d\n", mtu));
++
++ memset(&ifr, '\0', sizeof (ifr));
++ strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
++ ifr.ifr_mtu = mtu;
++
++ if (ifunit >= 0 && ioctl(sock_fd, SIOCSIFMTU, (caddr_t) &ifr) < 0)
++ fatal("ioctl(SIOCSIFMTU): %m");
++}
++
++/*
++ * netif_get_mtu - get the MTU on the PPP network interface.
++ */
++int
++netif_get_mtu(int unit)
++{
++ struct ifreq ifr;
++
++ memset (&ifr, '\0', sizeof (ifr));
++ strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
++
++ if (ifunit >= 0 && ioctl(sock_fd, SIOCGIFMTU, (caddr_t) &ifr) < 0) {
++ error("ioctl(SIOCGIFMTU): %m (line %d)", __LINE__);
++ return 0;
++ }
++ return ifr.ifr_mtu;
++}
++
++
++/*
++ * tty_send_config - configure the transmit characteristics of
++ * the ppp interface.
++ */
++void
++tty_send_config(mtu, asyncmap, pcomp, accomp)
++ int mtu;
++ u_int32_t asyncmap;
++ int pcomp, accomp;
++{
++ u_int x;
++#if 0
++ /* Linux code does not do anything with the mtu here */
++ ifnet_set_mtu(-1, mtu);
++#endif
++
++ if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0)
++ fatal("ioctl(PPPIOCSASYNCMAP): %m");
++
++ x = get_flags(ppp_fd);
++ x = pcomp? x | SC_COMP_PROT: x &~ SC_COMP_PROT;
++ x = accomp? x | SC_COMP_AC: x &~ SC_COMP_AC;
++ x = sync_serial ? x | SC_SYNC : x & ~SC_SYNC;
++ set_flags(ppp_fd, x);
++}
++
++
++/*
++ * ppp_set_xaccm - set the extended transmit ACCM for the interface.
++ */
++void
++tty_set_xaccm(accm)
++ ext_accm accm;
++{
++ if (ioctl(ppp_fd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY)
++ warn("ioctl(set extended ACCM): %m");
++}
++
++
++/*
++ * ppp_recv_config - configure the receive-side characteristics of
++ * the ppp interface.
++ */
++void
++tty_recv_config(mru, asyncmap, pcomp, accomp)
++ int mru;
++ u_int32_t asyncmap;
++ int pcomp, accomp;
++{
++ int x;
++
++ if (ioctl(ppp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0)
++ fatal("ioctl(PPPIOCSMRU): %m");
++ if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0)
++ fatal("ioctl(PPPIOCSRASYNCMAP): %m");
++ x = get_flags(ppp_fd);
++ x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC;
++ set_flags(ppp_fd, x);
++}
++
++/*
++ * ccp_test - ask kernel whether a given compression method
++ * 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;
++{
++ struct ppp_option_data data;
++
++ data.ptr = opt_ptr;
++ data.length = opt_len;
++ data.transmit = for_transmit;
++ if (ioctl(ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
++ return 1;
++ return (errno == ENOBUFS)? 0: -1;
++}
++
++/*
++ * ccp_flags_set - inform kernel about the current state of CCP.
++ */
++void
++ccp_flags_set(unit, isopen, isup)
++ int unit, isopen, isup;
++{
++ int x;
++
++ x = get_flags(ppp_fd);
++ x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN;
++ x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP;
++ set_flags(ppp_fd, x);
++}
++
++/*
++ * ccp_fatal_error - returns 1 if decompression was disabled as a
++ * result of an error detected after decompression of a packet,
++ * 0 otherwise. This is necessary because of patent nonsense.
++ */
++int
++ccp_fatal_error(unit)
++ int unit;
++{
++ int x;
++
++ x = get_flags(ppp_fd);
++ return x & SC_DC_FERROR;
++}
++
++/*
++ * 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;
++}
++
++/*
++ * get_ppp_stats - return statistics for the link.
++ */
++int
++get_ppp_stats(u, stats)
++ int u;
++ struct pppd_stats *stats;
++{
++ struct ifpppstatsreq req;
++
++ memset (&req, 0, sizeof (req));
++ strlcpy(req.ifr_name, ifname, sizeof(req.ifr_name));
++ if (ioctl(sock_fd, SIOCGPPPSTATS, &req) < 0) {
++ error("Couldn't get PPP statistics: %m");
++ return 0;
++ }
++ stats->bytes_in = req.stats.p.ppp_ibytes;
++ stats->bytes_out = req.stats.p.ppp_obytes;
++ return 1;
++}
++
++
++#ifdef PPP_FILTER
++/*
++ * set_filters - transfer the pass and active filters to the kernel.
++ */
++int
++set_filters(pass_in, pass_out, active_in, active_out)
++ struct bpf_program *pass_in, *pass_out, *active_in, *active_out;
++{
++ int ret = 1;
++
++ if (pass_in->bf_len > 0) {
++ if (ioctl(ppp_fd, PPPIOCSIPASS, pass_in) < 0) {
++ error("Couldn't set pass-filter-in in kernel: %m");
++ ret = 0;
++ }
++ }
++
++ if (pass_out->bf_len > 0) {
++ if (ioctl(ppp_fd, PPPIOCSOPASS, pass_out) < 0) {
++ error("Couldn't set pass-filter-out in kernel: %m");
++ ret = 0;
++ }
++ }
++
++ if (active_in->bf_len > 0) {
++ if (ioctl(ppp_fd, PPPIOCSIACTIVE, active_in) < 0) {
++ error("Couldn't set active-filter-in in kernel: %m");
++ ret = 0;
++ }
++ }
++
++ if (active_out->bf_len > 0) {
++ if (ioctl(ppp_fd, PPPIOCSOACTIVE, active_out) < 0) {
++ error("Couldn't set active-filter-out in kernel: %m");
++ ret = 0;
++ }
++ }
++
++ return ret;
++}
++#endif
++
++/*
++ * sifvjcomp - config tcp header compression
++ */
++int
++sifvjcomp(u, vjcomp, cidcomp, maxcid)
++ int u, vjcomp, cidcomp, maxcid;
++{
++ u_int x;
++
++ x = get_flags(ppp_fd);
++ x = vjcomp ? x | SC_COMP_TCP: x &~ SC_COMP_TCP;
++ x = cidcomp? x & ~SC_NO_TCP_CCID: x | SC_NO_TCP_CCID;
++ set_flags(ppp_fd, x);
++ if (vjcomp && ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
++ error("ioctl(PPPIOCSMAXCID): %m");
++ return 0;
++ }
++ return 1;
++}
++
++/*
++ * sifup - Config the interface up and enable IP packets to pass.
++ */
++int
++sifup(u)
++ int u;
++{
++ struct ifreq ifr;
++
++ strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
++ if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
++ error("ioctl (SIOCGIFFLAGS): %m");
++ return 0;
++ }
++ ifr.ifr_flags |= IFF_UP;
++ if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
++ error("ioctl(SIOCSIFFLAGS): %m");
++ return 0;
++ }
++ if_is_up = 1;
++ 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) {
++ error("ioctl(set NP %d mode to %d): %m", proto, mode);
++ return 0;
++ }
++ return 1;
++}
++
++/*
++ * sifdown - Config the interface down and disable IP.
++ */
++int
++sifdown(u)
++ int u;
++{
++ struct ifreq ifr;
++ int rv;
++ struct npioctl npi;
++
++ rv = 1;
++ npi.protocol = PPP_IP;
++ npi.mode = NPMODE_ERROR;
++ ioctl(ppp_fd, PPPIOCSNPMODE, (caddr_t) &npi);
++ /* ignore errors, because ppp_fd might have been closed by now. */
++
++ strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
++ if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
++ error("ioctl (SIOCGIFFLAGS): %m");
++ rv = 0;
++ } else {
++ ifr.ifr_flags &= ~IFF_UP;
++ if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
++ error("ioctl(SIOCSIFFLAGS): %m");
++ rv = 0;
++ } else
++ if_is_up = 0;
++ }
++ return rv;
++}
++
++/*
++ * SET_SA_FAMILY - set the sa_family field of a struct sockaddr,
++ * if it exists.
++ */
++#define SET_SA_FAMILY(addr, family) \
++ BZERO((char *) &(addr), sizeof(addr)); \
++ addr.sa_family = (family); \
++ addr.sa_len = sizeof(addr);
++
++/*
++ * sifaddr - Config the interface IP addresses and netmask.
++ */
++int
++sifaddr(u, o, h, m)
++ int u;
++ u_int32_t o, h, m;
++{
++ struct ifaliasreq ifra;
++ struct ifreq ifr;
++
++ strlcpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name));
++ SET_SA_FAMILY(ifra.ifra_addr, AF_INET);
++ ((struct sockaddr_in *) &ifra.ifra_addr)->sin_addr.s_addr = o;
++ SET_SA_FAMILY(ifra.ifra_broadaddr, AF_INET);
++ ((struct sockaddr_in *) &ifra.ifra_broadaddr)->sin_addr.s_addr = h;
++ if (m != 0) {
++ SET_SA_FAMILY(ifra.ifra_mask, AF_INET);
++ ((struct sockaddr_in *) &ifra.ifra_mask)->sin_addr.s_addr = m;
++ } else
++ BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask));
++ BZERO(&ifr, sizeof(ifr));
++ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++ if (ioctl(sock_fd, SIOCDIFADDR, (caddr_t) &ifr) < 0) {
++ if (errno != EADDRNOTAVAIL)
++ warn("Couldn't remove interface address: %m");
++ }
++ if (ioctl(sock_fd, SIOCAIFADDR, (caddr_t) &ifra) < 0) {
++ if (errno != EEXIST) {
++ error("Couldn't set interface address: %m");
++ return 0;
++ }
++ warn("Couldn't set interface address: Address %I already exists", o);
++ }
++ ifaddrs[0] = o;
++ ifaddrs[1] = h;
++ return 1;
++}
++
++/*
++ * cifaddr - Clear the interface IP addresses, and delete routes
++ * through the interface if possible.
++ */
++int
++cifaddr(u, o, h)
++ int u;
++ u_int32_t o, h;
++{
++ struct ifaliasreq ifra;
++
++ ifaddrs[0] = 0;
++ strlcpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name));
++ SET_SA_FAMILY(ifra.ifra_addr, AF_INET);
++ ((struct sockaddr_in *) &ifra.ifra_addr)->sin_addr.s_addr = o;
++ SET_SA_FAMILY(ifra.ifra_broadaddr, AF_INET);
++ ((struct sockaddr_in *) &ifra.ifra_broadaddr)->sin_addr.s_addr = h;
++ BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask));
++ if (ioctl(sock_fd, SIOCDIFADDR, (caddr_t) &ifra) < 0) {
++ if (errno != EADDRNOTAVAIL)
++ warn("Couldn't delete interface address: %m");
++ return 0;
++ }
++ return 1;
++}
++
++/*
++ * sifdefaultroute - assign a default route through the address given.
++ */
++int
++sifdefaultroute(u, l, g)
++ int u;
++ u_int32_t l, g;
++{
++ return dodefaultroute(g, 's');
++}
++
++/*
++ * cifdefaultroute - delete a default route through the address given.
++ */
++int
++cifdefaultroute(u, l, g)
++ int u;
++ u_int32_t l, g;
++{
++ return dodefaultroute(g, 'c');
++}
++
++/********************************************************************
++ *
++ * sipxfaddr - Config the interface IPX networknumber
++ */
++
++int sipxfaddr (int unit, unsigned long int network, unsigned char * node )
++{
++ int result = 1;
++
++#ifdef IPX_CHANGE
++ int skfd;
++ struct ifreq ifr;
++ struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &ifr.ifr_addr;
++
++ skfd = socket (AF_IPX, SOCK_DGRAM, 0);
++ if (skfd < 0) {
++ if (! ok_error (errno))
++ dbglog("socket(AF_IPX): %m (line %d)", __LINE__);
++ result = 0;
++ }
++ else {
++ memset (&ifr, '\0', sizeof (ifr));
++ strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++
++ memcpy (sipx->sipx_node, node, IPX_NODE_LEN);
++ sipx->sipx_family = AF_IPX;
++ sipx->sipx_port = 0;
++ sipx->sipx_network = htonl (network);
++ sipx->sipx_type = IPX_FRAME_ETHERII;
++ sipx->sipx_action = IPX_CRTITF;
++/*
++ * Set the IPX device
++ */
++ if (ioctl(skfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
++ result = 0;
++ if (errno != EEXIST) {
++ if (! ok_error (errno))
++ dbglog("ioctl(SIOCSIFADDR, CRTITF): %m (line %d)", __LINE__);
++ }
++ else {
++ warn("ioctl(SIOCSIFADDR, CRTITF): Address already exists");
++ }
++ }
++ close (skfd);
++ }
++#endif
++ return result;
++}
++
++/********************************************************************
++ *
++ * cipxfaddr - Clear the information for the IPX network. The IPX routes
++ * are removed and the device is no longer able to pass IPX
++ * frames.
++ */
++
++int cipxfaddr (int unit)
++{
++ int result = 1;
++
++#ifdef IPX_CHANGE
++ int skfd;
++ struct ifreq ifr;
++ struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &ifr.ifr_addr;
++
++ skfd = socket (AF_IPX, SOCK_DGRAM, 0);
++ if (skfd < 0) {
++ if (! ok_error (errno))
++ dbglog("socket(AF_IPX): %m (line %d)", __LINE__);
++ result = 0;
++ }
++ else {
++ memset (&ifr, '\0', sizeof (ifr));
++ strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++
++ sipx->sipx_type = IPX_FRAME_ETHERII;
++ sipx->sipx_action = IPX_DLTITF;
++ sipx->sipx_family = AF_IPX;
++/*
++ * Set the IPX device
++ */
++ if (ioctl(skfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
++ if (! ok_error (errno))
++ info("ioctl(SIOCSIFADDR, IPX_DLTITF): %m (line %d)", __LINE__);
++ result = 0;
++ }
++ close (skfd);
++ }
++#endif
++ return result;
++}
++
++/*
++ * dodefaultroute - talk to a routing socket to add/delete a default route.
++ */
++static int
++dodefaultroute(g, cmd)
++ u_int32_t g;
++ int cmd;
++{
++ int routes;
++ struct {
++ struct rt_msghdr hdr;
++ struct sockaddr_in dst;
++ struct sockaddr_in gway;
++ struct sockaddr_in netmask;
++ struct sockaddr_in genmask;
++ struct sockaddr_dl ifp;
++ } rtmsg;
++
++ if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
++ error("Couldn't %s default route: socket: %m",
++ cmd == 's' ? "add" : "delete");
++ return 0;
++ }
++
++ memset(&rtmsg, 0, sizeof(rtmsg));
++
++ rtmsg.hdr.rtm_type = cmd == 's' ? RTM_ADD : RTM_DELETE;
++ rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
++ rtmsg.hdr.rtm_version = RTM_VERSION;
++ rtmsg.hdr.rtm_seq = ++rtm_seq;
++ rtmsg.hdr.rtm_addrs =
++ RTA_DST | RTA_GATEWAY | RTA_NETMASK | RTA_GENMASK | RTA_IFP;
++
++ rtmsg.dst.sin_len = sizeof(rtmsg.dst);
++ rtmsg.dst.sin_family = AF_INET;
++ rtmsg.dst.sin_addr.s_addr = 0;
++
++ rtmsg.gway.sin_len = sizeof(rtmsg.gway);
++ rtmsg.gway.sin_family = AF_INET;
++ rtmsg.gway.sin_addr.s_addr = g;
++
++ rtmsg.netmask.sin_len = sizeof(rtmsg.netmask);
++ rtmsg.netmask.sin_family = AF_INET;
++ rtmsg.netmask.sin_addr.s_addr = 0;
++
++ rtmsg.genmask.sin_len = sizeof(rtmsg.genmask);
++ rtmsg.genmask.sin_family = AF_INET;
++ rtmsg.genmask.sin_addr.s_addr = 0;
++
++ rtmsg.ifp.sdl_family = AF_LINK;
++ rtmsg.ifp.sdl_len = sizeof(rtmsg.ifp);
++ link_addr(ifname, &rtmsg.ifp);
++
++ rtmsg.hdr.rtm_msglen = sizeof(rtmsg);
++
++ if (write(routes, &rtmsg, sizeof(rtmsg)) < 0) {
++ error("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;
++}
++
++#if RTM_VERSION >= 3
++
++/*
++ * sifproxyarp - Make a proxy ARP entry for the peer.
++ */
++static struct {
++ struct rt_msghdr hdr;
++ struct sockaddr_inarp dst;
++ struct sockaddr_dl hwa;
++ char extra[128];
++} arpmsg;
++
++static int arpmsg_valid;
++
++int
++sifproxyarp(unit, hisaddr)
++ int unit;
++ u_int32_t hisaddr;
++{
++ int routes;
++
++ /*
++ * Get the hardware address of an interface on the same subnet
++ * as our local address.
++ */
++ memset(&arpmsg, 0, sizeof(arpmsg));
++ if (!get_ether_addr(hisaddr, &arpmsg.hwa)) {
++ error("Cannot determine ethernet address for proxy ARP");
++ return 0;
++ }
++
++ if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
++ error("Couldn't add proxy arp entry: socket: %m");
++ return 0;
++ }
++
++ arpmsg.hdr.rtm_type = RTM_ADD;
++ arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC;
++ arpmsg.hdr.rtm_version = RTM_VERSION;
++ arpmsg.hdr.rtm_seq = ++rtm_seq;
++ arpmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY;
++ arpmsg.hdr.rtm_inits = RTV_EXPIRE;
++ arpmsg.dst.sin_len = sizeof(struct sockaddr_inarp);
++ arpmsg.dst.sin_family = AF_INET;
++ arpmsg.dst.sin_addr.s_addr = hisaddr;
++ arpmsg.dst.sin_other = SIN_PROXY;
++
++ arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
++ + arpmsg.hwa.sdl_len;
++ if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
++ error("Couldn't add proxy arp entry: %m");
++ close(routes);
++ return 0;
++ }
++
++ close(routes);
++ arpmsg_valid = 1;
++ proxy_arp_addr = hisaddr;
++ return 1;
++}
++
++/*
++ * cifproxyarp - Delete the proxy ARP entry for the peer.
++ */
++int
++cifproxyarp(unit, hisaddr)
++ int unit;
++ u_int32_t hisaddr;
++{
++ int routes;
++
++ if (!arpmsg_valid)
++ return 0;
++ arpmsg_valid = 0;
++
++ arpmsg.hdr.rtm_type = RTM_DELETE;
++ arpmsg.hdr.rtm_seq = ++rtm_seq;
++
++ if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
++ error("Couldn't delete proxy arp entry: socket: %m");
++ return 0;
++ }
++
++ if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
++ error("Couldn't delete proxy arp entry: %m");
++ close(routes);
++ return 0;
++ }
++
++ close(routes);
++ proxy_arp_addr = 0;
++ return 1;
++}
++
++#else /* RTM_VERSION */
++
++/*
++ * sifproxyarp - Make a proxy ARP entry for the peer.
++ */
++int
++sifproxyarp(unit, hisaddr)
++ int unit;
++ u_int32_t hisaddr;
++{
++ struct arpreq arpreq;
++ struct {
++ struct sockaddr_dl sdl;
++ char space[128];
++ } dls;
++
++ BZERO(&arpreq, sizeof(arpreq));
++
++ /*
++ * Get the hardware address of an interface on the same subnet
++ * as our local address.
++ */
++ if (!get_ether_addr(hisaddr, &dls.sdl)) {
++ error("Cannot determine ethernet address for proxy ARP");
++ return 0;
++ }
++
++ arpreq.arp_ha.sa_len = sizeof(struct sockaddr);
++ arpreq.arp_ha.sa_family = AF_UNSPEC;
++ BCOPY(LLADDR(&dls.sdl), arpreq.arp_ha.sa_data, dls.sdl.sdl_alen);
++ SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
++ ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
++ arpreq.arp_flags = ATF_PERM | ATF_PUBL;
++ if (ioctl(sock_fd, SIOCSARP, (caddr_t)&arpreq) < 0) {
++ error("Couldn't add proxy arp entry: %m");
++ return 0;
++ }
++
++ proxy_arp_addr = hisaddr;
++ return 1;
++}
++
++/*
++ * cifproxyarp - Delete the proxy ARP entry for the peer.
++ */
++int
++cifproxyarp(unit, hisaddr)
++ int unit;
++ u_int32_t hisaddr;
++{
++ struct arpreq arpreq;
++
++ BZERO(&arpreq, sizeof(arpreq));
++ SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
++ ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
++ if (ioctl(sock_fd, SIOCDARP, (caddr_t)&arpreq) < 0) {
++ warn("Couldn't delete proxy arp entry: %m");
++ return 0;
++ }
++ proxy_arp_addr = 0;
++ return 1;
++}
++#endif /* RTM_VERSION */
++
++
++/*
++ * get_ether_addr - get the hardware address of an interface on the
++ * the same subnet as ipaddr.
++ */
++static int
++get_ether_addr(ipaddr, hwaddr)
++ u_int32_t ipaddr;
++ struct sockaddr_dl *hwaddr;
++{
++ u_int32_t ina, mask;
++ struct sockaddr_dl *dla;
++ struct ifaddrs *ifap, *ifa, *ifp;
++
++ /*
++ * Scan through looking for an interface with an Internet
++ * address on the same subnet as `ipaddr'.
++ */
++ if (getifaddrs(&ifap) != 0) {
++ error("getifaddrs: %m");
++ return 0;
++ }
++
++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
++ if (ifa->ifa_addr->sa_family != AF_INET)
++ continue;
++ ina = ((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr;
++ /*
++ * Check that the interface is up, and not point-to-point
++ * or loopback.
++ */
++ if ((ifa->ifa_flags &
++ (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|IFF_LOOPBACK|IFF_NOARP))
++ != (IFF_UP|IFF_BROADCAST))
++ continue;
++ /*
++ * Get its netmask and check that it's on the right subnet.
++ */
++ mask = ((struct sockaddr_in *) ifa->ifa_netmask)->sin_addr.s_addr;
++ if ((ipaddr & mask) != (ina & mask))
++ continue;
++ break;
++ }
++
++ if (!ifa) {
++ freeifaddrs(ifap);
++ return 0;
++ }
++ info("found interface %s for proxy arp", ifa->ifa_name);
++
++ ifp = ifa;
++
++ /*
++ * Now scan through again looking for a link-level address
++ * for this interface.
++ */
++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
++ if (strcmp(ifp->ifa_name, ifa->ifa_name) != 0)
++ continue;
++ if (ifa->ifa_addr->sa_family != AF_LINK)
++ continue;
++ /*
++ * Found the link-level address - copy it out
++ */
++ dla = (struct sockaddr_dl *) ifa->ifa_addr;
++ BCOPY(dla, hwaddr, dla->sdl_len);
++ freeifaddrs(ifap);
++ return 1;
++ }
++
++ freeifaddrs(ifap);
++ return 0;
++}
++
++/*
++ * get_if_hwaddr - get the hardware address for the specified
++ * network interface device.
++ */
++int
++get_if_hwaddr(addr, name)
++ u_char *addr;
++ char *name;
++{
++ struct ifreq ifreq;
++ struct sockaddr_dl *sdl = (struct sockaddr_dl *) &ifreq.ifr_addr;
++ int fd;
++
++ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
++ return 0;
++ (void)memset(sdl, 0, sizeof(*sdl));
++ sdl->sdl_family = AF_LINK;
++ (void)strlcpy(ifreq.ifr_name, name, sizeof(ifreq.ifr_name));
++ if (ioctl(fd, SIOCGIFADDR, &ifreq) == -1) {
++ (void)close(fd);
++ return 0;
++ }
++ (void)close(fd);
++ (void)memcpy(addr, LLADDR(sdl), sdl->sdl_alen);
++ return sdl->sdl_nlen;
++}
++
++/*
++ * get_first_ethernet - return the name of the first ethernet-style
++ * interface on this system.
++ */
++char *
++get_first_ethernet()
++{
++ static char ifname[IFNAMSIZ];
++ struct ifaddrs *ifap, *ifa;
++
++ /*
++ * Scan through the system's network interfaces.
++ */
++ if (getifaddrs(&ifap) != 0) {
++ warn("getifaddrs: %m");
++ return NULL;
++ }
++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
++ /*
++ * Check the interface's internet address.
++ */
++ if (ifa->ifa_addr->sa_family != AF_INET)
++ continue;
++ /*
++ * Check that the interface is up, and not point-to-point or loopback.
++ */
++ if ((ifa->ifa_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
++ != IFF_UP) {
++ strlcpy(ifname, ifa->ifa_name, sizeof(ifname));
++ freeifaddrs(ifap);
++ return ifname;
++ }
++ }
++ freeifaddrs(ifap);
++ return NULL;
++}
++
++/*
++ * Return user specified netmask, modified by any mask we might determine
++ * for address `addr' (in network byte order).
++ * Here we scan through the system's list of interfaces, looking for
++ * any non-point-to-point interfaces which might appear to be on the same
++ * network as `addr'. If we find any, we OR in their netmask to the
++ * user-specified netmask.
++ */
++u_int32_t
++GetMask(addr)
++ u_int32_t addr;
++{
++ u_int32_t mask, nmask, ina;
++ struct ifaddrs *ifap, *ifa;
++
++ addr = ntohl(addr);
++ if (IN_CLASSA(addr)) /* determine network mask for address class */
++ nmask = IN_CLASSA_NET;
++ else if (IN_CLASSB(addr))
++ nmask = IN_CLASSB_NET;
++ else
++ nmask = IN_CLASSC_NET;
++ /* class D nets are disallowed by bad_ip_adrs */
++ mask = netmask | htonl(nmask);
++
++ /*
++ * Scan through the system's network interfaces.
++ */
++ if (getifaddrs(&ifap) != 0) {
++ warn("getifaddrs: %m");
++ return 0;
++ }
++
++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
++ /*
++ * Check the interface's internet address.
++ */
++ if (ifa->ifa_addr->sa_family != AF_INET)
++ continue;
++ ina = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
++ if ((ntohl(ina) & nmask) != (addr & nmask))
++ continue;
++ /*
++ * Check that the interface is up, and not point-to-point or loopback.
++ */
++ if ((ifa->ifa_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK)) != IFF_UP)
++ continue;
++ /*
++ * Get its netmask and OR it into our mask.
++ */
++ mask |= ((struct sockaddr_in *)&ifa->ifa_netmask)->sin_addr.s_addr;
++ }
++
++ freeifaddrs(ifap);
++ return mask;
++}
++
++/*
++ * have_route_to - determine if the system has any route to
++ * a given IP address.
++ * For demand mode to work properly, we have to ignore routes
++ * through our own interface.
++ */
++int have_route_to(u_int32_t addr)
++{
++ return -1;
++}
++
++/*
++ * Use the hostid as part of the random number seed.
++ */
++int
++get_host_seed()
++{
++ return gethostid();
++}
++
++#if 0
++/*
++ * lock - create a lock file for the named lock device
++ */
++#define LOCK_PREFIX "/var/spool/lock/LCK.."
++
++static char *lock_file; /* name of lock file created */
++
++int
++lock(dev)
++ char *dev;
++{
++ char hdb_lock_buffer[12];
++ int fd, pid, n;
++ char *p;
++ size_t l;
++
++ if ((p = strrchr(dev, '/')) != NULL)
++ dev = p + 1;
++ l = strlen(LOCK_PREFIX) + strlen(dev) + 1;
++ lock_file = malloc(l);
++ if (lock_file == NULL)
++ novm("lock file name");
++ slprintf(lock_file, l, "%s%s", LOCK_PREFIX, dev);
++
++ while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) {
++ if (errno == EEXIST
++ && (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) {
++ error("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) {
++ close(fd);
++ notice("Removed stale lock on %s (pid %d)",
++ dev, pid);
++ continue;
++ } else
++ warn("Couldn't remove stale lock on %s",
++ dev);
++ } else
++ notice("Device %s is locked by pid %d",
++ dev, pid);
++ }
++ close(fd);
++ } else
++ error("Can't create lock file %s: %m", lock_file);
++ free(lock_file);
++ lock_file = NULL;
++ return -1;
++ }
++
++ slprintf(hdb_lock_buffer, sizeof(hdb_lock_buffer), "%10d\n", getpid());
++ write(fd, hdb_lock_buffer, 11);
++
++ close(fd);
++ return 0;
++}
++
++/*
++ * unlock - remove our lockfile
++ */
++void
++unlock()
++{
++ if (lock_file) {
++ unlink(lock_file);
++ free(lock_file);
++ lock_file = NULL;
++ }
++}
++#endif
diff --git a/net/pppd/patches/patch-ba b/net/pppd/patches/patch-ba
new file mode 100644
index 00000000000..0addef16a3d
--- /dev/null
+++ b/net/pppd/patches/patch-ba
@@ -0,0 +1,30 @@
+$NetBSD: patch-ba,v 1.1.1.1 2005/01/02 02:51:43 cube Exp $
+
+--- pppd/tdb.c.orig 2004-11-13 08:13:07.000000000 +0100
++++ pppd/tdb.c
+@@ -193,6 +193,8 @@ void tdb_set_lock_alarm(sig_atomic_t *pa
+ palarm_fired = palarm;
+ }
+
++static int tdb_update_hash __P((TDB_CONTEXT *, TDB_DATA, u32, TDB_DATA));
++
+ /* a byte range locking function - return 0 on success
+ this functions locks/unlocks 1 byte at the specified offset.
+
+@@ -800,9 +802,13 @@ static int tdb_expand(TDB_CONTEXT *tdb,
+
+ tdb->map_size += size;
+
+- if (tdb->flags & TDB_INTERNAL)
+- tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size);
+- else {
++ if (tdb->flags & TDB_INTERNAL) {
++ void *n;
++ n = realloc(tdb->map_ptr, tdb->map_size);
++ if (!n)
++ goto fail;
++ tdb->map_ptr = n;
++ } else {
+ /*
+ * We must ensure the file is remapped before adding the space
+ * to ensure consistency with systems like OpenBSD where
diff --git a/net/pppd/patches/patch-bb b/net/pppd/patches/patch-bb
new file mode 100644
index 00000000000..506e1bc2f7c
--- /dev/null
+++ b/net/pppd/patches/patch-bb
@@ -0,0 +1,87 @@
+$NetBSD: patch-bb,v 1.1.1.1 2005/01/02 02:51:43 cube Exp $
+
+--- pppd/tty.c.orig 2004-11-13 13:07:29.000000000 +0100
++++ pppd/tty.c
+@@ -80,7 +80,6 @@
+ #include <fcntl.h>
+ #include <syslog.h>
+ #include <netdb.h>
+-#include <utmp.h>
+ #include <pwd.h>
+ #include <setjmp.h>
+ #include <sys/param.h>
+@@ -216,8 +215,11 @@ option_t tty_options[] = {
+ "Disable hardware flow control",
+ OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
+ { "nocdtrcts", o_int, &crtscts,
+- "Disable hardware flow control",
+- OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
++ "Disable alternate hardware (DTR/CTS) flow control",
++ OPT_PRIOSUB | OPT_NOARG | OPT_VAL(2) },
++ { "-cdtrcts", o_int, &crtscts,
++ "Disable alternate hardware (DTR/CTS) flow control",
++ OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(2) },
+ { "xonxoff", o_special_noarg, (void *)setxonxoff,
+ "Set software (XON/XOFF) flow control", OPT_PRIOSUB },
+
+@@ -840,7 +842,7 @@ finish_tty()
+ #ifndef __linux__
+ if (tty_mode != (mode_t) -1) {
+ if (fchmod(real_ttyfd, tty_mode) != 0)
+- error("Couldn't restore tty permissions");
++ warn("Couldn't restore tty permissions: %m");
+ }
+ #endif /* __linux__ */
+
+@@ -1097,17 +1099,29 @@ charshunt(ifd, ofd, record_file)
+ if (nibuf != 0) {
+ if (ilevel >= max_level)
+ top = &tout;
+- else
++ else {
++ if (pty_master >= FD_SETSIZE)
++ fatal("descriptor too big");
+ FD_SET(pty_master, &writey);
+- } else if (stdin_readable)
++ }
++ } else if (stdin_readable) {
++ if (ifd >= FD_SETSIZE)
++ fatal("descriptor too big");
+ FD_SET(ifd, &ready);
++ }
+ if (nobuf != 0) {
+ if (olevel >= max_level)
+ top = &tout;
+- else
++ else {
++ if (ofd >= FD_SETSIZE)
++ fatal("descriptor too big");
+ FD_SET(ofd, &writey);
+- } else if (pty_readable)
++ }
++ } else if (pty_readable) {
++ if (pty_master >= FD_SETSIZE)
++ fatal("descriptor too big");
+ FD_SET(pty_master, &ready);
++ }
+ if (select(nfds, &ready, &writey, NULL, top) < 0) {
+ if (errno != EINTR)
+ fatal("select");
+@@ -1145,6 +1159,8 @@ charshunt(ifd, ofd, record_file)
+ if (!record_write(recordf, 4, NULL, 0, &lasttime))
+ recordf = NULL;
+ } else {
++ if (pty_master >= FD_SETSIZE)
++ fatal("descriptor too big");
+ FD_SET(pty_master, &writey);
+ if (recordf)
+ if (!record_write(recordf, 2, ibufp, nibuf, &lasttime))
+@@ -1172,6 +1188,8 @@ charshunt(ifd, ofd, record_file)
+ if (!record_write(recordf, 3, NULL, 0, &lasttime))
+ recordf = NULL;
+ } else {
++ if (ofd >= FD_SETSIZE)
++ fatal("descriptor too big");
+ FD_SET(ofd, &writey);
+ if (recordf)
+ if (!record_write(recordf, 1, obufp, nobuf, &lasttime))
diff --git a/net/pppd/patches/patch-bc b/net/pppd/patches/patch-bc
new file mode 100644
index 00000000000..132e9c47ac2
--- /dev/null
+++ b/net/pppd/patches/patch-bc
@@ -0,0 +1,71 @@
+$NetBSD: patch-bc,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppd/utils.c.orig 2004-11-04 11:02:26.000000000 +0100
++++ pppd/utils.c
+@@ -41,7 +41,6 @@
+ #include <syslog.h>
+ #include <netdb.h>
+ #include <time.h>
+-#include <utmp.h>
+ #include <pwd.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -76,6 +75,7 @@ struct buffer_info {
+ int len;
+ };
+
++#ifndef HAS_STRLFUNCS
+ /*
+ * strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
+ * always leaves destination null-terminated (for len > 0).
+@@ -113,6 +113,7 @@ strlcat(dest, src, len)
+
+ return dlen + strlcpy(dest + dlen, src, (len > dlen? len - dlen: 0));
+ }
++#endif
+
+
+ /*
+@@ -197,7 +198,7 @@ vslprintf(buf, buflen, fmt, args)
+ width = va_arg(args, int);
+ c = *++fmt;
+ } else {
+- while (isdigit(c)) {
++ while (isdigit((unsigned char)c)) {
+ width = width * 10 + c - '0';
+ c = *++fmt;
+ }
+@@ -209,7 +210,7 @@ vslprintf(buf, buflen, fmt, args)
+ c = *++fmt;
+ } else {
+ prec = 0;
+- while (isdigit(c)) {
++ while (isdigit((unsigned char)c)) {
+ prec = prec * 10 + c - '0';
+ c = *++fmt;
+ }
+@@ -287,19 +288,15 @@ vslprintf(buf, buflen, fmt, args)
+ (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
+ str = num;
+ break;
+-#if 0 /* not used, and breaks on S/390, apparently */
+- case 'r':
++ case 'r': {
++ va_list vlist;
+ f = va_arg(args, char *);
+-#ifndef __powerpc__
+- n = vslprintf(buf, buflen + 1, f, va_arg(args, va_list));
+-#else
+- /* On the powerpc, a va_list is an array of 1 structure */
+- n = vslprintf(buf, buflen + 1, f, va_arg(args, void *));
+-#endif
++ vlist = va_arg(args, va_list);
++ n = vslprintf(buf, buflen + 1, f, vlist);
+ buf += n;
+ buflen -= n;
+ continue;
+-#endif
++ }
+ case 't':
+ time(&t);
+ str = ctime(&t);
diff --git a/net/pppd/patches/patch-bd b/net/pppd/patches/patch-bd
new file mode 100644
index 00000000000..ba33e414832
--- /dev/null
+++ b/net/pppd/patches/patch-bd
@@ -0,0 +1,12 @@
+$NetBSD: patch-bd,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/Makefile.linux.orig 2004-10-31 02:36:52.000000000 +0200
++++ pppdump/Makefile.linux
+@@ -1,6 +1,6 @@
+ DESTDIR = @DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+-MANDIR = $(DESTDIR)/share/man/man8
++MANDIR = $(DESTDIR)/man/man8
+
+ CFLAGS= -O -I../include/net
+ OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
diff --git a/net/pppd/patches/patch-be b/net/pppd/patches/patch-be
new file mode 100644
index 00000000000..4087803274d
--- /dev/null
+++ b/net/pppd/patches/patch-be
@@ -0,0 +1,26 @@
+$NetBSD: patch-be,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/Makefile.netbsd.orig 2004-12-31 23:51:00.000000000 +0100
++++ pppdump/Makefile.netbsd
+@@ -0,0 +1,21 @@
++DESTDIR = @DESTDIR@
++BINDIR = $(DESTDIR)/sbin
++MANDIR = $(DESTDIR)/man/man8
++
++CFLAGS= -O -I../include/net
++OBJS = pppdump.o bsd-comp.o deflate.o
++
++INSTALL= install
++
++all: pppdump
++
++pppdump: $(OBJS)
++ $(CC) -o pppdump $(OBJS) -lz
++
++clean:
++ rm -f pppdump $(OBJS) *~
++
++install:
++ mkdir -p $(BINDIR) $(MANDIR)
++ $(INSTALL) -s -c pppdump $(BINDIR)
++ $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)
diff --git a/net/pppd/patches/patch-bf b/net/pppd/patches/patch-bf
new file mode 100644
index 00000000000..5126922d7e1
--- /dev/null
+++ b/net/pppd/patches/patch-bf
@@ -0,0 +1,177 @@
+$NetBSD: patch-bf,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/bsd-comp.c.orig 2004-02-02 04:36:46.000000000 +0100
++++ pppdump/bsd-comp.c
+@@ -46,8 +46,15 @@
+ #include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include "pppdump.h"
++#ifdef __NetBSD__
++#include <net/ppp_defs.h>
++#include <net/ppp-comp.h>
++#else
+ #include "ppp_defs.h"
+ #include "ppp-comp.h"
++#endif
++
+
+ #if DO_BSD_COMPRESS
+
+@@ -128,9 +135,8 @@ static void *bsd_decomp_alloc __P((u_cha
+ static void bsd_free __P((void *state));
+ static int bsd_decomp_init __P((void *state, u_char *options, int opt_len,
+ int unit, int hdrlen, int mru, int debug));
+-static void bsd_incomp __P((void *state, u_char *dmsg, int len));
+-static int bsd_decompress __P((void *state, u_char *cmp, int inlen,
+- u_char *dmp, int *outlen));
++static void bsd_incomp __P((void *state, PACKETPTR in));
++static int bsd_decompress __P((void *state, PACKETPTR in, PACKETPTR *out));
+ static void bsd_reset __P((void *state));
+ static void bsd_comp_stats __P((void *state, struct compstat *stats));
+
+@@ -139,6 +145,12 @@ static void bsd_comp_stats __P((void *st
+ */
+ struct compressor ppp_bsd_compress = {
+ CI_BSD_COMPRESS, /* compress_proto */
++ NULL, /* comp_alloc */
++ NULL, /* comp_free */
++ NULL, /* comp_init */
++ NULL, /* comp_reset */
++ NULL, /* comp_compress */
++ NULL, /* comp_stat */
+ bsd_decomp_alloc, /* decomp_alloc */
+ bsd_free, /* decomp_free */
+ bsd_decomp_init, /* decomp_init */
+@@ -170,6 +182,12 @@ struct compressor ppp_bsd_compress = {
+ #define RATIO_SCALE (1<<RATIO_SCALE_LOG)
+ #define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG)
+
++static void bsd_clear __P((struct bsd_db *));
++static int bsd_check __P((struct bsd_db *));
++static void *bsd_alloc __P((u_char *, int, int));
++static int bsd_init __P((struct bsd_db *, u_char *, int, int, int, int,
++ int, int));
++
+ /*
+ * clear the dictionary
+ */
+@@ -257,7 +275,7 @@ bsd_comp_stats(state, stats)
+ stats->ratio = db->in_count;
+ out = db->bytes_out;
+ if (stats->ratio <= 0x7fffff)
+- stats->ratio <<= 8;
++ stats->ratio = ((stats->ratio) << 8);
+ else
+ out >>= 8;
+ if (out != 0)
+@@ -383,7 +401,7 @@ bsd_init(db, options, opt_len, unit, hdr
+ || options[0] != CI_BSD_COMPRESS || options[1] != CILEN_BSD_COMPRESS
+ || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION
+ || BSD_NBITS(options[2]) != db->maxbits
+- || decomp && db->lens == NULL)
++ || (decomp && db->lens == NULL))
+ return 0;
+
+ if (decomp) {
+@@ -424,10 +442,9 @@ bsd_decomp_init(state, options, opt_len,
+ * incompressible data by pretending to compress the incoming data.
+ */
+ static void
+-bsd_incomp(state, dmsg, mlen)
++bsd_incomp(state, in)
+ void *state;
+- u_char *dmsg;
+- int mlen;
++ PACKETPTR in;
+ {
+ struct bsd_db *db = (struct bsd_db *) state;
+ u_int hshift = db->hshift;
+@@ -442,11 +459,11 @@ bsd_incomp(state, dmsg, mlen)
+ u_char *rptr;
+ u_int ent;
+
+- rptr = dmsg;
++ rptr = in->buf;
+ ent = rptr[0]; /* get the protocol */
+ if (ent == 0) {
+ ++rptr;
+- --mlen;
++ in->len--;
+ ent = rptr[0];
+ }
+ if ((ent & 1) == 0 || ent < 0x21 || ent > 0xf9)
+@@ -455,7 +472,7 @@ bsd_incomp(state, dmsg, mlen)
+ db->seqno++;
+ ilen = 1; /* count the protocol as 1 byte */
+ ++rptr;
+- slen = dmsg + mlen - rptr;
++ slen = in->buf + in->len - rptr;
+ ilen += slen;
+ for (; slen > 0; --slen) {
+ c = *rptr++;
+@@ -544,10 +561,10 @@ bsd_incomp(state, dmsg, mlen)
+ * compression, even though they are detected by inspecting the input.
+ */
+ static int
+-bsd_decompress(state, cmsg, inlen, dmp, outlenp)
++bsd_decompress(state, in, out)
+ void *state;
+- u_char *cmsg, *dmp;
+- int inlen, *outlenp;
++ PACKETPTR in;
++ PACKETPTR *out;
+ {
+ struct bsd_db *db = (struct bsd_db *) state;
+ u_int max_ent = db->max_ent;
+@@ -556,19 +573,19 @@ bsd_decompress(state, cmsg, inlen, dmp,
+ u_int n_bits = db->n_bits;
+ u_int tgtbitno = 32-n_bits; /* bitno when we have a code */
+ struct bsd_dict *dictp;
+- int explen, i, seq, len;
++ int explen, seq, len;
+ u_int incode, oldcode, finchar;
+ u_char *p, *rptr, *wptr;
+ int ilen;
+- int dlen, space, codelen, extra;
++ int dlen, codelen, extra;
+
+- rptr = cmsg;
++ rptr = in->buf;
+ if (*rptr == 0)
+ ++rptr;
+ ++rptr; /* skip protocol (assumed 0xfd) */
+ seq = (rptr[0] << 8) + rptr[1];
+ rptr += BSD_OVHD;
+- ilen = len = cmsg + inlen - rptr;
++ ilen = len = in->buf + in->len - rptr;
+
+ /*
+ * Check the sequence number and give up if it is not what we expect.
+@@ -580,7 +597,7 @@ bsd_decompress(state, cmsg, inlen, dmp,
+ return DECOMP_ERROR;
+ }
+
+- wptr = dmp + db->hdrlen;
++ wptr = (*out)->buf + db->hdrlen;
+
+ oldcode = CLEAR;
+ explen = 0;
+@@ -616,7 +633,7 @@ bsd_decompress(state, cmsg, inlen, dmp,
+ }
+
+ if (incode > max_ent + 2 || incode > db->maxmaxcode
+- || incode > max_ent && oldcode == CLEAR) {
++ || (incode > max_ent && oldcode == CLEAR)) {
+ if (db->debug) {
+ printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
+ db->unit, incode, oldcode);
+@@ -729,7 +746,7 @@ bsd_decompress(state, cmsg, inlen, dmp,
+ }
+ oldcode = incode;
+ }
+- *outlenp = wptr - (dmp + db->hdrlen);
++ (*out)->len = wptr - ((*out)->buf + db->hdrlen);
+
+ /*
+ * Keep the checkpoint right so that incompressible packets
diff --git a/net/pppd/patches/patch-bg b/net/pppd/patches/patch-bg
new file mode 100644
index 00000000000..b4b00b37626
--- /dev/null
+++ b/net/pppd/patches/patch-bg
@@ -0,0 +1,122 @@
+$NetBSD: patch-bg,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/deflate.c.orig 2004-02-02 04:36:46.000000000 +0100
++++ pppdump/deflate.c
+@@ -41,9 +41,16 @@
+ #include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include "pppdump.h"
++#ifdef __NetBSD__
++#include <net/ppp_defs.h>
++#include <net/ppp-comp.h>
++#include <zlib.h>
++#else
+ #include "ppp_defs.h"
+ #include "ppp-comp.h"
+ #include "zlib.h"
++#endif
+
+ #if DO_DEFLATE
+
+@@ -71,9 +78,8 @@ static void *z_decomp_alloc __P((u_char
+ static void z_decomp_free __P((void *state));
+ static int z_decomp_init __P((void *state, u_char *options, int opt_len,
+ int unit, int hdrlen, int mru, int debug));
+-static void z_incomp __P((void *state, u_char *dmsg, int len));
+-static int z_decompress __P((void *state, u_char *cmp, int inlen,
+- u_char *dmp, int *outlenp));
++static void z_incomp __P((void *state, PACKETPTR mi));
++static int z_decompress __P((void *state, PACKETPTR mi, PACKETPTR *mo));
+ static void z_decomp_reset __P((void *state));
+ static void z_comp_stats __P((void *state, struct compstat *stats));
+
+@@ -82,6 +88,12 @@ static void z_comp_stats __P((void *stat
+ */
+ struct compressor ppp_deflate = {
+ CI_DEFLATE, /* compress_proto */
++ NULL, /* comp_alloc */
++ NULL, /* comp_free */
++ NULL, /* comp_init */
++ NULL, /* comp_reset */
++ NULL, /* comp_compress */
++ NULL, /* comp_stat */
+ z_decomp_alloc, /* decomp_alloc */
+ z_decomp_free, /* decomp_free */
+ z_decomp_init, /* decomp_init */
+@@ -230,17 +242,17 @@ z_decomp_reset(arg)
+ * compression, even though they are detected by inspecting the input.
+ */
+ static int
+-z_decompress(arg, mi, inlen, mo, outlenp)
++z_decompress(arg, mi, mo)
+ void *arg;
+- u_char *mi, *mo;
+- int inlen, *outlenp;
++ PACKETPTR mi;
++ PACKETPTR *mo;
+ {
+ struct deflate_state *state = (struct deflate_state *) arg;
+ u_char *rptr, *wptr;
+- int rlen, olen, ospace;
+- int seq, i, flush, r, decode_proto;
++ int rlen, olen;
++ int seq, r;
+
+- rptr = mi;
++ rptr = mi->buf;
+ if (*rptr == 0)
+ ++rptr;
+ ++rptr;
+@@ -261,9 +273,9 @@ z_decompress(arg, mi, inlen, mo, outlenp
+ /*
+ * Set up to call inflate.
+ */
+- wptr = mo;
++ wptr = (*mo)->buf;
+ state->strm.next_in = rptr;
+- state->strm.avail_in = mi + inlen - rptr;
++ state->strm.avail_in = mi->buf + mi->len - rptr;
+ rlen = state->strm.avail_in + PPP_HDRLEN + DEFLATE_OVHD;
+ state->strm.next_out = wptr;
+ state->strm.avail_out = state->mru + 2;
+@@ -278,7 +290,7 @@ z_decompress(arg, mi, inlen, mo, outlenp
+ return DECOMP_FATALERROR;
+ }
+ olen = state->mru + 2 - state->strm.avail_out;
+- *outlenp = olen;
++ (*mo)->len = olen;
+
+ if ((wptr[0] & 1) != 0)
+ ++olen; /* for suppressed protocol high byte */
+@@ -302,10 +314,9 @@ z_decompress(arg, mi, inlen, mo, outlenp
+ * Incompressible data has arrived - add it to the history.
+ */
+ static void
+-z_incomp(arg, mi, mlen)
++z_incomp(arg, mi)
+ void *arg;
+- u_char *mi;
+- int mlen;
++ PACKETPTR mi;
+ {
+ struct deflate_state *state = (struct deflate_state *) arg;
+ u_char *rptr;
+@@ -314,7 +325,7 @@ z_incomp(arg, mi, mlen)
+ /*
+ * Check that the protocol is one we handle.
+ */
+- rptr = mi;
++ rptr = mi->buf;
+ proto = rptr[0];
+ if ((proto & 1) == 0)
+ proto = (proto << 8) + rptr[1];
+@@ -325,7 +336,7 @@ z_incomp(arg, mi, mlen)
+
+ if (rptr[0] == 0)
+ ++rptr;
+- rlen = mi + mlen - rptr;
++ rlen = mi->buf + mi->len - rptr;
+ state->strm.next_in = rptr;
+ state->strm.avail_in = rlen;
+ r = inflateIncomp(&state->strm);
diff --git a/net/pppd/patches/patch-bh b/net/pppd/patches/patch-bh
new file mode 100644
index 00000000000..19314b1d02b
--- /dev/null
+++ b/net/pppd/patches/patch-bh
@@ -0,0 +1,37 @@
+$NetBSD: patch-bh,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/ppp-comp.h.orig 2002-12-06 10:49:16.000000000 +0100
++++ pppdump/ppp-comp.h
+@@ -57,6 +57,19 @@
+ struct compressor {
+ int compress_proto; /* CCP compression protocol number */
+
++ /* Allocate space for a compressor (transmit side) */
++ void *(*comp_alloc) __P((u_char *, int));
++ /* Free space used by a compressor */
++ void (*comp_free) __P((void *));
++ /* Initialize a compressor */
++ int (*comp_init) __P((void *, u_char *, int, int, int, int));
++ /* Reset a compressor */
++ void (*comp_reset) __P((void *));
++ /* Compress a packet */
++ int (*compress) __P((void *, PACKETPTR *, PACKETPTR));
++ /* Return compression statistics */
++ void (*comp_stat) __P((void *, struct compstat *));
++
+ /* Allocate space for a decompressor (receive side) */
+ void *(*decomp_alloc) __P((u_char *options, int opt_len));
+ /* Free space used by a decompressor */
+@@ -67,10 +80,9 @@ struct compressor {
+ /* Reset a decompressor */
+ void (*decomp_reset) __P((void *state));
+ /* Decompress a packet. */
+- int (*decompress) __P((void *state, u_char *mp, int inlen,
+- u_char *dmp, int *outlen));
++ int (*decompress) __P((void *state, PACKETPTR, PACKETPTR *));
+ /* Update state for an incompressible packet received */
+- void (*incomp) __P((void *state, u_char *mp, int len));
++ void (*incomp) __P((void *state, PACKETPTR));
+ /* Return decompression statistics */
+ void (*decomp_stat) __P((void *state, struct compstat *stats));
+ };
diff --git a/net/pppd/patches/patch-bi b/net/pppd/patches/patch-bi
new file mode 100644
index 00000000000..8a5c2cff087
--- /dev/null
+++ b/net/pppd/patches/patch-bi
@@ -0,0 +1,99 @@
+$NetBSD: patch-bi,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/pppdump.c.orig 2004-02-02 04:36:46.000000000 +0100
++++ pppdump/pppdump.c
+@@ -38,8 +38,13 @@
+ #include <stdlib.h>
+ #include <time.h>
+ #include <sys/types.h>
+-#include "ppp_defs.h"
++#include "pppdump.h"
++#include <net/ppp_defs.h>
++#ifdef __NetBSD__
++#include <net/ppp-comp.h>
++#else
+ #include "ppp-comp.h"
++#endif
+
+ int hexmode;
+ int pppmode;
+@@ -51,6 +56,15 @@ time_t start_time;
+ int start_time_tenths;
+ int tot_sent, tot_rcvd;
+
++struct pkt {
++ int cnt;
++ int esc;
++ int flags;
++ struct compressor *comp;
++ void *state;
++ unsigned char buf[8192];
++} spkt, rpkt;
++
+ extern int optind;
+ extern char *optarg;
+
+@@ -191,7 +205,7 @@ dumplog(f)
+ show_time(f, c);
+ break;
+ default:
+- printf("?%.2x\n");
++ printf("?%.2x\n", c);
+ }
+ }
+ }
+@@ -234,15 +248,6 @@ static u_short fcstab[256] = {
+ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
+ };
+
+-struct pkt {
+- int cnt;
+- int esc;
+- int flags;
+- struct compressor *comp;
+- void *state;
+- unsigned char buf[8192];
+-} spkt, rpkt;
+-
+ /* Values for flags */
+ #define CCP_ISUP 1
+ #define CCP_ERROR 2
+@@ -321,7 +326,7 @@ dumpppp(f)
+ ++r;
+ if (endp - r > mru)
+ printf(" ERROR: length (%d) > MRU (%d)\n",
+- endp - r, mru);
++ (int)(endp - r), mru);
+ if (decompress && fcs == PPP_GOODFCS) {
+ /* See if this is a CCP or compressed packet */
+ d = dbuf;
+@@ -340,8 +345,15 @@ dumpppp(f)
+ && (pkt->flags & CCP_DECOMP_RUN)
+ && pkt->state
+ && (pkt->flags & CCP_ERR) == 0) {
+- rv = pkt->comp->decompress(pkt->state, r,
+- endp - r, d, &dn);
++ struct packet in, out, *outp;
++ in.buf = r;
++ in.len = endp - r;
++ out.buf = d;
++ outp = &out;
++ rv = pkt->comp->decompress(pkt->state, &in,
++ &outp);
++ dn = outp->len;
++ d = outp->buf;
+ switch (rv) {
+ case DECOMP_OK:
+ p = dbuf;
+@@ -364,7 +376,10 @@ dumpppp(f)
+ }
+ } else if (pkt->state
+ && (pkt->flags & CCP_DECOMP_RUN)) {
+- pkt->comp->incomp(pkt->state, r, endp - r);
++ struct packet in;
++ in.buf = r;
++ in.len = endp - r;
++ pkt->comp->incomp(pkt->state, &in);
+ }
+ }
+ do {
diff --git a/net/pppd/patches/patch-bj b/net/pppd/patches/patch-bj
new file mode 100644
index 00000000000..e9388ae24c9
--- /dev/null
+++ b/net/pppd/patches/patch-bj
@@ -0,0 +1,49 @@
+$NetBSD: patch-bj,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppdump/pppdump.h.orig 2004-12-31 23:51:00.000000000 +0100
++++ pppdump/pppdump.h
+@@ -0,0 +1,44 @@
++/* NetBSD: pppdump.h,v 1.1 2002/05/29 19:07:13 christos Exp */
++
++/*-
++ * Copyright (c) 2002 The NetBSD Foundation, Inc.
++ * All rights reserved.
++ *
++ * This code is derived from software contributed to The NetBSD Foundation
++ * by Christos Zoulas.
++ *
++ * 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 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 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 FOUNDATION 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.
++ */
++
++struct packet {
++ u_char *buf;
++ int len;
++};
++
++#define PACKETPTR struct packet *
diff --git a/net/pppd/patches/patch-bk b/net/pppd/patches/patch-bk
new file mode 100644
index 00000000000..bb36e7bbce1
--- /dev/null
+++ b/net/pppd/patches/patch-bk
@@ -0,0 +1,13 @@
+$NetBSD: patch-bk,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppstats/Makefile.linux.orig 2004-10-31 23:09:03.000000000 +0100
++++ pppstats/Makefile.linux
+@@ -4,7 +4,7 @@
+ #
+ DESTDIR = @DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+-MANDIR = $(DESTDIR)/share/man/man8
++MANDIR = $(DESTDIR)/man/man8
+
+ PPPSTATSRCS = pppstats.c
+ PPPSTATOBJS = pppstats.o
diff --git a/net/pppd/patches/patch-bl b/net/pppd/patches/patch-bl
new file mode 100644
index 00000000000..0e6294ab600
--- /dev/null
+++ b/net/pppd/patches/patch-bl
@@ -0,0 +1,40 @@
+$NetBSD: patch-bl,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppstats/Makefile.netbsd.orig 2004-12-31 23:51:00.000000000 +0100
++++ pppstats/Makefile.netbsd
+@@ -0,0 +1,35 @@
++#
++# pppstats makefile
++#
++DESTDIR = @DESTDIR@
++BINDIR = $(DESTDIR)/sbin
++MANDIR = $(DESTDIR)/man/man8
++
++PPPSTATSRCS = pppstats.c
++PPPSTATOBJS = pppstats.o
++
++#CC = gcc
++COPTS = -O
++COMPILE_FLAGS = -I../include
++LIBS =
++
++INSTALL= install
++
++CFLAGS = $(COPTS) $(COMPILE_FLAGS)
++
++all: pppstats
++
++install: pppstats
++ -mkdir -p $(MANDIR)
++ $(INSTALL) -s -c pppstats $(BINDIR)
++ $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)
++
++pppstats: $(PPPSTATSRCS)
++ $(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
++
++clean:
++ rm -f pppstats *~ #* core
++
++depend:
++ cpp -M $(CFLAGS) $(PPPSTATSRCS) >.depend
++# makedepend $(CFLAGS) $(PPPSTATSRCS)
diff --git a/net/pppd/patches/patch-bm b/net/pppd/patches/patch-bm
new file mode 100644
index 00000000000..f08f566f10d
--- /dev/null
+++ b/net/pppd/patches/patch-bm
@@ -0,0 +1,26 @@
+$NetBSD: patch-bm,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- pppstats/pppstats.8.orig 2004-11-13 13:22:49.000000000 +0100
++++ pppstats/pppstats.8
+@@ -14,10 +14,10 @@ pppstats \- print PPP statistics
+ .B \-z
+ ] [
+ .B \-c
+-.I <count>
++.I \*[Lt]count\*[Gt]
+ ] [
+ .B \-w
+-.I <secs>
++.I \*[Lt]secs\*[Gt]
+ ] [
+ .I interface
+ ]
+@@ -172,7 +172,7 @@ option is specified.
+ When the
+ .B \-z
+ option is specified,
+-.Nm pppstats
++.B pppstats
+ instead displays the following fields, relating to the packet
+ compression algorithm currently in use. If packet compression is not
+ in use, these fields will all display zeroes. The fields displayed on
diff --git a/net/pppd/patches/patch-bn b/net/pppd/patches/patch-bn
new file mode 100644
index 00000000000..a0e37dfbe30
--- /dev/null
+++ b/net/pppd/patches/patch-bn
@@ -0,0 +1,13 @@
+$NetBSD: patch-bn,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- solaris/Makedefs.gcc.orig 2004-10-30 06:13:29.000000000 +0200
++++ solaris/Makedefs.gcc
+@@ -6,7 +6,7 @@ INSTALL= /usr/sbin/install
+
+ BINDIR = @DESTDIR@/bin
+ MANDIR = @DESTDIR@/man
+-ETCDIR = @SYSCONF@/ppp
++ETCDIR = @SYSCONF@
+
+ CC = gcc
+ COPTS = -O2
diff --git a/net/pppd/patches/patch-bo b/net/pppd/patches/patch-bo
new file mode 100644
index 00000000000..d3076da914f
--- /dev/null
+++ b/net/pppd/patches/patch-bo
@@ -0,0 +1,13 @@
+$NetBSD: patch-bo,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $
+
+--- solaris/Makedefs.orig 2004-10-30 05:44:06.000000000 +0200
++++ solaris/Makedefs
+@@ -6,7 +6,7 @@ INSTALL= /usr/sbin/install
+
+ BINDIR = @DESTDIR@/bin
+ MANDIR = @DESTDIR@/man
+-ETCDIR = @SYSCONF@/ppp
++ETCDIR = @SYSCONF@
+
+ CC = /opt/SUNWspro/bin/cc
+ COPTS = -O -Xa