Bring Solaris port back up to date (#525)

- Updated READMEs
- Disabled MPPE support for Solaris
- Fixed compilation error in ccp.c with MPPE disabled
- Use OS-provided drivers and associated include files
- Tested on OpenIndiana Hipster (Illumos)

Signed-off-by: James Carlson <carlsonj@workingcode.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Co-authored-by: James Carlson <carlsonj@workingcode.com>
This commit is contained in:
Paul Mackerras 2024-10-15 13:20:29 +11:00 committed by GitHub
parent d540579ce5
commit ff28c30967
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 77 additions and 1215 deletions

8
README
View File

@ -35,6 +35,12 @@ Linux distributions. The Linux kernel code supports using PPP over
things other than serial ports, such as PPP over Ethernet and PPP over
ATM.
Similarly, the kernel code for Solaris is no longer distributed with
this package. See the Illumos web site for pointers to the kernel
module source code and build environment.
https://www.illumos.org/
Installation.
*************
@ -172,7 +178,7 @@ to linux-ppp@vger.kernel.org, or report them to the maintainer for the
port for the operating system you are using:
Linux Paul Mackerras <paulus@ozlabs.org>
Solaris James Carlson <carlson@workingcode.com>
Solaris James Carlson <carlsonj@workingcode.com>
Copyrights:

View File

@ -1,215 +1,69 @@
NOTE: These instructions are out of date.
Introduction.
*************
This file describes the installation process for ppp-2.4 on systems
running Solaris. The Solaris and SVR4 ports share a lot of code but
are not identical. The STREAMS kernel modules and driver for Solaris
are in the solaris directory (and use some code from the modules
directory).
This file describes the installation process for ppp-2.5 on systems
running an OpenSolaris-derived OS, such as Illumos or OpenIndiana.
For these systems, the STREAMS kernel modules are supplied with the
OS itself and are used as-is by this distribution. For more
information on these distributions (including kernel source) see:
NOTE: Although the kernel driver and modules have been designed to
operate correctly on SMP systems, they have not been extensively
tested on SMP machines. Some users of SMP Solaris x86 systems have
reported system problems apparently linked to the use of previous
versions of this software. I believe these problems have been fixed.
https://www.illumos.org/
https://illumos.org/docs/about/distro/
For Oracle Solaris systems, either use the vendor-supplied PPP
implementation ("Solaris PPP 4.0" based on pppd-2.4.0), or download
an older version of the pppd sources here:
https://download.samba.org/pub/ppp/
The last version known to compile and run correctly on Oracle
Solaris 10 is pppd-2.4.8. It may be possible to compile and use
newer versions on either Solaris 11 or by installing third-party
compilers; this has not been tested.
Installation.
*************
1. Run the configure script and make the user-level programs and the
kernel modules.
1. Make sure you have a suitable compiler installed. This package was
tested with "pkg install gcc-14" but other modern compilers should
work.
./configure
make
2. Run the configure script and build the package.
The configure script will automatically find Sun's cc if it's in
the standard location (/opt/SUNWspro/bin/cc). If you do not have
Sun's WorkShop compiler, configure will attempt to use 'gcc'. If
this is found and you have a 64 bit kernel, it will check that gcc
accepts the "-m64" option, which is required to build kernel
modules.
./configure --with-runtime-dir=/var/run --with-logfile-dir=/var/log/ppp
make
You should not have to edit the Makefiles for most ordinary cases.
The configure script will automatically find the compiler if it's in
the standard location (/usr/bin/gcc). By default, everything will be
installed in /usr/local. Use "--prefix" to choose a different
installation directory if desired. Use "./configure -h" to see other
options.
2. Install the programs and kernel modules: as root, do
3. Install the programs.
make install
sudo make install
This installs pppd, chat and pppstats in /usr/local/bin and the
kernel modules in /kernel/drv and /kernel/strmod, and creates the
/etc/ppp directory and populates it with default configuration
files. You can change the installation directories by editing
solaris/Makedefs. If you have a 64 bit kernel, the 64-bit drivers
are installed in /kernel/drv/sparcv9 and /kernel/strmod/sparcv9.
This installs the following:
If your system normally has only one network interface at boot
time, the default Solaris system startup scripts will disable IP
forwarding in the IP kernel module. This will prevent the remote
machine from using the local machine as a gateway to access other
hosts. The solution is to create an /etc/ppp/ip-up script
containing something like this:
/usr/local/sbin pppd, chat, pppstats, pppdump
/usr/local/share/man/man8 man pages
/usr/local/include/pppd plug-in header files
/usr/local/lib/pppd/$VER plug-in modules
/usr/local/etc/ppp example configuration files
If your system normally has only one network interface at boot
time, the default Solaris system startup scripts will disable IP
forwarding in the IP kernel module. This will prevent the remote
machine from using the local machine as a gateway to access other
hosts. The solution is to create an /etc/ppp/ip-up script
containing something like this:
#!/bin/sh
/usr/sbin/ndd -set /dev/ip ip_forwarding 1
#!/bin/sh
/usr/sbin/ndd -set /dev/ip ip_forwarding 1
See the man page for ip(7p) for details.
See the man page for ip(7p) for details.
Integrated pppd
***************
Solaris 8 07/01 (Update 5) and later have an integrated version of
pppd, known as "Solaris PPP 4.0," and is based on ppp-2.4.0. This
version comes with the standard Solaris software distribution and is
supported by Sun. It is fully tested in 64-bit and SMP modes, and
with bundled and unbundled synchronous drivers. Solaris 8 10/01
(Update 6) and later includes integrated PPPoE client and server
support, with kernel-resident data handling. See pppd(1M).
The feature is part of the regular full installation, and is
provided by these packages:
SUNWpppd - 32-bit mode kernel drivers
SUNWpppdr - root-resident /etc/ppp config samples
SUNWpppdu - /usr/bin/pppd itself, plus chat
SUNWpppdx - 64-bit mode kernel drivers
SUNWpppdt - PPPoE support
SUNWpppg - GPL'd optional 'pppdump' and plugins
SUNWpppgS - Source for GPL'd optional features
Use the open source version of pppd if you wish to recompile to add
new features or to experiment with the code. Production systems,
however, should run the Sun-supplied version, if at all possible.
You can run both versions on a single system if you wish. The
Solaris PPP 4.0 interfaces are named "spppN," while this open source
version names its interfaces as "pppN". The STREAMS modules are
similarly separated. The Sun-supplied pppd lives in /usr/bin/pppd,
while the open source version installs (by default) in
/usr/local/bin/pppd.
Dynamic STREAMS Re-Plumbing Support.
************************************
Solaris 8 (and later) includes dynamic re-plumbing support. With
this feature, modules below ip can be inserted, or removed, without
having the ip stream be unplumbed, and re-plumbed again. All state
in ip for the interface will be preserved as modules are added or
removed. Users can install (or upgrade) modules such as firewall,
bandwidth manager, cache manager, tunneling, etc., without shutting
the interface down.
To support this, ppp driver now uses /dev/udp instead of /dev/ip for
the ip stream. The interface stream (where ip module pushed on top
of ppp) is then I_PLINK'ed below the ip stream. /dev/udp is used
because 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. The mux ids of the ip streams are then added
using SIOCSxIFMUXID ioctl.
Users will be able to see the modules on the interface stream by,
for example:
pikapon# ifconfig ppp modlist
0 ip
1 ppp
Or arbitrarily if bandwidth manager and firewall modules are installed:
pikapon# ifconfig hme0 modlist
0 arp
1 ip
2 ipqos
3 firewall
4 hme
Snoop Support.
**************
This version includes support for /usr/sbin/snoop. Tests have been
done on Solaris 7 through 9. Only IPv4 and IPv6 packets will be sent
up to stream(s) marked as promiscuous (i.e., those used by snoop).
Users will be able to see the packets on the ppp interface by, for
example:
snoop -d ppp0
See the man page for snoop(1M) for details.
IPv6 Support.
*************
This is for Solaris 8 and later.
This version has been tested under Solaris 8 and 9 running IPv6.
Interoperability testing has only been done between Solaris machines
in terms of the IPV6 NCP. An additional command line option for the
pppd daemon has been added: ipv6cp-use-persistent.
By default, compilation for IPv6 support is not enabled. Uncomment
the necessary lines in pppd/Makefile.sol2 to enable it. Once done,
the quickest way to get IPv6 running is to add the following
somewhere in the command line option:
+ipv6 ipv6cp-use-persistent
The persistent id for the link-local address was added to conform to
RFC 2472; such that if there's an EUI-48 available, use that to make
up the EUI-64. As of now, the Solaris implementation extracts the
EUI-48 id from the Ethernet's MAC address (the ethernet interface
needs to be up). Future work might support other ways of obtaining
a unique yet persistent id, such as EEPROM serial numbers, etc.
There need not be any up/down scripts for ipv6,
e.g. /etc/ppp/ipv6-up or /etc/ppp/ipv6-down, to trigger IPv6
neighbor discovery for auto configuration and routing. The in.ndpd
daemon will perform all of the necessary jobs in the
background. /etc/inet/ndpd.conf can be further customized to enable
the machine as an IPv6 router. See the man page for in.ndpd(1M) and
ndpd.conf(4) for details.
Below is a sample output of "ifconfig -a" with persistent link-local
address. Note the UNNUMBERED flag is set because hme0 and ppp0 both
have identical link-local IPv6 addresses:
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 129.146.86.248 netmask ffffff00 broadcast 129.146.86.255
ether 8:0:20:8d:38:c1
lo0: flags=2000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6> mtu 8252 index 1
inet6 ::1/128
hme0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2
ether 8:0:20:8d:38:c1
inet6 fe80::a00:20ff:fe8d:38c1/10
hme0:1: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
inet6 fec0::56:a00:20ff:fe8d:38c1/64
hme0:2: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
inet6 2000::56:a00:20ff:fe8d:38c1/64
hme0:3: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
inet6 2::56:a00:20ff:fe8d:38c1/64
ppp0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> mtu 1500 index 12
inet 172.16.1.1 --> 172.16.1.2 netmask ffffff00
ppp0: flags=2202851<UP,POINTOPOINT,RUNNING,MULTICAST,UNNUMBERED,NONUD,IPv6> mtu 1500 index 12
inet6 fe80::a00:20ff:fe8d:38c1/10 --> fe80::a00:20ff:fe7a:24fb
Note also that a plumbed ipv6 interface stream will exist throughout
the entire PPP session in the case where the peer rejects IPV6CP,
which further causes the interface state to stay down. Unplumbing
will happen when the daemon exits. This is done by design and is not
a bug.
64-bit Support.
***************
This version has been tested under Solaris 7 through 9 in both 32-
and 64-bit environments (Ultra class machines). Installing the
package by executing "make install" will result in additional files
residing in /kernel/drv/sparcv9 and /kernel/strmod/sparcv9
subdirectories.
64-bit modules and driver have been compiled and tested using Sun's
cc and gcc.
Synchronous Serial Support.
***************************
@ -220,14 +74,8 @@ Synchronous Serial Support.
was tested with a Cisco router.
The ppp daemon does not directly support controlling the serial
interface. It relies on the /usr/sbin/syncinit command to
initialize HDLC mode and clocking.
There is a confirmed bug with NRZ/NRZI mode in the /dev/se_hdlc
driver, and Solaris patch 104596-11 is needed to correct it.
(However this patch seems to introduce other serial problems. If
you don't apply the patch, the workaround is to change the nrzi mode
to yes or no, whichever works.)
interface. It relies on the OS-supplied /usr/sbin/syncinit command
to initialize HDLC mode and clocking.
How to start pppd with synchronous support:

View File

@ -138,7 +138,7 @@ AM_CONDITIONAL(PPP_WITH_CHAPMS, test "x${enable_microsoft_extensions}" != "xno")
AM_COND_IF([PPP_WITH_CHAPMS],
AC_DEFINE([PPP_WITH_CHAPMS], 1, [Have Microsoft CHAP support]))
AM_CONDITIONAL(PPP_WITH_MPPE, test "x${enable_microsoft_extensions}" != "xno")
AM_CONDITIONAL(PPP_WITH_MPPE, test "x${build_sunos}" != "xyes" && test "x${enable_microsoft_extensions}" != "xno")
AM_COND_IF([PPP_WITH_MPPE],
AC_DEFINE([PPP_WITH_MPPE], 1, [Have Microsoft MPPE support]))

View File

@ -1,10 +1,6 @@
EXTRA_HEADERS = \
linux/ppp-comp.h \
linux/ppp_defs.h \
net/ppp-comp.h \
net/ppp_defs.h \
net/pppio.h \
net/vjcompress.h
linux/ppp_defs.h
EXTRA_DIST = \
$(EXTRA_HEADERS)

View File

@ -1,179 +0,0 @@
/*
* ppp-comp.h - Definitions for doing PPP packet compression.
*
* 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@ozlabs.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.h,v 1.13 2002/12/06 09:49:15 paulus Exp $
*/
#ifndef _NET_PPP_COMP_H
#define _NET_PPP_COMP_H
/*
* The following symbols control whether we include code for
* various compression methods.
*/
#ifndef DO_BSD_COMPRESS
#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
#endif
#ifndef DO_DEFLATE
#define DO_DEFLATE 1 /* by default, include Deflate */
#endif
#define DO_PREDICTOR_1 0
#define DO_PREDICTOR_2 0
/*
* Structure giving methods for compression/decompression.
*/
#ifdef PACKETPTR
struct compressor {
int compress_proto; /* CCP compression protocol number */
/* Allocate space for a compressor (transmit side) */
void *(*comp_alloc)(u_char *options, int opt_len);
/* Free space used by a compressor */
void (*comp_free)(void *state);
/* Initialize a compressor */
int (*comp_init)(void *state, u_char *options, int opt_len,
int unit, int hdrlen, int debug);
/* Reset a compressor */
void (*comp_reset)(void *state);
/* Compress a packet */
int (*compress)(void *state, PACKETPTR *mret,
PACKETPTR mp, int orig_len, int max_len);
/* Return compression statistics */
void (*comp_stat)(void *state, struct compstat *stats);
/* Allocate space for a decompressor (receive side) */
void *(*decomp_alloc)(u_char *options, int opt_len);
/* Free space used by a decompressor */
void (*decomp_free)(void *state);
/* Initialize a decompressor */
int (*decomp_init)(void *state, u_char *options, int opt_len,
int unit, int hdrlen, int mru, int debug);
/* Reset a decompressor */
void (*decomp_reset)(void *state);
/* Decompress a packet. */
int (*decompress)(void *state, PACKETPTR mp,
PACKETPTR *dmpp);
/* Update state for an incompressible packet received */
void (*incomp)(void *state, PACKETPTR mp);
/* Return decompression statistics */
void (*decomp_stat)(void *state, struct compstat *stats);
};
#endif /* PACKETPTR */
/*
* Return values for decompress routine.
* We need to make these distinctions so that we can disable certain
* useful functionality, namely sending a CCP reset-request as a result
* of an error detected after decompression. This is to avoid infringing
* a patent held by Motorola.
* Don't you just lurve software patents.
*/
#define DECOMP_OK 0 /* everything went OK */
#define DECOMP_ERROR 1 /* error detected before decomp. */
#define DECOMP_FATALERROR 2 /* error detected after decomp. */
/*
* CCP codes.
*/
#define CCP_CONFREQ 1
#define CCP_CONFACK 2
#define CCP_TERMREQ 5
#define CCP_TERMACK 6
#define CCP_RESETREQ 14
#define CCP_RESETACK 15
/*
* Max # bytes for a CCP option
*/
#define CCP_MAX_OPTION_LENGTH 32
/*
* Parts of a CCP packet.
*/
#define CCP_CODE(dp) ((dp)[0])
#define CCP_ID(dp) ((dp)[1])
#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
#define CCP_HDRLEN 4
#define CCP_OPT_CODE(dp) ((dp)[0])
#define CCP_OPT_LENGTH(dp) ((dp)[1])
#define CCP_OPT_MINLEN 2
/*
* Definitions for BSD-Compress.
*/
#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
#define CILEN_BSD_COMPRESS 3 /* length of config. option */
/* Macros for handling the 3rd byte of the BSD-Compress config option. */
#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
#define BSD_VERSION(x) ((x) >> 5) /* version of option format */
#define BSD_CURRENT_VERSION 1 /* current version number */
#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
#define BSD_MIN_BITS 9 /* smallest code size supported */
#define BSD_MAX_BITS 15 /* largest code size supported */
/*
* Definitions for Deflate.
*/
#define CI_DEFLATE 26 /* config option for Deflate */
#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
#define CILEN_DEFLATE 4 /* length of its config option */
#define DEFLATE_MIN_SIZE 8
#define DEFLATE_MAX_SIZE 15
#define DEFLATE_METHOD_VAL 8
#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
#define DEFLATE_METHOD(x) ((x) & 0x0F)
#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
+ DEFLATE_METHOD_VAL)
#define DEFLATE_CHK_SEQUENCE 0
/*
* Definitions for MPPE.
*/
#define CI_MPPE 18 /* config option for MPPE */
#define CILEN_MPPE 6 /* length of config option */
/*
* Definitions for other, as yet unsupported, compression methods.
*/
#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
#define CILEN_PREDICTOR_1 2 /* length of its config option */
#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
#define CILEN_PREDICTOR_2 2 /* length of its config option */
#endif /* _NET_PPP_COMP_H */

View File

@ -1,186 +0,0 @@
/* $Id: ppp_defs.h,v 1.17 2002/12/06 09:49:15 paulus Exp $ */
/*
* ppp_defs.h - PPP definitions.
*
* 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@ozlabs.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 */
/*
* Packet sizes
*
* Note - lcp shouldn't be allowed to negotiate stuff outside these
* limits. See lcp.h in the pppd directory.
* (XXX - these constants should simply be shared by lcp.c instead
* of living in lcp.h)
*/
#define PPP_MTU 1500 /* Default MTU (size of Info field) */
#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN)
#define PPP_MINMTU 64
#define PPP_MRU 1500 /* default MRU = max length of info field */
#define PPP_MAXMRU 65000 /* Largest MRU we allow */
#define PPP_MINMRU 128
#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_IPX 0x2b /* IPX protocol */
#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
#define PPP_COMP 0xfd /* compressed packet */
#define PPP_IPCP 0x8021 /* IP Control Protocol */
#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
#define PPP_IPXCP 0x802b /* IPX Control Protocol */
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
#define PPP_CCP 0x80fd /* Compression Control Protocol */
#define PPP_ECP 0x8053 /* Encryption 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 */
#define PPP_EAP 0xc227 /* Extensible Authentication 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])
/*
* A 32-bit unsigned integral type.
*/
#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
&& !defined(__FreeBSD__) && (NS_TARGET < 40)
#ifdef UINT32_T
typedef UINT32_T u_int32_t;
#else
typedef unsigned int u_int32_t;
typedef unsigned short u_int16_t;
#endif
#endif
/*
* 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 */
};
#endif /* _PPP_DEFS_H_ */

View File

@ -1,107 +0,0 @@
/*
* pppio.h - ioctl and other misc. definitions for STREAMS modules.
*
* 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@ozlabs.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: pppio.h,v 1.9 2002/12/06 09:49:15 paulus Exp $
*/
#define _PPPIO(n) (('p' << 8) + (n))
#define PPPIO_NEWPPA _PPPIO(130) /* allocate a new PPP unit */
#define PPPIO_GETSTAT _PPPIO(131) /* get PPP statistics */
#define PPPIO_GETCSTAT _PPPIO(132) /* get PPP compression stats */
#define PPPIO_MTU _PPPIO(133) /* set max transmission unit */
#define PPPIO_MRU _PPPIO(134) /* set max receive unit */
#define PPPIO_CFLAGS _PPPIO(135) /* set/clear/get compression flags */
#define PPPIO_XCOMP _PPPIO(136) /* alloc transmit compressor */
#define PPPIO_RCOMP _PPPIO(137) /* alloc receive decompressor */
#define PPPIO_XACCM _PPPIO(138) /* set transmit asyncmap */
#define PPPIO_RACCM _PPPIO(139) /* set receive asyncmap */
#define PPPIO_VJINIT _PPPIO(140) /* initialize VJ comp/decomp */
#define PPPIO_ATTACH _PPPIO(141) /* attach to a ppa (without putmsg) */
#define PPPIO_LASTMOD _PPPIO(142) /* mark last ppp module */
#define PPPIO_GCLEAN _PPPIO(143) /* get 8-bit-clean flags */
#define PPPIO_DEBUG _PPPIO(144) /* request debug information */
#define PPPIO_BIND _PPPIO(145) /* bind to SAP */
#define PPPIO_NPMODE _PPPIO(146) /* set mode for handling data pkts */
#define PPPIO_GIDLE _PPPIO(147) /* get time since last data pkt */
#define PPPIO_PASSFILT _PPPIO(148) /* set filter for packets to pass */
#define PPPIO_ACTIVEFILT _PPPIO(149) /* set filter for "link active" pkts */
/*
* Values for PPPIO_CFLAGS
*/
#define COMP_AC 0x1 /* compress address/control */
#define DECOMP_AC 0x2 /* decompress address/control */
#define COMP_PROT 0x4 /* compress PPP protocol */
#define DECOMP_PROT 0x8 /* decompress PPP protocol */
#define COMP_VJC 0x10 /* compress TCP/IP headers */
#define COMP_VJCCID 0x20 /* compress connection ID as well */
#define DECOMP_VJC 0x40 /* decompress TCP/IP headers */
#define DECOMP_VJCCID 0x80 /* accept compressed connection ID */
#define CCP_ISOPEN 0x100 /* look at CCP packets */
#define CCP_ISUP 0x200 /* do packet comp/decomp */
#define CCP_ERROR 0x400 /* (status) error in packet decomp */
#define CCP_FATALERROR 0x800 /* (status) fatal error ditto */
#define CCP_COMP_RUN 0x1000 /* (status) seen CCP ack sent */
#define CCP_DECOMP_RUN 0x2000 /* (status) seen CCP ack rcvd */
/*
* Values for 8-bit-clean flags.
*/
#define RCV_B7_0 1 /* have rcvd char with bit 7 = 0 */
#define RCV_B7_1 2 /* have rcvd char with bit 7 = 1 */
#define RCV_EVNP 4 /* have rcvd char with even parity */
#define RCV_ODDP 8 /* have rcvd char with odd parity */
/*
* Values for the first byte of M_CTL messages passed between
* PPP modules.
*/
#define PPPCTL_OERROR 0xe0 /* output error [up] */
#define PPPCTL_IERROR 0xe1 /* input error (e.g. FCS) [up] */
#define PPPCTL_MTU 0xe2 /* set MTU [down] */
#define PPPCTL_MRU 0xe3 /* set MRU [down] */
#define PPPCTL_UNIT 0xe4 /* note PPP unit number [down] */
/*
* Values for the integer argument to PPPIO_DEBUG.
*/
#define PPPDBG_DUMP 0x10000 /* print out debug info now */
#define PPPDBG_LOG 0x100 /* log various things */
#define PPPDBG_DRIVER 0 /* identifies ppp driver as target */
#define PPPDBG_IF 1 /* identifies ppp network i/f target */
#define PPPDBG_COMP 2 /* identifies ppp compression target */
#define PPPDBG_AHDLC 3 /* identifies ppp async hdlc target */

View File

@ -1,144 +0,0 @@
/*
* Definitions for tcp compression routines.
*
* $Id: vjcompress.h,v 1.3 1996/05/28 00:55:33 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 _VJCOMPRESS_H_
#define _VJCOMPRESS_H_
#define MAX_STATES 16 /* must be > 2 and < 256 */
#define MAX_HDR 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 state (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 */
} vjcs_u;
};
#define cs_ip vjcs_u.csu_ip
#define cs_hdr vjcs_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 VJ_NO_STATS
struct vjstat stats;
#endif
struct cstate tstate[MAX_STATES]; /* xmit connection states */
struct cstate rstate[MAX_STATES]; /* receive connection states */
};
/* flag values */
#define VJF_TOSS 1 /* tossing rcvd frames because of input err */
extern void vj_compress_init(struct vjcompress *comp, int max_state);
extern u_int vj_compress_tcp(struct ip *ip, u_int mlen,
struct vjcompress *comp, int compress_cid_flag,
u_char **vjhdrp);
extern void vj_uncompress_err(struct vjcompress *comp);
extern int vj_uncompress_uncomp(u_char *buf, int buflen,
struct vjcompress *comp);
extern int vj_uncompress_tcp(u_char *buf, int buflen, int total_len,
struct vjcompress *comp, u_char **hdrp,
u_int *hlenp);
#endif /* _VJCOMPRESS_H_ */

View File

@ -685,7 +685,10 @@ static int
+ (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0)
+ (go->predictor_1? CILEN_PREDICTOR_1: 0)
+ (go->predictor_2? CILEN_PREDICTOR_2: 0)
+ (go->mppe? CILEN_MPPE: 0);
#ifdef PPP_WITH_MPPE
+ (go->mppe? CILEN_MPPE: 0)
#endif
;
}
/*

View File

@ -65,7 +65,11 @@
* Where should PPP_DRV_NAME come from? Do we include it here?
*/
#if !defined(PPP_DRV_NAME)
#if defined(SOL2)
#define PPP_DRV_NAME "sppp"
#else
#define PPP_DRV_NAME "ppp"
#endif /* defined(SOL2) */
#endif /* !defined(PPP_DRV_NAME) */

View File

@ -99,9 +99,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#ifndef CRTSCTS
#include <sys/termiox.h>
#endif
#include <signal.h>
#include <utmpx.h>
#include <stropts.h>
@ -123,13 +120,11 @@
#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
#ifdef PPP_WITH_FILTER
#include <pcap.h>
@ -140,45 +135,27 @@
#include "lcp.h"
#include "ipcp.h"
#include "ccp.h"
#ifdef PPP_WITH_IPV6CP
#include "eui64.h"
#endif
#if !defined(PPP_DRV_NAME)
#define PPP_DRV_NAME "ppp"
#endif /* !defined(PPP_DRV_NAME) */
#if !defined(PPP_DEV_NAME)
#define PPP_DEV_NAME "/dev/" PPP_DRV_NAME
#endif /* !defined(PPP_DEV_NAME) */
#if !defined(AHDLC_MOD_NAME)
#define AHDLC_MOD_NAME "ppp_ahdl"
#define AHDLC_MOD_NAME "spppasyn"
#endif /* !defined(AHDLC_MOD_NAME) */
#if !defined(COMP_MOD_NAME)
#define COMP_MOD_NAME "ppp_comp"
#define COMP_MOD_NAME "spppcomp"
#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) */
#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
@ -186,15 +163,10 @@
* 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(PPP_WITH_IPV6CP) && 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 */
@ -228,18 +200,8 @@ static int if6_is_up = 0; /* IPv6 interface has been marked up */
#define IN6A_LLADDR_FROM_EUI64(s, eui64) \
_IN6A_LLX_FROM_EUI64(s, eui64, 0xfe800000)
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
#if !defined(PPP_WITH_IPV6CP) || !defined(SOL2)
#define MAXIFS 256 /* Max # of interfaces */
#endif /* defined(PPP_WITH_IPV6CP) && 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 */
@ -273,7 +235,6 @@ static int dlpi_info_req(int);
static int dlpi_get_reply(int, union DL_primitives *, int, size_t);
static int strioctl(int, int, void *, int, int);
#ifdef SOL2
/*
* sifppa - Sets interface ppa
*
@ -299,14 +260,10 @@ sifppa(fd, ppa)
{
return (int)ioctl(fd, IF_UNITSEL, (char *)&ppa);
}
#endif /* SOL2 */
#if defined(SOL2) && defined(PPP_WITH_IPV6CP)
/*
* get_first_ether_hwaddr - get the hardware address for the first
* ethernet-style interface on this system.
*
* NOTE: This is the lifreq version (Solaris 8 and above)
*/
int
get_first_ether_hwaddr(u_char *addr)
@ -395,95 +352,7 @@ get_first_ether_hwaddr(u_char *addr)
else
return -1;
}
#else
/*
* get_first_ether_hwaddr - get the hardware address for the first
* ethernet-style interface on this system.
*
* NOTE: This is the ifreq version (before Solaris 8).
*/
int
get_first_ether_hwaddr(u_char *addr)
{
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 -1;
}
/*
* 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 -1;
}
/*
* 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 -1;
}
/*
* 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) {
error("SIOCGIFFLAGS: %m");
break;
}
fl = ifr.ifr_flags;
if ((fl & (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|IFF_LOOPBACK|IFF_NOARP))
!= (IFF_UP | IFF_BROADCAST))
continue;
if (get_if_hwaddr(addr, ifr.ifr_name) < 0)
continue;
found = 1;
break;
}
free(req);
close(fd);
if (found)
return 0;
else
return -1;
}
#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */
#if defined(SOL2)
/*
* get_if_hwaddr - get the hardware address for the specified
* network interface device.
@ -508,9 +377,7 @@ get_if_hwaddr(u_char *addr, char *if_name)
memcpy(addr, eth_addr->ether_addr_octet, 6);
return 1;
}
#endif /* SOL2 */
#if defined(SOL2) && defined(PPP_WITH_IPV6CP)
/*
* slifname - Sets interface ppa and flags
*
@ -537,10 +404,7 @@ slifname(int fd, int ppa)
slifname_done:
return ret;
}
#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */
/*
* sys_init - System-dependent initialization.
@ -550,26 +414,16 @@ sys_init(void)
{
int ifd, x;
struct ifreq ifr;
#if defined(PPP_WITH_IPV6CP) && defined(SOL2)
int i6fd;
struct lifreq lifr;
#endif /* defined(PPP_WITH_IPV6CP) && 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(PPP_WITH_IPV6CP) && defined(SOL2)
ip6fd = open(UDP6_DEV_NAME, O_RDWR, 0);
if (ip6fd < 0)
fatal("Couldn't open IP device (2): %m");
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
if (default_device && !notty)
tty_sid = getsid((pid_t)0);
@ -586,7 +440,6 @@ sys_init(void)
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,
@ -594,7 +447,7 @@ sys_init(void)
* <adi.masputra@sun.com>
*/
sprintf(ifname, PPP_DRV_NAME "%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.
@ -608,7 +461,6 @@ sys_init(void)
strioctl(ifd, PPPIO_DEBUG, &x, sizeof(int), 0);
}
#if defined(PPP_WITH_IPV6CP) && defined(SOL2)
i6fd = open(PPP_DEV_NAME, O_RDWR, 0);
if (i6fd < 0) {
close(ifd);
@ -618,14 +470,10 @@ sys_init(void)
x = PPPDBG_LOG + PPPDBG_DRIVER;
strioctl(i6fd, PPPIO_DEBUG, &x, sizeof(int), 0);
}
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
#if defined(SOL2)
if (ioctl(ifd, I_PUSH, IP_MOD_NAME) < 0) {
close(ifd);
#if defined(PPP_WITH_IPV6CP)
close(i6fd);
#endif /* defined(PPP_WITH_IPV6CP) */
fatal("Can't push IP module: %m");
}
@ -635,13 +483,10 @@ sys_init(void)
*/
if (sifppa(ifd, ifunit) < 0) {
close (ifd);
#if defined(PPP_WITH_IPV6CP)
close(i6fd);
#endif /* defined(PPP_WITH_IPV6CP) */
fatal("Can't set ppa for unit %d: %m", ifunit);
}
#if defined(PPP_WITH_IPV6CP)
/*
* An IPv6 interface is created anyway, even when the user does not
* explicitly enable it. Note that the interface will be marked
@ -663,14 +508,11 @@ sys_init(void)
close(i6fd);
fatal("Can't set ifname for unit %d: %m", ifunit);
}
#endif /* defined(PPP_WITH_IPV6CP) */
ipmuxid = ioctl(ipfd, I_PLINK, ifd);
close(ifd);
if (ipmuxid < 0) {
#if defined(PPP_WITH_IPV6CP)
close(i6fd);
#endif /* defined(PPP_WITH_IPV6CP) */
fatal("Can't I_PLINK PPP device to IP: %m");
}
@ -687,27 +529,10 @@ sys_init(void)
*/
if (ioctl(ipfd, SIOCSIFMUXID, &ifr) < 0) {
ioctl(ipfd, I_PUNLINK, ipmuxid);
#if defined(PPP_WITH_IPV6CP)
close(i6fd);
#endif /* defined(PPP_WITH_IPV6CP) */
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(PPP_WITH_IPV6CP) && defined(SOL2)
ip6muxid = ioctl(ip6fd, I_PLINK, i6fd);
close(i6fd);
if (ip6muxid < 0) {
@ -727,15 +552,6 @@ sys_init(void)
ioctl(ip6fd, I_PUNLINK, ip6muxid);
fatal("Can't link PPP device to IP (2): %m");
}
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
#if !defined(SOL2)
/* Set the interface name for the link. */
slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), PPP_DRV_NAME "%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;
}
@ -748,17 +564,11 @@ sys_init(void)
void
sys_cleanup(void)
{
#if defined(SOL2)
struct ifreq ifr;
#if defined(PPP_WITH_IPV6CP)
struct lifreq lifr;
#endif /* defined(PPP_WITH_IPV6CP) */
#endif /* defined(SOL2) */
#if defined(SOL2) && defined(PPP_WITH_IPV6CP)
if (if6_is_up)
sif6down(0);
#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */
if (if_is_up)
sifdown(0);
if (default_route_gateway)
@ -767,7 +577,7 @@ sys_cleanup(void)
cif6defaultroute(0, default_route_gateway6, default_route_gateway6);
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.
@ -790,7 +600,7 @@ sys_cleanup(void)
error("Can't I_PUNLINK PPP from IP: %m");
return;
}
#if defined(PPP_WITH_IPV6CP)
/*
* Make sure we ask ip what the muxid, because 'ifconfig modlist' will
* unlink and re-link the modules, causing the muxid to change.
@ -812,8 +622,6 @@ sys_cleanup(void)
if (ioctl(ip6fd, I_PUNLINK, ip6muxid) < 0) {
error("Can't I_PUNLINK PPP from IP (2): %m");
}
#endif /* defined(PPP_WITH_IPV6CP) */
#endif /* defined(SOL2) */
}
/*
@ -823,9 +631,7 @@ void
ppp_sys_close(void)
{
close(ipfd);
#if defined(PPP_WITH_IPV6CP) && defined(SOL2)
close(ip6fd);
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
if (pppfd >= 0)
close(pppfd);
}
@ -839,31 +645,6 @@ sys_check_options(void)
return 1;
}
#if 0
/*
* daemon - Detach us from controlling terminal session.
*/
int
daemon(int nochdir, int 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_check_kernel_support - check whether the system has any ppp interfaces
*/
@ -1156,46 +937,21 @@ set_up_tty(int fd, int local)
{
int speed;
struct termios tios;
#if !defined (CRTSCTS)
struct termiox tiox;
#endif
if (!ppp_sync_serial() && tcgetattr(fd, &tios) < 0)
fatal("tcgetattr: %m");
#ifndef CRTSCTS
termiox_ok = 1;
if (!ppp_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 (!ppp_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
if (stop_bits >= 2)
tios.c_cflag |= CSTOPB;
@ -1232,12 +988,6 @@ set_up_tty(int fd, int local)
if (!ppp_sync_serial() && tcsetattr(fd, TCSAFLUSH, &tios) < 0)
fatal("tcsetattr: %m");
#ifndef CRTSCTS
if (!ppp_sync_serial() && termiox_ok && ioctl (fd, TCSETXF, &tiox) < 0){
error("TCSETXF: %m");
}
#endif
baud_rate = inspeed = baud_rate_of(speed);
if (!ppp_sync_serial())
restore_term = 1;
@ -1262,12 +1012,6 @@ restore_tty(int fd)
if (!ppp_sync_serial() && tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
if (!hungup && errno != ENXIO)
warn("tcsetattr: %m");
#ifndef CRTSCTS
if (!ppp_sync_serial() && ioctl (fd, TCSETXF, &inittermiox) < 0){
if (!hungup && errno != ENXIO)
error("TCSETXF: %m");
}
#endif
if (!ppp_sync_serial())
ioctl(fd, TIOCSWINSZ, &wsinfo);
restore_term = 0;
@ -1376,34 +1120,6 @@ void remove_fd(int fd)
}
}
#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(struct timeval *timo)
{
wait_input(timo);
}
/*
* wait_time - wait for a given length of time or until a
* signal is received.
*/
void
wait_time(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.
*/
@ -1434,7 +1150,7 @@ read_packet(u_char *buf)
* Got a M_PROTO or M_PCPROTO message. Interpret it
* as a DLPI primitive??
*/
if (debug)
if (debug && ((union DL_primitives *)ctrlbuf)->dl_primitive != 0x53505050)
dbglog("got dlpi prim 0x%x, len=%d",
((union DL_primitives *)ctrlbuf)->dl_primitive, ctrl.len);
@ -1466,10 +1182,8 @@ void
ppp_set_mtu(int unit, int mtu)
{
struct ifreq ifr;
#if defined(PPP_WITH_IPV6CP) && defined(SOL2)
struct lifreq lifr;
int fd;
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
@ -1478,7 +1192,6 @@ ppp_set_mtu(int unit, int mtu)
error("Couldn't set IP MTU (%s): %m", ifr.ifr_name);
}
#if defined(PPP_WITH_IPV6CP) && defined(SOL2)
fd = socket(AF_INET6, SOCK_DGRAM, 0);
if (fd < 0)
error("Couldn't open IPv6 socket: %m");
@ -1491,7 +1204,6 @@ ppp_set_mtu(int unit, int mtu)
error("Couldn't set IPv6 MTU (%s): %m", ifr.ifr_name);
}
close(fd);
#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */
}
@ -1634,10 +1346,10 @@ get_idle_time(int u, struct ppp_idle *ip)
int
get_ppp_stats(int u, struct pppd_stats *stats)
{
struct ppp_stats s;
struct ppp_stats64 s;
if (!ppp_sync_serial() &&
strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
strioctl(pppfd, PPPIO_GETSTAT64, &s, 0, sizeof(s)) < 0) {
error("Couldn't get link statistics: %m");
return 0;
}
@ -1758,7 +1470,6 @@ sifnpmode(int u, int proto, enum NPmode mode)
return 1;
}
#if defined(SOL2) && defined(PPP_WITH_IPV6CP)
/*
* sif6up - Config the IPv6 interface up and enable IPv6 packets to pass.
*/
@ -1942,9 +1653,6 @@ cif6defaultroute(int u, eui64_t l, eui64_t g)
return 1;
}
#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */
#define INET_ADDR(x) (((struct sockaddr_in *) &(x))->sin_addr.s_addr)
/*
@ -2136,9 +1844,7 @@ get_ether_addr(u_int32_t ipaddr, struct sockaddr *hwaddr)
/*
* 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);
@ -2236,12 +1942,10 @@ get_hw_addr_dlpi(char *name, struct sockaddr *hwaddr)
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);
@ -2481,85 +2185,6 @@ strioctl(int fd, int cmd, void *ptr, int ilen, int olen)
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(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(void)
{
if (lock_file[0]) {
unlink(lock_file);
lock_file[0] = 0;
}
}
#endif
/*
* cifroute - delete a route through the addresses given.
*/
@ -2597,7 +2222,6 @@ cifroute(int u, u_int32_t our, u_int32_t his)
int
have_route_to(u_int32_t addr)
{
#ifdef SOL2
int fd, r, flags, i;
struct {
struct T_optmgmt_req req;
@ -2673,7 +2297,7 @@ have_route_to(u_int32_t addr)
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",
dbglog("have_route_to: dest=%I gw=%I mask=%I",
rp->ipRouteDest, rp->ipRouteNextHop,
rp->ipRouteMask);
if (((addr ^ rp->ipRouteDest) & rp->ipRouteMask) == 0
@ -2688,9 +2312,6 @@ have_route_to(u_int32_t addr)
}
close(fd);
return 0;
#else
return -1;
#endif /* SOL2 */
}
/*