]> git.ozlabs.org Git - ppp.git/commitdiff
Remove files that don't go into releases
authorPaul Mackerras <paulus@samba.org>
Sun, 27 Jul 2008 12:23:45 +0000 (22:23 +1000)
committerPaul Mackerras <paulus@samba.org>
Sun, 27 Jul 2008 12:23:45 +0000 (22:23 +1000)
This mainly removes files specific to platforms that we no longer support,
and removes a few other outdated files.

Signed-off-by: Paul Mackerras <paulus@samba.org>
173 files changed:
NeXT/ChangeLog.rtf [deleted file]
NeXT/Examples/NXHosting_with_PPP [deleted file]
NeXT/Examples/Persistent_Connection [deleted file]
NeXT/Examples/README [deleted file]
NeXT/Examples/chap-secrets.example [deleted file]
NeXT/Examples/flow-control-hints [deleted file]
NeXT/Examples/ip-down.example [deleted file]
NeXT/Examples/ip-up.example [deleted file]
NeXT/Examples/options.example [deleted file]
NeXT/Examples/pap-secrets.example [deleted file]
NeXT/Examples/ppp_multiple_hosts.tar.gz [deleted file]
NeXT/Examples/pppdown [deleted file]
NeXT/Examples/pppkill.c [deleted file]
NeXT/Examples/pppup.annex [deleted file]
NeXT/Examples/pppup.direct [deleted file]
NeXT/Examples/pppup.portmaster [deleted file]
NeXT/Examples/pppup.remote [deleted file]
NeXT/Examples/pppup.zyxel [deleted file]
NeXT/Examples/redial.sh [deleted file]
NeXT/INSTALL [deleted file]
NeXT/Load_Commands.sect [deleted file]
NeXT/Makefile [deleted file]
NeXT/Makefile.top [deleted file]
NeXT/NeXT_Version.h [deleted file]
NeXT/TODO.NeXT [deleted file]
NeXT/Unload_Commands.sect [deleted file]
NeXT/bsd-comp.c [deleted file]
NeXT/hppa/README.hppa [deleted file]
NeXT/if_ppp.c [deleted file]
NeXT/if_pppvar.h [deleted file]
NeXT/inlines.h [deleted file]
NeXT/libposix/Makefile [deleted file]
NeXT/libposix/libposix.c [deleted file]
NeXT/linedisc.h [deleted file]
NeXT/mach/features.h [deleted file]
NeXT/nbq.h [deleted file]
NeXT/netbuf.h [deleted file]
NeXT/ppp_tty.c [deleted file]
NeXT/spl.h [deleted file]
NeXT/vjcompress.c [deleted file]
README.NeXT [deleted file]
README.aix4 [deleted file]
README.bsd [deleted file]
README.osf [deleted file]
README.sunos4 [deleted file]
README.svr4 [deleted file]
README.ultrix [deleted file]
TODO [deleted file]
aix4/Makefile [deleted file]
aix4/Makefile.top [deleted file]
aix4/load [deleted file]
aix4/ppp_async.c [deleted file]
aix4/ppp_async.exp [deleted file]
aix4/ppp_comp.c [deleted file]
aix4/ppp_if.c [deleted file]
aix4/ppp_if.exp [deleted file]
chat/Makefile.NeXT [deleted file]
chat/Makefile.aix4 [deleted file]
chat/Makefile.bsd [deleted file]
chat/Makefile.netbsd-1.2 [deleted file]
chat/Makefile.osf [deleted file]
chat/Makefile.sunos4 [deleted file]
chat/Makefile.svr4 [deleted file]
chat/Makefile.ultrix [deleted file]
freebsd-2.0/Makefile.top [deleted file]
freebsd-2.0/files-2.2.patch [deleted file]
freebsd-2.0/files.patch [deleted file]
freebsd-2.0/if_ppp.c [deleted file]
freebsd-2.0/if_pppvar.h [deleted file]
freebsd-2.0/kinstall.sh [deleted file]
freebsd-2.0/ppp_defs.h [deleted file]
freebsd-2.0/ppp_tty.c [deleted file]
freebsd-2.0/pppcompress.c [deleted file]
freebsd-2.0/pppcompress.h [deleted file]
freebsd-2.2.8/Makefile.top [deleted file]
freebsd-2.2.8/kinstall.sh [deleted file]
freebsd-2.2.8/patch.if_ppp.c [deleted file]
freebsd-2.2.8/patch.if_ppp.h [deleted file]
freebsd-2.2.8/patch.ppp_tty.c [deleted file]
freebsd-3.0/Makefile.top [deleted file]
freebsd-3.0/kinstall.sh [deleted file]
freebsd-3.0/patch.if_ppp.c [deleted file]
freebsd-3.0/patch.if_ppp.h [deleted file]
freebsd-3.0/patch.ppp_tty.c [deleted file]
freebsd-3.0/patch.ttycom.h [deleted file]
linux/patch-include [deleted file]
linux/ppp.c [deleted file]
linux/ppp_deflate.c [deleted file]
netbsd-1.1/Makefile.top [deleted file]
netbsd-1.1/bsd-comp.c [deleted file]
netbsd-1.1/files.oldconf.patch [deleted file]
netbsd-1.1/files.patch [deleted file]
netbsd-1.1/if_ppp.c [deleted file]
netbsd-1.1/if_pppvar.h [deleted file]
netbsd-1.1/kinstall.sh [deleted file]
netbsd-1.1/ppp-deflate.c [deleted file]
netbsd-1.1/ppp_tty.c [deleted file]
netbsd-1.1/slcompress.c [deleted file]
netbsd-1.1/slcompress.h [deleted file]
netbsd-1.2/Makefile.top [deleted file]
netbsd-1.2/bsd-comp.c [deleted file]
netbsd-1.2/if_ppp.c [deleted file]
netbsd-1.2/if_pppvar.h [deleted file]
netbsd-1.2/kinstall.sh [deleted file]
netbsd-1.2/ppp-deflate.c [deleted file]
netbsd-1.2/ppp_tty.c [deleted file]
netbsd-1.2/slcompress.c [deleted file]
netbsd-1.2/slcompress.h [deleted file]
osf1/Makefile [deleted file]
osf1/Makefile.top [deleted file]
osf1/makevers [deleted file]
osf1/ppp_init.c [deleted file]
pppd/Makefile.NeXT [deleted file]
pppd/Makefile.aix4 [deleted file]
pppd/Makefile.bsd [deleted file]
pppd/Makefile.netbsd-1.2 [deleted file]
pppd/Makefile.osf [deleted file]
pppd/Makefile.sunos4 [deleted file]
pppd/Makefile.svr4 [deleted file]
pppd/Makefile.ultrix [deleted file]
pppd/sys-NeXT.c [deleted file]
pppd/sys-aix4.c [deleted file]
pppd/sys-bsd.c [deleted file]
pppd/sys-osf.c [deleted file]
pppd/sys-sunos4.c [deleted file]
pppd/sys-svr4.c [deleted file]
pppd/sys-ultrix.c [deleted file]
pppdump/Makefile.sunos4 [deleted file]
pppdump/Makefile.svr4 [deleted file]
pppstats/Makefile.NeXT [deleted file]
pppstats/Makefile.aix4 [deleted file]
pppstats/Makefile.bsd [deleted file]
pppstats/Makefile.netbsd-1.2 [deleted file]
pppstats/Makefile.osf [deleted file]
pppstats/Makefile.sunos4 [deleted file]
pppstats/Makefile.svr4 [deleted file]
pppstats/Makefile.ultrix [deleted file]
sunos4/Makedefs [deleted file]
sunos4/Makefile [deleted file]
sunos4/Makefile.top [deleted file]
sunos4/if_ppp_vdcmd.c [deleted file]
sunos4/ppp.INSTALL [deleted file]
sunos4/ppp_ahdlc_vdcmd.c [deleted file]
sunos4/ppp_comp_vdcmd.c [deleted file]
sunos4/ppp_vdcmd.c [deleted file]
svr4/Makedefs [deleted file]
svr4/Makedefs.sol2 [deleted file]
svr4/Makefile.sol2 [deleted file]
svr4/Makefile.sol2-64 [deleted file]
svr4/Makefile.svr4 [deleted file]
svr4/Makefile.top [deleted file]
svr4/ppp.Master [deleted file]
svr4/ppp.Node [deleted file]
svr4/ppp.System [deleted file]
svr4/ppp.conf [deleted file]
svr4/ppp_ahdl.Master [deleted file]
svr4/ppp_ahdl.System [deleted file]
svr4/ppp_ahdlc_mod.c [deleted file]
svr4/ppp_comp.Master [deleted file]
svr4/ppp_comp.System [deleted file]
svr4/ppp_comp_mod.c [deleted file]
svr4/ppp_mod.c [deleted file]
ultrix/Makefile.top [deleted file]
ultrix/bsd-comp.c [deleted file]
ultrix/if_ppp.c [deleted file]
ultrix/if_ppp.h [deleted file]
ultrix/if_pppvar.h [deleted file]
ultrix/patches [deleted file]
ultrix/ppp-deflate.c [deleted file]
ultrix/ppp_tty.c [deleted file]
ultrix/slcompress.c [deleted file]
ultrix/slcompress.h [deleted file]
ultrix/upgrade [deleted file]

diff --git a/NeXT/ChangeLog.rtf b/NeXT/ChangeLog.rtf
deleted file mode 100644 (file)
index 25c5e98..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-{\rtf0\ansi{\fonttbl\f0\fmodern Courier;\f1\fswiss Helvetica;\f2\fmodern Ohlfs;}
-\paperw12040
-\paperh11720
-\margl40
-\margr40
-{\colortbl;\red59\green11\blue84;\red0\green0\blue0;\red19\green34\blue84;\red6\green0\blue85;}
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs24\fc0\cf0 \
-
-\b\gray128\fc1\cf1 11
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Jul 10 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/Documentation/WWW Pages/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Fixed\
-       
-\b0 \
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b\i\gray136\fc3\cf3         Mail setup for FAQ\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [perkins Wed Jul 10 14:59:39 EDT 1996]\
-[perkins Wed Jun 05 21:31:44 EDT 1996]\
-On 06/04/96, Francois Magnan wrote:\
-
-\gray46\fc4\cf4 >\
->I have written down the steps I did to configure sendmail 8.7.5 for a \
->standalone machine using a dial up PPP connection to link to the \
->internet. It uses the user database to set From and Reply to fields \
->correctly to each user of the system own's Pop account (in all \
->outgoing mail). Is there a need for this? Should I post it? Could an \
->expert verify it before an unexperienced user try this???\
->\
->Thank you,\
->Francois Magnan\
->   \
->-- \
->______________________________________________________\
->Francois Magnan\
->Departement de Mathematique & Statistiques\
->Universite de Montreal\
->email: magnan@mathcn.umontreal.ca (MIME, NeXTMail Ok!)\
->\
->\
-
-\gray0\fc0\cf0 \
-Sorry for this.... My news server was always telling me it could not \
-send the post.\
-\
-Francois\
-\
-\
--- \
-______________________________________________________\
-Francois Magnan\
-Departement de Mathematique & Statistiques\
-Universite de Montreal\
-email: magnan@mathcn.umontreal.ca (MIME, NeXTMail Ok!)\
-\
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 \
-
-\b\gray128\fc1\cf1 13
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Jul 10 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/PPP Daemon/Interoperation/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Open\
-       
-\b0 \
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b\i\gray136\fc3\cf3         PPP-2.2 doesn't negotiate well with Netcom's PPP server using bsdcomp\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [perkins Wed Jul 10 15:01:24 EDT 1996]\
-\
-[aisbell@cubicsol.com Mon Jun 17 16:47:27 CDT 1996]\
-    Using the default PPP options file which specifies the "bsdcomp 10,10" pppd option, negotiation with Netcom's PPP server has been problematic since early June, 1996.  Negotiation succeeds, ipcp comes up, but then the Netcom server resends a negotiation packet causing ipcp to be brought down followed by successful renegotiation bringing ipcp up.  This causes ip-up to run, then ip-down, and then ip-up again.  Depending on what is being done in ip-up and ip-down, this multiple repeated execution, possibly concurrently, can cause problems.\
-\
-    However, BSD compression negotiation is rejected by the Netcom server.  So by disabling BSD compression negotiation (i.e., specifying the "-bsdcomp" instead of the "bsdcomp 10,10" pppd option), this problem seems to disappear.
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               \
-
-\b\gray128\fc1\cf1 15
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Jul 10 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/Kernel Server/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Open\
-       
-\b0 \
-
-\b\i\gray136\fc3\cf3   PPP running out of netbuffers & thrashing\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [perkins Wed Jul 10 15:02:51 EDT 1996]\
-\
-[rvose@ix.netcom.com Wed Jun 26 01:03:20 CDT 1996]\
-You'll have to excuse me if this is categorized wrong.  I'm a PPP newbie.\
-\
-I'm running PPP 2.2.046 on a NeXTstation Turbo Color w/32MB RAM to access my ISP over a modem.  Certain operations cause my system to thrash until I break into the NMI to stop it.  When I look at messages in the NMI, at the very end are several errors from PPP indicating that it's out of 'netbuffers'  I'm not sure if PPP is causing the trash, but the netbuffer errors seemed to point to it.  A friend of mine running the same configuration has the same problems.\
-\
-I'm looking for a way to recreate the problem on demand, and will forward that on when I find it.  The trashing usually appears while using OmniWeb 2.0.1 from Lighthouse Design, but I've had similar problems using NetSurfer.  The problem seems to happen much faster with NetSurfer.\
-\
-Again, I'll try to get you more details.  Does this sound like a PPP problem? 
-\b \
- ===============================================\
-\
-
-\b0 [perkins Mon Jul 01 10:33:36 EDT 1996]\
-\
-See Bug #16 for more information.\
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               \
-
-\b\gray128\fc1\cf1 16
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Jul 10 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/Kernel Server/Panic/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Obsolete\
-       
-\b0 \
-
-\b\i\gray136\fc3\cf3   Re: PPP causing thrashing - Tracking ID 15\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [perkins Wed Jul 10 15:04:07 EDT 1996]\
-\
-[rvose@ix.netcom.com Mon Jul  1 04:37:03 CDT 1996]\
-Last week I had submitted report indicating that my NeXTstation Color Turbo machine ran out of network buffers and thrashed to the point of crashing.  The tracking ID assigned was 16.\
-\
-I believe that this problem may have been due to my swapfile size growing beyond the high-water mark.  My machine crashed several times this evening (thrashing) while connected and I happened to notice that the swapfile size was pushing the hiwat limit.  I increased the hiwat limit on the file from 40 MB (which is the NeXT default) to 105 MB (the partition size where the file residess - it's on its own drive) and voila!  No more thrashing.  I've been connected over PPP and hitting the system hard with network transactions with ZERO difficulties.\
-\
-Just wanted to pass that info along.  I'm not sure if the combination of the system hitting the hiwat mark on the swapfile + PPP needing more resources caused the thrashing problem, but it seems reasobable.\
-\
-Thanks...\
-\
-Randy\
-rvose@ix.netcom.com\
-\
-\b \
- ===============================================\
-\
-
-\b0 [perkins Mon Jul 01 10:33:24 EDT 1996]\
-\
-This bug is in relation to bug #15\
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               \
-
-\b\gray128\fc1\cf1 21
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Aug 10 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/PPP Daemon/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Fixed\
-       
-\b0 \
-
-\b\i\gray136\fc3\cf3   ip-up and ip-down examples need updating\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [perkins Sat Aug 10 09:41:59 EDT 1996]\
-\
-Update ip-up and ip-down examples.\
-\
-\
-\
-\
-ams@best.com (Samuel G. Streeper) wrote:\
-\
-
-\gray46\fc4\cf4 > You need to restart the nameserver on your home system when\
-> you bring PPP up:\
-> \
->      kill -USR2 <nmserver pid>\
-> \
-> (You may want to do this in your ppp-up script)  I've heard some\
-> people also do the same with lookupd but that hasn't been necessary\
-> for me.\
-
-\gray0\fc0\cf0 \
-    Sending the pre-OS 4.0 lookupd a USR2 signal causes it to toggle logging, \
-but sending it a HUP signal forces it to restart and thus read any new \
-resolv.conf indo.  You shouldn't have to do this unless you need to use \
-different nameservers when establishing your PPP connection.  I need to \
-connect to several different PPP servers, so I slide in the correct \
-resolv.conf and send resolv.conf a HUP signal in pppd's ip-up.\
-\
-    Note that sending the OS 4.0 lookupd a HUP signal won't cause it to \
-restart.  Restarting it manually will leave the system unusable until a \
-reboot :-(  NeXT is aware of this problem.\
--- \
-Art Isbell                      NeXT/MIME Mail: aisbell@ix.netcom.com\
-Trego Systems                              Voice/Fax: +1 408 335 2515\
-CaseServ:  NEXTSTEP/OpenStep              Voice Mail: +1 408 335 1154\
-   managed care solutions              US Mail: Felton, CA 95018-9442\
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               \
-
-\b\gray128\fc1\cf1 22
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Aug 13 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/PPP Daemon/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Open\
-       
-\b0 \
-
-\b\i\gray136\fc3\cf3   NXHosting \
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [perkins Tue Aug 13 09:06:52 EDT 1996]\
-\
-In article <4ule10$g2t@nuke.csu.net>, John Rudd <kzin@arcadia.sjsu.edu> wrote:\
-
-\gray46\fc4\cf4 >(isc-ts2-* are our dialup PPP lines.. each line in the hunt group has a \
->different IP addy associated with it.. so you are likely to get a different \
->one each time.  And this is why I can't do the "Services -> OpenSesame -> \
->Open on host X", because that sends "-NXHost copernicus".. which is what my \
->home machine internally identifies itself as)\
-
-\gray0\fc0\cf0 \
-The only way to get -NXHost to work over PPP is to have an IP address\
-assigned to your Ethernet port, and have a route to that address\
-reachable over the PPP.\
-\
-When you try to -NXHost, it uses UDP, and for some reason the UDP\
-protocol decides to use the Ethernet's IP address for outgoing\
-packets, rather than using the PPP's IP address.\
-\
-You'll also have similar problems trying to get talk to work over\
-PPP. Unless there is a route to your Ethernet's IP address, it isn't\
-going to work.\
-\
--- \
-Chris Osborn, Network Administrator     Napa Valley College\
-707 253 3130 - Voice                    2277 Napa-Vallejo Hwy.\
-707 253 3063 - Fax                      Napa, CA 94558\
-<fozztexx@nvc.cc.ca.us>    <¬http://www.nvc.cc.ca.us/~fozztexx>\
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               \
-
-\b\gray128\fc1\cf1 25
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 perkins
-\b0    
-\b\fc0\cf0 Sep 17 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/Documentation/Installation Instructions/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Fixed\
-       
-\b0 \
-
-\b\i\gray136\fc3\cf3   typo?\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [sysadmin Tue Sep 17 12:05:33 EDT 1996]\
-In ./NeXT/INSTALL, I assume '-DBPFILTER' in the second paragraph  \
-should be '-DNBPFILTER'? And the third paragraph applies with the  \
-second paragraph condition?\
-\
- 4) If you plan in using tcpdump to monitor packets, you must\
-    enable the Berkley Packet Filter code.  Edit ./NeXT/Makefile\
-    and make sure the '-DNBPFILTER' option is defined in DFLAGS.\
-    WARNING: If you choose to use BPF, you must make sure that you\
-    compile _AND LOAD_ the bpf_reloc LKS _BEFORE_ you load the\
-    ppp_reloc LKS.  See the ./NeXT/bpf directory for more  \
-information.\
-\
-    If you don't want to compile in this code, please make sure that\
-    '-DBPFILTER' is _not_ defined in the ./NeXT/Makefile DFLAGS.\
-\
-    Also, make sure you read the installation file in ./NeXT/bpf.   \
-You\
-    will need to create a few special device files in /dev/.\
-\
-Stephen Johnson\
-stephen@ccc1.tamu.edu\
-\
-\
-
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               \
-
-\b\gray128\fc1\cf1 26
-\b0\gray0\fc0\cf0      Submitted:      
-\b\fc2\cf2 J. P. McCann
-\b0    
-\b\fc0\cf0 Oct 06 1996 00:00\
-       
-\b0 Topic:             
-\b /PPP-2.x/PPP Daemon/Option Handling/
-\b0 \
-       Owner:          
-\b perkins 
-\b0 (nobody)
-\b \
-
-\b0    Status:         
-\b Superseded\
-       
-\b0 \
-
-\b\i\gray136\fc3\cf3   Netcom ISP hookups disconnect with bsdcomp values\
-
-\i0\gray0\fc0\cf0      
-\b0 \
-
-\pard\tx1480\tx2020\tx2560\tx3080\tx3620\tx4160\tx4680\tx5220\tx5760\tx6280\f1\li960\fc0\cf0 [jpmeia@ix.netcom.com Sun Oct  6 20:11:22 CDT 1996]\
-When trying to connect to Netcom with any bsdcomp values (eg, bsdcomp 10,10) in the options script, connection will fail vice ignore bsdcomp.  Must use the "-bsdcomp" option to negotiate a connection that does not fail.
-\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\li960\fc0\cf0 \
-
-\li0 \
-Trackers:      perkins\
-               
-}
diff --git a/NeXT/Examples/NXHosting_with_PPP b/NeXT/Examples/NXHosting_with_PPP
deleted file mode 100644 (file)
index 7c744c4..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-From: gbrown@alumni.caltech.edu (Glenn Brown)
-Subject: Re: ppp and NXHost problems
-Date: 23 Nov 1994 07:37:57 GMT
-Organization: California Institute of Technology, Pasadena
-
-If you want to NXHost over PPP, Simply execute the following 7 lines
-after the ppp connection has been brought up (these are simply the
-lines from the rc.net script that signal the nmserver that it should
-check for new interfaces.  Note that the kill command does not kill the
-nmserver.  Rather, it sends the "USR2" signal to the nmserver.)
-
-#!/bin/sh
-#  Let the nmserver know the fruits of our network configuration endeavor.
-pid=`ps cax | egrep nmserver | awk '{print $1;}'`
-if [ -n "$pid" ]; then
-    echo "Reinitializing nmserver's network portion"
-    /bin/kill -USR2 $pid
-fi
-
-Note 1: You have to executed the lines under "sh".  I suggest you
-save them in a file and type "/bin/sh file".
-
-Note 2: I haven't actually tried this (I don't have another NeXT to
-test it on), but I figured out out reading the rc scripts.  Please let
-me know the result if you try it.
-
---Glenn
-
-----------------------------------------------------------------------
-
-In article <4ule10$g2t@nuke.csu.net>, John Rudd <kzin@arcadia.sjsu.edu> wrote:
->(isc-ts2-* are our dialup PPP lines.. each line in the hunt group has a 
->different IP addy associated with it.. so you are likely to get a different 
->one each time.  And this is why I can't do the "Services -> OpenSesame -> 
->Open on host X", because that sends "-NXHost copernicus".. which is what my 
->home machine internally identifies itself as)
-
-The only way to get -NXHost to work over PPP is to have an IP address
-assigned to your Ethernet port, and have a route to that address
-reachable over the PPP.
-
-When you try to -NXHost, it uses UDP, and for some reason the UDP
-protocol decides to use the Ethernet's IP address for outgoing
-packets, rather than using the PPP's IP address.
-
-You'll also have similar problems trying to get talk to work over
-PPP. Unless there is a route to your Ethernet's IP address, it isn't
-going to work.
-
--- 
-Chris Osborn, Network Administrator     Napa Valley College
-707 253 3130 - Voice                    2277 Napa-Vallejo Hwy.
-707 253 3063 - Fax                      Napa, CA 94558
-<fozztexx@nvc.cc.ca.us>    <¬http://www.nvc.cc.ca.us/~fozztexx>
-
-
diff --git a/NeXT/Examples/Persistent_Connection b/NeXT/Examples/Persistent_Connection
deleted file mode 100644 (file)
index 0813c51..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#! /usr/bin/perl
-
-# ip-down -- executed by pppd on connection death
-#
-# This particular implementation of ip-down attempts to re-establish
-# the ppp connection.  It does this by first forking and having the
-# parent die (returning control to the invoking pppd for final
-# cleanup).
-#
-# The child waits until the specified port (pppd passes the path to
-# the port's device as argument 2) is available and launches pppd (or
-# whatever is specfied by $PATH_pppd.
-#
-# This script requires "syslog.pl" (included with perl).  Because of
-# this, it also requires "syslog.ph";  "syslog.ph" can be
-# manufactured using the h2ph script included with the perl
-# distribution.  Under NeXTSTEP, one can create syslog.ph by:
-#
-#        h2ph < /usr/include/bsd/sys/syslog.h > syslog.ph
-#
-# 'syslog.ph' should either be copied into your machines perl library
-# (wherever syslog.pl resides), or you should add wherever syslog.ph
-# resides to Perl's library search path.
-#
-# Removing all references to syslog (including openlog() and
-# closelog()) will also work, but will render this script's execution
-# completely silent.
-#
-# By default, this script logs to the default target for ppp's logs --
-# LOCAL2.
-#
-# hacqued by: <bbum@friday.com>, jan 30 1995
-#
-# Please send any changes/improvements to <bbum@friday.com>.  And
-# please try not to laugh at this code... or, at least, tell me why
-# you are laughing so I won't make the same mistakes twice.
-
-# ABSOLUTE path to PPP daemon (or whatever you want executed after the
-# port becomes available).
-
-$PATH_pppd = "/usr/local/ppp/bin/pppd";
-
-# number of seconds to sleep between checking for port availability
-$lock_sleep = 2;
-
-require "syslog.pl";
-
-FORK: {
-    if ($pid = fork) {
-       # this is the parent.  It must die so the old pppd can
-       # clean-up and exit.
-       exit;
-    } elsif ($! =~ /No more process/) {
-       # oops! ran out of processes.  This is supposed to be a
-       # recoverable error, so sleep and try again.
-       sleep 5;
-       redo FORK;      
-    } elsif (!defined($pid)) {
-       # fork error -- log it and die.
-       &openlog("pppd/ip-down", 'cons,pid', LOG_LOCAL2);
-       &syslog('warning',
-               "Fork() error '$!'");
-       &closelog;
-       die "can't fork: $!\n";
-    }
-}
-
-# everything from here down is the child.
-&openlog("pppd/ip-down", 'cons,pid', LOG_LOCAL2);
-
-if ( ! @ARGV ) {
-    # no arguments -- exec specified thing (assume the process
-    # being called has a clue about what port it should use)
-
-    &syslog('info', "No device specified. Executing '$PATH_pppd'.");
-    &closelog;
-
-    exec $PATH_pppd;
-    ## NOT REACHED: exec never returns
-}
-
-# (assume-- it will if pppd starts ip-down)
-# ARGV contains:
-#          interface-name tty-device speed local-IP-address
-#          remote-IP-address
-($interface_name,
- $tty_device,
- $speed,
- $local_IP_address,
- $remote_IP_address) = @ARGV;
-
-# find the raw device name
-@path = split ('/', $tty_device);
-$device = pop @path;
-
-# Generate path to lock file -- assumes NeXT style device locking
-$lock = "/usr/spool/uucp/LCK/LCK..$device";
-
-# log some info.
-&syslog('info',
-       "Reconnecting '$interface_name' ($local_IP_address:$remote_IP_address) through '$tty_device' at '$speed' baud.");
-
-# check for lock
-if ( -e $lock) {
-
-    &syslog('info',
-           "'$device' locked. Waiting for unlock.");
-
-    # loop until unlocked
-    while ( -e $lock ) {
-       sleep $lock_sleep;
-    }
-}
-
-#### port available -- log and execute
-
-&syslog('info',
-       "Port '$device' available. Launching '$PATH_pppd'");
-
-&closelog;
-
-exec $PATH_pppd;
-### NOT REACHED
-
-
diff --git a/NeXT/Examples/README b/NeXT/Examples/README
deleted file mode 100644 (file)
index bc35d58..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-This directory contains example files that people have found useful
-on NeXTStep systems.  They were collected by Stephen Perkins
-(perkins@netmass.com).
diff --git a/NeXT/Examples/chap-secrets.example b/NeXT/Examples/chap-secrets.example
deleted file mode 100644 (file)
index 5cc3abb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This file is used to control CHAP access
-# the local machine.  See the man pages
-# for details.  Make sure this file does
-# not have world read access.
-#
-#"userid" "providerid" "Password"
-
-
diff --git a/NeXT/Examples/flow-control-hints b/NeXT/Examples/flow-control-hints
deleted file mode 100644 (file)
index e0e6787..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-From katzlbt@vuse.vanderbilt.edu mentions:
-
-I was working with software flow control (at 38400 baud) so the output
-to /dev/cufa resulted in a deadlock.  If the modem does not dial but
-shows TR, check hardware flow control by using the device /dev/cufa
-with tip. If this results in a deadlock relace your modem cable, for
-now replace /dev/cufa with /dev/cua and change the baudrate to 19200.
-
-
diff --git a/NeXT/Examples/ip-down.example b/NeXT/Examples/ip-down.example
deleted file mode 100644 (file)
index 92576ec..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-# -*- Fundamental -*-
-#
-# args: interface-name tty-device speed local-IP remote-IP
-
-PATH=/usr/ucb:/bin:/usr/bin:/etc:/usr/etc:/usr/local/bin; export PATH
-
-#
-# Remove the route to localhost that we created in ip-up
-#
-/usr/etc/route delete $4 127.0.0.1
-
-#  Let the nmserver know the fruits of our network configuration
-#  endeavor. This allows NXHost connections. Thanks to Glenn Brown
-#  <gbrown@alumni.caltech.edu>  
-pid=`ps cax | egrep nmserver | awk '{print $1;}'`
-if [ -n "$pid" ]; then
-    echo "PPP Reinitializing nmserver's network portion" > /dev/console
-    kill -USR2 $pid
-fi
-
-#
-# Let lookupd know that things have changed
-#
-pid=`ps cax | egrep lookupd | awk '{print $1;}'`
-if [ -n "$pid" ]; then
-    echo "PPP Reinitializing lookupd" > /dev/console
-    kill -HUP $pid
-fi
-
-
-
-
diff --git a/NeXT/Examples/ip-up.example b/NeXT/Examples/ip-up.example
deleted file mode 100644 (file)
index 0cd5266..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-# -*- Fundamental -*-
-#
-#
-# args: interface-name tty-device speed local-IP remote-IP
-
-PATH=/usr/ucb:/bin:/usr/bin:/etc:/usr/etc:/usr/local/bin; export PATH
-
-#
-# Add a route to localhost so netinfo won't sleep.
-#
-/usr/etc/route add $4 127.0.0.1 0
-
-
-#  Let the nmserver know the fruits of our network configuration
-#  endeavor. This allows NXHost connections. Thanks to Glenn Brown
-#  <gbrown@alumni.caltech.edu>  
-pid=`ps cax | egrep nmserver | awk '{print $1;}'`
-if [ -n "$pid" ]; then
-    echo "PPP Reinitializing nmserver's network portion" > /dev/console
-    kill -USR2 $pid
-fi
-
-
-#
-# Let lookupd know that things have changed
-pid=`ps cax | egrep lookupd | awk '{print $1;}'`
-if [ -n "$pid" ]; then
-    echo "PPP Reinitializing lookupd" > /dev/console
-    kill -HUP $pid
-fi
-
-
-#
-# Send any mail that has been queued while the link
-# was down.
-/usr/lib/sendmail -q &
-
-
-#
-# Synchronize our clock with some of the public NTP servers.
-#
-# norad.arc.nasa.gov  - 192.203.230.10
-# tick.usno.navy.mil  - 192.5.41.40
-#
-/usr/etc/ntp -sf 192.203.230.10 192.5.41.40 > /dev/console 2>&1 &
diff --git a/NeXT/Examples/options.example b/NeXT/Examples/options.example
deleted file mode 100644 (file)
index 14b58b8..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#
-# NOTE:  All options in the file are commented out.  PPP.app
-#        typically takes care of setting options on a per provider
-#        basis.  If you want to set a global option, then 
-#        add/uncomment the appropriate option in this file.
-#
-#
-# This is an example options file.  The options file
-# should be placed in /etc/ppp/options.  These options
-# are global to all ppp connections.  See the "OPTIONS FILES" section
-# in the pppd man page for more details.
-#
-# Options specified here don't need to be respecified
-# on the pppd command line.  Note: Most of the example
-# scripts in this directory assume an empty options file.
-# However, it doesn't hurt to respecify them.
-#
-
-#
-# The size of the Maximum Transfer Unit.  Higher values
-# give better performance for file transfers.  Lower values
-# give better performance for interactive performance.
-#
-#mtu 296
-
-#
-# If you want to periodically touch the other end to make 
-# sure it is still alive, set these options.
-#
-#lcp-echo-interval 15    # interval in seconds between touches
-#lcp-echo-failure  3     # number of failed attempts before link shutdown
-
-#
-# If you want to enable debugging of the pppd process, leave
-# this uncommented.  Output will be sent to the file
-# /usr/adm/ppp2.2.debug (or whatever you set it to in
-# /etc/syslog.conf.
-#
-#debug
-
-#
-# If you want kernel debugging (i.e. debug output from the
-# NeXT LKS), enable this:
-#
-# kdebug 1  is SC_DEBUG
-#        2  is SC_LOG_INPKT
-#        4  is SC_LOG_OUTPKT
-#        8  is SC_LOG_RAWIN
-#        16 is SC_LOG_FLUSH
-# 
-# add together to get debugging you want.
-#
-#kdebug 17
-
-#
-# If you want pppd to set the PPP connection as the default
-# route when the link is brought up, enable this option.
-# Standalone systems dialing into a provider probably want this
-# option.
-#
-#defaultroute
-
-#
-# These two options disable some of the
-# various types of authentication.
-#
-# Note: Some systems require authenticaion before
-#       negotiation can complete.  If you disable
-#       authentication on these systems, they will
-#       not complain, but they will also not allow
-#       negotiaion to complete and your link will
-#       not come up.
-#
-# NOTE: PAP and CHAP authentication are enabled
-#       by default.
-#
-# If you uncomment either or both of these, you will
-# refuse that type of authentication if the server
-# requests it.  DO NOT put +pap or +chap.  This will
-# require the server to authenticate to you and it will
-# refuse (causing PPP to fail).  read the pppd man page
-# to create the proper secrets files.
-#
-#-pap
-#-chap
-
-#
-# This specifies that should use a UUCP-style lock on the
-# serial device to ensure exclusive access to the device.
-#
-#lock
-
-#
-# Use hardware flow control (i.e. RTS/CTS) to control the
-#  flow of data on the serial port.
-#
-# On NeXT, you also must use the proper device.
-#  /dev/cufa 
-#    -or-
-#  /dev/cufb
-#
-#crtscts
-
-#
-# bsdcomp nr,nt
-#
-# Request that the peer compress packets that it sends,
-# using the BSD-Compress scheme, with a maximum code size
-# of nr bits, and agree to compress packets sent to the
-# peer with a maximum code size of nt bits.  If nt is not
-# specified, it defaults to the value given for nr.
-# Values in the range 9 to 15 may be used for nr and nt;
-# larger values give better compression but consume more
-# kernel memory for compression dictionaries.  Alterna-
-# tively, a value of 0 for nr or nt disables compression
-# in the corresponding direction.
-#
-# It is OK if the peer doesn't support BSD compression.  In that
-# case, the peer will NAK this option and things will continue
-# normally.
-#
-#bsdcomp 10,10 
-
-#
-# Add an entry to this system's ARP [Address Resolution
-# Protocol] table with the IP address of the peer and the
-# Ethernet address of this system.
-#
-# This is only necessary if your are allowing others to dial
-# into you (i.e. you are the server).
-#proxyarp
-
-
-
diff --git a/NeXT/Examples/pap-secrets.example b/NeXT/Examples/pap-secrets.example
deleted file mode 100644 (file)
index 8e415a4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This file is used to control PAP access
-# the local machine.  See the man pages
-# for details.  Make sure this file does
-# not have world read access.
-#
-#"userid" "providerid" "Password"
-
-
diff --git a/NeXT/Examples/ppp_multiple_hosts.tar.gz b/NeXT/Examples/ppp_multiple_hosts.tar.gz
deleted file mode 100644 (file)
index ddeda96..0000000
Binary files a/NeXT/Examples/ppp_multiple_hosts.tar.gz and /dev/null differ
diff --git a/NeXT/Examples/pppdown b/NeXT/Examples/pppdown
deleted file mode 100644 (file)
index c35471f..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-#
-# This script fill find processes with 'pppd' in the name 
-# and send them SIGINT.  It must be run suid root to work
-# correctly.  Some people don't like suid root shell scripts.
-# In that case, check out the example pppkill.c which contains a
-# C program that does the same thing.  This might be a bit safer
-# to make suid root.
-#
-# Note: there is the potential that this script can kill more than
-#       one process.  Maybe even an incorrect process.  It could 
-#       probably be done better.
-#
-
-PATH=/usr/ucb:/bin:/usr/bin:/etc:/usr/etc:/usr/local/bin; export PATH
-
-kill -INT `ps -ax | egrep "(pppd)" | egrep -v "egrep" | sed 's/^\([ 0-9]*\) .*/\1'/`
-exit 0
diff --git a/NeXT/Examples/pppkill.c b/NeXT/Examples/pppkill.c
deleted file mode 100644 (file)
index 932eaca..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-Many thanks to:
-   shess@winternet.com (Scott Hess)  
-   andrew_abernathy@wire.seanet.com (Andrew Abernathy)
-   michal@ellpspace.math.ualberta.ca (Michal Jaegermann)
-
-for contributing programs that can take the place
-of the pppdown script.  I have included Scott Hess's 
-(now modified) here.  If you would like to see the other program, please
-mail Andrew.
-
-======================================================================
-
-From shess@winternet.com Mon Jan  9 02:45 EST 1995
-Date: Mon, 9 Jan 95 01:45 CST
-From: shess@winternet.com (Scott Hess)
-Reply-To: shess@winternet.com (Scott Hess)
-To: Steve Perkins <perkins@cps.msu.edu>
-Subject: Bringing down ppp.
-
-[munch]
-
-In any case, having to run pppdown as root has been annoying,
-because I don't like to run things as root more than necessary.
-In other words, more than about once a week is too often :-).  So,
-I wrote the following quick&dirty hack.  Basic operation is to read
-the pppd pid from a file where it's stored and send a SIGINT to
-that process.  Since there's not a shell script in sight, this
-should be a reasonably safe program to make setuid root.  [I'll
-have to think on what someone can do if they crack it or /etc/ppp
-and can send SIGINT to just anyone.  Perhaps it should check to
-see if the process is really a pppd?  Oh, well.]
-
-howard:/tmp> ls -l /usr/local/ppp/bin/killppp 
-
--rwsr-sr-x  1 root        1464 Jan  7 12:41 /usr/local/ppp/bin/killppp*
-howard:/tmp> cat /usr/local/ppp/src/killppp.c 
-
-/*
- * Originally written by Scott Hess <shess@winternet.com>
- * and later modified by Michal Jaegermann  <michal@ellpspace.math.ualberta.ca>
- */
-
-#include <libc.h>
-#include <stdio.h>
-
-
-#include <libc.h>
-#include <stdio.h>
-
-#define PIDF "/etc/ppp/ppp0.pid"
-
-int
-main( void)
-{
-    FILE *ff;
-    int pid;
-
-    
-    if( NULL == (ff = fopen( PIDF, "r"))) {
-        perror( "opening " PIDF
-       "\nppp0 link does not seem to be active" );
-        exit(1);
-    }
-    
-
-    if( fscanf( ff, "%d", &pid)<1) {
-        fprintf( stderr, "Cannot read pid from" PIDF "\n");
-        exit(1);
-    }
-    
-
-    fclose( ff);
-    if( kill( pid, SIGINT)==-1) {
-        perror( "killing pppd");
-       fprintf( stderr, "removing stale" PIDF "file\n");
-       if (0 != unlink( PIDF)) {
-           perror("cannot remove" PIDF);
-       }
-       exit(1);
-    }
-    return 0;
-}
-
-Later,
----
-scott hess <shess@winternet.com> (WWW to "http://www.winternet.com/~shess/")
-Home:   12901 Upton Avenue South, #326  Burnsville, MN 55337  (612) 895-1208
-Office: 101 W. Burnsville Pkwy, Suite 108E, Burnsville, MN 55337    890-1332
-<?If you haven't the time to design, where will you find the time to debug?>
-
diff --git a/NeXT/Examples/pppup.annex b/NeXT/Examples/pppup.annex
deleted file mode 100644 (file)
index d5ee18f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh -f
-# -*- Fundamental -*-
-#
-# kdebug 1  is SC_DEBUG
-#        2  is SC_LOG_INPKT
-#        4  is SC_LOG_OUTPKT
-#        8  is SC_LOG_RAWIN
-#        16 is SC_LOG_FLUSH
-# 
-# add together to get debugging you want
-# Remember: for HW flow control you must you /dev/cufa or /dev/cufb
-#
-#
-#  This is an example that dials a modem, logs into a remote Annex terminal
-#  server and starts ppp. 
-#
-exec /usr/local/bin/pppd bsdcomp 10,10 mtu 296 lcp-echo-interval 15 \
-lcp-echo-failure 3 debug crtscts kdebug 17 defaultroute modem -pap -chap \
-connect '/usr/local/bin/chat -v ABORT BUSY ABORT "NO CARRIER" ABORT "NO DIAL TONE" ABORT "ERROR" "" ATZ0 "OK" ATDT####### CONNECT "" MSUnet: ppp sername: USER assword: PASS PPP.' \
-/dev/cufa 57600 lock
-
diff --git a/NeXT/Examples/pppup.direct b/NeXT/Examples/pppup.direct
deleted file mode 100644 (file)
index 4958fc6..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh -f
-#
-# -*- Fundamental -*-
-#
-# kdebug 1  is SC_DEBUG
-#        2  is SC_LOG_INPKT
-#        4  is SC_LOG_OUTPKT
-#        8  is SC_LOG_RAWIN
-#        16 is SC_LOG_FLUSH
-# 
-# add together to get debugging you want
-# Remember: for HW flow control you must you /dev/cufa or /dev/cufb
-#
-# This is used to start a ppp session over a link that is directly
-# connected to another computer.  Make sure the peer runs at the
-# same speed.
-#
-/usr/local/bin/pppd bsdcomp 10,10 ipcp-restart 4 ipcp-max-configure 5 lcp-echo-failure 3 lcp-echo-interval 30 debug crtscts kdebug 17 -pap -chap /dev/ttyfb 38400 lock
-exit 0
diff --git a/NeXT/Examples/pppup.portmaster b/NeXT/Examples/pppup.portmaster
deleted file mode 100644 (file)
index c6431ff..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh -f
-#
-#  Call a portmaster terminal server;
-#  start ppp.
-#
-# Thanks to Terence John Parr <parrt@parr-research.com>
-#
-exec /usr/local/ppp/bin/pppd \
-netmask 255.255.255.0 bsdcomp 10,10 mtu 296 lcp-echo-interval 15 \
-lcp-echo-failure 3 debug crtscts kdebug 31 defaultroute modem +pap -chap \
-connect '/usr/local/ppp/bin/chat -v ABORT BUSY ABORT "NO CARRIER" ABORT "NO DIAL TONE" ABORT "ERROR" "" ATZ0 "OK" ATDT000-0000 CONNECT "" ogin:--ogin: mylogin: assword: mypassword.' \
-/dev/cufb 57600
diff --git a/NeXT/Examples/pppup.remote b/NeXT/Examples/pppup.remote
deleted file mode 100644 (file)
index 5e10552..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/csh -f
-#
-# -*- Fundamental -*-
-#
-#
-# kdebug 1  is SC_DEBUG
-#        2  is SC_LOG_INPKT
-#        4  is SC_LOG_OUTPKT
-#        8  is SC_LOG_RAWIN
-#        16 is SC_LOG_FLUSH
-# 
-# add together to get debugging you want
-# Remember: for HW flow control you must you /dev/cufa or /dev/cufb
-#
-# This script is used as the shell for a user account entitiled ppp.
-# When users log into this account, PPP is automatically started
-# (through this script).  The 'echo' command is to help the remote
-# process synchronize with this end.
-echo Starting PPP
-/usr/bin/mesg n
-/bin/stty -tostop litout
-exec /usr/local/bin/pppd passive bsdcomp 10,10 lcp-echo-interval 15 lcp-echo-failure 3 debug kdebug 17 57600
diff --git a/NeXT/Examples/pppup.zyxel b/NeXT/Examples/pppup.zyxel
deleted file mode 100644 (file)
index a1d87fc..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-ABORT BUSY ABORT "NO CARRIER" ABORT "NO DIAL TONE" ABORT "ERROR"
-""
-ATI1 "OK"
-AT+FCLASS=0 "OK"
-ATS42.1=0 "OK"
-ATS38.3=1 "OK"
-ATS38.5=1 "OK"
-ATS2=128 "OK"
-ATS46.2=1 "OK"
-AT&K4 "OK"
-AT&N0 "OK"
-ATM0 "OK"
-ATV1 "OK"
-ATQ0 "OK"
-ATX5 "OK"
-AT&C1 "OK"
-AT&D3 "OK"
-AT&H3 "OK"
-AT&J0 "OK"
-AT&L0 "OK"
-AT&M0 "OK"
-AT&R1 "OK"
-AT&S0 "OK"
-ATN1 "OK"
-ATDT########
-CONNECT "" ogin: USERNAME assword: PASSWORD
-ACTIVE
diff --git a/NeXT/Examples/redial.sh b/NeXT/Examples/redial.sh
deleted file mode 100644 (file)
index 5c40acf..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/csh
-# Script for multiple redialing to bring up PPP connection.
-# Written by Colin.Allen@tamu.edu
-# I make no warranties about this script, but if you have suggestions
-# for improving it please feel free to email them to me.
-
-# Last modified 11-29-95
-
-if ( -f /usr/local/ppp/etc/ppp0.pid ) then
-
-# The ppp0.pid file should only exist with an active ppp connection
-# in which case we don't want to try to dial out. Sometimes the file
-# will need to be deleted manually if ppp was dropped abnormally.
-
-        echo ERROR: PPP already running.
-        set quit = y
-else
-        set quit = n
-        set count = 0
-        set limit = 500
-       set script = pppup
-
-endif
-
-while ( $quit != y );
-
-# Next we loop as long as we are not quitting.  Each circuit we check
-# for a connection and if it's there we launch PopOver.
-# Delete or add other programs as desired.
-
-        if ( -f /usr/local/ppp/etc/ppp0.pid ) then
-                set quit = y
-                echo Connected after $count attempts.
-                echo -n "Launching PopOver...Process id: "
-                nohup /LocalApps/PopOver.app/PopOver &
-                echo Done.
-
-# If the connection is not there we ascertain whether the modem is
-# still trying to get a connection by looking to see if "chat" appears
-# in the output of ps.  It is bound to appear at least once because ps
-# will find the grep process.  If it appears exactly once then any
-# previous connection attempt has failed and we need to allow time
-# for the modem to reset, then we are free to dial again.
-
-# You may be able to optimize this script by adjusting the sleep values
-# below.  My modem (a ZyXEL 1496E) takes about 8 seconds to reset after
-# hanging up.
-
-        else
-                set chat =  `ps | grep -c chat`
-                if ( $chat == 1 ) then
-                        if ( $count != 0 ) then
-                                echo "no connect"
-                                sleep 8
-                        endif
-                        @ count++
-                        if ( $count == $limit ) then
-                                echo "Dial count over limit.  Aborting."
-                                set quit = y
-                        else
-                                /usr/local/ppp/scripts/$script
-                                echo -n "($count) Dialing..."
-                                sleep 5
-                                echo -n "trying to connect..."
-                                sleep 5
-                        endif
-                else
-
-# If chat is still working we just wait a bit and loop again.
-
-                        echo -n "."
-                        sleep 5
-                endif
-        endif
-end
-
diff --git a/NeXT/INSTALL b/NeXT/INSTALL
deleted file mode 100644 (file)
index bd00b61..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-               PPP-2.3 for systems running NeXTSTEP
-                ====================================
-
-
-Authoritative information can be found at:
-
-  WWW site:     http://www.peak.org/next/ppp/
-  WWW mirror:   http://www.thoughtport.com:8080/PPP/
-
-  FTP site:     ftp://next-ftp.peak.org/pub/next/apps/internet/ppp/dev
-  FTP Mirror:   ftp://ftp.NMR.EMBL-Heidelberg.DE/pub/next/ppp/
-
-If you have questions or problems, please visit the WWW site
-for FAQ and mailing list information.
-
-NEW: If you want to submit a bug report, please
-     use the bug submission form on the WWW site.
-
-If you use this software and are pleased with its performance, you are
-encouraged to make a donation to support continued development.  50%
-of all donations go to charity.  For more information, please see:
-  http://www.thoughtport.com:8080/cgi-bin/PPP/donation
-
-
-NeXT Specific Installation Instructions
-=======================================
-
-The procedure for an initial installation and for an upgrade are very
-similar. However, if this is the first time you are installing PPP,
-there are a few extra steps that you must do for the initial setup.
-They will be described later in this document.
-
-Making the source files
-=========================
-
-To install on a computer running NeXTSTEP:
-
- 1) Read this file completely through before you start.
-
- 2) If you are on an HP-PA system, read the file
-    ./NeXT/hppa/README.hppa and install the serial
-    driver patch.  Successfull installation of this
-    patch will require a reboot of your machine.  HPPA
-    is no longer supported.
-
- 3) If you have previously installed a SLIP package, comment out
-    the slip configuration code in /etc/rc.local and reboot your
-    machine.  SLIP and PPP _should_ interoperate but for initial
-    testing it is best to remove SLIP.
-
- 4) If you are using Intel OS version 3.3, you _must_ get the latest
-    NeXT serial drivers from NeXTAnswers.  You need both the serial
-    and ttyport drivers (version 3.33 or later).  Install these
-    according to the directions.  PPP-2.3 is optimized to work with 
-    the NeXT drivers.   It will work with the Mux driver (especially
-    beneficial for OS versions prior to 3.3), but that driver has been
-    known to cause panics with PPP.  If you use OS 4.x you can use the
-    drivers that came with the system.
-
- 5) Type ./configure in the top level PPP directory.  This will set
-    up some necessary links.
-
- 6) If you have developer 3.2, you need to use the old version of
-    chat.c.  Perform:
-      a) cd to the chat directory
-      b) backup chat.c (mv chat.c chat.c.orig)
-      c) use the old chat (mv chat.c.3.2 chat.c)
-
- 7) Edit ./Makefile and set the installation directories.
-    If you change the ETCDIR you will need to modify pathnames in
-    pppd/pathnames.h. I recommend keeping it set to /etc/ppp. 
-    If you don't specifically like that directory, you may
-    also change the Makefile directory and put a link in /etc/ppp
-    that points to the proper place. 
-
-    You will also want to set the -arch flags to the appropriate
-    architectures.  Leaving it blank will default to your current
-    architecture. 
-
- 9) Do a:
-      make 
-
- 10) If you are satisfied with the results, then as root, type:
-      make install
-
-
-If you are performing an upgrade, you are done after successfully
-making and installing the latest release.  All you need to do is to
-reboot your machine so that the new loadable kernel server (LKS) is
-loaded.  You should be able to start the upgraded PPP just like
-normal.  If this doesn't work, see the "Troubleshooting" section later
-on.
-
-Also, you might want to compare the ip-up and ip-down scripts in 
-the ./NeXT/Examples directory with those you have installed in
-/etc/ppp/ip-up and /etc/ppp/ip-down.  Most things included in the
-examples should be in any installation.
-
-
-Extra Steps for Initial Configuration 
-=====================================
-
-If this is the initial installation of PPP, there are several system
-administration steps that must be performed.  These only need to be
-done once.  These steps do not need to be re-performed for an upgrade.
-
-1) Before PPP can successfully run, a module called the loadable
-   kernel server (LKS) must be linked into the system.  This is 
-   something that must be done each time the computer boots up.
-   So that you don't have to do this by hand each time the machine
-   boots, you should modify a file called /etc/rc.local.  Since 
-   this is a system file, you must be root to perform the
-   modification.
-
-   This file contains code that is run each time the machine is
-   started.  This is the standard place where "local" modifications 
-   are made to the system.  First, make a backup copy of /etc/rc.local
-   (maybe named /etc/rc.local.prePPP).  It will be available in case
-   you accidentally mess up the file.  Then, using vi or your favorite
-   editor, place the following lines (not includeing the ==...==
-   separators ;) somewhere near the end of the file /etc/rc.local:
-======================================================================
-# 
-# Load the selected version of the PPP-2.3 loadable
-# kernel server (LKS).
-#     
-if [ -f /usr/local/ppp/reloc/ppp_reloc ]; then
-       /usr/etc/kl_util -a /usr/local/ppp/reloc/ppp_reloc > /dev/console 2>&1
-       (echo -n ' ppp')        > /dev/console
-fi
-======================================================================
-
-  This code will now be executed next time you reboot your machine.
-  You can verify that this was executed by checking the output of
-  /usr/adm/messages upon a successful reboot.  There should be a
-  section of output that says the PPP-2.3 LKS was successfully loaded.
-
-
-2) The default Makefile paths place PPP files  in a directory called
-   /usr/local/ppp.  There are several subdirectories under this
-   directory.  However, these directories are not part of the standard
-   UNIX Path.  The UNIX Path is a list of directories that UNIX searches 
-   when it is trying to find a command.  There are two solutions
-   to fix the problem.  You may either add specific PPP directories to
-   the current path (must be done for each individual user), or you
-   may add important files to a directory that is already in the
-   standard path.  I believe the second approach is the better
-   solution.  
-
-   This step is optional, but highly recommended.  As root,
-   execute the following commands to add important files
-   to directories that are already in the Standard UNIX path:
-
-   /bin/mkdirs -o root -g wheel -m 755 /usr/local/bin /usr/local/man/man8
-   ln -s /usr/local/ppp/bin/* /usr/local/bin
-   ln -s /usr/local/ppp/man/man8/* /usr/local/man/man8
-
-   To get the man program to understand that you have added some pages
-   to the /usr/local/man directory, you need to make sure that the
-   environment variable MANPATH includes the /usr/local/man entry.  In
-   my .cshrc file (in my home directory) I have an entry that looks like:
-      setenv MANPATH "/usr/local/man:/usr/man:.:.."
-   See 'man man' for more information.
-
-   Once these commands are executed, the programs pppd, pppstats, and
-   chat (along with their respective man pages) will become available
-   to you from the command line.  However, before you can immediately
-   see them, you may need to log out and log back in.
-3) Once you start trying to make PPP connections, it is important
-   to have access to the logging information that PPP generates. This
-   will allow you to follow the progress of PPP and will aid in
-   diagnosing problems.  The user level process 'pppd' outputs
-   logging information by using the standard UNIX syslog facility.
-   Part of this facility allows you to select how much (i.e.
-   what level of verbosity) and where (i.e. to which file) this
-   information will be placed.  While the following step is optional,
-   it is highly recommended.
-
-   As root, make a backup copy of /etc/syslog.conf.  You may wish
-   to call it /etc/syslog.conf.prePPP.  If you run into problems with
-   the system logging error messages, you can replace /etc/syslog.conf
-   with the original, reboot, and then you should be back to normal.
-
-   Now, as root, use vi or your favorite editor to edit the file
-   /etc/syslog.conf.  You need to add the line:
-
-       local2.debug            /usr/adm/pppd.log
-
-   It is _imperative_ that you place a <tab> character
-   between the level "local2.debug" and the file name
-   "/usr/adm/pppd.log.  Do _not_ use spaces. If your
-   editor converts tab characters to spaces, you need to
-   use a different editor.  Also beware of cutting and pasting
-   between buffers.  Sometimes a tab will be converted to spaces
-   during that operation. Below is the actual contents of
-   my /etc/syslog.conf:
-
-======================================================================
-local2.debug                                   /usr/adm/pppd.log
-*.err;kern.debug;auth.notice                   /dev/console
-kern.debug;daemon,auth.notice;*.err;mail.crit  /usr/adm/messages
-mark.debug,daemon.info                         /usr/adm/messages
-lpr.debug                                      /usr/adm/lpd-errs
-mail.info                                      /usr/spool/mqueue/syslog
-
-*.alert;kern.err;daemon.err                    operator
-*.alert                                                root
-
-*.emerg                                                *
-======================================================================
-
-   Once you have modified /etc/syslog.conf, you then need to perform
-   one more step.  You need to actually create an empty logging file.
-   This step is necessary because if syslog does not see the file, it
-   will not create it.  So, removing the file is a handy way to turn
-   off the logging.  To create an empty logging file, as root execute:
-        touch /usr/adm/pppd.log
-
-   Upon a successful reboot, logging will be enabled for pppd
-   (remember to specify the 'debug' option to pppd to get reasonable 
-   information sent to the logging file).
-
-
-4) You should copy a few files to a new directory.  Part of the
-   installation process creates a new directory (or link)
-   called /etc/ppp/. Further, it creates an empty file called
-   /etc/ppp/options. An empty options file is the bare minimum of what
-   is necessary. However, the directory ./NeXT/Examples contains
-   several files that are useful in almost any setup.  It is
-   recommended that you perform the following steps to place better
-   files in the directory /etc/ppp.  As user root, perform the
-   following commands.  It assumes you are in the PPP distribution
-   directory:
-
-     cp NeXT/Examples/options.example /etc/ppp/options
-     cp NeXT/Examples/ip-up.example /etc/ppp/ip-up
-     cp NeXT/Examples/ip-down.example /etc/ppp/ip-down
-     /usr/etc/chown root.wheel /etc/ppp/options /etc/ppp/ip-up /etc/ppp/ip-down
-     chmod 644 /etc/ppp/options
-     chmod  511 /etc/ppp/ip-up /etc/ppp/ip-down
-
-
-Congratulations!  You have successfully installed PPP and are now
-ready to start up a connection.  See the section "Initial Testing" for
-steps to verify that PPP works on your system.  
-
-
-Initial Testing
-===============
-
-One of the most notoriously difficult portions of getting PPP links up
-and running involves writing the script that automatically dials your
-modem, connects to the peer, and starts the remote ppp process.  Once
-you are connected to the peer, each PPP process will start
-communications and things become much easier.  Several frontends are
-available that help ease this problem.  See:
-  http://www.peak.org/next/ppp/NeXT_PPP_Frontends.html
-for more information on those.  If you want or need to go the
-scripting route, then please read on.
-
-Before you dive into script writing, there is a simpler solution that
-will allow you to test the ppp portion.  Once this works, getting the
-dial scripts to work is a matter of sheer determination!
-
-The mechanism is this... use a communications package (tip or kermit
-are good choices) to manually dial the modem and log into the remote
-server.  There, manually start up the pppd process (the remote
-process, once started, will probably print some garbage on the screen.
-You can ignore this). Once this is done, you can exit the
-communications process (to free up the device it is using).  Then,
-start your local pppd on the same device.  The pppd processes will
-then start communicating.  The premise is that you manually perform
-the operations that you would like your dial script to automatically
-perform.  Once you _know_ ppp works, you can spend time on the dial
-scripts.
-
-Please note, you _must_ exit from your communications program before
-you start your local pppd.  If you find that when you exit, your modem
-immediately hangs up, you need to instruct the modem to ignore DTR.
-There is an AT command that will do this (AT&D on Supra), but you will
-need to check your modem manual to determine the correct command.
-
-If you are planning on using kermit, Stephane I. Matis
-<petergun@vectrex.login.qc.ca>, has supplied this excellent definition
-that you may place inside your .kermrc file to help with PPP testing:
-----------------------------------------------------------------------
-set term byte 8
-
-# define pppd 
-define pppd -
-        !pppd < \v(line) > \v(line) defaultroute
-----------------------------------------------------------------------
-
-To use this, add the above to your ~/.kermrc file (minus the
-'---...---' separators).  Then start kermit.  After you have started
-the remote PPP server by hand and you see garbage being printed on the
-screen, return back to your local kermit prompt and execute the
-command 'do pppd'.  In this particular circumstance, you will not need
-to exit completely from kermit.
-
-Before you start initial testing, you may want to read the pppd man
-page.  This will allow you to familiarize yourself with the some of
-the options available to you for starting your local pppd.
-
-Of particular interest for most people is the 'defaultroute' option to
-pppd.  If you have a standalone machine, then all your foreign traffic
-must go to the peer.  Adding the 'defaultroute' option to pppd
-instructs pppd to set your system up in such a manner.
-
-
-Determining if the link is actually up
-======================================
-
-There are several ways to determine if the link has actaully been
-established.  I will go through some of them.
-
-1) You may look at the pppd log file (typically
-   /usr/adm/pppd.log).  If you see lines that look similar to:
-
-    Jan 11 23:13:38 sidney2b pppd[2141]: local  IP address 35.9.12.55
-    Jan 11 23:13:38 sidney2b pppd[2141]: remote IP address 35.9.10.13
-
-   You are probably up.
-
-2) You may check the status of the PPP interface.  Using the command:
-     /usr/etc/ifconfig ppp0
-
-   You should see that the interface is UP and that there are valid
-   IP addresses assigned to it (0.0.0.0 is not valid).  Here is an
-   example of what you might see:
-
-       ppp0: flags=51<UP,POINTOPOINT,RUNNING>
-               inet 35.9.12.104 --> 35.9.10.14 netmask ff000000 
-
-3) You may check the routing.  When the connection comes up, you
-   should get at least one route to the new interface.  If you
-   specified 'defaultroute' to pppd, you should also see a default
-   route.  The command for checking routes is 'netstat -rn'.  Here
-   is an example of what you might see:
-
-       Routing tables
-        Destination      Gateway            Flags     Refs     Use  Interface
-        35.9.10.32       35.9.15.107        UH          0        0  ppp0
-        127.0.0.1        127.0.0.1          UH         12     2636  lo0
-        35.9.15.107      127.0.0.1          UH          0        0  lo0
-        default          35.9.10.32         UG          2        6  ppp0
-        192.42.172       192.42.172.1       U          15     8872  en0
-
-
-  In the above case, the peer is 35.9.10.32 and my local machine has
-  been assigned 35.9.15.107.  All foreign traffic goes through the
-  default route to the peer.
-
-  If you don't have an ethernet card installed on your system, you
-  will not have an 'en0' interface.
-   
-  
-The routing issue is important.  Discussion of this issue is outside
-the scope of these instructions, but I thought it might be beneficial
-to list a few other important tools that may help you out.  The man
-pages can give more details:
-  /usr/etc/ping           - send packets to an IP address or hostname
-  traceroute             - Show the route to a particular machine
-
-The IP address that you use can be negotiated automatically in PPP.
-Unlike SLIP, you do not have to specify an IP address when the link is
-brought up.  If no address is specified as an argument to pppd, then
-PPP will negotiate the address with the peer.  This is the preferred
-mechanism of operation.  Probably the only time you should specify an
-IP address as an argument to pppd is if you are assigned your own IP
-address by your system administrator.  Otherwise, sit back and let PPP
-do the work for you.  If you are assigned an address by your PPP
-provider, that address does _NOT_ go in the hostconfig.app or netinfo.
-Instead, you provide that IP address as a command line option to pppd
-when you start it up.  See the pppd man page for details on specifying
-a fixed IP address.
-
-
-A Typical PPP Session
-=====================
-
-A tyipcal PPP session begins when you log into your system.  From a
-terminal window, you will run your dial script by typing its name at
-the prompt.  If you use the Workspace manager, you can double click on
-the scripts icon.  This will start the chat process that will dial the
-modem and log into the remote system.  It will then turn control over
-to pppd.  If your script is successful (as described in the
-"Determining if the link is actually up" section), you will be all
-set.  All your apps, OmniWeb, FTP, telnet, etc should work.  Please
-note that pppd itself will not appear to do anything but sit there.
-
-Once you are through using the connection, you can close down the PPP
-link by executing the ppp down script.  Again, this can be done by
-typing the name of the pppdown script in a terminal window, or double
-clicking on the appropriate icon in the Workspace manager.  At this
-point, ppp will terminate the phone connection and pppd will die off.
-
-You may start and kill the ppp session as many times as you like while
-you are logged on.  However, if you do not kill the PPP session, it
-will not die once you log out (unless you use the idle timer option to
-pppd).  Thus your telephone will remain off the hook and your computer
-will remain connected to the net until you log back in and shut down
-the connection.  Turning off the computer will obviously close the
-connection.
-
-
-Name Resolution
-===============
-
-Once you have a ppp connection up, you may notice that your machine
-will not be able to resolve the names of machines to their IP
-addresses.  You can check this by trying to telnet to a machine outside
-your local domain.  If "telnet <IP address of machine>" is successful,
-but "telnet <machinename>" is not, then your name resolution is not
-configured correctly. The fix is to edit the file /etc/resolv.conf.
-This file contains two important items.  The first is your domain
-name.  This is the name that is automatically tacked on to a computer
-name if you don't specify the complete name.  For example if my domain
-is 'cps.msu.edu' and I say 'telnet sidney', the computer will try
-'telnet sidney.cps.msu.edu' (although, it will not print this name on
-the command line).
-
-The second thing is a list of name servers.  These should be local to
-your ppp provider.  Your network administrator will be able to provide
-you with the appropriate addresses and you should use those, not the
-ones listed below.  An example file might look like:
-
-----------------------------------------------------------------------
-domain cps.msu.edu
-
-#
-# Insert local name servers here
-#
-
-
-#
-# MSU name servers 
-#
-nameserver 35.8.2.41
-nameserver 35.8.2.41
-nameserver 128.247.160.56
-
-----------------------------------------------------------------------
-
-You will need to reboot your computer for the new nameservers to take
-effect.
-
-
-Making startup and shutdown scripts
-===================================
-
-By this time, I'm assuming that PPP has been successfully installed.
-However, there are a few more steps that you must perform so that
-using PPP (now and with future upgrades) will be convenient and easy.
-These steps are optional, but they are highly recommended.
-
-Make scripts 'pppup' and 'pppdown' that bring up and shutdown PPP
-connections.  There are a number of example scripts that you can copy
-and modify.  Reading the man page for 'chat' will help you understand
-these scripts. You should note that once these scripts are made, you
-probably won't need to change them for future upgrades to PPP.
-
-One note that you should be VERY careful about.  These file are shell
-scripts.  This means that the contents are executed in a shell just as
-if you had typed them in by hand.  You must make sure that any
-characters that are treated specially by the shell (such as < > | \ )
-are inside quotation marks ("").  Otherwise, they will be interpreted
-by the shell in a manner that is probably to your dislike.  For
-example, if your peer sends you a prompt like MSUnet> you must add it
-to the chat portion of your script like "MSUnet>".
-
-In order to ensure that these scripts are not removed or modified when
-new versions of PPP are installed, you should copy all important
-scripts into a new directory.  I suggest /usr/local/ppp/scripts.  This
-directory will not be modified during installation. Further, as you
-did earlier for the important binaries, you may want to add important
-scripts to a directory that is in the default UNIX Search Path.  The
-mechanism for doing this is as follows.  Suppose you have a script
-'pppup' (found in /usr/local/ppp/scripts) that you want to be
-available on your command line.  You could execute the commands:
-  /bin/mkdirs -o root -g wheel -m 755 /usr/local/bin
-  ln -s /usr/local/ppp/scripts/pppup /usr/local/bin
-
-Once you log out and log back in, this script will be available.  If
-you want to be able to call this script from a non-root account, you
-need to modify the permission on the file to make it suid root.
-Please note that this can be a potential security hazard.  See your
-system administrator for more details.
-
-As mentioned above, of particular interest for most people is the
-'defaultroute' option to pppd.  If you have a standalone machine, then
-all your foreign traffic must go to the peer.  Remember to add the
-'defaultroute' option to pppd in your startup scripts if necessary (or
-place it in the /etc/ppp/options file).
-
-Troubleshooting
-===============
-
-Any time that you have a bug report, please use the included
-MailBug.app (in the NeXT directory) to submit an electronic report.
-If you don't have email capability, please see the WWW site and use
-the bug report form found there.  Please remember to include your 
-hardware type and the LKS version number in all reports.  This number
-may be found in the file /usr/adm/messages (once the LKS has been
-installed). Also, for most questions, it is best to append a copy of
-the /usr/adm/pppd.log file.
-
-If you do have troubles, please see the FAQ on:
-  http://www.peak.org/next/ppp/
-
-
-Updates
-=======
-
-You may want to join the mailing list for PPP.  This will keep
-you informed of new releases and will provide an arena for discussing
-problems with the NeXT specific PPP port.  To add yourself to the list
-(or for any other administrative requests), send an email message to:
-       majordomo@peak.org
-with no subject and message body consisting of:
-       subscribe nextppp 
-(please use your own name ;). To send mail to all the participants on
-the list, address your messages to:
-       nextppp@peak.org
-
-If you want announcements only, there is a second "announcements only"
-list.  To subscribe to this, you may use the alternate body:
-       subscribe nextppp-announce 
-You don't need to subscribe to both.  All announcements are forwarded
-to the regular list.
-
-Security
-========
-
-Security issues are not dealt with in this document.  Please
-note that the pppd file is installed suid root.  This is a potential
-security hazard.
-
-
-Noted bugs
-==========
-
-There have been various problems reported when trying to install LKSs
-the way NeXT intended (i.e. placing them in /usr/lib/kern_loader/* and
-modifying /etc/kern_loader.conf). The main problem is that if users
-have a bad copy of the LKS, the system will panic and will be unable
-to boot. So, for the time, it is suggested that you install the package
-manually and load the LKS in /etc/rc.local as directed above.
-
-
-Modem Configuration
-===================
-
-It is important to use hardware flow control if you use a high speed
-modem. On my supra V.32bis modem, the command to use Hardware Flow
-Control is 'AT&K3'.
-
-Also, you will probably want to set your modem so that when the DTR is
-dropped, the modem will disconnect.  On my modem the command is
-'AT&D2' This setting disables auto-answer so if you want to allow
-dialins, you must read your modem manual to determine the correct
-setting.
-
-
-Obtaining the Software by Electronic Mail
------------------------------------------
-
-Do not send me requests for the software; they will be ignored
-(without response).  If you cannot use FTP at all, there is a service
-called "ftpmail" available from decwrl.dec.com: you can send e-mail to
-this machine and it will use FTP to retrieve files for you and send
-you the files back again via e-mail.  To find out more about the
-ftpmail service, send a message to "ftpmail@decwrl.dec.com" whose body
-consists of the single line "help".
-
-
-Thanks
-
-Stephen J. Perkins
diff --git a/NeXT/Load_Commands.sect b/NeXT/Load_Commands.sect
deleted file mode 100755 (executable)
index d701060..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-# Associate ports with proc/arg
-
-CALL           pppattach               0
-WIRE
-START
diff --git a/NeXT/Makefile b/NeXT/Makefile
deleted file mode 100755 (executable)
index b39a849..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# Makefile for NeXT OS 3.2
-#
-# $Id: Makefile,v 1.3 1998/03/26 02:51:37 paulus Exp $
-#
-
-#ARCHFLAGS = -arch i386 -arch m68k
-ARCHFLAGS =
-
-BINDIR = /usr/local/ppp/bin
-MANDIR = /usr/local/ppp/man
-ETCDIR = /usr/local/ppp/etc
-
-#
-# If you change this pathname, you must also change the path
-# in and rc.local (or rc.ppp).
-#
-LKS_DIR=/usr/local/ppp/reloc
-
-#
-# NUM_PPP=x      The number of ppp interfaces you want to create
-#
-# VJC            If defined, enables VJ header compression
-#
-# PPP_COMPRESS   If defined, enables BSD packet compression
-#
-# HAS_BROKEN_TIOCSPGRP Fixes broken IOCTL with NeXT serial drivers
-#
-# OLD_MUX        Fixes double buffer problem with the MuX serial
-#                driver.
-#
-# OPTIMIZE_PPPREND Enable an optimization supported by the NeXT serial
-#                  drivers.  Basically they buffer characters for an
-#                  interrupt and call ppprend.
-#
-# NEW_CLOCAL     Used to enable the new code that sets CLOCAL.  Else,
-#                the old code is used.
-#
-
-DFLAGS = -D_POSIX_SOURCE -DINET -DKERNEL -DMACH -DPOSIX_KERN \
-       -DNUM_PPP=2 -DVJC -DPPP_COMPRESS \
-       -DDEBUG -DNEW_CLOCAL -DOPTIMIZE_PPPREND
-
-IFLAGS = -I. -I../include -I../pppd
-
-CFLAGS = -O -g -pipe $(ARCHFLAGS) $(DFLAGS) $(IFLAGS) 
-
-OBJS = bsd-comp.o if_ppp.o ppp_tty.o vjcompress.o
-SRCS = $(OBJS:.o=.c)
-
-
-#
-# Default target
-#
-all:   ppp_reloc
-
-
-install: all
-       /bin/mkdirs $(ETCDIR) $(LKS_DIR)
-       if (test ! -r /etc/ppp) then (ln -s $(ETCDIR) /etc/ppp) fi
-       install -c -m 644 -o root -g daemon ppp_reloc $(LKS_DIR)
-       touch $(ETCDIR)/options
-
-ppp_reloc:     $(OBJS) Load_Commands.sect Unload_Commands.sect
-       kl_ld $(ARCHFLAGS) -n ppp -l Load_Commands.sect -u Unload_Commands.sect \
-              -d ppp_loadable -i instance -o $@ $(OBJS)
-
-clean:
-       rm -f ppp_reloc ppp_loadable core make $(OBJS) *~ 
-
-
-$(SRCS): if_pppvar.h nbq.h inlines.h Makefile
diff --git a/NeXT/Makefile.top b/NeXT/Makefile.top
deleted file mode 100644 (file)
index 4ca9d58..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-# ppp top level makefile for NeXT systems
-#
-# $Id: Makefile.top,v 1.10 1999/12/23 01:48:44 paulus Exp $
-#
-
-# Change the values of ARCHFLAGS to include the 
-# appropriate architectures.  A blank entry compiles
-# for the local architecture
-#ARCHFLAGS = -arch i386 -arch m68k -arch hppa -arch sparc
-#ARCHFLAGS = -arch i386 -arch m68k
-ARCHFLAGS =
-
-#
-# It is not suggested that you change any values from here
-# on.
-#
-BINDIR = /usr/local/ppp/bin
-MANDIR = /usr/local/ppp/man
-ETCDIR = /etc/ppp
-
-
-all:
-       cd NeXT/libposix; $(MAKE) ARCHFLAGS="$(ARCHFLAGS)" all
-       cd chat; $(MAKE) -f Makefile.NeXT ARCHFLAGS="$(ARCHFLAGS)" all
-       cd pppstats; $(MAKE) -f Makefile.NeXT ARCHFLAGS="$(ARCHFLAGS)" all
-       cd pppd; $(MAKE) -f Makefile.NeXT ARCHFLAGS="$(ARCHFLAGS)" all
-       cd NeXT; $(MAKE) ARCHFLAGS="$(ARCHFLAGS)" all
-
-
-install: 
-       cd chat; \
-       $(MAKE) -f Makefile.NeXT ARCHFLAGS="$(ARCHFLAGS)" BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppstats; \
-       $(MAKE) -f Makefile.NeXT ARCHFLAGS="$(ARCHFLAGS)" BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppd; \
-       $(MAKE) -f Makefile.NeXT ARCHFLAGS="$(ARCHFLAGS)" BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd NeXT; \
-       $(MAKE) ARCHFLAGS="$(ARCHFLAGS)" BINDIR=$(BINDIR) ETCDIR=$(ETCDIR) install
-
-clean: 
-       rm -f *~
-       (cd libposix; $(MAKE) -f Makefile.NeXT clean)
-       (cd chat; $(MAKE) -f Makefile.NeXT clean)
-       (cd pppstats; $(MAKE) -f Makefile.NeXT clean)
-       (cd pppd; $(MAKE) -f Makefile.NeXT clean)
-       (cd NeXT; $(MAKE) clean)
-
-
-
-NEXTTOP = \
-       README.NeXT                             \
-       ${NULL}
-
-NEXTPOSIX = \
-       libposix/Makefile.NeXT                  \
-       libposix/libposix.c                     \
-       ${NULL}
-
-NEXTPPPD = \
-       pppd/Makefile.NeXT                      \
-       pppd/sys-NeXT.c                         \
-       ${NULL}
-
-NEXTNET = \
-       net/if_ppp.h                            \
-       net/ppp_defs.h                          \
-       ${NULL}
-
-NEXTSTATS = \
-       pppstats/Makefile.NeXT                  \
-       ${NULL}
-
-#      pppstats/pppstats.c                     
-
-
-NEXTCHAT = \
-       chat/Makefile.NeXT                      \
-       chat/chat.c.3.2                         \
-       ${NULL}
-
-NEXTLKS = \
-       NeXT/ChangeLog.rtf                      \
-       NeXT/INSTALL                            \
-       NeXT/Load_Commands.sect                 \
-       NeXT/Makefile                           \
-       NeXT/Makefile.top                       \
-        NeXT/NeXT_Version.h                    \
-       NeXT/TODO.NeXT                          \
-       NeXT/Unload_Commands.sect               \
-       NeXT/bsd-comp.c                         \
-       NeXT/if_ppp.c                           \
-       NeXT/if_pppvar.h                        \
-       NeXT/inlines.h                          \
-       NeXT/linedisc.h                         \
-       NeXT/nbq.h                              \
-       NeXT/netbuf.h                           \
-       NeXT/ppp_tty.c                          \
-       NeXT/spl.h                              \
-       NeXT/vjcompress.c                       \
-       ${NULL}
-
-NEXTHPPA = \
-       NeXT/hppa/README.hppa                   \
-       NeXT/hppa/hppaSerialPatch.tar.gz        \
-       ${NULL}
-
-NEXTMACH = \
-       NeXT/mach/features.h                    \
-       ${NULL}
-
-
-NEXTEXAMP = \
-       NeXT/Examples/NXHosting_with_PPP        \
-       NeXT/Examples/Persistent_Connection     \
-       NeXT/Examples/README                    \
-       NeXT/Examples/chap-secrets.example      \
-       NeXT/Examples/flow-control-hints        \
-       NeXT/Examples/ip-down.example           \
-       NeXT/Examples/ip-up.example             \
-       NeXT/Examples/options.example           \
-       NeXT/Examples/pap-secrets.example       \
-       NeXT/Examples/ppp_multiple_hosts.tar.gz \
-       NeXT/Examples/pppdown                   \
-       NeXT/Examples/pppkill.c                 \
-       NeXT/Examples/pppup.annex               \
-       NeXT/Examples/pppup.direct              \
-       NeXT/Examples/pppup.portmaster          \
-       NeXT/Examples/pppup.remote              \
-       NeXT/Examples/pppup.zyxel               \
-       NeXT/Examples/redial.sh                 \
-       ${NULL}
-
-NEXTPORT = \
-          ${NEXTTOP}                   \
-          ${NEXTPOSIX}                 \
-          ${NEXTPPPD}                  \
-          ${NEXTNET}                   \
-          ${NEXTSTATS}                 \
-          ${NEXTCHAT}                  \
-          ${NEXTLKS}                   \
-          ${NEXTHPPA}                  \
-          ${NEXTMACH}                  \
-          ${NEXTEXAMP}                 \
-          ${NULL}
-
-
-#
-#  The idea is to make for easy distribution of new port material.
-#  Just make sure all relevant files appear in the lists above,
-#  then:
-#    1) Update the file ./NeXT_Version with a new number
-#    2) go to the top level directory and type 'make portdist'.
-#       You should get a nice tared/compressed file that is ready for
-#       the archive. 
-#
-
-portdist: 
-       echo NeXT-ppp2.3.11-`sed -e '/version_string/!d' \
-             -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q ./NeXT/NeXT_Version.h` > .fname
-       rm -rf `cat .fname`
-       mkdir `cat .fname`
-       mkdir `cat .fname`/libposix
-       mkdir `cat .fname`/pppd
-       mkdir `cat .fname`/net
-       mkdir `cat .fname`/chat
-       mkdir `cat .fname`/NeXT
-       mkdir `cat .fname`/NeXT/hppa
-       mkdir `cat .fname`/NeXT/mach
-       mkdir `cat .fname`/NeXT/Examples
-       mkdir `cat .fname`/pppstats
-       -ln $(NEXTTOP) `cat .fname`
-       -ln $(NEXTPOSIX) `cat .fname`/libposix
-       -ln $(NEXTPPPD) `cat .fname`/pppd
-       -ln $(NEXTNET) `cat .fname`/net
-       -ln $(NEXTCHAT) `cat .fname`/chat
-       -ln $(NEXTLKS) `cat .fname`/NeXT
-       -ln $(NEXTHPPA) `cat .fname`/NeXT/hppa
-       -ln $(NEXTMACH) `cat .fname`/NeXT/mach
-       -ln $(NEXTEXAMP) `cat .fname`/NeXT/Examples
-       -ln $(NEXTSTATS) `cat .fname`/pppstats
-       for file in $(NEXTPORT); do \
-               test -r `cat .fname`/$$file || cp -p $$file `cat .fname`; \
-       done
-       (cd `cat .fname`;tar chf - '.' | gzip --best > ../`cat ../.fname`.tar.gz)
-       rm -rf `cat .fname` .fname
-
-.PHONY: dialppp portdist
diff --git a/NeXT/NeXT_Version.h b/NeXT/NeXT_Version.h
deleted file mode 100644 (file)
index 41fe944..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
-* ppp-2.3 port to the NeXT
-* version_string 0.5.1
-*
-* $Id: NeXT_Version.h,v 1.1 1998/03/26 02:51:41 paulus Exp $
-*/
-#define PPPVERSION "0.5.1"
diff --git a/NeXT/TODO.NeXT b/NeXT/TODO.NeXT
deleted file mode 100644 (file)
index a893288..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-#  $Id: TODO.NeXT,v 1.3 1998/03/26 02:51:42 paulus Exp $
-#
-
-* Check persist option
-
-* Fix installer to recognize other installation.
-
-* Add threads to LKS.
-
-* NUM_PPP in pppd/pppd.h and Makefile are different
-
-* Fix with VirtModem
-
-* Use kget inside interrupt handler.
-
-* Move LKS to user space via an IP Tunneler
-
-Look at NAT:There *is* a way to get multiple machines on a network to use
-       one IP address.  RFC 1631 -- The IP Network Address Translator
-       (NAT) describes how this works.
-       http://www.mischler.com 
-       http://willow.canberra.edu.au/~chrisc/nat.html
\ No newline at end of file
diff --git a/NeXT/Unload_Commands.sect b/NeXT/Unload_Commands.sect
deleted file mode 100755 (executable)
index 81ff88e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-CALL           pppdetach               0
diff --git a/NeXT/bsd-comp.c b/NeXT/bsd-comp.c
deleted file mode 100644 (file)
index 8ae9404..0000000
+++ /dev/null
@@ -1,1079 +0,0 @@
-/* Because this code is derived from the 4.3BSD compress source:
- *
- *
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * 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 University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Rewritten for NextStep's funky kernel functions, I/O threads,
- * and netbufs (instead of real mbufs).  Also, ifnets don't install
- * into the kernel under NS as they do under BSD.  We have tried to
- * make the code remain as similar to the NetBSD version without
- * incurring too much hassle.  This code is the merge of 
- * Philip Prindeville's <philipp@res.enst.fr>/Pete French's <pete@ohm.york.ac.uk>
- * and Stephen Perkins'  <perkins@cps.msu.edu> independent ports.
- *
- */
-
-/*
- * This version is for use with mbufs on BSD-derived systems.
- *
- * $Id: bsd-comp.c,v 1.5 1998/03/26 02:51:45 paulus Exp $
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#define        KERNEL 1
-#include <net/netbuf.h>
-#include <net/if.h>
-
-#include <net/ppp_defs.h>
-
-#include <net/if_ppp.h>
-
-#include "nbq.h"
-
-#define PACKETPTR      NETBUF_T
-#include <net/ppp-comp.h>
-
-
-/*
- * We align with this number of bits zero. The code makes the somewhat
- * suspect assumption that an address can be held in an unsigned long.
- * Sadly this is necessary to do bit operations on it.
- */
-
-#define Z_ALIGN 3      /* 8 byte boudary */
-#define Z_EXTRA ((unsigned long)((1<<Z_ALIGN)-1))
-#define ALIGN(x) ((x+Z_EXTRA) & ~Z_EXTRA)
-
-#if DO_BSD_COMPRESS
-
-/*
- * The following includes are necessary to correctly
- * support BYTE_ORDER.  -SJP
- */
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-
-#define        mtod(m,type)    ((type)NB_MAP(m))
-
-/*
- * PPP "BSD compress" compression
- *  The differences between this compression and the classic BSD LZW
- *  source are obvious from the requirement that the classic code worked
- *  with files while this handles arbitrarily long streams that
- *  are broken into packets.  They are:
- *
- *     When the code size expands, a block of junk is not emitted by
- *         the compressor and not expected by the decompressor.
- *
- *     New codes are not necessarily assigned every time an old
- *         code is output by the compressor.  This is because a packet
- *         end forces a code to be emitted, but does not imply that a
- *         new sequence has been seen.
- *
- *     The compression ratio is checked at the first end of a packet
- *         after the appropriate gap.  Besides simplifying and speeding
- *         things up, this makes it more likely that the transmitter
- *         and receiver will agree when the dictionary is cleared when
- *         compression is not going well.
- */
-
-/*
- * A dictionary for doing BSD compress.
- */
-struct bsd_db {
-    void    *kbase;                    /* actual kalloc'd address for struct */
-    void    *klens;                    /* actual kalloc'd address for lens */
-    int            totlen;                     /* length of this structure */
-    u_int   hsize;                     /* size of the hash table */
-    u_char  hshift;                    /* used in hash function */
-    u_char  n_bits;                    /* current bits/code */
-    u_char  maxbits;
-    u_char  debug;
-    u_char  unit;
-    u_int16_t seqno;                   /* sequence # of next packet */
-    u_int   hdrlen;                    /* header length to preallocate */
-    u_int   mru;
-    u_int   maxmaxcode;                        /* largest valid code */
-    u_int   max_ent;                   /* largest code in use */
-    u_int   in_count;                  /* uncompressed bytes, aged */
-    u_int   bytes_out;                 /* compressed bytes, aged */
-    u_int   ratio;                     /* recent compression ratio */
-    u_int   checkpoint;                        /* when to next check the ratio */
-    u_int   clear_count;               /* times dictionary cleared */
-    u_int   incomp_count;              /* incompressible packets */
-    u_int   incomp_bytes;              /* incompressible bytes */
-    u_int   uncomp_count;              /* uncompressed packets */
-    u_int   uncomp_bytes;              /* uncompressed bytes */
-    u_int   comp_count;                        /* compressed packets */
-    u_int   comp_bytes;                        /* compressed bytes */
-    u_int16_t *lens;                   /* array of lengths of codes */
-    struct bsd_dict {
-       union {                         /* hash value */
-           u_int32_t   fcode;
-           struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
-               u_int16_t prefix;               /* preceding code */
-               u_char  suffix;         /* last character of new code */
-               u_char  pad;
-#else
-               u_char  pad;
-               u_char  suffix;         /* last character of new code */
-               u_int16_t prefix;               /* preceding code */
-#endif
-           } hs;
-       } f;
-       u_int16_t codem1;                       /* output of hash table -1 */
-       u_int16_t cptr;                 /* map code to hash table entry */
-    } dict[1];
-};
-
-#define BSD_OVHD       2               /* BSD compress overhead/packet */
-#define BSD_INIT_BITS  BSD_MIN_BITS
-
-static void    *bsd_comp_alloc __P((u_char *options, int opt_len));
-static void    *bsd_decomp_alloc __P((u_char *options, int opt_len));
-static void    bsd_free __P((void *state));
-static int     bsd_comp_init __P((void *state, u_char *options, int opt_len,
-                                  int unit, int hdrlen, int debug));
-static int     bsd_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     bsd_compress __P((void *state, NETBUF_T *mret,
-                                 NETBUF_T mp, int slen, int maxolen));
-static void    bsd_incomp __P((void *state, NETBUF_T dmsg));
-static int     bsd_decompress __P((void *state, NETBUF_T cmp, NETBUF_T *dmpp));
-static void    bsd_reset __P((void *state));
-static void    bsd_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_bsd_compress = {
-    CI_BSD_COMPRESS,           /* compress_proto */
-    bsd_comp_alloc,            /* comp_alloc */
-    bsd_free,                  /* comp_free */
-    bsd_comp_init,             /* comp_init */
-    bsd_reset,                 /* comp_reset */
-    bsd_compress,              /* compress */
-    bsd_comp_stats,            /* comp_stat */
-    bsd_decomp_alloc,          /* decomp_alloc */
-    bsd_free,                  /* decomp_free */
-    bsd_decomp_init,           /* decomp_init */
-    bsd_reset,                 /* decomp_reset */
-    bsd_decompress,            /* decompress */
-    bsd_incomp,                        /* incomp */
-    bsd_comp_stats,            /* decomp_stat */
-};
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define CLEAR  256                     /* table clear output code */
-#define FIRST  257                     /* first free entry */
-#define LAST   255
-
-#define MAXCODE(b)     ((1 << (b)) - 1)
-#define BADCODEM1      MAXCODE(BSD_MAX_BITS)
-
-#define BSD_HASH(prefix,suffix,hshift) ((((u_int32_t)(suffix)) << (hshift)) \
-                                        ^ (u_int32_t)(prefix))
-#define BSD_KEY(prefix,suffix)         ((((u_int32_t)(suffix)) << 16) \
-                                        + (u_int32_t)(prefix))
-
-#define CHECK_GAP      10000           /* Ratio check interval */
-
-#define RATIO_SCALE_LOG        8
-#define RATIO_SCALE    (1<<RATIO_SCALE_LOG)
-#define RATIO_MAX      (0x7fffffff>>RATIO_SCALE_LOG)
-
-/* Could include inlines.h */
-#ifndef IOLog
-#define IOLog printf
-#define        IOLogDbg        if (db->debug) printf
-#else
-#define        IOLogDbg        if (db->debug) IOLog
-#endif
-
-/*
- * clear the dictionary
- */
-static void
-bsd_clear(db)
-    struct bsd_db *db;
-{
-    db->clear_count++;
-    db->max_ent = FIRST-1;
-    db->n_bits = BSD_INIT_BITS;
-    db->ratio = 0;
-    db->bytes_out = 0;
-    db->in_count = 0;
-    db->incomp_count = 0;
-    db->checkpoint = CHECK_GAP;
-}
-
-/*
- * If the dictionary is full, then see if it is time to reset it.
- *
- * Compute the compression ratio using fixed-point arithmetic
- * with 8 fractional bits.
- *
- * Since we have an infinite stream instead of a single file,
- * watch only the local compression ratio.
- *
- * Since both peers must reset the dictionary at the same time even in
- * the absence of CLEAR codes (while packets are incompressible), they
- * must compute the same ratio.
- */
-static int                             /* 1=output CLEAR */
-bsd_check(db)
-    struct bsd_db *db;
-{
-    u_int new_ratio;
-
-    if (db->in_count >= db->checkpoint)
-      {
-
-       /* age the ratio by limiting the size of the counts */
-       if (db->in_count >= RATIO_MAX
-           || db->bytes_out >= RATIO_MAX) {
-           db->in_count -= db->in_count/4;
-           db->bytes_out -= db->bytes_out/4;
-       }
-
-       db->checkpoint = db->in_count + CHECK_GAP;
-
-       if (db->max_ent >= db->maxmaxcode) {
-           /* Reset the dictionary only if the ratio is worse,
-            * or if it looks as if it has been poisoned
-            * by incompressible data.
-            *
-            * This does not overflow, because
-            *  db->in_count <= RATIO_MAX.
-            */
-           new_ratio = db->in_count << RATIO_SCALE_LOG;
-           if (db->bytes_out != 0)
-               new_ratio /= db->bytes_out;
-
-           if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE)
-             {
-               bsd_clear(db);
-               return 1;
-             }
-           db->ratio = new_ratio;
-       }
-    }
-    return 0;
-}
-
-/*
- * Return statistics.
- */
-static void
-bsd_comp_stats(state, stats)
-    void *state;
-    struct compstat *stats;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int out;
-
-    stats->unc_bytes = db->uncomp_bytes;
-    stats->unc_packets = db->uncomp_count;
-    stats->comp_bytes = db->comp_bytes;
-    stats->comp_packets = db->comp_count;
-    stats->inc_bytes = db->incomp_bytes;
-    stats->inc_packets = db->incomp_count;
-    stats->ratio = db->in_count;
-    out = db->bytes_out;
-    if (stats->ratio <= 0x7fffff)
-      stats->ratio <<= 8;
-    else
-      out >>= 8;
-    if (out != 0)
-      stats->ratio /= out;
-}
-
-/*
- * Reset state, as on a CCP ResetReq.
- */
-static void
-bsd_reset(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    db->seqno = 0;
-    bsd_clear(db);
-    db->clear_count = 0;
-}
-
-/*
- * Allocate space for a (de) compressor.
- */
-static void *
-bsd_alloc(options, opt_len, decomp)
-    u_char *options;
-    int opt_len, decomp;
-{
-    int bits;
-    u_int newlen, hsize, hshift, maxmaxcode;
-    struct bsd_db *db;
-
-    if (opt_len != CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
-       || options[1] != CILEN_BSD_COMPRESS
-       || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
-       return NULL;
-    bits = BSD_NBITS(options[2]);
-    switch (bits) {
-    case 9:                    /* needs 82152 for both directions */
-    case 10:                   /* needs 84144 */
-    case 11:                   /* needs 88240 */
-    case 12:                   /* needs 96432 */
-       hsize = 5003;
-       hshift = 4;
-       break;
-    case 13:                   /* needs 176784 */
-       hsize = 9001;
-       hshift = 5;
-       break;
-    case 14:                   /* needs 353744 */
-       hsize = 18013;
-       hshift = 6;
-       break;
-    case 15:                   /* needs 691440 */
-       hsize = 35023;
-       hshift = 7;
-       break;
-    case 16:                   /* needs 1366160--far too much, */
-       /* hsize = 69001; */    /* and 69001 is too big for cptr */
-       /* hshift = 8; */       /* in struct bsd_db */
-       /* break; */
-    default:
-       return NULL;
-    }
-
-    maxmaxcode = MAXCODE(bits);
-    newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
-    {
-    unsigned long kret;
-    kret = (unsigned long) kalloc(Z_EXTRA + newlen);
-    if (!kret)
-       return NULL;
-    db = (struct bsd_db *) ALIGN(kret);
-    bzero(db, sizeof(*db) - sizeof(db->dict));
-    db->kbase = (void *)kret;
-    }
-
-    if (!decomp) {
-       db->lens = NULL;
-    } else {
-        unsigned long kret;
-       kret = (unsigned long) kalloc(Z_EXTRA +
-                               ((maxmaxcode+1) * sizeof(db->lens[0])));
-       if (!kret) {
-           kfree(db->kbase, newlen + Z_EXTRA);
-           return NULL;
-       }
-       db->lens = (u_int16_t *) ALIGN(kret);
-       db->klens = (void *) kret;
-    }
-
-    db->totlen = newlen;
-    db->hsize = hsize;
-    db->hshift = hshift;
-    db->maxmaxcode = maxmaxcode;
-    db->maxbits = bits;
-
-    return (void *) db;
-}
-
-static void
-bsd_free(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    if (db->lens)
-       kfree(db->klens, ((db->maxmaxcode+1) * sizeof(db->lens[0])) + Z_EXTRA);
-    kfree(db->kbase, db->totlen + Z_EXTRA);
-}
-
-static void *
-bsd_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 0);
-}
-
-static void *
-bsd_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 1);
-}
-
-/*
- * Initialize the database.
- */
-static int
-bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
-    struct bsd_db *db;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug, decomp;
-{
-    int i;
-
-    if (opt_len < CILEN_BSD_COMPRESS || 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)
-       return 0;
-
-    if (decomp) {
-       i = LAST+1;
-       while (i != 0)
-           db->lens[--i] = 1;
-    }
-    i = db->hsize;
-    while (i != 0) {
-       db->dict[--i].codem1 = BADCODEM1;
-       db->dict[i].cptr = 0;
-    }
-
-    db->unit = unit;
-    db->hdrlen = hdrlen;
-    db->mru = mru;
-#ifndef        DEBUG
-    if (debug)
-#endif
-       db->debug = 1;
-
-    bsd_reset(db);
-
-    return 1;
-}
-
-static int
-bsd_comp_init(state, options, opt_len, unit, hdrlen, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, 0, debug, 0);
-}
-
-static int
-bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, mru, debug, 1);
-}
-
-
-/*
- * compress a packet
- *     One change from the BSD compress command is that when the
- *     code size expands, we do not output a bunch of padding.
- */
-int                                    /* new slen */
-bsd_compress(state, mret, mp, slen, maxolen)
-    void *state;
-    NETBUF_T *mret;            /* return compressed netbuf here */
-    NETBUF_T mp;               /* from here */
-    int slen;                  /* uncompressed length */
-    int maxolen;               /* max compressed length */
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    u_int bitno = 32;
-    u_int32_t accm = 0, fcode;
-    struct bsd_dict *dictp;
-    u_char c;
-    int hval, disp, ent, ilen;
-    u_char *rptr, *wptr;
-    u_char *cp_end;
-    int olen;
-    NETBUF_T m;
-
-#define PUTBYTE(v) {                                   \
-    ++olen;                                            \
-    if (wptr) {                                                \
-       *wptr++ = (v);                                  \
-       if (wptr >= cp_end)                             \
-           wptr = NULL;                                \
-    }                                                  \
-}
-
-#define OUTPUT(ent) {                                  \
-    bitno -= n_bits;                                   \
-    accm |= ((ent) << bitno);                          \
-    do {                                               \
-       PUTBYTE(accm >> 24);                            \
-       accm <<= 8;                                     \
-       bitno += 8;                                     \
-    } while (bitno <= 24);                             \
-}
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without compressing the packet.  If it is,
-     * the protocol becomes the first byte to compress.
-     */
-    rptr = mtod(mp, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < CI_BSD_COMPRESS || ent > 0xf9) {
-       *mret = NULL;
-       return slen;
-    }
-
-    /* Don't generate compressed packets which are larger than
-       the uncompressed packet. */
-    if (maxolen > slen)
-       maxolen = slen;
-
-    /* Allocate one mbuf to start with. (don't forget space for the FCS!) */
-    m = NB_ALLOC(maxolen + db->hdrlen + PPP_FCSLEN);
-    *mret = m;
-    if (m != NULL) {
-      if (db->hdrlen > 0)
-       NB_SHRINK_TOP(m, db->hdrlen);
-      NB_SHRINK_BOT(m, PPP_FCSLEN);  /* grown by pppstart() */
-       wptr = mtod(m, u_char *);
-       cp_end = wptr + maxolen;
-    } else
-       wptr = cp_end = NULL;
-
-    /*
-     * Copy the PPP header over, changing the protocol,
-     * and install the 2-byte packet sequence number.
-     */
-    if (wptr) {
-       *wptr++ = PPP_ADDRESS(rptr);    /* assumes the ppp header is */
-       *wptr++ = PPP_CONTROL(rptr);    /* all in one mbuf */
-       *wptr++ = 0;                    /* change the protocol */
-       *wptr++ = PPP_COMP;
-       *wptr++ = db->seqno >> 8;
-       *wptr++ = db->seqno;
-    }
-    ++db->seqno;
-
-    olen = 0;
-    rptr += PPP_HDRLEN;
-    slen = NB_SIZE(mp) - PPP_HDRLEN;
-    ilen = slen + 1;
-    while (slen > 0) {
-       slen--;
-       c = *rptr++;
-       fcode = BSD_KEY(ent, c);
-       hval = BSD_HASH(ent, c, hshift);
-       dictp = &db->dict[hval];
-
-       /* Validate and then check the entry. */
-       if (dictp->codem1 >= max_ent)
-           goto nomatch;
-       if (dictp->f.fcode == fcode) {
-           ent = dictp->codem1+1;
-           continue;   /* found (prefix,suffix) */
-       }
-
-       /* continue probing until a match or invalid entry */
-       disp = (hval == 0) ? 1 : hval;
-       do {
-           hval += disp;
-           if (hval >= db->hsize)
-               hval -= db->hsize;
-           dictp = &db->dict[hval];
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-       } while (dictp->f.fcode != fcode);
-       ent = dictp->codem1 + 1;        /* finally found (prefix,suffix) */
-       continue;
-
-    nomatch:
-       OUTPUT(ent);            /* output the prefix */
-
-       /* code -> hashtable */
-       if (max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           /* expand code size if needed */
-           if (max_ent >= MAXCODE(n_bits))
-               db->n_bits = ++n_bits;
-
-           /* Invalidate old hash table entry using
-            * this code, and then take it over.
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent)
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-       }
-       ent = c;
-    }
-
-    OUTPUT(ent);               /* output the last code */
-    db->bytes_out += olen;
-    db->in_count += ilen;
-    if (bitno < 32)
-       ++db->bytes_out;        /* count complete bytes */
-
-    if (bsd_check(db))
-       OUTPUT(CLEAR);          /* do not count the CLEAR */
-
-    /*
-     * Pad dribble bits of last code with ones.
-     * Do not emit a completely useless byte of ones.
-     */
-    if (bitno != 32)
-       PUTBYTE((accm | (0xff << (bitno-8))) >> 24);
-
-    /*
-     * Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-
-    db->uncomp_bytes += ilen;
-    ++db->uncomp_count;
-    if (olen + PPP_HDRLEN + BSD_OVHD > maxolen || wptr == NULL) {
-       /* throw away the compressed stuff if it is longer than uncompressed */
-       if (*mret != NULL) {
-           NB_FREE(*mret);
-           *mret = NULL;
-       }
-       ++db->incomp_count;
-       db->incomp_bytes += ilen;
-    } else {
-       NB_SHRINK_BOT(m, NB_SIZE(m) - (wptr - mtod(m, u_char *)));
-       ++db->comp_count;
-       db->comp_bytes += olen + BSD_OVHD;
-    }
-
-    return olen + PPP_HDRLEN + BSD_OVHD;
-#undef OUTPUT
-#undef PUTBYTE
-}
-
-
-/*
- * Update the "BSD Compress" dictionary on the receiver for
- * incompressible data by pretending to compress the incoming data.
- */
-static void
-bsd_incomp(state, dmsg)
-    void *state;
-    NETBUF_T dmsg;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    struct bsd_dict *dictp;
-    u_int32_t fcode;
-    u_char c;
-    u_int32_t hval, disp;
-    int slen, ilen;
-    u_int bitno = 7;
-    u_char *rptr;
-    u_int ent;
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without looking at the packet.  If it is,
-     * the protocol becomes the first byte to "compress".
-     */
-    rptr = mtod(dmsg, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < CI_BSD_COMPRESS || ent > 0xf9)
-       return;
-
-    db->incomp_count++;
-    db->seqno++;
-    ilen = 1;          /* count the protocol as 1 byte */
-    rptr += PPP_HDRLEN;
-    slen = NB_SIZE(dmsg) - PPP_HDRLEN;
-    ilen += slen;
-
-    do {
-       c = *rptr++;
-       fcode = BSD_KEY(ent, c);
-       hval = BSD_HASH(ent, c, hshift);
-       dictp = &db->dict[hval];
-
-       /* validate and then check the entry */
-       if (dictp->codem1 >= max_ent)
-           goto nomatch;
-       if (dictp->f.fcode == fcode) {
-           ent = dictp->codem1+1;
-           continue;   /* found (prefix,suffix) */
-       }
-
-       /* continue probing until a match or invalid entry */
-       disp = (hval == 0) ? 1 : hval;
-       do {
-           hval += disp;
-           if (hval >= db->hsize)
-               hval -= db->hsize;
-           dictp = &db->dict[hval];
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-       } while (dictp->f.fcode != fcode);
-       ent = dictp->codem1+1;
-       continue;       /* finally found (prefix,suffix) */
-
-    nomatch:           /* output (count) the prefix */
-       bitno += n_bits;
-
-       /* code -> hashtable */
-       if (max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           /* expand code size if needed */
-           if (max_ent >= MAXCODE(n_bits))
-               db->n_bits = ++n_bits;
-
-           /* Invalidate previous hash table entry
-            * assigned this code, and then take it over.
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent)
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-           db->lens[max_ent] = db->lens[ent]+1;
-       }
-       ent = c;
-    } while (--slen != 0);
-    bitno += n_bits;           /* output (count) the last code */
-    db->bytes_out += bitno/8;
-    db->in_count += ilen;
-    (void)bsd_check(db);
-
-    ++db->incomp_count;
-    db->incomp_bytes += ilen;
-    ++db->uncomp_count;
-    db->uncomp_bytes += ilen;
-
-    /* Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-}
-
-
-/*
- * Decompress "BSD Compress".
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-bsd_decompress(state, cmp, dmpp)
-    void *state;
-    NETBUF_T cmp, *dmpp;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int max_ent = db->max_ent;
-    u_int32_t accm = 0;
-    u_int bitno = 32;          /* 1st valid bit in accm */
-    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, seq, len;
-    u_int incode, oldcode, finchar;
-    u_char *p, *rptr, *wptr;
-    NETBUF_T dmp, mret;
-    int adrs, ctrl, ilen;
-    int space, codelen, extra, maxilen;
-
-    /*
-     * Save the address/control from the PPP header
-     * and then get the sequence number.
-     */
-    *dmpp = NULL;
-    rptr = mtod(cmp, u_char *);
-    adrs = PPP_ADDRESS(rptr);
-    ctrl = PPP_CONTROL(rptr);
-    rptr += PPP_HDRLEN;
-    len = NB_SIZE(cmp) - PPP_HDRLEN;
-    seq = (rptr[0] << 8) + rptr[1];
-    rptr += BSD_OVHD;
-    len -= BSD_OVHD;
-
-    /*
-     * Check the sequence number and give up if it differs from
-     * the value we're expecting.
-     */
-    if (seq != db->seqno) {
-       IOLogDbg("bsd_decomp%d: bad sequence # %d, expected %d\n",
-                  db->unit, seq, db->seqno - 1);
-       return DECOMP_ERROR;
-    }
-    ++db->seqno;
-
-    /*
-     * Allocate an netbuf large enough for all the data.
-     */
-    maxilen = db->mru + db->hdrlen + PPP_HDRLEN;       /* no FCS */
-    dmp = NB_ALLOC(maxilen);                   /* XXX */
-    if (dmp == NULL)
-       return DECOMP_ERROR;
-    if (db->hdrlen > 0)
-       NB_SHRINK_TOP(dmp, db->hdrlen);
-    mret = dmp;
-    wptr = mtod(dmp, u_char *);
-    space = NB_SIZE(dmp) - PPP_HDRLEN + 1;
-
-    /*
-     * Fill in the ppp header, but not the last byte of the protocol
-     * (that comes from the decompressed data).
-     */
-    wptr[0] = adrs;
-    wptr[1] = ctrl;
-    wptr[2] = 0;
-    wptr += PPP_HDRLEN - 1;
-
-    ilen = len;
-    oldcode = CLEAR;
-    explen = 0;
-    while (len > 0) {
-       /*
-        * Accumulate bytes until we have a complete code.
-        * Then get the next code, relying on the 32-bit,
-        * unsigned accm to mask the result.
-        */
-       bitno -= 8;
-       accm |= *rptr++ << bitno;
-       --len;
-       if (tgtbitno < bitno)
-           continue;
-       incode = accm >> tgtbitno;
-       accm <<= n_bits;
-       bitno += n_bits;
-
-       if (incode == CLEAR) {
-           /*
-            * The dictionary must only be cleared at
-            * the end of a packet.  But there could be an
-            * empty mbuf at the end.
-            */
-           if (len > 0) {
-               NB_FREE(mret);
-               IOLogDbg("bsd_decomp%d: bad CLEAR\n", db->unit);
-               return DECOMP_FATALERROR;       /* probably a bug */
-           }
-           bsd_clear(db);
-           explen = ilen = 0;
-           break;
-       }
-
-       if (incode > max_ent + 2 || incode > db->maxmaxcode
-           || incode > max_ent && oldcode == CLEAR) {
-           NB_FREE(mret);
-           IOLogDbg("bsd_decomp%d: bad code 0x%x oldcode=0x%x max_ent=0x%x explen=%d seqno=%d\n",
-                    db->unit, incode, oldcode, max_ent, explen, db->seqno);
-           return DECOMP_FATALERROR;   /* probably a bug */
-       }
-
-       /* Special case for KwKwK string. */
-       if (incode > max_ent) {
-           finchar = oldcode;
-           extra = 1;
-       } else {
-           finchar = incode;
-           extra = 0;
-       }
-
-       codelen = db->lens[finchar];
-       explen += codelen + extra;
-       if (explen > db->mru + 1) {
-           NB_FREE(mret);
-           IOLogDbg("bsd_decomp%d: ran out of mru\n  len=%d, finchar=0x%x, codelen=%d, explen=%d\n",
-                      db->unit, len, finchar, codelen, explen);
-           return DECOMP_FATALERROR;
-       }
-
-       /*
-        * If we have no space left, then we've overflowed...
-        */
-       if ((space -= codelen + extra) < 0) {
-           IOLog("bsd_decompress%d: no space left in netbuf (need %d bytes)\n",
-                 db->unit, (codelen + extra) - space);
-           NB_FREE(mret);
-           return DECOMP_ERROR;
-       }
-
-       /*
-        * Decode this code and install it in the decompressed buffer.
-        */
-       p = (wptr += codelen);
-       while (finchar > LAST) {
-           dictp = &db->dict[db->dict[finchar].cptr];
-#ifdef DEBUG
-           if (--codelen <= 0 || dictp->codem1 != finchar-1)
-               goto bad;
-#endif
-           *--p = dictp->f.hs.suffix;
-           finchar = dictp->f.hs.prefix;
-       }
-       *--p = finchar;
-
-#ifdef DEBUG
-       if (--codelen != 0)
-           IOLog("bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n",
-                  db->unit, codelen, incode, max_ent);
-#endif
-
-       if (extra)              /* the KwKwK case again */
-           *wptr++ = finchar;
-
-       /*
-        * If not first code in a packet, and
-        * if not out of code space, then allocate a new code.
-        *
-        * Keep the hash table correct so it can be used
-        * with uncompressed packets.
-        */
-       if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           u_int32_t fcode;
-           u_int32_t hval, disp;
-
-           fcode = BSD_KEY(oldcode,finchar);
-           hval = BSD_HASH(oldcode,finchar,db->hshift);
-           dictp = &db->dict[hval];
-
-           /* look for a free hash table entry */
-           if (dictp->codem1 < max_ent) {
-               disp = (hval == 0) ? 1 : hval;
-               do {
-                   hval += disp;
-                   if (hval >= db->hsize)
-                       hval -= db->hsize;
-                   dictp = &db->dict[hval];
-               } while (dictp->codem1 < max_ent);
-           }
-
-           /*
-            * Invalidate previous hash table entry
-            * assigned this code, and then take it over
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent) {
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           }
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-           db->lens[max_ent] = db->lens[oldcode]+1;
-
-           /* Expand code size if needed. */
-           if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
-               db->n_bits = ++n_bits;
-               tgtbitno = 32-n_bits;
-           }
-       }
-       oldcode = incode;
-    }
-    NB_SHRINK_BOT(dmp, NB_SIZE(dmp) - (wptr - mtod(dmp, u_char *)));
-
-    /*
-     * Keep the checkpoint right so that incompressible packets
-     * clear the dictionary at the right times.
-     */
-    db->bytes_out += ilen;
-    db->in_count += explen;
-    if (bsd_check(db)) {
-       IOLogDbg("bsd_decomp%d: peer should have cleared dictionary\n",
-              db->unit);
-    }
-
-    ++db->comp_count;
-    db->comp_bytes += ilen + BSD_OVHD;
-    ++db->uncomp_count;
-    db->uncomp_bytes += explen;
-
-    *dmpp = mret;
-    return DECOMP_OK;
-
-#ifdef DEBUG
- bad:
-    if (codelen <= 0) {
-       IOLog("bsd_decomp%d: fell off end of chain 0x%x at 0x%x by 0x%x, max_ent=0x%x\n",
-             db->unit, incode, finchar, db->dict[finchar].cptr, max_ent);
-    } else if (dictp->codem1 != finchar-1) {
-       IOLog("bsd_decomp%d: bad code chain 0x%x finchar=0x%x oldcode=0x%x cptr=0x%x codem1=0x%x\n",
-             db->unit, incode, finchar, oldcode, db->dict[finchar].cptr,
-             dictp->codem1);
-    }
-    NB_FREE(mret);
-    return DECOMP_FATALERROR;
-#endif /* DEBUG */
-}
-#endif /* DO_BSD_COMPRESS */
diff --git a/NeXT/hppa/README.hppa b/NeXT/hppa/README.hppa
deleted file mode 100755 (executable)
index daf140f..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-NeXTSTEP on HP-PA OS 3.2 has a few problems that require special
-installation procedures.
-
-There seem to be two major problems.  The first is related to the use
-of FAT binaries on HPPA Lodable Kernel Servers and the second seems to
-be kernel bugs. NeXT says they will be fixed in 3.3.  I guess we will
-have to wait and see. 
-
-Problem 1
-=========
-
-For some reason, the HPPA kernel loading utility kl_util is unable to
-load FAT LKS modules.  So before you try to load a FAT LKS onto an
-HPPA machine, you will need to use lipo to thin it down. You may use a
-command similar to:
-    lipo ppp_reloc -thin hppa -output ppp_reloc.hppa
-to get a thin version named ppp_reloc.hppa. 
-
-
-
-Problem 2
-=========
-
-Alain Fauconnet managed to get PPP-2.1.2 working
-on HPPA.  He graciously allowed me to incorporate his changes into
-PPP-2.2.  I have included part of his original instructions for
-getting the serial driver patch installed.  You should follow these
-procedures for PPP-2.2.  Also, you may wish to send him a short thank
-you for his excellent work.
-
-Please note, that you only need these instructions to install the
-SerialDriverPatch.  After that is installed, you may install PPP-2.2
-as specified in the README.NeXT file at the top level directory.
-
-Here are the original instructions:
-
-Temporary PPP 2.1.2 kit for HP-PA systems running NeXTSTEP 3.2
-==============================================================
-
-                                                       14-Nov-1994
-                                                       Alain Fauconnet
-                                                       <af@biomath.jussieu.fr>
-
-
-INSTALLATION FOR A HP-PA/NEXSTEP MACHINE
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-       1) Serial driver patch
-
-This tarfile includes a ./hppaSerialPatch tree that is a temporary
-work-around for a severe bug in the HP-PA serial tty driver. I have
-been allowed to include it here provided that it is clearly stated that
-it is *not* an official patch from NeXT and that it should *not* be
-installed on machines that do not absolutely require it. The problem
-will be corrected in NeXTSTEP 3.3, according to the NeXT people.
-
-As I understand it, the problem is about the select() call on a file
-descriptor opened on a tty line. This affect emacs (hangs when run from
-a remote tty session), MicroEMACS (arrow keys don't work), PPP (protocol
-hangs) and probably other programs as well.
-
-I felt the need to add some installation instructions, since I've lost
-some hair in that process myself.
-
-Install it as follows :
-
-a) go to the hppaSerialPatch directory
-
-b) type `make'. Compilation should complete with a few warnings about
-`linesw'
-
-c) type `make install' (YOU DON'T NEED TO BE root FOR THAT, the
-installed tree will be created in /tmp/hppaSerialPatch.*
-
-d) as root, bring up  /NextAdmin/Configure.app, choose Configuration ->
-Install driver... and select
-/tmp/hppaSerialPatch.bproj/usr/Devices/hppaSerialPatch.config from the
-file selection box.
-
-e) reboot the system. As root, bring up /NextAdmin/Configure.app again
-and look if "hppaSerialPatch" appears on the "Other" line. If not, click
-the "Other" icon. Click "Add". The correct driver will probably appear
-as "Long Name" in the list of drivers. Select it and click "Add".
-Go back to "Summary" and click "Save". Reboot the system.
-Check the file /usr/Devices/System.config/Instance0.table,
-"hppaSerialPatch" should appear in the line of "Active Drivers".
-
-f) the /tmp/hppaSerialPatch trees may be deleted now.
-
-
-GOOD LUCK !
-
-Thanks to:
-               Jean Michel LUNATI <Jean_Michel_Lunati@NeXT.COM>
-               Philip Prindeville <philipp@res.enst.fr>
diff --git a/NeXT/if_ppp.c b/NeXT/if_ppp.c
deleted file mode 100644 (file)
index c10a6ca..0000000
+++ /dev/null
@@ -1,1697 +0,0 @@
-/*
- * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a collision if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- *
- * Rewritten for NextStep's funky kernel functions, I/O threads,
- * and netbufs (instead of real mbufs).  Also, ifnets don't install
- * into the kernel under NS as they do under BSD.  We have tried to
- * make the code remain as similar to the NetBSD version without
- * incurring too much hassle.  This code is the merge of 
- * Philip Prindeville's <philipp@res.enst.fr>/Pete French's <pete@ohm.york.ac.uk>
- * and Stephen Perkins'  <perkins@cps.msu.edu> independent ports.
- *
- */
-
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-
-#if !defined(lint)
-static char sccsid[] = "$Revision: 1.13 $ ($Date: 2002/12/06 09:49:15 $)";
-#endif /* not lint*/
-
-#define KERNEL 1
-#define KERNEL_FEATURES 1
-#define INET 1
-
-#if NS_TARGET >= 40
-#if NS_TARGET >= 41
-#include <kernserv/clock_timer.h>
-#include <kernserv/lock.h>
-#else
-#include <kern/lock.h>
-#endif /* NS_TARGET */
-#endif /* NS_TARGET */
-
-#include <sys/param.h>
-#if NS_TARGET >= 41
-typedef simple_lock_data_t lock_data_t;                /* XXX */
-#endif /* NS_TARGET */
-#include <sys/proc.h>
-#include "netbuf.h"
-#include <sys/socket.h>
-#include <sys/conf.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#if !(NS_TARGET >= 40)
-#include <kernserv/prototypes.h>
-#endif
-#if defined(m68k)
-#import "spl.h"
-#else
-#include <driverkit/generalFuncs.h>
-#import <kernserv/machine/spl.h>
-#endif
-#if defined(sparc) || defined(m68k)
-#include <machine/psl.h>
-#endif
-#include <kernserv/kern_server_types.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#if INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#endif
-
-#include <net/ppp_defs.h>
-#ifdef VJC
-#include <net/vjcompress.h>
-#endif
-#include <net/if_ppp.h>
-#include "NeXT_Version.h"
-#include "if_pppvar.h"
-
-
-struct ppp_softc ppp_softc[NUM_PPP];
-
-
-#ifdef PPP_COMPRESS
-#define        PACKETPTR       NETBUF_T
-#include <net/ppp-comp.h>
-#endif
-
-/*
- * The max number of NETBUF_Ts we wish to compress and cache for
- * sending.
- */
-#define COMPRESS_CACHE_LEN 1
-
-#include "inlines.h"
-
-/*
- * Necessary to avoid redefinition warnings or bogus type casts later.
- */
-int    pppoutput __P((netif_t ifp, netbuf_t m, void *arg));
-int    pppsioctl __P((netif_t ifp, int cmd, caddr_t data));
-int    pppcontrol __P((netif_t ifp, const char *cmd, void *data));
-void   pppintr_comp __P((void *arg));
-void   pppintr_decomp __P((void *arg));
-void   pppfillfreeq __P((void *arg));
-void   pppgetm __P((register struct ppp_softc *sc));
-
-static void    ppp_requeue __P((struct ppp_softc *));
-static void    ppp_outpkt __P((struct ppp_softc *));
-static void    ppp_ccp __P((struct ppp_softc *, NETBUF_T, int rcvd));
-static void    ppp_ccp_closed __P((struct ppp_softc *));
-static void    ppp_inproc __P((struct ppp_softc *, NETBUF_T));
-static void    pppdumpm __P((NETBUF_T));
-
-extern int     install_ppp_ld __P((void));
-extern int     tty_ld_remove __P((int));
-
-/*
- * We steal two bits in the mbuf m_flags, to mark high-priority packets
- * for output, and received packets following lost/corrupted packets.
- */
-#define        M_HIGHPRI       0x2000  /* output packet for sc_fastq */
-#define        M_ERRMARK       0x4000  /* steal a bit in mbuf m_flags */
-
-/*
- * The following disgusting hack gets around the problem that IP TOS
- * can't be set yet.  We want to put "interactive" traffic on a high
- * priority queue.  To decide if traffic is interactive, we check that
- * a) it is TCP and b) one of its ports is telnet, rlogin or ftp control.
- */
-static u_short interactive_ports[8] = {
-       0,      513,    0,      0,
-       0,      21,     0,      23,
-};
-
-enum { QFREE, QRAW, QFAST, QSLOW, QIN, QNP, QCACHE };
-
-static struct qparms qparms[] = {
-       {20, 40, 50, "free"},           /* freeq */
-       {5, 20, 25, "raw"},             /* rawq */
-       {5, 20, 25, "fast"},            /* fastq */
-       {5, 20, 25, "slow"},            /* slowq */
-       {5, 20, 25, "in"},              /* inq */
-       {5, 20, 25, "np"},              /* npq */
-       {0, COMPRESS_CACHE_LEN, COMPRESS_CACHE_LEN, "cache"}    /* cache */
-};
-
-#define INTERACTIVE(p) (interactive_ports[(p) & 7] == (p))
-
-#ifndef        IPTOS_LOWDELAY
-#define        IPTOS_LOWDELAY  0x10
-#endif
-
-#ifdef PPP_COMPRESS
-/*
- * List of compressors we know about.
- * We leave some space so maybe we can modload compressors.
- */
-
-extern struct compressor ppp_bsd_compress;
-
-struct compressor *ppp_compressors[8] = {
-#if DO_BSD_COMPRESS
-    &ppp_bsd_compress,
-#endif
-    NULL
-};
-#endif /* PPP_COMPRESS */
-
-/* yeah, we sometimes have to change the MTU after having created the
- * device.  Let's hope this doesn't break anything!!!
- */
-#define        if_mtu_set(ifn,mtu)  (((struct ifnet *)ifn)->if_mtu = mtu)
-
-extern int ipforwarding;
-extern int ipsendredirects;
-
-kern_server_t instance;
-
-/*
- * Sigh.  Should be defined in <net/if.h> but isn't...
- */
-union ifr_ifru {
-       short   ifru_flags;
-       short   ifru_mtu;
-       u_long  ifru_asyncmap;
-       int     ifru_metric;
-       caddr_t ifru_data;
-};
-
-
-/*
- * Returns a new "outgoing" netbuf.
- *  
- * Must return an actual netbuf_t since other protocols
- * use this to get our buffers.  Before releasing, save
- * any space we may need when the buffer returns.
- */
-
-netbuf_t
-pppgetbuf(netif_t ifp)
-{
-    NETBUF_T nb;
-
-    int len = MAX(if_mtu(ifp), PPP_MTU) + PPP_HDRLEN + PPP_FCSLEN;
-    nb = NB_ALLOC(len);
-    if (nb != NULL)
-      {
-       NB_SHRINK_TOP(nb, PPP_HDRLEN);
-       NB_SHRINK_BOT(nb, PPP_FCSLEN);          /* grown by pppstart() */
-      }
-    return NB_TO_nb(nb);
-}
-
-/*
- * Called from boot code to establish ppp interfaces.
- */
-void
-pppattach()
-{
-    register struct ppp_softc *sc;
-    register int i = 0;
-    
-    IOLog("\nPPP version 2.3.11-%s for NeXTSTEP and OPENSTEP\n", PPPVERSION);
-    IOLog("by  Stephen Perkins, Philip Prindeville, and Pete French\n");
-    if (install_ppp_ld() < 0) {
-       IOLog("ppp: Could not install line discipline\n");
-    }
-    
-    for (sc = ppp_softc; i < NUM_PPP; sc++, i++) {
-       sc->sc_if = if_attach(NULL, NULL, pppoutput, 
-                             pppgetbuf, pppcontrol, "ppp", i, "Serial line PPP", 
-                             PPP_MTU, IFF_POINTOPOINT, NETIFCLASS_VIRTUAL, (void *) sc);
-       nbq_init(&sc->sc_freeq, &qparms[QFREE]);
-       nbq_init(&sc->sc_rawq, &qparms[QRAW]);
-       nbq_init(&sc->sc_fastq, &qparms[QFAST]);
-       nbq_init(&sc->sc_slowq, &qparms[QSLOW]);
-       nbq_init(&sc->sc_inq, &qparms[QIN]);
-       nbq_init(&sc->sc_npq, &qparms[QNP]);
-       nbq_init(&sc->sc_compq, &qparms[QCACHE]);
-       IOLog("     ppp%d successfully attached.\n", i);
-    }
-
-    ipforwarding = 1;
-    ipsendredirects = 1;
-
-    IOLog("PPP Successfully Installed.\n\n");
-}
-
-int
-pppdetach()
-{
-    struct ppp_softc *sc;
-    int i;
-
-    IOLog("Removing PPP on Line Discipline %d\n", PPPDISC);
-    if (!tty_ld_remove(PPPDISC))
-       IOLog("ppp: Could not remove line discipline\n");
-
-    IOLog("Removing interfaces:\n");
-    for (sc = ppp_softc, i = 0; i < NUM_PPP; sc++, i++) {
-       nbq_free(&sc->sc_freeq);
-       nbq_free(&sc->sc_rawq);
-       nbq_free(&sc->sc_fastq);
-       nbq_free(&sc->sc_slowq);
-       nbq_free(&sc->sc_inq);
-       nbq_free(&sc->sc_npq);
-       nbq_free(&sc->sc_compq);
-       if_detach(sc->sc_if);
-       /* no idea why we need this, but... */
-       bzero(sc->sc_if, sizeof(netif_t));
-       IOLog("     ppp%d successfully detached.\n", i);
-    }
-    IOLog("PPP-2.3 Successfully Removed.\n\n");
-    return 0;
-}
-
-/*
- * Allocate a ppp interface unit and initialize it.
- */
-struct ppp_softc *
-pppalloc(pid)
-    pid_t pid;
-{
-    int nppp, i;
-    struct ppp_softc *sc;
-#if NS_TARGET >= 40
-    struct timeval tv_time;
-#endif /* NS_TARGET */
-
-    for (nppp = 0, sc = ppp_softc; nppp < NUM_PPP; nppp++, sc++)
-       if (sc->sc_xfer == pid) {
-           IOLogDbg("ppp%d: alloc'ing unit %d to proc %d\n", nppp, nppp, pid);
-           sc->sc_xfer = 0;
-           return sc;
-       }
-    for (nppp = 0, sc = ppp_softc; nppp < NUM_PPP; nppp++, sc++)
-       if (sc->sc_devp == NULL)
-           break;
-    if (nppp >= NUM_PPP)
-       return NULL;
-
-    sc->sc_flags = 0;
-    sc->sc_mru = PPP_MRU;
-    sc->sc_relinq = NULL;
-#ifdef VJC
-    vj_compress_init(&sc->sc_comp, -1);
-#endif
-#ifdef PPP_COMPRESS
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-    for (i = 0; i < NUM_NP; ++i)
-       sc->sc_npmode[i] = NPMODE_ERROR;
-    /* XXX - I'm not sure why the npqueue was zapped here... */
-
-#if NS_TARGET >= 40
-    ns_time_to_timeval(clock_value(System), &tv_time);
-    sc->sc_last_sent = sc->sc_last_recv = tv_time.tv_sec;
-#else
-    sc->sc_last_sent = sc->sc_last_recv = time.tv_sec;
-#endif
-
-    sc->sc_compsched = 0;
-    sc->sc_decompsched = 0;
-
-    /*
-     * XXX -- We need to get packets here, and we don't care if we do block...
-     * We do this after we set the sc_mru.
-     */
-    pppfillfreeq((void *) sc);
-
-    return sc;
-}
-
-/*
- * Deallocate a ppp unit.  Must be called at splnet or higher.
- */
-void
-pppdealloc(sc)
-    struct ppp_softc *sc;
-{
-
-    if_flags_set(sc->sc_if, if_flags(sc->sc_if) & ~(IFF_UP|IFF_RUNNING));
-    sc->sc_devp = NULL;
-    sc->sc_xfer = 0;
-    nbq_flush(&sc->sc_freeq);
-    nbq_flush(&sc->sc_rawq);
-    nbq_flush(&sc->sc_inq);
-    nbq_flush(&sc->sc_fastq);
-    nbq_flush(&sc->sc_slowq);
-    nbq_flush(&sc->sc_npq);
-    nbq_flush(&sc->sc_compq);
-#ifdef PPP_COMPRESS
-    ppp_ccp_closed(sc);
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-
-
-}
-
-/*
- * Ioctl routine for generic ppp devices.
- */
-int
-pppioctl(sc, cmd, data, flag)
-    struct ppp_softc *sc;
-    void *data;
-    u_long cmd;
-    int flag;
-{
-    struct proc *p = curproc;
-    int s, error, flags, mru, nb, npx, oldflags;
-    struct ppp_option_data *odp;
-    struct compressor **cp;
-    struct npioctl *npi;
-    time_t t;
-#ifdef PPP_COMPRESS
-    u_char ccp_option[CCP_MAX_OPTION_LENGTH];
-#endif
-    NETBUF_T m;
-#ifdef HAS_BROKEN_TIOCSPGRP
-    struct tty *tp = sc->sc_devp;
-#endif
-#if NS_TARGET >= 40
-       struct timeval tv_time;
-#endif /* NS_TARGET */
-
-
-    switch (cmd) {
-    case FIONREAD:
-       s = splimp();           /* paranoid; splnet probably ok */
-       if ((m = nbq_peek(&sc->sc_inq)) != NULL)
-           *(int *)data = NB_SIZE(m);
-       else
-           *(int *)data = 0;
-       splx(s);
-       break;
-
-    case PPPIOCGUNIT:
-       *(int *)data = if_unit(sc->sc_if);
-       break;
-
-     case PPPIOCGFLAGS:
-       *(u_int *)data = sc->sc_flags;
-       break;
-
-    case PPPIOCSFLAGS:
-       if (! suser())
-           return EPERM;
-       flags = *(int *)data & SC_MASK;
-       s = splnet();
-#ifdef PPP_COMPRESS
-       if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN))
-           ppp_ccp_closed(sc);
-#endif
-       splimp();
-       oldflags = sc->sc_flags;
-       sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags;
-       splx(s);
-       break;
-
-    case PPPIOCSMRU:
-       if (! suser())
-           return EPERM;
-       mru = *(int *)data;
-
-       IOLogDbg("ppp%d: setting mru %d\n", if_unit(sc->sc_if), mru);
-
-       if (mru >= PPP_MRU && mru <= PPP_MAXMRU) {
-
-           /* To make sure we handle the received packet
-            * correctly, we do two things.  First, we
-            * empty out the free_q.  We then remove
-            * the current input buffer, set the input length
-            * to zero, and set the flush flag.
-            */
-           s = splimp();
-           nbq_flush(&sc->sc_freeq);   /* get rid of old buffers */
-           sc->sc_mru = mru;
-           if (sc->sc_m){
-             NB_FREE(sc->sc_m);
-             sc->sc_m = NULL;
-             if (sc->sc_ilen != 0)
-               sc->sc_flags |= SC_FLUSH;
-           }
-           sc->sc_ilen = 0;
-           splx(s);
-           pppfillfreeq((void *) sc);  /* and make a queue of new ones */
-           pppgetm(sc);
-       }
-       break;
-
-    case PPPIOCGMRU:
-       *(int *)data = sc->sc_mru;
-       break;
-
-#ifdef VJC
-    case PPPIOCSMAXCID:
-       if (! suser())
-           return EPERM;
-       s = splnet();
-       vj_compress_init(&sc->sc_comp, *(int *)data);
-       splx(s);
-       break;
-#endif
-
-    case PPPIOCXFERUNIT:
-       if (! suser())
-           return EPERM;
-       sc->sc_xfer = p->p_pid;
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPPIOCSCOMPRESS:
-       if (! suser())
-           return EPERM;
-       odp = (struct ppp_option_data *) data;
-       nb = odp->length;
-       if (nb > sizeof(ccp_option))
-           nb = sizeof(ccp_option);
-       if (error = copyin(odp->ptr, ccp_option, nb))
-           return (error);
-       if (ccp_option[1] < 2)  /* preliminary check on the length byte */
-           return (EINVAL);
-       for (cp = ppp_compressors; *cp != NULL; ++cp)
-           if ((*cp)->compress_proto == ccp_option[0]) {
-               /*
-                * Found a handler for the protocol - try to allocate
-                * a compressor or decompressor.
-                */
-               error = 0;
-               s = splnet();
-               if (odp->transmit) {
-                   if (sc->sc_xc_state != NULL)
-                       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-                   sc->sc_xcomp = *cp;  /* entry points for compressor */
-                   sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
-                   if (sc->sc_xc_state == NULL) {
-                       IOLogDbg("ppp%d: comp_alloc failed", if_unit(sc->sc_if));
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_COMP_RUN;
-               } else {
-                   if (sc->sc_rc_state != NULL)
-                       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-                   sc->sc_rcomp = *cp; /* entry points for compressor */
-                   sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
-                   if (sc->sc_rc_state == NULL) {
-                       IOLogDbg("ppp%d: decomp_alloc failed", if_unit(sc->sc_if));
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_DECOMP_RUN;
-               }
-               splx(s);
-               return (error);
-           }
-       IOLogDbg("ppp%d: no compressor for [%x %x %x], %x", if_unit(sc->sc_if),
-                ccp_option[0], ccp_option[1], ccp_option[2], nb);
-       return (EINVAL);        /* no handler found */
-#endif /* PPP_COMPRESS */
-
-#ifdef HAS_BROKEN_TIOCSPGRP
-    case TIOCSPGRP:
-       tp->t_pgrp = *(int *)data;
-       break;
-#endif
-
-    case PPPIOCGNPMODE:
-    case PPPIOCSNPMODE:
-       npi = (struct npioctl *) data;
-       switch (npi->protocol) {
-       case PPP_IP:
-           npx = NP_IP;
-           break;
-       default:
-           return EINVAL;
-       }
-       if (cmd == PPPIOCGNPMODE) {
-           npi->mode = sc->sc_npmode[npx];
-       } else {
-           if (! suser())
-               return EPERM;
-           if (npi->mode != sc->sc_npmode[npx]) {
-               s = splimp();
-               sc->sc_npmode[npx] = npi->mode;
-               if (npi->mode != NPMODE_QUEUE) {
-                   ppp_requeue(sc);
-                   (*sc->sc_start)(sc);
-               }
-               splx(s);
-           }
-       }
-       break;
-
-    case PPPIOCGIDLE:
-       s = splimp();
-#if NS_TARGET >= 40
-       ns_time_to_timeval(clock_value(System), &tv_time);
-       t = tv_time.tv_sec;
-#else
-       t = time.tv_sec;
-#endif /* NS_TARGET */
-       ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
-       ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
-       splx(s);
-       break;
-
-    default:
-       return (-1);
-    }
-    return (0);
-}
-
-int
-pppcontrol(ifp, cmd, data)
-    netif_t ifp;
-    const char *cmd;
-    void *data;
-{
-
-    if (!strcmp(cmd, IFCONTROL_UNIXIOCTL)) {
-       if_ioctl_t* ctl = (if_ioctl_t*)data;
-       return pppsioctl(ifp,
-                       ctl->ioctl_command,
-                       ctl->ioctl_data);
-    } else if (!strcmp(cmd, IFCONTROL_SETADDR)) {
-       struct sockaddr_in *sin = (struct sockaddr_in *)data;
-       if (sin->sin_family != AF_INET)
-               return EAFNOSUPPORT;
-       if_flags_set(ifp, if_flags(ifp) | IFF_UP);
-       return 0;
-    }
-    /*
-     * We implement this to allow iftab
-     * to contain -AUTOMATIC- entries
-     * without generating errors at boot time.
-     * We do not, however, mark it as UP.
-     */
-    else if (!strcmp(cmd, IFCONTROL_AUTOADDR)) {
-       struct sockaddr_in *sin = (struct sockaddr_in *) data;
-       if (sin->sin_family != AF_INET)
-           return EAFNOSUPPORT;
-       return 0;
-    } else if (!strcmp(cmd, IFCONTROL_SETFLAGS)) {
-       register union ifr_ifru *ifr = (union ifr_ifru *)data;
-       if (!suser())
-           return EPERM;
-       if_flags_set(ifp, ifr->ifru_flags);
-       return 0;
-    }
-    /*
-     * Under 3.2 developer, I don't know the symbol for this
-     * new 3.3 command.  So it is a constant for now. I don't
-     * believe I need to do anything to support this at the moment.
-     */
-    else if (strcmp(cmd, "add-multicast") == 0) {
-      struct sockaddr_in *sin = (struct sockaddr_in *) data;
-      if (sin->sin_family != AF_INET)
-       return EAFNOSUPPORT;
-    } else {
-       IOLog("ppp%d: Invalid ppp control %s\n", if_unit(ifp), cmd);
-       return EINVAL;
-    }
-}
-
-/*
- * Process an ioctl request to the ppp network interface.
- */
-int
-pppsioctl(ifp, cmd, data)
-    register netif_t ifp;
-    int cmd;
-    caddr_t data;
-{
-    register struct ppp_softc *sc = &ppp_softc[if_unit(ifp)];
-    register struct ifaddr *ifa = (struct ifaddr *)data;
-    register struct ifreq *ifr = (struct ifreq *)data;
-    struct ppp_stats *psp;
-#ifdef PPP_COMPRESS
-    struct ppp_comp_stats *pcp;
-#endif
-    int s = splimp(), error = 0;
-
-    switch (cmd) {
-    case SIOCSIFFLAGS:
-       IOLog("ppp%d: pppioctl: SIOCSIFFLAGS called!\n", if_unit(ifp));
-       break;
-
-    case SIOCSIFADDR:
-       if (ifa->ifa_addr.sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFDSTADDR:
-       if (ifa->ifa_addr.sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFMTU:
-       if (!suser()) {
-           error = EPERM;
-           break;
-       }
-       if_mtu_set(sc->sc_if, ifr->ifr_mtu);
-       nbq_flush(&sc->sc_freeq);               /* get rid of old buffers */
-       pppsched(pppfillfreeq, sc);             /* and make a queue of new ones */
-       pppgetm(sc);
-       break;
-
-    case SIOCGIFMTU:
-       ifr->ifr_mtu = if_mtu(sc->sc_if);
-       break;
-
-    case SIOCGPPPSTATS:
-       psp = &((struct ifpppstatsreq *) data)->stats;
-       bzero(psp, sizeof(*psp));
-       psp->p.ppp_ibytes = sc->sc_bytesrcvd;
-       psp->p.ppp_ipackets = if_ipackets(sc->sc_if);
-       psp->p.ppp_ierrors = if_ierrors(sc->sc_if);
-       psp->p.ppp_obytes = sc->sc_bytessent;
-       psp->p.ppp_opackets = if_opackets(sc->sc_if);
-       psp->p.ppp_oerrors = if_oerrors(sc->sc_if);
-#ifdef VJC
-       psp->vj.vjs_packets = sc->sc_comp.stats.vjs_packets;
-       psp->vj.vjs_compressed = sc->sc_comp.stats.vjs_compressed;
-       psp->vj.vjs_searches = sc->sc_comp.stats.vjs_searches;
-       psp->vj.vjs_misses = sc->sc_comp.stats.vjs_misses;
-       psp->vj.vjs_uncompressedin = sc->sc_comp.stats.vjs_uncompressedin;
-       psp->vj.vjs_compressedin = sc->sc_comp.stats.vjs_compressedin;
-       psp->vj.vjs_errorin = sc->sc_comp.stats.vjs_errorin;
-       psp->vj.vjs_tossed = sc->sc_comp.stats.vjs_tossed;
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case SIOCGPPPCSTATS:
-       pcp = &((struct ifpppcstatsreq *) data)->stats;
-       bzero(pcp, sizeof(*pcp));
-       if (sc->sc_xc_state != NULL)
-           (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c);
-       if (sc->sc_rc_state != NULL)
-           (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d);
-       break;
-#endif /* PPP_COMPRESS */
-
-    default:
-       error = EINVAL;
-    }
-    splx(s);
-    return (error);
-}
-
-/*
- * Queue a packet.  Start transmission if not active.
- * Packet is placed in Information field of PPP frame.
- *
- * This procedure MUST take an actual netbuf_t as input
- * since it may be called by procedures outside of us.
- * The buffer received must be in the same format as that
- * returned by pppgetbuf().
- */
-int
-pppoutput(ifp, in_nb, arg)
-    netif_t ifp;
-    netbuf_t in_nb;
-    void *arg;
-{
-    register struct ppp_softc *sc = &ppp_softc[if_unit(ifp)];
-    struct sockaddr *dst = (struct sockaddr *) arg;
-    int protocol, address, control;
-    u_char *cp;
-    int s, error;
-    mark_t flags = 0;
-    struct ip *ip;
-    struct nb_queue *ifq;
-    enum NPmode mode;
-    NETBUF_T m0;
-
-    m0 = nb_TO_NB(in_nb);
-
-    if (sc->sc_devp == NULL || (if_flags(ifp) & IFF_RUNNING) == 0
-       || (if_flags(ifp) & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC) {
-       error = ENETDOWN;       /* sort of */
-       goto bad;
-    }
-
-
-    /*
-     * Compute PPP header.
-     */
-    flags &= ~M_HIGHPRI;
-    switch (dst->sa_family) {
-#ifdef INET
-    case AF_INET:
-       address = PPP_ALLSTATIONS;
-       control = PPP_UI;
-       protocol = PPP_IP;
-       mode = sc->sc_npmode[NP_IP];
-
-       /*
-        * If this packet has the "low delay" bit set in the IP header,
-        * or TCP and to an interactive port, put it on the fastq instead
-        */
-       ip = mtod(m0, struct ip *);
-       if (ip->ip_tos & IPTOS_LOWDELAY || ip->ip_p == IPPROTO_ICMP)
-           goto urgent;
-       else if (ip->ip_p == IPPROTO_TCP) {
-           register u_short *p = (u_short *) &(((caddr_t) ip)[ip->ip_hl << 2]);
-           if (INTERACTIVE(ntohs(p[0])) || INTERACTIVE(ntohs(p[1])))
-urgent:                flags |= M_HIGHPRI;
-       }
-       break;
-#endif
-#ifdef NS
-    case AF_NS:
-       address = PPP_ALLSTATIONS;
-       control = PPP_UI;
-       protocol = PPP_XNS;
-       mode = NPMODE_PASS;
-       break;
-#endif
-    case AF_UNSPEC:
-       address = PPP_ADDRESS(dst->sa_data);
-       control = PPP_CONTROL(dst->sa_data);
-       protocol = PPP_PROTOCOL(dst->sa_data);
-       mode = NPMODE_PASS;
-       break;
-    default:
-       IOLog("ppp%d: af%d not supported\n", if_unit(ifp), dst->sa_family);
-       error = EAFNOSUPPORT;
-       goto bad;
-    }
-
-    /*
-     * Drop this packet, or return an error, if necessary.
-     */
-    if (mode == NPMODE_ERROR) {
-       error = ENETDOWN;
-       goto bad;
-    }
-    if (mode == NPMODE_DROP) {
-       error = 0;
-       goto bad;
-    }
-
-    /*
-     * Add PPP header.
-     */
-    NB_GROW_TOP(m0, PPP_HDRLEN);
-
-    cp = mtod(m0, u_char *);
-    *cp++ = address;
-    *cp++ = control;
-    *cp++ = protocol >> 8;
-    *cp++ = protocol & 0xff;
-
-
-    if (sc->sc_flags & SC_LOG_OUTPKT) {
-       IOLog("ppp%d: output:\n", if_unit(ifp));        /* XXX */
-       pppdumpm(m0);
-    }
-
-
-    /*
-     * Put the packet on the appropriate queue.
-     */
-    s = splimp();              /* splnet should be OK now */
-    if (mode == NPMODE_QUEUE) {
-       NB_SET_MARK(m0,flags);                  /* save priority */
-       /* XXX we should limit the number of packets on this queue */
-       nbq_enqueue(&sc->sc_npq, m0);           /* XXX is this correct? */
-    } else {
-       ifq = (flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_slowq;
-       if (nbq_full(ifq) < 0) {
-           nbq_drop(ifq);
-           IOLog("ppp%d: output queue full\n", if_unit(sc->sc_if));
-           splx(s);
-           incr_cnt(sc->sc_if, if_oerrors);
-           error = ENOBUFS;
-           goto bad;
-       }
-       nbq_enqueue(ifq, m0);
-    }
-
-    /*
-     * If we don't have some compressed packets already
-     * and we are not at interrupt priority, then do some compression. 
-     *
-     * We need to be especially careful here.  pppouput() is typically
-     * called at 2 different priority levels.  On a NeXT, neither of these
-     * is the interrupt priority level.  However, on Intel, one of them is.
-     * I don't know about HPPA or Sparc. Simple fix is to just check.
-     */
-    
-    if(!sc->sc_compsched && s != ipltospl(IPLIMP)) {
-       sc->sc_compsched = 1;
-       splx(s);
-       pppintr_comp(sc);    /* Calls pppstart() */
-    }
-    else {
-      (*sc->sc_start)(sc);
-      splx(s);
-    }
-
-    return (0);
-
-bad:
-    NB_FREE(m0);
-    return (error);
-}
-
-/*
- * After a change in the NPmode for some NP, move packets from the
- * npqueue to the send queue or the fast queue as appropriate.
- * Should be called at splimp (actually splnet would probably suffice).
- * Due to some of the uglies in the packet queueing system I have
- * implemented this without the mpp stuff.
- * PCF
- */
-
-static void
-ppp_requeue(sc)
-    struct ppp_softc *sc;
-{
-    NETBUF_T m, lm, nm;
-    struct nb_queue *ifq;
-    enum NPmode mode;
-    mark_t flags;
-
-    lm = nm = NULL;
-    for (m = sc->sc_npq.head; m; ) {
-       NB_GET_NEXT(m,&nm);
-
-       switch (PPP_PROTOCOL(mtod(m, u_char *))) {
-       case PPP_IP:
-           mode = sc->sc_npmode[NP_IP];
-           break;
-       default:
-           mode = NPMODE_PASS;
-       }
-
-       switch (mode) {
-       case NPMODE_PASS:
-           /*
-            * This packet can now go on one of the queues to be sent.
-            */
-           if(lm)
-               NB_SET_NEXT(lm,nm);
-           else
-               sc->sc_npq.head = nm;
-           NB_SET_NEXT(m,NULL);
-           NB_GET_MARK(m,&flags);
-           ifq = (flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_slowq;
-           if (nbq_full(ifq)) {
-               nbq_drop(ifq);
-               incr_cnt(sc->sc_if, if_oerrors);
-               NB_FREE(m);
-           } else 
-               nbq_enqueue(ifq, m);
-           sc->sc_npq.len--;
-           break;
-
-       case NPMODE_DROP:
-       case NPMODE_ERROR:
-           sc->sc_npq.len--;
-           NB_FREE(m);
-           break;
-
-       case NPMODE_QUEUE:
-           lm = m;
-           break;
-       }
-       m = nm;
-    }
-    sc->sc_npq.tail = lm;      /*  anything further on has been sent ! */
-}
-
-/*
- * Get a packet to send.  This procedure is intended to be called
- * at spltty()/splimp(), so it takes little time.  If there isn't
- * a packet waiting to go out, it schedules a software interrupt
- * to prepare a new packet; the device start routine gets called
- * again when a packet is ready.
- */
-NETBUF_T
-ppp_dequeue(sc)
-    struct ppp_softc *sc;
-{
-  NETBUF_T m;
-  int error;
-  
-  m = nbq_dequeue(&sc->sc_compq);
-
-
-  if (!sc->sc_compsched && 
-      (! nbq_empty(&sc->sc_slowq) || ! nbq_empty(&sc->sc_fastq)))
-    {
-      
-      if ((error = pppsched(pppintr_comp, sc)) == KERN_SUCCESS)
-       sc->sc_compsched = 1;
-      else
-       {
-         IOLogDbg("ppp%d: compression callout failed returning %d\n",
-                  if_unit(sc->sc_if), error);
-       }
-    }
-  
-  return m;
-}
-
-/*
- * Takes all received input packets and uncompresses/hands_off.
- * Must not be reentrant and is called at normal priority.
- * Guaranteed Non-Reentrancy means we don't need to be at splnet().
- *
- */
-
-void
-pppintr_decomp(arg)
-    void *arg;
-{
-    struct ppp_softc *sc = (struct ppp_softc *)arg;
-    int s;
-    NETBUF_T m;
-
-    if (nbq_low(&sc->sc_freeq))
-      pppfillfreeq((void *) sc);
-
-  decomp:
-    for (;;) {
-      m = nbq_dequeue(&sc->sc_rawq);
-      if (m == NULL)
-       break;
-      ppp_inproc(sc, m);
-    }
-
-  /*
-   * Now we have aparently emptied the queue.  So, we try to reset the
-   * synchronization flag that schedules callbacks.  We check for the
-   * possibility that an interrupt occurred before we finish this check.
-   */
-  s = splimp();
-  if (!nbq_empty(&sc->sc_rawq))
-    {
-      splx(s);
-      goto decomp;
-    }
-  else
-    {
-      sc->sc_decompsched = 0;
-      splx(s);
-    }
-}
-
-
-
-/*
- * Readies the next few output packet from
- * the sc_fastq/sc_slowq.  Will try to
- * precompress all packets on the fast
- * queue and at most one from the slow queue.
- */
-void
-pppintr_comp(arg)
-    void *arg;
-{
-  struct ppp_softc *sc = (struct ppp_softc *)arg;
-  int s;
-  NETBUF_T m;
-  
-  if (nbq_low(&sc->sc_freeq))
-    pppfillfreeq((void *) sc);
-
-  
-  while (!nbq_full(&sc->sc_compq) && !nbq_empty(&sc->sc_fastq))
-    ppp_outpkt(sc);
-
-  if (!nbq_full(&sc->sc_compq) && !nbq_empty(&sc->sc_slowq))
-    ppp_outpkt(sc);
-      
-  sc->sc_compsched = 0;
-}
-
-/*
- * Grab another packet off a queue and apply VJ compression,
- * packet compression, address/control and/or protocol compression
- * if enabled.  Should be called at splnet.
- */
-static void
-ppp_outpkt(sc)
-    struct ppp_softc *sc;
-{
-    int s;
-    NETBUF_T m;
-    u_char *cp;
-    int address, control, protocol;
-#if NS_TARGET >= 40
-    struct timeval tv_time;
-#endif
-
-    /*
-     * Grab a packet to send: first try the fast queue, then the
-     * normal queue.
-     */
-    m = nbq_dequeue(&sc->sc_fastq);
-    if (m == NULL)
-       m = nbq_dequeue(&sc->sc_slowq);
-    if (m == NULL)
-       return;
-
-    /*
-     * Extract the ppp header of the new packet.
-     * The ppp header will be in one netbuf.
-     */
-    cp = mtod(m, u_char *);
-    address = PPP_ADDRESS(cp);
-    control = PPP_CONTROL(cp);
-    protocol = PPP_PROTOCOL(cp);
-
-#if NS_TARGET >= 40
-       ns_time_to_timeval(clock_value(System), &tv_time);
-#endif /* NS_TARGET */
-
-    switch (protocol) {
-    case PPP_IP:
-       /*
-        * Update the time we sent the most recent packet.
-        */
-#if NS_TARGET >= 40
-       sc->sc_last_sent = tv_time.tv_sec;
-#else
-        sc->sc_last_sent = time.tv_sec;
-#endif /* NS_TARGET */
-
-#ifdef VJC
-       /*
-        * If the packet is a TCP/IP packet, see if we can compress it.
-        */
-       if (sc->sc_flags & SC_COMP_TCP) {
-           struct ip *ip;
-           int type;
-           u_char *vjhdr;
-
-           ip = (struct ip *) (cp + PPP_HDRLEN);
-           /* this code assumes the IP/TCP header is in one netbuf */
-           if (ip->ip_p == IPPROTO_TCP) {
-               type = vj_compress_tcp(ip, NB_SIZE(m) - PPP_HDRLEN,
-                                      &sc->sc_comp,
-                                      !(sc->sc_flags & SC_NO_TCP_CCID), &vjhdr);
-               switch (type) {
-               case TYPE_UNCOMPRESSED_TCP:
-                   protocol = PPP_VJC_UNCOMP;
-                   break;
-               case TYPE_COMPRESSED_TCP:
-                   NB_SHRINK_TOP(m, vjhdr - (u_char *) ip);
-                   protocol = PPP_VJC_COMP;
-                   cp = mtod(m, u_char *);
-                   cp[0] = address;    /* header has moved */
-                   cp[1] = control;
-                   cp[2] = 0;
-                   break;
-               }
-               cp[3] = protocol;       /* update protocol in PPP header */
-           }
-       }
-
-#endif /* VJC */
-
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPP_CCP:
-       ppp_ccp(sc, m, 0);
-       break;
-#endif /* PPP_COMPRESS */
-    }
-
-
-#ifdef PPP_COMPRESS
-    if (protocol != PPP_LCP && protocol != PPP_CCP
-       && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
-       NETBUF_T mcomp;
-       int slen, clen;
-
-       slen = NB_SIZE(m);
-
-       clen = (*sc->sc_xcomp->compress)
-           (sc->sc_xc_state, &mcomp, m, slen,
-            sc->sc_flags & SC_CCP_UP? if_mtu(sc->sc_if): 0);
-
-
-       if (mcomp && (NB_SIZE(mcomp) >= slen))
-           IOLog("BSD Warning... packet growth: Orig=%d New=%d.\n",
-                 slen, NB_SIZE(mcomp));
-
-       if (mcomp != NULL) {
-
-           NB_FREE(m);
-           m = mcomp;
-           cp = mtod(m, u_char *);
-           protocol = cp[3];
-       }
-    }
-#endif /* PPP_COMPRESS */
-
-    /*
-     * Compress the address/control and protocol, if possible.
-     */
-    if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS &&
-       control == PPP_UI && protocol != PPP_ALLSTATIONS &&
-       protocol != PPP_LCP) {
-       /* can compress address/control */
-       NB_SHRINK_TOP(m, 2);
-    }
-    if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) {
-       /* can compress protocol */
-       if (mtod(m, u_char *) == cp) {
-           cp[2] = cp[1];      /* move address/control up */
-           cp[1] = cp[0];
-       }
-       NB_SHRINK_TOP(m, 1);
-    }
-
-
-    s = splimp();
-    nbq_enqueue(&sc->sc_compq, m);
-    (*sc->sc_start)(sc);
-    splx(s);
-}
-
-#ifdef PPP_COMPRESS
-/*
- * Handle a CCP packet.  `rcvd' is 1 if the packet was received,
- * 0 if it is about to be transmitted.
- */
-static void
-ppp_ccp(sc, m, rcvd)
-    struct ppp_softc *sc;
-    NETBUF_T m;
-    int rcvd;
-{
-    u_char *dp, *ep;
-    int slen, s;
-
-    /*
-     * Get a pointer to the data after the PPP header.
-     */
-    dp = mtod(m, u_char *) + PPP_HDRLEN;
-
-    ep = mtod(m, u_char *) + NB_SIZE(m);
-    if (dp + CCP_HDRLEN > ep)
-       return;
-    slen = CCP_LENGTH(dp);
-    if (dp + slen > ep) {
-       IOLogDbg("ppp%d: ccp: not enough data in netbuf (%x+%x > %x+%x)\n",
-                if_unit(sc->sc_if), dp, slen, mtod(m, u_char *), NB_SIZE(m));
-       return;
-    }
-
-    switch (CCP_CODE(dp)) {
-    case CCP_CONFREQ:
-    case CCP_TERMREQ:
-    case CCP_TERMACK:
-       /* CCP must be going down - disable compression */
-       if (sc->sc_flags & SC_CCP_UP) {
-           s = splimp();
-           sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
-           splx(s);
-       }
-       break;
-
-    case CCP_CONFACK:
-       if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP)
-           && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
-           && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
-           if (!rcvd) {
-               /* we're agreeing to send compressed packets. */
-               if (sc->sc_xc_state != NULL
-                   && (*sc->sc_xcomp->comp_init)
-                       (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        if_unit(sc->sc_if), 0, sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_COMP_RUN;
-                   splx(s);
-               }
-           } else {
-               /* peer is agreeing to send compressed packets. */
-               if (sc->sc_rc_state != NULL
-                   && (*sc->sc_rcomp->decomp_init)
-                       (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        if_unit(sc->sc_if),
-#ifdef VJC
-                        VJ_HDRLEN +
-#endif
-                        0, sc->sc_mru, sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_DECOMP_RUN;
-                   sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
-                   splx(s);
-               }
-           }
-       }
-       break;
-
-    case CCP_RESETACK:
-       if (sc->sc_flags & SC_CCP_UP) {
-           if (!rcvd) {
-               if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
-                   (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state);
-                   nbq_flush(&sc->sc_compq);  /* Flush pre-compressed packets */
-                 }
-           } else {
-               if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-                   (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state);
-                   s = splimp();
-                   sc->sc_flags &= ~SC_DC_ERROR;
-                   splx(s);
-               }
-           }
-       }
-       break;
-    }
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-static void
-ppp_ccp_closed(sc)
-    struct ppp_softc *sc;
-{
-    if (sc->sc_xc_state) {
-       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-       sc->sc_xc_state = NULL;
-    }
-    if (sc->sc_rc_state) {
-       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-       sc->sc_rc_state = NULL;
-    }
-}
-#endif /* PPP_COMPRESS */
-
-/*
- * PPP packet input routine.
- * The caller has checked and removed the FCS and has inserted
- * the address/control bytes and the protocol high byte if they
- * were omitted.
- */
-void
-ppppktin(sc, m, lost)
-    struct ppp_softc *sc;
-    NETBUF_T m;
-    int lost;
-{
-  int error, s = splimp();
-  
-  NB_SET_MARK(m,(lost ? M_ERRMARK : 0));
-  
-  /* XXX - we should check for the raw queue overflowing... */
-  nbq_enqueue(&sc->sc_rawq, m);
-  if (!sc->sc_decompsched)
-    {
-      if ((error = pppsched(pppintr_decomp, sc)) == KERN_SUCCESS)
-       sc->sc_decompsched = 1;
-      else
-       IOLogDbg("ppp%d: decompression callout failed returning %d\n",
-                if_unit(sc->sc_if), error);
-    }
-  
-  splx(s);
-}
-
-/*
- * Process a received PPP packet, doing decompression as necessary.
- */
-#define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
-                        TYPE_UNCOMPRESSED_TCP)
-
-static void
-ppp_inproc(sc, m)
-    struct ppp_softc *sc;
-    NETBUF_T m;
-{
-    struct nb_queue *inq;
-    int s, ilen, xlen, proto, rv;
-    mark_t flags;
-    u_char *cp, adrs, ctrl;
-    NETBUF_T dmp;
-    u_char *iphdr;
-    u_int hlen;
-#if NS_TARGET >= 40
-    struct timeval tv_time;
-#endif /* NS_TARGET */
-
-
-    incr_cnt(sc->sc_if, if_ipackets);
-
-    NB_GET_MARK(m,&flags);
-
-    if (sc->sc_flags & SC_LOG_INPKT) {
-       IOLog("ppp%d: got %d bytes\n", if_unit(sc->sc_if), NB_SIZE(m));
-       pppdumpm(m);
-    }
-
-    cp = mtod(m, u_char *);
-    adrs = PPP_ADDRESS(cp);
-    ctrl = PPP_CONTROL(cp);
-    proto = PPP_PROTOCOL(cp);
-
-    if (flags & M_ERRMARK) {
-       s = splimp();
-       sc->sc_flags |= SC_VJ_RESET;
-       splx(s);
-    }
-
-#ifdef PPP_COMPRESS
-    /*
-     * Decompress this packet if necessary, update the receiver's
-     * dictionary, or take appropriate action on a CCP packet.
-     */
-    if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)
-       && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) {
-       /* decompress this packet */
-       rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp);
-       if (rv == DECOMP_OK){
-
-         NB_FREE(m);
-         if (dmp == NULL){
-           /* No error, but no decompressed packet returned */
-           return;
-         }
-           m = dmp;
-           cp = mtod(m, u_char *);
-           proto = PPP_PROTOCOL(cp);
-       } else {
-           /*
-            * An error has occurred in decompression.
-            * Pass the compressed packet up to pppd, which may take
-            * CCP down or issue a Reset-Req.
-            */
-           IOLogDbg("ppp%d: decompress failed %d\n", if_unit(sc->sc_if), rv);
-           s = splimp();
-           sc->sc_flags |= SC_VJ_RESET;
-
-           if (rv == DECOMP_ERROR)
-             sc->sc_flags |= SC_DC_ERROR;
-           else
-             sc->sc_flags |= SC_DC_FERROR;
-           splx(s);
-       }
-
-    } else {
-       if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN))
-         {
-
-           (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m);
-       }
-       if (proto == PPP_CCP) {
-           ppp_ccp(sc, m, 1);
-       }
-    }
-#endif
-
-    ilen = NB_SIZE(m);
-
-#ifdef VJC
-    if (sc->sc_flags & SC_VJ_RESET) {
-       /*
-        * If we've missed a packet, we must toss subsequent compressed
-        * packets which don't have an explicit connection ID.
-        */
-
-/*     IOLog("SC_VJ_RESET was set!\n"); */
-
-       vj_uncompress_err(&sc->sc_comp);
-       s = splimp();
-       sc->sc_flags &= ~SC_VJ_RESET;
-       splx(s);
-    }
-
-    /*
-     * See if we have a VJ-compressed packet to uncompress.
-     */
-    if (proto == PPP_VJC_COMP) {
-       if (sc->sc_flags & SC_REJ_COMP_TCP)
-           goto bad;
-
-
-       xlen = vj_uncompress_tcp(cp + PPP_HDRLEN, ilen - PPP_HDRLEN,
-                                ilen - PPP_HDRLEN,
-                                &sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen <= 0) {
-/*
-   IOLogDbg("ppp%d: VJ uncompress failed on type comp\n", 
-                       if_unit(sc->sc_if));
-*/
-           goto bad;
-       }
-
-       /*
-        * Write the IP/TCP header back into the datagram.
-        * The pointers point to the stored copy in the VJ
-        * compression table.
-        */
-   
-       NB_GROW_TOP(m, hlen - xlen);
-       NB_WRITE(m, PPP_HDRLEN, hlen, iphdr);
-
-       cp = mtod(m, u_char *);
-
-#ifdef TCP_CHECKSUM
-    {
-#define getip_hl(base) ((base).ip_hl)
-
-      u_short mytcpcksum (struct ip *pip);
-      struct tcphdr *ptcp;
-      struct ip *iphdr;
-      u_short thecksum;
-      u_long hlen;
-
-      iphdr = (struct ip*) (cp + PPP_HDRLEN);
-      hlen = getip_hl(*iphdr) << 2;  /* Length is in words */
-      ptcp = (struct tcphdr *)&((u_char *)iphdr)[hlen];
-
-      thecksum = (u_short)mytcpcksum(iphdr);
-
-      if(ptcp->th_sum != thecksum)
-       {
-#ifdef NEWVJ_RESYNC
-         set_newvj_error_mode();
-#endif
-         IOLog("NEWVJ: Warning... TCP checksum failed Received=%u, Calculated=%u)\n",
-               (ptcp->th_sum)&0xffff, thecksum&0xffff);
-       }
-    }              
-#endif
-
-
-       cp[0] = adrs;
-       cp[1] = ctrl;
-       cp[2] = 0;
-       cp[3] = PPP_IP;
-       proto = PPP_IP;
-
-       ilen += hlen - xlen;
-
-    } else if (proto == PPP_VJC_UNCOMP) {
-       if (sc->sc_flags & SC_REJ_COMP_TCP)
-           goto bad;
-
-
-       vj_uncompress_uncomp(cp + PPP_HDRLEN, ilen-PPP_HDRLEN, &sc->sc_comp);
-
-       proto = PPP_IP;
-       cp[3] = PPP_IP;
-    }
-#endif /* VJC */
-
-
-    rv = 0;
-    switch (proto) {
-#ifdef INET
-    case PPP_IP:
-       /*
-        * IP packet - take off the ppp header and pass it up to IP.
-        */
-       if ((if_flags(sc->sc_if) & IFF_UP) == 0
-           || sc->sc_npmode[NP_IP] != NPMODE_PASS) {
-           /* interface is down - drop the packet. */
-           NB_FREE(m);
-           IOLogDbg("ppp%d: IP packed dropped (NPmode)\n", if_unit(sc->sc_if));
-           return;
-       }
-       NB_SHRINK_TOP(m, PPP_HDRLEN);
-       inet_queue(sc->sc_if, NB_TO_nb(m));
-#if NS_TARGET >= 40
-       /*  I am assuming the time is different here than above. */
-       ns_time_to_timeval(clock_value(System), &tv_time);
-       sc->sc_last_recv = tv_time.tv_sec; /* update time of last pkt rcvd */
-#else
-       sc->sc_last_recv = time.tv_sec; /* update time of last pkt rcvd */
-#endif
-       return;
-#endif
-
-    default:
-       /*
-        * Some other protocol - place on input queue for read().
-        */
-       inq = &sc->sc_inq;
-       rv = 1;
-       break;
-    }
-
-    /*
-     * Put the packet on the appropriate input queue.
-     */
-    s = splimp();
-    if (nbq_full(inq)) {
-       nbq_drop(inq);
-       splx(s);
-       IOLog("ppp%d: input queue full\n", if_unit(sc->sc_if));
-       goto bad;
-    }
-    nbq_enqueue(inq, m);
-    splx(s);
-
-    if (rv)
-       (*sc->sc_ctlp)(sc);
-
-    return;
-
- bad:
-    NB_FREE(m);
-    incr_cnt(sc->sc_if, if_ierrors);
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-pppdumpm(m0)
-    NETBUF_T m0;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-    int l = NB_SIZE(m0);
-    u_char *rptr = mtod(m0, u_char *);
-
-    while (l--) {
-       if (bp > buf + sizeof(buf) - 4)
-           goto done;
-       *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*rptr++ & 0xf];
-    }
-
-    *bp++ = ' ';
-done:
-    if (l)
-       *bp++ = '>';
-    *bp = 0;
-    IOLog("%s\n", buf);
-}
-
-
diff --git a/NeXT/if_pppvar.h b/NeXT/if_pppvar.h
deleted file mode 100644 (file)
index 55f2250..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * if_ppp.h - Point-to-Point Protocol definitions.
- *
- * 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.
- */
-
-/* Portions Copyright (C) 1990 Brad K. Clements (streams support)
- */
-
-#if !(NS_TARGET >= 40)
-#import <kernserv/prototypes.h>
-#endif /* NS_TARGET */
-
-/*
- * Supported network protocols.  These values are used for
- * indexing sc_npmode.
- */
-#define NP_IP  0               /* Internet Protocol */
-#define NUM_NP 1               /* Number of NPs. */
-
-#include "nbq.h"
-
-
-/* only defined in the posix universe... */
-/*typedef      int pid_t; */
-
-struct ppp_softc {
-       netif_t sc_if;          /* network-visible interface */
-       u_int   sc_flags;       /* control/status bits; see if_ppp.h */
-       struct  tty *sc_devp;   /* pointer to device-dep structure */
-       void    (*sc_start) __P((struct ppp_softc *));  /* start output proc */
-       void    (*sc_ctlp) __P((struct ppp_softc *));   /* rcvd control pkt */
-       void    (*sc_relinq) __P((struct ppp_softc *)); /* relinquish ifunit */
-       u_int16_t sc_mru;       /* max receive unit */
-       pid_t   sc_xfer;        /* used in transferring unit */
-       NETBUF_T sc_m;          /* Current TTY input netbuf */
-       struct nb_queue sc_freeq; /* reserve netbufs */
-       struct nb_queue sc_rawq;  /* Raw input buffers */
-       struct nb_queue sc_fastq; /* For telnet, rlogin, and ftp control */
-       struct nb_queue sc_slowq; /* Everything else */
-       struct nb_queue sc_inq; /* Input available to user ppp */
-       struct nb_queue sc_npq; /* output packets not to be sent yet */
-       struct nb_queue sc_compq; /* Cache of compressed bufs to be sent */
-#ifdef VJC
-       struct vjcompress sc_comp;
-#endif
-       u_int   sc_bytessent;   /* count of octets sent */
-       u_int   sc_bytesrcvd;   /* count of octets received */
-       enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
-#ifdef PPP_COMPRESS
-       struct compressor *sc_xcomp; /* transmit compressor */
-       void    *sc_xc_state;   /* transmit compressor state */
-       struct compressor *sc_rcomp; /* receive decompressor */
-       void    *sc_rc_state;   /* receive decompressor state */
-#endif
-       time_t  sc_last_sent;   /* time (secs) last NP pkt sent */
-       time_t  sc_last_recv;   /* time (secs) last NP pkt rcvd */
-
-       short sc_compsched;     /* synchronize compression callouts */
-       short sc_decompsched;   /* synchronize decompression callouts */
-
-       /* Device-dependent part for async lines. */
-       ext_accm sc_asyncmap;   /* async control character map */
-       u_int32_t sc_rasyncmap; /* receive async control char map */
-       NETBUF_T sc_outm;       /* netbuf currently being output */
-       char    *sc_mp;         /* ptr to next char in input netbuf */
-       u_int16_t sc_ilen;      /* length of input packet so far */
-       u_int16_t sc_fcs;       /* FCS so far (input) */
-       u_int16_t sc_outfcs;    /* FCS so far for output packet */
-       u_char  sc_rawin[16];   /* chars as received */
-       int     sc_rawin_count; /* # in sc_rawin */
-};
-
-extern struct  ppp_softc ppp_softc[];
-
-struct ppp_softc *pppalloc __P((pid_t pid));
-void   pppdealloc __P((struct ppp_softc *sc));
-int    pppioctl __P((struct ppp_softc *sc, u_long cmd, void *data, int flag));
-void   ppppktin __P((struct ppp_softc *sc, NETBUF_T m, int lost));
-NETBUF_T ppp_dequeue __P((struct ppp_softc *sc));
-
-#define t_sc T_LINEP
-
-#define incr_cnt(ifp,field) field##_set(ifp, field(ifp) + 1)
-
-#ifdef VJC
-#define VJ_HDRLEN      128
-#endif
diff --git a/NeXT/inlines.h b/NeXT/inlines.h
deleted file mode 100644 (file)
index 88e155a..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Netbufs don't come with nifty queuing functions
- * like mbufs. We therefore make our own quques by
- * squirreling away an extra pointer before the data
- * in a netbuf. As we can't guarantee that this will
- * be aligned to anything in particular I use bcopy to
- * read and write it. bcopy can use 32 bit if it really
- * feels like it...
- * PCF
- *
-
-#if defined(m68k)
-#import "spl.h"
-#else
-#import <kernserv/machine/spl.h>
-#endif
-#include <kernserv/kern_server_types.h>
-#include <kernserv/kalloc.h>
-#include "nbq.h"
-
-/*
- * There is no driver kit for the Moto release.
- */
-#ifndef IOLog
-#define IOLog printf
-#define        IOLogDbg                if (sc->sc_flags & SC_DEBUG) printf
-#else
-#define        IOLogDbg                if (sc->sc_flags & SC_DEBUG) IOLog
-#endif
-
-extern kern_server_t instance;
-
-/*
- * Careful about using this function.  Some places
- * in the code drop packets based on this count
- * but they never free them.
- */
-
-static inline int
-nbq_full(struct nb_queue* nbq)
-{
-    int rv;
-    rv = (nbq->len >= nbq->max);
-    return rv;
-}
-
-static inline int
-nbq_empty(struct nb_queue* nbq)
-{
-    int rv;
-    rv = (!nbq->head);
-    return rv;
-}
-
-static inline int
-nbq_low(struct nb_queue* nbq)
-{
-    int rv;
-    rv = (nbq->len <= nbq->low);
-    return rv;
-}
-
-static inline int
-nbq_high(struct nb_queue* nbq)
-{
-    int rv;
-    rv = (nbq->len >= nbq->high);
-    return rv;
-}
-
-static inline NETBUF_T
-nbq_peek(struct nb_queue* nbq)
-{
-    int s;
-    NETBUF_T nb;
-
-    s = splimp();
-    nb = nbq->head;
-    splx(s);
-    return nb;
-}
-
-static inline NETBUF_T
-nbq_dequeue(struct nb_queue* nbq)
-{
-  int s;
-  NETBUF_T nb;
-
-  if (!nbq->head)
-      return NULL;
-
-  s = splimp();
-  nb = nbq->head;
-  NB_GET_NEXT(nb,&nbq->head);
-  if (!nbq->head)
-       nbq->tail = NULL;
-  --nbq->len;
-  splx(s);
-
-  return nb;
-}
-
-/*
- * One simple note about nbq_enqueue: it will enqueue packets even if
- * it is full, so the caller is responsible for checking this first...
- *
- * We return 1 if we added, else we return 0
- * if there was a problem. We leave it up to the caller
- * to detect an error return value (0) and print
- * an appropriate message/update stats.  However, in the spirit of
- * keeping the code as close to the netbsd version as is possible,
- * WE WILL FREE a packet that can't be enqueued.  This should be the
- * responsibility of the caller but that is currently not the case.
- *
- * Actually, now I'm using the hidden pointer arrangement then theres
- * no circumstances under which this can return 0, oh well...
- * PCF
- */
-
-static inline int
-nbq_enqueue(struct nb_queue* nbq, NETBUF_T nb)
-{
-  int s;
-
-  NB_SET_NEXT(nb,NULL);
-  s = splimp();
-  if (nbq->tail)
-    NB_SET_NEXT(nbq->tail,nb);
-  else
-    nbq->head = nb;
-  nbq->tail = nb;
-  ++nbq->len;
-  splx(s);
-  return 1;
-}
-
-static inline void
-nbq_flush(struct nb_queue *nbq)
-{
-    NETBUF_T nb,temp;
-    int s;
-
-    s  = splimp();
-    nb = nbq->head;
-    while(nb) {
-       temp=nb;
-       NB_GET_NEXT(nb,&nb);
-       NB_FREE(temp);
-    }
-
-    nbq->head = nbq->tail = NULL;
-    nbq->len = 0;
-    nbq->dropped = 0;
-    splx(s);
-}
-
-/*
- * Must not be called at interrupt priority
- */
-
-static inline void
-nbq_init(struct nb_queue *nbq, struct qparms *qp)
-{
-  nbq->name = qp->q_name;
-  nbq->head = nbq->tail = NULL;
-  nbq->low = qp->q_low;
-  nbq->high = qp->q_high;
-  nbq->max = qp->q_max;
-  nbq->len = 0;
-  nbq->dropped = 0;
-}
-
-static inline void
-nbq_free(struct nb_queue *nbq)
-{
-  nbq_flush(nbq);
-}
-
-static inline void
-nbq_drop(struct nb_queue *nbq)
-{
-    ++nbq->dropped;
-}
-
-/*
- * Not very pretty, but it makes for less "diffs"...
- */
-#define mtod(m,type)   ((type) NB_MAP(m))
-
-typedef void (*pfv)(void *);
-
-/* used by both ppp_tty.c and if_ppp.c */
-static inline kern_return_t
-pppsched(pfv func, struct ppp_softc *sc)
-{
-    extern kern_server_t instance;
-    kern_return_t result;
-
-    if ((result = kern_serv_callout(&instance, func, (void *)sc)) != KERN_SUCCESS)
-      IOLog("kern_serv_callout failed: ret = %x\n", result);
-
-    return result;
-}
-
-#undef u
-
-static inline thread_t
-current_thread(void)
-{
-       extern thread_t active_threads[];
-
-       return active_threads[0];
-}
-
-extern struct proc *proc_from_thread(thread_t);
-extern struct uthread *uthread_from_thread(thread_t);
-
-#define        curproc         (proc_from_thread(current_thread()))
-
diff --git a/NeXT/libposix/Makefile b/NeXT/libposix/Makefile
deleted file mode 100644 (file)
index d4c9188..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# libposix makefile
-# $Id: Makefile,v 1.1 1998/03/26 02:52:03 paulus Exp $
-#
-
-ARCHFLAGS = 
-
-SRCS = libposix.c
-OBJS = libposix.o
-
-CFLAGS = -O -D_POSIX_SOURCE $(ARCHFLAGS)
-
-all: $(OBJS)
-
-clean:
-       rm -f *.o *~ core
-
diff --git a/NeXT/libposix/libposix.c b/NeXT/libposix/libposix.c
deleted file mode 100644 (file)
index a9a5887..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*  Yes, that's right:  of all the platforms supported by ppp, 
-    only Mach OpenStep 4.x doesn't support POSIX.  Sheesh.
-
-    Stranger still, the POSIX declatations are still in the 4.x header files,
-    and the gcc -posix still defines _POSIX_SOURCE.  So... 
-    we emulate (sometimes badly) the missing POSIX functions.  This
-    is by no means a complete or general POSIX emulation.  Just enough 
-    to get us by for ppp, so we don't have to pollute the rest of the 
-    sources of every other (non-braindead) platform.  Much of the
-    code was snarfed from NeXT's 4.0 ppp port, the rest inspired by
-    "POSIX Programmers Guide" by Donald Lewine.
-    
-    Maybe if we complain NeXT will upgrade to BSD4.4 libs like the rest of
-    the free world (and maybe pink elephants will fly out of my...  -KC)
- */
-
-#include <signal.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <errno.h>
-
-int sigemptyset(sigset_t *set)
-{
-       *set = 0;
-       return 0;
-}
-
-int sigaddset(sigset_t *set, int signo)
-{
-       *set |= 1<<signo;
-       return 0;
-}
-
-int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
-{
-       switch(how) {
-       case SIG_BLOCK:
-               *oset = sigblock(*set);
-               break;
-       case SIG_UNBLOCK:
-               /* XXX How does one emulate this with ancient BSD? (KC) */
-               break;
-       case SIG_SETMASK:
-               *oset = sigsetmask(*set);
-               break;
-       }
-       return 0;
-}
-
-int sigsuspend(const sigset_t *sigmask)
-{
-       sigpause(*sigmask);
-}
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
-{
-       struct sigvec vec, ovec;
-       int st;
-
-       vec.sv_handler = act->sa_handler;
-       vec.sv_mask = act->sa_mask;
-       vec.sv_flags = act->sa_flags;
-       
-       st = sigvec(sig, &vec, &ovec);
-
-       if (oact) {
-               oact->sa_handler = ovec.sv_handler;
-               oact->sa_mask = ovec.sv_mask;
-               oact->sa_flags = ovec.sv_flags;
-       }
-
-       return st;
-}
-
-int tcgetattr(int fildes, struct termios *tp)
-{
-       return ioctl(fildes, TIOCGETA, tp);
-}
-
-int tcsetattr(int fd, int opt, const struct termios *t)
-{
-       int st;
-
-       switch(opt) {
-       case TCSANOW:
-               st = ioctl(fd, TIOCSETA, t);
-               break;
-       case TCSADRAIN:
-               st = ioctl(fd, TIOCSETAW, t);
-               break;
-       case TCSAFLUSH:
-               st = ioctl(fd, TIOCSETAF, t);
-               break;
-       default:
-               st = -1;
-               errno = EINVAL;
-               break;
-       }
-       return st;
-}
-
-/*  XXX we ignore duration (which is 0 in chat.c anyway).
- */
-int tcsendbreak(int fildes, int duration)
-{
-       struct timeval sleepytime;
-
-       sleepytime.tv_sec = 0;
-       sleepytime.tv_usec = 400000;
-       if (ioctl(fildes, TIOCSBRK, 0) != -1)
-       {
-           select(0, 0, 0, 0, &sleepytime);
-           (void) ioctl(fildes, TIOCCBRK, 0);
-       }
-}
-
-/*  XXX This is the implementation of cfgetospeed from NeXT's ppp-5
-    pppd/sys-NeXT.c.  I don't know whether returning c_ispeed instead
-    of c_ospeed is deliberate or a type-o.
- */
-speed_t cfgetospeed(const struct termios *t)
-{
-       return t->c_ispeed;
-}
-
-int cfsetospeed(struct termios *t, int speed)
-{ 
-       t->c_ospeed = speed; 
-       return 0; 
-}
-
-speed_t cfgetispeed(const struct termios *t)
-{
-       return t->c_ispeed;
-}
-
-int cfsetispeed(struct termios *t, int speed)
-{ 
-       t->c_ispeed = speed; 
-       return 0; 
-}
-
-int setsid(void)
-{
-    int fd;
-
-    setpgrp(0, getpid());
-    
-    if ( (fd = open("/dev/tty", O_RDWR | O_NDELAY)) < 0)
-           return -1;
-    ioctl(fd, TIOCNOTTY, NULL);
-    close(fd);
-
-    return 0;
-}
-
-int waitpid(pid_t pid, int *stat_loc, int options)
-{
-    if (pid == -1) 
-       pid = 0;
-    return wait4(pid, (union wait *) stat_loc, options, NULL);
-}
-
diff --git a/NeXT/linedisc.h b/NeXT/linedisc.h
deleted file mode 100644 (file)
index a7147ef..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * linedisc.h -- includes for use with loadable line disciplines
- */
-#define        KERNEL          1
-#define        KERNEL_FEATURES 1
-
-#ifdef m68k
-#import <machine/reg.h>
-#endif
-
-#import <sys/param.h>
-/*
-#import <sys/systm.h>
-*/
-#import <sys/user.h>
-#import <sys/ioctl.h>
-#import <sys/tty.h>
-#import <sys/proc.h>
-/*
-#import <sys/vnode.h>
-#import <sys/file.h>
-*/
-#import <sys/conf.h>
-#import <sys/buf.h>
-#import <sys/dk.h>
-#import <sys/uio.h>
-#import <sys/kernel.h>
-
-/*
-#import <machine/spl.h>
-*/
-#ifdef m68k
-#include "spl.h"
-#endif
-
-#if    NeXT
-/*
-#import <next/cons.h>
-#import <nextdev/kmreg.h>
-*/
-#endif NeXT
-
-/*
- * Line discipline "kind"
- * NORMAL_LDISC -- Normal line disciplines use tty struct clists in
- *                     standard manner
- * SPECIAL_LDISC -- Special line disciplines have private buffering
- *                     strategy
- */
-#define        NORMAL_LDISC    0
-#define        SPECIAL_LDISC   1
-
-extern int tty_ld_install(
-       int ld_number,
-       int ld_kind,
-       int (*ld_open)(dev_t dev, struct tty *tp),
-       void (*ld_close)(struct tty *tp),
-       int (*ld_read)(struct tty *tp, struct uio *uiop),
-       int (*ld_write)(struct tty *tp, struct uio *uiop),
-       int (*ld_ioctl)(struct tty *tp, int command, void *dataptr, int flag),
-       void (*ld_rint)(int c, struct tty *tp),
-       void (*ld_rend)(char *cp, u_int n, struct tty *tp),
-       void (*ld_start)(struct tty *tp),
-       int (*ld_modem)(struct tty *tp, int dcd_on),
-       int (*ld_select)(struct tty *tp, int rw)
-);
-extern int tty_ld_remove(int ld_number);
-extern void ttydevstart(struct tty *tp);
-extern void ttydevstop(struct tty *tp);
-extern void ttyselwait(struct tty *tp, int rw);
-extern void ttselwakeup(struct tty *tp);
-
diff --git a/NeXT/mach/features.h b/NeXT/mach/features.h
deleted file mode 100644 (file)
index e2efd55..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * NeXTStep 3.3 Developer for m68k is missing this file.
- * Some needed headers try to include it:
- *    proc.h includes user.h
- *    user.h includes cpu.h
- *    m68k cpu.h tries in include features.h
- *
- */
diff --git a/NeXT/nbq.h b/NeXT/nbq.h
deleted file mode 100644 (file)
index 0fd632c..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * All very trivial - the simpler the better I say. We try and keep
- * quqes of netbufs by squirreling a pointer away below the data area.
- * This is done by the ppp_nb_alloc function. As long as everyone
- * uses the ppp shrink and grow functions we should be o.k. This code
- * has now been modified to keep the mark_t stuff nhere as well since
- * we probably shafted that good and proper in the last version. oops !
- * PCF
- */
-
-#ifndef __NBQ_H__
-#define __NBQ_H__
-
-#define KERNEL 1
-
-#include <sys/types.h>
-#if !(NS_TARGET >= 40)
-#include <kernserv/prototypes.h>
-#endif /* NS_TARGET */
-
-#include "netbuf.h"
-typedef u_int mark_t;
-
-#define NETBUF_T netbuf_t
-#define NB_ALLOC ppp_nb_alloc
-#define NB_FREE nb_free
-#define NB_MAP nb_map
-#define NB_SIZE nb_size
-#define NB_SHRINK_TOP ppp_nb_shrink_top
-#define NB_GROW_TOP ppp_nb_grow_top
-#define NB_SHRINK_BOT nb_shrink_bot
-#define NB_GROW_BOT nb_grow_bot
-#define NB_READ nb_read
-#define NB_WRITE nb_write
-#define NB_GET_MARK nb_get_mark
-#define NB_SET_MARK nb_set_mark
-#define NB_GET_NEXT nb_get_next
-#define NB_SET_NEXT nb_set_next
-#define nb_TO_NB(nb) (nb)
-#define NB_TO_nb(NB) (NB)
-
-
-struct qparms {
-    u_char     q_low, q_high, q_max;
-    char       *q_name;
-};
-
-struct nb_queue {
-    char       *name;
-    int                low, high, max, len, dropped;
-    NETBUF_T   head, tail;
-};
-
-#define NB_EXTRA (sizeof(mark_t)+sizeof(netbuf_t))
-
-static inline void
-nb_set_next(netbuf_t nb, netbuf_t ptr)
-{
-if(nb) bcopy(&ptr,NB_MAP(nb)-sizeof(netbuf_t),sizeof(netbuf_t));
-}
-
-static inline void
-nb_get_next(netbuf_t nb, netbuf_t *ptr)
-{
-if(nb && ptr) bcopy(NB_MAP(nb)-sizeof(netbuf_t),ptr,sizeof(netbuf_t));
-}
-
-static inline void
-nb_set_mark(netbuf_t nb, mark_t ptr)
-{
-if(nb) bcopy(&ptr,NB_MAP(nb)-NB_EXTRA,sizeof(mark_t));
-}
-
-static inline void
-nb_get_mark(netbuf_t nb, mark_t *ptr)
-{
-if(nb && ptr) bcopy(NB_MAP(nb)-NB_EXTRA,ptr,sizeof(mark_t));
-}
-
-static inline void
-ppp_nb_shrink_top(netbuf_t nb, unsigned int size)
-{
-    netbuf_t ptr;
-    mark_t   mark;
-    NB_GET_NEXT(nb,&ptr);
-    NB_GET_MARK(nb,&mark);
-    nb_shrink_top(nb,size);
-    NB_SET_MARK(nb,mark);
-    NB_SET_NEXT(nb,ptr);
-}
-
-static inline void
-ppp_nb_grow_top(netbuf_t nb, unsigned int size)
-{
-    netbuf_t ptr;
-    mark_t   mark;
-    NB_GET_NEXT(nb,&ptr);
-    NB_GET_MARK(nb,&mark);
-    nb_grow_top(nb,size);
-    NB_SET_MARK(nb,mark);
-    NB_SET_NEXT(nb,ptr);
-}
-
-
-static inline netbuf_t
-ppp_nb_alloc(unsigned int size)
-{
-    netbuf_t nb;
-
-    size+=NB_EXTRA;
-    nb=nb_alloc(size);
-    if(nb) {
-       nb_shrink_top(nb,NB_EXTRA);
-       NB_SET_NEXT(nb,NULL);
-       NB_SET_MARK(nb,0);
-    }
-    return nb;
-}
-#endif /* __NBQ_H__ */
-
diff --git a/NeXT/netbuf.h b/NeXT/netbuf.h
deleted file mode 100644 (file)
index 578ac8f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/* 
- * Copyright (C) 1990 by NeXT, Inc., All Rights Reserved
- *
- */
-
-/* 
- * Network Buffer API (for kernel use only)
- *
- * HISTORY
- * 09-Apr-90  Bradley Taylor (btaylor) at NeXT, Inc.
- *     Created. 
- */
-#ifndef _NETBUF_
-#define _NETBUF_
-
-/*
- * We know only that the first entry in the structure is a
- * pointer that isn't used while the netbuf is allocated.
- * (that is, until an nb_free() or an inet_queue() of course!)
- */
-typedef struct netbuf { struct netbuf *m_nextpkt; } *netbuf_t;
-
-#ifdef KERNEL
-
-extern char *nb_map(netbuf_t nb);
-extern netbuf_t nb_alloc(unsigned size);
-extern netbuf_t nb_alloc_wrapper(void *data, unsigned size,
-                                void freefunc(void *), void *freefunc_arg);
-
-extern void nb_free(netbuf_t nb);
-extern void nb_free_wrapper(netbuf_t nb);
-extern unsigned nb_size(netbuf_t nb);
-extern int nb_read(netbuf_t nb, unsigned offset, unsigned size, void *target);
-extern int nb_write(netbuf_t nb, unsigned offset, unsigned size, void *source);
-extern int nb_shrink_top(netbuf_t nb, unsigned size);
-extern int nb_grow_top(netbuf_t nb, unsigned size);
-extern int nb_shrink_bot(netbuf_t nb, unsigned size);
-extern int nb_grow_bot(netbuf_t nb, unsigned size);
-
-#endif /* KERNEL */
-#endif /* _NETBUF_ */
diff --git a/NeXT/ppp_tty.c b/NeXT/ppp_tty.c
deleted file mode 100644 (file)
index 280ba19..0000000
+++ /dev/null
@@ -1,1220 +0,0 @@
-/*     $ID: ppp_tty.c,v 1.4 1994/12/13 03:42:17 paulus Exp paulus $    */
-
-/*
- * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
- *            tty devices.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a collision if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- *
- * Rewritten for NextStep's funky kernel functions, I/O threads,
- * and netbufs (instead of real mbufs).  Also, ifnets don't install
- * into the kernel under NS as they do under BSD.  We have tried to
- * make the code remain as similar to the NetBSD version without
- * incurring too much hassle.  This code is the merge of 
- * Philip Prindeville's <philipp@res.enst.fr>/Pete French's <pete@ohm.york.ac.uk>
- * and Stephen Perkins'  <perkins@cps.msu.edu> independent ports.
- *
- */
-
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:59 cgd Exp */
-
-/* #include "ppp.h" */
-#if NUM_PPP > 0
-
-#define KERNEL 1
-#define KERNEL_FEATURES 1
-#define INET 1
-
-#if NS_TARGET >= 40
-#if NS_TARGET >= 41
-#include <kernserv/lock.h>
-#else
-#include <kern/lock.h>
-#endif /* NS_TARGET */
-#endif /* NS_TARGET */
-
-#include <sys/param.h>
-#if NS_TARGET >= 41
-typedef simple_lock_data_t lock_data_t;                /* XXX */
-#endif /* NS_TARGET */
-#include <sys/proc.h>
-#include <sys/user.h>
-#include "netbuf.h"
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/tty.h>
-#include <sys/conf.h>
-#include <sys/dk.h>
-#include <sys/uio.h>
-#include <sys/errno.h>
-#if !(NS_TARGET >= 40)
-/*  XXX what happened to this header file? */
-#include <machine/param.h>
-#endif
-
-#include <kernserv/prototypes.h>
-/* NeXT broke spl.h in 3.2/m68k. Thanks EPS! */
-
-#if defined(m68k)
-#import "spl.h"
-#else
-#include <driverkit/generalFuncs.h>
-#import <kernserv/machine/spl.h>
-#endif
-
-#include <kernserv/kern_server_types.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#ifdef VJC
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#endif
-
-#include <net/ppp_defs.h>
-#ifdef VJC
-#include <net/vjcompress.h>
-#endif
-#include <net/if_ppp.h>
-#include "if_pppvar.h"
-
-#include "inlines.h"
-
-int    pppopen __P((dev_t dev, struct tty *tp));
-void   pppclose __P((struct tty *tp));
-int    pppread __P((struct tty *tp, struct uio *uio));
-int    pppwrite __P((struct tty *tp, struct uio *uio));
-int    ppptioctl __P((struct tty *tp, int cmd, void *data, int flag));
-void   pppinput __P((int c, struct tty *tp));
-void   pppstart __P((struct tty *tp));
-
-/*
- * Must return an actual netbuf_t since other protocols
- * use this to get our buffers.
- */
-netbuf_t       pppgetbuf __P((netif_t));
-
-/*
- * Must accept an actual netbuf_t since others use this
- * Procedure to access our output routine.
- */
-int            pppoutput __P((netif_t ifp, netbuf_t m, void *arg));
-
-static u_int16_t pppfcs __P((u_int16_t fcs, u_char *cp, int len));
-static void    pppasyncstart __P((struct ppp_softc *));
-static void    pppasyncctlp __P((struct ppp_softc *));
-static void    pppasyncrelinq __P((struct ppp_softc *));
-static int     ppp_timeout __P((void *));
-void           pppgetm __P((struct ppp_softc *sc));
-static void    pppdumpb __P((u_char *b, int l));
-void           ppplogchar __P((struct ppp_softc *, int));
-
-extern kern_server_t instance;
-
-/*
- * Does c need to be escaped?
- */
-#define        ESCAPE_P(c)     (sc->sc_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F)))
-
-#define CCOUNT(q)      ((q)->c_cc)
-
-#define        PPP_HIWAT       400     /* Don't start a new packet if HIWAT on que */
-
-#include "linedisc.h"  
-
-
-extern int ttymodem(struct tty*, int);
-extern int ttselect(struct tty *tp, int rw);
-
-
-static NETBUF_T
-pppgetinbuf(netif_t ifp)
-{
-    register struct ppp_softc *sc = &ppp_softc[if_unit(ifp)];
-    NETBUF_T nb;
-    int len = MAX(sc->sc_mru, PPP_MTU) + sizeof (struct ifnet *) +
-#ifdef VJC
-             VJ_HDRLEN +
-#endif
-             PPP_HDRLEN + PPP_FCSLEN;
-    nb =  NB_ALLOC(len);
-    if (nb != NULL)
-      {
-#ifdef VJC
-       NB_SHRINK_TOP(nb, VJ_HDRLEN + PPP_HDRLEN);
-#else
-       NB_SHRINK_TOP(nb, PPP_HDRLEN);
-#endif
-      }
-
-    return nb;
-}
-
-/*
- * I was a bit worried about reentrancy here.  +++SJP
- */
-
-void
-pppfillfreeq(void *arg)
-{
-    struct ppp_softc *sc = (struct ppp_softc *)arg;
-    NETBUF_T nb;
-    volatile static int in = 0;
-
-    if (in)
-      return;
-    in = 1;
-
-    while(!nbq_high(&sc->sc_freeq)) {
-       nb = pppgetinbuf(sc->sc_if);
-       if (! nb) break;
-       nbq_enqueue(&sc->sc_freeq, nb);
-    }
-
-    in = 0;
-}
-
-/*
- * Line specific open routine for async tty devices.
- * Attach the given tty to the first available ppp unit.
- */
-/* ARGSUSED */
-int
-pppopen(dev, tp)
-    dev_t dev;
-    register struct tty *tp;
-{
-    struct proc *p = curproc;          /* XXX */
-    register struct ppp_softc *sc;
-    int s;
-
-    if (! suser())
-       return EPERM;
-
-    if (tp->t_line == PPPDISC) {
-       sc = (struct ppp_softc *) tp->t_sc;
-       if (sc != NULL && sc->sc_devp == (void *) tp)
-           return (0);
-    }
-
-    if ((sc = pppalloc(p->p_pid)) == NULL)
-       return ENXIO;
-
-    if (sc->sc_relinq)
-       (*sc->sc_relinq)(sc);   /* get previous owner to relinquish the unit */
-
-    pppfillfreeq((void *) sc);   /* fill the free queue - we may block */
-
-    s = splimp();
-    sc->sc_ilen = 0;
-    sc->sc_m = NULL;
-    bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-    sc->sc_asyncmap[0] = 0xffffffff;
-    sc->sc_asyncmap[3] = 0x60000000;    /* 0x7D and 0x7E */
-    sc->sc_rasyncmap = 0;
-    sc->sc_devp = (void *) tp;
-    sc->sc_start = pppasyncstart;
-    sc->sc_ctlp = pppasyncctlp;
-    sc->sc_relinq = pppasyncrelinq;
-    sc->sc_outm = NULL;
-    pppgetm(sc);
-    if_flags_set(sc->sc_if, if_flags(sc->sc_if) | IFF_RUNNING);
-
-    tp->t_sc = (caddr_t) sc;
-    ttyflush(tp, FREAD | FWRITE);
-    splx(s);
-
-    return (0);
-}
-
-/*
- * Line specific close routine.
- * Detach the tty from the ppp unit.
- * Mimics part of ttyclose().
- */
-void
-pppclose(tp)
-    struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    int s;
-
-    ttywflush(tp);
-    s = splimp();              /* paranoid; splnet probably ok */
-    tp->t_line = 0;
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc != NULL) {
-       tp->t_sc = NULL;
-       if (tp == (struct tty *) sc->sc_devp) {
-           pppasyncrelinq(sc);
-           pppdealloc(sc);
-       }
-    }
-    splx(s);
-    return;
-}
-
-/*
- * Relinquish the interface unit to another device.
- */
-static void
-pppasyncrelinq(sc)
-    struct ppp_softc *sc;
-{
-    int s;
-
-    s = splimp();
-    if (sc->sc_outm) {
-       NB_FREE(sc->sc_outm);
-       sc->sc_outm = NULL;
-    }
-    if (sc->sc_m) {
-       NB_FREE(sc->sc_m);
-       sc->sc_m = NULL;
-    }
-    if (sc->sc_flags & SC_TIMEOUT) {
-       ns_untimeout(ppp_timeout, (void *) sc);
-       sc->sc_flags &= ~SC_TIMEOUT;
-    }
-    splx(s);
-}
-
-/*
- * Line specific (tty) read routine.
- */
-int
-pppread(tp, uio)
-    register struct tty *tp;
-    struct uio *uio;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    NETBUF_T m;
-    register int s;
-    int error = 0;
-    struct nty *np = ttynty(tp);
-
-#ifdef NEW_CLOCAL
-    if ((tp->t_state & TS_CARR_ON) == 0 && (np->t_pflags & TP_CLOCAL) == 0)
-       return 0;               /* end of file */
-
-#else
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_flags & CLOCAL) == 0)
-       return 0;               /* end of file */
-
-#endif /* NEW_CLOCAL */
-
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return 0;
-    s = splimp();
-    while (nbq_empty(&sc->sc_inq) && tp->t_line == PPPDISC) {
-       if (tp->t_state & (TS_ASYNC | TS_NBIO)) {
-           splx(s);
-           return (EWOULDBLOCK);
-       }
-       sleep((caddr_t)&tp->t_rawq, TTIPRI);
-    }
-    if (tp->t_line != PPPDISC) {
-       splx(s);
-       return (-1);
-    }
-
-    /* Pull place-holder byte out of canonical queue */
-    getc(&tp->t_canq);
-
-    /* Get the packet from the input queue */
-    m = nbq_dequeue(&sc->sc_inq);
-    splx(s);
-    if (nbuf == NULL){
-      if (sc->sc_flags & SC_DEBUG)
-       IOLogDbg("Read didn't get a buffer at %s %d\n", __FILE__, __LINE__);
-      return -1;
-    }
-    error = uiomove(NB_MAP(m), NB_SIZE(m), UIO_READ, uio);
-    NB_FREE(m);
-    return (error);
-}
-
-/*
- * Line specific (tty) write routine.
- */
-int
-pppwrite(tp, uio)
-    register struct tty *tp;
-    struct uio *uio;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    NETBUF_T m;
-    struct sockaddr dst;
-    int len, error;
-    struct nty *np = ttynty(tp);
-
-#ifdef NEW_CLOCAL
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (np->t_pflags & TP_CLOCAL) == 0)
-       return 0;               /* wrote 0 bytes */
-
-#else
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_flags & CLOCAL) == 0)
-       return 0;               /* wrote 0 bytes */
-
-#endif /* NEW_CLOCAL */
-
-    if (tp->t_line != PPPDISC)
-       return (EINVAL);
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return EIO;
-    if (uio->uio_resid > if_mtu(sc->sc_if) + PPP_HDRLEN ||
-      uio->uio_resid < PPP_HDRLEN)
-       return (EMSGSIZE);
-    m = nb_TO_NB(pppgetbuf(sc->sc_if));
-
-    if (m == NULL){
-      if (sc->sc_flags & SC_DEBUG)
-       IOLogDbg("No buffers available for user level write()\n");
-      return(ENOBUFS);
-    }
-    NB_GROW_TOP(m, PPP_HDRLEN);
-    len = uio->uio_resid;
-    if (error = uiomove(NB_MAP(m), NB_SIZE(m), UIO_WRITE, uio)) {
-       NB_FREE(m);
-       return error;
-    }
-    NB_SHRINK_BOT(m, NB_SIZE(m) - len);
-    dst.sa_family = AF_UNSPEC;
-    bcopy(mtod(m, u_char *), dst.sa_data, PPP_HDRLEN);
-
-    NB_SHRINK_TOP(m, PPP_HDRLEN);
-    return (pppoutput(sc->sc_if, NB_TO_nb(m), &dst));
-}
-
-/*
- * Line specific (tty) ioctl routine.
- * This discipline requires that tty device drivers call
- * the line specific l_ioctl routine from their ioctl routines.
- */
-/* ARGSUSED */
-int
-ppptioctl(tp, cmd, data, flag)
-    struct tty *tp;
-    void *data;
-    int cmd, flag;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-    int error, s;
-
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return -1;
-
-    error = 0;
-    switch (cmd) {
-    case PPPIOCSASYNCMAP:
-       if (! suser())
-           return EPERM;
-
-       sc->sc_asyncmap[0] = *(u_int *)data;
-       break;
-
-    case PPPIOCGASYNCMAP:
-       *(u_int *)data = sc->sc_asyncmap[0];
-       break;
-
-    case PPPIOCSRASYNCMAP:
-       if (! suser())
-           return EPERM;
-       sc->sc_rasyncmap = *(u_int *)data;
-       break;
-
-    case PPPIOCGRASYNCMAP:
-       *(u_int *)data = sc->sc_rasyncmap;
-       break;
-
-    case PPPIOCSXASYNCMAP:
-       if (! suser())
-           return EPERM;
-       s = spltty();
-       bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-       sc->sc_asyncmap[1] = 0;                 /* mustn't escape 0x20 - 0x3f */
-       sc->sc_asyncmap[2] &= ~0x40000000;      /* mustn't escape 0x5e */
-       sc->sc_asyncmap[3] |= 0x60000000;       /* must escape 0x7d, 0x7e */
-       splx(s);
-       break;
-
-    case PPPIOCGXASYNCMAP:
-       bcopy(sc->sc_asyncmap, data, sizeof(sc->sc_asyncmap));
-       break;
-
-    default:
-       error = pppioctl(sc, cmd, data, flag);
-       if (error == 0 && cmd == PPPIOCSMRU)
-           pppgetm(sc);
-    }
-
-#ifdef i386
-    if (! error && (cmd & IOC_OUT)) {
-       struct uthread *_u = uthread_from_thread(current_thread());
-
-       /* third arg is destination in ioctl() call... */
-       copyout(data, (caddr_t) _u->uu_arg[2], (cmd >> 16) & IOCPARM_MASK);
-    }
-#endif
-
-    return error;
-}
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static const u_int16_t fcstab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-/*
- * Calculate a new FCS given the current FCS and the new data.
- */
-static u_int16_t
-pppfcs(fcs, cp, len)
-    register u_int16_t fcs;
-    register u_char *cp;
-    register int len;
-{
-    while (len--)
-       fcs = PPP_FCS(fcs, *cp++);
-    return (fcs);
-}
-
-/*
- * This gets called from pppoutput when a new packet is
- * put on a queue.
- */
-static void
-pppasyncstart(sc)
-    register struct ppp_softc *sc;
-{
-    register struct tty *tp = (struct tty *) sc->sc_devp;
-    int s;
-
-    s = splimp();
-    pppstart(tp);
-    splx(s);
-}
-
-/*
- * This gets called when a received packet is placed on
- * the inq.
- */
-static void
-pppasyncctlp(sc)
-    struct ppp_softc *sc;
-{
-    struct tty *tp;
-
-    /* Put a placeholder byte in canq for ttselect()/ttnread(). */
-    tp = (struct tty *) sc->sc_devp;
-    putc(0, &tp->t_canq);
-    ttwakeup(tp);
-}
-
-/*
- * Start output on async tty interface.  Get another datagram
- * to send from the interface queue and start sending it.
- */
-void
-pppstart(tp)
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-    register NETBUF_T m;
-    register int len;
-    register u_char *start, *stop, *cp;
-    int n, ndone, done, idle;
-    struct nty *np = ttynty(tp);
-
-#ifdef NEW_CLOCAL
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (np->t_pflags & TP_CLOCAL) == 0
-
-#else
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_flags & CLOCAL) == 0 
-
-#endif /* NEW_CLOCAL */
-
-       || sc == NULL || tp != (struct tty *) sc->sc_devp) {
-       if (tp->t_oproc != NULL)
-           (*tp->t_oproc)(tp);
-       return;
-    }
-
-    idle = 0;
-#ifdef OLD_MUX
-    while (CCOUNT(&tp->t_outq) == 0) {
-#else
-    while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-#endif
-       /*
-        * See if we have an existing packet partly sent.
-        * If not, get a new packet and start sending it.
-        */
-       m = sc->sc_outm;
-       if (m == NULL) {
-           /*
-            * Get another packet to be sent.
-            */
-           m = ppp_dequeue(sc);
-           if (m == NULL) {
-               idle = 1;
-               break;
-           }
-
-           /*
-            * The extra PPP_FLAG will start up a new packet, and thus
-            * will flush any accumulated garbage.  We do this whenever
-            * the line may have been idle for some time.
-            */
-           if (CCOUNT(&tp->t_outq) == 0) {
-               ++sc->sc_bytessent;
-               (void) putc(PPP_FLAG, &tp->t_outq);
-           }
-
-           /* Calculate the FCS for the first netbuf's worth. */
-           sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), NB_SIZE(m));
-           sc->sc_outfcs ^= 0xffff;
-           
-           cp = mtod(m, u_char *) + NB_SIZE(m);
-           NB_GROW_BOT(m, PPP_FCSLEN);
-           *cp++ = sc->sc_outfcs & 0xFF;
-           *cp++ = (sc->sc_outfcs >> 8) & 0xFF;
-       }
-
-       start = mtod(m, u_char *);
-       len = NB_SIZE(m);
-       stop = start + len;
-       while (len > 0) {
-           /*
-            * Find out how many bytes in the string we can
-            * handle without doing something special.
-            */
-           for (cp = start; cp < stop; cp++)
-               if (ESCAPE_P(*cp))
-                   break;
-
-           n = cp - start;
-
-           if (n) {
-               /*
-                * b_to_q returns the number of characters
-                * _not_ sent
-                *
-                * NetBSD (0.9 or later), 4.3-Reno or similar.
-                */
-               ndone = n - b_to_q(start, n, &tp->t_outq);
-               len -= ndone;
-               start += ndone;
-               sc->sc_bytessent += ndone;
-
-               if (ndone < n)
-                   break;      /* packet doesn't fit */
-
-           }
-
-           /*
-            * If there are characters left in the netbuf,
-            * the first one must be special..
-            * Put it out in a different form.
-            */
-           if (len) {
-               if (putc(PPP_ESCAPE, &tp->t_outq))
-                   break;
-               if (putc(*start ^ PPP_TRANS, &tp->t_outq)) {
-                   (void) unputc(&tp->t_outq);
-                   break;
-               }
-               sc->sc_bytessent += 2;
-               start++;
-               len--;
-           }
-       }
-       /*
-        * If we didn't empty this netbuf, remember where we're up to.
-        */
-       done = len == 0;
-
-       if (!done) {
-           /* remember where we got to */
-           NB_SHRINK_TOP(m, start - mtod(m, u_char *));
-           break;      /* can't do any more at the moment */
-       }
-
-       /*
-        * Output trailing PPP flag and finish packet.
-        * We make the length zero in case the flag
-        * cannot be output immediately.
-        */
-       NB_SHRINK_TOP(m, NB_SIZE(m));
-       if (putc(PPP_FLAG, &tp->t_outq))
-           break;
-       sc->sc_bytessent++;
-
-
-       /* Finished with this netbuf; free it and move on. */
-       NB_FREE(m);
-       m = NULL;
-       incr_cnt(sc->sc_if, if_opackets);
-
-       sc->sc_outm = m;
-    }
-
-    /*
-     * If there is stuff in the output queue, send it now.
-     * We are being called in lieu of ttstart and must do what it would.
-     */
-    if (tp->t_oproc != NULL)
-       (*tp->t_oproc)(tp);
-
-    /*
-     * This timeout is needed for operation on a pseudo-tty,
-     * because the pty code doesn't call pppstart after it has
-     * drained the t_outq.
-     */
-    if (!idle && (sc->sc_flags & SC_TIMEOUT) == 0) {
-#if NS_TARGET >= 40
-       timeout(ppp_timeout, (void *) sc, 1);
-#else
-       ns_timeout(ppp_timeout, (void *) sc, 1 * (1000000000L / HZ), CALLOUT_PRI_SOFTINT0);
-#endif /*NS_TARGET */
-       sc->sc_flags |= SC_TIMEOUT;
-    }
-
-    return;
-}
-
-/*
- * Timeout routine - try to start some more output.
- */
-static int
-ppp_timeout(x)
-    void *x;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) x;
-    struct tty *tp = (struct tty *) sc->sc_devp;
-    int s;
-
-    s = splimp();
-    sc->sc_flags &= ~SC_TIMEOUT;
-    pppstart(tp);
-    splx(s);
-    return 0;
-}
-
-/*
- * Allocate enough netbuf to handle current MRU.
- *
- * Warning Will Robinson:  pppgetm() can get called at interrupt-level!
- */
-void
-pppgetm(sc)
-    register struct ppp_softc *sc;
-{
-    int s;
-
-    s = splimp();
-    /*
-     * When the MRU is being changed, we could conceivably end up
-     * nuking a packet being received, but I doubt it, since the
-     * hand-shake is lock-step (ie. single packet).
-     */
-    if (sc->sc_m != NULL)
-       NB_FREE(sc->sc_m);
-    sc->sc_m = nbq_dequeue(&sc->sc_freeq);
-    splx(s);
-}
-
-/*
- * 4.3 says this is an unused function.  However,
- * it appears to be returning a NULL terminated string
- * of several characters.  My guess is that the serial
- * driver is doing a little buffering so that we don't
- * get burdend with interrupts.
- *
- * This function gets called when you use the NeXT
- * supplied serial drivers.  It does not get called
- * with the MuX driver.  
- *
- * In order to expedite the work done here, we
- * handle most things here that don't require
- * processing of a PPP_FLAG.
- *
- */
-
-void
-ppprend(cp, n, tp)
-    unsigned char *cp;
-    int n;
-    struct tty *tp;
-{
-
-#ifndef OPTIMIZE_PPPREND       
-#warning PPPREND Not optimized!!!
-  while (n--) pppinput((u_char) *cp++, tp);
-#else
-
-
-  register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-  register int ret;
-
-  if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-    {
-      printf("Warning, bad softc structure at %s %d\n", __FILE__, __LINE__);
-      return;
-    }
-
-  /*
-   * We can handle FLUSHs, ESCAPES, and non PPP_FLAG characters
-   */
-  
-  while (n)
-    {
-      if (sc->sc_flags & SC_FLUSH)
-       {
-         do
-           {
-             if (*(cp++) == PPP_FLAG)
-               {
-                 pppinput(PPP_FLAG, tp);
-                 --n;
-                 break;
-               }
-             else if (sc->sc_flags & SC_LOG_FLUSH)
-               ppplogchar(sc, *cp);
-           }
-         while(--n);
-       }
-      else if (sc->sc_ilen > 3 &&
-              (NB_SIZE(sc->sc_m) - sc->sc_ilen) > n &&
-              *cp != PPP_FLAG &&
-              *cp != PPP_ESCAPE)        /* Dont really handle escapes properly...should */
-       {
-         unsigned char* cp1 = cp;
-         if (sc->sc_flags & SC_ESCAPED)
-           {
-             sc->sc_flags &= ~SC_ESCAPED;
-             *cp ^= PPP_TRANS;
-           }
-         
-         do
-           {
-             sc->sc_fcs = PPP_FCS(sc->sc_fcs, *(cp++));
-             if (sc->sc_flags & SC_LOG_RAWIN)
-               ppplogchar(sc, *cp);
-             
-           } while(--n && *cp != PPP_FLAG && *cp != PPP_ESCAPE);
-         
-         
-         bcopy(cp1, sc->sc_mp, (cp-cp1));
-         
-         sc->sc_bytesrcvd += (cp - cp1);
-         sc->sc_ilen += (cp-cp1);
-         sc->sc_mp += (cp-cp1);
-         
-       }
-      else
-       {
-         --n;
-         pppinput(*(cp++), tp);
-       }
-    }
-  
-#endif /* OPTIMIZE_PPPREND */
-}
-
-/*
- * tty interface receiver interrupt.
- */
-static const unsigned paritytab[8] = {
-    0x96696996, 0x69969669, 0x69969669, 0x96696996,
-    0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-
-void
-pppinput(c, tp)
-    int c;
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    NETBUF_T m;
-    int ilen, s;
-
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return;
-
-    ++tk_nin;
-    ++sc->sc_bytesrcvd;
-
-    if (c & TTY_FE) {
-       /* framing error or overrun on this char - abort packet */
-       IOLogDbg("ppp%d: bad char 0x%x\n", if_unit(sc->sc_if), c);
-       goto flush;
-    }
-
-    c &= 0xff;
-
-    if (c & 0x80)
-       sc->sc_flags |= SC_RCV_B7_1;
-    else
-       sc->sc_flags |= SC_RCV_B7_0;
-    if (paritytab[c >> 5] & (1 << (c & 0x1F)))
-       sc->sc_flags |= SC_RCV_ODDP;
-    else
-       sc->sc_flags |= SC_RCV_EVNP;
-
-    if (sc->sc_flags & SC_LOG_RAWIN)
-       ppplogchar(sc, c);
-
-    if (c == PPP_FLAG) {
-
-      if (sc->sc_ilen == 0)
-       return;
-
-       ilen = sc->sc_ilen;
-       sc->sc_ilen = 0;
-
-       if (sc->sc_rawin_count > 0)
-           ppplogchar(sc, -1);
-
-       /*
-        * From the RFC:
-        *  Each Control Escape octet is also
-         *  removed, and the following octet is exclusive-or'd with hexadecimal
-         *  0x20, unless it is the Flag Sequence (which aborts a frame).
-         *
-        * So, if SC_ESCAPED is set, then we've seen the packet
-        * abort sequence "}~".
-        */
-       if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) ||
-           ((ilen > 0) && (sc->sc_fcs != PPP_GOODFCS)))
-         {
-           sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
-           if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0)
-             {
-               IOLog("ppp%d: bad fcs 0x%04x\n", if_unit(sc->sc_if), sc->sc_fcs);
-               incr_cnt(sc->sc_if, if_ierrors);
-             }
-           else
-             {
-               IOLog("ppp%d: bad packet flushed...\n", if_unit(sc->sc_if));
-               sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
-             }
-           return;
-         }
-       
-       if (ilen < (PPP_HDRLEN + PPP_FCSLEN))
-         {
-           if (ilen)
-             {
-               IOLogDbg("ppp%d: too short (%d)\n", if_unit(sc->sc_if), ilen);
-               incr_cnt(sc->sc_if, if_ierrors);
-               sc->sc_flags |= SC_PKTLOST;
-             }
-           return;
-         }
-       
-       /*
-        * Remove FCS trailer.  Set packet length...
-        */
-       ilen -= PPP_FCSLEN;
-       NB_SHRINK_BOT(sc->sc_m, NB_SIZE(sc->sc_m) - ilen);
-
-       /* excise this netbuf */
-       m = sc->sc_m;
-       sc->sc_m = NULL;
-
-       ppppktin(sc, m, sc->sc_flags & SC_PKTLOST);
-       sc->sc_flags &= ~SC_PKTLOST;
-
-       pppgetm(sc);
-       return;
-    }
-
-    if (sc->sc_flags & SC_FLUSH) {
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-       return;
-    }
-
-/*
- * From the RFC:
- *  On reception, prior to FCS computation, each octet with value less
- *  than hexadecimal 0x20 is checked.  If it is flagged in the receiving
- *  ACCM, it is simply removed (it may have been inserted by intervening
- *  data communications equipment).  Each Control Escape octet is also
- *  removed, and the following octet is exclusive-or'd with hexadecimal
- *  0x20, unless it is the Flag Sequence (which aborts a frame).
- */
-    if (c < 0x20 && (sc->sc_rasyncmap & (1 << c))) {
-       return;
-    }
-
-    if (sc->sc_flags & SC_ESCAPED) {
-       sc->sc_flags &= ~SC_ESCAPED;
-       c ^= PPP_TRANS;
-    } else if (c == PPP_ESCAPE) {
-       sc->sc_flags |= SC_ESCAPED;
-       return;
-    }
-
-    /*
-     * Initialize buffer on first octet received.
-     * First octet could be address or protocol (when compressing
-     * address/control).
-     * Second octet is control.
-     * Third octet is first or second (when compressing protocol)
-     * octet of protocol.
-     * Fourth octet is second octet of protocol.
-     */
-    if (sc->sc_ilen == 0) {
-
-       /* reset the input netbuf */
-       if (sc->sc_m == NULL) {
-           pppgetm(sc);
-           if (sc->sc_m == NULL) {
-               /*
-                * We schedule a call here as pppindrain will
-                * not get scheduled and we need the free buffers
-                */
-               IOLog("ppp%d: no input netbufs!\n", if_unit(sc->sc_if));
-               (void)pppsched(pppfillfreeq, sc);
-               goto flush;
-           }
-       }
-       m = sc->sc_m;
-       sc->sc_mp = mtod(m, char *);
-       sc->sc_fcs = PPP_INITFCS;
-
-       if (c != PPP_ALLSTATIONS) {
-           if (sc->sc_flags & SC_REJ_COMP_AC) {
-               IOLogDbg("ppp%d: garbage received: 0x%02x (need 0x%02x)\n",
-                          if_unit(sc->sc_if), c, PPP_ALLSTATIONS);
-               goto flush;
-           }
-           *sc->sc_mp++ = PPP_ALLSTATIONS;
-           *sc->sc_mp++ = PPP_UI;
-           sc->sc_ilen += 2;
-       }
-    }
-
-
-    if (sc->sc_ilen == 1 && c != PPP_UI) {
-       IOLogDbg("ppp%d: missing UI (0x%02x), got 0x%02x\n",
-                  if_unit(sc->sc_if), PPP_UI, c);
-       goto flush;
-    }
-
-    if (sc->sc_ilen == 2 && (c & 1) == 1) {
-       /* a compressed protocol */
-       *sc->sc_mp++ = 0;
-       sc->sc_ilen++;
-    }
-
-    if (sc->sc_ilen == 3 && (c & 1) == 0) {
-       IOLogDbg("ppp%d: bad protocol %x\n", if_unit(sc->sc_if),
-                  (sc->sc_mp[-1] << 8) + c);
-       goto flush;
-    }
-
-    /* packet beyond configured mru? */
-    if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) {
-       IOLogDbg("ppp%d: packet too big (%d bytes)\n", if_unit(sc->sc_if),
-               sc->sc_ilen);
-       goto flush;
-    }
-
-    /* ilen was incremented above... */
-    *sc->sc_mp++ = c;
-    sc->sc_fcs = PPP_FCS(sc->sc_fcs, c);
-    return;
-
- flush:
-    if (!(sc->sc_flags & SC_FLUSH)) {
-       incr_cnt(sc->sc_if, if_ierrors);
-       sc->sc_flags |= SC_FLUSH;
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-    }
-    return;
-}
-
-int
-install_ppp_ld(void)
-{
-    return tty_ld_install(PPPDISC, NORMAL_LDISC, pppopen,
-                         pppclose, pppread, pppwrite, ppptioctl,
-                         pppinput, ppprend, pppstart, ttymodem,
-                         ttselect);
-}
-
-#define MAX_DUMP_BYTES 128
-
-void
-ppplogchar(sc, c)
-    struct ppp_softc *sc;
-    int c;
-{
-    if (c >= 0)
-       sc->sc_rawin[sc->sc_rawin_count++] = c;
-    if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
-       || c < 0 && sc->sc_rawin_count > 0) {
-       IOLog("ppp%d input:\n", if_unit(sc->sc_if));
-       pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
-       sc->sc_rawin_count = 0;
-    }
-}
-
-static void
-pppdumpb(b, l)
-    u_char *b;
-    int l;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-
-    while (l--) {
-       if (bp >= buf + sizeof(buf) - 3) {
-           *bp++ = '>';
-           break;
-       }
-       *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*b++ & 0xf];
-       *bp++ = ' ';
-    }
-
-    *bp = 0;
-    IOLog("%s\n", buf);
-}
-#endif /* NUM_PPP > 0 */
diff --git a/NeXT/spl.h b/NeXT/spl.h
deleted file mode 100644 (file)
index 120f480..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *     File:   spl.h
- *     Author: Avadis Tevanian, Jr.
- *
- *     Define inline macros for spl routines.
- *     
- * HISTORY
- *
- * 14-May-90  Gregg Kellogg (gk) at NeXT
- *     Changed SPLCLOCK from 6 to 3, as much scheduling code expects
- *     splclock() == splsched().  Added splusclock().
- *
- * 19-Jun-89  Mike DeMoney (mike) at NeXT
- *     Modified to allow spl assertions in spl_measured.h
- */
-
-#ifndef        _KERNSERV_M68K_SPL_H_
-#define        _KERNSERV_M68K_SPL_H_
-
-#ifdef KERNEL_BUILD
-#import <iplmeas.h>
-#else  KERNEL_BUILD
-/* #import <mach/features.h> */
-#endif KERNEL_BUILD
-
-#import <bsd/m68k/psl.h>
-
-#if    NIPLMEAS && !defined(NO_IPLMEAS)
-#import <machdep/m68k/spl_measured.h>
-#endif NIPLMEAS && !defined(NO_IPLMEAS)
-
-#ifndef        SPLU_MACRO
-
-#ifdef ASSEMBLER
-#define        SPLU_MACRO(ipl) \
-       movw    sr,d0; \
-       movw    \#((ipl)*256 + 0x2000),sr;
-
-#define        splx(nsr) \
-       movw    sr,d0; \
-       movw    nsr,sr;
-
-#else  ASSEMBLER
-
-#define SPLU_MACRO(x) \
-({ register short ret; \
-       asm volatile ("movw     sr,%0" : "=dm" (ret)); \
-       asm volatile ("movw     %1,sr" : "=m" (*(char *)0): "Jdm" ((short)(x)*256+0x2000)); \
-       ret; \
-})
-
-#define splx(x) \
-({ register short ret; \
-       asm volatile ("movw     sr,%0" : "=dm" (ret)); \
-       asm volatile ("movw     %1,sr" : "=m" (*(char *)0): "Jdm" ((short)x)); \
-       ret; \
-})
-
-#endif ASSEMBLER
-
-#define        SPLD_MACRO(ipl) SPLU_MACRO(ipl)
-#define        spln(x)         splx(x)
-
-#endif SPLU_MACRO
-
-#define ipltospl(ipl)  (SR_SUPER | ((ipl) << 8))
-
-/*
- *     Define spls as the usual numbers (which should never be used
- *     directly.
- */
-
-#define spl0() SPLD_MACRO(0)
-#define spl1() SPLU_MACRO(1)
-#define spl2() SPLU_MACRO(2)
-#define spl3() SPLU_MACRO(3)
-#define spl4() SPLU_MACRO(4)
-#define spl5() SPLU_MACRO(5)
-#define spl6() SPLU_MACRO(6)
-#define spl7() SPLU_MACRO(7)
-
-/*
- *     Define spl mnemonics.
- */
-#define IPLHIGH                7
-#define IPLDMA         6
-#define IPLUSCLOCK     6
-#define IPLSCC         5
-#define IPLCLOCK       3
-#define IPLBIO         3
-#define IPLSCHED       3
-#define IPLIMP         3
-#define IPLVM          3
-#define IPLNET         2
-#define IPLTTY         1
-#define IPLSOFTCLOCK   1
-
-#define splhigh()      SPLU_MACRO(IPLHIGH)
-#define splusclock()   SPLU_MACRO(IPLUSCLOCK)
-#define spldma()       SPLU_MACRO(IPLDMA)
-#define splscc()       SPLU_MACRO(IPLSCC)
-#define splclock()     SPLU_MACRO(IPLCLOCK)
-#define splbio()       SPLU_MACRO(IPLBIO)
-#define splsched()     SPLU_MACRO(IPLSCHED)
-#define splimp()       SPLU_MACRO(IPLIMP)
-#define splvm()                SPLU_MACRO(IPLVM)
-#define splnet()       SPLU_MACRO(IPLNET)
-#define spltty()       SPLU_MACRO(IPLTTY)
-#define splsoftclock() SPLU_MACRO(IPLSOFTCLOCK)
-
-#endif _KERNSERV_M68K_SPL_H_
diff --git a/NeXT/vjcompress.c b/NeXT/vjcompress.c
deleted file mode 100644 (file)
index cbbab89..0000000
+++ /dev/null
@@ -1,587 +0,0 @@
-/*
- * Routines to compress and uncompess tcp packets (for transmission
- * over low speed serial lines.
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- *     Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- *
- * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au,
- * so that the entire packet being decompressed doesn't have
- * to be in contiguous memory (just the compressed header).
- */
-
-/*
- * This version is used under SunOS 4.x, Digital UNIX, AIX 4.x,
- * and SVR4 systems including Solaris 2.
- *
- * $Id: vjcompress.c,v 1.3 1997/04/30 05:39:44 paulus Exp $
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-
-#ifdef SVR4
-#ifndef __GNUC__
-#include <sys/byteorder.h>     /* for ntohl, etc. */
-#else
-/* make sure we don't get the gnu "fixed" one! */
-#include "/usr/include/sys/byteorder.h"
-#endif
-#endif
-
-#ifdef __osf__
-#include <net/net_globals.h>
-#endif
-#include <netinet/in.h>
-
-#ifdef AIX4
-#define _NETINET_IN_SYSTM_H_
-typedef u_long  n_long;
-#else
-#include <netinet/in_systm.h>
-#endif
-
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include <net/ppp_defs.h>
-#include <net/vjcompress.h>
-
-#ifndef VJ_NO_STATS
-#define INCR(counter) ++comp->stats.counter
-#else
-#define INCR(counter)
-#endif
-
-#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
-#undef  BCOPY
-#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
-#ifndef KERNEL
-#define ovbcopy bcopy
-#endif
-
-#ifdef __osf__
-#define getip_hl(base) (((base).ip_vhl)&0xf)
-#define getth_off(base)        ((((base).th_xoff)&0xf0)>>4)
-
-#else
-#define getip_hl(base) ((base).ip_hl)
-#define getth_off(base)        ((base).th_off)
-#endif
-
-void
-vj_compress_init(comp, max_state)
-    struct vjcompress *comp;
-    int max_state;
-{
-    register u_int i;
-    register struct cstate *tstate = comp->tstate;
-
-    if (max_state == -1)
-       max_state = MAX_STATES - 1;
-    bzero((char *)comp, sizeof(*comp));
-    for (i = max_state; i > 0; --i) {
-       tstate[i].cs_id = i;
-       tstate[i].cs_next = &tstate[i - 1];
-    }
-    tstate[0].cs_next = &tstate[max_state];
-    tstate[0].cs_id = 0;
-    comp->last_cs = &tstate[0];
-    comp->last_recv = 255;
-    comp->last_xmit = 255;
-    comp->flags = VJF_TOSS;
-}
-
-
-/* ENCODE encodes a number that is known to be non-zero.  ENCODEZ
- * checks for zero (since zero has to be encoded in the long, 3 byte
- * form).
- */
-#define ENCODE(n) { \
-       if ((u_short)(n) >= 256) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-#define ENCODEZ(n) { \
-       if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-
-#define DECODEL(f) { \
-       if (*cp == 0) {\
-               u_int32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \
-               (f) = htonl(tmp); \
-               cp += 3; \
-       } else { \
-               u_int32_t tmp = ntohl(f) + (u_int32_t)*cp++; \
-               (f) = htonl(tmp); \
-       } \
-}
-
-#define DECODES(f) { \
-       if (*cp == 0) {\
-               u_short tmp = ntohs(f) + ((cp[1] << 8) | cp[2]); \
-               (f) = htons(tmp); \
-               cp += 3; \
-       } else { \
-               u_short tmp = ntohs(f) + (u_int32_t)*cp++; \
-               (f) = htons(tmp); \
-       } \
-}
-
-#define DECODEU(f) { \
-       if (*cp == 0) {\
-               (f) = htons((cp[1] << 8) | cp[2]); \
-               cp += 3; \
-       } else { \
-               (f) = htons((u_int32_t)*cp++); \
-       } \
-}
-
-u_int
-vj_compress_tcp(ip, mlen, comp, compress_cid, vjhdrp)
-    register struct ip *ip;
-    u_int mlen;
-    struct vjcompress *comp;
-    int compress_cid;
-    u_char **vjhdrp;
-{
-    register struct cstate *cs = comp->last_cs->cs_next;
-    register u_int hlen = getip_hl(*ip);
-    register struct tcphdr *oth;
-    register struct tcphdr *th;
-    register u_int deltaS, deltaA;
-    register u_int changes = 0;
-    u_char new_seq[16];
-    register u_char *cp = new_seq;
-
-    /*
-     * Bail if this is an IP fragment or if the TCP packet isn't
-     * `compressible' (i.e., ACK isn't set or some other control bit is
-     * set).  (We assume that the caller has already made sure the
-     * packet is IP proto TCP).
-     */
-    if ((ip->ip_off & htons(0x3fff)) || mlen < 40)
-       return (TYPE_IP);
-
-    th = (struct tcphdr *)&((int *)ip)[hlen];
-    if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
-       return (TYPE_IP);
-    /*
-     * Packet is compressible -- we're going to send either a
-     * COMPRESSED_TCP or UNCOMPRESSED_TCP packet.  Either way we need
-     * to locate (or create) the connection state.  Special case the
-     * most recently used connection since it's most likely to be used
-     * again & we don't have to do any reordering if it's used.
-     */
-    INCR(vjs_packets);
-    if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
-       ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
-       *(int *)th != ((int *)&cs->cs_ip)[getip_hl(cs->cs_ip)]) {
-       /*
-        * Wasn't the first -- search for it.
-        *
-        * States are kept in a circularly linked list with
-        * last_cs pointing to the end of the list.  The
-        * list is kept in lru order by moving a state to the
-        * head of the list whenever it is referenced.  Since
-        * the list is short and, empirically, the connection
-        * we want is almost always near the front, we locate
-        * states via linear search.  If we don't find a state
-        * for the datagram, the oldest state is (re-)used.
-        */
-       register struct cstate *lcs;
-       register struct cstate *lastcs = comp->last_cs;
-
-       do {
-           lcs = cs; cs = cs->cs_next;
-           INCR(vjs_searches);
-           if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
-               && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
-               && *(int *)th == ((int *)&cs->cs_ip)[getip_hl(cs->cs_ip)])
-               goto found;
-       } while (cs != lastcs);
-
-       /*
-        * Didn't find it -- re-use oldest cstate.  Send an
-        * uncompressed packet that tells the other side what
-        * connection number we're using for this conversation.
-        * Note that since the state list is circular, the oldest
-        * state points to the newest and we only need to set
-        * last_cs to update the lru linkage.
-        */
-       INCR(vjs_misses);
-       comp->last_cs = lcs;
-       hlen += getth_off(*th);
-       hlen <<= 2;
-       if (hlen > mlen)
-           return (TYPE_IP);
-       goto uncompressed;
-
-    found:
-       /*
-        * Found it -- move to the front on the connection list.
-        */
-       if (cs == lastcs)
-           comp->last_cs = lcs;
-       else {
-           lcs->cs_next = cs->cs_next;
-           cs->cs_next = lastcs->cs_next;
-           lastcs->cs_next = cs;
-       }
-    }
-
-    /*
-     * Make sure that only what we expect to change changed. The first
-     * line of the `if' checks the IP protocol version, header length &
-     * type of service.  The 2nd line checks the "Don't fragment" bit.
-     * The 3rd line checks the time-to-live and protocol (the protocol
-     * check is unnecessary but costless).  The 4th line checks the TCP
-     * header length.  The 5th line checks IP options, if any.  The 6th
-     * line checks TCP options, if any.  If any of these things are
-     * different between the previous & current datagram, we send the
-     * current datagram `uncompressed'.
-     */
-    oth = (struct tcphdr *)&((int *)&cs->cs_ip)[hlen];
-    deltaS = hlen;
-    hlen += getth_off(*th);
-    hlen <<= 2;
-    if (hlen > mlen)
-       return (TYPE_IP);
-
-    if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
-       ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
-       ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] ||
-       getth_off(*th) != getth_off(*oth) ||
-       (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
-       (getth_off(*th) > 5 && BCMP(th + 1, oth + 1, (getth_off(*th) - 5) << 2)))
-       goto uncompressed;
-
-    /*
-     * Figure out which of the changing fields changed.  The
-     * receiver expects changes in the order: urgent, window,
-     * ack, seq (the order minimizes the number of temporaries
-     * needed in this section of code).
-     */
-    if (th->th_flags & TH_URG) {
-       deltaS = ntohs(th->th_urp);
-       ENCODEZ(deltaS);
-       changes |= NEW_U;
-    } else if (th->th_urp != oth->th_urp)
-       /* argh! URG not set but urp changed -- a sensible
-        * implementation should never do this but RFC793
-        * doesn't prohibit the change so we have to deal
-        * with it. */
-       goto uncompressed;
-
-    if (deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) {
-       ENCODE(deltaS);
-       changes |= NEW_W;
-    }
-
-    if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
-       if (deltaA > 0xffff)
-           goto uncompressed;
-       ENCODE(deltaA);
-       changes |= NEW_A;
-    }
-
-    if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
-       if (deltaS > 0xffff)
-           goto uncompressed;
-       ENCODE(deltaS);
-       changes |= NEW_S;
-    }
-
-    switch(changes) {
-
-    case 0:
-       /*
-        * Nothing changed. If this packet contains data and the
-        * last one didn't, this is probably a data packet following
-        * an ack (normal on an interactive connection) and we send
-        * it compressed.  Otherwise it's probably a retransmit,
-        * retransmitted ack or window probe.  Send it uncompressed
-        * in case the other side missed the compressed version.
-        */
-       if (ip->ip_len != cs->cs_ip.ip_len &&
-           ntohs(cs->cs_ip.ip_len) == hlen)
-           break;
-
-       /* (fall through) */
-
-    case SPECIAL_I:
-    case SPECIAL_D:
-       /*
-        * actual changes match one of our special case encodings --
-        * send packet uncompressed.
-        */
-       goto uncompressed;
-
-    case NEW_S|NEW_A:
-       if (deltaS == deltaA && deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-           /* special case for echoed terminal traffic */
-           changes = SPECIAL_I;
-           cp = new_seq;
-       }
-       break;
-
-    case NEW_S:
-       if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-           /* special case for data xfer */
-           changes = SPECIAL_D;
-           cp = new_seq;
-       }
-       break;
-    }
-
-    deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
-    if (deltaS != 1) {
-       ENCODEZ(deltaS);
-       changes |= NEW_I;
-    }
-    if (th->th_flags & TH_PUSH)
-       changes |= TCP_PUSH_BIT;
-    /*
-     * Grab the cksum before we overwrite it below.  Then update our
-     * state with this packet's header.
-     */
-    deltaA = ntohs(th->th_sum);
-    BCOPY(ip, &cs->cs_ip, hlen);
-
-    /*
-     * We want to use the original packet as our compressed packet.
-     * (cp - new_seq) is the number of bytes we need for compressed
-     * sequence numbers.  In addition we need one byte for the change
-     * mask, one for the connection id and two for the tcp checksum.
-     * So, (cp - new_seq) + 4 bytes of header are needed.  hlen is how
-     * many bytes of the original packet to toss so subtract the two to
-     * get the new packet size.
-     */
-    deltaS = cp - new_seq;
-    cp = (u_char *)ip;
-    if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
-       comp->last_xmit = cs->cs_id;
-       hlen -= deltaS + 4;
-       *vjhdrp = (cp += hlen);
-       *cp++ = changes | NEW_C;
-       *cp++ = cs->cs_id;
-    } else {
-       hlen -= deltaS + 3;
-       *vjhdrp = (cp += hlen);
-       *cp++ = changes;
-    }
-    *cp++ = deltaA >> 8;
-    *cp++ = deltaA;
-    BCOPY(new_seq, cp, deltaS);
-    INCR(vjs_compressed);
-    return (TYPE_COMPRESSED_TCP);
-
-    /*
-     * Update connection state cs & send uncompressed packet (that is,
-     * a regular ip/tcp packet but with the 'conversation id' we hope
-     * to use on future compressed packets in the protocol field).
-     */
- uncompressed:
-    BCOPY(ip, &cs->cs_ip, hlen);
-    ip->ip_p = cs->cs_id;
-    comp->last_xmit = cs->cs_id;
-    return (TYPE_UNCOMPRESSED_TCP);
-}
-
-/*
- * Called when we may have missed a packet.
- */
-void
-vj_uncompress_err(comp)
-    struct vjcompress *comp;
-{
-    comp->flags |= VJF_TOSS;
-    INCR(vjs_errorin);
-}
-
-/*
- * "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP.
- */
-int
-vj_uncompress_uncomp(buf, buflen, comp)
-    u_char *buf;
-    int buflen;
-    struct vjcompress *comp;
-{
-    register u_int hlen;
-    register struct cstate *cs;
-    register struct ip *ip;
-
-    ip = (struct ip *) buf;
-    hlen = getip_hl(*ip) << 2;
-    if (ip->ip_p >= MAX_STATES
-       || hlen + sizeof(struct tcphdr) > buflen
-       || (hlen += getth_off(*((struct tcphdr *)&((char *)ip)[hlen])) << 2)
-           > buflen
-       || hlen > MAX_HDR) {
-       comp->flags |= VJF_TOSS;
-       INCR(vjs_errorin);
-       return (0);
-    }
-    cs = &comp->rstate[comp->last_recv = ip->ip_p];
-    comp->flags &=~ VJF_TOSS;
-    ip->ip_p = IPPROTO_TCP;
-    BCOPY(ip, &cs->cs_ip, hlen);
-    cs->cs_hlen = hlen;
-    INCR(vjs_uncompressedin);
-    return (1);
-}
-
-/*
- * Uncompress a packet of type TYPE_COMPRESSED_TCP.
- * The packet starts at buf and is of total length total_len.
- * The first buflen bytes are at buf; this must include the entire
- * compressed TCP/IP header.  This procedure returns the length
- * of the VJ header, with a pointer to the uncompressed IP header
- * in *hdrp and its length in *hlenp.
- */
-int
-vj_uncompress_tcp(buf, buflen, total_len, comp, hdrp, hlenp)
-    u_char *buf;
-    int buflen, total_len;
-    struct vjcompress *comp;
-    u_char **hdrp;
-    u_int *hlenp;
-{
-    register u_char *cp;
-    register u_int hlen, changes;
-    register struct tcphdr *th;
-    register struct cstate *cs;
-    register u_short *bp;
-    register u_int vjlen;
-    register u_int32_t tmp;
-
-    INCR(vjs_compressedin);
-    cp = buf;
-    changes = *cp++;
-    if (changes & NEW_C) {
-       /* Make sure the state index is in range, then grab the state.
-        * If we have a good state index, clear the 'discard' flag. */
-       if (*cp >= MAX_STATES)
-           goto bad;
-
-       comp->flags &=~ VJF_TOSS;
-       comp->last_recv = *cp++;
-    } else {
-       /* this packet has an implicit state index.  If we've
-        * had a line error since the last time we got an
-        * explicit state index, we have to toss the packet. */
-       if (comp->flags & VJF_TOSS) {
-           INCR(vjs_tossed);
-           return (-1);
-       }
-    }
-    cs = &comp->rstate[comp->last_recv];
-    hlen = getip_hl(cs->cs_ip) << 2;
-    th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
-    th->th_sum = htons((*cp << 8) | cp[1]);
-    cp += 2;
-    if (changes & TCP_PUSH_BIT)
-       th->th_flags |= TH_PUSH;
-    else
-       th->th_flags &=~ TH_PUSH;
-
-    switch (changes & SPECIALS_MASK) {
-    case SPECIAL_I:
-       {
-           register u_int32_t i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
-           /* some compilers can't nest inline assembler.. */
-           tmp = ntohl(th->th_ack) + i;
-           th->th_ack = htonl(tmp);
-           tmp = ntohl(th->th_seq) + i;
-           th->th_seq = htonl(tmp);
-       }
-       break;
-
-    case SPECIAL_D:
-       /* some compilers can't nest inline assembler.. */
-       tmp = ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
-       th->th_seq = htonl(tmp);
-       break;
-
-    default:
-       if (changes & NEW_U) {
-           th->th_flags |= TH_URG;
-           DECODEU(th->th_urp);
-       } else
-           th->th_flags &=~ TH_URG;
-       if (changes & NEW_W)
-           DECODES(th->th_win);
-       if (changes & NEW_A)
-           DECODEL(th->th_ack);
-       if (changes & NEW_S)
-           DECODEL(th->th_seq);
-       break;
-    }
-    if (changes & NEW_I) {
-       DECODES(cs->cs_ip.ip_id);
-    } else {
-       cs->cs_ip.ip_id = ntohs(cs->cs_ip.ip_id) + 1;
-       cs->cs_ip.ip_id = htons(cs->cs_ip.ip_id);
-    }
-
-    /*
-     * At this point, cp points to the first byte of data in the
-     * packet.  Fill in the IP total length and update the IP
-     * header checksum.
-     */
-    vjlen = cp - buf;
-    buflen -= vjlen;
-    if (buflen < 0)
-       /* we must have dropped some characters (crc should detect
-        * this but the old slip framing won't) */
-       goto bad;
-
-    total_len += cs->cs_hlen - vjlen;
-    cs->cs_ip.ip_len = htons(total_len);
-
-    /* recompute the ip header checksum */
-    bp = (u_short *) &cs->cs_ip;
-    cs->cs_ip.ip_sum = 0;
-    for (changes = 0; hlen > 0; hlen -= 2)
-       changes += *bp++;
-    changes = (changes & 0xffff) + (changes >> 16);
-    changes = (changes & 0xffff) + (changes >> 16);
-    cs->cs_ip.ip_sum = ~ changes;
-
-    *hdrp = (u_char *) &cs->cs_ip;
-    *hlenp = cs->cs_hlen;
-    return vjlen;
-
- bad:
-    comp->flags |= VJF_TOSS;
-    INCR(vjs_errorin);
-    return (-1);
-}
diff --git a/README.NeXT b/README.NeXT
deleted file mode 100644 (file)
index 41fb9e1..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-#  $Id: README.NeXT,v 1.4 1998/03/26 02:54:17 paulus Exp $
-#
-
-This distribution contains a port of PPP-2.3 for NeXT.  The full
-source code is available as well as an MAB installer package.  Since
-this project is a continuing effort, you are encouraged to check out
-the "PPP-2.3 for NeXTSTEP" web page to see if you have the latest
-software.  This is especially true if you find you have problems with
-the version you presently use.  The web site contains a comprehensive
-NeXT specific FAQ, mailing list information, and a bug submission
-form.  Please see:
-
-  WWW site:     http://www.peak.org/next/ppp/
-  WWW mirror:   http://www.thoughtport.com:8080/PPP/
-
-  FTP site:     ftp://next-ftp.peak.org/pub/next/apps/internet/ppp/dev
-  FTP Mirror:   ftp://ftp.NMR.EMBL-Heidelberg.DE/pub/next/ppp/
-
-If you use this software and are pleased with its performance, you are
-encouraged to make a donation to support continued development.  50%
-of all donations go to charity.  For more information, please see:
-  http://www.thoughtport.com:8080/cgi-bin/PPP/donation
-
-It is recommended that you use the PPP installer package to install
-the latest version of PPP.  This installer package has been designed
-to make installation of PPP exceedingly easy and includes all the
-documentation you need.  However, if you want to manually compile and
-configure PPP, the subdirectory 'NeXT' contains the documentation and
-information you need.  You do NOT need to look at these files if you
-use the installer package.
-
-   INSTALL -     A file giving specific directions for installing
-                 ppp-2.3 on a NeXT computer.
-
-   Examples -    This directory provides more examples of
-                 scripts and other helpful utilities.
-
-   NeXT_Version - This file describes what NeXT specific version of
-                  PPP-2.3 you have.
-
-   ChangeLog.rtf - A history of development and bug fixes for ppp-2.3
-
-   TODO.NeXT -   A wishlist for features.
diff --git a/README.aix4 b/README.aix4
deleted file mode 100644 (file)
index b01bfc9..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-
-AIX 4.1 support is ported from the SunOS code for ppp 2.2. It requires
-a streams-based tty and will not work on AIX 3.2. This is the first
-release of this package for AIX. It is provided free and without warranty
-of any kind.
-
-Introduction
-
-  PPP implements TCP/IP through serial connections. In ppp 2.2, an
-  interface is established by running the program 'pppd'. pppd opens
-  a serial connection, negotiates link attributes with the peer and
-  configures a TCP/IP interface. The interface remains up as long as
-  the peer stays up and 'pppd' remains running. There are no SMIT menus
-  and ppp interfaces can not be defined through ifconfig. An interface 
-  can be brought down by killing pppd.
-
-  The program 'chat' processes send-expect sequences similar to UUCP
-  Dialers commands or a Systems chat string. It can be used to dial
-  a modem.
-
-  'pppstats' prints interface statistics similar to netstat. Some of the
-  statistics are the same as netstat but pppstat also provides additional
-  info specific to ppp interfaces. 
-
-Installation
-
-  First execute the following commands in the ppp-2.2 directory:
-
-       ./configure
-       make install            (you need to be root for this)
-
-  By default, pppd, chat and pppstats are placed in /usr/sbin and the
-  streams modules in /usr/lib/drivers. The modules are loaded by the following
-  'strload' commands.
-  
-  strload -m /usr/lib/drivers/ppp_if
-  strload -m /usr/lib/drivers/ppp_comp
-  strload -m /usr/lib/drivers/ppp_async
-  
-  'make install' appends the strloads to /etc/rc.tcpip so the modules
-  will be loaded at boot.  A 'pppd' command can be added to start
-  up an interface.
-  
-  'make install' will also create /etc/ppp/options containing the option
-  'lock' only (lock tty device when in use). Any other options which will
-  always be used should be added by hand.
-  
-  Man pages for pppd and pppstats are installed.
-
-Examples
-
-  To answer a modem and accept connections, use something like
-
-    pppd tty1 myhostname:remotehostname persist
-
-  This will wait for calls on tty1 and establish a connection with any
-  ppp caller. The server will use myhostname and tell the caller
-  to use remotehostname. The persist option tells pppd to remain 
-  active and accept another connection after the call terminates.
-  You can use the 'auth' option to force callers to authenticate
-  themselves. See pppd man page for details of authentication protocols.
-
-  To dial in to a user account and start PPP, use something like
-
-    pppd tty1 myhostname: connect 'chat -f /etc/ppp/chat-script'
-
-  where the file /etc/ppp/chat-script should contain something like
-
-    "" ATDT5551212 CONNECT "" ogin: myname sword: mypassword $ pppd
-
-  This command uses the chat program to dial the modem, log in and
-  start pppd on the server. No ttyname is needed when starting pppd on the
-  server side because pppd will attach to the current terminal (the tty line),
-  if no device is specified. Any pppd options needed can be set in ~/.ppprc
-  on the called system.
-
-  The chat -v option may be helpful in debugging connection failures. The
-  chat output and other debug messages are sent to syslog. You may need
-  to edit /etc/syslog.conf and "refresh -s syslogd" to see the debug messages.
-
-  The simplest way to allow a remote dial-in host to use your network is
-  to use the 'proxyarp' option on the server. This will cause the
-  server to publish an arp entry with the remote's IP address and the 
-  server's hardware address. The remote will then appear to be part of
-  local network to other hosts. The address/netmask used by the remote
-  must be suitable for the subnet you wish to connect to.  If the remote
-  is a standalone system, or has no other default route, use the
-  'defaultroute' option when dialing in. This will create a default route
-  on the remote system through the server. If the remote is on another
-  local network, you might not want this because it could conflict with
-  an existing default route.
-
-  These are just a few examples to help the new user get started. The
-  man page for pppd describes all the options in detail.
-
-       Charlie Wick
-
diff --git a/README.bsd b/README.bsd
deleted file mode 100644 (file)
index c62619a..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-Installation instructions for installing ppp-2.4 on FreeBSD.
-
-This package supports NetBSD-current, NetBSD-1.2, NetBSD-1.1,
-FreeBSD-2.1, and FreeBSD-2.0.  Modloading is not supported.  I have
-code which may work on earlier systems; contact me if you need it.
-
-To install PPP, you need to rebuild your kernel to include the latest
-version of the PPP driver, as well as compiling and installing the
-user-level applications: pppd, pppstats and chat.  The user-level
-applications can be compiled and installed either before or after you
-reboot with the new kernel (you'll have to reboot with the new kernel
-before you can run them, of course).
-
-The following commands should compile and install the user-level
-applications (in the ppp-2.3 directory):
-
-       ./configure
-       make
-       make install            (you need to be root for this)
-
-The process of updating the kernel source files is now largely
-automated.  In the ppp-2.3 directory, issue the command:
-
-       make kernel
-
-(you probably need to be root for this).  This will copy new versions
-of several files into /sys, patch other files, and finally give you
-instructions about modifying your kernel configuration file (if
-necessary), rebuilding the kernel and rebooting.
-
-If you want to do the process by hand, read the next section.
-
-
-Updating the kernel ppp code.
-*****************************
-
-You need to update several files in the /sys/net directory, and patch
-some other files under /sys.  The details depend on which operating
-system you're running.
-
-
-NetBSD.
-=======
-
-Copy the following files to /sys/net:
-
-       net/if_ppp.h
-       net/ppp-comp.h
-       net/ppp_defs.h
-       netbsd-1.1/bsd-comp.c
-       netbsd-1.1/if_ppp.c
-       netbsd-1.1/if_pppvar.h
-       netbsd-1.1/ppp-deflate.c
-       netbsd-1.1/ppp_tty.c
-       netbsd-1.1/slcompress.c
-       netbsd-1.1/slcompress.h
-       common/zlib.c
-       common/zlib.h
-
-You may need to edit /sys/conf/files to make sure it contains entries
-for if_ppp.c, ppp_tty.c, bsd-comp.c, ppp-deflate.c and zlib.c.
-Depending on whether your port uses the old-style or new-style config
-files, these entries will look like this (new-style):
-
-       file net/if_ppp.c               ppp             needs-count
-       file net/ppp_tty.c              ppp
-       file net/bsd-comp.c             ppp
-       file net/ppp-deflate.c          ppp
-       file net/zlib.c                 ppp
-
-or this (old-style):
-
-       net/if_ppp.c            optional ppp device-driver
-       net/ppp_tty.c           optional ppp
-       net/bsd-comp.c          optional ppp
-       net/ppp-deflate.c       optional ppp
-       net/zlib.c              optional ppp
-
-If you use config.old or config.new, you will need to edit
-/sys/conf/files.oldconf or /sys/conf/files.newconf respectively.
-
-
-FreeBSD.
-========
-
-Copy the following files to /sys/net:
-
-       net/if_ppp.h
-       net/ppp-comp.h
-       net/ppp_defs.h
-       freebsd-2.0/bsd-comp.c
-       freebsd-2.0/if_ppp.c
-       freebsd-2.0/if_pppvar.h
-       freebsd-2.0/ppp-deflate.c
-       freebsd-2.0/ppp_tty.c
-       freebsd-2.0/pppcompress.c
-       freebsd-2.0/pppcompress.h
-       common/zlib.c
-       common/zlib.h
-
-You then need to edit /sys/conf/files to make sure it contains entries
-for if_ppp.c, ppp_tty.c, bsd-comp.c, ppp-deflate.c and zlib.c.  These
-entries should look like this:
-
-       net/if_ppp.c            optional ppp device-driver
-       net/ppp_tty.c           optional ppp
-       net/bsd-comp.c          optional ppp
-       net/ppp-deflate.c       optional ppp
-       net/zlib.c              optional ppp
-
-
-Configuring and making the new kernel.
-**************************************
-
-First, make sure that the configuration file you are using includes a
-line something like
-
-       pseudo-device ppp 2
-
-If it doesn't, add one.  The `2' is the number of ppp interfaces to
-configure, that is, the maximum number of simultaneous ppp connections
-you will be able to have; change it as required.
-
-Next, run config (or config.old or config.new) in the directory
-containing the configuration file, giving the configuration file name
-as an argument.  Then cd to the compilation directory and make the
-kernel.  For the i386 port of NetBSD, with a configuration file called
-CONF, this involves the following commands:
-
-       cd /sys/arch/i386/conf
-       /usr/sbin/config CONF
-       cd ../compile/CONF
-       make
-
-For FreeBSD, the commands are similar except for different
-directories:
-
-       cd /sys/i386/conf
-       /usr/sbin/config CONF
-       cd ../../compile/CONF
-       make
-
-The result should be a new kernel image (usually called `netbsd' under
-NetBSD, `kernel' under FreeBSD).  Save a copy of the kernel image
-you're currently using, copy the new kernel image file to /, and
-reboot.
diff --git a/README.osf b/README.osf
deleted file mode 100644 (file)
index 74d74ab..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-This file (README.osf) contains instructions for installing ppp-2.3 on a
-Compaq Alpha-based system running Tru64 Unix (formerly Digital UNIX aka
-DEC OSF/1) version 4.0. Please note that  PPP is an integral
-component of Tru64 UNIX version 3.2G and beyond (documented in the
-Guide to Network Administration),  and though it *is* possible to install 
-this software on V3.2G and later of Tru64 UNIX, you are likely
-to have problems with the "update install" feature of Tru64
-UNIX and while installing some OS patches. (See the note on 
-de-installation below). 
-
-Tru64 Unix versions Version 3.X and earlier are no longer supported
-in this package.  Please use ppp-2.3.5 on these systems.
-
-INSTALLATION.
-
-If you encounter bugs while using this PPP package under Tru64
-UNIX then please let me (varadhan@zk3.dec.com) know.  I can't promise
-quick turnaround but I should be able to address issues eventually.
-
-Below are the steps for installing PPP on Tru64 UNIX.
-You must do all of the following as "root".
-
-1.  back up /usr/sys/BINARY, /usr/sys/include/net,
-    /usr/sys/conf/files, /sys/kern/lockinfo.c  and /sys/BINARY/ppp.mod
-       # mkdir -p /usr/tmp/ppp
-       # cd /usr/sys
-       # tar cvf /usr/tmp/ppp/BINARY.tar ./BINARY
-        # cd /usr/sys/include
-       # tar cvf /usr/tmp/ppp/usr_sys_include_net.tar  ./net
-       # cp /usr/sys/conf/files /usr/tmp/ppp/files
-       # cp /sys/kern/lockinfo.c /usr/tmp/ppp/lockinfo.c
-       # cp /sys/BINARY/ppp.mod /usr/tmp/ppp/ppp.mod
-
-2.  Edit /usr/sys/conf/files- search for the string: "MODULE/STATIC/ppp"
-comment out the existing entries, and change it to look like:
-
-MODULE/STATIC/ppp               optional ppp Binary
-#streamsm/ppp_init.c            module ppp
-#streamsm/ppp_if.c              module ppp
-#streamsm/ppp_async.c           module ppp
-#streamsm/ppp_comp.c            module ppp
-#streamsm/vjcompress.c          module ppp
-#streamsm/bsd_comp.c            module ppp
-streamsm/if_ppp.c         module ppp
-streamsm/ppp_comp.c       module ppp
-streamsm/ppp_init.c       module ppp
-streamsm/vjcompress.c     module ppp
-streamsm/bsd-comp.c       module ppp
-streamsm/deflate.c        module ppp
-streamsm/ppp.c            module ppp
-streamsm/ppp_ahdlc.c      module ppp
-streamsm/zlib.c           module ppp
-
-3.  Make the kernel sources, daemon, chat, and pppstat program by typing 
-
-        ./configure
-        make install
-
-    in the directory that this file unpacked into.  This installs the
-    binaries for the PPP daemon and the statistics program in 
-    /usr/local/etc/ppp.  If you want them somewhere else, just change 
-    the definition of BINDIR in the top level Makefile.osf. If you plan
-    to over-write exisiting pppd executables in /usr/sbin/, it's advisable
-    that you create back-up copies of these first, before doing the
-    'make install'
-
-    Note that BINDIR and MANDIR/man8 must exist before you do a 
-    'make install'
-
-
-4.  Edit /sys/kern/lockinfo.c, and conditionally compile out the lines:
-
-#if PPP
-        SLI("ppp_if_table_lock", ppp_if_table_lock_info, SPLNONE, DEFAULT);
-        SLI("ppp_if_info.ppp_if_element_lock", ppp_if_element_lock_info, SPLNONE
-, DEFAULT);
-        SLI("ppp_comp_table_lock", ppp_comp_table_lock_info, SPLNONE, DEFAULT);
-        SLI("ppp_comp_info.ppp_comp_element_lock", ppp_comp_element_lock_info, S
-PLNONE, DEFAULT);
-        SLI("ppp_async_table_lock", ppp_async_table_lock_info, SPLNONE, DEFAULT)
-;
-        SLI("ppp_async_info.ppp_async_element_lock", ppp_async_element_lock_info
-, SPLNONE, DEFAULT);
-#endif  /* PPP */
-
-by changing the line
-
-#if PPP 
-
-to be
-
-#if 0 
-
-5.  Find your system's configuration file.  This should be called
-    /sys/conf/SYSNAME, where SYSNAME is replaced by the name of your
-    host.  For example, on my machine (zaphod.csci.unt.edu) it it called
-    /sys/conf/ZAPHOD.  I will refer to this file from now on as 
-    /sys/conf/SYSNAME.
-
-6.  Add the following line at the end of /sys/conf/SYSNAME:
-
-       options         PPP
-
-7.  Build a new kernel by using the command
-
-       doconfig -c SYSNAME
-
-    (say "n" to "Do you want to edit...").
-
-8.  Copy the new kernel to /vmunix --- I'm usually pretty nervous about
-    writing over a perfectly good kernel with one that I'm not sure
-    about, so I will usually "mv /vmunix /vmunix.old" first.  To put
-    the new kernel in place, do a "cp /sys/SYSNAME/vmunix /vmunix".
-
-9.  Make sure your system is set up so that it can act like a gateway
-    for messages to your new connection.  In particular, check the file
-    /etc/rc.config for the line define ROUTER, and make sure it is
-    defined as "yes".
-
-10.  Reboot and you're ready to go!
-
-Hopefully, that should work with no hitches.  If you find any bugs, or
-errors in these instructions, contact Sowmini Varadhan<varadhan@zk3.dec.com>.
-
-
-DEINSTALLATION
-
-It is advisable to retrace your steps and restore the system
-to its normal state before installing patches or running update_install.
-Here's how you can retrace..
-
-1. Restore /usr/sys/BINARY, /usr/sys/include/net, /usr/sys/conf/files
-   and /sys/kern/lockinfo.c and /sys/BINARY/ppp.mod. For example,
-   if you followed the instructions in step 1 verbatim, you would do
-
-       # cd /usr/sys/
-       # rm -rf ./BINARY
-       # tar xvf /usr/tmp/ppp/BINARY.tar
-        # cd /usr/sys/include
-        # rm -rf ./net
-       # tar xvf /usr/tmp/ppp/usr_sys_include_net.tar
-       # cp  /usr/tmp/ppp/files /usr/sys/conf/files
-       # cp /usr/tmp/ppp/lockinfo.c /sys/kern/lockinfo.c
-       # cp /usr/tmp/ppp/ppp.mod /sys/BINARY/ppp.mod
-
-Now redo steps 5-10 and install the patch after you have rebooted.
diff --git a/README.sunos4 b/README.sunos4
deleted file mode 100644 (file)
index b48aec3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-This file describes the installation process for ppp-2.3 on systems
-running SunOS 4.1.x (or the equivalent).
-
-The STREAMS modules in the sunos4 directory provide kernel support for
-PPP on SunOS 4.1.x systems.  They have been tested under SunOS 4.1.3
-on a SparcStation 1+.  They should work under earlier SunOS 4.1.x
-systems, but no guarantees are given.
-
-These modules are designed to be loaded into the running kernel using
-the `modload' command.
-
-
-Installation.
-*************
-
-1. Run the configure script and make the user-level programs and the
-kernel modules.
-
-       ./configure
-       make
-
-If you wish to compile using gcc instead of cc, edit the
-sunos4/Makedefs file and uncomment the line saying "CC = gcc".  You
-can also change the C compiler options by editing the COPTS
-definition.
-
-2. Install the pppd, pppstats and chat programs and the loadable
-module object files (you need to be root to do this):
-
-       make install
-
-By default, the programs and the loadable module object files go into
-/usr/local/etc.  Doing `make install' also copies a script called
-ppp.INSTALL into /dev, and makes ppp.LOAD, ppp.UNLOAD, ppp.MKDEV and
-ppp.RMDEV links to it.  You can change the installation directories by
-editing sunos4/Makedefs.
-
-3. Load the ppp modules (you need to be root for this too):
-
-       /dev/ppp.LOAD
-
-You will want to do this in your /etc/rc.local file once you have
-everything installed.  I suggest you put something like the following
-in /etc/rc.local (or /etc/loadable, if you have one):
-
-       if [ -f /dev/ppp.AUTOLOAD ]; then
-               /dev/ppp.LOAD
-       fi
-
-and then create a /dev/ppp.AUTOLOAD file with the command
-
-       touch /dev/ppp.AUTOLOAD
-
-It is not advisable to unload the "if_ppp" module, because it creates
-network interface units, and SunOS does not provide any way to destroy
-network interfaces once created.  If you do unload it, the system will
-probably crash at some later stage.
-
-If you have previously had ppp-2.2 installed, you may have statements
-in your /etc/rc.local to load the ppp module.  You will need to remove
-those.  Having done this, you will need to reboot to remove the old
-ppp module and load the new modules.
diff --git a/README.svr4 b/README.svr4
deleted file mode 100644 (file)
index 86942bb..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-This file describes the installation process for ppp-2.3 on systems
-running standard System V Release 4 and using the Lachman TCP/IP
-protocol code.  The STREAMS kernel modules and driver for SVR4 are in
-the svr4 directory (and use some code from the modules directory).
-
-Installation.
-*************
-
-1. Run the configure script and make the user-level programs and the
-kernel modules.
-
-       ./configure
-       make
-
-If you wish to use gcc instead of cc, edit the svr4/Makedefs file and
-uncomment the definition of CC.  You can also change the options
-passed to the C compiler by editing the COPTS definition.
-
-2. Install the programs and kernel modules: as root, do
-
-       make install
-
-This installs pppd, chat and pppstats in /usr/local/bin and adds the
-ppp STREAMS modules and driver to the system configuration.  You can
-change the installation directories by editing svr4/Makedefs.
-
-3. Rebuild your kernel (with /etc/conf/bin/idbuild) and reboot.
-
-Bug reports.
-************
-
-If you find a bug in this software, please send email to Matthias
-Apitz (Matthias.Apitz@sisis.de) describing the bug and, if possible, a
-workaround or fix for the bug.
diff --git a/README.ultrix b/README.ultrix
deleted file mode 100644 (file)
index b6a80d8..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-
-Installing PPP on an Ultrix system requires rebuilding the kernel and
-rebooting, in addition to making and installing the pppd and chat
-programs.  These instructions apply to RISC (MIPS) systems.  This
-software should work under Ultrix 4.2, 4.3 or 4.4 (this release has
-not been tested yet).
-
-
-Kernel installation procedure.
-******************************
-
-If you have not previously had an earlier version of this package
-installed in the kernel, follow these steps:
-
-1. Become root.
-
-2. Apply the patches in the file ultrix/patches using the command:
-
-       patch -p -N <ultrix/patches
-
-This will edit the following files, saving the original versions in a
-file with `.orig' appended to the name:
-
-       /usr/sys/h/ioctl.h
-       /usr/sys/net/net/if.h
-       /usr/sys/net/net/netisr.h
-       /usr/sys/net/net/conf_net.c
-       /usr/sys/data/pseudo_data.c
-       /usr/sys/data/tty_conf_data.c
-       /usr/sys/conf/mips/files.mips
-
-Alternatively, edit these files according to the differences shown in
-ultrix/patches.
-
-3. Copy the following files to /usr/sys/io/netif:
-
-       net/ppp-comp.h
-       net/ppp_defs.h
-       ultrix/bsd-comp.c
-       ultrix/ppp-deflate.c
-       ultrix/if_ppp.c
-       ultrix/if_ppp.h
-       ultrix/if_pppvar.h
-       ultrix/ppp_tty.c
-       ultrix/slcompress.c
-       ultrix/slcompress.h
-       common/zlib.c
-       common/zlib.h
-
-4. Add a line like this to the configuration file for your kernel:
-
-       pseudo-device ppp       2
-
-The `2' indicates the number of interfaces desired.  The configuration
-file should be in /usr/sys/conf/mips.
-
-5. Rebuild your kernel.  The simplest way to do this is with the
-`doconfig' command, like this:
-
-       /etc/doconfig -c kernel-name
-
-where `kernel-name' should be replaced by the name of your kernel
-configuration file.  Alternatively, run config, cd to the compilation
-directory, and run make.
-
-6. Copy the new /vmunix to /.  It would be a good idea to keep a copy
-of your old /vmunix in / under a different name.
-
-7. Reboot the system.
-
-********
-
-If you have ppp-2.2 already installed in your kernel, most files will
-already have been modified as required.  You will need to add some
-entries to /usr/sys/conf/mips/files.mips.  You can do this with a
-command like this (as root):
-
-       patch -p -N <ultrix/upgrade
-
-Alternatively, edit /usr/sys/conf/mips/files.mips according to the
-differences shown in ultrix/upgrade.
-
-Then, proceed with steps 3, 5, 6, 7 above (step 4 should have been
-done already).
-
-
-Installing pppd and chat.
-*************************
-
-1. cd to the ppp-2.2 directory and do:
-
-       ./configure
-       make
-
-2. Become root, and do:
-
-       make install
-
-
-Credits.
-********
-
-The original port to Ultrix was done by:
-
-       Per Sundstrom 
-       DEC, Sweden
-       email: sundstrom@stkhlm.enet.dec.com
-
-and
-
-       Robert Olsson 
-       Swedish University of Agricultural Sciences
-       and also RO Komm. & Konsult
-       email: robert@robur.slu.se
-
-It was updated to ppp-2.3 by
-
-       Paul Mackerras
-       Dept. of Computer Science
-       Australian National University
-       paulus@cs.anu.edu.au
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index fed1f31..0000000
--- a/TODO
+++ /dev/null
@@ -1,16 +0,0 @@
-* Things to do *
-
-- How should we handle the case where MTU > MRU?
-  Should we reduce the IP MTU to the link MRU (so TCP MSS is correct)?
-
-- Provide ways to:
-  + set the IP address, possibly based on the peer's identity
-  + have external checking of PAP user/password, CHAP response
-  + supply the PAP user/password, CHAP secret
-  + decide which tty to use (locking, DTR issues)
-
-- Integrate callback stuff?
-
-- Implement link quality monitoring
-
-- Implement other network control protocols
diff --git a/aix4/Makefile b/aix4/Makefile
deleted file mode 100644 (file)
index fbca3e6..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Makefile for AIX 4.1
-#
-#
-# $Id: Makefile,v 1.5 1998/03/25 03:18:06 paulus Exp $
-#
-#ifndef DRIVERS
-DRIVERS=/usr/lib/drivers
-#endif
-
-CC=xlc
-IFLAGS = -I../include
-DFLAGS = -D_KERNEL -DINET -DPPP_VD -DNUM_PPP=5 -DDEBUGS -DPPP_STATS -DVJC -D__aix4__ -DAIX4
-CFLAGS = $(DFLAGS) $(IFLAGS)
-
-KIMP = -bI:/lib/pse.exp -bI:/lib/kernex.exp -bI:/lib/syscalls.exp
-NETIMP = -bI:/lib/netinet.exp
-KLIBS = /lib/libsys.a /lib/libcsys.a
-
-
-OBJ = vjcompress.o ppp_if.o ppp_async.o bsd-comp.o ppp_comp.o
-
-all: ppp_if ppp_async ppp_comp
-
-ppp_if: ppp_if.o vjcompress.o
-       ld -o ppp_if ppp_if.o -e ppp_load -bE:ppp_if.exp vjcompress.o ${KIMP} ${NETIMP} ${KLIBS}
-
-ppp_async: ppp_async.o
-       ld -o ppp_async ppp_async.o -e ppp_async_load -bE:ppp_async.exp ${KIMP} ${NETIMP} ${KLIBS}
-
-ppp_comp: ppp_comp.o bsd-comp.o
-       ld -o ppp_comp ppp_comp.o -e pppcomp_load bsd-comp.o ${KIMP} ${NETIMP} ${KLIBS}
-
-vjcompress.o: ../modules/vjcompress.c
-       $(CC) $(CFLAGS) -c $?
-bsd-comp.o: ../modules/bsd-comp.c
-       $(CC) $(CFLAGS) -c $?
-ppp_if.o: ppp_if.c
-ppp_async.o: ppp_async.c
-ppp_comp.o: ppp_comp.c
-
-install: all
-       install -f ${DRIVERS} -M 500 ppp_if
-       install -f ${DRIVERS} -M 500 ppp_async
-       install -f ${DRIVERS} -M 500 ppp_comp
-       grep "strload -m ${DRIVERS}/ppp_if" /etc/rc.tcpip || { \
-           echo strload -m ${DRIVERS}/ppp_if; \
-           echo strload -m ${DRIVERS}/ppp_async; \
-           echo strload -m ${DRIVERS}/ppp_comp; \
-       } >>/etc/rc.tcpip
-
-clean:
-       rm -f $(OBJ) ppp_if ppp_async ppp_comp
diff --git a/aix4/Makefile.top b/aix4/Makefile.top
deleted file mode 100644 (file)
index 1fc37e3..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# ppp top level makefile
-#
-
-BINDIR = /usr/sbin
-DRIVERS = /usr/lib/drivers
-MANDIR = /usr/man
-
-all:
-       cd chat; $(MAKE) all
-       cd pppd; $(MAKE) all
-       cd pppstats; $(MAKE) all
-       cd aix4; $(MAKE) all
-
-install:
-       cd chat; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppstats; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd aix4; $(MAKE) BINDIR=$(BINDIR) install
-       [ -d /etc/ppp ] || { mkdir /etc/ppp; echo lock > /etc/ppp/options; }
-
-clean:
-       rm -f *~
-       cd chat; $(MAKE) clean
-       cd pppd; $(MAKE) clean
-       cd pppstats; $(MAKE) clean
-       cd aix4; $(MAKE) clean
-
diff --git a/aix4/load b/aix4/load
deleted file mode 100644 (file)
index af6b750..0000000
--- a/aix4/load
+++ /dev/null
@@ -1,4 +0,0 @@
-
-strload -m ppp_async
-strload -m ppp_if
-strload -m ppp_comp
diff --git a/aix4/ppp_async.c b/aix4/ppp_async.c
deleted file mode 100644 (file)
index d079e3f..0000000
+++ /dev/null
@@ -1,902 +0,0 @@
-/*
-  ppp_async.c - Streams async functions Also does FCS
-
-  Copyright (C) 1990  Brad K. Clements, All Rights Reserved
-  fcstab and some ideas nicked from if_ppp.c from cmu.
-  See copyright notice in if_ppp.h and NOTES
-
-  $Id: ppp_async.c,v 1.3 1995/04/26 04:15:48 paulus Exp $
-*/
-
-#include <sys/types.h>
-
-#ifndef PPP_VD
-#include "ppp.h"
-#endif
-
-#if NUM_PPP > 0
-
-#define        STREAMS 1
-#define        DEBUGS  1
-#include <net/net_globals.h>
-#include <sys/param.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/strconf.h>
-#include <sys/device.h>
-#include <sys/dir.h>
-#include <sys/signal.h>
-#include <sys/user.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-
-#include <net/ppp_defs.h>
-#include <net/ppp_str.h>
-
-/* how big of a buffer block to allocate for each chunk of the input chain */
-#define       ALLOCBSIZE      64
-
-#ifdef DEBUGS
-#include <sys/syslog.h>
-#define        DLOG(s,a) if (p->pai_flags&PAI_FLAGS_DEBUG) bsdlog(LOG_INFO, s, a)
-
-int    ppp_async_max_dump_bytes = 28;
-#define MAX_DUMP_BYTES 1504
-
-static void ppp_dump_frame();
-
-#else
-#define        DLOG(s) {}
-#endif
-
-static int     ppp_async_open(), ppp_async_close(), ppp_async_rput(),
-       ppp_async_wput(), ppp_async_wsrv(), ppp_async_rsrv();
-
-static         struct  module_info     minfo ={
-       0xabcd,"ppp_async",0, INFPSZ, 16384, 4096
-};
-
-static struct  qinit   r_init = {
-       ppp_async_rput, ppp_async_rsrv, ppp_async_open, ppp_async_close,
-       NULL, &minfo, NULL
-};
-static struct  qinit   w_init = {
-       ppp_async_wput, ppp_async_wsrv, ppp_async_open, ppp_async_close,
-       NULL, &minfo, NULL
-};
-struct streamtab       ppp_asyncinfo = {
-       &r_init, &w_init, NULL, NULL
-};
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static u_short fcstab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-
-struct  ppp_async_info {
-    u_int      pai_flags;
-    int                pai_buffsize;   /* how big of an input buffer to alloc */
-    int                pai_buffcount;  /* how many chars currently in input buffer */
-    u_short    pai_fcs;        /* the current fcs */
-    mblk_t     *pai_buffer;    /* pointer to the current buffer list */
-    mblk_t     *pai_bufftail;  /* pointer to the current input block */
-    ext_accm   pai_asyncmap;   /* current outgoing asyncmap */
-    u_int32_t  pai_rasyncmap;  /* current receive asyncmap */
-};
-
-/* Values for pai_flags */
-#define        PAI_FLAGS_INUSE         0x1
-#define        PAI_FLAGS_FLUSH         0x2
-#define        PAI_FLAGS_ESCAPED       0x4
-#define        PAI_FLAGS_COMPPROT      0x8
-#define        PAI_FLAGS_COMPAC        0x10
-#define        PAI_FLAGS_RCV_COMPPROT  0x20
-#define        PAI_FLAGS_RCV_COMPAC    0x40
-
-#define PAI_FLAGS_DEBUG                0x1000
-#define PAI_FLAGS_LOG_INPKT    0x2000
-#define PAI_FLAGS_LOG_OUTPKT   0x4000
-#define PAI_FLAGS_ALL_DEBUG    0x7000
-
-typedef        struct ppp_async_info   PAI;
-
-static PAI pai[NUM_PPP*2];             /* our private cache of async ctrl structs */
-
-static strconf_t pppasync_conf = {
-        "pppasync", &ppp_asyncinfo, STR_NEW_OPEN, 0, SQLVL_DEFAULT, (void *) 0
-};
-
-int ppp_async_load(int cmd, struct uio *uiop)
-{
-    int rc;
-
-    switch (cmd) {
-        case CFG_INIT:
-            rc = str_install(STR_LOAD_MOD, &pppasync_conf);
-            break;
-        case CFG_TERM:
-            rc = str_install(STR_UNLOAD_MOD, &pppasync_conf);
-            break;
-        default:
-            rc = EINVAL;
-            break;
-    }
-    return(rc);
-}
-
-/* open might fail if we don't have any more pai elements left free */
-static int
-ppp_async_open(q, dev, flag, sflag)
-    queue_t    *q;
-    dev_t      dev;
-    int        flag;
-    int sflag;
-{
-    register PAI *p;
-    register int x;
-    int        s;
-  
-    /* only let the superuser or setuid root ppl open this module */
-    if (!suser()) {
-       return(EPERM);  
-    }
-
-    if (!q->q_ptr) {
-       for (x=0; x < NUM_PPP; x++)     /* search for an empty PAI */
-           if (!(pai[x].pai_flags & PAI_FLAGS_INUSE))
-               break;
-       if (x == NUM_PPP) {             /* all buffers in use */
-           return(ENOBUFS);
-       }
-       p = &pai[x];
-       DLOG("ppp_async%d: opening\n",x);
-
-       /* initialize the unit to default values */
-       WR(q)->q_ptr = q->q_ptr =  (caddr_t) p;
-       bzero(p, sizeof(*p));
-       p->pai_flags = PAI_FLAGS_INUSE | PAI_FLAGS_RCV_COMPAC
-           | PAI_FLAGS_RCV_COMPPROT;
-       p->pai_asyncmap[0] = 0xffffffff;        /* default async map */
-       p->pai_asyncmap[3] = 0x60000000;        /* escape 7d, 7e */
-       p->pai_buffsize = PPP_MTU + PPP_HDRLEN + PPP_FCSLEN;
-    }
-    else {
-       p = (PAI *) q->q_ptr;
-       DLOG("ppp_async%d: reopen\n", p - pai);
-    }
-    return(0);
-}
-
-static int
-ppp_async_close(q)
-    queue_t    *q;                     /* queue info */
-{
-    int        s;
-    register PAI *p;
-  
-    if ((p = (PAI *) q->q_ptr) != NULL) {
-       p->pai_flags = 0;               /* clear all flags */
-       if (p->pai_buffer) {
-           /* currently receiving some chars, discard the buffer */
-           freemsg(p->pai_buffer);
-           p->pai_buffer = NULL;
-       }
-       DLOG("ppp_async%d: closing\n", p - pai);
-    }
-    return(0);                 
-}
-
-
-/* M_IOCTL processing is performed at this level. There is some 
-   weirdness here, but I couldn't think of an easier way to handle it.
-   
-   SIOC{G,S}IF{,R,X}ASYNCMAP are handled here.
-   
-   SIOCSIFCOMPAC and SIOCSIFCOMPPROT are both handled here. 
-   
-   SIOCSIFMRU and SIOCGIFMRU (Max Receive Unit) are both handled here.
-   Rather than using the MTU to set the MRU, we have a seperate IOCTL for it.
-*/
-
-static int
-ppp_async_wput(q, mp)
-    queue_t  *q;
-    register mblk_t *mp;
-{
-    register struct iocblk     *i;
-    register PAI       *p;
-    int        x, flags;
-  
-    switch (mp->b_datap->db_type) {
-    case M_CTL:
-        switch (*(u_char *)mp->b_rptr) {
-        case IF_GET_CSTATS:
-            /* trap this and remove it */
-            freemsg(mp);
-            break;
-        default:
-            putnext(q, mp);
-        }
-        break;
-   
-    case M_FLUSH :
-       if (*mp->b_rptr & FLUSHW)
-           flushq(q, FLUSHDATA);
-       putnext(q, mp);                 /* send it along too */
-       break;
-    
-    case M_DATA :
-       putq(q, mp);                    /* queue it for my service routine */
-       break;
-    
-    case M_IOCTL :
-       i = (struct iocblk *) mp->b_rptr;
-       p = (PAI *) q->q_ptr;
-       switch ((unsigned int)i->ioc_cmd) {
-      
-       case SIOCSIFCOMPAC :    /* enable or disable AC compression */
-           if (i->ioc_count != TRANSPARENT) {
-               i->ioc_error = EINVAL;
-               goto iocnak;
-           }
-           x = *(u_int *) mp->b_cont->b_rptr;
-           DLOG("ppp_async: SIFCOMPAC %d\n", x);
-           flags = (x & 2)? PAI_FLAGS_RCV_COMPAC: PAI_FLAGS_COMPAC;
-           if (x & 1) 
-               p->pai_flags |= flags;
-           else
-               p->pai_flags &= ~flags;
-           i->ioc_count = 0;
-           goto iocack;
-
-       case SIOCSIFCOMPPROT:   /* enable or disable PROT  compression */
-           if (i->ioc_count != TRANSPARENT) {
-               i->ioc_error = EINVAL;
-               goto iocnak;
-           }
-           x = *(u_int *) mp->b_cont->b_rptr;
-           DLOG("ppp_async: SIFCOMPPROT %d\n", x);
-           flags = (x & 2)? PAI_FLAGS_RCV_COMPPROT: PAI_FLAGS_COMPPROT;
-           if (x & 1) 
-               p->pai_flags |= flags;
-           else
-               p->pai_flags &= ~flags;
-           i->ioc_count = 0;
-           goto iocack;
-      
-      
-       case SIOCSIFMRU :
-           if ((i->ioc_count != TRANSPARENT) &&
-               (i->ioc_count != sizeof(int))) {
-               i->ioc_error = EINVAL;
-               goto iocnak;
-           }
-           x = *(int *) mp->b_cont->b_rptr;
-           if (x < PPP_MTU)
-               x = PPP_MTU;
-           x += PPP_HDRLEN + PPP_FCSLEN;
-           if (x > 4096) {     /* couldn't allocb something this big */
-               i->ioc_error = EINVAL;
-               goto iocnak;
-           }
-           p->pai_buffsize = x;
-           i->ioc_count  = 0;
-           goto iocack;
-
-       case SIOCGIFMRU :
-           if ((mp->b_cont = allocb(sizeof(int), BPRI_MED)) != NULL) {
-               *(int *) mp->b_cont->b_wptr = 
-                   p->pai_buffsize - (PPP_HDRLEN + PPP_FCSLEN);
-               mp->b_cont->b_wptr += i->ioc_count  = sizeof(int);
-               goto iocack;
-           }
-           i->ioc_error = ENOSR;
-           goto iocnak;
-      
-       case SIOCGIFASYNCMAP :
-           if ((mp->b_cont = allocb(sizeof(u_int32_t), BPRI_MED)) != NULL) {
-               *(u_int32_t *) mp->b_cont->b_wptr = p->pai_asyncmap[0];
-               mp->b_cont->b_wptr += i->ioc_count = sizeof(u_int32_t);
-               goto iocack;
-           }
-           i->ioc_error = ENOSR;
-           goto iocnak;
-
-       case SIOCSIFASYNCMAP :
-           if ((i->ioc_count != TRANSPARENT) &&
-               (i->ioc_count != sizeof(u_int32_t))) {
-               i->ioc_error = EINVAL;
-               goto iocnak;    /* ugh, goto */
-           }
-           p->pai_asyncmap[0] = *(u_int32_t *) mp->b_cont->b_rptr;
-           DLOG("ppp_async: SIFASYNCMAP %lx\n", p->pai_asyncmap[0]);
-           i->ioc_count = 0;
-           goto iocack;
-
-       case SIOCGIFRASYNCMAP :
-           if ((mp->b_cont = allocb(sizeof(u_int32_t), BPRI_MED)) != NULL) {
-               *(u_int32_t *) mp->b_cont->b_wptr = p->pai_rasyncmap;
-               mp->b_cont->b_wptr += i->ioc_count = sizeof(u_int32_t);
-               goto iocack;
-           }
-           i->ioc_error = ENOSR;
-           goto iocnak;
-
-       case SIOCSIFRASYNCMAP :
-           if ((i->ioc_count != TRANSPARENT) &&
-               (i->ioc_count != sizeof(u_int32_t))) {
-               i->ioc_error = EINVAL;
-               goto iocnak;    /* ugh, goto */
-           }
-           p->pai_rasyncmap = *(u_int32_t *) mp->b_cont->b_rptr;
-           DLOG("ppp_async: SIFRASYNCMAP %lx\n", p->pai_rasyncmap);
-           i->ioc_count = 0;
-           goto iocack;
-
-       case SIOCGIFXASYNCMAP :
-           if ((mp->b_cont = allocb(sizeof(ext_accm), BPRI_MED)) != NULL) {
-               bcopy(p->pai_asyncmap, mp->b_cont->b_wptr, sizeof(ext_accm));
-               mp->b_cont->b_wptr += i->ioc_count = sizeof(ext_accm);
-               goto iocack;
-           }
-           i->ioc_error = ENOSR;
-           goto iocnak;
-
-       case SIOCSIFXASYNCMAP :
-           if ((i->ioc_count != TRANSPARENT) &&
-               (i->ioc_count != sizeof(ext_accm))) {
-               i->ioc_error = EINVAL;
-               goto iocnak;    /* ugh, goto */
-           }
-           bcopy(*mp->b_cont->b_rptr, p->pai_asyncmap, sizeof(ext_accm));
-           p->pai_asyncmap[1] = 0;             /* can't escape 20-3f */
-           p->pai_asyncmap[2] &= ~0x40000000;  /* can't escape 5e */
-           p->pai_asyncmap[3] |= 0x60000000;   /* must escape 7d, 7e */
-           i->ioc_count = 0;
-           goto iocack;
-
-       case SIOCGIFDEBUG :
-           if ((mp->b_cont = allocb(sizeof(int), BPRI_MED)) != NULL) {
-               *(int *)mp->b_cont->b_wptr =
-                   (unsigned)(p->pai_flags & PAI_FLAGS_ALL_DEBUG)
-                       / PAI_FLAGS_DEBUG |
-                   (p->pai_flags & PAI_FLAGS_HIBITS);
-               mp->b_cont->b_wptr += i->ioc_count = sizeof(int);
-               goto iocack;
-           }
-           i->ioc_error = ENOSR;
-           goto iocnak;
-
-       case SIOCSIFDEBUG :
-           if ((i->ioc_count != TRANSPARENT) &&
-               (i->ioc_count != sizeof(int))) {
-               i->ioc_error = EINVAL;
-               goto iocnak;    /* ugh, goto */
-           }
-           flags = *(int *)mp->b_cont->b_rptr;
-           DLOG("ppp_async: SIFIFDEBUG %x\n", flags);
-           p->pai_flags &= ~PAI_FLAGS_ALL_DEBUG | PAI_FLAGS_HIBITS;
-           p->pai_flags |= ((unsigned) flags * PAI_FLAGS_DEBUG)
-               & PAI_FLAGS_ALL_DEBUG;
-           i->ioc_count = 0;
-           goto iocack;
-
-       iocack:;
-           mp->b_datap->db_type = M_IOCACK;
-           qreply(q,mp);
-           break;
-       iocnak:;
-           i->ioc_count = 0;
-           mp->b_datap->db_type = M_IOCNAK;
-           qreply(q, mp);
-           break;
-       default:                                /* unknown IOCTL call */
-           putnext(q,mp);              /* pass it along */
-       }
-       break;
-
-    default:
-       putnext(q, mp); /* don't know what to do with this, so send it along*/
-    }
-}
-
-static int
-ppp_async_wsrv(q)
-    queue_t    *q;
-{
-    register u_char    *cp, *wp;
-    register PAI       *p;
-    register u_short   fcs;
-    register mblk_t    *mp, *m0;
-    mblk_t     *cop, *outgoing;
-    int proto, len, olen, c;
-
-    p = (PAI *) q->q_ptr;
-
-    while ((mp = getq(q)) != NULL) {
-       /*
-        * we can only get M_DATA types into our Queue,
-        * due to our Put function
-        */
-       if (!canput(q->q_next)) {
-           putbq(q, mp);
-           return;
-       }
-
-       /* at least a header required */
-       len = msgdsize(mp);
-       if (len < PPP_HDRLEN
-           || (mp->b_wptr - mp->b_rptr < PPP_HDRLEN
-               && !pullupmsg(mp, PPP_HDRLEN))) {       
-           freemsg(mp);                /* discard the message */
-           DLOG("ppp_async: short message (%d)\n", len);
-           /* indicate output err */
-           putctl1(OTHERQ(q), M_CTL, IF_OUTPUT_ERROR);
-           continue;
-       }
-
-       /* Do address/control and protocol compression */
-       proto = (mp->b_rptr[2] << 8) + mp->b_rptr[3];
-       if (p->pai_flags & PAI_FLAGS_COMPAC && proto != PPP_LCP
-           && mp->b_rptr[0] == PPP_ALLSTATIONS && mp->b_rptr[1] == PPP_UI) {
-           mp->b_rptr += 2;
-           if (p->pai_flags & PAI_FLAGS_COMPPROT && proto < 0xff)
-               ++mp->b_rptr;
-       } else if (p->pai_flags & PAI_FLAGS_COMPPROT && proto < 0xff) {
-           mp->b_rptr[2] = mp->b_rptr[1];
-           mp->b_rptr[1] = mp->b_rptr[0];
-           ++mp->b_rptr;
-       }
-
-       m0 = mp;                /* remember first message block */
-       fcs = PPP_INITFCS;
-
-       /*
-        * Estimate the required buffer length as 1.25 * message length
-        * to allow for escaped characters.  If this isn't enough, we
-        * allocate another buffer later.
-        */
-       olen = len + (len >> 2) + 5;
-       if (olen < 32)
-           olen = 32;
-       else if (olen > 2048)
-           olen = 2048;
-       outgoing = cop = allocb(olen, BPRI_MED);
-       if (outgoing == NULL) {
-           DLOG("allocb(%d) failed!\n", olen);
-           /* should do something tricky here */
-           goto nobuffs;
-       }
-       wp = cop->b_wptr;
-
-       /* Put the initial flag in (we'll take it out later if we don't
-          need it). */
-       *wp++ = PPP_FLAG;
-       --olen;
-
-#define        SPECIAL(p, c)   (p->pai_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F)))
-
-       /*
-        * Copy the message to the output block, escaping characters
-        * as needed.
-        */
-       while (mp) {
-           for (cp = mp->b_rptr; cp < mp->b_wptr; ) {
-               c = *cp++;
-               if (olen < 2) {
-                   /* grab another message block and put it on the end */
-                   cop->b_wptr = wp;
-                   olen = 256;
-                   cop = allocb(olen, BPRI_MED);
-                   if (cop == NULL)
-                       goto nobuffs;
-                   linkb(outgoing, cop);
-                   wp = cop->b_wptr;
-               }
-               if (SPECIAL(p, c)) {
-                   *wp++ = PPP_ESCAPE;
-                   *wp++ = c ^ PPP_TRANS;
-                   olen -= 2;
-               } else {
-                   *wp++ = c;
-                   --olen;
-               }
-               fcs = PPP_FCS(fcs, c);
-           }
-           mp = mp->b_cont; /* look at the next block */
-       }                                       /* end while(mp) */
-
-       /*
-        * Add the FCS and the trailing flag.
-        */
-       if (olen < 5) {
-           /* grab another message block for FCS and trailing flag */
-           cop->b_wptr = wp;
-           cop = allocb(5, BPRI_MED);
-           if (cop == NULL)
-               goto nobuffs;
-           linkb(outgoing, cop);
-           wp = cop->b_wptr;
-       }
-       fcs ^= 0xffff;                          /* XOR the resulting FCS */
-       c = fcs & 0xff;
-       if (SPECIAL(p, c)) {
-           *wp++ = PPP_ESCAPE;
-           *wp++ = c ^ PPP_TRANS;
-       } else
-           *wp++ = c;
-       c = fcs >> 8;
-       if (SPECIAL(p, c)) {
-           *wp++ = PPP_ESCAPE;
-           *wp++ = c ^ PPP_TRANS;
-       } else
-           *wp++  = c;
-       *wp++ = PPP_FLAG;       /* add trailing PPP_FLAG */
-
-       cop->b_wptr = wp;
-       freemsg(m0);
-
-       /*
-        * now we check to see if the lower queue has entries, if so,
-        * we assume that we don't need a leading PPP_FLAG because
-        * these packets will be sent back to back.
-        */
-       if (qsize(q->q_next) > 0) {
-           /* entries in next queue, remove the leading PPP_FLAG */
-           ++outgoing->b_rptr;
-       }
-
-#if DEBUGS
-       if (p->pai_flags & PAI_FLAGS_LOG_OUTPKT)
-           ppp_dump_frame(p, outgoing, " sent output");
-#endif
-       putnext(q, outgoing);
-       continue;
-
-    nobuffs:   /* well, we ran out of memory somewhere */
-       if (outgoing)
-           freemsg(outgoing);          /* throw away what we have already */
-       putbq(q, m0);                   /* put back the original message */
-       putctl1(OTHERQ(q), M_CTL, IF_OUTPUT_ERROR);
-       qenable(q);                     /* reschedule ourselves for later */
-       return;
-    } /* end while(getq()) */
-}      /* end function */                                      
-
-static int
-ppp_async_rput(q, mp)
-    queue_t *q;
-    register mblk_t *mp;
-{
-    switch (mp->b_datap->db_type) {
-    
-    case M_FLUSH:
-       if(*mp->b_rptr & FLUSHR)
-           flushq(q, FLUSHDATA);
-       putnext(q, mp);         /* send it along too */
-       break;
-    
-    case M_DATA:
-       putq(q, mp);            /* queue it for my service routine */
-       break;
-    
-    default:
-       putnext(q,mp);  /* don't know what to do with this, so send it along */
-    }
-}
-
-static u_int32_t paritytab[8] = {
-    0x96696996, 0x69969669, 0x69969669, 0x96696996,
-    0x69969669, 0x96696996, 0x96696996, 0x69969669,
-};
-
-static int
-ppp_async_rsrv(q)
-    queue_t    *q;
-{
-    register mblk_t *mp, *bp;
-    register PAI       *p;
-    register u_char    *cp,c;
-    mblk_t     *m0;
-    register u_char *wptr;
-    int bcount;
-  
-    p = (PAI *) q->q_ptr;
-
-#define        INPUT_ERROR(q)  putctl1(q, M_CTL, IF_INPUT_ERROR)
-#define        STUFF_CHAR(p,c) (*wptr++ = (c), (p)->pai_buffcount++)
-#define        FLUSHEM(q, p)   (INPUT_ERROR(q), (p)->pai_flags |= PAI_FLAGS_FLUSH)
-  
-    while ((mp = getq(q)) != NULL) {
-       /* we can only get M_DATA types into our Queue,
-          due to our Put function */
-       if (!canput(q->q_next)) {
-           putbq(q, mp);
-           return;
-       }
-       m0 = mp;        /* remember first message block */
-       for (; mp != NULL; mp = mp->b_cont) {   /* for each message block */
-           cp = mp->b_rptr;
-           while (cp < mp->b_wptr) {
-               c = *cp++;
-
-               /* Accumulate info to help with detecting
-                  non 8-bit clean links. */
-               if (c & 0x80)
-                   p->pai_flags |= PAI_FLAGS_B7_1;
-               else
-                   p->pai_flags |= PAI_FLAGS_B7_0;
-               if (paritytab[c >> 5] & (1 << (c & 0x1F)))
-                   p->pai_flags |= PAI_FLAGS_PAR_ODD;
-               else
-                   p->pai_flags |= PAI_FLAGS_PAR_EVEN;
-
-               /* Throw out chars in the receive asyncmap. */
-               if (c < 0x20 && (p->pai_rasyncmap & (1 << c)))
-                   continue;
-
-               /* A flag marks the end of a frame. */
-               if (c == PPP_FLAG) {
-                   bp = p->pai_buffer;
-                   bcount = p->pai_buffcount;
-                   p->pai_buffer = NULL;
-                   p->pai_buffcount = 0;
-
-                   /* if the escape indicator is set, then we have
-                      seen the packet abort sequence "}~". */
-                   if (p->pai_flags & (PAI_FLAGS_ESCAPED | PAI_FLAGS_FLUSH)) {
-                       if ((p->pai_flags & PAI_FLAGS_FLUSH) == 0)
-                           DLOG("ppp_async: packet abort\n", 0);
-                       p->pai_flags &= ~(PAI_FLAGS_ESCAPED | PAI_FLAGS_FLUSH);
-                       if (bp)
-                           freemsg(bp);
-                       continue;
-                   }
-
-                   if (bcount > PPP_FCSLEN) {  /* discard FCS */
-                       adjmsg(bp, -PPP_FCSLEN);
-                       bcount -= PPP_FCSLEN;
-                   }
-
-                   if (bcount < PPP_HDRLEN) {
-                       if (bcount) {
-                           INPUT_ERROR(q);
-                           DLOG("ppp_async: short input packet (%d)\n",
-                                bcount);
-                       }
-                       if (bp)
-                           freemsg(bp);
-                       continue;
-                   }
-
-                   if (bp) {
-                       if (p->pai_fcs == PPP_GOODFCS) {
-#if DEBUGS
-                           if (p->pai_flags & PAI_FLAGS_LOG_INPKT)
-                               ppp_dump_frame(p, bp, " got input");
-#endif /*DEBUGS*/
-                           putnext(q, bp);
-                       }
-                       else {
-                           INPUT_ERROR(q);
-                           freemsg(bp);
-                           DLOG("ppp_async: FCS Error\n", 0);
-                       }
-                   }
-                   continue;
-               }
-
-               /* here c != PPP_FLAG */
-               if (p->pai_flags & PAI_FLAGS_FLUSH) {
-                   while (cp < mp->b_wptr && *cp != PPP_FLAG)
-                       ++cp;
-                   continue;
-               }
-
-               if (p->pai_flags & PAI_FLAGS_ESCAPED) {
-                   p->pai_flags &= ~PAI_FLAGS_ESCAPED; /* clear esc flag */
-                   c ^= PPP_TRANS;
-               } else if (c == PPP_ESCAPE) {
-                   if (cp >= mp->b_wptr || (c = *cp) == PPP_FLAG
-                       || c < 0x20 && (p->pai_rasyncmap & (1 << c))) {
-                       p->pai_flags |= PAI_FLAGS_ESCAPED;
-                       continue;
-                   }
-                   c ^= PPP_TRANS;
-                   ++cp;
-               }
-
-               /* here we check to see if we have a buffer.
-                  If we don't, we assume that this is the first char
-                  for the buffer, and we allocb one */
-       
-               if (!p->pai_buffer) {
-                   /* we allocate buffer chains in blocks of ALLOCBSIZE */
-         
-                   if (!(p->pai_buffer = allocb(ALLOCBSIZE, BPRI_MED))) {
-                       FLUSHEM(q, p);
-                       continue;
-                       /* if we don't get a buffer, is there some way
-                          to recover and requeue later? rather than flushing
-                          the current packet... ? */
-                   }
-                   p->pai_bufftail = p->pai_buffer;
-               }
-               wptr = p->pai_bufftail->b_wptr;
-
-               if (!p->pai_buffcount) {
-                   p->pai_fcs = PPP_INITFCS;
-                   if (c != PPP_ALLSTATIONS) {
-                       if (p->pai_flags & PAI_FLAGS_RCV_COMPAC) {
-                           STUFF_CHAR(p, PPP_ALLSTATIONS);
-                           STUFF_CHAR(p, PPP_UI);
-                       }
-                       else {
-                           DLOG("ppp_async: missed ALLSTATIONS (0xff), got 0x%x\n", c);
-                           FLUSHEM(q, p);
-                           continue;
-                       }
-                   }
-               } /* end if !p->pai_buffcount */
-
-               if (p->pai_buffcount == 1 && c != PPP_UI) {
-                   DLOG("ppp_async: missed UI (0x3), got 0x%x\n", c);
-                   FLUSHEM(q,p);
-                   continue;
-               }
-
-               if (p->pai_buffcount == 2 && (c & 1) == 1) {
-                   if (p->pai_flags & PAI_FLAGS_RCV_COMPPROT)
-                       STUFF_CHAR(p, 0);
-                   else {
-                       DLOG("ppp_async: bad protocol high byte %x\n", c);
-                       FLUSHEM(q, p);
-                       continue;
-                   }
-               }
-
-               if (p->pai_buffcount == 3 && (c & 1) == 0) {
-                   DLOG("ppp_async: bad protocol low byte %x\n", c);
-                   FLUSHEM(q, p);
-                   continue;
-               }
-
-               if (p->pai_buffcount >= p->pai_buffsize) {      /* overrun */
-                   DLOG("ppp_async: too many chars in input buffer %d\n",
-                        p->pai_buffcount);
-                   FLUSHEM(q, p);
-                   continue;
-               }
-
-               /* determine if we have enough space in the buffer */
-               if (wptr >= p->pai_bufftail->b_datap->db_lim) {
-                   p->pai_bufftail->b_wptr = wptr;
-                   if (!(p->pai_bufftail = allocb(ALLOCBSIZE, BPRI_MED))) {
-                       DLOG("ppp_async: couldn't get buffer for tail\n", 0);
-                       FLUSHEM(q, p);  /* discard all of it */
-                       continue;
-                   }
-                   linkb(p->pai_buffer, p->pai_bufftail);
-                   wptr = p->pai_bufftail->b_wptr;
-               }
-
-               STUFF_CHAR(p, c);
-               p->pai_fcs = PPP_FCS(p->pai_fcs, c);
-
-               if (p->pai_buffcount >= PPP_HDRLEN) {
-                   while (cp < mp->b_wptr
-                          && wptr < p->pai_bufftail->b_datap->db_lim
-                          && (c = *cp) != PPP_FLAG && c != PPP_ESCAPE) {
-                       if (c >= 0x20 || (p->pai_rasyncmap & (1 << c)) == 0) {
-                           STUFF_CHAR(p, c);
-                           p->pai_fcs = PPP_FCS(p->pai_fcs, c);
-                       }
-                       ++cp;
-                   }
-               }
-
-               p->pai_bufftail->b_wptr = wptr;
-
-           } /* end while cp < wptr */
-       }       /* end for each block */
-       /* discard this message now */
-       freemsg(m0);
-    }  /* end while  getq */
-  
-}
-
-#if DEBUGS
-/*
- * here is where we will dump out a frame in hex using the log() 
- * function if ppp_async_input_debug is non-zero. As this function is
- * a pig, we only print up to the number of bytes specified by the value of
- * the ppp_async_max_dump_bytes variable so as to not cause too many
- * timeouts.   <gmc@quotron.com> 
- */
-
-static void
-ppp_dump_frame(p, mptr, msg)
-    register PAI *p;
-    register mblk_t *mptr;
-    char *msg;
-{
-    register u_char *rptr;
-    register u_int i, mlen, frame_length;
-    char buf[2*MAX_DUMP_BYTES+4];      /* tmp buffer */
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-
-    frame_length = i = msgdsize(mptr);
-    bsdlog(LOG_INFO, "ppp_async%d:%s frame of %d bytes\n", p - pai,
-       msg, frame_length); 
-    rptr = mptr->b_rptr; /* get pointer to beginning  */
-    mlen = mptr->b_wptr - rptr; /* get length of this dblock */
-
-    /* only dump up to MAX_DUMP_BYTES */
-    if (i > ppp_async_max_dump_bytes)
-       i = ppp_async_max_dump_bytes;   
-
-    while (i--) {                      /* convert to ascii hex */
-       while (mlen == 0) {             /* get next dblock */
-           mptr = mptr->b_cont;
-           if (mptr) { /* are we done? */
-               rptr = mptr->b_rptr;    /* nope, get next dblock */
-               mlen = mptr->b_wptr - rptr;
-           }
-           else {                      /* no more dblocks */
-               if (i != 0)
-                   bsdlog(LOG_ERR, "ppp_async: ran out of data! (this shouldn't happen\n");
-               break;
-           }
-       }
-       --mlen;
-       *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*rptr++ & 0xf];
-    }
-
-    /* add a '>' to show that frame was truncated*/
-    if (ppp_async_max_dump_bytes < frame_length)
-       *bp++ = '>';
-    *bp = 0;
-    bsdlog(LOG_INFO,"ppp_async: %s\n", buf); 
-}
-#endif /* DEBUGS */
-
-#endif /* NUM_PPP > 0 */
diff --git a/aix4/ppp_async.exp b/aix4/ppp_async.exp
deleted file mode 100644 (file)
index a1992d2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp_async_load
diff --git a/aix4/ppp_comp.c b/aix4/ppp_comp.c
deleted file mode 100644 (file)
index 2d0c440..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * ppp_comp.c - STREAMS module for kernel-level CCP support.
- *
- * Copyright (c) 1994 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.
- *
- * $Id: ppp_comp.c,v 1.7 2002/12/06 09:49:15 paulus Exp $
- */
-
-#include <net/net_globals.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/user.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/strconf.h>
-#include <sys/device.h>
-#include <sys/syslog.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/ppp_defs.h>
-#include <net/ppp_str.h>
-
-#define PACKETPTR      mblk_t *
-#include <net/ppp-comp.h>
-
-static int ppp_comp_open(), ppp_comp_close();
-static int ppp_comp_rput(), ppp_comp_wput();
-static void ppp_comp_ccp();
-
-static struct module_info minfo = {
-    0xbadf, "ppp_compress", 0, INFPSZ, 16384, 4096,
-};
-
-static struct qinit r_init = {
-    ppp_comp_rput, NULL, ppp_comp_open, ppp_comp_close,
-    NULL, &minfo, NULL
-};
-
-static struct qinit w_init = {
-    ppp_comp_wput, NULL, NULL, NULL, NULL, &minfo, NULL
-};
-
-struct streamtab ppp_compinfo = {
-    &r_init, &w_init, NULL, NULL
-};
-
-struct ppp_comp_state {
-    int        ccp_state;
-    int                debug;
-    int                mru;
-    struct compressor *xcomp;
-    void       *xstate;
-    struct compressor *rcomp;
-    void       *rstate;
-};
-
-/* Bits in ccp_state are as defined in ppp_str.h. */
-#define CCP_ERR                (CCP_ERROR | CCP_FATALERROR)
-
-/*
- * List of compressors we know about.
- */
-
-extern struct compressor ppp_bsd_compress;
-
-struct compressor *ppp_compressors[] = {
-#if DO_BSD_COMPRESS
-    &ppp_bsd_compress,
-#endif
-    NULL
-};
-
-strconf_t pppcompconf = {
-    "pppcomp", &ppp_compinfo, STR_NEW_OPEN, 0, SQLVL_DEFAULT, (void *) 0
-};
-
-int pppcomp_load(int cmd, struct uio *uiop)
-{
-    int rc = 0;
-
-    switch (cmd) {
-        case CFG_INIT:
-            rc = str_install(STR_LOAD_MOD, &pppcompconf);
-            break;
-        case CFG_TERM:
-            rc = str_install(STR_UNLOAD_MOD, &pppcompconf);
-            break;
-        default:
-            rc = EINVAL;
-            break;
-    }
-    return(rc);
-}
-
-static int
-ppp_comp_open(q, dev, flag, sflag)
-    queue_t *q;
-    dev_t dev;
-    int flag;
-    int sflag;
-{
-    struct ppp_comp_state *cp;
-
-    if (q->q_ptr == NULL) {
-       cp = (struct ppp_comp_state *)
-           xmalloc(sizeof(struct ppp_comp_state), 0, pinned_heap);
-       if (cp == NULL) {
-           return(ENOSR);
-       }
-       bzero(cp, sizeof(struct ppp_comp_state));
-       OTHERQ(q)->q_ptr = q->q_ptr = (caddr_t) cp;
-       cp->ccp_state = 0;
-       cp->debug = 0;
-       cp->mru = PPP_MRU;
-       cp->xstate = NULL;
-       cp->rstate = NULL;
-    }
-    return 0;
-}
-
-static int
-ppp_comp_close(q)
-    queue_t *q;
-{
-    struct ppp_comp_state *cp;
-
-    cp = (struct ppp_comp_state *) q->q_ptr;
-    if (cp != NULL) {
-       if (cp->xstate != NULL)
-           (*cp->xcomp->comp_free)(cp->xstate);
-       if (cp->rstate != NULL)
-           (*cp->rcomp->decomp_free)(cp->rstate);
-       xmfree(cp, pinned_heap);
-       q->q_ptr = NULL;
-       OTHERQ(q)->q_ptr = NULL;
-    }
-    return 0;
-}
-
-static int
-ppp_comp_wput(q, mp)
-    queue_t *q;
-    mblk_t *mp;
-{
-    struct iocblk *iop;
-    struct ppp_comp_state *cp;
-    mblk_t *cmp;
-    int error, len, proto, state;
-    struct ppp_option_data *odp;
-    struct compressor **comp;
-    struct ppp_comp_stats *pcp;
-
-    cp = (struct ppp_comp_state *) q->q_ptr;
-    switch (mp->b_datap->db_type) {
-
-    case M_CTL:
-        switch (*(u_char *) mp->b_rptr) {
-        case IF_GET_CSTATS:
-            freemsg(mp);
-            mp = allocb(sizeof(struct ppp_comp_stats) + sizeof(u_long),
-                        BPRI_HI);
-            if (mp != NULL) {
-               mp->b_datap->db_type = M_CTL;
-                *(u_char *) mp->b_wptr = IF_CSTATS;
-                mp->b_wptr += sizeof(u_long); /* should be enough alignment */
-                pcp = (struct ppp_comp_stats *) mp->b_wptr;
-                mp->b_wptr += sizeof(struct ppp_comp_stats);
-                bzero(pcp, sizeof(struct ppp_comp_stats));
-                if (cp->xstate != NULL)
-                    (*cp->xcomp->comp_stat)(cp->xstate, &pcp->c);
-                if (cp->rstate != NULL)
-                    (*cp->rcomp->decomp_stat)(cp->rstate, &pcp->d);
-                qreply(q, mp);
-            }
-            break;
-        default:
-            putnext(q, mp);
-        }
-        break;
-
-    case M_DATA:
-       /* first find out what the protocol is */
-       if (mp->b_wptr - mp->b_rptr >= PPP_HDRLEN
-           || pullupmsg(mp, PPP_HDRLEN)) {
-           proto = PPP_PROTOCOL(mp->b_rptr);
-           if (proto == PPP_CCP)
-               ppp_comp_ccp(q, mp, 0);
-           else if (proto != PPP_LCP && (cp->ccp_state & CCP_COMP_RUN)
-                    && cp->xstate != NULL) {
-               len = msgdsize(mp);
-               (*cp->xcomp->compress)(cp->xstate, &cmp, mp, len,
-                                      (cp->ccp_state & CCP_ISUP? len: 0));
-               /* XXX we really want the MTU here, not len */
-               if (cmp != NULL) {
-                   freemsg(mp);
-                   mp = cmp;
-               }
-           }
-       }
-       putnext(q, mp);
-       break;
-
-    case M_IOCTL:
-       iop = (struct iocblk *) mp->b_rptr;
-       error = -1;
-       switch ((unsigned int)iop->ioc_cmd) {
-
-       case SIOCSIFCOMP:
-           /* set CCP state */
-           if ((iop->ioc_count != sizeof(int)) &&
-               (iop->ioc_count != TRANSPARENT)) {
-               error = EINVAL;
-               break;
-           }
-           state = (*(int *) mp->b_cont->b_rptr) & (CCP_ISUP | CCP_ISOPEN);
-           if ((state & CCP_ISOPEN) == 0) {
-               if (cp->xstate != NULL) {
-                   (*cp->xcomp->comp_free)(cp->xstate);
-                   cp->xstate = NULL;
-               }
-               if (cp->rstate != NULL) {
-                   (*cp->rcomp->decomp_free)(cp->rstate);
-                   cp->rstate = NULL;
-               }
-               cp->ccp_state = 0;
-           } else {
-               cp->ccp_state = (cp->ccp_state & ~CCP_ISUP) | state;
-           }
-           if (cp->debug)
-               bsdlog(LOG_INFO, "SIOCSIFCOMP %x, state = %x\n",
-                   *(int *) mp->b_cont->b_rptr, cp->ccp_state);
-           error = 0;
-           iop->ioc_count = 0;
-           break;
-
-       case SIOCGIFCOMP:
-           if ((mp->b_cont = allocb(sizeof(int), BPRI_MED)) == NULL) {
-               error = ENOSR;
-               break;
-           }
-           *(int *)mp->b_cont->b_wptr = cp->ccp_state;
-           mp->b_cont->b_wptr += iop->ioc_count = sizeof(int);
-           break;
-
-       case SIOCSCOMPRESS:
-           error = EINVAL;
-           if (iop->ioc_count != TRANSPARENT)
-               break;
-           odp = *((struct ppp_option_data **) mp->b_cont->b_rptr);
-           len = sizeof(odp->opt_data);
-           if (len > odp->length)
-               len = odp->length;
-           if (odp->opt_data[1] < 2 || odp->opt_data[1] > len)
-               break;
-           for (comp = ppp_compressors; *comp != NULL; ++comp)
-               if ((*comp)->compress_proto == odp->opt_data[0]) {
-                   /* here's the handler! */
-                   error = 0;
-                   if (odp->transmit) {
-                       if (cp->xstate != NULL)
-                           (*cp->xcomp->comp_free)(cp->xstate);
-                       cp->xcomp = *comp;
-                       cp->xstate = (*comp)->comp_alloc(odp->opt_data, len);
-                       if (cp->xstate == NULL)
-                           error = ENOSR;
-                   } else {
-                       if (cp->rstate != NULL)
-                           (*cp->rcomp->decomp_free)(cp->rstate);
-                       cp->rcomp = *comp;
-                       cp->rstate = (*comp)->decomp_alloc(odp->opt_data, len);
-                       if (cp->rstate == NULL)
-                           error = ENOSR;
-                   }
-                   if (cp->debug)
-                       bsdlog(LOG_INFO, "SIOCSCOMPRESS %s len=%d\n",
-                           odp->transmit? "xmit": "recv", len);
-                   break;
-               }
-           iop->ioc_count = 0;
-           break;
-
-       case SIOCSIFDEBUG:
-           /* set our debug flag from this */
-           if ((iop->ioc_count == TRANSPARENT) ||
-               (iop->ioc_count == sizeof(int))) {
-               cp->debug = *(int *) mp->b_cont->b_rptr & 1;
-           }
-           break;
-
-       case SIOCSIFMRU:
-           /* remember this value */
-           if ((iop->ioc_count == TRANSPARENT) ||
-               (iop->ioc_count == sizeof(int))) {
-               cp->mru = *(int *) mp->b_cont->b_rptr;
-           }
-           break;
-
-       }
-
-       if (error < 0)
-           putnext(q, mp);
-       else if (error == 0) {
-           mp->b_datap->db_type = M_IOCACK;
-           qreply(q, mp);
-       } else {
-           mp->b_datap->db_type = M_IOCNAK;
-           iop->ioc_count = 0;
-           qreply(q, mp);
-       }
-       break;
-
-    default:
-       putnext(q, mp);
-    }
-}
-
-static int
-ppp_comp_rput(q, mp)
-    queue_t *q;
-    mblk_t *mp;
-{
-    int proto, rv;
-    mblk_t *dmp;
-    struct ppp_comp_state *cp;
-
-    cp = (struct ppp_comp_state *) q->q_ptr;
-    switch (mp->b_datap->db_type) {
-
-    case M_DATA:
-       /* possibly a compressed packet to decompress,
-          or a CCP packet to take notice of. */
-       if (mp->b_wptr - mp->b_rptr >= PPP_HDRLEN
-           || pullupmsg(mp, PPP_HDRLEN)) {
-           proto = PPP_PROTOCOL(mp->b_rptr);
-           if (proto == PPP_CCP)
-               ppp_comp_ccp(q, mp, 1);
-           else if (proto == PPP_COMP) {
-               if ((cp->ccp_state & CCP_ISUP)
-                   && (cp->ccp_state & CCP_DECOMP_RUN) && cp->rstate
-                   && (cp->ccp_state & CCP_ERR) == 0) {
-                   rv = (*cp->rcomp->decompress)(cp->rstate, mp, &dmp);
-                   if (dmp != NULL) {
-                       freemsg(mp);
-                       mp = dmp;
-                   } else {
-                       switch (rv) {
-                       case DECOMP_OK:
-                           /* no error, but no packet returned */
-                           freemsg(mp);
-                           mp = NULL;
-                           break;
-                       case DECOMP_ERROR:
-                           cp->ccp_state |= CCP_ERROR;
-                           break;
-                       case DECOMP_FATALERROR:
-                           cp->ccp_state |= CCP_FATALERROR;
-                           break;
-                       }
-                   }
-               }
-           } else if (cp->rstate && (cp->ccp_state & CCP_DECOMP_RUN)) {
-               (*cp->rcomp->incomp)(cp->rstate, mp);
-           }
-       }
-       if (mp != NULL)
-           putnext(q, mp);
-       break;
-
-    default:
-       putnext(q, mp);
-    }
-}
-
-static void
-ppp_comp_ccp(q, mp, rcvd)
-    queue_t *q;
-    mblk_t *mp;
-    int rcvd;
-{
-    int len, clen;
-    struct ppp_comp_state *cp;
-    unsigned char *dp;
-
-    len = msgdsize(mp);
-    if (len < PPP_HDRLEN + CCP_HDRLEN || !pullupmsg(mp, len))
-       return;
-    cp = (struct ppp_comp_state *) q->q_ptr;
-    dp = mp->b_rptr + PPP_HDRLEN;
-    len -= PPP_HDRLEN;
-    clen = CCP_LENGTH(dp);
-    if (clen > len)
-       return;
-    if (cp->debug)
-       bsdlog(LOG_INFO, "CCP %s: code=%x len=%d\n", rcvd? "rcvd": "sent",
-           CCP_CODE(dp), clen);
-
-    switch (CCP_CODE(dp)) {
-    case CCP_CONFREQ:
-    case CCP_TERMREQ:
-    case CCP_TERMACK:
-       cp->ccp_state &= ~CCP_ISUP;
-       break;
-
-    case CCP_CONFACK:
-       if ((cp->ccp_state & (CCP_ISOPEN | CCP_ISUP)) == CCP_ISOPEN
-           && clen >= CCP_HDRLEN + CCP_OPT_MINLEN
-           && clen >= CCP_HDRLEN + CCP_OPT_LENGTH(dp + CCP_HDRLEN)) {
-           if (!rcvd) {
-               if (cp->xstate != NULL
-                   && (*cp->xcomp->comp_init)
-                       (cp->xstate, dp + CCP_HDRLEN, clen - CCP_HDRLEN,
-                        0, /* XXX: should be unit */ 0,
-                        cp->debug))
-                   cp->ccp_state |= CCP_COMP_RUN;
-           } else {
-               if (cp->rstate != NULL
-                   && (*cp->rcomp->decomp_init)
-                       (cp->rstate, dp + CCP_HDRLEN, clen - CCP_HDRLEN,
-                        0/* unit */, 0, cp->mru, cp->debug))
-                   cp->ccp_state = (cp->ccp_state & ~CCP_ERR)
-                       | CCP_DECOMP_RUN;
-           }
-       }
-       break;
-
-    case CCP_RESETACK:
-       if (cp->ccp_state & CCP_ISUP) {
-           if (!rcvd) {
-               if (cp->xstate && (cp->ccp_state & CCP_COMP_RUN))
-                   (*cp->xcomp->comp_reset)(cp->xstate);
-           } else {
-               if (cp->rstate && (cp->ccp_state & CCP_DECOMP_RUN)) {
-                   (*cp->rcomp->decomp_reset)(cp->rstate);
-                   cp->ccp_state &= ~CCP_ERROR;
-               }
-           }
-       }
-       break;
-    }
-
-    if (cp->debug)
-       bsdlog(LOG_INFO, "ccp_state = %x\n", cp->ccp_state);
-}
diff --git a/aix4/ppp_if.c b/aix4/ppp_if.c
deleted file mode 100644 (file)
index 23b8446..0000000
+++ /dev/null
@@ -1,1144 +0,0 @@
-/*
-  ppp_if.c - Streams PPP interface module
-
-  top level module handles if_ and packetizing PPP packets.
-
-  Copyright (C) 1990  Brad K. Clements, All Rights Reserved
-  See copyright notice in NOTES
-
-*/
-
-#define        VJC     1
-#include <sys/types.h>
-
-#ifndef PPP_VD
-#include "ppp.h"
-#endif
-
-#if NUM_PPP > 0
-
-#define        STREAMS 1
-
-#define        PPP_STATS       1       /* keep statistics */
-#define        DEBUGS          1
-
-#include <net/net_globals.h>
-#include <sys/param.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/strconf.h>
-
-#include <sys/device.h>
-/*
-#include <sys/user.h>
-*/
-/*
-#include <sys/systm.h>
-*/
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/uio.h>
-#include <net/if.h>
-#include <net/route.h>
-#include <net/netisr.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-#define  _NETINET_IN_SYSTM_H_
-typedef u_long  n_long;
-#include <netinet/ip.h>
-
-#include <net/ppp_defs.h>
-#include <net/ppp_str.h>
-
-#ifdef VJC
-#undef SPECIAL_I
-#include <net/vjcompress.h>
-#endif
-
-#ifdef PPP_STATS
-#define        INCR(comp)      ++p->pii_stats.comp
-#else
-#define        INCR(comp)
-#endif
-
-#define MAX_PKTSIZE    4096    /* max packet size including framing */
-#define PPP_FRAMING    6       /* 4-byte header + 2-byte FCS */
-#define MAX_IPHDR      128     /* max TCP/IP header size */
-#define MAX_VJHDR      20      /* max VJ compressed header size (?) */
-
-/*
- * Network protocols we support.
- */
-#define NP_IP          0
-#define NUM_NP         1       /* # protocols supported */
-
-/*
- * Structure used within the ppp_if streams module.
- */
-struct ppp_if_info {
-    int                        pii_flags;
-    struct ifnet       pii_ifnet;
-    queue_t            *pii_writeq;    /* used by ppp_output */
-    enum NPmode                pii_npmode[NUM_NP];
-    mblk_t             *pii_npq;       /* list of packets queued up */
-    mblk_t             **pii_npq_tail;
-#ifdef VJC
-    struct vjcompress  pii_sc_comp;    /* vjc control buffer */
-#endif
-#ifdef PPP_STATS
-    struct pppstat     pii_stats;
-    struct ppp_comp_stats pii_cstats;
-#endif
-};
-
-/*
- * Values for pii_flags.
- */
-#define        PII_FLAGS_INUSE         0x1     /* in use by  a stream  */
-#define        PII_FLAGS_ATTACHED      0x8     /* already if_attached  */
-#define        PII_FLAGS_VJC_ON        0x10    /* VJ TCP header compression enabled */
-#define PII_FLAGS_VJC_NOCCID   0x20    /* VJ: don't compress conn. id */
-#define PII_FLAGS_VJC_REJ      0x40    /* receive: reject VJ comp */
-#define PII_FLAGS_DEBUG                0x80    /* enable debug printout */
-
-#ifdef DEBUGS
-#include <sys/syslog.h>
-#define        DLOG(s,a) if (p->pii_flags&PII_FLAGS_DEBUG) bsdlog(LOG_INFO, s, a)
-#else
-#define        DLOG(s) {}
-#endif
-
-#ifdef PPP_SNIT
-#include <net/nit_if.h>
-#include <netinet/if_ether.h>
-/* Use a fake link level header to make etherfind and tcpdump happy. */
-static struct ether_header header = {{1}, {2}, ETHERTYPE_IP};
-static struct nit_if nif = {(caddr_t)&header, sizeof(header), 0, 0};
-#endif
-
-static int     ppp_if_open(), ppp_if_close(), ppp_if_rput(), ppp_if_wput(),
-               ppp_if_wsrv(), ppp_if_rsrv();
-
-static         struct  module_info     minfo ={
-       0xbad,"ppp_if",0, INFPSZ, 16384, 4096
-};
-
-static struct  qinit   r_init = {
-       ppp_if_rput, ppp_if_rsrv, ppp_if_open, ppp_if_close, NULL, &minfo, NULL
-};
-static struct  qinit   w_init = {
-       ppp_if_wput, ppp_if_wsrv, ppp_if_open, ppp_if_close, NULL, &minfo, NULL
-};
-struct streamtab       ppp_ifinfo = {
-       &r_init, &w_init, NULL, NULL
-};
-
-typedef        struct ppp_if_info      PII;
-
-PII    *pii;
-
-int ppp_output(), ppp_ioctl();
-static void if_release_addrs(), if_delete_route();
-
-strconf_t pppconf = {
-    "pppif", &ppp_ifinfo, STR_NEW_OPEN, 0, SQLVL_DEFAULT, (void *) 0
-};
-
-int ppp_load(int cmd, struct uio *uiop)
-{
-    int rc = 0;
-
-    switch (cmd) {
-        case CFG_INIT:
-            rc = str_install(STR_LOAD_MOD, &pppconf);
-            break;
-        case CFG_TERM:
-            rc = str_install(STR_UNLOAD_MOD, &pppconf);
-            break;
-        default:
-            rc = EINVAL;
-            break;
-    }
-    if ((rc == 0) && !(pii = xmalloc(sizeof(PII) * NUM_PPP, 0, pinned_heap)))
-        rc = ENOMEM;
-    else
-       bzero(pii, sizeof(PII) * NUM_PPP);
-
-    return(rc);
-}
-
-int
-ppp_attach(unit)
-    int        unit;
-{
-    register struct ifnet *ifp = &pii[unit].pii_ifnet;
-
-    ifp->if_name = "ppp";
-    ifp->if_type = IFT_PTPSERIAL;
-    ifp->if_mtu  = PPP_MTU;
-    ifp->if_flags = IFF_POINTOPOINT;
-    ifp->if_unit  = unit;
-    ifp->if_ioctl = ppp_ioctl;
-    ifp->if_output = ppp_output;
-    ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
-    if_attach(ifp);
-    if_nostat(ifp);
-    pii[unit].pii_flags |= PII_FLAGS_ATTACHED;
-}
-
-
-int
-ppp_unattach(unit)
-    int        unit;
-{
-    struct ifnet *ifp = &pii[unit].pii_ifnet;
-    struct ifnet **p;
-    int s;
-
-    if (!(pii[unit].pii_flags & PII_FLAGS_ATTACHED))
-       return 0;
-
-    /* remove interface from interface list */
-    for (p = &ifp; *p; p = &((*p)->if_next)) {
-       if (*p == ifp) {
-           *p = (*p)->if_next;
-
-           /* mark it down and flush it's que */
-           if_down(ifp);
-
-           /* free any addresses hanging off the intf */
-           if_release_addrs(ifp);
-
-           pii[unit].pii_flags &= ~PII_FLAGS_ATTACHED;
-
-           return 0;
-       }
-    }
-
-    return -1;
-}
-
-
-static void
-if_release_addrs(ifp)
-register struct ifnet *ifp;
-{
-    register struct in_ifaddr **addr;
-    register struct ifaddr *ifa, *ifanxt;
-    register int s;
-    if_delete_route(ifp);
-    for (addr = &in_ifaddr; *addr; ) {
-       if ((*addr)->ia_ifp == ifp)
-           *addr = (*addr)->ia_next;
-       else
-           addr = &((*addr)->ia_next);
-    }
-    /*
-     * Free all mbufs holding down this interface's address(es).
-     */
-    for (ifa = ifp->if_addrlist; ifa; ifa = ifanxt) {
-       ifanxt = ifa->ifa_next;
-       m_free(dtom(ifa));
-    }
-    ifp->if_addrlist = 0;
-}
-
-/*
- * Delete routes to the specified interface.
- * Hacked from rtrequest().
- */
-static void
-if_delete_route(ifp)
-struct ifnet *ifp;
-{
-    extern int rttrash;                /* routes not in table but not freed */
-    register struct mbuf **mprev, *m;
-    register struct rtentry *route;
-    register int i;
-    /* search host rt tbl */
-/*
-    for (i = 0; i < RTHASHSIZ; i++) {
-       mprev = &rthost[i];
-       while (m = *mprev) {
-           route = mtod(m, struct rtentry *);
-           if (route->rt_ifp == ifp) {
-               *mprev = m->m_next;
-               if (route->rt_refcnt > 0) {
-                   route->rt_flags &= ~RTF_UP;
-                   rttrash++;
-                   m->m_next = 0;
-               } else {
-                   m_free(m);
-               }
-           } else
-               mprev = &m->m_next;
-       }
-    }
-*/
-    /* search net rt tbl */
-/*
-    for (i = 0; i < RTHASHSIZ; i++) {
-       mprev = &rtnet[i];
-       while (m = *mprev) {
-           route = mtod(m, struct rtentry *);
-           if (route->rt_ifp == ifp) {
-               *mprev = m->m_next;
-               if (route->rt_refcnt > 0) {
-                   route->rt_flags &= ~RTF_UP;
-                   rttrash++;
-                   m->m_next = 0;
-               } else {
-                   m_free(m);
-               }
-           } else
-               mprev = &m->m_next;
-       }
-    }
-*/
-} 
-
-int
-ppp_busy()
-{
-    int x;
-
-    for (x = 0; x < NUM_PPP; x++) {
-       if (pii[x].pii_flags & PII_FLAGS_INUSE)
-           return 1;
-    }
-    return 0;
-}
-
-static PII *
-ppp_if_alloc()
-{
-    int s, x;
-    PII *p;
-
-    for (x = 0; x < NUM_PPP; x++)
-       if (!(pii[x].pii_flags & PII_FLAGS_INUSE))
-           break;
-    if (x == NUM_PPP) {                /* all buffers in use */
-       return NULL;
-    }
-    p = &pii[x];
-    p->pii_flags |= PII_FLAGS_INUSE;
-    return p;
-}
-
-static void
-ppp_if_init(q, p)
-    queue_t *q;
-    PII *p;
-{
-    int s, n;
-
-
-#ifdef VJC
-    vj_compress_init(&p->pii_sc_comp, -1);
-#endif
-#ifdef PPP_STATS
-    bzero(&p->pii_stats, sizeof(p->pii_stats));
-#endif
-    if (!(p->pii_flags & PII_FLAGS_ATTACHED))
-       ppp_attach(p - pii);                    /* attach it */
-    else
-       p->pii_ifnet.if_mtu = PPP_MTU;
-    p->pii_writeq = WR(q);
-    /* set write Q and read Q to point here */
-    WR(q)->q_ptr = q->q_ptr = (caddr_t) p;
-    p->pii_ifnet.if_flags |= IFF_RUNNING;
-    p->pii_flags &= PII_FLAGS_INUSE | PII_FLAGS_ATTACHED | PII_FLAGS_DEBUG;
-    for (n = 0; n < NUM_NP; ++n)
-       p->pii_npmode[n] = NPMODE_ERROR;
-    p->pii_npmode[NP_IP] = NPMODE_PASS;        /* for backwards compatibility */
-    p->pii_npq = NULL;
-    p->pii_npq_tail = &p->pii_npq;
-
-    DLOG("ppp_if%d: init\n", p - pii);
-}
-
-static int
-ppp_if_open(q, dev, flag, sflag)
-    queue_t    *q;
-    dev_t      dev;
-    int                flag, sflag;
-
-{
-    if (!suser()) {
-       return(EPERM);
-    }
-
-    return (0);
-}
-
-static int
-ppp_if_close(q)
-    queue_t    *q;                     /* queue info */
-{
-    PII        *p = (PII *) q->q_ptr;
-    int        s, n;
-    mblk_t *mp, *mq;
-
-    if (p != NULL) {
-       if_down(&p->pii_ifnet);
-       p->pii_ifnet.if_flags &= ~IFF_RUNNING;
-       p->pii_flags &= ~PII_FLAGS_INUSE;
-       q->q_ptr = NULL;
-       for (mp = p->pii_npq; mp != NULL; mp = mq) {
-           mq = mp->b_next;
-           freemsg(mp);
-       }
-       p->pii_npq = NULL;
-       p->pii_npq_tail = &p->pii_npq;
-       p->pii_writeq = NULL;
-       DLOG("ppp_if%d: closed\n", p - pii);
-    }
-    return(0);                 /* no work to be done */
-}
-
-
-static int
-ppp_if_wput(q, mp)
-    queue_t  *q;
-    register mblk_t *mp;
-{
-    register struct iocblk *i;
-    register PII *p;
-    int bits, flags, error, unit, s;
-    queue_t *oq;
-    int npix;
-    struct npioctl *npi;
-    mblk_t *mq, **mqnext;
-    struct ppp_stats *psp;
-
-    switch (mp->b_datap->db_type) {
-
-    case M_FLUSH:
-       if (*mp->b_rptr & FLUSHW)
-           flushq(q, FLUSHDATA);
-       putnext(q, mp);         /* send it along too */
-       break;
-
-    case M_DATA:
-       putq(q, mp);    /* queue it for my service routine */
-       break;
-
-    case M_IOCTL:
-       i = (struct iocblk *) mp->b_rptr;
-       p = (PII *) q->q_ptr;
-       switch ((unsigned int)i->ioc_cmd) {
-
-       case SIOCSIFVJCOMP:     /* enable or disable VJ compression */
-#ifdef VJC
-           if (i->ioc_count == TRANSPARENT) {
-               bits = *(u_int *) mp->b_cont->b_rptr;
-               DLOG("ppp_if: SIFVJCOMP %d\n", bits);
-               if (bits & 1) 
-                   p->pii_flags |= PII_FLAGS_VJC_ON;
-               else
-                   p->pii_flags &= ~PII_FLAGS_VJC_ON;
-               if (bits & 2)
-                   p->pii_flags |= PII_FLAGS_VJC_NOCCID;
-               else
-                   p->pii_flags &= ~PII_FLAGS_VJC_NOCCID;
-               if (bits & 4)
-                   p->pii_flags |= PII_FLAGS_VJC_REJ;
-               else
-                   p->pii_flags &= ~PII_FLAGS_VJC_REJ;
-               bits >>= 4;             /* now max conn id. */
-               if (bits)
-                   vj_compress_init(&p->pii_sc_comp, bits);
-               mp->b_datap->db_type = M_IOCACK;
-               i->ioc_count = 0;
-               qreply(q, mp);
-               break;
-           }
-#endif
-           putnext(q, mp);
-           break;
-
-       case SIOCGETU:  /* get unit number */
-           /*
-            * Allocate a unit if we don't already have one.
-            */
-           error = 0;
-           if (p == (PII *) 0) {
-               p = ppp_if_alloc();
-               if (p == NULL)
-                   error = ENOBUFS;
-               else
-                   ppp_if_init(RD(q), p);
-           }
-           if (error == 0
-               && (mp->b_cont = allocb(sizeof(int), BPRI_MED)) == NULL)
-               error = ENOSR;
-           if (error == 0) {
-               *(int *) mp->b_cont->b_wptr = p->pii_ifnet.if_unit;
-               mp->b_cont->b_wptr += i->ioc_count = sizeof(int);
-               mp->b_datap->db_type = M_IOCACK;
-           } else {
-               i->ioc_error = error;
-               i->ioc_count = 0;
-               mp->b_datap->db_type = M_IOCNAK;
-           }
-           qreply(q,mp);
-           break;
-
-       case SIOCSETU:  /* set unit number */
-           if ((i->ioc_count == sizeof(int)) ||
-               (i->ioc_count == TRANSPARENT)) {
-               unit = *(int *)mp->b_cont->b_rptr;
-               if (p != NULL || (unsigned) unit > NUM_PPP) {
-                   mp->b_datap->db_type = M_IOCNAK;
-                   i->ioc_error = EINVAL;
-                   i->ioc_count = 0;
-                   error = EINVAL;
-               } else {
-                   p = &pii[unit];
-                   if (p->pii_flags & PII_FLAGS_INUSE) {
-                       oq = p->pii_writeq;
-                       oq->q_ptr = RD(oq)->q_ptr = NULL;
-                       q->q_ptr = RD(q)->q_ptr = (caddr_t) p;
-                       p->pii_writeq = q;
-                   } else {
-                       ppp_if_init(RD(q), p);
-                   }
-                   mp->b_datap->db_type = M_IOCACK;
-               }
-               qreply(q, mp);
-               break;
-           }
-           putnext(q, mp);
-           break;
-
-       case SIOCSIFDEBUG :
-           /* catch it on the way past to set our debug flag as well */
-           if (i->ioc_count == TRANSPARENT) {
-               flags = *(int *)mp->b_cont->b_rptr;
-               if (flags & 1)
-                   p->pii_flags |= PII_FLAGS_DEBUG;
-               else
-                   p->pii_flags &= ~PII_FLAGS_DEBUG;
-           }
-           putnext(q, mp);
-           break;
-
-       case SIOCGETNPMODE:
-       case SIOCSETNPMODE:
-           if (i->ioc_count == TRANSPARENT && p != NULL) {
-               npi = *((struct npioctl **) mp->b_cont->b_rptr);
-               switch (npi->protocol) {
-               case PPP_IP:
-                   npix = NP_IP;
-                   break;
-               default:
-                   npix = -1;
-               }
-               if (npix < 0) {
-                   i->ioc_error = EAFNOSUPPORT;
-                   i->ioc_count = 0;
-                   mp->b_datap->db_type = M_IOCNAK;
-                   qreply(q, mp);
-                   break;
-               }
-               if (i->ioc_cmd == SIOCSETNPMODE) {
-                   if (p->pii_npmode[npix] == NPMODE_QUEUE
-                       && npi->mode != NPMODE_QUEUE) {
-                       for (mqnext = &p->pii_npq; (mq = *mqnext) != NULL; ) {
-                           if (PPP_PROTOCOL(mq->b_rptr) != npi->protocol){
-                               mqnext = &mq->b_next;
-                               continue;
-                           }
-                           *mqnext = mq->b_next;
-                           if (npi->mode == NPMODE_PASS) {
-                               putq(q, mq); /* q it for service routine */
-                           } else {
-                               freemsg(mq);
-                           }
-                       }
-                       p->pii_npq_tail = mqnext;
-                   }
-                   p->pii_npmode[npix] = npi->mode;
-                   i->ioc_count = 0;
-               } else
-                   npi->mode = p->pii_npmode[npix];
-               mp->b_datap->db_type = M_IOCACK;
-               qreply(q, mp);
-               break;
-           }
-           putnext(q, mp);
-           break;
-
-       default:                /* unknown IOCTL call */
-           putnext(q, mp);     /* pass it along */
-       }
-       break;
-
-    default:
-       putnext(q, mp); /* don't know what to do with this, so send it along*/
-    }
-}
-
-static int
-ppp_if_wsrv(q)
-    queue_t    *q;
-{
-    register mblk_t *mp;
-    register PII *p;
-
-    p = (PII *) q->q_ptr;
-
-    while ((mp = getq(q)) != NULL) {
-       /*
-        * we can only get M_DATA types into our Queue,
-        * due to our Put function
-        */
-       if (!canput(q->q_next)) {
-           putbq(q, mp);
-           return;
-       }
-
-       /* increment count of outgoing packets */
-       if (p != NULL)
-           INCR(ppp_opackets);
-
-       /* just pass it along, nothing to do in this direction */
-       putnext(q, mp);
-    }  /* end while */
-}
-
-
-static int
-ppp_if_rput(q, mp)
-    queue_t *q;
-    register mblk_t *mp;
-{
-    register PII       *p;
-
-    switch (mp->b_datap->db_type) {
-
-    case M_FLUSH:
-       if (*mp->b_rptr & FLUSHR)
-           flushq(q, FLUSHDATA);
-       putnext(q, mp);         /* send it along too */
-       break;
-
-    case M_DATA:
-       putq(q, mp);            /* queue it for my service routine */
-       break;
-
-    case M_CTL:
-       p = (PII *) q->q_ptr;
-       if (p != NULL) {
-           switch (*(u_char *) mp->b_rptr) {
-           case IF_INPUT_ERROR :
-               p->pii_ifnet.if_ierrors++;
-               INCR(ppp_ierrors);
-               DLOG("ppp_if: input error inc to %d\n",
-                    p->pii_ifnet.if_ierrors);
-               break;
-           case IF_OUTPUT_ERROR :
-               p->pii_ifnet.if_oerrors++;
-               INCR(ppp_oerrors);
-               DLOG("ppp_if: output error inc to %d\n",
-                    p->pii_ifnet.if_oerrors);
-               break;
-            case IF_CSTATS:
-                bcopy(mp->b_rptr + sizeof(u_long), &p->pii_cstats,
-                      sizeof(struct ppp_comp_stats));
-                freemsg(mp);
-                break;
-            default:
-                putnext(q, mp);         /* send it up to pppd */
-                break;
-            }
-       }
-       break;
-
-    default:
-       putnext(q, mp);         /* send along other message types */
-    }
-}
-
-static int
-ppp_if_rsrv(q)
-    queue_t    *q;
-{
-    register mblk_t *mp,*m0;
-#ifdef VJC
-    register mblk_t *mvjc;
-    unsigned char *cp, *iphdr;
-    u_int hlen;
-#endif
-    register PII *p;
-    struct mbuf        *mb1, *mb2, *mbtail;
-    struct ifnet       *ifp;
-    int        len, xlen, count, s, pklen;
-    u_char *rptr;
-    int address, control;
-    int dlen;
-
-    p = (PII *) q->q_ptr;
-
-    while ((mp = getq(q)) != NULL) {
-       /*
-        * we can only get M_DATA types into our Queue,
-        * due to our Put function
-        */
-
-       if (p == NULL) {
-           if (!canput(q->q_next)) {
-               putbq(q, mp);
-               return;
-           }
-           putnext(q, mp);
-           continue;
-       }
-
-       len = msgdsize(mp);
-        dlen = len - PPP_HDRLEN;
-#ifdef PPP_STATS
-       p->pii_stats.ppp_ibytes += len;
-#endif
-
-       /* make sure ppp_header is completely in first block */
-       if (mp->b_wptr - mp->b_rptr < PPP_HDRLEN
-           && !pullupmsg(mp, PPP_HDRLEN)) {
-           DLOG("pullupmsg failed!\n", 0);
-           freemsg(mp);
-           p->pii_ifnet.if_ierrors++;
-           continue;
-       }
-       m0 = mp;        /* remember first message block */
-
-#ifdef VJC
-       switch (PPP_PROTOCOL(mp->b_rptr)) {
-       case PPP_VJC_COMP :
-           if ((p->pii_flags & PII_FLAGS_VJC_REJ)
-               || p->pii_npmode[NP_IP] != NPMODE_PASS) {
-               DLOG("VJC rejected\n", 0);
-               freemsg(mp);
-               continue;                               
-           }
-           address = PPP_ADDRESS(mp->b_rptr);
-           control = PPP_CONTROL(mp->b_rptr);
-           mp->b_rptr += PPP_HDRLEN;
-           len -= PPP_HDRLEN;
-
-           /*
-            * Make sure the VJ header is in one message block.
-            */
-           xlen = MIN(len, MAX_VJHDR);
-           if (mp->b_rptr + xlen > mp->b_wptr && !pullupmsg(mp, xlen)) {
-               DLOG("pullupmsg vjc %d failed\n", xlen);
-               freemsg(mp);
-               continue;
-           }
-
-           /*
-            * Decompress it, then get a buffer and put the
-            * decompressed header in it.
-            */
-           xlen = vj_uncompress_tcp(mp->b_rptr, mp->b_wptr - mp->b_rptr,
-                                    len, &p->pii_sc_comp, &iphdr, &hlen);
-           if (xlen < 0) {
-               DLOG("ppp: vj_uncompress failed on type Compressed\n", 0);
-               freemsg(mp);
-               continue;
-           }
-           if (!(mvjc = allocb(hlen + PPP_HDRLEN, BPRI_MED))) {
-               DLOG("allocb mvjc failed (%d)\n", hlen + PPP_HDRLEN);
-               freemsg(mp);
-               continue;
-           }
-           dlen = len - xlen + hlen;
-           cp = mvjc->b_rptr;
-           cp[0] = address;
-           cp[1] = control;
-           cp[2] = 0;
-           cp[3] = PPP_IP;
-           bcopy(iphdr, cp + PPP_HDRLEN, hlen);
-           mvjc->b_wptr = cp + PPP_HDRLEN + hlen;
-           mvjc->b_cont = mp;
-           mp->b_rptr += xlen;
-           m0 = mp = mvjc;
-           break;
-
-       case PPP_VJC_UNCOMP :
-           if ((p->pii_flags & PII_FLAGS_VJC_REJ)
-               || p->pii_npmode[NP_IP] != NPMODE_PASS) {
-               DLOG("VJU rejected\n", 0);
-               freemsg(mp);
-               continue;
-           }
-
-           /*
-            * Make sure the IP header is in one message block.
-            */
-           xlen = MIN(len, MAX_IPHDR + PPP_HDRLEN);
-           if (mp->b_rptr + xlen > mp->b_wptr && !pullupmsg(mp, xlen)) {
-               DLOG("pullupmsg vju %d failed\n", xlen);
-               freemsg(mp);
-               continue;
-           }
-
-           /*
-            * "Uncompress" it.  Basically this just copies information
-            * into p->pii_sc_comp and restores the protocol field of
-            * the IP header.
-            */
-           if (!vj_uncompress_uncomp(mp->b_rptr + PPP_HDRLEN,
-                                     &p->pii_sc_comp)) {
-               DLOG("ppp: vj_uncompress failed on type Uncompresed\n", 0);
-               freemsg(mp);
-               continue;
-           }
-           mp->b_rptr[3] = PPP_IP;
-           break;
-       }
-#endif
-
-       switch (PPP_PROTOCOL(mp->b_rptr)) {
-       default:
-           if (!canput(q->q_next)) {
-               putbq(q, mp);
-               return;
-           }
-           INCR(ppp_ipackets);
-           p->pii_ifnet.if_ipackets++;
-           putnext(q, mp);
-           continue;
-
-       case PPP_IP:
-           /*
-            * Don't let packets through until IPCP is up.
-            */
-           INCR(ppp_ipackets);
-           p->pii_ifnet.if_ipackets++;
-
-           if (!(p->pii_ifnet.if_flags & IFF_UP)
-               || p->pii_npmode[NP_IP] != NPMODE_PASS) {
-               DLOG("pkt ignored - IP down\n", 0);
-               freemsg(mp);
-               continue;
-           }
-
-           /*
-            * Get the first mbuf and put the struct ifnet * in.
-            */
-           MGETHDR(mb1, M_DONTWAIT, MT_DATA);
-           mb1->m_len = 0;
-           if (mb1 == NULL) {
-               p->pii_ifnet.if_ierrors++;
-               freemsg(m0);
-               continue;
-           }
-           len = MHLEN;
-            mb1->m_pkthdr.rcvif = &(p->pii_ifnet);
-            mb1->m_pkthdr.len = dlen;
-           mbtail = mb2 = mb1;
-           mb1->m_len = 0;
-
-           rptr = mp->b_rptr + PPP_HDRLEN;
-           xlen = mp->b_wptr - rptr;
-           for(;;) {
-               if (xlen == 0) {        /* move to the next mblk */
-                   mp = mp->b_cont;
-                   if (mp == NULL)
-                       break;
-                   xlen = mp->b_wptr - (rptr = mp->b_rptr);
-                   continue;
-               }
-               if (len == 0) {
-                   MGET(mb2, M_DONTWAIT, MT_DATA);
-                   if (!mb2) {
-                       /* if we couldn't get a buffer, drop the packet */
-                       p->pii_ifnet.if_ierrors++;
-                       m_freem(mb1);   /* discard what we've used already */
-                       mb1 = NULL;
-                       break;
-                   }
-                   len = MLEN;
-                   mb2->m_len = 0;
-                   mbtail->m_next = mb2;
-                   mbtail = mb2;
-               }
-               count = MIN(xlen, len);
-               bcopy((char *) rptr, mtod(mb2, char *) + mb2->m_len, count);
-               rptr += count;
-               len -= count;
-               xlen -= count;
-               mb2->m_len += count;
-           }
-
-           freemsg(m0);
-           if (mb1 == NULL)
-               continue;
-
-#ifdef PPP_SNIT
-           if (p->pii_ifnet.if_flags & IFF_PROMISC) {
-               struct mbuf *m = mb1;
-
-               len = 0;
-               do {
-                   len += m->m_len;
-               } while (m = m->m_next);
-               nif.nif_bodylen = len - sizeof(struct ifnet *);
-               mb1->m_off += sizeof(struct ifnet *);
-               snit_intr(&p->pii_ifnet, mb1, &nif);
-               mb1->m_off -= sizeof(struct ifnet *);
-           }
-#endif
-/*
-           if (IF_QFULL(&ipintrq)) {
-               IF_DROP(&ipintrq);
-               p->pii_ifnet.if_ierrors++;
-               m_freem(mb1);
-           }
-           else {
-*/
-            find_input_type(0x0800, mb1, ifp, 0);
-       }
-    }  /* end while */
-}
-
-/* ifp output procedure */
-int
-ppp_output(ifp, m0, dst)
-    struct ifnet *ifp;
-    struct mbuf *m0;
-    struct sockaddr *dst;
-{
-    register PII *p = &pii[ifp->if_unit];
-    struct mbuf        *m1;
-    int        error, s, len;
-    u_short protocol;
-#ifdef VJC
-    int        type;
-    u_char *vjhdr;
-#endif
-    mblk_t *mp;
-    enum NPmode npmode;
-
-    error = 0;
-    if (!(ifp->if_flags & IFF_UP)) {
-       error = ENETDOWN;
-       goto getout;
-    }
-
-    switch (dst->sa_family) {
-#ifdef INET
-    case AF_INET:
-#ifdef PPP_SNIT
-       if (ifp->if_flags & IFF_PROMISC) {
-           struct mbuf *m = m0;
-
-           len = 0;
-           do {
-               len += m->m_len;
-           } while (m = m->m_next);
-           nif.nif_bodylen = len;
-           snit_intr(ifp, m0, &nif);
-       }
-#endif
-       protocol = PPP_IP;
-       npmode = p->pii_npmode[NP_IP];
-       break;
-#endif
-
-    default:
-       DLOG("ppp: af%d not supported\n", dst->sa_family);
-       error = EAFNOSUPPORT;
-       goto getout;
-    }
-
-    if (!p->pii_writeq) {
-       DLOG("ppp_if%d: no queue\n", p - pii);
-       error = EHOSTUNREACH;
-       goto getout;
-    }
-
-    switch (npmode) {
-    case NPMODE_DROP:
-       goto getout;
-    case NPMODE_ERROR:
-       error = ENETDOWN;
-       goto getout;
-    }
-
-#ifdef VJC
-    if ((protocol == PPP_IP) && (p->pii_flags & PII_FLAGS_VJC_ON)) {
-       register struct ip *ip;
-       ip = mtod(m0, struct ip *);
-       if (ip->ip_p == IPPROTO_TCP) {
-           type = vj_compress_tcp(ip, m0->m_len, &p->pii_sc_comp,
-                                  !(p->pii_flags & PII_FLAGS_VJC_NOCCID),
-                                  &vjhdr);
-           switch (type) {
-           case TYPE_UNCOMPRESSED_TCP :
-               protocol = PPP_VJC_UNCOMP;
-               break;
-           case TYPE_COMPRESSED_TCP :
-               protocol = PPP_VJC_COMP;
-               len = vjhdr - (u_char *) ip;
-               m0->m_data += len;
-               m0->m_len -= len;
-               break;  
-           }
-       }
-    }
-#endif
-
-    len = PPP_HDRLEN;
-    for (m1 = m0; m1; m1 = m1->m_next) 
-       len += m1->m_len;
-
-    if (!(mp = allocb(len, BPRI_MED))) {
-       DLOG("ppp_if%d: allocb failed\n", p - pii);
-       error = ENOBUFS;
-       goto getout;
-    }
-
-#ifdef PPP_STATS
-    p->pii_stats.ppp_obytes += len;
-#endif
-
-    *mp->b_wptr++ = PPP_ALLSTATIONS;
-    *mp->b_wptr++ = PPP_UI;
-    *mp->b_wptr++ = 0;
-    *mp->b_wptr++ = protocol;
-    for (m1 = m0; m1; m1 = m1->m_next) {       /* copy all data */
-       bcopy(mtod(m1, char *), (char *) mp->b_wptr, m1->m_len);
-       mp->b_wptr += m1->m_len;
-    }
-
-    p->pii_ifnet.if_opackets++;
-DLOG("ppp_output npmode is %d\n",npmode);
-    if (npmode == NPMODE_PASS) {
-       putq(p->pii_writeq, mp);
-    } else {
-       mp->b_next = NULL;
-       *p->pii_npq_tail = mp;
-       p->pii_npq_tail = &mp;
-    }
-
- getout:
-    m_freem(m0);
-    if (error) {
-       INCR(ppp_oerrors);
-       p->pii_ifnet.if_oerrors++;
-    }
-    return (error);
-}
-
-/*
- * if_ ioctl requests 
-*/
-ppp_ioctl(ifp, cmd, data)
-    register struct ifnet *ifp;
-    unsigned int       cmd;
-    caddr_t    data;
-{
-    register struct ifaddr *ifa = (struct ifaddr *) data;
-    register struct ifreq *ifr = (struct ifreq *) data;
-    struct ppp_stats *psp;
-    struct ppp_comp_stats *pcp;
-    PII *p;
-    queue_t *q;
-    int        error = 0;
-
-    switch (cmd) {
-    case SIOCSIFFLAGS :
-       /* This happens every time IFF_PROMISC has been changed. */
-       if (!ifr)
-           break;
-       if (!suser()) {
-           error = EPERM;
-           break;
-       }
-
-       /* clear the flags that can be cleared */
-       ifp->if_flags &= (IFF_CANTCHANGE);      
-       /* or in the flags that can be changed */
-       ifp->if_flags |= (ifr->ifr_flags & ~IFF_CANTCHANGE);
-       break;
-
-    case SIOCGIFFLAGS :
-       ifr->ifr_flags = ifp->if_flags;
-       break;
-
-    case SIOCSIFADDR :
-       if( ifa->ifa_addr->sa_family != AF_INET) 
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFDSTADDR :
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFMTU :
-       if (!suser()) {
-           error = EPERM;
-           break;
-       }
-       if (ifr->ifr_mtu > MAX_PKTSIZE - PPP_FRAMING) {
-           error = EINVAL;
-           break;
-       }
-       ifp->if_mtu = ifr->ifr_mtu;
-       break;
-
-    case SIOCGIFMTU :
-       ifr->ifr_mtu = ifp->if_mtu;
-       break;
-
-    case SIOCGPPPSTATS:
-       p = &pii[ifp->if_unit];
-       psp = (struct ppp_stats *) &((struct ifpppstatsreq *)data)->stats;
-       bzero(psp, sizeof(struct ppp_stats));
-#ifdef PPP_STATS
-       psp->p = p->pii_stats;
-#endif
-#if defined(VJC) && !defined(VJ_NO_STATS)
-       psp->vj = p->pii_sc_comp.stats;
-#endif
-       break;
-
-    case SIOCGPPPCSTATS:
-        p = &pii[ifp->if_unit];
-        bzero(&p->pii_cstats, sizeof(struct ppp_comp_stats));
-
-        /* Make a message to send on the interface's write stream */
-        q = p->pii_writeq;
-        if (q != NULL) {
-            putctl1(q, M_CTL, IF_GET_CSTATS);
-            /*
-             * We assume the message gets passed along immediately, so
-             * by the time the putctl1 returns, the request has been
-             * processed, the values returned and p->pii_cstats has
-             * been updated.  If not, we just get zeroes.
-             */
-        }
-        pcp = (struct ppp_comp_stats *)&((struct ifpppcstatsreq *)data)->stats;
-        bcopy(&p->pii_cstats, pcp, sizeof(struct ppp_comp_stats));
-        break;
-
-    default:
-        error = EINVAL;
-        break;
-    }
-
-    return(error);
-}
-
-#endif
diff --git a/aix4/ppp_if.exp b/aix4/ppp_if.exp
deleted file mode 100644 (file)
index 7f2de25..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp_load
diff --git a/chat/Makefile.NeXT b/chat/Makefile.NeXT
deleted file mode 100644 (file)
index 4cf9741..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Makefile for chat on NeXTs
-# 
-# $Id: Makefile.NeXT,v 1.4 1998/03/25 03:18:32 paulus Exp $
-#
-
-ARCHFLAGS = 
-BINDIR = /usr/local/ppp/bin
-MANDIR = /usr/local/ppp/man
-
-CFLAGS=        -O -D_POSIX_SOURCE $(ARCHFLAGS)
-
-SRCS =  chat.c
-OBJS =  chat.o
-LIBS =   ../NeXT/libposix/libposix.o
-
-MANPAGES = chat.8
-
-
-#
-# Load dependencies
-#
-all:   chat
-
-chat:  $(OBJS)
-       $(CC) -o chat $(CFLAGS) $(OBJS) $(LIBS)
-
-install:
-       /bin/mkdirs $(MANDIR)/man8 $(BINDIR) 
-       install -c -s -m 555 -o root -g wheel chat $(BINDIR)/chat
-       install -c -m 444 -o root -g wheel chat.8 $(MANDIR)/man8
-
-clean:
-       rm -f *~ *.o chat
-
diff --git a/chat/Makefile.aix4 b/chat/Makefile.aix4
deleted file mode 100644 (file)
index 8280699..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Makefile for chat on AIX 4.1
-#
-
-#ifndef BINDIR
-BINDIR=/usr/sbin
-#endif
-
-CC=xlc
-CFLAGS= -D_NO_PROTO
-
-all:   chat
-
-chat: chat.o
-       $(CC) -o chat chat.o
-
-install:
-       install -f $(BINDIR) chat
-
-clean:
-       rm -f *~ *.o chat
diff --git a/chat/Makefile.bsd b/chat/Makefile.bsd
deleted file mode 100644 (file)
index 5006338..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#      $Id: Makefile.bsd,v 1.4 1996/10/08 04:37:59 paulus Exp $
-
-PROG=  chat
-SRCS=  chat.c
-MAN8=  chat.8
-MAN=   chat.cat8
-BINDIR=        /usr/sbin
-
-.include <bsd.prog.mk>
diff --git a/chat/Makefile.netbsd-1.2 b/chat/Makefile.netbsd-1.2
deleted file mode 100644 (file)
index 21af9bb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#      $Id: Makefile.netbsd-1.2,v 1.1 1997/04/30 05:40:28 paulus Exp $
-
-PROG=  chat
-SRCS=  chat.c
-MAN8=  chat.8
-MAN=   chat.cat8
-BINDIR=        /usr/sbin
-
-.include <bsd.prog.mk>
diff --git a/chat/Makefile.osf b/chat/Makefile.osf
deleted file mode 100644 (file)
index 9b0d747..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Makefile for chat on OSF/1
-#
-
-all:   chat
-
-chat: chat.o
-       $(CC) -o chat chat.o
-
-install: chat
-       installbsd -c chat $(BINDIR)/chat
-       installbsd -c -m 444 chat.8 $(MANDIR)/man8/chat.8
-
-clean:
-       rm -f *~ *.o chat
diff --git a/chat/Makefile.sunos4 b/chat/Makefile.sunos4
deleted file mode 100644 (file)
index b350736..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for chat on suns
-#
-
-include ../sunos4/Makedefs
-
-CFLAGS = -DSUNOS $(COPTS)
-
-all:   chat
-
-chat: chat.o
-       $(CC) -o chat chat.o
-
-install: chat
-       $(INSTALL) -c chat $(BINDIR)/chat
-       $(INSTALL) -c -m 444 chat.8 $(MANDIR)/man8/chat.8
-
-clean:
-       rm -f *~ *.o chat
diff --git a/chat/Makefile.svr4 b/chat/Makefile.svr4
deleted file mode 100644 (file)
index 2726c93..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for chat on Solaris 2
-#
-
-include ../svr4/Makedefs
-
-CFLAGS = -DNO_USLEEP $(COPTS)
-
-all:   chat
-
-chat: chat.o
-       $(CC) -o chat chat.o
-
-install: chat
-       $(INSTALL) -f $(BINDIR) chat
-       $(INSTALL) -m 444 -f $(MANDIR)/man8 chat.8
-
-clean:
-       rm -f *~ *.o chat
diff --git a/chat/Makefile.ultrix b/chat/Makefile.ultrix
deleted file mode 100644 (file)
index a5d2b1f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Makefile for chat with ultrix
-#
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-
-CFLAGS = -DNO_USLEEP
-
-all:   chat
-
-chat: chat.o
-       $(CC) -o chat chat.o
-
-install: chat
-       install -c chat $(BINDIR)/chat
-       install -c -m 444 chat.8 $(MANDIR)/man8/chat.8
-
-clean:
-       rm -f *~ *.o chat
diff --git a/freebsd-2.0/Makefile.top b/freebsd-2.0/Makefile.top
deleted file mode 100644 (file)
index 4f1ea08..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# ppp top level makefile for *bsd systems
-#
-
-BINDIR?= /usr/sbin
-
-SUBDIR=        chat pppd pppstats
-MAKE+=  BINDIR=$(BINDIR)
-
-kernel:
-       @sh -e freebsd-2.0/kinstall.sh
-
-.include <bsd.subdir.mk>
diff --git a/freebsd-2.0/files-2.2.patch b/freebsd-2.0/files-2.2.patch
deleted file mode 100644 (file)
index 4ce538b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-*** files.orig Wed Dec 14 13:11:12 1994
---- files      Wed Dec 14 13:13:56 1994
-***************
-*** 141,146 ****
---- 141,148 ----
-  net/if_ppp.c         optional ppp
-  net/ppp_tty.c                optional ppp
-  net/bsd-comp.c               optional ppp
-+ net/ppp-deflate.c    optional ppp
-+ net/zlib.c           optional ppp
-  net/if_sl.c          optional sl
-  net/pppcompress.c    optional ppp
-  net/radix.c          standard
diff --git a/freebsd-2.0/files.patch b/freebsd-2.0/files.patch
deleted file mode 100644 (file)
index b9e9f68..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-*** files.orig Wed Dec 14 13:11:12 1994
---- files      Wed Dec 14 13:13:56 1994
-***************
-*** 139,144 ****
---- 139,148 ----
-  net/if_ethersubr.c   optional ether
-  net/if_loop.c                optional loop
-  net/if_ppp.c         optional ppp
-+ net/ppp_tty.c                optional ppp
-+ net/bsd-comp.c               optional ppp
-+ net/ppp-deflate.c    optional ppp
-+ net/zlib.c           optional ppp
-  net/if_sl.c          optional sl
-  net/pppcompress.c    optional ppp
-  net/radix.c          standard
diff --git a/freebsd-2.0/if_ppp.c b/freebsd-2.0/if_ppp.c
deleted file mode 100644 (file)
index ad3243b..0000000
+++ /dev/null
@@ -1,1527 +0,0 @@
-/*
- * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a collision if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- */
-
-/* $Id: if_ppp.c,v 1.15 2002/12/06 09:49:15 paulus Exp $ */
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/kernel.h>
-#include <sys/time.h>
-#include <sys/malloc.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/netisr.h>
-#include <net/route.h>
-#ifdef PPP_FILTER
-#include <net/bpf.h>
-#endif
-
-#if INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#endif
-
-#include "bpfilter.h"
-#if NBPFILTER > 0
-#include <net/bpf.h>
-#endif
-
-#ifdef VJC
-#include <net/pppcompress.h>
-#endif
-
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/if_pppvar.h>
-#include <machine/cpu.h>
-
-#define splsoftnet     splnet
-
-#ifndef NETISR_PPP
-/* This definition should be moved to net/netisr.h */
-#define NETISR_PPP     26      /* PPP software interrupt */
-#endif
-
-#ifdef PPP_COMPRESS
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-#endif
-
-static int     pppsioctl __P((struct ifnet *, int, caddr_t));
-static void    ppp_requeue __P((struct ppp_softc *));
-static void    ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
-static void    ppp_ccp_closed __P((struct ppp_softc *));
-static void    ppp_inproc __P((struct ppp_softc *, struct mbuf *));
-static void    pppdumpm __P((struct mbuf *m0));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m)        ((m)->m_flags & M_EXT)
-
-#define M_DATASTART(m) \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
-           (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
-           (m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
-
-/*
- * We steal two bits in the mbuf m_flags, to mark high-priority packets
- * for output, and received packets following lost/corrupted packets.
- */
-#define M_HIGHPRI      0x2000  /* output packet for sc_fastq */
-#define M_ERRMARK      0x4000  /* steal a bit in mbuf m_flags */
-
-
-#ifdef PPP_COMPRESS
-/*
- * List of compressors we know about.
- * We leave some space so maybe we can modload compressors.
- */
-
-extern struct compressor ppp_bsd_compress;
-extern struct compressor ppp_deflate, ppp_deflate_draft;
-
-struct compressor *ppp_compressors[8] = {
-#if DO_BSD_COMPRESS
-    &ppp_bsd_compress,
-#endif
-#if DO_DEFLATE
-    &ppp_deflate,
-    &ppp_deflate_draft,
-#endif
-    NULL
-};
-#endif /* PPP_COMPRESS */
-
-TEXT_SET(pseudo_set, pppattach);
-
-/*
- * Called from boot code to establish ppp interfaces.
- */
-void
-pppattach()
-{
-    register struct ppp_softc *sc;
-    register int i = 0;
-    extern void (*netisrs[])__P((void));
-
-    for (sc = ppp_softc; i < NPPP; sc++) {
-       sc->sc_if.if_name = "ppp";
-       sc->sc_if.if_unit = i++;
-       sc->sc_if.if_mtu = PPP_MTU;
-       sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
-       sc->sc_if.if_type = IFT_PPP;
-       sc->sc_if.if_hdrlen = PPP_HDRLEN;
-       sc->sc_if.if_ioctl = pppsioctl;
-       sc->sc_if.if_output = pppoutput;
-       sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
-       if_attach(&sc->sc_if);
-#if NBPFILTER > 0
-       bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
-#endif
-    }
-    netisrs[NETISR_PPP] = pppintr;
-}
-
-/*
- * Allocate a ppp interface unit and initialize it.
- */
-struct ppp_softc *
-pppalloc(pid)
-    pid_t pid;
-{
-    int nppp, i;
-    struct ppp_softc *sc;
-
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_xfer == pid) {
-           sc->sc_xfer = 0;
-           return sc;
-       }
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_devp == NULL)
-           break;
-    if (nppp >= NPPP)
-       return NULL;
-
-    sc->sc_flags = 0;
-    sc->sc_mru = PPP_MRU;
-    sc->sc_relinq = NULL;
-    bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
-#ifdef VJC
-    MALLOC(sc->sc_comp, struct vjcompress *, sizeof(struct vjcompress),
-          M_DEVBUF, M_NOWAIT);
-    if (sc->sc_comp)
-       vj_compress_init(sc->sc_comp, -1);
-#endif
-#ifdef PPP_COMPRESS
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-    for (i = 0; i < NUM_NP; ++i)
-       sc->sc_npmode[i] = NPMODE_ERROR;
-    sc->sc_npqueue = NULL;
-    sc->sc_npqtail = &sc->sc_npqueue;
-    sc->sc_last_sent = sc->sc_last_recv = time.tv_sec;
-
-    return sc;
-}
-
-/*
- * Deallocate a ppp unit.  Must be called at splsoftnet or higher.
- */
-void
-pppdealloc(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m;
-
-    if_down(&sc->sc_if);
-    sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
-    sc->sc_devp = NULL;
-    sc->sc_xfer = 0;
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_rawq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_inq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_fastq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    while ((m = sc->sc_npqueue) != NULL) {
-       sc->sc_npqueue = m->m_nextpkt;
-       m_freem(m);
-    }
-    if (sc->sc_togo != NULL) {
-       m_freem(sc->sc_togo);
-       sc->sc_togo = NULL;
-    }
-#ifdef PPP_COMPRESS
-    ppp_ccp_closed(sc);
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-#ifdef PPP_FILTER
-    if (sc->sc_pass_filt.bf_insns != 0) {
-       FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF);
-       sc->sc_pass_filt.bf_insns = 0;
-       sc->sc_pass_filt.bf_len = 0;
-    }
-    if (sc->sc_active_filt.bf_insns != 0) {
-       FREE(sc->sc_active_filt.bf_insns, M_DEVBUF);
-       sc->sc_active_filt.bf_insns = 0;
-       sc->sc_active_filt.bf_len = 0;
-    }
-#endif /* PPP_FILTER */
-#ifdef VJC
-    if (sc->sc_comp != 0) {
-       FREE(sc->sc_comp, M_DEVBUF);
-       sc->sc_comp = 0;
-    }
-#endif
-}
-
-/*
- * Ioctl routine for generic ppp devices.
- */
-int
-pppioctl(sc, cmd, data, flag, p)
-    struct ppp_softc *sc;
-    int cmd;
-    caddr_t data;
-    int flag;
-    struct proc *p;
-{
-    int s, error, flags, mru, nb, npx;
-    struct ppp_option_data *odp;
-    struct compressor **cp;
-    struct npioctl *npi;
-    time_t t;
-#ifdef PPP_FILTER
-    struct bpf_program *bp, *nbp;
-    struct bpf_insn *newcode, *oldcode;
-    int newcodelen;
-#endif /* PPP_FILTER */
-#ifdef PPP_COMPRESS
-    u_char ccp_option[CCP_MAX_OPTION_LENGTH];
-#endif
-
-    switch (cmd) {
-    case FIONREAD:
-       *(int *)data = sc->sc_inq.ifq_len;
-       break;
-
-    case PPPIOCGUNIT:
-       *(int *)data = sc->sc_if.if_unit;
-       break;
-
-    case PPPIOCGFLAGS:
-       *(u_int *)data = sc->sc_flags;
-       break;
-
-    case PPPIOCSFLAGS:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       flags = *(int *)data & SC_MASK;
-       s = splsoftnet();
-#ifdef PPP_COMPRESS
-       if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN))
-           ppp_ccp_closed(sc);
-#endif
-       splimp();
-       sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags;
-       splx(s);
-       break;
-
-    case PPPIOCSMRU:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       mru = *(int *)data;
-       if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
-           sc->sc_mru = mru;
-       break;
-
-    case PPPIOCGMRU:
-       *(int *)data = sc->sc_mru;
-       break;
-
-#ifdef VJC
-    case PPPIOCSMAXCID:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       if (sc->sc_comp) {
-           s = splsoftnet();
-           vj_compress_init(sc->sc_comp, *(int *)data);
-           splx(s);
-       }
-       break;
-#endif
-
-    case PPPIOCXFERUNIT:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       sc->sc_xfer = p->p_pid;
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPPIOCSCOMPRESS:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       odp = (struct ppp_option_data *) data;
-       nb = odp->length;
-       if (nb > sizeof(ccp_option))
-           nb = sizeof(ccp_option);
-       if ((error = copyin(odp->ptr, ccp_option, nb)) != 0)
-           return (error);
-       if (ccp_option[1] < 2)  /* preliminary check on the length byte */
-           return (EINVAL);
-       for (cp = ppp_compressors; *cp != NULL; ++cp)
-           if ((*cp)->compress_proto == ccp_option[0]) {
-               /*
-                * Found a handler for the protocol - try to allocate
-                * a compressor or decompressor.
-                */
-               error = 0;
-               if (odp->transmit) {
-                   s = splsoftnet();
-                   if (sc->sc_xc_state != NULL)
-                       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-                   sc->sc_xcomp = *cp;
-                   sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
-                   if (sc->sc_xc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("ppp%d: comp_alloc failed\n",
-                              sc->sc_if.if_unit);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_COMP_RUN;
-                   splx(s);
-               } else {
-                   s = splsoftnet();
-                   if (sc->sc_rc_state != NULL)
-                       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-                   sc->sc_rcomp = *cp;
-                   sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
-                   if (sc->sc_rc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("ppp%d: decomp_alloc failed\n",
-                              sc->sc_if.if_unit);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_DECOMP_RUN;
-                   splx(s);
-               }
-               return (error);
-           }
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: no compressor for [%x %x %x], %x\n",
-                  sc->sc_if.if_unit, ccp_option[0], ccp_option[1],
-                  ccp_option[2], nb);
-       return (EINVAL);        /* no handler found */
-#endif /* PPP_COMPRESS */
-
-    case PPPIOCGNPMODE:
-    case PPPIOCSNPMODE:
-       npi = (struct npioctl *) data;
-       switch (npi->protocol) {
-       case PPP_IP:
-           npx = NP_IP;
-           break;
-       default:
-           return EINVAL;
-       }
-       if (cmd == PPPIOCGNPMODE) {
-           npi->mode = sc->sc_npmode[npx];
-       } else {
-           if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-               return (error);
-           if (npi->mode != sc->sc_npmode[npx]) {
-               s = splsoftnet();
-               sc->sc_npmode[npx] = npi->mode;
-               if (npi->mode != NPMODE_QUEUE) {
-                   ppp_requeue(sc);
-                   (*sc->sc_start)(sc);
-               }
-               splx(s);
-           }
-       }
-       break;
-
-    case PPPIOCGIDLE:
-       s = splsoftnet();
-       t = time.tv_sec;
-       ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
-       ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
-       splx(s);
-       break;
-
-#ifdef PPP_FILTER
-    case PPPIOCSPASS:
-    case PPPIOCSACTIVE:
-       nbp = (struct bpf_program *) data;
-       if ((unsigned) nbp->bf_len > BPF_MAXINSNS)
-           return EINVAL;
-       newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
-       if (newcodelen != 0) {
-           MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK);
-           if (newcode == 0) {
-               return EINVAL;          /* or sumpin */
-           }
-           if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode,
-                              newcodelen)) != 0) {
-               FREE(newcode, M_DEVBUF);
-               return error;
-           }
-           if (!bpf_validate(newcode, nbp->bf_len)) {
-               FREE(newcode, M_DEVBUF);
-               return EINVAL;
-           }
-       } else
-           newcode = 0;
-       bp = (cmd == PPPIOCSPASS)? &sc->sc_pass_filt: &sc->sc_active_filt;
-       oldcode = bp->bf_insns;
-       s = splimp();
-       bp->bf_len = nbp->bf_len;
-       bp->bf_insns = newcode;
-       splx(s);
-       if (oldcode != 0)
-           FREE(oldcode, M_DEVBUF);
-       break;
-#endif
-
-    default:
-       return (-1);
-    }
-    return (0);
-}
-
-/*
- * Process an ioctl request to the ppp network interface.
- */
-static int
-pppsioctl(ifp, cmd, data)
-    register struct ifnet *ifp;
-    int cmd;
-    caddr_t data;
-{
-    struct proc *p = curproc;  /* XXX */
-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
-    register struct ifaddr *ifa = (struct ifaddr *)data;
-    register struct ifreq *ifr = (struct ifreq *)data;
-    struct ppp_stats *psp;
-#ifdef PPP_COMPRESS
-    struct ppp_comp_stats *pcp;
-#endif
-    int s = splimp(), error = 0;
-
-    switch (cmd) {
-    case SIOCSIFFLAGS:
-       if ((ifp->if_flags & IFF_RUNNING) == 0)
-           ifp->if_flags &= ~IFF_UP;
-       break;
-
-    case SIOCSIFADDR:
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFDSTADDR:
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFMTU:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_if.if_mtu = ifr->ifr_mtu;
-       break;
-
-    case SIOCGIFMTU:
-       ifr->ifr_mtu = sc->sc_if.if_mtu;
-       break;
-
-    case SIOCADDMULTI:
-    case SIOCDELMULTI:
-       if (ifr == 0) {
-           error = EAFNOSUPPORT;
-           break;
-       }
-       switch(ifr->ifr_addr.sa_family) {
-#ifdef INET
-       case AF_INET:
-           break;
-#endif
-       default:
-           error = EAFNOSUPPORT;
-           break;
-       }
-       break;
-
-    case SIOCGPPPSTATS:
-       psp = &((struct ifpppstatsreq *) data)->stats;
-       bzero(psp, sizeof(*psp));
-       psp->p = sc->sc_stats;
-#if defined(VJC) && !defined(SL_NO_STATS)
-       if (sc->sc_comp) {
-           psp->vj.vjs_packets = sc->sc_comp->sls_packets;
-           psp->vj.vjs_compressed = sc->sc_comp->sls_compressed;
-           psp->vj.vjs_searches = sc->sc_comp->sls_searches;
-           psp->vj.vjs_misses = sc->sc_comp->sls_misses;
-           psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin;
-           psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin;
-           psp->vj.vjs_errorin = sc->sc_comp->sls_errorin;
-           psp->vj.vjs_tossed = sc->sc_comp->sls_tossed;
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case SIOCGPPPCSTATS:
-       pcp = &((struct ifpppcstatsreq *) data)->stats;
-       bzero(pcp, sizeof(*pcp));
-       if (sc->sc_xc_state != NULL)
-           (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c);
-       if (sc->sc_rc_state != NULL)
-           (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d);
-       break;
-#endif /* PPP_COMPRESS */
-
-    default:
-       error = EINVAL;
-    }
-    splx(s);
-    return (error);
-}
-
-/*
- * Queue a packet.  Start transmission if not active.
- * Packet is placed in Information field of PPP frame.
- */
-int
-pppoutput(ifp, m0, dst, rtp)
-    struct ifnet *ifp;
-    struct mbuf *m0;
-    struct sockaddr *dst;
-    struct rtentry *rtp;
-{
-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
-    int protocol, address, control;
-    u_char *cp;
-    int s, error;
-    struct ip *ip;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-    int len;
-    struct mbuf *m;
-
-    if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
-       || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
-       error = ENETDOWN;       /* sort of */
-       goto bad;
-    }
-
-    /*
-     * Compute PPP header.
-     */
-    m0->m_flags &= ~M_HIGHPRI;
-    switch (dst->sa_family) {
-#ifdef INET
-    case AF_INET:
-       address = PPP_ALLSTATIONS;
-       control = PPP_UI;
-       protocol = PPP_IP;
-       mode = sc->sc_npmode[NP_IP];
-
-       /*
-        * If this packet has the "low delay" bit set in the IP header,
-        * put it on the fastq instead.
-        */
-       ip = mtod(m0, struct ip *);
-       if (ip->ip_tos & IPTOS_LOWDELAY)
-           m0->m_flags |= M_HIGHPRI;
-       break;
-#endif
-    case AF_UNSPEC:
-       address = PPP_ADDRESS(dst->sa_data);
-       control = PPP_CONTROL(dst->sa_data);
-       protocol = PPP_PROTOCOL(dst->sa_data);
-       mode = NPMODE_PASS;
-       break;
-    default:
-       printf("ppp%d: af%d not supported\n", ifp->if_unit, dst->sa_family);
-       error = EAFNOSUPPORT;
-       goto bad;
-    }
-
-    /*
-     * Drop this packet, or return an error, if necessary.
-     */
-    if (mode == NPMODE_ERROR) {
-       error = ENETDOWN;
-       goto bad;
-    }
-    if (mode == NPMODE_DROP) {
-       error = 0;
-       goto bad;
-    }
-
-    /*
-     * Add PPP header.  If no space in first mbuf, allocate another.
-     * (This assumes M_LEADINGSPACE is always 0 for a cluster mbuf.)
-     */
-    if (M_LEADINGSPACE(m0) < PPP_HDRLEN) {
-       m0 = m_prepend(m0, PPP_HDRLEN, M_DONTWAIT);
-       if (m0 == 0) {
-           error = ENOBUFS;
-           goto bad;
-       }
-       m0->m_len = 0;
-    } else
-       m0->m_data -= PPP_HDRLEN;
-
-    cp = mtod(m0, u_char *);
-    *cp++ = address;
-    *cp++ = control;
-    *cp++ = protocol >> 8;
-    *cp++ = protocol & 0xff;
-    m0->m_len += PPP_HDRLEN;
-
-    len = 0;
-    for (m = m0; m != 0; m = m->m_next)
-       len += m->m_len;
-
-    if (sc->sc_flags & SC_LOG_OUTPKT) {
-       printf("ppp%d output: ", ifp->if_unit);
-       pppdumpm(m0);
-    }
-
-    if ((protocol & 0x8000) == 0) {
-#ifdef PPP_FILTER
-       /*
-        * Apply the pass and active filters to the packet,
-        * but only if it is a data packet.
-        */
-       *mtod(m0, u_char *) = 1;        /* indicates outbound */
-       if (sc->sc_pass_filt.bf_insns != 0
-           && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m0,
-                         len, 0) == 0) {
-           error = 0;          /* drop this packet */
-           goto bad;
-       }
-
-       /*
-        * Update the time we sent the most recent packet.
-        */
-       if (sc->sc_active_filt.bf_insns == 0
-           || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
-           sc->sc_last_sent = time.tv_sec;
-
-       *mtod(m0, u_char *) = address;
-#else
-       /*
-        * Update the time we sent the most recent data packet.
-        */
-       sc->sc_last_sent = time.tv_sec;
-#endif /* PPP_FILTER */
-    }
-
-#if NBPFILTER > 0
-    /*
-     * See if bpf wants to look at the packet.
-     */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m0);
-#endif
-
-    /*
-     * Put the packet on the appropriate queue.
-     */
-    s = splsoftnet();
-    if (mode == NPMODE_QUEUE) {
-       /* XXX we should limit the number of packets on this queue */
-       *sc->sc_npqtail = m0;
-       m0->m_nextpkt = NULL;
-       sc->sc_npqtail = &m0->m_nextpkt;
-    } else {
-       ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
-       if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
-           IF_DROP(ifq);
-           splx(s);
-           sc->sc_if.if_oerrors++;
-           sc->sc_stats.ppp_oerrors++;
-           error = ENOBUFS;
-           goto bad;
-       }
-       IF_ENQUEUE(ifq, m0);
-       (*sc->sc_start)(sc);
-    }
-    ifp->if_lastchange = time;
-    ifp->if_opackets++;
-    ifp->if_obytes += len;
-
-    splx(s);
-    return (0);
-
-bad:
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * After a change in the NPmode for some NP, move packets from the
- * npqueue to the send queue or the fast queue as appropriate.
- * Should be called at splsoftnet.
- */
-static void
-ppp_requeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, **mpp;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-
-    for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) {
-       switch (PPP_PROTOCOL(mtod(m, u_char *))) {
-       case PPP_IP:
-           mode = sc->sc_npmode[NP_IP];
-           break;
-       default:
-           mode = NPMODE_PASS;
-       }
-
-       switch (mode) {
-       case NPMODE_PASS:
-           /*
-            * This packet can now go on one of the queues to be sent.
-            */
-           *mpp = m->m_nextpkt;
-           m->m_nextpkt = NULL;
-           ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd;
-           if (IF_QFULL(ifq)) {
-               IF_DROP(ifq);
-               sc->sc_if.if_oerrors++;
-               sc->sc_stats.ppp_oerrors++;
-           } else
-               IF_ENQUEUE(ifq, m);
-           break;
-
-       case NPMODE_DROP:
-       case NPMODE_ERROR:
-           *mpp = m->m_nextpkt;
-           m_freem(m);
-           break;
-
-       case NPMODE_QUEUE:
-           mpp = &m->m_nextpkt;
-           break;
-       }
-    }
-    sc->sc_npqtail = mpp;
-}
-
-/*
- * Transmitter has finished outputting some stuff;
- * remember to call sc->sc_start later at splsoftnet.
- */
-void
-ppp_restart(sc)
-    struct ppp_softc *sc;
-{
-    int s = splimp();
-
-    sc->sc_flags &= ~SC_TBUSY;
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Get a packet to send.  This procedure is intended to be called at
- * splsoftnet, since it may involve time-consuming operations such as
- * applying VJ compression, packet compression, address/control and/or
- * protocol field compression to the packet.
- */
-struct mbuf *
-ppp_dequeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, *mp;
-    u_char *cp;
-    int address, control, protocol;
-
-    /*
-     * Grab a packet to send: first try the fast queue, then the
-     * normal queue.
-     */
-    IF_DEQUEUE(&sc->sc_fastq, m);
-    if (m == NULL)
-       IF_DEQUEUE(&sc->sc_if.if_snd, m);
-    if (m == NULL)
-       return NULL;
-
-    ++sc->sc_stats.ppp_opackets;
-
-    /*
-     * Extract the ppp header of the new packet.
-     * The ppp header will be in one mbuf.
-     */
-    cp = mtod(m, u_char *);
-    address = PPP_ADDRESS(cp);
-    control = PPP_CONTROL(cp);
-    protocol = PPP_PROTOCOL(cp);
-
-    switch (protocol) {
-    case PPP_IP:
-#ifdef VJC
-       /*
-        * If the packet is a TCP/IP packet, see if we can compress it.
-        */
-       if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) {
-           struct ip *ip;
-           int type;
-
-           mp = m;
-           ip = (struct ip *) (cp + PPP_HDRLEN);
-           if (mp->m_len <= PPP_HDRLEN) {
-               mp = mp->m_next;
-               if (mp == NULL)
-                   break;
-               ip = mtod(mp, struct ip *);
-           }
-           /* this code assumes the IP/TCP header is in one non-shared mbuf */
-           if (ip->ip_p == IPPROTO_TCP) {
-               type = vj_compress_tcp(mp, ip, sc->sc_comp,
-                                      !(sc->sc_flags & SC_NO_TCP_CCID));
-               switch (type) {
-               case TYPE_UNCOMPRESSED_TCP:
-                   protocol = PPP_VJC_UNCOMP;
-                   break;
-               case TYPE_COMPRESSED_TCP:
-                   protocol = PPP_VJC_COMP;
-                   cp = mtod(m, u_char *);
-                   cp[0] = address;    /* header has moved */
-                   cp[1] = control;
-                   cp[2] = 0;
-                   break;
-               }
-               cp[3] = protocol;       /* update protocol in PPP header */
-           }
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPP_CCP:
-       ppp_ccp(sc, m, 0);
-       break;
-#endif /* PPP_COMPRESS */
-    }
-
-#ifdef PPP_COMPRESS
-    if (protocol != PPP_LCP && protocol != PPP_CCP
-       && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
-       struct mbuf *mcomp = NULL;
-       int slen, clen;
-
-       slen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           slen += mp->m_len;
-       clen = (*sc->sc_xcomp->compress)
-           (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
-       if (mcomp != NULL) {
-           if (sc->sc_flags & SC_CCP_UP) {
-               /* Send the compressed packet instead of the original. */
-               m_freem(m);
-               m = mcomp;
-               cp = mtod(m, u_char *);
-               protocol = cp[3];
-           } else {
-               /* Can't transmit compressed packets until CCP is up. */
-               m_freem(mcomp);
-           }
-       }
-    }
-#endif /* PPP_COMPRESS */
-
-    /*
-     * Compress the address/control and protocol, if possible.
-     */
-    if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS &&
-       control == PPP_UI && protocol != PPP_ALLSTATIONS &&
-       protocol != PPP_LCP) {
-       /* can compress address/control */
-       m->m_data += 2;
-       m->m_len -= 2;
-    }
-    if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) {
-       /* can compress protocol */
-       if (mtod(m, u_char *) == cp) {
-           cp[2] = cp[1];      /* move address/control up */
-           cp[1] = cp[0];
-       }
-       ++m->m_data;
-       --m->m_len;
-    }
-
-    return m;
-}
-
-/*
- * Software interrupt routine, called at splsoftnet.
- */
-void
-pppintr()
-{
-    struct ppp_softc *sc;
-    int i, s, s2;
-    struct mbuf *m;
-
-    sc = ppp_softc;
-    s = splsoftnet();
-    for (i = 0; i < NPPP; ++i, ++sc) {
-       if (!(sc->sc_flags & SC_TBUSY)
-           && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
-           s2 = splimp();
-           sc->sc_flags |= SC_TBUSY;
-           splx(s2);
-           (*sc->sc_start)(sc);
-       }
-       for (;;) {
-           s2 = splimp();
-           IF_DEQUEUE(&sc->sc_rawq, m);
-           splx(s2);
-           if (m == NULL)
-               break;
-           ppp_inproc(sc, m);
-       }
-    }
-    splx(s);
-}
-
-#ifdef PPP_COMPRESS
-/*
- * Handle a CCP packet.  `rcvd' is 1 if the packet was received,
- * 0 if it is about to be transmitted.
- */
-static void
-ppp_ccp(sc, m, rcvd)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int rcvd;
-{
-    u_char *dp, *ep;
-    struct mbuf *mp;
-    int slen, s;
-
-    /*
-     * Get a pointer to the data after the PPP header.
-     */
-    if (m->m_len <= PPP_HDRLEN) {
-       mp = m->m_next;
-       if (mp == NULL)
-           return;
-       dp = (mp != NULL)? mtod(mp, u_char *): NULL;
-    } else {
-       mp = m;
-       dp = mtod(mp, u_char *) + PPP_HDRLEN;
-    }
-
-    ep = mtod(mp, u_char *) + mp->m_len;
-    if (dp + CCP_HDRLEN > ep)
-       return;
-    slen = CCP_LENGTH(dp);
-    if (dp + slen > ep) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n",
-                  dp, slen, mtod(mp, u_char *), mp->m_len);
-       return;
-    }
-
-    switch (CCP_CODE(dp)) {
-    case CCP_CONFREQ:
-    case CCP_TERMREQ:
-    case CCP_TERMACK:
-       /* CCP must be going down - disable compression */
-       if (sc->sc_flags & SC_CCP_UP) {
-           s = splimp();
-           sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
-           splx(s);
-       }
-       break;
-
-    case CCP_CONFACK:
-       if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP)
-           && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
-           && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
-           if (!rcvd) {
-               /* we're agreeing to send compressed packets. */
-               if (sc->sc_xc_state != NULL
-                   && (*sc->sc_xcomp->comp_init)
-                       (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_COMP_RUN;
-                   splx(s);
-               }
-           } else {
-               /* peer is agreeing to send compressed packets. */
-               if (sc->sc_rc_state != NULL
-                   && (*sc->sc_rcomp->decomp_init)
-                       (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, 0, sc->sc_mru,
-                        sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_DECOMP_RUN;
-                   sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
-                   splx(s);
-               }
-           }
-       }
-       break;
-
-    case CCP_RESETACK:
-       if (sc->sc_flags & SC_CCP_UP) {
-           if (!rcvd) {
-               if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN))
-                   (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state);
-           } else {
-               if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-                   (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state);
-                   s = splimp();
-                   sc->sc_flags &= ~SC_DC_ERROR;
-                   splx(s);
-               }
-           }
-       }
-       break;
-    }
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-static void
-ppp_ccp_closed(sc)
-    struct ppp_softc *sc;
-{
-    if (sc->sc_xc_state) {
-       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-       sc->sc_xc_state = NULL;
-    }
-    if (sc->sc_rc_state) {
-       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-       sc->sc_rc_state = NULL;
-    }
-}
-#endif /* PPP_COMPRESS */
-
-/*
- * PPP packet input routine.
- * The caller has checked and removed the FCS and has inserted
- * the address/control bytes and the protocol high byte if they
- * were omitted.
- */
-void
-ppppktin(sc, m, lost)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int lost;
-{
-    int s = splimp();
-
-    if (lost)
-       m->m_flags |= M_ERRMARK;
-    IF_ENQUEUE(&sc->sc_rawq, m);
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Process a received PPP packet, doing decompression as necessary.
- * Should be called at splsoftnet.
- */
-#define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
-                        TYPE_UNCOMPRESSED_TCP)
-
-static void
-ppp_inproc(sc, m)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-{
-    struct ifnet *ifp = &sc->sc_if;
-    struct ifqueue *inq;
-    int s, ilen, xlen, proto, rv;
-    u_char *cp, adrs, ctrl;
-    struct mbuf *mp, *dmp = NULL;
-    u_char *iphdr;
-    u_int hlen;
-
-    sc->sc_stats.ppp_ipackets++;
-
-    if (sc->sc_flags & SC_LOG_INPKT) {
-       ilen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           ilen += mp->m_len;
-       printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen);
-       pppdumpm(m);
-    }
-
-    cp = mtod(m, u_char *);
-    adrs = PPP_ADDRESS(cp);
-    ctrl = PPP_CONTROL(cp);
-    proto = PPP_PROTOCOL(cp);
-
-    if (m->m_flags & M_ERRMARK) {
-       m->m_flags &= ~M_ERRMARK;
-       s = splimp();
-       sc->sc_flags |= SC_VJ_RESET;
-       splx(s);
-    }
-
-#ifdef PPP_COMPRESS
-    /*
-     * Decompress this packet if necessary, update the receiver's
-     * dictionary, or take appropriate action on a CCP packet.
-     */
-    if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)
-       && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) {
-       /* decompress this packet */
-       rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp);
-       if (rv == DECOMP_OK) {
-           m_freem(m);
-           if (dmp == NULL) {
-               /* no error, but no decompressed packet produced */
-               return;
-           }
-           m = dmp;
-           cp = mtod(m, u_char *);
-           proto = PPP_PROTOCOL(cp);
-
-       } else {
-           /*
-            * An error has occurred in decompression.
-            * Pass the compressed packet up to pppd, which may take
-            * CCP down or issue a Reset-Req.
-            */
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: decompress failed %d\n", ifp->if_unit, rv);
-           s = splimp();
-           sc->sc_flags |= SC_VJ_RESET;
-           if (rv == DECOMP_ERROR)
-               sc->sc_flags |= SC_DC_ERROR;
-           else
-               sc->sc_flags |= SC_DC_FERROR;
-           splx(s);
-       }
-
-    } else {
-       if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-           (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m);
-       }
-       if (proto == PPP_CCP) {
-           ppp_ccp(sc, m, 1);
-       }
-    }
-#endif
-
-    ilen = 0;
-    for (mp = m; mp != NULL; mp = mp->m_next)
-       ilen += mp->m_len;
-
-#ifdef VJC
-    if (sc->sc_flags & SC_VJ_RESET) {
-       /*
-        * If we've missed a packet, we must toss subsequent compressed
-        * packets which don't have an explicit connection ID.
-        */
-       if (sc->sc_comp)
-           vj_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp);
-       s = splimp();
-       sc->sc_flags &= ~SC_VJ_RESET;
-       splx(s);
-    }
-
-    /*
-     * See if we have a VJ-compressed packet to uncompress.
-     */
-    if (proto == PPP_VJC_COMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = vj_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen <= 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: VJ uncompress failed on type comp\n",
-                       ifp->if_unit);
-           goto bad;
-       }
-
-       /* Copy the PPP and IP headers into a new mbuf. */
-       MGETHDR(mp, M_DONTWAIT, MT_DATA);
-       if (mp == NULL)
-           goto bad;
-       mp->m_len = 0;
-       mp->m_next = NULL;
-       if (hlen + PPP_HDRLEN > MHLEN) {
-           MCLGET(mp, M_DONTWAIT);
-           if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) {
-               m_freem(mp);
-               goto bad;       /* lose if big headers and no clusters */
-           }
-       }
-       cp = mtod(mp, u_char *);
-       cp[0] = adrs;
-       cp[1] = ctrl;
-       cp[2] = 0;
-       cp[3] = PPP_IP;
-       proto = PPP_IP;
-       bcopy(iphdr, cp + PPP_HDRLEN, hlen);
-       mp->m_len = hlen + PPP_HDRLEN;
-
-       /*
-        * Trim the PPP and VJ headers off the old mbuf
-        * and stick the new and old mbufs together.
-        */
-       m->m_data += PPP_HDRLEN + xlen;
-       m->m_len -= PPP_HDRLEN + xlen;
-       if (m->m_len <= M_TRAILINGSPACE(mp)) {
-           bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len);
-           mp->m_len += m->m_len;
-           MFREE(m, mp->m_next);
-       } else
-           mp->m_next = m;
-       m = mp;
-       ilen += hlen - xlen;
-
-    } else if (proto == PPP_VJC_UNCOMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = vj_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen < 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: VJ uncompress failed on type uncomp\n",
-                       ifp->if_unit);
-           goto bad;
-       }
-
-       proto = PPP_IP;
-       cp[3] = PPP_IP;
-    }
-#endif /* VJC */
-
-    /*
-     * If the packet will fit in a header mbuf, don't waste a
-     * whole cluster on it.
-     */
-    if (ilen <= MHLEN && M_IS_CLUSTER(m)) {
-       MGETHDR(mp, M_DONTWAIT, MT_DATA);
-       if (mp != NULL) {
-           m_copydata(m, 0, ilen, mtod(mp, caddr_t));
-           m_freem(m);
-           m = mp;
-           m->m_len = ilen;
-       }
-    }
-    m->m_pkthdr.len = ilen;
-    m->m_pkthdr.rcvif = ifp;
-
-    if ((proto & 0x8000) == 0) {
-#ifdef PPP_FILTER
-       /*
-        * See whether we want to pass this packet, and
-        * if it counts as link activity.
-        */
-       adrs = *mtod(m, u_char *);      /* save address field */
-       *mtod(m, u_char *) = 0;         /* indicate inbound */
-       if (sc->sc_pass_filt.bf_insns != 0
-           && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m,
-                         ilen, 0) == 0) {
-           /* drop this packet */
-           m_freem(m);
-           return;
-       }
-       if (sc->sc_active_filt.bf_insns == 0
-           || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
-           sc->sc_last_recv = time.tv_sec;
-
-       *mtod(m, u_char *) = adrs;
-#else
-       /*
-        * Record the time that we received this packet.
-        */
-       sc->sc_last_recv = time.tv_sec;
-#endif /* PPP_FILTER */
-    }
-
-#if NBPFILTER > 0
-    /* See if bpf wants to look at the packet. */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m);
-#endif
-
-    rv = 0;
-    switch (proto) {
-#ifdef INET
-    case PPP_IP:
-       /*
-        * IP packet - take off the ppp header and pass it up to IP.
-        */
-       if ((ifp->if_flags & IFF_UP) == 0
-           || sc->sc_npmode[NP_IP] != NPMODE_PASS) {
-           /* interface is down - drop the packet. */
-           m_freem(m);
-           return;
-       }
-       m->m_pkthdr.len -= PPP_HDRLEN;
-       m->m_data += PPP_HDRLEN;
-       m->m_len -= PPP_HDRLEN;
-       schednetisr(NETISR_IP);
-       inq = &ipintrq;
-       break;
-#endif
-
-    default:
-       /*
-        * Some other protocol - place on input queue for read().
-        */
-       inq = &sc->sc_inq;
-       rv = 1;
-       break;
-    }
-
-    /*
-     * Put the packet on the appropriate input queue.
-     */
-    s = splimp();
-    if (IF_QFULL(inq)) {
-       IF_DROP(inq);
-       splx(s);
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: input queue full\n", ifp->if_unit);
-       ifp->if_iqdrops++;
-       goto bad;
-    }
-    IF_ENQUEUE(inq, m);
-    splx(s);
-    ifp->if_ipackets++;
-    ifp->if_ibytes += ilen;
-    ifp->if_lastchange = time;
-
-    if (rv)
-       (*sc->sc_ctlp)(sc);
-
-    return;
-
- bad:
-    m_freem(m);
-    sc->sc_if.if_ierrors++;
-    sc->sc_stats.ppp_ierrors++;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-pppdumpm(m0)
-    struct mbuf *m0;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    struct mbuf *m;
-    static char digits[] = "0123456789abcdef";
-
-    for (m = m0; m; m = m->m_next) {
-       int l = m->m_len;
-       u_char *rptr = (u_char *)m->m_data;
-
-       while (l--) {
-           if (bp > buf + sizeof(buf) - 4)
-               goto done;
-           *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
-           *bp++ = digits[*rptr++ & 0xf];
-       }
-
-       if (m->m_next) {
-           if (bp > buf + sizeof(buf) - 3)
-               goto done;
-           *bp++ = '|';
-       } else
-           *bp++ = ' ';
-    }
-done:
-    if (m)
-       *bp++ = '>';
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/freebsd-2.0/if_pppvar.h b/freebsd-2.0/if_pppvar.h
deleted file mode 100644 (file)
index b5b4a98..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*     $Id: if_pppvar.h,v 1.7 2002/12/06 09:49:15 paulus Exp $ */
-/*
- * if_pppvar.h - private structures and declarations for PPP.
- *
- * Copyright (c) 1984 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.
- *
- * 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.
- */
-
-/*
- * Supported network protocols.  These values are used for
- * indexing sc_npmode.
- */
-#define NP_IP  0               /* Internet Protocol */
-#define NUM_NP 1               /* Number of NPs. */
-
-/*
- * Structure describing each ppp unit.
- */
-struct ppp_softc {
-       struct  ifnet sc_if;            /* network-visible interface */
-       u_int   sc_flags;               /* control/status bits; see if_ppp.h */
-       void    *sc_devp;               /* pointer to device-dep structure */
-       void    (*sc_start) __P((struct ppp_softc *));  /* start output proc */
-       void    (*sc_ctlp) __P((struct ppp_softc *)); /* rcvd control pkt */
-       void    (*sc_relinq) __P((struct ppp_softc *)); /* relinquish ifunit */
-       short   sc_mru;                 /* max receive unit */
-       pid_t   sc_xfer;                /* used in transferring unit */
-       struct  ifqueue sc_rawq;        /* received packets */
-       struct  ifqueue sc_inq;         /* queue of input packets for daemon */
-       struct  ifqueue sc_fastq;       /* interactive output packet q */
-       struct  mbuf *sc_togo;          /* output packet ready to go */
-       struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
-       struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
-       struct  pppstat sc_stats;       /* count of bytes/pkts sent/rcvd */
-       caddr_t sc_bpf;                 /* hook for BPF */
-       enum    NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
-       struct  compressor *sc_xcomp;   /* transmit compressor */
-       void    *sc_xc_state;           /* transmit compressor state */
-       struct  compressor *sc_rcomp;   /* receive decompressor */
-       void    *sc_rc_state;           /* receive decompressor state */
-       time_t  sc_last_sent;           /* time (secs) last NP pkt sent */
-       time_t  sc_last_recv;           /* time (secs) last NP pkt rcvd */
-#ifdef PPP_FILTER
-       struct  bpf_program sc_pass_filt;   /* filter for packets to pass */
-       struct  bpf_program sc_active_filt; /* filter for "non-idle" packets */
-#endif /* PPP_FILTER */
-#ifdef VJC
-       struct  vjcompress *sc_comp;    /* vjc control buffer */
-#endif
-
-       /* Device-dependent part for async lines. */
-       ext_accm sc_asyncmap;           /* async control character map */
-       u_long  sc_rasyncmap;           /* receive async control char map */
-       struct  mbuf *sc_outm;          /* mbuf chain currently being output */
-       struct  mbuf *sc_m;             /* pointer to input mbuf chain */
-       struct  mbuf *sc_mc;            /* pointer to current input mbuf */
-       char    *sc_mp;                 /* ptr to next char in input mbuf */
-       short   sc_ilen;                /* length of input packet so far */
-       u_short sc_fcs;                 /* FCS so far (input) */
-       u_short sc_outfcs;              /* FCS so far for output packet */
-       u_char  sc_rawin[16];           /* chars as received */
-       int     sc_rawin_count;         /* # in sc_rawin */
-};
-
-struct ppp_softc ppp_softc[NPPP];
-
-struct ppp_softc *pppalloc __P((pid_t pid));
-void   pppdealloc __P((struct ppp_softc *sc));
-int    pppoutput __P((struct ifnet *, struct mbuf *,
-                      struct sockaddr *, struct rtentry *));
-int    pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data,
-                     int flag, struct proc *p));
-void   ppp_restart __P((struct ppp_softc *sc));
-void   ppppktin __P((struct ppp_softc *sc, struct mbuf *m, int lost));
-struct mbuf *ppp_dequeue __P((struct ppp_softc *sc));
diff --git a/freebsd-2.0/kinstall.sh b/freebsd-2.0/kinstall.sh
deleted file mode 100755 (executable)
index 0310677..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-
-# This script modifies the kernel sources in /sys to install
-# ppp-2.3.  It is intended to be run in the ppp-2.3 directory.
-#
-# Paul Mackerras       17-Mar-95
-#
-# Modified to match the output of the uname command for FreeBSD 2.1.0
-# and 2.1.5 (and perhaps later).
-#
-# John Lind (john@starfire.mn.org) 18-Nov-96
-
-KPATH=$(uname -v | sed 's/.*://')
-CONF=$(echo $KPATH | sed 's;.*compile/;;')
-SYS=$(echo $KPATH | sed 's;/compile/.*$;;')
-ARCHDIR=$SYS/i386
-CFILE=$ARCHDIR/conf/$CONF
-SRC=freebsd-2.0
-DOCONF=
-DOMAKE=
-CONFIG=config
-
-# Copy new versions of files into /sys/net
-
-for f in include/net/if_ppp.h include/net/ppp-comp.h \
-         $SRC/ppp_defs.h $SRC/bsd-comp.c $SRC/ppp-deflate.c \
-        $SRC/if_ppp.c $SRC/if_pppvar.h $SRC/ppp_tty.c \
-        $SRC/pppcompress.c $SRC/pppcompress.h common/zlib.c common/zlib.h; do
-  dest=$SYS/net/$(basename $f)
-  if [ -f $dest ]; then
-    if ! cmp -s $f $dest; then
-      echo "Copying $f to $dest"
-      mv -f $dest $dest.orig && echo " (old version saved in $dest.orig)"
-      cp $f $dest
-      DOMAKE=yes
-    fi
-  else
-    echo "Copying $f to $dest"
-    cp $f $dest
-    DOMAKE=yes
-  fi
-done
-
-# Add extra stuff to /sys/conf/files
-
-if [ -f $SYS/conf/files ]; then
-  if ! grep -q ppp_tty $SYS/conf/files; then
-    echo "Patching $SYS/conf/files"
-    patch -p -N -d $SYS/conf <$SRC/files.patch
-    DOCONF=yes
-  elif ! grep -q ppp-deflate $SYS/conf/files; then
-    echo "Patching $SYS/conf/files"
-    patch -N $SYS/conf/$OLDFILES <$SRC/files-2.2.patch
-    DOCONF=yes
-  fi
-fi
-
-# Tell the user to add a pseudo-device line to the configuration file.
-
-if [ -f $CFILE ]; then
-  if ! grep -q '^[     ]*pseudo-device[        ][      ]*ppp' $CFILE; then
-    echo
-    echo "The currently-running kernel was built from configuration file"
-    echo "$CFILE, which does not include PPP."
-    echo "You need either to add a line like 'pseudo-device ppp 2' to"
-    echo "this file, or use another configuration file which includes"
-    echo "a line like this."
-    DOCONF=yes
-  fi
-fi
-
-if [ $DOCONF ]; then
-  echo
-  echo "You need to configure and build a new kernel."
-  echo "The procedure for doing this involves the following commands."
-  echo "(\"$CONF\" may be replaced by the name of another config file.)"
-  echo
-  echo "       cd $ARCHDIR/conf"
-  echo "       /usr/sbin/$CONFIG $CONF"
-  echo "       cd ../../compile/$CONF"
-  echo "       make depend"
-  DOMAKE=yes
-elif [ $DOMAKE ]; then
-  echo "You need to build a new kernel."
-  echo "The procedure for doing this involves the following commands."
-  echo
-  echo "       cd $KPATH"
-fi
-if [ $DOMAKE ]; then
-  echo "       make"
-  echo
-  echo "Then copy the new kernel ($KPATH/kernel) to /"
-  echo "and reboot.  (Keep a copy of the old /kernel, just in case.)"
-fi
diff --git a/freebsd-2.0/ppp_defs.h b/freebsd-2.0/ppp_defs.h
deleted file mode 100644 (file)
index 1d8cc3a..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*     $Id: ppp_defs.h,v 1.3 2002/12/06 09:49:15 paulus Exp $  */
-
-/*
- * ppp_defs.h - PPP definitions.
- *
- * 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.
- */
-
-#ifndef _PPP_DEFS_H_
-#define _PPP_DEFS_H_
-
-/*
- * The basic PPP frame.
- */
-#define PPP_HDRLEN     4       /* octets for standard ppp header */
-#define PPP_FCSLEN     2       /* octets for FCS */
-#define PPP_MRU                1500    /* default MRU = max length of info field */
-
-#define PPP_ADDRESS(p) (((u_char *)(p))[0])
-#define PPP_CONTROL(p) (((u_char *)(p))[1])
-#define PPP_PROTOCOL(p)        ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
-
-/*
- * Significant octet values.
- */
-#define        PPP_ALLSTATIONS 0xff    /* All-Stations broadcast address */
-#define        PPP_UI          0x03    /* Unnumbered Information */
-#define        PPP_FLAG        0x7e    /* Flag Sequence */
-#define        PPP_ESCAPE      0x7d    /* Asynchronous Control Escape */
-#define        PPP_TRANS       0x20    /* Asynchronous transparency modifier */
-
-/*
- * Protocol field values.
- */
-#define PPP_IP         0x21    /* Internet Protocol */
-#define PPP_AT         0x29    /* AppleTalk Protocol */
-#define        PPP_VJC_COMP    0x2d    /* VJ compressed TCP */
-#define        PPP_VJC_UNCOMP  0x2f    /* VJ uncompressed TCP */
-#define PPP_COMP       0xfd    /* compressed packet */
-#define PPP_IPCP       0x8021  /* IP Control Protocol */
-#define PPP_ATCP       0x8029  /* AppleTalk Control Protocol */
-#define PPP_CCP                0x80fd  /* Compression Control Protocol */
-#define PPP_LCP                0xc021  /* Link Control Protocol */
-#define PPP_PAP                0xc023  /* Password Authentication Protocol */
-#define PPP_LQR                0xc025  /* Link Quality Report protocol */
-#define PPP_CHAP       0xc223  /* Cryptographic Handshake Auth. Protocol */
-#define PPP_CBCP       0xc029  /* Callback Control Protocol */
-
-/*
- * Values for FCS calculations.
- */
-#define PPP_INITFCS    0xffff  /* Initial FCS value */
-#define PPP_GOODFCS    0xf0b8  /* Good final FCS value */
-#define PPP_FCS(fcs, c)        (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
-
-/*
- * Extended asyncmap - allows any character to be escaped.
- */
-typedef u_int32_t      ext_accm[8];
-
-/*
- * What to do with network protocol (NP) packets.
- */
-enum NPmode {
-    NPMODE_PASS,               /* pass the packet through */
-    NPMODE_DROP,               /* silently drop the packet */
-    NPMODE_ERROR,              /* return an error */
-    NPMODE_QUEUE               /* save it up for later. */
-};
-
-/*
- * Statistics.
- */
-struct pppstat {
-    unsigned int ppp_ibytes;   /* bytes received */
-    unsigned int ppp_ipackets; /* packets received */
-    unsigned int ppp_ierrors;  /* receive errors */
-    unsigned int ppp_obytes;   /* bytes sent */
-    unsigned int ppp_opackets; /* packets sent */
-    unsigned int ppp_oerrors;  /* transmit errors */
-};
-
-struct vjstat {
-    unsigned int vjs_packets;  /* outbound packets */
-    unsigned int vjs_compressed; /* outbound compressed packets */
-    unsigned int vjs_searches; /* searches for connection state */
-    unsigned int vjs_misses;   /* times couldn't find conn. state */
-    unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
-    unsigned int vjs_compressedin; /* inbound compressed packets */
-    unsigned int vjs_errorin;  /* inbound unknown type packets */
-    unsigned int vjs_tossed;   /* inbound packets tossed because of error */
-};
-
-struct ppp_stats {
-    struct pppstat p;          /* basic PPP statistics */
-    struct vjstat vj;          /* VJ header compression statistics */
-};
-
-struct compstat {
-    unsigned int unc_bytes;    /* total uncompressed bytes */
-    unsigned int unc_packets;  /* total uncompressed packets */
-    unsigned int comp_bytes;   /* compressed bytes */
-    unsigned int comp_packets; /* compressed packets */
-    unsigned int inc_bytes;    /* incompressible bytes */
-    unsigned int inc_packets;  /* incompressible packets */
-    unsigned int ratio;                /* recent compression ratio << 8 */
-};
-
-struct ppp_comp_stats {
-    struct compstat c;         /* packet compression statistics */
-    struct compstat d;         /* packet decompression statistics */
-};
-
-/*
- * The following structure records the time in seconds since
- * the last NP packet was sent or received.
- */
-struct ppp_idle {
-    time_t xmit_idle;          /* time since last NP packet sent */
-    time_t recv_idle;          /* time since last NP packet received */
-};
-
-#ifndef __P
-#ifdef __STDC__
-#define __P(x) x
-#else
-#define __P(x) ()
-#endif
-#endif
-
-#endif /* _PPP_DEFS_H_ */
diff --git a/freebsd-2.0/ppp_tty.c b/freebsd-2.0/ppp_tty.c
deleted file mode 100644 (file)
index f46148e..0000000
+++ /dev/null
@@ -1,1103 +0,0 @@
-/*
- * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
- *            tty devices.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a "collision" if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- */
-
-/* $Id: ppp_tty.c,v 1.9 2002/12/06 09:49:15 paulus Exp $ */
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/mbuf.h>
-#include <sys/dkstat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/tty.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/vnode.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-
-#ifdef VJC
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <net/pppcompress.h>
-#endif
-
-#ifdef PPP_FILTER
-#include <net/bpf.h>
-#endif
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/if_pppvar.h>
-
-void   pppasyncattach __P((void));
-int    pppopen __P((dev_t dev, struct tty *tp));
-int    pppclose __P((struct tty *tp, int flag));
-int    pppread __P((struct tty *tp, struct uio *uio, int flag));
-int    pppwrite __P((struct tty *tp, struct uio *uio, int flag));
-int    ppptioctl __P((struct tty *tp, int cmd, caddr_t data, int flag,
-                      struct proc *));
-int    pppinput __P((int c, struct tty *tp));
-int    pppstart __P((struct tty *tp));
-
-static u_short pppfcs __P((u_short fcs, u_char *cp, int len));
-static void    pppasyncstart __P((struct ppp_softc *));
-static void    pppasyncctlp __P((struct ppp_softc *));
-static void    pppasyncrelinq __P((struct ppp_softc *));
-static void    ppp_timeout __P((void *));
-static void    pppgetm __P((struct ppp_softc *sc));
-static void    pppdumpb __P((u_char *b, int l));
-static void    ppplogchar __P((struct ppp_softc *, int));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m)        ((m)->m_flags & M_EXT)
-
-#define M_DATASTART(m) \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
-           (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
-           (m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
-
-/*
- * Does c need to be escaped?
- */
-#define ESCAPE_P(c)    (sc->sc_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F)))
-
-/*
- * Procedures for using an async tty interface for PPP.
- */
-
-/* This is a FreeBSD-2.0 kernel. */
-#define CCOUNT(q)      ((q)->c_cc)
-#define PPP_LOWAT      100     /* Process more output when < LOWAT on queue */
-#define        PPP_HIWAT       400     /* Don't start a new packet if HIWAT on que */
-
-/*
- * Define the PPP line discipline.
- */
-
-static struct linesw pppdisc = {
-       pppopen, pppclose, pppread, pppwrite, ppptioctl,
-       pppinput, pppstart, ttymodem
-};
-
-void
-pppasyncattach()
-{
-    linesw[PPPDISC] = pppdisc;
-}
-
-TEXT_SET(pseudo_set, pppasyncattach);
-
-/*
- * Line specific open routine for async tty devices.
- * Attach the given tty to the first available ppp unit.
- * Called from device open routine or ttioctl.
- */
-/* ARGSUSED */
-int
-pppopen(dev, tp)
-    dev_t dev;
-    register struct tty *tp;
-{
-    struct proc *p = curproc;          /* XXX */
-    register struct ppp_softc *sc;
-    int error, s;
-
-    if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-       return (error);
-
-    s = spltty();
-
-    if (tp->t_line == PPPDISC) {
-       sc = (struct ppp_softc *) tp->t_sc;
-       if (sc != NULL && sc->sc_devp == (void *) tp) {
-           splx(s);
-           return (0);
-       }
-    }
-
-    if ((sc = pppalloc(p->p_pid)) == NULL) {
-       splx(s);
-       return ENXIO;
-    }
-
-    if (sc->sc_relinq)
-       (*sc->sc_relinq)(sc);   /* get previous owner to relinquish the unit */
-
-    sc->sc_ilen = 0;
-    sc->sc_m = NULL;
-    bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-    sc->sc_asyncmap[0] = 0xffffffff;
-    sc->sc_asyncmap[3] = 0x60000000;
-    sc->sc_rasyncmap = 0;
-    sc->sc_devp = (void *) tp;
-    sc->sc_start = pppasyncstart;
-    sc->sc_ctlp = pppasyncctlp;
-    sc->sc_relinq = pppasyncrelinq;
-    sc->sc_outm = NULL;
-    pppgetm(sc);
-    sc->sc_if.if_flags |= IFF_RUNNING;
-    sc->sc_if.if_baudrate = tp->t_ospeed;
-
-    tp->t_sc = (caddr_t) sc;
-    ttyflush(tp, FREAD | FWRITE);
-
-    splx(s);
-    return (0);
-}
-
-/*
- * Line specific close routine, called from device close routine
- * and from ttioctl.
- * Detach the tty from the ppp unit.
- * Mimics part of ttyclose().
- */
-int
-pppclose(tp, flag)
-    struct tty *tp;
-    int flag;
-{
-    register struct ppp_softc *sc;
-    int s;
-
-    s = spltty();
-    ttyflush(tp, FREAD|FWRITE);
-    tp->t_line = 0;
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc != NULL) {
-       tp->t_sc = NULL;
-       if (tp == (struct tty *) sc->sc_devp) {
-           pppasyncrelinq(sc);
-           pppdealloc(sc);
-       }
-    }
-    splx(s);
-    return 0;
-}
-
-/*
- * Relinquish the interface unit to another device.
- */
-static void
-pppasyncrelinq(sc)
-    struct ppp_softc *sc;
-{
-    int s;
-
-    s = spltty();
-    if (sc->sc_outm) {
-       m_freem(sc->sc_outm);
-       sc->sc_outm = NULL;
-    }
-    if (sc->sc_m) {
-       m_freem(sc->sc_m);
-       sc->sc_m = NULL;
-    }
-    if (sc->sc_flags & SC_TIMEOUT) {
-       untimeout(ppp_timeout, (void *) sc);
-       sc->sc_flags &= ~SC_TIMEOUT;
-    }
-    splx(s);
-}
-
-/*
- * Line specific (tty) read routine.
- */
-int
-pppread(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0;
-    register int s;
-    int error = 0;
-
-    if (sc == NULL)
-       return 0;
-    /*
-     * Loop waiting for input, checking that nothing disasterous
-     * happens in the meantime.
-     */
-    s = spltty();
-    for (;;) {
-       if (tp != (struct tty *) sc->sc_devp || tp->t_line != PPPDISC) {
-           splx(s);
-           return 0;
-       }
-       if (sc->sc_inq.ifq_head != NULL)
-           break;
-       if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0
-           && (tp->t_state & TS_ISOPEN)) {
-           splx(s);
-           return 0;           /* end of file */
-       }
-       if (tp->t_state & TS_ASYNC || flag & IO_NDELAY) {
-           splx(s);
-           return (EWOULDBLOCK);
-       }
-       error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH, "ttyin", 0);
-       if (error) {
-           splx(s);
-           return error;
-       }
-    }
-
-    /* Pull place-holder byte out of canonical queue */
-    getc(&tp->t_canq);
-
-    /* Get the packet from the input queue */
-    IF_DEQUEUE(&sc->sc_inq, m0);
-    splx(s);
-
-    for (m = m0; m && uio->uio_resid; m = m->m_next)
-       if ((error = uiomove(mtod(m, u_char *), m->m_len, uio)) != 0)
-           break;
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * Line specific (tty) write routine.
- */
-int
-pppwrite(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0, **mp;
-    struct sockaddr dst;
-    int len, error;
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       return 0;               /* wrote 0 bytes */
-    if (tp->t_line != PPPDISC)
-       return (EINVAL);
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return EIO;
-    if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HDRLEN ||
-       uio->uio_resid < PPP_HDRLEN)
-       return (EMSGSIZE);
-    for (mp = &m0; uio->uio_resid; mp = &m->m_next) {
-       MGET(m, M_WAIT, MT_DATA);
-       if ((*mp = m) == NULL) {
-           m_freem(m0);
-           return (ENOBUFS);
-       }
-       m->m_len = 0;
-       if (uio->uio_resid >= MCLBYTES / 2)
-           MCLGET(m, M_DONTWAIT);
-       len = M_TRAILINGSPACE(m);
-       if (len > uio->uio_resid)
-           len = uio->uio_resid;
-       if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) {
-           m_freem(m0);
-           return (error);
-       }
-       m->m_len = len;
-    }
-    dst.sa_family = AF_UNSPEC;
-    bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN);
-    m0->m_data += PPP_HDRLEN;
-    m0->m_len -= PPP_HDRLEN;
-    return (pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0));
-}
-
-/*
- * Line specific (tty) ioctl routine.
- * This discipline requires that tty device drivers call
- * the line specific l_ioctl routine from their ioctl routines.
- */
-/* ARGSUSED */
-int
-ppptioctl(tp, cmd, data, flag, p)
-    struct tty *tp;
-    int cmd;
-    caddr_t data;
-    int flag;
-    struct proc *p;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-    int error, s;
-
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return -1;
-
-    error = 0;
-    switch (cmd) {
-    case PPPIOCSASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_asyncmap[0] = *(u_int *)data;
-       break;
-
-    case PPPIOCGASYNCMAP:
-       *(u_int *)data = sc->sc_asyncmap[0];
-       break;
-
-    case PPPIOCSRASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_rasyncmap = *(u_int *)data;
-       break;
-
-    case PPPIOCGRASYNCMAP:
-       *(u_int *)data = sc->sc_rasyncmap;
-       break;
-
-    case PPPIOCSXASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       s = spltty();
-       bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-       sc->sc_asyncmap[1] = 0;             /* mustn't escape 0x20 - 0x3f */
-       sc->sc_asyncmap[2] &= ~0x40000000;  /* mustn't escape 0x5e */
-       sc->sc_asyncmap[3] |= 0x60000000;   /* must escape 0x7d, 0x7e */
-       splx(s);
-       break;
-
-    case PPPIOCGXASYNCMAP:
-       bcopy(sc->sc_asyncmap, data, sizeof(sc->sc_asyncmap));
-       break;
-
-    default:
-       error = pppioctl(sc, cmd, data, flag, p);
-       if (error == 0 && cmd == PPPIOCSMRU)
-           pppgetm(sc);
-    }
-
-    return error;
-}
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static u_short fcstab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-/*
- * Calculate a new FCS given the current FCS and the new data.
- */
-static u_short
-pppfcs(fcs, cp, len)
-    register u_short fcs;
-    register u_char *cp;
-    register int len;
-{
-    while (len--)
-       fcs = PPP_FCS(fcs, *cp++);
-    return (fcs);
-}
-
-/*
- * This gets called at splsoftnet from if_ppp.c at various times
- * when there is data ready to be sent.
- */
-static void
-pppasyncstart(sc)
-    register struct ppp_softc *sc;
-{
-    register struct tty *tp = (struct tty *) sc->sc_devp;
-    register struct mbuf *m;
-    register int len;
-    register u_char *start, *stop, *cp;
-    int n, ndone, done, idle;
-    struct mbuf *m2;
-    int s;
-
-    idle = 0;
-    while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-       /*
-        * See if we have an existing packet partly sent.
-        * If not, get a new packet and start sending it.
-        */
-       m = sc->sc_outm;
-       if (m == NULL) {
-           /*
-            * Get another packet to be sent.
-            */
-           m = ppp_dequeue(sc);
-           if (m == NULL) {
-               idle = 1;
-               break;
-           }
-
-           /*
-            * The extra PPP_FLAG will start up a new packet, and thus
-            * will flush any accumulated garbage.  We do this whenever
-            * the line may have been idle for some time.
-            */
-           if (CCOUNT(&tp->t_outq) == 0) {
-               ++sc->sc_stats.ppp_obytes;
-               (void) putc(PPP_FLAG, &tp->t_outq);
-           }
-
-           /* Calculate the FCS for the first mbuf's worth. */
-           sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
-           sc->sc_if.if_lastchange = time;
-       }
-
-       for (;;) {
-           start = mtod(m, u_char *);
-           len = m->m_len;
-           stop = start + len;
-           while (len > 0) {
-               /*
-                * Find out how many bytes in the string we can
-                * handle without doing something special.
-                */
-               for (cp = start; cp < stop; cp++)
-                   if (ESCAPE_P(*cp))
-                       break;
-               n = cp - start;
-               if (n) {
-                   /* NetBSD (0.9 or later), 4.3-Reno or similar. */
-                   ndone = n - b_to_q(start, n, &tp->t_outq);
-                   len -= ndone;
-                   start += ndone;
-                   sc->sc_stats.ppp_obytes += ndone;
-
-                   if (ndone < n)
-                       break;  /* packet doesn't fit */
-               }
-               /*
-                * If there are characters left in the mbuf,
-                * the first one must be special.
-                * Put it out in a different form.
-                */
-               if (len) {
-                   s = spltty();
-                   if (putc(PPP_ESCAPE, &tp->t_outq))
-                       break;
-                   if (putc(*start ^ PPP_TRANS, &tp->t_outq)) {
-                       (void) unputc(&tp->t_outq);
-                       splx(s);
-                       break;
-                   }
-                   splx(s);
-                   sc->sc_stats.ppp_obytes += 2;
-                   start++;
-                   len--;
-               }
-           }
-
-           /*
-            * If we didn't empty this mbuf, remember where we're up to.
-            * If we emptied the last mbuf, try to add the FCS and closing
-            * flag, and if we can't, leave sc_outm pointing to m, but with
-            * m->m_len == 0, to remind us to output the FCS and flag later.
-            */
-           done = len == 0;
-           if (done && m->m_next == NULL) {
-               u_char *p, *q;
-               int c;
-               u_char endseq[8];
-
-               /*
-                * We may have to escape the bytes in the FCS.
-                */
-               p = endseq;
-               c = ~sc->sc_outfcs & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               c = (~sc->sc_outfcs >> 8) & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               *p++ = PPP_FLAG;
-
-               /*
-                * Try to output the FCS and flag.  If the bytes
-                * don't all fit, back out.
-                */
-               s = spltty();
-               for (q = endseq; q < p; ++q)
-                   if (putc(*q, &tp->t_outq)) {
-                       done = 0;
-                       for (; q > endseq; --q)
-                           unputc(&tp->t_outq);
-                       break;
-                   }
-               splx(s);
-               if (done)
-                   sc->sc_stats.ppp_obytes += q - endseq;
-           }
-
-           if (!done) {
-               /* remember where we got to */
-               m->m_data = start;
-               m->m_len = len;
-               break;
-           }
-
-           /* Finished with this mbuf; free it and move on. */
-           MFREE(m, m2);
-           m = m2;
-           if (m == NULL) {
-               /* Finished a packet */
-               break;
-           }
-           sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len);
-       }
-
-       /*
-        * If m == NULL, we have finished a packet.
-        * If m != NULL, we've either done as much work this time
-        * as we need to, or else we've filled up the output queue.
-        */
-       sc->sc_outm = m;
-       if (m)
-           break;
-    }
-
-    /* Call pppstart to start output again if necessary. */
-    s = spltty();
-    pppstart(tp);
-
-    /*
-     * This timeout is needed for operation on a pseudo-tty,
-     * because the pty code doesn't call pppstart after it has
-     * drained the t_outq.
-     */
-    if (!idle && (sc->sc_flags & SC_TIMEOUT) == 0) {
-       timeout(ppp_timeout, (void *) sc, 1);
-       sc->sc_flags |= SC_TIMEOUT;
-    }
-
-    splx(s);
-}
-
-/*
- * This gets called when a received packet is placed on
- * the inq, at splsoftnet.
- */
-static void
-pppasyncctlp(sc)
-    struct ppp_softc *sc;
-{
-    struct tty *tp;
-    int s;
-
-    /* Put a placeholder byte in canq for ttselect()/ttnread(). */
-    s = spltty();
-    tp = (struct tty *) sc->sc_devp;
-    putc(0, &tp->t_canq);
-    ttwakeup(tp);
-    splx(s);
-}
-
-/*
- * Start output on async tty interface.  If the transmit queue
- * has drained sufficiently, arrange for pppasyncstart to be
- * called later at splsoftnet.
- * Called at spltty or higher.
- */
-int
-pppstart(tp)
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-
-    /*
-     * If there is stuff in the output queue, send it now.
-     * We are being called in lieu of ttstart and must do what it would.
-     */
-    if (tp->t_oproc != NULL)
-       (*tp->t_oproc)(tp);
-
-    /*
-     * If the transmit queue has drained and the tty has not hung up
-     * or been disconnected from the ppp unit, then tell if_ppp.c that
-     * we need more output.
-     */
-    if (CCOUNT(&tp->t_outq) < PPP_LOWAT
-       && !((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       && sc != NULL && tp == (struct tty *) sc->sc_devp) {
-       ppp_restart(sc);
-    }
-
-    return 0;
-}
-
-/*
- * Timeout routine - try to start some more output.
- */
-static void
-ppp_timeout(x)
-    void *x;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) x;
-    struct tty *tp = (struct tty *) sc->sc_devp;
-    int s;
-
-    s = spltty();
-    sc->sc_flags &= ~SC_TIMEOUT;
-    pppstart(tp);
-    splx(s);
-}
-
-/*
- * Allocate enough mbuf to handle current MRU.
- */
-static void
-pppgetm(sc)
-    register struct ppp_softc *sc;
-{
-    struct mbuf *m, **mp;
-    int len;
-
-    mp = &sc->sc_m;
-    for (len = sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){
-       if ((m = *mp) == NULL) {
-           MGETHDR(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL)
-               break;
-           *mp = m;
-           MCLGET(m, M_DONTWAIT);
-       }
-       len -= M_DATASIZE(m);
-       mp = &m->m_next;
-    }
-}
-
-/*
- * tty interface receiver interrupt.
- */
-static unsigned paritytab[8] = {
-    0x96696996, 0x69969669, 0x69969669, 0x96696996,
-    0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-
-int
-pppinput(c, tp)
-    int c;
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    struct mbuf *m;
-    int ilen, s;
-
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return 0;
-
-    ++tk_nin;
-    ++sc->sc_stats.ppp_ibytes;
-
-    if (c & TTY_FE) {
-       /* framing error or overrun on this char - abort packet */
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: bad char %x\n", sc->sc_if.if_unit, c);
-       goto flush;
-    }
-
-    c &= 0xff;
-
-    /*
-     * Handle software flow control of output.
-     */
-    if (tp->t_iflag & IXON) {
-       if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
-           if ((tp->t_state & TS_TTSTOP) == 0) {
-               tp->t_state |= TS_TTSTOP;
-               (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
-           }
-           return 0;
-       }
-       if (c == tp->t_cc[VSTART] && tp->t_cc[VSTART] != _POSIX_VDISABLE) {
-           tp->t_state &= ~TS_TTSTOP;
-           if (tp->t_oproc != NULL)
-               (*tp->t_oproc)(tp);
-           return 0;
-       }
-    }
-
-    s = spltty();
-    if (c & 0x80)
-       sc->sc_flags |= SC_RCV_B7_1;
-    else
-       sc->sc_flags |= SC_RCV_B7_0;
-    if (paritytab[c >> 5] & (1 << (c & 0x1F)))
-       sc->sc_flags |= SC_RCV_ODDP;
-    else
-       sc->sc_flags |= SC_RCV_EVNP;
-    splx(s);
-
-    if (sc->sc_flags & SC_LOG_RAWIN)
-       ppplogchar(sc, c);
-
-    if (c == PPP_FLAG) {
-       ilen = sc->sc_ilen;
-       sc->sc_ilen = 0;
-
-       if (sc->sc_rawin_count > 0) 
-           ppplogchar(sc, -1);
-
-       /*
-        * If SC_ESCAPED is set, then we've seen the packet
-        * abort sequence "}~".
-        */
-       if (sc->sc_flags & (SC_FLUSH | SC_ESCAPED)
-           || (ilen > 0 && sc->sc_fcs != PPP_GOODFCS)) {
-           s = spltty();
-           sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
-           if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: bad fcs %x, pkt len %d\n",
-                          sc->sc_if.if_unit, sc->sc_fcs, ilen);
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-           } else
-               sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
-           splx(s);
-           return 0;
-       }
-
-       if (ilen < PPP_HDRLEN + PPP_FCSLEN) {
-           if (ilen) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: too short (%d)\n", sc->sc_if.if_unit, ilen);
-               s = spltty();
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-               sc->sc_flags |= SC_PKTLOST;
-               splx(s);
-           }
-           return 0;
-       }
-
-       /*
-        * Remove FCS trailer.  Somewhat painful...
-        */
-       ilen -= 2;
-       if (--sc->sc_mc->m_len == 0) {
-           for (m = sc->sc_m; m->m_next != sc->sc_mc; m = m->m_next)
-               ;
-           sc->sc_mc = m;
-       }
-       sc->sc_mc->m_len--;
-
-       /* excise this mbuf chain */
-       m = sc->sc_m;
-       sc->sc_m = sc->sc_mc->m_next;
-       sc->sc_mc->m_next = NULL;
-
-       ppppktin(sc, m, sc->sc_flags & SC_PKTLOST);
-       if (sc->sc_flags & SC_PKTLOST) {
-           s = spltty();
-           sc->sc_flags &= ~SC_PKTLOST;
-           splx(s);
-       }
-
-       pppgetm(sc);
-       return 0;
-    }
-
-    if (sc->sc_flags & SC_FLUSH) {
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-       return 0;
-    }
-
-    if (c < 0x20 && (sc->sc_rasyncmap & (1 << c)))
-       return 0;
-
-    s = spltty();
-    if (sc->sc_flags & SC_ESCAPED) {
-       sc->sc_flags &= ~SC_ESCAPED;
-       c ^= PPP_TRANS;
-    } else if (c == PPP_ESCAPE) {
-       sc->sc_flags |= SC_ESCAPED;
-       splx(s);
-       return 0;
-    }
-    splx(s);
-
-    /*
-     * Initialize buffer on first octet received.
-     * First octet could be address or protocol (when compressing
-     * address/control).
-     * Second octet is control.
-     * Third octet is first or second (when compressing protocol)
-     * octet of protocol.
-     * Fourth octet is second octet of protocol.
-     */
-    if (sc->sc_ilen == 0) {
-       /* reset the first input mbuf */
-       if (sc->sc_m == NULL) {
-           pppgetm(sc);
-           if (sc->sc_m == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit);
-               goto flush;
-           }
-       }
-       m = sc->sc_m;
-       m->m_len = 0;
-       m->m_data = M_DATASTART(sc->sc_m);
-       sc->sc_mc = m;
-       sc->sc_mp = mtod(m, char *);
-       sc->sc_fcs = PPP_INITFCS;
-       if (c != PPP_ALLSTATIONS) {
-           if (sc->sc_flags & SC_REJ_COMP_AC) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: garbage received: 0x%x (need 0xFF)\n",
-                          sc->sc_if.if_unit, c);
-               goto flush;
-           }
-           *sc->sc_mp++ = PPP_ALLSTATIONS;
-           *sc->sc_mp++ = PPP_UI;
-           sc->sc_ilen += 2;
-           m->m_len += 2;
-       }
-    }
-    if (sc->sc_ilen == 1 && c != PPP_UI) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: missing UI (0x3), got 0x%x\n",
-                  sc->sc_if.if_unit, c);
-       goto flush;
-    }
-    if (sc->sc_ilen == 2 && (c & 1) == 1) {
-       /* a compressed protocol */
-       *sc->sc_mp++ = 0;
-       sc->sc_ilen++;
-       sc->sc_mc->m_len++;
-    }
-    if (sc->sc_ilen == 3 && (c & 1) == 0) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit,
-                  (sc->sc_mp[-1] << 8) + c);
-       goto flush;
-    }
-
-    /* packet beyond configured mru? */
-    if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: packet too big\n", sc->sc_if.if_unit);
-       goto flush;
-    }
-
-    /* is this mbuf full? */
-    m = sc->sc_mc;
-    if (M_TRAILINGSPACE(m) <= 0) {
-       if (m->m_next == NULL) {
-           pppgetm(sc);
-           if (m->m_next == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit);
-               goto flush;
-           }
-       }
-       sc->sc_mc = m = m->m_next;
-       m->m_len = 0;
-       m->m_data = M_DATASTART(m);
-       sc->sc_mp = mtod(m, char *);
-    }
-
-    ++m->m_len;
-    *sc->sc_mp++ = c;
-    sc->sc_fcs = PPP_FCS(sc->sc_fcs, c);
-    return 0;
-
- flush:
-    if (!(sc->sc_flags & SC_FLUSH)) {
-       s = spltty();
-       sc->sc_if.if_ierrors++;
-       sc->sc_stats.ppp_ierrors++;
-       sc->sc_flags |= SC_FLUSH;
-       splx(s);
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-    }
-    return 0;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-ppplogchar(sc, c)
-    struct ppp_softc *sc;
-    int c;
-{
-    if (c >= 0)
-       sc->sc_rawin[sc->sc_rawin_count++] = c;
-    if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
-       || (c < 0 && sc->sc_rawin_count > 0)) {
-       printf("ppp%d input: ", sc->sc_if.if_unit);
-       pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
-       sc->sc_rawin_count = 0;
-    }
-}
-
-static void
-pppdumpb(b, l)
-    u_char *b;
-    int l;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-
-    while (l--) {
-       if (bp >= buf + sizeof(buf) - 3) {
-           *bp++ = '>';
-           break;
-       }
-       *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*b++ & 0xf];
-       *bp++ = ' ';
-    }
-
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/freebsd-2.0/pppcompress.c b/freebsd-2.0/pppcompress.c
deleted file mode 100644 (file)
index 383ca58..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-/*-
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)slcompress.c        7.7 (Berkeley) 5/7/91
- */
-
-/*
- * Routines to compress and uncompess tcp packets (for transmission
- * over low speed serial lines.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *    - Initial distribution.
- *
- *     $Id: pppcompress.c,v 1.2 1996/05/24 07:04:14 paulus Exp $
- */
-  
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include <net/pppcompress.h>
-
-#ifndef SL_NO_STATS
-#define INCR(counter) ++comp->counter;
-#else
-#define INCR(counter)
-#endif
-
-#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
-#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
-#ifndef KERNEL
-#define ovbcopy bcopy
-#endif
-
-void
-vj_compress_init(comp, max_state)
-       struct vjcompress *comp;
-       int max_state;
-{
-       register u_int i;
-       register struct cstate *tstate = comp->tstate;
-
-       if ((unsigned) max_state > MAX_STATES - 1)
-               max_state = MAX_STATES - 1;
-       bzero((char *)comp, sizeof(*comp));
-       for (i = max_state; i > 0; --i) {
-               tstate[i].cs_id = i;
-               tstate[i].cs_next = &tstate[i - 1];
-       }
-       tstate[0].cs_next = &tstate[max_state];
-       tstate[0].cs_id = 0;
-       comp->last_cs = &tstate[0];
-       comp->last_recv = 255;
-       comp->last_xmit = 255;
-       comp->flags = SLF_TOSS;
-}
-
-
-/* ENCODE encodes a number that is known to be non-zero.  ENCODEZ
- * checks for zero (since zero has to be encoded in the long, 3 byte
- * form).
- */
-#define ENCODE(n) { \
-       if ((u_short)(n) >= 256) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-#define ENCODEZ(n) { \
-       if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-
-#define DECODEL(f) { \
-       if (*cp == 0) {\
-               (f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htonl(ntohl(f) + (u_long)*cp++); \
-       } \
-}
-
-#define DECODES(f) { \
-       if (*cp == 0) {\
-               (f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htons(ntohs(f) + (u_long)*cp++); \
-       } \
-}
-
-#define DECODEU(f) { \
-       if (*cp == 0) {\
-               (f) = htons((cp[1] << 8) | cp[2]); \
-               cp += 3; \
-       } else { \
-               (f) = htons((u_long)*cp++); \
-       } \
-}
-
-u_int
-vj_compress_tcp(m, ip, comp, compress_cid)
-       struct mbuf *m;
-       register struct ip *ip;
-       struct vjcompress *comp;
-       int compress_cid;
-{
-       register struct cstate *cs = comp->last_cs->cs_next;
-       register u_int hlen = ip->ip_hl;
-       register struct tcphdr *oth;
-       register struct tcphdr *th;
-       register u_int deltaS, deltaA;
-       register u_int changes = 0;
-       u_char new_seq[16];
-       register u_char *cp = new_seq;
-
-       /*
-        * Bail if this is an IP fragment or if the TCP packet isn't
-        * `compressible' (i.e., ACK isn't set or some other control bit is
-        * set).  (We assume that the caller has already made sure the
-        * packet is IP proto TCP).
-        */
-       if ((ip->ip_off & htons(0x3fff)) || m->m_len < 40)
-               return (TYPE_IP);
-
-       th = (struct tcphdr *)&((int *)ip)[hlen];
-       if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
-               return (TYPE_IP);
-       /*
-        * Packet is compressible -- we're going to send either a
-        * COMPRESSED_TCP or UNCOMPRESSED_TCP packet.  Either way we need
-        * to locate (or create) the connection state.  Special case the
-        * most recently used connection since it's most likely to be used
-        * again & we don't have to do any reordering if it's used.
-        */
-       INCR(sls_packets)
-       if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
-           ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
-           *(int *)th != ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl]) {
-               /*
-                * Wasn't the first -- search for it.
-                *
-                * States are kept in a circularly linked list with
-                * last_cs pointing to the end of the list.  The
-                * list is kept in lru order by moving a state to the
-                * head of the list whenever it is referenced.  Since
-                * the list is short and, empirically, the connection
-                * we want is almost always near the front, we locate
-                * states via linear search.  If we don't find a state
-                * for the datagram, the oldest state is (re-)used.
-                */
-               register struct cstate *lcs;
-               register struct cstate *lastcs = comp->last_cs;
-
-               do {
-                       lcs = cs; cs = cs->cs_next;
-                       INCR(sls_searches)
-                       if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
-                           && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
-                           && *(int *)th == ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl])
-                               goto found;
-               } while (cs != lastcs);
-
-               /*
-                * Didn't find it -- re-use oldest cstate.  Send an
-                * uncompressed packet that tells the other side what
-                * connection number we're using for this conversation.
-                * Note that since the state list is circular, the oldest
-                * state points to the newest and we only need to set
-                * last_cs to update the lru linkage.
-                */
-               INCR(sls_misses)
-               comp->last_cs = lcs;
-               hlen += th->th_off;
-               hlen <<= 2;
-               goto uncompressed;
-
-       found:
-               /*
-                * Found it -- move to the front on the connection list.
-                */
-               if (cs == lastcs)
-                       comp->last_cs = lcs;
-               else {
-                       lcs->cs_next = cs->cs_next;
-                       cs->cs_next = lastcs->cs_next;
-                       lastcs->cs_next = cs;
-               }
-       }
-
-       /*
-        * Make sure that only what we expect to change changed. The first
-        * line of the `if' checks the IP protocol version, header length &
-        * type of service.  The 2nd line checks the "Don't fragment" bit.
-        * The 3rd line checks the time-to-live and protocol (the protocol
-        * check is unnecessary but costless).  The 4th line checks the TCP
-        * header length.  The 5th line checks IP options, if any.  The 6th
-        * line checks TCP options, if any.  If any of these things are
-        * different between the previous & current datagram, we send the
-        * current datagram `uncompressed'.
-        */
-       oth = (struct tcphdr *)&((int *)&cs->cs_ip)[hlen];
-       deltaS = hlen;
-       hlen += th->th_off;
-       hlen <<= 2;
-
-       if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
-           ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
-           ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] ||
-           th->th_off != oth->th_off ||
-           (deltaS > 5 &&
-            BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
-           (th->th_off > 5 &&
-            BCMP(th + 1, oth + 1, (th->th_off - 5) << 2)))
-               goto uncompressed;
-
-       /*
-        * Figure out which of the changing fields changed.  The
-        * receiver expects changes in the order: urgent, window,
-        * ack, seq (the order minimizes the number of temporaries
-        * needed in this section of code).
-        */
-       if (th->th_flags & TH_URG) {
-               deltaS = ntohs(th->th_urp);
-               ENCODEZ(deltaS);
-               changes |= NEW_U;
-       } else if (th->th_urp != oth->th_urp)
-               /* argh! URG not set but urp changed -- a sensible
-                * implementation should never do this but RFC793
-                * doesn't prohibit the change so we have to deal
-                * with it. */
-                goto uncompressed;
-
-       if (deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) {
-               ENCODE(deltaS);
-               changes |= NEW_W;
-       }
-
-       if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
-               if (deltaA > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaA);
-               changes |= NEW_A;
-       }
-
-       if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
-               if (deltaS > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaS);
-               changes |= NEW_S;
-       }
-
-       switch(changes) {
-
-       case 0:
-               /*
-                * Nothing changed. If this packet contains data and the
-                * last one didn't, this is probably a data packet following
-                * an ack (normal on an interactive connection) and we send
-                * it compressed.  Otherwise it's probably a retransmit,
-                * retransmitted ack or window probe.  Send it uncompressed
-                * in case the other side missed the compressed version.
-                */
-               if (ip->ip_len != cs->cs_ip.ip_len &&
-                   ntohs(cs->cs_ip.ip_len) == hlen)
-                       break;
-
-               /* (fall through) */
-
-       case SPECIAL_I:
-       case SPECIAL_D:
-               /*
-                * actual changes match one of our special case encodings --
-                * send packet uncompressed.
-                */
-               goto uncompressed;
-
-       case NEW_S|NEW_A:
-               if (deltaS == deltaA &&
-                   deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for echoed terminal traffic */
-                       changes = SPECIAL_I;
-                       cp = new_seq;
-               }
-               break;
-
-       case NEW_S:
-               if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for data xfer */
-                       changes = SPECIAL_D;
-                       cp = new_seq;
-               }
-               break;
-       }
-
-       deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
-       if (deltaS != 1) {
-               ENCODEZ(deltaS);
-               changes |= NEW_I;
-       }
-       if (th->th_flags & TH_PUSH)
-               changes |= TCP_PUSH_BIT;
-       /*
-        * Grab the cksum before we overwrite it below.  Then update our
-        * state with this packet's header.
-        */
-       deltaA = ntohs(th->th_sum);
-       BCOPY(ip, &cs->cs_ip, hlen);
-
-       /*
-        * We want to use the original packet as our compressed packet.
-        * (cp - new_seq) is the number of bytes we need for compressed
-        * sequence numbers.  In addition we need one byte for the change
-        * mask, one for the connection id and two for the tcp checksum.
-        * So, (cp - new_seq) + 4 bytes of header are needed.  hlen is how
-        * many bytes of the original packet to toss so subtract the two to
-        * get the new packet size.
-        */
-       deltaS = cp - new_seq;
-       cp = (u_char *)ip;
-       if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
-               comp->last_xmit = cs->cs_id;
-               hlen -= deltaS + 4;
-               cp += hlen;
-               *cp++ = changes | NEW_C;
-               *cp++ = cs->cs_id;
-       } else {
-               hlen -= deltaS + 3;
-               cp += hlen;
-               *cp++ = changes;
-       }
-       m->m_len -= hlen;
-       m->m_data += hlen;
-       *cp++ = deltaA >> 8;
-       *cp++ = deltaA;
-       BCOPY(new_seq, cp, deltaS);
-       INCR(sls_compressed)
-       return (TYPE_COMPRESSED_TCP);
-
-       /*
-        * Update connection state cs & send uncompressed packet ('uncompressed'
-        * means a regular ip/tcp packet but with the 'conversation id' we hope
-        * to use on future compressed packets in the protocol field).
-        */
-uncompressed:
-       BCOPY(ip, &cs->cs_ip, hlen);
-       ip->ip_p = cs->cs_id;
-       comp->last_xmit = cs->cs_id;
-       return (TYPE_UNCOMPRESSED_TCP);
-}
-
-
-int
-vj_uncompress_tcp(bufp, len, type, comp)
-       u_char **bufp;
-       int len;
-       u_int type;
-       struct vjcompress *comp;
-{
-       u_char *hdr, *cp;
-       int hlen, vjlen;
-
-       cp = bufp? *bufp: NULL;
-       vjlen = vj_uncompress_tcp_core(cp, len, len, type, comp, &hdr, &hlen);
-       if (vjlen < 0)
-               return (0);     /* error */
-       if (vjlen == 0)
-               return (len);   /* was uncompressed already */
-
-       cp += vjlen;
-       len -= vjlen;
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  If we're not aligned on a 4-byte boundary, copy the
-        * data down so the ip & tcp headers will be aligned.  Then back up
-        * cp by the tcp/ip header length to make room for the reconstructed
-        * header (we assume the packet we were handed has enough space to
-        * prepend 128 bytes of header).
-        */
-       if ((int)cp & 3) {
-               if (len > 0)
-                       (void) ovbcopy(cp, (caddr_t)((int)cp &~ 3), len);
-               cp = (u_char *)((int)cp &~ 3);
-       }
-       cp -= hlen;
-       len += hlen;
-       BCOPY(hdr, cp, hlen);
-
-       *bufp = cp;
-       return (len);
-}
-
-/*
- * Uncompress a packet of total length total_len.  The first buflen
- * bytes are at buf; this must include the entire (compressed or
- * uncompressed) TCP/IP header.  This procedure returns the length
- * of the VJ header, with a pointer to the uncompressed IP header
- * in *hdrp and its length in *hlenp.
- */
-int
-vj_uncompress_tcp_core(buf, buflen, total_len, type, comp, hdrp, hlenp)
-       u_char *buf;
-       int buflen, total_len;
-       u_int type;
-       struct vjcompress *comp;
-       u_char **hdrp;
-       u_int *hlenp;
-{
-       register u_char *cp;
-       register u_int hlen, changes;
-       register struct tcphdr *th;
-       register struct cstate *cs;
-       register struct ip *ip;
-       register u_short *bp;
-       register u_int vjlen;
-
-       switch (type) {
-
-       case TYPE_UNCOMPRESSED_TCP:
-               ip = (struct ip *) buf;
-               if (ip->ip_p >= MAX_STATES)
-                       goto bad;
-               cs = &comp->rstate[comp->last_recv = ip->ip_p];
-               comp->flags &=~ SLF_TOSS;
-               ip->ip_p = IPPROTO_TCP;
-               /*
-                * Calculate the size of the TCP/IP header and make sure that
-                * we don't overflow the space we have available for it.
-                */
-               hlen = ip->ip_hl << 2;
-               if (hlen + sizeof(struct tcphdr) > buflen)
-                       goto bad;
-               hlen += ((struct tcphdr *)&((char *)ip)[hlen])->th_off << 2;
-               if (hlen > MAX_HDR || hlen > buflen)
-                       goto bad;
-               BCOPY(ip, &cs->cs_ip, hlen);
-               cs->cs_hlen = hlen;
-               INCR(sls_uncompressedin)
-               *hdrp = (u_char *) &cs->cs_ip;
-               *hlenp = hlen;
-               return (0);
-
-       default:
-               goto bad;
-
-       case TYPE_COMPRESSED_TCP:
-               break;
-       }
-       /* We've got a compressed packet. */
-       INCR(sls_compressedin)
-       cp = buf;
-       changes = *cp++;
-       if (changes & NEW_C) {
-               /* Make sure the state index is in range, then grab the state.
-                * If we have a good state index, clear the 'discard' flag. */
-               if (*cp >= MAX_STATES)
-                       goto bad;
-
-               comp->flags &=~ SLF_TOSS;
-               comp->last_recv = *cp++;
-       } else {
-               /* this packet has an implicit state index.  If we've
-                * had a line error since the last time we got an
-                * explicit state index, we have to toss the packet. */
-               if (comp->flags & SLF_TOSS) {
-                       INCR(sls_tossed)
-                       return (-1);
-               }
-       }
-       cs = &comp->rstate[comp->last_recv];
-       hlen = cs->cs_ip.ip_hl << 2;
-       th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
-       th->th_sum = htons((*cp << 8) | cp[1]);
-       cp += 2;
-       if (changes & TCP_PUSH_BIT)
-               th->th_flags |= TH_PUSH;
-       else
-               th->th_flags &=~ TH_PUSH;
-
-       switch (changes & SPECIALS_MASK) {
-       case SPECIAL_I:
-               {
-               register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
-               th->th_ack = htonl(ntohl(th->th_ack) + i);
-               th->th_seq = htonl(ntohl(th->th_seq) + i);
-               }
-               break;
-
-       case SPECIAL_D:
-               th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len)
-                                  - cs->cs_hlen);
-               break;
-
-       default:
-               if (changes & NEW_U) {
-                       th->th_flags |= TH_URG;
-                       DECODEU(th->th_urp)
-               } else
-                       th->th_flags &=~ TH_URG;
-               if (changes & NEW_W)
-                       DECODES(th->th_win)
-               if (changes & NEW_A)
-                       DECODEL(th->th_ack)
-               if (changes & NEW_S)
-                       DECODEL(th->th_seq)
-               break;
-       }
-       if (changes & NEW_I) {
-               DECODES(cs->cs_ip.ip_id)
-       } else
-               cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1);
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  Fill in the IP total length and update the IP
-        * header checksum.
-        */
-       vjlen = cp - buf;
-       buflen -= vjlen;
-       if (buflen < 0)
-               /* we must have dropped some characters (crc should detect
-                * this but the old slip framing won't) */
-               goto bad;
-
-       total_len += cs->cs_hlen - vjlen;
-       cs->cs_ip.ip_len = htons(total_len);
-
-       /* recompute the ip header checksum */
-       bp = (u_short *) &cs->cs_ip;
-       cs->cs_ip.ip_sum = 0;
-       for (changes = 0; hlen > 0; hlen -= 2)
-               changes += *bp++;
-       changes = (changes & 0xffff) + (changes >> 16);
-       changes = (changes & 0xffff) + (changes >> 16);
-       cs->cs_ip.ip_sum = ~ changes;
-
-       *hdrp = (u_char *) &cs->cs_ip;
-       *hlenp = cs->cs_hlen;
-       return vjlen;
-
-bad:
-       comp->flags |= SLF_TOSS;
-       INCR(sls_errorin)
-       return (-1);
-}
diff --git a/freebsd-2.0/pppcompress.h b/freebsd-2.0/pppcompress.h
deleted file mode 100644 (file)
index bbdc973..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Definitions for tcp compression routines.
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- *
- *     From:   slcompress.h    7.4     90/06/28
- *     $Id: pppcompress.h,v 1.1 1994/12/15 22:27:17 paulus Exp $
- */
-
-#ifndef _NET_PPPCOMPRESS_H_
-#define _NET_PPPCOMPRESS_H_
-
-#define MAX_STATES 16          /* must be > 2 and < 256 */
-#define MAX_HDR MLEN           /* XXX 4bsd-ism: should really be 128 */
-
-/*
- * Compressed packet format:
- *
- * The first octet contains the packet type (top 3 bits), TCP
- * 'push' bit, and flags that indicate which of the 4 TCP sequence
- * numbers have changed (bottom 5 bits).  The next octet is a
- * conversation number that associates a saved IP/TCP header with
- * the compressed packet.  The next two octets are the TCP checksum
- * from the original datagram.  The next 0 to 15 octets are
- * sequence number changes, one change per bit set in the header
- * (there may be no changes and there are two special cases where
- * the receiver implicitly knows what changed -- see below).
- * 
- * There are 5 numbers which can change (they are always inserted
- * in the following order): TCP urgent pointer, window,
- * acknowlegement, sequence number and IP ID.  (The urgent pointer
- * is different from the others in that its value is sent, not the
- * change in value.)  Since typical use of SLIP links is biased
- * toward small packets (see comments on MTU/MSS below), changes
- * use a variable length coding with one octet for numbers in the
- * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
- * range 256 - 65535 or 0.  (If the change in sequence number or
- * ack is more than 65535, an uncompressed packet is sent.)
- */
-
-/*
- * Packet types (must not conflict with IP protocol version)
- *
- * The top nibble of the first octet is the packet type.  There are
- * three possible types: IP (not proto TCP or tcp with one of the
- * control flags set); uncompressed TCP (a normal IP/TCP packet but
- * with the 8-bit protocol field replaced by an 8-bit connection id --
- * this type of packet syncs the sender & receiver); and compressed
- * TCP (described above).
- *
- * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
- * is logically part of the 4-bit "changes" field that follows.  Top
- * three bits are actual packet type.  For backward compatibility
- * and in the interest of conserving bits, numbers are chosen so the
- * IP protocol version number (4) which normally appears in this nibble
- * means "IP packet".
- */
-
-/* packet types */
-#define TYPE_IP 0x40
-#define TYPE_UNCOMPRESSED_TCP 0x70
-#define TYPE_COMPRESSED_TCP 0x80
-#define TYPE_ERROR 0x00
-
-/* Bits in first octet of compressed packet */
-#define NEW_C  0x40    /* flag bits for what changed in a packet */
-#define NEW_I  0x20
-#define NEW_S  0x08
-#define NEW_A  0x04
-#define NEW_W  0x02
-#define NEW_U  0x01
-
-/* reserved, special-case values of above */
-#define SPECIAL_I (NEW_S|NEW_W|NEW_U)          /* echoed interactive traffic */
-#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)    /* unidirectional data */
-#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
-
-#define TCP_PUSH_BIT 0x10
-
-
-/*
- * "state" data for each active tcp conversation on the wire.  This is
- * basically a copy of the entire IP/TCP header from the last packet
- * we saw from the conversation together with a small identifier
- * the transmit & receive ends of the line use to locate saved header.
- */
-struct cstate {
-       struct cstate *cs_next; /* next most recently used cstate (xmit only) */
-       u_short cs_hlen;        /* size of hdr (receive only) */
-       u_char cs_id;           /* connection # associated with this state */
-       u_char cs_filler;
-       union {
-               char csu_hdr[MAX_HDR];
-               struct ip csu_ip;       /* ip/tcp hdr from most recent packet */
-       } slcs_u;
-};
-#define cs_ip slcs_u.csu_ip
-#define cs_hdr slcs_u.csu_hdr
-
-/*
- * all the state data for one serial line (we need one of these
- * per line).
- */
-struct vjcompress {
-       struct cstate *last_cs; /* most recently used tstate */
-       u_char last_recv;       /* last rcvd conn. id */
-       u_char last_xmit;       /* last sent conn. id */
-       u_short flags;
-#ifndef SL_NO_STATS
-       int sls_packets;        /* outbound packets */
-       int sls_compressed;     /* outbound compressed packets */
-       int sls_searches;       /* searches for connection state */
-       int sls_misses;         /* times couldn't find conn. state */
-       int sls_uncompressedin; /* inbound uncompressed packets */
-       int sls_compressedin;   /* inbound compressed packets */
-       int sls_errorin;        /* inbound unknown type packets */
-       int sls_tossed;         /* inbound packets tossed because of error */
-#endif
-       struct cstate tstate[MAX_STATES];       /* xmit connection states */
-       struct cstate rstate[MAX_STATES];       /* receive connection states */
-};
-/* flag values */
-#define SLF_TOSS 1             /* tossing rcvd frames because of input err */
-
-void    vj_compress_init __P((struct vjcompress *, int));
-u_int   vj_compress_tcp __P((struct mbuf *,
-           struct ip *, struct vjcompress *, int));
-int     vj_uncompress_tcp __P((u_char **, int, u_int, struct vjcompress *));
-int     vj_uncompress_tcp_core __P((u_char *, int, int, u_int,
-           struct vjcompress *, u_char **, u_int *));
-
-#endif /* _NET_PPPCOMPRESS_H_ */
diff --git a/freebsd-2.2.8/Makefile.top b/freebsd-2.2.8/Makefile.top
deleted file mode 100644 (file)
index 4d06f11..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# ppp top level makefile for *bsd systems
-#
-
-BINDIR?= /usr/sbin
-
-SUBDIR=        chat pppd pppstats
-MAKE+=  BINDIR=$(BINDIR)
-
-kernel:
-       @sh -e freebsd-2.2.8/kinstall.sh
-
-.include <bsd.subdir.mk>
diff --git a/freebsd-2.2.8/kinstall.sh b/freebsd-2.2.8/kinstall.sh
deleted file mode 100644 (file)
index f56c456..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/sh
-
-# This script modifies the kernel sources in /usr/src/sys to install
-# ppp-2.3.  It is intended to be run in the ppp-2.3 directory.
-#
-# This works for FreeBSD 2.2.8
-# Most of the kernel files are already part of the kernel source
-# but, this updates them for synchronous HDLC operation
-#
-# Paul Fulghum         19-Apr-99
-
-KPATH=$(uname -v | sed 's/.*://')
-CONF=$(echo $KPATH | sed 's;.*compile/;;')
-SYS=$(echo $KPATH | sed 's;/compile/.*$;;')
-ARCHDIR=$SYS/i386
-CFILE=$ARCHDIR/conf/$CONF
-SRC=freebsd-2.2.8
-DOCONF=
-DOMAKE=
-CONFIG=config
-
-# Patch files in /usr/src/sys/net
-
-for f in if_ppp.h if_ppp.c ppp_tty.c ; do
-  dest=$SYS/net/$f
-  patch=$SRC/patch.$f
-  if [ -f $dest ]; then
-     echo -n "Patching $dest..."
-     if patch -s -C -N $dest < $patch 2> /dev/null; then
-       patch -s -N $dest < $patch
-        echo "successful."
-        DOMAKE=yes
-     else
-        if patch -s -C -R $dest < $patch 2> /dev/null; then
-           echo "already applied."
-        else
-           echo "failed (incorrect version or already applied)."
-        fi
-     fi
-  else
-    echo "Warning, file $dest not found"
-  fi
-done
-
-for f in if_ppp.h ; do
-  dest=/usr/include/net/$f
-  patch=$SRC/patch.$f
-  if [ -f $dest ]; then
-     echo -n "Patching $dest..."
-     if patch -s -C -N $dest < $patch 2> /dev/null; then
-       patch -s -N $dest < $patch
-        echo "successful."
-        DOMAKE=yes
-     else
-        if patch -s -C -R $dest < $patch 2> /dev/null; then
-           echo "already applied."
-        else
-           echo "failed (incorrect version or already applied)."
-        fi
-     fi
-  else
-    echo "Warning, file $dest not found"
-  fi
-done
-
-# Tell the user to add a pseudo-device line to the configuration file.
-
-if [ -f $CFILE ]; then
-  if ! grep -q '^[     ]*pseudo-device[        ][      ]*ppp' $CFILE; then
-    echo
-    echo "The currently-running kernel was built from configuration file"
-    echo "$CFILE, which does not include PPP."
-    echo "You need either to add a line like 'pseudo-device ppp 2' to"
-    echo "this file, or use another configuration file which includes"
-    echo "a line like this."
-    DOCONF=yes
-  fi
-fi
-
-if [ $DOCONF ]; then
-  echo
-  echo "You need to configure and build a new kernel."
-  echo "The procedure for doing this involves the following commands."
-  echo "(\"$CONF\" may be replaced by the name of another config file.)"
-  echo
-  echo "       cd $ARCHDIR/conf"
-  echo "       /usr/sbin/$CONFIG $CONF"
-  echo "       cd ../../compile/$CONF"
-  echo "       make depend"
-  DOMAKE=yes
-elif [ $DOMAKE ]; then
-  echo "You need to build a new kernel."
-  echo "The procedure for doing this involves the following commands."
-  echo
-  echo "       cd $KPATH"
-fi
-if [ $DOMAKE ]; then
-  echo "       make"
-  echo
-  echo "Then copy the new kernel ($KPATH/kernel) to /"
-  echo "and reboot.  (Keep a copy of the old /kernel, just in case.)"
-fi
diff --git a/freebsd-2.2.8/patch.if_ppp.c b/freebsd-2.2.8/patch.if_ppp.c
deleted file mode 100644 (file)
index 6bd8c69..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
---- sys.stable/net/if_ppp.c    Fri Apr 16 16:14:37 1999
-+++ /usr/src/synclink/bsd2/if_ppp.c    Tue Apr 13 09:54:07 1999
-@@ -930,7 +930,6 @@
-     struct ppp_softc *sc;
- {
-     int s = splimp();
--
-     sc->sc_flags &= ~SC_TBUSY;
-     schednetisr(NETISR_PPP);
-     splx(s);
-@@ -1082,7 +1081,7 @@
-     for (i = 0; i < NPPP; ++i, ++sc) {
-       s = splimp();
-       if (!(sc->sc_flags & SC_TBUSY)
--          && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
-+          && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head || sc->sc_outm)) {
-           sc->sc_flags |= SC_TBUSY;
-           splx(s);
-           (*sc->sc_start)(sc);
diff --git a/freebsd-2.2.8/patch.if_ppp.h b/freebsd-2.2.8/patch.if_ppp.h
deleted file mode 100644 (file)
index 59538b8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
---- sys.stable/net/if_ppp.h    Fri Apr 16 16:14:37 1999
-+++ /usr/src/synclink/bsd2/if_ppp.h    Tue Apr 20 15:30:48 1999
-@@ -53,6 +53,7 @@
- #define SC_RCV_B7_1   0x02000000      /* have rcvd char with bit 7 = 1 */
- #define SC_RCV_EVNP   0x04000000      /* have rcvd char with even parity */
- #define SC_RCV_ODDP   0x08000000      /* have rcvd char with odd parity */
-+#define SC_SYNC               0x00200000      /* synchronous HDLC */
- #define       SC_MASK         0x0fff00ff      /* bits that user can change */
- /*
diff --git a/freebsd-2.2.8/patch.ppp_tty.c b/freebsd-2.2.8/patch.ppp_tty.c
deleted file mode 100644 (file)
index 9b7a416..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
---- sys.stable/net/ppp_tty.c   Fri Apr 16 16:14:38 1999
-+++ /usr/src/synclink/bsd2/ppp_tty.c   Thu Apr 15 14:40:51 1999
-@@ -113,7 +113,10 @@
- static int    pppinput __P((int c, struct tty *tp));
- static int    pppstart __P((struct tty *tp));
-+static void   ppprcvframe __P((struct ppp_softc *sc, struct mbuf *m));
-+
- static u_short        pppfcs __P((u_short fcs, u_char *cp, int len));
-+static void   pppsyncstart __P((register struct ppp_softc *sc));
- static void   pppasyncstart __P((struct ppp_softc *));
- static void   pppasyncctlp __P((struct ppp_softc *));
- static void   pppasyncrelinq __P((struct ppp_softc *));
-@@ -121,6 +124,7 @@
- static void   ppp_timeout __P((void *));
- static void   pppgetm __P((struct ppp_softc *sc));
- static void   ppplogchar __P((struct ppp_softc *, int));
-+static void   pppdumpframe __P((struct ppp_softc *sc,struct mbuf* m,int xmit));
- /* XXX called from if_ppp.c - layering violation */
- void          pppasyncattach __P((void *));
-@@ -473,6 +477,10 @@
-     error = 0;
-     switch (cmd) {
-+    case TIOCRCVFRAME:
-+      ppprcvframe(sc,*((struct mbuf **)data));
-+      break;
-+      
-     case PPPIOCSASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-@@ -517,6 +525,111 @@
-     return error;
- }
-+/* receive a complete ppp frame from device in synchronous
-+ * hdlc mode. caller gives up ownership of mbuf
-+ */
-+static void ppprcvframe(struct ppp_softc *sc, struct mbuf *m)
-+{
-+      int len, s;
-+      struct mbuf *n;
-+      u_char hdr[4];
-+      int hlen,count;
-+              
-+      for (n=m,len=0;n != NULL;n = n->m_next)
-+              len += n->m_len;
-+      if (len==0) {
-+              m_freem(m);
-+              return;
-+      }
-+      
-+      /* extract PPP header from mbuf chain (1 to 4 bytes) */
-+      for (n=m,hlen=0;n!=NULL && hlen<sizeof(hdr);n=n->m_next) {
-+              count = (sizeof(hdr)-hlen) < n->m_len ?
-+                              sizeof(hdr)-hlen : n->m_len;
-+              bcopy(mtod(n,u_char*),&hdr[hlen],count);
-+              hlen+=count;
-+      }
-+      
-+      s = spltty();
-+      
-+      /* if AFCF compressed then prepend AFCF */
-+      if (hdr[0] != PPP_ALLSTATIONS) {
-+              if (sc->sc_flags & SC_REJ_COMP_AC) {
-+                      if (sc->sc_flags & SC_DEBUG)
-+                              printf("ppp%d: garbage received: 0x%x (need 0xFF)\n",
-+                                      sc->sc_if.if_unit, hdr[0]);
-+                              goto bail;
-+                      }
-+              M_PREPEND(m,2,M_DONTWAIT);              
-+              if (m==NULL) {
-+                      splx(s);
-+                      return;
-+              }
-+              hdr[3] = hdr[1];
-+              hdr[2] = hdr[0];
-+              hdr[0] = PPP_ALLSTATIONS;
-+              hdr[1] = PPP_UI;
-+              len += 2;
-+      }
-+
-+      /* if protocol field compressed, add MSB of protocol field = 0 */
-+      if (hdr[2] & 1) {
-+              /* a compressed protocol */
-+              M_PREPEND(m,1,M_DONTWAIT);              
-+              if (m==NULL) {
-+                      splx(s);
-+                      return;
-+              }
-+              hdr[3] = hdr[2];
-+              hdr[2] = 0;
-+              len++;
-+      } 
-+      
-+      /* valid LSB of protocol field has bit0 set */
-+      if (!(hdr[3] & 1)) {
-+              if (sc->sc_flags & SC_DEBUG)
-+                      printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit,
-+                              (hdr[2] << 8) + hdr[3]);
-+                      goto bail;
-+      }
-+      
-+      /* packet beyond configured mru? */
-+      if (len > sc->sc_mru + PPP_HDRLEN) {
-+              if (sc->sc_flags & SC_DEBUG)
-+                      printf("ppp%d: packet too big\n", sc->sc_if.if_unit);
-+              goto bail;
-+      }
-+      
-+      /* add expanded 4 byte header to mbuf chain */
-+      for (n=m,hlen=0;n!=NULL && hlen<sizeof(hdr);n=n->m_next) {
-+              count = (sizeof(hdr)-hlen) < n->m_len ?
-+                              sizeof(hdr)-hlen : n->m_len;
-+              bcopy(&hdr[hlen],mtod(n,u_char*),count);
-+              hlen+=count;
-+      }
-+      
-+      /* if_ppp.c requires the PPP header and IP header */
-+      /* to be contiguous */
-+      count = len < MHLEN ? len : MHLEN;
-+      if (m->m_len < count) {
-+              m = m_pullup(m,count);
-+              if (m==NULL)
-+                      goto bail;
-+      }
-+      
-+      sc->sc_stats.ppp_ibytes += len;
-+      
-+      if (sc->sc_flags & SC_LOG_RAWIN)
-+              pppdumpframe(sc,m,0);
-+    
-+      ppppktin(sc, m, 0);
-+      splx(s);
-+      return;
-+bail: 
-+      m_freem(m);
-+      splx(s);
-+}
-+
- /*
-  * FCS lookup table as calculated by genfcstab.
-  */
-@@ -566,6 +679,39 @@
-     return (fcs);
- }
-+/* This gets called at splsoftnet from pppasyncstart at various times
-+ * when there is data ready to be sent.
-+ */
-+static void pppsyncstart(register struct ppp_softc *sc)
-+{
-+      struct tty *tp = (struct tty *) sc->sc_devp;
-+      struct mbuf *m, *n;
-+      int len;
-+    
-+      for(m = sc->sc_outm;;) {
-+              if (m == NULL) {
-+                      m = ppp_dequeue(sc);    /* get new packet */
-+                      if (m == NULL)
-+                              break;          /* no more packets */
-+                      if (sc->sc_flags & SC_DEBUG)
-+                              pppdumpframe(sc,m,1);
-+              }
-+              microtime(&sc->sc_if.if_lastchange);
-+              for(n=m,len=0;n!=NULL;n=n->m_next)
-+                      len += n->m_len;
-+                      
-+              /* call device driver IOCTL to transmit a frame */
-+              if ((*cdevsw[major(tp->t_dev)]->d_ioctl)
-+                      (tp->t_dev,TIOCXMTFRAME,(caddr_t)&m,0,0)) {
-+                      /* busy or error, set as current packet */
-+                      sc->sc_outm = m;
-+                      break;
-+              }
-+              sc->sc_outm = m = NULL;
-+              sc->sc_stats.ppp_obytes += len;
-+      }
-+}
-+
- /*
-  * This gets called at splsoftnet from if_ppp.c at various times
-  * when there is data ready to be sent.
-@@ -582,6 +728,11 @@
-     struct mbuf *m2;
-     int s;
-+    if (sc->sc_flags & SC_SYNC){
-+      pppsyncstart(sc);
-+      return;
-+    }
-+    
-     idle = 0;
-     /* XXX assumes atomic access to *tp although we're not at spltty(). */
-     while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-@@ -1125,6 +1276,44 @@
-               sc->sc_rawin_count, sc->sc_rawin, " ");
-       sc->sc_rawin_count = 0;
-     }
-+}
-+
-+static void pppdumpframe(struct ppp_softc *sc,struct mbuf* m,int xmit)
-+{
-+      int i,lcount,copycount,count;
-+      char lbuf[16];
-+      char *data;
-+      
-+      if (m == NULL)
-+              return;
-+              
-+      for(count=m->m_len,data=mtod(m,char*);m != NULL;) {
-+              /* build a line of output */
-+              for(lcount=0;lcount < sizeof(lbuf);lcount += copycount) {
-+                      if (!count) {
-+                              m = m->m_next;
-+                              if (m == NULL)
-+                                      break;
-+                              count = m->m_len;
-+                              data  = mtod(m,char*);
-+                      }
-+                      copycount = (count > sizeof(lbuf)-lcount) ?
-+                                      sizeof(lbuf)-lcount : count;
-+                      bcopy(data,&lbuf[lcount],copycount);
-+                      data  += copycount;
-+                      count -= copycount;
-+              }
-+
-+              /* output line (hex 1st, then ascii) */         
-+              printf("ppp%d %s:",sc->sc_if.if_unit,xmit ? "output":"input ");
-+              for(i=0;i<lcount;i++)
-+                      printf("%02x ",(u_char)lbuf[i]);
-+              for(;i<sizeof(lbuf);i++)
-+                      printf("   ");
-+              for(i=0;i<lcount;i++)
-+                      printf("%c",(lbuf[i]>=040 && lbuf[i]<=0176)?lbuf[i]:'.');
-+              printf("\n");
-+      }
- }
- #endif        /* NPPP > 0 */
diff --git a/freebsd-3.0/Makefile.top b/freebsd-3.0/Makefile.top
deleted file mode 100644 (file)
index a8b635d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# ppp top level makefile for *bsd systems
-#
-
-BINDIR?= /usr/sbin
-
-SUBDIR=        chat pppd pppstats
-MAKE+=  BINDIR=$(BINDIR)
-
-kernel:
-       @sh -e freebsd-3.0/kinstall.sh
-
-.include <bsd.subdir.mk>
diff --git a/freebsd-3.0/kinstall.sh b/freebsd-3.0/kinstall.sh
deleted file mode 100644 (file)
index 7a44f95..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/bin/sh
-
-# This script modifies the kernel sources in /usr/src/sys to install
-# ppp-2.3.  It is intended to be run in the ppp-2.3 directory.
-#
-# This works for FreeBSD 3.0/3.1
-# Most of the kernel files are already part of the kernel source
-# but, this updates them for synchronous HDLC operation
-#
-# Paul Fulghum paulkf@microgate.com            August 11, 1999
-#
-# 990911 - Added patch for ttycom.h that defines new IOCTL for sync support.
-# 
-
-KPATH=$(uname -v | sed 's/.*://')
-CONF=$(echo $KPATH | sed 's;.*compile/;;')
-SYS=$(echo $KPATH | sed 's;/compile/.*$;;')
-ARCHDIR=$SYS/i386
-CFILE=$ARCHDIR/conf/$CONF
-SRC=freebsd-3.0
-DOCONF=
-DOMAKE=
-CONFIG=config
-
-# Patch files in /usr/src/sys/net
-
-for f in if_ppp.h if_ppp.c ppp_tty.c ; do
-  dest=$SYS/net/$f
-  patch=$SRC/patch.$f
-  if [ -f $dest ]; then
-     echo -n "Patching $dest..."
-     if patch -s -C -N $dest < $patch 2> /dev/null; then
-       patch -s -N $dest < $patch
-        echo "successful."
-        DOMAKE=yes
-     else
-        if patch -s -C -R $dest < $patch 2> /dev/null; then
-           echo "already applied."
-        else
-           echo "failed (incorrect version or already applied)."
-        fi
-     fi
-  else
-    echo "Warning, file $dest not found"
-  fi
-done
-
-# Patch files in /usr/src/sys/sys
-
-for f in ttycom.h ; do
-  dest=$SYS/sys/$f
-  patch=$SRC/patch.$f
-  if [ -f $dest ]; then
-     echo -n "Patching $dest..."
-     if patch -s -C -N $dest < $patch 2> /dev/null; then
-       patch -s -N $dest < $patch
-        echo "successful."
-        DOMAKE=yes
-     else
-        if patch -s -C -R $dest < $patch 2> /dev/null; then
-           echo "already applied."
-        else
-           echo "failed (incorrect version or already applied)."
-        fi
-     fi
-  else
-    echo "Warning, file $dest not found"
-  fi
-done
-
-# Patch files in /usr/include/net
-
-for f in if_ppp.h ; do
-  dest=/usr/include/net/$f
-  patch=$SRC/patch.$f
-  if [ -f $dest ]; then
-     echo -n "Patching $dest..."
-     if patch -s -C -N $dest < $patch 2> /dev/null; then
-       patch -s -N $dest < $patch
-        echo "successful."
-        DOMAKE=yes
-     else
-        if patch -s -C -R $dest < $patch 2> /dev/null; then
-           echo "already applied."
-        else
-           echo "failed (incorrect version or already applied)."
-        fi
-     fi
-  else
-    echo "Warning, file $dest not found"
-  fi
-done
-
-# Patch files in /usr/include/sys
-
-for f in ttycom.h ; do
-  dest=/usr/include/sys/$f
-  patch=$SRC/patch.$f
-  if [ -f $dest ]; then
-     echo -n "Patching $dest..."
-     if patch -s -C -N $dest < $patch 2> /dev/null; then
-       patch -s -N $dest < $patch
-        echo "successful."
-        DOMAKE=yes
-     else
-        if patch -s -C -R $dest < $patch 2> /dev/null; then
-           echo "already applied."
-        else
-           echo "failed (incorrect version or already applied)."
-        fi
-     fi
-  else
-    echo "Warning, file $dest not found"
-  fi
-done
-
-# Tell the user to add a pseudo-device line to the configuration file.
-
-if [ -f $CFILE ]; then
-  if ! grep -q '^[     ]*pseudo-device[        ][      ]*ppp' $CFILE; then
-    echo
-    echo "The currently-running kernel was built from configuration file"
-    echo "$CFILE, which does not include PPP."
-    echo "You need either to add a line like 'pseudo-device ppp 2' to"
-    echo "this file, or use another configuration file which includes"
-    echo "a line like this."
-    DOCONF=yes
-  fi
-fi
-
-if [ $DOCONF ]; then
-  echo
-  echo "You need to configure and build a new kernel."
-  echo "The procedure for doing this involves the following commands."
-  echo "(\"$CONF\" may be replaced by the name of another config file.)"
-  echo
-  echo "       cd $ARCHDIR/conf"
-  echo "       /usr/sbin/$CONFIG $CONF"
-  echo "       cd ../../compile/$CONF"
-  echo "       make depend"
-  DOMAKE=yes
-elif [ $DOMAKE ]; then
-  echo "You need to build a new kernel."
-  echo "The procedure for doing this involves the following commands."
-  echo
-  echo "       cd $KPATH"
-fi
-if [ $DOMAKE ]; then
-  echo "       make"
-  echo
-  echo "Then copy the new kernel ($KPATH/kernel) to /"
-  echo "and reboot.  (Keep a copy of the old /kernel, just in case.)"
-fi
diff --git a/freebsd-3.0/patch.if_ppp.c b/freebsd-3.0/patch.if_ppp.c
deleted file mode 100644 (file)
index 4da2649..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- sys.stable/net/if_ppp.c    Sat Jun 20 11:28:01 1998
-+++ /usr/src/synclink/bsd3/if_ppp.c    Fri Apr 16 12:54:12 1999
-@@ -1084,7 +1084,7 @@
-     for (i = 0; i < NPPP; ++i, ++sc) {
-       s = splimp();
-       if (!(sc->sc_flags & SC_TBUSY)
--          && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
-+          && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head || sc->sc_outm)) {
-           sc->sc_flags |= SC_TBUSY;
-           splx(s);
-           (*sc->sc_start)(sc);
diff --git a/freebsd-3.0/patch.if_ppp.h b/freebsd-3.0/patch.if_ppp.h
deleted file mode 100644 (file)
index 3937618..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
---- sys.stable/net/if_ppp.h    Sat Oct 18 04:02:39 1997
-+++ /usr/src/synclink/bsd3/if_ppp.h    Fri Apr 16 12:54:12 1999
-@@ -53,6 +53,7 @@
- #define SC_RCV_B7_1   0x02000000      /* have rcvd char with bit 7 = 1 */
- #define SC_RCV_EVNP   0x04000000      /* have rcvd char with even parity */
- #define SC_RCV_ODDP   0x08000000      /* have rcvd char with odd parity */
-+#define SC_SYNC               0x00200000      /* synchronous HDLC */
- #define       SC_MASK         0x0fff00ff      /* bits that user can change */
- /*
diff --git a/freebsd-3.0/patch.ppp_tty.c b/freebsd-3.0/patch.ppp_tty.c
deleted file mode 100644 (file)
index a4c9e3a..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
---- sys.stable/net/ppp_tty.c   Sun Jan 17 14:53:47 1999
-+++ /usr/src/synclink/bsd3/ppp_tty.c   Fri Apr 16 12:54:20 1999
-@@ -110,7 +110,10 @@
- static int    pppinput __P((int c, struct tty *tp));
- static int    pppstart __P((struct tty *tp));
-+static void   ppprcvframe __P((struct ppp_softc *sc, struct mbuf *m));
-+
- static u_short        pppfcs __P((u_short fcs, u_char *cp, int len));
-+static void   pppsyncstart __P((register struct ppp_softc *sc));
- static void   pppasyncstart __P((struct ppp_softc *));
- static void   pppasyncctlp __P((struct ppp_softc *));
- static void   pppasyncrelinq __P((struct ppp_softc *));
-@@ -118,6 +121,7 @@
- static void   ppp_timeout __P((void *));
- static void   pppgetm __P((struct ppp_softc *sc));
- static void   ppplogchar __P((struct ppp_softc *, int));
-+static void   pppdumpframe __P((struct ppp_softc *sc,struct mbuf* m,int xmit));
- /* XXX called from if_ppp.c - layering violation */
- void          pppasyncattach __P((void *));
-@@ -471,6 +475,10 @@
-     error = 0;
-     switch (cmd) {
-+    case TIOCRCVFRAME:
-+      ppprcvframe(sc,*((struct mbuf **)data));
-+      break;
-+      
-     case PPPIOCSASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-@@ -515,6 +523,111 @@
-     return error;
- }
-+/* receive a complete ppp frame from device in synchronous
-+ * hdlc mode. caller gives up ownership of mbuf
-+ */
-+static void ppprcvframe(struct ppp_softc *sc, struct mbuf *m)
-+{
-+      int len, s;
-+      struct mbuf *n;
-+      u_char hdr[4];
-+      int hlen,count;
-+              
-+      for (n=m,len=0;n != NULL;n = n->m_next)
-+              len += n->m_len;
-+      if (len==0) {
-+              m_freem(m);
-+              return;
-+      }
-+      
-+      /* extract PPP header from mbuf chain (1 to 4 bytes) */
-+      for (n=m,hlen=0;n!=NULL && hlen<sizeof(hdr);n=n->m_next) {
-+              count = (sizeof(hdr)-hlen) < n->m_len ?
-+                              sizeof(hdr)-hlen : n->m_len;
-+              bcopy(mtod(n,u_char*),&hdr[hlen],count);
-+              hlen+=count;
-+      }
-+      
-+      s = spltty();
-+      
-+      /* if AFCF compressed then prepend AFCF */
-+      if (hdr[0] != PPP_ALLSTATIONS) {
-+              if (sc->sc_flags & SC_REJ_COMP_AC) {
-+                      if (sc->sc_flags & SC_DEBUG)
-+                              printf("ppp%d: garbage received: 0x%x (need 0xFF)\n",
-+                                      sc->sc_if.if_unit, hdr[0]);
-+                              goto bail;
-+                      }
-+              M_PREPEND(m,2,M_DONTWAIT);              
-+              if (m==NULL) {
-+                      splx(s);
-+                      return;
-+              }
-+              hdr[3] = hdr[1];
-+              hdr[2] = hdr[0];
-+              hdr[0] = PPP_ALLSTATIONS;
-+              hdr[1] = PPP_UI;
-+              len += 2;
-+      }
-+
-+      /* if protocol field compressed, add MSB of protocol field = 0 */
-+      if (hdr[2] & 1) {
-+              /* a compressed protocol */
-+              M_PREPEND(m,1,M_DONTWAIT);              
-+              if (m==NULL) {
-+                      splx(s);
-+                      return;
-+              }
-+              hdr[3] = hdr[2];
-+              hdr[2] = 0;
-+              len++;
-+      } 
-+      
-+      /* valid LSB of protocol field has bit0 set */
-+      if (!(hdr[3] & 1)) {
-+              if (sc->sc_flags & SC_DEBUG)
-+                      printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit,
-+                              (hdr[2] << 8) + hdr[3]);
-+                      goto bail;
-+      }
-+      
-+      /* packet beyond configured mru? */
-+      if (len > sc->sc_mru + PPP_HDRLEN) {
-+              if (sc->sc_flags & SC_DEBUG)
-+                      printf("ppp%d: packet too big\n", sc->sc_if.if_unit);
-+              goto bail;
-+      }
-+      
-+      /* add expanded 4 byte header to mbuf chain */
-+      for (n=m,hlen=0;n!=NULL && hlen<sizeof(hdr);n=n->m_next) {
-+              count = (sizeof(hdr)-hlen) < n->m_len ?
-+                              sizeof(hdr)-hlen : n->m_len;
-+              bcopy(&hdr[hlen],mtod(n,u_char*),count);
-+              hlen+=count;
-+      }
-+      
-+      /* if_ppp.c requires the PPP header and IP header */
-+      /* to be contiguous */
-+      count = len < MHLEN ? len : MHLEN;
-+      if (m->m_len < count) {
-+              m = m_pullup(m,count);
-+              if (m==NULL)
-+                      goto bail;
-+      }
-+      
-+      sc->sc_stats.ppp_ibytes += len;
-+      
-+      if (sc->sc_flags & SC_LOG_RAWIN)
-+              pppdumpframe(sc,m,0);
-+    
-+      ppppktin(sc, m, 0);
-+      splx(s);
-+      return;
-+bail: 
-+      m_freem(m);
-+      splx(s);
-+}
-+
- /*
-  * FCS lookup table as calculated by genfcstab.
-  */
-@@ -564,6 +677,39 @@
-     return (fcs);
- }
-+/* This gets called at splsoftnet from pppasyncstart at various times
-+ * when there is data ready to be sent.
-+ */
-+static void pppsyncstart(register struct ppp_softc *sc)
-+{
-+      struct tty *tp = (struct tty *) sc->sc_devp;
-+      struct mbuf *m, *n;
-+      int len;
-+    
-+      for(m = sc->sc_outm;;) {
-+              if (m == NULL) {
-+                      m = ppp_dequeue(sc);    /* get new packet */
-+                      if (m == NULL)
-+                              break;          /* no more packets */
-+                      if (sc->sc_flags & SC_DEBUG)
-+                              pppdumpframe(sc,m,1);
-+              }
-+              microtime(&sc->sc_if.if_lastchange);
-+              for(n=m,len=0;n!=NULL;n=n->m_next)
-+                      len += n->m_len;
-+                      
-+              /* call device driver IOCTL to transmit a frame */
-+              if ((*cdevsw[major(tp->t_dev)]->d_ioctl)
-+                      (tp->t_dev,TIOCXMTFRAME,(caddr_t)&m,0,0)) {
-+                      /* busy or error, set as current packet */
-+                      sc->sc_outm = m;
-+                      break;
-+              }
-+              sc->sc_outm = m = NULL;
-+              sc->sc_stats.ppp_obytes += len;
-+      }
-+}
-+
- /*
-  * This gets called at splsoftnet from if_ppp.c at various times
-  * when there is data ready to be sent.
-@@ -580,6 +726,11 @@
-     struct mbuf *m2;
-     int s;
-+    if (sc->sc_flags & SC_SYNC){
-+      pppsyncstart(sc);
-+      return;
-+    }
-+    
-     idle = 0;
-     /* XXX assumes atomic access to *tp although we're not at spltty(). */
-     while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-@@ -1123,6 +1274,44 @@
-               sc->sc_rawin_count, sc->sc_rawin, " ");
-       sc->sc_rawin_count = 0;
-     }
-+}
-+
-+static void pppdumpframe(struct ppp_softc *sc,struct mbuf* m,int xmit)
-+{
-+      int i,lcount,copycount,count;
-+      char lbuf[16];
-+      char *data;
-+      
-+      if (m == NULL)
-+              return;
-+              
-+      for(count=m->m_len,data=mtod(m,char*);m != NULL;) {
-+              /* build a line of output */
-+              for(lcount=0;lcount < sizeof(lbuf);lcount += copycount) {
-+                      if (!count) {
-+                              m = m->m_next;
-+                              if (m == NULL)
-+                                      break;
-+                              count = m->m_len;
-+                              data  = mtod(m,char*);
-+                      }
-+                      copycount = (count > sizeof(lbuf)-lcount) ?
-+                                      sizeof(lbuf)-lcount : count;
-+                      bcopy(data,&lbuf[lcount],copycount);
-+                      data  += copycount;
-+                      count -= copycount;
-+              }
-+
-+              /* output line (hex 1st, then ascii) */         
-+              printf("ppp%d %s:",sc->sc_if.if_unit,xmit ? "output":"input ");
-+              for(i=0;i<lcount;i++)
-+                      printf("%02x ",(u_char)lbuf[i]);
-+              for(;i<sizeof(lbuf);i++)
-+                      printf("   ");
-+              for(i=0;i<lcount;i++)
-+                      printf("%c",(lbuf[i]>=040 && lbuf[i]<=0176)?lbuf[i]:'.');
-+              printf("\n");
-+      }
- }
- #endif        /* NPPP > 0 */
diff --git a/freebsd-3.0/patch.ttycom.h b/freebsd-3.0/patch.ttycom.h
deleted file mode 100644 (file)
index c2fc7ba..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
---- ttycom.h   Mon Jun 17 08:08:09 1996
-+++ ttycom.h.new       Fri Apr  9 08:22:06 1999
-@@ -133,9 +133,13 @@
- #define       TIOCDSIMICROCODE _IO('t', 85)           /* download microcode to
-                                                * DSI Softmodem */
-+#define       TIOCRCVFRAME    _IOW('t', 69, struct mbuf *)    /* data frame received */
-+#define       TIOCXMTFRAME    _IOW('t', 68, struct mbuf *)    /* data frame transmit */
-+
- #define       TTYDISC         0               /* termios tty line discipline */
- #define       TABLDISC        3               /* tablet discipline */
- #define       SLIPDISC        4               /* serial IP discipline */
- #define       PPPDISC         5               /* PPP discipline */
-+#define       HDLCDISC        6               /* HDLC discipline */
- #endif /* !_SYS_TTYCOM_H_ */
diff --git a/linux/patch-include b/linux/patch-include
deleted file mode 100644 (file)
index dabe680..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
---- types.h.orig       Wed Mar 27 16:36:46 1996
-+++ types.h    Tue Jul  4 16:07:02 1995
-@@ -3,4 +3,5 @@
- #include <linux/types.h>
-+#include <sys/bitypes.h>
- #ifndef howmany
diff --git a/linux/ppp.c b/linux/ppp.c
deleted file mode 100644 (file)
index 0fa98fd..0000000
+++ /dev/null
@@ -1,3371 +0,0 @@
-/*  PPP for Linux
- *
- *  Michael Callahan <callahan@maths.ox.ac.uk>
- *  Al Longyear <longyear@netcom.com>
- *  Extensively rewritten by Paul Mackerras <paulus@cs.anu.edu.au>
- *
- *  ==FILEVERSION 990910==
- *
- *  NOTE TO MAINTAINERS:
- *     If you modify this file at all, please set the number above to the
- *     date of the modification as YYMMDD (year month day).
- *     ppp.c is shipped with a PPP distribution as well as with the kernel;
- *     if everyone increases the FILEVERSION number above, then scripts
- *     can do the right thing when deciding whether to install a new ppp.c
- *     file.  Don't change the format of that line otherwise, so the
- *     installation script can recognize it.
- */
-
-/*
-   Sources:
-
-   slip.c
-
-   RFC1331: The Point-to-Point Protocol (PPP) for the Transmission of
-   Multi-protocol Datagrams over Point-to-Point Links
-
-   RFC1332: IPCP
-
-   ppp-2.0
-
-   Flags for this module (any combination is acceptable for testing.):
-
-   OPTIMIZE_FLAG_TIME - Number of jiffies to force sending of leading flag
-                       character. This is normally set to ((HZ * 3) / 2).
-                       This is 1.5 seconds. If zero then the leading
-                       flag is always sent.
-
-   CHECK_CHARACTERS   - Enable the checking on all received characters for
-                       8 data bits, no parity. This adds a small amount of
-                       processing for each received character.
-*/
-
-#define OPTIMIZE_FLAG_TIME     ((HZ * 3)/2)
-#define CHECK_CHARACTERS       1
-
-#define PPP_MAX_RCV_QLEN       32      /* max # frames we queue up for pppd */
-
-/* $Id: ppp.c,v 1.33 1999/12/23 01:48:45 paulus Exp $ */
-
-#include <linux/version.h>
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/ptrace.h>
-
-/* a macro to generate linux version number codes */
-#define VERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
-
-#if LINUX_VERSION_CODE < VERSION(2,1,14)
-#include <linux/ioport.h>
-#endif
-
-#if LINUX_VERSION_CODE >= VERSION(2,1,23)
-#include <linux/poll.h>
-#endif
-
-#include <linux/in.h>
-#include <linux/malloc.h>
-#include <linux/tty.h>
-#include <linux/errno.h>
-#include <linux/sched.h>       /* to get the struct task_struct */
-#include <linux/string.h>      /* used in new tty drivers */
-#include <linux/signal.h>      /* used in new tty drivers */
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <linux/if.h>
-#include <linux/if_ether.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/inet.h>
-#include <linux/ioctl.h>
-#include <linux/ip.h>
-#include <linux/tcp.h>
-#include <linux/if_arp.h>
-#include <net/slhc_vj.h>
-
-#define fcstab ppp_crc16_table         /* Name of the table in the kernel */
-#include <linux/ppp_defs.h>
-
-#include <linux/socket.h>
-#include <linux/if_ppp.h>
-#include <linux/if_pppvar.h>
-#include <linux/ppp-comp.h>
-
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
-#ifdef CONFIG_KERNELD
-#include <linux/kerneld.h>
-#endif
-
-#undef PPP_VERSION
-#define PPP_VERSION    "2.3.11"
-
-#if LINUX_VERSION_CODE >= VERSION(2,1,4)
-
-#if LINUX_VERSION_CODE >= VERSION(2,1,5)
-#include <asm/uaccess.h>
-#else
-#include <asm/segment.h>
-#endif
-
-#define GET_USER       get_user
-#define PUT_USER       put_user
-#define COPY_FROM_USER copy_from_user
-#define COPY_TO_USER   copy_to_user
-
-#else  /* 2.0.x and 2.1.x before 2.1.4 */
-
-#define GET_USER(val, src)     \
-       (verify_area(VERIFY_READ, src, sizeof(*src))? -EFAULT: \
-        ((val) = get_user(src), 0))
-#define PUT_USER(val, dst)     \
-       (verify_area(VERIFY_WRITE, dst, sizeof(*dst))? -EFAULT: \
-        (put_user(val, dst), 0))
-#define COPY_FROM_USER(dst, src, size) \
-       (verify_area(VERIFY_READ, src, size)? -EFAULT: \
-        (memcpy_fromfs(dst, src, size), 0))
-#define COPY_TO_USER(dst, src, size)   \
-       (verify_area(VERIFY_WRITE, dst, size)? -EFAULT: \
-        (memcpy_tofs(dst, src, size), 0))
-
-#endif /* < 2.1.4 */
-
-#if LINUX_VERSION_CODE < VERSION(2,1,37)
-#define test_and_set_bit(nr, addr)     set_bit(nr, addr)
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,25)
-#define net_device_stats       enet_statistics
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,57)
-#define signal_pending(tsk)    ((tsk)->signal & ~(tsk)->blocked)
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,60)
-typedef int            rw_ret_t;
-typedef unsigned int   rw_count_t;
-#else
-typedef ssize_t                rw_ret_t;
-typedef size_t         rw_count_t;
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,86)
-#define KFREE_SKB(s)   dev_kfree_skb((s), FREE_WRITE)
-#else
-#define KFREE_SKB(s)   kfree_skb(s)
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,15)
-#define LIBERATE_SKB(s)        ((s)->free = 1)
-#else
-#define LIBERATE_SKB(s)        do { } while (0)
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,95)
-#define SUSER()                suser()
-#else
-#define SUSER()                capable(CAP_NET_ADMIN)
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,2,0)
-#define wmb()          mb()
-#endif
-
-/*
- * Local functions
- */
-
-static int ppp_register_compressor (struct compressor *cp);
-static void ppp_unregister_compressor (struct compressor *cp);
-
-static void ppp_async_init(struct ppp *ppp);
-static void ppp_async_release(struct ppp *ppp);
-static int ppp_tty_sync_push(struct ppp *ppp);
-static int ppp_tty_push(struct ppp *ppp);
-static int ppp_async_encode(struct ppp *ppp);
-static int ppp_async_send(struct ppp *, struct sk_buff *);
-static int ppp_sync_send(struct ppp *, struct sk_buff *);
-static void ppp_tty_flush_output(struct ppp *);
-
-static int ppp_ioctl(struct ppp *, unsigned int, unsigned long);
-static int ppp_set_compression (struct ppp *ppp, struct ppp_option_data *odp);
-static void ppp_proto_ccp(struct ppp *ppp, __u8 *dp, int len, int rcvd);
-static void ppp_ccp_closed(struct ppp *ppp);
-static int ppp_receive_frame(struct ppp *, struct sk_buff *);
-static void ppp_receive_error(struct ppp *ppp);
-static void ppp_output_wakeup(struct ppp *ppp);
-static void ppp_send_ctrl(struct ppp *ppp, struct sk_buff *skb);
-static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
-static void ppp_send_frames(struct ppp *ppp);
-static struct sk_buff *ppp_vj_compress(struct ppp *ppp, struct sk_buff *skb);
-
-static struct ppp *ppp_find (int pid_value);
-static struct ppp *ppp_alloc (void);
-static void ppp_generic_init(struct ppp *ppp);
-static void ppp_release(struct ppp *ppp);
-static void ppp_print_buffer (const char *, const __u8 *, int);
-static struct compressor *find_compressor (int type);
-
-#ifndef OPTIMIZE_FLAG_TIME
-#define OPTIMIZE_FLAG_TIME     0
-#endif
-
-/*
- * Parameters which may be changed via insmod.
- */
-
-static int  flag_time = OPTIMIZE_FLAG_TIME;
-#if LINUX_VERSION_CODE >= VERSION(2,1,19) 
-MODULE_PARM(flag_time, "i");
-#endif
-
-#define CHECK_PPP_MAGIC(ppp)   do { \
-       if (ppp->magic != PPP_MAGIC) { \
-               printk(ppp_magic_warn, ppp, __FILE__, __LINE__); \
-       } \
-} while (0)
-#define CHECK_PPP(a)   do { \
-       CHECK_PPP_MAGIC(ppp); \
-       if (!ppp->inuse) { \
-               printk(ppp_warning, __LINE__); \
-               return a; \
-       } \
-} while (0)
-#define CHECK_PPP_VOID() do { \
-       CHECK_PPP_MAGIC(ppp); \
-       if (!ppp->inuse) { \
-               printk(ppp_warning, __LINE__); \
-               return; \
-       } \
-} while (0)
-
-#define tty2ppp(tty)   ((struct ppp *) ((tty)->disc_data))
-#define dev2ppp(dev)   ((struct ppp *) ((dev)->priv))
-#define ppp2tty(ppp)   ((ppp)->tty)
-#define ppp2dev(ppp)   (&(ppp)->dev)
-
-static struct ppp *ppp_list = NULL;
-static struct ppp *ppp_last = NULL;
-
-/* Define these strings only once for all macro invocations */
-static char ppp_warning[] = KERN_WARNING "PPP: ALERT! not INUSE! %d\n";
-static char ppp_magic_warn[] = KERN_WARNING "bad magic for ppp %p at %s:%d\n";
-
-static char szVersion[]                = PPP_VERSION;
-
-#if LINUX_VERSION_CODE < VERSION(2,1,18)
-static struct symbol_table ppp_syms = {
-#include <linux/symtab_begin.h>
-       X(ppp_register_compressor),
-       X(ppp_unregister_compressor),
-#include <linux/symtab_end.h>
-};
-#else
-EXPORT_SYMBOL(ppp_register_compressor);
-EXPORT_SYMBOL(ppp_unregister_compressor);
-#endif
-
-/*************************************************************
- * LINE DISCIPLINE SUPPORT
- *    The following code implements the PPP line discipline
- *    and supports using PPP on an async serial line.
- *************************************************************/
-
-#define in_xmap(ppp,c) (ppp->xmit_async_map[(c) >> 5] & (1 << ((c) & 0x1f)))
-#define in_rmap(ppp,c) ((((unsigned int) (__u8) (c)) < 0x20) && \
-                       ppp->recv_async_map & (1 << (c)))
-
-/*
- * TTY callbacks
- */
-
-static rw_ret_t ppp_tty_read(struct tty_struct *, struct file *, __u8 *,
-                            rw_count_t);
-static rw_ret_t ppp_tty_write(struct tty_struct *, struct file *, const __u8 *,
-                             rw_count_t);
-static int ppp_tty_ioctl(struct tty_struct *, struct file *, unsigned int,
-                        unsigned long);
-#if LINUX_VERSION_CODE < VERSION(2,1,23)
-static int ppp_tty_select(struct tty_struct *tty, struct inode *inode,
-                       struct file *filp, int sel_type, select_table * wait);
-#else
-static unsigned int ppp_tty_poll(struct tty_struct *tty, struct file *filp,
-                                poll_table * wait);
-#endif
-static int ppp_tty_open (struct tty_struct *);
-static void ppp_tty_close (struct tty_struct *);
-static int ppp_tty_room (struct tty_struct *tty);
-static void ppp_tty_receive (struct tty_struct *tty, const __u8 * cp,
-                            char *fp, int count);
-static void ppp_tty_wakeup (struct tty_struct *tty);
-
-__u16 ppp_crc16_table[256] =
-{
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-#if LINUX_VERSION_CODE >= VERSION(2,1,18)
-EXPORT_SYMBOL(ppp_crc16_table);
-#endif
-
-#ifdef CHECK_CHARACTERS
-static __u32 paritytab[8] =
-{
-       0x96696996, 0x69969669, 0x69969669, 0x96696996,
-       0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-#endif
-
-/*
- * This procedure is called at initialization time to register
- * the PPP line discipline.
- */
-static int
-ppp_first_time(void)
-{
-       static struct tty_ldisc ppp_ldisc;
-       int    status;
-
-       printk(KERN_INFO
-              "PPP: version %s (demand dialling)"
-              "\n", szVersion);
-
-#ifndef MODULE /* slhc module logic has its own copyright announcement */
-       printk(KERN_INFO
-              "TCP compression code copyright 1989 Regents of the "
-              "University of California\n");
-#endif
-
-       /*
-        * Register the tty discipline
-        */
-       (void) memset (&ppp_ldisc, 0, sizeof (ppp_ldisc));
-       ppp_ldisc.magic         = TTY_LDISC_MAGIC;
-#if LINUX_VERSION_CODE >= VERSION(2,1,28)
-       ppp_ldisc.name          = "ppp";
-#endif
-       ppp_ldisc.open          = ppp_tty_open;
-       ppp_ldisc.close         = ppp_tty_close;
-       ppp_ldisc.read          = ppp_tty_read;
-       ppp_ldisc.write         = ppp_tty_write;
-       ppp_ldisc.ioctl         = ppp_tty_ioctl;
-#if LINUX_VERSION_CODE < VERSION(2,1,23)
-       ppp_ldisc.select        = ppp_tty_select;
-#else
-       ppp_ldisc.poll          = ppp_tty_poll;
-#endif
-       ppp_ldisc.receive_room  = ppp_tty_room;
-       ppp_ldisc.receive_buf   = ppp_tty_receive;
-       ppp_ldisc.write_wakeup  = ppp_tty_wakeup;
-
-       status = tty_register_ldisc (N_PPP, &ppp_ldisc);
-       if (status == 0)
-               printk(KERN_INFO "PPP line discipline registered.\n");
-       else
-               printk(KERN_ERR "error registering line discipline: %d\n",
-                      status);
-       return status;
-}
-
-
-#ifndef MODULE
-/*
- * Called at boot time if the PPP driver is compiled into the kernel.
- */
-int
-ppp_init(struct device *dev)
-{
-       static int first_time = 1;
-       int    answer = 0;
-
-       if (first_time) {
-               first_time = 0;
-               answer     = ppp_first_time();
-#if LINUX_VERSION_CODE < VERSION(2,1,18)
-               if (answer == 0)
-                       (void) register_symtab(&ppp_syms);
-#endif
-       }
-       if (answer == 0)
-               answer = -ENODEV;
-       return answer;
-}
-#endif
-
-/*
- * Initialize the async-specific parts of the ppp structure.
- */
-static void
-ppp_async_init(struct ppp *ppp)
-{
-       ppp->escape = 0;
-       ppp->toss   = 0xE0;
-       ppp->tty_pushing = 0;
-
-       memset (ppp->xmit_async_map, 0, sizeof (ppp->xmit_async_map));
-       ppp->xmit_async_map[0] = 0xffffffff;
-       ppp->xmit_async_map[3] = 0x60000000;
-       ppp->recv_async_map    = 0xffffffff;
-
-       ppp->tpkt = NULL;
-       ppp->tfcs = PPP_INITFCS;
-       ppp->optr = ppp->obuf;
-       ppp->olim = ppp->obuf;
-
-       ppp->rpkt = NULL;
-       ppp->rfcs = PPP_INITFCS;
-
-       ppp->tty  = NULL;
-       ppp->backup_tty = NULL;
-
-       ppp->bytes_sent = 0;
-       ppp->bytes_rcvd = 0;
-}
-
-/*
- * Clean up the async-specific parts of the ppp structure.
- */
-static void
-ppp_async_release(struct ppp *ppp)
-{
-       struct sk_buff *skb;
-
-       if ((skb = ppp->rpkt) != NULL)
-               KFREE_SKB(skb);
-       ppp->rpkt = NULL;
-       if ((skb = ppp->tpkt) != NULL)
-               KFREE_SKB(skb);
-       ppp->tpkt = NULL;
-}
-
-/*
- * TTY callback.
- *
- * Called when the tty discipline is switched to PPP.
- */
-
-static int
-ppp_tty_open (struct tty_struct *tty)
-{
-       struct ppp *ppp;
-
-       /*
-        * Allocate a ppp structure to use.
-        */
-       tty->disc_data = NULL;
-       ppp = ppp_find(current->pid);
-       if (ppp != NULL) {
-               /*
-                * If we are taking over a ppp unit which is currently
-                * connected to a loopback pty, there's not much to do.
-                */
-               CHECK_PPP(-EINVAL);
-
-       } else {
-               ppp = ppp_alloc();
-               if (ppp == NULL) {
-                       printk(KERN_ERR "ppp_alloc failed\n");
-                       return -ENFILE;
-               }
-
-               /*
-                * Initialize the control block
-                */
-               ppp_generic_init(ppp);
-               ppp_async_init(ppp);
-
-               MOD_INC_USE_COUNT;
-       }
-
-       tty->disc_data = ppp;
-       ppp->tty       = tty;
-
-       /*
-        * Flush any pending characters in the driver
-        */
-       if (tty->driver.flush_buffer)
-               tty->driver.flush_buffer (tty);
-
-       return ppp->line;
-}
-
-/*
- * TTY callback.
- *
- * Called when the line discipline is changed to something
- * else, the tty is closed, or the tty detects a hangup.
- */
-
-static void
-ppp_tty_close (struct tty_struct *tty)
-{
-       struct ppp *ppp = tty2ppp(tty);
-
-       if (ppp == NULL)
-               return;
-       tty->disc_data = NULL;
-       if (ppp->magic != PPP_MAGIC) {
-               printk(KERN_WARNING "ppp_tty_close: bogus\n");
-               return;
-       }
-       if (!ppp->inuse) {
-               printk(KERN_WARNING "ppp_tty_close: not inuse\n");
-               ppp->tty = ppp->backup_tty = 0;
-               return;
-       }
-       if (tty == ppp->backup_tty)
-               ppp->backup_tty = 0;
-       if (tty != ppp->tty)
-               return;
-       if (ppp->backup_tty) {
-               ppp->tty = ppp->backup_tty;
-               if (ppp_tty_push(ppp))
-                       ppp_output_wakeup(ppp);
-               wake_up_interruptible(&ppp->read_wait);
-       } else {
-               ppp->tty = 0;
-               ppp->sc_xfer = 0;
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO "ppp: channel %s closing.\n",
-                              ppp2dev(ppp)->name);
-
-               ppp_async_release(ppp);
-               ppp_release(ppp);
-               MOD_DEC_USE_COUNT;
-       }
-}
-
-/*
- * Read a PPP frame from the rcv_q list,
- * waiting if necessary
- */
-static rw_ret_t
-ppp_tty_read(struct tty_struct *tty, struct file *file, __u8 * buf,
-            rw_count_t nr)
-{
-       struct ppp *ppp = tty2ppp (tty);
-       struct sk_buff *skb;
-       rw_ret_t len, err;
-
-       /*
-        * Validate the pointers
-        */
-       if (!ppp)
-               return -EIO;
-       CHECK_PPP(-ENXIO);
-
-       /*
-        * Before we attempt to write the frame to the user, ensure that the
-        * user has access to the pages for the total buffer length.
-        */
-       err = verify_area(VERIFY_WRITE, buf, nr);
-       if (err != 0)
-               return (err);
-
-       /*
-        * Wait for a frame to arrive if necessary.
-        * We increment the module use count so that the module
-        * can't go away while we're sleeping.
-        */
-       MOD_INC_USE_COUNT;
-       skb = NULL;
-       for (;;) {
-               ppp = tty2ppp(tty);
-               err = 0;
-               if (!ppp || ppp->magic != PPP_MAGIC || !ppp->inuse
-                   || tty != ppp->tty)
-                       break;
-
-               skb = skb_dequeue(&ppp->rcv_q);
-               if (skb != 0)
-                       break;
-
-               /*
-                * If no frame is available, return -EAGAIN or wait.
-                */
-               err = -EAGAIN;
-               if (file->f_flags & O_NONBLOCK)
-                       break;
-
-               interruptible_sleep_on(&ppp->read_wait);
-               err = -EINTR;
-               if (signal_pending(current))
-                       break;
-       }
-       MOD_DEC_USE_COUNT;
-       if (skb == 0)
-               return err;
-
-       /*
-        * Ensure that the frame will fit within the caller's buffer.
-        * If not, just discard the frame.
-        */
-       len = skb->len;
-       if (len > nr) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_DEBUG
-                              "ppp: read of %lu bytes too small for %ld "
-                              "frame\n", (unsigned long) nr, (long) len);
-               ppp->stats.ppp_ierrors++;
-               err = -EOVERFLOW;
-               goto out;
-       }
-
-       /*
-        * Copy the received data from the buffer to the caller's area.
-        */
-       err = len;
-       if (COPY_TO_USER(buf, skb->data, len))
-               err = -EFAULT;
-
-out:
-       KFREE_SKB(skb);
-       return err;
-}
-
-/*
- * Writing to a tty in ppp line discipline sends a PPP frame.
- * Used by pppd to send control packets (LCP, etc.).
- */
-static rw_ret_t
-ppp_tty_write(struct tty_struct *tty, struct file *file, const __u8 * data,
-             rw_count_t count)
-{
-       struct ppp *ppp = tty2ppp (tty);
-       __u8 *new_data;
-       struct sk_buff *skb;
-
-       /*
-        * Verify the pointers.
-        */
-       if (!ppp)
-               return -EIO;
-
-       if (ppp->magic != PPP_MAGIC)
-               return -EIO;
-
-       CHECK_PPP(-ENXIO);
-
-       /*
-        * Ensure that the caller does not wish to send too much.
-        */
-       if (count > PPP_MTU + PPP_HDRLEN) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_WARNING
-                              "ppp_tty_write: truncating user packet "
-                              "from %lu to mtu %d\n", (unsigned long) count,
-                              PPP_MTU + PPP_HDRLEN);
-               count = PPP_MTU + PPP_HDRLEN;
-       }
-
-       /*
-        * Allocate a buffer for the data and fetch it from the user space.
-        */
-       skb = alloc_skb(count, GFP_KERNEL);
-       if (skb == NULL) {
-               printk(KERN_ERR "ppp_tty_write: no memory\n");
-               return 0;
-       }
-       LIBERATE_SKB(skb);
-       new_data = skb_put(skb, count);
-
-       /*
-        * Retrieve the user's buffer
-        */
-       if (COPY_FROM_USER(new_data, data, count)) {
-               KFREE_SKB(skb);
-               return -EFAULT;
-       }
-
-       /*
-        * Send the frame
-        */
-       ppp_send_ctrl(ppp, skb);
-
-       return (rw_ret_t) count;
-}
-
-/*
- * Process the IOCTL call for the tty device.
- * Only the ioctls that relate to using ppp on async serial lines
- * are processed here; the rest are handled by ppp_ioctl.
- */
-static int
-ppp_tty_ioctl (struct tty_struct *tty, struct file * file,
-               unsigned int param2, unsigned long param3)
-{
-       struct ppp *ppp = tty2ppp (tty);
-       register int temp_i = 0;
-       int error = -EFAULT;
-
-       /*
-        * Verify the status of the PPP device.
-        */
-       if (!ppp || ppp->magic != PPP_MAGIC || !ppp->inuse)
-               return -ENXIO;
-
-       /*
-        * The user must have an euid of root to do these requests.
-        */
-       if (!SUSER())
-               return -EPERM;
-
-       switch (param2) {
-       case PPPIOCGASYNCMAP:
-               /*
-                * Retrieve the transmit async map
-                */
-               if (PUT_USER(ppp->xmit_async_map[0], (int *) param3))
-                       break;
-               error = 0;
-               break;
-
-       case PPPIOCSASYNCMAP:
-               /*
-                * Set the transmit async map
-                */
-               if (GET_USER(temp_i, (int *) param3))
-                       break;
-               ppp->xmit_async_map[0] = temp_i;
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO
-                              "ppp_tty_ioctl: set xmit asyncmap %x\n",
-                              ppp->xmit_async_map[0]);
-               error = 0;
-               break;
-
-       case PPPIOCSRASYNCMAP:
-               /*
-                * Set the receive async map
-                */
-               if (GET_USER(temp_i, (int *) param3))
-                       break;
-               ppp->recv_async_map = temp_i;
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO
-                              "ppp_tty_ioctl: set rcv asyncmap %x\n",
-                              ppp->recv_async_map);
-               error = 0;
-               break;
-
-       case PPPIOCGXASYNCMAP:
-               /*
-                * Get the map of characters to be escaped on transmission.
-                */
-               if (COPY_TO_USER((void *) param3, ppp->xmit_async_map,
-                                sizeof (ppp->xmit_async_map)))
-                       break;
-               error = 0;
-               break;
-
-       case PPPIOCSXASYNCMAP:
-               /*
-                * Set the map of characters to be escaped on transmission.
-                */
-               {
-                       __u32 temp_tbl[8];
-
-                       if (COPY_FROM_USER(temp_tbl, (void *) param3,
-                                          sizeof (temp_tbl)))
-                               break;
-
-                       temp_tbl[1]  =  0x00000000;
-                       temp_tbl[2] &= ~0x40000000;
-                       temp_tbl[3] |=  0x60000000;
-
-                       memcpy(ppp->xmit_async_map, temp_tbl,
-                              sizeof (ppp->xmit_async_map));
-
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_INFO
-                                      "ppp_tty_ioctl: set xasyncmap\n");
-                       error = 0;
-               }
-               break;
-
-       case PPPIOCXFERUNIT:
-               /*
-                * Set up this PPP unit to be used next time this
-                * process sets a tty to PPP line discipline.
-                */
-               ppp->backup_tty = tty;
-               ppp->sc_xfer = current->pid;
-               error = 0;
-               break;
-
-       case TCGETS:
-       case TCGETA:
-               /*
-                * Allow users to read, but not set, the serial port parameters
-                */
-               error = n_tty_ioctl (tty, file, param2, param3);
-               break;
-
-       case TCFLSH:
-               /*
-                * Flush our buffers, then call the generic code to
-                * flush the serial port's buffer.
-                */
-               if (param3 == TCIFLUSH || param3 == TCIOFLUSH) {
-                       struct sk_buff *skb;
-                       while ((skb = skb_dequeue(&ppp->rcv_q)) != NULL)
-                               KFREE_SKB(skb);
-               }
-               if (param3 == TCIOFLUSH || param3 == TCOFLUSH)
-                       ppp_tty_flush_output(ppp);
-               error = n_tty_ioctl (tty, file, param2, param3);
-               break;
-
-       case FIONREAD:
-               /*
-                * Returns how many bytes are available for a read().
-                */
-               {
-                       unsigned long flags;
-                       struct sk_buff *skb;
-                       int count = 0;
-
-                       save_flags(flags);
-                       cli();
-                       skb = skb_peek(&ppp->rcv_q);
-                       if (skb != 0)
-                               count = skb->len;
-                       restore_flags(flags);
-                       if (PUT_USER(count, (int *) param3))
-                               break;
-                       error = 0;
-               }
-               break;
-
-       default:
-               /*
-                *  All other ioctl() events will come here.
-                */
-               error = ppp_ioctl(ppp, param2, param3);
-               break;
-       }
-       return error;
-}
-
-/*
- * TTY callback.
- *
- * Process the select() or poll() statement for the PPP device.
- */
-
-#if LINUX_VERSION_CODE < VERSION(2,1,23)
-static int
-ppp_tty_select(struct tty_struct *tty, struct inode *inode,
-              struct file *filp, int sel_type, select_table * wait)
-{
-       struct ppp *ppp = tty2ppp(tty);
-       int result = 1;
-
-       /*
-        * Verify the status of the PPP device.
-        */
-       if (!ppp || tty != ppp->tty)
-               return -EBADF;
-
-       CHECK_PPP(-EBADF);
-
-       switch (sel_type) {
-       case SEL_IN:
-               /* The fd is readable if the receive queue isn't empty. */
-               if (skb_peek(&ppp->rcv_q) != NULL)
-                       break;
-               /* fall through */
-       case SEL_EX:
-               /* Check for exceptions or read errors. */
-               /* Is this a pty link and the remote disconnected? */
-               if (tty->flags & (1 << TTY_OTHER_CLOSED))
-                       break;
-
-               /* Is this a local link and the modem disconnected? */
-               if (tty_hung_up_p (filp))
-                       break;
-
-               select_wait(&ppp->read_wait, wait);
-               result = 0;
-               break;
-
-       case SEL_OUT:
-               /* The fd is always writable. */
-               break;
-       }
-       return result;
-}
-
-#else  /* 2.1.23 or later */
-
-static unsigned int
-ppp_tty_poll(struct tty_struct *tty, struct file *filp, poll_table * wait)
-{
-       struct ppp *ppp = tty2ppp(tty);
-       unsigned int mask = 0;
-
-       if (ppp && ppp->magic == PPP_MAGIC && tty == ppp->tty) {
-               CHECK_PPP(0);
-
-               poll_wait(filp, &ppp->read_wait, wait);
-
-               if (skb_peek(&ppp->rcv_q) != NULL)
-                       mask |= POLLIN | POLLRDNORM;
-               if (tty->flags & (1 << TTY_OTHER_CLOSED)
-                   || tty_hung_up_p(filp))
-                       mask |= POLLHUP;
-               mask |= POLLOUT | POLLWRNORM;
-       }
-       return mask;
-}
-#endif /* >= 2.1.23 */
-
-/*
- * This function is called by the tty driver when the transmit buffer has
- * additional space. It is used by the ppp code to continue to transmit
- * the current buffer should the buffer have been partially sent.
- */
-static void
-ppp_tty_wakeup (struct tty_struct *tty)
-{
-       struct ppp *ppp = tty2ppp (tty);
-
-       tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
-       if (!ppp)
-               return;
-       CHECK_PPP_VOID();
-       if (tty != ppp->tty)
-               return;
-
-       if (ppp_tty_push(ppp))
-               ppp_output_wakeup(ppp);
-}
-
-/*
- * Send a packet to the peer over a synchronous tty line.
- * All encoding and FCS are handled by hardware.
- * Addr/Ctrl and Protocol field compression implemented.
- * Returns -1 iff the packet could not be accepted at present,
- * 0 if the packet was accepted but we can't accept another yet, or
- * 1 if we can accept another packet immediately.
- * If this procedure returns 0, ppp_output_wakeup will be called
- * exactly once.
- */
-static int
-ppp_sync_send(struct ppp *ppp, struct sk_buff *skb)
-{
-       unsigned char *data;
-       int islcp;
-       
-       CHECK_PPP(0);
-
-       if (ppp->tpkt != NULL)
-               return -1;
-       ppp->tpkt = skb;
-
-       data = ppp->tpkt->data;
-       
-       /*
-        * LCP packets with code values between 1 (configure-reqest)
-        * and 7 (code-reject) must be sent as though no options
-        * had been negotiated.
-        */
-       islcp = PPP_PROTOCOL(data) == PPP_LCP
-               && 1 <= data[PPP_HDRLEN] && data[PPP_HDRLEN] <= 7;
-
-       /* only reset idle time for data packets */
-       if (PPP_PROTOCOL(data) < 0x8000)
-               ppp->last_xmit = jiffies;
-       ++ppp->stats.ppp_opackets;
-       ppp->stats.ppp_ooctects += ppp->tpkt->len;
-
-       if ( !(data[2]) && (ppp->flags & SC_COMP_PROT) ) {
-               /* compress protocol field */
-               data[2] = data[1];
-               data[1] = data[0];
-               skb_pull(ppp->tpkt,1);
-               data = ppp->tpkt->data;
-       }
-       
-       /*
-        * Do address/control compression
-        */
-       if ((ppp->flags & SC_COMP_AC) && !islcp
-           && PPP_ADDRESS(data) == PPP_ALLSTATIONS
-           && PPP_CONTROL(data) == PPP_UI) {
-               /* strip addr and control field */
-               skb_pull(ppp->tpkt,2);
-       }
-
-       return ppp_tty_sync_push(ppp);
-}
-
-/*
- * Push a synchronous frame out to the tty.
- * Returns 1 if frame accepted (or discarded), 0 otherwise.
- */
-static int
-ppp_tty_sync_push(struct ppp *ppp)
-{
-       int sent;
-       struct tty_struct *tty = ppp2tty(ppp);
-       unsigned long flags;
-               
-       CHECK_PPP(0);
-
-       if (ppp->tpkt == NULL)
-               return 0;
-               
-       /* prevent reentrancy with tty_pushing flag */          
-       save_flags(flags);
-       cli();
-       if (ppp->tty_pushing) {
-               /* record wakeup attempt so we don't lose */
-               /* a wakeup call while doing push processing */
-               ppp->woke_up=1;
-               restore_flags(flags);
-               return 0;
-       }
-       ppp->tty_pushing = 1;
-       restore_flags(flags);
-       
-       if (tty == NULL || tty->disc_data != (void *) ppp)
-               goto flush;
-               
-       for(;;){
-               ppp->woke_up=0;
-               
-               /* Note: Sync driver accepts complete frame or nothing */
-               tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-               sent = tty->driver.write(tty, 0, ppp->tpkt->data, ppp->tpkt->len);
-               if (sent < 0) {
-                       /* write error (possible loss of CD) */
-                       /* record error and discard current packet */
-                       ppp->stats.ppp_oerrors++;
-                       break;
-               }
-               ppp->stats.ppp_obytes += sent;
-               if (sent < ppp->tpkt->len) {
-                       /* driver unable to accept frame just yet */
-                       save_flags(flags);
-                       cli();
-                       if (ppp->woke_up) {
-                               /* wake up called while processing */
-                               /* try to send the frame again */
-                               restore_flags(flags);
-                               continue;
-                       }
-                       /* wait for wakeup callback to try send again */
-                       ppp->tty_pushing = 0;
-                       restore_flags(flags);
-                       return 0;
-               }
-               break;
-       }
-flush: 
-       /* done with current packet (sent or discarded) */
-       KFREE_SKB(ppp->tpkt);
-       ppp->tpkt = 0;
-       ppp->tty_pushing = 0;
-       return 1;
-}
-
-/*
- * Send a packet to the peer over an async tty line.
- * Returns -1 iff the packet could not be accepted at present,
- * 0 if the packet was accepted but we can't accept another yet, or
- * 1 if we can accept another packet immediately.
- * If this procedure returns 0, ppp_output_wakeup will be called
- * exactly once.
- */
-static int
-ppp_async_send(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-
-       ppp_tty_push(ppp);
-
-       if (ppp->tpkt != NULL)
-               return -1;
-       ppp->tpkt = skb;
-       ppp->tpkt_pos = 0;
-
-       return ppp_tty_push(ppp);
-}
-
-/*
- * Push as much data as possible out to the tty.
- * Returns 1 if we finished encoding the current frame, 0 otherwise.
- */
-static int
-ppp_tty_push(struct ppp *ppp)
-{
-       int avail, sent, done = 0;
-       struct tty_struct *tty = ppp2tty(ppp);
-       
-       if (ppp->flags & SC_SYNC) 
-               return ppp_tty_sync_push(ppp);
-
-       CHECK_PPP(0);
-       if (ppp->tty_pushing) {
-               ppp->woke_up = 1;
-               return 0;
-       }
-       if (tty == NULL || tty->disc_data != (void *) ppp)
-               goto flush;
-       while (ppp->optr < ppp->olim || ppp->tpkt != 0) {
-               ppp->tty_pushing = 1;
-               mb();
-               ppp->woke_up = 0;
-               avail = ppp->olim - ppp->optr;
-               if (avail > 0) {
-                       tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-                       sent = tty->driver.write(tty, 0, ppp->optr, avail);
-                       if (sent < 0)
-                               goto flush;     /* error, e.g. loss of CD */
-                       ppp->stats.ppp_obytes += sent;
-                       ppp->optr += sent;
-                       if (sent < avail) {
-                               wmb();
-                               ppp->tty_pushing = 0;
-                               mb();
-                               if (ppp->woke_up)
-                                       continue;
-                               return done;
-                       }
-               }
-               if (ppp->tpkt != 0)
-                       done = ppp_async_encode(ppp);
-               wmb();
-               ppp->tty_pushing = 0;
-       }
-       return done;
-
-flush:
-       ppp->tty_pushing = 1;
-       mb();
-       ppp->stats.ppp_oerrors++;
-       if (ppp->tpkt != 0) {
-               KFREE_SKB(ppp->tpkt);
-               ppp->tpkt = 0;
-               done = 1;
-       }
-       ppp->optr = ppp->olim;
-       wmb();
-       ppp->tty_pushing = 0;
-       return done;
-}
-
-/*
- * Procedure to encode the data for async serial transmission.
- * Does octet stuffing (escaping) and address/control
- * and protocol compression.
- * Assumes ppp->opkt != 0 on entry.
- * Returns 1 if we finished the current frame, 0 otherwise.
- */
-static int
-ppp_async_encode(struct ppp *ppp)
-{
-       int fcs, i, count, c;
-       unsigned char *buf, *buflim;
-       unsigned char *data;
-       int islcp;
-
-       CHECK_PPP(0);
-
-       buf = ppp->obuf;
-       ppp->olim = buf;
-       ppp->optr = buf;
-       i = ppp->tpkt_pos;
-       data = ppp->tpkt->data;
-       count = ppp->tpkt->len;
-       fcs = ppp->tfcs;
-
-       /*
-        * LCP packets with code values between 1 (configure-reqest)
-        * and 7 (code-reject) must be sent as though no options
-        * had been negotiated.
-        */
-       islcp = PPP_PROTOCOL(data) == PPP_LCP
-               && 1 <= data[PPP_HDRLEN] && data[PPP_HDRLEN] <= 7;
-
-       if (i == 0) {
-               /*
-                * Start of a new packet - insert the leading FLAG
-                * character if necessary.
-                */
-               if (islcp || flag_time == 0
-                   || jiffies - ppp->last_xmit >= flag_time)
-                       *buf++ = PPP_FLAG;
-               /* only reset idle time for data packets */
-               if (PPP_PROTOCOL(data) < 0x8000)
-                       ppp->last_xmit = jiffies;
-               fcs = PPP_INITFCS;
-               ++ppp->stats.ppp_opackets;
-               ppp->stats.ppp_ooctects += count;
-
-               /*
-                * Do address/control compression
-                */
-               if ((ppp->flags & SC_COMP_AC) != 0 && !islcp
-                   && PPP_ADDRESS(data) == PPP_ALLSTATIONS
-                   && PPP_CONTROL(data) == PPP_UI)
-                       i += 2;
-       }
-
-       /*
-        * Once we put in the last byte, we need to put in the FCS
-        * and closing flag, so make sure there is at least 7 bytes
-        * of free space in the output buffer.
-        */
-       buflim = buf + OBUFSIZE - 6;
-       while (i < count && buf < buflim) {
-               c = data[i++];
-               if (i == 3 && c == 0 && (ppp->flags & SC_COMP_PROT))
-                       continue;       /* compress protocol field */
-               fcs = PPP_FCS(fcs, c);
-               if (in_xmap(ppp, c) || (islcp && c < 0x20)) {
-                       *buf++ = PPP_ESCAPE;
-                       c ^= 0x20;
-               }
-               *buf++ = c;
-       }
-
-       if (i == count) {
-               /*
-                * We have finished the packet.  Add the FCS and flag.
-                */
-               fcs = ~fcs;
-               c = fcs & 0xff;
-               if (in_xmap(ppp, c) || (islcp && c < 0x20)) {
-                       *buf++ = PPP_ESCAPE;
-                       c ^= 0x20;
-               }
-               *buf++ = c;
-               c = (fcs >> 8) & 0xff;
-               if (in_xmap(ppp, c) || (islcp && c < 0x20)) {
-                       *buf++ = PPP_ESCAPE;
-                       c ^= 0x20;
-               }
-               *buf++ = c;
-               *buf++ = PPP_FLAG;
-               ppp->olim = buf;
-
-               KFREE_SKB(ppp->tpkt);
-               ppp->tpkt = 0;
-               return 1;
-       }
-
-       /*
-        * Remember where we are up to in this packet.
-        */
-       ppp->olim = buf;
-       ppp->tpkt_pos = i;
-       ppp->tfcs = fcs;
-       return 0;
-}
-
-/*
- * Flush output from our internal buffers.
- * Called for the TCFLSH ioctl.
- */
-static void
-ppp_tty_flush_output(struct ppp *ppp)
-{
-       struct sk_buff *skb;
-       int done = 0;
-
-       while ((skb = skb_dequeue(&ppp->xmt_q)) != NULL)
-               KFREE_SKB(skb);
-       ppp->tty_pushing = 1;
-       mb();
-       ppp->optr = ppp->olim;
-       if (ppp->tpkt != NULL) {
-               KFREE_SKB(ppp->tpkt);
-               ppp->tpkt = 0;
-               done = 1;
-       }
-       wmb();
-       ppp->tty_pushing = 0;
-       if (done)
-               ppp_output_wakeup(ppp);
-}
-
-/*
- * Callback function from tty driver. Return the amount of space left
- * in the receiver's buffer to decide if remote transmitter is to be
- * throttled.
- */
-static int
-ppp_tty_room (struct tty_struct *tty)
-{
-       return 65536;       /* We can handle an infinite amount of data. :-) */
-}
-
-/*
- * Callback function when data is available at the tty driver.
- */
-static void
-ppp_tty_receive (struct tty_struct *tty, const __u8 * data,
-                char *flags, int count)
-{
-       register struct ppp *ppp = tty2ppp (tty);
-       struct sk_buff *skb;
-       int chr, flg;
-       unsigned char *p;
-
-       if (ppp != 0)
-               CHECK_PPP_VOID();
-       /*
-        * This can happen if stuff comes in on the backup tty.
-        */
-       if (ppp == 0 || tty != ppp->tty)
-               return;
-       /*
-        * Verify the table pointer and ensure that the line is
-        * still in PPP discipline.
-        */
-       if (ppp->magic != PPP_MAGIC) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_DEBUG
-                              "PPP: tty_receive called but couldn't find "
-                              "PPP struct.\n");
-               return;
-       }
-       /*
-        * Print the buffer if desired
-        */
-       if (ppp->flags & SC_LOG_RAWIN)
-               ppp_print_buffer ("receive buffer", data, count);
-
-       ppp->stats.ppp_ibytes += count;
-       skb = ppp->rpkt;
-       
-       if ( ppp->flags & SC_SYNC ) {
-               /* synchronous mode */
-               
-               if (ppp->toss==0xE0) {
-                       /* this is the 1st frame, reset vj comp */
-                       ppp_receive_error(ppp);
-                       ppp->toss = 0;
-               }
-               
-               /*
-                * Allocate an skbuff for frame.
-                * The 128 is room for VJ header expansion.
-                */
-               
-               if (skb == NULL)
-                       skb = dev_alloc_skb(ppp->mru + 128 + PPP_HDRLEN);
-                       
-               if (skb == NULL) {
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "couldn't "
-                                      "alloc skb for recv\n");
-               } else {
-                       LIBERATE_SKB(skb);
-                       /*
-                        * Decompress A/C and protocol compression here.
-                        */
-                       p = skb_put(skb, 2);
-                       p[0] = PPP_ALLSTATIONS;
-                       p[1] = PPP_UI;
-                       if (*data == PPP_ALLSTATIONS) {
-                               data += 2;
-                               count -= 2;
-                       }
-                       if ((*data & 1) != 0) {
-                               p = skb_put(skb, 1);
-                               p[0] = 0;
-                       }
-
-                       /* copy frame to socket buffer */
-                       p = skb_put(skb, count);
-                       memcpy(p,data,count);
-                       
-                       /*
-                        * Check if we've overflowed the MRU
-                        */
-                       if (skb->len >= ppp->mru + PPP_HDRLEN + 2
-                           || skb_tailroom(skb) <= 0) {
-                               ++ppp->estats.rx_length_errors;
-                               if (ppp->flags & SC_DEBUG)
-                                       printk(KERN_DEBUG "rcv frame too long: "
-                                              "len=%d mru=%d hroom=%d troom=%d\n",
-                                              skb->len, ppp->mru, skb_headroom(skb),
-                                              skb_tailroom(skb));
-                       } else {
-                               if (!ppp_receive_frame(ppp, skb)) {
-                                       KFREE_SKB(skb);
-                                       ppp_receive_error(ppp);
-                               }
-                       }
-               
-                       /* Reset for the next frame */
-                       skb = NULL;
-               }
-               ppp->rpkt = skb;
-               return;
-       }
-       
-       while (count-- > 0) {
-               /*
-                * Collect the character and error condition for the character.
-                * Set the toss flag for the first character error.
-                */
-               chr = *data++;
-               if (flags) {
-                       flg = *flags++;
-                       if (flg) {
-                               if (ppp->toss == 0)
-                                       ppp->toss = flg;
-                               switch (flg) {
-                               case TTY_OVERRUN:
-                                       ++ppp->estats.rx_fifo_errors;
-                                       break;
-                               case TTY_FRAME:
-                               case TTY_BREAK:
-                                       ++ppp->estats.rx_frame_errors;
-                                       break;
-                               }
-                               continue;
-                       }
-               }
-
-               /*
-                * Set the flags for d7 being 0/1 and parity being
-                * even/odd so that the normal processing would have
-                * all flags set at the end of the session.  A
-                * missing flag bit indicates an error condition.
-                */
-
-#ifdef CHECK_CHARACTERS
-               if (chr & 0x80)
-                       ppp->flags |= SC_RCV_B7_1;
-               else
-                       ppp->flags |= SC_RCV_B7_0;
-
-               if (paritytab[chr >> 5] & (1 << (chr & 0x1F)))
-                       ppp->flags |= SC_RCV_ODDP;
-               else
-                       ppp->flags |= SC_RCV_EVNP;
-#endif
-
-               if (chr == PPP_FLAG) {
-                       /*
-                        * FLAG. This is the end of the block. If the block
-                        * ends with ESC FLAG, then the block is to be ignored.
-                        */
-                       if (ppp->escape)
-                               ppp->toss |= 0x80;
-                       /*
-                        * Process the frame if it was received correctly.
-                        * If there was an error, let the VJ decompressor know.
-                        * There are 4 cases here:
-                        * skb != NULL, toss != 0: error in frame
-                        * skb != NULL, toss == 0: frame ok
-                        * skb == NULL, toss != 0: very first frame,
-                        *      error on 1st char, or alloc_skb failed
-                        * skb == NULL, toss == 0: empty frame (~~)
-                        */
-                       if (ppp->toss || !ppp_receive_frame(ppp, skb)) {
-                               if (ppp->toss && (ppp->flags & SC_DEBUG))
-                                       printk(KERN_DEBUG
-                                              "ppp: tossing frame (%x)\n",
-                                              ppp->toss);
-                               if (skb != NULL)
-                                       KFREE_SKB(skb);
-                               if (!(ppp->toss == 0xE0 || ppp->toss == 0x80))
-                                       ++ppp->stats.ppp_ierrors;
-                               ppp_receive_error(ppp);
-                       }
-                       /*
-                        * Reset for the next frame.
-                        */
-                       skb = NULL;
-                       ppp->rfcs = PPP_INITFCS;
-                       ppp->escape = 0;
-                       ppp->toss = 0;
-                       continue;
-               }
-
-               /* If we're tossing, look no further. */
-               if (ppp->toss != 0)
-                       continue;
-
-               /* If this is a control char to be ignored, do so */
-               if (in_rmap(ppp, chr))
-                       continue;
-
-               /*
-                * Modify the next character if preceded by escape.
-                * The escape character (0x7d) could be an escaped
-                * 0x5d, if it follows an escape :-)
-                */
-               if (ppp->escape) {
-                       chr ^= PPP_TRANS;
-                       ppp->escape = 0;
-               } else if (chr == PPP_ESCAPE) {
-                       ppp->escape = PPP_TRANS;
-                       continue;
-               }
-
-               /*
-                * Allocate an skbuff on the first character received.
-                * The 128 is room for VJ header expansion and FCS.
-                */
-               if (skb == NULL) {
-                       skb = dev_alloc_skb(ppp->mru + 128 + PPP_HDRLEN);
-                       if (skb == NULL) {
-                               if (ppp->flags & SC_DEBUG)
-                                       printk(KERN_DEBUG "couldn't "
-                                              "alloc skb for recv\n");
-                               ppp->toss = 1;
-                               continue;
-                       }
-                       LIBERATE_SKB(skb);
-               }
-
-               /*
-                * Decompress A/C and protocol compression here.
-                */
-               if (skb->len == 0 && chr != PPP_ALLSTATIONS) {
-                       p = skb_put(skb, 2);
-                       p[0] = PPP_ALLSTATIONS;
-                       p[1] = PPP_UI;
-               }
-               if (skb->len == 2 && (chr & 1) != 0) {
-                       p = skb_put(skb, 1);
-                       p[0] = 0;
-               }
-
-               /*
-                * Check if we've overflowed the MRU
-                */
-               if (skb->len >= ppp->mru + PPP_HDRLEN + 2
-                   || skb_tailroom(skb) <= 0) {
-                       ++ppp->estats.rx_length_errors;
-                       ppp->toss = 0xC0;
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "rcv frame too long: "
-                                      "len=%d mru=%d hroom=%d troom=%d\n",
-                                      skb->len, ppp->mru, skb_headroom(skb),
-                                      skb_tailroom(skb));
-                       continue;
-               }
-
-               /*
-                * Store the character and update the FCS.
-                */
-               p = skb_put(skb, 1);
-               *p = chr;
-               ppp->rfcs = PPP_FCS(ppp->rfcs, chr);
-       }
-       ppp->rpkt = skb;
-}
-
-/*************************************************************
- * PPP NETWORK INTERFACE SUPPORT
- *     The following code implements the PPP network
- *     interface device and handles those parts of
- *     the PPP processing which are independent of the
- *     type of hardware link being used, including
- *     VJ and packet compression.
- *************************************************************/
-
-/*
- * Network device driver callback routines
- */
-
-static int ppp_init_dev(struct device *dev);
-static int ppp_dev_open(struct device *);
-static int ppp_dev_ioctl(struct device *dev, struct ifreq *ifr, int cmd);
-static int ppp_dev_close(struct device *);
-static int ppp_dev_xmit(struct sk_buff *, struct device *);
-static struct net_device_stats *ppp_dev_stats (struct device *);
-
-#if LINUX_VERSION_CODE < VERSION(2,1,15)
-static int ppp_dev_header(struct sk_buff *, struct device *, __u16,
-                         void *, void *, unsigned int);
-static int ppp_dev_rebuild(void *eth, struct device *dev,
-                          unsigned long raddr, struct sk_buff *skb);
-#endif
-
-/*
- * Information for the protocol decoder
- */
-
-typedef int (*pfn_proto)  (struct ppp *, struct sk_buff *);
-
-typedef struct ppp_proto_struct {
-       int             proto;
-       pfn_proto       func;
-} ppp_proto_type;
-
-static int rcv_proto_ip                (struct ppp *, struct sk_buff *);
-static int rcv_proto_ipv6      (struct ppp *, struct sk_buff *);
-static int rcv_proto_ipx       (struct ppp *, struct sk_buff *);
-static int rcv_proto_at                (struct ppp *, struct sk_buff *);
-static int rcv_proto_vjc_comp  (struct ppp *, struct sk_buff *);
-static int rcv_proto_vjc_uncomp (struct ppp *, struct sk_buff *);
-static int rcv_proto_ccp       (struct ppp *, struct sk_buff *);
-static int rcv_proto_unknown   (struct ppp *, struct sk_buff *);
-
-static
-ppp_proto_type proto_list[] = {
-       { PPP_IP,         rcv_proto_ip         },
-       { PPP_IPV6,       rcv_proto_ipv6       },
-       { PPP_IPX,        rcv_proto_ipx        },
-       { PPP_AT,         rcv_proto_at         },
-       { PPP_VJC_COMP,   rcv_proto_vjc_comp   },
-       { PPP_VJC_UNCOMP, rcv_proto_vjc_uncomp },
-       { PPP_CCP,        rcv_proto_ccp        },
-       { 0,              rcv_proto_unknown    }  /* !!! MUST BE LAST !!! */
-};
-
-/*
- * Called when the PPP network interface device is actually created.
- */
-static int
-ppp_init_dev (struct device *dev)
-{
-       dev->hard_header_len  = PPP_HDRLEN;
-#if LINUX_VERSION_CODE < VERSION(2,1,15)
-       dev->hard_header      = ppp_dev_header;
-       dev->rebuild_header   = ppp_dev_rebuild;
-#endif
-
-       /* device INFO */
-       dev->mtu              = PPP_MTU;
-       dev->hard_start_xmit  = ppp_dev_xmit;
-       dev->open             = ppp_dev_open;
-       dev->stop             = ppp_dev_close;
-       dev->get_stats        = ppp_dev_stats;
-       dev->do_ioctl         = ppp_dev_ioctl;
-       dev->addr_len         = 0;
-       dev->tx_queue_len     = 10;
-       dev->type             = ARPHRD_PPP;
-
-#if LINUX_VERSION_CODE < VERSION(2,1,20)
-       {
-               int    indx;
-
-               for (indx = 0; indx < DEV_NUMBUFFS; indx++)
-                       skb_queue_head_init (&dev->buffs[indx]);
-       }
-#else
-       dev_init_buffers(dev);
-#endif
-
-       dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
-
-       return 0;
-}
-
-/*
- * Callback from the network layer when the device goes up.
- */
-
-static int
-ppp_dev_open (struct device *dev)
-{
-       struct ppp *ppp = dev2ppp(dev);
-
-       if (!ppp->inuse || ppp2tty(ppp) == NULL) {
-               printk(KERN_ERR "ppp: %s not active\n", dev->name);
-               return -ENXIO;
-       }
-
-       MOD_INC_USE_COUNT;
-
-       return 0;
-}
-
-/*
- * Callback from the network layer when the ppp device goes down.
- */
-
-static int
-ppp_dev_close (struct device *dev)
-{
-       struct ppp *ppp = dev2ppp (dev);
-
-       CHECK_PPP_MAGIC(ppp);
-
-       MOD_DEC_USE_COUNT;
-
-       return 0;
-}
-
-static inline void
-get_vj_stats(struct vjstat *vj, struct slcompress *slc)
-{
-       vj->vjs_packets    = slc->sls_o_compressed + slc->sls_o_uncompressed;
-       vj->vjs_compressed = slc->sls_o_compressed;
-       vj->vjs_searches   = slc->sls_o_searches;
-       vj->vjs_misses     = slc->sls_o_misses;
-       vj->vjs_errorin    = slc->sls_i_error;
-       vj->vjs_tossed     = slc->sls_i_tossed;
-       vj->vjs_uncompressedin = slc->sls_i_uncompressed;
-       vj->vjs_compressedin   = slc->sls_i_compressed;
-}
-
-/*
- * Callback from the network layer to process the sockioctl functions.
- */
-static int
-ppp_dev_ioctl (struct device *dev, struct ifreq *ifr, int cmd)
-{
-       struct ppp *ppp = dev2ppp(dev);
-       int nb;
-       union {
-               struct ppp_stats stats;
-               struct ppp_comp_stats cstats;
-               char vers[32];
-       } u;
-
-       CHECK_PPP_MAGIC(ppp);
-
-       memset(&u, 0, sizeof(u));
-       switch (cmd) {
-       case SIOCGPPPSTATS:
-               u.stats.p = ppp->stats;
-               if (ppp->slcomp != NULL)
-                       get_vj_stats(&u.stats.vj, ppp->slcomp);
-               nb = sizeof(u.stats);
-               break;
-
-       case SIOCGPPPCSTATS:
-               if (ppp->sc_xc_state != NULL)
-                       (*ppp->sc_xcomp->comp_stat)
-                               (ppp->sc_xc_state, &u.cstats.c);
-               if (ppp->sc_rc_state != NULL)
-                       (*ppp->sc_rcomp->decomp_stat)
-                               (ppp->sc_rc_state, &u.cstats.d);
-               nb = sizeof(u.cstats);
-               break;
-
-       case SIOCGPPPVER:
-               strcpy(u.vers, szVersion);
-               nb = strlen(u.vers) + 1;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       if (COPY_TO_USER((void *) ifr->ifr_ifru.ifru_data, &u, nb))
-               return -EFAULT;
-       return 0;
-}
-
-/*
- * Process the generic PPP ioctls, i.e. those which are not specific
- * to any particular type of hardware link.
- */
-static int
-ppp_ioctl(struct ppp *ppp, unsigned int param2, unsigned long param3)
-{
-       register int temp_i = 0, oldflags;
-       int error = -EFAULT;
-       unsigned long flags;
-       struct ppp_idle cur_ddinfo;
-       struct npioctl npi;
-
-       CHECK_PPP(-ENXIO);
-
-       /*
-        * The user must have an euid of root to do these requests.
-        */
-       if (!SUSER())
-               return -EPERM;
-
-       switch (param2) {
-       case PPPIOCSMRU:
-               /*
-                * Set the MRU value
-                */
-               if (GET_USER(temp_i, (int *) param3))
-                       break;
-               if (temp_i < PPP_MRU)
-                       temp_i = PPP_MRU;
-               ppp->mru = temp_i;
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO
-                              "ppp_ioctl: set mru to %x\n", temp_i);
-               error = 0;
-               break;
-
-       case PPPIOCGFLAGS:
-               /*
-                * Fetch the current flags
-                */
-               temp_i = ppp->flags & SC_MASK;
-#ifndef CHECK_CHARACTERS /* Don't generate errors if we don't check chars. */
-               temp_i |= SC_RCV_B7_1 | SC_RCV_B7_0 |
-                         SC_RCV_ODDP | SC_RCV_EVNP;
-#endif
-               if (PUT_USER(temp_i, (int *) param3))
-                       break;
-               error = 0;
-               break;
-
-       case PPPIOCSFLAGS:
-               /*
-                * Set the flags for the various options
-                */
-               if (GET_USER(temp_i, (int *) param3))
-                       break;
-
-               if (ppp->flags & ~temp_i & SC_CCP_OPEN)
-                       ppp_ccp_closed(ppp);
-
-               save_flags(flags);
-               cli();
-               oldflags = ppp->flags;
-               temp_i = (temp_i & SC_MASK) | (oldflags & ~SC_MASK);
-               ppp->flags = temp_i;
-               restore_flags(flags);
-
-               if ((oldflags | temp_i) & SC_DEBUG)
-                       printk(KERN_INFO
-                              "ppp_ioctl: set flags to %x\n", temp_i);
-               error = 0;
-               break;
-
-       case PPPIOCSCOMPRESS:
-               /*
-                * Set the compression mode
-                */
-               error = ppp_set_compression
-                       (ppp, (struct ppp_option_data *) param3);
-               break;
-
-       case PPPIOCGUNIT:
-               /*
-                * Obtain the unit number for this device.
-                */
-               if (PUT_USER(ppp->line, (int *) param3))
-                       break;
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO
-                              "ppp_ioctl: get unit: %d\n", ppp->line);
-               error = 0;
-               break;
-
-       case PPPIOCSDEBUG:
-               /*
-                * Set the debug level
-                */
-               if (GET_USER(temp_i, (int *) param3))
-                       break;
-               temp_i = (temp_i & 0x1F) << 16;
-
-               if ((ppp->flags | temp_i) & SC_DEBUG)
-                       printk(KERN_INFO
-                              "ppp_ioctl: set dbg flags to %x\n", temp_i);
-
-               save_flags(flags);
-               cli();
-               ppp->flags = (ppp->flags & ~0x1F0000) | temp_i;
-               restore_flags(flags);
-               error = 0;
-               break;
-
-       case PPPIOCGDEBUG:
-               /*
-                * Get the debug level
-                */
-               temp_i = (ppp->flags >> 16) & 0x1F;
-               if (PUT_USER(temp_i, (int *) param3))
-                       break;
-               error = 0;
-               break;
-
-       case PPPIOCGIDLE:
-               /*
-                * Get the times since the last send/receive frame operation
-                */
-               /* change absolute times to relative times. */
-               cur_ddinfo.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
-               cur_ddinfo.recv_idle = (jiffies - ppp->last_recv) / HZ;
-               if (COPY_TO_USER((void *) param3, &cur_ddinfo,
-                                sizeof (cur_ddinfo)))
-                       break;
-               error = 0;
-               break;
-
-       case PPPIOCSMAXCID:
-               /*
-                * Set the maximum VJ header compression slot number.
-                */
-               if (GET_USER(temp_i, (int *) param3))
-                       break;
-               error = -EINVAL;
-               if (temp_i < 2 || temp_i > 255)
-                       break;
-               ++temp_i;
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO "ppp_ioctl: set maxcid to %d\n",
-                              temp_i);
-               if (ppp->slcomp != NULL)
-                       slhc_free(ppp->slcomp);
-               ppp->slcomp = slhc_init(16, temp_i);
-
-               error = -ENOMEM;
-               if (ppp->slcomp == NULL) {
-                       printk(KERN_ERR "ppp: no memory for VJ compression\n");
-                       break;
-               }
-               error = 0;
-               break;
-
-       case PPPIOCGNPMODE:
-       case PPPIOCSNPMODE:
-               if (COPY_FROM_USER(&npi, (void *) param3, sizeof(npi)))
-                       break;
-
-               switch (npi.protocol) {
-               case PPP_IPV6:
-                       npi.protocol = NP_IPV6;
-                       break;
-               case PPP_IP:
-                       npi.protocol = NP_IP;
-                       break;
-               case PPP_IPX:
-                       npi.protocol = NP_IPX;
-                       break;
-               case PPP_AT:
-                       npi.protocol = NP_AT;
-                       break;
-               default:
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "pppioc[gs]npmode: "
-                                      "invalid proto %d\n", npi.protocol);
-                       error = -EINVAL;
-                       goto out;
-               }
-
-               if (param2 == PPPIOCGNPMODE) {
-                       npi.mode = ppp->sc_npmode[npi.protocol];
-                       if (COPY_TO_USER((void *) param3, &npi, sizeof(npi)))
-                               break;
-               } else {
-                       ppp->sc_npmode[npi.protocol] = npi.mode;
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "ppp: set np %d to %d\n",
-                                      npi.protocol, npi.mode);
-                       mark_bh(NET_BH);
-               }
-               error = 0;
-               break;
-
-       default:
-               /*
-                *  All other ioctl() events will come here.
-                */
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_ERR
-                              "ppp_ioctl: invalid ioctl: %x, addr %lx\n",
-                              param2, param3);
-
-               error = -ENOIOCTLCMD;
-               break;
-       }
-out:
-       return error;
-}
-
-/*
- * Process the set-compression ioctl.
- */
-static int
-ppp_set_compression (struct ppp *ppp, struct ppp_option_data *odp)
-{
-       struct compressor *cp;
-       int error, nb;
-       unsigned long flags;
-       __u8 *ptr;
-       __u8 ccp_option[CCP_MAX_OPTION_LENGTH];
-       struct ppp_option_data data;
-
-       /*
-        * Fetch the compression parameters
-        */
-       error = -EFAULT;
-       if (COPY_FROM_USER(&data, odp, sizeof (data)))
-               goto out;
-
-       nb  = data.length;
-       ptr = data.ptr;
-       if ((unsigned) nb >= CCP_MAX_OPTION_LENGTH)
-               nb = CCP_MAX_OPTION_LENGTH;
-
-       if (COPY_FROM_USER(ccp_option, ptr, nb))
-               goto out;
-
-       error = -EINVAL;
-       if (ccp_option[1] < 2)  /* preliminary check on the length byte */
-               goto out;
-
-       save_flags(flags);
-       cli();
-       ppp->flags &= ~(data.transmit? SC_COMP_RUN: SC_DECOMP_RUN);
-       restore_flags(flags);
-
-       cp = find_compressor (ccp_option[0]);
-#if defined(CONFIG_KMOD) || defined(CONFIG_KERNELD)
-       if (cp == NULL) {
-               char modname[32];
-               sprintf(modname, "ppp-compress-%d", ccp_option[0]);
-               request_module(modname);
-               cp = find_compressor(ccp_option[0]);
-       }
-#endif /* CONFIG_KMOD */
-
-       if (cp == NULL) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_DEBUG
-                              "%s: no compressor for [%x %x %x], %x\n",
-                              ppp->name, ccp_option[0], ccp_option[1],
-                              ccp_option[2], nb);
-               goto out;               /* compressor not loaded */
-       }
-
-       /*
-        * Found a handler for the protocol - try to allocate
-        * a compressor or decompressor.
-        */
-       error = 0;
-       if (data.transmit) {
-               if (ppp->sc_xc_state != NULL)
-                       (*ppp->sc_xcomp->comp_free)(ppp->sc_xc_state);
-               ppp->sc_xc_state = NULL;
-
-               ppp->sc_xcomp    = cp;
-               ppp->sc_xc_state = cp->comp_alloc(ccp_option, nb);
-               if (ppp->sc_xc_state == NULL) {
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "%s: comp_alloc failed\n",
-                                      ppp->name);
-                       error = -ENOBUFS;
-               }
-       } else {
-               if (ppp->sc_rc_state != NULL)
-                       (*ppp->sc_rcomp->decomp_free)(ppp->sc_rc_state);
-               ppp->sc_rc_state = NULL;
-
-               ppp->sc_rcomp    = cp;
-               ppp->sc_rc_state = cp->decomp_alloc(ccp_option, nb);
-               if (ppp->sc_rc_state == NULL) {
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "%s: decomp_alloc failed\n",
-                                      ppp->name);
-                       error = -ENOBUFS;
-               }
-       }
-out:
-       return error;
-}
-
-/*
- * Handle a CCP packet.
- *
- * The CCP packet is passed along to the pppd process just like any
- * other PPP frame. The difference is that some processing needs to be
- * immediate or the compressors will become confused on the peer.
- */
-
-static void ppp_proto_ccp(struct ppp *ppp, __u8 *dp, int len, int rcvd)
-{
-       int slen    = CCP_LENGTH(dp);
-       __u8 *opt = dp   + CCP_HDRLEN;
-       int opt_len = slen - CCP_HDRLEN;
-       unsigned long flags;
-
-       if (slen > len)
-               return;
-
-       if (ppp->flags & SC_DEBUG)
-               printk(KERN_DEBUG "ppp_proto_ccp rcvd=%d code=%x flags=%x\n",
-                      rcvd, CCP_CODE(dp), ppp->flags);
-       save_flags(flags);
-       switch (CCP_CODE(dp)) {
-       case CCP_CONFREQ:
-       case CCP_TERMREQ:
-       case CCP_TERMACK:
-               /*
-                * CCP must be going down - disable compression
-                */
-               if (ppp->flags & SC_CCP_UP) {
-                       cli();
-                       ppp->flags &= ~(SC_CCP_UP   |
-                                       SC_COMP_RUN |
-                                       SC_DECOMP_RUN);
-               }
-               break;
-
-       case CCP_CONFACK:
-               if ((ppp->flags & SC_CCP_OPEN) == 0)
-                       break;
-               if (ppp->flags & SC_CCP_UP)
-                       break;
-               if (slen < (CCP_HDRLEN + CCP_OPT_MINLEN))
-                       break;
-               if (slen < (CCP_OPT_LENGTH (opt) + CCP_HDRLEN))
-                       break;
-               if (!rcvd) {
-                       /*
-                        * we're agreeing to send compressed packets.
-                        */
-                       if (ppp->sc_xc_state == NULL)
-                               break;
-
-                       if ((*ppp->sc_xcomp->comp_init)
-                           (ppp->sc_xc_state,
-                            opt, opt_len,
-                            ppp->line, 0, ppp->flags & SC_DEBUG)) {
-                               if (ppp->flags & SC_DEBUG)
-                                       printk(KERN_DEBUG "%s: comp running\n",
-                                              ppp->name);
-                               cli();
-                               ppp->flags |= SC_COMP_RUN;
-                       }
-                       break;
-               }
-
-               /*
-                * peer is agreeing to send compressed packets.
-                */
-               if (ppp->sc_rc_state == NULL)
-                       break;
-
-               if ((*ppp->sc_rcomp->decomp_init)
-                   (ppp->sc_rc_state,
-                    opt, opt_len,
-                    ppp->line, 0, ppp->mru, ppp->flags & SC_DEBUG)) {
-                       if (ppp->flags & SC_DEBUG)
-                               printk(KERN_DEBUG "%s: decomp running\n",
-                                      ppp->name);
-                       cli();
-                       ppp->flags |= SC_DECOMP_RUN;
-                       ppp->flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
-               }
-               break;
-
-       case CCP_RESETACK:
-               /*
-                * CCP Reset-ack resets compressors and decompressors
-                * as it passes through.
-                */
-               if ((ppp->flags & SC_CCP_UP) == 0)
-                       break;
-
-               if (!rcvd) {
-                       if (ppp->sc_xc_state && (ppp->flags & SC_COMP_RUN)) {
-                               (*ppp->sc_xcomp->comp_reset)(ppp->sc_xc_state);
-                               if (ppp->flags & SC_DEBUG)
-                                       printk(KERN_DEBUG "%s: comp reset\n",
-                                              ppp->name);
-                       }
-               } else {
-                       if (ppp->sc_rc_state && (ppp->flags & SC_DECOMP_RUN)) {
-                             (*ppp->sc_rcomp->decomp_reset)(ppp->sc_rc_state);
-                             if (ppp->flags & SC_DEBUG)
-                                       printk(KERN_DEBUG "%s: decomp reset\n",
-                                              ppp->name);
-                             cli();
-                             ppp->flags &= ~SC_DC_ERROR;
-                       }
-               }
-               break;
-       }
-       restore_flags(flags);
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-
-static void
-ppp_ccp_closed(struct ppp *ppp)
-{
-       unsigned long flags;
-
-       save_flags(flags);
-       cli();
-       ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
-       restore_flags(flags);
-       if (ppp->flags & SC_DEBUG)
-               printk(KERN_DEBUG "%s: ccp closed\n", ppp->name);
-       if (ppp->sc_xc_state) {
-               (*ppp->sc_xcomp->comp_free) (ppp->sc_xc_state);
-               ppp->sc_xc_state = NULL;
-       }
-
-       if (ppp->sc_rc_state) {
-               (*ppp->sc_rcomp->decomp_free) (ppp->sc_rc_state);
-               ppp->sc_rc_state = NULL;
-       }
-}
-
-/*************************************************************
- * RECEIVE-SIDE ROUTINES
- *************************************************************/
-
-/*
- * On entry, a received frame is in skb.
- * Check it and dispose as appropriate.
- */
-static int
-ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb)
-{
-       __u8    *data;
-       int     count;
-       int     proto;
-       int     new_count;
-       struct sk_buff *new_skb;
-       ppp_proto_type  *proto_ptr;
-
-       /*
-        * An empty frame is ignored. This occurs if the FLAG sequence
-        * precedes and follows each frame.
-        */
-       if (skb == NULL)
-               return 1;
-       if (skb->len == 0) {
-               KFREE_SKB(skb);
-               return 1;
-       }
-       data = skb->data;
-       count = skb->len;
-
-       /*
-        * Generate an error if the frame is too small.
-        */
-       if (count < PPP_HDRLEN + 2) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_DEBUG
-                              "ppp: got runt ppp frame, %d chars\n", count);
-               ++ppp->estats.rx_length_errors;
-               return 0;
-       }
-
-       if ( !(ppp->flags & SC_SYNC) ) { 
-               /*
-                * Verify the FCS of the frame and discard the FCS characters
-                * from the end of the buffer.
-                */
-               if (ppp->rfcs != PPP_GOODFCS) {
-                       if (ppp->flags & SC_DEBUG) {
-                               printk(KERN_DEBUG
-                                      "ppp: frame with bad fcs, length = %d\n",
-                                      count);
-                               ppp_print_buffer("bad frame", data, count);
-                       }
-                       ++ppp->estats.rx_crc_errors;
-                       return 0;
-               }
-               count -= 2;             /* ignore the fcs characters */
-               skb_trim(skb, count);
-       }
-       
-       /*
-        * Process the active decompressor.
-        */
-       if (ppp->sc_rc_state != NULL &&
-           (ppp->flags & SC_DECOMP_RUN) &&
-           ((ppp->flags & (SC_DC_FERROR | SC_DC_ERROR)) == 0)) {
-               if (PPP_PROTOCOL(data) == PPP_COMP) {
-                       /*
-                        * If the frame is compressed then decompress it.
-                        */
-                       new_skb = dev_alloc_skb(ppp->mru + 128 + PPP_HDRLEN);
-                       if (new_skb == NULL) {
-                               printk(KERN_ERR "ppp_recv_frame: no memory\n");
-                               new_count = DECOMP_ERROR;
-                       } else {
-                               LIBERATE_SKB(new_skb);
-                               new_count = (*ppp->sc_rcomp->decompress)
-                                       (ppp->sc_rc_state, data, count,
-                                        new_skb->data, ppp->mru + PPP_HDRLEN);
-                       }
-                       if (new_count > 0) {
-                               /* Frame was decompressed OK */
-                               KFREE_SKB(skb);
-                               skb = new_skb;
-                               count = new_count;
-                               data = skb_put(skb, count);
-
-                       } else {
-                               /*
-                                * On a decompression error, we pass the
-                                * compressed frame up to pppd as an
-                                * error indication.
-                                */
-                               if (ppp->flags & SC_DEBUG)
-                                       printk(KERN_INFO "%s: decomp err %d\n",
-                                              ppp->name, new_count);
-                               if (new_skb != 0)
-                                       KFREE_SKB(new_skb);
-                               if (ppp->slcomp != 0)
-                                       slhc_toss(ppp->slcomp);
-                               ++ppp->stats.ppp_ierrors;
-                               if (new_count == DECOMP_FATALERROR) {
-                                       ppp->flags |= SC_DC_FERROR;
-                               } else {
-                                       ppp->flags |= SC_DC_ERROR;
-                               }
-                       }
-
-
-               } else {
-                       /*
-                        * The frame is not compressed. Pass it to the
-                        * decompression code so it can update its
-                        * dictionary if necessary.
-                        */
-                       (*ppp->sc_rcomp->incomp)(ppp->sc_rc_state,
-                                                data, count);
-               }
-       }
-       else if (PPP_PROTOCOL(data) == PPP_COMP && (ppp->flags & SC_DEBUG))
-               printk(KERN_INFO "%s: not decomp, rc_state=%p flags=%x\n",
-                      ppp->name, ppp->sc_rc_state, ppp->flags);
-
-       /*
-        * Count the frame and print it
-        */
-       ++ppp->stats.ppp_ipackets;
-       ppp->stats.ppp_ioctects += count;
-       if (ppp->flags & SC_LOG_INPKT)
-               ppp_print_buffer ("receive frame", data, count);
-
-       /*
-        * Find the procedure to handle this protocol.
-        * The last one is marked as protocol 0 which is the 'catch-all'
-        * to feed it to the pppd daemon.
-        */
-       proto = PPP_PROTOCOL(data);
-       proto_ptr = proto_list;
-       while (proto_ptr->proto != 0 && proto_ptr->proto != proto)
-               ++proto_ptr;
-
-       /*
-        * Update the appropriate statistic counter.
-        */
-       if (!(*proto_ptr->func)(ppp, skb)) {
-               KFREE_SKB(skb);
-               ++ppp->stats.ppp_discards;
-       }
-
-       return 1;
-}
-
-/*
- * An input error has been detected, so we need to inform
- * the VJ decompressor.
- */
-static void
-ppp_receive_error(struct ppp *ppp)
-{
-       CHECK_PPP_VOID();
-
-       if (ppp->slcomp != 0)
-               slhc_toss(ppp->slcomp);
-}
-
-/*
- * Put the input frame into the networking system for the indicated protocol
- */
-static int
-ppp_rcv_rx(struct ppp *ppp, __u16 proto, struct sk_buff *skb)
-{
-
-       /*
-        * Fill in a few fields of the skb and give it to netif_rx().
-        */
-       skb->dev      = ppp2dev(ppp);   /* We are the device */
-       skb->protocol = htons(proto);
-       skb_pull(skb, PPP_HDRLEN);      /* pull off ppp header */
-       skb->mac.raw   = skb->data;
-       ppp->last_recv = jiffies;
-       netif_rx (skb);
-       return 1;
-}
-
-/*
- * Process the receipt of an IP frame
- */
-static int
-rcv_proto_ip(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-       if ((ppp2dev(ppp)->flags & IFF_UP) && (skb->len > 0)
-           && ppp->sc_npmode[NP_IP] == NPMODE_PASS)
-               return ppp_rcv_rx(ppp, ETH_P_IP, skb);
-       return 0;
-}
-
-/*
- * Process the receipt of an IPv6 frame
- */
-static int
-rcv_proto_ipv6(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-       if ((ppp2dev(ppp)->flags & IFF_UP) && (skb->len > 0)
-           && ppp->sc_npmode[NP_IPV6] == NPMODE_PASS)
-               return ppp_rcv_rx(ppp, ETH_P_IPV6, skb);
-       return 0;
-}
-
-/*
- * Process the receipt of an IPX frame
- */
-static int
-rcv_proto_ipx(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-       if (((ppp2dev(ppp)->flags & IFF_UP) != 0) && (skb->len > 0)
-           && ppp->sc_npmode[NP_IPX] == NPMODE_PASS)
-               return ppp_rcv_rx(ppp, ETH_P_IPX, skb);
-       return 0;
-}
-
-/*
- * Process the receipt of an Appletalk frame
- */
-static int
-rcv_proto_at(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-       if ((ppp2dev(ppp)->flags & IFF_UP) && (skb->len > 0)
-           && ppp->sc_npmode[NP_AT] == NPMODE_PASS)
-               return ppp_rcv_rx(ppp, ETH_P_PPPTALK, skb);
-       return 0;
-}
-
-/*
- * Process the receipt of an VJ Compressed frame
- */
-static int
-rcv_proto_vjc_comp(struct ppp *ppp, struct sk_buff *skb)
-{
-       int new_count;
-
-       CHECK_PPP(0);
-       if ((ppp->flags & SC_REJ_COMP_TCP) || ppp->slcomp == NULL)
-               return 0;
-       new_count = slhc_uncompress(ppp->slcomp, skb->data + PPP_HDRLEN,
-                                   skb->len - PPP_HDRLEN);
-       if (new_count <= 0) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_NOTICE
-                              "ppp: error in VJ decompression\n");
-               return 0;
-       }
-       new_count += PPP_HDRLEN;
-       if (new_count > skb->len)
-               skb_put(skb, new_count - skb->len);
-       else
-               skb_trim(skb, new_count);
-       return rcv_proto_ip(ppp, skb);
-}
-
-/*
- * Process the receipt of an VJ Un-compressed frame
- */
-static int
-rcv_proto_vjc_uncomp(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-       if ((ppp->flags & SC_REJ_COMP_TCP) || ppp->slcomp == NULL)
-               return 0;
-       if (slhc_remember(ppp->slcomp, skb->data + PPP_HDRLEN,
-                         skb->len - PPP_HDRLEN) <= 0) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_NOTICE "ppp: error in VJ memorizing\n");
-               return 0;
-       }
-       return rcv_proto_ip(ppp, skb);
-}
-
-static int
-rcv_proto_ccp(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-       ppp_proto_ccp (ppp, skb->data + PPP_HDRLEN, skb->len - PPP_HDRLEN, 1);
-       return rcv_proto_unknown(ppp, skb);
-}
-
-/*
- * Receive all unclassified protocols.
- */
-static int
-rcv_proto_unknown(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP(0);
-
-       /*
-        * Limit queue length by dropping old frames.
-        */
-       skb_queue_tail(&ppp->rcv_q, skb);
-       while (ppp->rcv_q.qlen > PPP_MAX_RCV_QLEN) {
-               struct sk_buff *skb = skb_dequeue(&ppp->rcv_q);
-               if (skb)
-                       KFREE_SKB(skb);
-       }
-
-       wake_up_interruptible (&ppp->read_wait);
-       if (ppp->tty->fasync != NULL)
-               kill_fasync (ppp->tty->fasync, SIGIO);
-
-       return 1;
-}
-
-/*************************************************************
- * TRANSMIT-SIDE ROUTINES
- *************************************************************/
-
-/* local function to store a value into the LQR frame */
-extern inline __u8 * store_long (register __u8 *p, register int value) {
-       *p++ = (__u8) (value >> 24);
-       *p++ = (__u8) (value >> 16);
-       *p++ = (__u8) (value >>  8);
-       *p++ = (__u8) value;
-       return p;
-}
-
-/*
- * Compress and send an frame to the peer.
- * Should be called with xmit_busy == 1, having been set by the caller.
- * That is, we use xmit_busy as a lock to prevent reentry of this
- * procedure.
- */
-static void
-ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
-{
-       int     proto;
-       __u8    *data;
-       int     count;
-       __u8    *p;
-       int     ret;
-
-       CHECK_PPP_VOID();
-       data = skb->data;
-       count = skb->len;
-
-       /* dump the buffer */
-       if (ppp->flags & SC_LOG_OUTPKT)
-               ppp_print_buffer ("write frame", data, count);
-
-       /*
-        * Handle various types of protocol-specific compression
-        * and other processing, including:
-        * - VJ TCP header compression
-        * - updating LQR packets
-        * - updating CCP state on CCP packets
-        */
-       proto = PPP_PROTOCOL(data);
-       switch (proto) {
-       case PPP_IP:
-               if ((ppp->flags & SC_COMP_TCP) && ppp->slcomp != NULL)
-                       skb = ppp_vj_compress(ppp, skb);
-               break;
-
-       case PPP_LQR:
-               /*
-                * Update the LQR frame with the current MIB information.
-                * This way the information is accurate and up-to-date.
-                */
-               if (count < 48)
-                       break;
-               p = data + 40;  /* Point to last two items. */
-               p = store_long(p, ppp->stats.ppp_opackets + 1);
-               p = store_long(p, ppp->stats.ppp_ooctects + count);
-               ++ppp->stats.ppp_olqrs;
-               break;
-
-       case PPP_CCP:
-               /*
-                * Outbound compression control frames
-                */
-               ppp_proto_ccp(ppp, data + PPP_HDRLEN, count - PPP_HDRLEN, 0);
-               break;
-       }
-       data = skb->data;
-       count = skb->len;
-
-       /*
-        * Compress the whole frame if possible.
-        */
-       if (((ppp->flags & SC_COMP_RUN) != 0)   &&
-           (ppp->sc_xc_state != (void *) 0)    &&
-           (proto != PPP_LCP)                  &&
-           (proto != PPP_CCP)) {
-               struct sk_buff *new_skb;
-               int new_count;
-
-               /* Allocate an skb for the compressed frame. */
-               new_skb = alloc_skb(ppp->mtu + PPP_HDRLEN, GFP_ATOMIC);
-               if (new_skb == NULL) {
-                       printk(KERN_ERR "ppp_send_frame: no memory\n");
-                       KFREE_SKB(skb);
-                       ppp->xmit_busy = 0;
-                       return;
-               }
-               LIBERATE_SKB(new_skb);
-
-               /* Compress the frame. */
-               new_count = (*ppp->sc_xcomp->compress)
-                       (ppp->sc_xc_state, data, new_skb->data,
-                        count, ppp->mtu + PPP_HDRLEN);
-
-               /* Did it compress? */
-               if (new_count > 0 && (ppp->flags & SC_CCP_UP)) {
-                       skb_put(new_skb, new_count);
-                       KFREE_SKB(skb);
-                       skb = new_skb;
-               } else {
-                       /*
-                        * The frame could not be compressed, or it could not
-                        * be sent in compressed form because CCP is down.
-                        */
-                       KFREE_SKB(new_skb);
-               }
-       }
-
-       /*
-        * Send the frame
-        */
-       if ( ppp->flags & SC_SYNC ) 
-               ret = ppp_sync_send(ppp, skb);
-       else
-               ret = ppp_async_send(ppp, skb);
-       if (ret > 0) {
-               /* we can release the lock */
-               ppp->xmit_busy = 0;
-       } else if (ret < 0) {
-               /* can't happen, since the caller got the xmit_busy lock */
-               printk(KERN_ERR "ppp: ppp_async_send didn't accept pkt\n");
-       }
-}
-
-/*
- * Apply VJ TCP header compression to a packet.
- */
-static struct sk_buff *
-ppp_vj_compress(struct ppp *ppp, struct sk_buff *skb)
-{
-       __u8 *orig_data, *data;
-       struct sk_buff *new_skb;
-       int len, proto;
-
-       new_skb = alloc_skb(skb->len, GFP_ATOMIC);
-       if (new_skb == NULL) {
-               printk(KERN_ERR "ppp: no memory for vj compression\n");
-               return skb;
-       }
-       LIBERATE_SKB(new_skb);
-
-       orig_data = data = skb->data + PPP_HDRLEN;
-       len = slhc_compress(ppp->slcomp, data, skb->len - PPP_HDRLEN,
-                           new_skb->data + PPP_HDRLEN, &data,
-                           (ppp->flags & SC_NO_TCP_CCID) == 0);
-
-       if (data == orig_data) {
-               /* Couldn't compress the data */
-               KFREE_SKB(new_skb);
-               return skb;
-       }
-
-       /* The data has been changed */
-       if (data[0] & SL_TYPE_COMPRESSED_TCP) {
-               proto = PPP_VJC_COMP;
-               data[0] ^= SL_TYPE_COMPRESSED_TCP;
-       } else {
-               if (data[0] >= SL_TYPE_UNCOMPRESSED_TCP)
-                       proto = PPP_VJC_UNCOMP;
-               else
-                       proto = PPP_IP;
-               data[0] = orig_data[0];
-       }
-
-       data = skb_put(new_skb, len + PPP_HDRLEN);
-       data[0] = PPP_ALLSTATIONS;
-       data[1] = PPP_UI;
-       data[2] = 0;
-       data[3] = proto;
-
-       KFREE_SKB(skb);
-       return new_skb;
-}
-
-static inline void
-ppp_send_frames(struct ppp *ppp)
-{
-       struct sk_buff *skb;
-
-       while (!test_and_set_bit(0, &ppp->xmit_busy)) {
-               skb = skb_dequeue(&ppp->xmt_q);
-               if (skb == NULL) {
-                       ppp->xmit_busy = 0;
-                       break;
-               }
-               ppp_send_frame(ppp, skb);
-       }
-       if (!ppp->xmit_busy && ppp->dev.tbusy) {
-               ppp->dev.tbusy = 0;
-               mark_bh(NET_BH);
-       }
-}
-
-/*
- * Called from the hardware (tty) layer when it can accept
- * another packet.
- */
-static void
-ppp_output_wakeup(struct ppp *ppp)
-{
-       CHECK_PPP_VOID();
-
-       if (!ppp->xmit_busy) {
-               printk(KERN_ERR "ppp_output_wakeup called but xmit_busy==0\n");
-               return;
-       }
-       ppp->xmit_busy = 0;
-       ppp_send_frames(ppp);
-}
-
-/*
- * Send a control frame (from pppd).
- */
-static void
-ppp_send_ctrl(struct ppp *ppp, struct sk_buff *skb)
-{
-       CHECK_PPP_VOID();
-
-       /*
-        * Put the packet on the queue, then send as many as we can.
-        */
-       skb_queue_tail(&ppp->xmt_q, skb);
-       ppp_send_frames(ppp);
-}
-
-
-/*************************************************************
- * NETWORK OUTPUT
- *    This routine accepts requests from the network layer
- *    and attempts to deliver the packets.
- *************************************************************/
-/*
- * Send a frame to the peer.
- * Returns 1 iff the frame was not accepted.
- */
-static int
-ppp_dev_xmit(struct sk_buff *skb, struct device *dev)
-{
-       struct ppp *ppp = dev2ppp(dev);
-       struct tty_struct *tty = ppp2tty(ppp);
-       enum NPmode npmode;
-       int proto;
-       unsigned char *hdr;
-
-       /* just a little sanity check. */
-       if (skb == NULL)
-               return 0;
-       if (skb->data == NULL) {
-               KFREE_SKB(skb);
-               return 0;
-       }
-
-       /*
-        * Avoid timing problem should tty hangup while data is
-        * queued to be sent.
-        */
-       if (!ppp->inuse) {
-               KFREE_SKB(skb);
-               return 0;
-       }
-
-       /*
-        * Validate the tty interface
-        */
-       if (tty == NULL) {
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_ERR
-                              "ppp_dev_xmit: %s not connected to a TTY!\n",
-                              dev->name);
-               KFREE_SKB(skb);
-               return 0;
-       }
-
-       /*
-        * Work out the appropriate network-protocol mode for this packet.
-        */
-       npmode = NPMODE_PASS;   /* default */
-       switch (ntohs(skb->protocol)) {
-       case ETH_P_IP:
-               proto = PPP_IP;
-               npmode = ppp->sc_npmode[NP_IP];
-               break;
-       case ETH_P_IPV6:
-               proto = PPP_IPV6;
-               npmode = ppp->sc_npmode[NP_IPV6];
-               break;
-       case ETH_P_IPX:
-               proto = PPP_IPX;
-               npmode = ppp->sc_npmode[NP_IPX];
-               break;
-       case ETH_P_PPPTALK:
-       case ETH_P_ATALK:
-               proto = PPP_AT;
-               npmode = ppp->sc_npmode[NP_AT];
-               break;
-       default:
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_INFO "%s: packet for unknown proto %x\n",
-                              ppp->name, ntohs(skb->protocol));
-               KFREE_SKB(skb);
-               return 0;
-       }
-
-       /*
-        * Drop, accept or reject the packet depending on the mode.
-        */
-       switch (npmode) {
-       case NPMODE_PASS:
-               break;
-
-       case NPMODE_QUEUE:
-               /*
-                * We may not send the packet now, so drop it.
-                * XXX It would be nice to be able to return it to the
-                * network system to be queued and retransmitted later.
-                */
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_DEBUG "%s: returning frame\n", ppp->name);
-               KFREE_SKB(skb);
-               return 0;
-
-       case NPMODE_ERROR:
-       case NPMODE_DROP:
-               if (ppp->flags & SC_DEBUG)
-                       printk(KERN_DEBUG
-                              "ppp_dev_xmit: dropping (npmode = %d) on %s\n",
-                              npmode, ppp->name);
-               KFREE_SKB(skb);
-               return 0;
-       }
-
-       /*
-        * The dev->tbusy field acts as a lock to allow only
-        * one packet to be processed at a time.  If we can't
-        * get the lock, try again later.
-        * We deliberately queue as little as possible inside
-        * the ppp driver in order to minimize the latency
-        * for high-priority packets.
-        */
-       if (test_and_set_bit(0, &ppp->xmit_busy)) {
-               dev->tbusy = 1; /* can't take it now */
-               return 1;
-       }
-       dev->tbusy = 0;
-
-       /*
-        * Put the 4-byte PPP header on the packet.
-        * If there isn't room for it, we have to copy the packet.
-        */
-       if (skb_headroom(skb) < PPP_HDRLEN) {
-               struct sk_buff *new_skb;
-
-               new_skb = alloc_skb(skb->len + PPP_HDRLEN, GFP_ATOMIC);
-               if (new_skb == NULL) {
-                       printk(KERN_ERR "%s: skb hdr alloc failed\n",
-                              ppp->name);
-                       KFREE_SKB(skb);
-                       ppp->xmit_busy = 0;
-                       ppp_send_frames(ppp);
-                       return 0;
-               }
-               LIBERATE_SKB(new_skb);
-               skb_reserve(new_skb, PPP_HDRLEN);
-               memcpy(skb_put(new_skb, skb->len), skb->data, skb->len);
-               KFREE_SKB(skb);
-               skb = new_skb;
-       }
-
-       hdr = skb_push(skb, PPP_HDRLEN);
-       hdr[0] = PPP_ALLSTATIONS;
-       hdr[1] = PPP_UI;
-       hdr[2] = proto >> 8;
-       hdr[3] = proto;
-
-       ppp_send_frame(ppp, skb);
-       if (!ppp->xmit_busy)
-               ppp_send_frames(ppp);
-       return 0;
-}
-
-#if LINUX_VERSION_CODE < VERSION(2,1,15)
-/*
- * Null hard_header and header_rebuild routines.
- */
-static int ppp_dev_header(struct sk_buff *skb, struct device *dev,
-                         unsigned short type, void *daddr,
-                         void *saddr, unsigned int len)
-{
-       return 0;
-}
-
-static int ppp_dev_rebuild(void *eth, struct device *dev,
-                          unsigned long raddr, struct sk_buff *skb)
-{
-       return 0;
-}
-#endif /* < 2.1.15 */
-
-/*
- * Generate the statistic information for the /proc/net/dev listing.
- */
-static struct net_device_stats *
-ppp_dev_stats (struct device *dev)
-{
-       struct ppp *ppp = dev2ppp (dev);
-
-       ppp->estats.rx_packets = ppp->stats.ppp_ipackets;
-       ppp->estats.rx_errors  = ppp->stats.ppp_ierrors;
-       ppp->estats.tx_packets = ppp->stats.ppp_opackets;
-       ppp->estats.tx_errors  = ppp->stats.ppp_oerrors;
-#if LINUX_VERSION_CODE >= VERSION(2,1,25)
-       ppp->estats.rx_bytes   = ppp->stats.ppp_ibytes;
-       ppp->estats.tx_bytes   = ppp->stats.ppp_obytes;
-#endif
-
-       return &ppp->estats;
-}
-
-/*************************************************************
- * UTILITIES
- *    Miscellany called by various functions above.
- *************************************************************/
-
-/* Locate the previous instance of the PPP channel */
-static struct ppp *
-ppp_find(int pid_value)
-{
-       struct ppp      *ppp;
-
-       /* try to find the device which this pid is already using */
-       for (ppp = ppp_list; ppp != 0; ppp = ppp->next) {
-               if (ppp->inuse && ppp->sc_xfer == pid_value) {
-                       ppp->sc_xfer = 0;
-                       break;
-               }
-       }
-       return ppp;
-}
-
-/* allocate or create a PPP channel */
-static struct ppp *
-ppp_alloc(void)
-{
-       int             if_num;
-       int             status;
-       struct device   *dev;
-       struct ppp      *ppp;
-
-       /* try to find an free device */
-       for (ppp = ppp_list; ppp != 0; ppp = ppp->next) {
-               if (!test_and_set_bit(0, &ppp->inuse)) {
-                       dev = ppp2dev(ppp);
-                       if (dev->flags & IFF_UP) {
-                               clear_bit(0, &ppp->inuse);
-                               continue;
-                       }
-                       /* Reregister device */
-                       unregister_netdev(dev);
-                       if (register_netdev(dev) == 0)
-                               return ppp;
-                       printk(KERN_DEBUG "could not reregister ppp device\n");
-                       /* leave inuse set in this case */
-               }
-       }
-
-       /*
-        * There are no available units, so make a new one.
-        */
-       ppp = (struct ppp *) kmalloc(sizeof(struct ppp), GFP_KERNEL);
-       if (ppp == 0) {
-               printk(KERN_ERR "ppp: struct ppp allocation failed\n");
-               return 0;
-       }
-       memset(ppp, 0, sizeof(*ppp));
-
-       /* initialize channel control data */
-       ppp->magic = PPP_MAGIC;
-       ppp->next = NULL;
-       ppp->inuse = 1;
-       ppp->read_wait = NULL;
-
-       /*
-        * Make up a suitable name for this device
-        */
-       dev = ppp2dev(ppp);
-       dev->name = ppp->name;
-#if LINUX_VERSION_CODE < VERSION(2,1,31)
-       if_num = (ppp_list == 0)? 0: ppp_last->line + 1;
-       sprintf(ppp->name, "ppp%d", if_num);
-#else
-       if_num = dev_alloc_name(dev, "ppp%d");
-#endif
-       if (if_num < 0) {
-               printk(KERN_ERR "ppp: dev_alloc_name failed (%d)\n", if_num);
-               kfree(ppp);
-               return 0;
-       }
-       ppp->line = if_num;
-       ppp->slcomp = NULL;
-
-       dev->next = NULL;
-       dev->init = ppp_init_dev;
-       dev->name = ppp->name;
-       dev->priv = (void *) ppp;
-
-       /* register device so that we can be ifconfig'd */
-       /* ppp_init_dev() will be called as a side-effect */
-       status = register_netdev (dev);
-       if (status == 0) {
-               printk(KERN_INFO "registered device %s\n", dev->name);
-       } else {
-               printk(KERN_ERR
-                      "ppp_alloc - register_netdev(%s) = %d failure.\n",
-                      dev->name, status);
-               kfree(ppp);
-               ppp = NULL;
-       }
-
-       /* link this unit into our list */
-       if (ppp_list == 0)
-               ppp_list = ppp;
-       else
-               ppp_last->next = ppp;
-       ppp_last = ppp;
-
-       return ppp;
-}
-
-/*
- * Initialize the generic parts of the ppp structure.
- */
-static void
-ppp_generic_init(struct ppp *ppp)
-{
-       int indx;
-
-       ppp->flags  = 0;
-       ppp->mtu    = PPP_MTU;
-       ppp->mru    = PPP_MRU;
-
-       skb_queue_head_init(&ppp->xmt_q);
-       skb_queue_head_init(&ppp->rcv_q);
-
-       ppp->last_xmit  = jiffies;
-       ppp->last_recv  = jiffies;
-       ppp->xmit_busy  = 0;
-
-       /* clear statistics */
-       memset(&ppp->stats, 0, sizeof (struct pppstat));
-       memset(&ppp->estats, 0, sizeof(struct net_device_stats));
-
-       /* PPP compression data */
-       ppp->sc_xc_state = NULL;
-       ppp->sc_rc_state = NULL;
-
-       for (indx = 0; indx < NUM_NP; ++indx)
-               ppp->sc_npmode[indx] = NPMODE_PASS;
-}
-
-/*
- * Called to clean up the generic parts of the ppp structure.
- */
-static void
-ppp_release(struct ppp *ppp)
-{
-       struct sk_buff *skb;
-
-       CHECK_PPP_MAGIC(ppp);
-
-       if (ppp->flags & SC_DEBUG)
-               printk(KERN_DEBUG "%s released\n", ppp->name);
-
-       ppp_ccp_closed(ppp);
-
-        /* Ensure that the pppd process is not hanging on select()/poll() */
-        wake_up_interruptible(&ppp->read_wait);
-
-       if (ppp->slcomp) {
-               slhc_free(ppp->slcomp);
-               ppp->slcomp = NULL;
-       }
-
-       while ((skb = skb_dequeue(&ppp->rcv_q)) != NULL)
-               KFREE_SKB(skb);
-       while ((skb = skb_dequeue(&ppp->xmt_q)) != NULL)
-               KFREE_SKB(skb);
-
-       ppp->inuse = 0;
-       if (ppp->dev.tbusy) {
-               ppp->dev.tbusy = 0;
-               mark_bh(NET_BH);
-       }
-}
-
-/*
- * Utility procedures to print a buffer in hex/ascii
- */
-static void
-ppp_print_hex (register __u8 * out, const __u8 * in, int count)
-{
-       register __u8 next_ch;
-       static char hex[] = "0123456789ABCDEF";
-
-       while (count-- > 0) {
-               next_ch = *in++;
-               *out++ = hex[(next_ch >> 4) & 0x0F];
-               *out++ = hex[next_ch & 0x0F];
-               ++out;
-       }
-}
-
-static void
-ppp_print_char (register __u8 * out, const __u8 * in, int count)
-{
-       register __u8 next_ch;
-
-       while (count-- > 0) {
-               next_ch = *in++;
-
-               if (next_ch < 0x20 || next_ch > 0x7e)
-                       *out++ = '.';
-               else {
-                       *out++ = next_ch;
-                       if (next_ch == '%')   /* printk/syslogd has a bug !! */
-                               *out++ = '%';
-               }
-       }
-       *out = '\0';
-}
-
-static void
-ppp_print_buffer (const char *name, const __u8 *buf, int count)
-{
-       __u8 line[44];
-
-       if (name != NULL)
-               printk(KERN_DEBUG "ppp: %s, count = %d\n", name, count);
-
-       while (count > 8) {
-               memset (line, 32, 44);
-               ppp_print_hex (line, buf, 8);
-               ppp_print_char (&line[8 * 3], buf, 8);
-               printk(KERN_DEBUG "%s\n", line);
-               count -= 8;
-               buf += 8;
-       }
-
-       if (count > 0) {
-               memset (line, 32, 44);
-               ppp_print_hex (line, buf, count);
-               ppp_print_char (&line[8 * 3], buf, count);
-               printk(KERN_DEBUG "%s\n", line);
-       }
-}
-
-/*************************************************************
- * Compressor module interface
- *************************************************************/
-
-struct compressor_link {
-       struct compressor_link  *next;
-       struct compressor       *comp;
-};
-
-static struct compressor_link *ppp_compressors = (struct compressor_link *) 0;
-
-static struct compressor *find_compressor (int type)
-{
-       struct compressor_link *lnk;
-       unsigned long flags;
-
-       save_flags(flags);
-       cli();
-
-       lnk = ppp_compressors;
-       while (lnk != (struct compressor_link *) 0) {
-               if ((int) (__u8) lnk->comp->compress_proto == type) {
-                       restore_flags(flags);
-                       return lnk->comp;
-               }
-               lnk = lnk->next;
-       }
-
-       restore_flags(flags);
-       return (struct compressor *) 0;
-}
-
-static int ppp_register_compressor (struct compressor *cp)
-{
-       struct compressor_link *new;
-       unsigned long flags;
-
-       new = (struct compressor_link *)
-               kmalloc (sizeof (struct compressor_link), GFP_KERNEL);
-
-       if (new == (struct compressor_link *) 0)
-               return 1;
-
-       save_flags(flags);
-       cli();
-
-       if (find_compressor (cp->compress_proto)) {
-               restore_flags(flags);
-               kfree (new);
-               return 0;
-       }
-
-       new->next       = ppp_compressors;
-       new->comp       = cp;
-       ppp_compressors = new;
-
-       restore_flags(flags);
-       return 0;
-}
-
-static void ppp_unregister_compressor (struct compressor *cp)
-{
-       struct compressor_link *prev = (struct compressor_link *) 0;
-       struct compressor_link *lnk;
-       unsigned long flags;
-
-       save_flags(flags);
-       cli();
-
-       lnk  = ppp_compressors;
-       while (lnk != (struct compressor_link *) 0) {
-               if (lnk->comp == cp) {
-                       if (prev)
-                               prev->next = lnk->next;
-                       else
-                               ppp_compressors = lnk->next;
-                       kfree (lnk);
-                       break;
-               }
-               prev = lnk;
-               lnk  = lnk->next;
-       }
-       restore_flags(flags);
-}
-
-/*************************************************************
- * Module support routines
- *************************************************************/
-
-#ifdef MODULE
-int
-init_module(void)
-{
-       int status;
-
-       /* register our line disciplines */
-       status = ppp_first_time();
-       if (status != 0)
-               printk(KERN_INFO "PPP: ppp_init() failure %d\n", status);
-#if LINUX_VERSION_CODE < VERSION(2,1,18)
-       else
-               (void) register_symtab (&ppp_syms);
-#endif
-
-       return status;
-}
-
-void
-cleanup_module(void)
-{
-       int status;
-       struct ppp *ppp, *next_ppp;
-       int busy = 0;
-
-       /*
-        * Ensure that the devices are not in operation.
-        */
-       for (ppp = ppp_list; ppp != 0; ppp = ppp->next) {
-               CHECK_PPP_MAGIC(ppp);
-               if (ppp->inuse || (ppp->dev.flags & IFF_UP))
-                       ++busy;
-       }
-       if (busy)
-               printk(KERN_CRIT "PPP: removing despite %d units in use!\n",
-                      busy);
-
-       /*
-        * Release the tty registration of the line discipline so that
-        * ttys can no longer be put into PPP line discipline.
-        */
-       status = tty_register_ldisc (N_PPP, NULL);
-       if (status != 0)
-               printk(KERN_ERR
-                      "PPP: Unable to unregister ppp line discipline "
-                      "(err = %d)\n", status);
-       else
-               printk(KERN_INFO
-                      "PPP: ppp line discipline successfully unregistered\n");
-
-       /*
-        * De-register the devices so that there is no problem with them
-        */
-       for (ppp = ppp_list; ppp != 0; ppp = next_ppp) {
-               next_ppp = ppp->next;
-               unregister_netdev(&ppp->dev);
-               kfree (ppp);
-       }
-}
-#endif
diff --git a/linux/ppp_deflate.c b/linux/ppp_deflate.c
deleted file mode 100644 (file)
index 1b13f71..0000000
+++ /dev/null
@@ -1,704 +0,0 @@
-/*
- *  ==FILEVERSION 980319==
- *
- * ppp_deflate.c - interface the zlib procedures for Deflate compression
- * and decompression (as used by gzip) to the PPP code.
- * This version is for use with Linux kernel 1.3.X and later.
- *
- * Copyright (c) 1994 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.
- *
- * From: deflate.c,v 1.1 1996/01/18 03:17:48 paulus Exp
- */
-
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/in.h>
-#include <linux/malloc.h>
-
-#undef VERSION
-/* a nice define to generate linux version numbers */
-#define VERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
-
-#if LINUX_VERSION_CODE >= VERSION(2,1,4)
-#include <linux/vmalloc.h>
-#endif
-
-#include <linux/errno.h>
-#include <linux/sched.h>       /* to get the struct task_struct */
-#include <linux/string.h>      /* used in new tty drivers */
-#include <linux/signal.h>      /* used in new tty drivers */
-
-#include <asm/system.h>
-
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/inet.h>
-#include <linux/ioctl.h>
-
-#include <linux/ppp_defs.h>
-#include <linux/ppp-comp.h>
-
-#include "zlib.c"
-
-/*
- * State for a Deflate (de)compressor.
- */
-struct ppp_deflate_state {
-    int                seqno;
-    int                w_size;
-    int                unit;
-    int                mru;
-    int                debug;
-    z_stream   strm;
-    struct compstat stats;
-};
-
-#define DEFLATE_OVHD   2               /* Deflate overhead/packet */
-
-static void    *zalloc __P((void *, unsigned int items, unsigned int size));
-static void    *zalloc_init __P((void *, unsigned int items,
-                                 unsigned int size));
-static void    zfree __P((void *, void *ptr));
-static void    *z_comp_alloc __P((unsigned char *options, int opt_len));
-static void    *z_decomp_alloc __P((unsigned char *options, int opt_len));
-static void    z_comp_free __P((void *state));
-static void    z_decomp_free __P((void *state));
-static int     z_comp_init __P((void *state, unsigned char *options,
-                                int opt_len,
-                                int unit, int hdrlen, int debug));
-static int     z_decomp_init __P((void *state, unsigned char *options,
-                                  int opt_len,
-                                  int unit, int hdrlen, int mru, int debug));
-static int     z_compress __P((void *state, unsigned char *rptr,
-                               unsigned char *obuf,
-                               int isize, int osize));
-static void    z_incomp __P((void *state, unsigned char *ibuf, int icnt));
-static int     z_decompress __P((void *state, unsigned char *ibuf,
-                               int isize, unsigned char *obuf, int osize));
-static void    z_comp_reset __P((void *state));
-static void    z_decomp_reset __P((void *state));
-static void    z_comp_stats __P((void *state, struct compstat *stats));
-
-struct chunk_header {
-       int valloced;           /* allocated with valloc, not kmalloc */
-       int guard;              /* check for overwritten header */
-};
-
-#define GUARD_MAGIC    0x77a8011a
-#define MIN_VMALLOC    2048    /* use kmalloc for blocks < this */
-
-/*
- * Space allocation and freeing routines for use by zlib routines.
- */
-void
-zfree(arg, ptr)
-    void *arg;
-    void *ptr;
-{
-       struct chunk_header *hdr = ((struct chunk_header *)ptr) - 1;
-
-       if (hdr->guard != GUARD_MAGIC) {
-               printk(KERN_WARNING "zfree: header corrupted (%x %x) at %p\n",
-                      hdr->valloced, hdr->guard, hdr);
-               return;
-       }
-       if (hdr->valloced)
-               vfree(hdr);
-       else
-               kfree(hdr);
-}
-
-void *
-zalloc(arg, items, size)
-    void *arg;
-    unsigned int items, size;
-{
-       struct chunk_header *hdr;
-       unsigned nbytes;
-
-       nbytes = items * size + sizeof(*hdr);
-       hdr = kmalloc(nbytes, GFP_ATOMIC);
-       if (hdr == 0)
-               return 0;
-       hdr->valloced = 0;
-       hdr->guard = GUARD_MAGIC;
-       return (void *) (hdr + 1);
-}
-
-void *
-zalloc_init(arg, items, size)
-    void *arg;
-    unsigned int items, size;
-{
-       struct chunk_header *hdr;
-       unsigned nbytes;
-
-       nbytes = items * size + sizeof(*hdr);
-       if (nbytes >= MIN_VMALLOC)
-               hdr = vmalloc(nbytes);
-       else
-               hdr = kmalloc(nbytes, GFP_KERNEL);
-       if (hdr == 0)
-               return 0;
-       hdr->valloced = nbytes >= MIN_VMALLOC;
-       hdr->guard = GUARD_MAGIC;
-       return (void *) (hdr + 1);
-}
-
-static void
-z_comp_free(arg)
-    void *arg;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       if (state) {
-               deflateEnd(&state->strm);
-               kfree(state);
-               MOD_DEC_USE_COUNT;
-       }
-}
-
-/*
- * Allocate space for a compressor.
- */
-static void *
-z_comp_alloc(options, opt_len)
-    unsigned char *options;
-    int opt_len;
-{
-       struct ppp_deflate_state *state;
-       int w_size;
-
-       if (opt_len != CILEN_DEFLATE
-           || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-           || options[1] != CILEN_DEFLATE
-           || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-           || options[3] != DEFLATE_CHK_SEQUENCE)
-               return NULL;
-       w_size = DEFLATE_SIZE(options[2]);
-       if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-               return NULL;
-
-       state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
-       if (state == NULL)
-               return NULL;
-
-       MOD_INC_USE_COUNT;
-       memset (state, 0, sizeof (struct ppp_deflate_state));
-       state->strm.next_in = NULL;
-       state->strm.zalloc  = zalloc_init;
-       state->strm.zfree   = zfree;
-       state->w_size       = w_size;
-
-       if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION,
-                        DEFLATE_METHOD_VAL, -w_size, 8, Z_DEFAULT_STRATEGY)
-           != Z_OK)
-               goto out_free;
-       state->strm.zalloc = zalloc;
-       return (void *) state;
-
-out_free:
-       z_comp_free(state);
-       MOD_DEC_USE_COUNT;
-       return NULL;
-}
-
-static int
-z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
-    void *arg;
-    unsigned char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       if (opt_len < CILEN_DEFLATE
-           || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-           || options[1] != CILEN_DEFLATE
-           || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-           || DEFLATE_SIZE(options[2]) != state->w_size
-           || options[3] != DEFLATE_CHK_SEQUENCE)
-               return 0;
-
-       state->seqno = 0;
-       state->unit  = unit;
-       state->debug = debug;
-
-       deflateReset(&state->strm);
-
-       return 1;
-}
-
-static void
-z_comp_reset(arg)
-    void *arg;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       state->seqno = 0;
-       deflateReset(&state->strm);
-}
-
-int
-z_compress(arg, rptr, obuf, isize, osize)
-    void *arg;
-    unsigned char *rptr;       /* uncompressed packet (in) */
-    unsigned char *obuf;       /* compressed packet (out) */
-    int isize, osize;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-       int r, proto, off, olen, oavail;
-       unsigned char *wptr;
-
-       /*
-        * Check that the protocol is in the range we handle.
-        */
-       proto = PPP_PROTOCOL(rptr);
-       if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
-               return 0;
-
-       /* Don't generate compressed packets which are larger than
-          the uncompressed packet. */
-       if (osize > isize)
-               osize = isize;
-
-       wptr = obuf;
-
-       /*
-        * Copy over the PPP header and store the 2-byte sequence number.
-        */
-       wptr[0] = PPP_ADDRESS(rptr);
-       wptr[1] = PPP_CONTROL(rptr);
-       wptr[2] = PPP_COMP >> 8;
-       wptr[3] = PPP_COMP;
-       wptr += PPP_HDRLEN;
-       wptr[0] = state->seqno >> 8;
-       wptr[1] = state->seqno;
-       wptr += DEFLATE_OVHD;
-       olen = PPP_HDRLEN + DEFLATE_OVHD;
-       state->strm.next_out = wptr;
-       state->strm.avail_out = oavail = osize - olen;
-       ++state->seqno;
-
-       off = (proto > 0xff) ? 2 : 3;   /* skip 1st proto byte if 0 */
-       rptr += off;
-       state->strm.next_in = rptr;
-       state->strm.avail_in = (isize - off);
-
-       for (;;) {
-               r = deflate(&state->strm, Z_PACKET_FLUSH);
-               if (r != Z_OK) {
-                       if (state->debug)
-                               printk(KERN_ERR
-                                      "z_compress: deflate returned %d\n", r);
-                       break;
-               }
-               if (state->strm.avail_out == 0) {
-                       olen += oavail;
-                       state->strm.next_out = NULL;
-                       state->strm.avail_out = oavail = 1000000;
-               } else {
-                       break;          /* all done */
-               }
-       }
-       olen += oavail - state->strm.avail_out;
-
-       /*
-        * See if we managed to reduce the size of the packet.
-        */
-       if (olen < isize) {
-               state->stats.comp_bytes += olen;
-               state->stats.comp_packets++;
-       } else {
-               state->stats.inc_bytes += isize;
-               state->stats.inc_packets++;
-               olen = 0;
-       }
-       state->stats.unc_bytes += isize;
-       state->stats.unc_packets++;
-
-       return olen;
-}
-
-static void
-z_comp_stats(arg, stats)
-    void *arg;
-    struct compstat *stats;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       *stats = state->stats;
-}
-
-static void
-z_decomp_free(arg)
-    void *arg;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       if (state) {
-               inflateEnd(&state->strm);
-               kfree(state);
-               MOD_DEC_USE_COUNT;
-       }
-}
-
-/*
- * Allocate space for a decompressor.
- */
-static void *
-z_decomp_alloc(options, opt_len)
-    unsigned char *options;
-    int opt_len;
-{
-       struct ppp_deflate_state *state;
-       int w_size;
-
-       if (opt_len != CILEN_DEFLATE
-           || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-           || options[1] != CILEN_DEFLATE
-           || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-           || options[3] != DEFLATE_CHK_SEQUENCE)
-               return NULL;
-       w_size = DEFLATE_SIZE(options[2]);
-       if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-               return NULL;
-
-       state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
-       if (state == NULL)
-               return NULL;
-
-       MOD_INC_USE_COUNT;
-       memset (state, 0, sizeof (struct ppp_deflate_state));
-       state->w_size        = w_size;
-       state->strm.next_out = NULL;
-       state->strm.zalloc   = zalloc_init;
-       state->strm.zfree    = zfree;
-
-       if (inflateInit2(&state->strm, -w_size) != Z_OK)
-               goto out_free;
-       state->strm.zalloc = zalloc;
-       return (void *) state;
-
-out_free:
-       z_decomp_free(state);
-       MOD_DEC_USE_COUNT;
-       return NULL;
-}
-
-static int
-z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
-    void *arg;
-    unsigned char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       if (opt_len < CILEN_DEFLATE
-           || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-           || options[1] != CILEN_DEFLATE
-           || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-           || DEFLATE_SIZE(options[2]) != state->w_size
-           || options[3] != DEFLATE_CHK_SEQUENCE)
-               return 0;
-
-       state->seqno = 0;
-       state->unit  = unit;
-       state->debug = debug;
-       state->mru   = mru;
-
-       inflateReset(&state->strm);
-
-       return 1;
-}
-
-static void
-z_decomp_reset(arg)
-    void *arg;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-
-       state->seqno = 0;
-       inflateReset(&state->strm);
-}
-
-/*
- * Decompress a Deflate-compressed packet.
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-z_decompress(arg, ibuf, isize, obuf, osize)
-    void *arg;
-    unsigned char *ibuf;
-    int isize;
-    unsigned char *obuf;
-    int osize;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-       int olen, seq, r;
-       int decode_proto, overflow;
-       unsigned char overflow_buf[1];
-
-       if (isize <= PPP_HDRLEN + DEFLATE_OVHD) {
-               if (state->debug)
-                       printk(KERN_DEBUG "z_decompress%d: short pkt (%d)\n",
-                              state->unit, isize);
-               return DECOMP_ERROR;
-       }
-
-       /* Check the sequence number. */
-       seq = (ibuf[PPP_HDRLEN] << 8) + ibuf[PPP_HDRLEN+1];
-       if (seq != state->seqno) {
-               if (state->debug)
-                       printk(KERN_DEBUG "z_decompress%d: bad seq # %d, expected %d\n",
-                              state->unit, seq, state->seqno);
-               return DECOMP_ERROR;
-       }
-       ++state->seqno;
-
-       /*
-        * Fill in the first part of the PPP header.  The protocol field
-        * comes from the decompressed data.
-        */
-       obuf[0] = PPP_ADDRESS(ibuf);
-       obuf[1] = PPP_CONTROL(ibuf);
-       obuf[2] = 0;
-
-       /*
-        * Set up to call inflate.  We set avail_out to 1 initially so we can
-        * look at the first byte of the output and decide whether we have
-        * a 1-byte or 2-byte protocol field.
-        */
-       state->strm.next_in = ibuf + PPP_HDRLEN + DEFLATE_OVHD;
-       state->strm.avail_in = isize - (PPP_HDRLEN + DEFLATE_OVHD);
-       state->strm.next_out = obuf + 3;
-       state->strm.avail_out = 1;
-       decode_proto = 1;
-       overflow = 0;
-
-       /*
-        * Call inflate, supplying more input or output as needed.
-        */
-       for (;;) {
-               r = inflate(&state->strm, Z_PACKET_FLUSH);
-               if (r != Z_OK) {
-                       if (state->debug)
-                               printk(KERN_DEBUG "z_decompress%d: inflate returned %d (%s)\n",
-                                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-                       return DECOMP_FATALERROR;
-               }
-               if (state->strm.avail_out != 0)
-                       break;          /* all done */
-               if (decode_proto) {
-                       state->strm.avail_out = osize - PPP_HDRLEN;
-                       if ((obuf[3] & 1) == 0) {
-                               /* 2-byte protocol field */
-                               obuf[2] = obuf[3];
-                               --state->strm.next_out;
-                               ++state->strm.avail_out;
-                       }
-                       decode_proto = 0;
-               } else if (!overflow) {
-                       /*
-                        * We've filled up the output buffer; the only way to
-                        * find out whether inflate has any more characters
-                        * left is to give it another byte of output space.
-                        */
-                       state->strm.next_out = overflow_buf;
-                       state->strm.avail_out = 1;
-                       overflow = 1;
-               } else {
-                       if (state->debug)
-                               printk(KERN_DEBUG "z_decompress%d: ran out of mru\n",
-                                      state->unit);
-                       return DECOMP_FATALERROR;
-               }
-       }
-
-       if (decode_proto) {
-               if (state->debug)
-                       printk(KERN_DEBUG "z_decompress%d: didn't get proto\n",
-                              state->unit);
-               return DECOMP_ERROR;
-       }
-
-       olen = osize + overflow - state->strm.avail_out;
-       state->stats.unc_bytes += olen;
-       state->stats.unc_packets++;
-       state->stats.comp_bytes += isize;
-       state->stats.comp_packets++;
-
-       return olen;
-}
-
-/*
- * Incompressible data has arrived - add it to the history.
- */
-static void
-z_incomp(arg, ibuf, icnt)
-    void *arg;
-    unsigned char *ibuf;
-    int icnt;
-{
-       struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
-       int proto, r;
-
-       /*
-        * Check that the protocol is one we handle.
-        */
-       proto = PPP_PROTOCOL(ibuf);
-       if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
-               return;
-
-       ++state->seqno;
-
-       /*
-        * We start at the either the 1st or 2nd byte of the protocol field,
-        * depending on whether the protocol value is compressible.
-        */
-       state->strm.next_in = ibuf + 3;
-       state->strm.avail_in = icnt - 3;
-       if (proto > 0xff) {
-               --state->strm.next_in;
-               ++state->strm.avail_in;
-       }
-
-       r = inflateIncomp(&state->strm);
-       if (r != Z_OK) {
-               /* gak! */
-               if (state->debug) {
-                       printk(KERN_DEBUG "z_incomp%d: inflateIncomp returned %d (%s)\n",
-                              state->unit, r, (state->strm.msg? state->strm.msg: ""));
-               }
-               return;
-       }
-
-       /*
-        * Update stats.
-        */
-       state->stats.inc_bytes += icnt;
-       state->stats.inc_packets++;
-       state->stats.unc_bytes += icnt;
-       state->stats.unc_packets++;
-}
-
-/*************************************************************
- * Module interface table
- *************************************************************/
-
-/* These are in ppp.c */
-extern int  ppp_register_compressor   (struct compressor *cp);
-extern void ppp_unregister_compressor (struct compressor *cp);
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_deflate = {
-       CI_DEFLATE,             /* compress_proto */
-       z_comp_alloc,           /* comp_alloc */
-       z_comp_free,            /* comp_free */
-       z_comp_init,            /* comp_init */
-       z_comp_reset,           /* comp_reset */
-       z_compress,             /* compress */
-       z_comp_stats,           /* comp_stat */
-       z_decomp_alloc,         /* decomp_alloc */
-       z_decomp_free,          /* decomp_free */
-       z_decomp_init,          /* decomp_init */
-       z_decomp_reset,         /* decomp_reset */
-       z_decompress,           /* decompress */
-       z_incomp,               /* incomp */
-       z_comp_stats,           /* decomp_stat */
-};
-
-struct compressor ppp_deflate_draft = {
-       CI_DEFLATE_DRAFT,       /* compress_proto */
-       z_comp_alloc,           /* comp_alloc */
-       z_comp_free,            /* comp_free */
-       z_comp_init,            /* comp_init */
-       z_comp_reset,           /* comp_reset */
-       z_compress,             /* compress */
-       z_comp_stats,           /* comp_stat */
-       z_decomp_alloc,         /* decomp_alloc */
-       z_decomp_free,          /* decomp_free */
-       z_decomp_init,          /* decomp_init */
-       z_decomp_reset,         /* decomp_reset */
-       z_decompress,           /* decompress */
-       z_incomp,               /* incomp */
-       z_comp_stats,           /* decomp_stat */
-};
-
-#ifdef MODULE
-/*************************************************************
- * Module support routines
- *************************************************************/
-
-int
-init_module(void)
-{  
-        int answer = ppp_register_compressor (&ppp_deflate);
-        if (answer == 0)
-                printk (KERN_INFO
-                       "PPP Deflate Compression module registered\n");
-       ppp_register_compressor(&ppp_deflate_draft);
-        return answer;
-}
-     
-void
-cleanup_module(void)
-{
-       if (MOD_IN_USE)
-               printk (KERN_INFO
-                       "Deflate Compression module busy, remove delayed\n");
-       else {
-               ppp_unregister_compressor (&ppp_deflate);
-               ppp_unregister_compressor (&ppp_deflate_draft);
-       }
-}
-#endif
diff --git a/netbsd-1.1/Makefile.top b/netbsd-1.1/Makefile.top
deleted file mode 100644 (file)
index 2fff895..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# ppp top level makefile for *bsd systems
-#
-
-BINDIR?= /usr/sbin
-
-SUBDIR=        chat pppd pppstats
-MAKE+=  BINDIR=$(BINDIR)
-
-kernel:
-       @sh -e netbsd-1.1/kinstall.sh
-
-.include <bsd.subdir.mk>
diff --git a/netbsd-1.1/bsd-comp.c b/netbsd-1.1/bsd-comp.c
deleted file mode 100644 (file)
index f4f2984..0000000
+++ /dev/null
@@ -1,1117 +0,0 @@
-/*     $Id: bsd-comp.c,v 1.6 1996/08/28 06:31:58 paulus Exp $  */
-
-/* Because this code is derived from the 4.3BSD compress source:
- *
- *
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * 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 University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This version is for use with mbufs on BSD-derived systems.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-
-#if DO_BSD_COMPRESS
-/*
- * PPP "BSD compress" compression
- *  The differences between this compression and the classic BSD LZW
- *  source are obvious from the requirement that the classic code worked
- *  with files while this handles arbitrarily long streams that
- *  are broken into packets.  They are:
- *
- *     When the code size expands, a block of junk is not emitted by
- *         the compressor and not expected by the decompressor.
- *
- *     New codes are not necessarily assigned every time an old
- *         code is output by the compressor.  This is because a packet
- *         end forces a code to be emitted, but does not imply that a
- *         new sequence has been seen.
- *
- *     The compression ratio is checked at the first end of a packet
- *         after the appropriate gap.  Besides simplifying and speeding
- *         things up, this makes it more likely that the transmitter
- *         and receiver will agree when the dictionary is cleared when
- *         compression is not going well.
- */
-
-/*
- * A dictionary for doing BSD compress.
- */
-struct bsd_db {
-    int            totlen;                     /* length of this structure */
-    u_int   hsize;                     /* size of the hash table */
-    u_char  hshift;                    /* used in hash function */
-    u_char  n_bits;                    /* current bits/code */
-    u_char  maxbits;
-    u_char  debug;
-    u_char  unit;
-    u_int16_t seqno;                   /* sequence # of next packet */
-    u_int   hdrlen;                    /* header length to preallocate */
-    u_int   mru;
-    u_int   maxmaxcode;                        /* largest valid code */
-    u_int   max_ent;                   /* largest code in use */
-    u_int   in_count;                  /* uncompressed bytes, aged */
-    u_int   bytes_out;                 /* compressed bytes, aged */
-    u_int   ratio;                     /* recent compression ratio */
-    u_int   checkpoint;                        /* when to next check the ratio */
-    u_int   clear_count;               /* times dictionary cleared */
-    u_int   incomp_count;              /* incompressible packets */
-    u_int   incomp_bytes;              /* incompressible bytes */
-    u_int   uncomp_count;              /* uncompressed packets */
-    u_int   uncomp_bytes;              /* uncompressed bytes */
-    u_int   comp_count;                        /* compressed packets */
-    u_int   comp_bytes;                        /* compressed bytes */
-    u_int16_t *lens;                   /* array of lengths of codes */
-    struct bsd_dict {
-       union {                         /* hash value */
-           u_int32_t   fcode;
-           struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
-               u_int16_t prefix;       /* preceding code */
-               u_char  suffix;         /* last character of new code */
-               u_char  pad;
-#else
-               u_char  pad;
-               u_char  suffix;         /* last character of new code */
-               u_int16_t prefix;       /* preceding code */
-#endif
-           } hs;
-       } f;
-       u_int16_t codem1;               /* output of hash table -1 */
-       u_int16_t cptr;                 /* map code to hash table entry */
-    } dict[1];
-};
-
-#define BSD_OVHD       2               /* BSD compress overhead/packet */
-#define BSD_INIT_BITS  BSD_MIN_BITS
-
-static void    *bsd_comp_alloc __P((u_char *options, int opt_len));
-static void    *bsd_decomp_alloc __P((u_char *options, int opt_len));
-static void    bsd_free __P((void *state));
-static int     bsd_comp_init __P((void *state, u_char *options, int opt_len,
-                                  int unit, int hdrlen, int debug));
-static int     bsd_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     bsd_compress __P((void *state, struct mbuf **mret,
-                                 struct mbuf *mp, int slen, int maxolen));
-static void    bsd_incomp __P((void *state, struct mbuf *dmsg));
-static int     bsd_decompress __P((void *state, struct mbuf *cmp,
-                                   struct mbuf **dmpp));
-static void    bsd_reset __P((void *state));
-static void    bsd_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_bsd_compress = {
-    CI_BSD_COMPRESS,           /* compress_proto */
-    bsd_comp_alloc,            /* comp_alloc */
-    bsd_free,                  /* comp_free */
-    bsd_comp_init,             /* comp_init */
-    bsd_reset,                 /* comp_reset */
-    bsd_compress,              /* compress */
-    bsd_comp_stats,            /* comp_stat */
-    bsd_decomp_alloc,          /* decomp_alloc */
-    bsd_free,                  /* decomp_free */
-    bsd_decomp_init,           /* decomp_init */
-    bsd_reset,                 /* decomp_reset */
-    bsd_decompress,            /* decompress */
-    bsd_incomp,                        /* incomp */
-    bsd_comp_stats,            /* decomp_stat */
-};
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define CLEAR  256                     /* table clear output code */
-#define FIRST  257                     /* first free entry */
-#define LAST   255
-
-#define MAXCODE(b)     ((1 << (b)) - 1)
-#define BADCODEM1      MAXCODE(BSD_MAX_BITS)
-
-#define BSD_HASH(prefix,suffix,hshift) ((((u_int32_t)(suffix)) << (hshift)) \
-                                        ^ (u_int32_t)(prefix))
-#define BSD_KEY(prefix,suffix)         ((((u_int32_t)(suffix)) << 16) \
-                                        + (u_int32_t)(prefix))
-
-#define CHECK_GAP      10000           /* Ratio check interval */
-
-#define RATIO_SCALE_LOG        8
-#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
- */
-static void
-bsd_clear(db)
-    struct bsd_db *db;
-{
-    db->clear_count++;
-    db->max_ent = FIRST-1;
-    db->n_bits = BSD_INIT_BITS;
-    db->ratio = 0;
-    db->bytes_out = 0;
-    db->in_count = 0;
-    db->checkpoint = CHECK_GAP;
-}
-
-/*
- * If the dictionary is full, then see if it is time to reset it.
- *
- * Compute the compression ratio using fixed-point arithmetic
- * with 8 fractional bits.
- *
- * Since we have an infinite stream instead of a single file,
- * watch only the local compression ratio.
- *
- * Since both peers must reset the dictionary at the same time even in
- * the absence of CLEAR codes (while packets are incompressible), they
- * must compute the same ratio.
- */
-static int                             /* 1=output CLEAR */
-bsd_check(db)
-    struct bsd_db *db;
-{
-    u_int new_ratio;
-
-    if (db->in_count >= db->checkpoint) {
-       /* age the ratio by limiting the size of the counts */
-       if (db->in_count >= RATIO_MAX
-           || db->bytes_out >= RATIO_MAX) {
-           db->in_count -= db->in_count/4;
-           db->bytes_out -= db->bytes_out/4;
-       }
-
-       db->checkpoint = db->in_count + CHECK_GAP;
-
-       if (db->max_ent >= db->maxmaxcode) {
-           /* Reset the dictionary only if the ratio is worse,
-            * or if it looks as if it has been poisoned
-            * by incompressible data.
-            *
-            * This does not overflow, because
-            *  db->in_count <= RATIO_MAX.
-            */
-           new_ratio = db->in_count << RATIO_SCALE_LOG;
-           if (db->bytes_out != 0)
-               new_ratio /= db->bytes_out;
-
-           if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) {
-               bsd_clear(db);
-               return 1;
-           }
-           db->ratio = new_ratio;
-       }
-    }
-    return 0;
-}
-
-/*
- * Return statistics.
- */
-static void
-bsd_comp_stats(state, stats)
-    void *state;
-    struct compstat *stats;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int out;
-
-    stats->unc_bytes = db->uncomp_bytes;
-    stats->unc_packets = db->uncomp_count;
-    stats->comp_bytes = db->comp_bytes;
-    stats->comp_packets = db->comp_count;
-    stats->inc_bytes = db->incomp_bytes;
-    stats->inc_packets = db->incomp_count;
-    stats->ratio = db->in_count;
-    out = db->bytes_out;
-    if (stats->ratio <= 0x7fffff)
-       stats->ratio <<= 8;
-    else
-       out >>= 8;
-    if (out != 0)
-       stats->ratio /= out;
-}
-
-/*
- * Reset state, as on a CCP ResetReq.
- */
-static void
-bsd_reset(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    db->seqno = 0;
-    bsd_clear(db);
-    db->clear_count = 0;
-}
-
-/*
- * Allocate space for a (de) compressor.
- */
-static void *
-bsd_alloc(options, opt_len, decomp)
-    u_char *options;
-    int opt_len, decomp;
-{
-    int bits;
-    u_int newlen, hsize, hshift, maxmaxcode;
-    struct bsd_db *db;
-
-    if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
-       || options[1] != CILEN_BSD_COMPRESS
-       || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
-       return NULL;
-    bits = BSD_NBITS(options[2]);
-    switch (bits) {
-    case 9:                    /* needs 82152 for both directions */
-    case 10:                   /* needs 84144 */
-    case 11:                   /* needs 88240 */
-    case 12:                   /* needs 96432 */
-       hsize = 5003;
-       hshift = 4;
-       break;
-    case 13:                   /* needs 176784 */
-       hsize = 9001;
-       hshift = 5;
-       break;
-    case 14:                   /* needs 353744 */
-       hsize = 18013;
-       hshift = 6;
-       break;
-    case 15:                   /* needs 691440 */
-       hsize = 35023;
-       hshift = 7;
-       break;
-    case 16:                   /* needs 1366160--far too much, */
-       /* hsize = 69001; */    /* and 69001 is too big for cptr */
-       /* hshift = 8; */       /* in struct bsd_db */
-       /* break; */
-    default:
-       return NULL;
-    }
-
-    maxmaxcode = MAXCODE(bits);
-    newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
-    MALLOC(db, struct bsd_db *, newlen, M_DEVBUF, M_NOWAIT);
-    if (!db)
-       return NULL;
-    bzero(db, sizeof(*db) - sizeof(db->dict));
-
-    if (!decomp) {
-       db->lens = NULL;
-    } else {
-       MALLOC(db->lens, u_int16_t *, (maxmaxcode+1) * sizeof(db->lens[0]),
-              M_DEVBUF, M_NOWAIT);
-       if (!db->lens) {
-           FREE(db, M_DEVBUF);
-           return NULL;
-       }
-    }
-
-    db->totlen = newlen;
-    db->hsize = hsize;
-    db->hshift = hshift;
-    db->maxmaxcode = maxmaxcode;
-    db->maxbits = bits;
-
-    return (void *) db;
-}
-
-static void
-bsd_free(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    if (db->lens)
-       FREE(db->lens, M_DEVBUF);
-    FREE(db, M_DEVBUF);
-}
-
-static void *
-bsd_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 0);
-}
-
-static void *
-bsd_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 1);
-}
-
-/*
- * Initialize the database.
- */
-static int
-bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
-    struct bsd_db *db;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug, decomp;
-{
-    int i;
-
-    if (opt_len < CILEN_BSD_COMPRESS || 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))
-       return 0;
-
-    if (decomp) {
-       i = LAST+1;
-       while (i != 0)
-           db->lens[--i] = 1;
-    }
-    i = db->hsize;
-    while (i != 0) {
-       db->dict[--i].codem1 = BADCODEM1;
-       db->dict[i].cptr = 0;
-    }
-
-    db->unit = unit;
-    db->hdrlen = hdrlen;
-    db->mru = mru;
-#ifndef DEBUG
-    if (debug)
-#endif
-       db->debug = 1;
-
-    bsd_reset(db);
-
-    return 1;
-}
-
-static int
-bsd_comp_init(state, options, opt_len, unit, hdrlen, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, 0, debug, 0);
-}
-
-static int
-bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, mru, debug, 1);
-}
-
-
-/*
- * compress a packet
- *     One change from the BSD compress command is that when the
- *     code size expands, we do not output a bunch of padding.
- */
-int                                    /* new slen */
-bsd_compress(state, mret, mp, slen, maxolen)
-    void *state;
-    struct mbuf **mret;                /* return compressed mbuf chain here */
-    struct mbuf *mp;           /* from here */
-    int slen;                  /* uncompressed length */
-    int maxolen;               /* max compressed length */
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    u_int bitno = 32;
-    u_int32_t accm = 0, fcode;
-    struct bsd_dict *dictp;
-    u_char c;
-    int hval, disp, ent, ilen;
-    u_char *rptr, *wptr;
-    u_char *cp_end;
-    int olen;
-    struct mbuf *m;
-
-#define PUTBYTE(v) {                                   \
-    ++olen;                                            \
-    if (wptr) {                                                \
-       *wptr++ = (v);                                  \
-       if (wptr >= cp_end) {                           \
-           m->m_len = wptr - mtod(m, u_char *);        \
-           MGET(m->m_next, M_DONTWAIT, MT_DATA);       \
-           m = m->m_next;                              \
-           if (m) {                                    \
-               m->m_len = 0;                           \
-               if (maxolen - olen > MLEN)              \
-                   MCLGET(m, M_DONTWAIT);              \
-               wptr = mtod(m, u_char *);               \
-               cp_end = wptr + M_TRAILINGSPACE(m);     \
-           } else                                      \
-               wptr = NULL;                            \
-       }                                               \
-    }                                                  \
-}
-
-#define OUTPUT(ent) {                                  \
-    bitno -= n_bits;                                   \
-    accm |= ((ent) << bitno);                          \
-    do {                                               \
-       PUTBYTE(accm >> 24);                            \
-       accm <<= 8;                                     \
-       bitno += 8;                                     \
-    } while (bitno <= 24);                             \
-}
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without compressing the packet.  If it is,
-     * the protocol becomes the first byte to compress.
-     */
-    rptr = mtod(mp, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < 0x21 || ent > 0xf9) {
-       *mret = NULL;
-       return slen;
-    }
-
-    /* Don't generate compressed packets which are larger than
-       the uncompressed packet. */
-    if (maxolen > slen)
-       maxolen = slen;
-
-    /* Allocate one mbuf to start with. */
-    MGET(m, M_DONTWAIT, MT_DATA);
-    *mret = m;
-    if (m != NULL) {
-       m->m_len = 0;
-       if (maxolen + db->hdrlen > MLEN)
-           MCLGET(m, M_DONTWAIT);
-       m->m_data += db->hdrlen;
-       wptr = mtod(m, u_char *);
-       cp_end = wptr + M_TRAILINGSPACE(m);
-    } else
-       wptr = cp_end = NULL;
-
-    /*
-     * Copy the PPP header over, changing the protocol,
-     * and install the 2-byte packet sequence number.
-     */
-    if (wptr) {
-       *wptr++ = PPP_ADDRESS(rptr);    /* assumes the ppp header is */
-       *wptr++ = PPP_CONTROL(rptr);    /* all in one mbuf */
-       *wptr++ = 0;                    /* change the protocol */
-       *wptr++ = PPP_COMP;
-       *wptr++ = db->seqno >> 8;
-       *wptr++ = db->seqno;
-    }
-    ++db->seqno;
-
-    olen = 0;
-    rptr += PPP_HDRLEN;
-    slen = mp->m_len - PPP_HDRLEN;
-    ilen = slen + 1;
-    for (;;) {
-       if (slen <= 0) {
-           mp = mp->m_next;
-           if (!mp)
-               break;
-           rptr = mtod(mp, u_char *);
-           slen = mp->m_len;
-           if (!slen)
-               continue;   /* handle 0-length buffers */
-           ilen += slen;
-       }
-
-       slen--;
-       c = *rptr++;
-       fcode = BSD_KEY(ent, c);
-       hval = BSD_HASH(ent, c, hshift);
-       dictp = &db->dict[hval];
-
-       /* Validate and then check the entry. */
-       if (dictp->codem1 >= max_ent)
-           goto nomatch;
-       if (dictp->f.fcode == fcode) {
-           ent = dictp->codem1+1;
-           continue;   /* found (prefix,suffix) */
-       }
-
-       /* continue probing until a match or invalid entry */
-       disp = (hval == 0) ? 1 : hval;
-       do {
-           hval += disp;
-           if (hval >= db->hsize)
-               hval -= db->hsize;
-           dictp = &db->dict[hval];
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-       } while (dictp->f.fcode != fcode);
-       ent = dictp->codem1 + 1;        /* finally found (prefix,suffix) */
-       continue;
-
-    nomatch:
-       OUTPUT(ent);            /* output the prefix */
-
-       /* code -> hashtable */
-       if (max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           /* expand code size if needed */
-           if (max_ent >= MAXCODE(n_bits))
-               db->n_bits = ++n_bits;
-
-           /* Invalidate old hash table entry using
-            * this code, and then take it over.
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent)
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-       }
-       ent = c;
-    }
-
-    OUTPUT(ent);               /* output the last code */
-    db->bytes_out += olen;
-    db->in_count += ilen;
-    if (bitno < 32)
-       ++db->bytes_out;        /* count complete bytes */
-
-    if (bsd_check(db))
-       OUTPUT(CLEAR);          /* do not count the CLEAR */
-
-    /*
-     * Pad dribble bits of last code with ones.
-     * Do not emit a completely useless byte of ones.
-     */
-    if (bitno != 32)
-       PUTBYTE((accm | (0xff << (bitno-8))) >> 24);
-
-    if (m != NULL) {
-       m->m_len = wptr - mtod(m, u_char *);
-       m->m_next = NULL;
-    }
-
-    /*
-     * Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-
-    db->uncomp_bytes += ilen;
-    ++db->uncomp_count;
-    if (olen + PPP_HDRLEN + BSD_OVHD > maxolen) {
-       /* throw away the compressed stuff if it is longer than uncompressed */
-       if (*mret != NULL) {
-           m_freem(*mret);
-           *mret = NULL;
-       }
-       ++db->incomp_count;
-       db->incomp_bytes += ilen;
-    } else {
-       ++db->comp_count;
-       db->comp_bytes += olen + BSD_OVHD;
-    }
-
-    return olen + PPP_HDRLEN + BSD_OVHD;
-#undef OUTPUT
-#undef PUTBYTE
-}
-
-
-/*
- * Update the "BSD Compress" dictionary on the receiver for
- * incompressible data by pretending to compress the incoming data.
- */
-static void
-bsd_incomp(state, dmsg)
-    void *state;
-    struct mbuf *dmsg;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    struct bsd_dict *dictp;
-    u_int32_t fcode;
-    u_char c;
-    u_int32_t hval, disp;
-    int slen, ilen;
-    u_int bitno = 7;
-    u_char *rptr;
-    u_int ent;
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without looking at the packet.  If it is,
-     * the protocol becomes the first byte to "compress".
-     */
-    rptr = mtod(dmsg, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < 0x21 || ent > 0xf9)
-       return;
-
-    db->seqno++;
-    ilen = 1;          /* count the protocol as 1 byte */
-    rptr += PPP_HDRLEN;
-    slen = dmsg->m_len - PPP_HDRLEN;
-    for (;;) {
-       if (slen <= 0) {
-           dmsg = dmsg->m_next;
-           if (!dmsg)
-               break;
-           rptr = mtod(dmsg, u_char *);
-           slen = dmsg->m_len;
-           continue;
-       }
-       ilen += slen;
-
-       do {
-           c = *rptr++;
-           fcode = BSD_KEY(ent, c);
-           hval = BSD_HASH(ent, c, hshift);
-           dictp = &db->dict[hval];
-
-           /* validate and then check the entry */
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-           if (dictp->f.fcode == fcode) {
-               ent = dictp->codem1+1;
-               continue;   /* found (prefix,suffix) */
-           }
-
-           /* continue probing until a match or invalid entry */
-           disp = (hval == 0) ? 1 : hval;
-           do {
-               hval += disp;
-               if (hval >= db->hsize)
-                   hval -= db->hsize;
-               dictp = &db->dict[hval];
-               if (dictp->codem1 >= max_ent)
-                   goto nomatch;
-           } while (dictp->f.fcode != fcode);
-           ent = dictp->codem1+1;
-           continue;   /* finally found (prefix,suffix) */
-
-       nomatch:                /* output (count) the prefix */
-           bitno += n_bits;
-
-           /* code -> hashtable */
-           if (max_ent < db->maxmaxcode) {
-               struct bsd_dict *dictp2;
-               /* expand code size if needed */
-               if (max_ent >= MAXCODE(n_bits))
-                   db->n_bits = ++n_bits;
-
-               /* Invalidate previous hash table entry
-                * assigned this code, and then take it over.
-                */
-               dictp2 = &db->dict[max_ent+1];
-               if (db->dict[dictp2->cptr].codem1 == max_ent)
-                   db->dict[dictp2->cptr].codem1 = BADCODEM1;
-               dictp2->cptr = hval;
-               dictp->codem1 = max_ent;
-               dictp->f.fcode = fcode;
-
-               db->max_ent = ++max_ent;
-               db->lens[max_ent] = db->lens[ent]+1;
-           }
-           ent = c;
-       } while (--slen != 0);
-    }
-    bitno += n_bits;           /* output (count) the last code */
-    db->bytes_out += bitno/8;
-    db->in_count += ilen;
-    (void)bsd_check(db);
-
-    ++db->incomp_count;
-    db->incomp_bytes += ilen;
-    ++db->uncomp_count;
-    db->uncomp_bytes += ilen;
-
-    /* Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-}
-
-
-/*
- * Decompress "BSD Compress".
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-bsd_decompress(state, cmp, dmpp)
-    void *state;
-    struct mbuf *cmp, **dmpp;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int max_ent = db->max_ent;
-    u_int32_t accm = 0;
-    u_int bitno = 32;          /* 1st valid bit in accm */
-    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;
-    u_int incode, oldcode, finchar;
-    u_char *p, *rptr, *wptr;
-    struct mbuf *m, *dmp, *mret;
-    int adrs, ctrl, ilen;
-    int space, codelen, extra;
-
-    /*
-     * Save the address/control from the PPP header
-     * and then get the sequence number.
-     */
-    *dmpp = NULL;
-    rptr = mtod(cmp, u_char *);
-    adrs = PPP_ADDRESS(rptr);
-    ctrl = PPP_CONTROL(rptr);
-    rptr += PPP_HDRLEN;
-    len = cmp->m_len - PPP_HDRLEN;
-    seq = 0;
-    for (i = 0; i < 2; ++i) {
-       while (len <= 0) {
-           cmp = cmp->m_next;
-           if (cmp == NULL)
-               return DECOMP_ERROR;
-           rptr = mtod(cmp, u_char *);
-           len = cmp->m_len;
-       }
-       seq = (seq << 8) + *rptr++;
-       --len;
-    }
-
-    /*
-     * Check the sequence number and give up if it differs from
-     * the value we're expecting.
-     */
-    if (seq != db->seqno) {
-       if (db->debug)
-           printf("bsd_decomp%d: bad sequence # %d, expected %d\n",
-                  db->unit, seq, db->seqno - 1);
-       return DECOMP_ERROR;
-    }
-    ++db->seqno;
-
-    /*
-     * Allocate one mbuf to start with.
-     */
-    MGETHDR(dmp, M_DONTWAIT, MT_DATA);
-    if (dmp == NULL)
-       return DECOMP_ERROR;
-    mret = dmp;
-    dmp->m_len = 0;
-    dmp->m_next = NULL;
-    MCLGET(dmp, M_DONTWAIT);
-    dmp->m_data += db->hdrlen;
-    wptr = mtod(dmp, u_char *);
-    space = M_TRAILINGSPACE(dmp) - PPP_HDRLEN + 1;
-
-    /*
-     * Fill in the ppp header, but not the last byte of the protocol
-     * (that comes from the decompressed data).
-     */
-    wptr[0] = adrs;
-    wptr[1] = ctrl;
-    wptr[2] = 0;
-    wptr += PPP_HDRLEN - 1;
-
-    ilen = len;
-    oldcode = CLEAR;
-    explen = 0;
-    for (;;) {
-       if (len == 0) {
-           cmp = cmp->m_next;
-           if (!cmp)           /* quit at end of message */
-               break;
-           rptr = mtod(cmp, u_char *);
-           len = cmp->m_len;
-           ilen += len;
-           continue;           /* handle 0-length buffers */
-       }
-
-       /*
-        * Accumulate bytes until we have a complete code.
-        * Then get the next code, relying on the 32-bit,
-        * unsigned accm to mask the result.
-        */
-       bitno -= 8;
-       accm |= *rptr++ << bitno;
-       --len;
-       if (tgtbitno < bitno)
-           continue;
-       incode = accm >> tgtbitno;
-       accm <<= n_bits;
-       bitno += n_bits;
-
-       if (incode == CLEAR) {
-           /*
-            * The dictionary must only be cleared at
-            * the end of a packet.  But there could be an
-            * empty mbuf at the end.
-            */
-           if (len > 0 || cmp->m_next != NULL) {
-               while ((cmp = cmp->m_next) != NULL)
-                   len += cmp->m_len;
-               if (len > 0) {
-                   m_freem(mret);
-                   if (db->debug)
-                       printf("bsd_decomp%d: bad CLEAR\n", db->unit);
-                   return DECOMP_FATALERROR;   /* probably a bug */
-               }
-           }
-           bsd_clear(db);
-           explen = ilen = 0;
-           break;
-       }
-
-       if (incode > max_ent + 2 || incode > db->maxmaxcode
-           || (incode > max_ent && oldcode == CLEAR)) {
-           m_freem(mret);
-           if (db->debug) {
-               printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
-                      db->unit, incode, oldcode);
-               printf("max_ent=0x%x explen=%d seqno=%d\n",
-                      max_ent, explen, db->seqno);
-           }
-           return DECOMP_FATALERROR;   /* probably a bug */
-       }
-
-       /* Special case for KwKwK string. */
-       if (incode > max_ent) {
-           finchar = oldcode;
-           extra = 1;
-       } else {
-           finchar = incode;
-           extra = 0;
-       }
-
-       codelen = db->lens[finchar];
-       explen += codelen + extra;
-       if (explen > db->mru + 1) {
-           m_freem(mret);
-           if (db->debug) {
-               printf("bsd_decomp%d: ran out of mru\n", db->unit);
-#ifdef DEBUG
-               while ((cmp = cmp->m_next) != NULL)
-                   len += cmp->m_len;
-               printf("  len=%d, finchar=0x%x, codelen=%d, explen=%d\n",
-                      len, finchar, codelen, explen);
-#endif
-           }
-           return DECOMP_FATALERROR;
-       }
-
-       /*
-        * For simplicity, the decoded characters go in a single mbuf,
-        * so we allocate a single extra cluster mbuf if necessary.
-        */
-       if ((space -= codelen + extra) < 0) {
-           dmp->m_len = wptr - mtod(dmp, u_char *);
-           MGET(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL) {
-               m_freem(mret);
-               return DECOMP_ERROR;
-           }
-           m->m_len = 0;
-           m->m_next = NULL;
-           dmp->m_next = m;
-           MCLGET(m, M_DONTWAIT);
-           space = M_TRAILINGSPACE(m) - (codelen + extra);
-           if (space < 0) {
-               /* now that's what I call *compression*. */
-               m_freem(mret);
-               return DECOMP_ERROR;
-           }
-           dmp = m;
-           wptr = mtod(dmp, u_char *);
-       }
-
-       /*
-        * Decode this code and install it in the decompressed buffer.
-        */
-       p = (wptr += codelen);
-       while (finchar > LAST) {
-           dictp = &db->dict[db->dict[finchar].cptr];
-#ifdef DEBUG
-           if (--codelen <= 0 || dictp->codem1 != finchar-1)
-               goto bad;
-#endif
-           *--p = dictp->f.hs.suffix;
-           finchar = dictp->f.hs.prefix;
-       }
-       *--p = finchar;
-
-#ifdef DEBUG
-       if (--codelen != 0)
-           printf("bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n",
-                  db->unit, codelen, incode, max_ent);
-#endif
-
-       if (extra)              /* the KwKwK case again */
-           *wptr++ = finchar;
-
-       /*
-        * If not first code in a packet, and
-        * if not out of code space, then allocate a new code.
-        *
-        * Keep the hash table correct so it can be used
-        * with uncompressed packets.
-        */
-       if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           u_int32_t fcode;
-           u_int32_t hval, disp;
-
-           fcode = BSD_KEY(oldcode,finchar);
-           hval = BSD_HASH(oldcode,finchar,db->hshift);
-           dictp = &db->dict[hval];
-
-           /* look for a free hash table entry */
-           if (dictp->codem1 < max_ent) {
-               disp = (hval == 0) ? 1 : hval;
-               do {
-                   hval += disp;
-                   if (hval >= db->hsize)
-                       hval -= db->hsize;
-                   dictp = &db->dict[hval];
-               } while (dictp->codem1 < max_ent);
-           }
-
-           /*
-            * Invalidate previous hash table entry
-            * assigned this code, and then take it over
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent) {
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           }
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-           db->lens[max_ent] = db->lens[oldcode]+1;
-
-           /* Expand code size if needed. */
-           if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
-               db->n_bits = ++n_bits;
-               tgtbitno = 32-n_bits;
-           }
-       }
-       oldcode = incode;
-    }
-    dmp->m_len = wptr - mtod(dmp, u_char *);
-
-    /*
-     * Keep the checkpoint right so that incompressible packets
-     * clear the dictionary at the right times.
-     */
-    db->bytes_out += ilen;
-    db->in_count += explen;
-    if (bsd_check(db) && db->debug) {
-       printf("bsd_decomp%d: peer should have cleared dictionary\n",
-              db->unit);
-    }
-
-    ++db->comp_count;
-    db->comp_bytes += ilen + BSD_OVHD;
-    ++db->uncomp_count;
-    db->uncomp_bytes += explen;
-
-    *dmpp = mret;
-    return DECOMP_OK;
-
-#ifdef DEBUG
- bad:
-    if (codelen <= 0) {
-       printf("bsd_decomp%d: fell off end of chain ", db->unit);
-       printf("0x%x at 0x%x by 0x%x, max_ent=0x%x\n",
-              incode, finchar, db->dict[finchar].cptr, max_ent);
-    } else if (dictp->codem1 != finchar-1) {
-       printf("bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",
-              db->unit, incode, finchar);
-       printf("oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode,
-              db->dict[finchar].cptr, dictp->codem1);
-    }
-    m_freem(mret);
-    return DECOMP_FATALERROR;
-#endif /* DEBUG */
-}
-#endif /* DO_BSD_COMPRESS */
diff --git a/netbsd-1.1/files.oldconf.patch b/netbsd-1.1/files.oldconf.patch
deleted file mode 100644 (file)
index 59b8d3b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-*** files.oldconf.orig Thu Mar  7 14:04:18 1996
---- files.oldconf      Tue May 28 13:01:09 1996
-***************
-*** 135,140 ****
---- 135,142 ----
-  net/if_ppp.c         optional ppp device-driver
-  net/bsd-comp.c               optional ppp
-  net/ppp_tty.c                optional ppp
-+ net/ppp-deflate.c    optional ppp
-+ net/zlib.c           optional ppp
-  net/if_sl.c          optional sl device-driver
-  net/if_tun.c         optional tun device-driver
-  net/radix.c          standard
diff --git a/netbsd-1.1/files.patch b/netbsd-1.1/files.patch
deleted file mode 100644 (file)
index 3ff9f6e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-*** files.orig Thu Mar  7 14:04:18 1996
---- files      Tue May 28 12:59:43 1996
-***************
-*** 181,186 ****
---- 181,188 ----
-  file net/if_ppp.c                    ppp                     needs-count
-  file net/ppp_tty.c                   ppp
-  file net/bsd-comp.c                  ppp
-+ file net/ppp-deflate.c                       ppp
-+ file net/zlib.c                              ppp
-  file net/if_tun.c                    tun                     needs-count
-  file net/radix.c
-  file net/raw_cb.c
diff --git a/netbsd-1.1/if_ppp.c b/netbsd-1.1/if_ppp.c
deleted file mode 100644 (file)
index 0a47e00..0000000
+++ /dev/null
@@ -1,1539 +0,0 @@
-/*     $Id: if_ppp.c,v 1.9 2002/12/06 12:03:44 paulus Exp $    */
-
-/*
- * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a collision if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- */
-
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/malloc.h>
-
-#if NetBSD1_0 && defined(i386)
-#include <machine/psl.h>
-#endif
-
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/netisr.h>
-#include <net/route.h>
-#ifdef PPP_FILTER
-#include <net/bpf.h>
-#endif
-
-#if INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#endif
-
-#include "bpfilter.h"
-#if NBPFILTER > 0
-#include <sys/time.h>
-#include <net/bpf.h>
-#endif
-
-#ifdef VJC
-#include <net/slcompress.h>
-#endif
-
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/if_pppvar.h>
-#include <machine/cpu.h>
-
-#if NetBSD1_0
-#define splsoftnet     splnet
-#endif
-
-#ifdef PPP_COMPRESS
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-#endif
-
-static int     pppsioctl __P((struct ifnet *, u_long, caddr_t));
-static void    ppp_requeue __P((struct ppp_softc *));
-static void    ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
-static void    ppp_ccp_closed __P((struct ppp_softc *));
-static void    ppp_inproc __P((struct ppp_softc *, struct mbuf *));
-static void    pppdumpm __P((struct mbuf *m0));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m)        ((m)->m_flags & M_EXT)
-
-#define M_DATASTART(m) \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
-           (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
-           (m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
-
-/*
- * We steal two bits in the mbuf m_flags, to mark high-priority packets
- * for output, and received packets following lost/corrupted packets.
- */
-#define M_HIGHPRI      0x2000  /* output packet for sc_fastq */
-#define M_ERRMARK      0x4000  /* steal a bit in mbuf m_flags */
-
-
-#ifdef PPP_COMPRESS
-/*
- * List of compressors we know about.
- * We leave some space so maybe we can modload compressors.
- */
-
-extern struct compressor ppp_bsd_compress;
-extern struct compressor ppp_deflate, ppp_deflate_draft;
-
-struct compressor *ppp_compressors[8] = {
-#if DO_BSD_COMPRESS
-    &ppp_bsd_compress,
-#endif
-#if DO_DEFLATE
-    &ppp_deflate,
-    &ppp_deflate_draft,
-#endif
-    NULL
-};
-#endif /* PPP_COMPRESS */
-
-
-/*
- * Called from boot code to establish ppp interfaces.
- */
-void
-pppattach()
-{
-    register struct ppp_softc *sc;
-    register int i = 0;
-
-    for (sc = ppp_softc; i < NPPP; sc++) {
-       sc->sc_if.if_name = "ppp";
-       sc->sc_if.if_unit = i++;
-       sc->sc_if.if_mtu = PPP_MTU;
-       sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
-       sc->sc_if.if_type = IFT_PPP;
-       sc->sc_if.if_hdrlen = PPP_HDRLEN;
-       sc->sc_if.if_ioctl = pppsioctl;
-       sc->sc_if.if_output = pppoutput;
-       sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
-       if_attach(&sc->sc_if);
-#if NBPFILTER > 0
-       bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
-#endif
-    }
-
-#if NetBSD1_0 && defined(i386)
-    /*
-     * XXX kludge to fix the bug in the i386 interrupt handling code,
-     * where software interrupts could be taken while hardware
-     * interrupts were blocked.
-     */
-    if ((imask[IPL_TTY] & (1 << SIR_NET)) == 0) {
-       imask[IPL_TTY] |= (1 << SIR_NET);
-       intr_calculatemasks();
-    }
-#endif
-}
-
-/*
- * Allocate a ppp interface unit and initialize it.
- */
-struct ppp_softc *
-pppalloc(pid)
-    pid_t pid;
-{
-    int nppp, i;
-    struct ppp_softc *sc;
-
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_xfer == pid) {
-           sc->sc_xfer = 0;
-           return sc;
-       }
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_devp == NULL)
-           break;
-    if (nppp >= NPPP)
-       return NULL;
-
-    sc->sc_flags = 0;
-    sc->sc_mru = PPP_MRU;
-    sc->sc_relinq = NULL;
-    bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
-#ifdef VJC
-    MALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress),
-          M_DEVBUF, M_NOWAIT);
-    if (sc->sc_comp)
-       sl_compress_init(sc->sc_comp, -1);
-#endif
-#ifdef PPP_COMPRESS
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-    for (i = 0; i < NUM_NP; ++i)
-       sc->sc_npmode[i] = NPMODE_ERROR;
-    sc->sc_npqueue = NULL;
-    sc->sc_npqtail = &sc->sc_npqueue;
-    sc->sc_last_sent = sc->sc_last_recv = time.tv_sec;
-
-    return sc;
-}
-
-/*
- * Deallocate a ppp unit.  Must be called at splsoftnet or higher.
- */
-void
-pppdealloc(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m;
-
-    if_down(&sc->sc_if);
-    sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
-    sc->sc_devp = NULL;
-    sc->sc_xfer = 0;
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_rawq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_inq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_fastq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    while ((m = sc->sc_npqueue) != NULL) {
-       sc->sc_npqueue = m->m_nextpkt;
-       m_freem(m);
-    }
-    if (sc->sc_togo != NULL) {
-       m_freem(sc->sc_togo);
-       sc->sc_togo = NULL;
-    }
-#ifdef PPP_COMPRESS
-    ppp_ccp_closed(sc);
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-#ifdef PPP_FILTER
-    if (sc->sc_pass_filt.bf_insns != 0) {
-       FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF);
-       sc->sc_pass_filt.bf_insns = 0;
-       sc->sc_pass_filt.bf_len = 0;
-    }
-    if (sc->sc_active_filt.bf_insns != 0) {
-       FREE(sc->sc_active_filt.bf_insns, M_DEVBUF);
-       sc->sc_active_filt.bf_insns = 0;
-       sc->sc_active_filt.bf_len = 0;
-    }
-#endif /* PPP_FILTER */
-#ifdef VJC
-    if (sc->sc_comp != 0) {
-       FREE(sc->sc_comp, M_DEVBUF);
-       sc->sc_comp = 0;
-    }
-#endif
-}
-
-/*
- * Ioctl routine for generic ppp devices.
- */
-int
-pppioctl(sc, cmd, data, flag, p)
-    struct ppp_softc *sc;
-    u_long cmd;
-    caddr_t data;
-    int flag;
-    struct proc *p;
-{
-    int s, error, flags, mru, nb, npx;
-    struct ppp_option_data *odp;
-    struct compressor **cp;
-    struct npioctl *npi;
-    time_t t;
-#ifdef PPP_FILTER
-    struct bpf_program *bp, *nbp;
-    struct bpf_insn *newcode, *oldcode;
-    int newcodelen;
-#endif /* PPP_FILTER */
-#ifdef PPP_COMPRESS
-    u_char ccp_option[CCP_MAX_OPTION_LENGTH];
-#endif
-
-    switch (cmd) {
-    case FIONREAD:
-       *(int *)data = sc->sc_inq.ifq_len;
-       break;
-
-    case PPPIOCGUNIT:
-       *(int *)data = sc->sc_if.if_unit;
-       break;
-
-    case PPPIOCGFLAGS:
-       *(u_int *)data = sc->sc_flags;
-       break;
-
-    case PPPIOCSFLAGS:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       flags = *(int *)data & SC_MASK;
-       s = splsoftnet();
-#ifdef PPP_COMPRESS
-       if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN))
-           ppp_ccp_closed(sc);
-#endif
-       splimp();
-       sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags;
-       splx(s);
-       break;
-
-    case PPPIOCSMRU:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       mru = *(int *)data;
-       if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
-           sc->sc_mru = mru;
-       break;
-
-    case PPPIOCGMRU:
-       *(int *)data = sc->sc_mru;
-       break;
-
-#ifdef VJC
-    case PPPIOCSMAXCID:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       if (sc->sc_comp) {
-           s = splsoftnet();
-           sl_compress_init(sc->sc_comp, *(int *)data);
-           splx(s);
-       }
-       break;
-#endif
-
-    case PPPIOCXFERUNIT:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       sc->sc_xfer = p->p_pid;
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPPIOCSCOMPRESS:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       odp = (struct ppp_option_data *) data;
-       nb = odp->length;
-       if (nb > sizeof(ccp_option))
-           nb = sizeof(ccp_option);
-       if ((error = copyin(odp->ptr, ccp_option, nb)) != 0)
-           return (error);
-       if (ccp_option[1] < 2)  /* preliminary check on the length byte */
-           return (EINVAL);
-       for (cp = ppp_compressors; *cp != NULL; ++cp)
-           if ((*cp)->compress_proto == ccp_option[0]) {
-               /*
-                * Found a handler for the protocol - try to allocate
-                * a compressor or decompressor.
-                */
-               error = 0;
-               if (odp->transmit) {
-                   s = splsoftnet();
-                   if (sc->sc_xc_state != NULL)
-                       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-                   sc->sc_xcomp = *cp;
-                   sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
-                   if (sc->sc_xc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("ppp%d: comp_alloc failed\n",
-                              sc->sc_if.if_unit);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_COMP_RUN;
-                   splx(s);
-               } else {
-                   s = splsoftnet();
-                   if (sc->sc_rc_state != NULL)
-                       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-                   sc->sc_rcomp = *cp;
-                   sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
-                   if (sc->sc_rc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("ppp%d: decomp_alloc failed\n",
-                              sc->sc_if.if_unit);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_DECOMP_RUN;
-                   splx(s);
-               }
-               return (error);
-           }
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: no compressor for [%x %x %x], %x\n",
-                  sc->sc_if.if_unit, ccp_option[0], ccp_option[1],
-                  ccp_option[2], nb);
-       return (EINVAL);        /* no handler found */
-#endif /* PPP_COMPRESS */
-
-    case PPPIOCGNPMODE:
-    case PPPIOCSNPMODE:
-       npi = (struct npioctl *) data;
-       switch (npi->protocol) {
-       case PPP_IP:
-           npx = NP_IP;
-           break;
-       default:
-           return EINVAL;
-       }
-       if (cmd == PPPIOCGNPMODE) {
-           npi->mode = sc->sc_npmode[npx];
-       } else {
-           if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-               return (error);
-           if (npi->mode != sc->sc_npmode[npx]) {
-               s = splsoftnet();
-               sc->sc_npmode[npx] = npi->mode;
-               if (npi->mode != NPMODE_QUEUE) {
-                   ppp_requeue(sc);
-                   (*sc->sc_start)(sc);
-               }
-               splx(s);
-           }
-       }
-       break;
-
-    case PPPIOCGIDLE:
-       s = splsoftnet();
-       t = time.tv_sec;
-       ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
-       ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
-       splx(s);
-       break;
-
-#ifdef PPP_FILTER
-    case PPPIOCSPASS:
-    case PPPIOCSACTIVE:
-       nbp = (struct bpf_program *) data;
-       if ((unsigned) nbp->bf_len > BPF_MAXINSNS)
-           return EINVAL;
-       newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
-       if (newcodelen != 0) {
-           MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK);
-           if (newcode == 0) {
-               return EINVAL;          /* or sumpin */
-           }
-           if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode,
-                              newcodelen)) != 0) {
-               FREE(newcode, M_DEVBUF);
-               return error;
-           }
-           if (!bpf_validate(newcode, nbp->bf_len)) {
-               FREE(newcode, M_DEVBUF);
-               return EINVAL;
-           }
-       } else
-           newcode = 0;
-       bp = (cmd == PPPIOCSPASS)? &sc->sc_pass_filt: &sc->sc_active_filt;
-       oldcode = bp->bf_insns;
-       s = splimp();
-       bp->bf_len = nbp->bf_len;
-       bp->bf_insns = newcode;
-       splx(s);
-       if (oldcode != 0)
-           FREE(oldcode, M_DEVBUF);
-       break;
-#endif
-
-    default:
-       return (-1);
-    }
-    return (0);
-}
-
-/*
- * Process an ioctl request to the ppp network interface.
- */
-static int
-pppsioctl(ifp, cmd, data)
-    register struct ifnet *ifp;
-    u_long cmd;
-    caddr_t data;
-{
-    struct proc *p = curproc;  /* XXX */
-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
-    register struct ifaddr *ifa = (struct ifaddr *)data;
-    register struct ifreq *ifr = (struct ifreq *)data;
-    struct ppp_stats *psp;
-#ifdef PPP_COMPRESS
-    struct ppp_comp_stats *pcp;
-#endif
-    int s = splimp(), error = 0;
-
-    switch (cmd) {
-    case SIOCSIFFLAGS:
-       if ((ifp->if_flags & IFF_RUNNING) == 0)
-           ifp->if_flags &= ~IFF_UP;
-       break;
-
-    case SIOCSIFADDR:
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFDSTADDR:
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFMTU:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_if.if_mtu = ifr->ifr_mtu;
-       break;
-
-    case SIOCGIFMTU:
-       ifr->ifr_mtu = sc->sc_if.if_mtu;
-       break;
-
-    case SIOCADDMULTI:
-    case SIOCDELMULTI:
-       if (ifr == 0) {
-           error = EAFNOSUPPORT;
-           break;
-       }
-       switch(ifr->ifr_addr.sa_family) {
-#ifdef INET
-       case AF_INET:
-           break;
-#endif
-       default:
-           error = EAFNOSUPPORT;
-           break;
-       }
-       break;
-
-    case SIOCGPPPSTATS:
-       psp = &((struct ifpppstatsreq *) data)->stats;
-       bzero(psp, sizeof(*psp));
-       psp->p = sc->sc_stats;
-#if defined(VJC) && !defined(SL_NO_STATS)
-       if (sc->sc_comp) {
-           psp->vj.vjs_packets = sc->sc_comp->sls_packets;
-           psp->vj.vjs_compressed = sc->sc_comp->sls_compressed;
-           psp->vj.vjs_searches = sc->sc_comp->sls_searches;
-           psp->vj.vjs_misses = sc->sc_comp->sls_misses;
-           psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin;
-           psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin;
-           psp->vj.vjs_errorin = sc->sc_comp->sls_errorin;
-           psp->vj.vjs_tossed = sc->sc_comp->sls_tossed;
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case SIOCGPPPCSTATS:
-       pcp = &((struct ifpppcstatsreq *) data)->stats;
-       bzero(pcp, sizeof(*pcp));
-       if (sc->sc_xc_state != NULL)
-           (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c);
-       if (sc->sc_rc_state != NULL)
-           (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d);
-       break;
-#endif /* PPP_COMPRESS */
-
-    default:
-       error = EINVAL;
-    }
-    splx(s);
-    return (error);
-}
-
-/*
- * Queue a packet.  Start transmission if not active.
- * Packet is placed in Information field of PPP frame.
- */
-int
-pppoutput(ifp, m0, dst, rtp)
-    struct ifnet *ifp;
-    struct mbuf *m0;
-    struct sockaddr *dst;
-    struct rtentry *rtp;
-{
-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
-    int protocol, address, control;
-    u_char *cp;
-    int s, error;
-    struct ip *ip;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-    int len;
-    struct mbuf *m;
-
-    if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
-       || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
-       error = ENETDOWN;       /* sort of */
-       goto bad;
-    }
-
-    /*
-     * Compute PPP header.
-     */
-    m0->m_flags &= ~M_HIGHPRI;
-    switch (dst->sa_family) {
-#ifdef INET
-    case AF_INET:
-       address = PPP_ALLSTATIONS;
-       control = PPP_UI;
-       protocol = PPP_IP;
-       mode = sc->sc_npmode[NP_IP];
-
-       /*
-        * If this packet has the "low delay" bit set in the IP header,
-        * put it on the fastq instead.
-        */
-       ip = mtod(m0, struct ip *);
-       if (ip->ip_tos & IPTOS_LOWDELAY)
-           m0->m_flags |= M_HIGHPRI;
-       break;
-#endif
-    case AF_UNSPEC:
-       address = PPP_ADDRESS(dst->sa_data);
-       control = PPP_CONTROL(dst->sa_data);
-       protocol = PPP_PROTOCOL(dst->sa_data);
-       mode = NPMODE_PASS;
-       break;
-    default:
-       printf("ppp%d: af%d not supported\n", ifp->if_unit, dst->sa_family);
-       error = EAFNOSUPPORT;
-       goto bad;
-    }
-
-    /*
-     * Drop this packet, or return an error, if necessary.
-     */
-    if (mode == NPMODE_ERROR) {
-       error = ENETDOWN;
-       goto bad;
-    }
-    if (mode == NPMODE_DROP) {
-       error = 0;
-       goto bad;
-    }
-
-    /*
-     * Add PPP header.  If no space in first mbuf, allocate another.
-     * (This assumes M_LEADINGSPACE is always 0 for a cluster mbuf.)
-     */
-    if (M_LEADINGSPACE(m0) < PPP_HDRLEN) {
-       m0 = m_prepend(m0, PPP_HDRLEN, M_DONTWAIT);
-       if (m0 == 0) {
-           error = ENOBUFS;
-           goto bad;
-       }
-       m0->m_len = 0;
-    } else
-       m0->m_data -= PPP_HDRLEN;
-
-    cp = mtod(m0, u_char *);
-    *cp++ = address;
-    *cp++ = control;
-    *cp++ = protocol >> 8;
-    *cp++ = protocol & 0xff;
-    m0->m_len += PPP_HDRLEN;
-
-    len = 0;
-    for (m = m0; m != 0; m = m->m_next)
-       len += m->m_len;
-
-    if (sc->sc_flags & SC_LOG_OUTPKT) {
-       printf("ppp%d output: ", ifp->if_unit);
-       pppdumpm(m0);
-    }
-
-    if ((protocol & 0x8000) == 0) {
-#ifdef PPP_FILTER
-       /*
-        * Apply the pass and active filters to the packet,
-        * but only if it is a data packet.
-        */
-       *mtod(m0, u_char *) = 1;        /* indicates outbound */
-       if (sc->sc_pass_filt.bf_insns != 0
-           && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m0,
-                         len, 0) == 0) {
-           error = 0;          /* drop this packet */
-           goto bad;
-       }
-
-       /*
-        * Update the time we sent the most recent packet.
-        */
-       if (sc->sc_active_filt.bf_insns == 0
-           || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
-           sc->sc_last_sent = time.tv_sec;
-
-       *mtod(m0, u_char *) = address;
-#else
-       /*
-        * Update the time we sent the most recent data packet.
-        */
-       sc->sc_last_sent = time.tv_sec;
-#endif /* PPP_FILTER */
-    }
-
-#if NBPFILTER > 0
-    /*
-     * See if bpf wants to look at the packet.
-     */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m0);
-#endif
-
-    /*
-     * Put the packet on the appropriate queue.
-     */
-    s = splsoftnet();
-    if (mode == NPMODE_QUEUE) {
-       /* XXX we should limit the number of packets on this queue */
-       *sc->sc_npqtail = m0;
-       m0->m_nextpkt = NULL;
-       sc->sc_npqtail = &m0->m_nextpkt;
-    } else {
-       ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
-       if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
-           IF_DROP(ifq);
-           splx(s);
-           sc->sc_if.if_oerrors++;
-           sc->sc_stats.ppp_oerrors++;
-           error = ENOBUFS;
-           goto bad;
-       }
-       IF_ENQUEUE(ifq, m0);
-       (*sc->sc_start)(sc);
-    }
-    ifp->if_lastchange = time;
-    ifp->if_opackets++;
-    ifp->if_obytes += len;
-
-    splx(s);
-    return (0);
-
-bad:
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * After a change in the NPmode for some NP, move packets from the
- * npqueue to the send queue or the fast queue as appropriate.
- * Should be called at splsoftnet.
- */
-static void
-ppp_requeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, **mpp;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-
-    for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) {
-       switch (PPP_PROTOCOL(mtod(m, u_char *))) {
-       case PPP_IP:
-           mode = sc->sc_npmode[NP_IP];
-           break;
-       default:
-           mode = NPMODE_PASS;
-       }
-
-       switch (mode) {
-       case NPMODE_PASS:
-           /*
-            * This packet can now go on one of the queues to be sent.
-            */
-           *mpp = m->m_nextpkt;
-           m->m_nextpkt = NULL;
-           ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd;
-           if (IF_QFULL(ifq)) {
-               IF_DROP(ifq);
-               sc->sc_if.if_oerrors++;
-               sc->sc_stats.ppp_oerrors++;
-           } else
-               IF_ENQUEUE(ifq, m);
-           break;
-
-       case NPMODE_DROP:
-       case NPMODE_ERROR:
-           *mpp = m->m_nextpkt;
-           m_freem(m);
-           break;
-
-       case NPMODE_QUEUE:
-           mpp = &m->m_nextpkt;
-           break;
-       }
-    }
-    sc->sc_npqtail = mpp;
-}
-
-/*
- * Transmitter has finished outputting some stuff;
- * remember to call sc->sc_start later at splsoftnet.
- */
-void
-ppp_restart(sc)
-    struct ppp_softc *sc;
-{
-    int s = splimp();
-
-    sc->sc_flags &= ~SC_TBUSY;
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Get a packet to send.  This procedure is intended to be called at
- * splsoftnet, since it may involve time-consuming operations such as
- * applying VJ compression, packet compression, address/control and/or
- * protocol field compression to the packet.
- */
-struct mbuf *
-ppp_dequeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, *mp;
-    u_char *cp;
-    int address, control, protocol;
-
-    /*
-     * Grab a packet to send: first try the fast queue, then the
-     * normal queue.
-     */
-    IF_DEQUEUE(&sc->sc_fastq, m);
-    if (m == NULL)
-       IF_DEQUEUE(&sc->sc_if.if_snd, m);
-    if (m == NULL)
-       return NULL;
-
-    ++sc->sc_stats.ppp_opackets;
-
-    /*
-     * Extract the ppp header of the new packet.
-     * The ppp header will be in one mbuf.
-     */
-    cp = mtod(m, u_char *);
-    address = PPP_ADDRESS(cp);
-    control = PPP_CONTROL(cp);
-    protocol = PPP_PROTOCOL(cp);
-
-    switch (protocol) {
-    case PPP_IP:
-#ifdef VJC
-       /*
-        * If the packet is a TCP/IP packet, see if we can compress it.
-        */
-       if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) {
-           struct ip *ip;
-           int type;
-
-           mp = m;
-           ip = (struct ip *) (cp + PPP_HDRLEN);
-           if (mp->m_len <= PPP_HDRLEN) {
-               mp = mp->m_next;
-               if (mp == NULL)
-                   break;
-               ip = mtod(mp, struct ip *);
-           }
-           /* this code assumes the IP/TCP header is in one non-shared mbuf */
-           if (ip->ip_p == IPPROTO_TCP) {
-               type = sl_compress_tcp(mp, ip, sc->sc_comp,
-                                      !(sc->sc_flags & SC_NO_TCP_CCID));
-               switch (type) {
-               case TYPE_UNCOMPRESSED_TCP:
-                   protocol = PPP_VJC_UNCOMP;
-                   break;
-               case TYPE_COMPRESSED_TCP:
-                   protocol = PPP_VJC_COMP;
-                   cp = mtod(m, u_char *);
-                   cp[0] = address;    /* header has moved */
-                   cp[1] = control;
-                   cp[2] = 0;
-                   break;
-               }
-               cp[3] = protocol;       /* update protocol in PPP header */
-           }
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPP_CCP:
-       ppp_ccp(sc, m, 0);
-       break;
-#endif /* PPP_COMPRESS */
-    }
-
-#ifdef PPP_COMPRESS
-    if (protocol != PPP_LCP && protocol != PPP_CCP
-       && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
-       struct mbuf *mcomp = NULL;
-       int slen, clen;
-
-       slen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           slen += mp->m_len;
-       clen = (*sc->sc_xcomp->compress)
-           (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
-       if (mcomp != NULL) {
-           if (sc->sc_flags & SC_CCP_UP) {
-               /* Send the compressed packet instead of the original. */
-               m_freem(m);
-               m = mcomp;
-               cp = mtod(m, u_char *);
-               protocol = cp[3];
-           } else {
-               /* Can't transmit compressed packets until CCP is up. */
-               m_freem(mcomp);
-           }
-       }
-    }
-#endif /* PPP_COMPRESS */
-
-    /*
-     * Compress the address/control and protocol, if possible.
-     */
-    if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS &&
-       control == PPP_UI && protocol != PPP_ALLSTATIONS &&
-       protocol != PPP_LCP) {
-       /* can compress address/control */
-       m->m_data += 2;
-       m->m_len -= 2;
-    }
-    if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) {
-       /* can compress protocol */
-       if (mtod(m, u_char *) == cp) {
-           cp[2] = cp[1];      /* move address/control up */
-           cp[1] = cp[0];
-       }
-       ++m->m_data;
-       --m->m_len;
-    }
-
-    return m;
-}
-
-/*
- * Software interrupt routine, called at splsoftnet.
- */
-void
-pppintr()
-{
-    struct ppp_softc *sc;
-    int i, s, s2;
-    struct mbuf *m;
-
-    sc = ppp_softc;
-    s = splsoftnet();
-    for (i = 0; i < NPPP; ++i, ++sc) {
-       if (!(sc->sc_flags & SC_TBUSY)
-           && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
-           s2 = splimp();
-           sc->sc_flags |= SC_TBUSY;
-           splx(s2);
-           (*sc->sc_start)(sc);
-       }
-       for (;;) {
-           s2 = splimp();
-           IF_DEQUEUE(&sc->sc_rawq, m);
-           splx(s2);
-           if (m == NULL)
-               break;
-           ppp_inproc(sc, m);
-       }
-    }
-    splx(s);
-}
-
-#ifdef PPP_COMPRESS
-/*
- * Handle a CCP packet.  `rcvd' is 1 if the packet was received,
- * 0 if it is about to be transmitted.
- */
-static void
-ppp_ccp(sc, m, rcvd)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int rcvd;
-{
-    u_char *dp, *ep;
-    struct mbuf *mp;
-    int slen, s;
-
-    /*
-     * Get a pointer to the data after the PPP header.
-     */
-    if (m->m_len <= PPP_HDRLEN) {
-       mp = m->m_next;
-       if (mp == NULL)
-           return;
-       dp = (mp != NULL)? mtod(mp, u_char *): NULL;
-    } else {
-       mp = m;
-       dp = mtod(mp, u_char *) + PPP_HDRLEN;
-    }
-
-    ep = mtod(mp, u_char *) + mp->m_len;
-    if (dp + CCP_HDRLEN > ep)
-       return;
-    slen = CCP_LENGTH(dp);
-    if (dp + slen > ep) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n",
-                  dp, slen, mtod(mp, u_char *), mp->m_len);
-       return;
-    }
-
-    switch (CCP_CODE(dp)) {
-    case CCP_CONFREQ:
-    case CCP_TERMREQ:
-    case CCP_TERMACK:
-       /* CCP must be going down - disable compression */
-       if (sc->sc_flags & SC_CCP_UP) {
-           s = splimp();
-           sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
-           splx(s);
-       }
-       break;
-
-    case CCP_CONFACK:
-       if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP)
-           && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
-           && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
-           if (!rcvd) {
-               /* we're agreeing to send compressed packets. */
-               if (sc->sc_xc_state != NULL
-                   && (*sc->sc_xcomp->comp_init)
-                       (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_COMP_RUN;
-                   splx(s);
-               }
-           } else {
-               /* peer is agreeing to send compressed packets. */
-               if (sc->sc_rc_state != NULL
-                   && (*sc->sc_rcomp->decomp_init)
-                       (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, 0, sc->sc_mru,
-                        sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_DECOMP_RUN;
-                   sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
-                   splx(s);
-               }
-           }
-       }
-       break;
-
-    case CCP_RESETACK:
-       if (sc->sc_flags & SC_CCP_UP) {
-           if (!rcvd) {
-               if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN))
-                   (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state);
-           } else {
-               if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-                   (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state);
-                   s = splimp();
-                   sc->sc_flags &= ~SC_DC_ERROR;
-                   splx(s);
-               }
-           }
-       }
-       break;
-    }
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-static void
-ppp_ccp_closed(sc)
-    struct ppp_softc *sc;
-{
-    if (sc->sc_xc_state) {
-       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-       sc->sc_xc_state = NULL;
-    }
-    if (sc->sc_rc_state) {
-       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-       sc->sc_rc_state = NULL;
-    }
-}
-#endif /* PPP_COMPRESS */
-
-/*
- * PPP packet input routine.
- * The caller has checked and removed the FCS and has inserted
- * the address/control bytes and the protocol high byte if they
- * were omitted.
- */
-void
-ppppktin(sc, m, lost)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int lost;
-{
-    int s = splimp();
-
-    if (lost)
-       m->m_flags |= M_ERRMARK;
-    IF_ENQUEUE(&sc->sc_rawq, m);
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Process a received PPP packet, doing decompression as necessary.
- * Should be called at splsoftnet.
- */
-#define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
-                        TYPE_UNCOMPRESSED_TCP)
-
-static void
-ppp_inproc(sc, m)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-{
-    struct ifnet *ifp = &sc->sc_if;
-    struct ifqueue *inq;
-    int s, ilen, xlen, proto, rv;
-    u_char *cp, adrs, ctrl;
-    struct mbuf *mp, *dmp = NULL;
-    u_char *iphdr;
-    u_int hlen;
-
-    sc->sc_stats.ppp_ipackets++;
-
-    if (sc->sc_flags & SC_LOG_INPKT) {
-       ilen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           ilen += mp->m_len;
-       printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen);
-       pppdumpm(m);
-    }
-
-    cp = mtod(m, u_char *);
-    adrs = PPP_ADDRESS(cp);
-    ctrl = PPP_CONTROL(cp);
-    proto = PPP_PROTOCOL(cp);
-
-    if (m->m_flags & M_ERRMARK) {
-       m->m_flags &= ~M_ERRMARK;
-       s = splimp();
-       sc->sc_flags |= SC_VJ_RESET;
-       splx(s);
-    }
-
-#ifdef PPP_COMPRESS
-    /*
-     * Decompress this packet if necessary, update the receiver's
-     * dictionary, or take appropriate action on a CCP packet.
-     */
-    if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)
-       && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) {
-       /* decompress this packet */
-       rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp);
-       if (rv == DECOMP_OK) {
-           m_freem(m);
-           if (dmp == NULL) {
-               /* no error, but no decompressed packet produced */
-               return;
-           }
-           m = dmp;
-           cp = mtod(m, u_char *);
-           proto = PPP_PROTOCOL(cp);
-
-       } else {
-           /*
-            * An error has occurred in decompression.
-            * Pass the compressed packet up to pppd, which may take
-            * CCP down or issue a Reset-Req.
-            */
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: decompress failed %d\n", ifp->if_unit, rv);
-           s = splimp();
-           sc->sc_flags |= SC_VJ_RESET;
-           if (rv == DECOMP_ERROR)
-               sc->sc_flags |= SC_DC_ERROR;
-           else
-               sc->sc_flags |= SC_DC_FERROR;
-           splx(s);
-       }
-
-    } else {
-       if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-           (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m);
-       }
-       if (proto == PPP_CCP) {
-           ppp_ccp(sc, m, 1);
-       }
-    }
-#endif
-
-    ilen = 0;
-    for (mp = m; mp != NULL; mp = mp->m_next)
-       ilen += mp->m_len;
-
-#ifdef VJC
-    if (sc->sc_flags & SC_VJ_RESET) {
-       /*
-        * If we've missed a packet, we must toss subsequent compressed
-        * packets which don't have an explicit connection ID.
-        */
-       if (sc->sc_comp)
-           sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp);
-       s = splimp();
-       sc->sc_flags &= ~SC_VJ_RESET;
-       splx(s);
-    }
-
-    /*
-     * See if we have a VJ-compressed packet to uncompress.
-     */
-    if (proto == PPP_VJC_COMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen <= 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: VJ uncompress failed on type comp\n",
-                       ifp->if_unit);
-           goto bad;
-       }
-
-       /* Copy the PPP and IP headers into a new mbuf. */
-       MGETHDR(mp, M_DONTWAIT, MT_DATA);
-       if (mp == NULL)
-           goto bad;
-       mp->m_len = 0;
-       mp->m_next = NULL;
-       if (hlen + PPP_HDRLEN > MHLEN) {
-           MCLGET(mp, M_DONTWAIT);
-           if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) {
-               m_freem(mp);
-               goto bad;       /* lose if big headers and no clusters */
-           }
-       }
-       cp = mtod(mp, u_char *);
-       cp[0] = adrs;
-       cp[1] = ctrl;
-       cp[2] = 0;
-       cp[3] = PPP_IP;
-       proto = PPP_IP;
-       bcopy(iphdr, cp + PPP_HDRLEN, hlen);
-       mp->m_len = hlen + PPP_HDRLEN;
-
-       /*
-        * Trim the PPP and VJ headers off the old mbuf
-        * and stick the new and old mbufs together.
-        */
-       m->m_data += PPP_HDRLEN + xlen;
-       m->m_len -= PPP_HDRLEN + xlen;
-       if (m->m_len <= M_TRAILINGSPACE(mp)) {
-           bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len);
-           mp->m_len += m->m_len;
-           MFREE(m, mp->m_next);
-       } else
-           mp->m_next = m;
-       m = mp;
-       ilen += hlen - xlen;
-
-    } else if (proto == PPP_VJC_UNCOMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen < 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: VJ uncompress failed on type uncomp\n",
-                       ifp->if_unit);
-           goto bad;
-       }
-
-       proto = PPP_IP;
-       cp[3] = PPP_IP;
-    }
-#endif /* VJC */
-
-    /*
-     * If the packet will fit in a header mbuf, don't waste a
-     * whole cluster on it.
-     */
-    if (ilen <= MHLEN && M_IS_CLUSTER(m)) {
-       MGETHDR(mp, M_DONTWAIT, MT_DATA);
-       if (mp != NULL) {
-           m_copydata(m, 0, ilen, mtod(mp, caddr_t));
-           m_freem(m);
-           m = mp;
-           m->m_len = ilen;
-       }
-    }
-    m->m_pkthdr.len = ilen;
-    m->m_pkthdr.rcvif = ifp;
-
-    if ((proto & 0x8000) == 0) {
-#ifdef PPP_FILTER
-       /*
-        * See whether we want to pass this packet, and
-        * if it counts as link activity.
-        */
-       adrs = *mtod(m, u_char *);      /* save address field */
-       *mtod(m, u_char *) = 0;         /* indicate inbound */
-       if (sc->sc_pass_filt.bf_insns != 0
-           && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m,
-                         ilen, 0) == 0) {
-           /* drop this packet */
-           m_freem(m);
-           return;
-       }
-       if (sc->sc_active_filt.bf_insns == 0
-           || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
-           sc->sc_last_recv = time.tv_sec;
-
-       *mtod(m, u_char *) = adrs;
-#else
-       /*
-        * Record the time that we received this packet.
-        */
-       sc->sc_last_recv = time.tv_sec;
-#endif /* PPP_FILTER */
-    }
-
-#if NBPFILTER > 0
-    /* See if bpf wants to look at the packet. */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m);
-#endif
-
-    rv = 0;
-    switch (proto) {
-#ifdef INET
-    case PPP_IP:
-       /*
-        * IP packet - take off the ppp header and pass it up to IP.
-        */
-       if ((ifp->if_flags & IFF_UP) == 0
-           || sc->sc_npmode[NP_IP] != NPMODE_PASS) {
-           /* interface is down - drop the packet. */
-           m_freem(m);
-           return;
-       }
-       m->m_pkthdr.len -= PPP_HDRLEN;
-       m->m_data += PPP_HDRLEN;
-       m->m_len -= PPP_HDRLEN;
-       schednetisr(NETISR_IP);
-       inq = &ipintrq;
-       break;
-#endif
-
-    default:
-       /*
-        * Some other protocol - place on input queue for read().
-        */
-       inq = &sc->sc_inq;
-       rv = 1;
-       break;
-    }
-
-    /*
-     * Put the packet on the appropriate input queue.
-     */
-    s = splimp();
-    if (IF_QFULL(inq)) {
-       IF_DROP(inq);
-       splx(s);
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: input queue full\n", ifp->if_unit);
-       ifp->if_iqdrops++;
-       goto bad;
-    }
-    IF_ENQUEUE(inq, m);
-    splx(s);
-    ifp->if_ipackets++;
-    ifp->if_ibytes += ilen;
-    ifp->if_lastchange = time;
-
-    if (rv)
-       (*sc->sc_ctlp)(sc);
-
-    return;
-
- bad:
-    m_freem(m);
-    sc->sc_if.if_ierrors++;
-    sc->sc_stats.ppp_ierrors++;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-pppdumpm(m0)
-    struct mbuf *m0;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    struct mbuf *m;
-    static char digits[] = "0123456789abcdef";
-
-    for (m = m0; m; m = m->m_next) {
-       int l = m->m_len;
-       u_char *rptr = (u_char *)m->m_data;
-
-       while (l--) {
-           if (bp > buf + sizeof(buf) - 4)
-               goto done;
-           *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
-           *bp++ = digits[*rptr++ & 0xf];
-       }
-
-       if (m->m_next) {
-           if (bp > buf + sizeof(buf) - 3)
-               goto done;
-           *bp++ = '|';
-       } else
-           *bp++ = ' ';
-    }
-done:
-    if (m)
-       *bp++ = '>';
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/netbsd-1.1/if_pppvar.h b/netbsd-1.1/if_pppvar.h
deleted file mode 100644 (file)
index dc29f84..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*     $Id: if_pppvar.h,v 1.6 2002/12/06 12:03:44 paulus Exp $ */
-
-/*
- * if_pppvar.h - private structures and declarations for PPP.
- *
- * Copyright (c) 1994 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.
- *
- * 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.
- */
-
-/*
- * Supported network protocols.  These values are used for
- * indexing sc_npmode.
- */
-#define NP_IP  0               /* Internet Protocol */
-#define NUM_NP 1               /* Number of NPs. */
-
-/*
- * Structure describing each ppp unit.
- */
-struct ppp_softc {
-       struct  ifnet sc_if;            /* network-visible interface */
-       u_int   sc_flags;               /* control/status bits; see if_ppp.h */
-       void    *sc_devp;               /* pointer to device-dep structure */
-       void    (*sc_start) __P((struct ppp_softc *));  /* start output proc */
-       void    (*sc_ctlp) __P((struct ppp_softc *)); /* rcvd control pkt */
-       void    (*sc_relinq) __P((struct ppp_softc *)); /* relinquish ifunit */
-       u_int16_t sc_mru;               /* max receive unit */
-       pid_t   sc_xfer;                /* used in transferring unit */
-       struct  ifqueue sc_rawq;        /* received packets */
-       struct  ifqueue sc_inq;         /* queue of input packets for daemon */
-       struct  ifqueue sc_fastq;       /* interactive output packet q */
-       struct  mbuf *sc_togo;          /* output packet ready to go */
-       struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
-       struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
-       struct  pppstat sc_stats;       /* count of bytes/pkts sent/rcvd */
-       caddr_t sc_bpf;                 /* hook for BPF */
-       enum    NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
-       struct  compressor *sc_xcomp;   /* transmit compressor */
-       void    *sc_xc_state;           /* transmit compressor state */
-       struct  compressor *sc_rcomp;   /* receive decompressor */
-       void    *sc_rc_state;           /* receive decompressor state */
-       time_t  sc_last_sent;           /* time (secs) last NP pkt sent */
-       time_t  sc_last_recv;           /* time (secs) last NP pkt rcvd */
-#ifdef PPP_FILTER
-       struct  bpf_program sc_pass_filt;   /* filter for packets to pass */
-       struct  bpf_program sc_active_filt; /* filter for "non-idle" packets */
-#endif /* PPP_FILTER */
-#ifdef VJC
-       struct  slcompress *sc_comp;    /* vjc control buffer */
-#endif
-
-       /* Device-dependent part for async lines. */
-       ext_accm sc_asyncmap;           /* async control character map */
-       u_int32_t sc_rasyncmap;         /* receive async control char map */
-       struct  mbuf *sc_outm;          /* mbuf chain currently being output */
-       struct  mbuf *sc_m;             /* pointer to input mbuf chain */
-       struct  mbuf *sc_mc;            /* pointer to current input mbuf */
-       char    *sc_mp;                 /* ptr to next char in input mbuf */
-       u_int16_t sc_ilen;              /* length of input packet so far */
-       u_int16_t sc_fcs;               /* FCS so far (input) */
-       u_int16_t sc_outfcs;            /* FCS so far for output packet */
-       u_char  sc_rawin[16];           /* chars as received */
-       int     sc_rawin_count;         /* # in sc_rawin */
-};
-
-#ifdef _KERNEL
-struct ppp_softc ppp_softc[NPPP];
-
-struct ppp_softc *pppalloc __P((pid_t pid));
-void   pppdealloc __P((struct ppp_softc *sc));
-int    pppioctl __P((struct ppp_softc *sc, u_long cmd, caddr_t data,
-                     int flag, struct proc *p));
-void   ppp_restart __P((struct ppp_softc *sc));
-void   ppppktin __P((struct ppp_softc *sc, struct mbuf *m, int lost));
-struct mbuf *ppp_dequeue __P((struct ppp_softc *sc));
-int    pppoutput __P((struct ifnet *, struct mbuf *,
-                      struct sockaddr *, struct rtentry *));
-#endif /* _KERNEL */
diff --git a/netbsd-1.1/kinstall.sh b/netbsd-1.1/kinstall.sh
deleted file mode 100755 (executable)
index bf25ae2..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/bin/sh
-
-# This script modifies the kernel sources in /sys to install
-# ppp-2.3.  It is intended to be run in the ppp-2.3 directory.
-#
-# Paul Mackerras       11-Dec-95
-
-ARCH=$(uname -m)
-CONF=$(uname -v | sed 's/.*(\(.*\)).*/\1/')
-SYS=/sys
-ARCHDIR=$SYS/arch/$ARCH
-CFILE=$ARCHDIR/conf/$CONF
-SRC=netbsd-1.1
-DOCONF=
-DOMAKE=
-
-# Work out whether to use config or config.old
-if grep -q '^[         ]*timezone' $CFILE; then
-  CONFIG=config.old
-else
-  CONFIG=config
-fi
-
-# Copy new versions of files into /sys/net
-
-for f in include/net/if_ppp.h include/net/ppp-comp.h include/net/ppp_defs.h \
-         $SRC/bsd-comp.c $SRC/ppp-deflate.c \
-        $SRC/if_ppp.c $SRC/if_pppvar.h $SRC/ppp_tty.c \
-        $SRC/slcompress.c $SRC/slcompress.h common/zlib.c common/zlib.h; do
-  dest=$SYS/net/$(basename $f)
-  if [ -f $dest ]; then
-    if ! diff -qBI '[  ]\$[IN][de].*:.*\$' $f $dest >/dev/null; then
-      echo "Copying $f to $dest"
-      mv -f $dest $dest.orig && echo " (old version saved in $dest.orig)"
-      cp $f $dest
-      DOMAKE=yes
-    fi
-  else
-    echo "Copying $f to $dest"
-    cp $f $dest
-    DOMAKE=yes
-  fi
-done
-
-OLDFILES=files.oldconf
-NEWFILES=files
-OLDCONFIG=config.old
-NEWCONFIG=config
-
-if [ -f $SYS/conf/$OLDFILES ]; then
-  if ! grep -q ppp-deflate $SYS/conf/$OLDFILES; then
-    echo "Patching $SYS/conf/$OLDFILES"
-    patch -N $SYS/conf/$OLDFILES <$SRC/files.oldconf.patch
-    if [ $CONFIG = $OLDCONFIG ]; then
-      DOCONF=yes
-    fi
-  fi
-fi
-if [ -f $SYS/conf/$NEWFILES ]; then
-  if ! grep -q ppp-deflate $SYS/conf/$NEWFILES; then
-    echo "Patching $SYS/conf/$NEWFILES"
-    patch -N $SYS/conf/$NEWFILES <$SRC/files.patch
-    if [ $CONFIG = $NEWCONFIG ]; then
-      DOCONF=yes
-    fi
-  fi
-fi
-
-# Tell the user to add a pseudo-device line to the configuration file
-# and remake the kernel, if necessary.
-
-if [ -f $CFILE ]; then
-  if ! grep -q '^[     ]*pseudo-device[        ][      ]*ppp' $CFILE; then
-    echo
-    echo "The currently-running kernel was built from configuration file"
-    echo "$CFILE, which does not include PPP."
-    echo "You need either to add a line like 'pseudo-device ppp 2' to"
-    echo "this file, or use another configuration file which includes"
-    echo "a line like this."
-    DOCONF=yes
-  fi
-fi
-
-if [ $DOCONF ]; then
-  echo
-  echo "You need to configure and build a new kernel."
-  echo "The procedure for doing this involves the following commands:"
-  echo "(\"$CONF\" may be replaced by the name of another config file.)"
-  echo
-  echo "       cd $ARCHDIR/conf"
-  echo "       /usr/sbin/$CONFIG $CONF"
-  echo "       cd ../compile/$CONF"
-  echo "       make depend"
-  DOMAKE=yes
-elif [ $DOMAKE ]; then
-  echo
-  echo "You need to build a new kernel."
-  echo "The procedure for doing this involves the following commands:"
-  echo
-  echo "       cd $ARCHDIR/compile/$CONF"
-fi
-if [ $DOMAKE ]; then
-  echo "       make"
-  echo
-  echo "Then copy the new kernel ($ARCHDIR/compile/$CONF/netbsd)"
-  echo "to /netbsd and reboot.  (Keep a copy of the old /netbsd,"
-  echo "just in case.)"
-fi
diff --git a/netbsd-1.1/ppp-deflate.c b/netbsd-1.1/ppp-deflate.c
deleted file mode 100644 (file)
index 9e65797..0000000
+++ /dev/null
@@ -1,691 +0,0 @@
-/*     $Id: ppp-deflate.c,v 1.9 2002/12/06 09:49:16 paulus Exp $       */
-
-/*
- * ppp_deflate.c - interface the zlib procedures for Deflate compression
- * and decompression (as used by gzip) to the PPP code.
- * This version is for use with mbufs on BSD-derived systems.
- *
- * Copyright (c) 1994 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/param.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <net/ppp_defs.h>
-#include <net/zlib.h>
-
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-
-#if DO_DEFLATE
-
-#define DEFLATE_DEBUG  1
-
-/*
- * State for a Deflate (de)compressor.
- */
-struct deflate_state {
-    int                seqno;
-    int                w_size;
-    int                unit;
-    int                hdrlen;
-    int                mru;
-    int                debug;
-    z_stream   strm;
-    struct compstat stats;
-};
-
-#define DEFLATE_OVHD   2               /* Deflate overhead/packet */
-
-static void    *zalloc __P((void *, u_int items, u_int size));
-static void    zfree __P((void *, void *ptr));
-static void    *z_comp_alloc __P((u_char *options, int opt_len));
-static void    *z_decomp_alloc __P((u_char *options, int opt_len));
-static void    z_comp_free __P((void *state));
-static void    z_decomp_free __P((void *state));
-static int     z_comp_init __P((void *state, u_char *options, int opt_len,
-                                int unit, int hdrlen, int debug));
-static int     z_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     z_compress __P((void *state, struct mbuf **mret,
-                                 struct mbuf *mp, int slen, int maxolen));
-static void    z_incomp __P((void *state, struct mbuf *dmsg));
-static int     z_decompress __P((void *state, struct mbuf *cmp,
-                                   struct mbuf **dmpp));
-static void    z_comp_reset __P((void *state));
-static void    z_decomp_reset __P((void *state));
-static void    z_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_deflate = {
-    CI_DEFLATE,                        /* compress_proto */
-    z_comp_alloc,              /* comp_alloc */
-    z_comp_free,               /* comp_free */
-    z_comp_init,               /* comp_init */
-    z_comp_reset,              /* comp_reset */
-    z_compress,                        /* compress */
-    z_comp_stats,              /* comp_stat */
-    z_decomp_alloc,            /* decomp_alloc */
-    z_decomp_free,             /* decomp_free */
-    z_decomp_init,             /* decomp_init */
-    z_decomp_reset,            /* decomp_reset */
-    z_decompress,              /* decompress */
-    z_incomp,                  /* incomp */
-    z_comp_stats,              /* decomp_stat */
-};
-
-struct compressor ppp_deflate = {
-    CI_DEFLATE_DRAFT,          /* compress_proto */
-    z_comp_alloc,              /* comp_alloc */
-    z_comp_free,               /* comp_free */
-    z_comp_init,               /* comp_init */
-    z_comp_reset,              /* comp_reset */
-    z_compress,                        /* compress */
-    z_comp_stats,              /* comp_stat */
-    z_decomp_alloc,            /* decomp_alloc */
-    z_decomp_free,             /* decomp_free */
-    z_decomp_init,             /* decomp_init */
-    z_decomp_reset,            /* decomp_reset */
-    z_decompress,              /* decompress */
-    z_incomp,                  /* incomp */
-    z_comp_stats,              /* decomp_stat */
-};
-
-/*
- * Space allocation and freeing routines for use by zlib routines.
- */
-void *
-zalloc(notused, items, size)
-    void *notused;
-    u_int items, size;
-{
-    void *ptr;
-
-    MALLOC(ptr, void *, items * size, M_DEVBUF, M_NOWAIT);
-    return ptr;
-}
-
-void
-zfree(notused, ptr)
-    void *notused;
-    void *ptr;
-{
-    FREE(ptr, M_DEVBUF);
-}
-
-/*
- * Allocate space for a compressor.
- */
-static void *
-z_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    struct deflate_state *state;
-    int w_size;
-
-    if (opt_len != CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return NULL;
-    w_size = DEFLATE_SIZE(options[2]);
-    if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-       return NULL;
-
-    MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
-          M_DEVBUF, M_NOWAIT);
-    if (state == NULL)
-       return NULL;
-
-    state->strm.next_in = NULL;
-    state->strm.zalloc = zalloc;
-    state->strm.zfree = zfree;
-    if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
-                    -w_size, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
-       FREE(state, M_DEVBUF);
-       return NULL;
-    }
-
-    state->w_size = w_size;
-    bzero(&state->stats, sizeof(state->stats));
-    return (void *) state;
-}
-
-static void
-z_comp_free(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    deflateEnd(&state->strm);
-    FREE(state, M_DEVBUF);
-}
-
-static int
-z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
-    void *arg;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    if (opt_len < CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || DEFLATE_SIZE(options[2]) != state->w_size
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return 0;
-
-    state->seqno = 0;
-    state->unit = unit;
-    state->hdrlen = hdrlen;
-    state->debug = debug;
-
-    deflateReset(&state->strm);
-
-    return 1;
-}
-
-static void
-z_comp_reset(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    state->seqno = 0;
-    deflateReset(&state->strm);
-}
-
-int
-z_compress(arg, mret, mp, orig_len, maxolen)
-    void *arg;
-    struct mbuf **mret;                /* compressed packet (out) */
-    struct mbuf *mp;           /* uncompressed packet (in) */
-    int orig_len, maxolen;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_char *rptr, *wptr;
-    int proto, olen, wspace, r, flush;
-    struct mbuf *m;
-
-    /*
-     * Check that the protocol is in the range we handle.
-     */
-    rptr = mtod(mp, u_char *);
-    proto = PPP_PROTOCOL(rptr);
-    if (proto > 0x3fff || proto == 0xfd || proto == 0xfb) {
-       *mret = NULL;
-       return orig_len;
-    }
-
-    /* Allocate one mbuf initially. */
-    if (maxolen > orig_len)
-       maxolen = orig_len;
-    MGET(m, M_DONTWAIT, MT_DATA);
-    *mret = m;
-    if (m != NULL) {
-       m->m_len = 0;
-       if (maxolen + state->hdrlen > MLEN)
-           MCLGET(m, M_DONTWAIT);
-       wspace = M_TRAILINGSPACE(m);
-       if (state->hdrlen + PPP_HDRLEN + 2 < wspace) {
-           m->m_data += state->hdrlen;
-           wspace -= state->hdrlen;
-       }
-       wptr = mtod(m, u_char *);
-
-       /*
-        * Copy over the PPP header and store the 2-byte sequence number.
-        */
-       wptr[0] = PPP_ADDRESS(rptr);
-       wptr[1] = PPP_CONTROL(rptr);
-       wptr[2] = PPP_COMP >> 8;
-       wptr[3] = PPP_COMP;
-       wptr += PPP_HDRLEN;
-       wptr[0] = state->seqno >> 8;
-       wptr[1] = state->seqno;
-       wptr += 2;
-       state->strm.next_out = wptr;
-       state->strm.avail_out = wspace - (PPP_HDRLEN + 2);
-    } else {
-       state->strm.next_out = NULL;
-       state->strm.avail_out = 1000000;
-       wptr = NULL;
-       wspace = 0;
-    }
-    ++state->seqno;
-
-    rptr += (proto > 0xff)? 2: 3;      /* skip 1st proto byte if 0 */
-    state->strm.next_in = rptr;
-    state->strm.avail_in = mtod(mp, u_char *) + mp->m_len - rptr;
-    mp = mp->m_next;
-    flush = (mp == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
-    olen = 0;
-    for (;;) {
-       r = deflate(&state->strm, flush);
-       if (r != Z_OK) {
-           printf("z_compress: deflate returned %d (%s)\n",
-                  r, (state->strm.msg? state->strm.msg: ""));
-           break;
-       }
-       if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
-           break;              /* all done */
-       if (state->strm.avail_in == 0 && mp != NULL) {
-           state->strm.next_in = mtod(mp, u_char *);
-           state->strm.avail_in = mp->m_len;
-           mp = mp->m_next;
-           if (mp == NULL)
-               flush = Z_PACKET_FLUSH;
-       }
-       if (state->strm.avail_out == 0) {
-           if (m != NULL) {
-               m->m_len = wspace;
-               olen += wspace;
-               MGET(m->m_next, M_DONTWAIT, MT_DATA);
-               m = m->m_next;
-               if (m != NULL) {
-                   m->m_len = 0;
-                   if (maxolen - olen > MLEN)
-                       MCLGET(m, M_DONTWAIT);
-                   state->strm.next_out = mtod(m, u_char *);
-                   state->strm.avail_out = wspace = M_TRAILINGSPACE(m);
-               }
-           }
-           if (m == NULL) {
-               state->strm.next_out = NULL;
-               state->strm.avail_out = 1000000;
-           }
-       }
-    }
-    if (m != NULL)
-       olen += (m->m_len = wspace - state->strm.avail_out);
-
-    /*
-     * See if we managed to reduce the size of the packet.
-     * If the compressor just gave us a single zero byte, it means
-     * the packet was incompressible.
-     */
-    if (m != NULL && olen < orig_len
-       && !(olen == PPP_HDRLEN + 3 && *wptr == 0)) {
-       state->stats.comp_bytes += olen;
-       state->stats.comp_packets++;
-    } else {
-       if (*mret != NULL) {
-           m_freem(*mret);
-           *mret = NULL;
-       }
-       state->stats.inc_bytes += orig_len;
-       state->stats.inc_packets++;
-       olen = orig_len;
-    }
-    state->stats.unc_bytes += orig_len;
-    state->stats.unc_packets++;
-
-    return olen;
-}
-
-static void
-z_comp_stats(arg, stats)
-    void *arg;
-    struct compstat *stats;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_int out;
-
-    *stats = state->stats;
-    stats->ratio = stats->unc_bytes;
-    out = stats->comp_bytes + stats->inc_bytes;
-    if (stats->ratio <= 0x7ffffff)
-       stats->ratio <<= 8;
-    else
-       out >>= 8;
-    if (out != 0)
-       stats->ratio /= out;
-}
-
-/*
- * Allocate space for a decompressor.
- */
-static void *
-z_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    struct deflate_state *state;
-    int w_size;
-
-    if (opt_len != CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return NULL;
-    w_size = DEFLATE_SIZE(options[2]);
-    if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-       return NULL;
-
-    MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
-          M_DEVBUF, M_NOWAIT);
-    if (state == NULL)
-       return NULL;
-
-    state->strm.next_out = NULL;
-    state->strm.zalloc = zalloc;
-    state->strm.zfree = zfree;
-    if (inflateInit2(&state->strm, -w_size) != Z_OK) {
-       FREE(state, M_DEVBUF);
-       return NULL;
-    }
-
-    state->w_size = w_size;
-    bzero(&state->stats, sizeof(state->stats));
-    return (void *) state;
-}
-
-static void
-z_decomp_free(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    inflateEnd(&state->strm);
-    FREE(state, M_DEVBUF);
-}
-
-static int
-z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
-    void *arg;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    if (opt_len < CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || DEFLATE_SIZE(options[2]) != state->w_size
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return 0;
-
-    state->seqno = 0;
-    state->unit = unit;
-    state->hdrlen = hdrlen;
-    state->debug = debug;
-    state->mru = mru;
-
-    inflateReset(&state->strm);
-
-    return 1;
-}
-
-static void
-z_decomp_reset(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    state->seqno = 0;
-    inflateReset(&state->strm);
-}
-
-/*
- * Decompress a Deflate-compressed packet.
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-z_decompress(arg, mi, mop)
-    void *arg;
-    struct mbuf *mi, **mop;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    struct mbuf *mo, *mo_head;
-    u_char *rptr, *wptr;
-    int rlen, olen, ospace;
-    int seq, i, flush, r, decode_proto;
-    u_char hdr[PPP_HDRLEN + DEFLATE_OVHD];
-
-    *mop = NULL;
-    rptr = mtod(mi, u_char *);
-    rlen = mi->m_len;
-    for (i = 0; i < PPP_HDRLEN + DEFLATE_OVHD; ++i) {
-       while (rlen <= 0) {
-           mi = mi->m_next;
-           if (mi == NULL)
-               return DECOMP_ERROR;
-           rptr = mtod(mi, u_char *);
-           rlen = mi->m_len;
-       }
-       hdr[i] = *rptr++;
-       --rlen;
-    }
-
-    /* Check the sequence number. */
-    seq = (hdr[PPP_HDRLEN] << 8) + hdr[PPP_HDRLEN+1];
-    if (seq != state->seqno) {
-       if (state->debug)
-           printf("z_decompress%d: bad seq # %d, expected %d\n",
-                  state->unit, seq, state->seqno);
-       return DECOMP_ERROR;
-    }
-    ++state->seqno;
-
-    /* Allocate an output mbuf. */
-    MGETHDR(mo, M_DONTWAIT, MT_DATA);
-    if (mo == NULL)
-       return DECOMP_ERROR;
-    mo_head = mo;
-    mo->m_len = 0;
-    mo->m_next = NULL;
-    MCLGET(mo, M_DONTWAIT);
-    ospace = M_TRAILINGSPACE(mo);
-    if (state->hdrlen + PPP_HDRLEN < ospace) {
-       mo->m_data += state->hdrlen;
-       ospace -= state->hdrlen;
-    }
-
-    /*
-     * Fill in the first part of the PPP header.  The protocol field
-     * comes from the decompressed data.
-     */
-    wptr = mtod(mo, u_char *);
-    wptr[0] = PPP_ADDRESS(hdr);
-    wptr[1] = PPP_CONTROL(hdr);
-    wptr[2] = 0;
-
-    /*
-     * Set up to call inflate.  We set avail_out to 1 initially so we can
-     * look at the first byte of the output and decide whether we have
-     * a 1-byte or 2-byte protocol field.
-     */
-    state->strm.next_in = rptr;
-    state->strm.avail_in = rlen;
-    mi = mi->m_next;
-    flush = (mi == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
-    rlen += PPP_HDRLEN + DEFLATE_OVHD;
-    state->strm.next_out = wptr + 3;
-    state->strm.avail_out = 1;
-    decode_proto = 1;
-    olen = PPP_HDRLEN;
-
-    /*
-     * Call inflate, supplying more input or output as needed.
-     */
-    for (;;) {
-       r = inflate(&state->strm, flush);
-       if (r != Z_OK) {
-#if !DEFLATE_DEBUG
-           if (state->debug)
-#endif
-               printf("z_decompress%d: inflate returned %d (%s)\n",
-                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-           m_freem(mo_head);
-           return DECOMP_FATALERROR;
-       }
-       if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
-           break;              /* all done */
-       if (state->strm.avail_in == 0 && mi != NULL) {
-           state->strm.next_in = mtod(mi, u_char *);
-           state->strm.avail_in = mi->m_len;
-           rlen += mi->m_len;
-           mi = mi->m_next;
-           if (mi == NULL)
-               flush = Z_PACKET_FLUSH;
-       }
-       if (state->strm.avail_out == 0) {
-           if (decode_proto) {
-               state->strm.avail_out = ospace - PPP_HDRLEN;
-               if ((wptr[3] & 1) == 0) {
-                   /* 2-byte protocol field */
-                   wptr[2] = wptr[3];
-                   --state->strm.next_out;
-                   ++state->strm.avail_out;
-                   --olen;
-               }
-               decode_proto = 0;
-           } else {
-               mo->m_len = ospace;
-               olen += ospace;
-               MGET(mo->m_next, M_DONTWAIT, MT_DATA);
-               mo = mo->m_next;
-               if (mo == NULL) {
-                   m_freem(mo_head);
-                   return DECOMP_ERROR;
-               }
-               MCLGET(mo, M_DONTWAIT);
-               state->strm.next_out = mtod(mo, u_char *);
-               state->strm.avail_out = ospace = M_TRAILINGSPACE(mo);
-           }
-       }
-    }
-    if (decode_proto) {
-       m_freem(mo_head);
-       return DECOMP_ERROR;
-    }
-    olen += (mo->m_len = ospace - state->strm.avail_out);
-#if DEFLATE_DEBUG
-    if (olen > state->mru + PPP_HDRLEN)
-       printf("ppp_deflate%d: exceeded mru (%d > %d)\n",
-              state->unit, olen, state->mru + PPP_HDRLEN);
-#endif
-
-    state->stats.unc_bytes += olen;
-    state->stats.unc_packets++;
-    state->stats.comp_bytes += rlen;
-    state->stats.comp_packets++;
-
-    *mop = mo_head;
-    return DECOMP_OK;
-}
-
-/*
- * Incompressible data has arrived - add it to the history.
- */
-static void
-z_incomp(arg, mi)
-    void *arg;
-    struct mbuf *mi;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_char *rptr;
-    int rlen, proto, r;
-
-    /*
-     * Check that the protocol is one we handle.
-     */
-    rptr = mtod(mi, u_char *);
-    proto = PPP_PROTOCOL(rptr);
-    if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
-       return;
-
-    ++state->seqno;
-
-    /*
-     * Iterate through the mbufs, adding the characters in them
-     * to the decompressor's history.  For the first mbuf, we start
-     * at the either the 1st or 2nd byte of the protocol field,
-     * depending on whether the protocol value is compressible.
-     */
-    rlen = mi->m_len;
-    state->strm.next_in = rptr + 3;
-    state->strm.avail_in = rlen - 3;
-    if (proto > 0xff) {
-       --state->strm.next_in;
-       ++state->strm.avail_in;
-    }
-    for (;;) {
-       r = inflateIncomp(&state->strm);
-       if (r != Z_OK) {
-           /* gak! */
-#if !DEFLATE_DEBUG
-           if (state->debug)
-#endif
-               printf("z_incomp%d: inflateIncomp returned %d (%s)\n",
-                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-           return;
-       }
-       mi = mi->m_next;
-       if (mi == NULL)
-           break;
-       state->strm.next_in = mtod(mi, u_char *);
-       state->strm.avail_in = mi->m_len;
-       rlen += mi->m_len;
-    }
-
-    /*
-     * Update stats.
-     */
-    state->stats.inc_bytes += rlen;
-    state->stats.inc_packets++;
-    state->stats.unc_bytes += rlen;
-    state->stats.unc_packets++;
-}
-
-#endif /* DO_DEFLATE */
diff --git a/netbsd-1.1/ppp_tty.c b/netbsd-1.1/ppp_tty.c
deleted file mode 100644 (file)
index d24b990..0000000
+++ /dev/null
@@ -1,1091 +0,0 @@
-/*     $Id: ppp_tty.c,v 1.5 2002/12/06 12:03:44 paulus Exp $   */
-
-/*
- * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
- *            tty devices.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a "collision" if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- */
-
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/mbuf.h>
-#include <sys/dkstat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/tty.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/vnode.h>
-#include <sys/systm.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-
-#ifdef VJC
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <net/slcompress.h>
-#endif
-
-#ifdef PPP_FILTER
-#include <net/bpf.h>
-#endif
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/if_pppvar.h>
-
-int    pppopen __P((dev_t dev, struct tty *tp));
-int    pppclose __P((struct tty *tp, int flag));
-int    pppread __P((struct tty *tp, struct uio *uio, int flag));
-int    pppwrite __P((struct tty *tp, struct uio *uio, int flag));
-int    ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data, int flag,
-                      struct proc *));
-int    pppinput __P((int c, struct tty *tp));
-int    pppstart __P((struct tty *tp, int));
-
-static u_int16_t pppfcs __P((u_int16_t fcs, u_char *cp, int len));
-static void    pppasyncstart __P((struct ppp_softc *));
-static void    pppasyncctlp __P((struct ppp_softc *));
-static void    pppasyncrelinq __P((struct ppp_softc *));
-static void    ppp_timeout __P((void *));
-static void    pppgetm __P((struct ppp_softc *sc));
-static void    pppdumpb __P((u_char *b, int l));
-static void    ppplogchar __P((struct ppp_softc *, int));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m)        ((m)->m_flags & M_EXT)
-
-#define M_DATASTART(m) \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
-           (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
-           (m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
-
-/*
- * Does c need to be escaped?
- */
-#define ESCAPE_P(c)    (sc->sc_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F)))
-
-/*
- * Procedures for using an async tty interface for PPP.
- */
-
-/* This is a NetBSD-1.0 or later kernel. */
-#define CCOUNT(q)      ((q)->c_cc)
-
-#define PPP_LOWAT      100     /* Process more output when < LOWAT on queue */
-#define        PPP_HIWAT       400     /* Don't start a new packet if HIWAT on que */
-
-/*
- * Line specific open routine for async tty devices.
- * Attach the given tty to the first available ppp unit.
- * Called from device open routine or ttioctl.
- */
-/* ARGSUSED */
-int
-pppopen(dev, tp)
-    dev_t dev;
-    register struct tty *tp;
-{
-    struct proc *p = curproc;          /* XXX */
-    register struct ppp_softc *sc;
-    int error, s;
-
-    if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-       return (error);
-
-    s = spltty();
-
-    if (tp->t_line == PPPDISC) {
-       sc = (struct ppp_softc *) tp->t_sc;
-       if (sc != NULL && sc->sc_devp == (void *) tp) {
-           splx(s);
-           return (0);
-       }
-    }
-
-    if ((sc = pppalloc(p->p_pid)) == NULL) {
-       splx(s);
-       return ENXIO;
-    }
-
-    if (sc->sc_relinq)
-       (*sc->sc_relinq)(sc);   /* get previous owner to relinquish the unit */
-
-    sc->sc_ilen = 0;
-    sc->sc_m = NULL;
-    bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-    sc->sc_asyncmap[0] = 0xffffffff;
-    sc->sc_asyncmap[3] = 0x60000000;
-    sc->sc_rasyncmap = 0;
-    sc->sc_devp = (void *) tp;
-    sc->sc_start = pppasyncstart;
-    sc->sc_ctlp = pppasyncctlp;
-    sc->sc_relinq = pppasyncrelinq;
-    sc->sc_outm = NULL;
-    pppgetm(sc);
-    sc->sc_if.if_flags |= IFF_RUNNING;
-    sc->sc_if.if_baudrate = tp->t_ospeed;
-
-    tp->t_sc = (caddr_t) sc;
-    ttyflush(tp, FREAD | FWRITE);
-
-    splx(s);
-    return (0);
-}
-
-/*
- * Line specific close routine, called from device close routine
- * and from ttioctl.
- * Detach the tty from the ppp unit.
- * Mimics part of ttyclose().
- */
-int
-pppclose(tp, flag)
-    struct tty *tp;
-    int flag;
-{
-    register struct ppp_softc *sc;
-    int s;
-
-    s = spltty();
-    ttyflush(tp, FREAD|FWRITE);
-    tp->t_line = 0;
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc != NULL) {
-       tp->t_sc = NULL;
-       if (tp == (struct tty *) sc->sc_devp) {
-           pppasyncrelinq(sc);
-           pppdealloc(sc);
-       }
-    }
-    splx(s);
-    return 0;
-}
-
-/*
- * Relinquish the interface unit to another device.
- */
-static void
-pppasyncrelinq(sc)
-    struct ppp_softc *sc;
-{
-    int s;
-
-    s = spltty();
-    if (sc->sc_outm) {
-       m_freem(sc->sc_outm);
-       sc->sc_outm = NULL;
-    }
-    if (sc->sc_m) {
-       m_freem(sc->sc_m);
-       sc->sc_m = NULL;
-    }
-    if (sc->sc_flags & SC_TIMEOUT) {
-       untimeout(ppp_timeout, (void *) sc);
-       sc->sc_flags &= ~SC_TIMEOUT;
-    }
-    splx(s);
-}
-
-/*
- * Line specific (tty) read routine.
- */
-int
-pppread(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0;
-    register int s;
-    int error = 0;
-
-    if (sc == NULL)
-       return 0;
-    /*
-     * Loop waiting for input, checking that nothing disasterous
-     * happens in the meantime.
-     */
-    s = spltty();
-    for (;;) {
-       if (tp != (struct tty *) sc->sc_devp || tp->t_line != PPPDISC) {
-           splx(s);
-           return 0;
-       }
-       if (sc->sc_inq.ifq_head != NULL)
-           break;
-       if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0
-           && (tp->t_state & TS_ISOPEN)) {
-           splx(s);
-           return 0;           /* end of file */
-       }
-       if (tp->t_state & TS_ASYNC || flag & IO_NDELAY) {
-           splx(s);
-           return (EWOULDBLOCK);
-       }
-       error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, ttyin, 0);
-       if (error) {
-           splx(s);
-           return error;
-       }
-    }
-
-    /* Pull place-holder byte out of canonical queue */
-    getc(&tp->t_canq);
-
-    /* Get the packet from the input queue */
-    IF_DEQUEUE(&sc->sc_inq, m0);
-    splx(s);
-
-    for (m = m0; m && uio->uio_resid; m = m->m_next)
-       if ((error = uiomove(mtod(m, u_char *), m->m_len, uio)) != 0)
-           break;
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * Line specific (tty) write routine.
- */
-int
-pppwrite(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0, **mp;
-    struct sockaddr dst;
-    int len, error;
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       return 0;               /* wrote 0 bytes */
-    if (tp->t_line != PPPDISC)
-       return (EINVAL);
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return EIO;
-    if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HDRLEN ||
-       uio->uio_resid < PPP_HDRLEN)
-       return (EMSGSIZE);
-    for (mp = &m0; uio->uio_resid; mp = &m->m_next) {
-       MGET(m, M_WAIT, MT_DATA);
-       if ((*mp = m) == NULL) {
-           m_freem(m0);
-           return (ENOBUFS);
-       }
-       m->m_len = 0;
-       if (uio->uio_resid >= MCLBYTES / 2)
-           MCLGET(m, M_DONTWAIT);
-       len = M_TRAILINGSPACE(m);
-       if (len > uio->uio_resid)
-           len = uio->uio_resid;
-       if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) {
-           m_freem(m0);
-           return (error);
-       }
-       m->m_len = len;
-    }
-    dst.sa_family = AF_UNSPEC;
-    bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN);
-    m0->m_data += PPP_HDRLEN;
-    m0->m_len -= PPP_HDRLEN;
-    return (pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0));
-}
-
-/*
- * Line specific (tty) ioctl routine.
- * This discipline requires that tty device drivers call
- * the line specific l_ioctl routine from their ioctl routines.
- */
-/* ARGSUSED */
-int
-ppptioctl(tp, cmd, data, flag, p)
-    struct tty *tp;
-    u_long cmd;
-    caddr_t data;
-    int flag;
-    struct proc *p;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-    int error, s;
-
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return -1;
-
-    error = 0;
-    switch (cmd) {
-    case PPPIOCSASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_asyncmap[0] = *(u_int *)data;
-       break;
-
-    case PPPIOCGASYNCMAP:
-       *(u_int *)data = sc->sc_asyncmap[0];
-       break;
-
-    case PPPIOCSRASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_rasyncmap = *(u_int *)data;
-       break;
-
-    case PPPIOCGRASYNCMAP:
-       *(u_int *)data = sc->sc_rasyncmap;
-       break;
-
-    case PPPIOCSXASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       s = spltty();
-       bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-       sc->sc_asyncmap[1] = 0;             /* mustn't escape 0x20 - 0x3f */
-       sc->sc_asyncmap[2] &= ~0x40000000;  /* mustn't escape 0x5e */
-       sc->sc_asyncmap[3] |= 0x60000000;   /* must escape 0x7d, 0x7e */
-       splx(s);
-       break;
-
-    case PPPIOCGXASYNCMAP:
-       bcopy(sc->sc_asyncmap, data, sizeof(sc->sc_asyncmap));
-       break;
-
-    default:
-       error = pppioctl(sc, cmd, data, flag, p);
-       if (error == 0 && cmd == PPPIOCSMRU)
-           pppgetm(sc);
-    }
-
-    return error;
-}
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static u_int16_t fcstab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-/*
- * Calculate a new FCS given the current FCS and the new data.
- */
-static u_int16_t
-pppfcs(fcs, cp, len)
-    register u_int16_t fcs;
-    register u_char *cp;
-    register int len;
-{
-    while (len--)
-       fcs = PPP_FCS(fcs, *cp++);
-    return (fcs);
-}
-
-/*
- * This gets called at splsoftnet from if_ppp.c at various times
- * when there is data ready to be sent.
- */
-static void
-pppasyncstart(sc)
-    register struct ppp_softc *sc;
-{
-    register struct tty *tp = (struct tty *) sc->sc_devp;
-    register struct mbuf *m;
-    register int len;
-    register u_char *start, *stop, *cp;
-    int n, ndone, done, idle;
-    struct mbuf *m2;
-    int s;
-
-    idle = 0;
-    while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-       /*
-        * See if we have an existing packet partly sent.
-        * If not, get a new packet and start sending it.
-        */
-       m = sc->sc_outm;
-       if (m == NULL) {
-           /*
-            * Get another packet to be sent.
-            */
-           m = ppp_dequeue(sc);
-           if (m == NULL) {
-               idle = 1;
-               break;
-           }
-
-           /*
-            * The extra PPP_FLAG will start up a new packet, and thus
-            * will flush any accumulated garbage.  We do this whenever
-            * the line may have been idle for some time.
-            */
-           if (CCOUNT(&tp->t_outq) == 0) {
-               ++sc->sc_stats.ppp_obytes;
-               (void) putc(PPP_FLAG, &tp->t_outq);
-           }
-
-           /* Calculate the FCS for the first mbuf's worth. */
-           sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
-           sc->sc_if.if_lastchange = time;
-       }
-
-       for (;;) {
-           start = mtod(m, u_char *);
-           len = m->m_len;
-           stop = start + len;
-           while (len > 0) {
-               /*
-                * Find out how many bytes in the string we can
-                * handle without doing something special.
-                */
-               for (cp = start; cp < stop; cp++)
-                   if (ESCAPE_P(*cp))
-                       break;
-               n = cp - start;
-               if (n) {
-                   /* NetBSD (0.9 or later), 4.3-Reno or similar. */
-                   ndone = n - b_to_q(start, n, &tp->t_outq);
-                   len -= ndone;
-                   start += ndone;
-                   sc->sc_stats.ppp_obytes += ndone;
-
-                   if (ndone < n)
-                       break;  /* packet doesn't fit */
-               }
-               /*
-                * If there are characters left in the mbuf,
-                * the first one must be special.
-                * Put it out in a different form.
-                */
-               if (len) {
-                   s = spltty();
-                   if (putc(PPP_ESCAPE, &tp->t_outq)) {
-                       splx(s);
-                       break;
-                   }
-                   if (putc(*start ^ PPP_TRANS, &tp->t_outq)) {
-                       (void) unputc(&tp->t_outq);
-                       splx(s);
-                       break;
-                   }
-                   splx(s);
-                   sc->sc_stats.ppp_obytes += 2;
-                   start++;
-                   len--;
-               }
-           }
-
-           /*
-            * If we didn't empty this mbuf, remember where we're up to.
-            * If we emptied the last mbuf, try to add the FCS and closing
-            * flag, and if we can't, leave sc_outm pointing to m, but with
-            * m->m_len == 0, to remind us to output the FCS and flag later.
-            */
-           done = len == 0;
-           if (done && m->m_next == NULL) {
-               u_char *p, *q;
-               int c;
-               u_char endseq[8];
-
-               /*
-                * We may have to escape the bytes in the FCS.
-                */
-               p = endseq;
-               c = ~sc->sc_outfcs & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               c = (~sc->sc_outfcs >> 8) & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               *p++ = PPP_FLAG;
-
-               /*
-                * Try to output the FCS and flag.  If the bytes
-                * don't all fit, back out.
-                */
-               s = spltty();
-               for (q = endseq; q < p; ++q)
-                   if (putc(*q, &tp->t_outq)) {
-                       done = 0;
-                       for (; q > endseq; --q)
-                           unputc(&tp->t_outq);
-                       break;
-                   }
-               splx(s);
-               if (done)
-                   sc->sc_stats.ppp_obytes += q - endseq;
-           }
-
-           if (!done) {
-               /* remember where we got to */
-               m->m_data = start;
-               m->m_len = len;
-               break;
-           }
-
-           /* Finished with this mbuf; free it and move on. */
-           MFREE(m, m2);
-           m = m2;
-           if (m == NULL) {
-               /* Finished a packet */
-               break;
-           }
-           sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len);
-       }
-
-       /*
-        * If m == NULL, we have finished a packet.
-        * If m != NULL, we've either done as much work this time
-        * as we need to, or else we've filled up the output queue.
-        */
-       sc->sc_outm = m;
-       if (m)
-           break;
-    }
-
-    /* Call pppstart to start output again if necessary. */
-    s = spltty();
-    pppstart(tp, 0);
-
-    /*
-     * This timeout is needed for operation on a pseudo-tty,
-     * because the pty code doesn't call pppstart after it has
-     * drained the t_outq.
-     */
-    if (!idle && (sc->sc_flags & SC_TIMEOUT) == 0) {
-       timeout(ppp_timeout, (void *) sc, 1);
-       sc->sc_flags |= SC_TIMEOUT;
-    }
-
-    splx(s);
-}
-
-/*
- * This gets called when a received packet is placed on
- * the inq, at splsoftnet.
- */
-static void
-pppasyncctlp(sc)
-    struct ppp_softc *sc;
-{
-    struct tty *tp;
-    int s;
-
-    /* Put a placeholder byte in canq for ttselect()/ttnread(). */
-    s = spltty();
-    tp = (struct tty *) sc->sc_devp;
-    putc(0, &tp->t_canq);
-    ttwakeup(tp);
-    splx(s);
-}
-
-/*
- * Start output on async tty interface.  If the transmit queue
- * has drained sufficiently, arrange for pppasyncstart to be
- * called later at splsoftnet.
- * Called at spltty or higher.
- */
-int
-pppstart(tp, force)
-    register struct tty *tp;
-    int force;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-
-    /*
-     * If there is stuff in the output queue, send it now.
-     * We are being called in lieu of ttstart and must do what it would.
-     */
-    if (tp->t_oproc != NULL)
-       (*tp->t_oproc)(tp);
-
-    /*
-     * If the transmit queue has drained and the tty has not hung up
-     * or been disconnected from the ppp unit, then tell if_ppp.c that
-     * we need more output.
-     */
-    if (CCOUNT(&tp->t_outq) >= PPP_LOWAT && !force)
-       return 0;
-    if (!((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       && sc != NULL && tp == (struct tty *) sc->sc_devp) {
-       ppp_restart(sc);
-    }
-
-    return 0;
-}
-
-/*
- * Timeout routine - try to start some more output.
- */
-static void
-ppp_timeout(x)
-    void *x;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) x;
-    struct tty *tp = (struct tty *) sc->sc_devp;
-    int s;
-
-    s = spltty();
-    sc->sc_flags &= ~SC_TIMEOUT;
-    pppstart(tp, 1);
-    splx(s);
-}
-
-/*
- * Allocate enough mbuf to handle current MRU.
- */
-static void
-pppgetm(sc)
-    register struct ppp_softc *sc;
-{
-    struct mbuf *m, **mp;
-    int len;
-
-    mp = &sc->sc_m;
-    for (len = sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){
-       if ((m = *mp) == NULL) {
-           MGETHDR(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL)
-               break;
-           *mp = m;
-           MCLGET(m, M_DONTWAIT);
-       }
-       len -= M_DATASIZE(m);
-       mp = &m->m_next;
-    }
-}
-
-/*
- * tty interface receiver interrupt.
- */
-static unsigned paritytab[8] = {
-    0x96696996, 0x69969669, 0x69969669, 0x96696996,
-    0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-
-int
-pppinput(c, tp)
-    int c;
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    struct mbuf *m;
-    int ilen, s;
-
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return 0;
-
-    ++tk_nin;
-    ++sc->sc_stats.ppp_ibytes;
-
-    if (c & TTY_FE) {
-       /* framing error or overrun on this char - abort packet */
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: bad char %x\n", sc->sc_if.if_unit, c);
-       goto flush;
-    }
-
-    c &= 0xff;
-
-    /*
-     * Handle software flow control of output.
-     */
-    if (tp->t_iflag & IXON) {
-       if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
-           if ((tp->t_state & TS_TTSTOP) == 0) {
-               tp->t_state |= TS_TTSTOP;
-               (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
-           }
-           return 0;
-       }
-       if (c == tp->t_cc[VSTART] && tp->t_cc[VSTART] != _POSIX_VDISABLE) {
-           tp->t_state &= ~TS_TTSTOP;
-           if (tp->t_oproc != NULL)
-               (*tp->t_oproc)(tp);
-           return 0;
-       }
-    }
-
-    s = spltty();
-    if (c & 0x80)
-       sc->sc_flags |= SC_RCV_B7_1;
-    else
-       sc->sc_flags |= SC_RCV_B7_0;
-    if (paritytab[c >> 5] & (1 << (c & 0x1F)))
-       sc->sc_flags |= SC_RCV_ODDP;
-    else
-       sc->sc_flags |= SC_RCV_EVNP;
-    splx(s);
-
-    if (sc->sc_flags & SC_LOG_RAWIN)
-       ppplogchar(sc, c);
-
-    if (c == PPP_FLAG) {
-       ilen = sc->sc_ilen;
-       sc->sc_ilen = 0;
-
-       if (sc->sc_rawin_count > 0) 
-           ppplogchar(sc, -1);
-
-       /*
-        * If SC_ESCAPED is set, then we've seen the packet
-        * abort sequence "}~".
-        */
-       if (sc->sc_flags & (SC_FLUSH | SC_ESCAPED)
-           || (ilen > 0 && sc->sc_fcs != PPP_GOODFCS)) {
-           s = spltty();
-           sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
-           if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: bad fcs %x, pkt len %d\n",
-                          sc->sc_if.if_unit, sc->sc_fcs, ilen);
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-           } else
-               sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
-           splx(s);
-           return 0;
-       }
-
-       if (ilen < PPP_HDRLEN + PPP_FCSLEN) {
-           if (ilen) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: too short (%d)\n", sc->sc_if.if_unit, ilen);
-               s = spltty();
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-               sc->sc_flags |= SC_PKTLOST;
-               splx(s);
-           }
-           return 0;
-       }
-
-       /*
-        * Remove FCS trailer.  Somewhat painful...
-        */
-       ilen -= 2;
-       if (--sc->sc_mc->m_len == 0) {
-           for (m = sc->sc_m; m->m_next != sc->sc_mc; m = m->m_next)
-               ;
-           sc->sc_mc = m;
-       }
-       sc->sc_mc->m_len--;
-
-       /* excise this mbuf chain */
-       m = sc->sc_m;
-       sc->sc_m = sc->sc_mc->m_next;
-       sc->sc_mc->m_next = NULL;
-
-       ppppktin(sc, m, sc->sc_flags & SC_PKTLOST);
-       if (sc->sc_flags & SC_PKTLOST) {
-           s = spltty();
-           sc->sc_flags &= ~SC_PKTLOST;
-           splx(s);
-       }
-
-       pppgetm(sc);
-       return 0;
-    }
-
-    if (sc->sc_flags & SC_FLUSH) {
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-       return 0;
-    }
-
-    if (c < 0x20 && (sc->sc_rasyncmap & (1 << c)))
-       return 0;
-
-    s = spltty();
-    if (sc->sc_flags & SC_ESCAPED) {
-       sc->sc_flags &= ~SC_ESCAPED;
-       c ^= PPP_TRANS;
-    } else if (c == PPP_ESCAPE) {
-       sc->sc_flags |= SC_ESCAPED;
-       splx(s);
-       return 0;
-    }
-    splx(s);
-
-    /*
-     * Initialize buffer on first octet received.
-     * First octet could be address or protocol (when compressing
-     * address/control).
-     * Second octet is control.
-     * Third octet is first or second (when compressing protocol)
-     * octet of protocol.
-     * Fourth octet is second octet of protocol.
-     */
-    if (sc->sc_ilen == 0) {
-       /* reset the first input mbuf */
-       if (sc->sc_m == NULL) {
-           pppgetm(sc);
-           if (sc->sc_m == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit);
-               goto flush;
-           }
-       }
-       m = sc->sc_m;
-       m->m_len = 0;
-       m->m_data = M_DATASTART(sc->sc_m);
-       sc->sc_mc = m;
-       sc->sc_mp = mtod(m, char *);
-       sc->sc_fcs = PPP_INITFCS;
-       if (c != PPP_ALLSTATIONS) {
-           if (sc->sc_flags & SC_REJ_COMP_AC) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: garbage received: 0x%x (need 0xFF)\n",
-                          sc->sc_if.if_unit, c);
-               goto flush;
-           }
-           *sc->sc_mp++ = PPP_ALLSTATIONS;
-           *sc->sc_mp++ = PPP_UI;
-           sc->sc_ilen += 2;
-           m->m_len += 2;
-       }
-    }
-    if (sc->sc_ilen == 1 && c != PPP_UI) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: missing UI (0x3), got 0x%x\n",
-                  sc->sc_if.if_unit, c);
-       goto flush;
-    }
-    if (sc->sc_ilen == 2 && (c & 1) == 1) {
-       /* a compressed protocol */
-       *sc->sc_mp++ = 0;
-       sc->sc_ilen++;
-       sc->sc_mc->m_len++;
-    }
-    if (sc->sc_ilen == 3 && (c & 1) == 0) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit,
-                  (sc->sc_mp[-1] << 8) + c);
-       goto flush;
-    }
-
-    /* packet beyond configured mru? */
-    if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: packet too big\n", sc->sc_if.if_unit);
-       goto flush;
-    }
-
-    /* is this mbuf full? */
-    m = sc->sc_mc;
-    if (M_TRAILINGSPACE(m) <= 0) {
-       if (m->m_next == NULL) {
-           pppgetm(sc);
-           if (m->m_next == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit);
-               goto flush;
-           }
-       }
-       sc->sc_mc = m = m->m_next;
-       m->m_len = 0;
-       m->m_data = M_DATASTART(m);
-       sc->sc_mp = mtod(m, char *);
-    }
-
-    ++m->m_len;
-    *sc->sc_mp++ = c;
-    sc->sc_fcs = PPP_FCS(sc->sc_fcs, c);
-    return 0;
-
- flush:
-    if (!(sc->sc_flags & SC_FLUSH)) {
-       s = spltty();
-       sc->sc_if.if_ierrors++;
-       sc->sc_stats.ppp_ierrors++;
-       sc->sc_flags |= SC_FLUSH;
-       splx(s);
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-    }
-    return 0;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-ppplogchar(sc, c)
-    struct ppp_softc *sc;
-    int c;
-{
-    if (c >= 0)
-       sc->sc_rawin[sc->sc_rawin_count++] = c;
-    if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
-       || (c < 0 && sc->sc_rawin_count > 0)) {
-       printf("ppp%d input: ", sc->sc_if.if_unit);
-       pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
-       sc->sc_rawin_count = 0;
-    }
-}
-
-static void
-pppdumpb(b, l)
-    u_char *b;
-    int l;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-
-    while (l--) {
-       if (bp >= buf + sizeof(buf) - 3) {
-           *bp++ = '>';
-           break;
-       }
-       *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*b++ & 0xf];
-       *bp++ = ' ';
-    }
-
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/netbsd-1.1/slcompress.c b/netbsd-1.1/slcompress.c
deleted file mode 100644 (file)
index c46c57f..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-/*     $Id: slcompress.c,v 1.3 1996/05/24 07:04:47 paulus Exp $        */
-
-/*
- * Copyright (c) 1989, 1993, 1994
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)slcompress.c        8.2 (Berkeley) 4/16/94
- */
-
-/*
- * Routines to compress and uncompess tcp packets (for transmission
- * over low speed serial lines.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- */
-
-#include <sys/param.h>
-#include <sys/mbuf.h>
-#include <sys/systm.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include <net/slcompress.h>
-
-#ifndef SL_NO_STATS
-#define INCR(counter) ++comp->counter;
-#else
-#define INCR(counter)
-#endif
-
-#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
-#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
-#ifndef _KERNEL
-#define ovbcopy bcopy
-#endif
-
-void
-sl_compress_init(comp, max_state)
-       struct slcompress *comp;
-       int max_state;
-{
-       register u_int i;
-       register struct cstate *tstate = comp->tstate;
-
-       if (max_state == -1) {
-               max_state = MAX_STATES - 1;
-               bzero((char *)comp, sizeof(*comp));
-       } else {
-               /* Don't reset statistics */
-               bzero((char *)comp->tstate, sizeof(comp->tstate));
-               bzero((char *)comp->rstate, sizeof(comp->rstate));
-       }
-       for (i = max_state; i > 0; --i) {
-               tstate[i].cs_id = i;
-               tstate[i].cs_next = &tstate[i - 1];
-       }
-       tstate[0].cs_next = &tstate[max_state];
-       tstate[0].cs_id = 0;
-       comp->last_cs = &tstate[0];
-       comp->last_recv = 255;
-       comp->last_xmit = 255;
-       comp->flags = SLF_TOSS;
-}
-
-
-/* ENCODE encodes a number that is known to be non-zero.  ENCODEZ
- * checks for zero (since zero has to be encoded in the long, 3 byte
- * form).
- */
-#define ENCODE(n) { \
-       if ((u_int16_t)(n) >= 256) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-#define ENCODEZ(n) { \
-       if ((u_int16_t)(n) >= 256 || (u_int16_t)(n) == 0) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-
-#define DECODEL(f) { \
-       if (*cp == 0) {\
-               (f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htonl(ntohl(f) + (u_int32_t)*cp++); \
-       } \
-}
-
-#define DECODES(f) { \
-       if (*cp == 0) {\
-               (f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htons(ntohs(f) + (u_int32_t)*cp++); \
-       } \
-}
-
-#define DECODEU(f) { \
-       if (*cp == 0) {\
-               (f) = htons((cp[1] << 8) | cp[2]); \
-               cp += 3; \
-       } else { \
-               (f) = htons((u_int32_t)*cp++); \
-       } \
-}
-
-u_int
-sl_compress_tcp(m, ip, comp, compress_cid)
-       struct mbuf *m;
-       register struct ip *ip;
-       struct slcompress *comp;
-       int compress_cid;
-{
-       register struct cstate *cs = comp->last_cs->cs_next;
-       register u_int hlen = ip->ip_hl;
-       register struct tcphdr *oth;
-       register struct tcphdr *th;
-       register u_int deltaS, deltaA;
-       register u_int changes = 0;
-       u_char new_seq[16];
-       register u_char *cp = new_seq;
-
-       /*
-        * Bail if this is an IP fragment or if the TCP packet isn't
-        * `compressible' (i.e., ACK isn't set or some other control bit is
-        * set).  (We assume that the caller has already made sure the
-        * packet is IP proto TCP).
-        */
-       if ((ip->ip_off & htons(0x3fff)) || m->m_len < 40)
-               return (TYPE_IP);
-
-       th = (struct tcphdr *)&((int32_t *)ip)[hlen];
-       if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
-               return (TYPE_IP);
-       /*
-        * Packet is compressible -- we're going to send either a
-        * COMPRESSED_TCP or UNCOMPRESSED_TCP packet.  Either way we need
-        * to locate (or create) the connection state.  Special case the
-        * most recently used connection since it's most likely to be used
-        * again & we don't have to do any reordering if it's used.
-        */
-       INCR(sls_packets)
-       if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
-           ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
-           *(int32_t *)th != ((int32_t *)&cs->cs_ip)[cs->cs_ip.ip_hl]) {
-               /*
-                * Wasn't the first -- search for it.
-                *
-                * States are kept in a circularly linked list with
-                * last_cs pointing to the end of the list.  The
-                * list is kept in lru order by moving a state to the
-                * head of the list whenever it is referenced.  Since
-                * the list is short and, empirically, the connection
-                * we want is almost always near the front, we locate
-                * states via linear search.  If we don't find a state
-                * for the datagram, the oldest state is (re-)used.
-                */
-               register struct cstate *lcs;
-               register struct cstate *lastcs = comp->last_cs;
-
-               do {
-                       lcs = cs; cs = cs->cs_next;
-                       INCR(sls_searches)
-                       if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
-                           && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
-                           && *(int32_t *)th ==
-                           ((int32_t *)&cs->cs_ip)[cs->cs_ip.ip_hl])
-                               goto found;
-               } while (cs != lastcs);
-
-               /*
-                * Didn't find it -- re-use oldest cstate.  Send an
-                * uncompressed packet that tells the other side what
-                * connection number we're using for this conversation.
-                * Note that since the state list is circular, the oldest
-                * state points to the newest and we only need to set
-                * last_cs to update the lru linkage.
-                */
-               INCR(sls_misses)
-               comp->last_cs = lcs;
-               hlen += th->th_off;
-               hlen <<= 2;
-               goto uncompressed;
-
-       found:
-               /*
-                * Found it -- move to the front on the connection list.
-                */
-               if (cs == lastcs)
-                       comp->last_cs = lcs;
-               else {
-                       lcs->cs_next = cs->cs_next;
-                       cs->cs_next = lastcs->cs_next;
-                       lastcs->cs_next = cs;
-               }
-       }
-
-       /*
-        * Make sure that only what we expect to change changed. The first
-        * line of the `if' checks the IP protocol version, header length &
-        * type of service.  The 2nd line checks the "Don't fragment" bit.
-        * The 3rd line checks the time-to-live and protocol (the protocol
-        * check is unnecessary but costless).  The 4th line checks the TCP
-        * header length.  The 5th line checks IP options, if any.  The 6th
-        * line checks TCP options, if any.  If any of these things are
-        * different between the previous & current datagram, we send the
-        * current datagram `uncompressed'.
-        */
-       oth = (struct tcphdr *)&((int32_t *)&cs->cs_ip)[hlen];
-       deltaS = hlen;
-       hlen += th->th_off;
-       hlen <<= 2;
-
-       if (((u_int16_t *)ip)[0] != ((u_int16_t *)&cs->cs_ip)[0] ||
-           ((u_int16_t *)ip)[3] != ((u_int16_t *)&cs->cs_ip)[3] ||
-           ((u_int16_t *)ip)[4] != ((u_int16_t *)&cs->cs_ip)[4] ||
-           th->th_off != oth->th_off ||
-           (deltaS > 5 &&
-            BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
-           (th->th_off > 5 &&
-            BCMP(th + 1, oth + 1, (th->th_off - 5) << 2)))
-               goto uncompressed;
-
-       /*
-        * Figure out which of the changing fields changed.  The
-        * receiver expects changes in the order: urgent, window,
-        * ack, seq (the order minimizes the number of temporaries
-        * needed in this section of code).
-        */
-       if (th->th_flags & TH_URG) {
-               deltaS = ntohs(th->th_urp);
-               ENCODEZ(deltaS);
-               changes |= NEW_U;
-       } else if (th->th_urp != oth->th_urp)
-               /* argh! URG not set but urp changed -- a sensible
-                * implementation should never do this but RFC793
-                * doesn't prohibit the change so we have to deal
-                * with it. */
-                goto uncompressed;
-
-       deltaS = (u_int16_t)(ntohs(th->th_win) - ntohs(oth->th_win));
-       if (deltaS) {
-               ENCODE(deltaS);
-               changes |= NEW_W;
-       }
-
-       deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack);
-       if (deltaA) {
-               if (deltaA > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaA);
-               changes |= NEW_A;
-       }
-
-       deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq);
-       if (deltaS) {
-               if (deltaS > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaS);
-               changes |= NEW_S;
-       }
-
-       switch(changes) {
-
-       case 0:
-               /*
-                * Nothing changed. If this packet contains data and the
-                * last one didn't, this is probably a data packet following
-                * an ack (normal on an interactive connection) and we send
-                * it compressed.  Otherwise it's probably a retransmit,
-                * retransmitted ack or window probe.  Send it uncompressed
-                * in case the other side missed the compressed version.
-                */
-               if (ip->ip_len != cs->cs_ip.ip_len &&
-                   ntohs(cs->cs_ip.ip_len) == hlen)
-                       break;
-
-               /* (fall through) */
-
-       case SPECIAL_I:
-       case SPECIAL_D:
-               /*
-                * actual changes match one of our special case encodings --
-                * send packet uncompressed.
-                */
-               goto uncompressed;
-
-       case NEW_S|NEW_A:
-               if (deltaS == deltaA &&
-                   deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for echoed terminal traffic */
-                       changes = SPECIAL_I;
-                       cp = new_seq;
-               }
-               break;
-
-       case NEW_S:
-               if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for data xfer */
-                       changes = SPECIAL_D;
-                       cp = new_seq;
-               }
-               break;
-       }
-
-       deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
-       if (deltaS != 1) {
-               ENCODEZ(deltaS);
-               changes |= NEW_I;
-       }
-       if (th->th_flags & TH_PUSH)
-               changes |= TCP_PUSH_BIT;
-       /*
-        * Grab the cksum before we overwrite it below.  Then update our
-        * state with this packet's header.
-        */
-       deltaA = ntohs(th->th_sum);
-       BCOPY(ip, &cs->cs_ip, hlen);
-
-       /*
-        * We want to use the original packet as our compressed packet.
-        * (cp - new_seq) is the number of bytes we need for compressed
-        * sequence numbers.  In addition we need one byte for the change
-        * mask, one for the connection id and two for the tcp checksum.
-        * So, (cp - new_seq) + 4 bytes of header are needed.  hlen is how
-        * many bytes of the original packet to toss so subtract the two to
-        * get the new packet size.
-        */
-       deltaS = cp - new_seq;
-       cp = (u_char *)ip;
-       if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
-               comp->last_xmit = cs->cs_id;
-               hlen -= deltaS + 4;
-               cp += hlen;
-               *cp++ = changes | NEW_C;
-               *cp++ = cs->cs_id;
-       } else {
-               hlen -= deltaS + 3;
-               cp += hlen;
-               *cp++ = changes;
-       }
-       m->m_len -= hlen;
-       m->m_data += hlen;
-       *cp++ = deltaA >> 8;
-       *cp++ = deltaA;
-       BCOPY(new_seq, cp, deltaS);
-       INCR(sls_compressed)
-       return (TYPE_COMPRESSED_TCP);
-
-       /*
-        * Update connection state cs & send uncompressed packet ('uncompressed'
-        * means a regular ip/tcp packet but with the 'conversation id' we hope
-        * to use on future compressed packets in the protocol field).
-        */
-uncompressed:
-       BCOPY(ip, &cs->cs_ip, hlen);
-       ip->ip_p = cs->cs_id;
-       comp->last_xmit = cs->cs_id;
-       return (TYPE_UNCOMPRESSED_TCP);
-}
-
-
-int
-sl_uncompress_tcp(bufp, len, type, comp)
-       u_char **bufp;
-       int len;
-       u_int type;
-       struct slcompress *comp;
-{
-       u_char *hdr, *cp;
-       int hlen, vjlen;
-
-       cp = bufp? *bufp: NULL;
-       vjlen = sl_uncompress_tcp_core(cp, len, len, type, comp, &hdr, &hlen);
-       if (vjlen < 0)
-               return (0);     /* error */
-       if (vjlen == 0)
-               return (len);   /* was uncompressed already */
-
-       cp += vjlen;
-       len -= vjlen;
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  If we're not aligned on a 4-byte boundary, copy the
-        * data down so the ip & tcp headers will be aligned.  Then back up
-        * cp by the tcp/ip header length to make room for the reconstructed
-        * header (we assume the packet we were handed has enough space to
-        * prepend 128 bytes of header).
-        */
-       if ((long)cp & 3) {
-               if (len > 0)
-                       (void) ovbcopy(cp, (caddr_t)((long)cp &~ 3), len);
-               cp = (u_char *)((long)cp &~ 3);
-       }
-       cp -= hlen;
-       len += hlen;
-       BCOPY(hdr, cp, hlen);
-
-       *bufp = cp;
-       return (len);
-}
-
-/*
- * Uncompress a packet of total length total_len.  The first buflen
- * bytes are at buf; this must include the entire (compressed or
- * uncompressed) TCP/IP header.  This procedure returns the length
- * of the VJ header, with a pointer to the uncompressed IP header
- * in *hdrp and its length in *hlenp.
- */
-int
-sl_uncompress_tcp_core(buf, buflen, total_len, type, comp, hdrp, hlenp)
-       u_char *buf;
-       int buflen, total_len;
-       u_int type;
-       struct slcompress *comp;
-       u_char **hdrp;
-       u_int *hlenp;
-{
-       register u_char *cp;
-       register u_int hlen, changes;
-       register struct tcphdr *th;
-       register struct cstate *cs;
-       register struct ip *ip;
-       register u_int16_t *bp;
-       register u_int vjlen;
-
-       switch (type) {
-
-       case TYPE_UNCOMPRESSED_TCP:
-               ip = (struct ip *) buf;
-               if (ip->ip_p >= MAX_STATES)
-                       goto bad;
-               cs = &comp->rstate[comp->last_recv = ip->ip_p];
-               comp->flags &=~ SLF_TOSS;
-               ip->ip_p = IPPROTO_TCP;
-               /*
-                * Calculate the size of the TCP/IP header and make sure that
-                * we don't overflow the space we have available for it.
-                */
-               hlen = ip->ip_hl << 2;
-               if (hlen + sizeof(struct tcphdr) > buflen)
-                       goto bad;
-               hlen += ((struct tcphdr *)&((char *)ip)[hlen])->th_off << 2;
-               if (hlen > MAX_HDR || hlen > buflen)
-                       goto bad;
-               BCOPY(ip, &cs->cs_ip, hlen);
-               cs->cs_hlen = hlen;
-               INCR(sls_uncompressedin)
-               *hdrp = (u_char *) &cs->cs_ip;
-               *hlenp = hlen;
-               return (0);
-
-       default:
-               goto bad;
-
-       case TYPE_COMPRESSED_TCP:
-               break;
-       }
-       /* We've got a compressed packet. */
-       INCR(sls_compressedin)
-       cp = buf;
-       changes = *cp++;
-       if (changes & NEW_C) {
-               /* Make sure the state index is in range, then grab the state.
-                * If we have a good state index, clear the 'discard' flag. */
-               if (*cp >= MAX_STATES)
-                       goto bad;
-
-               comp->flags &=~ SLF_TOSS;
-               comp->last_recv = *cp++;
-       } else {
-               /* this packet has an implicit state index.  If we've
-                * had a line error since the last time we got an
-                * explicit state index, we have to toss the packet. */
-               if (comp->flags & SLF_TOSS) {
-                       INCR(sls_tossed)
-                       return (-1);
-               }
-       }
-       cs = &comp->rstate[comp->last_recv];
-       hlen = cs->cs_ip.ip_hl << 2;
-       th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
-       th->th_sum = htons((*cp << 8) | cp[1]);
-       cp += 2;
-       if (changes & TCP_PUSH_BIT)
-               th->th_flags |= TH_PUSH;
-       else
-               th->th_flags &=~ TH_PUSH;
-
-       switch (changes & SPECIALS_MASK) {
-       case SPECIAL_I:
-               {
-               register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
-               th->th_ack = htonl(ntohl(th->th_ack) + i);
-               th->th_seq = htonl(ntohl(th->th_seq) + i);
-               }
-               break;
-
-       case SPECIAL_D:
-               th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len)
-                                  - cs->cs_hlen);
-               break;
-
-       default:
-               if (changes & NEW_U) {
-                       th->th_flags |= TH_URG;
-                       DECODEU(th->th_urp)
-               } else
-                       th->th_flags &=~ TH_URG;
-               if (changes & NEW_W)
-                       DECODES(th->th_win)
-               if (changes & NEW_A)
-                       DECODEL(th->th_ack)
-               if (changes & NEW_S)
-                       DECODEL(th->th_seq)
-               break;
-       }
-       if (changes & NEW_I) {
-               DECODES(cs->cs_ip.ip_id)
-       } else
-               cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1);
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  Fill in the IP total length and update the IP
-        * header checksum.
-        */
-       vjlen = cp - buf;
-       buflen -= vjlen;
-       if (buflen < 0)
-               /* we must have dropped some characters (crc should detect
-                * this but the old slip framing won't) */
-               goto bad;
-
-       total_len += cs->cs_hlen - vjlen;
-       cs->cs_ip.ip_len = htons(total_len);
-
-       /* recompute the ip header checksum */
-       bp = (u_int16_t *) &cs->cs_ip;
-       cs->cs_ip.ip_sum = 0;
-       for (changes = 0; hlen > 0; hlen -= 2)
-               changes += *bp++;
-       changes = (changes & 0xffff) + (changes >> 16);
-       changes = (changes & 0xffff) + (changes >> 16);
-       cs->cs_ip.ip_sum = ~ changes;
-
-       *hdrp = (u_char *) &cs->cs_ip;
-       *hlenp = cs->cs_hlen;
-       return vjlen;
-
-bad:
-       comp->flags |= SLF_TOSS;
-       INCR(sls_errorin)
-       return (-1);
-}
diff --git a/netbsd-1.1/slcompress.h b/netbsd-1.1/slcompress.h
deleted file mode 100644 (file)
index 5ce0946..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*     $Id: slcompress.h,v 1.1 1995/12/11 05:17:12 paulus Exp $        */
-
-/*
- * Copyright (c) 1989, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)slcompress.h        8.1 (Berkeley) 6/10/93
- */
-
-/*
- * Definitions for tcp compression routines.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- */
-
-#define MAX_STATES 16          /* must be > 2 and < 256 */
-#define MAX_HDR MLEN           /* XXX 4bsd-ism: should really be 128 */
-
-/*
- * Compressed packet format:
- *
- * The first octet contains the packet type (top 3 bits), TCP
- * 'push' bit, and flags that indicate which of the 4 TCP sequence
- * numbers have changed (bottom 5 bits).  The next octet is a
- * conversation number that associates a saved IP/TCP header with
- * the compressed packet.  The next two octets are the TCP checksum
- * from the original datagram.  The next 0 to 15 octets are
- * sequence number changes, one change per bit set in the header
- * (there may be no changes and there are two special cases where
- * the receiver implicitly knows what changed -- see below).
- * 
- * There are 5 numbers which can change (they are always inserted
- * in the following order): TCP urgent pointer, window,
- * acknowlegement, sequence number and IP ID.  (The urgent pointer
- * is different from the others in that its value is sent, not the
- * change in value.)  Since typical use of SLIP links is biased
- * toward small packets (see comments on MTU/MSS below), changes
- * use a variable length coding with one octet for numbers in the
- * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
- * range 256 - 65535 or 0.  (If the change in sequence number or
- * ack is more than 65535, an uncompressed packet is sent.)
- */
-
-/*
- * Packet types (must not conflict with IP protocol version)
- *
- * The top nibble of the first octet is the packet type.  There are
- * three possible types: IP (not proto TCP or tcp with one of the
- * control flags set); uncompressed TCP (a normal IP/TCP packet but
- * with the 8-bit protocol field replaced by an 8-bit connection id --
- * this type of packet syncs the sender & receiver); and compressed
- * TCP (described above).
- *
- * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
- * is logically part of the 4-bit "changes" field that follows.  Top
- * three bits are actual packet type.  For backward compatibility
- * and in the interest of conserving bits, numbers are chosen so the
- * IP protocol version number (4) which normally appears in this nibble
- * means "IP packet".
- */
-
-/* packet types */
-#define TYPE_IP 0x40
-#define TYPE_UNCOMPRESSED_TCP 0x70
-#define TYPE_COMPRESSED_TCP 0x80
-#define TYPE_ERROR 0x00
-
-/* Bits in first octet of compressed packet */
-#define NEW_C  0x40    /* flag bits for what changed in a packet */
-#define NEW_I  0x20
-#define NEW_S  0x08
-#define NEW_A  0x04
-#define NEW_W  0x02
-#define NEW_U  0x01
-
-/* reserved, special-case values of above */
-#define SPECIAL_I (NEW_S|NEW_W|NEW_U)          /* echoed interactive traffic */
-#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)    /* unidirectional data */
-#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
-
-#define TCP_PUSH_BIT 0x10
-
-
-/*
- * "state" data for each active tcp conversation on the wire.  This is
- * basically a copy of the entire IP/TCP header from the last packet
- * we saw from the conversation together with a small identifier
- * the transmit & receive ends of the line use to locate saved header.
- */
-struct cstate {
-       struct cstate *cs_next; /* next most recently used cstate (xmit only) */
-       u_int16_t cs_hlen;      /* size of hdr (receive only) */
-       u_char cs_id;           /* connection # associated with this state */
-       u_char cs_filler;
-       union {
-               char csu_hdr[MAX_HDR];
-               struct ip csu_ip;       /* ip/tcp hdr from most recent packet */
-       } slcs_u;
-};
-#define cs_ip slcs_u.csu_ip
-#define cs_hdr slcs_u.csu_hdr
-
-/*
- * all the state data for one serial line (we need one of these
- * per line).
- */
-struct slcompress {
-       struct cstate *last_cs; /* most recently used tstate */
-       u_char last_recv;       /* last rcvd conn. id */
-       u_char last_xmit;       /* last sent conn. id */
-       u_int16_t flags;
-#ifndef SL_NO_STATS
-       int sls_packets;        /* outbound packets */
-       int sls_compressed;     /* outbound compressed packets */
-       int sls_searches;       /* searches for connection state */
-       int sls_misses;         /* times couldn't find conn. state */
-       int sls_uncompressedin; /* inbound uncompressed packets */
-       int sls_compressedin;   /* inbound compressed packets */
-       int sls_errorin;        /* inbound unknown type packets */
-       int sls_tossed;         /* inbound packets tossed because of error */
-#endif
-       struct cstate tstate[MAX_STATES];       /* xmit connection states */
-       struct cstate rstate[MAX_STATES];       /* receive connection states */
-};
-/* flag values */
-#define SLF_TOSS 1             /* tossing rcvd frames because of input err */
-
-void    sl_compress_init __P((struct slcompress *, int));
-u_int   sl_compress_tcp __P((struct mbuf *,
-           struct ip *, struct slcompress *, int));
-int     sl_uncompress_tcp __P((u_char **, int, u_int, struct slcompress *));
-int     sl_uncompress_tcp_core __P((u_char *, int, int, u_int,
-           struct slcompress *, u_char **, u_int *));
diff --git a/netbsd-1.2/Makefile.top b/netbsd-1.2/Makefile.top
deleted file mode 100644 (file)
index 23dd7cc..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# ppp top level makefile for *bsd systems
-#
-
-BINDIR?= /usr/sbin
-
-SUBDIR=        chat pppd pppstats
-MAKE+=  BINDIR=$(BINDIR)
-
-kernel:
-       @sh -e netbsd-1.2/kinstall.sh
-
-.include <bsd.subdir.mk>
diff --git a/netbsd-1.2/bsd-comp.c b/netbsd-1.2/bsd-comp.c
deleted file mode 100644 (file)
index f010763..0000000
+++ /dev/null
@@ -1,1118 +0,0 @@
-/*     $NetBSD: bsd-comp.c,v 1.7 1997/03/12 20:26:46 christos Exp $    */
-/*     Id: bsd-comp.c,v 1.6 1996/08/28 06:31:58 paulus Exp     */
-
-/* Because this code is derived from the 4.3BSD compress source:
- *
- *
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * 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 University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This version is for use with mbufs on BSD-derived systems.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-
-#if DO_BSD_COMPRESS
-/*
- * PPP "BSD compress" compression
- *  The differences between this compression and the classic BSD LZW
- *  source are obvious from the requirement that the classic code worked
- *  with files while this handles arbitrarily long streams that
- *  are broken into packets.  They are:
- *
- *     When the code size expands, a block of junk is not emitted by
- *         the compressor and not expected by the decompressor.
- *
- *     New codes are not necessarily assigned every time an old
- *         code is output by the compressor.  This is because a packet
- *         end forces a code to be emitted, but does not imply that a
- *         new sequence has been seen.
- *
- *     The compression ratio is checked at the first end of a packet
- *         after the appropriate gap.  Besides simplifying and speeding
- *         things up, this makes it more likely that the transmitter
- *         and receiver will agree when the dictionary is cleared when
- *         compression is not going well.
- */
-
-/*
- * A dictionary for doing BSD compress.
- */
-struct bsd_db {
-    int            totlen;                     /* length of this structure */
-    u_int   hsize;                     /* size of the hash table */
-    u_char  hshift;                    /* used in hash function */
-    u_char  n_bits;                    /* current bits/code */
-    u_char  maxbits;
-    u_char  debug;
-    u_char  unit;
-    u_int16_t seqno;                   /* sequence # of next packet */
-    u_int   hdrlen;                    /* header length to preallocate */
-    u_int   mru;
-    u_int   maxmaxcode;                        /* largest valid code */
-    u_int   max_ent;                   /* largest code in use */
-    u_int   in_count;                  /* uncompressed bytes, aged */
-    u_int   bytes_out;                 /* compressed bytes, aged */
-    u_int   ratio;                     /* recent compression ratio */
-    u_int   checkpoint;                        /* when to next check the ratio */
-    u_int   clear_count;               /* times dictionary cleared */
-    u_int   incomp_count;              /* incompressible packets */
-    u_int   incomp_bytes;              /* incompressible bytes */
-    u_int   uncomp_count;              /* uncompressed packets */
-    u_int   uncomp_bytes;              /* uncompressed bytes */
-    u_int   comp_count;                        /* compressed packets */
-    u_int   comp_bytes;                        /* compressed bytes */
-    u_int16_t *lens;                   /* array of lengths of codes */
-    struct bsd_dict {
-       union {                         /* hash value */
-           u_int32_t   fcode;
-           struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
-               u_int16_t prefix;       /* preceding code */
-               u_char  suffix;         /* last character of new code */
-               u_char  pad;
-#else
-               u_char  pad;
-               u_char  suffix;         /* last character of new code */
-               u_int16_t prefix;       /* preceding code */
-#endif
-           } hs;
-       } f;
-       u_int16_t codem1;               /* output of hash table -1 */
-       u_int16_t cptr;                 /* map code to hash table entry */
-    } dict[1];
-};
-
-#define BSD_OVHD       2               /* BSD compress overhead/packet */
-#define BSD_INIT_BITS  BSD_MIN_BITS
-
-static void    *bsd_comp_alloc __P((u_char *options, int opt_len));
-static void    *bsd_decomp_alloc __P((u_char *options, int opt_len));
-static void    bsd_free __P((void *state));
-static int     bsd_comp_init __P((void *state, u_char *options, int opt_len,
-                                  int unit, int hdrlen, int debug));
-static int     bsd_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     bsd_compress __P((void *state, struct mbuf **mret,
-                                 struct mbuf *mp, int slen, int maxolen));
-static void    bsd_incomp __P((void *state, struct mbuf *dmsg));
-static int     bsd_decompress __P((void *state, struct mbuf *cmp,
-                                   struct mbuf **dmpp));
-static void    bsd_reset __P((void *state));
-static void    bsd_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_bsd_compress = {
-    CI_BSD_COMPRESS,           /* compress_proto */
-    bsd_comp_alloc,            /* comp_alloc */
-    bsd_free,                  /* comp_free */
-    bsd_comp_init,             /* comp_init */
-    bsd_reset,                 /* comp_reset */
-    bsd_compress,              /* compress */
-    bsd_comp_stats,            /* comp_stat */
-    bsd_decomp_alloc,          /* decomp_alloc */
-    bsd_free,                  /* decomp_free */
-    bsd_decomp_init,           /* decomp_init */
-    bsd_reset,                 /* decomp_reset */
-    bsd_decompress,            /* decompress */
-    bsd_incomp,                        /* incomp */
-    bsd_comp_stats,            /* decomp_stat */
-};
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define CLEAR  256                     /* table clear output code */
-#define FIRST  257                     /* first free entry */
-#define LAST   255
-
-#define MAXCODE(b)     ((1 << (b)) - 1)
-#define BADCODEM1      MAXCODE(BSD_MAX_BITS)
-
-#define BSD_HASH(prefix,suffix,hshift) ((((u_int32_t)(suffix)) << (hshift)) \
-                                        ^ (u_int32_t)(prefix))
-#define BSD_KEY(prefix,suffix)         ((((u_int32_t)(suffix)) << 16) \
-                                        + (u_int32_t)(prefix))
-
-#define CHECK_GAP      10000           /* Ratio check interval */
-
-#define RATIO_SCALE_LOG        8
-#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
- */
-static void
-bsd_clear(db)
-    struct bsd_db *db;
-{
-    db->clear_count++;
-    db->max_ent = FIRST-1;
-    db->n_bits = BSD_INIT_BITS;
-    db->ratio = 0;
-    db->bytes_out = 0;
-    db->in_count = 0;
-    db->checkpoint = CHECK_GAP;
-}
-
-/*
- * If the dictionary is full, then see if it is time to reset it.
- *
- * Compute the compression ratio using fixed-point arithmetic
- * with 8 fractional bits.
- *
- * Since we have an infinite stream instead of a single file,
- * watch only the local compression ratio.
- *
- * Since both peers must reset the dictionary at the same time even in
- * the absence of CLEAR codes (while packets are incompressible), they
- * must compute the same ratio.
- */
-static int                             /* 1=output CLEAR */
-bsd_check(db)
-    struct bsd_db *db;
-{
-    u_int new_ratio;
-
-    if (db->in_count >= db->checkpoint) {
-       /* age the ratio by limiting the size of the counts */
-       if (db->in_count >= RATIO_MAX
-           || db->bytes_out >= RATIO_MAX) {
-           db->in_count -= db->in_count/4;
-           db->bytes_out -= db->bytes_out/4;
-       }
-
-       db->checkpoint = db->in_count + CHECK_GAP;
-
-       if (db->max_ent >= db->maxmaxcode) {
-           /* Reset the dictionary only if the ratio is worse,
-            * or if it looks as if it has been poisoned
-            * by incompressible data.
-            *
-            * This does not overflow, because
-            *  db->in_count <= RATIO_MAX.
-            */
-           new_ratio = db->in_count << RATIO_SCALE_LOG;
-           if (db->bytes_out != 0)
-               new_ratio /= db->bytes_out;
-
-           if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) {
-               bsd_clear(db);
-               return 1;
-           }
-           db->ratio = new_ratio;
-       }
-    }
-    return 0;
-}
-
-/*
- * Return statistics.
- */
-static void
-bsd_comp_stats(state, stats)
-    void *state;
-    struct compstat *stats;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int out;
-
-    stats->unc_bytes = db->uncomp_bytes;
-    stats->unc_packets = db->uncomp_count;
-    stats->comp_bytes = db->comp_bytes;
-    stats->comp_packets = db->comp_count;
-    stats->inc_bytes = db->incomp_bytes;
-    stats->inc_packets = db->incomp_count;
-    stats->ratio = db->in_count;
-    out = db->bytes_out;
-    if (stats->ratio <= 0x7fffff)
-       stats->ratio <<= 8;
-    else
-       out >>= 8;
-    if (out != 0)
-       stats->ratio /= out;
-}
-
-/*
- * Reset state, as on a CCP ResetReq.
- */
-static void
-bsd_reset(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    db->seqno = 0;
-    bsd_clear(db);
-    db->clear_count = 0;
-}
-
-/*
- * Allocate space for a (de) compressor.
- */
-static void *
-bsd_alloc(options, opt_len, decomp)
-    u_char *options;
-    int opt_len, decomp;
-{
-    int bits;
-    u_int newlen, hsize, hshift, maxmaxcode;
-    struct bsd_db *db;
-
-    if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
-       || options[1] != CILEN_BSD_COMPRESS
-       || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
-       return NULL;
-    bits = BSD_NBITS(options[2]);
-    switch (bits) {
-    case 9:                    /* needs 82152 for both directions */
-    case 10:                   /* needs 84144 */
-    case 11:                   /* needs 88240 */
-    case 12:                   /* needs 96432 */
-       hsize = 5003;
-       hshift = 4;
-       break;
-    case 13:                   /* needs 176784 */
-       hsize = 9001;
-       hshift = 5;
-       break;
-    case 14:                   /* needs 353744 */
-       hsize = 18013;
-       hshift = 6;
-       break;
-    case 15:                   /* needs 691440 */
-       hsize = 35023;
-       hshift = 7;
-       break;
-    case 16:                   /* needs 1366160--far too much, */
-       /* hsize = 69001; */    /* and 69001 is too big for cptr */
-       /* hshift = 8; */       /* in struct bsd_db */
-       /* break; */
-    default:
-       return NULL;
-    }
-
-    maxmaxcode = MAXCODE(bits);
-    newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
-    MALLOC(db, struct bsd_db *, newlen, M_DEVBUF, M_NOWAIT);
-    if (!db)
-       return NULL;
-    bzero(db, sizeof(*db) - sizeof(db->dict));
-
-    if (!decomp) {
-       db->lens = NULL;
-    } else {
-       MALLOC(db->lens, u_int16_t *, (maxmaxcode+1) * sizeof(db->lens[0]),
-              M_DEVBUF, M_NOWAIT);
-       if (!db->lens) {
-           FREE(db, M_DEVBUF);
-           return NULL;
-       }
-    }
-
-    db->totlen = newlen;
-    db->hsize = hsize;
-    db->hshift = hshift;
-    db->maxmaxcode = maxmaxcode;
-    db->maxbits = bits;
-
-    return (void *) db;
-}
-
-static void
-bsd_free(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    if (db->lens)
-       FREE(db->lens, M_DEVBUF);
-    FREE(db, M_DEVBUF);
-}
-
-static void *
-bsd_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 0);
-}
-
-static void *
-bsd_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 1);
-}
-
-/*
- * Initialize the database.
- */
-static int
-bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
-    struct bsd_db *db;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug, decomp;
-{
-    int i;
-
-    if (opt_len < CILEN_BSD_COMPRESS || 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))
-       return 0;
-
-    if (decomp) {
-       i = LAST+1;
-       while (i != 0)
-           db->lens[--i] = 1;
-    }
-    i = db->hsize;
-    while (i != 0) {
-       db->dict[--i].codem1 = BADCODEM1;
-       db->dict[i].cptr = 0;
-    }
-
-    db->unit = unit;
-    db->hdrlen = hdrlen;
-    db->mru = mru;
-#ifndef DEBUG
-    if (debug)
-#endif
-       db->debug = 1;
-
-    bsd_reset(db);
-
-    return 1;
-}
-
-static int
-bsd_comp_init(state, options, opt_len, unit, hdrlen, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, 0, debug, 0);
-}
-
-static int
-bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, mru, debug, 1);
-}
-
-
-/*
- * compress a packet
- *     One change from the BSD compress command is that when the
- *     code size expands, we do not output a bunch of padding.
- */
-int                                    /* new slen */
-bsd_compress(state, mret, mp, slen, maxolen)
-    void *state;
-    struct mbuf **mret;                /* return compressed mbuf chain here */
-    struct mbuf *mp;           /* from here */
-    int slen;                  /* uncompressed length */
-    int maxolen;               /* max compressed length */
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    u_int bitno = 32;
-    u_int32_t accm = 0, fcode;
-    struct bsd_dict *dictp;
-    u_char c;
-    int hval, disp, ent, ilen;
-    u_char *rptr, *wptr;
-    u_char *cp_end;
-    int olen;
-    struct mbuf *m;
-
-#define PUTBYTE(v) {                                   \
-    ++olen;                                            \
-    if (wptr) {                                                \
-       *wptr++ = (v);                                  \
-       if (wptr >= cp_end) {                           \
-           m->m_len = wptr - mtod(m, u_char *);        \
-           MGET(m->m_next, M_DONTWAIT, MT_DATA);       \
-           m = m->m_next;                              \
-           if (m) {                                    \
-               m->m_len = 0;                           \
-               if (maxolen - olen > MLEN)              \
-                   MCLGET(m, M_DONTWAIT);              \
-               wptr = mtod(m, u_char *);               \
-               cp_end = wptr + M_TRAILINGSPACE(m);     \
-           } else                                      \
-               wptr = NULL;                            \
-       }                                               \
-    }                                                  \
-}
-
-#define OUTPUT(ent) {                                  \
-    bitno -= n_bits;                                   \
-    accm |= ((ent) << bitno);                          \
-    do {                                               \
-       PUTBYTE(accm >> 24);                            \
-       accm <<= 8;                                     \
-       bitno += 8;                                     \
-    } while (bitno <= 24);                             \
-}
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without compressing the packet.  If it is,
-     * the protocol becomes the first byte to compress.
-     */
-    rptr = mtod(mp, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < 0x21 || ent > 0xf9) {
-       *mret = NULL;
-       return slen;
-    }
-
-    /* Don't generate compressed packets which are larger than
-       the uncompressed packet. */
-    if (maxolen > slen)
-       maxolen = slen;
-
-    /* Allocate one mbuf to start with. */
-    MGET(m, M_DONTWAIT, MT_DATA);
-    *mret = m;
-    if (m != NULL) {
-       m->m_len = 0;
-       if (maxolen + db->hdrlen > MLEN)
-           MCLGET(m, M_DONTWAIT);
-       m->m_data += db->hdrlen;
-       wptr = mtod(m, u_char *);
-       cp_end = wptr + M_TRAILINGSPACE(m);
-    } else
-       wptr = cp_end = NULL;
-
-    /*
-     * Copy the PPP header over, changing the protocol,
-     * and install the 2-byte packet sequence number.
-     */
-    if (wptr) {
-       *wptr++ = PPP_ADDRESS(rptr);    /* assumes the ppp header is */
-       *wptr++ = PPP_CONTROL(rptr);    /* all in one mbuf */
-       *wptr++ = 0;                    /* change the protocol */
-       *wptr++ = PPP_COMP;
-       *wptr++ = db->seqno >> 8;
-       *wptr++ = db->seqno;
-    }
-    ++db->seqno;
-
-    olen = 0;
-    rptr += PPP_HDRLEN;
-    slen = mp->m_len - PPP_HDRLEN;
-    ilen = slen + 1;
-    for (;;) {
-       if (slen <= 0) {
-           mp = mp->m_next;
-           if (!mp)
-               break;
-           rptr = mtod(mp, u_char *);
-           slen = mp->m_len;
-           if (!slen)
-               continue;   /* handle 0-length buffers */
-           ilen += slen;
-       }
-
-       slen--;
-       c = *rptr++;
-       fcode = BSD_KEY(ent, c);
-       hval = BSD_HASH(ent, c, hshift);
-       dictp = &db->dict[hval];
-
-       /* Validate and then check the entry. */
-       if (dictp->codem1 >= max_ent)
-           goto nomatch;
-       if (dictp->f.fcode == fcode) {
-           ent = dictp->codem1+1;
-           continue;   /* found (prefix,suffix) */
-       }
-
-       /* continue probing until a match or invalid entry */
-       disp = (hval == 0) ? 1 : hval;
-       do {
-           hval += disp;
-           if (hval >= db->hsize)
-               hval -= db->hsize;
-           dictp = &db->dict[hval];
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-       } while (dictp->f.fcode != fcode);
-       ent = dictp->codem1 + 1;        /* finally found (prefix,suffix) */
-       continue;
-
-    nomatch:
-       OUTPUT(ent);            /* output the prefix */
-
-       /* code -> hashtable */
-       if (max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           /* expand code size if needed */
-           if (max_ent >= MAXCODE(n_bits))
-               db->n_bits = ++n_bits;
-
-           /* Invalidate old hash table entry using
-            * this code, and then take it over.
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent)
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-       }
-       ent = c;
-    }
-
-    OUTPUT(ent);               /* output the last code */
-    db->bytes_out += olen;
-    db->in_count += ilen;
-    if (bitno < 32)
-       ++db->bytes_out;        /* count complete bytes */
-
-    if (bsd_check(db))
-       OUTPUT(CLEAR);          /* do not count the CLEAR */
-
-    /*
-     * Pad dribble bits of last code with ones.
-     * Do not emit a completely useless byte of ones.
-     */
-    if (bitno != 32)
-       PUTBYTE((accm | (0xff << (bitno-8))) >> 24);
-
-    if (m != NULL) {
-       m->m_len = wptr - mtod(m, u_char *);
-       m->m_next = NULL;
-    }
-
-    /*
-     * Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-
-    db->uncomp_bytes += ilen;
-    ++db->uncomp_count;
-    if (olen + PPP_HDRLEN + BSD_OVHD > maxolen) {
-       /* throw away the compressed stuff if it is longer than uncompressed */
-       if (*mret != NULL) {
-           m_freem(*mret);
-           *mret = NULL;
-       }
-       ++db->incomp_count;
-       db->incomp_bytes += ilen;
-    } else {
-       ++db->comp_count;
-       db->comp_bytes += olen + BSD_OVHD;
-    }
-
-    return olen + PPP_HDRLEN + BSD_OVHD;
-#undef OUTPUT
-#undef PUTBYTE
-}
-
-
-/*
- * Update the "BSD Compress" dictionary on the receiver for
- * incompressible data by pretending to compress the incoming data.
- */
-static void
-bsd_incomp(state, dmsg)
-    void *state;
-    struct mbuf *dmsg;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    struct bsd_dict *dictp;
-    u_int32_t fcode;
-    u_char c;
-    u_int32_t hval, disp;
-    int slen, ilen;
-    u_int bitno = 7;
-    u_char *rptr;
-    u_int ent;
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without looking at the packet.  If it is,
-     * the protocol becomes the first byte to "compress".
-     */
-    rptr = mtod(dmsg, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < 0x21 || ent > 0xf9)
-       return;
-
-    db->seqno++;
-    ilen = 1;          /* count the protocol as 1 byte */
-    rptr += PPP_HDRLEN;
-    slen = dmsg->m_len - PPP_HDRLEN;
-    for (;;) {
-       if (slen <= 0) {
-           dmsg = dmsg->m_next;
-           if (!dmsg)
-               break;
-           rptr = mtod(dmsg, u_char *);
-           slen = dmsg->m_len;
-           continue;
-       }
-       ilen += slen;
-
-       do {
-           c = *rptr++;
-           fcode = BSD_KEY(ent, c);
-           hval = BSD_HASH(ent, c, hshift);
-           dictp = &db->dict[hval];
-
-           /* validate and then check the entry */
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-           if (dictp->f.fcode == fcode) {
-               ent = dictp->codem1+1;
-               continue;   /* found (prefix,suffix) */
-           }
-
-           /* continue probing until a match or invalid entry */
-           disp = (hval == 0) ? 1 : hval;
-           do {
-               hval += disp;
-               if (hval >= db->hsize)
-                   hval -= db->hsize;
-               dictp = &db->dict[hval];
-               if (dictp->codem1 >= max_ent)
-                   goto nomatch;
-           } while (dictp->f.fcode != fcode);
-           ent = dictp->codem1+1;
-           continue;   /* finally found (prefix,suffix) */
-
-       nomatch:                /* output (count) the prefix */
-           bitno += n_bits;
-
-           /* code -> hashtable */
-           if (max_ent < db->maxmaxcode) {
-               struct bsd_dict *dictp2;
-               /* expand code size if needed */
-               if (max_ent >= MAXCODE(n_bits))
-                   db->n_bits = ++n_bits;
-
-               /* Invalidate previous hash table entry
-                * assigned this code, and then take it over.
-                */
-               dictp2 = &db->dict[max_ent+1];
-               if (db->dict[dictp2->cptr].codem1 == max_ent)
-                   db->dict[dictp2->cptr].codem1 = BADCODEM1;
-               dictp2->cptr = hval;
-               dictp->codem1 = max_ent;
-               dictp->f.fcode = fcode;
-
-               db->max_ent = ++max_ent;
-               db->lens[max_ent] = db->lens[ent]+1;
-           }
-           ent = c;
-       } while (--slen != 0);
-    }
-    bitno += n_bits;           /* output (count) the last code */
-    db->bytes_out += bitno/8;
-    db->in_count += ilen;
-    (void)bsd_check(db);
-
-    ++db->incomp_count;
-    db->incomp_bytes += ilen;
-    ++db->uncomp_count;
-    db->uncomp_bytes += ilen;
-
-    /* Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-}
-
-
-/*
- * Decompress "BSD Compress".
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-bsd_decompress(state, cmp, dmpp)
-    void *state;
-    struct mbuf *cmp, **dmpp;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int max_ent = db->max_ent;
-    u_int32_t accm = 0;
-    u_int bitno = 32;          /* 1st valid bit in accm */
-    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;
-    u_int incode, oldcode, finchar;
-    u_char *p, *rptr, *wptr;
-    struct mbuf *m, *dmp, *mret;
-    int adrs, ctrl, ilen;
-    int space, codelen, extra;
-
-    /*
-     * Save the address/control from the PPP header
-     * and then get the sequence number.
-     */
-    *dmpp = NULL;
-    rptr = mtod(cmp, u_char *);
-    adrs = PPP_ADDRESS(rptr);
-    ctrl = PPP_CONTROL(rptr);
-    rptr += PPP_HDRLEN;
-    len = cmp->m_len - PPP_HDRLEN;
-    seq = 0;
-    for (i = 0; i < 2; ++i) {
-       while (len <= 0) {
-           cmp = cmp->m_next;
-           if (cmp == NULL)
-               return DECOMP_ERROR;
-           rptr = mtod(cmp, u_char *);
-           len = cmp->m_len;
-       }
-       seq = (seq << 8) + *rptr++;
-       --len;
-    }
-
-    /*
-     * Check the sequence number and give up if it differs from
-     * the value we're expecting.
-     */
-    if (seq != db->seqno) {
-       if (db->debug)
-           printf("bsd_decomp%d: bad sequence # %d, expected %d\n",
-                  db->unit, seq, db->seqno - 1);
-       return DECOMP_ERROR;
-    }
-    ++db->seqno;
-
-    /*
-     * Allocate one mbuf to start with.
-     */
-    MGETHDR(dmp, M_DONTWAIT, MT_DATA);
-    if (dmp == NULL)
-       return DECOMP_ERROR;
-    mret = dmp;
-    dmp->m_len = 0;
-    dmp->m_next = NULL;
-    MCLGET(dmp, M_DONTWAIT);
-    dmp->m_data += db->hdrlen;
-    wptr = mtod(dmp, u_char *);
-    space = M_TRAILINGSPACE(dmp) - PPP_HDRLEN + 1;
-
-    /*
-     * Fill in the ppp header, but not the last byte of the protocol
-     * (that comes from the decompressed data).
-     */
-    wptr[0] = adrs;
-    wptr[1] = ctrl;
-    wptr[2] = 0;
-    wptr += PPP_HDRLEN - 1;
-
-    ilen = len;
-    oldcode = CLEAR;
-    explen = 0;
-    for (;;) {
-       if (len == 0) {
-           cmp = cmp->m_next;
-           if (!cmp)           /* quit at end of message */
-               break;
-           rptr = mtod(cmp, u_char *);
-           len = cmp->m_len;
-           ilen += len;
-           continue;           /* handle 0-length buffers */
-       }
-
-       /*
-        * Accumulate bytes until we have a complete code.
-        * Then get the next code, relying on the 32-bit,
-        * unsigned accm to mask the result.
-        */
-       bitno -= 8;
-       accm |= *rptr++ << bitno;
-       --len;
-       if (tgtbitno < bitno)
-           continue;
-       incode = accm >> tgtbitno;
-       accm <<= n_bits;
-       bitno += n_bits;
-
-       if (incode == CLEAR) {
-           /*
-            * The dictionary must only be cleared at
-            * the end of a packet.  But there could be an
-            * empty mbuf at the end.
-            */
-           if (len > 0 || cmp->m_next != NULL) {
-               while ((cmp = cmp->m_next) != NULL)
-                   len += cmp->m_len;
-               if (len > 0) {
-                   m_freem(mret);
-                   if (db->debug)
-                       printf("bsd_decomp%d: bad CLEAR\n", db->unit);
-                   return DECOMP_FATALERROR;   /* probably a bug */
-               }
-           }
-           bsd_clear(db);
-           explen = ilen = 0;
-           break;
-       }
-
-       if (incode > max_ent + 2 || incode > db->maxmaxcode
-           || (incode > max_ent && oldcode == CLEAR)) {
-           m_freem(mret);
-           if (db->debug) {
-               printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
-                      db->unit, incode, oldcode);
-               printf("max_ent=0x%x explen=%d seqno=%d\n",
-                      max_ent, explen, db->seqno);
-           }
-           return DECOMP_FATALERROR;   /* probably a bug */
-       }
-
-       /* Special case for KwKwK string. */
-       if (incode > max_ent) {
-           finchar = oldcode;
-           extra = 1;
-       } else {
-           finchar = incode;
-           extra = 0;
-       }
-
-       codelen = db->lens[finchar];
-       explen += codelen + extra;
-       if (explen > db->mru + 1) {
-           m_freem(mret);
-           if (db->debug) {
-               printf("bsd_decomp%d: ran out of mru\n", db->unit);
-#ifdef DEBUG
-               while ((cmp = cmp->m_next) != NULL)
-                   len += cmp->m_len;
-               printf("  len=%d, finchar=0x%x, codelen=%d, explen=%d\n",
-                      len, finchar, codelen, explen);
-#endif
-           }
-           return DECOMP_FATALERROR;
-       }
-
-       /*
-        * For simplicity, the decoded characters go in a single mbuf,
-        * so we allocate a single extra cluster mbuf if necessary.
-        */
-       if ((space -= codelen + extra) < 0) {
-           dmp->m_len = wptr - mtod(dmp, u_char *);
-           MGET(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL) {
-               m_freem(mret);
-               return DECOMP_ERROR;
-           }
-           m->m_len = 0;
-           m->m_next = NULL;
-           dmp->m_next = m;
-           MCLGET(m, M_DONTWAIT);
-           space = M_TRAILINGSPACE(m) - (codelen + extra);
-           if (space < 0) {
-               /* now that's what I call *compression*. */
-               m_freem(mret);
-               return DECOMP_ERROR;
-           }
-           dmp = m;
-           wptr = mtod(dmp, u_char *);
-       }
-
-       /*
-        * Decode this code and install it in the decompressed buffer.
-        */
-       p = (wptr += codelen);
-       while (finchar > LAST) {
-           dictp = &db->dict[db->dict[finchar].cptr];
-#ifdef DEBUG
-           if (--codelen <= 0 || dictp->codem1 != finchar-1)
-               goto bad;
-#endif
-           *--p = dictp->f.hs.suffix;
-           finchar = dictp->f.hs.prefix;
-       }
-       *--p = finchar;
-
-#ifdef DEBUG
-       if (--codelen != 0)
-           printf("bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n",
-                  db->unit, codelen, incode, max_ent);
-#endif
-
-       if (extra)              /* the KwKwK case again */
-           *wptr++ = finchar;
-
-       /*
-        * If not first code in a packet, and
-        * if not out of code space, then allocate a new code.
-        *
-        * Keep the hash table correct so it can be used
-        * with uncompressed packets.
-        */
-       if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           u_int32_t fcode;
-           u_int32_t hval, disp;
-
-           fcode = BSD_KEY(oldcode,finchar);
-           hval = BSD_HASH(oldcode,finchar,db->hshift);
-           dictp = &db->dict[hval];
-
-           /* look for a free hash table entry */
-           if (dictp->codem1 < max_ent) {
-               disp = (hval == 0) ? 1 : hval;
-               do {
-                   hval += disp;
-                   if (hval >= db->hsize)
-                       hval -= db->hsize;
-                   dictp = &db->dict[hval];
-               } while (dictp->codem1 < max_ent);
-           }
-
-           /*
-            * Invalidate previous hash table entry
-            * assigned this code, and then take it over
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent) {
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           }
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-           db->lens[max_ent] = db->lens[oldcode]+1;
-
-           /* Expand code size if needed. */
-           if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
-               db->n_bits = ++n_bits;
-               tgtbitno = 32-n_bits;
-           }
-       }
-       oldcode = incode;
-    }
-    dmp->m_len = wptr - mtod(dmp, u_char *);
-
-    /*
-     * Keep the checkpoint right so that incompressible packets
-     * clear the dictionary at the right times.
-     */
-    db->bytes_out += ilen;
-    db->in_count += explen;
-    if (bsd_check(db) && db->debug) {
-       printf("bsd_decomp%d: peer should have cleared dictionary\n",
-              db->unit);
-    }
-
-    ++db->comp_count;
-    db->comp_bytes += ilen + BSD_OVHD;
-    ++db->uncomp_count;
-    db->uncomp_bytes += explen;
-
-    *dmpp = mret;
-    return DECOMP_OK;
-
-#ifdef DEBUG
- bad:
-    if (codelen <= 0) {
-       printf("bsd_decomp%d: fell off end of chain ", db->unit);
-       printf("0x%x at 0x%x by 0x%x, max_ent=0x%x\n",
-              incode, finchar, db->dict[finchar].cptr, max_ent);
-    } else if (dictp->codem1 != finchar-1) {
-       printf("bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",
-              db->unit, incode, finchar);
-       printf("oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode,
-              db->dict[finchar].cptr, dictp->codem1);
-    }
-    m_freem(mret);
-    return DECOMP_FATALERROR;
-#endif /* DEBUG */
-}
-#endif /* DO_BSD_COMPRESS */
diff --git a/netbsd-1.2/if_ppp.c b/netbsd-1.2/if_ppp.c
deleted file mode 100644 (file)
index 88efa84..0000000
+++ /dev/null
@@ -1,1538 +0,0 @@
-/*     $NetBSD: if_ppp.c,v 1.46 1998/08/02 15:09:50 sommerfe Exp $     */
-/*     $Id: if_ppp.c,v 1.6 2002/12/06 12:03:44 paulus Exp $    */
-
-/*
- * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a collision if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- */
-
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include <sys/param.h>
-
-#ifdef __NetBSD_Version__      /* Post 1.3 */
-#include "opt_inet.h"
-#include "opt_gateway.h"
-#endif
-
-#include <sys/proc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/malloc.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/netisr.h>
-#include <net/route.h>
-#ifdef PPP_FILTER
-#include <net/bpf.h>
-#endif
-
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#endif
-
-#include "bpfilter.h"
-#if NBPFILTER > 0
-#include <sys/time.h>
-#include <net/bpf.h>
-#endif
-
-#ifdef VJC
-#include <net/slcompress.h>
-#endif
-
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/if_pppvar.h>
-#include <machine/cpu.h>
-
-#ifdef PPP_COMPRESS
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-#endif
-
-static int     pppsioctl __P((struct ifnet *, u_long, caddr_t));
-static void    ppp_requeue __P((struct ppp_softc *));
-static void    ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
-static void    ppp_ccp_closed __P((struct ppp_softc *));
-static void    ppp_inproc __P((struct ppp_softc *, struct mbuf *));
-static void    pppdumpm __P((struct mbuf *m0));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m)        ((m)->m_flags & M_EXT)
-
-#define M_DATASTART(m) \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
-           (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
-           (m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
-
-/*
- * We steal two bits in the mbuf m_flags, to mark high-priority packets
- * for output, and received packets following lost/corrupted packets.
- */
-#define M_HIGHPRI      0x2000  /* output packet for sc_fastq */
-#define M_ERRMARK      0x4000  /* steal a bit in mbuf m_flags */
-
-
-#ifdef PPP_COMPRESS
-/*
- * List of compressors we know about.
- * We leave some space so maybe we can modload compressors.
- */
-
-extern struct compressor ppp_bsd_compress;
-extern struct compressor ppp_deflate, ppp_deflate_draft;
-
-struct compressor *ppp_compressors[8] = {
-#if DO_BSD_COMPRESS && defined(PPP_BSDCOMP)
-    &ppp_bsd_compress,
-#endif
-#if DO_DEFLATE && defined(PPP_DEFLATE)
-    &ppp_deflate,
-    &ppp_deflate_draft,
-#endif
-    NULL
-};
-#endif /* PPP_COMPRESS */
-
-
-/*
- * Called from boot code to establish ppp interfaces.
- */
-void
-pppattach()
-{
-    register struct ppp_softc *sc;
-    register int i = 0;
-
-    for (sc = ppp_softc; i < NPPP; sc++) {
-       sc->sc_unit = i;        /* XXX */
-       sprintf(sc->sc_if.if_xname, "ppp%d", i++);
-       sc->sc_if.if_softc = sc;
-       sc->sc_if.if_mtu = PPP_MTU;
-       sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
-       sc->sc_if.if_type = IFT_PPP;
-       sc->sc_if.if_hdrlen = PPP_HDRLEN;
-       sc->sc_if.if_ioctl = pppsioctl;
-       sc->sc_if.if_output = pppoutput;
-       sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
-       if_attach(&sc->sc_if);
-#if NBPFILTER > 0
-       bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
-#endif
-    }
-}
-
-/*
- * Allocate a ppp interface unit and initialize it.
- */
-struct ppp_softc *
-pppalloc(pid)
-    pid_t pid;
-{
-    int nppp, i;
-    struct ppp_softc *sc;
-
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_xfer == pid) {
-           sc->sc_xfer = 0;
-           return sc;
-       }
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_devp == NULL)
-           break;
-    if (nppp >= NPPP)
-       return NULL;
-
-    sc->sc_flags = 0;
-    sc->sc_mru = PPP_MRU;
-    sc->sc_relinq = NULL;
-    bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
-#ifdef VJC
-    MALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress),
-          M_DEVBUF, M_NOWAIT);
-    if (sc->sc_comp)
-       sl_compress_init(sc->sc_comp);
-#endif
-#ifdef PPP_COMPRESS
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-    for (i = 0; i < NUM_NP; ++i)
-       sc->sc_npmode[i] = NPMODE_ERROR;
-    sc->sc_npqueue = NULL;
-    sc->sc_npqtail = &sc->sc_npqueue;
-    sc->sc_last_sent = sc->sc_last_recv = time.tv_sec;
-
-    return sc;
-}
-
-/*
- * Deallocate a ppp unit.  Must be called at splsoftnet or higher.
- */
-void
-pppdealloc(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m;
-
-    if_down(&sc->sc_if);
-    sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
-    sc->sc_devp = NULL;
-    sc->sc_xfer = 0;
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_rawq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_inq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_fastq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    while ((m = sc->sc_npqueue) != NULL) {
-       sc->sc_npqueue = m->m_nextpkt;
-       m_freem(m);
-    }
-    if (sc->sc_togo != NULL) {
-       m_freem(sc->sc_togo);
-       sc->sc_togo = NULL;
-    }
-#ifdef PPP_COMPRESS
-    ppp_ccp_closed(sc);
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-#ifdef PPP_FILTER
-    if (sc->sc_pass_filt.bf_insns != 0) {
-       FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF);
-       sc->sc_pass_filt.bf_insns = 0;
-       sc->sc_pass_filt.bf_len = 0;
-    }
-    if (sc->sc_active_filt.bf_insns != 0) {
-       FREE(sc->sc_active_filt.bf_insns, M_DEVBUF);
-       sc->sc_active_filt.bf_insns = 0;
-       sc->sc_active_filt.bf_len = 0;
-    }
-#endif /* PPP_FILTER */
-#ifdef VJC
-    if (sc->sc_comp != 0) {
-       FREE(sc->sc_comp, M_DEVBUF);
-       sc->sc_comp = 0;
-    }
-#endif
-}
-
-/*
- * Ioctl routine for generic ppp devices.
- */
-int
-pppioctl(sc, cmd, data, flag, p)
-    struct ppp_softc *sc;
-    u_long cmd;
-    caddr_t data;
-    int flag;
-    struct proc *p;
-{
-    int s, error, flags, mru, nb, npx;
-    struct ppp_option_data *odp;
-    struct compressor **cp;
-    struct npioctl *npi;
-    time_t t;
-#ifdef PPP_FILTER
-    struct bpf_program *bp, *nbp;
-    struct bpf_insn *newcode, *oldcode;
-    int newcodelen;
-#endif /* PPP_FILTER */
-#ifdef PPP_COMPRESS
-    u_char ccp_option[CCP_MAX_OPTION_LENGTH];
-#endif
-
-    switch (cmd) {
-    case FIONREAD:
-       *(int *)data = sc->sc_inq.ifq_len;
-       break;
-
-    case PPPIOCGUNIT:
-       *(int *)data = sc->sc_unit;     /* XXX */
-       break;
-
-    case PPPIOCGFLAGS:
-       *(u_int *)data = sc->sc_flags;
-       break;
-
-    case PPPIOCSFLAGS:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       flags = *(int *)data & SC_MASK;
-       s = splsoftnet();
-#ifdef PPP_COMPRESS
-       if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN))
-           ppp_ccp_closed(sc);
-#endif
-       splimp();
-       sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags;
-       splx(s);
-       break;
-
-    case PPPIOCSMRU:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       mru = *(int *)data;
-       if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
-           sc->sc_mru = mru;
-       break;
-
-    case PPPIOCGMRU:
-       *(int *)data = sc->sc_mru;
-       break;
-
-#ifdef VJC
-    case PPPIOCSMAXCID:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       if (sc->sc_comp) {
-           s = splsoftnet();
-           sl_compress_setup(sc->sc_comp, *(int *)data);
-           splx(s);
-       }
-       break;
-#endif
-
-    case PPPIOCXFERUNIT:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       sc->sc_xfer = p->p_pid;
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPPIOCSCOMPRESS:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           return (error);
-       odp = (struct ppp_option_data *) data;
-       nb = odp->length;
-       if (nb > sizeof(ccp_option))
-           nb = sizeof(ccp_option);
-       if ((error = copyin(odp->ptr, ccp_option, nb)) != 0)
-           return (error);
-       if (ccp_option[1] < 2)  /* preliminary check on the length byte */
-           return (EINVAL);
-       for (cp = ppp_compressors; *cp != NULL; ++cp)
-           if ((*cp)->compress_proto == ccp_option[0]) {
-               /*
-                * Found a handler for the protocol - try to allocate
-                * a compressor or decompressor.
-                */
-               error = 0;
-               if (odp->transmit) {
-                   s = splsoftnet();
-                   if (sc->sc_xc_state != NULL)
-                       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-                   sc->sc_xcomp = *cp;
-                   sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
-                   if (sc->sc_xc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("%s: comp_alloc failed\n",
-                               sc->sc_if.if_xname);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_COMP_RUN;
-                   splx(s);
-               } else {
-                   s = splsoftnet();
-                   if (sc->sc_rc_state != NULL)
-                       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-                   sc->sc_rcomp = *cp;
-                   sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
-                   if (sc->sc_rc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("%s: decomp_alloc failed\n",
-                               sc->sc_if.if_xname);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_DECOMP_RUN;
-                   splx(s);
-               }
-               return (error);
-           }
-       if (sc->sc_flags & SC_DEBUG)
-           printf("%s: no compressor for [%x %x %x], %x\n",
-               sc->sc_if.if_xname, ccp_option[0], ccp_option[1],
-               ccp_option[2], nb);
-       return (EINVAL);        /* no handler found */
-#endif /* PPP_COMPRESS */
-
-    case PPPIOCGNPMODE:
-    case PPPIOCSNPMODE:
-       npi = (struct npioctl *) data;
-       switch (npi->protocol) {
-       case PPP_IP:
-           npx = NP_IP;
-           break;
-       default:
-           return EINVAL;
-       }
-       if (cmd == PPPIOCGNPMODE) {
-           npi->mode = sc->sc_npmode[npx];
-       } else {
-           if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-               return (error);
-           if (npi->mode != sc->sc_npmode[npx]) {
-               s = splimp();
-               sc->sc_npmode[npx] = npi->mode;
-               if (npi->mode != NPMODE_QUEUE) {
-                   ppp_requeue(sc);
-                   ppp_restart(sc);
-               }
-               splx(s);
-           }
-       }
-       break;
-
-    case PPPIOCGIDLE:
-       s = splsoftnet();
-       t = time.tv_sec;
-       ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
-       ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
-       splx(s);
-       break;
-
-#ifdef PPP_FILTER
-    case PPPIOCSPASS:
-    case PPPIOCSACTIVE:
-       nbp = (struct bpf_program *) data;
-       if ((unsigned) nbp->bf_len > BPF_MAXINSNS)
-           return EINVAL;
-       newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
-       if (newcodelen != 0) {
-           MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK);
-           if (newcode == 0) {
-               return EINVAL;          /* or sumpin */
-           }
-           if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode,
-                              newcodelen)) != 0) {
-               FREE(newcode, M_DEVBUF);
-               return error;
-           }
-           if (!bpf_validate(newcode, nbp->bf_len)) {
-               FREE(newcode, M_DEVBUF);
-               return EINVAL;
-           }
-       } else
-           newcode = 0;
-       bp = (cmd == PPPIOCSPASS)? &sc->sc_pass_filt: &sc->sc_active_filt;
-       oldcode = bp->bf_insns;
-       s = splimp();
-       bp->bf_len = nbp->bf_len;
-       bp->bf_insns = newcode;
-       splx(s);
-       if (oldcode != 0)
-           FREE(oldcode, M_DEVBUF);
-       break;
-#endif
-
-    default:
-       return (-1);
-    }
-    return (0);
-}
-
-/*
- * Process an ioctl request to the ppp network interface.
- */
-static int
-pppsioctl(ifp, cmd, data)
-    register struct ifnet *ifp;
-    u_long cmd;
-    caddr_t data;
-{
-    register struct proc *p = curproc; /* XXX */
-    register struct ppp_softc *sc = ifp->if_softc;
-    register struct ifaddr *ifa = (struct ifaddr *)data;
-    register struct ifreq *ifr = (struct ifreq *)data;
-    struct ppp_stats *psp;
-#ifdef PPP_COMPRESS
-    struct ppp_comp_stats *pcp;
-#endif
-    int s = splimp(), error = 0;
-
-    switch (cmd) {
-    case SIOCSIFFLAGS:
-       if ((ifp->if_flags & IFF_RUNNING) == 0)
-           ifp->if_flags &= ~IFF_UP;
-       break;
-
-    case SIOCSIFADDR:
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFDSTADDR:
-       if (ifa->ifa_addr->sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFMTU:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_if.if_mtu = ifr->ifr_mtu;
-       break;
-
-    case SIOCGIFMTU:
-       ifr->ifr_mtu = sc->sc_if.if_mtu;
-       break;
-
-    case SIOCADDMULTI:
-    case SIOCDELMULTI:
-       if (ifr == 0) {
-           error = EAFNOSUPPORT;
-           break;
-       }
-       switch(ifr->ifr_addr.sa_family) {
-#ifdef INET
-       case AF_INET:
-           break;
-#endif
-       default:
-           error = EAFNOSUPPORT;
-           break;
-       }
-       break;
-
-    case SIOCGPPPSTATS:
-       psp = &((struct ifpppstatsreq *) data)->stats;
-       bzero(psp, sizeof(*psp));
-       psp->p = sc->sc_stats;
-#if defined(VJC) && !defined(SL_NO_STATS)
-       if (sc->sc_comp) {
-           psp->vj.vjs_packets = sc->sc_comp->sls_packets;
-           psp->vj.vjs_compressed = sc->sc_comp->sls_compressed;
-           psp->vj.vjs_searches = sc->sc_comp->sls_searches;
-           psp->vj.vjs_misses = sc->sc_comp->sls_misses;
-           psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin;
-           psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin;
-           psp->vj.vjs_errorin = sc->sc_comp->sls_errorin;
-           psp->vj.vjs_tossed = sc->sc_comp->sls_tossed;
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case SIOCGPPPCSTATS:
-       pcp = &((struct ifpppcstatsreq *) data)->stats;
-       bzero(pcp, sizeof(*pcp));
-       if (sc->sc_xc_state != NULL)
-           (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c);
-       if (sc->sc_rc_state != NULL)
-           (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d);
-       break;
-#endif /* PPP_COMPRESS */
-
-    default:
-       error = EINVAL;
-    }
-    splx(s);
-    return (error);
-}
-
-/*
- * Queue a packet.  Start transmission if not active.
- * Packet is placed in Information field of PPP frame.
- */
-int
-pppoutput(ifp, m0, dst, rtp)
-    struct ifnet *ifp;
-    struct mbuf *m0;
-    struct sockaddr *dst;
-    struct rtentry *rtp;
-{
-    register struct ppp_softc *sc = ifp->if_softc;
-    int protocol, address, control;
-    u_char *cp;
-    int s, error;
-    struct ip *ip;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-    int len;
-    struct mbuf *m;
-
-    if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
-       || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
-       error = ENETDOWN;       /* sort of */
-       goto bad;
-    }
-
-    /*
-     * Compute PPP header.
-     */
-    m0->m_flags &= ~M_HIGHPRI;
-    switch (dst->sa_family) {
-#ifdef INET
-    case AF_INET:
-       address = PPP_ALLSTATIONS;
-       control = PPP_UI;
-       protocol = PPP_IP;
-       mode = sc->sc_npmode[NP_IP];
-
-       /*
-        * If this packet has the "low delay" bit set in the IP header,
-        * put it on the fastq instead.
-        */
-       ip = mtod(m0, struct ip *);
-       if (ip->ip_tos & IPTOS_LOWDELAY)
-           m0->m_flags |= M_HIGHPRI;
-       break;
-#endif
-    case AF_UNSPEC:
-       address = PPP_ADDRESS(dst->sa_data);
-       control = PPP_CONTROL(dst->sa_data);
-       protocol = PPP_PROTOCOL(dst->sa_data);
-       mode = NPMODE_PASS;
-       break;
-    default:
-       printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family);
-       error = EAFNOSUPPORT;
-       goto bad;
-    }
-
-    /*
-     * Drop this packet, or return an error, if necessary.
-     */
-    if (mode == NPMODE_ERROR) {
-       error = ENETDOWN;
-       goto bad;
-    }
-    if (mode == NPMODE_DROP) {
-       error = 0;
-       goto bad;
-    }
-
-    /*
-     * Add PPP header.  If no space in first mbuf, allocate another.
-     * (This assumes M_LEADINGSPACE is always 0 for a cluster mbuf.)
-     */
-    if (M_LEADINGSPACE(m0) < PPP_HDRLEN) {
-       m0 = m_prepend(m0, PPP_HDRLEN, M_DONTWAIT);
-       if (m0 == 0) {
-           error = ENOBUFS;
-           goto bad;
-       }
-       m0->m_len = 0;
-    } else
-       m0->m_data -= PPP_HDRLEN;
-
-    cp = mtod(m0, u_char *);
-    *cp++ = address;
-    *cp++ = control;
-    *cp++ = protocol >> 8;
-    *cp++ = protocol & 0xff;
-    m0->m_len += PPP_HDRLEN;
-
-    len = 0;
-    for (m = m0; m != 0; m = m->m_next)
-       len += m->m_len;
-
-    if (sc->sc_flags & SC_LOG_OUTPKT) {
-       printf("%s output: ", ifp->if_xname);
-       pppdumpm(m0);
-    }
-
-    if ((protocol & 0x8000) == 0) {
-#ifdef PPP_FILTER
-       /*
-        * Apply the pass and active filters to the packet,
-        * but only if it is a data packet.
-        */
-       *mtod(m0, u_char *) = 1;        /* indicates outbound */
-       if (sc->sc_pass_filt.bf_insns != 0
-           && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m0,
-                         len, 0) == 0) {
-           error = 0;          /* drop this packet */
-           goto bad;
-       }
-
-       /*
-        * Update the time we sent the most recent packet.
-        */
-       if (sc->sc_active_filt.bf_insns == 0
-           || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
-           sc->sc_last_sent = time.tv_sec;
-
-       *mtod(m0, u_char *) = address;
-#else
-       /*
-        * Update the time we sent the most recent packet.
-        */
-       sc->sc_last_sent = time.tv_sec;
-#endif /* PPP_FILTER */
-    }
-
-#if NBPFILTER > 0
-    /*
-     * See if bpf wants to look at the packet.
-     */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m0);
-#endif
-
-    /*
-     * Put the packet on the appropriate queue.
-     */
-    s = splimp();
-    if (mode == NPMODE_QUEUE) {
-       /* XXX we should limit the number of packets on this queue */
-       *sc->sc_npqtail = m0;
-       m0->m_nextpkt = NULL;
-       sc->sc_npqtail = &m0->m_nextpkt;
-    } else {
-       ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
-       if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
-           IF_DROP(ifq);
-           splx(s);
-           sc->sc_if.if_oerrors++;
-           sc->sc_stats.ppp_oerrors++;
-           error = ENOBUFS;
-           goto bad;
-       }
-       IF_ENQUEUE(ifq, m0);
-       ppp_restart(sc);
-    }
-    ifp->if_lastchange = time;
-    ifp->if_opackets++;
-    ifp->if_obytes += len;
-
-    splx(s);
-    return (0);
-
-bad:
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * After a change in the NPmode for some NP, move packets from the
- * npqueue to the send queue or the fast queue as appropriate.
- * Should be called at splimp, since we muck with the queues.
- */
-static void
-ppp_requeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, **mpp;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-
-    for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) {
-       switch (PPP_PROTOCOL(mtod(m, u_char *))) {
-       case PPP_IP:
-           mode = sc->sc_npmode[NP_IP];
-           break;
-       default:
-           mode = NPMODE_PASS;
-       }
-
-       switch (mode) {
-       case NPMODE_PASS:
-           /*
-            * This packet can now go on one of the queues to be sent.
-            */
-           *mpp = m->m_nextpkt;
-           m->m_nextpkt = NULL;
-           ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd;
-           if (IF_QFULL(ifq)) {
-               IF_DROP(ifq);
-               sc->sc_if.if_oerrors++;
-               sc->sc_stats.ppp_oerrors++;
-           } else
-               IF_ENQUEUE(ifq, m);
-           break;
-
-       case NPMODE_DROP:
-       case NPMODE_ERROR:
-           *mpp = m->m_nextpkt;
-           m_freem(m);
-           break;
-
-       case NPMODE_QUEUE:
-           mpp = &m->m_nextpkt;
-           break;
-       }
-    }
-    sc->sc_npqtail = mpp;
-}
-
-/*
- * Transmitter has finished outputting some stuff;
- * remember to call sc->sc_start later at splsoftnet.
- */
-void
-ppp_restart(sc)
-    struct ppp_softc *sc;
-{
-    int s = splimp();
-
-    sc->sc_flags &= ~SC_TBUSY;
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Get a packet to send.  This procedure is intended to be called at
- * splsoftnet, since it may involve time-consuming operations such as
- * applying VJ compression, packet compression, address/control and/or
- * protocol field compression to the packet.
- */
-struct mbuf *
-ppp_dequeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, *mp;
-    u_char *cp;
-    int address, control, protocol;
-    int s;
-
-    /*
-     * Grab a packet to send: first try the fast queue, then the
-     * normal queue.
-     */
-    s = splimp();    
-    IF_DEQUEUE(&sc->sc_fastq, m);
-    if (m == NULL)
-       IF_DEQUEUE(&sc->sc_if.if_snd, m);
-    splx(s);
-    
-    if (m == NULL)
-       return NULL;
-
-    ++sc->sc_stats.ppp_opackets;
-
-    /*
-     * Extract the ppp header of the new packet.
-     * The ppp header will be in one mbuf.
-     */
-    cp = mtod(m, u_char *);
-    address = PPP_ADDRESS(cp);
-    control = PPP_CONTROL(cp);
-    protocol = PPP_PROTOCOL(cp);
-
-    switch (protocol) {
-    case PPP_IP:
-#ifdef VJC
-       /*
-        * If the packet is a TCP/IP packet, see if we can compress it.
-        */
-       if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) {
-           struct ip *ip;
-           int type;
-
-           mp = m;
-           ip = (struct ip *) (cp + PPP_HDRLEN);
-           if (mp->m_len <= PPP_HDRLEN) {
-               mp = mp->m_next;
-               if (mp == NULL)
-                   break;
-               ip = mtod(mp, struct ip *);
-           }
-           /* this code assumes the IP/TCP header is in one non-shared mbuf */
-           if (ip->ip_p == IPPROTO_TCP) {
-               type = sl_compress_tcp(mp, ip, sc->sc_comp,
-                                      !(sc->sc_flags & SC_NO_TCP_CCID));
-               switch (type) {
-               case TYPE_UNCOMPRESSED_TCP:
-                   protocol = PPP_VJC_UNCOMP;
-                   break;
-               case TYPE_COMPRESSED_TCP:
-                   protocol = PPP_VJC_COMP;
-                   cp = mtod(m, u_char *);
-                   cp[0] = address;    /* header has moved */
-                   cp[1] = control;
-                   cp[2] = 0;
-                   break;
-               }
-               cp[3] = protocol;       /* update protocol in PPP header */
-           }
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPP_CCP:
-       ppp_ccp(sc, m, 0);
-       break;
-#endif /* PPP_COMPRESS */
-    }
-
-#ifdef PPP_COMPRESS
-    if (protocol != PPP_LCP && protocol != PPP_CCP
-       && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
-       struct mbuf *mcomp = NULL;
-       int slen, clen;
-
-       slen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           slen += mp->m_len;
-       clen = (*sc->sc_xcomp->compress)
-           (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
-       if (mcomp != NULL) {
-           if (sc->sc_flags & SC_CCP_UP) {
-               /* Send the compressed packet instead of the original. */
-               m_freem(m);
-               m = mcomp;
-               cp = mtod(m, u_char *);
-               protocol = cp[3];
-           } else {
-               /* Can't transmit compressed packets until CCP is up. */
-               m_freem(mcomp);
-           }
-       }
-    }
-#endif /* PPP_COMPRESS */
-
-    /*
-     * Compress the address/control and protocol, if possible.
-     */
-    if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS &&
-       control == PPP_UI && protocol != PPP_ALLSTATIONS &&
-       protocol != PPP_LCP) {
-       /* can compress address/control */
-       m->m_data += 2;
-       m->m_len -= 2;
-    }
-    if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) {
-       /* can compress protocol */
-       if (mtod(m, u_char *) == cp) {
-           cp[2] = cp[1];      /* move address/control up */
-           cp[1] = cp[0];
-       }
-       ++m->m_data;
-       --m->m_len;
-    }
-
-    return m;
-}
-
-/*
- * Software interrupt routine, called at splsoftnet.
- */
-void
-pppintr()
-{
-    struct ppp_softc *sc;
-    int i, s, s2;
-    struct mbuf *m;
-
-    sc = ppp_softc;
-    s = splsoftnet();
-    for (i = 0; i < NPPP; ++i, ++sc) {
-       if (!(sc->sc_flags & SC_TBUSY)
-           && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head
-               || sc->sc_outm)) {
-           s2 = splimp();
-           sc->sc_flags |= SC_TBUSY;
-           splx(s2);
-           (*sc->sc_start)(sc);
-       }
-       for (;;) {
-           s2 = splimp();
-           IF_DEQUEUE(&sc->sc_rawq, m);
-           splx(s2);
-           if (m == NULL)
-               break;
-           ppp_inproc(sc, m);
-       }
-    }
-    splx(s);
-}
-
-#ifdef PPP_COMPRESS
-/*
- * Handle a CCP packet.  `rcvd' is 1 if the packet was received,
- * 0 if it is about to be transmitted.
- */
-static void
-ppp_ccp(sc, m, rcvd)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int rcvd;
-{
-    u_char *dp, *ep;
-    struct mbuf *mp;
-    int slen, s;
-
-    /*
-     * Get a pointer to the data after the PPP header.
-     */
-    if (m->m_len <= PPP_HDRLEN) {
-       mp = m->m_next;
-       if (mp == NULL)
-           return;
-       dp = (mp != NULL)? mtod(mp, u_char *): NULL;
-    } else {
-       mp = m;
-       dp = mtod(mp, u_char *) + PPP_HDRLEN;
-    }
-
-    ep = mtod(mp, u_char *) + mp->m_len;
-    if (dp + CCP_HDRLEN > ep)
-       return;
-    slen = CCP_LENGTH(dp);
-    if (dp + slen > ep) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n",
-               dp, slen, mtod(mp, u_char *), mp->m_len);
-       return;
-    }
-
-    switch (CCP_CODE(dp)) {
-    case CCP_CONFREQ:
-    case CCP_TERMREQ:
-    case CCP_TERMACK:
-       /* CCP must be going down - disable compression */
-       if (sc->sc_flags & SC_CCP_UP) {
-           s = splimp();
-           sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
-           splx(s);
-       }
-       break;
-
-    case CCP_CONFACK:
-       if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP)
-           && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
-           && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
-           if (!rcvd) {
-               /* we're agreeing to send compressed packets. */
-               if (sc->sc_xc_state != NULL
-                   && (*sc->sc_xcomp->comp_init)
-                       (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_unit, 0, sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_COMP_RUN;
-                   splx(s);
-               }
-           } else {
-               /* peer is agreeing to send compressed packets. */
-               if (sc->sc_rc_state != NULL
-                   && (*sc->sc_rcomp->decomp_init)
-                       (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_unit, 0, sc->sc_mru,
-                        sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_DECOMP_RUN;
-                   sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
-                   splx(s);
-               }
-           }
-       }
-       break;
-
-    case CCP_RESETACK:
-       if (sc->sc_flags & SC_CCP_UP) {
-           if (!rcvd) {
-               if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN))
-                   (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state);
-           } else {
-               if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-                   (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state);
-                   s = splimp();
-                   sc->sc_flags &= ~SC_DC_ERROR;
-                   splx(s);
-               }
-           }
-       }
-       break;
-    }
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-static void
-ppp_ccp_closed(sc)
-    struct ppp_softc *sc;
-{
-    if (sc->sc_xc_state) {
-       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-       sc->sc_xc_state = NULL;
-    }
-    if (sc->sc_rc_state) {
-       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-       sc->sc_rc_state = NULL;
-    }
-}
-#endif /* PPP_COMPRESS */
-
-/*
- * PPP packet input routine.
- * The caller has checked and removed the FCS and has inserted
- * the address/control bytes and the protocol high byte if they
- * were omitted.
- */
-void
-ppppktin(sc, m, lost)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int lost;
-{
-    int s = splimp();
-
-    if (lost)
-       m->m_flags |= M_ERRMARK;
-    IF_ENQUEUE(&sc->sc_rawq, m);
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Process a received PPP packet, doing decompression as necessary.
- * Should be called at splsoftnet.
- */
-#define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
-                        TYPE_UNCOMPRESSED_TCP)
-
-static void
-ppp_inproc(sc, m)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-{
-    struct ifnet *ifp = &sc->sc_if;
-    struct ifqueue *inq;
-    int s, ilen, xlen, proto, rv;
-    u_char *cp, adrs, ctrl;
-    struct mbuf *mp, *dmp = NULL;
-    u_char *iphdr;
-    u_int hlen;
-
-    sc->sc_stats.ppp_ipackets++;
-
-    if (sc->sc_flags & SC_LOG_INPKT) {
-       ilen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           ilen += mp->m_len;
-       printf("%s: got %d bytes\n", ifp->if_xname, ilen);
-       pppdumpm(m);
-    }
-
-    cp = mtod(m, u_char *);
-    adrs = PPP_ADDRESS(cp);
-    ctrl = PPP_CONTROL(cp);
-    proto = PPP_PROTOCOL(cp);
-
-    if (m->m_flags & M_ERRMARK) {
-       m->m_flags &= ~M_ERRMARK;
-       s = splimp();
-       sc->sc_flags |= SC_VJ_RESET;
-       splx(s);
-    }
-
-#ifdef PPP_COMPRESS
-    /*
-     * Decompress this packet if necessary, update the receiver's
-     * dictionary, or take appropriate action on a CCP packet.
-     */
-    if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)
-       && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) {
-       /* decompress this packet */
-       rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp);
-       if (rv == DECOMP_OK) {
-           m_freem(m);
-           if (dmp == NULL) {
-               /* no error, but no decompressed packet produced */
-               return;
-           }
-           m = dmp;
-           cp = mtod(m, u_char *);
-           proto = PPP_PROTOCOL(cp);
-
-       } else {
-           /*
-            * An error has occurred in decompression.
-            * Pass the compressed packet up to pppd, which may take
-            * CCP down or issue a Reset-Req.
-            */
-           if (sc->sc_flags & SC_DEBUG)
-               printf("%s: decompress failed %d\n", ifp->if_xname, rv);
-           s = splimp();
-           sc->sc_flags |= SC_VJ_RESET;
-           if (rv == DECOMP_ERROR)
-               sc->sc_flags |= SC_DC_ERROR;
-           else
-               sc->sc_flags |= SC_DC_FERROR;
-           splx(s);
-       }
-
-    } else {
-       if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-           (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m);
-       }
-       if (proto == PPP_CCP) {
-           ppp_ccp(sc, m, 1);
-       }
-    }
-#endif
-
-    ilen = 0;
-    for (mp = m; mp != NULL; mp = mp->m_next)
-       ilen += mp->m_len;
-
-#ifdef VJC
-    if (sc->sc_flags & SC_VJ_RESET) {
-       /*
-        * If we've missed a packet, we must toss subsequent compressed
-        * packets which don't have an explicit connection ID.
-        */
-       if (sc->sc_comp)
-           sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp);
-       s = splimp();
-       sc->sc_flags &= ~SC_VJ_RESET;
-       splx(s);
-    }
-
-    /*
-     * See if we have a VJ-compressed packet to uncompress.
-     */
-    if (proto == PPP_VJC_COMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen <= 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("%s: VJ uncompress failed on type comp\n",
-                   ifp->if_xname);
-           goto bad;
-       }
-
-       /* Copy the PPP and IP headers into a new mbuf. */
-       MGETHDR(mp, M_DONTWAIT, MT_DATA);
-       if (mp == NULL)
-           goto bad;
-       mp->m_len = 0;
-       mp->m_next = NULL;
-       if (hlen + PPP_HDRLEN > MHLEN) {
-           MCLGET(mp, M_DONTWAIT);
-           if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) {
-               m_freem(mp);
-               goto bad;       /* lose if big headers and no clusters */
-           }
-       }
-       cp = mtod(mp, u_char *);
-       cp[0] = adrs;
-       cp[1] = ctrl;
-       cp[2] = 0;
-       cp[3] = PPP_IP;
-       proto = PPP_IP;
-       bcopy(iphdr, cp + PPP_HDRLEN, hlen);
-       mp->m_len = hlen + PPP_HDRLEN;
-
-       /*
-        * Trim the PPP and VJ headers off the old mbuf
-        * and stick the new and old mbufs together.
-        */
-       m->m_data += PPP_HDRLEN + xlen;
-       m->m_len -= PPP_HDRLEN + xlen;
-       if (m->m_len <= M_TRAILINGSPACE(mp)) {
-           bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len);
-           mp->m_len += m->m_len;
-           MFREE(m, mp->m_next);
-       } else
-           mp->m_next = m;
-       m = mp;
-       ilen += hlen - xlen;
-
-    } else if (proto == PPP_VJC_UNCOMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen < 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("%s: VJ uncompress failed on type uncomp\n",
-                   ifp->if_xname);
-           goto bad;
-       }
-
-       proto = PPP_IP;
-       cp[3] = PPP_IP;
-    }
-#endif /* VJC */
-
-    /*
-     * If the packet will fit in a header mbuf, don't waste a
-     * whole cluster on it.
-     */
-    if (ilen <= MHLEN && M_IS_CLUSTER(m)) {
-       MGETHDR(mp, M_DONTWAIT, MT_DATA);
-       if (mp != NULL) {
-           m_copydata(m, 0, ilen, mtod(mp, caddr_t));
-           m_freem(m);
-           m = mp;
-           m->m_len = ilen;
-       }
-    }
-    m->m_pkthdr.len = ilen;
-    m->m_pkthdr.rcvif = ifp;
-
-    if ((proto & 0x8000) == 0) {
-#ifdef PPP_FILTER
-       /*
-        * See whether we want to pass this packet, and
-        * if it counts as link activity.
-        */
-       adrs = *mtod(m, u_char *);      /* save address field */
-       *mtod(m, u_char *) = 0;         /* indicate inbound */
-       if (sc->sc_pass_filt.bf_insns != 0
-           && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m,
-                         ilen, 0) == 0) {
-           /* drop this packet */
-           m_freem(m);
-           return;
-       }
-       if (sc->sc_active_filt.bf_insns == 0
-           || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
-           sc->sc_last_recv = time.tv_sec;
-
-       *mtod(m, u_char *) = adrs;
-#else
-       /*
-        * Record the time that we received this packet.
-        */
-       sc->sc_last_recv = time.tv_sec;
-#endif /* PPP_FILTER */
-    }
-
-#if NBPFILTER > 0
-    /* See if bpf wants to look at the packet. */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m);
-#endif
-
-    rv = 0;
-    switch (proto) {
-#ifdef INET
-    case PPP_IP:
-       /*
-        * IP packet - take off the ppp header and pass it up to IP.
-        */
-       if ((ifp->if_flags & IFF_UP) == 0
-           || sc->sc_npmode[NP_IP] != NPMODE_PASS) {
-           /* interface is down - drop the packet. */
-           m_freem(m);
-           return;
-       }
-       m->m_pkthdr.len -= PPP_HDRLEN;
-       m->m_data += PPP_HDRLEN;
-       m->m_len -= PPP_HDRLEN;
-#ifdef __NetBSD_Version__
-#ifdef GATEWAY
-       if (ipflow_fastforward(m))
-               return;
-#endif
-#endif
-       schednetisr(NETISR_IP);
-       inq = &ipintrq;
-       break;
-#endif
-
-    default:
-       /*
-        * Some other protocol - place on input queue for read().
-        */
-       inq = &sc->sc_inq;
-       rv = 1;
-       break;
-    }
-
-    /*
-     * Put the packet on the appropriate input queue.
-     */
-    s = splimp();
-    if (IF_QFULL(inq)) {
-       IF_DROP(inq);
-       splx(s);
-       if (sc->sc_flags & SC_DEBUG)
-           printf("%s: input queue full\n", ifp->if_xname);
-       ifp->if_iqdrops++;
-       goto bad;
-    }
-    IF_ENQUEUE(inq, m);
-    splx(s);
-    ifp->if_ipackets++;
-    ifp->if_ibytes += ilen;
-    ifp->if_lastchange = time;
-
-    if (rv)
-       (*sc->sc_ctlp)(sc);
-
-    return;
-
- bad:
-    m_freem(m);
-    sc->sc_if.if_ierrors++;
-    sc->sc_stats.ppp_ierrors++;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-pppdumpm(m0)
-    struct mbuf *m0;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    struct mbuf *m;
-    static char digits[] = "0123456789abcdef";
-
-    for (m = m0; m; m = m->m_next) {
-       int l = m->m_len;
-       u_char *rptr = (u_char *)m->m_data;
-
-       while (l--) {
-           if (bp > buf + sizeof(buf) - 4)
-               goto done;
-           *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
-           *bp++ = digits[*rptr++ & 0xf];
-       }
-
-       if (m->m_next) {
-           if (bp > buf + sizeof(buf) - 3)
-               goto done;
-           *bp++ = '|';
-       } else
-           *bp++ = ' ';
-    }
-done:
-    if (m)
-       *bp++ = '>';
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/netbsd-1.2/if_pppvar.h b/netbsd-1.2/if_pppvar.h
deleted file mode 100644 (file)
index e2d7694..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*     $NetBSD: if_pppvar.h,v 1.8 1998/02/09 17:43:52 perry Exp $      */
-/*     Id: if_pppvar.h,v 1.3 1996/07/01 01:04:37 paulus Exp     */
-
-/*
- * if_pppvar.h - private structures and declarations for PPP.
- *
- * Copyright (c) 1994 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.
- *
- * 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.
- */
-
-#ifndef _NET_IF_PPPVAR_H_
-#define _NET_IF_PPPVAR_H_
-
-/*
- * Supported network protocols.  These values are used for
- * indexing sc_npmode.
- */
-#define NP_IP  0               /* Internet Protocol */
-#define NUM_NP 1               /* Number of NPs. */
-
-/*
- * Structure describing each ppp unit.
- */
-struct ppp_softc {
-       struct  ifnet sc_if;            /* network-visible interface */
-       int     sc_unit;                /* XXX unit number */
-       u_int   sc_flags;               /* control/status bits; see if_ppp.h */
-       void    *sc_devp;               /* pointer to device-dep structure */
-       void    (*sc_start) __P((struct ppp_softc *));  /* start output proc */
-       void    (*sc_ctlp) __P((struct ppp_softc *)); /* rcvd control pkt */
-       void    (*sc_relinq) __P((struct ppp_softc *)); /* relinquish ifunit */
-       u_int16_t sc_mru;               /* max receive unit */
-       pid_t   sc_xfer;                /* used in transferring unit */
-       struct  ifqueue sc_rawq;        /* received packets */
-       struct  ifqueue sc_inq;         /* queue of input packets for daemon */
-       struct  ifqueue sc_fastq;       /* interactive output packet q */
-       struct  mbuf *sc_togo;          /* output packet ready to go */
-       struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
-       struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
-       struct  pppstat sc_stats;       /* count of bytes/pkts sent/rcvd */
-       caddr_t sc_bpf;                 /* hook for BPF */
-       enum    NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
-       struct  compressor *sc_xcomp;   /* transmit compressor */
-       void    *sc_xc_state;           /* transmit compressor state */
-       struct  compressor *sc_rcomp;   /* receive decompressor */
-       void    *sc_rc_state;           /* receive decompressor state */
-       time_t  sc_last_sent;           /* time (secs) last NP pkt sent */
-       time_t  sc_last_recv;           /* time (secs) last NP pkt rcvd */
-#ifdef PPP_FILTER
-       struct  bpf_program sc_pass_filt;   /* filter for packets to pass */
-       struct  bpf_program sc_active_filt; /* filter for "non-idle" packets */
-#endif /* PPP_FILTER */
-#ifdef VJC
-       struct  slcompress *sc_comp;    /* vjc control buffer */
-#endif
-
-       /* Device-dependent part for async lines. */
-       ext_accm sc_asyncmap;           /* async control character map */
-       u_int32_t sc_rasyncmap;         /* receive async control char map */
-       struct  mbuf *sc_outm;          /* mbuf chain currently being output */
-       struct  mbuf *sc_m;             /* pointer to input mbuf chain */
-       struct  mbuf *sc_mc;            /* pointer to current input mbuf */
-       char    *sc_mp;                 /* ptr to next char in input mbuf */
-       u_int16_t sc_ilen;              /* length of input packet so far */
-       u_int16_t sc_fcs;               /* FCS so far (input) */
-       u_int16_t sc_outfcs;            /* FCS so far for output packet */
-       u_char  sc_rawin[16];           /* chars as received */
-       int     sc_rawin_count;         /* # in sc_rawin */
-};
-
-#ifdef _KERNEL
-struct ppp_softc ppp_softc[NPPP];
-
-struct ppp_softc *pppalloc __P((pid_t pid));
-void   pppdealloc __P((struct ppp_softc *sc));
-int    pppioctl __P((struct ppp_softc *sc, u_long cmd, caddr_t data,
-                     int flag, struct proc *p));
-void   ppp_restart __P((struct ppp_softc *sc));
-void   ppppktin __P((struct ppp_softc *sc, struct mbuf *m, int lost));
-struct mbuf *ppp_dequeue __P((struct ppp_softc *sc));
-int    pppoutput __P((struct ifnet *, struct mbuf *,
-                      struct sockaddr *, struct rtentry *));
-#endif /* _KERNEL */
-
-#endif /* _NET_IF_PPPVAR_H_ */
diff --git a/netbsd-1.2/kinstall.sh b/netbsd-1.2/kinstall.sh
deleted file mode 100755 (executable)
index f407c3f..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-
-# This script modifies the kernel sources in /sys to install
-# ppp-2.3.  It is intended to be run in the ppp-2.3 directory.
-#
-# Paul Mackerras       11-Dec-95
-
-ARCH=$(uname -m)
-CONF=$(uname -v | sed 's/.*(\(.*\)).*/\1/')
-SYS=/sys
-ARCHDIR=$SYS/arch/$ARCH
-CFILE=$ARCHDIR/conf/$CONF
-SRC=netbsd-1.2
-DOCONF=
-DOMAKE=
-CONFIG=config
-
-# Copy new versions of files into /sys/net
-
-for f in include/net/if_ppp.h include/net/ppp-comp.h include/net/ppp_defs.h \
-        $SRC/bsd-comp.c $SRC/ppp-deflate.c $SRC/if_ppp.c $SRC/if_pppvar.h \
-         $SRC/ppp_tty.c $SRC/slcompress.c $SRC/slcompress.h \
-         common/zlib.c common/zlib.h; do
-  dest=$SYS/net/$(basename $f)
-  if [ -f $dest ]; then
-    if ! diff -qBI '[  ]\$[IN][de].*:.*\$' $f $dest >/dev/null; then
-      echo "Copying $f to $dest"
-      mv -f $dest $dest.orig && echo " (old version saved in $dest.orig)"
-      cp $f $dest
-      DOMAKE=yes
-    fi
-  else
-    echo "Copying $f to $dest"
-    cp $f $dest
-    DOMAKE=yes
-  fi
-done
-
-# Tell the user to add a pseudo-device line to the configuration file
-# and remake the kernel, if necessary.
-
-if [ -f $CFILE ]; then
-  if ! grep -q '^[     ]*pseudo-device[        ][      ]*ppp' $CFILE; then
-    echo
-    echo "The currently-running kernel was built from configuration file"
-    echo "$CFILE, which does not include PPP."
-    echo "You need either to add a line like 'pseudo-device ppp 2' to"
-    echo "this file, or use another configuration file which includes"
-    echo "a line like this."
-    DOCONF=yes
-  fi
-fi
-
-if [ $DOCONF ]; then
-  echo
-  echo "You need to configure and build a new kernel."
-  echo "The procedure for doing this involves the following commands:"
-  echo "(\"$CONF\" may be replaced by the name of another config file.)"
-  echo
-  echo "       cd $ARCHDIR/conf"
-  echo "       /usr/sbin/$CONFIG $CONF"
-  echo "       cd ../compile/$CONF"
-  echo "       make depend"
-  DOMAKE=yes
-elif [ $DOMAKE ]; then
-  echo
-  echo "You need to build a new kernel."
-  echo "The procedure for doing this involves the following commands:"
-  echo
-  echo "       cd $ARCHDIR/compile/$CONF"
-fi
-if [ $DOMAKE ]; then
-  echo "       make"
-  echo
-  echo "Then copy the new kernel ($ARCHDIR/compile/$CONF/netbsd)"
-  echo "to /netbsd and reboot.  (Keep a copy of the old /netbsd,"
-  echo "just in case.)"
-fi
diff --git a/netbsd-1.2/ppp-deflate.c b/netbsd-1.2/ppp-deflate.c
deleted file mode 100644 (file)
index 11aa069..0000000
+++ /dev/null
@@ -1,688 +0,0 @@
-/*     $NetBSD: ppp-deflate.c,v 1.6 1998/05/02 14:34:25 christos Exp $ */
-/*     Id: ppp-deflate.c,v 1.5 1997/03/04 03:33:28 paulus Exp  */
-
-/*
- * ppp_deflate.c - interface the zlib procedures for Deflate compression
- * and decompression (as used by gzip) to the PPP code.
- * This version is for use with mbufs on BSD-derived systems.
- *
- * Copyright (c) 1994 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/param.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <net/ppp_defs.h>
-#include <net/zlib.h>
-
-#define PACKETPTR      struct mbuf *
-#include <net/ppp-comp.h>
-
-#if DO_DEFLATE
-
-#define DEFLATE_DEBUG  1
-
-/*
- * State for a Deflate (de)compressor.
- */
-struct deflate_state {
-    int                seqno;
-    int                w_size;
-    int                unit;
-    int                hdrlen;
-    int                mru;
-    int                debug;
-    z_stream   strm;
-    struct compstat stats;
-};
-
-#define DEFLATE_OVHD   2               /* Deflate overhead/packet */
-
-static void    *zalloc __P((void *, u_int items, u_int size));
-static void    zfree __P((void *, void *ptr));
-static void    *z_comp_alloc __P((u_char *options, int opt_len));
-static void    *z_decomp_alloc __P((u_char *options, int opt_len));
-static void    z_comp_free __P((void *state));
-static void    z_decomp_free __P((void *state));
-static int     z_comp_init __P((void *state, u_char *options, int opt_len,
-                                int unit, int hdrlen, int debug));
-static int     z_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     z_compress __P((void *state, struct mbuf **mret,
-                                 struct mbuf *mp, int slen, int maxolen));
-static void    z_incomp __P((void *state, struct mbuf *dmsg));
-static int     z_decompress __P((void *state, struct mbuf *cmp,
-                                   struct mbuf **dmpp));
-static void    z_comp_reset __P((void *state));
-static void    z_decomp_reset __P((void *state));
-static void    z_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_deflate = {
-    CI_DEFLATE,                        /* compress_proto */
-    z_comp_alloc,              /* comp_alloc */
-    z_comp_free,               /* comp_free */
-    z_comp_init,               /* comp_init */
-    z_comp_reset,              /* comp_reset */
-    z_compress,                        /* compress */
-    z_comp_stats,              /* comp_stat */
-    z_decomp_alloc,            /* decomp_alloc */
-    z_decomp_free,             /* decomp_free */
-    z_decomp_init,             /* decomp_init */
-    z_decomp_reset,            /* decomp_reset */
-    z_decompress,              /* decompress */
-    z_incomp,                  /* incomp */
-    z_comp_stats,              /* decomp_stat */
-};
-
-struct compressor ppp_deflate_draft = {
-    CI_DEFLATE_DRAFT,          /* compress_proto */
-    z_comp_alloc,              /* comp_alloc */
-    z_comp_free,               /* comp_free */
-    z_comp_init,               /* comp_init */
-    z_comp_reset,              /* comp_reset */
-    z_compress,                        /* compress */
-    z_comp_stats,              /* comp_stat */
-    z_decomp_alloc,            /* decomp_alloc */
-    z_decomp_free,             /* decomp_free */
-    z_decomp_init,             /* decomp_init */
-    z_decomp_reset,            /* decomp_reset */
-    z_decompress,              /* decompress */
-    z_incomp,                  /* incomp */
-    z_comp_stats,              /* decomp_stat */
-};
-/*
- * Space allocation and freeing routines for use by zlib routines.
- */
-void *
-zalloc(notused, items, size)
-    void *notused;
-    u_int items, size;
-{
-    void *ptr;
-
-    MALLOC(ptr, void *, items * size, M_DEVBUF, M_NOWAIT);
-    return ptr;
-}
-
-void
-zfree(notused, ptr)
-    void *notused;
-    void *ptr;
-{
-    FREE(ptr, M_DEVBUF);
-}
-
-/*
- * Allocate space for a compressor.
- */
-static void *
-z_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    struct deflate_state *state;
-    int w_size;
-
-    if (opt_len != CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return NULL;
-    w_size = DEFLATE_SIZE(options[2]);
-    if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-       return NULL;
-
-    MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
-          M_DEVBUF, M_NOWAIT);
-    if (state == NULL)
-       return NULL;
-
-    state->strm.next_in = NULL;
-    state->strm.zalloc = zalloc;
-    state->strm.zfree = zfree;
-    if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
-                    -w_size, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
-       FREE(state, M_DEVBUF);
-       return NULL;
-    }
-
-    state->w_size = w_size;
-    bzero(&state->stats, sizeof(state->stats));
-    return (void *) state;
-}
-
-static void
-z_comp_free(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    deflateEnd(&state->strm);
-    FREE(state, M_DEVBUF);
-}
-
-static int
-z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
-    void *arg;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    if (opt_len < CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || DEFLATE_SIZE(options[2]) != state->w_size
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return 0;
-
-    state->seqno = 0;
-    state->unit = unit;
-    state->hdrlen = hdrlen;
-    state->debug = debug;
-
-    deflateReset(&state->strm);
-
-    return 1;
-}
-
-static void
-z_comp_reset(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    state->seqno = 0;
-    deflateReset(&state->strm);
-}
-
-int
-z_compress(arg, mret, mp, orig_len, maxolen)
-    void *arg;
-    struct mbuf **mret;                /* compressed packet (out) */
-    struct mbuf *mp;           /* uncompressed packet (in) */
-    int orig_len, maxolen;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_char *rptr, *wptr;
-    int proto, olen, wspace, r, flush;
-    struct mbuf *m;
-
-    /*
-     * Check that the protocol is in the range we handle.
-     */
-    rptr = mtod(mp, u_char *);
-    proto = PPP_PROTOCOL(rptr);
-    if (proto > 0x3fff || proto == 0xfd || proto == 0xfb) {
-       *mret = NULL;
-       return orig_len;
-    }
-
-    /* Allocate one mbuf initially. */
-    if (maxolen > orig_len)
-       maxolen = orig_len;
-    MGET(m, M_DONTWAIT, MT_DATA);
-    *mret = m;
-    if (m != NULL) {
-       m->m_len = 0;
-       if (maxolen + state->hdrlen > MLEN)
-           MCLGET(m, M_DONTWAIT);
-       wspace = M_TRAILINGSPACE(m);
-       if (state->hdrlen + PPP_HDRLEN + 2 < wspace) {
-           m->m_data += state->hdrlen;
-           wspace -= state->hdrlen;
-       }
-       wptr = mtod(m, u_char *);
-
-       /*
-        * Copy over the PPP header and store the 2-byte sequence number.
-        */
-       wptr[0] = PPP_ADDRESS(rptr);
-       wptr[1] = PPP_CONTROL(rptr);
-       wptr[2] = PPP_COMP >> 8;
-       wptr[3] = PPP_COMP;
-       wptr += PPP_HDRLEN;
-       wptr[0] = state->seqno >> 8;
-       wptr[1] = state->seqno;
-       wptr += 2;
-       state->strm.next_out = wptr;
-       state->strm.avail_out = wspace - (PPP_HDRLEN + 2);
-    } else {
-       state->strm.next_out = NULL;
-       state->strm.avail_out = 1000000;
-       wptr = NULL;
-       wspace = 0;
-    }
-    ++state->seqno;
-
-    rptr += (proto > 0xff)? 2: 3;      /* skip 1st proto byte if 0 */
-    state->strm.next_in = rptr;
-    state->strm.avail_in = mtod(mp, u_char *) + mp->m_len - rptr;
-    mp = mp->m_next;
-    flush = (mp == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
-    olen = 0;
-    for (;;) {
-       r = deflate(&state->strm, flush);
-       if (r != Z_OK) {
-           printf("z_compress: deflate returned %d (%s)\n",
-                  r, (state->strm.msg? state->strm.msg: ""));
-           break;
-       }
-       if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
-           break;              /* all done */
-       if (state->strm.avail_in == 0 && mp != NULL) {
-           state->strm.next_in = mtod(mp, u_char *);
-           state->strm.avail_in = mp->m_len;
-           mp = mp->m_next;
-           if (mp == NULL)
-               flush = Z_PACKET_FLUSH;
-       }
-       if (state->strm.avail_out == 0) {
-           if (m != NULL) {
-               m->m_len = wspace;
-               olen += wspace;
-               MGET(m->m_next, M_DONTWAIT, MT_DATA);
-               m = m->m_next;
-               if (m != NULL) {
-                   m->m_len = 0;
-                   if (maxolen - olen > MLEN)
-                       MCLGET(m, M_DONTWAIT);
-                   state->strm.next_out = mtod(m, u_char *);
-                   state->strm.avail_out = wspace = M_TRAILINGSPACE(m);
-               }
-           }
-           if (m == NULL) {
-               state->strm.next_out = NULL;
-               state->strm.avail_out = 1000000;
-           }
-       }
-    }
-    if (m != NULL)
-       olen += (m->m_len = wspace - state->strm.avail_out);
-
-    /*
-     * See if we managed to reduce the size of the packet.
-     */
-    if (m != NULL && olen < orig_len) {
-       state->stats.comp_bytes += olen;
-       state->stats.comp_packets++;
-    } else {
-       if (*mret != NULL) {
-           m_freem(*mret);
-           *mret = NULL;
-       }
-       state->stats.inc_bytes += orig_len;
-       state->stats.inc_packets++;
-       olen = orig_len;
-    }
-    state->stats.unc_bytes += orig_len;
-    state->stats.unc_packets++;
-
-    return olen;
-}
-
-static void
-z_comp_stats(arg, stats)
-    void *arg;
-    struct compstat *stats;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_int out;
-
-    *stats = state->stats;
-    stats->ratio = stats->unc_bytes;
-    out = stats->comp_bytes + stats->inc_bytes;
-    if (stats->ratio <= 0x7ffffff)
-       stats->ratio <<= 8;
-    else
-       out >>= 8;
-    if (out != 0)
-       stats->ratio /= out;
-}
-
-/*
- * Allocate space for a decompressor.
- */
-static void *
-z_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    struct deflate_state *state;
-    int w_size;
-
-    if (opt_len != CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return NULL;
-    w_size = DEFLATE_SIZE(options[2]);
-    if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-       return NULL;
-
-    MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
-          M_DEVBUF, M_NOWAIT);
-    if (state == NULL)
-       return NULL;
-
-    state->strm.next_out = NULL;
-    state->strm.zalloc = zalloc;
-    state->strm.zfree = zfree;
-    if (inflateInit2(&state->strm, -w_size) != Z_OK) {
-       FREE(state, M_DEVBUF);
-       return NULL;
-    }
-
-    state->w_size = w_size;
-    bzero(&state->stats, sizeof(state->stats));
-    return (void *) state;
-}
-
-static void
-z_decomp_free(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    inflateEnd(&state->strm);
-    FREE(state, M_DEVBUF);
-}
-
-static int
-z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
-    void *arg;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    if (opt_len < CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || DEFLATE_SIZE(options[2]) != state->w_size
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return 0;
-
-    state->seqno = 0;
-    state->unit = unit;
-    state->hdrlen = hdrlen;
-    state->debug = debug;
-    state->mru = mru;
-
-    inflateReset(&state->strm);
-
-    return 1;
-}
-
-static void
-z_decomp_reset(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    state->seqno = 0;
-    inflateReset(&state->strm);
-}
-
-/*
- * Decompress a Deflate-compressed packet.
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-z_decompress(arg, mi, mop)
-    void *arg;
-    struct mbuf *mi, **mop;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    struct mbuf *mo, *mo_head;
-    u_char *rptr, *wptr;
-    int rlen, olen, ospace;
-    int seq, i, flush, r, decode_proto;
-    u_char hdr[PPP_HDRLEN + DEFLATE_OVHD];
-
-    *mop = NULL;
-    rptr = mtod(mi, u_char *);
-    rlen = mi->m_len;
-    for (i = 0; i < PPP_HDRLEN + DEFLATE_OVHD; ++i) {
-       while (rlen <= 0) {
-           mi = mi->m_next;
-           if (mi == NULL)
-               return DECOMP_ERROR;
-           rptr = mtod(mi, u_char *);
-           rlen = mi->m_len;
-       }
-       hdr[i] = *rptr++;
-       --rlen;
-    }
-
-    /* Check the sequence number. */
-    seq = (hdr[PPP_HDRLEN] << 8) + hdr[PPP_HDRLEN+1];
-    if (seq != state->seqno) {
-       if (state->debug)
-           printf("z_decompress%d: bad seq # %d, expected %d\n",
-                  state->unit, seq, state->seqno);
-       return DECOMP_ERROR;
-    }
-    ++state->seqno;
-
-    /* Allocate an output mbuf. */
-    MGETHDR(mo, M_DONTWAIT, MT_DATA);
-    if (mo == NULL)
-       return DECOMP_ERROR;
-    mo_head = mo;
-    mo->m_len = 0;
-    mo->m_next = NULL;
-    MCLGET(mo, M_DONTWAIT);
-    ospace = M_TRAILINGSPACE(mo);
-    if (state->hdrlen + PPP_HDRLEN < ospace) {
-       mo->m_data += state->hdrlen;
-       ospace -= state->hdrlen;
-    }
-
-    /*
-     * Fill in the first part of the PPP header.  The protocol field
-     * comes from the decompressed data.
-     */
-    wptr = mtod(mo, u_char *);
-    wptr[0] = PPP_ADDRESS(hdr);
-    wptr[1] = PPP_CONTROL(hdr);
-    wptr[2] = 0;
-
-    /*
-     * Set up to call inflate.  We set avail_out to 1 initially so we can
-     * look at the first byte of the output and decide whether we have
-     * a 1-byte or 2-byte protocol field.
-     */
-    state->strm.next_in = rptr;
-    state->strm.avail_in = rlen;
-    mi = mi->m_next;
-    flush = (mi == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
-    rlen += PPP_HDRLEN + DEFLATE_OVHD;
-    state->strm.next_out = wptr + 3;
-    state->strm.avail_out = 1;
-    decode_proto = 1;
-    olen = PPP_HDRLEN;
-
-    /*
-     * Call inflate, supplying more input or output as needed.
-     */
-    for (;;) {
-       r = inflate(&state->strm, flush);
-       if (r != Z_OK) {
-#if !DEFLATE_DEBUG
-           if (state->debug)
-#endif
-               printf("z_decompress%d: inflate returned %d (%s)\n",
-                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-           m_freem(mo_head);
-           return DECOMP_FATALERROR;
-       }
-       if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
-           break;              /* all done */
-       if (state->strm.avail_in == 0 && mi != NULL) {
-           state->strm.next_in = mtod(mi, u_char *);
-           state->strm.avail_in = mi->m_len;
-           rlen += mi->m_len;
-           mi = mi->m_next;
-           if (mi == NULL)
-               flush = Z_PACKET_FLUSH;
-       }
-       if (state->strm.avail_out == 0) {
-           if (decode_proto) {
-               state->strm.avail_out = ospace - PPP_HDRLEN;
-               if ((wptr[3] & 1) == 0) {
-                   /* 2-byte protocol field */
-                   wptr[2] = wptr[3];
-                   --state->strm.next_out;
-                   ++state->strm.avail_out;
-                   --olen;
-               }
-               decode_proto = 0;
-           } else {
-               mo->m_len = ospace;
-               olen += ospace;
-               MGET(mo->m_next, M_DONTWAIT, MT_DATA);
-               mo = mo->m_next;
-               if (mo == NULL) {
-                   m_freem(mo_head);
-                   return DECOMP_ERROR;
-               }
-               MCLGET(mo, M_DONTWAIT);
-               state->strm.next_out = mtod(mo, u_char *);
-               state->strm.avail_out = ospace = M_TRAILINGSPACE(mo);
-           }
-       }
-    }
-    if (decode_proto) {
-       m_freem(mo_head);
-       return DECOMP_ERROR;
-    }
-    olen += (mo->m_len = ospace - state->strm.avail_out);
-#if DEFLATE_DEBUG
-    if (olen > state->mru + PPP_HDRLEN)
-       printf("ppp_deflate%d: exceeded mru (%d > %d)\n",
-              state->unit, olen, state->mru + PPP_HDRLEN);
-#endif
-
-    state->stats.unc_bytes += olen;
-    state->stats.unc_packets++;
-    state->stats.comp_bytes += rlen;
-    state->stats.comp_packets++;
-
-    *mop = mo_head;
-    return DECOMP_OK;
-}
-
-/*
- * Incompressible data has arrived - add it to the history.
- */
-static void
-z_incomp(arg, mi)
-    void *arg;
-    struct mbuf *mi;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_char *rptr;
-    int rlen, proto, r;
-
-    /*
-     * Check that the protocol is one we handle.
-     */
-    rptr = mtod(mi, u_char *);
-    proto = PPP_PROTOCOL(rptr);
-    if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
-       return;
-
-    ++state->seqno;
-
-    /*
-     * Iterate through the mbufs, adding the characters in them
-     * to the decompressor's history.  For the first mbuf, we start
-     * at the either the 1st or 2nd byte of the protocol field,
-     * depending on whether the protocol value is compressible.
-     */
-    rlen = mi->m_len;
-    state->strm.next_in = rptr + 3;
-    state->strm.avail_in = rlen - 3;
-    if (proto > 0xff) {
-       --state->strm.next_in;
-       ++state->strm.avail_in;
-    }
-    for (;;) {
-       r = inflateIncomp(&state->strm);
-       if (r != Z_OK) {
-           /* gak! */
-#if !DEFLATE_DEBUG
-           if (state->debug)
-#endif
-               printf("z_incomp%d: inflateIncomp returned %d (%s)\n",
-                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-           return;
-       }
-       mi = mi->m_next;
-       if (mi == NULL)
-           break;
-       state->strm.next_in = mtod(mi, u_char *);
-       state->strm.avail_in = mi->m_len;
-       rlen += mi->m_len;
-    }
-
-    /*
-     * Update stats.
-     */
-    state->stats.inc_bytes += rlen;
-    state->stats.inc_packets++;
-    state->stats.unc_bytes += rlen;
-    state->stats.unc_packets++;
-}
-
-#endif /* DO_DEFLATE */
diff --git a/netbsd-1.2/ppp_tty.c b/netbsd-1.2/ppp_tty.c
deleted file mode 100644 (file)
index 71a0673..0000000
+++ /dev/null
@@ -1,1092 +0,0 @@
-/*     $NetBSD: ppp_tty.c,v 1.14 1998/08/02 15:09:50 sommerfe Exp $    */
-/*     $Id: ppp_tty.c,v 1.4 2002/12/06 12:03:44 paulus Exp $   */
-
-/*
- * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
- *            tty devices.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a "collision" if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- */
-
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/mbuf.h>
-#include <sys/dkstat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/tty.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/vnode.h>
-#include <sys/systm.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-
-#ifdef VJC
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <net/slcompress.h>
-#endif
-
-#ifdef PPP_FILTER
-#include <net/bpf.h>
-#endif
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/if_pppvar.h>
-
-int    pppopen __P((dev_t dev, struct tty *tp));
-int    pppclose __P((struct tty *tp, int flag));
-int    pppread __P((struct tty *tp, struct uio *uio, int flag));
-int    pppwrite __P((struct tty *tp, struct uio *uio, int flag));
-int    ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data, int flag,
-                      struct proc *));
-int    pppinput __P((int c, struct tty *tp));
-int    pppstart __P((struct tty *tp));
-
-static u_int16_t pppfcs __P((u_int16_t fcs, u_char *cp, int len));
-static void    pppasyncstart __P((struct ppp_softc *));
-static void    pppasyncctlp __P((struct ppp_softc *));
-static void    pppasyncrelinq __P((struct ppp_softc *));
-static void    ppp_timeout __P((void *));
-static void    pppgetm __P((struct ppp_softc *sc));
-static void    pppdumpb __P((u_char *b, int l));
-static void    ppplogchar __P((struct ppp_softc *, int));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m)        ((m)->m_flags & M_EXT)
-
-#define M_DATASTART(m) \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
-           (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
-           (m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
-
-/*
- * Does c need to be escaped?
- */
-#define ESCAPE_P(c)    (sc->sc_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F)))
-
-/*
- * Procedures for using an async tty interface for PPP.
- */
-
-/* This is a NetBSD-1.0 or later kernel. */
-#define CCOUNT(q)      ((q)->c_cc)
-
-#define PPP_LOWAT      100     /* Process more output when < LOWAT on queue */
-#define        PPP_HIWAT       400     /* Don't start a new packet if HIWAT on que */
-
-/*
- * Line specific open routine for async tty devices.
- * Attach the given tty to the first available ppp unit.
- * Called from device open routine or ttioctl.
- */
-/* ARGSUSED */
-int
-pppopen(dev, tp)
-    dev_t dev;
-    register struct tty *tp;
-{
-    struct proc *p = curproc;          /* XXX */
-    register struct ppp_softc *sc;
-    int error, s;
-
-    if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-       return (error);
-
-    s = spltty();
-
-    if (tp->t_line == PPPDISC) {
-       sc = (struct ppp_softc *) tp->t_sc;
-       if (sc != NULL && sc->sc_devp == (void *) tp) {
-           splx(s);
-           return (0);
-       }
-    }
-
-    if ((sc = pppalloc(p->p_pid)) == NULL) {
-       splx(s);
-       return ENXIO;
-    }
-
-    if (sc->sc_relinq)
-       (*sc->sc_relinq)(sc);   /* get previous owner to relinquish the unit */
-
-    sc->sc_ilen = 0;
-    sc->sc_m = NULL;
-    bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-    sc->sc_asyncmap[0] = 0xffffffff;
-    sc->sc_asyncmap[3] = 0x60000000;
-    sc->sc_rasyncmap = 0;
-    sc->sc_devp = (void *) tp;
-    sc->sc_start = pppasyncstart;
-    sc->sc_ctlp = pppasyncctlp;
-    sc->sc_relinq = pppasyncrelinq;
-    sc->sc_outm = NULL;
-    pppgetm(sc);
-    sc->sc_if.if_flags |= IFF_RUNNING;
-    sc->sc_if.if_baudrate = tp->t_ospeed;
-
-    tp->t_sc = (caddr_t) sc;
-    ttyflush(tp, FREAD | FWRITE);
-
-    splx(s);
-    return (0);
-}
-
-/*
- * Line specific close routine, called from device close routine
- * and from ttioctl.
- * Detach the tty from the ppp unit.
- * Mimics part of ttyclose().
- */
-int
-pppclose(tp, flag)
-    struct tty *tp;
-    int flag;
-{
-    register struct ppp_softc *sc;
-    int s;
-
-    s = spltty();
-    ttyflush(tp, FREAD|FWRITE);
-    tp->t_line = 0;
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc != NULL) {
-       tp->t_sc = NULL;
-       if (tp == (struct tty *) sc->sc_devp) {
-           pppasyncrelinq(sc);
-           pppdealloc(sc);
-       }
-    }
-    splx(s);
-    return 0;
-}
-
-/*
- * Relinquish the interface unit to another device.
- */
-static void
-pppasyncrelinq(sc)
-    struct ppp_softc *sc;
-{
-    int s;
-
-    s = spltty();
-    if (sc->sc_outm) {
-       m_freem(sc->sc_outm);
-       sc->sc_outm = NULL;
-    }
-    if (sc->sc_m) {
-       m_freem(sc->sc_m);
-       sc->sc_m = NULL;
-    }
-    if (sc->sc_flags & SC_TIMEOUT) {
-       untimeout(ppp_timeout, (void *) sc);
-       sc->sc_flags &= ~SC_TIMEOUT;
-    }
-    splx(s);
-}
-
-/*
- * Line specific (tty) read routine.
- */
-int
-pppread(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0;
-    register int s;
-    int error = 0;
-
-    if (sc == NULL)
-       return 0;
-    /*
-     * Loop waiting for input, checking that nothing disasterous
-     * happens in the meantime.
-     */
-    s = spltty();
-    for (;;) {
-       if (tp != (struct tty *) sc->sc_devp || tp->t_line != PPPDISC) {
-           splx(s);
-           return 0;
-       }
-       if (sc->sc_inq.ifq_head != NULL)
-           break;
-       if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0
-           && (tp->t_state & TS_ISOPEN)) {
-           splx(s);
-           return 0;           /* end of file */
-       }
-       if (tp->t_state & TS_ASYNC || flag & IO_NDELAY) {
-           splx(s);
-           return (EWOULDBLOCK);
-       }
-       error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, ttyin, 0);
-       if (error) {
-           splx(s);
-           return error;
-       }
-    }
-
-    /* Pull place-holder byte out of canonical queue */
-    getc(&tp->t_canq);
-
-    /* Get the packet from the input queue */
-    IF_DEQUEUE(&sc->sc_inq, m0);
-    splx(s);
-
-    for (m = m0; m && uio->uio_resid; m = m->m_next)
-       if ((error = uiomove(mtod(m, u_char *), m->m_len, uio)) != 0)
-           break;
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * Line specific (tty) write routine.
- */
-int
-pppwrite(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0, **mp;
-    struct sockaddr dst;
-    int len, error;
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       return 0;               /* wrote 0 bytes */
-    if (tp->t_line != PPPDISC)
-       return (EINVAL);
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return EIO;
-    if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HDRLEN ||
-       uio->uio_resid < PPP_HDRLEN)
-       return (EMSGSIZE);
-    for (mp = &m0; uio->uio_resid; mp = &m->m_next) {
-       MGET(m, M_WAIT, MT_DATA);
-       if ((*mp = m) == NULL) {
-           m_freem(m0);
-           return (ENOBUFS);
-       }
-       m->m_len = 0;
-       if (uio->uio_resid >= MCLBYTES / 2)
-           MCLGET(m, M_DONTWAIT);
-       len = M_TRAILINGSPACE(m);
-       if (len > uio->uio_resid)
-           len = uio->uio_resid;
-       if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) {
-           m_freem(m0);
-           return (error);
-       }
-       m->m_len = len;
-    }
-    dst.sa_family = AF_UNSPEC;
-    bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN);
-    m0->m_data += PPP_HDRLEN;
-    m0->m_len -= PPP_HDRLEN;
-    return ((*sc->sc_if.if_output)(&sc->sc_if, m0, &dst, (struct rtentry *)0));
-}
-
-/*
- * Line specific (tty) ioctl routine.
- * This discipline requires that tty device drivers call
- * the line specific l_ioctl routine from their ioctl routines.
- */
-/* ARGSUSED */
-int
-ppptioctl(tp, cmd, data, flag, p)
-    struct tty *tp;
-    u_long cmd;
-    caddr_t data;
-    int flag;
-    struct proc *p;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-    int error, s;
-
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return -1;
-
-    error = 0;
-    switch (cmd) {
-    case PPPIOCSASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_asyncmap[0] = *(u_int *)data;
-       break;
-
-    case PPPIOCGASYNCMAP:
-       *(u_int *)data = sc->sc_asyncmap[0];
-       break;
-
-    case PPPIOCSRASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       sc->sc_rasyncmap = *(u_int *)data;
-       break;
-
-    case PPPIOCGRASYNCMAP:
-       *(u_int *)data = sc->sc_rasyncmap;
-       break;
-
-    case PPPIOCSXASYNCMAP:
-       if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-           break;
-       s = spltty();
-       bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-       sc->sc_asyncmap[1] = 0;             /* mustn't escape 0x20 - 0x3f */
-       sc->sc_asyncmap[2] &= ~0x40000000;  /* mustn't escape 0x5e */
-       sc->sc_asyncmap[3] |= 0x60000000;   /* must escape 0x7d, 0x7e */
-       splx(s);
-       break;
-
-    case PPPIOCGXASYNCMAP:
-       bcopy(sc->sc_asyncmap, data, sizeof(sc->sc_asyncmap));
-       break;
-
-    default:
-       error = pppioctl(sc, cmd, data, flag, p);
-       if (error == 0 && cmd == PPPIOCSMRU)
-           pppgetm(sc);
-    }
-
-    return error;
-}
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static u_int16_t fcstab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-/*
- * Calculate a new FCS given the current FCS and the new data.
- */
-static u_int16_t
-pppfcs(fcs, cp, len)
-    register u_int16_t fcs;
-    register u_char *cp;
-    register int len;
-{
-    while (len--)
-       fcs = PPP_FCS(fcs, *cp++);
-    return (fcs);
-}
-
-/*
- * This gets called at splsoftnet from if_ppp.c at various times
- * when there is data ready to be sent.
- */
-static void
-pppasyncstart(sc)
-    register struct ppp_softc *sc;
-{
-    register struct tty *tp = (struct tty *) sc->sc_devp;
-    register struct mbuf *m;
-    register int len;
-    register u_char *start, *stop, *cp;
-    int n, ndone, done, idle;
-    struct mbuf *m2;
-    int s;
-
-    idle = 0;
-    while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-       /*
-        * See if we have an existing packet partly sent.
-        * If not, get a new packet and start sending it.
-        */
-       m = sc->sc_outm;
-       if (m == NULL) {
-           /*
-            * Get another packet to be sent.
-            */
-           m = ppp_dequeue(sc);
-           if (m == NULL) {
-               idle = 1;
-               break;
-           }
-
-           /*
-            * The extra PPP_FLAG will start up a new packet, and thus
-            * will flush any accumulated garbage.  We do this whenever
-            * the line may have been idle for some time.
-            */
-           if (CCOUNT(&tp->t_outq) == 0) {
-               ++sc->sc_stats.ppp_obytes;
-               (void) putc(PPP_FLAG, &tp->t_outq);
-           }
-
-           /* Calculate the FCS for the first mbuf's worth. */
-           sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
-           sc->sc_if.if_lastchange = time;
-       }
-
-       for (;;) {
-           start = mtod(m, u_char *);
-           len = m->m_len;
-           stop = start + len;
-           while (len > 0) {
-               /*
-                * Find out how many bytes in the string we can
-                * handle without doing something special.
-                */
-               for (cp = start; cp < stop; cp++)
-                   if (ESCAPE_P(*cp))
-                       break;
-               n = cp - start;
-               if (n) {
-                   /* NetBSD (0.9 or later), 4.3-Reno or similar. */
-                   ndone = n - b_to_q(start, n, &tp->t_outq);
-                   len -= ndone;
-                   start += ndone;
-                   sc->sc_stats.ppp_obytes += ndone;
-
-                   if (ndone < n)
-                       break;  /* packet doesn't fit */
-               }
-               /*
-                * If there are characters left in the mbuf,
-                * the first one must be special.
-                * Put it out in a different form.
-                */
-               if (len) {
-                   s = spltty();
-                   if (putc(PPP_ESCAPE, &tp->t_outq)) {
-                       splx(s);
-                       break;
-                   }
-                   if (putc(*start ^ PPP_TRANS, &tp->t_outq)) {
-                       (void) unputc(&tp->t_outq);
-                       splx(s);
-                       break;
-                   }
-                   splx(s);
-                   sc->sc_stats.ppp_obytes += 2;
-                   start++;
-                   len--;
-               }
-           }
-
-           /*
-            * If we didn't empty this mbuf, remember where we're up to.
-            * If we emptied the last mbuf, try to add the FCS and closing
-            * flag, and if we can't, leave sc_outm pointing to m, but with
-            * m->m_len == 0, to remind us to output the FCS and flag later.
-            */
-           done = len == 0;
-           if (done && m->m_next == NULL) {
-               u_char *p, *q;
-               int c;
-               u_char endseq[8];
-
-               /*
-                * We may have to escape the bytes in the FCS.
-                */
-               p = endseq;
-               c = ~sc->sc_outfcs & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               c = (~sc->sc_outfcs >> 8) & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               *p++ = PPP_FLAG;
-
-               /*
-                * Try to output the FCS and flag.  If the bytes
-                * don't all fit, back out.
-                */
-               s = spltty();
-               for (q = endseq; q < p; ++q)
-                   if (putc(*q, &tp->t_outq)) {
-                       done = 0;
-                       for (; q > endseq; --q)
-                           unputc(&tp->t_outq);
-                       break;
-                   }
-               splx(s);
-               if (done)
-                   sc->sc_stats.ppp_obytes += q - endseq;
-           }
-
-           if (!done) {
-               /* remember where we got to */
-               m->m_data = start;
-               m->m_len = len;
-               break;
-           }
-
-           /* Finished with this mbuf; free it and move on. */
-           MFREE(m, m2);
-           m = m2;
-           if (m == NULL) {
-               /* Finished a packet */
-               break;
-           }
-           sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len);
-       }
-
-       /*
-        * If m == NULL, we have finished a packet.
-        * If m != NULL, we've either done as much work this time
-        * as we need to, or else we've filled up the output queue.
-        */
-       sc->sc_outm = m;
-       if (m)
-           break;
-    }
-
-    /* Call pppstart to start output again if necessary. */
-    s = spltty();
-    pppstart(tp);
-
-    /*
-     * This timeout is needed for operation on a pseudo-tty,
-     * because the pty code doesn't call pppstart after it has
-     * drained the t_outq.
-     */
-    if (!idle && (sc->sc_flags & SC_TIMEOUT) == 0) {
-       timeout(ppp_timeout, (void *) sc, 1);
-       sc->sc_flags |= SC_TIMEOUT;
-    }
-
-    splx(s);
-}
-
-/*
- * This gets called when a received packet is placed on
- * the inq, at splsoftnet.
- */
-static void
-pppasyncctlp(sc)
-    struct ppp_softc *sc;
-{
-    struct tty *tp;
-    int s;
-
-    /* Put a placeholder byte in canq for ttselect()/ttnread(). */
-    s = spltty();
-    tp = (struct tty *) sc->sc_devp;
-    putc(0, &tp->t_canq);
-    ttwakeup(tp);
-    splx(s);
-}
-
-/*
- * Start output on async tty interface.  If the transmit queue
- * has drained sufficiently, arrange for pppasyncstart to be
- * called later at splsoftnet.
- * Called at spltty or higher.
- */
-int
-pppstart(tp)
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-
-    /*
-     * If there is stuff in the output queue, send it now.
-     * We are being called in lieu of ttstart and must do what it would.
-     */
-    if (tp->t_oproc != NULL)
-       (*tp->t_oproc)(tp);
-
-    /*
-     * If the transmit queue has drained and the tty has not hung up
-     * or been disconnected from the ppp unit, then tell if_ppp.c that
-     * we need more output.
-     */
-    if ((CCOUNT(&tp->t_outq) >= PPP_LOWAT)
-       && ((sc == NULL) || (sc->sc_flags & SC_TIMEOUT)))
-       return 0;
-    if (!((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       && sc != NULL && tp == (struct tty *) sc->sc_devp) {
-       ppp_restart(sc);
-    }
-
-    return 0;
-}
-
-/*
- * Timeout routine - try to start some more output.
- */
-static void
-ppp_timeout(x)
-    void *x;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) x;
-    struct tty *tp = (struct tty *) sc->sc_devp;
-    int s;
-
-    s = spltty();
-    sc->sc_flags &= ~SC_TIMEOUT;
-    pppstart(tp);
-    splx(s);
-}
-
-/*
- * Allocate enough mbuf to handle current MRU.
- */
-static void
-pppgetm(sc)
-    register struct ppp_softc *sc;
-{
-    struct mbuf *m, **mp;
-    int len;
-
-    mp = &sc->sc_m;
-    for (len = sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){
-       if ((m = *mp) == NULL) {
-           MGETHDR(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL)
-               break;
-           *mp = m;
-           MCLGET(m, M_DONTWAIT);
-       }
-       len -= M_DATASIZE(m);
-       mp = &m->m_next;
-    }
-}
-
-/*
- * tty interface receiver interrupt.
- */
-static unsigned paritytab[8] = {
-    0x96696996, 0x69969669, 0x69969669, 0x96696996,
-    0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-
-int
-pppinput(c, tp)
-    int c;
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    struct mbuf *m;
-    int ilen, s;
-
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return 0;
-
-    ++tk_nin;
-    ++sc->sc_stats.ppp_ibytes;
-
-    if (c & TTY_FE) {
-       /* framing error or overrun on this char - abort packet */
-       if (sc->sc_flags & SC_DEBUG)
-           printf("%s: bad char %x\n", sc->sc_if.if_xname, c);
-       goto flush;
-    }
-
-    c &= 0xff;
-
-    /*
-     * Handle software flow control of output.
-     */
-    if (tp->t_iflag & IXON) {
-       if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
-           if ((tp->t_state & TS_TTSTOP) == 0) {
-               tp->t_state |= TS_TTSTOP;
-               (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
-           }
-           return 0;
-       }
-       if (c == tp->t_cc[VSTART] && tp->t_cc[VSTART] != _POSIX_VDISABLE) {
-           tp->t_state &= ~TS_TTSTOP;
-           if (tp->t_oproc != NULL)
-               (*tp->t_oproc)(tp);
-           return 0;
-       }
-    }
-
-    s = spltty();
-    if (c & 0x80)
-       sc->sc_flags |= SC_RCV_B7_1;
-    else
-       sc->sc_flags |= SC_RCV_B7_0;
-    if (paritytab[c >> 5] & (1 << (c & 0x1F)))
-       sc->sc_flags |= SC_RCV_ODDP;
-    else
-       sc->sc_flags |= SC_RCV_EVNP;
-    splx(s);
-
-    if (sc->sc_flags & SC_LOG_RAWIN)
-       ppplogchar(sc, c);
-
-    if (c == PPP_FLAG) {
-       ilen = sc->sc_ilen;
-       sc->sc_ilen = 0;
-
-       if (sc->sc_rawin_count > 0) 
-           ppplogchar(sc, -1);
-
-       /*
-        * If SC_ESCAPED is set, then we've seen the packet
-        * abort sequence "}~".
-        */
-       if (sc->sc_flags & (SC_FLUSH | SC_ESCAPED)
-           || (ilen > 0 && sc->sc_fcs != PPP_GOODFCS)) {
-           s = spltty();
-           sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
-           if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("%s: bad fcs %x\n", sc->sc_if.if_xname,
-                       sc->sc_fcs);
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-           } else
-               sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
-           splx(s);
-           return 0;
-       }
-
-       if (ilen < PPP_HDRLEN + PPP_FCSLEN) {
-           if (ilen) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("%s: too short (%d)\n", sc->sc_if.if_xname, ilen);
-               s = spltty();
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-               sc->sc_flags |= SC_PKTLOST;
-               splx(s);
-           }
-           return 0;
-       }
-
-       /*
-        * Remove FCS trailer.  Somewhat painful...
-        */
-       ilen -= 2;
-       if (--sc->sc_mc->m_len == 0) {
-           for (m = sc->sc_m; m->m_next != sc->sc_mc; m = m->m_next)
-               ;
-           sc->sc_mc = m;
-       }
-       sc->sc_mc->m_len--;
-
-       /* excise this mbuf chain */
-       m = sc->sc_m;
-       sc->sc_m = sc->sc_mc->m_next;
-       sc->sc_mc->m_next = NULL;
-
-       ppppktin(sc, m, sc->sc_flags & SC_PKTLOST);
-       if (sc->sc_flags & SC_PKTLOST) {
-           s = spltty();
-           sc->sc_flags &= ~SC_PKTLOST;
-           splx(s);
-       }
-
-       pppgetm(sc);
-       return 0;
-    }
-
-    if (sc->sc_flags & SC_FLUSH) {
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-       return 0;
-    }
-
-    if (c < 0x20 && (sc->sc_rasyncmap & (1 << c)))
-       return 0;
-
-    s = spltty();
-    if (sc->sc_flags & SC_ESCAPED) {
-       sc->sc_flags &= ~SC_ESCAPED;
-       c ^= PPP_TRANS;
-    } else if (c == PPP_ESCAPE) {
-       sc->sc_flags |= SC_ESCAPED;
-       splx(s);
-       return 0;
-    }
-    splx(s);
-
-    /*
-     * Initialize buffer on first octet received.
-     * First octet could be address or protocol (when compressing
-     * address/control).
-     * Second octet is control.
-     * Third octet is first or second (when compressing protocol)
-     * octet of protocol.
-     * Fourth octet is second octet of protocol.
-     */
-    if (sc->sc_ilen == 0) {
-       /* reset the first input mbuf */
-       if (sc->sc_m == NULL) {
-           pppgetm(sc);
-           if (sc->sc_m == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("%s: no input mbufs!\n", sc->sc_if.if_xname);
-               goto flush;
-           }
-       }
-       m = sc->sc_m;
-       m->m_len = 0;
-       m->m_data = M_DATASTART(sc->sc_m);
-       sc->sc_mc = m;
-       sc->sc_mp = mtod(m, char *);
-       sc->sc_fcs = PPP_INITFCS;
-       if (c != PPP_ALLSTATIONS) {
-           if (sc->sc_flags & SC_REJ_COMP_AC) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("%s: garbage received: 0x%x (need 0xFF)\n",
-                   sc->sc_if.if_xname, c);
-               goto flush;
-           }
-           *sc->sc_mp++ = PPP_ALLSTATIONS;
-           *sc->sc_mp++ = PPP_UI;
-           sc->sc_ilen += 2;
-           m->m_len += 2;
-       }
-    }
-    if (sc->sc_ilen == 1 && c != PPP_UI) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("%s: missing UI (0x3), got 0x%x\n",
-               sc->sc_if.if_xname, c);
-       goto flush;
-    }
-    if (sc->sc_ilen == 2 && (c & 1) == 1) {
-       /* a compressed protocol */
-       *sc->sc_mp++ = 0;
-       sc->sc_ilen++;
-       sc->sc_mc->m_len++;
-    }
-    if (sc->sc_ilen == 3 && (c & 1) == 0) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("%s: bad protocol %x\n", sc->sc_if.if_xname,
-               (sc->sc_mp[-1] << 8) + c);
-       goto flush;
-    }
-
-    /* packet beyond configured mru? */
-    if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("%s: packet too big\n", sc->sc_if.if_xname);
-       goto flush;
-    }
-
-    /* is this mbuf full? */
-    m = sc->sc_mc;
-    if (M_TRAILINGSPACE(m) <= 0) {
-       if (m->m_next == NULL) {
-           pppgetm(sc);
-           if (m->m_next == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("%s: too few input mbufs!\n", sc->sc_if.if_xname);
-               goto flush;
-           }
-       }
-       sc->sc_mc = m = m->m_next;
-       m->m_len = 0;
-       m->m_data = M_DATASTART(m);
-       sc->sc_mp = mtod(m, char *);
-    }
-
-    ++m->m_len;
-    *sc->sc_mp++ = c;
-    sc->sc_fcs = PPP_FCS(sc->sc_fcs, c);
-    return 0;
-
- flush:
-    if (!(sc->sc_flags & SC_FLUSH)) {
-       s = spltty();
-       sc->sc_if.if_ierrors++;
-       sc->sc_stats.ppp_ierrors++;
-       sc->sc_flags |= SC_FLUSH;
-       splx(s);
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-    }
-    return 0;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-ppplogchar(sc, c)
-    struct ppp_softc *sc;
-    int c;
-{
-    if (c >= 0)
-       sc->sc_rawin[sc->sc_rawin_count++] = c;
-    if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
-       || (c < 0 && sc->sc_rawin_count > 0)) {
-       printf("%s input: ", sc->sc_if.if_xname);
-       pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
-       sc->sc_rawin_count = 0;
-    }
-}
-
-static void
-pppdumpb(b, l)
-    u_char *b;
-    int l;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-
-    while (l--) {
-       if (bp >= buf + sizeof(buf) - 3) {
-           *bp++ = '>';
-           break;
-       }
-       *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*b++ & 0xf];
-       *bp++ = ' ';
-    }
-
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/netbsd-1.2/slcompress.c b/netbsd-1.2/slcompress.c
deleted file mode 100644 (file)
index 96da963..0000000
+++ /dev/null
@@ -1,626 +0,0 @@
-/*     $NetBSD: slcompress.c,v 1.17 1997/05/17 21:12:10 christos Exp $   */
-/*     Id: slcompress.c,v 1.3 1996/05/24 07:04:47 paulus Exp   */
-
-/*
- * Copyright (c) 1989, 1993, 1994
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)slcompress.c        8.2 (Berkeley) 4/16/94
- */
-
-/*
- * Routines to compress and uncompess tcp packets (for transmission
- * over low speed serial lines.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- */
-
-#include <sys/param.h>
-#include <sys/mbuf.h>
-#include <sys/systm.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include <net/slcompress.h>
-
-#ifndef SL_NO_STATS
-#define INCR(counter) ++comp->counter;
-#else
-#define INCR(counter)
-#endif
-
-#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
-#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
-#ifndef _KERNEL
-#define ovbcopy bcopy
-#endif
-
-
-void
-sl_compress_init(comp)
-       struct slcompress *comp;
-{
-       register u_int i;
-       register struct cstate *tstate = comp->tstate;
-
-       bzero((char *)comp, sizeof(*comp));
-       for (i = MAX_STATES - 1; i > 0; --i) {
-               tstate[i].cs_id = i;
-               tstate[i].cs_next = &tstate[i - 1];
-       }
-       tstate[0].cs_next = &tstate[MAX_STATES - 1];
-       tstate[0].cs_id = 0;
-       comp->last_cs = &tstate[0];
-       comp->last_recv = 255;
-       comp->last_xmit = 255;
-       comp->flags = SLF_TOSS;
-}
-
-
-/*
- * Like sl_compress_init, but we get to specify the maximum connection
- * ID to use on transmission.
- */
-void
-sl_compress_setup(comp, max_state)
-       struct slcompress *comp;
-       int max_state;
-{
-       register u_int i;
-       register struct cstate *tstate = comp->tstate;
-
-       if (max_state == -1) {
-               max_state = MAX_STATES - 1;
-               bzero((char *)comp, sizeof(*comp));
-       } else {
-               /* Don't reset statistics */
-               bzero((char *)comp->tstate, sizeof(comp->tstate));
-               bzero((char *)comp->rstate, sizeof(comp->rstate));
-       }
-       for (i = max_state; i > 0; --i) {
-               tstate[i].cs_id = i;
-               tstate[i].cs_next = &tstate[i - 1];
-       }
-       tstate[0].cs_next = &tstate[max_state];
-       tstate[0].cs_id = 0;
-       comp->last_cs = &tstate[0];
-       comp->last_recv = 255;
-       comp->last_xmit = 255;
-       comp->flags = SLF_TOSS;
-}
-
-
-/* ENCODE encodes a number that is known to be non-zero.  ENCODEZ
- * checks for zero (since zero has to be encoded in the long, 3 byte
- * form).
- */
-#define ENCODE(n) { \
-       if ((u_int16_t)(n) >= 256) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-#define ENCODEZ(n) { \
-       if ((u_int16_t)(n) >= 256 || (u_int16_t)(n) == 0) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-
-#define DECODEL(f) { \
-       if (*cp == 0) {\
-               (f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htonl(ntohl(f) + (u_int32_t)*cp++); \
-       } \
-}
-
-#define DECODES(f) { \
-       if (*cp == 0) {\
-               (f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htons(ntohs(f) + (u_int32_t)*cp++); \
-       } \
-}
-
-#define DECODEU(f) { \
-       if (*cp == 0) {\
-               (f) = htons((cp[1] << 8) | cp[2]); \
-               cp += 3; \
-       } else { \
-               (f) = htons((u_int32_t)*cp++); \
-       } \
-}
-
-u_int
-sl_compress_tcp(m, ip, comp, compress_cid)
-       struct mbuf *m;
-       register struct ip *ip;
-       struct slcompress *comp;
-       int compress_cid;
-{
-       register struct cstate *cs = comp->last_cs->cs_next;
-       register u_int hlen = ip->ip_hl;
-       register struct tcphdr *oth;
-       register struct tcphdr *th;
-       register u_int deltaS, deltaA;
-       register u_int changes = 0;
-       u_char new_seq[16];
-       register u_char *cp = new_seq;
-
-       /*
-        * Bail if this is an IP fragment or if the TCP packet isn't
-        * `compressible' (i.e., ACK isn't set or some other control bit is
-        * set).  (We assume that the caller has already made sure the
-        * packet is IP proto TCP).
-        */
-       if ((ip->ip_off & htons(0x3fff)) || m->m_len < 40)
-               return (TYPE_IP);
-
-       th = (struct tcphdr *)&((int32_t *)ip)[hlen];
-       if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
-               return (TYPE_IP);
-       /*
-        * Packet is compressible -- we're going to send either a
-        * COMPRESSED_TCP or UNCOMPRESSED_TCP packet.  Either way we need
-        * to locate (or create) the connection state.  Special case the
-        * most recently used connection since it's most likely to be used
-        * again & we don't have to do any reordering if it's used.
-        */
-       INCR(sls_packets)
-       if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
-           ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
-           *(int32_t *)th != ((int32_t *)&cs->cs_ip)[cs->cs_ip.ip_hl]) {
-               /*
-                * Wasn't the first -- search for it.
-                *
-                * States are kept in a circularly linked list with
-                * last_cs pointing to the end of the list.  The
-                * list is kept in lru order by moving a state to the
-                * head of the list whenever it is referenced.  Since
-                * the list is short and, empirically, the connection
-                * we want is almost always near the front, we locate
-                * states via linear search.  If we don't find a state
-                * for the datagram, the oldest state is (re-)used.
-                */
-               register struct cstate *lcs;
-               register struct cstate *lastcs = comp->last_cs;
-
-               do {
-                       lcs = cs; cs = cs->cs_next;
-                       INCR(sls_searches)
-                       if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
-                           && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
-                           && *(int32_t *)th ==
-                           ((int32_t *)&cs->cs_ip)[cs->cs_ip.ip_hl])
-                               goto found;
-               } while (cs != lastcs);
-
-               /*
-                * Didn't find it -- re-use oldest cstate.  Send an
-                * uncompressed packet that tells the other side what
-                * connection number we're using for this conversation.
-                * Note that since the state list is circular, the oldest
-                * state points to the newest and we only need to set
-                * last_cs to update the lru linkage.
-                */
-               INCR(sls_misses)
-               comp->last_cs = lcs;
-               hlen += th->th_off;
-               hlen <<= 2;
-               goto uncompressed;
-
-       found:
-               /*
-                * Found it -- move to the front on the connection list.
-                */
-               if (cs == lastcs)
-                       comp->last_cs = lcs;
-               else {
-                       lcs->cs_next = cs->cs_next;
-                       cs->cs_next = lastcs->cs_next;
-                       lastcs->cs_next = cs;
-               }
-       }
-
-       /*
-        * Make sure that only what we expect to change changed. The first
-        * line of the `if' checks the IP protocol version, header length &
-        * type of service.  The 2nd line checks the "Don't fragment" bit.
-        * The 3rd line checks the time-to-live and protocol (the protocol
-        * check is unnecessary but costless).  The 4th line checks the TCP
-        * header length.  The 5th line checks IP options, if any.  The 6th
-        * line checks TCP options, if any.  If any of these things are
-        * different between the previous & current datagram, we send the
-        * current datagram `uncompressed'.
-        */
-       oth = (struct tcphdr *)&((int32_t *)&cs->cs_ip)[hlen];
-       deltaS = hlen;
-       hlen += th->th_off;
-       hlen <<= 2;
-
-       if (((u_int16_t *)ip)[0] != ((u_int16_t *)&cs->cs_ip)[0] ||
-           ((u_int16_t *)ip)[3] != ((u_int16_t *)&cs->cs_ip)[3] ||
-           ((u_int16_t *)ip)[4] != ((u_int16_t *)&cs->cs_ip)[4] ||
-           th->th_off != oth->th_off ||
-           (deltaS > 5 &&
-            BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
-           (th->th_off > 5 &&
-            BCMP(th + 1, oth + 1, (th->th_off - 5) << 2)))
-               goto uncompressed;
-
-       /*
-        * Figure out which of the changing fields changed.  The
-        * receiver expects changes in the order: urgent, window,
-        * ack, seq (the order minimizes the number of temporaries
-        * needed in this section of code).
-        */
-       if (th->th_flags & TH_URG) {
-               deltaS = ntohs(th->th_urp);
-               ENCODEZ(deltaS);
-               changes |= NEW_U;
-       } else if (th->th_urp != oth->th_urp)
-               /* argh! URG not set but urp changed -- a sensible
-                * implementation should never do this but RFC793
-                * doesn't prohibit the change so we have to deal
-                * with it. */
-                goto uncompressed;
-
-       deltaS = (u_int16_t)(ntohs(th->th_win) - ntohs(oth->th_win));
-       if (deltaS) {
-               ENCODE(deltaS);
-               changes |= NEW_W;
-       }
-
-       deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack);
-       if (deltaA) {
-               if (deltaA > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaA);
-               changes |= NEW_A;
-       }
-
-       deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq);
-       if (deltaS) {
-               if (deltaS > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaS);
-               changes |= NEW_S;
-       }
-
-       switch(changes) {
-
-       case 0:
-               /*
-                * Nothing changed. If this packet contains data and the
-                * last one didn't, this is probably a data packet following
-                * an ack (normal on an interactive connection) and we send
-                * it compressed.  Otherwise it's probably a retransmit,
-                * retransmitted ack or window probe.  Send it uncompressed
-                * in case the other side missed the compressed version.
-                */
-               if (ip->ip_len != cs->cs_ip.ip_len &&
-                   ntohs(cs->cs_ip.ip_len) == hlen)
-                       break;
-
-               /* (fall through) */
-
-       case SPECIAL_I:
-       case SPECIAL_D:
-               /*
-                * actual changes match one of our special case encodings --
-                * send packet uncompressed.
-                */
-               goto uncompressed;
-
-       case NEW_S|NEW_A:
-               if (deltaS == deltaA &&
-                   deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for echoed terminal traffic */
-                       changes = SPECIAL_I;
-                       cp = new_seq;
-               }
-               break;
-
-       case NEW_S:
-               if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for data xfer */
-                       changes = SPECIAL_D;
-                       cp = new_seq;
-               }
-               break;
-       }
-
-       deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
-       if (deltaS != 1) {
-               ENCODEZ(deltaS);
-               changes |= NEW_I;
-       }
-       if (th->th_flags & TH_PUSH)
-               changes |= TCP_PUSH_BIT;
-       /*
-        * Grab the cksum before we overwrite it below.  Then update our
-        * state with this packet's header.
-        */
-       deltaA = ntohs(th->th_sum);
-       BCOPY(ip, &cs->cs_ip, hlen);
-
-       /*
-        * We want to use the original packet as our compressed packet.
-        * (cp - new_seq) is the number of bytes we need for compressed
-        * sequence numbers.  In addition we need one byte for the change
-        * mask, one for the connection id and two for the tcp checksum.
-        * So, (cp - new_seq) + 4 bytes of header are needed.  hlen is how
-        * many bytes of the original packet to toss so subtract the two to
-        * get the new packet size.
-        */
-       deltaS = cp - new_seq;
-       cp = (u_char *)ip;
-       if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
-               comp->last_xmit = cs->cs_id;
-               hlen -= deltaS + 4;
-               cp += hlen;
-               *cp++ = changes | NEW_C;
-               *cp++ = cs->cs_id;
-       } else {
-               hlen -= deltaS + 3;
-               cp += hlen;
-               *cp++ = changes;
-       }
-       m->m_len -= hlen;
-       m->m_data += hlen;
-       *cp++ = deltaA >> 8;
-       *cp++ = deltaA;
-       BCOPY(new_seq, cp, deltaS);
-       INCR(sls_compressed)
-       return (TYPE_COMPRESSED_TCP);
-
-       /*
-        * Update connection state cs & send uncompressed packet ('uncompressed'
-        * means a regular ip/tcp packet but with the 'conversation id' we hope
-        * to use on future compressed packets in the protocol field).
-        */
-uncompressed:
-       BCOPY(ip, &cs->cs_ip, hlen);
-       ip->ip_p = cs->cs_id;
-       comp->last_xmit = cs->cs_id;
-       return (TYPE_UNCOMPRESSED_TCP);
-}
-
-
-int
-sl_uncompress_tcp(bufp, len, type, comp)
-       u_char **bufp;
-       int len;
-       u_int type;
-       struct slcompress *comp;
-{
-       u_char *hdr, *cp;
-       int hlen, vjlen;
-
-       cp = bufp? *bufp: NULL;
-       vjlen = sl_uncompress_tcp_core(cp, len, len, type, comp, &hdr, &hlen);
-       if (vjlen < 0)
-               return (0);     /* error */
-       if (vjlen == 0)
-               return (len);   /* was uncompressed already */
-
-       cp += vjlen;
-       len -= vjlen;
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  If we're not aligned on a 4-byte boundary, copy the
-        * data down so the ip & tcp headers will be aligned.  Then back up
-        * cp by the tcp/ip header length to make room for the reconstructed
-        * header (we assume the packet we were handed has enough space to
-        * prepend 128 bytes of header).
-        */
-       if ((long)cp & 3) {
-               if (len > 0)
-                       (void) ovbcopy(cp, (caddr_t)((long)cp &~ 3), len);
-               cp = (u_char *)((long)cp &~ 3);
-       }
-       cp -= hlen;
-       len += hlen;
-       BCOPY(hdr, cp, hlen);
-
-       *bufp = cp;
-       return (len);
-}
-
-/*
- * Uncompress a packet of total length total_len.  The first buflen
- * bytes are at buf; this must include the entire (compressed or
- * uncompressed) TCP/IP header.  This procedure returns the length
- * of the VJ header, with a pointer to the uncompressed IP header
- * in *hdrp and its length in *hlenp.
- */
-int
-sl_uncompress_tcp_core(buf, buflen, total_len, type, comp, hdrp, hlenp)
-       u_char *buf;
-       int buflen, total_len;
-       u_int type;
-       struct slcompress *comp;
-       u_char **hdrp;
-       u_int *hlenp;
-{
-       register u_char *cp;
-       register u_int hlen, changes;
-       register struct tcphdr *th;
-       register struct cstate *cs;
-       register struct ip *ip;
-       register u_int16_t *bp;
-       register u_int vjlen;
-
-       switch (type) {
-
-       case TYPE_UNCOMPRESSED_TCP:
-               ip = (struct ip *) buf;
-               if (ip->ip_p >= MAX_STATES)
-                       goto bad;
-               cs = &comp->rstate[comp->last_recv = ip->ip_p];
-               comp->flags &=~ SLF_TOSS;
-               ip->ip_p = IPPROTO_TCP;
-               /*
-                * Calculate the size of the TCP/IP header and make sure that
-                * we don't overflow the space we have available for it.
-                */
-               hlen = ip->ip_hl << 2;
-               if (hlen + sizeof(struct tcphdr) > buflen)
-                       goto bad;
-               hlen += ((struct tcphdr *)&((char *)ip)[hlen])->th_off << 2;
-               if (hlen > MAX_HDR || hlen > buflen)
-                       goto bad;
-               BCOPY(ip, &cs->cs_ip, hlen);
-               cs->cs_hlen = hlen;
-               INCR(sls_uncompressedin)
-               *hdrp = (u_char *) &cs->cs_ip;
-               *hlenp = hlen;
-               return (0);
-
-       default:
-               goto bad;
-
-       case TYPE_COMPRESSED_TCP:
-               break;
-       }
-       /* We've got a compressed packet. */
-       INCR(sls_compressedin)
-       cp = buf;
-       changes = *cp++;
-       if (changes & NEW_C) {
-               /* Make sure the state index is in range, then grab the state.
-                * If we have a good state index, clear the 'discard' flag. */
-               if (*cp >= MAX_STATES)
-                       goto bad;
-
-               comp->flags &=~ SLF_TOSS;
-               comp->last_recv = *cp++;
-       } else {
-               /* this packet has an implicit state index.  If we've
-                * had a line error since the last time we got an
-                * explicit state index, we have to toss the packet. */
-               if (comp->flags & SLF_TOSS) {
-                       INCR(sls_tossed)
-                       return (-1);
-               }
-       }
-       cs = &comp->rstate[comp->last_recv];
-       hlen = cs->cs_ip.ip_hl << 2;
-       th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
-       th->th_sum = htons((*cp << 8) | cp[1]);
-       cp += 2;
-       if (changes & TCP_PUSH_BIT)
-               th->th_flags |= TH_PUSH;
-       else
-               th->th_flags &=~ TH_PUSH;
-
-       switch (changes & SPECIALS_MASK) {
-       case SPECIAL_I:
-               {
-               register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
-               th->th_ack = htonl(ntohl(th->th_ack) + i);
-               th->th_seq = htonl(ntohl(th->th_seq) + i);
-               }
-               break;
-
-       case SPECIAL_D:
-               th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len)
-                                  - cs->cs_hlen);
-               break;
-
-       default:
-               if (changes & NEW_U) {
-                       th->th_flags |= TH_URG;
-                       DECODEU(th->th_urp)
-               } else
-                       th->th_flags &=~ TH_URG;
-               if (changes & NEW_W)
-                       DECODES(th->th_win)
-               if (changes & NEW_A)
-                       DECODEL(th->th_ack)
-               if (changes & NEW_S)
-                       DECODEL(th->th_seq)
-               break;
-       }
-       if (changes & NEW_I) {
-               DECODES(cs->cs_ip.ip_id)
-       } else
-               cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1);
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  Fill in the IP total length and update the IP
-        * header checksum.
-        */
-       vjlen = cp - buf;
-       buflen -= vjlen;
-       if (buflen < 0)
-               /* we must have dropped some characters (crc should detect
-                * this but the old slip framing won't) */
-               goto bad;
-
-       total_len += cs->cs_hlen - vjlen;
-       cs->cs_ip.ip_len = htons(total_len);
-
-       /* recompute the ip header checksum */
-       bp = (u_int16_t *) &cs->cs_ip;
-       cs->cs_ip.ip_sum = 0;
-       for (changes = 0; hlen > 0; hlen -= 2)
-               changes += *bp++;
-       changes = (changes & 0xffff) + (changes >> 16);
-       changes = (changes & 0xffff) + (changes >> 16);
-       cs->cs_ip.ip_sum = ~ changes;
-
-       *hdrp = (u_char *) &cs->cs_ip;
-       *hlenp = cs->cs_hlen;
-       return vjlen;
-
-bad:
-       comp->flags |= SLF_TOSS;
-       INCR(sls_errorin)
-       return (-1);
-}
diff --git a/netbsd-1.2/slcompress.h b/netbsd-1.2/slcompress.h
deleted file mode 100644 (file)
index 196fc1e..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*     $NetBSD: slcompress.h,v 1.12 1998/02/09 17:43:56 perry Exp $    */
-/*     Id: slcompress.h,v 1.4 1994/09/21 06:50:08 paulus Exp   */
-
-/*
- * Copyright (c) 1989, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)slcompress.h        8.1 (Berkeley) 6/10/93
- */
-
-/*
- * Definitions for tcp compression routines.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- */
-
-#ifndef _NET_SLCOMPRESS_H_
-#define _NET_SLCOMPRESS_H_
-
-#define MAX_STATES 16          /* must be > 2 and < 256 */
-#define MAX_HDR MLEN           /* XXX 4bsd-ism: should really be 128 */
-
-/*
- * Compressed packet format:
- *
- * The first octet contains the packet type (top 3 bits), TCP
- * 'push' bit, and flags that indicate which of the 4 TCP sequence
- * numbers have changed (bottom 5 bits).  The next octet is a
- * conversation number that associates a saved IP/TCP header with
- * the compressed packet.  The next two octets are the TCP checksum
- * from the original datagram.  The next 0 to 15 octets are
- * sequence number changes, one change per bit set in the header
- * (there may be no changes and there are two special cases where
- * the receiver implicitly knows what changed -- see below).
- * 
- * There are 5 numbers which can change (they are always inserted
- * in the following order): TCP urgent pointer, window,
- * acknowlegement, sequence number and IP ID.  (The urgent pointer
- * is different from the others in that its value is sent, not the
- * change in value.)  Since typical use of SLIP links is biased
- * toward small packets (see comments on MTU/MSS below), changes
- * use a variable length coding with one octet for numbers in the
- * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
- * range 256 - 65535 or 0.  (If the change in sequence number or
- * ack is more than 65535, an uncompressed packet is sent.)
- */
-
-/*
- * Packet types (must not conflict with IP protocol version)
- *
- * The top nibble of the first octet is the packet type.  There are
- * three possible types: IP (not proto TCP or tcp with one of the
- * control flags set); uncompressed TCP (a normal IP/TCP packet but
- * with the 8-bit protocol field replaced by an 8-bit connection id --
- * this type of packet syncs the sender & receiver); and compressed
- * TCP (described above).
- *
- * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
- * is logically part of the 4-bit "changes" field that follows.  Top
- * three bits are actual packet type.  For backward compatibility
- * and in the interest of conserving bits, numbers are chosen so the
- * IP protocol version number (4) which normally appears in this nibble
- * means "IP packet".
- */
-
-/* packet types */
-#define TYPE_IP 0x40
-#define TYPE_UNCOMPRESSED_TCP 0x70
-#define TYPE_COMPRESSED_TCP 0x80
-#define TYPE_ERROR 0x00
-
-/* Bits in first octet of compressed packet */
-#define NEW_C  0x40    /* flag bits for what changed in a packet */
-#define NEW_I  0x20
-#define NEW_S  0x08
-#define NEW_A  0x04
-#define NEW_W  0x02
-#define NEW_U  0x01
-
-/* reserved, special-case values of above */
-#define SPECIAL_I (NEW_S|NEW_W|NEW_U)          /* echoed interactive traffic */
-#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)    /* unidirectional data */
-#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
-
-#define TCP_PUSH_BIT 0x10
-
-
-/*
- * "state" data for each active tcp conversation on the wire.  This is
- * basically a copy of the entire IP/TCP header from the last packet
- * we saw from the conversation together with a small identifier
- * the transmit & receive ends of the line use to locate saved header.
- */
-struct cstate {
-       struct cstate *cs_next; /* next most recently used cstate (xmit only) */
-       u_int16_t cs_hlen;      /* size of hdr (receive only) */
-       u_char cs_id;           /* connection # associated with this state */
-       u_char cs_filler;
-       union {
-               char csu_hdr[MAX_HDR];
-               struct ip csu_ip;       /* ip/tcp hdr from most recent packet */
-       } slcs_u;
-};
-#define cs_ip slcs_u.csu_ip
-#define cs_hdr slcs_u.csu_hdr
-
-/*
- * all the state data for one serial line (we need one of these
- * per line).
- */
-struct slcompress {
-       struct cstate *last_cs; /* most recently used tstate */
-       u_char last_recv;       /* last rcvd conn. id */
-       u_char last_xmit;       /* last sent conn. id */
-       u_int16_t flags;
-#ifndef SL_NO_STATS
-       int sls_packets;        /* outbound packets */
-       int sls_compressed;     /* outbound compressed packets */
-       int sls_searches;       /* searches for connection state */
-       int sls_misses;         /* times couldn't find conn. state */
-       int sls_uncompressedin; /* inbound uncompressed packets */
-       int sls_compressedin;   /* inbound compressed packets */
-       int sls_errorin;        /* inbound unknown type packets */
-       int sls_tossed;         /* inbound packets tossed because of error */
-#endif
-       struct cstate tstate[MAX_STATES];       /* xmit connection states */
-       struct cstate rstate[MAX_STATES];       /* receive connection states */
-};
-/* flag values */
-#define SLF_TOSS 1             /* tossing rcvd frames because of input err */
-
-void   sl_compress_init __P((struct slcompress *));
-void   sl_compress_setup __P((struct slcompress *, int));
-u_int  sl_compress_tcp __P((struct mbuf *,
-           struct ip *, struct slcompress *, int));
-int    sl_uncompress_tcp __P((u_char **, int, u_int, struct slcompress *));
-int    sl_uncompress_tcp_core __P((u_char *, int, int, u_int,
-           struct slcompress *, u_char **, u_int *));
-
-#endif /* _NET_SLCOMPRESS_H_ */
diff --git a/osf1/Makefile b/osf1/Makefile
deleted file mode 100644 (file)
index 4454279..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Dummy Makefile for OSF/1
-#
-# $Id: Makefile,v 1.6 1999/04/27 22:24:23 varadhan Exp $
-#
-
-KOBJ = if_ppp.o ppp_comp.o ppp_init.o vjcompress.o bsd-comp.o deflate.o\
-       ppp.o ppp_ahdlc.o zlib.o
-
-install: 
-       @echo
-       @echo ' Proceeding to build the kernel. You must have followed the 
-       @echo ' instructions in README.osf prior to this step'
-       @echo
-       ./makevers
-       cp ../modules/bsd-comp.c ../modules/deflate.c ../modules/ppp.c \
-       ../modules/ppp_ahdlc.c ../modules/ppp_comp.c ../modules/ppp_mod.h \
-       ../modules/vjcompress.c  $(STREAMSDIR)
-       cp ../modules/if_ppp.c $(STREAMSDIR)
-       cp ppp_init.c $(STREAMSDIR)
-       cp ../common/zlib.c ../common/zlib.h $(STREAMSDIR)
-       cp ../include/net/ppp-comp.h ../include/net/ppp_defs.h \
-       ../include/net/pppio.h ../include/net/vjcompress.h $(INCLNETDIR)
-#
-# The following assumes that OS version is at least 4.0
-#
-       @( cd /usr/sys/conf; \
-          ../bin/sourceconfig BINARY; \
-          cd /usr/sys/BINARY ; \
-          make $(KOBJ); \
-          make MODULE_ppp; \
-          cp /usr/sys/BINARY/ppp.mod /sys/BINARY/ppp.mod; \
-          echo ;\
-          echo 'Please modify lockinfo.c and run doconfig to build kernel now.' )
diff --git a/osf1/Makefile.top b/osf1/Makefile.top
deleted file mode 100644 (file)
index 90f73db..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# ppp top level makefile
-#
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-
-all:
-       cd chat; $(MAKE) all
-       cd pppd; $(MAKE) all
-       cd pppstats; $(MAKE) all
-
-install:
-       cd chat; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppstats; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       @( release=`uname -r` ;\
-         case $${release} in \
-               V[123].*) sdir="/sys/streamsm"; \
-                         idir="/sys/include/net";; \
-               V[4-9]*)  sdir="/usr/sys/BINARY/streamsm"; \
-                         idir="/usr/sys/include/net";; \
-         esac; \
-         mkdir -p $${sdir}; \
-         mkdir -p $${idir}; \
-         cd osf1; $(MAKE) STREAMSDIR=$${sdir} INCLNETDIR=$${idir} install ;)
-
-clean:
-       rm -f *~
-       cd chat; $(MAKE) clean
-       cd pppd; $(MAKE) clean
-       cd pppstats; $(MAKE) clean
-
diff --git a/osf1/makevers b/osf1/makevers
deleted file mode 100644 (file)
index 4e84981..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-#
-# create constants to figure out which version of Digital UNIX
-# (or DEC OSF/1) we're building ppp for
-#
-FULL_VERSION=`uname -r`
-MAJOR_VERSION=`echo $FULL_VERSION | cut -d. -f1 | cut -dV -f2`
-MINOR_VERSION=`echo $FULL_VERSION | cut -d. -f2`
-REVISION=`uname -v`
-
-cat >ppp_osf.h <<XYZZY
-/* Definitions for the exact version of Digital UNIX
- * (aka DEC OSF/1) we're building PPP for.
- *
- * This file is automatically generated.  DO NOT EDIT!
- */
-
-XYZZY
-
-echo "#define FULL_VERSION \"$FULL_VERSION\"" >>ppp_osf.h
-echo "#define MAJOR_VERSION $MAJOR_VERSION" >>ppp_osf.h
-echo "#define MINOR_VERSION $MINOR_VERSION" >>ppp_osf.h
-echo "#define REVISION $REVISION" >>ppp_osf.h
diff --git a/osf1/ppp_init.c b/osf1/ppp_init.c
deleted file mode 100644 (file)
index f40f8c5..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *  ppp_init.c --- PPP initialization/configuration for OSF/1.
- *
- * Get rid of svr4-style interface flag since the driver bits use
- * use the old calling conventions.
- *
- * Configure should return ENOTSUP instead of EINVAL
- *
- * Use sysconfigtab framework
- *
- * Defer initialization callback until later in boot, to avoid panic.
- *
- *  Note:  Checks for #ifdef CFG_OP_CONFIGURE is my cheap way of telling
- *      whether this system is V3.0+ or V2.0.  Is there a better way?  srt
- *  Note:  Checks for #ifdef CFG_PT_VM_AVAIL is my cheap way of telling
- *      whether this system is V4.0+ or earlier. smd
- */
-
-#include <sys/sysconfig.h>
-#include <sys/stream.h>
-
-static int configured = 0;
-static struct streamadm        tmpl_sa = {
-    OSF_STREAMS_11,
-    STR_IS_MODULE,
-    { NULL },  /* sa_name, filled in at boot time */
-    NULL,      /* sa_ttys */
-    SQLVL_ELSEWHERE,
-    "ppp"      /* "global" sync across all PPP modules */
-};
-
-extern struct streamtab ppp_ahdlcinfo;
-extern struct streamtab if_pppinfo;
-extern struct streamtab ppp_compinfo;
-extern struct streamtab pppinfo;
-
-#ifdef CFG_OP_CONFIGURE
-/* the number of actual PPP interfaces is extended
- * on-the-fly, as needed
- */
-static int nppp = 1;
-
-cfg_subsys_attr_t ppp_attributes[] = {
-    {"nppp",       CFG_ATTR_INTTYPE, 
-       CFG_OP_QUERY | CFG_OP_CONFIGURE,
-       (caddr_t) &nppp, 1, 1024, 0},
-    {"", 0, 0, 0, 0, 0, 0} /* must be the last element */
-};
-#else
-typedef sysconfig_op_t cfg_op_t;
-#endif
-
-/* Add the PPP streams modules to the pool of available modules.
- * If for some reason we can't add one of them, then remove the
- * ones we did succeed in adding.
- */
-static int
-ppp_initialize()
-{
-    dev_t devno = NODEV;
-    int ret = ESUCCESS;
-
-    if (!configured) {
-       strcpy(tmpl_sa.sa_name, "if_ppp");
-       if ((devno = strmod_add(NODEV, &if_pppinfo, &tmpl_sa)) == NODEV)
-           ret = ENODEV;
-
-       strcpy(tmpl_sa.sa_name, "ppp_ahdl");
-       if ((devno = strmod_add(NODEV, &ppp_ahdlcinfo, &tmpl_sa)) == NODEV) {
-           strcpy(tmpl_sa.sa_name, "if_ppp");
-           strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
-           ret = ENODEV;
-       }
-
-       strcpy(tmpl_sa.sa_name, "pppcomp");
-       if ((devno = strmod_add(NODEV, &ppp_compinfo, &tmpl_sa)) == NODEV) {
-           strcpy(tmpl_sa.sa_name, "if_ppp");
-           strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
-           strcpy(tmpl_sa.sa_name, "ppp_ahdl");
-           strmod_del(NODEV, &ppp_ahdlcinfo, &tmpl_sa);
-           ret = ENODEV;
-       }
-
-       strcpy(tmpl_sa.sa_name, "ppp");
-       tmpl_sa.sa_flags = STR_IS_DEVICE;
-       if ((devno = strmod_add(NODEV, &pppinfo, &tmpl_sa)) == NODEV) {
-           tmpl_sa.sa_flags = STR_IS_MODULE;
-           strcpy(tmpl_sa.sa_name, "if_ppp");
-           strmod_del(NODEV, &if_pppinfo, &tmpl_sa);
-           strcpy(tmpl_sa.sa_name, "ppp_ahdl");
-           strmod_del(NODEV, &ppp_ahdlcinfo, &tmpl_sa);
-           strcpy(tmpl_sa.sa_name, "pppcomp");
-           strmod_del(NODEV, &ppp_compinfo, &tmpl_sa);
-           ret = ENODEV;
-       }
-       configured = 1;
-    } else
-       ret = EINVAL;
-
-    return(ret);
-}
-
-#ifdef CFG_PT_VM_AVAIL
-static void
-ppp_callback(point, order, arg, event_arg)
-int    point;
-int    order;
-ulong  arg;
-ulong  event_arg;
-{
-    int ret;
-
-    ret = ppp_initialize();
-
-    return;            /* _callback returns void, losing info */
-}
-#endif /* CFG_PT_VM_AVAIL */
-
-int
-ppp_configure(op, indata, indata_size, outdata, outdata_size)
-cfg_op_t  op;
-char *indata, *outdata;
-ulong indata_size, outdata_size;
-{
-    int ret = ESUCCESS;
-
-    switch (op) {
-
-#ifdef CFG_OP_CONFIGURE
-      case CFG_OP_CONFIGURE:
-#else
-      case SYSCONFIG_CONFIGURE:
-#endif /* CFG_OP_CONFIGURE */
-
-#ifdef CFG_PT_VM_AVAIL
-       ret = register_callback(ppp_callback, 
-               CFG_PT_OLD_CONF_ALL, CFG_ORD_DONTCARE, 0L);
-#else
-       ret = ppp_initialize();
-#endif /* CFG_PT_VM_AVAIL */
-
-       break;
-
-#ifdef CFG_OP_QUERY
-      case CFG_OP_QUERY:
-#else
-      case SYSCONFIG_QUERY:
-#endif
-        break;
-
-#ifdef CFG_OP_RECONFIGURE
-      case CFG_OP_RECONFIGURE:
-        break;
-#endif
-
-      default:
-       ret = ENOTSUP;
-       break;
-    }
-
-    return(ret);
-}
diff --git a/pppd/Makefile.NeXT b/pppd/Makefile.NeXT
deleted file mode 100644 (file)
index d350599..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# pppd makefile for NeXT
-#
-# $Original: Makefile.ultrix,v 1.4 1994/09/01 00:40:40 paulus Exp $
-# $Id: Makefile.NeXT,v 1.8 2002/11/02 19:48:12 carlsonj Exp $
-#
-
-ARCHFLAGS = 
-
-BINDIR = /usr/local/ppp/bin
-MANDIR = /usr/local/ppp/man
-
-OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o eap.o md5.o ccp.o \
-       ecp.o auth.o options.o demand.o utils.o sys-NeXT.o tty.o
-
-#
-# For HPPA and SPARC, define FIXSIGS to get around posix bugs in
-# OS release 3.2.  Problems are supposed to be fixed
-# in release 3.3 (but at least for Sparc don't appear to be).
-#
-# Defining -DHAS_BROKEN_IOCTL fixes problems with the old
-# NeXT supplied serial drivers.
-#
-# Defining -DCHAPMS will enable Eric Rosenquist's extensions for
-# Microsoft's propritary CHAP scheme.  For all the details,
-# see the README.MSCHAP80 file at the top level.
-#
-
-COMPILE_FLAGS = -DNO_DRAND48 \
-       -DFIXSIGS -DHAS_BROKEN_IOCTL -DLOCK_BINARY \
-       -DLOCK_DIR=\"/usr/spool/uucp/LCK\"
-
-#
-# If you want to use MSCHAP, see the README.MSCHAP80 file.
-# Use required you get a separate DES library.  If this
-# library is installed, uncomment the following.
-
-#LIBS = -ldes
-LIBS = ../NeXT/libposix/libposix.o
-
-COPTS = $(ARCHFLAGS) -O -D_POSIX_SOURCE
-
-CFLAGS = $(COPTS) $(COMPILE_FLAGS) -I../include
-
-
-all: pppd
-
-pppd: $(OBJS) 
-       $(CC) $(CFLAGS) -o pppd $(OBJS) $(LIBS)
-
-install:
-       /bin/mkdirs $(MANDIR)/man8 $(BINDIR) 
-       install -c -s -m 4511 -o root -g daemon pppd $(BINDIR)/pppd
-       install -c -m  444 -o root -g wheel pppd.8 $(MANDIR)/man8
-
-
-clean:
-       rm -f $(OBJS) pppd *.o *~ 
-
diff --git a/pppd/Makefile.aix4 b/pppd/Makefile.aix4
deleted file mode 100644 (file)
index f1bf643..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# pppd makefile for AIX 4.1
-# $Id: Makefile.aix4,v 1.6 2002/11/02 19:48:12 carlsonj Exp $
-#
-#ifndef BINDIR
-BINDIR = /usr/sbin
-#endif
-#ifndef MANDIR
-MANDIR = /usr/man
-#ENDIF
-
-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
-       ecp.c auth.c options.c demand.c utils.c sys-aix4.c eap.c tty.c
-
-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
-       ecp.o auth.o options.o demand.o utils.o sys-aix4.o eap.o tty.o
-
-# xxx what are these?  They're not here.
-#      gencode.c grammar.c scanner.c nametoaddr.c optimize.c
-#      gencode.o grammar.o scanner.o nametoaddr.o optimize.o
-
-CC = xlc
-DEBUG_FLAGS = -DDEBUGALL
-# SECURE_FLAGS = -DREQ_SYSOPTIONS=1
-COMPILE_FLAGS = -DSTREAMS
-COPTS = -O
-LIBS= -bI:/lib/pse.exp
-LOCK_PREFIX=\"/var/locks/LCK..\"
-
-CFLAGS = -I ../include $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) $(SECURE_FLAGS)
-
-all: pppd
-
-pppd: $(PPPDOBJS)
-       $(CC) $(CFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-install: all
-       install -M 4555 -O root -G system -f $(BINDIR) pppd
-       install -M 555 -O root -f $(MANDIR)/man8 pppd.8
-
-pppd: $(PPPDOBJS)
-       $(CC) $(CFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-clean:
-       rm -f $(PPPDOBJS) pppd *~ #* core
-
-depend:
-       cpp -M $(CFLAGS) $(PPPDSRCS) >.depend
-#      makedepend $(CFLAGS) $(PPPDSRCS)
diff --git a/pppd/Makefile.bsd b/pppd/Makefile.bsd
deleted file mode 100644 (file)
index c1f7738..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#      $Id: Makefile.bsd,v 1.17 2002/11/02 19:48:12 carlsonj Exp $
-
-BINDIR?= /usr/sbin
-# -D_BITYPES is for FreeBSD, which doesn't define anything to
-# tell us that u_int32_t gets defined if <sys/types.h> is included.
-# Remove for older *BSD systems for which this isn't true.
-CFLAGS+= -g -I../include -DHAVE_PATHS_H -D_BITYPES
-
-PROG=  pppd
-SRCS=  main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
-       ecp.c demand.c auth.c options.c utils.c sys-bsd.c eap.c tty.c
-MAN=   pppd.cat8
-MAN8=  pppd.8
-BINMODE=4555
-BINOWN=        root
-
-LDADD= -lcrypt -lutil
-DPADD= ${LIBCRYPT} ${LIBUTIL}
-
-.include <bsd.prog.mk>
diff --git a/pppd/Makefile.netbsd-1.2 b/pppd/Makefile.netbsd-1.2
deleted file mode 100644 (file)
index 4dbe7e9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#      $NetBSD: Makefile,v 1.13 1996/12/18 16:54:57 christos Exp $
-
-PCAPDIR=${.CURDIR}/../../lib/libpcap
-
-PROG=  pppd
-SRCS=  auth.c cbcp.c ccp.c ecp.c chap.c chap_ms.c demand.c fsm.c ipcp.c \
-       ipxcp.c lcp.c magic.c main.c options.c sys-bsd.c upap.c eap.c tty.c \
-       utils.c
-
-.PATH: ${PCAPDIR} ${.CURDIR}/../../sys/net
-MAN=   pppd.8 pppd.cbcp.8
-SUBDIR=        pppstats chat
-BINMODE=4555
-BINOWN=        root
-
-# pick up md5, md4, and sha1
-LDADD= -lpcap -lcrypt -lutil
-DPADD= ${LIBPCAP} ${LIBCRYPT} ${LIBUTIL}
-CFLAGS+= -I. -I../include -DHAVE_PATHS_H -I${PCAPDIR} -DPPP_FILTER
-#CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Dlint
-
-.include <bsd.prog.mk>
diff --git a/pppd/Makefile.osf b/pppd/Makefile.osf
deleted file mode 100644 (file)
index 385e311..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# pppd makefile for OSF/1 on DEC Alpha
-# $Id: Makefile.osf,v 1.13 2002/11/02 19:48:12 carlsonj Exp $
-#
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-
-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c ecp.c \
-       auth.c options.c demand.c utils.c sys-osf.c md4.c chap_ms.c sha1.c \
-       eap.c tty.c
-
-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o ecp.o \
-       auth.o options.o demand.o utils.o sys-osf.o md4.o chap_ms.o sha1.o \
-       eap.o tty.o
-
-CC = cc
-#DEBUG_FLAGS = -DDEBUGALL
-COMPILE_FLAGS = -DSTREAMS -DGIDSET_TYPE=int -D_SOCKADDR_LEN -DCHAPMS \
-       -DUSE_CRYPT $(DEBUG_FLAGS) -DLOCK_DIR=\"/usr/spool/locks\"
-#COPTS = -O2
-COPTS = -g
-LIBS = 
-
-CFLAGS = -I. -I../include $(COPTS) $(COMPILE_FLAGS)
-
-all: pppd
-
-install: pppd
-       installbsd -c -m 4555 -o root -g daemon pppd $(BINDIR)/pppd
-       installbsd -c -m 444 -o root pppd.8 $(MANDIR)/man8/pppd.8
-
-pppd: $(PPPDOBJS)
-       $(CC) $(CFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-clean:
-       rm -f $(PPPDOBJS) pppd *~ #* core
-
-depend:
-       cpp -M $(CFLAGS) $(PPPDSRCS) >.depend
-#      makedepend $(CFLAGS) $(PPPDSRCS)
diff --git a/pppd/Makefile.sunos4 b/pppd/Makefile.sunos4
deleted file mode 100644 (file)
index df6f647..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Makefile for pppd under SunOS 4.
-# $Id: Makefile.sunos4,v 1.14 2003/11/27 21:25:25 paulus Exp $
-#
-
-include ../sunos4/Makedefs
-
-LIBS =
-
-CFLAGS = $(COPTS) -I../include -DSUNOS4 -DGIDSET_TYPE=int \
-       -DLOCK_DIR=\"/usr/spool/locks\"
-
-all: pppd
-
-OBJS = 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-sunos4.o tty.o eap.o
-
-pppd:  $(OBJS)
-       $(CC) -o pppd $(OBJS) $(LIBS)
-
-install:
-       $(INSTALL) -c -m 4555 pppd $(BINDIR)/pppd
-       $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8/pppd.8
-
-clean:
-       rm -f $(OBJS) pppd *~ core
diff --git a/pppd/Makefile.svr4 b/pppd/Makefile.svr4
deleted file mode 100644 (file)
index f84d758..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Makefile for pppd on generic System V release 4
-# $Id: Makefile.svr4,v 1.16 2002/11/02 19:48:12 carlsonj Exp $
-#
-
-include ../svr4/Makedefs
-
-CFLAGS = -DSVR4 -DHAS_SHADOW -I../include $(COPTS)
-LIBS = -lsocket -lnsl -lc -L/usr/ucblib -lucb
-
-all: pppd
-
-OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o ecp.o \
-       auth.o options.o demand.o utils.o sys-svr4.o eap.o tty.o
-
-pppd:  $(OBJS)
-       $(CC) -o pppd $(OBJS) $(LIBS)
-
-install:
-       $(INSTALL) -f $(BINDIR) -m 4755 -u root pppd
-       $(INSTALL) -f $(MANDIR)/man8 -m 444 pppd.8
-
-clean:
-       rm -f $(OBJS) pppd *~ core
diff --git a/pppd/Makefile.ultrix b/pppd/Makefile.ultrix
deleted file mode 100644 (file)
index 57072c8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# pppd makefile for Ultrix
-# $Id: Makefile.ultrix,v 1.13 2002/11/02 19:48:12 carlsonj Exp $
-#
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-
-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c ecp.c \
-       auth.c options.c demand.c utils.c sys-ultrix.c eap.c tty.c
-
-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o ecp.o \
-       auth.o options.o demand.o utils.o sys-ultrix.o eap.o tty.o
-
-# CC = gcc
-DEBUG_FLAGS =
-COMPILE_FLAGS = -DNO_DRAND48 -DGIDSET_TYPE=int -DULTRIX \
-       -DLOCK_BINARY -DLOCK_DIR=\"/usr/spool/uucp\"
-COPTS = -O
-LIBS =
-
-CFLAGS = -I../include $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS)
-
-all: pppd
-
-install: pppd
-       install -c -m 4555 -o root -g daemon pppd $(BINDIR)/pppd
-       install -c -m 555 -o root pppd.8 $(MANDIR)/man8
-
-pppd: $(PPPDOBJS)
-       $(CC) $(CFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-clean:
-       rm -f $(PPPDOBJS) pppd *~ #* core
-
-depend:
-       cpp -M $(CFLAGS) $(PPPDSRCS) >.depend
-#      makedepend $(CFLAGS) $(PPPDSRCS)
diff --git a/pppd/sys-NeXT.c b/pppd/sys-NeXT.c
deleted file mode 100644 (file)
index bf819f6..0000000
+++ /dev/null
@@ -1,1716 +0,0 @@
-/*
- * sys-next.c - System-dependent procedures for setting up
- * PPP interfaces on NeXT 3.2/3.3  systems
- *
- * Copyright (c) 1994 Philippe-Andre Prindeville.
- * All rights reserved.
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-NeXT.c,v 1.21 2002/12/04 23:03:32 paulus Exp $"
-
-#include <stdio.h>
-#include <termios.h>
-#include <utmp.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <libc.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/fcntl.h>
-
-#include <net/if.h>
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#if !(NS_TARGET >= 40)
-/* XXX get an error "duplicate member ip_v under 4.1 GAMMA */
-#include <netinet/ip.h>
-#endif /* NS_TARGET */
-#include <netinet/if_ether.h>
-#include <net/route.h>
-#include <netinet/in.h>
-
-#include <netinfo/ni.h>
-
-#include "pppd.h"
-
-static const char rcsid[] = RCSID;
-
-static int initdisc = -1;      /* Initial TTY discipline */
-static int initfdflags = -1;   /* Initial file descriptor flags for fd */
-static int ppp_fd = -1;                /* fd which is set to PPP discipline */
-static int loop_slave = -1;
-static int loop_master;
-static char loop_name[20];
-
-static fd_set in_fds;          /* set of fds that wait_input waits for */
-static int max_in_fd;          /* highest fd set in in_fds */
-
-extern int errno;
-
-static int     restore_term;   /* 1 => we've munged the terminal */
-static struct termios inittermios; /* Initial TTY termios */
-
-static int sockfd;             /* socket for doing interface ioctls */
-static int pppdev;  /* +++ */
-
-#if defined(i386) && defined(HAS_BROKEN_IOCTL)
-#define        ioctl   myioctl
-#endif
-
-static int if_is_up;           /* the interface is currently up */
-static u_int32_t default_route_gateway;        /* gateway addr for default route */
-static u_int32_t proxy_arp_addr;       /* remote addr for proxy arp */
-
-/* Prototypes for procedures local to this file. */
-static int translate_speed __P((int));
-static int baud_rate_of __P((int));
-static int dodefaultroute __P((u_int32_t, int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr *));
-static int ether_by_host __P((char *, struct ether_addr *));
-
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
-    setlogmask(LOG_UPTO(LOG_INFO));
-
-    /* Get an internet socket for doing socket ioctl's on. */
-    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
-       fatal("Couldn't create IP socket: %m");
-
-    if((pppdev = open("/dev/ppp0", O_RDWR, O_NONBLOCK)) == NULL)
-       fatal("Couldn't open /dev/ppp0: %m");
-      
-    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(sockfd, SIOCGIFFLAGS, &ifr) >= 0
-           && ((ifr.ifr_flags & IFF_UP) != 0)) {
-           ifr.ifr_flags &= ~IFF_UP;
-           ioctl(sockfd, SIOCSIFFLAGS, &ifr);
-       }
-    }
-
-    if (default_route_gateway)
-       cifdefaultroute(0, 0, default_route_gateway);
-    if (proxy_arp_addr)
-       cifproxyarp(0, proxy_arp_addr);
-
-    close(pppdev);
-}
-
-/*
- * 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 - maybe we're not root */
-
-    strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
-    ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
-    close(s);
-
-    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.NeXT\n\
-file in the ppp-2.2 distribution.\n";
-
-    return ok;
-}
-
-/*
- * establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-establish_ppp(fd)
-    int fd;
-{
-    int pppdisc = PPPDISC;
-    int x;
-
-    if (ioctl(fd, TIOCGETD, &initdisc) < 0)
-       fatal("ioctl(TIOCGETD): %m");
-    if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
-       fatal("ioctl(establish TIOCSETD): %m");
-
-    /*
-     * Find out which interface we were given.
-     */
-    if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0)
-       fatal("ioctl(PPPIOCGUNIT): %m");
-
-    /*
-     * Enable debug in the driver if requested.
-     */
-    if (kdebugflag) {
-       if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-           warn("ioctl(PPPIOCGFLAGS): %m");
-       } else {
-           x |= (kdebugflag & 0xFF) * SC_DEBUG;
-           if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-               warn("ioctl(PPPIOCSFLAGS): %m");
-       }
-    }
-
-    /*
-     * Set device for non-blocking reads so PPPD can poll for
-     * input from the kernel.
-     */
-    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;
-}
-
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * This shouldn't call die() because it's called from die().
- */
-void
-disestablish_ppp(fd)
-    int fd;
-{
-    /* 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;
-
-    /* Restore old line discipline. */
-    if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) < 0)
-       error("ioctl(TIOCSETD): %m");
-    initdisc = -1;
-}
-
-/*
- * Check whether the link seems not to be 8-bit clean.
- */
-void
-clean_check()
-{
-    int x;
-    char *s;
-
-    if (ioctl(ttyfd, 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) {
-           warn("Serial link is not 8-bit clean:");
-           warn("All received characters had %s", s);
-       }
-    }
-}
-
-/*
- * List of valid speeds.
- */
-struct speed {
-    int speed_int, speed_val;
-} speeds[] = {
-#ifdef B50
-    { 50, B50 },
-#endif
-#ifdef B75
-    { 75, B75 },
-#endif
-#ifdef B110
-    { 110, B110 },
-#endif
-#ifdef B134
-    { 134, B134 },
-#endif
-#ifdef B150
-    { 150, B150 },
-#endif
-#ifdef B200
-    { 200, B200 },
-#endif
-#ifdef B300
-    { 300, B300 },
-#endif
-#ifdef B600
-    { 600, B600 },
-#endif
-#ifdef B1200
-    { 1200, B1200 },
-#endif
-#ifdef B1800
-    { 1800, B1800 },
-#endif
-#ifdef B2000
-    { 2000, B2000 },
-#endif
-#ifdef B2400
-    { 2400, B2400 },
-#endif
-#ifdef B3600
-    { 3600, B3600 },
-#endif
-#ifdef B4800
-    { 4800, B4800 },
-#endif
-#ifdef B7200
-    { 7200, B7200 },
-#endif
-#ifdef B9600
-    { 9600, B9600 },
-#endif
-#ifdef B19200
-    { 19200, B19200 },
-#endif
-#ifdef B38400
-    { 38400, B38400 },
-#endif
-#ifdef EXTA
-    { 19200, EXTA },
-#endif
-#ifdef EXTB
-    { 38400, EXTB },
-#endif
-#ifdef B14400
-    { 14400, B14400 },
-#endif
-#ifdef B28800
-    { 28800, B28800 },
-#endif
-#ifdef B43200
-    { 43200, B43200 },
-#endif
-#ifdef B57600
-    { 57600, B57600 },
-#endif
-/*
-#ifndef B115200
-#warning Defining B115200
-#define B115200 20
-#endif
-*/
-#ifdef B115200
-    { 115200, B115200 },
-#endif
-    { 0, 0 }
-};
-
-/*
- * Translate from bits/second to a speed_t.
- */
-int
-translate_speed(bps)
-    int bps;
-{
-    struct speed *speedp;
-
-    if (bps == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (bps == speedp->speed_int)
-           return speedp->speed_val;
-    warn("speed %d not supported", bps);
-    return 0;
-}
-
-/*
- * Translate from a speed_t to bits/second.
- */
-static int
-baud_rate_of(speed)
-    int speed;
-{
-    struct speed *speedp;
-
-    if (speed == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (speed == speedp->speed_val)
-           return speedp->speed_int;
-    return 0;
-}
-
-
-/*
- * 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.
- */
-void
-set_up_tty(fd, local)
-    int fd, local;
-{
-    int speed, x, modembits;
-    struct termios tios;
-
-    if (tcgetattr(fd, &tios) < 0)
-       fatal("tcgetattr: %m");
-
-    if (!restore_term)
-       inittermios = tios;
-
-    tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
-
-    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 */
-    }
-
-    speed = translate_speed(inspeed);
-    if (speed) {
-       cfsetospeed(&tios, speed);
-       cfsetispeed(&tios, speed);
-    } else {
-       speed = cfgetospeed(&tios);
-       /*
-        * We can't proceed if the serial port speed is B0,
-        * since that implies that the serial port is disabled.
-        */
-       if (speed == B0)
-           fatal("Baud rate for %s is 0; need explicit baud rate",
-                 devnam);
-    }
-
-    if (modem) {
-      modembits = TIOCM_RTS | TIOCM_CTS;
-      if (ioctl(fd, (crtscts ? TIOCMBIS : TIOCMBIC), &modembits) < 0)
-       error("ioctl: TIOCMBIS/BIC: %m");
-    }
-
-    if (tcsetattr(fd, TCSAFLUSH, &tios) < 0)
-       fatal("tcsetattr: %m");
-
-   baud_rate = inspeed = baud_rate_of(speed);
-   restore_term = 1;
-}
-
-/*
- * restore_tty - restore the terminal to the saved settings.
- */
-void
-restore_tty(fd)
-    int fd;
-{
-    if (restore_term) {
-       if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
-           if (errno != ENXIO)
-               warn("tcsetattr: %m");
-       restore_term = 0;
-    }
-}
-
-/*
- * setdtr - control the DTR line on the serial port.
- * This is called from die(), so it shouldn't call die().
- *
- * The write hack is to get NXFax to recognize that there is
- * activity on the port.  Not using the write nukes
- * NXFax's capability to determine port usage.
- *
- */
-void
-setdtr(fd, on)
-int fd, on;
-{
-    int modembits = TIOCM_DTR;
-
-    if (!on)
-      {
-       write(fd, " ", 1);
-       sleep(1);
-      }
-
-/*    ioctl(fd, (on? TIOCMBIS: TIOCMBIC), &modembits); */
-    ioctl(fd, (on? TIOCSDTR: TIOCCDTR), 0);
-}
-
-
-/*
- * 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 == EWOULDBLOCK || errno == ENOBUFS
-           || errno == ENXIO || errno == EIO) {
-           warn("write: warning: %m");
-       } else {
-           fatal("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;
-{
-    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);
-}
-
-/*
- * 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) {
-           SYSDEBUG(("read: %m"));
-           return -1;
-       }
-       fatal("read: %m");
-    }
-    return len;
-}
-
-
-/*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
-    int unit, mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    u_int x;
-    struct ifreq ifr;
-
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    ifr.ifr_mtu = mtu;
-    if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0)
-       fatal("ioctl(SIOCSIFMTU): %m");
-
-    if (ioctl(ttyfd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0)
-       fatal("ioctl(PPPIOCSASYNCMAP): %m");
-
-    if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCGFLAGS): %m");
-
-    x = pcomp? x | SC_COMP_PROT: x &~ SC_COMP_PROT;
-    x = accomp? x | SC_COMP_AC: x &~ SC_COMP_AC;
-    if (ioctl(ttyfd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCSFLAGS): %m");
-}
-
-
-/*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-ppp_set_xaccm(unit, accm)
-    int unit;
-    ext_accm accm;
-{
-    if (ioctl(ttyfd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY)
-       warn("ioctl(PPPIOCSXASYNCMAP): %m");
-}
-
-
-/*
- * ppp_recv_config - configure the receive-side characteristics of
- * the ppp interface.
- */
-void
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, mru;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int x;
-
-    if (ioctl(ttyfd, PPPIOCSMRU, (caddr_t) &mru) < 0)
-       fatal("ioctl(PPPIOCSMRU): %m");
-    if (ioctl(ttyfd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0)
-       fatal("ioctl(PPPIOCSRASYNCMAP): %m");
-    if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCGFLAGS): %m");
-    x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC;
-    if (ioctl(ttyfd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCSFLAGS): %m");
-}
-
-/*
- * ccp_test - ask kernel whether a given compression method
- * is acceptable for use.
- */
-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;
-
-    if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCGFLAGS): %m");
-       return;
-    }
-    x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN;
-    x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP;
-    if (ioctl(ttyfd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       error("ioctl(PPPIOCSFLAGS): %m");
-}
-
-/*
- * 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;
-
-    if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCGFLAGS): %m");
-       return 0;
-    }
-    return x & SC_DC_FERROR;
-}
-
-/*
- * sifvjcomp - config tcp header compression
- */
-int
-sifvjcomp(u, vjcomp, cidcomp, maxcid)
-    int u, vjcomp, cidcomp, maxcid;
-{
-    u_int x;
-
-    if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPIOCGFLAGS): %m");
-       return 0;
-    }
-    x = vjcomp ? x | SC_COMP_TCP: x &~ SC_COMP_TCP;
-    x = cidcomp? x & ~SC_NO_TCP_CCID: x | SC_NO_TCP_CCID;
-    if (ioctl(ttyfd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCSFLAGS): %m");
-       return 0;
-    }
-    if (ioctl(ttyfd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
-       error("ioctl(PPPIOCSFLAGS): %m");
-       return 0;
-    }
-    return 1;
-}
-
-/*
- * sifup - Config the interface up and enable IP packets to pass.
- */
-#ifndef SC_ENABLE_IP
-#define SC_ENABLE_IP   0x100   /* compat for old versions of kernel code */
-#endif
-
-int
-sifup(u)
-    int u;
-{
-    struct ifreq ifr;
-    u_int x;
-    struct npioctl npi;
-
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl(SIOCSIFFLAGS): %m");
-       return 0;
-    }
-    if_is_up = 1;
-    npi.protocol = PPP_IP;
-    npi.mode = NPMODE_PASS;
-    if (ioctl(ttyfd, PPPIOCSNPMODE, &npi) < 0) {
-       if (errno != ENOTTY) {
-           error("ioctl(PPPIOCSNPMODE): %m");
-           return 0;
-       }
-       /* for backwards compatibility */
-       if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-           error("ioctl (PPPIOCGFLAGS): %m");
-           return 0;
-       }
-       x |= SC_ENABLE_IP;
-       if (ioctl(ttyfd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
-           error("ioctl(PPPIOCSFLAGS): %m");
-           return 0;
-       }
-    }
-    return 1;
-}
-
-/*
- * sifdown - Config the interface down and disable IP.
- */
-int
-sifdown(u)
-    int u;
-{
-    struct ifreq ifr;
-    u_int x;
-    int rv;
-    struct npioctl npi;
-
-    rv = 1;
-    npi.protocol = PPP_IP;
-    npi.mode = NPMODE_ERROR;
-    ioctl(ttyfd, PPPIOCSNPMODE, (caddr_t) &npi);
-    /* ignore errors, because ttyfd might have been closed by now. */
-
-
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       rv = 0;
-    } else {
-       ifr.ifr_flags &= ~IFF_UP;
-       if (ioctl(sockfd, 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); 
-
-/*
- * sifaddr - Config the interface IP addresses and netmask.
- */
-int
-sifaddr(u, o, h, m)
-    int u;
-    u_int32_t o, h, m;
-{
-    int ret;
-    struct ifreq ifr;
-
-    ret = 1;
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    SET_SA_FAMILY(ifr.ifr_addr, AF_INET);
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
-    if (ioctl(sockfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
-       error("ioctl(SIOCAIFADDR): %m");
-       ret = 0;
-    }
-    ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = h;
-    if (ioctl(sockfd, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) {
-       error("ioctl(SIOCSIFDSTADDR): %m");
-       ret = 0;
-    }
-    if (m != 0) {
-       ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m;
-       info("Setting interface mask to %s\n", ip_ntoa(m));
-       if (ioctl(sockfd, SIOCSIFNETMASK, (caddr_t) &ifr) < 0) {
-           error("ioctl(SIOCSIFNETMASK): %m");
-           ret = 0;
-       }
-    }
-    return ret;
-}
-
-/*
- * cifaddr - Clear the interface IP addresses, and delete routes
- * through the interface if possible.
- *
- * N.B.: under NextStep, you can't *delete* an address on an interface,
- * so we change it to 0.0.0.0...  A real hack.  But it simplifies
- * reconnection on the server side.
- */
-int
-cifaddr(u, o, h)
-    int u;
-    u_int32_t o, h;
-{
-    struct rtentry rt;
-
-#if 1
-    h = o = 0L;
-    (void) sifaddr(u, o, h, 0L);
-#endif
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = h;
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = o;
-    rt.rt_flags = RTF_HOST;
-    if (ioctl(sockfd, SIOCDELRT, (caddr_t) &rt) < 0) {
-       error("ioctl(SIOCDELRT): %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');
-}
-
-/*
- * dodefaultroute - talk to a routing socket to add/delete a default route.
- */
-int
-dodefaultroute(g, cmd)
-    u_int32_t g;
-    int cmd;
-{
-    struct rtentry rt;
-
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = 0L;
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, (cmd == 's') ? SIOCADDRT : SIOCDELRT, &rt) < 0) {
-       error("%cifdefaultroute: ioctl(%s): %m", cmd,
-              (cmd == 's') ? "SIOCADDRT" : "SIOCDELRT");
-       return 0;
-    }
-    default_route_gateway = (cmd == 's')? g: 0;
-    return 1;
-}
-
-/*
- * sifproxyarp - Make a proxy ARP entry for the peer.
- */
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_int32_t hisaddr;
-{
-    struct arpreq arpreq;
-
-    BZERO(&arpreq, sizeof(arpreq));
-
-    /*
-     * Get the hardware address of an interface on the same subnet
-     * as our local address.
-     */
-    if (!get_ether_addr(hisaddr, &arpreq.arp_ha)) {
-       error("Cannot determine ethernet address for proxy ARP");
-       return 0;
-    }
-
-    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(sockfd, SIOCSARP, (caddr_t)&arpreq) < 0) {
-       error("ioctl(SIOCSARP): %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(sockfd, SIOCDARP, (caddr_t)&arpreq) < 0) {
-       warn("ioctl(SIOCDARP): %m");
-       return 0;
-    }
-    proxy_arp_addr = 0;
-    return 1;
-}
-
-/*
- * get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
- */
-#define MAX_IFS                32
-
-int
-get_ether_addr(ipaddr, hwaddr)
-    u_int32_t ipaddr;
-    struct sockaddr *hwaddr;
-{
-    struct ifreq *ifr, *ifend, *ifp;
-    u_int32_t ina, mask;
-    struct ether_addr dla;
-    struct ifreq ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-    struct hostent *hostent;
-
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       error("ioctl(SIOCGIFCONF): %m");
-       return 0;
-    }
-
-    /*
-     * Scan through looking for an interface with an Internet
-     * address on the same subnet as `ipaddr'.
-     */
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-               ((char *)&ifr->ifr_addr + sizeof(struct sockaddr))) {
-       if (ifr->ifr_addr.sa_family == AF_INET) {
-           ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
-           strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-           /*
-            * Check that the interface is up, and not point-to-point
-            * or loopback.
-            */
-           if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-               continue;
-           if ((ifreq.ifr_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.
-            */
-           if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-               continue;
-           mask = ((struct sockaddr_in*)&ifreq.ifr_addr)->sin_addr.s_addr;
-           if ((ipaddr & mask) != (ina & mask))
-               continue;
-
-           break;
-       }
-    }
-
-    if (ifr >= ifend)
-       return 0;
-    info("found interface %s for proxy arp", ifr->ifr_name);
-
-    /*
-     * Get the hostname and look for an entry using the ethers database.
-     * Under NeXTStep this is the best we can do for now.
-     */
-    if ((hostent = gethostbyaddr((char*)&ina, sizeof(ina), AF_INET)) == NULL)
-       return 0;
-
-    if (ether_by_host(hostent->h_name, &dla)) {
-       info("Add entry for %s in /etc/ethers", hostent->h_name);
-       return 0;       /* it's not there */
-    }
-    hwaddr->sa_family = AF_UNSPEC;
-    BCOPY(&dla, hwaddr->sa_data, sizeof(dla));
-    return 1;
-}
-
-static int
-ether_by_host(hostname, etherptr)
-    char *hostname;
-    struct ether_addr *etherptr;
-{
-    struct ether_addr *thisptr;
-    void *conn;
-    ni_id root;
-    ni_namelist val;
-    char path[256];
-
-    if (!ether_hostton(hostname, etherptr))
-       return 0;
-    /*
-     * We shall now try and
-     * find the address in the
-     * top domain of netinfo.
-     */
-    slprintf(path, sizeof(path), "/machines/%s", hostname);
-
-    if (ni_open((void *)0, "/", &conn)
-     || ni_root(conn, &root)
-     || ni_pathsearch(conn, &root, path)
-     || ni_lookupprop(conn, &root, "en_address", &val))
-       return 1;
-
-    /*
-     * Now we can convert the returned string into an ethernet address.
-     */
-    strlcpy(path, val.ni_namelist_val[0], sizeof(path));
-    ni_free(conn);
-    if ((thisptr = (struct ether_addr*)ether_aton(path)) == NULL)
-       return 1;
-    BCOPY(thisptr, etherptr, sizeof(struct ether_addr));
-    return 0;
-}
-
-
-
-/*
- * 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 ifreq *ifr, *ifend, ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-
-    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.
-     */
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("ioctl(SIOCGIFCONF): %m");
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-               ((char *)&ifr->ifr_addr + sizeof(struct sockaddr))) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       ina = ((struct sockaddr_in *) &ifr->ifr_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.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-           != IFF_UP)
-           continue;
-       /*
-        * Get its netmask and OR it into our mask.
-        */
-       if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       mask |= ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
-    }
-
-    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;
-}
-
-#if 0
-/*
- * daemon - Detach us from the terminal session.
- */
-int
-daemon(nochdir, noclose)
-    int nochdir, noclose;
-{
-    int pid;
-
-    if ((pid = fork()) < 0)
-       return -1;
-    if (pid != 0)
-       exit(0);                /* parent dies */
-    (void)setsid();
-    if (!nochdir)
-       chdir("/");
-    if (!noclose) {
-       fclose(stdin);          /* don't need stdin, stdout, stderr */
-       fclose(stdout);
-       fclose(stderr);
-    }
-    return 0;
-}
-#endif
-
-char *
-strdup(s)
-    const char *s;
-{
-    char *d = malloc(strlen(s) + 1);
-
-    if (d) strcpy(d, s);
-    return d;
-}
-
-/*
- * This logwtmp() implementation is subject to the following copyright:
- *
- * Copyright (c) 1988 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define WTMPFILE        "/usr/adm/wtmp"
-
-void
-logwtmp(line, name, host)
-    const char *line, *name, *host;
-{
-    int fd;
-    struct stat buf;
-    struct utmp ut;
-
-    if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
-       return;
-    if (!fstat(fd, &buf)) {
-       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-       strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-       strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-       (void)time(&ut.ut_time);
-       if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
-           (void)ftruncate(fd, buf.st_size);
-    }
-    close(fd);
-}
-
-#if 0
-/*
- * Routines for locking and unlocking the serial device, moved here
- * from chat.c.
- */
-
-#define LOCK_PREFIX    "/usr/spool/uucp/LCK/LCK.."
-
-static char *lock_file;
-
-/*
- * lock - create a lock file for the named device
- */
-int
-lock(dev)
-    char *dev;
-{
-    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, &pid, sizeof(pid));
-           if (n <= 0) {
-               error("Can't read pid from lock file %s", lock_file);
-               close(fd);
-           } else {
-               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;
-    }
-
-    pid = getpid();
-    write(fd, &pid, sizeof pid);
-
-    close(fd);
-    return 0;
-}
-
-/*
- * unlock - remove our lockfile
- */
-void
-unlock()
-{
-    if (lock_file) {
-       unlink(lock_file);
-       free(lock_file);
-       lock_file = NULL;
-    }
-}
-#endif
-
-#if defined(i386) && defined(HAS_BROKEN_IOCTL)
-int
-ioctl(fd, cmd, c)
-    int fd, cmd;
-    caddr_t c;
-{
-#undef ioctl
-    int ret;
-
-#ifdef DEBUGIOCTL
-    int serrno;
-    u_char let, code, size;
-
-    size = (cmd >> 16) & IOCPARM_MASK;
-    let = (cmd >> 8);
-    code = cmd;
-
-    if (let == 't' && (75 <= code && code <= 90))
-    info("ioctl(%d, 0x%x ('%c', %d, %d), 0x%x)\n", fd, cmd,
-          let, code, size, c);
-#endif
-
-    ret = ioctl(fd, cmd, c);
-
-#ifdef DEBUGIOCTL
-    serrno = errno;
-    if (ret == -1)
-       info("ioctl('%c', %d, %d) errno = %d (%m)\n",
-               let, code, size, errno);
-    if (let == 't' && (75 <= code && code <= 90) && (cmd & IOC_OUT)) {
-       int i, len = ((cmd >> 16) & IOCPARM_MASK);
-       for (i = 0; i < len / 4; ++i)
-               info("word[%d] @ 0x%06x = 0x%x\n",
-                      i, &((int *) c)[i],((int *)c)[i]);
-    }
-    errno = serrno;
-#endif
-
-    if (ret == -1 && errno == EPERM)
-       errno = ret = 0;
-    return ret;
-}
-#endif /* HAS_BROKEN_IOCTL */
-
-
-#if defined(FIXSIGS) && (defined (hppa) || defined(sparc))
-
-/*
- * These redefinitions of Posix functions are necessary
- * because HPPA systems have an OS bug that causes 
- * sigaction to core dump:
- *
- * AlainF 9-Nov-1994   HACK FOR HP-PA/NEXTSTEP
- *                     sigaction(3) seems broken in the HP-PA NeXTSTEP 3.2
- *                     Posix lib. This causes pppd to SIGBUS at the expiration
- *                     of the first timeout (_sigtramp seems to invoke
- *                     the SIGALRM handler at an unreasonably low address).
- *                     All calls so sigaction(3) have been changed to calls
- *                     to sigvec(2) and sigprocmask(SIG_BLOCK,...) to
- *                     sigblock(2).
- *                     This is kind of a hack, especially since there are
- *                     other routines of the Posix lib still used, but
- *                     it worked for me.
- *
- * Dave Hess <David-Hess@net.tamu.edu> noted that 3.3 Sparc seems to
- * have the same bug.  Thus this fix has been enabled for SPARC also.
- *
- *
- */
-
-int sigemptyset(sigset_t *mask)
-{
-  *mask = 0;
-}
-
-sigaddset(sigset_t *mask, int which_sig)
-{
-  *mask |= sigmask(which_sig);
-}
-
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
-{
-   struct sigvec sv;
-   static int in = 0;
-
-   sv.sv_handler = act->sa_handler;
-   sv.sv_mask = act->sa_mask;
-   sv.sv_flags = 0;
-
-   if (!in)
-     {
-       in = 1;
-       warn("PPPD: Inside modified HP and SPARC sigaction\n");
-     }
-
-   return sigvec(sig, &sv, NULL);
-}
-
-#endif
-
-
-/*
- * Code following is added for 2.3 compatibility
- */
-
-/*
- * 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(ttyfd, 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, interface, sizeof(req.ifr_name));
-    if (ioctl(sockfd, 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;
-}
-
-
-/*
- * 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()
-{
-
-#if 0
-    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;
-#endif
-
-    return 0;
-}
-
-/*
- * 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(ttyfd, PPPIOCSNPMODE, &npi) < 0) {
-       error("ioctl(set NP %d mode to %d): %m", proto, mode);
-       return 0;
-    }
-    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()
-{
-
-#if 0
-    int flags;
-    struct termios tios;
-    int pppdisc = PPPDISC;
-
-    fatal("open_ppp_loopback called!");
-
-    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");
-
-    ttyfd = loop_slave;
-    if (ioctl(ttyfd, TIOCSETD, &pppdisc) < 0)
-       fatal("ioctl(TIOCSETD): %m");
-
-    /*
-     * Find out which interface we were given.
-     */
-    if (ioctl(ttyfd, PPPIOCGUNIT, &ifunit) < 0)
-       fatal("ioctl(PPPIOCGUNIT): %m");
-
-    /*
-     * Enable debug in the driver if requested.
-     */
-    if (kdebugflag) {
-       if (ioctl(ttyfd, PPPIOCGFLAGS, (caddr_t) &flags) < 0) {
-           warn("ioctl (PPPIOCGFLAGS): %m");
-       } else {
-           flags |= (kdebugflag & 0xFF) * SC_DEBUG;
-           if (ioctl(ttyfd, PPPIOCSFLAGS, (caddr_t) &flags) < 0)
-               warn("ioctl(PPPIOCSFLAGS): %m");
-       }
-    }
-
-    return loop_master;
-#endif
-
-}
-
-/*
- * restore_loop - reattach the ppp unit to the loopback.
- */
-void
-restore_loop()
-{
-    int x;
-
-    /*
-     * Transfer the ppp interface back to the loopback.
-     */
-    if (ioctl(ttyfd, 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);
-    ttyfd = loop_slave;
-}
-
-
-/*
- * Use the hostid as part of the random number seed.
- */
-int
-get_host_seed()
-{
-    return gethostid();
-}
-
-
-/*
- * sys_check_options - check the options that the user specified
- */
-int
-sys_check_options()
-{
-  /*
-   * We don't support demand dialing yet.
-   */
-  if (demand)
-    {
-      option_error("PPP-2.3 for NeXTSTEP does not yet support demand dialing");
-      return 0;
-    }
-  return 1;
-}
-
-
-/*
- * sys_close - Clean up in a child process before execing.
- */
-void
-sys_close()
-{
-    close(sockfd);
-    if (loop_slave >= 0) {
-       close(loop_slave);
-       close(loop_master);
-    }
-    closelog();
-}
-
-#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);
-    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
diff --git a/pppd/sys-aix4.c b/pppd/sys-aix4.c
deleted file mode 100644 (file)
index ef69813..0000000
+++ /dev/null
@@ -1,1397 +0,0 @@
-/*
- * sys-aix4.c - System-dependent procedures for setting up
- * PPP interfaces on AIX systems which use the STREAMS ppp interface.
- *
- * Copyright (c) 1994-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. 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.
- *
- * 3. 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.
- *
- * Derived from main.c and pppd.h, which are:
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-aix4.c,v 1.24 2004/11/04 10:02:26 paulus Exp $"
-
-/*
- * TODO:
- */
-
-#include <stdio.h>
-/*
-#include <stdlib.h>
-*/
-#include <errno.h>
-#include <termios.h>
-#include <sys/termiox.h>
-#include <fcntl.h>
-#include <string.h>
-#include <time.h>
-#include <utmp.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-
-#include <net/if.h>
-#include <net/ppp_defs.h>
-#include <net/route.h>
-#include <net/if_arp.h>
-#include <netinet/in.h>
-
-#include "pppd.h"
-
-static const char rcsid[] = RCSID;
-
-#ifndef ifr_mtu
-#define ifr_mtu                ifr_metric
-#endif
-
-#define        MAXMODULES      10      /* max number of module names to save */
-static struct  modlist {
-    char       modname[FMNAMESZ+1];
-} str_modules[MAXMODULES];
-static int     str_module_count = 0;
-static int     pushed_ppp;
-static int     closed_stdio;
-
-static int     restore_term;   /* 1 => we've munged the terminal */
-static struct termios inittermios; /* Initial TTY termios */
-static int     initfdflags = -1; /* Initial file descriptor flags for fd */
-
-static int sockfd;             /* socket for doing interface ioctls */
-
-static int     if_is_up;       /* Interface has been marked up */
-static u_int32_t ifaddrs[2];   /* local and remote addresses */
-static u_int32_t default_route_gateway;        /* Gateway for default route added */
-static u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
-
-#define MAX_POLLFDS    32
-static struct pollfd pollfds[MAX_POLLFDS];
-static int n_pollfds;
-
-/* Prototypes for procedures local to this file. */
-static int translate_speed __P((int));
-static int baud_rate_of __P((int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr *));
-
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    /* Get an internet socket for doing socket ioctl's on. */
-    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
-       fatal("Couldn't create IP socket: %m");
-
-    n_pollfds = 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(sockfd, SIOCGIFFLAGS, &ifr) >= 0
-           && ((ifr.ifr_flags & IFF_UP) != 0)) {
-           ifr.ifr_flags &= ~IFF_UP;
-           ioctl(sockfd, SIOCSIFFLAGS, &ifr);
-       }
-    }
-    if (ifaddrs[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);
-}
-
-/*
- * 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;
-}
-
-#if 0
-/*
- * daemon - Detach us from the terminal session.
- */
-int
-daemon(nochdir, noclose)
-    int nochdir, noclose;
-{
-    int pid;
-
-    if ((pid = fork()) < 0)
-       return -1;
-    if (pid != 0)
-       exit(0);                /* parent dies */
-    setsid();
-    if (!nochdir)
-       chdir("/");
-    if (!noclose) {
-       fclose(stdin);          /* don't need stdin, stdout, stderr */
-       fclose(stdout);
-       fclose(stderr);
-    }
-    return 0;
-}
-#endif
-
-/*
- * ppp_available - check if this kernel supports PPP.
- */
-int
-ppp_available()
-{
-    int fd, ret;
-
-    fd = open("/dev/tty", O_RDONLY, 0);
-    if (fd < 0)
-       return 1;               /* can't find out - assume we have ppp */
-    ret = ioctl(fd, I_FIND, "pppasync") >= 0;
-    close(fd);
-    return ret;
-}
-
-
-/*
- * establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-establish_ppp(fd)
-    int fd;
-{
-    /* go through and save the name of all the modules, then pop em */
-    for (;;) { 
-       if (ioctl(fd, I_LOOK, str_modules[str_module_count].modname) < 0 ||
-           ioctl(fd, I_POP, 0) < 0)
-           break;
-       SYSDEBUG(("popped stream module : %s",
-                  str_modules[str_module_count].modname));
-       str_module_count++;
-    }
-
-    /* now push the async/fcs module */
-    if (ioctl(fd, I_PUSH, "pppasync") < 0)
-       fatal("ioctl(I_PUSH, ppp_async): %m");
-    /* push the compress module */
-    if (ioctl(fd, I_PUSH, "pppcomp") < 0) {
-       warn("ioctl(I_PUSH, ppp_comp): %m");
-    }
-    /* finally, push the ppp_if module that actually handles the */
-    /* network interface */ 
-    if (ioctl(fd, I_PUSH, "pppif") < 0)
-       fatal("ioctl(I_PUSH, ppp_if): %m");
-    pushed_ppp = 1;
-    /* read mode, message non-discard mode
-    if (ioctl(fd, I_SRDOPT, RMSGN) < 0)
-       fatal("ioctl(I_SRDOPT, RMSGN): %m");
-*/
-    /*
-     * Find out which interface we were given.
-     * (ppp_if handles this ioctl)
-     */
-    if (ioctl(fd, SIOCGETU, &ifunit) < 0)
-       fatal("ioctl(SIOCGETU): %m");
-
-    /* Set debug flags in driver */
-    if (ioctl(fd, SIOCSIFDEBUG, kdebugflag) < 0) {
-       error("ioctl(SIOCSIFDEBUG): %m");
-    }
-
-    /* close stdin, stdout, stderr if they might refer to the device */
-    if (default_device && !closed_stdio) {
-       int i;
-
-       for (i = 0; i <= 2; ++i)
-           if (i != fd && i != sockfd)
-               close(i);
-       closed_stdio = 1;
-    }
-
-    /*
-     * 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;
-}
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * It attempts to reconstruct the stream with the previously popped
- * modules.  This shouldn't call die() because it's called from die().
- */
-void
-disestablish_ppp(fd)
-    int fd;
-{
-    int flags;
-    char *s;
-
-    /* Reset non-blocking mode on the file descriptor. */
-    if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
-       warn("Couldn't restore device fd flags: %m");
-    initfdflags = -1;
-
-    if (hungup) {
-       /* we can't push or pop modules after the stream has hung up */
-       str_module_count = 0;
-       restore_term = 0;       /* nor can we fix up terminal settings */
-       return;
-    }
-
-    if (pushed_ppp) {
-       /*
-        * Check whether the link seems not to be 8-bit clean.
-        */
-       if (ioctl(fd, SIOCGIFDEBUG, (caddr_t) &flags) == 0) {
-           s = NULL;
-           switch (~flags & PAI_FLAGS_HIBITS) {
-           case PAI_FLAGS_B7_0:
-               s = "bit 7 set to 1";
-               break;
-           case PAI_FLAGS_B7_1:
-               s = "bit 7 set to 0";
-               break;
-           case PAI_FLAGS_PAR_EVEN:
-               s = "odd parity";
-               break;
-           case PAI_FLAGS_PAR_ODD:
-               s = "even parity";
-               break;
-           }
-           if (s != NULL) {
-               warn("Serial link is not 8-bit clean:");
-               warn("All received characters had %s", s);
-           }
-       }
-    }
-
-    while (ioctl(fd, I_POP, 0) == 0)   /* pop any we pushed */
-       ;
-    pushed_ppp = 0;
-  
-    for (; str_module_count > 0; str_module_count--) {
-       if (ioctl(fd, I_PUSH, str_modules[str_module_count-1].modname)) {
-           if (errno != ENXIO)
-               warn("str_restore: couldn't push module %s: %m",
-                    str_modules[str_module_count-1].modname);
-       } else {
-           SYSDEBUG(("str_restore: pushed module %s",
-                     str_modules[str_module_count-1].modname));
-       }
-    }
-}
-
-
-/*
- * List of valid speeds.
- */
-struct speed {
-    int speed_int, speed_val;
-} speeds[] = {
-#ifdef B50
-    { 50, B50 },
-#endif
-#ifdef B75
-    { 75, B75 },
-#endif
-#ifdef B110
-    { 110, B110 },
-#endif
-#ifdef B134
-    { 134, B134 },
-#endif
-#ifdef B150
-    { 150, B150 },
-#endif
-#ifdef B200
-    { 200, B200 },
-#endif
-#ifdef B300
-    { 300, B300 },
-#endif
-#ifdef B600
-    { 600, B600 },
-#endif
-#ifdef B1200
-    { 1200, B1200 },
-#endif
-#ifdef B1800
-    { 1800, B1800 },
-#endif
-#ifdef B2000
-    { 2000, B2000 },
-#endif
-#ifdef B2400
-    { 2400, B2400 },
-#endif
-#ifdef B3600
-    { 3600, B3600 },
-#endif
-#ifdef B4800
-    { 4800, B4800 },
-#endif
-#ifdef B7200
-    { 7200, B7200 },
-#endif
-#ifdef B9600
-    { 9600, B9600 },
-#endif
-#ifdef B19200
-    { 19200, B19200 },
-#endif
-#ifdef B38400
-    { 38400, B38400 },
-#endif
-#ifdef EXTA
-    { 19200, EXTA },
-#endif
-#ifdef EXTB
-    { 38400, EXTB },
-#endif
-#ifdef B57600
-    { 57600, B57600 },
-#endif
-#ifdef B115200
-    { 115200, B115200 },
-#endif
-    { 0, 0 }
-};
-
-/*
- * Translate from bits/second to a speed_t.
- */
-static int
-translate_speed(bps)
-    int bps;
-{
-    struct speed *speedp;
-
-    if (bps == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (bps == speedp->speed_int)
-           return speedp->speed_val;
-    warn("speed %d not supported", bps);
-    return 0;
-}
-
-/*
- * Translate from a speed_t to bits/second.
- */
-static int
-baud_rate_of(speed)
-    int speed;
-{
-    struct speed *speedp;
-
-    if (speed == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (speed == speedp->speed_val)
-           return speedp->speed_int;
-    return 0;
-}
-
-/*
- * 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.
- */
-void
-set_up_tty(fd, local)
-    int fd, local;
-{
-    int speed;
-    struct termios tios;
-    struct termiox tiox;
-
-    if (tcgetattr(fd, &tios) < 0)
-       fatal("tcgetattr: %m");
-
-
-    if (!restore_term)
-       inittermios = tios;
-
-    tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
-    if (crtscts > 0) {
-        bzero(&tiox, sizeof(tiox));
-        ioctl(fd, TCGETX, &tiox);
-        tiox.x_hflag = RTSXOFF;
-        ioctl(fd, TCSETX, &tiox);
-        tios.c_cflag &= ~(IXON | IXOFF);
-    } else if (crtscts < 0) {
-        bzero(&tiox, sizeof(tiox));
-        ioctl(fd, TCGETX, &tiox);
-        tiox.x_hflag &= ~RTSXOFF;
-        ioctl(fd, TCSETX, &tiox);
-    }
-
-
-    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 */
-    }
-
-    speed = translate_speed(inspeed);
-    if (speed) {
-       cfsetospeed(&tios, speed);
-       cfsetispeed(&tios, speed);
-    } else {
-       speed = cfgetospeed(&tios);
-       /*
-        * We can't proceed if the serial port speed is B0,
-        * since that implies that the serial port is disabled.
-        */
-       if (speed == B0)
-           fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
-    }
-
-    if (tcsetattr(fd, TCSAFLUSH, &tios) < 0)
-       fatal("tcsetattr: %m");
-
-    baud_rate = inspeed = baud_rate_of(speed);
-    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");
-       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);
-}
-
-
-/*
- * output - Output PPP packet.
- */
-void
-output(unit, p, len)
-    int unit;
-    u_char *p;
-    int len;
-{
-    struct strbuf str;
-    int retries;
-    struct pollfd pfd;
-
-    if (debug)
-       dbglog("sent %P", p, len);
-
-    str.len = len;
-    str.buf = (caddr_t) p;
-    retries = 4;
-    while (putmsg(ttyfd, NULL, &str, 0) < 0) {
-       if (--retries < 0 || (errno != EWOULDBLOCK && errno != EAGAIN)) {
-           if (errno != ENXIO)
-               error("Couldn't send packet: %m");
-           break;
-       }
-       pfd.fd = ttyfd;
-       pfd.events = POLLOUT;
-       poll(&pfd, 1, 250);     /* wait for up to 0.25 seconds */
-    }
-}
-
-/*
- * wait_input - wait for input, for a length of time specified in *timo.
- */
-void
-wait_input(timo)
-    struct timeval *timo;
-{
-    int t;
-
-    t = timo == NULL? -1: timo->tv_sec * 1000 + timo->tv_usec / 1000;
-    if (poll(pollfds, n_pollfds, t) < 0 && errno != EINTR)
-       fatal("poll: %m");
-}
-
-/*
- * add_fd - add an fd to the set that wait_input waits for.
- */
-void add_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n)
-       if (pollfds[n].fd == fd)
-           return;
-    if (n_pollfds < MAX_POLLFDS) {
-       pollfds[n_pollfds].fd = fd;
-       pollfds[n_pollfds].events = POLLIN | POLLPRI | POLLHUP;
-       ++n_pollfds;
-    } else
-       error("Too many inputs!");
-}
-
-/*
- * remove_fd - remove an fd from the set that wait_input waits for.
- */
-void remove_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n) {
-       if (pollfds[n].fd == fd) {
-           while (++n < n_pollfds)
-               pollfds[n-1] = pollfds[n];
-           --n_pollfds;
-           break;
-       }
-    }
-}
-
-
-/*
- * read_packet - get a PPP packet from the serial device.
- */
-int
-read_packet(buf)
-    u_char *buf;
-{
-    struct strbuf str, ctl;
-    int len, i;
-    unsigned char ctlbuf[16];
-
-    str.maxlen = PPP_MTU + PPP_HDRLEN;
-    str.buf = (caddr_t) buf;
-    ctl.maxlen = sizeof(ctlbuf);
-    ctl.buf = (caddr_t) ctlbuf;
-    i = 0;
-    len = getmsg(ttyfd, &ctl, &str, &i);
-    if (len < 0) {
-       if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
-           return -1;
-       }
-       fatal("getmsg %m");
-    }
-    if (len) 
-       SYSDEBUG(("getmsg returned 0x%x", len));
-    if (ctl.len > 0)
-       notice("got ctrl msg len %d %x %x\n", ctl.len, ctlbuf[0], ctlbuf[1]);
-
-    if (str.len < 0) {
-       SYSDEBUG(("getmsg short return length %d", str.len));
-       return -1;
-    }
-
-    return str.len;
-}
-
-
-/*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
-    int unit, mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int c;
-    struct ifreq ifr;
-
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    ifr.ifr_mtu = mtu;
-    if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0)
-       fatal("ioctl(SIOCSIFMTU): %m");
-
-    if(ioctl(ttyfd, SIOCSIFASYNCMAP, asyncmap) < 0)
-       fatal("ioctl(SIOCSIFASYNCMAP): %m");
-
-    c = (pcomp? 1: 0);
-    if(ioctl(ttyfd, SIOCSIFCOMPPROT, c) < 0)
-       fatal("ioctl(SIOCSIFCOMPPROT): %m");
-
-    c = (accomp? 1: 0);
-    if(ioctl(ttyfd, SIOCSIFCOMPAC, c) < 0)
-       fatal("ioctl(SIOCSIFCOMPAC): %m");
-}
-
-
-/*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-ppp_set_xaccm(unit, accm)
-    int unit;
-    ext_accm accm;
-{
-    if (ioctl(ttyfd, SIOCSIFXASYNCMAP, accm) < 0 && errno != ENOTTY)
-       warn("ioctl(set extended ACCM): %m");
-}
-
-
-/*
- * ppp_recv_config - configure the receive-side characteristics of
- * the ppp interface.
- */
-void
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, mru;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    char c;
-
-    if (ioctl(ttyfd, SIOCSIFMRU, mru) < 0) {
-       error("ioctl(SIOCSIFMRU): %m");
-    }
-
-    if (ioctl(ttyfd, SIOCSIFRASYNCMAP, (caddr_t) asyncmap) < 0) {
-       error("ioctl(SIOCSIFRASYNCMAP): %m");
-    }
-
-    c = 2 + (pcomp? 1: 0);
-    if(ioctl(ttyfd, SIOCSIFCOMPPROT, c) < 0) {
-       error("ioctl(SIOCSIFCOMPPROT): %m");
-    }
-
-    c = 2 + (accomp? 1: 0);
-    if (ioctl(ttyfd, SIOCSIFCOMPAC, c) < 0) {
-       error("ioctl(SIOCSIFCOMPAC): %m");
-    }
-}
-
-/*
- * ccp_test - ask kernel whether a given compression method
- * is acceptable for use.
- */
-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;
-
-    if ((unsigned) opt_len > MAX_PPP_OPTION)
-       opt_len = MAX_PPP_OPTION;
-    data.length = opt_len;
-    data.transmit = for_transmit;
-    BCOPY(opt_ptr, data.opt_data, opt_len);
-    if (ioctl(ttyfd, SIOCSCOMPRESS, &data) >= 0)
-       return 1;
-    return (errno == ENOSR)? 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 = (isopen? 1: 0) + (isup? 2: 0);
-    if (ioctl(ttyfd, SIOCSIFCOMP, x) < 0 && errno != ENOTTY)
-       error("ioctl (SIOCSIFCOMP): %m");
-}
-
-/*
- * 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;
-
-    if (ioctl(ttyfd, SIOCGIFCOMP, &x) < 0) {
-       error("ioctl(SIOCGIFCOMP): %m");
-       return 0;
-    }
-    return x & CCP_FATALERROR;
-}
-
-/*
- * sifvjcomp - config tcp header compression
- */
-int
-sifvjcomp(u, vjcomp, cidcomp, maxcid)
-    int u, vjcomp, cidcomp, maxcid;
-{
-    int x;
-
-    x = (vjcomp? 1: 0) + (cidcomp? 0: 2) + (maxcid << 4);
-    if (ioctl(ttyfd, SIOCSIFVJCOMP, x) < 0) {
-       error("ioctl(SIOCSIFVJCOMP): %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(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(sockfd, 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.
- */
-int
-sifdown(u)
-    int u;
-{
-    struct ifreq ifr;
-    int rv;
-    struct npioctl npi;
-
-    rv = 1;
-    npi.protocol = PPP_IP;
-    npi.mode = NPMODE_ERROR;
-    ioctl(ttyfd, SIOCSETNPMODE, &npi);
-    /* ignore errors, because ttyfd might have been closed by now. */
-
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-        error("ioctl (SIOCGIFFLAGS): %m");
-        rv = 0;
-    } else {
-        ifr.ifr_flags &= ~IFF_UP;
-        if (ioctl(sockfd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
-            error("ioctl(SIOCSIFFLAGS): %m");
-            rv = 0;
-        } else
-           if_is_up = 0;
-    }
-    return rv;
-}
-
-/*
- * SET_SA_FAMILY - initialize a struct sockaddr, setting the sa_family field.
- */
-#define SET_SA_FAMILY(addr, family)            \
-    BZERO((char *) &(addr), sizeof(addr));     \
-    addr.sa_family = (family);
-
-/*
- * sifaddr - Config the interface IP addresses and netmask.
- */
-int
-sifaddr(u, o, h, m)
-    int u;
-    u_int32_t o, h, m;
-{
-    int ret;
-    struct ifreq ifr;
-
-    ret = 1;
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    SET_SA_FAMILY(ifr.ifr_addr, AF_INET);
-    if (m != 0) {
-        info("Setting interface mask to %s\n", ip_ntoa(m));
-        ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m;
-        if (ioctl(sockfd, SIOCSIFNETMASK, (caddr_t) &ifr) < 0) {
-            error("ioctl(SIOCSIFNETMASK): %m");
-            ret = 0;
-        }
-    }
-
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
-    if (ioctl(sockfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
-        error("ioctl(SIOCSIFADDR): %m");
-        ret = 0;
-    }
-
-    SET_SA_FAMILY(ifr.ifr_dstaddr, AF_INET);
-    ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = h;
-    if (ioctl(sockfd, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) {
-        error("ioctl(SIOCSIFDSTADDR): %m");
-        ret = 0;
-    }
-
-    /* XXX is this necessary? */
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
-    if (ioctl(sockfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
-        error("ioctl(SIOCSIFADDR): %m");
-        ret = 0;
-    }
-
-    ifaddrs[0] = o;
-    ifaddrs[1] = h;
-    return ret;
-}
-
-/*
- * 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 ortentry rt;
-
-    ifaddrs[0] = 0;
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = h;
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = o;
-    rt.rt_flags = RTF_HOST;
-    if (ioctl(sockfd, SIOCDELRT, (caddr_t) &rt) < 0) {
-       error("ioctl(SIOCDELRT): %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;
-{
-    struct ortentry rt;
-
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, SIOCADDRT, &rt) < 0) {
-       error("default route ioctl(SIOCADDRT): %m");
-       return 0;
-    }
-    default_route_gateway = g;
-    return 1;
-}
-
-/*
- * cifdefaultroute - delete a default route through the address given.
- */
-int
-cifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct ortentry rt;
-
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, SIOCDELRT, &rt) < 0) {
-       error("default route ioctl(SIOCDELRT): %m");
-       return 0;
-    }
-    default_route_gateway = 0;
-    return 1;
-}
-
-/*
- * sifproxyarp - Make a proxy ARP entry for the peer.
- */
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_int32_t hisaddr;
-{
-    struct arpreq arpreq;
-
-    BZERO(&arpreq, sizeof(arpreq));
-
-    /*
-     * Get the hardware address of an interface on the same subnet
-     * as our local address.
-     */
-    if (!get_ether_addr(hisaddr, &arpreq.arp_ha)) {
-       warn("Cannot determine ethernet address for proxy ARP");
-       return 0;
-    }
-
-    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(sockfd, SIOCSARP, (caddr_t)&arpreq) < 0) {
-       error("ioctl(SIOCSARP): %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(sockfd, SIOCDARP, (caddr_t)&arpreq) < 0) {
-       error("ioctl(SIOCDARP): %m");
-       return 0;
-    }
-    proxy_arp_addr = 0;
-    return 1;
-}
-
-/*
- * get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.  Code borrowed from myetheraddr.c
- * in the cslip-2.6 distribution, which is subject to the following
- * copyright notice (which also applies to logwtmp below):
- *
- * Copyright (c) 1990, 1992 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <nlist.h>
-#include <arpa/inet.h>
-#include <netinet/in_var.h>
-#include <net/if_dl.h>
-
-/* Cast a struct sockaddr to a structaddr_in */
-#define SATOSIN(sa) ((struct sockaddr_in *)(sa))
-
-/* Determine if "bits" is set in "flag" */
-#define ALLSET(flag, bits) (((flag) & (bits)) == (bits))
-
-static struct nlist nl[] = {
-#define N_IFNET 0
-       { "ifnet" },
-       { 0 }
-};
-
-int kvm_read(int fd, off_t offset, void *buf, int nbytes)
-{
-    if (lseek(fd, offset, SEEK_SET) != offset) {
-        error("lseek in kmem: %m");
-        return(0);
-    }
-    return(read(fd, buf, nbytes));
-}
-
-int
-get_ether_addr(ipaddr, hwaddr)
-    u_long ipaddr;
-    struct sockaddr *hwaddr;
-{
-    int         kd;
-    register struct ifnet *ifp;
-    register struct arpcom *ac;
-    struct arpcom arpcom;
-    struct in_addr *inp;
-    register struct ifaddr *ifa;
-    register struct in_ifaddr *in;
-    union {
-        struct ifaddr ifa;
-        struct in_ifaddr in;
-    } ifaddr;
-    struct ifaddr       *ifap;
-    struct sockaddr     ifaddrsaddr;
-    struct sockaddr_in  ifmasksaddr;
-    struct sockaddr_in  *ifinetptr;
-    struct sockaddr_dl  *iflinkptr;
-    u_long addr, mask, ifip;
-    int         found = 0;
-
-/* Open kernel memory for reading */
-    if ((kd = open("/dev/kmem", O_RDONLY)) < 0) {
-        error("/dev/kmem: %m");
-        return 0;
-    }
-
-/* Fetch namelist */
-    if (nlist("/unix", nl) != 0) {
-        error("nlist(): %m");
-        return 0;
-    }
-
-    ac = &arpcom;
-    ifp = &arpcom.ac_if;
-    ifa = &ifaddr.ifa;
-    in = &ifaddr.in;
-
-    if (kvm_read(kd, nl[N_IFNET].n_value, (char *)&addr, sizeof(addr))
-        != sizeof(addr)) {
-        error("error reading ifnet addr");
-        return 0;
-    }
-    for ( ; addr && !found; addr = (u_long)ifp->if_next) {
-        if (kvm_read(kd, addr, (char *)ac, sizeof(*ac)) != sizeof(*ac)) {
-            error("error reading ifnet");
-            return 0;
-        }
-
-/* Only look at configured, broadcast interfaces */
-        if (!ALLSET(ifp->if_flags, IFF_UP | IFF_BROADCAST))
-            continue;
-/* This probably can't happen... */
-        if (ifp->if_addrlist == 0)
-            continue;
-
-/* Get interface ip address */
-        for (ifap = ifp->if_addrlist; ifap; ifap=ifaddr.ifa.ifa_next) {
-            if (kvm_read(kd, (u_long)ifap, (char *)&ifaddr,
-                     sizeof(ifaddr)) != sizeof(ifaddr)) {
-                error("error reading ifaddr");
-                return 0;
-            }
-            if (kvm_read(kd, (u_long)ifaddr.ifa.ifa_addr, &ifaddrsaddr,
-                sizeof(struct sockaddr_in)) != sizeof(struct sockaddr_in)) {
-                error("error reading ifaddrsaddr");
-                return(0);
-            }
-            if (kvm_read(kd, (u_long)ifaddr.ifa.ifa_netmask, &ifmasksaddr,
-                sizeof(struct sockaddr_in)) != sizeof(struct sockaddr_in)) {
-                error("error reading ifmasksaddr");
-                return(0);
-            }
-    /* Check if this interface on the right subnet */
-            switch (ifaddrsaddr.sa_family) {
-            case AF_LINK :
-                hwaddr->sa_family = AF_UNSPEC;
-                iflinkptr = (struct sockaddr_dl *) &ifaddrsaddr;
-                bcopy(LLADDR(iflinkptr),hwaddr->sa_data,iflinkptr->sdl_alen);
-                break;
-            case AF_INET:
-                ifinetptr= (struct sockaddr_in *) &ifaddrsaddr;
-                ifip = ifinetptr->sin_addr.s_addr;
-                if (kvm_read(kd, (u_long)ifaddr.ifa.ifa_netmask, &ifmasksaddr,
-                    sizeof(struct sockaddr_in)) != sizeof(struct sockaddr_in)) {
-                    error("error reading ifmasksaddr");
-                    return(0);
-                }
-                mask = ifmasksaddr.sin_addr.s_addr;
-                if ((ipaddr & mask) == (ifip & mask))
-                    ++found;
-                break;
-            default:
-                break;
-            }
-   
-        }
-    }
-    return(found);
-}
-
-/*
- * 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.
- */
-#define MAX_IFS                32
-
-u_int32_t
-GetMask(addr)
-    u_int32_t addr;
-{
-    u_int32_t mask, nmask, ina;
-    struct ifreq *ifr, *ifend, ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-
-    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.
-     */
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("ioctl(SIOCGIFCONF): %m");
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ++ifr) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       ina = ((struct sockaddr_in *) &ifr->ifr_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.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-           != IFF_UP)
-           continue;
-       /*
-        * Get its netmask and OR it into our mask.
-        */
-       if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       mask |= ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
-    }
-
-    return mask;
-}
-
-#define        WTMPFILE        "/var/adm/wtmp"
-
-void
-logwtmp(line, name, host)
-    const char *line, *name, *host;
-{
-    int fd;
-    struct stat buf;
-    struct utmp ut;
-
-    if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
-       return;
-    if (!fstat(fd, &buf)) {
-       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-       strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-       strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-       (void)time(&ut.ut_time);
-       if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
-           (void)ftruncate(fd, buf.st_size);
-    }
-    close(fd);
-}
-
-/*
- * Use the hostid as part of the random number seed.
- */
-int
-get_host_seed()
-{
-    return gethostid();
-}
-
-/*
- * Code for locking/unlocking the serial device.
- */
-
-static char *devlocked = (char *) 0;
-
-int lock(char *device)
-{
-    char       *devname;
-    int                rc;
-
-    if (devname = strrchr(device,'/'))
-       ++devname;
-    else
-       devname = device;
-
-    if ((rc = ttylock(devname)) == 0) {
-       devlocked = strdup(devname);
-    } else
-       devlocked = (char *) 0;
-
-    return(rc);
-}
-
-int unlock()
-{
-    int rc = 0;
-
-    if (devlocked) {
-       rc = ttyunlock(devlocked);
-       free(devlocked);
-       devlocked = (char *) 0;
-    }
-    return(rc);
-}
-
diff --git a/pppd/sys-bsd.c b/pppd/sys-bsd.c
deleted file mode 100644 (file)
index da186a4..0000000
+++ /dev/null
@@ -1,1579 +0,0 @@
-/*
- * sys-bsd.c - System-dependent procedures for setting up
- * PPP interfaces on bsd-4.4-ish systems (including 386BSD, NetBSD, etc.)
- *
- * Copyright (c) 1993-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. 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.
- *
- * 3. 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.
- *
- * Derived from main.c and pppd.h, which are:
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-bsd.c,v 1.50 2004/11/04 10:02:26 paulus Exp $"
-/*     $NetBSD: sys-bsd.c,v 1.1.1.3 1997/09/26 18:53:04 christos Exp $ */
-
-/*
- * 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 <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#ifdef NetBSD1_2
-#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>
-
-#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"
-
-static const char rcsid[] = RCSID;
-
-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 sockfd;             /* socket for doing interface ioctls */
-
-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 dodefaultroute __P((u_int32_t, int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr_dl *));
-
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    /* Get an internet socket for doing socket ioctl's on. */
-    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
-       fatal("Couldn't create IP socket: %m");
-
-    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(sockfd, SIOCGIFFLAGS, &ifr) >= 0
-           && ((ifr.ifr_flags & IFF_UP) != 0)) {
-           ifr.ifr_flags &= ~IFF_UP;
-           ioctl(sockfd, 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(sockfd);
-    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);
-
-    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";
-    return ok;
-}
-
-/*
- * establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-establish_ppp(fd)
-    int fd;
-{
-    int pppdisc = PPPDISC;
-    int x;
-
-    if (demand) {
-       /*
-        * Demand mode - prime the old ppp device to relinquish the unit.
-        */
-       if (ioctl(ppp_fd, PPPIOCXFERUNIT, 0) < 0)
-           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) {
-       if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-           warn("ioctl (PPPIOCGFLAGS): %m");
-       } else {
-           x |= (kdebugflag & 0xFF) * SC_DEBUG;
-           if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-               warn("ioctl(PPPIOCSFLAGS): %m");
-       }
-    }
-
-    /*
-     * 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.
- */
-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;
-}
-
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * This shouldn't call die() because it's called from die().
- */
-void
-disestablish_ppp(fd)
-    int fd;
-{
-    /* 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;
-
-    /* Restore old line discipline. */
-    if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) < 0)
-       error("ioctl(TIOCSETD): %m");
-    initdisc = -1;
-
-    if (fd == ppp_fd)
-       ppp_fd = -1;
-}
-
-/*
- * Check whether the link seems not to be 8-bit clean.
- */
-void
-clean_check()
-{
-    int x;
-    char *s;
-
-    if (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) {
-           warn("Serial link is not 8-bit clean:");
-           warn("All received characters had %s", s);
-       }
-    }
-}
-
-/*
- * 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);
-}
-
-/*
- * 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) {
-       if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &flags) < 0) {
-           warn("ioctl (PPPIOCGFLAGS): %m");
-       } else {
-           flags |= (kdebugflag & 0xFF) * SC_DEBUG;
-           if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &flags) < 0)
-               warn("ioctl(PPPIOCSFLAGS): %m");
-       }
-    }
-
-    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("internal error: file descriptor too large (%d)", fd);
-    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("internal error: file descriptor too large (%d)", loop_master);
-    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;
-}
-
-
-/*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
-    int unit, mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    u_int x;
-    struct ifreq ifr;
-
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    ifr.ifr_mtu = mtu;
-    if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0)
-       fatal("ioctl(SIOCSIFMTU): %m");
-
-    if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0)
-       fatal("ioctl(PPPIOCSASYNCMAP): %m");
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl (PPPIOCGFLAGS): %m");
-    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;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCSFLAGS): %m");
-}
-
-
-/*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-ppp_set_xaccm(unit, accm)
-    int unit;
-    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
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, 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");
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl (PPPIOCGFLAGS): %m");
-    x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCSFLAGS): %m");
-}
-
-/*
- * 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;
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl (PPPIOCGFLAGS): %m");
-       return;
-    }
-    x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN;
-    x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       error("ioctl(PPPIOCSFLAGS): %m");
-}
-
-/*
- * 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;
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCGFLAGS): %m");
-       return 0;
-    }
-    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(sockfd, 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, active)
-    struct bpf_program *pass, *active;
-{
-    int ret = 1;
-
-    if (pass->bf_len > 0) {
-       if (ioctl(ppp_fd, PPPIOCSPASS, pass) < 0) {
-           error("Couldn't set pass-filter in kernel: %m");
-           ret = 0;
-       }
-    }
-    if (active->bf_len > 0) {
-       if (ioctl(ppp_fd, PPPIOCSACTIVE, active) < 0) {
-           error("Couldn't set active-filter 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;
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl (PPPIOCGFLAGS): %m");
-       return 0;
-    }
-    x = vjcomp ? x | SC_COMP_TCP: x &~ SC_COMP_TCP;
-    x = cidcomp? x & ~SC_NO_TCP_CCID: x | SC_NO_TCP_CCID;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCSFLAGS): %m");
-       return 0;
-    }
-    if (vjcomp && ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
-       error("ioctl(PPPIOCSFLAGS): %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(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(sockfd, 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(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       rv = 0;
-    } else {
-       ifr.ifr_flags &= ~IFF_UP;
-       if (ioctl(sockfd, 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(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) {
-       if (errno != EADDRNOTAVAIL)
-           warn("Couldn't remove interface address: %m");
-    }
-    if (ioctl(sockfd, 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(sockfd, 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');
-}
-
-/*
- * 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      mask;
-    } 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;
-    rtmsg.dst.sin_len = sizeof(rtmsg.dst);
-    rtmsg.dst.sin_family = AF_INET;
-    rtmsg.gway.sin_len = sizeof(rtmsg.gway);
-    rtmsg.gway.sin_family = AF_INET;
-    rtmsg.gway.sin_addr.s_addr = g;
-    rtmsg.mask.sin_len = sizeof(rtmsg.dst);
-    rtmsg.mask.sin_family = AF_INET;
-
-    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(sockfd, 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(sockfd, 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.
- */
-#define MAX_IFS                32
-
-static int
-get_ether_addr(ipaddr, hwaddr)
-    u_int32_t ipaddr;
-    struct sockaddr_dl *hwaddr;
-{
-    struct ifreq *ifr, *ifend, *ifp;
-    u_int32_t ina, mask;
-    struct sockaddr_dl *dla;
-    struct ifreq ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       error("ioctl(SIOCGIFCONF): %m");
-       return 0;
-    }
-
-    /*
-     * Scan through looking for an interface with an Internet
-     * address on the same subnet as `ipaddr'.
-     */
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-               ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len)) {
-       if (ifr->ifr_addr.sa_family == AF_INET) {
-           ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
-           strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-           /*
-            * Check that the interface is up, and not point-to-point
-            * or loopback.
-            */
-           if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-               continue;
-           if ((ifreq.ifr_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.
-            */
-           if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-               continue;
-           mask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;
-           if ((ipaddr & mask) != (ina & mask))
-               continue;
-
-           break;
-       }
-    }
-
-    if (ifr >= ifend)
-       return 0;
-    info("found interface %s for proxy arp", ifr->ifr_name);
-
-    /*
-     * Now scan through again looking for a link-level address
-     * for this interface.
-     */
-    ifp = ifr;
-    for (ifr = ifc.ifc_req; ifr < ifend; ) {
-       if (strcmp(ifp->ifr_name, ifr->ifr_name) == 0
-           && ifr->ifr_addr.sa_family == AF_LINK) {
-           /*
-            * Found the link-level address - copy it out
-            */
-           dla = (struct sockaddr_dl *) &ifr->ifr_addr;
-           BCOPY(dla, hwaddr, dla->sdl_len);
-           return 1;
-       }
-       ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
-    }
-
-    return 0;
-}
-
-/*
- * 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 ifreq *ifr, *ifend, ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-
-    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.
-     */
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("ioctl(SIOCGIFCONF): %m");
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-               ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len)) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       ina = ((struct sockaddr_in *) &ifr->ifr_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.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-           != IFF_UP)
-           continue;
-       /*
-        * Get its netmask and OR it into our mask.
-        */
-       if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       mask |= ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
-    }
-
-    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/pppd/sys-osf.c b/pppd/sys-osf.c
deleted file mode 100644 (file)
index e2f4218..0000000
+++ /dev/null
@@ -1,1798 +0,0 @@
-/*
- * System-dependent procedures for pppd under Digital UNIX (OSF/1).
- *
- * Copyright (c) 1994-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. 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.
- *
- * 3. 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.
- *
- * Derived from main.c and pppd.h, which are:
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-osf.c,v 1.33 2004/11/04 10:02:26 paulus Exp $"
-
-#include <syslog.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <termios.h>
-#include <signal.h>
-#include <malloc.h>
-#include <utmp.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/poll.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_arp.h>
-#include <net/route.h>
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "pppd.h"
-
-static const char rcsid[] = RCSID;
-
-static int     pppfd;
-static int     fdmuxid = -1;
-static int     iffd;
-static int     sockfd;
-
-static int     restore_term;
-static struct termios inittermios;
-static struct winsize wsinfo;  /* Initial window size info */
-static pid_t   tty_sid;        /* PID of our session leader */
-
-extern u_char  inpacket_buf[]; /* borrowed from main.c */
-
-static int     link_mtu, link_mru;
-
-#define NMODULES       32
-static int     tty_nmodules;
-static char    tty_modules[NMODULES][FMNAMESZ+1];
-
-static int closed_stdio;
-static int initfdflags = -1;
-static int orig_ttyfd = -1;
-
-static int     if_is_up;       /* Interface has been marked up */
-static u_int32_t ifaddrs[2];   /* local and remote addresses */
-static u_int32_t default_route_gateway;        /* Gateway for default route added */
-static u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
-
-#define MAX_POLLFDS    32
-static struct pollfd pollfds[MAX_POLLFDS];
-static int n_pollfds;
-
-/* Prototypes for procedures local to this file. */
-static int translate_speed __P((int));
-static int baud_rate_of __P((int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr *));
-static int strioctl __P((int, int, void *, int, int));
-
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    int x;
-
-    openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
-    setlogmask(LOG_UPTO(LOG_INFO));
-    if (debug)
-       setlogmask(LOG_UPTO(LOG_DEBUG));
-
-    /* Get an internet socket for doing socket ioctl's on. */
-    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
-       fatal("Couldn't create IP socket: %m");
-
-    if (default_device)
-       tty_sid = getsid((pid_t)0);
-
-    /*
-     * Open the ppp device.
-     */
-    pppfd = open("/dev/streams/ppp", O_RDWR | O_NONBLOCK, 0);
-    if (pppfd < 0)
-       fatal("Can't open /dev/streams/ppp: %m");
-    if (kdebugflag) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(pppfd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-
-    /* Assign a new PPA and get its unit number. */
-    if (strioctl(pppfd, PPPIO_NEWPPA, &ifunit, 0, sizeof(int)) < 0)
-       fatal("Can't create new PPP interface: %m");
-
-    /*
-     * Open the ppp device again and push the if_ppp module on it.
-     */
-    iffd = open("/dev/streams/ppp", O_RDWR, 0);
-    if (iffd < 0)
-       fatal("Can't open /dev/streams/ppp (2): %m");
-    if (kdebugflag) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(iffd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-    if (strioctl(iffd, PPPIO_ATTACH, &ifunit, sizeof(int), 0) < 0)
-       fatal("Couldn't attach ppp interface to device: %m");
-    if (ioctl(iffd, I_PUSH, "if_ppp") < 0)
-       fatal("Can't push ppp interface module: %m");
-    if (kdebugflag) {
-       x = PPPDBG_LOG + PPPDBG_IF;
-       strioctl(iffd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-    if (strioctl(iffd, PPPIO_NEWPPA, &ifunit, sizeof(int), 0) < 0)
-       fatal("Couldn't create ppp interface unit: %m");
-    x = PPP_IP;
-    if (strioctl(iffd, PPPIO_BIND, &x, sizeof(int), 0) < 0)
-       fatal("Couldn't bind ppp interface to IP SAP: %m");
-
-    n_pollfds = 0;
-}
-
-/*
- * sys_cleanup - restore any system state we modified before exiting:
- * mark the interface down, delete default route and/or proxy arp entry.
- * This shouldn't call die() because it's called from die().
- */
-void
-sys_cleanup()
-{
-    if (if_is_up)
-       sifdown(0);
-    if (ifaddrs[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(iffd);
-    close(pppfd);
-    close(sockfd);
-    closelog();
-}
-
-/*
- * sys_check_options - check the options that the user specified
- */
-int
-sys_check_options()
-{
-    return 1;
-}
-
-#if 0
-/*
- * daemon - Detach us from controlling terminal session.
- */
-int
-daemon(nochdir, noclose)
-    int nochdir, noclose;
-{
-    int pid;
-
-    if ((pid = fork()) < 0)
-       return -1;
-    if (pid != 0)
-       exit(0);                /* parent dies */
-    setsid();
-    if (!nochdir)
-       chdir("/");
-    if (!noclose) {
-       fclose(stdin);          /* don't need stdin, stdout, stderr */
-       fclose(stdout);
-       fclose(stderr);
-    }
-    return 0;
-}
-#endif
-
-/*
- * ppp_available - check whether the system has any ppp interfaces
- */
-int
-ppp_available()
-{
-    struct stat buf;
-
-    return stat("/dev/streams/ppp", &buf) >= 0;
-}
-
-char pipename[] = "/dev/streams/pipe";
-
-/*
- *  streampipe -- Opens a STREAMS based pipe.  Used by streamify().
- */
-
-int 
-streampipe(int fd[2])
-{
-    if ((fd[0]=open(pipename, O_RDWR)) == -1)
-       return(-1);
-    else if ((fd[1]=open(pipename, O_RDWR)) == -1) {
-       close(fd[0]);
-       return(-1);
-    } else if (ioctl(fd[0], I_PIPE, fd[1]) != 0) {
-       close(fd[0]);
-       close(fd[1]);
-       return(-1);
-    } else {
-       return(ioctl(fd[0], I_PUSH, "pipemod"));
-    }
-}
-
-/*
- *  streamify -- Needed for Digital UNIX, since some tty devices are not STREAMS
- *               modules (but ptys are, and pipes can be).
- */
-
-#define BUFFSIZE 1000     /*  Size of buffer for streamify()  */
-
-int 
-streamify(int fd)
-{
-    int fdes[2];
-    fd_set readfds;
-    int ret, fret, rret, maxfd;
-    static char buffer[BUFFSIZE];
-    struct sigaction sa;
-
-    if (streampipe(fdes) != 0)
-       error("streampipe(): %m\n");
-    else if (isastream(fdes[0]) == 1) {
-       if ((fret=fork()) < 0) {
-           error("fork(): %m\n");
-       } else if (fret == 0) {
-           /*  Process to forward things from pipe to tty  */
-            sigemptyset(&(sa.sa_mask));
-           sa.sa_handler = SIG_DFL;
-           sa.sa_flags = 0;
-           sigaction(SIGHUP, &sa, NULL);   /*  Go back to default actions */
-           sigaction(SIGINT, &sa, NULL);   /*  for changed signals.  */
-           sigaction(SIGTERM, &sa, NULL);
-           sigaction(SIGCHLD, &sa, NULL);
-           sigaction(SIGUSR1, &sa, NULL);
-           sigaction(SIGUSR2, &sa, NULL);
-           close(fdes[0]);
-
-           maxfd = (fdes[1]>fd)?fdes[1]:fd;
-           while (1) {
-               FD_ZERO(&readfds);
-               FD_SET(fdes[1], &readfds);
-               FD_SET(fd, &readfds);
-               ret = select(maxfd+1, &readfds, NULL, NULL, NULL);
-               if (FD_ISSET(fd, &readfds)) {
-                   rret = read(fd, buffer, BUFFSIZE);
-                   if (rret == 0) {
-                       SYSDEBUG(("slave died:  EOF on tty."));
-                       exit(0);
-                   } else {
-                       write(fdes[1], buffer, rret);
-                   }
-               }
-               if (FD_ISSET(fdes[1], &readfds)) {
-                   rret = read(fdes[1], buffer, BUFFSIZE);
-                   if (rret == 0) {
-                       SYSDEBUG(("slave died:  EOF on pipe."));
-                       exit(0);
-                   } else {
-                       write(fd, buffer, rret);
-                   }
-               }
-           }
-       } else {
-           close(fdes[1]);
-           orig_ttyfd = fd;
-           return(fdes[0]);
-        }
-    }
-
-    return(-1);
-}
-
-/*
- * establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-establish_ppp(fd)
-    int fd;
-{
-    int i;
-
-    if (isastream(fd) != 1) {
-       if ((ttyfd = fd = streamify(fd)) < 0)
-           fatal("Couldn't get a STREAMS module!\n");
-    }
-
-    /* Pop any existing modules off the tty stream. */
-    for (i = 0;; ++i) {
-       if (ioctl(fd, I_LOOK, tty_modules[i]) < 0
-           || ioctl(fd, I_POP, 0) < 0)
-           break;
-        error("popping module %s\n", tty_modules[i]);
-    }
-
-    tty_nmodules = i;
-
-    /* Push the async hdlc module and the compressor module. */
-    if (ioctl(fd, I_PUSH, "ppp_ahdl") < 0)
-       fatal("Couldn't push PPP Async HDLC module: %m");
-    if (ioctl(fd, I_PUSH, "ppp_comp") < 0)
-       error("Couldn't push PPP compression module: %m");
-
-    /* read mode, message non-discard mode */
-    if (ioctl(fd, I_SRDOPT, RMSGN|RPROTNORM) < 0)
-        fatal("ioctl(I_SRDOPT, RMSGN): %m");
-
-    /* Link the serial port under the PPP multiplexor. */
-    if ((fdmuxid = ioctl(pppfd, I_LINK, fd)) < 0)
-       fatal("Can't link tty to PPP mux: %m");
-
-    /* close stdin, stdout, stderr if they might refer to the device */
-    if (default_device && !closed_stdio) {
-        int i;
-
-        for (i = 0; i <= 2; ++i)
-            if (i != fd && i != sockfd)
-                close(i);
-        closed_stdio = 1;
-       /* make sure 0, 1, 2 are open to /dev/null */
-       while ((i = open("/dev/null", O_RDWR)) >= 0) {
-           if (i > 2) {
-               close(i);
-               break;
-           }
-       }
-    }
-
-    /*
-     * Set device for non-blocking reads.
-     * XXX why do we need to do this?  don't we use pppfd not fd?
-     */
-    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 pppfd;
-}
-
-/*
- * restore_loop - reattach the ppp unit to the loopback.
- * This doesn't need to do anything because disestablish_ppp does it.
- */
-void
-restore_loop()
-{
-}
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * It attempts to reconstruct the stream with the previously popped
- * modules.  This shouldn't call die() because it's called from die().
- */
-void
-disestablish_ppp(fd)
-    int fd;
-{
-    int i;
-
-    if (fdmuxid >= 0) {
-       if (ioctl(pppfd, I_UNLINK, fdmuxid) < 0) {
-           if (!hungup)
-               error("Can't unlink tty from PPP mux: %m");
-       }
-       fdmuxid = -1;
-
-        /* Reset non-blocking mode on the file descriptor. */
-        if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
-            warn("Couldn't restore device fd flags: %m");
-        initfdflags = -1;
-
-       if (!hungup) {
-           while (ioctl(fd, I_POP, 0) >= 0)
-               ;
-           for (i = tty_nmodules - 1; i >= 0; --i)
-               if (ioctl(fd, I_PUSH, tty_modules[i]) < 0)
-                   error("Couldn't restore tty module %s: %m",
-                          tty_modules[i]);
-       }
-
-       if (hungup && default_device && tty_sid > 0) {
-           /*
-            * If we have received a hangup, we need to send a SIGHUP
-            * to the terminal's controlling process.  The reason is
-            * that the original stream head for the terminal hasn't
-            * seen the M_HANGUP message (it went up through the ppp
-            * driver to the stream head for our fd to /dev/ppp).
-            */
-           dbglog("sending hangup to %d", tty_sid);
-           if (kill(tty_sid, SIGHUP) < 0)
-               error("couldn't kill pgrp: %m");
-       }
-       if (orig_ttyfd >= 0) {
-           close(fd);
-           (void)wait((void *)0);
-           ttyfd = orig_ttyfd;
-           orig_ttyfd = -1;
-       }
-    }
-}
-
-/*
- * Check whether the link seems not to be 8-bit clean.
- */
-void
-clean_check()
-{
-    int x;
-    char *s;
-
-    if (strioctl(pppfd, PPPIO_GCLEAN, &x, 0, sizeof(x)) < 0)
-       return;
-    s = NULL;
-    switch (~x) {
-    case RCV_B7_0:
-       s = "bit 7 set to 1";
-       break;
-    case RCV_B7_1:
-       s = "bit 7 set to 0";
-       break;
-    case RCV_EVNP:
-       s = "odd parity";
-       break;
-    case RCV_ODDP:
-       s = "even parity";
-       break;
-    }
-    if (s != NULL) {
-       warn("Serial link is not 8-bit clean:");
-       warn("All received characters had %s", s);
-    }
-}
-
-/*
- * List of valid speeds.
- */
-struct speed {
-    int speed_int, speed_val;
-} speeds[] = {
-#ifdef B50
-    { 50, B50 },
-#endif
-#ifdef B75
-    { 75, B75 },
-#endif
-#ifdef B110
-    { 110, B110 },
-#endif
-#ifdef B134
-    { 134, B134 },
-#endif
-#ifdef B150
-    { 150, B150 },
-#endif
-#ifdef B200
-    { 200, B200 },
-#endif
-#ifdef B300
-    { 300, B300 },
-#endif
-#ifdef B600
-    { 600, B600 },
-#endif
-#ifdef B1200
-    { 1200, B1200 },
-#endif
-#ifdef B1800
-    { 1800, B1800 },
-#endif
-#ifdef B2000
-    { 2000, B2000 },
-#endif
-#ifdef B2400
-    { 2400, B2400 },
-#endif
-#ifdef B3600
-    { 3600, B3600 },
-#endif
-#ifdef B4800
-    { 4800, B4800 },
-#endif
-#ifdef B7200
-    { 7200, B7200 },
-#endif
-#ifdef B9600
-    { 9600, B9600 },
-#endif
-#ifdef B19200
-    { 19200, B19200 },
-#endif
-#ifdef B38400
-    { 38400, B38400 },
-#endif
-#ifdef EXTA
-    { 19200, EXTA },
-#endif
-#ifdef EXTB
-    { 38400, EXTB },
-#endif
-#ifdef B57600
-    { 57600, B57600 },
-#endif
-#ifdef B115200
-    { 115200, B115200 },
-#endif
-    { 0, 0 }
-};
-
-/*
- * Translate from bits/second to a speed_t.
- */
-static int
-translate_speed(bps)
-    int bps;
-{
-    struct speed *speedp;
-
-    if (bps == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (bps == speedp->speed_int)
-           return speedp->speed_val;
-    warn("speed %d not supported", bps);
-    return 0;
-}
-
-/*
- * Translate from a speed_t to bits/second.
- */
-static int
-baud_rate_of(speed)
-    int speed;
-{
-    struct speed *speedp;
-
-    if (speed == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (speed == speedp->speed_val)
-           return speedp->speed_int;
-    return 0;
-}
-
-/*
- * 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.
- */
-void
-set_up_tty(fd, local)
-    int fd, local;
-{
-    int speed;
-    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)
-       tios.c_cflag |= CRTSCTS;
-    else if (crtscts < 0)
-       tios.c_cflag &= ~CRTSCTS;
-
-    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 */
-    }
-
-    speed = translate_speed(inspeed);
-    if (speed) {
-       cfsetospeed(&tios, speed);
-       cfsetispeed(&tios, speed);
-    } else {
-       speed = cfgetospeed(&tios);
-       /*
-        * We can't proceed if the serial port speed is 0,
-        * since that implies that the serial port is disabled.
-        */
-       if (speed == B0)
-           fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
-    }
-
-    if (tcsetattr(fd, TCSAFLUSH, &tios) < 0)
-       fatal("tcsetattr: %m");
-
-    baud_rate = inspeed = baud_rate_of(speed);
-    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 (!hungup && 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);
-}
-
-/*
- * open_loopback - open the device we use for getting packets
- * in demand mode.  Under Digital Unix, we use our existing fd
- * to the ppp driver.
- */
-int
-open_ppp_loopback()
-{
-    return pppfd;
-}
-
-/*
- * output - Output PPP packet.
- */
-void
-output(unit, p, len)
-    int unit;
-    u_char *p;
-    int len;
-{
-    struct strbuf data;
-    int retries;
-    struct pollfd pfd;
-
-    if (debug)
-       dbglog("sent %P", p, len);
-
-    data.len = len;
-    data.buf = (caddr_t) p;
-    retries = 4;
-    while (putmsg(pppfd, NULL, &data, 0) < 0) {
-       if (--retries < 0 || (errno != EWOULDBLOCK && errno != EAGAIN)) {
-           if (errno != ENXIO)
-               error("Couldn't send packet: %m");
-           break;
-       }
-       pfd.fd = pppfd;
-       pfd.events = POLLOUT;
-       poll(&pfd, 1, 250);     /* wait for up to 0.25 seconds */
-    }
-}
-
-
-/*
- * wait_input - wait until there is data available on fd,
- * for the length of time specified by *timo (indefinite
- * if timo is NULL).
- */
-void
-wait_input(timo)
-    struct timeval *timo;
-{
-    int t;
-
-    t = timo == NULL? -1: timo->tv_sec * 1000 + timo->tv_usec / 1000;
-    if (poll(pollfds, n_pollfds, t) < 0 && errno != EINTR)
-       fatal("poll: %m");
-}
-
-/*
- * add_fd - add an fd to the set that wait_input waits for.
- */
-void add_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n)
-       if (pollfds[n].fd == fd)
-           return;
-    if (n_pollfds < MAX_POLLFDS) {
-       pollfds[n_pollfds].fd = fd;
-       pollfds[n_pollfds].events = POLLIN | POLLPRI | POLLHUP;
-       ++n_pollfds;
-    } else
-       error("Too many inputs!");
-}
-
-/*
- * remove_fd - remove an fd from the set that wait_input waits for.
- */
-void remove_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n) {
-       if (pollfds[n].fd == fd) {
-           while (++n < n_pollfds)
-               pollfds[n-1] = pollfds[n];
-           --n_pollfds;
-           break;
-       }
-    }
-}
-
-#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;
-{
-    wait_input(timo);
-}
-
-#endif
-
-/*
- * wait_time - wait for a given length of time or until a
- * signal is received. Called by ccp_test
- */
-static void
-wait_time(timo)
-    struct timeval *timo;
-{
-    int n;
-
-    n = select(0, NULL, NULL, NULL, timo);
-    if (n < 0 && errno != EINTR)
-       fatal("select: %m");
-}
-
-/*
- * read_packet - get a PPP packet from the serial device.
- */
-int
-read_packet(buf)
-    u_char *buf;
-{
-    struct strbuf ctrl, data;
-    int flags, len;
-    unsigned char ctrlbuf[64];
-
-    for (;;) {
-       data.maxlen = PPP_MRU + PPP_HDRLEN;
-       data.buf = (caddr_t) buf;
-       ctrl.maxlen = sizeof(ctrlbuf);
-       ctrl.buf = (caddr_t) ctrlbuf;
-       flags = 0;
-       len = getmsg(pppfd, &ctrl, &data, &flags);
-       if (len < 0) {
-           if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
-               return -1;
-           fatal("Error reading packet: %m");
-       }
-
-       if (ctrl.len <= 0)
-           return data.len;
-
-       /*
-        * Got a M_PROTO or M_PCPROTO message.  Huh?
-        */
-       if (debug)
-           dbglog("got ctrl msg len=%d", ctrl.len);
-
-    }
-}
-
-/*
- * get_loop_output - get outgoing packets from the ppp device,
- * 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 len;
-    int rv = 0;
-
-    while ((len = read_packet(inpacket_buf)) > 0) {
-       if (loop_frame(inpacket_buf, len))
-           rv = 1;
-    }
-    return rv;
-}
-
-/*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
-    int unit, mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int cf[2];
-
-    link_mtu = mtu;
-    if (strioctl(pppfd, PPPIO_MTU, &mtu, sizeof(mtu), 0) < 0) {
-       if (hungup && errno == ENXIO)
-           return;
-       error("Couldn't set MTU: %m");
-    }
-    if (strioctl(pppfd, PPPIO_XACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
-       error("Couldn't set transmit ACCM: %m");
-    }
-    cf[0] = (pcomp? COMP_PROT: 0) + (accomp? COMP_AC: 0);
-    cf[1] = COMP_PROT | COMP_AC;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       error("Couldn't set prot/AC compression: %m");
-    }
-}
-
-/*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-ppp_set_xaccm(unit, accm)
-    int unit;
-    ext_accm accm;
-{
-    if (strioctl(pppfd, PPPIO_XACCM, accm, sizeof(ext_accm), 0) < 0) {
-       if (!hungup || errno != ENXIO)
-           warn("Couldn't set extended ACCM: %m");
-    }
-}
-
-/*
- * ppp_recv_config - configure the receive-side characteristics of
- * the ppp interface.
- */
-void
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, mru;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int cf[2];
-
-    link_mru = mru;
-    if (strioctl(pppfd, PPPIO_MRU, &mru, sizeof(mru), 0) < 0) {
-       if (hungup && errno == ENXIO)
-           return;
-       error("Couldn't set MRU: %m");
-    }
-    if (strioctl(pppfd, PPPIO_RACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
-       error("Couldn't set receive ACCM: %m");
-    }
-    cf[0] = (pcomp? DECOMP_PROT: 0) + (accomp? DECOMP_AC: 0);
-    cf[1] = DECOMP_PROT | DECOMP_AC;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       error("Couldn't set prot/AC decompression: %m");
-    }
-}
-
-/*
- * ccp_test - ask kernel whether a given compression method
- * is acceptable for use.
- *
- * In Digital UNIX the memory buckets for chunks >16K are not
- * primed when the system comes up.  That means we're not
- * likely to get the memory needed for the compressor on
- * the first try.  The way we work around this is to have
- * the driver spin off a thread to go get the memory for us
- * (we can't block at that point in a streams context.)
- *
- * This code synchronizes with the thread when it has returned
- * with the memory we need.  The driver will continue to return
- * with EAGAIN until the thread comes back.  We give up here
- * if after 10 attempts in one second we still don't have memory.
- * It's up to the driver to not lose track of that memory if
- * thread takes too long to return.
- */
-int
-ccp_test(unit, opt_ptr, opt_len, for_transmit)
-    int unit, opt_len, for_transmit;
-    u_char *opt_ptr;
-{
-    struct timeval tval;
-    int i;
-
-    tval.tv_sec = 0;
-    tval.tv_usec = 100000;
-    for (i = 0; i < 10; ++i) {
-        if (strioctl(pppfd, (for_transmit? PPPIO_XCOMP: PPPIO_RCOMP),
-           opt_ptr, opt_len, 0) >= 0) {
-           return 1;
-       }
-       if (errno != EAGAIN)
-           break;
-        wait_time(&tval);
-    }
-    if (errno != 0)
-       error("hard failure trying to get memory for a compressor: %m");
-    return (errno == ENOSR)? 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 cf[2];
-
-    cf[0] = (isopen? CCP_ISOPEN: 0) + (isup? CCP_ISUP: 0);
-    cf[1] = CCP_ISOPEN | CCP_ISUP | CCP_ERROR | CCP_FATALERROR;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (!hungup || errno != ENXIO)
-           error("Couldn't set kernel CCP state: %m");
-    }
-}
-
-/*
- * get_idle_time - return how long the link has been idle.
- */
-int
-get_idle_time(u, ip)
-    int u;
-    struct ppp_idle *ip;
-{
-    return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
-}
-
-/*
- * get_ppp_stats - return statistics for the link.
- */
-int
-get_ppp_stats(u, stats)
-    int u;
-    struct pppd_stats *stats;
-{
-    struct ppp_stats s;
-
-    if (strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
-       error("Couldn't get link statistics: %m");
-       return 0;
-    }
-    stats->bytes_in = s.p.ppp_ibytes;
-    stats->bytes_out = s.p.ppp_obytes;
-    return 1;
-}
-
-
-/*
- * 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 cf[2];
-
-    cf[0] = cf[1] = 0;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (errno != ENXIO && errno != EINVAL)
-           error("Couldn't get compression flags: %m");
-       return 0;
-    }
-    return cf[0] & CCP_FATALERROR;
-}
-
-/*
- * sifvjcomp - config tcp header compression
- */
-int
-sifvjcomp(u, vjcomp, xcidcomp, xmaxcid)
-    int u, vjcomp, xcidcomp, xmaxcid;
-{
-    int cf[2];
-    char maxcid[2];
-
-    if (vjcomp) {
-       maxcid[0] = xcidcomp;
-       maxcid[1] = 15;         /* XXX should be rmaxcid */
-       if (strioctl(pppfd, PPPIO_VJINIT, maxcid, sizeof(maxcid), 0) < 0) {
-           error("Couldn't initialize VJ compression: %m");
-       }
-    }
-
-    cf[0] = (vjcomp? COMP_VJC + DECOMP_VJC: 0) /* XXX this is wrong */
-       + (xcidcomp? COMP_VJCCID + DECOMP_VJCCID: 0);
-    cf[1] = COMP_VJC + DECOMP_VJC + COMP_VJCCID + DECOMP_VJCCID;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (vjcomp)
-           error("Couldn't enable VJ compression: %m");
-    }
-
-    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(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface up (get): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface up (set): %m");
-       return 0;
-    }
-    if_is_up = 1;
-    return 1;
-}
-
-/*
- * sifdown - Config the interface down and disable IP.
- */
-int
-sifdown(u)
-    int u;
-{
-    struct ifreq ifr;
-
-    bzero(&ifr, sizeof(ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface down (get): %m");
-       return 0;
-    }
-    if ((ifr.ifr_flags & IFF_UP) != 0) {
-       ifr.ifr_flags &= ~IFF_UP;
-       if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) {
-           error("Couldn't mark interface down (set): %m");
-           return 0;
-       }
-    }
-    if_is_up = 0;
-    return 1;
-}
-
-/*
- * sifnpmode - Set the mode for handling packets for a given NP.
- */
-int
-sifnpmode(u, proto, mode)
-    int u;
-    int proto;
-    enum NPmode mode;
-{
-    int npi[2];
-
-    npi[0] = proto;
-    npi[1] = (int) mode;
-    if (strioctl(pppfd, PPPIO_NPMODE, npi, 2 * sizeof(int), 0) < 0) {
-       error("ioctl(set NP %d mode to %d): %m", proto, mode);
-       return 0;
-    }
-    return 1;
-}
-
-#define INET_ADDR(x)   (((struct sockaddr_in *) &(x))->sin_addr.s_addr)
-
-/*
- * SET_SA_FAMILY - initialize a struct sockaddr, setting the sa_family field.
- */
-#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 ifreq ifr;
-    struct ifaliasreq addreq;
-    int ret;
-
-    ret = 1;
-
-    /* flush old address, if any
-     */
-    bzero(&ifr, sizeof (ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    SET_SA_FAMILY(ifr.ifr_addr, AF_INET);
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
-    if ((ioctl(sockfd, (int)SIOCDIFADDR, (caddr_t) &ifr) < 0)
-        && errno != EADDRNOTAVAIL) {
-        error("ioctl(SIOCDIFADDR): %m");
-        ret = 0;
-    }
-
-    bzero(&addreq, sizeof (addreq));
-    strlcpy(addreq.ifra_name, ifname, sizeof (addreq.ifra_name));
-    SET_SA_FAMILY(addreq.ifra_addr, AF_INET);
-    SET_SA_FAMILY(addreq.ifra_broadaddr, AF_INET);
-    ((struct sockaddr_in *)&addreq.ifra_addr)->sin_addr.s_addr = o;
-    ((struct sockaddr_in *)&addreq.ifra_broadaddr)->sin_addr.s_addr = h;
-
-    if (m != 0) {
-        ((struct sockaddr_in *)&addreq.ifra_mask)->sin_addr.s_addr = m;
-        addreq.ifra_mask.sa_len = sizeof (struct sockaddr);
-        info("Setting interface mask to %s\n", ip_ntoa(m));
-    }
-
-    /* install new src/dst and (possibly) netmask
-     */
-    if (ioctl(sockfd, SIOCPIFADDR, &addreq) < 0) {
-        error("ioctl(SIOCPIFADDR): %m");
-        ret = 0;
-    }
-
-    ifr.ifr_data = (caddr_t)&link_mtu;
-
-    if (ioctl(sockfd, SIOCSIPMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-        ret = 0;
-    }
-
-    ifaddrs[0] = o;
-    ifaddrs[1] = h;
-    return (ret);
-}
-
-
-/*
- * 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 ifreq ifr;
-
-    ifaddrs[0] = 0;
-    ifaddrs[1] = 0;
-    bzero(&ifr, sizeof (ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    SET_SA_FAMILY(ifr.ifr_addr, AF_INET);
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
-    if (ioctl(sockfd, (int)SIOCDIFADDR, (caddr_t) &ifr) < 0) {
-        error("ioctl(SIOCDIFADDR): %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;
-{
-    struct ortentry rt;
-
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, (int)SIOCADDRT, &rt) < 0) {
-        error("default route ioctl(SIOCADDRT): %m");
-        return 0;
-    }
-    default_route_gateway = g;
-    return 1;
-}
-
-
-/*
- * cifdefaultroute - delete a default route through the address given.
- */
-int
-cifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct ortentry rt;
-
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, (int)SIOCDELRT, &rt) < 0) {
-        error("default route ioctl(SIOCDELRT): %m");
-        return 0;
-    }
-    default_route_gateway = 0;
-    return 1;
-}
-
-/*
- * sifproxyarp - Make a proxy ARP entry for the peer.
- */
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_int32_t hisaddr;
-{
-    struct arpreq arpreq;
-
-    BZERO(&arpreq, sizeof(arpreq));
-
-    /*
-     * Get the hardware address of an interface on the same subnet
-     * as our local address.
-     */
-    if (!get_ether_addr(hisaddr, &arpreq.arp_ha)) {
-        warn("Cannot determine ethernet address for proxy ARP");
-        return 0;
-    }
-
-    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(sockfd, (int)SIOCSARP, (caddr_t)&arpreq) < 0) {
-        error("ioctl(SIOCSARP): %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(sockfd, (int)SIOCDARP, (caddr_t)&arpreq) < 0) {
-        error("ioctl(SIOCDARP): %m");
-        return 0;
-    }
-    proxy_arp_addr = 0;
-    return 1;
-}
-
-/*
- * get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
- */
-#define MAX_IFS                32
-
-static int
-get_ether_addr(ipaddr, hwaddr)
-    u_int32_t ipaddr;
-    struct sockaddr *hwaddr;
-{
-    struct ifreq *ifr, *ifend;
-    u_int32_t ina, mask;
-    struct ifreq ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-    struct ifdevea ifdevreq;
-
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       error("ioctl(SIOCGIFCONF): %m");
-       return 0;
-    }
-
-    /*
-     * Scan through looking for an interface with an Internet
-     * address on the same subnet as `ipaddr'.
-     */
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr++) {
-        if (ifr->ifr_addr.sa_family == AF_INET) {
-
-            /*
-             * Check that the interface is up, and not point-to-point
-             * or loopback.
-             */
-            strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-            if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-                continue;
-            if ((ifreq.ifr_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.
-             */
-            if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-                continue;
-            ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
-            mask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;
-            if ((ipaddr & mask) != (ina & mask))
-                continue;
-
-            break;
-        } else {
-           if (ifr->ifr_addr.sa_len > sizeof (ifr->ifr_addr))
-               ifr = (struct ifreq *)((caddr_t)ifr + (ifr->ifr_addr.sa_len - sizeof (ifr->ifr_addr)));
-       }
-    }
-
-    if (ifr >= ifend)
-       return 0;
-    info("found interface %s for proxy arp", ifr->ifr_name);
-
-    strlcpy(ifdevreq.ifr_name, ifr->ifr_name, sizeof(ifdevreq.ifr_name));
-
-    if (ioctl(sockfd, (int)SIOCRPHYSADDR, &ifdevreq) < 0) {
-        perror("ioctl(SIOCRPHYSADDR)");
-        return(0);
-    }
-
-    hwaddr->sa_family = AF_UNSPEC;
-    memcpy(hwaddr->sa_data, ifdevreq.current_pa, sizeof(ifdevreq.current_pa));
-    return 1;
-}
-
-#define        WTMPFILE        "/usr/adm/wtmp"
-
-void
-logwtmp(line, name, host)
-    const char *line, *name, *host;
-{
-    int fd;
-    struct stat buf;
-    struct utmp ut;
-
-    if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
-       return;
-    if (!fstat(fd, &buf)) {
-       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-       strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-       strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-       (void)time(&ut.ut_time);
-       if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
-           (void)ftruncate(fd, buf.st_size);
-    }
-    close(fd);
-}
-
-/*
- * 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 ifreq *ifr, *ifend, ifreq;
-    struct ifconf ifc;
-
-    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.
-     */
-    ifc.ifc_len = MAX_IFS * sizeof(struct ifreq);
-    ifc.ifc_req = (struct ifreq *)alloca(ifc.ifc_len);
-    if (ifc.ifc_req == 0)
-       return mask;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("Couldn't get system interface list: %m");
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr++) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family == AF_INET) {
-           ina = INET_ADDR(ifr->ifr_addr);
-           if ((ntohl(ina) & nmask) != (addr & nmask))
-               continue;
-           /*
-            * Check that the interface is up, and not point-to-point or loopback.
-            */
-           strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-           if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-               continue;
-           if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-               != IFF_UP)
-               continue;
-           /*
-            * Get its netmask and OR it into our mask.
-            */
-           if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-               continue;
-           mask |= INET_ADDR(ifreq.ifr_addr);
-           break;
-       } else {
-           if (ifr->ifr_addr.sa_len > sizeof (ifr->ifr_addr))
-               ifr = (struct ifreq *)((caddr_t)ifr + (ifr->ifr_addr.sa_len - sizeof (ifr->ifr_addr)));
-       }
-    }
-
-    return mask;
-}
-
-/*
- * have_route_to - determine if the system has any route to
- * a given IP address.  `addr' is in network byte order.
- * 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; 
-}
-
-static int
-strioctl(fd, cmd, ptr, ilen, olen)
-    int fd, cmd, ilen, olen;
-    void *ptr;
-{
-    struct strioctl str;
-
-    str.ic_cmd = cmd;
-    str.ic_timout = 0;
-    str.ic_len = ilen;
-    str.ic_dp = ptr;
-    if (ioctl(fd, I_STR, &str) == -1)
-       return -1;
-    if (str.ic_len != olen)
-       dbglog("strioctl: expected %d bytes, got %d for cmd %x\n",
-              olen, str.ic_len, cmd);
-    return 0;
-}
-
-/*
- * Use the hostid as part of the random number seed.
- */
-int
-get_host_seed()
-{
-    return gethostid();
-}
-
-/*
- * 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;
-{
-    int i, mfd, sfd;
-    char pty_name[12];
-    struct termios tios;
-
-    sfd = -1;
-    for (i = 0; i < 64; ++i) {
-       slprintf(pty_name, sizeof(pty_name), "/dev/pty%c%x",
-                'p' + i / 16, i % 16);
-       mfd = open(pty_name, O_RDWR, 0);
-       if (mfd >= 0) {
-           pty_name[5] = 't';
-           sfd = open(pty_name, O_RDWR | O_NOCTTY, 0);
-           if (sfd >= 0)
-               break;
-           close(mfd);
-       }
-    }
-    if (sfd < 0)
-       return 0;
-
-    strlcpy(slave_name, pty_name, 12);
-    *master_fdp = mfd;
-    *slave_fdp = sfd;
-    fchown(sfd, uid, -1);
-    fchmod(sfd, S_IRUSR | S_IWUSR);
-    if (tcgetattr(sfd, &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(sfd, TCSAFLUSH, &tios) < 0)
-           warn("couldn't set attributes on pty: %m");
-    } else
-       warn("couldn't get attributes on pty: %m");
-
-    return 1;
-}
-
-#if 0
-/*
- * Code for locking/unlocking the serial device.
- * This code is derived from chat.c.
- */
-
-#if !defined(HDB) && !defined(SUNOS3)
-#define        HDB     1               /* ascii lock files are the default */
-#endif
-
-#ifndef LOCK_DIR
-# if HDB
-#  define      PIDSTRING
-#  define      LOCK_PREFIX     "/usr/spool/locks/LCK.."
-# else /* HDB */
-#  define      LOCK_PREFIX     "/usr/spool/uucp/LCK.."
-# endif /* HDB */
-#endif /* LOCK_DIR */
-
-static char *lock_file;                /* name of lock file created */
-
-/*
- * lock - create a lock file for the named device.
- */
-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 */
-#ifdef PIDSTRING
-           n = read(fd, hdb_lock_buffer, 11);
-           if (n > 0) {
-               hdb_lock_buffer[n] = 0;
-               pid = atoi(hdb_lock_buffer);
-           }
-#else
-           n = read(fd, &pid, sizeof(pid));
-#endif
-           if (n <= 0) {
-               error("Can't read pid from lock file %s", lock_file);
-               close(fd);
-           } else {
-               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;
-    }
-
-#ifdef PIDSTRING
-    slprintf(hdb_lock_buffer, sizeof(hdb_lock_buffer), "%10d\n", getpid());
-    write(fd, hdb_lock_buffer, 11);
-#else
-    pid = getpid();
-    write(fd, &pid, sizeof pid);
-#endif
-
-    close(fd);
-    return 0;
-}
-
-/*
- * unlock - remove our lockfile
- */
-void
-unlock()
-{
-    if (lock_file) {
-       unlink(lock_file);
-       free(lock_file);
-       lock_file = NULL;
-    }
-}
-#endif
-
-int
-set_filters(pass, active)
-    struct bpf_program *pass, *active;
-{
-    return 1;
-}
-
-int
-bpf_compile(program, buf, optimize)
-    struct bpf_program *program;
-    char *buf;
-    int optimize;
-{
-    return 0;
-}
-
-char *
-bpf_geterr()
-{
-    return 0;
-}
-
-u_int
-bpf_filter(pc, p, wirelen, buflen)
-    struct bpf_insn *pc;
-    u_char *p;
-    u_int wirelen;
-    u_int buflen;
-{
-    return 0;
-}
diff --git a/pppd/sys-sunos4.c b/pppd/sys-sunos4.c
deleted file mode 100644 (file)
index 3247b73..0000000
+++ /dev/null
@@ -1,1612 +0,0 @@
-/*
- * System-dependent procedures for pppd under SunOS 4.
- *
- * Copyright (c) 1994-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. 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.
- *
- * 3. 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.
- *
- * Derived from main.c and pppd.h, which are:
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-sunos4.c,v 1.33 2004/11/04 10:02:26 paulus Exp $"
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <termios.h>
-#include <signal.h>
-#include <malloc.h>
-#include <utmp.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/poll.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/nit_if.h>
-#include <net/route.h>
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include <netinet/in.h>
-
-#include "pppd.h"
-
-#if defined(sun) && defined(sparc)
-#include <alloca.h>
-#ifndef __GNUC__
-extern void *alloca();
-#endif
-#endif /*sparc*/
-
-static const char rcsid[] = RCSID;
-
-static int     pppfd;
-static int     fdmuxid = -1;
-static int     iffd;
-static int     sockfd;
-
-static int     restore_term;
-static struct termios inittermios;
-static struct winsize wsinfo;  /* Initial window size info */
-static pid_t   parent_pid;     /* PID of our parent */
-
-extern u_char  inpacket_buf[]; /* borrowed from main.c */
-
-#define MAX_POLLFDS    32
-static struct pollfd pollfds[MAX_POLLFDS];
-static int n_pollfds;
-
-static int     link_mtu, link_mru;
-
-#define NMODULES       32
-static int     tty_nmodules;
-static char    tty_modules[NMODULES][FMNAMESZ+1];
-
-static int     if_is_up;       /* Interface has been marked up */
-static u_int32_t ifaddrs[2];   /* local and remote addresses */
-static u_int32_t default_route_gateway;        /* Gateway for default route added */
-static u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
-
-/* Prototypes for procedures local to this file. */
-static int translate_speed __P((int));
-static int baud_rate_of __P((int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr *));
-static int strioctl __P((int, int, void *, int, int));
-
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    int x;
-
-    /* Get an internet socket for doing socket ioctl's on. */
-    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
-       fatal("Couldn't create IP socket: %m");
-
-    /*
-     * We may want to send a SIGHUP to the session leader associated
-     * with our controlling terminal later.  Because SunOS doesn't
-     * have getsid(), we make do with sending the signal to our
-     * parent process.
-     */
-    parent_pid = getppid();
-
-    /*
-     * Open the ppp device.
-     */
-    pppfd = open("/dev/ppp", O_RDWR | O_NONBLOCK, 0);
-    if (pppfd < 0)
-       fatal("Can't open /dev/ppp: %m");
-    if (kdebugflag) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(pppfd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-
-    /* Assign a new PPA and get its unit number. */
-    if (strioctl(pppfd, PPPIO_NEWPPA, &ifunit, 0, sizeof(int)) < 0)
-       fatal("Can't create new PPP interface: %m");
-
-    /*
-     * Open the ppp device again and push the if_ppp module on it.
-     */
-    iffd = open("/dev/ppp", O_RDWR, 0);
-    if (iffd < 0)
-       fatal("Can't open /dev/ppp (2): %m");
-    if (kdebugflag) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(iffd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-    if (strioctl(iffd, PPPIO_ATTACH, &ifunit, sizeof(int), 0) < 0)
-       fatal("Couldn't attach ppp interface to device: %m");
-    if (ioctl(iffd, I_PUSH, "if_ppp") < 0)
-       fatal("Can't push ppp interface module: %m");
-    if (kdebugflag) {
-       x = PPPDBG_LOG + PPPDBG_IF;
-       strioctl(iffd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-    if (strioctl(iffd, PPPIO_NEWPPA, &ifunit, sizeof(int), 0) < 0)
-       fatal("Couldn't create ppp interface unit: %m");
-    x = PPP_IP;
-    if (strioctl(iffd, PPPIO_BIND, &x, sizeof(int), 0) < 0)
-       fatal("Couldn't bind ppp interface to IP SAP: %m");
-
-    n_pollfds = 0;
-}
-
-/*
- * sys_cleanup - restore any system state we modified before exiting:
- * mark the interface down, delete default route and/or proxy arp entry.
- * This shouldn't call die() because it's called from die().
- */
-void
-sys_cleanup()
-{
-    if (if_is_up)
-       sifdown(0);
-    if (ifaddrs[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(iffd);
-    close(pppfd);
-    close(sockfd);
-}
-
-/*
- * sys_check_options - check the options that the user specified
- */
-int
-sys_check_options()
-{
-    return 1;
-}
-
-#if 0
-/*
- * daemon - Detach us from controlling terminal session.
- */
-int
-daemon(nochdir, noclose)
-    int nochdir, noclose;
-{
-    int pid;
-
-    if ((pid = fork()) < 0)
-       return -1;
-    if (pid != 0)
-       exit(0);                /* parent dies */
-    setsid();
-    if (!nochdir)
-       chdir("/");
-    if (!noclose) {
-       fclose(stdin);          /* don't need stdin, stdout, stderr */
-       fclose(stdout);
-       fclose(stderr);
-    }
-    return 0;
-}
-#endif
-
-/*
- * ppp_available - check whether the system has any ppp interfaces
- */
-int
-ppp_available()
-{
-    struct stat buf;
-
-    return stat("/dev/ppp", &buf) >= 0;
-}
-
-/*
- * tty_establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-tty_establish_ppp(fd)
-    int fd;
-{
-    int i;
-
-    /* Pop any existing modules off the tty stream. */
-    for (i = 0;; ++i)
-       if (ioctl(fd, I_LOOK, tty_modules[i]) < 0
-           || ioctl(fd, I_POP, 0) < 0)
-           break;
-    tty_nmodules = i;
-
-    /* Push the async hdlc module and the compressor module. */
-    if (ioctl(fd, I_PUSH, "ppp_ahdl") < 0)
-       fatal("Couldn't push PPP Async HDLC module: %m");
-    if (ioctl(fd, I_PUSH, "ppp_comp") < 0)
-       error("Couldn't push PPP compression module: %m");
-
-    /* Link the serial port under the PPP multiplexor. */
-    if ((fdmuxid = ioctl(pppfd, I_LINK, fd)) < 0)
-       fatal("Can't link tty to PPP mux: %m");
-
-    return pppfd;
-}
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * It attempts to reconstruct the stream with the previously popped
- * modules.  This shouldn't call die() because it's called from die().
- */
-void
-tty_disestablish_ppp(fd)
-    int fd;
-{
-    int i;
-
-    if (fdmuxid >= 0) {
-       if (ioctl(pppfd, I_UNLINK, fdmuxid) < 0) {
-           if (!hungup)
-               error("Can't unlink tty from PPP mux: %m");
-       }
-       fdmuxid = -1;
-
-       if (!hungup) {
-           while (ioctl(fd, I_POP, 0) >= 0)
-               ;
-           for (i = tty_nmodules - 1; i >= 0; --i)
-               if (ioctl(fd, I_PUSH, tty_modules[i]) < 0)
-                   error("Couldn't restore tty module %s: %m",
-                          tty_modules[i]);
-       }
-       if (hungup && default_device && parent_pid > 0) {
-           /*
-            * If we have received a hangup, we need to send a SIGHUP
-            * to the terminal's controlling process.  The reason is
-            * that the original stream head for the terminal hasn't
-            * seen the M_HANGUP message (it went up through the ppp
-            * driver to the stream head for our fd to /dev/ppp).
-            * Actually we send the signal to the process that invoked
-            * pppd, since SunOS doesn't have getsid().
-            */
-           kill(parent_pid, SIGHUP);
-       }
-    }
-}
-
-/*
- * Check whether the link seems not to be 8-bit clean.
- */
-void
-clean_check()
-{
-    int x;
-    char *s;
-
-    if (strioctl(pppfd, PPPIO_GCLEAN, &x, 0, sizeof(x)) < 0)
-       return;
-    s = NULL;
-    switch (~x) {
-    case RCV_B7_0:
-       s = "bit 7 set to 1";
-       break;
-    case RCV_B7_1:
-       s = "bit 7 set to 0";
-       break;
-    case RCV_EVNP:
-       s = "odd parity";
-       break;
-    case RCV_ODDP:
-       s = "even parity";
-       break;
-    }
-    if (s != NULL) {
-       warn("Serial link is not 8-bit clean:");
-       warn("All received characters had %s", s);
-    }
-}
-
-/*
- * List of valid speeds.
- */
-struct speed {
-    int speed_int, speed_val;
-} speeds[] = {
-#ifdef B50
-    { 50, B50 },
-#endif
-#ifdef B75
-    { 75, B75 },
-#endif
-#ifdef B110
-    { 110, B110 },
-#endif
-#ifdef B134
-    { 134, B134 },
-#endif
-#ifdef B150
-    { 150, B150 },
-#endif
-#ifdef B200
-    { 200, B200 },
-#endif
-#ifdef B300
-    { 300, B300 },
-#endif
-#ifdef B600
-    { 600, B600 },
-#endif
-#ifdef B1200
-    { 1200, B1200 },
-#endif
-#ifdef B1800
-    { 1800, B1800 },
-#endif
-#ifdef B2000
-    { 2000, B2000 },
-#endif
-#ifdef B2400
-    { 2400, B2400 },
-#endif
-#ifdef B3600
-    { 3600, B3600 },
-#endif
-#ifdef B4800
-    { 4800, B4800 },
-#endif
-#ifdef B7200
-    { 7200, B7200 },
-#endif
-#ifdef B9600
-    { 9600, B9600 },
-#endif
-#ifdef B19200
-    { 19200, B19200 },
-#endif
-#ifdef B38400
-    { 38400, B38400 },
-#endif
-#ifdef EXTA
-    { 19200, EXTA },
-#endif
-#ifdef EXTB
-    { 38400, EXTB },
-#endif
-#ifdef B57600
-    { 57600, B57600 },
-#endif
-#ifdef B115200
-    { 115200, B115200 },
-#endif
-    { 0, 0 }
-};
-
-/*
- * Translate from bits/second to a speed_t.
- */
-static int
-translate_speed(bps)
-    int bps;
-{
-    struct speed *speedp;
-
-    if (bps == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (bps == speedp->speed_int)
-           return speedp->speed_val;
-    warn("speed %d not supported", bps);
-    return 0;
-}
-
-/*
- * Translate from a speed_t to bits/second.
- */
-static int
-baud_rate_of(speed)
-    int speed;
-{
-    struct speed *speedp;
-
-    if (speed == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (speed == speedp->speed_val)
-           return speedp->speed_int;
-    return 0;
-}
-
-/*
- * 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.
- */
-void
-set_up_tty(fd, local)
-    int fd, local;
-{
-    int speed;
-    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)
-       tios.c_cflag |= CRTSCTS;
-    else if (crtscts < 0)
-       tios.c_cflag &= ~CRTSCTS;
-
-    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 */
-    }
-
-    speed = translate_speed(inspeed);
-    if (speed) {
-       cfsetospeed(&tios, speed);
-       cfsetispeed(&tios, speed);
-    } else {
-       speed = cfgetospeed(&tios);
-       /*
-        * We can't proceed if the serial port speed is 0,
-        * since that implies that the serial port is disabled.
-        */
-       if (speed == B0)
-           fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
-    }
-
-    if (tcsetattr(fd, TCSAFLUSH, &tios) < 0)
-       fatal("tcsetattr: %m");
-
-    baud_rate = inspeed = baud_rate_of(speed);
-    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 (!hungup && 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);
-}
-
-/*
- * open_loopback - open the device we use for getting packets
- * in demand mode.  Under SunOS, we use our existing fd
- * to the ppp driver.
- */
-int
-open_ppp_loopback()
-{
-    return pppfd;
-}
-
-/*
- * output - Output PPP packet.
- */
-void
-output(unit, p, len)
-    int unit;
-    u_char *p;
-    int len;
-{
-    struct strbuf data;
-    int retries;
-    struct pollfd pfd;
-
-    dump_packet("sent", p, len);
-    if (snoop_send_hook) snoop_send_hook(p, len);
-
-    data.len = len;
-    data.buf = (caddr_t) p;
-    retries = 4;
-    while (putmsg(pppfd, NULL, &data, 0) < 0) {
-       if (--retries < 0 || (errno != EWOULDBLOCK && errno != EAGAIN)) {
-           if (errno != ENXIO)
-               error("Couldn't send packet: %m");
-           break;
-       }
-       pfd.fd = pppfd;
-       pfd.events = POLLOUT;
-       poll(&pfd, 1, 250);     /* wait for up to 0.25 seconds */
-    }
-}
-
-
-/*
- * 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;
-{
-    int t;
-
-    t = timo == NULL? -1: timo->tv_sec * 1000 + timo->tv_usec / 1000;
-    if (poll(pollfds, n_pollfds, t) < 0 && errno != EINTR) {
-       if (errno != EAGAIN)
-           fatal("poll: %m");
-       /* we can get EAGAIN on a heavily loaded system,
-        * just wait a short time and try again. */
-       usleep(50000);
-    }
-}
-
-/*
- * add_fd - add an fd to the set that wait_input waits for.
- */
-void add_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n)
-       if (pollfds[n].fd == fd)
-           return;
-    if (n_pollfds < MAX_POLLFDS) {
-       pollfds[n_pollfds].fd = fd;
-       pollfds[n_pollfds].events = POLLIN | POLLPRI | POLLHUP;
-       ++n_pollfds;
-    } else
-       error("Too many inputs!");
-}
-
-/*
- * remove_fd - remove an fd from the set that wait_input waits for.
- */
-void remove_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n) {
-       if (pollfds[n].fd == fd) {
-           while (++n < n_pollfds)
-               pollfds[n-1] = pollfds[n];
-           --n_pollfds;
-           break;
-       }
-    }
-}
-
-#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;
-{
-    wait_input(timo);
-}
-
-/*
- * 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;
-{
-    struct strbuf ctrl, data;
-    int flags, len;
-    unsigned char ctrlbuf[64];
-
-    for (;;) {
-       data.maxlen = PPP_MRU + PPP_HDRLEN;
-       data.buf = (caddr_t) buf;
-       ctrl.maxlen = sizeof(ctrlbuf);
-       ctrl.buf = (caddr_t) ctrlbuf;
-       flags = 0;
-       len = getmsg(pppfd, &ctrl, &data, &flags);
-       if (len < 0) {
-           if (errno == EAGAIN || errno == EINTR)
-               return -1;
-           fatal("Error reading packet: %m");
-       }
-
-       if (ctrl.len <= 0)
-           return data.len;
-
-       /*
-        * Got a M_PROTO or M_PCPROTO message.  Huh?
-        */
-       if (debug)
-           dbglog("got ctrl msg len=%d", ctrl.len);
-
-    }
-}
-
-/*
- * get_loop_output - get outgoing packets from the ppp device,
- * 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 len;
-    int rv = 0;
-
-    while ((len = read_packet(inpacket_buf)) > 0) {
-       if (loop_frame(inpacket_buf, len))
-           rv = 1;
-    }
-    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;
-
-    memset(&ifr, 0, sizeof(ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    ifr.ifr_metric = link_mtu;
-    if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-    }
-}
-
-/*
- * tty_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-int
-tty_send_config(mtu, asyncmap, pcomp, accomp)
-    int mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int cf[2];
-
-    link_mtu = mtu;
-    if (strioctl(pppfd, PPPIO_MTU, &mtu, sizeof(mtu), 0) < 0) {
-       if (hungup && errno == ENXIO) {
-           ++error_count;
-           return;
-       }
-       error("Couldn't set MTU: %m");
-    }
-    if (strioctl(pppfd, PPPIO_XACCM, &asyncmap, sizeof(asyncmap), 0) < 0)
-       error("Couldn't set transmit ACCM: %m");
-    cf[0] = (pcomp? COMP_PROT: 0) + (accomp? COMP_AC: 0);
-    cf[1] = COMP_PROT | COMP_AC;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0)
-       error("Couldn't set prot/AC compression: %m");
-}
-
-/*
- * tty_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-tty_set_xaccm(unit, accm)
-    int unit;
-    ext_accm accm;
-{
-    if (strioctl(pppfd, PPPIO_XACCM, accm, sizeof(ext_accm), 0) < 0) {
-       if (!hungup || errno != ENXIO)
-           warn("Couldn't set extended ACCM: %m");
-    }
-}
-
-/*
- * tty_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 cf[2];
-
-    link_mru = mru;
-    if (strioctl(pppfd, PPPIO_MRU, &mru, sizeof(mru), 0) < 0) {
-       if (hungup && errno == ENXIO) {
-           ++error_count;
-           return;
-       }
-       error("Couldn't set MRU: %m");
-    }
-    if (strioctl(pppfd, PPPIO_RACCM, &asyncmap, sizeof(asyncmap), 0) < 0)
-       error("Couldn't set receive ACCM: %m");
-    cf[0] = (pcomp? DECOMP_PROT: 0) + (accomp? DECOMP_AC: 0);
-    cf[1] = DECOMP_PROT | DECOMP_AC;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0)
-       error("Couldn't set prot/AC decompression: %m");
-}
-
-/*
- * ccp_test - ask kernel whether a given compression method
- * is acceptable for use.
- */
-int
-ccp_test(unit, opt_ptr, opt_len, for_transmit)
-    int unit, opt_len, for_transmit;
-    u_char *opt_ptr;
-{
-    if (strioctl(pppfd, (for_transmit? PPPIO_XCOMP: PPPIO_RCOMP),
-                opt_ptr, opt_len, 0) >= 0)
-       return 1;
-    return (errno == ENOSR)? 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 cf[2];
-
-    cf[0] = (isopen? CCP_ISOPEN: 0) + (isup? CCP_ISUP: 0);
-    cf[1] = CCP_ISOPEN | CCP_ISUP | CCP_ERROR | CCP_FATALERROR;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (!hungup || errno != ENXIO)
-           error("Couldn't set kernel CCP state: %m");
-    }
-}
-
-/*
- * get_idle_time - return how long the link has been idle.
- */
-int
-get_idle_time(u, ip)
-    int u;
-    struct ppp_idle *ip;
-{
-    return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
-}
-
-/*
- * get_ppp_stats - return statistics for the link.
- */
-int
-get_ppp_stats(u, stats)
-    int u;
-    struct pppd_stats *stats;
-{
-    struct ppp_stats s;
-
-    if (strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
-       error("Couldn't get link statistics: %m");
-       return 0;
-    }
-    stats->bytes_in = s.p.ppp_ibytes;
-    stats->bytes_out = s.p.ppp_obytes;
-    stats->pkts_in = s.p.ppp_ipackets;
-    stats->pkts_out = s.p.ppp_opackets;
-    return 1;
-}
-
-
-/*
- * 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 cf[2];
-
-    cf[0] = cf[1] = 0;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (errno != ENXIO && errno != EINVAL)
-           error("Couldn't get compression flags: %m");
-       return 0;
-    }
-    return cf[0] & CCP_FATALERROR;
-}
-
-/*
- * sifvjcomp - config tcp header compression
- */
-int
-sifvjcomp(u, vjcomp, xcidcomp, xmaxcid)
-    int u, vjcomp, xcidcomp, xmaxcid;
-{
-    int cf[2];
-    char maxcid[2];
-
-    if (vjcomp) {
-       maxcid[0] = xcidcomp;
-       maxcid[1] = 15;         /* XXX should be rmaxcid */
-       if (strioctl(pppfd, PPPIO_VJINIT, maxcid, sizeof(maxcid), 0) < 0) {
-           error("Couldn't initialize VJ compression: %m");
-       }
-    }
-
-    cf[0] = (vjcomp? COMP_VJC + DECOMP_VJC: 0) /* XXX this is wrong */
-       + (xcidcomp? COMP_VJCCID + DECOMP_VJCCID: 0);
-    cf[1] = COMP_VJC + DECOMP_VJC + COMP_VJCCID + DECOMP_VJCCID;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (vjcomp)
-           error("Couldn't enable VJ compression: %m");
-    }
-
-    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(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface up (get): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface up (set): %m");
-       return 0;
-    }
-    if_is_up = 1;
-    return 1;
-}
-
-/*
- * sifdown - Config the interface down and disable IP.
- */
-int
-sifdown(u)
-    int u;
-{
-    struct ifreq ifr;
-
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface down (get): %m");
-       return 0;
-    }
-    if ((ifr.ifr_flags & IFF_UP) != 0) {
-       ifr.ifr_flags &= ~IFF_UP;
-       if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) {
-           error("Couldn't mark interface down (set): %m");
-           return 0;
-       }
-    }
-    if_is_up = 0;
-    return 1;
-}
-
-/*
- * sifnpmode - Set the mode for handling packets for a given NP.
- */
-int
-sifnpmode(u, proto, mode)
-    int u;
-    int proto;
-    enum NPmode mode;
-{
-    int npi[2];
-
-    npi[0] = proto;
-    npi[1] = (int) mode;
-    if (strioctl(pppfd, PPPIO_NPMODE, npi, 2 * sizeof(int), 0) < 0) {
-       error("ioctl(set NP %d mode to %d): %m", proto, mode);
-       return 0;
-    }
-    return 1;
-}
-
-#define INET_ADDR(x)   (((struct sockaddr_in *) &(x))->sin_addr.s_addr)
-
-/*
- * sifaddr - Config the interface IP addresses and netmask.
- */
-int
-sifaddr(u, o, h, m)
-    int u;
-    u_int32_t o, h, m;
-{
-    struct ifreq ifr;
-
-    memset(&ifr, 0, sizeof(ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    ifr.ifr_addr.sa_family = AF_INET;
-    INET_ADDR(ifr.ifr_addr) = m;
-    if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
-       error("Couldn't set IP netmask: %m");
-    }
-    ifr.ifr_addr.sa_family = AF_INET;
-    INET_ADDR(ifr.ifr_addr) = o;
-    if (ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
-       error("Couldn't set local IP address: %m");
-    }
-    ifr.ifr_dstaddr.sa_family = AF_INET;
-    INET_ADDR(ifr.ifr_dstaddr) = h;
-    if (ioctl(sockfd, SIOCSIFDSTADDR, &ifr) < 0) {
-       error("Couldn't set remote IP address: %m");
-    }
-#if 0  /* now done in ppp_send_config */
-    ifr.ifr_metric = link_mtu;
-    if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-    }
-#endif
-    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 rtentry rt;
-
-    bzero(&rt, sizeof(rt));
-    rt.rt_dst.sa_family = AF_INET;
-    INET_ADDR(rt.rt_dst) = h;
-    rt.rt_gateway.sa_family = AF_INET;
-    INET_ADDR(rt.rt_gateway) = o;
-    rt.rt_flags = RTF_HOST;
-    if (ioctl(sockfd, SIOCDELRT, &rt) < 0)
-       error("Couldn't delete route through interface: %m");
-    ifaddrs[0] = 0;
-    return 1;
-}
-
-/*
- * sifdefaultroute - assign a default route through the address given.
- */
-int
-sifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct rtentry rt;
-
-    bzero(&rt, sizeof(rt));
-    rt.rt_dst.sa_family = AF_INET;
-    INET_ADDR(rt.rt_dst) = 0;
-    rt.rt_gateway.sa_family = AF_INET;
-    INET_ADDR(rt.rt_gateway) = g;
-    rt.rt_flags = RTF_GATEWAY;
-
-    if (ioctl(sockfd, SIOCADDRT, &rt) < 0) {
-       error("Can't add default route: %m");
-       return 0;
-    }
-
-    default_route_gateway = g;
-    return 1;
-}
-
-/*
- * cifdefaultroute - delete a default route through the address given.
- */
-int
-cifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct rtentry rt;
-
-    bzero(&rt, sizeof(rt));
-    rt.rt_dst.sa_family = AF_INET;
-    INET_ADDR(rt.rt_dst) = 0;
-    rt.rt_gateway.sa_family = AF_INET;
-    INET_ADDR(rt.rt_gateway) = g;
-    rt.rt_flags = RTF_GATEWAY;
-
-    if (ioctl(sockfd, SIOCDELRT, &rt) < 0) {
-       error("Can't delete default route: %m");
-       return 0;
-    }
-
-    default_route_gateway = 0;
-    return 1;
-}
-
-/*
- * sifproxyarp - Make a proxy ARP entry for the peer.
- */
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_int32_t hisaddr;
-{
-    struct arpreq arpreq;
-
-    bzero(&arpreq, sizeof(arpreq));
-    if (!get_ether_addr(hisaddr, &arpreq.arp_ha))
-       return 0;
-
-    arpreq.arp_pa.sa_family = AF_INET;
-    INET_ADDR(arpreq.arp_pa) = hisaddr;
-    arpreq.arp_flags = ATF_PERM | ATF_PUBL;
-    if (ioctl(sockfd, SIOCSARP, (caddr_t) &arpreq) < 0) {
-       error("Couldn't set 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));
-    arpreq.arp_pa.sa_family = AF_INET;
-    INET_ADDR(arpreq.arp_pa) = hisaddr;
-    if (ioctl(sockfd, SIOCDARP, (caddr_t)&arpreq) < 0) {
-       error("Couldn't delete proxy ARP entry: %m");
-       return 0;
-    }
-
-    proxy_arp_addr = 0;
-    return 1;
-}
-
-/*
- * get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
- */
-#define MAX_IFS                32
-
-static int
-get_ether_addr(ipaddr, hwaddr)
-    u_int32_t ipaddr;
-    struct sockaddr *hwaddr;
-{
-    struct ifreq *ifr, *ifend;
-    u_int32_t ina, mask;
-    struct ifreq ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-    int nit_fd;
-
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       error("ioctl(SIOCGIFCONF): %m");
-       return 0;
-    }
-
-    /*
-     * Scan through looking for an interface with an Internet
-     * address on the same subnet as `ipaddr'.
-     */
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-           ((char *)&ifr->ifr_addr + sizeof(struct sockaddr))) {
-        if (ifr->ifr_addr.sa_family == AF_INET) {
-
-            /*
-             * Check that the interface is up, and not point-to-point
-             * or loopback.
-             */
-            strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-            if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-                continue;
-            if ((ifreq.ifr_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.
-             */
-            if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-                continue;
-            ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
-            mask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;
-            if ((ipaddr & mask) != (ina & mask))
-                continue;
-
-            break;
-        }
-    }
-
-    if (ifr >= ifend)
-       return 0;
-    info("found interface %s for proxy arp", ifr->ifr_name);
-
-    /*
-     * Grab the physical address for this interface.
-     */
-    if ((nit_fd = open("/dev/nit", O_RDONLY)) < 0) {
-       error("Couldn't open /dev/nit: %m");
-       return 0;
-    }
-    strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-    if (ioctl(nit_fd, NIOCBIND, &ifreq) < 0
-       || ioctl(nit_fd, SIOCGIFADDR, &ifreq) < 0) {
-       error("Couldn't get hardware address for %s: %m",
-              ifreq.ifr_name);
-       close(nit_fd);
-       return 0;
-    }
-
-    hwaddr->sa_family = AF_UNSPEC;
-    memcpy(hwaddr->sa_data, ifreq.ifr_addr.sa_data, 6);
-    close(nit_fd);
-    return 1;
-}
-
-/*
- * 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(addr)
-    u_int32_t addr;
-{
-    return -1;
-}
-
-#define        WTMPFILE        "/usr/adm/wtmp"
-
-void
-logwtmp(line, name, host)
-    const char *line, *name, *host;
-{
-    int fd;
-    struct stat buf;
-    struct utmp ut;
-
-    if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
-       return;
-    if (!fstat(fd, &buf)) {
-       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-       strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-       strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-       (void)time(&ut.ut_time);
-       if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
-           (void)ftruncate(fd, buf.st_size);
-    }
-    close(fd);
-}
-
-/*
- * 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 ifreq *ifr, *ifend, ifreq;
-    struct ifconf ifc;
-
-    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.
-     */
-    ifc.ifc_len = MAX_IFS * sizeof(struct ifreq);
-    ifc.ifc_req = alloca(ifc.ifc_len);
-    if (ifc.ifc_req == 0)
-       return mask;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("Couldn't get system interface list: %m");
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ++ifr) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       ina = INET_ADDR(ifr->ifr_addr);
-       if ((ntohl(ina) & nmask) != (addr & nmask))
-           continue;
-       /*
-        * Check that the interface is up, and not point-to-point or loopback.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-           != IFF_UP)
-           continue;
-       /*
-        * Get its netmask and OR it into our mask.
-        */
-       if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       mask |= INET_ADDR(ifreq.ifr_addr);
-    }
-
-    return mask;
-}
-
-static int
-strioctl(fd, cmd, ptr, ilen, olen)
-    int fd, cmd, ilen, olen;
-    void *ptr;
-{
-    struct strioctl str;
-
-    str.ic_cmd = cmd;
-    str.ic_timout = 0;
-    str.ic_len = ilen;
-    str.ic_dp = ptr;
-    if (ioctl(fd, I_STR, &str) == -1)
-       return -1;
-    if (str.ic_len != olen)
-       dbglog("strioctl: expected %d bytes, got %d for cmd %x\n",
-              olen, str.ic_len, cmd);
-    return 0;
-}
-
-/*
- * Use the hostid as part of the random number seed.
- */
-int
-get_host_seed()
-{
-    return gethostid();
-}
-
-#if 0
-/*
- * Code for locking/unlocking the serial device.
- * This code is derived from chat.c.
- */
-
-#if !defined(HDB) && !defined(SUNOS3)
-#define        HDB     1               /* ascii lock files are the default */
-#endif
-
-#ifndef LOCK_DIR
-# if HDB
-#  define      PIDSTRING
-#  define      LOCK_PREFIX     "/usr/spool/locks/LCK.."
-# else /* HDB */
-#  define      LOCK_PREFIX     "/usr/spool/uucp/LCK.."
-# endif /* HDB */
-#endif /* LOCK_DIR */
-
-static char *lock_file;                /* name of lock file created */
-
-/*
- * lock - create a lock file for the named device.
- */
-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 */
-#ifdef PIDSTRING
-           n = read(fd, hdb_lock_buffer, 11);
-           if (n > 0) {
-               hdb_lock_buffer[n] = 0;
-               pid = atoi(hdb_lock_buffer);
-           }
-#else
-           n = read(fd, &pid, sizeof(pid));
-#endif
-           if (n <= 0) {
-               error("Can't read pid from lock file %s", lock_file);
-               close(fd);
-           } else {
-               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;
-    }
-
-#ifdef PIDSTRING
-    slprintf(hdb_lock_buffer, sizeof(hdb_lock_buffer), "%10d\n", getpid());
-    write(fd, hdb_lock_buffer, 11);
-#else
-    pid = getpid();
-    write(fd, &pid, sizeof pid);
-#endif
-
-    close(fd);
-    return 0;
-}
-
-/*
- * unlock - remove our lockfile
- */
-void
-unlock()
-{
-    if (lock_file) {
-       unlink(lock_file);
-       free(lock_file);
-       lock_file = NULL;
-    }
-}
-#endif /* lock stuff removed */
-
-/*
- * 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;
-{
-    int i, mfd, sfd;
-    char pty_name[12];
-    struct termios tios;
-
-    sfd = -1;
-    for (i = 0; i < 64; ++i) {
-       slprintf(pty_name, sizeof(pty_name), "/dev/pty%c%x",
-                'p' + i / 16, i % 16);
-       mfd = open(pty_name, O_RDWR, 0);
-       if (mfd >= 0) {
-           pty_name[5] = 't';
-           sfd = open(pty_name, O_RDWR | O_NOCTTY, 0);
-           if (sfd >= 0)
-               break;
-           close(mfd);
-       }
-    }
-    if (sfd < 0)
-       return 0;
-
-    strlcpy(slave_name, pty_name, 12);
-    *master_fdp = mfd;
-    *slave_fdp = sfd;
-    fchown(sfd, uid, -1);
-    fchmod(sfd, S_IRUSR | S_IWUSR);
-    if (tcgetattr(sfd, &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(sfd, TCSAFLUSH, &tios) < 0)
-           warn("couldn't set attributes on pty: %m");
-    } else
-       warn("couldn't get attributes on pty: %m");
-
-    return 1;
-}
-
-/*
- * SunOS doesn't have strtoul :-(
- */
-unsigned long
-strtoul(str, ptr, base)
-    char *str, **ptr;
-    int base;
-{
-    return (unsigned long) strtol(str, ptr, base);
-}
-
-/*
- * Or strerror :-(
- */
-extern char *sys_errlist[];
-extern int sys_nerr;
-
-char *
-strerror(n)
-    int n;
-{
-    static char unknown[32];
-
-    if (n > 0 && n < sys_nerr)
-       return sys_errlist[n];
-    slprintf(unknown, sizeof(unknown), "Error %d", n);
-    return unknown;
-}
diff --git a/pppd/sys-svr4.c b/pppd/sys-svr4.c
deleted file mode 100644 (file)
index 1230cc6..0000000
+++ /dev/null
@@ -1,2778 +0,0 @@
-/*
- * System-dependent procedures for pppd under Solaris 2.
- *
- * Parts re-written by Adi Masputra <adi.masputra@sun.com>, based on 
- * the original sys-svr4.c
- *
- * Copyright (c) 2000 by Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies.  
- *
- * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
- *
- * Copyright (c) 1995-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. 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.
- *
- * 3. 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.
- *
- * Derived from main.c and pppd.h, which are:
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-svr4.c,v 1.46 2004/11/04 10:02:26 paulus Exp $"
-
-#include <limits.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <termios.h>
-#ifndef CRTSCTS
-#include <sys/termiox.h>
-#endif
-#include <signal.h>
-#include <utmpx.h>
-#include <sys/types.h>
-#include <sys/ioccom.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysmacros.h>
-#include <sys/systeminfo.h>
-#include <sys/dlpi.h>
-#include <sys/stat.h>
-#include <sys/mkdev.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/route.h>
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include <netinet/in.h>
-#ifdef SOL2
-#include <sys/tihdr.h>
-#include <sys/tiuser.h>
-#include <inet/common.h>
-#include <inet/mib2.h>
-#include <sys/ethernet.h>
-#endif
-
-#include "pppd.h"
-#include "fsm.h"
-#include "lcp.h"
-#include "ipcp.h"
-#include "ccp.h"
-
-#if !defined(PPP_DEV_NAME)
-#define PPP_DEV_NAME   "/dev/ppp"
-#endif /* !defined(PPP_DEV_NAME) */
-
-#if !defined(AHDLC_MOD_NAME)
-#define AHDLC_MOD_NAME "ppp_ahdl"
-#endif /* !defined(AHDLC_MOD_NAME) */
-
-#if !defined(COMP_MOD_NAME)
-#define COMP_MOD_NAME  "ppp_comp"
-#endif /* !defined(COMP_MOD_NAME) */
-
-#if !defined(IP_DEV_NAME)
-#define        IP_DEV_NAME     "/dev/ip"
-#endif /* !defined(IP_DEV_NAME) */
-
-#if !defined(IP_MOD_NAME)
-#define        IP_MOD_NAME     "ip"
-#endif /* !defined(IP_MOD_NAME) */
-
-#if !defined(UDP_DEV_NAME) && defined(SOL2)
-#define        UDP_DEV_NAME    "/dev/udp"
-#endif /* !defined(UDP_DEV_NAME) && defined(SOL2) */
-
-#if !defined(UDP6_DEV_NAME) && defined(SOL2)
-#define        UDP6_DEV_NAME   "/dev/udp6"
-#endif /* !defined(UDP6_DEV_NAME) && defined(SOL2) */
-
-static const char rcsid[] = RCSID;
-
-#if defined(SOL2)
-/*
- * "/dev/udp" is used as a multiplexor to PLINK the interface stream
- * under. It is used in place of "/dev/ip" since STREAMS will not let
- * a driver be PLINK'ed under itself, and "/dev/ip" is typically the
- * driver at the bottom of the tunneling interfaces stream.
- */
-static char *mux_dev_name = UDP_DEV_NAME;
-#else
-static char *mux_dev_name = IP_DEV_NAME;
-#endif
-static int     pppfd;
-static int     fdmuxid = -1;
-static int     ipfd;
-static int     ipmuxid = -1;
-
-#if defined(INET6) && defined(SOL2)
-static int     ip6fd;          /* IP file descriptor */
-static int     ip6muxid = -1;  /* Multiplexer file descriptor */
-static int     if6_is_up = 0;  /* IPv6 interface has been marked up */
-
-#define _IN6_LLX_FROM_EUI64(l, s, eui64, as) do {      \
-       s->sin6_addr.s6_addr32[0] = htonl(as);  \
-       eui64_copy(eui64, s->sin6_addr.s6_addr32[2]);   \
-       s->sin6_family = AF_INET6;              \
-       l.lifr_addr.ss_family = AF_INET6;       \
-       l.lifr_addrlen = 10;                    \
-       l.lifr_addr = laddr;                    \
-       } while (0)
-
-#define IN6_LLADDR_FROM_EUI64(l, s, eui64)  \
-    _IN6_LLX_FROM_EUI64(l, s, eui64, 0xfe800000)
-
-#define IN6_LLTOKEN_FROM_EUI64(l, s, eui64) \
-    _IN6_LLX_FROM_EUI64(l, s, eui64, 0)
-
-#endif /* defined(INET6) && defined(SOL2) */
-
-#if defined(INET6) && defined(SOL2)
-static char    first_ether_name[LIFNAMSIZ];    /* Solaris 8 and above */
-#else
-static char    first_ether_name[IFNAMSIZ];     /* Before Solaris 8 */
-#define MAXIFS         256                     /* Max # of interfaces */
-#endif /* defined(INET6) && defined(SOL2) */
-
-static int     restore_term;
-static struct termios inittermios;
-#ifndef CRTSCTS
-static struct termiox inittermiox;
-static int     termiox_ok;
-#endif
-static struct winsize wsinfo;  /* Initial window size info */
-static pid_t   tty_sid;        /* original session ID for terminal */
-
-extern u_char  inpacket_buf[]; /* borrowed from main.c */
-
-#define MAX_POLLFDS    32
-static struct pollfd pollfds[MAX_POLLFDS];
-static int n_pollfds;
-
-static int     link_mtu, link_mru;
-
-#define NMODULES       32
-static int     tty_nmodules;
-static char    tty_modules[NMODULES][FMNAMESZ+1];
-static int     tty_npushed;
-
-static int     if_is_up;       /* Interface has been marked up */
-static u_int32_t remote_addr;          /* IP address of peer */
-static u_int32_t default_route_gateway;        /* Gateway for default route added */
-static u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
-
-/* Prototypes for procedures local to this file. */
-static int translate_speed __P((int));
-static int baud_rate_of __P((int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr *));
-static int get_hw_addr __P((char *, u_int32_t, struct sockaddr *));
-static int get_hw_addr_dlpi __P((char *, struct sockaddr *));
-static int dlpi_attach __P((int, int));
-static int dlpi_info_req __P((int));
-static int dlpi_get_reply __P((int, union DL_primitives *, int, int));
-static int strioctl __P((int, int, void *, int, int));
-
-#ifdef SOL2
-/*
- * sifppa - Sets interface ppa
- *
- * without setting the ppa, ip module will return EINVAL upon setting the
- * interface UP (SIOCSxIFFLAGS). This is because ip module in 2.8 expects
- * two DLPI_INFO_REQ to be sent down to the driver (below ip) before
- * IFF_UP can be set. Plumbing the device causes one DLPI_INFO_REQ to
- * be sent down, and the second DLPI_INFO_REQ is sent upon receiving
- * IF_UNITSEL (old) or SIOCSLIFNAME (new) ioctls. Such setting of the ppa
- * is required because the ppp DLPI provider advertises itself as
- * a DLPI style 2 type, which requires a point of attachment to be
- * specified. The only way the user can specify a point of attachment
- * is via SIOCSLIFNAME or IF_UNITSEL.
- *
- * Such changes in the behavior of ip module was made to meet new or
- * evolving standards requirements.
- *
- */
-static int
-sifppa(fd, ppa)
-    int fd;
-    int ppa;
-{
-    return (int)ioctl(fd, IF_UNITSEL, (char *)&ppa);
-}
-#endif /* SOL2 */
-
-#if defined(SOL2) && defined(INET6)
-/*
- * get_first_ethernet - returns the first Ethernet interface name found in 
- * the system, or NULL if none is found
- *
- * NOTE: This is the lifreq version (Solaris 8 and above)
- */
-char *
-get_first_ethernet()
-{
-    struct lifnum lifn;
-    struct lifconf lifc;
-    struct lifreq *plifreq;
-    struct lifreq lifr;
-    int        fd, num_ifs, i, found;
-    uint_t fl, req_size;
-    char *req;
-
-    fd = socket(AF_INET, SOCK_DGRAM, 0);
-    if (fd < 0) {
-       return 0;
-    }
-
-    /*
-     * Find out how many interfaces are running
-     */
-    lifn.lifn_family = AF_UNSPEC;
-    lifn.lifn_flags = LIFC_NOXMIT;
-    if (ioctl(fd, SIOCGLIFNUM, &lifn) < 0) {
-       close(fd);
-       error("could not determine number of interfaces: %m");
-       return 0;
-    }
-
-    num_ifs = lifn.lifn_count;
-    req_size = num_ifs * sizeof(struct lifreq);
-    req = malloc(req_size);
-    if (req == NULL) {
-       close(fd);
-       error("out of memory");
-       return 0;
-    }
-
-    /*
-     * Get interface configuration info for all interfaces
-     */
-    lifc.lifc_family = AF_UNSPEC;
-    lifc.lifc_flags = LIFC_NOXMIT;
-    lifc.lifc_len = req_size;
-    lifc.lifc_buf = req;
-    if (ioctl(fd, SIOCGLIFCONF, &lifc) < 0) {
-       close(fd);
-       free(req);
-       error("SIOCGLIFCONF: %m");
-       return 0;
-    }
-
-    /*
-     * And traverse each interface to look specifically for the first
-     * occurence of an Ethernet interface which has been marked up
-     */
-    plifreq = lifc.lifc_req;
-    found = 0;
-    for (i = lifc.lifc_len / sizeof(struct lifreq); i > 0; i--, plifreq++) {
-
-       if (strchr(plifreq->lifr_name, ':') != NULL)
-           continue;
-
-       memset(&lifr, 0, sizeof(lifr));
-       strncpy(lifr.lifr_name, plifreq->lifr_name, sizeof(lifr.lifr_name));
-       if (ioctl(fd, SIOCGLIFFLAGS, &lifr) < 0) {
-           close(fd);
-           free(req);
-           error("SIOCGLIFFLAGS: %m");
-           return 0;
-       }
-       fl = lifr.lifr_flags;
-
-       if ((fl & (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|IFF_LOOPBACK|IFF_NOARP))
-               != (IFF_UP | IFF_BROADCAST))
-           continue;
-
-       found = 1;
-       break;
-    }
-    free(req);
-    close(fd);
-
-    if (found) {
-       strncpy(first_ether_name, lifr.lifr_name, sizeof(first_ether_name));
-       return (char *)first_ether_name;
-    } else
-       return NULL;
-}
-#else
-/*
- * get_first_ethernet - returns the first Ethernet interface name found in 
- * the system, or NULL if none is found
- *
- * NOTE: This is the ifreq version (before Solaris 8). 
- */
-char *
-get_first_ethernet()
-{
-    struct ifconf ifc;
-    struct ifreq *pifreq;
-    struct ifreq ifr;
-    int        fd, num_ifs, i, found;
-    uint_t fl, req_size;
-    char *req;
-
-    fd = socket(AF_INET, SOCK_DGRAM, 0);
-    if (fd < 0) {
-       return 0;
-    }
-
-    /*
-     * Find out how many interfaces are running
-     */
-    if (ioctl(fd, SIOCGIFNUM, (char *)&num_ifs) < 0) {
-       num_ifs = MAXIFS;
-    }
-
-    req_size = num_ifs * sizeof(struct ifreq);
-    req = malloc(req_size);
-    if (req == NULL) {
-       close(fd);
-       error("out of memory");
-       return 0;
-    }
-
-    /*
-     * Get interface configuration info for all interfaces
-     */
-    ifc.ifc_len = req_size;
-    ifc.ifc_buf = req;
-    if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
-       close(fd);
-       free(req);
-       error("SIOCGIFCONF: %m");
-       return 0;
-    }
-
-    /*
-     * And traverse each interface to look specifically for the first
-     * occurence of an Ethernet interface which has been marked up
-     */
-    pifreq = ifc.ifc_req;
-    found = 0;
-    for (i = ifc.ifc_len / sizeof(struct ifreq); i > 0; i--, pifreq++) {
-
-       if (strchr(pifreq->ifr_name, ':') != NULL)
-           continue;
-
-       memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, pifreq->ifr_name, sizeof(ifr.ifr_name));
-       if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
-           close(fd);
-           free(req);
-           error("SIOCGIFFLAGS: %m");
-           return 0;
-       }
-       fl = ifr.ifr_flags;
-
-       if ((fl & (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|IFF_LOOPBACK|IFF_NOARP))
-               != (IFF_UP | IFF_BROADCAST))
-           continue;
-
-       found = 1;
-       break;
-    }
-    free(req);
-    close(fd);
-
-    if (found) {
-       strncpy(first_ether_name, ifr.ifr_name, sizeof(first_ether_name));
-       return (char *)first_ether_name;
-    } else
-       return NULL;
-}
-#endif /* defined(SOL2) && defined(INET6) */
-
-#if defined(SOL2)
-/*
- * get_if_hwaddr - get the hardware address for the specified
- * network interface device.
- */
-int
-get_if_hwaddr(u_char *addr, char *if_name)
-{
-    struct sockaddr s_eth_addr;
-    struct ether_addr *eth_addr = (struct ether_addr *)&s_eth_addr.sa_data;
-
-    if (if_name == NULL)
-       return -1;
-
-    /*
-     * Send DL_INFO_REQ to the driver to solicit its MAC address
-     */
-    if (!get_hw_addr_dlpi(if_name, &s_eth_addr)) {
-       error("could not obtain hardware address for %s", if_name);
-       return -1;
-    }
-
-    memcpy(addr, eth_addr->ether_addr_octet, 6);
-    return 1;
-}
-#endif /* SOL2 */
-
-#if defined(SOL2) && defined(INET6)
-/*
- * slifname - Sets interface ppa and flags
- *
- * in addition to the comments stated in sifppa(), IFF_IPV6 bit must
- * be set in order to declare this as an IPv6 interface
- */
-static int
-slifname(fd, ppa)
-    int fd;
-    int ppa;
-{
-    struct  lifreq lifr;
-    int            ret;
-
-    memset(&lifr, 0, sizeof(lifr));
-    ret = ioctl(fd, SIOCGLIFFLAGS, &lifr);
-    if (ret < 0)
-       goto slifname_done;
-
-    lifr.lifr_flags |= IFF_IPV6;
-    lifr.lifr_flags &= ~(IFF_BROADCAST | IFF_IPV4);
-    lifr.lifr_ppa = ppa;
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-
-    ret = ioctl(fd, SIOCSLIFNAME, &lifr);
-
-slifname_done:
-    return ret;
-
-
-}
-
-
-/*
- * ether_to_eui64 - Convert 48-bit Ethernet address into 64-bit EUI
- *
- * walks the list of valid ethernet interfaces, and convert the first
- * found 48-bit MAC address into EUI 64. caller also assumes that
- * the system has a properly configured Ethernet interface for this
- * function to return non-zero.
- */
-int
-ether_to_eui64(eui64_t *p_eui64)
-{
-    struct sockaddr s_eth_addr;
-    struct ether_addr *eth_addr = (struct ether_addr *)&s_eth_addr.sa_data;
-    char *if_name;
-
-    if ((if_name = get_first_ethernet()) == NULL) {
-       error("no persistent id can be found");
-       return 0;
-    }
-    /*
-     * Send DL_INFO_REQ to the driver to solicit its MAC address
-     */
-    if (!get_hw_addr_dlpi(if_name, &s_eth_addr)) {
-       error("could not obtain hardware address for %s", if_name);
-       return 0;
-    }
-
-    /*
-     * And convert the EUI-48 into EUI-64, per RFC 2472 [sec 4.1]
-     */
-    p_eui64->e8[0] = (eth_addr->ether_addr_octet[0] & 0xFF) | 0x02;
-    p_eui64->e8[1] = (eth_addr->ether_addr_octet[1] & 0xFF);
-    p_eui64->e8[2] = (eth_addr->ether_addr_octet[2] & 0xFF);
-    p_eui64->e8[3] = 0xFF;
-    p_eui64->e8[4] = 0xFE;
-    p_eui64->e8[5] = (eth_addr->ether_addr_octet[3] & 0xFF);
-    p_eui64->e8[6] = (eth_addr->ether_addr_octet[4] & 0xFF);
-    p_eui64->e8[7] = (eth_addr->ether_addr_octet[5] & 0xFF);
-
-    return 1;
-}
-#endif /* defined(SOL2) && defined(INET6) */
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    int ifd, x;
-    struct ifreq ifr;
-#if defined(INET6) && defined(SOL2)
-    int i6fd;
-    struct lifreq lifr;
-#endif /* defined(INET6) && defined(SOL2) */
-#if !defined(SOL2)
-    struct {
-       union DL_primitives prim;
-       char space[64];
-    } reply;
-#endif /* !defined(SOL2) */
-
-    ipfd = open(mux_dev_name, O_RDWR, 0);
-    if (ipfd < 0)
-       fatal("Couldn't open IP device: %m");
-
-#if defined(INET6) && defined(SOL2)
-    ip6fd = open(UDP6_DEV_NAME, O_RDWR, 0);
-    if (ip6fd < 0)
-       fatal("Couldn't open IP device (2): %m");
-#endif /* defined(INET6) && defined(SOL2) */
-
-    if (default_device && !notty)
-       tty_sid = getsid((pid_t)0);
-
-    pppfd = open(PPP_DEV_NAME, O_RDWR | O_NONBLOCK, 0);
-    if (pppfd < 0)
-       fatal("Can't open %s: %m", PPP_DEV_NAME);
-    if (kdebugflag & 1) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(pppfd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-
-    /* Assign a new PPA and get its unit number. */
-    if (strioctl(pppfd, PPPIO_NEWPPA, &ifunit, 0, sizeof(int)) < 0)
-       fatal("Can't create new PPP interface: %m");
-
-#if defined(SOL2)
-    /*
-     * Since sys_init() is called prior to ifname being set in main(),
-     * we need to get the ifname now, otherwise slifname(), and others,
-     * will fail, or maybe, I should move them to a later point ?
-     * <adi.masputra@sun.com>
-     */
-    sprintf(ifname, "ppp%d", ifunit);
-#endif /* defined(SOL2) */
-    /*
-     * Open the ppp device again and link it under the ip multiplexor.
-     * IP will assign a unit number which hopefully is the same as ifunit.
-     * I don't know any way to be certain they will be the same. :-(
-     */
-    ifd = open(PPP_DEV_NAME, O_RDWR, 0);
-    if (ifd < 0)
-       fatal("Can't open %s (2): %m", PPP_DEV_NAME);
-    if (kdebugflag & 1) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(ifd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-
-#if defined(INET6) && defined(SOL2)
-    i6fd = open(PPP_DEV_NAME, O_RDWR, 0);
-    if (i6fd < 0) {
-       close(ifd);
-       fatal("Can't open %s (3): %m", PPP_DEV_NAME);
-    }
-    if (kdebugflag & 1) {
-       x = PPPDBG_LOG + PPPDBG_DRIVER;
-       strioctl(i6fd, PPPIO_DEBUG, &x, sizeof(int), 0);
-    }
-#endif /* defined(INET6) && defined(SOL2) */
-
-#if defined(SOL2)
-    if (ioctl(ifd, I_PUSH, IP_MOD_NAME) < 0) {
-       close(ifd);
-#if defined(INET6)
-       close(i6fd);
-#endif /* defined(INET6) */
-       fatal("Can't push IP module: %m");
-    }
-
-    /*
-     * Assign ppa according to the unit number returned by ppp device
-     * after plumbing is completed above.
-     */
-    if (sifppa(ifd, ifunit) < 0) {
-        close (ifd);
-#if defined(INET6)
-       close(i6fd);
-#endif /* defined(INET6) */
-        fatal("Can't set ppa for unit %d: %m", ifunit);
-    }
-
-#if defined(INET6)
-    /*
-     * An IPv6 interface is created anyway, even when the user does not 
-     * explicitly enable it. Note that the interface will be marked
-     * IPv6 during slifname().
-     */
-    if (ioctl(i6fd, I_PUSH, IP_MOD_NAME) < 0) {
-       close(ifd);
-       close(i6fd);
-       fatal("Can't push IP module (2): %m");
-    }
-
-    /*
-     * Assign ppa according to the unit number returned by ppp device
-     * after plumbing is completed above. In addition, mark the interface
-     * as an IPv6 interface.
-     */
-    if (slifname(i6fd, ifunit) < 0) {
-       close(ifd);
-       close(i6fd);
-       fatal("Can't set ifname for unit %d: %m", ifunit);
-    }
-#endif /* defined(INET6) */
-
-    ipmuxid = ioctl(ipfd, I_PLINK, ifd);
-    close(ifd);
-    if (ipmuxid < 0) {
-#if defined(INET6)
-       close(i6fd);
-#endif /* defined(INET6) */
-       fatal("Can't I_PLINK PPP device to IP: %m");
-    }
-
-    memset(&ifr, 0, sizeof(ifr));
-    sprintf(ifr.ifr_name, "%s", ifname);
-    ifr.ifr_ip_muxid = ipmuxid;
-
-    /*
-     * In Sol 8 and later, STREAMS dynamic module plumbing feature exists.
-     * This is so that an arbitrary module can be inserted, or deleted, 
-     * between ip module and the device driver without tearing down the 
-     * existing stream. Such feature requires the mux ids, which is set 
-     * by SIOCSIFMUXID (or SIOCLSIFMUXID).
-     */
-    if (ioctl(ipfd, SIOCSIFMUXID, &ifr) < 0) {
-       ioctl(ipfd, I_PUNLINK, ipmuxid);
-#if defined(INET6)
-       close(i6fd);
-#endif /* defined(INET6) */
-       fatal("SIOCSIFMUXID: %m");
-    }
-
-#else /* else if !defined(SOL2) */
-
-    if (dlpi_attach(ifd, ifunit) < 0 ||
-       dlpi_get_reply(ifd, &reply.prim, DL_OK_ACK, sizeof(reply)) < 0) {
-       close(ifd);
-       fatal("Can't attach to ppp%d: %m", ifunit);
-    }
-
-    ipmuxid = ioctl(ipfd, I_LINK, ifd);
-    close(ifd);
-    if (ipmuxid < 0)
-       fatal("Can't link PPP device to IP: %m");
-#endif /* defined(SOL2) */
-
-#if defined(INET6) && defined(SOL2)
-    ip6muxid = ioctl(ip6fd, I_PLINK, i6fd);
-    close(i6fd);
-    if (ip6muxid < 0) {
-       ioctl(ipfd, I_PUNLINK, ipmuxid);
-       fatal("Can't I_PLINK PPP device to IP (2): %m");
-    }
-
-    memset(&lifr, 0, sizeof(lifr));
-    sprintf(lifr.lifr_name, "%s", ifname);
-    lifr.lifr_ip_muxid = ip6muxid;
-
-    /*
-     * Let IP know of the mux id [see comment for SIOCSIFMUXID above]
-     */
-    if (ioctl(ip6fd, SIOCSLIFMUXID, &lifr) < 0) {
-       ioctl(ipfd, I_PUNLINK, ipmuxid);
-       ioctl(ip6fd, I_PUNLINK, ip6muxid);
-       fatal("Can't link PPP device to IP (2): %m");
-    }
-#endif /* defined(INET6) && defined(SOL2) */
-
-#if !defined(SOL2)
-    /* Set the interface name for the link. */
-    slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "ppp%d", ifunit);
-    ifr.ifr_metric = ipmuxid;
-    if (strioctl(ipfd, SIOCSIFNAME, (char *)&ifr, sizeof ifr, 0) < 0)
-       fatal("Can't set interface name %s: %m", ifr.ifr_name);
-#endif /* !defined(SOL2) */
-
-    n_pollfds = 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()
-{
-#if defined(SOL2)
-    struct ifreq ifr;
-#if defined(INET6)
-    struct lifreq lifr;
-#endif /* defined(INET6) */
-#endif /* defined(SOL2) */
-
-#if defined(SOL2) && defined(INET6)
-    if (if6_is_up)
-       sif6down(0);
-#endif /* defined(SOL2) && defined(INET6) */
-    if (if_is_up)
-       sifdown(0);
-    if (default_route_gateway)
-       cifdefaultroute(0, default_route_gateway, default_route_gateway);
-    if (proxy_arp_addr)
-       cifproxyarp(0, proxy_arp_addr);
-#if defined(SOL2)
-    /*
-     * Make sure we ask ip what the muxid, because 'ifconfig modlist' will
-     * unlink and re-link the modules, causing the muxid to change.
-     */
-    memset(&ifr, 0, sizeof(ifr));
-    sprintf(ifr.ifr_name, "%s", ifname);
-    if (ioctl(ipfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("SIOCGIFFLAGS: %m");
-       return;
-    }
-
-    if (ioctl(ipfd, SIOCGIFMUXID, &ifr) < 0) {
-       error("SIOCGIFMUXID: %m");
-       return;
-    }
-
-    ipmuxid = ifr.ifr_ip_muxid;
-     
-    if (ioctl(ipfd, I_PUNLINK, ipmuxid) < 0) {
-       error("Can't I_PUNLINK PPP from IP: %m");
-       return;
-    }
-#if defined(INET6)
-    /*
-     * Make sure we ask ip what the muxid, because 'ifconfig modlist' will
-     * unlink and re-link the modules, causing the muxid to change.
-     */
-    memset(&lifr, 0, sizeof(lifr));
-    sprintf(lifr.lifr_name, "%s", ifname);
-    if (ioctl(ip6fd, SIOCGLIFFLAGS, &lifr) < 0) {
-       error("SIOCGLIFFLAGS: %m");
-       return;
-    }
-
-    if (ioctl(ip6fd, SIOCGLIFMUXID, &lifr) < 0) {
-       error("SIOCGLIFMUXID: %m");
-       return;
-    }
-
-    ip6muxid = lifr.lifr_ip_muxid;
-
-    if (ioctl(ip6fd, I_PUNLINK, ip6muxid) < 0) {
-       error("Can't I_PUNLINK PPP from IP (2): %m");
-    }
-#endif /* defined(INET6) */
-#endif /* defined(SOL2) */
-}
-
-/*
- * sys_close - Clean up in a child process before execing.
- */
-void
-sys_close()
-{
-    close(ipfd);
-#if defined(INET6) && defined(SOL2)
-    close(ip6fd);
-#endif /* defined(INET6) && defined(SOL2) */
-    if (pppfd >= 0)
-       close(pppfd);
-}
-
-/*
- * sys_check_options - check the options that the user specified
- */
-int
-sys_check_options()
-{
-    return 1;
-}
-
-#if 0
-/*
- * daemon - Detach us from controlling terminal session.
- */
-int
-daemon(nochdir, noclose)
-    int nochdir, noclose;
-{
-    int pid;
-
-    if ((pid = fork()) < 0)
-       return -1;
-    if (pid != 0)
-       exit(0);                /* parent dies */
-    setsid();
-    if (!nochdir)
-       chdir("/");
-    if (!noclose) {
-       fclose(stdin);          /* don't need stdin, stdout, stderr */
-       fclose(stdout);
-       fclose(stderr);
-    }
-    return 0;
-}
-#endif
-
-/*
- * ppp_available - check whether the system has any ppp interfaces
- */
-int
-ppp_available()
-{
-    struct stat buf;
-
-    return stat(PPP_DEV_NAME, &buf) >= 0;
-}
-
-/*
- * any_compressions - see if compression is enabled or not
- *
- * In the STREAMS implementation of kernel-portion pppd,
- * the comp STREAMS module performs the ACFC, PFC, as well
- * CCP and VJ compressions. However, if the user has explicitly
- * declare to not enable them from the command line, there is
- * no point of having the comp module be pushed on the stream.
- */
-static int
-any_compressions()
-{
-    if ((!lcp_wantoptions[0].neg_accompression) &&
-       (!lcp_wantoptions[0].neg_pcompression) &&
-       (!ccp_protent.enabled_flag) &&
-       (!ipcp_wantoptions[0].neg_vj)) {
-           return 0;
-    }
-    return 1;
-}
-
-/*
- * establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-establish_ppp(fd)
-    int fd;
-{
-    int i;
-
-    /* Pop any existing modules off the tty stream. */
-    for (i = 0;; ++i)
-       if (ioctl(fd, I_LOOK, tty_modules[i]) < 0
-           || strcmp(tty_modules[i], "ptem") == 0
-           || ioctl(fd, I_POP, 0) < 0)
-           break;
-    tty_nmodules = i;
-
-    /* Push the async hdlc module and the compressor module. */
-    tty_npushed = 0;
-
-    if(!sync_serial) {
-        if (ioctl(fd, I_PUSH, AHDLC_MOD_NAME) < 0) {
-            error("Couldn't push PPP Async HDLC module: %m");
-           return -1;
-        }
-        ++tty_npushed;
-    }
-    if (kdebugflag & 4) {
-       i = PPPDBG_LOG + PPPDBG_AHDLC;
-       strioctl(pppfd, PPPIO_DEBUG, &i, sizeof(int), 0);
-    }
-    /*
-     * There's no need to push comp module if we don't intend
-     * to compress anything
-     */
-    if (any_compressions()) { 
-        if (ioctl(fd, I_PUSH, COMP_MOD_NAME) < 0)
-           error("Couldn't push PPP compression module: %m");
-       else
-           ++tty_npushed;
-    }
-
-    if (kdebugflag & 2) {
-       i = PPPDBG_LOG; 
-       if (any_compressions())
-           i += PPPDBG_COMP;
-       strioctl(pppfd, PPPIO_DEBUG, &i, sizeof(int), 0);
-    }
-
-    /* Link the serial port under the PPP multiplexor. */
-    if ((fdmuxid = ioctl(pppfd, I_LINK, fd)) < 0) {
-       error("Can't link tty to PPP mux: %m");
-       return -1;
-    }
-
-    return pppfd;
-}
-
-/*
- * restore_loop - reattach the ppp unit to the loopback.
- * This doesn't need to do anything because disestablish_ppp does it.
- */
-void
-restore_loop()
-{
-}
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * It attempts to reconstruct the stream with the previously popped
- * modules.  This shouldn't call die() because it's called from die().
- */
-void
-disestablish_ppp(fd)
-    int fd;
-{
-    int i;
-
-    if (fdmuxid >= 0) {
-       if (ioctl(pppfd, I_UNLINK, fdmuxid) < 0) {
-           if (!hungup)
-               error("Can't unlink tty from PPP mux: %m");
-       }
-       fdmuxid = -1;
-
-       if (!hungup) {
-           while (tty_npushed > 0 && ioctl(fd, I_POP, 0) >= 0)
-               --tty_npushed;
-           for (i = tty_nmodules - 1; i >= 0; --i)
-               if (ioctl(fd, I_PUSH, tty_modules[i]) < 0)
-                   error("Couldn't restore tty module %s: %m",
-                          tty_modules[i]);
-       }
-       if (hungup && default_device && tty_sid > 0) {
-           /*
-            * If we have received a hangup, we need to send a SIGHUP
-            * to the terminal's controlling process.  The reason is
-            * that the original stream head for the terminal hasn't
-            * seen the M_HANGUP message (it went up through the ppp
-            * driver to the stream head for our fd to /dev/ppp).
-            */
-           kill(tty_sid, SIGHUP);
-       }
-    }
-}
-
-/*
- * Check whether the link seems not to be 8-bit clean.
- */
-void
-clean_check()
-{
-    int x;
-    char *s;
-
-    if (strioctl(pppfd, PPPIO_GCLEAN, &x, 0, sizeof(x)) < 0)
-       return;
-    s = NULL;
-    switch (~x) {
-    case RCV_B7_0:
-       s = "bit 7 set to 1";
-       break;
-    case RCV_B7_1:
-       s = "bit 7 set to 0";
-       break;
-    case RCV_EVNP:
-       s = "odd parity";
-       break;
-    case RCV_ODDP:
-       s = "even parity";
-       break;
-    }
-    if (s != NULL) {
-       warn("Serial link is not 8-bit clean:");
-       warn("All received characters had %s", s);
-    }
-}
-
-/*
- * List of valid speeds.
- */
-struct speed {
-    int speed_int, speed_val;
-} speeds[] = {
-#ifdef B50
-    { 50, B50 },
-#endif
-#ifdef B75
-    { 75, B75 },
-#endif
-#ifdef B110
-    { 110, B110 },
-#endif
-#ifdef B134
-    { 134, B134 },
-#endif
-#ifdef B150
-    { 150, B150 },
-#endif
-#ifdef B200
-    { 200, B200 },
-#endif
-#ifdef B300
-    { 300, B300 },
-#endif
-#ifdef B600
-    { 600, B600 },
-#endif
-#ifdef B1200
-    { 1200, B1200 },
-#endif
-#ifdef B1800
-    { 1800, B1800 },
-#endif
-#ifdef B2000
-    { 2000, B2000 },
-#endif
-#ifdef B2400
-    { 2400, B2400 },
-#endif
-#ifdef B3600
-    { 3600, B3600 },
-#endif
-#ifdef B4800
-    { 4800, B4800 },
-#endif
-#ifdef B7200
-    { 7200, B7200 },
-#endif
-#ifdef B9600
-    { 9600, B9600 },
-#endif
-#ifdef B19200
-    { 19200, B19200 },
-#endif
-#ifdef B38400
-    { 38400, B38400 },
-#endif
-#ifdef EXTA
-    { 19200, EXTA },
-#endif
-#ifdef EXTB
-    { 38400, EXTB },
-#endif
-#ifdef B57600
-    { 57600, B57600 },
-#endif
-#ifdef B76800
-    { 76800, B76800 },
-#endif
-#ifdef B115200
-    { 115200, B115200 },
-#endif
-#ifdef B153600
-    { 153600, B153600 },
-#endif
-#ifdef B230400
-    { 230400, B230400 },
-#endif
-#ifdef B307200
-    { 307200, B307200 },
-#endif
-#ifdef B460800
-    { 460800, B460800 },
-#endif
-    { 0, 0 }
-};
-
-/*
- * Translate from bits/second to a speed_t.
- */
-static int
-translate_speed(bps)
-    int bps;
-{
-    struct speed *speedp;
-
-    if (bps == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (bps == speedp->speed_int)
-           return speedp->speed_val;
-    warn("speed %d not supported", bps);
-    return 0;
-}
-
-/*
- * Translate from a speed_t to bits/second.
- */
-static int
-baud_rate_of(speed)
-    int speed;
-{
-    struct speed *speedp;
-
-    if (speed == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (speed == speedp->speed_val)
-           return speedp->speed_int;
-    return 0;
-}
-
-/*
- * 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.
- */
-void
-set_up_tty(fd, local)
-    int fd, local;
-{
-    int speed;
-    struct termios tios;
-#if !defined (CRTSCTS)
-    struct termiox tiox;
-#endif
-
-    if (!sync_serial && tcgetattr(fd, &tios) < 0)
-       fatal("tcgetattr: %m");
-
-#ifndef CRTSCTS
-    termiox_ok = 1;
-    if (!sync_serial && ioctl (fd, TCGETX, &tiox) < 0) {
-       termiox_ok = 0;
-       if (errno != ENOTTY)
-           error("TCGETX: %m");
-    }
-#endif
-
-    if (!restore_term) {
-       inittermios = tios;
-#ifndef CRTSCTS
-       inittermiox = tiox;
-#endif
-       if (!sync_serial)
-           ioctl(fd, TIOCGWINSZ, &wsinfo);
-    }
-
-    tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
-#ifdef CRTSCTS
-    if (crtscts > 0)
-       tios.c_cflag |= CRTSCTS;
-    else if (crtscts < 0)
-       tios.c_cflag &= ~CRTSCTS;
-#else
-    if (crtscts != 0 && !termiox_ok) {
-       error("Can't set RTS/CTS flow control");
-    } else if (crtscts > 0) {
-       tiox.x_hflag |= RTSXOFF|CTSXON;
-    } else if (crtscts < 0) {
-       tiox.x_hflag &= ~(RTSXOFF|CTSXON);
-    }
-#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 */
-    }
-
-    speed = translate_speed(inspeed);
-    if (speed) {
-       cfsetospeed(&tios, speed);
-       cfsetispeed(&tios, speed);
-    } else {
-       speed = cfgetospeed(&tios);
-       /*
-        * We can't proceed if the serial port speed is 0,
-        * since that implies that the serial port is disabled.
-        */
-       if ((speed == B0) && !sync_serial)
-           fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
-    }
-
-    if (!sync_serial && tcsetattr(fd, TCSAFLUSH, &tios) < 0)
-       fatal("tcsetattr: %m");
-
-#ifndef CRTSCTS
-    if (!sync_serial && termiox_ok && ioctl (fd, TCSETXF, &tiox) < 0){
-       error("TCSETXF: %m");
-    }
-#endif
-
-    baud_rate = inspeed = baud_rate_of(speed);
-    if (!sync_serial)
-       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 (!sync_serial && tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
-           if (!hungup && errno != ENXIO)
-               warn("tcsetattr: %m");
-#ifndef CRTSCTS
-       if (!sync_serial && ioctl (fd, TCSETXF, &inittermiox) < 0){
-           if (!hungup && errno != ENXIO)
-               error("TCSETXF: %m");
-       }
-#endif
-       if (!sync_serial)
-           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);
-}
-
-/*
- * open_loopback - open the device we use for getting packets
- * in demand mode.  Under Solaris 2, we use our existing fd
- * to the ppp driver.
- */
-int
-open_ppp_loopback()
-{
-    return pppfd;
-}
-
-/*
- * output - Output PPP packet.
- */
-void
-output(unit, p, len)
-    int unit;
-    u_char *p;
-    int len;
-{
-    struct strbuf data;
-    int retries;
-    struct pollfd pfd;
-
-    dump_packet("sent", p, len);
-    if (snoop_send_hook) snoop_send_hook(p, len);
-
-    data.len = len;
-    data.buf = (caddr_t) p;
-    retries = 4;
-    while (putmsg(pppfd, NULL, &data, 0) < 0) {
-       if (--retries < 0 || (errno != EWOULDBLOCK && errno != EAGAIN)) {
-           if (errno != ENXIO)
-               error("Couldn't send packet: %m");
-           break;
-       }
-       pfd.fd = pppfd;
-       pfd.events = POLLOUT;
-       poll(&pfd, 1, 250);     /* wait for up to 0.25 seconds */
-    }
-}
-
-
-/*
- * 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;
-{
-    int t;
-
-    t = timo == NULL? -1: timo->tv_sec * 1000 + timo->tv_usec / 1000;
-    if (poll(pollfds, n_pollfds, t) < 0 && errno != EINTR)
-       fatal("poll: %m");
-}
-
-/*
- * add_fd - add an fd to the set that wait_input waits for.
- */
-void add_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n)
-       if (pollfds[n].fd == fd)
-           return;
-    if (n_pollfds < MAX_POLLFDS) {
-       pollfds[n_pollfds].fd = fd;
-       pollfds[n_pollfds].events = POLLIN | POLLPRI | POLLHUP;
-       ++n_pollfds;
-    } else
-       error("Too many inputs!");
-}
-
-/*
- * remove_fd - remove an fd from the set that wait_input waits for.
- */
-void remove_fd(fd)
-    int fd;
-{
-    int n;
-
-    for (n = 0; n < n_pollfds; ++n) {
-       if (pollfds[n].fd == fd) {
-           while (++n < n_pollfds)
-               pollfds[n-1] = pollfds[n];
-           --n_pollfds;
-           break;
-       }
-    }
-}
-
-#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;
-{
-    wait_input(timo);
-}
-
-/*
- * 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;
-{
-    struct strbuf ctrl, data;
-    int flags, len;
-    unsigned char ctrlbuf[sizeof(union DL_primitives) + 64];
-
-    for (;;) {
-       data.maxlen = PPP_MRU + PPP_HDRLEN;
-       data.buf = (caddr_t) buf;
-       ctrl.maxlen = sizeof(ctrlbuf);
-       ctrl.buf = (caddr_t) ctrlbuf;
-       flags = 0;
-       len = getmsg(pppfd, &ctrl, &data, &flags);
-       if (len < 0) {
-           if (errno == EAGAIN || errno == EINTR)
-               return -1;
-           fatal("Error reading packet: %m");
-       }
-
-       if (ctrl.len <= 0)
-           return data.len;
-
-       /*
-        * Got a M_PROTO or M_PCPROTO message.  Interpret it
-        * as a DLPI primitive??
-        */
-       if (debug)
-           dbglog("got dlpi prim 0x%x, len=%d",
-                  ((union DL_primitives *)ctrlbuf)->dl_primitive, ctrl.len);
-
-    }
-}
-
-/*
- * get_loop_output - get outgoing packets from the ppp device,
- * 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 len;
-    int rv = 0;
-
-    while ((len = read_packet(inpacket_buf)) > 0) {
-       if (loop_frame(inpacket_buf, len))
-           rv = 1;
-    }
-    return rv;
-}
-
-/*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
-    int unit, mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int cf[2];
-    struct ifreq ifr;
-#if defined(INET6) && defined(SOL2)
-    struct lifreq lifr;
-    int        fd;
-#endif /* defined(INET6) && defined(SOL2) */
-
-    link_mtu = mtu;
-    if (strioctl(pppfd, PPPIO_MTU, &mtu, sizeof(mtu), 0) < 0) {
-       if (hungup && errno == ENXIO)
-           return;
-       error("Couldn't set MTU: %m");
-    }
-    if (fdmuxid >= 0) {
-       if (!sync_serial) {
-           if (strioctl(pppfd, PPPIO_XACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
-               error("Couldn't set transmit ACCM: %m");
-           }
-       }
-       cf[0] = (pcomp? COMP_PROT: 0) + (accomp? COMP_AC: 0);
-       cf[1] = COMP_PROT | COMP_AC;
-       if (any_compressions() &&
-           strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-           error("Couldn't set prot/AC compression: %m");
-       }
-    }
-
-    /* set the MTU for IP as well */
-    memset(&ifr, 0, sizeof(ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    ifr.ifr_metric = link_mtu;
-    if (ioctl(ipfd, SIOCSIFMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-    }
-
-#if defined(INET6) && defined(SOL2) 
-    fd = socket(AF_INET6, SOCK_DGRAM, 0);
-    if (fd < 0)
-       error("Couldn't open IPv6 socket: %m");
-
-    memset(&lifr, 0, sizeof(lifr));
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-    lifr.lifr_mtu = link_mtu;
-    if (ioctl(fd, SIOCSLIFMTU, &lifr) < 0) {
-       close(fd);
-       error("Couldn't set IPv6 MTU: %m");
-    }
-    close(fd);
-#endif /* defined(INET6) && defined(SOL2) */
-}
-
-/*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-ppp_set_xaccm(unit, accm)
-    int unit;
-    ext_accm accm;
-{
-    if (sync_serial)
-       return;
-
-    if (fdmuxid >= 0
-       && strioctl(pppfd, PPPIO_XACCM, accm, sizeof(ext_accm), 0) < 0) {
-       if (!hungup || errno != ENXIO)
-           warn("Couldn't set extended ACCM: %m");
-    }
-}
-
-/*
- * ppp_recv_config - configure the receive-side characteristics of
- * the ppp interface.
- */
-void
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, mru;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    int cf[2];
-
-    link_mru = mru;
-    if (strioctl(pppfd, PPPIO_MRU, &mru, sizeof(mru), 0) < 0) {
-       if (hungup && errno == ENXIO)
-           return;
-       error("Couldn't set MRU: %m");
-    }
-    if (fdmuxid >= 0) {
-       if (!sync_serial) {
-           if (strioctl(pppfd, PPPIO_RACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
-               error("Couldn't set receive ACCM: %m");
-           }
-       }
-       cf[0] = (pcomp? DECOMP_PROT: 0) + (accomp? DECOMP_AC: 0);
-       cf[1] = DECOMP_PROT | DECOMP_AC;
-       if (any_compressions() &&
-           strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-           error("Couldn't set prot/AC decompression: %m");
-       }
-    }
-}
-
-/*
- * ccp_test - ask kernel whether a given compression method
- * is acceptable for use.
- */
-int
-ccp_test(unit, opt_ptr, opt_len, for_transmit)
-    int unit, opt_len, for_transmit;
-    u_char *opt_ptr;
-{
-    if (strioctl(pppfd, (for_transmit? PPPIO_XCOMP: PPPIO_RCOMP),
-                opt_ptr, opt_len, 0) >= 0)
-       return 1;
-    return (errno == ENOSR)? 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 cf[2];
-
-    cf[0] = (isopen? CCP_ISOPEN: 0) + (isup? CCP_ISUP: 0);
-    cf[1] = CCP_ISOPEN | CCP_ISUP | CCP_ERROR | CCP_FATALERROR;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (!hungup || errno != ENXIO)
-           error("Couldn't set kernel CCP state: %m");
-    }
-}
-
-/*
- * get_idle_time - return how long the link has been idle.
- */
-int
-get_idle_time(u, ip)
-    int u;
-    struct ppp_idle *ip;
-{
-    return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
-}
-
-/*
- * get_ppp_stats - return statistics for the link.
- */
-int
-get_ppp_stats(u, stats)
-    int u;
-    struct pppd_stats *stats;
-{
-    struct ppp_stats s;
-
-    if (!sync_serial && 
-       strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
-       error("Couldn't get link statistics: %m");
-       return 0;
-    }
-    stats->bytes_in = s.p.ppp_ibytes;
-    stats->bytes_out = s.p.ppp_obytes;
-    return 1;
-}
-
-#if 0
-/*
- * set_filters - transfer the pass and active filters to the kernel.
- */
-int
-set_filters(pass, active)
-    struct bpf_program *pass, *active;
-{
-    int ret = 1;
-
-    if (pass->bf_len > 0) {
-       if (strioctl(pppfd, PPPIO_PASSFILT, pass,
-                    sizeof(struct bpf_program), 0) < 0) {
-           error("Couldn't set pass-filter in kernel: %m");
-           ret = 0;
-       }
-    }
-    if (active->bf_len > 0) {
-       if (strioctl(pppfd, PPPIO_ACTIVEFILT, active,
-                    sizeof(struct bpf_program), 0) < 0) {
-           error("Couldn't set active-filter in kernel: %m");
-           ret = 0;
-       }
-    }
-    return ret;
-}
-#endif
-
-/*
- * 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 cf[2];
-
-    cf[0] = cf[1] = 0;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (errno != ENXIO && errno != EINVAL)
-           error("Couldn't get compression flags: %m");
-       return 0;
-    }
-    return cf[0] & CCP_FATALERROR;
-}
-
-/*
- * sifvjcomp - config tcp header compression
- */
-int
-sifvjcomp(u, vjcomp, xcidcomp, xmaxcid)
-    int u, vjcomp, xcidcomp, xmaxcid;
-{
-    int cf[2];
-    char maxcid[2];
-
-    if (vjcomp) {
-       maxcid[0] = xcidcomp;
-       maxcid[1] = 15;         /* XXX should be rmaxcid */
-       if (strioctl(pppfd, PPPIO_VJINIT, maxcid, sizeof(maxcid), 0) < 0) {
-           error("Couldn't initialize VJ compression: %m");
-       }
-    }
-
-    cf[0] = (vjcomp? COMP_VJC + DECOMP_VJC: 0) /* XXX this is wrong */
-       + (xcidcomp? COMP_VJCCID + DECOMP_VJCCID: 0);
-    cf[1] = COMP_VJC + DECOMP_VJC + COMP_VJCCID + DECOMP_VJCCID;
-    if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
-       if (vjcomp)
-           error("Couldn't enable VJ compression: %m");
-    }
-
-    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(ipfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface up (get): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(ipfd, SIOCSIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface up (set): %m");
-       return 0;
-    }
-    if_is_up = 1;
-    return 1;
-}
-
-/*
- * sifdown - Config the interface down and disable IP.
- */
-int
-sifdown(u)
-    int u;
-{
-    struct ifreq ifr;
-
-    if (ipmuxid < 0)
-       return 1;
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    if (ioctl(ipfd, SIOCGIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface down (get): %m");
-       return 0;
-    }
-    ifr.ifr_flags &= ~IFF_UP;
-    if (ioctl(ipfd, SIOCSIFFLAGS, &ifr) < 0) {
-       error("Couldn't mark interface down (set): %m");
-       return 0;
-    }
-    if_is_up = 0;
-    return 1;
-}
-
-/*
- * sifnpmode - Set the mode for handling packets for a given NP.
- */
-int
-sifnpmode(u, proto, mode)
-    int u;
-    int proto;
-    enum NPmode mode;
-{
-    int npi[2];
-
-    npi[0] = proto;
-    npi[1] = (int) mode;
-    if (strioctl(pppfd, PPPIO_NPMODE, &npi, 2 * sizeof(int), 0) < 0) {
-       error("ioctl(set NP %d mode to %d): %m", proto, mode);
-       return 0;
-    }
-    return 1;
-}
-
-#if defined(SOL2) && defined(INET6)
-/*
- * sif6up - Config the IPv6 interface up and enable IPv6 packets to pass.
- */
-int
-sif6up(u)
-    int u;
-{
-    struct lifreq lifr;
-    int fd;
-
-    fd = socket(AF_INET6, SOCK_DGRAM, 0);
-    if (fd < 0) {
-       return 0;
-    }
-
-    memset(&lifr, 0, sizeof(lifr));
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-    if (ioctl(fd, SIOCGLIFFLAGS, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    lifr.lifr_flags |= IFF_UP;
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-    if (ioctl(fd, SIOCSLIFFLAGS, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    if6_is_up = 1;
-    close(fd);
-    return 1;
-}
-
-/*
- * sifdown - Config the IPv6 interface down and disable IPv6.
- */
-int
-sif6down(u)
-    int u;
-{
-    struct lifreq lifr;
-    int fd;
-
-    fd = socket(AF_INET6, SOCK_DGRAM, 0);
-    if (fd < 0)
-       return 0;
-
-    memset(&lifr, 0, sizeof(lifr));
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-    if (ioctl(fd, SIOCGLIFFLAGS, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    lifr.lifr_flags &= ~IFF_UP;
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-    if (ioctl(fd, SIOCGLIFFLAGS, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    if6_is_up = 0;
-    close(fd);
-    return 1;
-}
-
-/*
- * sif6addr - Config the interface with an IPv6 link-local address
- */
-int
-sif6addr(u, o, h)
-    int u;
-    eui64_t o, h;
-{
-    struct lifreq lifr;
-    struct sockaddr_storage laddr;
-    struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&laddr;
-    int fd;
-
-    fd = socket(AF_INET6, SOCK_DGRAM, 0);
-    if (fd < 0)
-       return 0;
-
-    memset(&lifr, 0, sizeof(lifr));
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-
-    /*
-     * Do this because /dev/ppp responds to DL_PHYS_ADDR_REQ with
-     * zero values, hence the interface token came to be zero too,
-     * and without this, in.ndpd will complain
-     */
-    IN6_LLTOKEN_FROM_EUI64(lifr, sin6, o);
-    if (ioctl(fd, SIOCSLIFTOKEN, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    /*
-     * Set the interface address and destination address
-     */
-    IN6_LLADDR_FROM_EUI64(lifr, sin6, o);
-    if (ioctl(fd, SIOCSLIFADDR, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    memset(&lifr, 0, sizeof(lifr));
-    strlcpy(lifr.lifr_name, ifname, sizeof(lifr.lifr_name));
-    IN6_LLADDR_FROM_EUI64(lifr, sin6, h);
-    if (ioctl(fd, SIOCSLIFDSTADDR, &lifr) < 0) {
-       close(fd);
-       return 0;
-    }
-
-    return 1;
-}
-
-/*
- * cif6addr - Remove the IPv6 address from interface
- */
-int
-cif6addr(u, o, h)
-    int u;
-    eui64_t o, h;
-{
-    return 1;
-}
-
-#endif /* defined(SOL2) && defined(INET6) */
-
-
-#define INET_ADDR(x)   (((struct sockaddr_in *) &(x))->sin_addr.s_addr)
-
-/*
- * sifaddr - Config the interface IP addresses and netmask.
- */
-int
-sifaddr(u, o, h, m)
-    int u;
-    u_int32_t o, h, m;
-{
-    struct ifreq ifr;
-    int ret = 1;
-
-    memset(&ifr, 0, sizeof(ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    ifr.ifr_addr.sa_family = AF_INET;
-    INET_ADDR(ifr.ifr_addr) = m;
-    if (ioctl(ipfd, SIOCSIFNETMASK, &ifr) < 0) {
-       error("Couldn't set IP netmask: %m");
-       ret = 0;
-    }
-    ifr.ifr_addr.sa_family = AF_INET;
-    INET_ADDR(ifr.ifr_addr) = o;
-    if (ioctl(ipfd, SIOCSIFADDR, &ifr) < 0) {
-       error("Couldn't set local IP address: %m");
-       ret = 0;
-    }
-
-    /*
-     * On some systems, we have to explicitly set the point-to-point
-     * flag bit before we can set a destination address.
-     */
-    if (ioctl(ipfd, SIOCGIFFLAGS, &ifr) >= 0
-       && (ifr.ifr_flags & IFF_POINTOPOINT) == 0) {
-       ifr.ifr_flags |= IFF_POINTOPOINT;
-       if (ioctl(ipfd, SIOCSIFFLAGS, &ifr) < 0) {
-           error("Couldn't mark interface pt-to-pt: %m");
-           ret = 0;
-       }
-    }
-    ifr.ifr_dstaddr.sa_family = AF_INET;
-    INET_ADDR(ifr.ifr_dstaddr) = h;
-    if (ioctl(ipfd, SIOCSIFDSTADDR, &ifr) < 0) {
-       error("Couldn't set remote IP address: %m");
-       ret = 0;
-    }
-#if 0  /* now done in ppp_send_config */
-    ifr.ifr_metric = link_mtu;
-    if (ioctl(ipfd, SIOCSIFMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-    }
-#endif
-
-    remote_addr = h;
-    return ret;
-}
-
-/*
- * 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;
-{
-#if defined(__USLC__)          /* was: #if 0 */
-    cifroute(unit, ouraddr, hisaddr);
-    if (ipmuxid >= 0) {
-       notice("Removing ppp interface unit");
-       if (ioctl(ipfd, I_UNLINK, ipmuxid) < 0) {
-           error("Can't remove ppp interface unit: %m");
-           return 0;
-       }
-       ipmuxid = -1;
-    }
-#endif
-    remote_addr = 0;
-    return 1;
-}
-
-/*
- * sifdefaultroute - assign a default route through the address given.
- */
-int
-sifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct rtentry rt;
-
-#if defined(__USLC__)
-    g = l;                     /* use the local address as gateway */
-#endif
-    memset(&rt, 0, sizeof(rt));
-    rt.rt_dst.sa_family = AF_INET;
-    INET_ADDR(rt.rt_dst) = 0;
-    rt.rt_gateway.sa_family = AF_INET;
-    INET_ADDR(rt.rt_gateway) = g;
-    rt.rt_flags = RTF_GATEWAY;
-
-    if (ioctl(ipfd, SIOCADDRT, &rt) < 0) {
-       error("Can't add default route: %m");
-       return 0;
-    }
-
-    default_route_gateway = g;
-    return 1;
-}
-
-/*
- * cifdefaultroute - delete a default route through the address given.
- */
-int
-cifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct rtentry rt;
-
-#if defined(__USLC__)
-    g = l;                     /* use the local address as gateway */
-#endif
-    memset(&rt, 0, sizeof(rt));
-    rt.rt_dst.sa_family = AF_INET;
-    INET_ADDR(rt.rt_dst) = 0;
-    rt.rt_gateway.sa_family = AF_INET;
-    INET_ADDR(rt.rt_gateway) = g;
-    rt.rt_flags = RTF_GATEWAY;
-
-    if (ioctl(ipfd, SIOCDELRT, &rt) < 0) {
-       error("Can't delete default route: %m");
-       return 0;
-    }
-
-    default_route_gateway = 0;
-    return 1;
-}
-
-/*
- * sifproxyarp - Make a proxy ARP entry for the peer.
- */
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_int32_t hisaddr;
-{
-    struct arpreq arpreq;
-
-    memset(&arpreq, 0, sizeof(arpreq));
-    if (!get_ether_addr(hisaddr, &arpreq.arp_ha))
-       return 0;
-
-    arpreq.arp_pa.sa_family = AF_INET;
-    INET_ADDR(arpreq.arp_pa) = hisaddr;
-    arpreq.arp_flags = ATF_PERM | ATF_PUBL;
-    if (ioctl(ipfd, SIOCSARP, (caddr_t) &arpreq) < 0) {
-       error("Couldn't set 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;
-
-    memset(&arpreq, 0, sizeof(arpreq));
-    arpreq.arp_pa.sa_family = AF_INET;
-    INET_ADDR(arpreq.arp_pa) = hisaddr;
-    if (ioctl(ipfd, SIOCDARP, (caddr_t)&arpreq) < 0) {
-       error("Couldn't delete proxy ARP entry: %m");
-       return 0;
-    }
-
-    proxy_arp_addr = 0;
-    return 1;
-}
-
-/*
- * get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
- */
-#define MAX_IFS                32
-
-static int
-get_ether_addr(ipaddr, hwaddr)
-    u_int32_t ipaddr;
-    struct sockaddr *hwaddr;
-{
-    struct ifreq *ifr, *ifend, ifreq;
-    int nif;
-    struct ifconf ifc;
-    u_int32_t ina, mask;
-
-    /*
-     * Scan through the system's network interfaces.
-     */
-#ifdef SIOCGIFNUM
-    if (ioctl(ipfd, SIOCGIFNUM, &nif) < 0)
-#endif
-       nif = MAX_IFS;
-    ifc.ifc_len = nif * sizeof(struct ifreq);
-    ifc.ifc_buf = (caddr_t) malloc(ifc.ifc_len);
-    if (ifc.ifc_buf == 0)
-       return 0;
-    if (ioctl(ipfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("Couldn't get system interface list: %m");
-       free(ifc.ifc_buf);
-       return 0;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ++ifr) {
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       /*
-        * Check that the interface is up, and not point-to-point or loopback.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(ipfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_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.
-        */
-       if (ioctl(ipfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       ina = INET_ADDR(ifr->ifr_addr);
-       mask = INET_ADDR(ifreq.ifr_addr);
-       if ((ipaddr & mask) == (ina & mask))
-           break;
-    }
-
-    if (ifr >= ifend) {
-       warn("No suitable interface found for proxy ARP");
-       free(ifc.ifc_buf);
-       return 0;
-    }
-
-    info("found interface %s for proxy ARP", ifr->ifr_name);
-    if (!get_hw_addr(ifr->ifr_name, ina, hwaddr)) {
-       error("Couldn't get hardware address for %s", ifr->ifr_name);
-       free(ifc.ifc_buf);
-       return 0;
-    }
-
-    free(ifc.ifc_buf);
-    return 1;
-}
-
-/*
- * get_hw_addr_dlpi - obtain the hardware address using DLPI
- */
-static int
-get_hw_addr_dlpi(name, hwaddr)
-    char *name;
-    struct sockaddr *hwaddr;
-{
-    char *p, *q;
-    int unit, iffd, adrlen;
-    unsigned char *adrp;
-    char ifdev[24];
-    struct {
-       union DL_primitives prim;
-       char space[64];
-    } reply;
-
-    /*
-     * We have to open the device and ask it for its hardware address.
-     * First split apart the device name and unit.
-     */
-    slprintf(ifdev, sizeof(ifdev), "/dev/%s", name);
-    for (q = ifdev + strlen(ifdev); --q >= ifdev; )
-       if (!isdigit(*q))
-           break;
-    unit = atoi(q+1);
-    q[1] = 0;
-
-    /*
-     * Open the device and do a DLPI attach and phys_addr_req.
-     */
-    iffd = open(ifdev, O_RDWR);
-    if (iffd < 0) {
-       error("Can't open %s: %m", ifdev);
-       return 0;
-    }
-    if (dlpi_attach(iffd, unit) < 0
-       || dlpi_get_reply(iffd, &reply.prim, DL_OK_ACK, sizeof(reply)) < 0
-       || dlpi_info_req(iffd) < 0
-       || dlpi_get_reply(iffd, &reply.prim, DL_INFO_ACK, sizeof(reply)) < 0) {
-       close(iffd);
-       return 0;
-    }
-
-    adrlen = reply.prim.info_ack.dl_addr_length;
-    adrp = (unsigned char *)&reply + reply.prim.info_ack.dl_addr_offset;
-
-#if DL_CURRENT_VERSION >= 2
-    if (reply.prim.info_ack.dl_sap_length < 0)
-       adrlen += reply.prim.info_ack.dl_sap_length;
-    else
-       adrp += reply.prim.info_ack.dl_sap_length;
-#endif
-
-    hwaddr->sa_family = AF_UNSPEC;
-    memcpy(hwaddr->sa_data, adrp, adrlen);
-
-    return 1;
-}
-/*
- * get_hw_addr - obtain the hardware address for a named interface.
- */
-static int
-get_hw_addr(name, ina, hwaddr)
-    char *name;
-    u_int32_t ina;
-    struct sockaddr *hwaddr;
-{
-    /* New way - get the address by doing an arp request. */
-    int s;
-    struct arpreq req;
-
-    s = socket(AF_INET, SOCK_DGRAM, 0);
-    if (s < 0)
-       return 0;
-    memset(&req, 0, sizeof(req));
-    req.arp_pa.sa_family = AF_INET;
-    INET_ADDR(req.arp_pa) = ina;
-    if (ioctl(s, SIOCGARP, &req) < 0) {
-       error("Couldn't get ARP entry for %s: %m", ip_ntoa(ina));
-       return 0;
-    }
-    *hwaddr = req.arp_ha;
-    hwaddr->sa_family = AF_UNSPEC;
-
-    return 1;
-}
-
-static int
-dlpi_attach(fd, ppa)
-    int fd, ppa;
-{
-    dl_attach_req_t req;
-    struct strbuf buf;
-
-    req.dl_primitive = DL_ATTACH_REQ;
-    req.dl_ppa = ppa;
-    buf.len = sizeof(req);
-    buf.buf = (void *) &req;
-    return putmsg(fd, &buf, NULL, RS_HIPRI);
-}
-
-static int
-dlpi_info_req(fd)
-    int fd;
-{
-    dl_info_req_t req;
-    struct strbuf buf;
-
-    req.dl_primitive = DL_INFO_REQ;
-    buf.len = sizeof(req);
-    buf.buf = (void *) &req;
-    return putmsg(fd, &buf, NULL, RS_HIPRI);
-}
-
-static int
-dlpi_get_reply(fd, reply, expected_prim, maxlen)
-    union DL_primitives *reply;
-    int fd, expected_prim, maxlen;
-{
-    struct strbuf buf;
-    int flags, n;
-    struct pollfd pfd;
-
-    /*
-     * Use poll to wait for a message with a timeout.
-     */
-    pfd.fd = fd;
-    pfd.events = POLLIN | POLLPRI;
-    do {
-       n = poll(&pfd, 1, 1000);
-    } while (n == -1 && errno == EINTR);
-    if (n <= 0)
-       return -1;
-
-    /*
-     * Get the reply.
-     */
-    buf.maxlen = maxlen;
-    buf.buf = (void *) reply;
-    flags = 0;
-    if (getmsg(fd, &buf, NULL, &flags) < 0)
-       return -1;
-
-    if (buf.len < sizeof(ulong)) {
-       if (debug)
-           dbglog("dlpi response short (len=%d)\n", buf.len);
-       return -1;
-    }
-
-    if (reply->dl_primitive == expected_prim)
-       return 0;
-
-    if (debug) {
-       if (reply->dl_primitive == DL_ERROR_ACK) {
-           dbglog("dlpi error %d (unix errno %d) for prim %x\n",
-                  reply->error_ack.dl_errno, reply->error_ack.dl_unix_errno,
-                  reply->error_ack.dl_error_primitive);
-       } else {
-           dbglog("dlpi unexpected response prim %x\n",
-                  reply->dl_primitive);
-       }
-    }
-
-    return -1;
-}
-
-/*
- * 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 ifreq *ifr, *ifend, ifreq;
-    int nif;
-    struct ifconf ifc;
-
-    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.
-     */
-#ifdef SIOCGIFNUM
-    if (ioctl(ipfd, SIOCGIFNUM, &nif) < 0)
-#endif
-       nif = MAX_IFS;
-    ifc.ifc_len = nif * sizeof(struct ifreq);
-    ifc.ifc_buf = (caddr_t) malloc(ifc.ifc_len);
-    if (ifc.ifc_buf == 0)
-       return mask;
-    if (ioctl(ipfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("Couldn't get system interface list: %m");
-       free(ifc.ifc_buf);
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ++ifr) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       ina = INET_ADDR(ifr->ifr_addr);
-       if ((ntohl(ina) & nmask) != (addr & nmask))
-           continue;
-       /*
-        * Check that the interface is up, and not point-to-point or loopback.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(ipfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-           != IFF_UP)
-           continue;
-       /*
-        * Get its netmask and OR it into our mask.
-        */
-       if (ioctl(ipfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       mask |= INET_ADDR(ifreq.ifr_addr);
-    }
-
-    free(ifc.ifc_buf);
-    return mask;
-}
-
-/*
- * logwtmp - write an accounting record to the /var/adm/wtmp file.
- */
-void
-logwtmp(line, name, host)
-    const char *line, *name, *host;
-{
-    static struct utmpx utmpx;
-
-    if (name[0] != 0) {
-       /* logging in */
-       strncpy(utmpx.ut_user, name, sizeof(utmpx.ut_user));
-       strncpy(utmpx.ut_id, ifname, sizeof(utmpx.ut_id));
-       strncpy(utmpx.ut_line, line, sizeof(utmpx.ut_line));
-       utmpx.ut_pid = getpid();
-       utmpx.ut_type = USER_PROCESS;
-    } else {
-       utmpx.ut_type = DEAD_PROCESS;
-    }
-    gettimeofday(&utmpx.ut_tv, NULL);
-    updwtmpx("/var/adm/wtmpx", &utmpx);
-}
-
-/*
- * get_host_seed - return the serial number of this machine.
- */
-int
-get_host_seed()
-{
-    char buf[32];
-
-    if (sysinfo(SI_HW_SERIAL, buf, sizeof(buf)) < 0) {
-       error("sysinfo: %m");
-       return 0;
-    }
-    return (int) strtoul(buf, NULL, 16);
-}
-
-static int
-strioctl(fd, cmd, ptr, ilen, olen)
-    int fd, cmd, ilen, olen;
-    void *ptr;
-{
-    struct strioctl str;
-
-    str.ic_cmd = cmd;
-    str.ic_timout = 0;
-    str.ic_len = ilen;
-    str.ic_dp = ptr;
-    if (ioctl(fd, I_STR, &str) == -1)
-       return -1;
-    if (str.ic_len != olen)
-       dbglog("strioctl: expected %d bytes, got %d for cmd %x\n",
-              olen, str.ic_len, cmd);
-    return 0;
-}
-
-#if 0
-/*
- * lock - create a lock file for the named lock device
- */
-
-#define LOCK_PREFIX    "/var/spool/locks/LK."
-static char lock_file[40];     /* name of lock file created */
-
-int
-lock(dev)
-    char *dev;
-{
-    int n, fd, pid;
-    struct stat sbuf;
-    char ascii_pid[12];
-
-    if (stat(dev, &sbuf) < 0) {
-       error("Can't get device number for %s: %m", dev);
-       return -1;
-    }
-    if ((sbuf.st_mode & S_IFMT) != S_IFCHR) {
-       error("Can't lock %s: not a character device", dev);
-       return -1;
-    }
-    slprintf(lock_file, sizeof(lock_file), "%s%03d.%03d.%03d",
-            LOCK_PREFIX, major(sbuf.st_dev),
-            major(sbuf.st_rdev), minor(sbuf.st_rdev));
-
-    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, ascii_pid, 11);
-           if (n <= 0) {
-               error("Can't read pid from lock file %s", lock_file);
-               close(fd);
-           } else {
-               ascii_pid[n] = 0;
-               pid = atoi(ascii_pid);
-               if (pid > 0 && 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);
-       lock_file[0] = 0;
-       return -1;
-    }
-
-    slprintf(ascii_pid, sizeof(ascii_pid), "%10d\n", getpid());
-    write(fd, ascii_pid, 11);
-
-    close(fd);
-    return 1;
-}
-
-/*
- * unlock - remove our lockfile
- */
-void
-unlock()
-{
-    if (lock_file[0]) {
-       unlink(lock_file);
-       lock_file[0] = 0;
-    }
-}
-#endif
-
-/*
- * cifroute - delete a route through the addresses given.
- */
-int
-cifroute(u, our, his)
-    int u;
-    u_int32_t our, his;
-{
-    struct rtentry rt;
-
-    memset(&rt, 0, sizeof(rt));
-    rt.rt_dst.sa_family = AF_INET;
-    INET_ADDR(rt.rt_dst) = his;
-    rt.rt_gateway.sa_family = AF_INET;
-    INET_ADDR(rt.rt_gateway) = our;
-    rt.rt_flags = RTF_HOST;
-
-    if (ioctl(ipfd, SIOCDELRT, &rt) < 0) {
-       error("Can't delete route: %m");
-       return 0;
-    }
-
-    return 1;
-}
-
-/*
- * have_route_to - determine if the system has a route to the specified
- * IP address.  Returns 0 if not, 1 if so, -1 if we can't tell.
- * `addr' is in network byte order.
- * For demand mode to work properly, we have to ignore routes
- * through our own interface.
- */
-#ifndef T_CURRENT              /* needed for Solaris 2.5 */
-#define T_CURRENT      MI_T_CURRENT
-#endif
-
-int
-have_route_to(addr)
-    u_int32_t addr;
-{
-#ifdef SOL2
-    int fd, r, flags, i;
-    struct {
-       struct T_optmgmt_req req;
-       struct opthdr hdr;
-    } req;
-    union {
-       struct T_optmgmt_ack ack;
-       unsigned char space[64];
-    } ack;
-    struct opthdr *rh;
-    struct strbuf cbuf, dbuf;
-    int nroutes;
-    mib2_ipRouteEntry_t routes[8];
-    mib2_ipRouteEntry_t *rp;
-
-    fd = open(mux_dev_name, O_RDWR);
-    if (fd < 0) {
-       warn("have_route_to: couldn't open %s: %m", mux_dev_name);
-       return -1;
-    }
-
-    req.req.PRIM_type = T_OPTMGMT_REQ;
-    req.req.OPT_offset = (char *) &req.hdr - (char *) &req;
-    req.req.OPT_length = sizeof(req.hdr);
-    req.req.MGMT_flags = T_CURRENT;
-
-    req.hdr.level = MIB2_IP;
-    req.hdr.name = 0;
-    req.hdr.len = 0;
-
-    cbuf.buf = (char *) &req;
-    cbuf.len = sizeof(req);
-
-    if (putmsg(fd, &cbuf, NULL, 0) == -1) {
-       warn("have_route_to: putmsg: %m");
-       close(fd);
-       return -1;
-    }
-
-    for (;;) {
-       cbuf.buf = (char *) &ack;
-       cbuf.maxlen = sizeof(ack);
-       dbuf.buf = (char *) routes;
-       dbuf.maxlen = sizeof(routes);
-       flags = 0;
-       r = getmsg(fd, &cbuf, &dbuf, &flags);
-       if (r == -1) {
-           warn("have_route_to: getmsg: %m");
-           close(fd);
-           return -1;
-       }
-
-       if (cbuf.len < sizeof(struct T_optmgmt_ack)
-           || ack.ack.PRIM_type != T_OPTMGMT_ACK
-           || ack.ack.MGMT_flags != T_SUCCESS
-           || ack.ack.OPT_length < sizeof(struct opthdr)) {
-           dbglog("have_route_to: bad message len=%d prim=%d",
-                  cbuf.len, ack.ack.PRIM_type);
-           close(fd);
-           return -1;
-       }
-
-       rh = (struct opthdr *) ((char *)&ack + ack.ack.OPT_offset);
-       if (rh->level == 0 && rh->name == 0)
-           break;
-       if (rh->level != MIB2_IP || rh->name != MIB2_IP_21) {
-           while (r == MOREDATA)
-               r = getmsg(fd, NULL, &dbuf, &flags);
-           continue;
-       }
-
-       for (;;) {
-           nroutes = dbuf.len / sizeof(mib2_ipRouteEntry_t);
-           for (rp = routes, i = 0; i < nroutes; ++i, ++rp) {
-               if (rp->ipRouteMask != ~0) {
-                   dbglog("have_route_to: dest=%x gw=%x mask=%x\n",
-                          rp->ipRouteDest, rp->ipRouteNextHop,
-                          rp->ipRouteMask);
-                   if (((addr ^ rp->ipRouteDest) & rp->ipRouteMask) == 0
-                       && rp->ipRouteNextHop != remote_addr)
-                       return 1;
-               }
-           }
-           if (r == 0)
-               break;
-           r = getmsg(fd, NULL, &dbuf, &flags);
-       }
-    }
-    close(fd);
-    return 0;
-#else
-    return -1;
-#endif /* SOL2 */
-}
-
-/*
- * get_pty - get a pty master/slave pair and chown the slave side to
- * the uid given.  Assumes slave_name points to MAXPATHLEN bytes of space.
- */
-int
-get_pty(master_fdp, slave_fdp, slave_name, uid)
-    int *master_fdp;
-    int *slave_fdp;
-    char *slave_name;
-    int uid;
-{
-    int mfd, sfd;
-    char *pty_name;
-    struct termios tios;
-
-    mfd = open("/dev/ptmx", O_RDWR);
-    if (mfd < 0) {
-       error("Couldn't open pty master: %m");
-       return 0;
-    }
-
-    pty_name = ptsname(mfd);
-    if (pty_name == NULL) {
-       error("Couldn't get name of pty slave");
-       close(mfd);
-       return 0;
-    }
-    if (chown(pty_name, uid, -1) < 0)
-       warn("Couldn't change owner of pty slave: %m");
-    if (chmod(pty_name, S_IRUSR | S_IWUSR) < 0)
-       warn("Couldn't change permissions on pty slave: %m");
-    if (unlockpt(mfd) < 0)
-       warn("Couldn't unlock pty slave: %m");
-
-    sfd = open(pty_name, O_RDWR);
-    if (sfd < 0) {
-       error("Couldn't open pty slave %s: %m", pty_name);
-       close(mfd);
-       return 0;
-    }
-    if (ioctl(sfd, I_PUSH, "ptem") < 0)
-       warn("Couldn't push ptem module on pty slave: %m");
-
-    dbglog("Using %s", pty_name);
-    strlcpy(slave_name, pty_name, MAXPATHLEN);
-    *master_fdp = mfd;
-    *slave_fdp = sfd;
-
-    return 1;
-}
diff --git a/pppd/sys-ultrix.c b/pppd/sys-ultrix.c
deleted file mode 100644 (file)
index 6945894..0000000
+++ /dev/null
@@ -1,1438 +0,0 @@
-/*
- * sys-ultrix.c - System-dependent procedures for setting up
- * PPP interfaces on Ultrix systems.
- *
- * Copyright (c) 1995-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. 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.
- *
- * 3. 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.
- *
- * Derived from main.c and pppd.h, which are:
- *
- * 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.
- */
-
-#define RCSID  "$Id: sys-ultrix.c,v 1.35 2004/11/04 10:02:26 paulus Exp $"
-
-/*
- * TODO:
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <utmp.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-
-#include <net/if.h>
-#include <net/ppp_defs.h>
-#include <net/if_ppp.h>
-#include <net/route.h>
-#include <netinet/in.h>
-
-#include "pppd.h"
-
-static const char rcsid[] = RCSID;
-
-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 restore_term;       /* 1 => we've munged the terminal */
-static struct termios inittermios; /* Initial TTY termios */
-static struct winsize wsinfo;  /* Initial window size info */
-
-static char *lock_file;                /* name of lock file created */
-
-static int loop_slave = -1;
-static int loop_master;
-static char loop_name[20];
-
-static unsigned char inbuf[512]; /* buffer for chars read from loopback */
-
-static int sockfd;             /* socket for doing interface ioctls */
-
-static 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 */
-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 translate_speed __P((int));
-static int baud_rate_of __P((int));
-static int get_ether_addr __P((u_int32_t, struct sockaddr *));
-
-
-/*
- * sys_init - System-dependent initialization.
- */
-void
-sys_init()
-{
-    /* Get an internet socket for doing socket ioctl's on. */
-    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
-       fatal("Couldn't create IP socket: %m");
-
-    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 shouldn't 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(sockfd, SIOCGIFFLAGS, &ifr) >= 0
-           && ((ifr.ifr_flags & IFF_UP) != 0)) {
-           ifr.ifr_flags &= ~IFF_UP;
-           ioctl(sockfd, SIOCSIFFLAGS, &ifr);
-       }
-    }
-    if (ifaddrs[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(sockfd);
-    if (loop_slave >= 0) {
-       close(loop_slave);
-       close(loop_master);
-    }
-}
-
-/*
- * sys_check_options - check the options that the user specified
- */
-int
-sys_check_options()
-{
-    if (demand) {
-       option_error("Sorry - demand-dialling is not supported under Ultrix\n");
-       return 0;
-    }
-    return 1;
-}
-
-#if 0
-/*
- * daemon - Detach us from the terminal session.
- */
-int
-daemon(nochdir, noclose)
-    int nochdir, noclose;
-{
-    int pid;
-
-    if ((pid = fork()) < 0)
-       return -1;
-    if (pid != 0)
-       exit(0);                /* parent dies */
-    setsid();
-    if (!nochdir)
-       chdir("/");
-    if (!noclose) {
-       fclose(stdin);          /* don't need stdin, stdout, stderr */
-       fclose(stdout);
-       fclose(stderr);
-    }
-    return 0;
-}
-#endif
-
-/*
- * 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);
-
-    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.ultrix\n\
-file in the ppp-2.2 distribution.\n";
-    return ok;
-}
-
-/*
- * establish_ppp - Turn the serial port into a ppp interface.
- */
-int
-establish_ppp(fd)
-    int fd;
-{
-    int pppdisc = PPPDISC;
-    int x;
-
-    /*
-     * 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");
-
-    /*
-     * Find out which interface we were given.
-     */
-    if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0) {
-       fatal("ioctl(PPPIOCGUNIT): %m");
-
-    ppp_fd = fd;
-
-    /*
-     * Enable debug in the driver if requested.
-     */
-    if (kdebugflag) {
-       if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-           warn("ioctl (PPPIOCGFLAGS): %m");
-       } else {
-           x |= (kdebugflag & 0xFF) * SC_DEBUG;
-           if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-               warn("ioctl(PPPIOCSFLAGS): %m");
-       }
-    }
-
-    /*
-     * 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.
- */
-void
-restore_loop()
-{
-}
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
- * This shouldn't call die() because it's called from die().
- */
-void
-disestablish_ppp(fd)
-     int fd;
-{
-    /* 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;
-
-    /* Restore old line discipline. */
-    if (initdisc >= 0 && ioctl(fd, TIOCSETD, &initdisc) < 0)
-       error("ioctl(TIOCSETD): %m");
-    initdisc = -1;
-
-    if (fd == ppp_fd)
-       ppp_fd = -1;
-}
-
-/*
- * Check whether the link seems not to be 8-bit clean.
- */
-void
-clean_check()
-{
-    int x;
-    char *s;
-
-    if (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) {
-           warn("Serial link is not 8-bit clean:");
-           warn("All received characters had %s", s);
-       }
-    }
-}
-
-
-/*
- * List of valid speeds.
- */
-struct speed {
-    int speed_int, speed_val;
-} speeds[] = {
-#ifdef B50
-    { 50, B50 },
-#endif
-#ifdef B75
-    { 75, B75 },
-#endif
-#ifdef B110
-    { 110, B110 },
-#endif
-#ifdef B134
-    { 134, B134 },
-#endif
-#ifdef B150
-    { 150, B150 },
-#endif
-#ifdef B200
-    { 200, B200 },
-#endif
-#ifdef B300
-    { 300, B300 },
-#endif
-#ifdef B600
-    { 600, B600 },
-#endif
-#ifdef B1200
-    { 1200, B1200 },
-#endif
-#ifdef B1800
-    { 1800, B1800 },
-#endif
-#ifdef B2000
-    { 2000, B2000 },
-#endif
-#ifdef B2400
-    { 2400, B2400 },
-#endif
-#ifdef B3600
-    { 3600, B3600 },
-#endif
-#ifdef B4800
-    { 4800, B4800 },
-#endif
-#ifdef B7200
-    { 7200, B7200 },
-#endif
-#ifdef B9600
-    { 9600, B9600 },
-#endif
-#ifdef B19200
-    { 19200, B19200 },
-#endif
-#ifdef B38400
-    { 38400, B38400 },
-#endif
-#ifdef EXTA
-    { 19200, EXTA },
-#endif
-#ifdef EXTB
-    { 38400, EXTB },
-#endif
-#ifdef B57600
-    { 57600, B57600 },
-#endif
-#ifdef B115200
-    { 115200, B115200 },
-#endif
-    { 0, 0 }
-};
-
-/*
- * Translate from bits/second to a speed_t.
- */
-int
-translate_speed(bps)
-    int bps;
-{
-    struct speed *speedp;
-
-    if (bps == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (bps == speedp->speed_int)
-           return speedp->speed_val;
-    warn("speed %d not supported", bps);
-    return 0;
-}
-
-/*
- * Translate from a speed_t to bits/second.
- */
-int
-baud_rate_of(speed)
-    int speed;
-{
-    struct speed *speedp;
-
-    if (speed == 0)
-       return 0;
-    for (speedp = speeds; speedp->speed_int; speedp++)
-       if (speed == speedp->speed_val)
-           return speedp->speed_int;
-    return 0;
-}
-
-/*
- * 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.
- */
-void
-set_up_tty(fd, local)
-    int fd, local;
-{
-    int speed, x;
-    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);
-#ifdef CRTSCTS
-    if (crtscts > 0 && !local)
-       tios.c_cflag |= CRTSCTS;
-    else if (crtscts < 0)
-       tios.c_cflag &= ~CRTSCTS;
-#endif /* CRTSCTS */
-
-    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 */
-    }
-
-    speed = translate_speed(inspeed);
-    if (speed) {
-       cfsetospeed(&tios, speed);
-       cfsetispeed(&tios, speed);
-    } else {
-       speed = cfgetospeed(&tios);
-       /*
-        * We can't proceed if the serial port speed is B0,
-        * since that implies that the serial port is disabled.
-        */
-       if (speed == B0)
-           fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
-    }
-
-    if (tcsetattr(fd, TCSAFLUSH, &tios) < 0)
-       fatal("tcsetattr: %m");
-
-    x = 0;
-    if (ioctl(fd, (crtscts > 0 || modem)? TIOCMODEM: TIOCNMODEM, &x) < 0)
-       warn("TIOC(N)MODEM: %m");
-    if (ioctl(fd, (local || !modem)? TIOCNCAR: TIOCCAR) < 0)
-       warn("TIOC(N)CAR: %m");
-
-    baud_rate = inspeed = baud_rate_of(speed);
-    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);
-}
-
-
-/*
- * open_ppp_loopback - open the device we use for getting
- * packets in demand mode, and connect it to a ppp interface.
- * Here we use would use a pty, except that Ultrix ptys are brain-dead.
- */
-int
-open_ppp_loopback()
-{
-    fatal("open_ppp_loopback called!");
-    /* 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(ttyfd+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;
-{
-    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;
-{
-    wait_time(timo);
-}
-
-
-/*
- * 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(fd): %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()
-{
-    return 0;
-}
-
-
-/*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
- */
-void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
-    int unit, mtu;
-    u_int32_t asyncmap;
-    int pcomp, accomp;
-{
-    u_int x;
-
-    if (ioctl(ppp_fd, PPPIOCSMTU, &mtu) < 0)
-       fatal("ioctl(PPPIOCSMTU): %m");
-
-    if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0)
-       fatal("ioctl(PPPIOCSASYNCMAP): %m");
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl (PPPIOCGFLAGS): %m");
-    x = pcomp? x | SC_COMP_PROT: x &~ SC_COMP_PROT;
-    x = accomp? x | SC_COMP_AC: x &~ SC_COMP_AC;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCSFLAGS): %m");
-}
-
-
-/*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
- */
-void
-ppp_set_xaccm(unit, accm)
-    int unit;
-    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
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, 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");
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl (PPPIOCGFLAGS): %m");
-    x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       fatal("ioctl(PPPIOCSFLAGS): %m");
-}
-
-/*
- * 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;
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl (PPPIOCGFLAGS): %m");
-       return;
-    }
-    x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN;
-    x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
-       error("ioctl(PPPIOCSFLAGS): %m");
-}
-
-/*
- * 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;
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCGFLAGS): %m");
-       return 0;
-    }
-    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, interface, sizeof(req.ifr_name));
-    if (ioctl(sockfd, 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;
-}
-
-
-/*
- * sifvjcomp - config tcp header compression
- */
-int
-sifvjcomp(u, vjcomp, cidcomp, maxcid)
-    int u, vjcomp, cidcomp, maxcid;
-{
-    u_int x;
-
-    if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl (PPPIOCGFLAGS): %m");
-       return 0;
-    }
-    x = vjcomp ? x | SC_COMP_TCP: x &~ SC_COMP_TCP;
-    x = cidcomp? x & ~SC_NO_TCP_CCID: x | SC_NO_TCP_CCID;
-    if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) {
-       error("ioctl(PPPIOCSFLAGS): %m");
-       return 0;
-    }
-    if (ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
-       error("ioctl(PPPIOCSFLAGS): %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(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       return 0;
-    }
-    ifr.ifr_flags |= IFF_UP;
-    if (ioctl(sockfd, 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(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       error("ioctl (SIOCGIFFLAGS): %m");
-       rv = 0;
-    } else {
-       ifr.ifr_flags &= ~IFF_UP;
-       if (ioctl(sockfd, 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); 
-
-/*
- * sifaddr - Config the interface IP addresses and netmask.
- */
-int
-sifaddr(u, o, h, m)
-    int u;
-    u_int32_t o, h, m;
-{
-    int ret;
-    struct ifreq ifr;
-
-    ret = 1;
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    SET_SA_FAMILY(ifr.ifr_addr, AF_INET);
-    if (m != 0) {
-        ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m;
-        info("Setting interface mask to %s\n", ip_ntoa(m));
-        if (ioctl(sockfd, SIOCSIFNETMASK, (caddr_t) &ifr) < 0) {
-            error("ioctl(SIOCSIFNETMASK): %m");
-            ret = 0;
-        }
-    }
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
-    if (ioctl(sockfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
-        error("ioctl(SIOCSIFADDR): %m");
-        ret = 0;
-    }
-    ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = h;
-    if (ioctl(sockfd, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) {
-        error("ioctl(SIOCSIFDSTADDR): %m");
-        ret = 0;
-    }
-    ifaddrs[0] = o;
-    ifaddrs[1] = h;
-    return ret;
-}
-
-/*
- * 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 rtentry rt;
-
-    ifaddrs[0] = 0;
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = h;
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = o;
-    rt.rt_flags = RTF_HOST;
-    if (ioctl(sockfd, SIOCDELRT, (caddr_t) &rt) < 0) {
-        error("ioctl(SIOCDELRT): %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;
-{
-    struct rtentry rt;
-
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, SIOCADDRT, &rt) < 0) {
-        error("default route ioctl(SIOCADDRT): %m");
-        return 0;
-    }
-    default_route_gateway = g;
-    return 1;
-}
-
-/*
- * cifdefaultroute - delete a default route through the address given.
- */
-int
-cifdefaultroute(u, l, g)
-    int u;
-    u_int32_t l, g;
-{
-    struct rtentry rt;
-
-    BZERO(&rt, sizeof(rt));
-    SET_SA_FAMILY(rt.rt_dst, AF_INET);
-    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
-    ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
-    rt.rt_flags = RTF_GATEWAY;
-    if (ioctl(sockfd, SIOCDELRT, &rt) < 0)
-        warn("default route ioctl(SIOCDELRT): %m");
-    default_route_gateway = 0;
-    return 1;
-}
-
-/*
- * sifproxyarp - Make a proxy ARP entry for the peer.
- */
-int
-sifproxyarp(unit, hisaddr)
-    int unit;
-    u_int32_t hisaddr;
-{
-    struct arpreq arpreq;
-
-    BZERO(&arpreq, sizeof(arpreq));
-
-    /*
-     * Get the hardware address of an interface on the same subnet
-     * as our local address.
-     */
-    if (!get_ether_addr(hisaddr, &arpreq.arp_ha)) {
-       error("Cannot determine ethernet address for proxy ARP");
-       return 0;
-    }
-
-    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(sockfd, 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(sockfd, SIOCDARP, (caddr_t)&arpreq) < 0) {
-       warn("Couldn't delete proxy arp entry: %m");
-       return 0;
-    }
-    proxy_arp_addr = 0;
-    return 1;
-}
-
-/*
- * get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
- */
-#define MAX_IFS                32
-
-static int
-get_ether_addr(ipaddr, hwaddr)
-    u_int32_t ipaddr;
-    struct sockaddr *hwaddr;
-{
-    struct ifreq *ifr, *ifend;
-    u_int32_t ina, mask;
-    struct ifreq ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-    struct ifdevea ifdevea;
-
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       error("ioctl(SIOCGIFCONF): %m");
-       return 0;
-    }
-
-    /*
-     * Scan through looking for an interface with an Internet
-     * address on the same subnet as `ipaddr'.
-     */
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-           ((char *)&ifr->ifr_addr + sizeof(struct sockaddr))) {
-        if (ifr->ifr_addr.sa_family == AF_INET) {
-            ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
-            strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-            /*
-             * Check that the interface is up, and not point-to-point
-             * or loopback.
-             */
-            if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-                continue;
-            if ((ifreq.ifr_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.
-             */
-            if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-                continue;
-            mask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;
-            if ((ipaddr & mask) != (ina & mask))
-                continue;
-
-           break;
-       }
-    }
-
-    if (ifr >= ifend)
-       return 0;
-    info("found interface %s for proxy arp", ifr->ifr_name);
-
-    /*
-     * Grab the physical address for this interface.
-     */
-    strlcpy(ifdevea.ifr_name, ifr->ifr_name, sizeof(ifdevea.ifr_name));
-    if (ioctl(sockfd, SIOCRPHYSADDR, &ifdevea) < 0) {
-       error("Couldn't get h/w address for %s: %m", ifr->ifr_name);
-       return 0;
-    }
-
-    hwaddr->sa_family = AF_UNSPEC;
-    BCOPY(ifdevea.current_pa, hwaddr->sa_data, 6);
-    return 1;
-}
-
-/*
- * 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 ifreq *ifr, *ifend, ifreq;
-    struct ifconf ifc;
-    struct ifreq ifs[MAX_IFS];
-
-    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.
-     */
-    ifc.ifc_len = sizeof(ifs);
-    ifc.ifc_req = ifs;
-    if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) {
-       warn("ioctl(SIOCGIFCONF): %m");
-       return mask;
-    }
-    ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ifr = (struct ifreq *)
-               ((char *)&ifr->ifr_addr + sizeof(struct sockaddr))) {
-       /*
-        * Check the interface's internet address.
-        */
-       if (ifr->ifr_addr.sa_family != AF_INET)
-           continue;
-       ina = ((struct sockaddr_in *) &ifr->ifr_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.
-        */
-       strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
-       if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
-           continue;
-       if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
-           != IFF_UP)
-           continue;
-       /*
-        * Get its netmask and OR it into our mask.
-        */
-       if (ioctl(sockfd, SIOCGIFNETMASK, &ifreq) < 0)
-           continue;
-       mask |= ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
-    }
-
-    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();
-}
-
-
-/*
-  Seems like strdup() is not part of string package in Ultrix.
-  If I understood the man-page on the sun this should work.
-
-  Robert Olsson
-*/
-
-char *strdup( in ) char *in;
-{
-  char* dup;
-  if(! (dup = (char *) malloc( strlen( in ) +1 ))) return NULL;
-  (void) strcpy( dup, in );
-  return dup;
-}
-
-/*
- * This logwtmp() implementation is subject to the following copyright:
- *
- * Copyright (c) 1988 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define        WTMPFILE        "/usr/adm/wtmp"
-
-void
-logwtmp(line, name, host)
-    const char *line, *name, *host;
-{
-    int fd;
-    struct stat buf;
-    struct utmp ut;
-
-    if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
-       return;
-    if (!fstat(fd, &buf)) {
-       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-       strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-       strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-       (void)time(&ut.ut_time);
-       if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
-           (void)ftruncate(fd, buf.st_size);
-    }
-    close(fd);
-}
-
-#if 0
-/*
- * Routines for locking and unlocking the serial device, moved here
- * from chat.c.
- */
-
-#define LOCK_PREFIX    "/usr/spool/uucp/LCK.."
-
-/*
- * lock - create a lock file for the named device
- */
-int
-lock(dev)
-    char *dev;
-{
-    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, &pid, sizeof(pid));
-           if (n <= 0) {
-               error("Can't read pid from lock file %s", lock_file);
-               close(fd);
-           } else {
-               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;
-    }
-
-    pid = getpid();
-    write(fd, &pid, sizeof pid);
-
-    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/pppdump/Makefile.sunos4 b/pppdump/Makefile.sunos4
deleted file mode 100644 (file)
index 6f2581f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# pppstats makefile
-# $Id: Makefile.sunos4,v 1.1 1999/04/01 11:44:55 paulus Exp $
-#
-
-include ../sunos4/Makedefs
-
-OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
-CFLAGS = $(COPTS) -I../include/net
-
-all:   pppdump
-
-pppdump: $(OBJS)
-       $(CC) -o pppdump $(OBJS)
-
-clean:
-       rm -f pppdump $(OBJS) *~
-
-install: pppdump
-       $(INSTALL) -c pppdump $(BINDIR)/pppdump
-       $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)/man8/pppdump.8
diff --git a/pppdump/Makefile.svr4 b/pppdump/Makefile.svr4
deleted file mode 100644 (file)
index 15a4f2f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# pppdump Makefile for SVR4 systems
-# $Id: Makefile.svr4,v 1.1 1999/04/01 11:44:55 paulus Exp $
-#
-
-include ../svr4/Makedefs
-
-CFLAGS= $(COPTS) -I../include/net
-OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
-
-all:   pppdump
-
-pppdump: $(OBJS)
-       $(CC) -o pppdump $(OBJS)
-
-clean:
-       rm -f pppdump *~
-
-install:
-       $(INSTALL) -f $(BINDIR) pppdump
-       $(INSTALL) -m 444 -f $(MANDIR)/man8 pppdump.8
diff --git a/pppstats/Makefile.NeXT b/pppstats/Makefile.NeXT
deleted file mode 100644 (file)
index 93746f0..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# pppstats makefile
-# $Id: Makefile.NeXT,v 1.3 1998/03/25 02:20:35 paulus Exp $
-#
-
-ARCHFLAGS = 
-
-BINDIR = /usr/local/ppp/bin
-MANDIR = /usr/local/ppp/man
-
-CFLAGS = -O -D_POSIX_SOURCE $(ARCHFLAGS) -I../include
-
-SRCS = pppstats.c
-OBJS = pppstats.o
-LIBS = ../NeXT/libposix/libposix.o
-
-MANPAGES = chat.8
-
-
-all: pppstats
-
-pppstats: $(OBJS)
-       $(CC) -o pppstats $(CFLAGS) $(OBJS) $(LIBS)
-
-install:
-       /bin/mkdirs $(MANDIR)/man8 $(BINDIR) 
-       install -c -s -m 555 -o root -g daemon pppstats $(BINDIR)/pppstats
-       install -c -m 444 -o root -g wheel pppstats.8 $(MANDIR)/man8
-
-clean:
-       rm -f pppstats *.o *~ core
-
diff --git a/pppstats/Makefile.aix4 b/pppstats/Makefile.aix4
deleted file mode 100644 (file)
index 516b2a9..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# pppstats makefile
-#
-
-#ifndef BINDIR
-BINDIR=/usr/sbin
-#endif
-#ifndef MANDIR
-MANDIR = /usr/man
-#ENDIF
-
-PPPSTATSRCS = pppstats.c
-PPPSTATOBJS = pppstats.o
-
-CC = xlc
-COPTS = -O
-COMPILE_FLAGS = -DSTREAMS 
-LIBS =
-
-CFLAGS = -I../include $(COPTS) $(COMPILE_FLAGS)
-
-all: pppstats
-
-install: all
-       install -O root -G system -M 4555 -f $(BINDIR) pppstats
-       install -M 555 -O root -f $(MANDIR)/man8 pppstats.8
-
-pppstats: $(PPPSTATSRCS)
-       $(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
-
-clean:
-       rm -f pppstats *.o
-
-depend:
-       cpp -M $(CFLAGS) $(PPPSTATSRCS) >.depend
-#      makedepend $(CFLAGS) $(PPPSTATSRCS)
-
-saber_pppstats:
-       #setopt load_flags $(CFLAGS)
-       #load $(PPPSTATSRCS)
diff --git a/pppstats/Makefile.bsd b/pppstats/Makefile.bsd
deleted file mode 100644 (file)
index f4d186d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#      $Id: Makefile.bsd,v 1.6 1998/03/25 02:21:18 paulus Exp $
-
-PROG=  pppstats
-SRCS=  pppstats.c
-CFLAGS+=-I../include -D_BITYPES
-MAN8=  pppstats.8
-MAN=   pppstats.cat8
-BINDIR=        /usr/sbin
-
-.include <bsd.prog.mk>
diff --git a/pppstats/Makefile.netbsd-1.2 b/pppstats/Makefile.netbsd-1.2
deleted file mode 100644 (file)
index 873838b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#      $Id: Makefile.netbsd-1.2,v 1.2 1998/03/25 02:21:21 paulus Exp $
-
-PROG=  pppstats
-SRCS=  pppstats.c
-CFLAGS+=-I../include -D_BITYPES
-MAN8=  pppstats.8
-MAN=   pppstats.cat8
-BINDIR=        /usr/sbin
-
-.include <bsd.prog.mk>
diff --git a/pppstats/Makefile.osf b/pppstats/Makefile.osf
deleted file mode 100644 (file)
index 309bf04..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# pppstats makefile
-#
-
-PPPSTATSRCS = pppstats.c
-PPPSTATOBJS = pppstats.o
-
-#CC = gcc
-COPTS = -O
-COMPILE_FLAGS = -DSTREAMS
-LIBS =
-
-CFLAGS = -I../include $(COPTS) $(COMPILE_FLAGS)
-
-all: pppstats
-
-install: pppstats
-       installbsd -c pppstats $(BINDIR)/pppstats
-       installbsd -c -m 444 pppstats.8 $(MANDIR)/man8/pppstats.8
-
-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/pppstats/Makefile.sunos4 b/pppstats/Makefile.sunos4
deleted file mode 100644 (file)
index 12570f5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# pppstats makefile
-# $Id: Makefile.sunos4,v 1.4 1998/03/25 02:21:25 paulus Exp $
-#
-
-include ../sunos4/Makedefs
-
-PPPSTATSRCS = pppstats.c
-PPPSTATOBJS = pppstats.o
-
-COMPILE_FLAGS = -DSTREAMS -DSUNOS4
-LIBS =
-
-CFLAGS = -I../include $(COPTS) $(COMPILE_FLAGS)
-
-all: pppstats
-
-install: pppstats
-       $(INSTALL) -c pppstats $(BINDIR)/pppstats
-       $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)/man8/pppstats.8
-
-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/pppstats/Makefile.svr4 b/pppstats/Makefile.svr4
deleted file mode 100644 (file)
index eb6bb10..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# pppstats Makefile for SVR4 systems
-# $Id: Makefile.svr4,v 1.6 1998/03/25 02:21:26 paulus Exp $
-#
-
-include ../svr4/Makedefs
-
-CFLAGS = -DSTREAMS -I../include $(COPTS)
-
-all: pppstats
-
-pppstats: pppstats.c
-       $(CC) $(CFLAGS) -o pppstats pppstats.c
-
-install: pppstats
-       $(INSTALL) -f $(BINDIR) pppstats
-       $(INSTALL) -m 444 -f $(MANDIR)/man8 pppstats.8
-
-clean:
-       rm -f pppstats *~ core
diff --git a/pppstats/Makefile.ultrix b/pppstats/Makefile.ultrix
deleted file mode 100644 (file)
index 519cf1f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# pppstats makefile
-# $Id: Makefile.ultrix,v 1.6 1998/03/25 02:21:27 paulus Exp $
-#
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-
-PPPSTATSRCS = pppstats.c
-PPPSTATOBJS = pppstats.o
-
-#CC = gcc
-COPTS = -O
-COMPILE_FLAGS = -DULTRIX
-LIBS = 
-
-CFLAGS = -I../include $(COPTS) $(COMPILE_FLAGS)
-
-all: pppstats
-
-install: pppstats
-       install -c pppstats $(BINDIR)/pppstats
-       install -c -m 444 pppstats.8 $(MANDIR)/man8/pppstats.8
-
-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/sunos4/Makedefs b/sunos4/Makedefs
deleted file mode 100644 (file)
index 8b56a2b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# defines common to several Makefiles
-#
-
-INSTALL= install -o root -g daemon
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-ETCDIR = /etc/ppp
-
-# To use gcc, uncomment the next line.
-#CC = gcc
-COPTS = -O
diff --git a/sunos4/Makefile b/sunos4/Makefile
deleted file mode 100644 (file)
index 01c7d1a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Makefile for STREAMS modules for SunOS 4.
-#
-# $Id: Makefile,v 1.9 1998/03/25 03:09:38 paulus Exp $
-#
-
-include Makedefs
-
-LD = /usr/bin/ld               # make sure we don't get gnu ld
-
-# Defining __$(ARCH)__ is for gcc's broken version of sun/vddrv.h.
-ARCH = `/bin/arch -k`
-DEFINES= -DKERNEL -D_KERNEL -DSUNOS4 -D$(ARCH) -D__$(ARCH)__ \
-        -DDEBUG -DNO_DLPI -DSNIT_SUPPORT
-CFLAGS= $(DEFINES) -I../include $(COPTS)
-
-MODULES= ppp_mod.o ppp_ahdl_mod.o ppp_comp_mod.o if_ppp_mod.o
-
-all:   $(MODULES)
-
-ppp_mod.o:     ppp.o ppp_vdcmd.o
-       $(LD) -r -o ppp_mod.o ppp.o ppp_vdcmd.o
-
-ppp_ahdl_mod.o: ppp_ahdlc.o ppp_ahdlc_vdcmd.o
-       $(LD) -r -o ppp_ahdl_mod.o ppp_ahdlc.o ppp_ahdlc_vdcmd.o
-
-COMP_OBJS = ppp_comp.o bsd-comp.o deflate.o zlib.o vjcompress.o \
-       ppp_comp_vdcmd.o
-ppp_comp_mod.o: $(COMP_OBJS)
-       $(LD) -r -o $@ $(COMP_OBJS)
-
-if_ppp.o: ../modules/if_ppp.c
-       $(CC) $(CFLAGS) -c $?
-bsd-comp.o: ../modules/bsd-comp.c
-       $(CC) $(CFLAGS) -c $?
-deflate.o: ../modules/deflate.c
-       $(CC) $(CFLAGS) -c $?
-ppp.o: ../modules/ppp.c
-       $(CC) $(CFLAGS) -c $?
-ppp_ahdlc.o: ../modules/ppp_ahdlc.c
-       $(CC) $(CFLAGS) -c $?
-ppp_comp.o: ../modules/ppp_comp.c
-       $(CC) $(CFLAGS) -c $?
-vjcompress.o: ../modules/vjcompress.c
-       $(CC) $(CFLAGS) -c $?
-zlib.o:        ../common/zlib.c
-       $(CC) $(CFLAGS) -c $?
-
-if_ppp_mod.o:  if_ppp.o if_ppp_vdcmd.o
-       $(LD) -r -o if_ppp_mod.o if_ppp.o if_ppp_vdcmd.o
-
-install: all
-       $(INSTALL) $(MODULES) $(BINDIR)
-       ./ppp.INSTALL
-
-clean:
-       rm -f ppp ppp_comp ppp_ahdl *.o *~ core
diff --git a/sunos4/Makefile.top b/sunos4/Makefile.top
deleted file mode 100644 (file)
index c86e088..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# ppp top level makefile
-#
-
-include sunos4/Makedefs
-
-all:
-       cd chat; $(MAKE) all
-       cd pppd; $(MAKE) all
-       cd pppstats; $(MAKE) all
-       cd sunos4; $(MAKE) all
-       cd pppdump; $(MAKE) all
-
-install: $(BINDIR) $(MANDIR)/man8 install-progs install-etcppp
-
-install-progs:
-       cd chat; $(MAKE) install
-       cd pppd; $(MAKE) install
-       cd pppstats; $(MAKE) install
-       cd pppdump; $(MAKE) install
-       cd sunos4; $(MAKE) install
-
-install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
-       $(ETCDIR)/chap-secrets
-
-$(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 *~
-       cd chat; $(MAKE) clean
-       cd pppd; $(MAKE) clean
-       cd pppstats; $(MAKE) clean
-       cd sunos4; $(MAKE) clean
-
diff --git a/sunos4/if_ppp_vdcmd.c b/sunos4/if_ppp_vdcmd.c
deleted file mode 100644 (file)
index 2bf9710..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/conf.h>
-#include <sun/vddrv.h>
-
-extern struct streamtab if_pppinfo;
-
-static struct vdldrv vd = {
-    VDMAGIC_USER,
-    "if_ppp"
-};
-
-static int fmodsw_index = -1;
-
-int
-if_ppp_vdcmd(fun, vdp, vdi, vds)
-    unsigned int fun;
-    struct vddrv *vdp;
-    addr_t vdi;
-    struct vdstat *vds;
-{
-    int n, error;
-
-    switch (fun) {
-    case VDLOAD:
-       vdp->vdd_vdtab = (struct vdlinkage *) &vd;
-       if (fmodsw_index >= 0)
-           return EBUSY;
-       for (n = 0; n < fmodcnt; ++n)
-           if (fmodsw[n].f_str == 0)
-               break;
-       if (n >= fmodcnt)
-           return ENODEV;
-       strncpy(fmodsw[n].f_name, vd.Drv_name, FMNAMESZ+1);
-       fmodsw[n].f_str = &if_pppinfo;
-       fmodsw_index = n;
-       break;
-
-    case VDUNLOAD:
-       if (fmodsw_index <= 0)
-           return EINVAL;
-       error = if_ppp_unload();
-       if (error != 0)
-           return error;
-       fmodsw[fmodsw_index].f_name[0] = 0;
-       fmodsw[fmodsw_index].f_str = 0;
-       fmodsw_index = -1;
-       break;
-
-    case VDSTAT:
-       break;
-
-    default:
-       return EIO;
-    }
-    return 0;
-}
diff --git a/sunos4/ppp.INSTALL b/sunos4/ppp.INSTALL
deleted file mode 100755 (executable)
index 0018bf8..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/sh
-
-# Script for loading, unloading, etc. ppp modules.
-
-moddir=/usr/local/etc
-etcppp=/etc/ppp
-
-PATH=/usr/etc:/usr/bin
-
-# Check that we're superuser
-touch /tmp/su$$
-if chown root /tmp/su$$ >/dev/null; then :
-else
-    echo "$0: must be root."
-    rm -f /tmp/su$$
-    exit 1
-fi
-rm -f /tmp/su$$
-
-case "$0" in
-*ppp.INSTALL)
-    if [ ! -f ppp.INSTALL ]; then
-       echo "ppp.INSTALL: not found"
-       exit 1
-    fi
-    for n in INSTALL LOAD UNLOAD MKDEV RMDEV; do
-       if [ -h /dev/ppp.$n -o -f /dev/ppp.$n ]; then
-           rm /dev/ppp.$n
-       fi
-    done
-    cp ppp.INSTALL /dev
-    for n in LOAD UNLOAD MKDEV RMDEV; do
-       ln -s ppp.INSTALL /dev/ppp.$n
-    done
-    ;;
-
-*ppp.LOAD)
-    if modstat | grep -w ppp >/dev/null; then
-       echo "ppp driver is already loaded."
-       exit 1
-    fi
-    if modstat | grep -w if_ppp >/dev/null; then
-       echo "if_ppp module already loaded: not reloading."
-    else
-       echo -n "if_ppp: "
-       modload $moddir/if_ppp_mod.o -sym -entry _if_ppp_vdcmd \
-           -o $etcppp/if_ppp_mod
-    fi
-    echo -n "ppp: "
-    modload $moddir/ppp_mod.o -sym -entry _ppp_vdcmd -exec /dev/ppp.MKDEV \
-       -o $etcppp/ppp_mod
-    echo -n "ppp_comp: "
-    modload $moddir/ppp_comp_mod.o -sym -entry _ppp_comp_vdcmd \
-       -o $etcppp/ppp_comp
-    echo -n "ppp_ahdl: "
-    modload $moddir/ppp_ahdl_mod.o -sym -entry _ppp_ahdlc_vdcmd \
-       -o $etcppp/ppp_ahdl
-    exit 0
-    ;;
-
-*ppp.MKDEV)
-    # args: module number, type, b-major, c-major
-    if [ $# -ne 4 ]; then
-       echo "Usage: $0 module-id module-type b-major c-major"
-       exit 1
-    fi
-    if [ "$2" -ne "12345607" -a "$2" -ne "12345600" ]; then
-       echo "$0: $2: bad module type"
-       exit 1
-    fi
-    rm -f /dev/ppp
-    # we "just know" that 37 is the major number of the clone driver
-    mknod /dev/ppp c 37 $4
-    chmod 644 /dev/ppp
-    exit 0
-    ;;
-
-*ppp.UNLOAD)
-    stat=0
-    if modstat | grep -w if_ppp >/dev/null; then
-       echo "$0: not unloading if_ppp module."
-    fi
-    for mod in ppp ppp_comp ppp_ahdl; do
-       id=`modstat | grep -w $mod | awk '{print $1}'`
-       if [ x$id = x ]; then
-           echo "$mod is not loaded."
-           stat=1
-       else
-           modunload -id $id
-       fi
-    done
-    exit $stat
-    ;;
-
-*ppp.RMDEV)
-    rm -f /dev/ppp
-    exit 0
-    ;;
-
-*)
-    echo "Invocation names: ppp.INSTALL ppp.LOAD ppp.UNLOAD ppp.MKDEV ppp.RMDEV"
-    exit 1
-    ;;
-esac
diff --git a/sunos4/ppp_ahdlc_vdcmd.c b/sunos4/ppp_ahdlc_vdcmd.c
deleted file mode 100644 (file)
index 2dbe826..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/conf.h>
-#include <sun/vddrv.h>
-
-extern struct streamtab ppp_ahdlcinfo;
-extern int ppp_ahdlc_count;
-
-static struct vdldrv vd = {
-    VDMAGIC_USER,
-    "ppp_ahdl"
-};
-
-static int fmodsw_index = -1;
-
-int
-ppp_ahdlc_vdcmd(fun, vdp, vdi, vds)
-    unsigned int fun;
-    struct vddrv *vdp;
-    addr_t vdi;
-    struct vdstat *vds;
-{
-    int n;
-
-    switch (fun) {
-    case VDLOAD:
-       vdp->vdd_vdtab = (struct vdlinkage *) &vd;
-       if (fmodsw_index >= 0)
-           return EBUSY;
-       for (n = 0; n < fmodcnt; ++n)
-           if (fmodsw[n].f_str == 0)
-               break;
-       if (n >= fmodcnt)
-           return ENODEV;
-       strncpy(fmodsw[n].f_name, vd.Drv_name, FMNAMESZ+1);
-       fmodsw[n].f_str = &ppp_ahdlcinfo;
-       fmodsw_index = n;
-       break;
-
-    case VDUNLOAD:
-       if (ppp_ahdlc_count > 0)
-           return EBUSY;
-       if (fmodsw_index <= 0)
-           return EINVAL;
-       fmodsw[fmodsw_index].f_name[0] = 0;
-       fmodsw[fmodsw_index].f_str = 0;
-       fmodsw_index = -1;
-       break;
-
-    case VDSTAT:
-       break;
-
-    default:
-       return EIO;
-    }
-    return 0;
-}
diff --git a/sunos4/ppp_comp_vdcmd.c b/sunos4/ppp_comp_vdcmd.c
deleted file mode 100644 (file)
index b81bc47..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/conf.h>
-#include <sun/vddrv.h>
-
-extern struct streamtab ppp_compinfo;
-extern int ppp_comp_count;
-
-static struct vdldrv vd = {
-    VDMAGIC_USER,
-    "ppp_comp"
-};
-
-static int fmodsw_index = -1;
-
-int
-ppp_comp_vdcmd(fun, vdp, vdi, vds)
-    unsigned int fun;
-    struct vddrv *vdp;
-    addr_t vdi;
-    struct vdstat *vds;
-{
-    int n;
-
-    switch (fun) {
-    case VDLOAD:
-       vdp->vdd_vdtab = (struct vdlinkage *) &vd;
-       if (fmodsw_index >= 0)
-           return EBUSY;
-       for (n = 0; n < fmodcnt; ++n)
-           if (fmodsw[n].f_str == 0)
-               break;
-       if (n >= fmodcnt)
-           return ENODEV;
-       strncpy(fmodsw[n].f_name, vd.Drv_name, FMNAMESZ+1);
-       fmodsw[n].f_str = &ppp_compinfo;
-       fmodsw_index = n;
-       break;
-
-    case VDUNLOAD:
-       if (ppp_comp_count > 0)
-           return EBUSY;
-       if (fmodsw_index <= 0)
-           return EINVAL;
-       fmodsw[fmodsw_index].f_name[0] = 0;
-       fmodsw[fmodsw_index].f_str = 0;
-       fmodsw_index = -1;
-       break;
-
-    case VDSTAT:
-       break;
-
-    default:
-       return EIO;
-    }
-    return 0;
-}
diff --git a/sunos4/ppp_vdcmd.c b/sunos4/ppp_vdcmd.c
deleted file mode 100644 (file)
index 68095c9..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/conf.h>
-#include <sun/vddrv.h>
-
-extern struct streamtab pppinfo;
-extern int ppp_count;
-extern int nchrdev;
-
-static struct vdldrv vd = {
-    VDMAGIC_PSEUDO,
-    "ppp"
-};
-
-extern int nodev();
-
-static struct cdevsw ppp_cdevsw = {
-    nodev, nodev, nodev, nodev, nodev, nodev, nodev, 0,
-    &pppinfo
-};
-
-static struct cdevsw old_entry;
-
-int
-ppp_vdcmd(fun, vdp, vdi, vds)
-    unsigned int fun;
-    struct vddrv *vdp;
-    addr_t vdi;
-    struct vdstat *vds;
-{
-    static int majnum = -1;
-    int n, maj;
-
-    switch (fun) {
-    case VDLOAD:
-       /*
-        * It seems like modload doesn't install the cdevsw entry
-        * for us.  Oh well...
-        */
-       for (maj = 1; maj < nchrdev; ++maj)
-           if (cdevsw[maj].d_open == vd_unuseddev)
-               break;
-       if (maj >= nchrdev)
-           return ENODEV;
-       vd.Drv_charmajor = maj;
-       old_entry = cdevsw[maj];
-       cdevsw[maj] = ppp_cdevsw;
-       vd.Drv_cdevsw = &ppp_cdevsw;
-       vdp->vdd_vdtab = (struct vdlinkage *) &vd;
-       majnum = maj;
-       break;
-
-    case VDUNLOAD:
-       if (ppp_count > 0)
-           return EBUSY;
-       if (vd.Drv_charmajor > 0)
-           cdevsw[vd.Drv_charmajor] = old_entry;
-       break;
-
-    case VDSTAT:
-       /*
-        * We have to fool the modstat command into thinking
-        * that this module is actually a driver! This is
-        * so that installation commands that use the -exec
-        * option of modload to run a shell script find out
-        * the block and/or char major numbers of the driver
-        * loaded (so that the shell script can go off to
-        * /dev and *MAKE* the bloody device nodes- remember
-        * they might change from one load to another if
-        * you don't hardwire the number!).
-        */
-       vds->vds_magic = VDMAGIC_DRV;
-       vds->vds_modinfo[0] = (char) 0;
-       vds->vds_modinfo[1] = (char) majnum;
-       break;
-
-    default:
-       return EIO;
-    }
-    return 0;
-}
diff --git a/svr4/Makedefs b/svr4/Makedefs
deleted file mode 100644 (file)
index 81db8ab..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# defines common to several Makefiles
-#
-
-INSTALL= /usr/sbin/install
-
-BINDIR = /usr/local/bin
-MANDIR = /usr/local/man
-ETCDIR = /etc/ppp
-
-COPTS = -O -Xa
-
-# For compiling with gcc, comment out the COPTS definition above and
-# uncomment the next 2 definitions.
-#CC = gcc
-#COPTS = -O2
diff --git a/svr4/Makedefs.sol2 b/svr4/Makedefs.sol2
deleted file mode 100644 (file)
index ab2b502..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Generic make definitions for Solaris 2
-#
-# $Id: Makedefs.sol2,v 1.3 1999/09/21 20:37:20 masputra Exp $
-#
-
-include ../svr4/Makedefs
-
-CPPFLAGS       = -D_KERNEL -DSVR4 -DSOL2 -DPRIOQ -DDEBUG -I../include
-CFLAGS         = $(CPPFLAGS) $(COPTS)
-
-# lint-specific variables
-LINT            = lint
-LINT_OPT_32     =
-LINT_OPT_64     = -Xarch=v9 -errchk=longptr64
-
-LINT_32        =
-LINT_32        += -erroff=E_BAD_PTR_CAST_ALIGN
-LINT_32        += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
-LINT_32        += -erroff=E_SUSPICIOUS_COMPARISON
-LINT_32        += -erroff=E_CAST_UINT_TO_SIGNED_INT
-LINT_32        += -erroff=E_PASS_UINT_TO_SIGNED_INT
-LINT_32        += -erroff=E_INVALID_ANNOTATION_NAME
-LINT_32        += -erroff=E_FUNC_ARG_UNUSED
-# This might be needed, but zlib.c and vjcompress.c will squawk 
-# when not ignored
-LINT_32                += -erroff=E_CASE_FALLTHRU
-LINT_32                += -erroff=E_RET_INT_IMPLICITLY
-LINT_32                += -erroff=E_FUNC_NO_RET_VAL
-# Some STREAMS macros will be noisy too when this isn't ignored
-LINT_32                += -erroff=E_CONSTANT_CONDITION
-LINT_32                += -erroff=E_CONST_EXPR
-
-# Extra noise suppressant for 64-bit
-EXTRA_OFF      =
-EXTRA_OFF      += -erroff=E_CAST_INT_TO_SMALL_INT
-EXTRA_OFF      += -erroff=E_CAST_INT_CONST_TO_SMALL_INT
-EXTRA_OFF      += -erroff=E_CAST_TO_PTR_FROM_INT
-EXTRA_OFF      += -erroff=E_ASSIGN_INT_TO_SMALL_INT
-EXTRA_OFF      += -erroff=E_ASSIGN_INT_FROM_BIG_CONST
-EXTRA_OFF      += -erroff=E_CONST_PROMOTED_UNSIGNED_LL
-EXTRA_OFF      += -erroff=E_CONST_PROMOTED_LONG_LONG
-EXTRA_OFF      += -erroff=E_CONST_TRUNCATED_BY_ASSIGN
-EXTRA_OFF      += -erroff=E_PASS_INT_FROM_BIG_CONST
-EXTRA_OFF      += -erroff=E_COMP_INT_WITH_LARGE_INT
-EXTRA_OFF      += -erroff=E_ASSIGN_UINT_TO_SIGNED_INT
-EXTRA_OFF      += -erroff=E_ASSIGN_NARROW_CONV
-EXTRA_OFF      += -erroff=E_PASS_INT_TO_SMALL_INT
-EXTRA_OFF      += -erroff=E_PTR_CONV_LOSES_BITS
-
-LINT_64        = $(LINT_32)
-LINT_64        += $(EXTRA_OFF)
-
-LINTFLAGS64     = -Xa -nsxmuF -errtags=yes $(LINT_OPT_64) $(LINT_64)
-LINT64          = $(LINT) -c $(LINTFLAGS64) $(CPPFLAGS)
-
-LINTFLAGS32     = -Xa -nsxmuF -errtags=yes $(LINT_OPT_32) $(LINT_32)
-LINT32          = $(LINT) -c $(LINTFLAGS32) $(CPPFLAGS)
-
diff --git a/svr4/Makefile.sol2 b/svr4/Makefile.sol2
deleted file mode 100644 (file)
index 3d632f3..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Makefile for STREAMS modules for Solaris 2.
-#
-# $Id: Makefile.sol2,v 1.18 1999/09/21 20:37:20 masputra Exp $
-#
-
-include Makedefs.sol2
-
-COPTS += -xO2 -xspace -W0,-Lt
-
-COMP_OBJS = ppp_comp.o bsd-comp.o deflate.o zlib.o vjcompress.o \
-       ppp_comp_mod.o
-
-all:   ppp ppp_ahdl ppp_comp
-
-ppp:   ppp.o ppp_mod.o
-       ld -r -o $@ ppp.o ppp_mod.o
-       chmod +x $@
-
-ppp_ahdl: ppp_ahdlc.o ppp_ahdlc_mod.o
-       ld -r -o $@ ppp_ahdlc.o ppp_ahdlc_mod.o
-       chmod +x $@
-
-ppp_comp: $(COMP_OBJS)
-       ld -r -o $@ $(COMP_OBJS)
-       chmod +x $@
-
-bsd-comp.o:    ../modules/bsd-comp.c
-       $(CC) $(CFLAGS) -c $?
-deflate.o:     ../modules/deflate.c
-       $(CC) $(CFLAGS) -c $?
-ppp.o: ../modules/ppp.c
-       $(CC) $(CFLAGS) -c $?
-ppp_mod.o:     ppp_mod.c
-       $(CC) $(CFLAGS) -c $?
-ppp_ahdlc_mod.o: ppp_ahdlc_mod.c
-       $(CC) $(CFLAGS) -c $?
-ppp_ahdlc.o: ../modules/ppp_ahdlc.c
-       $(CC) $(CFLAGS) -c $?
-ppp_comp.o: ../modules/ppp_comp.c
-       $(CC) $(CFLAGS) -c $?
-ppp_comp_mod.o:        ppp_comp_mod.c
-       $(CC) $(CFLAGS) -c $?
-vjcompress.o:  ../modules/vjcompress.c
-       $(CC) $(CFLAGS) -c $?
-zlib.o:        ../common/zlib.c
-       $(CC) $(CFLAGS) -c $?
-
-install:
-       cp ppp ppp.conf /kernel/drv
-       cp ppp_comp ppp_ahdl /kernel/strmod
-       if grep clone:ppp /etc/minor_perm; then :; else \
-         echo clone:ppp 0644 root sys >>/etc/minor_perm; fi
-       /usr/sbin/rem_drv ppp 2>/dev/null || true
-       /usr/sbin/add_drv ppp
-
-SRCS   = ../modules/ppp.c ppp_mod.c ../modules/ppp_ahdlc.c ppp_ahdlc_mod.c \
-       ../modules/ppp_comp.c ../modules/bsd-comp.c ../modules/deflate.c \
-       ../common/zlib.c ../modules/vjcompress.c ppp_comp_mod.c
-
-lint:
-       $(LINT32) $(SRCS)
-
-clean:
-       rm -f ppp ppp_comp ppp_ahdl *.o *~ core
-       rm -f *.ln
diff --git a/svr4/Makefile.sol2-64 b/svr4/Makefile.sol2-64
deleted file mode 100644 (file)
index bd598e1..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#
-# Makefile for 64-bit STREAMS modules for Solaris 2.
-#
-# $Id: Makefile.sol2-64,v 1.3 1999/09/21 20:37:20 masputra Exp $
-#
-
-include Makedefs.sol2
-
-# Sun's cc flag for LP64 compilation / linkage
-COPTS          += -xchip=ultra -xarch=v9 -Wc,-xcode=abs32 -Wc,-Qiselect-regsym=0 -xO3 -xspace -W0,-Lt
-
-# subdirectory where 64-bit objects / binaries will be placed
-LP64DIR                = sparcv9
-
-# Name of legacy Makefile (for 32-bit binaries)
-STD_MAKE       = Makefile.sol2
-
-COMP_OBJS      = $(LP64DIR)/ppp_comp.o $(LP64DIR)/bsd-comp.o \
-               $(LP64DIR)/deflate.o $(LP64DIR)/zlib.o $(LP64DIR)/vjcompress.o \
-               $(LP64DIR)/ppp_comp_mod.o
-
-all:   std_objs $(LP64DIR) ppp ppp_ahdl ppp_comp
-
-std_objs:
-       $(MAKE) -f $(STD_MAKE) all
-
-ppp:   $(LP64DIR)/ppp.o $(LP64DIR)/ppp_mod.o
-       ld -r -o $(LP64DIR)/$@ $(LP64DIR)/ppp.o $(LP64DIR)/ppp_mod.o
-       chmod +x $(LP64DIR)/$@
-
-ppp_ahdl: $(LP64DIR)/ppp_ahdlc.o $(LP64DIR)/ppp_ahdlc_mod.o
-       ld -r -o $(LP64DIR)/$@ $(LP64DIR)/ppp_ahdlc.o $(LP64DIR)/ppp_ahdlc_mod.o
-       chmod +x $(LP64DIR)/$@
-
-ppp_comp: $(COMP_OBJS)
-       ld -r -o $(LP64DIR)/$@ $(COMP_OBJS)
-       chmod +x $(LP64DIR)/$@
-
-$(LP64DIR)/bsd-comp.o: ../modules/bsd-comp.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/deflate.o: ../modules/deflate.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/ppp.o:      ../modules/ppp.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/ppp_mod.o:  ppp_mod.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/ppp_ahdlc_mod.o: ppp_ahdlc_mod.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/ppp_ahdlc.o: ../modules/ppp_ahdlc.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/ppp_comp.o: ../modules/ppp_comp.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/ppp_comp_mod.o: ppp_comp_mod.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/vjcompress.o: ../modules/vjcompress.c
-       $(CC) $(CFLAGS) -c $? -o $@
-$(LP64DIR)/zlib.o:     ../common/zlib.c
-       $(CC) $(CFLAGS) -c $? -o $@
-
-$(LP64DIR):
-       mkdir -m 755 -p $@
-
-install:
-       cp ppp ppp.conf /kernel/drv
-       cp ppp_comp ppp_ahdl /kernel/strmod
-       cp $(LP64DIR)/ppp /kernel/drv/$(LP64DIR)
-       cp $(LP64DIR)/ppp_comp $(LP64DIR)/ppp_ahdl /kernel/strmod/$(LP64DIR)
-       if grep clone:ppp /etc/minor_perm; then :; else \
-         echo clone:ppp 0644 root sys >>/etc/minor_perm; fi
-       /usr/sbin/rem_drv ppp 2>/dev/null || true
-       /usr/sbin/add_drv ppp
-
-SRCS   = ../modules/ppp.c ppp_mod.c ../modules/ppp_ahdlc.c ppp_ahdlc_mod.c \
-       ../modules/ppp_comp.c ../modules/bsd-comp.c ../modules/deflate.c \
-       ../common/zlib.c ../modules/vjcompress.c ppp_comp_mod.c
-
-lint:
-       $(LINT64) $(SRCS)
-
-lint-32:
-       $(LINT32) $(SRCS)
-
-clean:
-       $(MAKE) -f $(STD_MAKE) clean
-       rm -f $(LP64DIR)/ppp $(LP64DIR)/ppp_comp $(LP64DIR)/ppp_ahdl $(LP64DIR)/*.o $(LP64DIR)/*~ $(LP64DIR)/core
diff --git a/svr4/Makefile.svr4 b/svr4/Makefile.svr4
deleted file mode 100644 (file)
index afdcf0d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Makefile for STREAMS modules for SVR4.
-#
-# $Id: Makefile.svr4,v 1.5 1998/03/25 03:09:58 paulus Exp $
-#
-
-COPTS = -O
-
-CFLAGS= -D_KERNEL -DSVR4 -DLACHTCP -I../include $(COPTS)
-
-all:   ppp ppp_ahdl ppp_comp
-
-ppp:   ppp.o
-       ld -r -o $@ ppp.o
-
-ppp_ahdl: ppp_ahdlc.o
-       ld -r -o $@ ppp_ahdlc.o
-
-ppp_comp: ppp_comp.o bsd-comp.o vjcompress.o deflate.o zlib.o
-       ld -r -o $@ ppp_comp.o bsd-comp.o vjcompress.o deflate.o zlib.o
-
-bsd-comp.o: ../modules/bsd-comp.c
-       $(CC) $(CFLAGS) -c $?
-deflate.o: ../modules/deflate.c
-       $(CC) $(CFLAGS) -c $?
-ppp.o: ../modules/ppp.c
-       $(CC) $(CFLAGS) -c $?
-ppp_ahdlc.o: ../modules/ppp_ahdlc.c
-       $(CC) $(CFLAGS) -c $?
-ppp_comp.o: ../modules/ppp_comp.c
-       $(CC) $(CFLAGS) -c $?
-vjcompress.o: ../modules/vjcompress.c
-       $(CC) $(CFLAGS) -c $?
-zlib.o:        ../common/zlib.c
-       $(CC) $(CFLAGS) -c $?
-
-install: all
-       cp ppp Driver.o
-       cp ppp.Master Master
-       cp ppp.System System
-       cp ppp.Node Node
-       /etc/conf/bin/idinstall -d ppp
-       /etc/conf/bin/idinstall -a ppp
-       cp ppp_comp Driver.o
-       cp ppp_comp.Master Master
-       cp ppp_comp.System System
-       /etc/conf/bin/idinstall -d ppp_comp
-       /etc/conf/bin/idinstall -a ppp_comp
-       cp ppp_ahdl Driver.o
-       cp ppp_ahdl.Master Master
-       cp ppp_ahdl.System System
-       /etc/conf/bin/idinstall -d ppp_ahdl
-       /etc/conf/bin/idinstall -a ppp_ahdl
-       @echo 
-       @echo 'NOTE: You must rebuild your kernel to incorporate the driver.'
-       @echo '(use /etc/conf/bin/idbuild)'
-       @echo
-
-clean:
-       rm -f ppp ppp_comp ppp_ahdl *.o *~ core
diff --git a/svr4/Makefile.top b/svr4/Makefile.top
deleted file mode 100644 (file)
index ffba7b3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# ppp top level makefile for SVR4 and Solaris 2
-#
-# $Id: Makefile.top,v 1.8 1999/04/01 11:44:55 paulus Exp $
-#
-
-include svr4/Makedefs
-
-all:
-       cd chat; $(MAKE) all
-       cd pppd; $(MAKE) all
-       cd pppstats; $(MAKE) all
-       cd pppdump; $(MAKE) all
-       cd svr4; $(MAKE) all
-
-install: $(BINDIR) $(MANDIR)/man8 install-progs install-etcppp
-
-install-progs:
-       cd chat; $(MAKE) install
-       cd pppd; $(MAKE) install
-       cd pppstats; $(MAKE) install
-       cd pppdump; $(MAKE) install
-       cd svr4; $(MAKE) install
-
-install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
-       $(ETCDIR)/chap-secrets
-
-$(ETCDIR)/options:
-       cp etc.ppp/options $@
-       chmod go-w $@
-$(ETCDIR)/pap-secrets:
-       $(INSTALL) -f $(ETCDIR) -m 600 etc.ppp/pap-secrets
-$(ETCDIR)/chap-secrets:
-       $(INSTALL) -f $(ETCDIR) -m 600 etc.ppp/chap-secrets
-
-$(BINDIR):
-       mkdir -m 755 -p $@
-$(MANDIR)/man8:
-       mkdir -m 755 -p $@
-$(ETCDIR):
-       mkdir -m 755 -p $@
-
-clean:
-       rm -f *~
-       cd chat; $(MAKE) clean
-       cd pppd; $(MAKE) clean
-       cd pppstats; $(MAKE) clean
-       cd pppdump; $(MAKE) clean
-       cd svr4; $(MAKE) clean
-
diff --git a/svr4/ppp.Master b/svr4/ppp.Master
deleted file mode 100644 (file)
index 346db03..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp    -       Sciof   ppp     0       0       1       128     -1
diff --git a/svr4/ppp.Node b/svr4/ppp.Node
deleted file mode 100644 (file)
index 7767ade..0000000
+++ /dev/null
@@ -1 +0,0 @@
-clone  ppp     c       ppp
diff --git a/svr4/ppp.System b/svr4/ppp.System
deleted file mode 100644 (file)
index e60c0ee..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp    Y       1       0       0       0       0       0       0       0
diff --git a/svr4/ppp.conf b/svr4/ppp.conf
deleted file mode 100644 (file)
index e443a7a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-name="ppp" parent="pseudo" instance=0;
diff --git a/svr4/ppp_ahdl.Master b/svr4/ppp_ahdl.Master
deleted file mode 100644 (file)
index 4fde525..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp_ahdl       -       iSf     phdl    0       0       1       1       -1
diff --git a/svr4/ppp_ahdl.System b/svr4/ppp_ahdl.System
deleted file mode 100644 (file)
index f41a500..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp_ahdl       Y       1       0       0       0       0       0       0       0
diff --git a/svr4/ppp_ahdlc_mod.c b/svr4/ppp_ahdlc_mod.c
deleted file mode 100644 (file)
index f81be8a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/conf.h>
-#include <sys/modctl.h>
-#include <sys/sunddi.h>
-
-extern struct streamtab ppp_ahdlcinfo;
-
-static struct fmodsw fsw = {
-    "ppp_ahdl",
-    &ppp_ahdlcinfo,
-    D_NEW | D_MP | D_MTQPAIR
-};
-
-extern struct mod_ops mod_strmodops;
-
-static struct modlstrmod modlstrmod = {
-    &mod_strmodops,
-    "PPP async HDLC module",
-    &fsw
-};
-
-static struct modlinkage modlinkage = {
-    MODREV_1,
-    (void *) &modlstrmod,
-    NULL
-};
-
-/*
- * Entry points for modloading.
- */
-int
-_init(void)
-{
-    return mod_install(&modlinkage);
-}
-
-int
-_fini(void)
-{
-    return mod_remove(&modlinkage);
-}
-
-int
-_info(mip)
-    struct modinfo *mip;
-{
-    return mod_info(&modlinkage, mip);
-}
diff --git a/svr4/ppp_comp.Master b/svr4/ppp_comp.Master
deleted file mode 100644 (file)
index 7801906..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp_comp       -       iSf     pcmp    0       0       1       1       -1
diff --git a/svr4/ppp_comp.System b/svr4/ppp_comp.System
deleted file mode 100644 (file)
index e69d4a1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ppp_comp       Y       1       0       0       0       0       0       0       0
diff --git a/svr4/ppp_comp_mod.c b/svr4/ppp_comp_mod.c
deleted file mode 100644 (file)
index 0889572..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ppp_comp_mod.c - modload support for PPP compression STREAMS module.
- *
- * Copyright (c) 1994 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.
- *
- * $Id: ppp_comp_mod.c,v 1.3 2002/12/06 09:49:16 paulus Exp $
- */
-
-/*
- * This file is used under Solaris 2.
- */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/conf.h>
-#include <sys/modctl.h>
-#include <sys/sunddi.h>
-
-extern struct streamtab ppp_compinfo;
-
-static struct fmodsw fsw = {
-    "ppp_comp",
-    &ppp_compinfo,
-    D_NEW | D_MP | D_MTQPAIR
-};
-
-extern struct mod_ops mod_strmodops;
-
-static struct modlstrmod modlstrmod = {
-    &mod_strmodops,
-    "PPP compression module",
-    &fsw
-};
-
-static struct modlinkage modlinkage = {
-    MODREV_1,
-    (void *) &modlstrmod,
-    NULL
-};
-
-/*
- * Entry points for modloading.
- */
-int
-_init(void)
-{
-    return mod_install(&modlinkage);
-}
-
-int
-_fini(void)
-{
-    return mod_remove(&modlinkage);
-}
-
-int
-_info(mip)
-    struct modinfo *mip;
-{
-    return mod_info(&modlinkage, mip);
-}
diff --git a/svr4/ppp_mod.c b/svr4/ppp_mod.c
deleted file mode 100644 (file)
index c0473b6..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * ppp_mod.c - modload support for PPP pseudo-device driver.
- *
- * Copyright (c) 1994 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.
- *
- * $Id: ppp_mod.c,v 1.4 2002/12/06 09:49:16 paulus Exp $
- */
-
-/*
- * This file is used under Solaris 2.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/conf.h>
-#include <sys/modctl.h>
-#include <sys/sunddi.h>
-#include <sys/ksynch.h>
-
-#ifdef __STDC__
-#define __P(x) x
-#else
-#define __P(x) ()
-#endif
-
-static int ppp_identify __P((dev_info_t *));
-static int ppp_attach __P((dev_info_t *, ddi_attach_cmd_t));
-static int ppp_detach __P((dev_info_t *, ddi_detach_cmd_t));
-static int ppp_devinfo __P((dev_info_t *, ddi_info_cmd_t, void *, void **));
-
-extern struct streamtab pppinfo;
-extern krwlock_t ppp_lower_lock;
-
-static dev_info_t *ppp_dip;
-
-static struct cb_ops cb_ppp_ops = {
-    nulldev, nulldev, nodev, nodev,    /* cb_open, ... */
-    nodev, nodev, nodev, nodev,                /* cb_dump, ... */
-    nodev, nodev, nodev, nochpoll,     /* cb_devmap, ... */
-    ddi_prop_op,                       /* cb_prop_op */
-    &pppinfo,                          /* cb_stream */
-    D_NEW|D_MP|D_MTQPAIR|D_MTOUTPERIM|D_MTOCEXCL       /* cb_flag */
-};
-
-static struct dev_ops ppp_ops = {
-    DEVO_REV,                          /* devo_rev */
-    0,                                 /* devo_refcnt */
-    ppp_devinfo,                       /* devo_getinfo */
-    ppp_identify,                      /* devo_identify */
-    nulldev,                           /* devo_probe */
-    ppp_attach,                                /* devo_attach */
-    ppp_detach,                                /* devo_detach */
-    nodev,                             /* devo_reset */
-    &cb_ppp_ops,                       /* devo_cb_ops */
-    NULL                               /* devo_bus_ops */
-};
-
-/*
- * Module linkage information
- */
-
-static struct modldrv modldrv = {
-    &mod_driverops,                    /* says this is a pseudo driver */
-    "PPP-2.3 multiplexing driver",
-    &ppp_ops                           /* driver ops */
-};
-
-static struct modlinkage modlinkage = {
-    MODREV_1,
-    (void *) &modldrv,
-    NULL
-};
-
-int
-_init(void)
-{
-    return mod_install(&modlinkage);
-}
-
-int
-_fini(void)
-{
-    return mod_remove(&modlinkage);
-}
-
-int
-_info(mip)
-    struct modinfo *mip;
-{
-    return mod_info(&modlinkage, mip);
-}
-
-static int
-ppp_identify(dip)
-    dev_info_t *dip;
-{
-    return strcmp(ddi_get_name(dip), "ppp") == 0? DDI_IDENTIFIED:
-       DDI_NOT_IDENTIFIED;
-}
-
-static int
-ppp_attach(dip, cmd)
-    dev_info_t *dip;
-    ddi_attach_cmd_t cmd;
-{
-
-    if (cmd != DDI_ATTACH)
-       return DDI_FAILURE;
-    if (ddi_create_minor_node(dip, "ppp", S_IFCHR, 0, DDI_PSEUDO, CLONE_DEV)
-       == DDI_FAILURE) {
-       ddi_remove_minor_node(dip, NULL);
-       return DDI_FAILURE;
-    }
-    rw_init(&ppp_lower_lock, NULL, RW_DRIVER, NULL);
-    return DDI_SUCCESS;
-}
-
-static int
-ppp_detach(dip, cmd)
-    dev_info_t *dip;
-    ddi_detach_cmd_t cmd;
-{
-    rw_destroy(&ppp_lower_lock);
-    ddi_remove_minor_node(dip, NULL);
-    return DDI_SUCCESS;
-}
-
-static int
-ppp_devinfo(dip, cmd, arg, result)
-    dev_info_t *dip;
-    ddi_info_cmd_t cmd;
-    void *arg;
-    void **result;
-{
-    int error;
-
-    error = DDI_SUCCESS;
-    switch (cmd) {
-    case DDI_INFO_DEVT2DEVINFO:
-       if (ppp_dip == NULL)
-           error = DDI_FAILURE;
-       else
-           *result = (void *) ppp_dip;
-       break;
-    case DDI_INFO_DEVT2INSTANCE:
-       *result = NULL;
-       break;
-    default:
-       error = DDI_FAILURE;
-    }
-    return error;
-}
diff --git a/ultrix/Makefile.top b/ultrix/Makefile.top
deleted file mode 100644 (file)
index 11954bf..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# ppp top level makefile
-#
-
-BINDIR = /usr/local/etc
-MANDIR = /usr/local/man
-
-all:
-       cd chat; $(MAKE) all
-       cd pppd; $(MAKE) all
-       cd pppstats; $(MAKE) all
-
-install:
-       cd chat; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-       cd pppstats; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) install
-
-clean:
-       rm -f *~
-       cd chat; $(MAKE) clean
-       cd pppd; $(MAKE) clean
-       cd pppstats; $(MAKE) clean
-
diff --git a/ultrix/bsd-comp.c b/ultrix/bsd-comp.c
deleted file mode 100644 (file)
index 27f3f93..0000000
+++ /dev/null
@@ -1,1131 +0,0 @@
-/* Because this code is derived from the 4.3BSD compress source:
- *
- *
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * 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 University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This version is for use with mbufs on Ultrix systems.
- *
- * $Id: bsd-comp.c,v 1.8 1996/08/28 06:32:00 paulus Exp $
- */
-
-#include "../h/param.h"
-#include "../h/types.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../net/net/if.h"
-#include "ppp_defs.h"
-#include "if_ppp.h"
-
-#define PACKETPTR      struct mbuf *
-#include "ppp-comp.h"
-
-#if DO_BSD_COMPRESS
-
-#define BSD_LITTLE_ENDIAN      /* all Ultrix machines are little-endian */
-
-/*
- * PPP "BSD compress" compression
- *  The differences between this compression and the classic BSD LZW
- *  source are obvious from the requirement that the classic code worked
- *  with files while this handles arbitrarily long streams that
- *  are broken into packets.  They are:
- *
- *     When the code size expands, a block of junk is not emitted by
- *         the compressor and not expected by the decompressor.
- *
- *     New codes are not necessarily assigned every time an old
- *         code is output by the compressor.  This is because a packet
- *         end forces a code to be emitted, but does not imply that a
- *         new sequence has been seen.
- *
- *     The compression ratio is checked at the first end of a packet
- *         after the appropriate gap.  Besides simplifying and speeding
- *         things up, this makes it more likely that the transmitter
- *         and receiver will agree when the dictionary is cleared when
- *         compression is not going well.
- */
-
-/*
- * A dictionary for doing BSD compress.
- */
-struct bsd_db {
-    int            totlen;                     /* length of this structure */
-    u_int   hsize;                     /* size of the hash table */
-    u_char  hshift;                    /* used in hash function */
-    u_char  n_bits;                    /* current bits/code */
-    u_char  maxbits;
-    u_char  debug;
-    u_char  unit;
-    u_short seqno;                     /* sequence # of next packet */
-    u_int   hdrlen;                    /* header length to preallocate */
-    u_int   mru;
-    u_int   maxmaxcode;                        /* largest valid code */
-    u_int   max_ent;                   /* largest code in use */
-    u_int   in_count;                  /* uncompressed bytes, aged */
-    u_int   bytes_out;                 /* compressed bytes, aged */
-    u_int   ratio;                     /* recent compression ratio */
-    u_int   checkpoint;                        /* when to next check the ratio */
-    u_int   clear_count;               /* times dictionary cleared */
-    u_int   incomp_count;              /* incompressible packets */
-    u_int   incomp_bytes;              /* incompressible bytes */
-    u_int   uncomp_count;              /* uncompressed packets */
-    u_int   uncomp_bytes;              /* uncompressed bytes */
-    u_int   comp_count;                        /* compressed packets */
-    u_int   comp_bytes;                        /* compressed bytes */
-    u_short *lens;                     /* array of lengths of codes */
-    struct bsd_dict {
-       union {                         /* hash value */
-           u_int32_t   fcode;
-           struct {
-#ifdef BSD_LITTLE_ENDIAN
-               u_short prefix;         /* preceding code */
-               u_char  suffix;         /* last character of new code */
-               u_char  pad;
-#else
-               u_char  pad;
-               u_char  suffix;         /* last character of new code */
-               u_short prefix;         /* preceding code */
-#endif
-           } hs;
-       } f;
-       u_short codem1;                 /* output of hash table -1 */
-       u_short cptr;                   /* map code to hash table entry */
-    } dict[1];
-};
-
-#define BSD_OVHD       2               /* BSD compress overhead/packet */
-#define BSD_INIT_BITS  BSD_MIN_BITS
-
-static void    *bsd_comp_alloc __P((u_char *options, int opt_len));
-static void    *bsd_decomp_alloc __P((u_char *options, int opt_len));
-static void    bsd_free __P((void *state));
-static int     bsd_comp_init __P((void *state, u_char *options, int opt_len,
-                                  int unit, int hdrlen, int debug));
-static int     bsd_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     bsd_compress __P((void *state, struct mbuf **mret,
-                                 struct mbuf *mp, int slen, int maxolen));
-static void    bsd_incomp __P((void *state, struct mbuf *dmsg));
-static int     bsd_decompress __P((void *state, struct mbuf *cmp,
-                                   struct mbuf **dmpp));
-static void    bsd_reset __P((void *state));
-static void    bsd_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_bsd_compress = {
-    CI_BSD_COMPRESS,           /* compress_proto */
-    bsd_comp_alloc,            /* comp_alloc */
-    bsd_free,                  /* comp_free */
-    bsd_comp_init,             /* comp_init */
-    bsd_reset,                 /* comp_reset */
-    bsd_compress,              /* compress */
-    bsd_comp_stats,            /* comp_stat */
-    bsd_decomp_alloc,          /* decomp_alloc */
-    bsd_free,                  /* decomp_free */
-    bsd_decomp_init,           /* decomp_init */
-    bsd_reset,                 /* decomp_reset */
-    bsd_decompress,            /* decompress */
-    bsd_incomp,                        /* incomp */
-    bsd_comp_stats,            /* decomp_stat */
-};
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m) ((m)->m_off > MMAXOFF)
-
-#define M_TRAILINGSPACE(m) \
-       ((M_IS_CLUSTER(m) ? (u_int)(m)->m_clptr + M_CLUSTERSZ : MSIZE) \
-        - ((m)->m_off + (m)->m_len))
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define CLEAR  256                     /* table clear output code */
-#define FIRST  257                     /* first free entry */
-#define LAST   255
-
-#define MAXCODE(b)     ((1 << (b)) - 1)
-#define BADCODEM1      MAXCODE(BSD_MAX_BITS)
-
-#define BSD_HASH(prefix,suffix,hshift) ((((u_int32_t)(suffix)) << (hshift)) \
-                                        ^ (u_int32_t)(prefix))
-#define BSD_KEY(prefix,suffix)         ((((u_int32_t)(suffix)) << 16) \
-                                        + (u_int32_t)(prefix))
-
-#define CHECK_GAP      10000           /* Ratio check interval */
-
-#define RATIO_SCALE_LOG        8
-#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
- */
-static void
-bsd_clear(db)
-    struct bsd_db *db;
-{
-    db->clear_count++;
-    db->max_ent = FIRST-1;
-    db->n_bits = BSD_INIT_BITS;
-    db->ratio = 0;
-    db->bytes_out = 0;
-    db->in_count = 0;
-    db->checkpoint = CHECK_GAP;
-}
-
-/*
- * If the dictionary is full, then see if it is time to reset it.
- *
- * Compute the compression ratio using fixed-point arithmetic
- * with 8 fractional bits.
- *
- * Since we have an infinite stream instead of a single file,
- * watch only the local compression ratio.
- *
- * Since both peers must reset the dictionary at the same time even in
- * the absence of CLEAR codes (while packets are incompressible), they
- * must compute the same ratio.
- */
-static int                             /* 1=output CLEAR */
-bsd_check(db)
-    struct bsd_db *db;
-{
-    u_int new_ratio;
-
-    if (db->in_count >= db->checkpoint) {
-       /* age the ratio by limiting the size of the counts */
-       if (db->in_count >= RATIO_MAX
-           || db->bytes_out >= RATIO_MAX) {
-           db->in_count -= db->in_count/4;
-           db->bytes_out -= db->bytes_out/4;
-       }
-
-       db->checkpoint = db->in_count + CHECK_GAP;
-
-       if (db->max_ent >= db->maxmaxcode) {
-           /* Reset the dictionary only if the ratio is worse,
-            * or if it looks as if it has been poisoned
-            * by incompressible data.
-            *
-            * This does not overflow, because
-            *  db->in_count <= RATIO_MAX.
-            */
-           new_ratio = db->in_count << RATIO_SCALE_LOG;
-           if (db->bytes_out != 0)
-               new_ratio /= db->bytes_out;
-
-           if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) {
-               bsd_clear(db);
-               return 1;
-           }
-           db->ratio = new_ratio;
-       }
-    }
-    return 0;
-}
-
-/*
- * Return statistics.
- */
-static void
-bsd_comp_stats(state, stats)
-    void *state;
-    struct compstat *stats;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int out;
-
-    stats->unc_bytes = db->uncomp_bytes;
-    stats->unc_packets = db->uncomp_count;
-    stats->comp_bytes = db->comp_bytes;
-    stats->comp_packets = db->comp_count;
-    stats->inc_bytes = db->incomp_bytes;
-    stats->inc_packets = db->incomp_count;
-    stats->ratio = db->in_count;
-    out = db->bytes_out;
-    if (stats->ratio <= 0x7fffff)
-       stats->ratio <<= 8;
-    else
-       out >>= 8;
-    if (out != 0)
-       stats->ratio /= out;
-}
-
-/*
- * Reset state, as on a CCP ResetReq.
- */
-static void
-bsd_reset(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    db->seqno = 0;
-    bsd_clear(db);
-    db->clear_count = 0;
-}
-
-/*
- * Allocate space for a (de) compressor.
- */
-static void *
-bsd_alloc(options, opt_len, decomp)
-    u_char *options;
-    int opt_len, decomp;
-{
-    int bits;
-    u_int newlen, hsize, hshift, maxmaxcode;
-    struct bsd_db *db;
-
-    if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
-       || options[1] != CILEN_BSD_COMPRESS
-       || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
-       return NULL;
-    bits = BSD_NBITS(options[2]);
-    switch (bits) {
-    case 9:                    /* needs 82152 for both directions */
-    case 10:                   /* needs 84144 */
-    case 11:                   /* needs 88240 */
-    case 12:                   /* needs 96432 */
-       hsize = 5003;
-       hshift = 4;
-       break;
-    case 13:                   /* needs 176784 */
-       hsize = 9001;
-       hshift = 5;
-       break;
-    case 14:                   /* needs 353744 */
-       hsize = 18013;
-       hshift = 6;
-       break;
-    case 15:                   /* needs 691440 */
-       hsize = 35023;
-       hshift = 7;
-       break;
-    case 16:                   /* needs 1366160--far too much, */
-       /* hsize = 69001; */    /* and 69001 is too big for cptr */
-       /* hshift = 8; */       /* in struct bsd_db */
-       /* break; */
-    default:
-       return NULL;
-    }
-
-    maxmaxcode = MAXCODE(bits);
-    newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
-    KM_ALLOC(db, struct bsd_db *, newlen, KM_DEVBUF, KM_NOARG);
-    if (!db)
-       return NULL;
-    bzero(db, sizeof(*db) - sizeof(db->dict));
-
-    if (!decomp) {
-       db->lens = NULL;
-    } else {
-       KM_ALLOC(db->lens, u_short *, (maxmaxcode+1) * sizeof(db->lens[0]),
-                KM_DEVBUF, KM_NOARG);
-       if (!db->lens) {
-           KM_FREE(db, KM_DEVBUF);
-           return NULL;
-       }
-    }
-
-    db->totlen = newlen;
-    db->hsize = hsize;
-    db->hshift = hshift;
-    db->maxmaxcode = maxmaxcode;
-    db->maxbits = bits;
-
-    return (void *) db;
-}
-
-static void
-bsd_free(state)
-    void *state;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-
-    if (db->lens)
-       KM_FREE(db->lens, KM_DEVBUF);
-    KM_FREE(db, KM_DEVBUF);
-}
-
-static void *
-bsd_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 0);
-}
-
-static void *
-bsd_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    return bsd_alloc(options, opt_len, 1);
-}
-
-/*
- * Initialize the database.
- */
-static int
-bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
-    struct bsd_db *db;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug, decomp;
-{
-    int i;
-
-    if (opt_len < CILEN_BSD_COMPRESS || 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)
-       return 0;
-
-    if (decomp) {
-       i = LAST+1;
-       while (i != 0)
-           db->lens[--i] = 1;
-    }
-    i = db->hsize;
-    while (i != 0) {
-       db->dict[--i].codem1 = BADCODEM1;
-       db->dict[i].cptr = 0;
-    }
-
-    db->unit = unit;
-    db->hdrlen = hdrlen;
-    db->mru = mru;
-#ifndef DEBUG
-    if (debug)
-#endif
-       db->debug = 1;
-
-    bsd_reset(db);
-
-    return 1;
-}
-
-static int
-bsd_comp_init(state, options, opt_len, unit, hdrlen, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, 0, debug, 0);
-}
-
-static int
-bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    return bsd_init((struct bsd_db *) state, options, opt_len,
-                   unit, hdrlen, mru, debug, 1);
-}
-
-
-/*
- * compress a packet
- *     One change from the BSD compress command is that when the
- *     code size expands, we do not output a bunch of padding.
- */
-static int                             /* new slen */
-bsd_compress(state, mret, mp, slen, maxolen)
-    void *state;
-    struct mbuf **mret;                /* return compressed mbuf chain here */
-    struct mbuf *mp;           /* from here */
-    int slen;                  /* uncompressed length */
-    int maxolen;               /* max compressed length */
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    u_int bitno = 32;
-    u_int32_t accm = 0, fcode;
-    struct bsd_dict *dictp;
-    u_char c;
-    int hval, disp, ent, ilen;
-    struct mbuf *np;
-    u_char *rptr, *wptr;
-    u_char *cp_end;
-    int olen;
-    struct mbuf *m, *clp;
-       
-#define PUTBYTE(v) {                                   \
-    ++olen;                                            \
-    if (wptr) {                                                \
-       *wptr++ = (v);                                  \
-       if (wptr >= cp_end) {                           \
-           m->m_len = wptr - mtod(m, u_char *);        \
-           MGET(m->m_next, M_DONTWAIT, MT_DATA);       \
-           m = m->m_next;                              \
-           if (m) {                                    \
-               if (maxolen - olen > MLEN) {            \
-                   MCLGET(m, clp);                     \
-               }                                       \
-               m->m_len = 0;                           \
-               wptr = mtod(m, u_char *);               \
-               cp_end = wptr + M_TRAILINGSPACE(m);     \
-           } else                                      \
-               wptr = NULL;                            \
-       }                                               \
-    }                                                  \
-}
-
-#define OUTPUT(ent) {                                  \
-    bitno -= n_bits;                                   \
-    accm |= ((ent) << bitno);                          \
-    do {                                               \
-       PUTBYTE(accm >> 24);                            \
-       accm <<= 8;                                     \
-       bitno += 8;                                     \
-    } while (bitno <= 24);                             \
-}
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without compressing the packet.  If it is,
-     * the protocol becomes the first byte to compress.
-     */
-    rptr = mtod(mp, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < 0x21 || ent > 0xf9) {
-       *mret = NULL;
-       return slen;
-    }
-
-    /* Don't generate compressed packets which are larger than
-       the uncompressed packet. */
-    if (maxolen > slen)
-       maxolen = slen;
-
-    /* Allocate one mbuf to start with. */
-    MGET(m, M_DONTWAIT, MT_DATA);
-    *mret = m;
-    if (m != NULL) {
-       if (maxolen + db->hdrlen > MLEN) {
-           MCLGET(m, clp);
-       }
-       m->m_off += db->hdrlen;
-       m->m_len = 0;
-       wptr = mtod(m, u_char *);
-       cp_end = wptr + M_TRAILINGSPACE(m);
-    } else
-       wptr = cp_end = NULL;
-
-    /*
-     * Copy the PPP header over, changing the protocol,
-     * and install the 2-byte packet sequence number.
-     */
-    if (wptr) {
-       *wptr++ = PPP_ADDRESS(rptr);    /* assumes the ppp header is */
-       *wptr++ = PPP_CONTROL(rptr);    /* all in one mbuf */
-       *wptr++ = 0;                    /* change the protocol */
-       *wptr++ = PPP_COMP;
-       *wptr++ = db->seqno >> 8;
-       *wptr++ = db->seqno;
-    }
-    ++db->seqno;
-
-    olen = 0;
-    rptr += PPP_HDRLEN;
-    slen = mp->m_len - PPP_HDRLEN;
-    ilen = slen + 1;
-    for (;;) {
-       if (slen <= 0) {
-           mp = mp->m_next;
-           if (!mp)
-               break;
-           rptr = mtod(mp, u_char *);
-           slen = mp->m_len;
-           if (!slen)
-               continue;   /* handle 0-length buffers */
-           ilen += slen;
-       }
-
-       slen--;
-       c = *rptr++;
-       fcode = BSD_KEY(ent, c);
-       hval = BSD_HASH(ent, c, hshift);
-       dictp = &db->dict[hval];
-
-       /* Validate and then check the entry. */
-       if (dictp->codem1 >= max_ent)
-           goto nomatch;
-       if (dictp->f.fcode == fcode) {
-           ent = dictp->codem1+1;
-           continue;   /* found (prefix,suffix) */
-       }
-
-       /* continue probing until a match or invalid entry */
-       disp = (hval == 0) ? 1 : hval;
-       do {
-           hval += disp;
-           if (hval >= db->hsize)
-               hval -= db->hsize;
-           dictp = &db->dict[hval];
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-       } while (dictp->f.fcode != fcode);
-       ent = dictp->codem1 + 1;        /* finally found (prefix,suffix) */
-       continue;
-
-    nomatch:
-       OUTPUT(ent);            /* output the prefix */
-
-       /* code -> hashtable */
-       if (max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           /* expand code size if needed */
-           if (max_ent >= MAXCODE(n_bits))
-               db->n_bits = ++n_bits;
-
-           /* Invalidate old hash table entry using
-            * this code, and then take it over.
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent)
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-       }
-       ent = c;
-    }
-
-    OUTPUT(ent);               /* output the last code */
-    db->bytes_out += olen;
-    db->in_count += ilen;
-    if (bitno < 32)
-       ++db->bytes_out;        /* count complete bytes */
-
-    if (bsd_check(db))
-       OUTPUT(CLEAR);          /* do not count the CLEAR */
-
-    /*
-     * Pad dribble bits of last code with ones.
-     * Do not emit a completely useless byte of ones.
-     */
-    if (bitno != 32)
-       PUTBYTE((accm | (0xff << (bitno-8))) >> 24);
-
-    if (m != NULL) {
-       m->m_len = wptr - mtod(m, u_char *);
-       m->m_next = NULL;
-    }
-
-    /*
-     * Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-
-    db->uncomp_bytes += ilen;
-    ++db->uncomp_count;
-    if (olen + PPP_HDRLEN + BSD_OVHD > maxolen) {
-       /* throw away the compressed stuff if it is longer than uncompressed */
-       if (*mret != NULL) {
-           m_freem(*mret);
-           *mret = NULL;
-       }
-       ++db->incomp_count;
-       db->incomp_bytes += ilen;
-    } else {
-       ++db->comp_count;
-       db->comp_bytes += olen + BSD_OVHD;
-    }
-
-    return olen + PPP_HDRLEN + BSD_OVHD;
-#undef OUTPUT
-#undef PUTBYTE
-}
-
-
-/*
- * Update the "BSD Compress" dictionary on the receiver for
- * incompressible data by pretending to compress the incoming data.
- */
-static void
-bsd_incomp(state, dmsg)
-    void *state;
-    struct mbuf *dmsg;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int hshift = db->hshift;
-    u_int max_ent = db->max_ent;
-    u_int n_bits = db->n_bits;
-    struct bsd_dict *dictp;
-    u_int32_t fcode;
-    u_char c;
-    long hval, disp;
-    int slen, ilen;
-    u_int bitno = 7;
-    u_char *rptr;
-    u_int ent;
-
-    /*
-     * If the protocol is not in the range we're interested in,
-     * just return without looking at the packet.  If it is,
-     * the protocol becomes the first byte to "compress".
-     */
-    rptr = mtod(dmsg, u_char *);
-    ent = PPP_PROTOCOL(rptr);
-    if (ent < 0x21 || ent > 0xf9)
-       return;
-
-    db->seqno++;
-    ilen = 1;          /* count the protocol as 1 byte */
-    rptr += PPP_HDRLEN;
-    slen = dmsg->m_len - PPP_HDRLEN;
-    for (;;) {
-       if (slen <= 0) {
-           dmsg = dmsg->m_next;
-           if (!dmsg)
-               break;
-           rptr = mtod(dmsg, u_char *);
-           slen = dmsg->m_len;
-           continue;
-       }
-       ilen += slen;
-
-       do {
-           c = *rptr++;
-           fcode = BSD_KEY(ent, c);
-           hval = BSD_HASH(ent, c, hshift);
-           dictp = &db->dict[hval];
-
-           /* validate and then check the entry */
-           if (dictp->codem1 >= max_ent)
-               goto nomatch;
-           if (dictp->f.fcode == fcode) {
-               ent = dictp->codem1+1;
-               continue;   /* found (prefix,suffix) */
-           }
-
-           /* continue probing until a match or invalid entry */
-           disp = (hval == 0) ? 1 : hval;
-           do {
-               hval += disp;
-               if (hval >= db->hsize)
-                   hval -= db->hsize;
-               dictp = &db->dict[hval];
-               if (dictp->codem1 >= max_ent)
-                   goto nomatch;
-           } while (dictp->f.fcode != fcode);
-           ent = dictp->codem1+1;
-           continue;   /* finally found (prefix,suffix) */
-
-       nomatch:                /* output (count) the prefix */
-           bitno += n_bits;
-
-           /* code -> hashtable */
-           if (max_ent < db->maxmaxcode) {
-               struct bsd_dict *dictp2;
-               /* expand code size if needed */
-               if (max_ent >= MAXCODE(n_bits))
-                   db->n_bits = ++n_bits;
-
-               /* Invalidate previous hash table entry
-                * assigned this code, and then take it over.
-                */
-               dictp2 = &db->dict[max_ent+1];
-               if (db->dict[dictp2->cptr].codem1 == max_ent)
-                   db->dict[dictp2->cptr].codem1 = BADCODEM1;
-               dictp2->cptr = hval;
-               dictp->codem1 = max_ent;
-               dictp->f.fcode = fcode;
-
-               db->max_ent = ++max_ent;
-               db->lens[max_ent] = db->lens[ent]+1;
-           }
-           ent = c;
-       } while (--slen != 0);
-    }
-    bitno += n_bits;           /* output (count) the last code */
-    db->bytes_out += bitno/8;
-    db->in_count += ilen;
-    (void)bsd_check(db);
-
-    ++db->incomp_count;
-    db->incomp_bytes += ilen;
-    ++db->uncomp_count;
-    db->uncomp_bytes += ilen;
-
-    /* Increase code size if we would have without the packet
-     * boundary and as the decompressor will.
-     */
-    if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
-       db->n_bits++;
-}
-
-
-/*
- * Decompress "BSD Compress".
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-static int
-bsd_decompress(state, cmp, dmpp)
-    void *state;
-    struct mbuf *cmp, **dmpp;
-{
-    struct bsd_db *db = (struct bsd_db *) state;
-    u_int max_ent = db->max_ent;
-    u_int32_t accm = 0;
-    u_int bitno = 32;          /* 1st valid bit in accm */
-    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;
-    u_int incode, oldcode, finchar;
-    u_char *p, *rptr, *wptr;
-    struct mbuf *m, *dmp, *mret;
-    int adrs, ctrl, ilen;
-    int space, codelen, extra;
-    struct mbuf *clp;
-
-    /*
-     * Save the address/control from the PPP header
-     * and then get the sequence number.
-     */
-    *dmpp = NULL;
-    rptr = mtod(cmp, u_char *);
-    adrs = PPP_ADDRESS(rptr);
-    ctrl = PPP_CONTROL(rptr);
-    rptr += PPP_HDRLEN;
-    len = cmp->m_len - PPP_HDRLEN;
-    seq = 0;
-    for (i = 0; i < 2; ++i) {
-       while (len <= 0) {
-           cmp = cmp->m_next;
-           if (cmp == NULL)
-               return DECOMP_ERROR;
-           rptr = mtod(cmp, u_char *);
-           len = cmp->m_len;
-       }
-       seq = (seq << 8) + *rptr++;
-       --len;
-    }
-
-    /*
-     * Check the sequence number and give up if it differs from
-     * the value we're expecting.
-     */
-    if (seq != db->seqno) {
-       if (db->debug)
-           printf("bsd_decomp%d: bad sequence # %d, expected %d\n",
-                  db->unit, seq, db->seqno - 1);
-       return DECOMP_ERROR;
-    }
-    ++db->seqno;
-
-    /*
-     * Allocate one mbuf to start with.
-     */
-    MGET(dmp, M_DONTWAIT, MT_DATA);
-    if (dmp == NULL)
-       return DECOMP_ERROR;
-    mret = dmp;
-    dmp->m_next = NULL;
-    MCLGET(dmp, clp);
-    dmp->m_len = 0;
-    dmp->m_off += db->hdrlen;
-    wptr = mtod(dmp, u_char *);
-    space = M_TRAILINGSPACE(dmp) - PPP_HDRLEN + 1;
-
-    /*
-     * Fill in the ppp header, but not the last byte of the protocol
-     * (that comes from the decompressed data).
-     */
-    wptr[0] = adrs;
-    wptr[1] = ctrl;
-    wptr[2] = 0;
-    wptr += PPP_HDRLEN - 1;
-
-    ilen = len;
-    oldcode = CLEAR;
-    explen = 0;
-    for (;;) {
-       if (len == 0) {
-           cmp = cmp->m_next;
-           if (!cmp)           /* quit at end of message */
-               break;
-           rptr = mtod(cmp, u_char *);
-           len = cmp->m_len;
-           ilen += len;
-           continue;           /* handle 0-length buffers */
-       }
-
-       /*
-        * Accumulate bytes until we have a complete code.
-        * Then get the next code, relying on the 32-bit,
-        * unsigned accm to mask the result.
-        */
-       bitno -= 8;
-       accm |= *rptr++ << bitno;
-       --len;
-       if (tgtbitno < bitno)
-           continue;
-       incode = accm >> tgtbitno;
-       accm <<= n_bits;
-       bitno += n_bits;
-
-       if (incode == CLEAR) {
-           /*
-            * The dictionary must only be cleared at
-            * the end of a packet.  But there could be an
-            * empty mbuf at the end.
-            */
-           if (len > 0 || cmp->m_next != NULL) {
-               while ((cmp = cmp->m_next) != NULL)
-                   len += cmp->m_len;
-               if (len > 0) {
-                   m_freem(mret);
-                   if (db->debug)
-                       printf("bsd_decomp%d: bad CLEAR\n", db->unit);
-                   return DECOMP_FATALERROR;   /* probably a bug */
-               }
-           }
-           bsd_clear(db);
-           explen = ilen = 0;
-           break;
-       }
-
-       if (incode > max_ent + 2 || incode > db->maxmaxcode
-           || incode > max_ent && oldcode == CLEAR) {
-           m_freem(mret);
-           if (db->debug) {
-               printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
-                      db->unit, incode, oldcode);
-               printf("max_ent=0x%x explen=%d seqno=%d\n",
-                      max_ent, explen, db->seqno);
-           }
-           return DECOMP_FATALERROR;   /* probably a bug */
-       }
-
-       /* Special case for KwKwK string. */
-       if (incode > max_ent) {
-           finchar = oldcode;
-           extra = 1;
-       } else {
-           finchar = incode;
-           extra = 0;
-       }
-
-       codelen = db->lens[finchar];
-       explen += codelen + extra;
-       if (explen > db->mru + 1) {
-           m_freem(mret);
-           if (db->debug) {
-               printf("bsd_decomp%d: ran out of mru\n", db->unit);
-#ifdef DEBUG
-               while ((cmp = cmp->m_next) != NULL)
-                   len += cmp->m_len;
-               printf("  len=%d, finchar=0x%x, codelen=%d, explen=%d\n",
-                      len, finchar, codelen, explen);
-#endif
-           }
-           return DECOMP_FATALERROR;
-       }
-
-       /*
-        * For simplicity, the decoded characters go in a single mbuf,
-        * so we allocate a single extra cluster mbuf if necessary.
-        */
-       if ((space -= codelen + extra) < 0) {
-           dmp->m_len = wptr - mtod(dmp, u_char *);
-           MGET(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL) {
-               m_freem(mret);
-               return DECOMP_ERROR;
-           }
-           m->m_next = NULL;
-           dmp->m_next = m;
-           MCLGET(m, clp);
-           m->m_len = 0;
-           space = M_TRAILINGSPACE(m) - (codelen + extra);
-           if (space < 0) {
-               /* now that's what I call *compression*. */
-               m_freem(mret);
-               return DECOMP_ERROR;
-           }
-           dmp = m;
-           wptr = mtod(dmp, u_char *);
-       }
-
-       /*
-        * Decode this code and install it in the decompressed buffer.
-        */
-       p = (wptr += codelen);
-       while (finchar > LAST) {
-           dictp = &db->dict[db->dict[finchar].cptr];
-#ifdef DEBUG
-           if (--codelen <= 0 || dictp->codem1 != finchar-1)
-               goto bad;
-#endif
-           *--p = dictp->f.hs.suffix;
-           finchar = dictp->f.hs.prefix;
-       }
-       *--p = finchar;
-
-#ifdef DEBUG
-       if (--codelen != 0)
-           printf("bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n",
-                  db->unit, codelen, incode, max_ent);
-#endif
-
-       if (extra)              /* the KwKwK case again */
-           *wptr++ = finchar;
-
-       /*
-        * If not first code in a packet, and
-        * if not out of code space, then allocate a new code.
-        *
-        * Keep the hash table correct so it can be used
-        * with uncompressed packets.
-        */
-       if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
-           struct bsd_dict *dictp2;
-           u_int32_t fcode;
-           int hval, disp;
-
-           fcode = BSD_KEY(oldcode,finchar);
-           hval = BSD_HASH(oldcode,finchar,db->hshift);
-           dictp = &db->dict[hval];
-
-           /* look for a free hash table entry */
-           if (dictp->codem1 < max_ent) {
-               disp = (hval == 0) ? 1 : hval;
-               do {
-                   hval += disp;
-                   if (hval >= db->hsize)
-                       hval -= db->hsize;
-                   dictp = &db->dict[hval];
-               } while (dictp->codem1 < max_ent);
-           }
-
-           /*
-            * Invalidate previous hash table entry
-            * assigned this code, and then take it over
-            */
-           dictp2 = &db->dict[max_ent+1];
-           if (db->dict[dictp2->cptr].codem1 == max_ent) {
-               db->dict[dictp2->cptr].codem1 = BADCODEM1;
-           }
-           dictp2->cptr = hval;
-           dictp->codem1 = max_ent;
-           dictp->f.fcode = fcode;
-
-           db->max_ent = ++max_ent;
-           db->lens[max_ent] = db->lens[oldcode]+1;
-
-           /* Expand code size if needed. */
-           if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
-               db->n_bits = ++n_bits;
-               tgtbitno = 32-n_bits;
-           }
-       }
-       oldcode = incode;
-    }
-    dmp->m_len = wptr - mtod(dmp, u_char *);
-
-    /*
-     * Keep the checkpoint right so that incompressible packets
-     * clear the dictionary at the right times.
-     */
-    db->bytes_out += ilen;
-    db->in_count += explen;
-    if (bsd_check(db) && db->debug) {
-       printf("bsd_decomp%d: peer should have cleared dictionary\n",
-              db->unit);
-    }
-
-    ++db->comp_count;
-    db->comp_bytes += ilen + BSD_OVHD;
-    ++db->uncomp_count;
-    db->uncomp_bytes += explen;
-
-    *dmpp = mret;
-    return DECOMP_OK;
-
-#ifdef DEBUG
- bad:
-    if (codelen <= 0) {
-       printf("bsd_decomp%d: fell off end of chain ", db->unit);
-       printf("0x%x at 0x%x by 0x%x, max_ent=0x%x\n",
-              incode, finchar, db->dict[finchar].cptr, max_ent);
-    } else if (dictp->codem1 != finchar-1) {
-       printf("bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",
-              db->unit, incode, finchar);
-       printf("oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode,
-              db->dict[finchar].cptr, dictp->codem1);
-    }
-    m_freem(mret);
-    return DECOMP_FATALERROR;
-#endif /* DEBUG */
-}
-#endif /* DO_BSD_COMPRESS */
diff --git a/ultrix/if_ppp.c b/ultrix/if_ppp.c
deleted file mode 100644 (file)
index 9a896c6..0000000
+++ /dev/null
@@ -1,1436 +0,0 @@
-/*
- * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a collision if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- *
- * Ultrix port by Per Sundstrom <sundstrom@stkhlm.enet.dec.com>,
- * Robert Olsson <robert@robur.slu.se> and Paul Mackerras.
- */
-
-/* $Id: if_ppp.c,v 1.16 2002/12/06 12:03:44 paulus Exp $ */
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include "../h/param.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/mbuf.h"
-#include "../h/buf.h"
-#include "../h/socket.h"
-#include "../h/ioctl.h"
-#include "../h/systm.h"
-#include "../h/time.h"
-
-#include "../net/net/if.h"
-#include "../net/net/netisr.h"
-#include "../net/net/route.h"
-
-#if INET
-#include "../net/netinet/in.h"
-#include "../net/netinet/in_systm.h"
-#include "../net/netinet/in_var.h"
-#include "../net/netinet/ip.h"
-#endif
-
-#ifdef vax
-#include "../machine/mtpr.h"
-#endif
-
-#ifdef VJC
-#include "slcompress.h"
-#endif
-
-#include "ppp_defs.h"
-#include "if_ppp.h"
-#include "if_pppvar.h"
-
-#ifdef PPP_COMPRESS
-#define PACKETPTR      struct mbuf *
-#include "ppp-comp.h"
-#endif
-
-static int     pppsioctl(struct ifnet *, int, caddr_t);
-static void    ppp_requeue __P((struct ppp_softc *));
-static void    ppp_outpkt __P((struct ppp_softc *));
-static void    ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
-static void    ppp_ccp_closed __P((struct ppp_softc *));
-static void    ppp_inproc __P((struct ppp_softc *, struct mbuf *));
-static void    pppdumpm __P((struct mbuf *m0));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m) ((m)->m_off > MMAXOFF)
-
-#define M_TRAILINGSPACE(m) \
-       ((M_IS_CLUSTER(m) ? (u_int)(m)->m_clptr + M_CLUSTERSZ : MSIZE) \
-        - ((m)->m_off + (m)->m_len))
-
-#define M_OFFSTART(m)  \
-       (M_IS_CLUSTER(m) ? (u_int)(m)->m_clptr : MMINOFF)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? M_CLUSTERSZ : MLEN)
-
-/*
- * The following disgusting hack gets around the problem that IP TOS
- * can't be set yet.  We want to put "interactive" traffic on a high
- * priority queue.  To decide if traffic is interactive, we check that
- * a) it is TCP and b) one of its ports is telnet, rlogin or ftp control.
- */
-static u_short interactive_ports[8] = {
-       0,      513,    0,      0,
-       0,      21,     0,      23,
-};
-#define INTERACTIVE(p) (interactive_ports[(p) & 7] == (p))
-
-#ifdef PPP_COMPRESS
-/*
- * List of compressors we know about.
- */
-
-extern struct compressor ppp_bsd_compress;
-extern struct compressor ppp_deflate;
-extern struct compressor ppp_deflate_draft;
-
-struct compressor *ppp_compressors[] = {
-#if DO_BSD_COMPRESS
-    &ppp_bsd_compress,
-#endif
-#if DO_DEFLATE
-    &ppp_deflate,
-    &ppp_deflate_draft,
-#endif
-    NULL
-};
-#endif /* PPP_COMPRESS */
-
-
-/*
- * Called from boot code to establish ppp interfaces.
- */
-void
-pppattach()
-{
-    register struct ppp_softc *sc;
-    register int i = 0;
-
-    for (sc = ppp_softc; i < NPPP; sc++) {
-       sc->sc_if.if_name = "ppp";
-       sc->sc_if.if_unit = i++;
-       sc->sc_if.if_mtu = PPP_MTU;
-       sc->sc_if.if_flags = IFF_POINTOPOINT;
-       sc->sc_if.if_type = IFT_PPP;
-       sc->sc_if.if_ioctl = pppsioctl;
-       sc->sc_if.if_output = pppoutput;
-       sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
-       sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
-       if_attach(&sc->sc_if);
-#if NBPFILTER > 0
-       bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
-#endif
-    }
-}
-
-/*
- * Allocate a ppp interface unit and initialize it.
- */
-struct ppp_softc *
-pppalloc(pid)
-    pid_t pid;
-{
-    int nppp, i;
-    struct ppp_softc *sc;
-
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_xfer == pid) {
-           sc->sc_xfer = 0;
-           return sc;
-       }
-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
-       if (sc->sc_devp == NULL)
-           break;
-    if (nppp >= NPPP)
-       return NULL;
-
-    sc->sc_flags = 0;
-    sc->sc_mru = PPP_MRU;
-    sc->sc_relinq = NULL;
-    bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
-#ifdef VJC
-    KM_ALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress),
-          KM_DEVBUF, KM_NOARG);
-    if (sc->sc_comp)
-       sl_compress_init(sc->sc_comp);
-#endif
-#ifdef PPP_COMPRESS
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-    for (i = 0; i < NUM_NP; ++i)
-       sc->sc_npmode[i] = NPMODE_ERROR;
-    sc->sc_npqueue = NULL;
-    sc->sc_npqtail = &sc->sc_npqueue;
-    sc->sc_last_sent = sc->sc_last_recv = time.tv_sec;
-
-    return sc;
-}
-
-/*
- * Deallocate a ppp unit.  Must be called at splnet or higher.
- */
-void
-pppdealloc(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m;
-
-    if_down(&sc->sc_if);
-    sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
-    sc->sc_devp = NULL;
-    sc->sc_xfer = 0;
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_rawq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_inq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    for (;;) {
-       IF_DEQUEUE(&sc->sc_fastq, m);
-       if (m == NULL)
-           break;
-       m_freem(m);
-    }
-    while ((m = sc->sc_npqueue) != NULL) {
-       sc->sc_npqueue = m->m_act;
-       m_freem(m);
-    }
-    if (sc->sc_togo != NULL) {
-       m_freem(sc->sc_togo);
-       sc->sc_togo = NULL;
-    }
-#ifdef PPP_COMPRESS
-    ppp_ccp_closed(sc);
-    sc->sc_xc_state = NULL;
-    sc->sc_rc_state = NULL;
-#endif /* PPP_COMPRESS */
-#ifdef VJC
-    if (sc->sc_comp != 0) {
-       KM_FREE(sc->sc_comp, KM_DEVBUF);
-       sc->sc_comp = 0;
-    }
-#endif
-}
-
-/*
- * Ioctl routine for generic ppp devices.
- */
-int
-pppioctl(sc, cmd, data, flag)
-    struct ppp_softc *sc;
-    caddr_t data;
-    int cmd, flag;
-{
-    struct proc *p = u.u_procp;
-    int s, error, flags, mru, mtu, nb, npx;
-    struct ppp_option_data *odp;
-    struct compressor **cp;
-    struct npioctl *npi;
-    time_t t;
-#ifdef PPP_COMPRESS
-    u_char ccp_option[CCP_MAX_OPTION_LENGTH];
-#endif
-
-    switch (cmd) {
-    case FIONREAD:
-       *(int *)data = sc->sc_inq.ifq_len;
-       break;
-
-    case PPPIOCGUNIT:
-       *(int *)data = sc->sc_if.if_unit;
-       break;
-
-    case PPPIOCGFLAGS:
-       *(u_int *)data = sc->sc_flags;
-       break;
-
-    case PPPIOCSFLAGS:
-       if (!suser())
-           return EPERM;
-       flags = *(int *)data & SC_MASK;
-       s = splnet();
-#ifdef PPP_COMPRESS
-       if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN))
-           ppp_ccp_closed(sc);
-#endif
-       splimp();
-       sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags;
-       splx(s);
-       break;
-
-    case PPPIOCSMRU:
-       if (!suser())
-           return EPERM;
-       mru = *(int *)data;
-       if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
-           sc->sc_mru = mru;
-       break;
-
-    case PPPIOCGMRU:
-       *(int *)data = sc->sc_mru;
-       break;
-
-    /*
-     * PPPIOC[GS]MTU are implemented here, instead of supporting
-     * SIOC[GS]IFMTU in pppsioctl, because under Ultrix, we can't get an
-     * interface ioctl through to the interface until it has an IP
-     * address set.
-     */
-    case PPPIOCSMTU:
-       if (!suser())
-           return EPERM;
-       mtu = *(int *) data;
-       if (mtu <= 0 || mtu > PPP_MAXMRU)
-           return EINVAL;
-       s = splimp();
-       sc->sc_if.if_mtu = mtu;
-       splx(s);
-       break;
-
-    case PPPIOCGMTU:
-       *(int *) data = sc->sc_if.if_mtu;
-       break;
-
-#ifdef VJC
-    case PPPIOCSMAXCID:
-       if (!suser())
-           return EPERM;
-       if (sc->sc_comp) {
-           s = splnet();
-           sl_compress_setup(sc->sc_comp, *(int *)data);
-           splx(s);
-       }
-       break;
-#endif
-
-    case PPPIOCXFERUNIT:
-       if (!suser())
-           return EPERM;
-       sc->sc_xfer = p->p_pid;
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPPIOCSCOMPRESS:
-       if (!suser())
-           return EPERM;
-       odp = (struct ppp_option_data *) data;
-       nb = odp->length;
-       if (nb > sizeof(ccp_option))
-           nb = sizeof(ccp_option);
-       if ((error = copyin(odp->ptr, ccp_option, nb)) != 0)
-           return (error);
-       if (ccp_option[1] < 2)  /* preliminary check on the length byte */
-           return (EINVAL);
-       for (cp = ppp_compressors; *cp != NULL; ++cp)
-           if ((*cp)->compress_proto == ccp_option[0]) {
-               /*
-                * Found a handler for the protocol - try to allocate
-                * a compressor or decompressor.
-                */
-               error = 0;
-               if (odp->transmit) {
-                   s = splnet();
-                   if (sc->sc_xc_state != NULL)
-                       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-                   sc->sc_xcomp = *cp;
-                   sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
-                   if (sc->sc_xc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("ppp%d: comp_alloc failed\n",
-                              sc->sc_if.if_unit);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_COMP_RUN;
-                   splx(s);
-               } else {
-                   s = splnet();
-                   if (sc->sc_rc_state != NULL)
-                       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-                   sc->sc_rcomp = *cp;
-                   sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
-                   if (sc->sc_rc_state == NULL) {
-                       if (sc->sc_flags & SC_DEBUG)
-                           printf("ppp%d: decomp_alloc failed\n",
-                              sc->sc_if.if_unit);
-                       error = ENOBUFS;
-                   }
-                   splimp();
-                   sc->sc_flags &= ~SC_DECOMP_RUN;
-                   splx(s);
-               }
-               return (error);
-           }
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: no compressor for [%x %x %x], %x\n",
-                  sc->sc_if.if_unit, ccp_option[0], ccp_option[1],
-                  ccp_option[2], nb);
-       return (EINVAL);        /* no handler found */
-#endif /* PPP_COMPRESS */
-
-    case PPPIOCGNPMODE:
-    case PPPIOCSNPMODE:
-       npi = (struct npioctl *) data;
-       switch (npi->protocol) {
-       case PPP_IP:
-           npx = NP_IP;
-           break;
-       default:
-           return EINVAL;
-       }
-       if (cmd == PPPIOCGNPMODE) {
-           npi->mode = sc->sc_npmode[npx];
-       } else {
-           if (!suser())
-               return EPERM;
-           if (npi->mode != sc->sc_npmode[npx]) {
-               s = splnet();
-               sc->sc_npmode[npx] = npi->mode;
-               if (npi->mode != NPMODE_QUEUE) {
-                   ppp_requeue(sc);
-                   (*sc->sc_start)(sc);
-               }
-               splx(s);
-           }
-       }
-       break;
-
-    case PPPIOCGIDLE:
-       s = splnet();
-       t = time.tv_sec;
-       ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
-       ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
-       splx(s);
-       break;
-
-    default:
-       return (-1);
-    }
-    return (0);
-}
-
-/*
- * Process an ioctl request to the ppp network interface.
- */
-int
-pppsioctl(ifp, cmd, data)
-    register struct ifnet *ifp;
-    int cmd;
-    caddr_t data;
-{
-    struct proc *p = u.u_procp;
-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
-    register struct ifaddr *ifa = (struct ifaddr *)data;
-    register struct ifreq *ifr = (struct ifreq *)data;
-    struct ppp_stats *psp;
-#ifdef PPP_COMPRESS
-    struct ppp_comp_stats *pcp;
-#endif
-    int s = splimp(), error = 0;
-
-    switch (cmd) {
-    case SIOCSIFFLAGS:
-       if ((ifp->if_flags & IFF_RUNNING) == 0)
-           ifp->if_flags &= ~IFF_UP;
-       break;
-
-    case SIOCSIFADDR:
-       if (ifa->ifa_addr.sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-    case SIOCSIFDSTADDR:
-       if (ifa->ifa_addr.sa_family != AF_INET)
-           error = EAFNOSUPPORT;
-       break;
-
-/*
- * Ioctls other than the above don't get through until the
- * interface has its IP addresses set :-(
- */
-
-#if 0
-    case SIOCSIFMTU:
-       if (!suser())
-           return EPERM;
-       sc->sc_if.if_mtu = ifr->ifr_mtu;
-       break;
-
-    case SIOCGIFMTU:
-       ifr->ifr_mtu = sc->sc_if.if_mtu;
-       break;
-#endif
-
-    case SIOCGPPPSTATS:
-       psp = &((struct ifpppstatsreq *) data)->stats;
-       bzero(psp, sizeof(*psp));
-       psp->p = sc->sc_stats;
-#if defined(VJC) && !defined(SL_NO_STATS)
-       if (sc->sc_comp) {
-           psp->vj.vjs_packets = sc->sc_comp->sls_packets;
-           psp->vj.vjs_compressed = sc->sc_comp->sls_compressed;
-           psp->vj.vjs_searches = sc->sc_comp->sls_searches;
-           psp->vj.vjs_misses = sc->sc_comp->sls_misses;
-           psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin;
-           psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin;
-           psp->vj.vjs_errorin = sc->sc_comp->sls_errorin;
-           psp->vj.vjs_tossed = sc->sc_comp->sls_tossed;
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case SIOCGPPPCSTATS:
-       pcp = &((struct ifpppcstatsreq *) data)->stats;
-       bzero(pcp, sizeof(*pcp));
-       if (sc->sc_xc_state != NULL)
-           (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c);
-       if (sc->sc_rc_state != NULL)
-           (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d);
-       break;
-#endif /* PPP_COMPRESS */
-
-    default:
-       error = EINVAL;
-    }
-    splx(s);
-    return (error);
-}
-
-/*
- * Queue a packet.  Start transmission if not active.
- * Packet is placed in Information field of PPP frame.
- */
-int
-pppoutput(ifp, m0, dst)
-    struct ifnet *ifp;
-    struct mbuf *m0;
-    struct sockaddr *dst;
-{
-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
-    int protocol, address, control;
-    u_char *cp;
-    int s, error;
-    struct ip *ip;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-    int len;
-    struct mbuf *m;
-
-    if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
-       || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
-       error = ENETDOWN;       /* sort of */
-       goto bad;
-    }
-
-    /*
-     * Compute PPP header.
-     * We use the m_context field of the mbuf to indicate whether
-     * the packet should go on the fast queue.
-     */
-    m0->m_context = 0;
-    switch (dst->sa_family) {
-#ifdef INET
-    case AF_INET:
-       address = PPP_ALLSTATIONS;
-       control = PPP_UI;
-       protocol = PPP_IP;
-       mode = sc->sc_npmode[NP_IP];
-
-       /*
-        * If this is a TCP packet to or from an "interactive" port,
-        * put the packet on the fastq instead.
-        */
-       if ((ip = mtod(m0, struct ip *))->ip_p == IPPROTO_TCP) {
-           register int p = ntohl(((int *)ip)[ip->ip_hl]);
-           if (INTERACTIVE(p & 0xffff) || INTERACTIVE(p >> 16))
-               m0->m_context = 1;
-       }
-       break;
-#endif
-    case AF_UNSPEC:
-       address = PPP_ADDRESS(dst->sa_data);
-       control = PPP_CONTROL(dst->sa_data);
-       protocol = PPP_PROTOCOL(dst->sa_data);
-       mode = NPMODE_PASS;
-       break;
-    default:
-       printf("ppp%d: af%d not supported\n", ifp->if_unit, dst->sa_family);
-       error = EAFNOSUPPORT;
-       goto bad;
-    }
-
-    /*
-     * Drop this packet, or return an error, if necessary.
-     */
-    if (mode == NPMODE_ERROR) {
-       error = ENETDOWN;
-       goto bad;
-    }
-    if (mode == NPMODE_DROP) {
-       error = 0;
-       goto bad;
-    }
-
-    /*
-     * Add PPP header.  If no space in first mbuf, allocate another.
-     */
-    if (M_IS_CLUSTER(m0) || m0->m_off < MMINOFF + PPP_HDRLEN) {
-       struct mbuf *m;
-
-       MGET(m, M_DONTWAIT, MT_DATA);
-       if (m == NULL) {
-           m_freem(m0);
-           return (ENOBUFS);
-       }
-       m->m_len = 0;
-       m->m_next = m0;
-       m0 = m;
-    } else
-       m0->m_off -= PPP_HDRLEN;
-
-    cp = mtod(m0, u_char *);
-    *cp++ = address;
-    *cp++ = control;
-    *cp++ = protocol >> 8;
-    *cp++ = protocol & 0xff;
-    m0->m_len += PPP_HDRLEN;
-
-    len = 0;
-    for (m = m0; m != 0; m = m->m_next)
-       len += m->m_len;
-
-    if (sc->sc_flags & SC_LOG_OUTPKT) {
-       printf("ppp%d output: ", ifp->if_unit);
-       pppdumpm(m0);
-    }
-
-    if ((protocol & 0x8000) == 0) {
-       /*
-        * Update the time we sent the most recent data packet.
-        */
-       sc->sc_last_sent = time.tv_sec;
-    }
-
-#if NBPFILTER > 0
-    /*
-     * See if bpf wants to look at the packet.
-     */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m0);
-#endif
-
-    /*
-     * Put the packet on the appropriate queue.
-     */
-    s = splnet();
-    if (mode == NPMODE_QUEUE) {
-       /* XXX we should limit the number of packets on this queue */
-       *sc->sc_npqtail = m0;
-       m0->m_act = NULL;
-       sc->sc_npqtail = &m0->m_act;
-    } else {
-       ifq = m0->m_context? &sc->sc_fastq: &ifp->if_snd;
-       if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
-           IF_DROP(ifq);
-           splx(s);
-           sc->sc_if.if_oerrors++;
-           sc->sc_stats.ppp_oerrors++;
-           error = ENOBUFS;
-           goto bad;
-       }
-       IF_ENQUEUE(ifq, m0);
-       (*sc->sc_start)(sc);
-    }
-    ifp->if_opackets++;
-
-    splx(s);
-    return (0);
-
-bad:
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * After a change in the NPmode for some NP, move packets from the
- * npqueue to the send queue or the fast queue as appropriate.
- * Should be called at splnet.
- */
-static void
-ppp_requeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, **mpp;
-    struct ifqueue *ifq;
-    enum NPmode mode;
-
-    for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) {
-       switch (PPP_PROTOCOL(mtod(m, u_char *))) {
-       case PPP_IP:
-           mode = sc->sc_npmode[NP_IP];
-           break;
-       default:
-           mode = NPMODE_PASS;
-       }
-
-       switch (mode) {
-       case NPMODE_PASS:
-           /*
-            * This packet can now go on one of the queues to be sent.
-            */
-           *mpp = m->m_act;
-           m->m_act = NULL;
-           ifq = m->m_context? &sc->sc_fastq: &sc->sc_if.if_snd;
-           if (IF_QFULL(ifq)) {
-               IF_DROP(ifq);
-               sc->sc_if.if_oerrors++;
-               sc->sc_stats.ppp_oerrors++;
-           } else
-               IF_ENQUEUE(ifq, m);
-           break;
-
-       case NPMODE_DROP:
-       case NPMODE_ERROR:
-           *mpp = m->m_act;
-           m_freem(m);
-           break;
-
-       case NPMODE_QUEUE:
-           mpp = &m->m_act;
-           break;
-       }
-    }
-    sc->sc_npqtail = mpp;
-}
-
-/*
- * Transmitter has finished outputting some stuff;
- * remember to call sc->sc_start later at splnet.
- */
-void
-ppp_restart(sc)
-    struct ppp_softc *sc;
-{
-    int s = splimp();
-
-    sc->sc_flags &= ~SC_TBUSY;
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Get a packet to send.  This procedure is intended to be called at
- * splnet, since it may involve time-consuming operations such as
- * applying VJ compression, packet compression, address/control and/or
- * protocol field compression to the packet.
- */
-struct mbuf *
-ppp_dequeue(sc)
-    struct ppp_softc *sc;
-{
-    struct mbuf *m, *mp;
-    u_char *cp;
-    int address, control, protocol;
-    int s;
-
-    /*
-     * Grab a packet to send: first try the fast queue, then the
-     * normal queue.
-     */
-    IF_DEQUEUE(&sc->sc_fastq, m);
-    if (m == NULL)
-       IF_DEQUEUE(&sc->sc_if.if_snd, m);
-    if (m == NULL)
-       return NULL;
-
-    ++sc->sc_stats.ppp_opackets;
-
-    /*
-     * Extract the ppp header of the new packet.
-     * The ppp header will be in one mbuf.
-     */
-    cp = mtod(m, u_char *);
-    address = PPP_ADDRESS(cp);
-    control = PPP_CONTROL(cp);
-    protocol = PPP_PROTOCOL(cp);
-
-    switch (protocol) {
-    case PPP_IP:
-#ifdef VJC
-       /*
-        * If the packet is a TCP/IP packet, see if we can compress it.
-        */
-       if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) {
-           struct ip *ip;
-           int type;
-
-           mp = m;
-           ip = (struct ip *) (cp + PPP_HDRLEN);
-           if (mp->m_len <= PPP_HDRLEN) {
-               mp = mp->m_next;
-               if (mp == NULL)
-                   break;
-               ip = mtod(mp, struct ip *);
-           }
-           /* this code assumes the IP/TCP header is in one non-shared mbuf */
-           if (ip->ip_p == IPPROTO_TCP) {
-               type = sl_compress_tcp(mp, ip, sc->sc_comp,
-                                      !(sc->sc_flags & SC_NO_TCP_CCID));
-               switch (type) {
-               case TYPE_UNCOMPRESSED_TCP:
-                   protocol = PPP_VJC_UNCOMP;
-                   break;
-               case TYPE_COMPRESSED_TCP:
-                   protocol = PPP_VJC_COMP;
-                   cp = mtod(m, u_char *);
-                   cp[0] = address;    /* header has moved */
-                   cp[1] = control;
-                   cp[2] = 0;
-                   break;
-               }
-               cp[3] = protocol;       /* update protocol in PPP header */
-           }
-       }
-#endif /* VJC */
-       break;
-
-#ifdef PPP_COMPRESS
-    case PPP_CCP:
-       ppp_ccp(sc, m, 0);
-       break;
-#endif /* PPP_COMPRESS */
-    }
-
-#ifdef PPP_COMPRESS
-    if (protocol != PPP_LCP && protocol != PPP_CCP
-       && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
-       struct mbuf *mcomp = NULL;
-       int slen, clen;
-
-       slen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           slen += mp->m_len;
-       clen = (*sc->sc_xcomp->compress)
-           (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
-       if (mcomp != NULL) {
-           if (sc->sc_flags & SC_CCP_UP) {
-               /* Send the compressed packet instead of the original. */
-               m_freem(m);
-               m = mcomp;
-               cp = mtod(m, u_char *);
-               protocol = cp[3];
-           } else {
-               /* Can't transmit compressed packets until CCP is up. */
-               m_freem(mcomp);
-           }
-       }
-    }
-#endif /* PPP_COMPRESS */
-
-    /*
-     * Compress the address/control and protocol, if possible.
-     */
-    if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS &&
-       control == PPP_UI && protocol != PPP_ALLSTATIONS &&
-       protocol != PPP_LCP) {
-       /* can compress address/control */
-       m->m_off += 2;
-       m->m_len -= 2;
-    }
-    if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) {
-       /* can compress protocol */
-       if (mtod(m, u_char *) == cp) {
-           cp[2] = cp[1];      /* move address/control up */
-           cp[1] = cp[0];
-       }
-       ++m->m_off;
-       --m->m_len;
-    }
-
-    return m;
-}
-
-/*
- * Software interrupt routine, called at splnet.
- */
-void
-pppintr()
-{
-    struct ppp_softc *sc;
-    int i, s, s2;
-    struct mbuf *m;
-
-    sc = ppp_softc;
-    s = splnet();
-    for (i = 0; i < NPPP; ++i, ++sc) {
-       if (!(sc->sc_flags & SC_TBUSY)
-           && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
-           s2 = splimp();
-           sc->sc_flags |= SC_TBUSY;
-           splx(s2);
-           (*sc->sc_start)(sc);
-       }
-       for (;;) {
-           s2 = splimp();
-           IF_DEQUEUE(&sc->sc_rawq, m);
-           splx(s2);
-           if (m == NULL)
-               break;
-           ppp_inproc(sc, m);
-       }
-    }
-    splx(s);
-}
-
-#ifdef PPP_COMPRESS
-/*
- * Handle a CCP packet.  `rcvd' is 1 if the packet was received,
- * 0 if it is about to be transmitted.
- */
-static void
-ppp_ccp(sc, m, rcvd)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int rcvd;
-{
-    u_char *dp, *ep;
-    struct mbuf *mp;
-    int slen, s;
-
-    /*
-     * Get a pointer to the data after the PPP header.
-     */
-    if (m->m_len <= PPP_HDRLEN) {
-       mp = m->m_next;
-       if (mp == NULL)
-           return;
-       dp = (mp != NULL)? mtod(mp, u_char *): NULL;
-    } else {
-       mp = m;
-       dp = mtod(mp, u_char *) + PPP_HDRLEN;
-    }
-
-    ep = mtod(mp, u_char *) + mp->m_len;
-    if (dp + CCP_HDRLEN > ep)
-       return;
-    slen = CCP_LENGTH(dp);
-    if (dp + slen > ep) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("if_ppp/ccp: not enough data in mbuf (%x+%x > %x+%x)\n",
-                  dp, slen, mtod(mp, u_char *), mp->m_len);
-       return;
-    }
-
-    switch (CCP_CODE(dp)) {
-    case CCP_CONFREQ:
-    case CCP_TERMREQ:
-    case CCP_TERMACK:
-       /* CCP must be going down - disable compression */
-       if (sc->sc_flags & SC_CCP_UP) {
-           s = splimp();
-           sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
-           splx(s);
-       }
-       break;
-
-    case CCP_CONFACK:
-       if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP)
-           && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
-           && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
-           if (!rcvd) {
-               /* we're agreeing to send compressed packets. */
-               if (sc->sc_xc_state != NULL
-                   && (*sc->sc_xcomp->comp_init)
-                       (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_COMP_RUN;
-                   splx(s);
-               }
-           } else {
-               /* peer is agreeing to send compressed packets. */
-               if (sc->sc_rc_state != NULL
-                   && (*sc->sc_rcomp->decomp_init)
-                       (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, 0, sc->sc_mru,
-                        sc->sc_flags & SC_DEBUG)) {
-                   s = splimp();
-                   sc->sc_flags |= SC_DECOMP_RUN;
-                   sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
-                   splx(s);
-               }
-           }
-       }
-       break;
-
-    case CCP_RESETACK:
-       if (sc->sc_flags & SC_CCP_UP) {
-           if (!rcvd) {
-               if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN))
-                   (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state);
-           } else {
-               if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-                   (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state);
-                   s = splimp();
-                   sc->sc_flags &= ~SC_DC_ERROR;
-                   splx(s);
-               }
-           }
-       }
-       break;
-    }
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-static void
-ppp_ccp_closed(sc)
-    struct ppp_softc *sc;
-{
-    if (sc->sc_xc_state) {
-       (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
-       sc->sc_xc_state = NULL;
-    }
-    if (sc->sc_rc_state) {
-       (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
-       sc->sc_rc_state = NULL;
-    }
-}
-#endif /* PPP_COMPRESS */
-
-/*
- * PPP packet input routine.
- * The caller has checked and removed the FCS and has inserted
- * the address/control bytes and the protocol high byte if they
- * were omitted.
- */
-void
-ppppktin(sc, m, lost)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-    int lost;
-{
-    int s = splimp();
-
-    m->m_context = lost;
-    IF_ENQUEUE(&sc->sc_rawq, m);
-    schednetisr(NETISR_PPP);
-    splx(s);
-}
-
-/*
- * Process a received PPP packet, doing decompression as necessary.
- * Should be called at splnet.
- */
-#define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
-                        TYPE_UNCOMPRESSED_TCP)
-
-static void
-ppp_inproc(sc, m)
-    struct ppp_softc *sc;
-    struct mbuf *m;
-{
-    struct ifnet *ifp = &sc->sc_if;
-    struct ifqueue *inq, *lock;
-    int s, ilen, xlen, proto, rv;
-    u_char *cp, adrs, ctrl;
-    struct mbuf *mp, *dmp = NULL, *pc;
-    u_char *iphdr;
-    u_int hlen;
-
-    sc->sc_stats.ppp_ipackets++;
-
-    if (sc->sc_flags & SC_LOG_INPKT) {
-       ilen = 0;
-       for (mp = m; mp != NULL; mp = mp->m_next)
-           ilen += mp->m_len;
-       printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen);
-       pppdumpm(m);
-    }
-
-    cp = mtod(m, u_char *);
-    adrs = PPP_ADDRESS(cp);
-    ctrl = PPP_CONTROL(cp);
-    proto = PPP_PROTOCOL(cp);
-
-    if (m->m_context) {
-       s = splimp();
-       sc->sc_flags |= SC_VJ_RESET;
-       splx(s);
-    }
-
-#ifdef PPP_COMPRESS
-    /*
-     * Decompress this packet if necessary, update the receiver's
-     * dictionary, or take appropriate action on a CCP packet.
-     */
-    if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)
-       && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) {
-       /* decompress this packet */
-       rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp);
-       if (rv == DECOMP_OK) {
-           m_freem(m);
-           if (dmp == NULL) {
-               /* no error, but no decompressed packet produced */
-               return;
-           }
-           m = dmp;
-           cp = mtod(m, u_char *);
-           proto = PPP_PROTOCOL(cp);
-
-       } else {
-           /*
-            * An error has occurred in decompression.
-            * Pass the compressed packet up to pppd, which may take
-            * CCP down or issue a Reset-Req.
-            */
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: decompress failed %d\n", ifp->if_unit, rv);
-           s = splimp();
-           sc->sc_flags |= SC_VJ_RESET;
-           if (rv == DECOMP_ERROR)
-               sc->sc_flags |= SC_DC_ERROR;
-           else
-               sc->sc_flags |= SC_DC_FERROR;
-           splx(s);
-       }
-
-    } else {
-       if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) {
-           (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m);
-       }
-       if (proto == PPP_CCP) {
-           ppp_ccp(sc, m, 1);
-       }
-    }
-#endif
-
-    ilen = 0;
-    for (mp = m; mp != NULL; mp = mp->m_next)
-       ilen += mp->m_len;
-
-#ifdef VJC
-    if (sc->sc_flags & SC_VJ_RESET) {
-       /*
-        * If we've missed a packet, we must toss subsequent compressed
-        * packets which don't have an explicit connection ID.
-        */
-       if (sc->sc_comp)
-           sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp);
-       s = splimp();
-       sc->sc_flags &= ~SC_VJ_RESET;
-       splx(s);
-    }
-
-    /*
-     * See if we have a VJ-compressed packet to uncompress.
-     */
-    if (proto == PPP_VJC_COMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen <= 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: VJ uncompress failed on type comp\n",
-                       ifp->if_unit);
-           goto bad;
-       }
-
-       /* Copy the PPP and IP headers into a new mbuf. */
-       MGET(mp, M_DONTWAIT, MT_DATA);
-       if (mp == NULL)
-           goto bad;
-       mp->m_len = 0;
-       mp->m_next = NULL;
-       if (hlen + PPP_HDRLEN > MLEN) {
-           MCLGET(mp, pc);
-           if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) {
-               m_freem(mp);
-               goto bad;       /* lose if big headers and no clusters */
-           }
-       }
-       cp = mtod(mp, u_char *);
-       cp[0] = adrs;
-       cp[1] = ctrl;
-       cp[2] = 0;
-       cp[3] = PPP_IP;
-       proto = PPP_IP;
-       bcopy(iphdr, cp + PPP_HDRLEN, hlen);
-       mp->m_len = hlen + PPP_HDRLEN;
-
-       /*
-        * Trim the PPP and VJ headers off the old mbuf
-        * and stick the new and old mbufs together.
-        */
-       m->m_off += PPP_HDRLEN + xlen;
-       m->m_len -= PPP_HDRLEN + xlen;
-       if (m->m_len <= M_TRAILINGSPACE(mp)) {
-           bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len);
-           mp->m_len += m->m_len;
-           MFREE(m, mp->m_next);
-       } else
-           mp->m_next = m;
-       m = mp;
-       ilen += hlen - xlen;
-
-    } else if (proto == PPP_VJC_UNCOMP) {
-       if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
-           goto bad;
-
-       xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
-                                     ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP,
-                                     sc->sc_comp, &iphdr, &hlen);
-
-       if (xlen < 0) {
-           if (sc->sc_flags & SC_DEBUG)
-               printf("ppp%d: VJ uncompress failed on type uncomp\n",
-                       ifp->if_unit);
-           goto bad;
-       }
-
-       proto = PPP_IP;
-       cp[3] = PPP_IP;
-    }
-#endif /* VJC */
-
-    /*
-     * If the packet will fit in an ordinary mbuf, don't waste a
-     * whole cluster on it.
-     */
-    if (ilen <= MLEN && M_IS_CLUSTER(m)) {
-       MGET(mp, M_DONTWAIT, MT_DATA);
-       if (mp != NULL) {
-           m_copydata(m, mtod(mp, caddr_t), ilen);
-           m_freem(m);
-           m = mp;
-           m->m_len = ilen;
-       }
-    }
-
-    /*
-     * Record the time that we received this packet.
-     */
-    if ((proto & 0x8000) == 0) {
-       sc->sc_last_recv = time.tv_sec;
-    }
-
-#if NBPFILTER > 0
-    /* See if bpf wants to look at the packet. */
-    if (sc->sc_bpf)
-       bpf_mtap(sc->sc_bpf, m);
-#endif
-
-    rv = 0;
-    switch (proto) {
-#ifdef INET
-    case PPP_IP:
-       /*
-        * IP packet - take off the ppp header and pass it up to IP.
-        */
-       if ((ifp->if_flags & IFF_UP) == 0
-           || sc->sc_npmode[NP_IP] != NPMODE_PASS) {
-           /* interface is down - drop the packet. */
-           m_freem(m);
-           return;
-       }
-       m->m_off += PPP_HDRLEN;
-       m->m_len -= PPP_HDRLEN;
-       schednetisr(NETISR_IP);
-       inq = &ipintrq;
-       break;
-#endif
-
-    default:
-       /*
-        * Some other protocol - place on input queue for read().
-        */
-       inq = &sc->sc_inq;
-       rv = 1;
-       break;
-    }
-
-    /*
-     * Put the packet on the appropriate input queue.
-     */
-    s = splimp();
-    lock = inq;
-    smp_lock(&lock->lk_ifqueue, LK_RETRY);
-    if (IF_QFULL(inq)) {
-       IF_DROP(inq);
-       smp_unlock(&lock->lk_ifqueue);
-       splx(s);
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: input queue full\n", ifp->if_unit);
-       goto bad;
-    }
-    IF_ENQUEUEIF(inq, m, &sc->sc_if);
-    smp_unlock(&lock->lk_ifqueue);
-    splx(s);
-    ifp->if_ipackets++;
-
-    if (rv)
-       (*sc->sc_ctlp)(sc);
-
-    return;
-
- bad:
-    m_freem(m);
-    sc->sc_if.if_ierrors++;
-    sc->sc_stats.ppp_ierrors++;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-pppdumpm(m0)
-    struct mbuf *m0;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    struct mbuf *m;
-    static char digits[] = "0123456789abcdef";
-
-    for (m = m0; m; m = m->m_next) {
-       int l = m->m_len;
-       u_char *rptr = mtod(m, u_char *);
-
-       while (l--) {
-           if (bp > buf + sizeof(buf) - 4)
-               goto done;
-           *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
-           *bp++ = digits[*rptr++ & 0xf];
-       }
-
-       if (m->m_next) {
-           if (bp > buf + sizeof(buf) - 3)
-               goto done;
-           *bp++ = '|';
-       } else
-           *bp++ = ' ';
-    }
-done:
-    if (m)
-       *bp++ = '>';
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/ultrix/if_ppp.h b/ultrix/if_ppp.h
deleted file mode 100644 (file)
index 4d60647..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*     $Id: if_ppp.h,v 1.4 2002/12/06 12:03:44 paulus Exp $    */
-
-/*
- * if_ppp.h - Point-to-Point Protocol definitions.
- *
- * 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.
- */
-
-#ifndef _IF_PPP_H_
-#define _IF_PPP_H_
-
-/*
- * Packet sizes
- */
-#define        PPP_MTU         1500    /* Default MTU (size of Info field) */
-#define PPP_MAXMRU     65000   /* Largest MRU we allow */
-
-/*
- * Bit definitions for flags.
- */
-#define SC_COMP_PROT   0x00000001      /* protocol compression (output) */
-#define SC_COMP_AC     0x00000002      /* header compression (output) */
-#define        SC_COMP_TCP     0x00000004      /* TCP (VJ) compression (output) */
-#define SC_NO_TCP_CCID 0x00000008      /* disable VJ connection-id comp. */
-#define SC_REJ_COMP_AC 0x00000010      /* reject adrs/ctrl comp. on input */
-#define SC_REJ_COMP_TCP        0x00000020      /* reject TCP (VJ) comp. on input */
-#define SC_CCP_OPEN    0x00000040      /* Look at CCP packets */
-#define SC_CCP_UP      0x00000080      /* May send/recv compressed packets */
-#define SC_DEBUG       0x00010000      /* enable debug messages */
-#define SC_LOG_INPKT   0x00020000      /* log contents of good pkts recvd */
-#define SC_LOG_OUTPKT  0x00040000      /* log contents of pkts sent */
-#define SC_LOG_RAWIN   0x00080000      /* log all chars received */
-#define SC_LOG_FLUSH   0x00100000      /* log all chars flushed */
-#define SC_RCV_B7_0    0x01000000      /* have rcvd char with bit 7 = 0 */
-#define SC_RCV_B7_1    0x02000000      /* have rcvd char with bit 7 = 1 */
-#define SC_RCV_EVNP    0x04000000      /* have rcvd char with even parity */
-#define SC_RCV_ODDP    0x08000000      /* have rcvd char with odd parity */
-#define        SC_MASK         0x0fff00ff      /* bits that user can change */
-
-/*
- * State bits in sc_flags, not changeable by user.
- */
-#define SC_TIMEOUT     0x00000400      /* timeout is currently pending */
-#define SC_VJ_RESET    0x00000800      /* need to reset VJ decomp */
-#define SC_COMP_RUN    0x00001000      /* compressor has been inited */
-#define SC_DECOMP_RUN  0x00002000      /* decompressor has been inited */
-#define SC_DC_ERROR    0x00004000      /* non-fatal decomp error detected */
-#define SC_DC_FERROR   0x00008000      /* fatal decomp error detected */
-#define SC_TBUSY       0x10000000      /* xmitter doesn't need a packet yet */
-#define SC_PKTLOST     0x20000000      /* have lost or dropped a packet */
-#define        SC_FLUSH        0x40000000      /* flush input until next PPP_FLAG */
-#define        SC_ESCAPED      0x80000000      /* saw a PPP_ESCAPE */
-
-/*
- * Ioctl definitions.
- */
-
-struct npioctl {
-    int                protocol;       /* PPP procotol, e.g. PPP_IP */
-    enum NPmode        mode;
-};
-
-/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
-struct ppp_option_data {
-       u_char  *ptr;
-       u_int   length;
-       int     transmit;
-};
-
-struct ifpppstatsreq {
-    char ifr_name[IFNAMSIZ];
-    struct ppp_stats stats;
-};
-
-struct ifpppcstatsreq {
-    char ifr_name[IFNAMSIZ];
-    struct ppp_comp_stats stats;
-};
-
-/*
- * Ioctl definitions.
- */
-
-#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 */
-#define        PPPIOCSASYNCMAP _IOW('t', 87, int)      /* set async map */
-#define        PPPIOCGUNIT     _IOR('t', 86, int)      /* get ppp unit number */
-#define        PPPIOCGRASYNCMAP _IOR('t', 85, int)     /* get receive async map */
-#define        PPPIOCSRASYNCMAP _IOW('t', 84, int)     /* set receive async map */
-#define        PPPIOCGMRU      _IOR('t', 83, int)      /* get max receive unit */
-#define        PPPIOCSMRU      _IOW('t', 82, int)      /* set max receive unit */
-#define        PPPIOCSMAXCID   _IOW('t', 81, int)      /* set VJ max slot ID */
-#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
-#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
-#define PPPIOCXFERUNIT _IO('t', 78)            /* transfer PPP unit */
-#define PPPIOCSCOMPRESS        _IOW('t', 77, struct ppp_option_data)
-#define PPPIOCGNPMODE  _IOWR('t', 76, struct npioctl) /* get NP mode */
-#define PPPIOCSNPMODE  _IOW('t', 75, struct npioctl)  /* set NP mode */
-#define PPPIOCGIDLE    _IOR('t', 74, struct ppp_idle) /* get idle time */
-
-/* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */
-#define PPPIOCGMTU     _IOR('t', 73, int)      /* get interface MTU */
-#define PPPIOCSMTU     _IOW('t', 72, int)      /* set interface MTU */
-
-/*
- * These two are interface ioctls so that pppstats can do them on
- * a socket without having to open the serial device.
- */
-#define SIOCGPPPSTATS  _IOWR('i', 123, struct ifpppstatsreq)
-#define SIOCGPPPCSTATS _IOWR('i', 122, struct ifpppcstatsreq)
-
-#if !defined(ifr_mtu)
-#define ifr_mtu        ifr_ifru.ifru_metric
-#endif
-
-#if defined(_KERNEL) || defined(KERNEL)
-void pppattach(void);
-void pppintr();
-#endif
-#endif /* _IF_PPP_H_ */
diff --git a/ultrix/if_pppvar.h b/ultrix/if_pppvar.h
deleted file mode 100644 (file)
index fde3f35..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*     $Id: if_pppvar.h,v 1.8 2002/12/06 12:03:44 paulus Exp $ */
-/*
- * if_pppvar.h - private structures and declarations for PPP.
- *
- * Copyright (c) 1994 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.
- *
- * 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.
- */
-
-/*
- * Supported network protocols.  These values are used for
- * indexing sc_npmode.
- */
-#define NP_IP  0               /* Internet Protocol */
-#define NUM_NP 1               /* Number of NPs. */
-
-/*
- * Structure describing each ppp unit.
- */
-struct ppp_softc {
-       struct  ifnet sc_if;            /* network-visible interface */
-       u_int   sc_flags;               /* control/status bits; see if_ppp.h */
-       void    *sc_devp;               /* pointer to device-dep structure */
-       void    (*sc_start) __P((struct ppp_softc *));  /* start output proc */
-       void    (*sc_ctlp) __P((struct ppp_softc *)); /* rcvd control pkt */
-       void    (*sc_relinq) __P((struct ppp_softc *)); /* relinquish ifunit */
-       short   sc_mru;                 /* max receive unit */
-       pid_t   sc_xfer;                /* used in transferring unit */
-       struct  ifqueue sc_rawq;        /* received packets */
-       struct  ifqueue sc_inq;         /* queue of input packets for daemon */
-       struct  ifqueue sc_fastq;       /* interactive output packet q */
-       struct  mbuf *sc_togo;          /* output packet ready to go */
-       struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
-       struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
-       struct  pppstat sc_stats;       /* count of bytes/pkts sent/rcvd */
-       caddr_t sc_bpf;                 /* hook for BPF */
-       enum    NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
-       struct  compressor *sc_xcomp;   /* transmit compressor */
-       void    *sc_xc_state;           /* transmit compressor state */
-       struct  compressor *sc_rcomp;   /* receive decompressor */
-       void    *sc_rc_state;           /* receive decompressor state */
-       time_t  sc_last_sent;           /* time (secs) last NP pkt sent */
-       time_t  sc_last_recv;           /* time (secs) last NP pkt rcvd */
-#ifdef VJC
-       struct  slcompress *sc_comp;    /* vjc control buffer */
-#endif
-
-       /* Device-dependent part for async lines. */
-       ext_accm sc_asyncmap;           /* async control character map */
-       u_long  sc_rasyncmap;           /* receive async control char map */
-       struct  mbuf *sc_outm;          /* mbuf chain currently being output */
-       struct  mbuf *sc_m;             /* pointer to input mbuf chain */
-       struct  mbuf *sc_mc;            /* pointer to current input mbuf */
-       char    *sc_mp;                 /* ptr to next char in input mbuf */
-       short   sc_ilen;                /* length of input packet so far */
-       u_short sc_fcs;                 /* FCS so far (input) */
-       u_short sc_outfcs;              /* FCS so far for output packet */
-       u_char  sc_rawin[16];           /* chars as received */
-       int     sc_rawin_count;         /* # in sc_rawin */
-};
-
-struct ppp_softc ppp_softc[NPPP];
-
-struct ppp_softc *pppalloc(pid_t pid);
-void   pppdealloc(struct ppp_softc *sc);
-int    pppoutput(struct ifnet *, struct mbuf *, struct sockaddr *);
-int    pppioctl(struct ppp_softc *sc, int cmd, caddr_t data, int flag);
-void   ppp_restart(struct ppp_softc *sc);
-void   ppppktin(struct ppp_softc *sc, struct mbuf *m, int lost);
-struct mbuf *ppp_dequeue(struct ppp_softc *sc);
diff --git a/ultrix/patches b/ultrix/patches
deleted file mode 100644 (file)
index d445ca9..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-*** /usr/sys/h/ioctl.h.orig    Fri Dec  9 10:05:18 1994
---- /usr/sys/h/ioctl.h Fri Dec  9 10:06:06 1994
-***************
-*** 405,410 ****
---- 405,411 ----
-  #define SLPDISC              0x07            /* BSD Serial Line IP           */
-  #define PCMDISC              0x08            /* Peripheral Control Module
-                                          for dial and button boxex */
-+ #define PPPDISC              0x09            /* PPP Point-to-Point Protocol  */
-                                       /* Line disc #'s 16-23 are 
-                                          reserved for local extension.*/
-  
-*** /usr/sys/net/net/if.h.orig Wed Aug  4 01:57:00 1993
---- /usr/sys/net/net/if.h      Fri Dec  9 09:29:11 1994
-***************
-*** 231,236 ****
---- 231,237 ----
-  #define      IFT_XETHER      0x1a            /* obsolete 3MB experimental ethernet */
-  #define      IFT_NSIP        0x1b            /* XNS over IP */
-  #define      IFT_SLIP        0x1c            /* IP over generic TTY */
-+ #define      IFT_PPP         0x1d            /* PPP over generic TTY */
-  
-  /*
-   * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
-*** /usr/sys/net/net/netisr.h.orig     Fri Dec  9 09:53:17 1994
---- /usr/sys/net/net/netisr.h  Fri Dec  9 09:54:14 1994
-***************
-*** 77,82 ****
---- 77,83 ----
-  #define NETISR_LAT   14              /* same as AF_LAT */
-  #define NETISR_BSC   15              /* same as AF_BSC */
-  #define NETISR_DLO      19              /* same as AF_OSI */
-+ #define NETISR_PPP   26              /* Point-to-Point Protocol */
-  
-  #define      schednetisr(anisr)      { set_bit_atomic(anisr,&netisr); setsoftnet(); }
-  
-*** /usr/sys/net/net/conf_net.c.orig   Fri Dec  9 13:29:49 1994
---- /usr/sys/net/net/conf_net.c        Fri Dec  9 13:32:50 1994
-***************
-*** 84,89 ****
---- 84,90 ----
-  #ifdef vax
-  #include "bsc.h"
-  #endif vax
-+ #include "ppp.h"
-  
-  
-  #if ((NETHER==0 && NFDDI==0) || NINET==0)
-***************
-*** 251,257 ****
-  };
-  
-  
-! extern int rawintr(), ipintr(), nsintr(), dnetintr(), dlointr(), dliintr(), latintr(), bscintr();
-  #ifdef       __mips
-  extern int scsiisr();
-  #endif
---- 252,258 ----
-  };
-  
-  
-! extern int rawintr(), ipintr(), nsintr(), dnetintr(), dlointr(), dliintr(), latintr(), bscintr(), pppintr();
-  #ifdef       __mips
-  extern int scsiisr();
-  #endif
-***************
-*** 289,294 ****
---- 290,298 ----
-          {NETISR_SCSI,scsiisr},
-  #endif /* NSCSI > 0 || NSII > 0 || NASC > 0 */
-  #endif       /* __mips */
-+ #if NPPP > 0
-+      {NETISR_PPP,pppintr},
-+ #endif /* NPPP */
-  
-       {-1     ,0}
-  };
-*** /usr/sys/data/pseudo_data.c.orig   Sat Sep 19 06:20:31 1992
---- /usr/sys/data/pseudo_data.c        Fri Dec  9 09:32:23 1994
-***************
-*** 25,30 ****
---- 25,35 ----
-  
-  #endif /* NSL > 0 */
-  
-+ #include "ppp.h"
-+ #if NPPP > 0
-+        pppattach();
-+ #endif
-+ 
-  return;
-  }
-  
-*** /usr/sys/data/tty_conf_data.c.orig Sat Sep 19 06:19:21 1992
---- /usr/sys/data/tty_conf_data.c      Fri Dec  9 09:32:38 1994
-***************
-*** 83,88 ****
---- 83,94 ----
-  int   slopen(), slclose(), slinput(), sltioctl(), slstart();
-  #endif
-  
-+ #include "ppp.h"
-+ #if NPPP > 0
-+ int   pppopen(), pppclose(), pppread(), pppwrite(), pppinput();
-+ int   ppptioctl(), pppstart();
-+ #endif
-+ 
-  #ifdef BINARY
-  
-  extern       int     nldisp;
-***************
-*** 141,146 ****
---- 147,161 ----
-       nodev, nodev, nodev, nodev, nodev,
-       nodev, nodev, nodev, nodev, nodev,
-  #endif
-+ 
-+ #if NPPP > 0   
-+        pppopen, pppclose, pppread, pppwrite, ppptioctl,
-+        pppinput, nodev, nulldev, pppstart, nulldev,   /* 9 - PPPDISC */
-+ #else
-+        nodev, nodev, nodev, nodev, nodev,
-+        nodev, nodev, nodev, nodev, nodev,
-+ #endif
-+ 
-  
-  };
-  
-*** /usr/sys/conf/mips/files.mips.orig Sat Sep 11 06:09:28 1993
---- /usr/sys/conf/mips/files.mips      Fri Dec  9 09:32:01 1994
-***************
-*** 114,120 ****
-  io/netif/if_ln_copy.s                optional ln Binary 
-  io/netif/if_ne.c             optional ne device-driver Binary
-  io/netif/if_sl.c             optional sl device-driver Binary Unsupported
-! io/netif/slcompress.c                optional sl device-driver Binary Unsupported
-  io/netif/if_qe.c             optional qe device-driver Binary
-  io/netif/if_uba.c            optional inet device-driver Binary
-  io/netif/if_ni.c             optional bvpni device-driver Binary
---- 114,125 ----
-  io/netif/if_ln_copy.s                optional ln Binary 
-  io/netif/if_ne.c             optional ne device-driver Binary
-  io/netif/if_sl.c             optional sl device-driver Binary Unsupported
-! io/netif/if_ppp.c            optional ppp device-driver Notbinary
-! io/netif/ppp_tty.c           optional ppp device-driver Notbinary
-! io/netif/bsd-comp.c          optional ppp device-driver Notbinary
-! io/netif/ppp-deflate.c               optional ppp device-driver Notbinary
-! io/netif/zlib.c                      optional ppp device-driver Notbinary
-! io/netif/slcompress.c                optional sl or ppp device-driver Notbinary
-  io/netif/if_qe.c             optional qe device-driver Binary
-  io/netif/if_uba.c            optional inet device-driver Binary
-  io/netif/if_ni.c             optional bvpni device-driver Binary
diff --git a/ultrix/ppp-deflate.c b/ultrix/ppp-deflate.c
deleted file mode 100644 (file)
index 8c1a721..0000000
+++ /dev/null
@@ -1,697 +0,0 @@
-/*     $Id: ppp-deflate.c,v 1.6 2002/12/06 09:49:16 paulus Exp $       */
-
-/*
- * ppp_deflate.c - interface the zlib procedures for Deflate compression
- * and decompression (as used by gzip) to the PPP code.
- * This version is for use with mbufs on BSD-derived systems.
- *
- * Copyright (c) 1994 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 "../h/param.h"
-#include "../h/types.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../net/net/if.h"
-#include "ppp_defs.h"
-#include "zlib.h"
-
-#define PACKETPTR      struct mbuf *
-#include "ppp-comp.h"
-
-#if DO_DEFLATE
-
-/*
- * State for a Deflate (de)compressor.
- */
-struct deflate_state {
-    int                seqno;
-    int                w_size;
-    int                unit;
-    int                hdrlen;
-    int                mru;
-    int                debug;
-    z_stream   strm;
-    struct compstat stats;
-};
-
-#define DEFLATE_OVHD   2               /* Deflate overhead/packet */
-
-static void    *zalloc __P((void *, u_int items, u_int size));
-static void    zfree __P((void *, void *ptr));
-static void    *z_comp_alloc __P((u_char *options, int opt_len));
-static void    *z_decomp_alloc __P((u_char *options, int opt_len));
-static void    z_comp_free __P((void *state));
-static void    z_decomp_free __P((void *state));
-static int     z_comp_init __P((void *state, u_char *options, int opt_len,
-                                int unit, int hdrlen, int debug));
-static int     z_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static int     z_compress __P((void *state, struct mbuf **mret,
-                                 struct mbuf *mp, int slen, int maxolen));
-static void    z_incomp __P((void *state, struct mbuf *dmsg));
-static int     z_decompress __P((void *state, struct mbuf *cmp,
-                                   struct mbuf **dmpp));
-static void    z_comp_reset __P((void *state));
-static void    z_decomp_reset __P((void *state));
-static void    z_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to if_ppp.c.
- */
-struct compressor ppp_deflate = {
-    CI_DEFLATE,                        /* compress_proto */
-    z_comp_alloc,              /* comp_alloc */
-    z_comp_free,               /* comp_free */
-    z_comp_init,               /* comp_init */
-    z_comp_reset,              /* comp_reset */
-    z_compress,                        /* compress */
-    z_comp_stats,              /* comp_stat */
-    z_decomp_alloc,            /* decomp_alloc */
-    z_decomp_free,             /* decomp_free */
-    z_decomp_init,             /* decomp_init */
-    z_decomp_reset,            /* decomp_reset */
-    z_decompress,              /* decompress */
-    z_incomp,                  /* incomp */
-    z_comp_stats,              /* decomp_stat */
-};
-
-struct compressor ppp_deflate_draft = {
-    CI_DEFLATE_DRAFT,          /* compress_proto */
-    z_comp_alloc,              /* comp_alloc */
-    z_comp_free,               /* comp_free */
-    z_comp_init,               /* comp_init */
-    z_comp_reset,              /* comp_reset */
-    z_compress,                        /* compress */
-    z_comp_stats,              /* comp_stat */
-    z_decomp_alloc,            /* decomp_alloc */
-    z_decomp_free,             /* decomp_free */
-    z_decomp_init,             /* decomp_init */
-    z_decomp_reset,            /* decomp_reset */
-    z_decompress,              /* decompress */
-    z_incomp,                  /* incomp */
-    z_comp_stats,              /* decomp_stat */
-};
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m) ((m)->m_off > MMAXOFF)
-
-#define M_TRAILINGSPACE(m) \
-       ((M_IS_CLUSTER(m) ? (u_int)(m)->m_clptr + M_CLUSTERSZ : MSIZE) \
-        - ((m)->m_off + (m)->m_len))
-
-/*
- * Space allocation and freeing routines for use by zlib routines.
- */
-void *
-zalloc(notused, items, size)
-    void *notused;
-    u_int items, size;
-{
-    void *ptr;
-
-    KM_ALLOC(ptr, void *, items * size, KM_DEVBUF, KM_NOARG);
-    return ptr;
-}
-
-void
-zfree(notused, ptr)
-    void *notused;
-    void *ptr;
-{
-    KM_FREE(ptr, KM_DEVBUF);
-}
-
-/*
- * Allocate space for a compressor.
- */
-static void *
-z_comp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    struct deflate_state *state;
-    int w_size;
-
-    if (opt_len != CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return NULL;
-    w_size = DEFLATE_SIZE(options[2]);
-    if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-       return NULL;
-
-    KM_ALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
-            KM_DEVBUF, KM_NOARG);
-    if (state == NULL)
-       return NULL;
-    bzero(state, sizeof(struct deflate_state));
-
-    state->strm.next_in = NULL;
-    state->strm.zalloc = (alloc_func) zalloc;
-    state->strm.zfree = (free_func) zfree;
-    if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
-                    -w_size, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
-       KM_FREE(state, KM_DEVBUF);
-       return NULL;
-    }
-
-    state->w_size = w_size;
-    bzero(&state->stats, sizeof(state->stats));
-    return (void *) state;
-}
-
-static void
-z_comp_free(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    deflateEnd(&state->strm);
-    KM_FREE(state, KM_DEVBUF);
-}
-
-static int
-z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
-    void *arg;
-    u_char *options;
-    int opt_len, unit, hdrlen, debug;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    if (opt_len < CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || DEFLATE_SIZE(options[2]) != state->w_size
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return 0;
-
-    state->seqno = 0;
-    state->unit = unit;
-    state->hdrlen = hdrlen;
-    state->debug = debug;
-
-    deflateReset(&state->strm);
-
-    return 1;
-}
-
-static void
-z_comp_reset(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    state->seqno = 0;
-    deflateReset(&state->strm);
-}
-
-int
-z_compress(arg, mret, mp, orig_len, maxolen)
-    void *arg;
-    struct mbuf **mret;                /* compressed packet (out) */
-    struct mbuf *mp;           /* uncompressed packet (in) */
-    int orig_len, maxolen;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_char *rptr, *wptr;
-    int proto, olen, wspace, r, flush;
-    struct mbuf *m, *clp;
-
-    /*
-     * Check that the protocol is in the range we handle.
-     */
-    rptr = mtod(mp, u_char *);
-    proto = PPP_PROTOCOL(rptr);
-    if (proto > 0x3fff || proto == 0xfd || proto == 0xfb) {
-       *mret = NULL;
-       return orig_len;
-    }
-
-    /* Allocate one mbuf initially. */
-    if (maxolen > orig_len)
-       maxolen = orig_len;
-    MGET(m, M_DONTWAIT, MT_DATA);
-    *mret = m;
-    if (m != NULL) {
-       if (maxolen + state->hdrlen > MLEN) {
-           /* MCLGET is not a single statement!!! */
-           MCLGET(m, clp)
-       }
-       m->m_len = 0;
-       wspace = M_TRAILINGSPACE(m);
-       if (state->hdrlen > 0 && state->hdrlen + PPP_HDRLEN + 2 < wspace) {
-           m->m_off += state->hdrlen;
-           wspace -= state->hdrlen;
-       }
-       wptr = mtod(m, u_char *);
-
-       /*
-        * Copy over the PPP header and store the 2-byte sequence number.
-        */
-       wptr[0] = PPP_ADDRESS(rptr);
-       wptr[1] = PPP_CONTROL(rptr);
-       wptr[2] = PPP_COMP >> 8;
-       wptr[3] = PPP_COMP;
-       wptr += PPP_HDRLEN;
-       wptr[0] = state->seqno >> 8;
-       wptr[1] = state->seqno;
-       wptr += 2;
-       state->strm.next_out = wptr;
-       state->strm.avail_out = wspace - (PPP_HDRLEN + 2);
-    } else {
-       state->strm.next_out = NULL;
-       state->strm.avail_out = 1000000;
-       wptr = NULL;
-       wspace = 0;
-    }
-    ++state->seqno;
-
-    rptr += (proto > 0xff)? 2: 3;      /* skip 1st proto byte if 0 */
-    state->strm.next_in = rptr;
-    state->strm.avail_in = mtod(mp, u_char *) + mp->m_len - rptr;
-    mp = mp->m_next;
-    flush = (mp == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
-    olen = 0;
-    for (;;) {
-       r = deflate(&state->strm, flush);
-       if (r != Z_OK) {
-           printf("z_compress: deflate returned %d (%s)\n",
-                  r, (state->strm.msg? state->strm.msg: ""));
-           break;
-       }
-       if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
-           break;              /* all done */
-       if (state->strm.avail_in == 0 && mp != NULL) {
-           state->strm.next_in = mtod(mp, u_char *);
-           state->strm.avail_in = mp->m_len;
-           mp = mp->m_next;
-           if (mp == NULL)
-               flush = Z_PACKET_FLUSH;
-       }
-       if (state->strm.avail_out == 0) {
-           if (m != NULL) {
-               m->m_len = wspace;
-               olen += wspace;
-               MGET(m->m_next, M_DONTWAIT, MT_DATA);
-               m = m->m_next;
-               if (m != NULL) {
-                   if (maxolen - olen > MLEN) {
-                       MCLGET(m, clp)
-                   }
-                   m->m_len = 0;
-                   state->strm.next_out = mtod(m, u_char *);
-                   state->strm.avail_out = wspace = M_TRAILINGSPACE(m);
-               }
-           }
-           if (m == NULL) {
-               state->strm.next_out = NULL;
-               state->strm.avail_out = 1000000;
-           }
-       }
-    }
-    if (m != NULL)
-       olen += (m->m_len = wspace - state->strm.avail_out);
-
-    /*
-     * See if we managed to reduce the size of the packet.
-     * If the compressor just gave us a single zero byte, it means
-     * the packet was incompressible.
-     */
-    if (m != NULL && olen < orig_len
-       && !(olen == PPP_HDRLEN + 3 && *wptr == 0)) {
-       state->stats.comp_bytes += olen;
-       state->stats.comp_packets++;
-    } else {
-       if (*mret != NULL) {
-           m_freem(*mret);
-           *mret = NULL;
-       }
-       state->stats.inc_bytes += orig_len;
-       state->stats.inc_packets++;
-       olen = orig_len;
-    }
-    state->stats.unc_bytes += orig_len;
-    state->stats.unc_packets++;
-
-    return olen;
-}
-
-static void
-z_comp_stats(arg, stats)
-    void *arg;
-    struct compstat *stats;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_int out;
-
-    *stats = state->stats;
-    stats->ratio = stats->unc_bytes;
-    out = stats->comp_bytes + stats->inc_bytes;
-    if (stats->ratio <= 0x7ffffff)
-       stats->ratio <<= 8;
-    else
-       out >>= 8;
-    if (out != 0)
-       stats->ratio /= out;
-}
-
-/*
- * Allocate space for a decompressor.
- */
-static void *
-z_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
-{
-    struct deflate_state *state;
-    int w_size;
-
-    if (opt_len != CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return NULL;
-    w_size = DEFLATE_SIZE(options[2]);
-    if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
-       return NULL;
-
-    KM_ALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
-            KM_DEVBUF, KM_NOARG);
-    if (state == NULL)
-       return NULL;
-    bzero(state, sizeof(struct deflate_state));
-
-    state->strm.next_out = NULL;
-    state->strm.zalloc = (alloc_func) zalloc;
-    state->strm.zfree = (free_func) zfree;
-    if (inflateInit2(&state->strm, -w_size) != Z_OK) {
-       KM_FREE(state, KM_DEVBUF);
-       return NULL;
-    }
-
-    state->w_size = w_size;
-    bzero(&state->stats, sizeof(state->stats));
-    return (void *) state;
-}
-
-static void
-z_decomp_free(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    inflateEnd(&state->strm);
-    KM_FREE(state, KM_DEVBUF);
-}
-
-static int
-z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
-    void *arg;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    if (opt_len < CILEN_DEFLATE
-       || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
-       || options[1] != CILEN_DEFLATE
-       || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
-       || DEFLATE_SIZE(options[2]) != state->w_size
-       || options[3] != DEFLATE_CHK_SEQUENCE)
-       return 0;
-
-    state->seqno = 0;
-    state->unit = unit;
-    state->hdrlen = hdrlen;
-    state->debug = debug;
-    state->mru = mru;
-
-    inflateReset(&state->strm);
-
-    return 1;
-}
-
-static void
-z_decomp_reset(arg)
-    void *arg;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-
-    state->seqno = 0;
-    inflateReset(&state->strm);
-}
-
-/*
- * Decompress a Deflate-compressed packet.
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression.  For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-int
-z_decompress(arg, mi, mop)
-    void *arg;
-    struct mbuf *mi, **mop;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    struct mbuf *mo, *mo_head, *clp;
-    u_char *rptr, *wptr;
-    int rlen, olen, ospace;
-    int seq, i, flush, r, decode_proto;
-    u_char hdr[PPP_HDRLEN + DEFLATE_OVHD];
-
-    *mop = NULL;
-    rptr = mtod(mi, u_char *);
-    rlen = mi->m_len;
-    for (i = 0; i < PPP_HDRLEN + DEFLATE_OVHD; ++i) {
-       while (rlen <= 0) {
-           mi = mi->m_next;
-           if (mi == NULL)
-               return DECOMP_ERROR;
-           rptr = mtod(mi, u_char *);
-           rlen = mi->m_len;
-       }
-       hdr[i] = *rptr++;
-       --rlen;
-    }
-
-    /* Check the sequence number. */
-    seq = (hdr[PPP_HDRLEN] << 8) + hdr[PPP_HDRLEN+1];
-    if (seq != state->seqno) {
-       if (state->debug)
-           printf("z_decompress%d: bad seq # %d, expected %d\n",
-                  state->unit, seq, state->seqno);
-       return DECOMP_ERROR;
-    }
-    ++state->seqno;
-
-    /* Allocate an output mbuf. */
-    MGET(mo, M_DONTWAIT, MT_DATA);
-    if (mo == NULL)
-       return DECOMP_ERROR;
-    mo_head = mo;
-    mo->m_next = NULL;
-    MCLGET(mo, clp)
-    mo->m_len = 0;
-    ospace = M_TRAILINGSPACE(mo);
-    if (state->hdrlen > 0 && state->hdrlen + PPP_HDRLEN < ospace) {
-       mo->m_off += state->hdrlen;
-       ospace -= state->hdrlen;
-    }
-
-    /*
-     * Fill in the first part of the PPP header.  The protocol field
-     * comes from the decompressed data.
-     */
-    wptr = mtod(mo, u_char *);
-    wptr[0] = PPP_ADDRESS(hdr);
-    wptr[1] = PPP_CONTROL(hdr);
-    wptr[2] = 0;
-
-    /*
-     * Set up to call inflate.  We set avail_out to 1 initially so we can
-     * look at the first byte of the output and decide whether we have
-     * a 1-byte or 2-byte protocol field.
-     */
-    state->strm.next_in = rptr;
-    state->strm.avail_in = rlen;
-    mi = mi->m_next;
-    flush = (mi == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
-    rlen += PPP_HDRLEN + DEFLATE_OVHD;
-    state->strm.next_out = wptr + 3;
-    state->strm.avail_out = 1;
-    decode_proto = 1;
-    olen = PPP_HDRLEN;
-
-    /*
-     * Call inflate, supplying more input or output as needed.
-     */
-    for (;;) {
-       r = inflate(&state->strm, flush);
-       if (r != Z_OK) {
-           if (state->debug)
-               printf("z_decompress%d: inflate returned %d (%s)\n",
-                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-           m_freem(mo_head);
-           return DECOMP_FATALERROR;
-       }
-       if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
-           break;              /* all done */
-       if (state->strm.avail_in == 0 && mi != NULL) {
-           state->strm.next_in = mtod(mi, u_char *);
-           state->strm.avail_in = mi->m_len;
-           rlen += mi->m_len;
-           mi = mi->m_next;
-           if (mi == NULL)
-               flush = Z_PACKET_FLUSH;
-       }
-       if (state->strm.avail_out == 0) {
-           if (decode_proto) {
-               state->strm.avail_out = ospace - PPP_HDRLEN;
-               if ((wptr[3] & 1) == 0) {
-                   /* 2-byte protocol field */
-                   wptr[2] = wptr[3];
-                   --state->strm.next_out;
-                   ++state->strm.avail_out;
-                   --olen;
-               }
-               decode_proto = 0;
-           } else {
-               mo->m_len = ospace;
-               olen += ospace;
-               MGET(mo->m_next, M_DONTWAIT, MT_DATA);
-               mo = mo->m_next;
-               if (mo == NULL) {
-                   m_freem(mo_head);
-                   return DECOMP_ERROR;
-               }
-               MCLGET(mo, clp)
-               mo->m_len = 0;
-               state->strm.next_out = mtod(mo, u_char *);
-               state->strm.avail_out = ospace = M_TRAILINGSPACE(mo);
-           }
-       }
-    }
-    if (decode_proto) {
-       m_freem(mo_head);
-       return DECOMP_ERROR;
-    }
-    olen += (mo->m_len = ospace - state->strm.avail_out);
-
-    state->stats.unc_bytes += olen;
-    state->stats.unc_packets++;
-    state->stats.comp_bytes += rlen;
-    state->stats.comp_packets++;
-
-    *mop = mo_head;
-    return DECOMP_OK;
-}
-
-/*
- * Incompressible data has arrived - add it to the history.
- */
-static void
-z_incomp(arg, mi)
-    void *arg;
-    struct mbuf *mi;
-{
-    struct deflate_state *state = (struct deflate_state *) arg;
-    u_char *rptr;
-    int rlen, proto, r;
-
-    /*
-     * Check that the protocol is one we handle.
-     */
-    rptr = mtod(mi, u_char *);
-    proto = PPP_PROTOCOL(rptr);
-    if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
-       return;
-
-    ++state->seqno;
-
-    /*
-     * Iterate through the mbufs, adding the characters in them
-     * to the decompressor's history.  For the first mbuf, we start
-     * at the either the 1st or 2nd byte of the protocol field,
-     * depending on whether the protocol value is compressible.
-     */
-    rlen = mi->m_len;
-    state->strm.next_in = rptr + 3;
-    state->strm.avail_in = rlen - 3;
-    if (proto > 0xff) {
-       --state->strm.next_in;
-       ++state->strm.avail_in;
-    }
-    for (;;) {
-       r = inflateIncomp(&state->strm);
-       if (r != Z_OK) {
-           /* gak! */
-           if (state->debug) {
-               printf("z_incomp%d: inflateIncomp returned %d (%s)\n",
-                      state->unit, r, (state->strm.msg? state->strm.msg: ""));
-           }
-           return;
-       }
-       mi = mi->m_next;
-       if (mi == NULL)
-           break;
-       state->strm.next_in = mtod(mi, u_char *);
-       state->strm.avail_in = mi->m_len;
-       rlen += mi->m_len;
-    }
-
-    /*
-     * Update stats.
-     */
-    state->stats.inc_bytes += rlen;
-    state->stats.inc_packets++;
-    state->stats.unc_bytes += rlen;
-    state->stats.unc_packets++;
-}
-
-#endif /* DO_DEFLATE */
diff --git a/ultrix/ppp_tty.c b/ultrix/ppp_tty.c
deleted file mode 100644 (file)
index 49f8316..0000000
+++ /dev/null
@@ -1,1073 +0,0 @@
-/*
- * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
- *            tty devices.
- *
- * 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.
- *
- * Drew D. Perkins
- * Carnegie Mellon University
- * 4910 Forbes Ave.
- * Pittsburgh, PA 15213
- * (412) 268-8576
- * ddp@andrew.cmu.edu
- *
- * Based on:
- *     @(#)if_sl.c     7.6.1.2 (Berkeley) 2/15/89
- *
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Serial Line interface
- *
- * Rick Adams
- * Center for Seismic Studies
- * 1300 N 17th Street, Suite 1450
- * Arlington, Virginia 22209
- * (703)276-7900
- * rick@seismo.ARPA
- * seismo!rick
- *
- * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
- * Converted to 4.3BSD Beta by Chris Torek.
- * Other changes made at Berkeley, based in part on code by Kirk Smith.
- *
- * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@cayman.com)
- * Added VJ tcp header compression; more unified ioctls
- *
- * Extensively modified by Paul Mackerras (paulus@cs.anu.edu.au).
- * Cleaned up a lot of the mbuf-related code to fix bugs that
- * caused system crashes and packet corruption.  Changed pppstart
- * so that it doesn't just give up with a "collision" if the whole
- * packet doesn't fit in the output ring buffer.
- *
- * Added priority queueing for interactive IP packets, following
- * the model of if_sl.c, plus hooks for bpf.
- * Paul Mackerras (paulus@cs.anu.edu.au).
- *
- * Ultrix port by Per Sundstrom <sundstrom@stkhlm.enet.dec.com>,
- * Robert Olsson <robert@robur.slu.se> and Paul Mackerras.
- */
-
-/* $Id: ppp_tty.c,v 1.9 2002/12/06 09:49:16 paulus Exp $ */
-/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
-/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
-
-#include "ppp.h"
-#if NPPP > 0
-
-#define VJC
-#define PPP_COMPRESS
-
-#include "../h/param.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/mbuf.h"
-#include "../h/buf.h"
-#include "../h/socket.h"
-#include "../h/ioctl.h"
-#include "../h/file.h"
-#include "../h/tty.h"
-#include "../h/kernel.h"
-#include "../h/conf.h"
-#include "../h/uio.h"
-#include "../h/systm.h"
-
-#include "../net/net/if.h"
-#include "ppp_defs.h"
-
-#ifdef VJC
-#include "../net/netinet/in.h"
-#include "../net/netinet/in_systm.h"
-#include "../net/netinet/ip.h"
-#include "slcompress.h"
-#endif
-
-#include "if_ppp.h"
-#include "if_pppvar.h"
-
-int    pppopen __P((dev_t dev, struct tty *tp));
-int    pppclose __P((struct tty *tp, int flag));
-int    pppread __P((struct tty *tp, struct uio *uio, int flag));
-int    pppwrite __P((struct tty *tp, struct uio *uio, int flag));
-int    ppptioctl __P((struct tty *tp, int cmd, caddr_t data, int flag));
-int    pppinput __P((int c, struct tty *tp));
-int    pppstart __P((struct tty *tp));
-
-static u_short pppfcs __P((u_short fcs, u_char *cp, int len));
-static void    pppasyncstart __P((struct ppp_softc *));
-static void    pppasyncctlp __P((struct ppp_softc *));
-static void    pppasyncrelinq __P((struct ppp_softc *));
-static void    ppp_timeout __P((void *));
-static void    pppgetm __P((struct ppp_softc *sc));
-static void    pppdumpb __P((u_char *b, int l));
-static void    ppplogchar __P((struct ppp_softc *, int));
-
-/*
- * Some useful mbuf macros not in mbuf.h.
- */
-#define M_IS_CLUSTER(m) ((m)->m_off > MMAXOFF)
-
-#define M_TRAILINGSPACE(m) \
-       ((M_IS_CLUSTER(m) ? (u_int)(m)->m_clptr + M_CLUSTERSZ : MSIZE) \
-        - ((m)->m_off + (m)->m_len))
-
-#define M_OFFSTART(m)  \
-       (M_IS_CLUSTER(m) ? (u_int)(m)->m_clptr : MMINOFF)
-
-#define M_DATASIZE(m)  \
-       (M_IS_CLUSTER(m) ? M_CLUSTERSZ : MLEN)
-
-/*
- * Does c need to be escaped?
- */
-#define ESCAPE_P(c)    (sc->sc_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F)))
-
-/*
- * Procedures for using an async tty interface for PPP.
- */
-
-/*
- * This is an Ultrix kernel, we've got clists.
- */
-#define CCOUNT(q)      ((q)->c_cc)
-
-#define t_sc           T_LINEP
-#define PPP_LOWAT      100     /* Process more output when < LOWAT on queue */
-#define        PPP_HIWAT       400     /* Don't start a new packet if HIWAT on que */
-
-/*
- * Line specific open routine for async tty devices.
- * Attach the given tty to the first available ppp unit.
- * Called from device open routine or ttioctl.
- */
-/* ARGSUSED */
-int
-pppopen(dev, tp)
-    dev_t dev;
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    int error, s;
-    struct proc *p = u.u_procp;
-
-    if (!suser())
-       return EPERM;
-
-    s = spltty();
-
-    if (tp->t_line == PPPDISC) {
-       sc = (struct ppp_softc *) tp->t_sc;
-       if (sc != NULL && sc->sc_devp == (void *) tp) {
-           splx(s);
-           return (0);
-       }
-    }
-
-    if ((sc = pppalloc(p->p_pid)) == NULL) {
-       splx(s);
-       return ENXIO;
-    }
-
-    if (sc->sc_relinq)
-       (*sc->sc_relinq)(sc);   /* get previous owner to relinquish the unit */
-
-    sc->sc_ilen = 0;
-    sc->sc_m = NULL;
-    bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-    sc->sc_asyncmap[0] = 0xffffffff;
-    sc->sc_asyncmap[3] = 0x60000000;
-    sc->sc_rasyncmap = 0;
-    sc->sc_devp = (void *) tp;
-    sc->sc_start = pppasyncstart;
-    sc->sc_ctlp = pppasyncctlp;
-    sc->sc_relinq = pppasyncrelinq;
-    sc->sc_outm = NULL;
-    pppgetm(sc);
-    sc->sc_if.if_flags |= IFF_RUNNING;
-
-    tp->t_sc = (caddr_t) sc;
-    ttyflush(tp, FREAD | FWRITE);
-
-    splx(s);
-    return (0);
-}
-
-/*
- * Line specific close routine, called from device close routine
- * and from ttioctl.
- * Detach the tty from the ppp unit.
- * Mimics part of ttyclose().
- */
-int
-pppclose(tp, flag)
-    struct tty *tp;
-    int flag;
-{
-    register struct ppp_softc *sc;
-    int s;
-
-    s = spltty();
-    ttyflush(tp, FREAD|FWRITE);
-    tp->t_line = 0;
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc != NULL) {
-       tp->t_sc = NULL;
-       if (tp == (struct tty *) sc->sc_devp) {
-           pppasyncrelinq(sc);
-           pppdealloc(sc);
-       }
-    }
-    splx(s);
-    return 0;
-}
-
-/*
- * Relinquish the interface unit to another device.
- */
-static void
-pppasyncrelinq(sc)
-    struct ppp_softc *sc;
-{
-    int s;
-
-    s = spltty();
-    if (sc->sc_outm) {
-       m_freem(sc->sc_outm);
-       sc->sc_outm = NULL;
-    }
-    if (sc->sc_m) {
-       m_freem(sc->sc_m);
-       sc->sc_m = NULL;
-    }
-    if (sc->sc_flags & SC_TIMEOUT) {
-       untimeout(ppp_timeout, (void *) sc);
-       sc->sc_flags &= ~SC_TIMEOUT;
-    }
-    splx(s);
-}
-
-/*
- * Line specific (tty) read routine.
- */
-int
-pppread(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0;
-    register int s;
-    int error = 0;
-
-    if (sc == NULL)
-       return 0;
-    /*
-     * Loop waiting for input, checking that nothing disasterous
-     * happens in the meantime.
-     */
-    s = spltty();
-    for (;;) {
-       if (tp != (struct tty *) sc->sc_devp || tp->t_line != PPPDISC) {
-           splx(s);
-           return 0;
-       }
-       if (sc->sc_inq.ifq_head != NULL)
-           break;
-       if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0
-           && (tp->t_state & TS_ISOPEN)) {
-           splx(s);
-           return 0;           /* end of file */
-       }
-       if (tp->t_state & (TS_ASYNC | TS_NBIO)) {
-           splx(s);
-           return (EWOULDBLOCK);
-       }
-       sleep((caddr_t) &tp->t_rawq, TTIPRI);
-    }
-
-    /* Pull place-holder byte out of canonical queue */
-    getc(&tp->t_canq);
-
-    /* Get the packet from the input queue */
-    IF_DEQUEUE(&sc->sc_inq, m0);
-    splx(s);
-
-    for (m = m0; m && uio->uio_resid; m = m->m_next)
-       if (error = uiomove(mtod(m, u_char *), m->m_len, UIO_READ, uio))
-           break;
-    m_freem(m0);
-    return (error);
-}
-
-/*
- * Line specific (tty) write routine.
- */
-int
-pppwrite(tp, uio, flag)
-    register struct tty *tp;
-    struct uio *uio;
-    int flag;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
-    struct mbuf *m, *m0, **mp, *p;
-    struct sockaddr dst;
-    int len, error;
-
-    if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       return 0;               /* wrote 0 bytes */
-    if (tp->t_line != PPPDISC)
-       return (EINVAL);
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return EIO;
-    if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HDRLEN ||
-       uio->uio_resid < PPP_HDRLEN)
-       return (EMSGSIZE);
-    for (mp = &m0; uio->uio_resid; mp = &m->m_next) {
-       MGET(m, M_WAIT, MT_DATA);
-       if ((*mp = m) == NULL) {
-           m_freem(m0);
-           return (ENOBUFS);
-       }
-       if (uio->uio_resid >= CLBYTES / 2) {
-           MCLGET(m, p);
-       } else
-           m->m_len = MLEN;
-       len = MIN(m->m_len, uio->uio_resid);
-       if (error = uiomove(mtod(m, u_char *), len, UIO_WRITE, uio)) {
-           m_freem(m0);
-           return (error);
-       }
-       m->m_len = len;
-    }
-    dst.sa_family = AF_UNSPEC;
-    bcopy(mtod(m0, caddr_t), dst.sa_data, PPP_HDRLEN);
-    m0->m_off += PPP_HDRLEN;
-    m0->m_len -= PPP_HDRLEN;
-    return (pppoutput(&sc->sc_if, m0, &dst));
-}
-
-/*
- * Line specific (tty) ioctl routine.
- * This discipline requires that tty device drivers call
- * the line specific l_ioctl routine from their ioctl routines.
- */
-/* ARGSUSED */
-int
-ppptioctl(tp, cmd, data, flag)
-    struct tty *tp;
-    caddr_t data;
-    int cmd, flag;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-    int error, s;
-
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return -1;
-
-    error = 0;
-    switch (cmd) {
-    case PPPIOCSASYNCMAP:
-       if (!suser())
-           return EPERM;
-       sc->sc_asyncmap[0] = *(u_int *)data;
-       break;
-
-    case PPPIOCGASYNCMAP:
-       *(u_int *)data = sc->sc_asyncmap[0];
-       break;
-
-    case PPPIOCSRASYNCMAP:
-       if (!suser())
-           return EPERM;
-       sc->sc_rasyncmap = *(u_int *)data;
-       break;
-
-    case PPPIOCGRASYNCMAP:
-       *(u_int *)data = sc->sc_rasyncmap;
-       break;
-
-    case PPPIOCSXASYNCMAP:
-       if (!suser())
-           return EPERM;
-       s = spltty();
-       bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
-       sc->sc_asyncmap[1] = 0;             /* mustn't escape 0x20 - 0x3f */
-       sc->sc_asyncmap[2] &= ~0x40000000;  /* mustn't escape 0x5e */
-       sc->sc_asyncmap[3] |= 0x60000000;   /* must escape 0x7d, 0x7e */
-       splx(s);
-       break;
-
-    case PPPIOCGXASYNCMAP:
-       bcopy(sc->sc_asyncmap, data, sizeof(sc->sc_asyncmap));
-       break;
-
-    default:
-       error = pppioctl(sc, cmd, data, flag);
-       if (error == 0 && cmd == PPPIOCSMRU)
-           pppgetm(sc);
-    }
-
-    return error;
-}
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static u_short fcstab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-/*
- * Calculate a new FCS given the current FCS and the new data.
- */
-static u_short
-pppfcs(fcs, cp, len)
-    register u_short fcs;
-    register u_char *cp;
-    register int len;
-{
-    while (len--)
-       fcs = PPP_FCS(fcs, *cp++);
-    return (fcs);
-}
-
-/*
- * This gets called at splnet from if_ppp.c at various times
- * when there is data ready to be sent.
- */
-static void
-pppasyncstart(sc)
-    register struct ppp_softc *sc;
-{
-    register struct tty *tp = (struct tty *) sc->sc_devp;
-    register struct mbuf *m;
-    register int len;
-    register u_char *start, *stop, *cp;
-    int n, ndone, done, idle;
-    struct mbuf *m2;
-    int s;
-
-    idle = 0;
-    while (CCOUNT(&tp->t_outq) < PPP_HIWAT) {
-       /*
-        * See if we have an existing packet partly sent.
-        * If not, get a new packet and start sending it.
-        */
-       m = sc->sc_outm;
-       if (m == NULL) {
-           /*
-            * Get another packet to be sent.
-            */
-           m = ppp_dequeue(sc);
-           if (m == NULL) {
-               idle = 1;
-               break;
-           }
-
-           /*
-            * The extra PPP_FLAG will start up a new packet, and thus
-            * will flush any accumulated garbage.  We do this whenever
-            * the line may have been idle for some time.
-            */
-           if (CCOUNT(&tp->t_outq) == 0) {
-               ++sc->sc_stats.ppp_obytes;
-               (void) putc(PPP_FLAG, &tp->t_outq);
-           }
-
-           /* Calculate the FCS for the first mbuf's worth. */
-           sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
-       }
-
-       for (;;) {
-           start = mtod(m, u_char *);
-           len = m->m_len;
-           stop = start + len;
-           while (len > 0) {
-               /*
-                * Find out how many bytes in the string we can
-                * handle without doing something special.
-                */
-               for (cp = start; cp < stop; cp++)
-                   if (ESCAPE_P(*cp))
-                       break;
-               n = cp - start;
-               if (n) {
-                   ndone = n - b_to_q(start, n, &tp->t_outq);
-                   len -= ndone;
-                   start += ndone;
-                   sc->sc_stats.ppp_obytes += ndone;
-
-                   if (ndone < n)
-                       break;  /* packet doesn't fit */
-               }
-               /*
-                * If there are characters left in the mbuf,
-                * the first one must be special.
-                * Put it out in a different form.
-                */
-               if (len) {
-                   s = spltty();
-                   if (putc(PPP_ESCAPE, &tp->t_outq))
-                       break;
-                   if (putc(*start ^ PPP_TRANS, &tp->t_outq)) {
-                       (void) unputc(&tp->t_outq);
-                       splx(s);
-                       break;
-                   }
-                   splx(s);
-                   sc->sc_stats.ppp_obytes += 2;
-                   start++;
-                   len--;
-               }
-           }
-
-           /*
-            * If we didn't empty this mbuf, remember where we're up to.
-            * If we emptied the last mbuf, try to add the FCS and closing
-            * flag, and if we can't, leave sc_outm pointing to m, but with
-            * m->m_len == 0, to remind us to output the FCS and flag later.
-            */
-           done = len == 0;
-           if (done && m->m_next == NULL) {
-               u_char *p, *q;
-               int c;
-               u_char endseq[8];
-
-               /*
-                * We may have to escape the bytes in the FCS.
-                */
-               p = endseq;
-               c = ~sc->sc_outfcs & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               c = (~sc->sc_outfcs >> 8) & 0xFF;
-               if (ESCAPE_P(c)) {
-                   *p++ = PPP_ESCAPE;
-                   *p++ = c ^ PPP_TRANS;
-               } else
-                   *p++ = c;
-               *p++ = PPP_FLAG;
-
-               /*
-                * Try to output the FCS and flag.  If the bytes
-                * don't all fit, back out.
-                */
-               s = spltty();
-               for (q = endseq; q < p; ++q)
-                   if (putc(*q, &tp->t_outq)) {
-                       done = 0;
-                       for (; q > endseq; --q)
-                           unputc(&tp->t_outq);
-                       break;
-                   }
-               splx(s);
-               if (done)
-                   sc->sc_stats.ppp_obytes += q - endseq;
-           }
-
-           if (!done) {
-               m->m_off += m->m_len - len;
-               m->m_len = len;
-               break;
-           }
-
-           /* Finished with this mbuf; free it and move on. */
-           MFREE(m, m2);
-           m = m2;
-           if (m == NULL) {
-               /* Finished a packet */
-               break;
-           }
-           sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len);
-       }
-
-       /*
-        * If m == NULL, we have finished a packet.
-        * If m != NULL, we've either done as much work this time
-        * as we need to, or else we've filled up the output queue.
-        */
-       sc->sc_outm = m;
-       if (m)
-           break;
-    }
-
-    /* Call pppstart to start output again if necessary. */
-    s = spltty();
-    pppstart(tp);
-
-    /*
-     * This timeout is needed for operation on a pseudo-tty,
-     * because the pty code doesn't call pppstart after it has
-     * drained the t_outq.
-     */
-    if (!idle && (sc->sc_flags & SC_TIMEOUT) == 0) {
-       timeout(ppp_timeout, (void *) sc, 1);
-       sc->sc_flags |= SC_TIMEOUT;
-    }
-
-    splx(s);
-}
-
-/*
- * This gets called when a received packet is placed on
- * the inq, at splnet.
- */
-static void
-pppasyncctlp(sc)
-    struct ppp_softc *sc;
-{
-    struct tty *tp;
-    int s;
-
-    /* Put a placeholder byte in canq for ttselect()/ttnread(). */
-    s = spltty();
-    tp = (struct tty *) sc->sc_devp;
-    putc(0, &tp->t_canq);
-    ttwakeup(tp);
-    splx(s);
-}
-
-/*
- * Start output on async tty interface.  If the transmit queue
- * has drained sufficiently, arrange for pppasyncstart to be
- * called later at splnet.
- * Called at spltty or higher.
- */
-int
-pppstart(tp)
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
-
-    /*
-     * If there is stuff in the output queue, send it now.
-     * We are being called in lieu of ttstart and must do what it would.
-     */
-    if (tp->t_oproc != NULL)
-       (*tp->t_oproc)(tp);
-
-    /*
-     * If the transmit queue has drained and the tty has not hung up
-     * or been disconnected from the ppp unit, then tell if_ppp.c that
-     * we need more output.
-     */
-    if (CCOUNT(&tp->t_outq) < PPP_LOWAT
-       && !((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
-       && sc != NULL && tp == (struct tty *) sc->sc_devp) {
-       ppp_restart(sc);
-    }
-
-    return 0;
-}
-
-/*
- * Timeout routine - try to start some more output.
- */
-static void
-ppp_timeout(x)
-    void *x;
-{
-    struct ppp_softc *sc = (struct ppp_softc *) x;
-    struct tty *tp = (struct tty *) sc->sc_devp;
-    int s;
-
-    s = spltty();
-    sc->sc_flags &= ~SC_TIMEOUT;
-    pppstart(tp);
-    splx(s);
-}
-
-/*
- * Allocate enough mbuf to handle current MRU.
- */
-static void
-pppgetm(sc)
-    register struct ppp_softc *sc;
-{
-    struct mbuf *m, **mp, *p;
-    int len;
-
-    mp = &sc->sc_m;
-    for (len = sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){
-       if ((m = *mp) == NULL) {
-           MGET(m, M_DONTWAIT, MT_DATA);
-           if (m == NULL)
-               break;
-           *mp = m;
-           MCLGET(m, p);
-       }
-       len -= M_DATASIZE(m);
-       mp = &m->m_next;
-    }
-}
-
-/*
- * tty interface receiver interrupt.
- */
-static unsigned paritytab[8] = {
-    0x96696996, 0x69969669, 0x69969669, 0x96696996,
-    0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-
-int
-pppinput(c, tp)
-    int c;
-    register struct tty *tp;
-{
-    register struct ppp_softc *sc;
-    struct mbuf *m;
-    int ilen, s;
-    extern int tk_nin;
-
-    sc = (struct ppp_softc *) tp->t_sc;
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-       return 0;
-
-    ++tk_nin;
-    ++sc->sc_stats.ppp_ibytes;
-
-    c &= 0xff;
-
-    /*
-     * Handle software flow control of output.
-     */
-    if (tp->t_iflag & IXON) {
-       if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != 0) {
-           if ((tp->t_state & TS_TTSTOP) == 0) {
-               tp->t_state |= TS_TTSTOP;
-               (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
-           }
-           return 0;
-       }
-       if (c == tp->t_cc[VSTART] && tp->t_cc[VSTART] != 0) {
-           tp->t_state &= ~TS_TTSTOP;
-           if (tp->t_oproc != NULL)
-               (*tp->t_oproc)(tp);
-           return 0;
-       }
-    }
-
-    s = spltty();
-    if (c & 0x80)
-       sc->sc_flags |= SC_RCV_B7_1;
-    else
-       sc->sc_flags |= SC_RCV_B7_0;
-    if (paritytab[c >> 5] & (1 << (c & 0x1F)))
-       sc->sc_flags |= SC_RCV_ODDP;
-    else
-       sc->sc_flags |= SC_RCV_EVNP;
-    splx(s);
-
-    if (sc->sc_flags & SC_LOG_RAWIN)
-       ppplogchar(sc, c);
-
-    if (c == PPP_FLAG) {
-       ilen = sc->sc_ilen;
-       sc->sc_ilen = 0;
-
-       if (sc->sc_rawin_count > 0) 
-           ppplogchar(sc, -1);
-
-       /*
-        * If SC_ESCAPED is set, then we've seen the packet
-        * abort sequence "}~".
-        */
-       if (sc->sc_flags & (SC_FLUSH | SC_ESCAPED)
-           || (ilen > 0 && sc->sc_fcs != PPP_GOODFCS)) {
-           s = spltty();
-           sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
-           if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: bad fcs %x, pkt len %d\n",
-                          sc->sc_if.if_unit, sc->sc_fcs, ilen);
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-           } else
-               sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
-           splx(s);
-           return 0;
-       }
-
-       if (ilen < PPP_HDRLEN + PPP_FCSLEN) {
-           if (ilen) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: too short (%d)\n", sc->sc_if.if_unit, ilen);
-               s = spltty();
-               sc->sc_if.if_ierrors++;
-               sc->sc_stats.ppp_ierrors++;
-               sc->sc_flags |= SC_PKTLOST;
-               splx(s);
-           }
-           return 0;
-       }
-
-       /*
-        * Remove FCS trailer.  Somewhat painful...
-        */
-       ilen -= 2;
-       if (--sc->sc_mc->m_len == 0) {
-           for (m = sc->sc_m; m->m_next != sc->sc_mc; m = m->m_next)
-               ;
-           sc->sc_mc = m;
-       }
-       sc->sc_mc->m_len--;
-
-       /* excise this mbuf chain */
-       m = sc->sc_m;
-       sc->sc_m = sc->sc_mc->m_next;
-       sc->sc_mc->m_next = NULL;
-
-       ppppktin(sc, m, sc->sc_flags & SC_PKTLOST);
-       if (sc->sc_flags & SC_PKTLOST) {
-           s = spltty();
-           sc->sc_flags &= ~SC_PKTLOST;
-           splx(s);
-       }
-
-       pppgetm(sc);
-       return 0;
-    }
-
-    if (sc->sc_flags & SC_FLUSH) {
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-       return 0;
-    }
-
-    if (c < 0x20 && (sc->sc_rasyncmap & (1 << c)))
-       return 0;
-
-    s = spltty();
-    if (sc->sc_flags & SC_ESCAPED) {
-       sc->sc_flags &= ~SC_ESCAPED;
-       c ^= PPP_TRANS;
-    } else if (c == PPP_ESCAPE) {
-       sc->sc_flags |= SC_ESCAPED;
-       splx(s);
-       return 0;
-    }
-    splx(s);
-
-    /*
-     * Initialize buffer on first octet received.
-     * First octet could be address or protocol (when compressing
-     * address/control).
-     * Second octet is control.
-     * Third octet is first or second (when compressing protocol)
-     * octet of protocol.
-     * Fourth octet is second octet of protocol.
-     */
-    if (sc->sc_ilen == 0) {
-       /* reset the first input mbuf */
-       if (sc->sc_m == NULL) {
-           pppgetm(sc);
-           if (sc->sc_m == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit);
-               goto flush;
-           }
-       }
-       m = sc->sc_m;
-       m->m_len = 0;
-       m->m_off = M_OFFSTART(m);
-       sc->sc_mc = m;
-       sc->sc_mp = mtod(m, char *);
-       sc->sc_fcs = PPP_INITFCS;
-       if (c != PPP_ALLSTATIONS) {
-           if (sc->sc_flags & SC_REJ_COMP_AC) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: garbage received: 0x%x (need 0xFF)\n",
-                          sc->sc_if.if_unit, c);
-               goto flush;
-           }
-           *sc->sc_mp++ = PPP_ALLSTATIONS;
-           *sc->sc_mp++ = PPP_UI;
-           sc->sc_ilen += 2;
-           m->m_len += 2;
-       }
-    }
-    if (sc->sc_ilen == 1 && c != PPP_UI) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: missing UI (0x3), got 0x%x\n",
-                  sc->sc_if.if_unit, c);
-       goto flush;
-    }
-    if (sc->sc_ilen == 2 && (c & 1) == 1) {
-       /* a compressed protocol */
-       *sc->sc_mp++ = 0;
-       sc->sc_ilen++;
-       sc->sc_mc->m_len++;
-    }
-    if (sc->sc_ilen == 3 && (c & 1) == 0) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit,
-                  (sc->sc_mp[-1] << 8) + c);
-       goto flush;
-    }
-
-    /* packet beyond configured mru? */
-    if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) {
-       if (sc->sc_flags & SC_DEBUG)
-           printf("ppp%d: packet too big\n", sc->sc_if.if_unit);
-       goto flush;
-    }
-
-    /* is this mbuf full? */
-    m = sc->sc_mc;
-    if (M_TRAILINGSPACE(m) <= 0) {
-       if (m->m_next == NULL) {
-           pppgetm(sc);
-           if (m->m_next == NULL) {
-               if (sc->sc_flags & SC_DEBUG)
-                   printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit);
-               goto flush;
-           }
-       }
-       sc->sc_mc = m = m->m_next;
-       m->m_len = 0;
-       m->m_off = M_OFFSTART(m);
-       sc->sc_mp = mtod(m, char *);
-    }
-
-    ++m->m_len;
-    *sc->sc_mp++ = c;
-    sc->sc_fcs = PPP_FCS(sc->sc_fcs, c);
-    return 0;
-
- flush:
-    if (!(sc->sc_flags & SC_FLUSH)) {
-       s = spltty();
-       sc->sc_if.if_ierrors++;
-       sc->sc_stats.ppp_ierrors++;
-       sc->sc_flags |= SC_FLUSH;
-       splx(s);
-       if (sc->sc_flags & SC_LOG_FLUSH)
-           ppplogchar(sc, c);
-    }
-    return 0;
-}
-
-#define MAX_DUMP_BYTES 128
-
-static void
-ppplogchar(sc, c)
-    struct ppp_softc *sc;
-    int c;
-{
-    if (c >= 0)
-       sc->sc_rawin[sc->sc_rawin_count++] = c;
-    if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
-       || (c < 0 && sc->sc_rawin_count > 0)) {
-       printf("ppp%d input: ", sc->sc_if.if_unit);
-       pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
-       sc->sc_rawin_count = 0;
-    }
-}
-
-static void
-pppdumpb(b, l)
-    u_char *b;
-    int l;
-{
-    char buf[3*MAX_DUMP_BYTES+4];
-    char *bp = buf;
-    static char digits[] = "0123456789abcdef";
-
-    while (l--) {
-       if (bp >= buf + sizeof(buf) - 3) {
-           *bp++ = '>';
-           break;
-       }
-       *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
-       *bp++ = digits[*b++ & 0xf];
-       *bp++ = ' ';
-    }
-
-    *bp = 0;
-    printf("%s\n", buf);
-}
-
-#endif /* NPPP > 0 */
diff --git a/ultrix/slcompress.c b/ultrix/slcompress.c
deleted file mode 100644 (file)
index 971bdee..0000000
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
- * Routines to compress and uncompess tcp packets (for transmission
- * over low speed serial lines.
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- *     Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- *
- * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au,
- * so that the entire packet being decompressed doesn't have
- * to be in contiguous memory (just the compressed header).
- *
- * $Id: slcompress.c,v 1.4 1997/03/04 03:45:18 paulus Exp $
- */
-
-#include "../h/types.h"
-#include "../h/param.h"
-#include "../h/mbuf.h"
-#include "../net/netinet/in.h"
-#include "../net/netinet/in_systm.h"
-#include "../net/netinet/ip.h"
-#include "../net/netinet/tcp.h"
-
-#include "ppp_defs.h"
-#include "slcompress.h"
-
-#ifndef SL_NO_STATS
-#define INCR(counter) ++comp->counter;
-#else
-#define INCR(counter)
-#endif
-
-#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
-#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
-#ifndef KERNEL
-#define ovbcopy bcopy
-#endif
-
-
-void
-sl_compress_init(comp)
-       struct slcompress *comp;
-{
-       register u_int i;
-       register struct cstate *tstate = comp->tstate;
-
-       bzero((char *)comp, sizeof(*comp));
-       for (i = MAX_STATES - 1; i > 0; --i) {
-               tstate[i].cs_id = i;
-               tstate[i].cs_next = &tstate[i - 1];
-       }
-       tstate[0].cs_next = &tstate[MAX_STATES - 1];
-       tstate[0].cs_id = 0;
-       comp->last_cs = &tstate[0];
-       comp->last_recv = 255;
-       comp->last_xmit = 255;
-       comp->flags = SLF_TOSS;
-}
-
-
-/*
- * Like sl_compress_init, but we get to specify the maximum connection
- * ID to use on transmission.
- */
-void
-sl_compress_setup(comp, max_state)
-       struct slcompress *comp;
-       int max_state;
-{
-       register u_int i;
-       register struct cstate *tstate = comp->tstate;
-
-       if ((unsigned) max_state > MAX_STATES - 1)
-               max_state = MAX_STATES - 1;
-       bzero((char *)comp, sizeof(*comp));
-       for (i = max_state; i > 0; --i) {
-               tstate[i].cs_id = i;
-               tstate[i].cs_next = &tstate[i - 1];
-       }
-       tstate[0].cs_next = &tstate[max_state];
-       tstate[0].cs_id = 0;
-       comp->last_cs = &tstate[0];
-       comp->last_recv = 255;
-       comp->last_xmit = 255;
-       comp->flags = SLF_TOSS;
-}
-
-
-/* ENCODE encodes a number that is known to be non-zero.  ENCODEZ
- * checks for zero (since zero has to be encoded in the long, 3 byte
- * form).
- */
-#define ENCODE(n) { \
-       if ((u_short)(n) >= 256) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-#define ENCODEZ(n) { \
-       if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \
-               *cp++ = 0; \
-               cp[1] = (n); \
-               cp[0] = (n) >> 8; \
-               cp += 2; \
-       } else { \
-               *cp++ = (n); \
-       } \
-}
-
-#define DECODEL(f) { \
-       if (*cp == 0) {\
-               (f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htonl(ntohl(f) + (u_long)*cp++); \
-       } \
-}
-
-#define DECODES(f) { \
-       if (*cp == 0) {\
-               (f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \
-               cp += 3; \
-       } else { \
-               (f) = htons(ntohs(f) + (u_long)*cp++); \
-       } \
-}
-
-#define DECODEU(f) { \
-       if (*cp == 0) {\
-               (f) = htons((cp[1] << 8) | cp[2]); \
-               cp += 3; \
-       } else { \
-               (f) = htons((u_long)*cp++); \
-       } \
-}
-
-u_int
-sl_compress_tcp(m, ip, comp, compress_cid)
-       struct mbuf *m;
-       register struct ip *ip;
-       struct slcompress *comp;
-       int compress_cid;
-{
-       register struct cstate *cs = comp->last_cs->cs_next;
-       register u_int hlen = ip->ip_hl;
-       register struct tcphdr *oth;
-       register struct tcphdr *th;
-       register u_int deltaS, deltaA;
-       register u_int changes = 0;
-       u_char new_seq[16];
-       register u_char *cp = new_seq;
-
-       /*
-        * Bail if this is an IP fragment or if the TCP packet isn't
-        * `compressible' (i.e., ACK isn't set or some other control bit is
-        * set).  (We assume that the caller has already made sure the
-        * packet is IP proto TCP).
-        */
-       if ((ip->ip_off & htons(0x3fff)) || m->m_len < 40)
-               return (TYPE_IP);
-
-       th = (struct tcphdr *)&((int *)ip)[hlen];
-       if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
-               return (TYPE_IP);
-       /*
-        * Packet is compressible -- we're going to send either a
-        * COMPRESSED_TCP or UNCOMPRESSED_TCP packet.  Either way we need
-        * to locate (or create) the connection state.  Special case the
-        * most recently used connection since it's most likely to be used
-        * again & we don't have to do any reordering if it's used.
-        */
-       INCR(sls_packets)
-       if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
-           ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
-           *(int *)th != ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl]) {
-               /*
-                * Wasn't the first -- search for it.
-                *
-                * States are kept in a circularly linked list with
-                * last_cs pointing to the end of the list.  The
-                * list is kept in lru order by moving a state to the
-                * head of the list whenever it is referenced.  Since
-                * the list is short and, empirically, the connection
-                * we want is almost always near the front, we locate
-                * states via linear search.  If we don't find a state
-                * for the datagram, the oldest state is (re-)used.
-                */
-               register struct cstate *lcs;
-               register struct cstate *lastcs = comp->last_cs;
-
-               do {
-                       lcs = cs; cs = cs->cs_next;
-                       INCR(sls_searches)
-                       if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
-                           && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
-                           && *(int *)th == ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl])
-                               goto found;
-               } while (cs != lastcs);
-
-               /*
-                * Didn't find it -- re-use oldest cstate.  Send an
-                * uncompressed packet that tells the other side what
-                * connection number we're using for this conversation.
-                * Note that since the state list is circular, the oldest
-                * state points to the newest and we only need to set
-                * last_cs to update the lru linkage.
-                */
-               INCR(sls_misses)
-               comp->last_cs = lcs;
-               hlen += th->th_off;
-               hlen <<= 2;
-               if (hlen > m->m_len)
-                       return (TYPE_IP);
-               goto uncompressed;
-
-       found:
-               /*
-                * Found it -- move to the front on the connection list.
-                */
-               if (cs == lastcs)
-                       comp->last_cs = lcs;
-               else {
-                       lcs->cs_next = cs->cs_next;
-                       cs->cs_next = lastcs->cs_next;
-                       lastcs->cs_next = cs;
-               }
-       }
-
-       /*
-        * Make sure that only what we expect to change changed. The first
-        * line of the `if' checks the IP protocol version, header length &
-        * type of service.  The 2nd line checks the "Don't fragment" bit.
-        * The 3rd line checks the time-to-live and protocol (the protocol
-        * check is unnecessary but costless).  The 4th line checks the TCP
-        * header length.  The 5th line checks IP options, if any.  The 6th
-        * line checks TCP options, if any.  If any of these things are
-        * different between the previous & current datagram, we send the
-        * current datagram `uncompressed'.
-        */
-       oth = (struct tcphdr *)&((int *)&cs->cs_ip)[hlen];
-       deltaS = hlen;
-       hlen += th->th_off;
-       hlen <<= 2;
-       if (hlen > m->m_len)
-               return (TYPE_IP);
-
-       if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
-           ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
-           ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] ||
-           th->th_off != oth->th_off ||
-           (deltaS > 5 &&
-            BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
-           (th->th_off > 5 &&
-            BCMP(th + 1, oth + 1, (th->th_off - 5) << 2)))
-               goto uncompressed;
-
-       /*
-        * Figure out which of the changing fields changed.  The
-        * receiver expects changes in the order: urgent, window,
-        * ack, seq (the order minimizes the number of temporaries
-        * needed in this section of code).
-        */
-       if (th->th_flags & TH_URG) {
-               deltaS = ntohs(th->th_urp);
-               ENCODEZ(deltaS);
-               changes |= NEW_U;
-       } else if (th->th_urp != oth->th_urp)
-               /* argh! URG not set but urp changed -- a sensible
-                * implementation should never do this but RFC793
-                * doesn't prohibit the change so we have to deal
-                * with it. */
-                goto uncompressed;
-
-       if (deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) {
-               ENCODE(deltaS);
-               changes |= NEW_W;
-       }
-
-       if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
-               if (deltaA > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaA);
-               changes |= NEW_A;
-       }
-
-       if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
-               if (deltaS > 0xffff)
-                       goto uncompressed;
-               ENCODE(deltaS);
-               changes |= NEW_S;
-       }
-
-       switch(changes) {
-
-       case 0:
-               /*
-                * Nothing changed. If this packet contains data and the
-                * last one didn't, this is probably a data packet following
-                * an ack (normal on an interactive connection) and we send
-                * it compressed.  Otherwise it's probably a retransmit,
-                * retransmitted ack or window probe.  Send it uncompressed
-                * in case the other side missed the compressed version.
-                */
-               if (ip->ip_len != cs->cs_ip.ip_len &&
-                   ntohs(cs->cs_ip.ip_len) == hlen)
-                       break;
-
-               /* (fall through) */
-
-       case SPECIAL_I:
-       case SPECIAL_D:
-               /*
-                * actual changes match one of our special case encodings --
-                * send packet uncompressed.
-                */
-               goto uncompressed;
-
-       case NEW_S|NEW_A:
-               if (deltaS == deltaA &&
-                   deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for echoed terminal traffic */
-                       changes = SPECIAL_I;
-                       cp = new_seq;
-               }
-               break;
-
-       case NEW_S:
-               if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
-                       /* special case for data xfer */
-                       changes = SPECIAL_D;
-                       cp = new_seq;
-               }
-               break;
-       }
-
-       deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
-       if (deltaS != 1) {
-               ENCODEZ(deltaS);
-               changes |= NEW_I;
-       }
-       if (th->th_flags & TH_PUSH)
-               changes |= TCP_PUSH_BIT;
-       /*
-        * Grab the cksum before we overwrite it below.  Then update our
-        * state with this packet's header.
-        */
-       deltaA = ntohs(th->th_sum);
-       BCOPY(ip, &cs->cs_ip, hlen);
-
-       /*
-        * We want to use the original packet as our compressed packet.
-        * (cp - new_seq) is the number of bytes we need for compressed
-        * sequence numbers.  In addition we need one byte for the change
-        * mask, one for the connection id and two for the tcp checksum.
-        * So, (cp - new_seq) + 4 bytes of header are needed.  hlen is how
-        * many bytes of the original packet to toss so subtract the two to
-        * get the new packet size.
-        */
-       deltaS = cp - new_seq;
-       cp = (u_char *)ip;
-       if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
-               comp->last_xmit = cs->cs_id;
-               hlen -= deltaS + 4;
-               cp += hlen;
-               *cp++ = changes | NEW_C;
-               *cp++ = cs->cs_id;
-       } else {
-               hlen -= deltaS + 3;
-               cp += hlen;
-               *cp++ = changes;
-       }
-       m->m_len -= hlen;
-       m->m_off += hlen;
-       *cp++ = deltaA >> 8;
-       *cp++ = deltaA;
-       BCOPY(new_seq, cp, deltaS);
-       INCR(sls_compressed)
-       return (TYPE_COMPRESSED_TCP);
-
-       /*
-        * Update connection state cs & send uncompressed packet ('uncompressed'
-        * means a regular ip/tcp packet but with the 'conversation id' we hope
-        * to use on future compressed packets in the protocol field).
-        */
-uncompressed:
-       BCOPY(ip, &cs->cs_ip, hlen);
-       ip->ip_p = cs->cs_id;
-       comp->last_xmit = cs->cs_id;
-       return (TYPE_UNCOMPRESSED_TCP);
-}
-
-
-int
-sl_uncompress_tcp(bufp, len, type, comp)
-       u_char **bufp;
-       int len;
-       u_int type;
-       struct slcompress *comp;
-{
-       u_char *hdr, *cp;
-       int vjlen;
-       u_int hlen;
-
-       cp = bufp? *bufp: NULL;
-       vjlen = sl_uncompress_tcp_core(cp, len, len, type, comp, &hdr, &hlen);
-       if (vjlen < 0)
-               return (0);     /* error */
-       if (vjlen == 0)
-               return (len);   /* was uncompressed already */
-
-       cp += vjlen;
-       len -= vjlen;
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  If we're not aligned on a 4-byte boundary, copy the
-        * data down so the ip & tcp headers will be aligned.  Then back up
-        * cp by the tcp/ip header length to make room for the reconstructed
-        * header (we assume the packet we were handed has enough space to
-        * prepend 128 bytes of header).
-        */
-       if ((int)cp & 3) {
-               if (len > 0)
-                       (void) ovbcopy(cp, (caddr_t)((int)cp &~ 3), len);
-               cp = (u_char *)((int)cp &~ 3);
-       }
-       cp -= hlen;
-       len += hlen;
-       BCOPY(hdr, cp, hlen);
-
-       *bufp = cp;
-       return (len);
-}
-
-/*
- * Uncompress a packet of total length total_len.  The first buflen
- * bytes are at buf; this must include the entire (compressed or
- * uncompressed) TCP/IP header.  This procedure returns the length
- * of the VJ header, with a pointer to the uncompressed IP header
- * in *hdrp and its length in *hlenp.
- */
-int
-sl_uncompress_tcp_core(buf, buflen, total_len, type, comp, hdrp, hlenp)
-       u_char *buf;
-       int buflen, total_len;
-       u_int type;
-       struct slcompress *comp;
-       u_char **hdrp;
-       u_int *hlenp;
-{
-       register u_char *cp;
-       register u_int hlen, changes;
-       register struct tcphdr *th;
-       register struct cstate *cs;
-       register struct ip *ip;
-       register u_short *bp;
-       register u_int vjlen;
-
-       switch (type) {
-
-       case TYPE_UNCOMPRESSED_TCP:
-               ip = (struct ip *) buf;
-               if (ip->ip_p >= MAX_STATES)
-                       goto bad;
-               cs = &comp->rstate[comp->last_recv = ip->ip_p];
-               comp->flags &=~ SLF_TOSS;
-               ip->ip_p = IPPROTO_TCP;
-               /*
-                * Calculate the size of the TCP/IP header and make sure that
-                * we don't overflow the space we have available for it.
-                */
-               hlen = ip->ip_hl << 2;
-               if (hlen + sizeof(struct tcphdr) > buflen)
-                       goto bad;
-               hlen += ((struct tcphdr *)&((char *)ip)[hlen])->th_off << 2;
-               if (hlen > MAX_HDR || hlen > buflen)
-                       goto bad;
-               BCOPY(ip, &cs->cs_ip, hlen);
-               cs->cs_hlen = hlen;
-               INCR(sls_uncompressedin)
-               *hdrp = (u_char *) &cs->cs_ip;
-               *hlenp = hlen;
-               return (0);
-
-       default:
-               goto bad;
-
-       case TYPE_COMPRESSED_TCP:
-               break;
-       }
-       /* We've got a compressed packet. */
-       INCR(sls_compressedin)
-       cp = buf;
-       changes = *cp++;
-       if (changes & NEW_C) {
-               /* Make sure the state index is in range, then grab the state.
-                * If we have a good state index, clear the 'discard' flag. */
-               if (*cp >= MAX_STATES)
-                       goto bad;
-
-               comp->flags &=~ SLF_TOSS;
-               comp->last_recv = *cp++;
-       } else {
-               /* this packet has an implicit state index.  If we've
-                * had a line error since the last time we got an
-                * explicit state index, we have to toss the packet. */
-               if (comp->flags & SLF_TOSS) {
-                       INCR(sls_tossed)
-                       return (-1);
-               }
-       }
-       cs = &comp->rstate[comp->last_recv];
-       hlen = cs->cs_ip.ip_hl << 2;
-       th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
-       th->th_sum = htons((*cp << 8) | cp[1]);
-       cp += 2;
-       if (changes & TCP_PUSH_BIT)
-               th->th_flags |= TH_PUSH;
-       else
-               th->th_flags &=~ TH_PUSH;
-
-       switch (changes & SPECIALS_MASK) {
-       case SPECIAL_I:
-               {
-               register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
-               th->th_ack = htonl(ntohl(th->th_ack) + i);
-               th->th_seq = htonl(ntohl(th->th_seq) + i);
-               }
-               break;
-
-       case SPECIAL_D:
-               th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len)
-                                  - cs->cs_hlen);
-               break;
-
-       default:
-               if (changes & NEW_U) {
-                       th->th_flags |= TH_URG;
-                       DECODEU(th->th_urp)
-               } else
-                       th->th_flags &=~ TH_URG;
-               if (changes & NEW_W)
-                       DECODES(th->th_win)
-               if (changes & NEW_A)
-                       DECODEL(th->th_ack)
-               if (changes & NEW_S)
-                       DECODEL(th->th_seq)
-               break;
-       }
-       if (changes & NEW_I) {
-               DECODES(cs->cs_ip.ip_id)
-       } else
-               cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1);
-
-       /*
-        * At this point, cp points to the first byte of data in the
-        * packet.  Fill in the IP total length and update the IP
-        * header checksum.
-        */
-       vjlen = cp - buf;
-       buflen -= vjlen;
-       if (buflen < 0)
-               /* we must have dropped some characters (crc should detect
-                * this but the old slip framing won't) */
-               goto bad;
-
-       total_len += cs->cs_hlen - vjlen;
-       cs->cs_ip.ip_len = htons(total_len);
-
-       /* recompute the ip header checksum */
-       bp = (u_short *) &cs->cs_ip;
-       cs->cs_ip.ip_sum = 0;
-       for (changes = 0; hlen > 0; hlen -= 2)
-               changes += *bp++;
-       changes = (changes & 0xffff) + (changes >> 16);
-       changes = (changes & 0xffff) + (changes >> 16);
-       cs->cs_ip.ip_sum = ~ changes;
-
-       *hdrp = (u_char *) &cs->cs_ip;
-       *hlenp = cs->cs_hlen;
-       return vjlen;
-
-bad:
-       comp->flags |= SLF_TOSS;
-       INCR(sls_errorin)
-       return (-1);
-}
diff --git a/ultrix/slcompress.h b/ultrix/slcompress.h
deleted file mode 100644 (file)
index 1668bf2..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Definitions for tcp compression routines.
- *
- * $Id: slcompress.h,v 1.1 1996/09/26 06:19:39 paulus Exp $
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- *     Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- *     - Initial distribution.
- */
-
-#ifndef _SLCOMPRESS_H_
-#define _SLCOMPRESS_H_
-
-#define MAX_STATES 16          /* must be > 2 and < 256 */
-#define MAX_HDR MLEN           /* XXX 4bsd-ism: should really be 128 */
-
-/*
- * Compressed packet format:
- *
- * The first octet contains the packet type (top 3 bits), TCP
- * 'push' bit, and flags that indicate which of the 4 TCP sequence
- * numbers have changed (bottom 5 bits).  The next octet is a
- * conversation number that associates a saved IP/TCP header with
- * the compressed packet.  The next two octets are the TCP checksum
- * from the original datagram.  The next 0 to 15 octets are
- * sequence number changes, one change per bit set in the header
- * (there may be no changes and there are two special cases where
- * the receiver implicitly knows what changed -- see below).
- * 
- * There are 5 numbers which can change (they are always inserted
- * in the following order): TCP urgent pointer, window,
- * acknowlegement, sequence number and IP ID.  (The urgent pointer
- * is different from the others in that its value is sent, not the
- * change in value.)  Since typical use of SLIP links is biased
- * toward small packets (see comments on MTU/MSS below), changes
- * use a variable length coding with one octet for numbers in the
- * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
- * range 256 - 65535 or 0.  (If the change in sequence number or
- * ack is more than 65535, an uncompressed packet is sent.)
- */
-
-/*
- * Packet types (must not conflict with IP protocol version)
- *
- * The top nibble of the first octet is the packet type.  There are
- * three possible types: IP (not proto TCP or tcp with one of the
- * control flags set); uncompressed TCP (a normal IP/TCP packet but
- * with the 8-bit protocol field replaced by an 8-bit connection id --
- * this type of packet syncs the sender & receiver); and compressed
- * TCP (described above).
- *
- * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
- * is logically part of the 4-bit "changes" field that follows.  Top
- * three bits are actual packet type.  For backward compatibility
- * and in the interest of conserving bits, numbers are chosen so the
- * IP protocol version number (4) which normally appears in this nibble
- * means "IP packet".
- */
-
-/* packet types */
-#define TYPE_IP 0x40
-#define TYPE_UNCOMPRESSED_TCP 0x70
-#define TYPE_COMPRESSED_TCP 0x80
-#define TYPE_ERROR 0x00
-
-/* Bits in first octet of compressed packet */
-#define NEW_C  0x40    /* flag bits for what changed in a packet */
-#define NEW_I  0x20
-#define NEW_S  0x08
-#define NEW_A  0x04
-#define NEW_W  0x02
-#define NEW_U  0x01
-
-/* reserved, special-case values of above */
-#define SPECIAL_I (NEW_S|NEW_W|NEW_U)          /* echoed interactive traffic */
-#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)    /* unidirectional data */
-#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
-
-#define TCP_PUSH_BIT 0x10
-
-
-/*
- * "state" data for each active tcp conversation on the wire.  This is
- * basically a copy of the entire IP/TCP header from the last packet
- * we saw from the conversation together with a small identifier
- * the transmit & receive ends of the line use to locate saved header.
- */
-struct cstate {
-       struct cstate *cs_next; /* next most recently used cstate (xmit only) */
-       u_short cs_hlen;        /* size of hdr (receive only) */
-       u_char cs_id;           /* connection # associated with this state */
-       u_char cs_filler;
-       union {
-               char csu_hdr[MAX_HDR];
-               struct ip csu_ip;       /* ip/tcp hdr from most recent packet */
-       } slcs_u;
-};
-#define cs_ip slcs_u.csu_ip
-#define cs_hdr slcs_u.csu_hdr
-
-/*
- * all the state data for one serial line (we need one of these
- * per line).
- */
-struct slcompress {
-       struct cstate *last_cs; /* most recently used tstate */
-       u_char last_recv;       /* last rcvd conn. id */
-       u_char last_xmit;       /* last sent conn. id */
-       u_short flags;
-#ifndef SL_NO_STATS
-       int sls_packets;        /* outbound packets */
-       int sls_compressed;     /* outbound compressed packets */
-       int sls_searches;       /* searches for connection state */
-       int sls_misses;         /* times couldn't find conn. state */
-       int sls_uncompressedin; /* inbound uncompressed packets */
-       int sls_compressedin;   /* inbound compressed packets */
-       int sls_errorin;        /* inbound unknown type packets */
-       int sls_tossed;         /* inbound packets tossed because of error */
-#endif
-       struct cstate tstate[MAX_STATES];       /* xmit connection states */
-       struct cstate rstate[MAX_STATES];       /* receive connection states */
-};
-/* flag values */
-#define SLF_TOSS 1             /* tossing rcvd frames because of input err */
-
-void   sl_compress_init(struct slcompress *);
-void   sl_compress_setup(struct slcompress *, int);
-u_int  sl_compress_tcp(struct mbuf *, struct ip *, struct slcompress *, int);
-int    sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *);
-int    sl_uncompress_tcp_core(u_char *, int, int, u_int,
-           struct slcompress *, u_char **, u_int *);
-
-#endif /* _SLCOMPRESS_H_ */
diff --git a/ultrix/upgrade b/ultrix/upgrade
deleted file mode 100644 (file)
index 88fc3db..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-*** /usr/sys/conf/mips/files.mips.orig Sat Sep 11 06:09:28 1993
---- /usr/sys/conf/mips/files.mips      Fri Dec  9 09:32:01 1994
-***************
-*** 117,122 ****
---- 117,124 ----
-  io/netif/if_ppp.c            optional ppp device-driver Notbinary
-  io/netif/ppp_tty.c           optional ppp device-driver Notbinary
-  io/netif/bsd-comp.c          optional ppp device-driver Notbinary
-+ io/netif/ppp-deflate.c               optional ppp device-driver Notbinary
-+ io/netif/zlib.c                      optional ppp device-driver Notbinary
-  io/netif/slcompress.c                optional sl or ppp device-driver Notbinary
-  io/netif/if_qe.c             optional qe device-driver Binary
-  io/netif/if_uba.c            optional inet device-driver Binary