xref: /onnv-gate/usr/src/uts/common/net/ppp_defs.h (revision 420:45e68e7aede3)
10Sstevel@tonic-gate /*	$Id: ppp_defs.h,v 1.14 1999/08/13 01:55:40 paulus Exp $	*/
20Sstevel@tonic-gate 
30Sstevel@tonic-gate /*
40Sstevel@tonic-gate  * ppp_defs.h - PPP definitions.
50Sstevel@tonic-gate  *
6*420Sstevel  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
70Sstevel@tonic-gate  * Use is subject to license terms.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
100Sstevel@tonic-gate  * All rights reserved.
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
130Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
140Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
150Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
160Sstevel@tonic-gate  * makes no representations about the suitability of this software for
170Sstevel@tonic-gate  * any purpose.
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
200Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
210Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
220Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
230Sstevel@tonic-gate  * OF SUCH DAMAGE.
240Sstevel@tonic-gate  *
250Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
260Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
270Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
280Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
290Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
300Sstevel@tonic-gate  * OR MODIFICATIONS.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifndef _PPP_DEFS_H_
340Sstevel@tonic-gate #define	_PPP_DEFS_H_
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #ifdef __cplusplus
390Sstevel@tonic-gate extern "C" {
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * The basic PPP frame.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate #define	PPP_HDRLEN	4	/* octets for standard ppp header */
460Sstevel@tonic-gate #define	PPP_FCSLEN	2	/* octets for FCS */
470Sstevel@tonic-gate #define	PPP_FCS32LEN	4	/* octets for FCS-32 */
480Sstevel@tonic-gate #define	PPP_MAX_MUX_LEN	127	/* maximum length of muxed frame */
490Sstevel@tonic-gate #define	PFF		0x80	/* protocol field flag */
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * Packet sizes
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate #define	PPP_MTU		1500	/* Default MTU (size of Info field) */
550Sstevel@tonic-gate #define	PPP_MAXMTU	65535 - (PPP_HDRLEN + PPP_FCSLEN)
560Sstevel@tonic-gate #define	PPP_MINMTU	64
570Sstevel@tonic-gate #define	PPP_MRU		1500	/* default MRU = max length of info field */
580Sstevel@tonic-gate #define	PPP_MAXMRU	65000	/* Largest MRU we allow */
590Sstevel@tonic-gate #define	PPP_MINMRU	128
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #define	PPP_ADDRESS(p)	(((uchar_t *)(p))[0])
620Sstevel@tonic-gate #define	PPP_CONTROL(p)	(((uchar_t *)(p))[1])
630Sstevel@tonic-gate #define	PPP_PROTOCOL(p)	((((uchar_t *)(p))[2] << 8) + ((uchar_t *)(p))[3])
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*
660Sstevel@tonic-gate  * Significant octet values.
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate #define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */
690Sstevel@tonic-gate #define	PPP_UI		0x03	/* Unnumbered Information */
700Sstevel@tonic-gate #define	PPP_FLAG	0x7e	/* Flag Sequence */
710Sstevel@tonic-gate #define	PPP_ESCAPE	0x7d	/* Asynchronous Control Escape */
720Sstevel@tonic-gate #define	PPP_TRANS	0x20	/* Asynchronous transparency modifier */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * Protocol field values.
760Sstevel@tonic-gate  */
770Sstevel@tonic-gate #define	PPP_IP		0x21	/* Internet Protocol */
780Sstevel@tonic-gate #define	PPP_OSI		0x23	/* OSI Network Layer */
790Sstevel@tonic-gate #define	PPP_AT		0x29	/* AppleTalk Protocol */
800Sstevel@tonic-gate #define	PPP_IPX		0x2b	/* IPX protocol */
810Sstevel@tonic-gate #define	PPP_VJC_COMP	0x2d	/* VJ compressed TCP */
820Sstevel@tonic-gate #define	PPP_VJC_UNCOMP	0x2f	/* VJ uncompressed TCP */
830Sstevel@tonic-gate #define	PPP_BRIDGE	0x31	/* Bridging */
840Sstevel@tonic-gate #define	PPP_MP		0x3d	/* Multilink protocol */
850Sstevel@tonic-gate #define	PPP_ENCRYPT	0x53	/* Encryption */
860Sstevel@tonic-gate #define	PPP_ENCRYPTFRAG	0x55	/* Individual Link Encryption */
870Sstevel@tonic-gate #define	PPP_IPV6	0x57	/* Internet Protocol Version 6 */
880Sstevel@tonic-gate #define	PPP_MUX		0x59	/* PPP Muxing */
890Sstevel@tonic-gate #define	PPP_FULLHDR	0x61	/* IP Compression; full header */
900Sstevel@tonic-gate #define	PPP_COMPTCP	0x63	/* IP Compression; compressed TCP */
910Sstevel@tonic-gate #define	PPP_COMPNONTCP	0x65	/* IP Compression; non TCP */
920Sstevel@tonic-gate #define	PPP_COMPUDP8	0x67	/* IP Compression; UDP, 8 bit CID */
930Sstevel@tonic-gate #define	PPP_COMPRTP8	0x69	/* IP Compression; RTP, 8 bit CID */
940Sstevel@tonic-gate #define	PPP_COMPFRAG	0xfb	/* fragment compressed below bundle */
950Sstevel@tonic-gate #define	PPP_COMP	0xfd	/* compressed packet */
960Sstevel@tonic-gate #define	PPP_802HELLO	0x201	/* 802.1d Hello (OBSOLETE) */
970Sstevel@tonic-gate #define	PPP_MPLS	0x281	/* MPLS Unicast */
980Sstevel@tonic-gate #define	PPP_MPLSMC	0x283	/* MPLS Multicast */
990Sstevel@tonic-gate #define	PPP_COMPTCPND	0x2063	/* IP Compression; compressed TCP no delta */
1000Sstevel@tonic-gate #define	PPP_COMPSTATE	0x2065	/* IP Compression; state message */
1010Sstevel@tonic-gate #define	PPP_COMPUDP16	0x2067	/* IP Compression; UDP, 16 bit CID */
1020Sstevel@tonic-gate #define	PPP_COMPRTP16	0x2069	/* IP Compression; RTP, 16 bit CID */
1030Sstevel@tonic-gate #define	PPP_IPCP	0x8021	/* IP Control Protocol */
1040Sstevel@tonic-gate #define	PPP_OSINLCP	0x8023	/* OSI Network Layer Control Protocol */
1050Sstevel@tonic-gate #define	PPP_ATCP	0x8029	/* AppleTalk Control Protocol */
1060Sstevel@tonic-gate #define	PPP_IPXCP	0x802b	/* IPX Control Protocol */
1070Sstevel@tonic-gate #define	PPP_BCP		0x8031	/* Bridging Control Protocol */
1080Sstevel@tonic-gate #define	PPP_ECP		0x8053	/* Encryption Control Protocol */
1090Sstevel@tonic-gate #define	PPP_ECPFRAG	0x8055	/* ECP at link level (below MP bundle) */
1100Sstevel@tonic-gate #define	PPP_IPV6CP	0x8057	/* IPv6 Control Protocol */
1110Sstevel@tonic-gate #define	PPP_MUXCP	0x8059	/* PPP Muxing Control Protocol */
1120Sstevel@tonic-gate #define	PPP_CCPFRAG	0x80fb	/* CCP at link level (below MP bundle) */
1130Sstevel@tonic-gate #define	PPP_CCP		0x80fd	/* Compression Control Protocol */
1140Sstevel@tonic-gate #define	PPP_MPLSCP	0x8281	/* MPLS Control Protocol */
1150Sstevel@tonic-gate #define	PPP_LCP		0xc021	/* Link Control Protocol */
1160Sstevel@tonic-gate #define	PPP_PAP		0xc023	/* Password Authentication Protocol */
1170Sstevel@tonic-gate #define	PPP_LQR		0xc025	/* Link Quality Report protocol */
1180Sstevel@tonic-gate #define	PPP_BACP	0xc02b	/* Bandwidth Allocation Control Protocol */
1190Sstevel@tonic-gate #define	PPP_BAP		0xc02d	/* Bandwidth Allocation Protocol */
1200Sstevel@tonic-gate #define	PPP_CBCP	0xc029	/* Callback Control Protocol */
1210Sstevel@tonic-gate #define	PPP_CHAP	0xc223	/* Challenge Handshake Auth. Protocol */
1220Sstevel@tonic-gate #define	PPP_EAP		0xc227	/* Extensible Authentication Protocol */
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * Values for FCS calculations.
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate #define	PPP_INITFCS	0xffff	/* Initial FCS value */
1280Sstevel@tonic-gate #define	PPP_GOODFCS	0xf0b8	/* Good final FCS value */
1290Sstevel@tonic-gate #define	PPP_FCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate #define	PPPINITFCS16	PPP_INITFCS
1320Sstevel@tonic-gate #define	PPPGOODFCS16	PPP_GOODFCS
1330Sstevel@tonic-gate #define	PPPFCS16(fcs, c)	PPP_FCS((fcs), (c))
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate #define	PPPINITFCS32	0xfffffffful
1360Sstevel@tonic-gate #define	PPPGOODFCS32	0xdebb20e3ul
1370Sstevel@tonic-gate #define	PPPFCS32(fcs, c) (((fcs) >> 8) ^ crc32_table[((fcs) ^ (c)) & 0xff])
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate /* Marker values shared between pppdump and pppd. */
1400Sstevel@tonic-gate #define	RECMARK_STARTSEND	1
1410Sstevel@tonic-gate #define	RECMARK_STARTRECV	2
1420Sstevel@tonic-gate #define	RECMARK_ENDSEND		3
1430Sstevel@tonic-gate #define	RECMARK_ENDRECV		4
1440Sstevel@tonic-gate #define	RECMARK_TIMEDELTA32	5
1450Sstevel@tonic-gate #define	RECMARK_TIMEDELTA8	6
1460Sstevel@tonic-gate #define	RECMARK_TIMESTART	7
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate /*
1490Sstevel@tonic-gate  * A 32-bit unsigned integral type.
1500Sstevel@tonic-gate  */
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) && \
1530Sstevel@tonic-gate 	!defined(__FreeBSD__) && (NS_TARGET < 40)
1540Sstevel@tonic-gate #ifdef	UINT32_T
1550Sstevel@tonic-gate typedef UINT32_T	u_int32_t;
1560Sstevel@tonic-gate #else
1570Sstevel@tonic-gate typedef unsigned int	u_int32_t;
1580Sstevel@tonic-gate typedef unsigned short  u_int16_t;
1590Sstevel@tonic-gate #endif
1600Sstevel@tonic-gate #endif
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #if defined(__sun) && !defined(_SYS_INT_TYPES_H) && !defined(_UINT32_T)
1630Sstevel@tonic-gate /* Backward compatibility */
1640Sstevel@tonic-gate typedef uint_t uint32_t;
1650Sstevel@tonic-gate typedef ushort_t uint16_t;
1660Sstevel@tonic-gate typedef uchar_t uint8_t;
1670Sstevel@tonic-gate typedef unsigned long uintptr_t;
1680Sstevel@tonic-gate #define	_UINT32_T
1690Sstevel@tonic-gate #endif
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate /*
1720Sstevel@tonic-gate  * Extended asyncmap - allows any character to be escaped.
1730Sstevel@tonic-gate  */
1740Sstevel@tonic-gate typedef u_int32_t	ext_accm[8];
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate /*
1770Sstevel@tonic-gate  * What to do with network protocol (NP) packets.
1780Sstevel@tonic-gate  */
1790Sstevel@tonic-gate enum NPmode {
1800Sstevel@tonic-gate     NPMODE_PASS,		/* pass the packet through */
1810Sstevel@tonic-gate     NPMODE_DROP,		/* silently drop the packet */
1820Sstevel@tonic-gate     NPMODE_ERROR,		/* return an error */
1830Sstevel@tonic-gate     NPMODE_QUEUE		/* save it up for later. */
1840Sstevel@tonic-gate };
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /*
1870Sstevel@tonic-gate  * Statistics.
1880Sstevel@tonic-gate  */
1890Sstevel@tonic-gate struct pppstat	{
1900Sstevel@tonic-gate     u_int32_t ppp_ibytes;	/* bytes received */
1910Sstevel@tonic-gate     u_int32_t ppp_ipackets;	/* packets received */
1920Sstevel@tonic-gate     u_int32_t ppp_ierrors;	/* receive errors */
1930Sstevel@tonic-gate     u_int32_t ppp_obytes;	/* bytes sent */
1940Sstevel@tonic-gate     u_int32_t ppp_opackets;	/* packets sent */
1950Sstevel@tonic-gate     u_int32_t ppp_oerrors;	/* transmit errors */
1960Sstevel@tonic-gate };
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate struct vjstat {
1990Sstevel@tonic-gate     u_int32_t vjs_packets;	/* outbound packets */
2000Sstevel@tonic-gate     u_int32_t vjs_compressed; /* outbound compressed packets */
2010Sstevel@tonic-gate     u_int32_t vjs_searches;	/* searches for connection state */
2020Sstevel@tonic-gate     u_int32_t vjs_misses;	/* times couldn't find conn. state */
2030Sstevel@tonic-gate     u_int32_t vjs_uncompressedin; /* inbound uncompressed packets */
2040Sstevel@tonic-gate     u_int32_t vjs_compressedin; /* inbound compressed packets */
2050Sstevel@tonic-gate     u_int32_t vjs_errorin;	/* inbound unknown type packets */
2060Sstevel@tonic-gate     u_int32_t vjs_tossed;	/* inbound packets tossed because of error */
2070Sstevel@tonic-gate };
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate struct ppp_stats {
2100Sstevel@tonic-gate     struct pppstat p;		/* basic PPP statistics */
2110Sstevel@tonic-gate     struct vjstat vj;		/* VJ header compression statistics */
2120Sstevel@tonic-gate };
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate #ifdef SOL2
2150Sstevel@tonic-gate #define	PPP_COUNTER_F	"llu"
2160Sstevel@tonic-gate typedef uint64_t	ppp_counter_t;
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate struct pppstat64 {
2190Sstevel@tonic-gate 	ppp_counter_t ppp_ibytes;	/* bytes received */
2200Sstevel@tonic-gate 	ppp_counter_t ppp_ipackets;	/* packets received */
2210Sstevel@tonic-gate 	ppp_counter_t ppp_ierrors;	/* receive errors */
2220Sstevel@tonic-gate 	ppp_counter_t ppp_obytes;	/* bytes sent */
2230Sstevel@tonic-gate 	ppp_counter_t ppp_opackets;	/* packets sent */
2240Sstevel@tonic-gate 	ppp_counter_t ppp_oerrors;	/* transmit errors */
2250Sstevel@tonic-gate };
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate struct ppp_stats64 {
2280Sstevel@tonic-gate 	struct pppstat64 p;
2290Sstevel@tonic-gate 	struct vjstat vj;
2300Sstevel@tonic-gate };
2310Sstevel@tonic-gate #else
2320Sstevel@tonic-gate #define	PPP_COUNTER_F	"u"
2330Sstevel@tonic-gate typedef u_int32_t	ppp_counter_t;
2340Sstevel@tonic-gate #endif
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate struct compstat {
2370Sstevel@tonic-gate     u_int32_t unc_bytes;	/* total uncompressed bytes */
2380Sstevel@tonic-gate     u_int32_t unc_packets;	/* total uncompressed packets */
2390Sstevel@tonic-gate     u_int32_t comp_bytes;	/* compressed bytes */
2400Sstevel@tonic-gate     u_int32_t comp_packets;	/* compressed packets */
2410Sstevel@tonic-gate     u_int32_t inc_bytes;	/* incompressible bytes */
2420Sstevel@tonic-gate     u_int32_t inc_packets;	/* incompressible packets */
2430Sstevel@tonic-gate     u_int32_t ratio;		/* recent compression ratio << 8 */
2440Sstevel@tonic-gate };
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate struct ppp_comp_stats {
2470Sstevel@tonic-gate     struct compstat c;		/* packet compression statistics */
2480Sstevel@tonic-gate     struct compstat d;		/* packet decompression statistics */
2490Sstevel@tonic-gate };
2500Sstevel@tonic-gate 
2510Sstevel@tonic-gate /*
2520Sstevel@tonic-gate  * The following structure records the time in seconds since
2530Sstevel@tonic-gate  * the last NP packet was sent or received.
2540Sstevel@tonic-gate  */
2550Sstevel@tonic-gate struct ppp_idle {
2560Sstevel@tonic-gate 	/*
2570Sstevel@tonic-gate 	 * Fix the length of these fields to be 32-bit, since
2580Sstevel@tonic-gate 	 * otherwise, a time_t (long) is 64-bit in kernel while 32-bit
2590Sstevel@tonic-gate 	 * in userland when running on a 64-bit CPU with a 64-bit OS.
2600Sstevel@tonic-gate 	 */
2610Sstevel@tonic-gate     u_int32_t xmit_idle;	/* time since last NP packet sent */
2620Sstevel@tonic-gate     u_int32_t recv_idle;	/* time since last NP packet received */
2630Sstevel@tonic-gate };
2640Sstevel@tonic-gate 
2650Sstevel@tonic-gate enum LSstat {
2660Sstevel@tonic-gate     PPP_LINKSTAT_HANGUP = 0xabcd, /* link is hung up */
2670Sstevel@tonic-gate     PPP_LINKSTAT_NEEDUP,	/* link is down and needs to be up */
2680Sstevel@tonic-gate     PPP_LINKSTAT_IPV4_UNBOUND,	/* DL_UNBIND received on IPv4 stream */
2690Sstevel@tonic-gate     PPP_LINKSTAT_IPV6_UNBOUND,	/* DL_UNBIND received on IPv6 stream */
2700Sstevel@tonic-gate     PPP_LINKSTAT_IPV4_BOUND,	/* DL_BIND received on IPv4 stream */
2710Sstevel@tonic-gate     PPP_LINKSTAT_IPV6_BOUND,	/* DL_BIND received on IPv6 stream */
2720Sstevel@tonic-gate     PPP_LINKSTAT_UP		/* Integrated driver; hardware is up */
2730Sstevel@tonic-gate };
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate #define	PPPLSMAGIC	0x53505050
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate struct ppp_ls {
2780Sstevel@tonic-gate     u_int32_t magic;		/* magic number identifier (PPPLSMAGIC) */
2790Sstevel@tonic-gate     u_int32_t ppp_message;	/* link status message */
2800Sstevel@tonic-gate };
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate #ifndef __P
2830Sstevel@tonic-gate #ifdef __STDC__
2840Sstevel@tonic-gate #define	__P(x)	x
2850Sstevel@tonic-gate #else
2860Sstevel@tonic-gate #define	__P(x)	()
2870Sstevel@tonic-gate #endif
2880Sstevel@tonic-gate #endif
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate #ifdef __cplusplus
2910Sstevel@tonic-gate }
2920Sstevel@tonic-gate #endif
2930Sstevel@tonic-gate 
2940Sstevel@tonic-gate #endif /* _PPP_DEFS_H_ */
295