xref: /onnv-gate/usr/src/uts/common/net/ppp-comp.h (revision 420:45e68e7aede3)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * ppp-comp.h - Definitions for doing PPP packet compression.
30Sstevel@tonic-gate  *
4*420Sstevel  * Copyright 2000 Sun Microsystems, Inc.  All rights reserved.
5*420Sstevel  * Use is subject to license terms.
60Sstevel@tonic-gate  *
70Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
80Sstevel@tonic-gate  * All rights reserved.
90Sstevel@tonic-gate  *
100Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
110Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
120Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
130Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
140Sstevel@tonic-gate  * makes no representations about the suitability of this software for
150Sstevel@tonic-gate  * any purpose.
160Sstevel@tonic-gate  *
170Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
180Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
190Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
200Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
210Sstevel@tonic-gate  * OF SUCH DAMAGE.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
240Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
250Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
260Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
270Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
280Sstevel@tonic-gate  * OR MODIFICATIONS.
290Sstevel@tonic-gate  *
300Sstevel@tonic-gate  * $Id: ppp-comp.h,v 1.11 1998/03/25 03:33:34 paulus Exp $
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifndef _NET_PPP_COMP_H
340Sstevel@tonic-gate #define	_NET_PPP_COMP_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 following symbols control whether we include code for
440Sstevel@tonic-gate  * various compression methods.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate #ifndef DO_BSD_COMPRESS
470Sstevel@tonic-gate #define	DO_BSD_COMPRESS	1	/* by default, include BSD-Compress */
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate #ifndef DO_DEFLATE
500Sstevel@tonic-gate #define	DO_DEFLATE	1	/* by default, include Deflate */
510Sstevel@tonic-gate #endif
520Sstevel@tonic-gate #define	DO_PREDICTOR_1	0
530Sstevel@tonic-gate #define	DO_PREDICTOR_2	0
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * Structure giving methods for compression/decompression.
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate #ifdef PACKETPTR
590Sstevel@tonic-gate struct compressor {
600Sstevel@tonic-gate 	int	compress_proto;	/* CCP compression protocol number */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	/* Allocate space for a compressor (transmit side) */
630Sstevel@tonic-gate 	void	*(*comp_alloc) __P((uchar_t *options, int opt_len));
640Sstevel@tonic-gate 	/* Free space used by a compressor */
650Sstevel@tonic-gate 	void	(*comp_free) __P((void *state));
660Sstevel@tonic-gate 	/* Initialize a compressor */
670Sstevel@tonic-gate 	int	(*comp_init) __P((void *state, uchar_t *options, int opt_len,
680Sstevel@tonic-gate 	    int unit, int hdrlen, int debug));
690Sstevel@tonic-gate 	/* Reset a compressor */
700Sstevel@tonic-gate 	void	(*comp_reset) __P((void *state));
710Sstevel@tonic-gate 	/* Compress a packet */
720Sstevel@tonic-gate 	int	(*compress) __P((void *state, PACKETPTR *mret,
730Sstevel@tonic-gate 	    PACKETPTR mp, int orig_len, int max_len));
740Sstevel@tonic-gate 	/* Return compression statistics */
750Sstevel@tonic-gate 	void	(*comp_stat) __P((void *state, struct compstat *stats));
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 	/* Allocate space for a decompressor (receive side) */
780Sstevel@tonic-gate 	void	*(*decomp_alloc) __P((uchar_t *options, int opt_len));
790Sstevel@tonic-gate 	/* Free space used by a decompressor */
800Sstevel@tonic-gate 	void	(*decomp_free) __P((void *state));
810Sstevel@tonic-gate 	/* Initialize a decompressor */
820Sstevel@tonic-gate 	int	(*decomp_init) __P((void *state, uchar_t *options, int opt_len,
830Sstevel@tonic-gate 				    int unit, int hdrlen, int mru, int debug));
840Sstevel@tonic-gate 	/* Reset a decompressor */
850Sstevel@tonic-gate 	void	(*decomp_reset) __P((void *state));
860Sstevel@tonic-gate 	/* Decompress a packet. */
870Sstevel@tonic-gate 	int	(*decompress) __P((void *state, PACKETPTR *mp));
880Sstevel@tonic-gate 	/* Update state for an incompressible packet received */
890Sstevel@tonic-gate 	int	(*incomp) __P((void *state, PACKETPTR mp));
900Sstevel@tonic-gate 	/* Return decompression statistics */
910Sstevel@tonic-gate 	void	(*decomp_stat) __P((void *state, struct compstat *stats));
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 	/* Set or change compression effort level */
940Sstevel@tonic-gate 	int	(*set_effort) __P((void *xstate, void *rstate,
950Sstevel@tonic-gate 	    int effortlevel));
960Sstevel@tonic-gate };
970Sstevel@tonic-gate #endif /* PACKETPTR */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1000Sstevel@tonic-gate  * Return values for decompress routine.
1010Sstevel@tonic-gate  * We need to make these distinctions so that we can disable certain
1020Sstevel@tonic-gate  * useful functionality, namely sending a CCP reset-request as a result
1030Sstevel@tonic-gate  * of an error detected after decompression.  This is to avoid infringing
1040Sstevel@tonic-gate  * a patent held by Motorola.
1050Sstevel@tonic-gate  * Don't you just lurve software patents.
1060Sstevel@tonic-gate  */
1070Sstevel@tonic-gate #define	DECOMP_OK		0	/* everything went OK */
1080Sstevel@tonic-gate #define	DECOMP_ERROR		1	/* error detected before decomp. */
1090Sstevel@tonic-gate #define	DECOMP_FATALERROR	2	/* error detected after decomp. */
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate /*
1120Sstevel@tonic-gate  * CCP codes.
1130Sstevel@tonic-gate  */
1140Sstevel@tonic-gate #define	CCP_CONFREQ	1
1150Sstevel@tonic-gate #define	CCP_CONFACK	2
1160Sstevel@tonic-gate #define	CCP_TERMREQ	5
1170Sstevel@tonic-gate #define	CCP_TERMACK	6
1180Sstevel@tonic-gate #define	CCP_RESETREQ	14
1190Sstevel@tonic-gate #define	CCP_RESETACK	15
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate /*
1220Sstevel@tonic-gate  * Max # bytes for a CCP option
1230Sstevel@tonic-gate  */
1240Sstevel@tonic-gate #define	CCP_MAX_OPTION_LENGTH	32
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate /*
1270Sstevel@tonic-gate  * Parts of a CCP packet.
1280Sstevel@tonic-gate  */
1290Sstevel@tonic-gate #define	CCP_CODE(dp)		((dp)[0])
1300Sstevel@tonic-gate #define	CCP_ID(dp)		((dp)[1])
1310Sstevel@tonic-gate #define	CCP_LENGTH(dp)		(((dp)[2] << 8) + (dp)[3])
1320Sstevel@tonic-gate #define	CCP_HDRLEN		4
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate #define	CCP_OPT_CODE(dp)	((dp)[0])
1350Sstevel@tonic-gate #define	CCP_OPT_LENGTH(dp)	((dp)[1])
1360Sstevel@tonic-gate #define	CCP_OPT_MINLEN		2
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate  * Definitions for BSD-Compress.
1400Sstevel@tonic-gate  */
1410Sstevel@tonic-gate #define	CI_BSD_COMPRESS		21	/* config. option for BSD-Compress */
1420Sstevel@tonic-gate #define	CILEN_BSD_COMPRESS	3	/* length of config. option */
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate /* Macros for handling the 3rd byte of the BSD-Compress config option. */
1450Sstevel@tonic-gate #define	BSD_NBITS(x)		((x) & 0x1F)	/* number of bits requested */
1460Sstevel@tonic-gate #define	BSD_VERSION(x)		((x) >> 5)	/* version of option format */
1470Sstevel@tonic-gate #define	BSD_CURRENT_VERSION	1		/* current version number */
1480Sstevel@tonic-gate #define	BSD_MAKE_OPT(v, n)	(((v) << 5) | (n))
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate #define	BSD_MIN_BITS		9	/* smallest code size supported */
1510Sstevel@tonic-gate #define	BSD_MAX_BITS		15	/* largest code size supported */
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate /*
1540Sstevel@tonic-gate  * Definitions for Deflate.
1550Sstevel@tonic-gate  */
1560Sstevel@tonic-gate #define	CI_DEFLATE		26	/* config option for Deflate */
1570Sstevel@tonic-gate #define	CI_DEFLATE_DRAFT	24	/* value used in original draft RFC */
1580Sstevel@tonic-gate #define	CILEN_DEFLATE		4	/* length of its config option */
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate #define	DEFLATE_MIN_SIZE	8
1610Sstevel@tonic-gate #define	DEFLATE_MAX_SIZE	15
1620Sstevel@tonic-gate #define	DEFLATE_METHOD_VAL	8
1630Sstevel@tonic-gate #define	DEFLATE_SIZE(x)		(((x) >> 4) + DEFLATE_MIN_SIZE)
1640Sstevel@tonic-gate #define	DEFLATE_METHOD(x)	((x) & 0x0F)
1650Sstevel@tonic-gate #define	DEFLATE_MAKE_OPT(w)	((((w) - DEFLATE_MIN_SIZE) << 4) \
1660Sstevel@tonic-gate 				    + DEFLATE_METHOD_VAL)
1670Sstevel@tonic-gate #define	DEFLATE_CHK_SEQUENCE	0
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate /*
1700Sstevel@tonic-gate  * Definitions for other, as yet unsupported, compression methods.
1710Sstevel@tonic-gate  */
1720Sstevel@tonic-gate #define	CI_PREDICTOR_1		1	/* config option for Predictor-1 */
1730Sstevel@tonic-gate #define	CILEN_PREDICTOR_1	2	/* length of its config option */
1740Sstevel@tonic-gate #define	CI_PREDICTOR_2		2	/* config option for Predictor-2 */
1750Sstevel@tonic-gate #define	CILEN_PREDICTOR_2	2	/* length of its config option */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate  * Note that some systems emit requests for STAC using a length of 6.
1790Sstevel@tonic-gate  * The extra octet is 00 and should be ignored.
1800Sstevel@tonic-gate  */
1810Sstevel@tonic-gate #define	CI_STAC			17	/* config option for STAC LZS */
1820Sstevel@tonic-gate #define	CILEN_STAC		5	/* length of its config option */
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate #define	STAC_CHK_NONE		0	/* No checking */
1850Sstevel@tonic-gate #define	STAC_CHK_LCB		1	/* Longitudinal Check Bytes */
1860Sstevel@tonic-gate #define	STAC_CHK_CRC		2	/* Cyclic Redundancy Check */
1870Sstevel@tonic-gate #define	STAC_CHK_SEQ		3	/* Sequence Number */
1880Sstevel@tonic-gate #define	STAC_CHK_EXTENDED	4	/* Extended (Microsoft) */
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate #define	CI_MPPC			18	/* config option for MS-PPC */
1910Sstevel@tonic-gate #define	CILEN_MPPC		6	/* length of its config option */
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate #define	MPPC_COMP		0x00000001	/* Compression */
1940Sstevel@tonic-gate #define	MPPC_40LANM		0x00000010	/* MPPE, 40 bit LANManager */
1950Sstevel@tonic-gate #define	MPPC_40NT		0x00000020	/* MPPE, 40 bit NT key */
1960Sstevel@tonic-gate #define	MPPC_128NT		0x00000040	/* MPPE, 128 bit NT key */
1970Sstevel@tonic-gate #define	MPPC_56NT		0x00000080	/* MPPE, 56 bit NT key */
1980Sstevel@tonic-gate #define	MPPC_PBP		0x01000000	/* Packet-by-Packet mode */
1990Sstevel@tonic-gate #define	MPPC_MPPE		0x000000F0
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate #ifdef __cplusplus
2020Sstevel@tonic-gate }
2030Sstevel@tonic-gate #endif
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate #endif /* _NET_PPP_COMP_H */
206