xref: /illumos-gate/usr/src/uts/common/net/ppp-comp.h (revision a0b85df4)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * ppp-comp.h - Definitions for doing PPP packet compression.
37c478bd9Sstevel@tonic-gate  *
4*a0b85df4Sstevel  * Copyright 2000 Sun Microsystems, Inc.  All rights reserved.
5*a0b85df4Sstevel  * Use is subject to license terms.
67c478bd9Sstevel@tonic-gate  *
77c478bd9Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
87c478bd9Sstevel@tonic-gate  * All rights reserved.
97c478bd9Sstevel@tonic-gate  *
107c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
117c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
127c478bd9Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
137c478bd9Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
147c478bd9Sstevel@tonic-gate  * makes no representations about the suitability of this software for
157c478bd9Sstevel@tonic-gate  * any purpose.
167c478bd9Sstevel@tonic-gate  *
177c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
187c478bd9Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
197c478bd9Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
207c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
217c478bd9Sstevel@tonic-gate  * OF SUCH DAMAGE.
227c478bd9Sstevel@tonic-gate  *
237c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
247c478bd9Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
257c478bd9Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
267c478bd9Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
277c478bd9Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
287c478bd9Sstevel@tonic-gate  * OR MODIFICATIONS.
297c478bd9Sstevel@tonic-gate  *
307c478bd9Sstevel@tonic-gate  * $Id: ppp-comp.h,v 1.11 1998/03/25 03:33:34 paulus Exp $
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef _NET_PPP_COMP_H
347c478bd9Sstevel@tonic-gate #define	_NET_PPP_COMP_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef __cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * The following symbols control whether we include code for
447c478bd9Sstevel@tonic-gate  * various compression methods.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #ifndef DO_BSD_COMPRESS
477c478bd9Sstevel@tonic-gate #define	DO_BSD_COMPRESS	1	/* by default, include BSD-Compress */
487c478bd9Sstevel@tonic-gate #endif
497c478bd9Sstevel@tonic-gate #ifndef DO_DEFLATE
507c478bd9Sstevel@tonic-gate #define	DO_DEFLATE	1	/* by default, include Deflate */
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate #define	DO_PREDICTOR_1	0
537c478bd9Sstevel@tonic-gate #define	DO_PREDICTOR_2	0
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * Structure giving methods for compression/decompression.
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate #ifdef PACKETPTR
597c478bd9Sstevel@tonic-gate struct compressor {
607c478bd9Sstevel@tonic-gate 	int	compress_proto;	/* CCP compression protocol number */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	/* Allocate space for a compressor (transmit side) */
637c478bd9Sstevel@tonic-gate 	void	*(*comp_alloc) __P((uchar_t *options, int opt_len));
647c478bd9Sstevel@tonic-gate 	/* Free space used by a compressor */
657c478bd9Sstevel@tonic-gate 	void	(*comp_free) __P((void *state));
667c478bd9Sstevel@tonic-gate 	/* Initialize a compressor */
677c478bd9Sstevel@tonic-gate 	int	(*comp_init) __P((void *state, uchar_t *options, int opt_len,
687c478bd9Sstevel@tonic-gate 	    int unit, int hdrlen, int debug));
697c478bd9Sstevel@tonic-gate 	/* Reset a compressor */
707c478bd9Sstevel@tonic-gate 	void	(*comp_reset) __P((void *state));
717c478bd9Sstevel@tonic-gate 	/* Compress a packet */
727c478bd9Sstevel@tonic-gate 	int	(*compress) __P((void *state, PACKETPTR *mret,
737c478bd9Sstevel@tonic-gate 	    PACKETPTR mp, int orig_len, int max_len));
747c478bd9Sstevel@tonic-gate 	/* Return compression statistics */
757c478bd9Sstevel@tonic-gate 	void	(*comp_stat) __P((void *state, struct compstat *stats));
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 	/* Allocate space for a decompressor (receive side) */
787c478bd9Sstevel@tonic-gate 	void	*(*decomp_alloc) __P((uchar_t *options, int opt_len));
797c478bd9Sstevel@tonic-gate 	/* Free space used by a decompressor */
807c478bd9Sstevel@tonic-gate 	void	(*decomp_free) __P((void *state));
817c478bd9Sstevel@tonic-gate 	/* Initialize a decompressor */
827c478bd9Sstevel@tonic-gate 	int	(*decomp_init) __P((void *state, uchar_t *options, int opt_len,
837c478bd9Sstevel@tonic-gate 				    int unit, int hdrlen, int mru, int debug));
847c478bd9Sstevel@tonic-gate 	/* Reset a decompressor */
857c478bd9Sstevel@tonic-gate 	void	(*decomp_reset) __P((void *state));
867c478bd9Sstevel@tonic-gate 	/* Decompress a packet. */
877c478bd9Sstevel@tonic-gate 	int	(*decompress) __P((void *state, PACKETPTR *mp));
887c478bd9Sstevel@tonic-gate 	/* Update state for an incompressible packet received */
897c478bd9Sstevel@tonic-gate 	int	(*incomp) __P((void *state, PACKETPTR mp));
907c478bd9Sstevel@tonic-gate 	/* Return decompression statistics */
917c478bd9Sstevel@tonic-gate 	void	(*decomp_stat) __P((void *state, struct compstat *stats));
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	/* Set or change compression effort level */
947c478bd9Sstevel@tonic-gate 	int	(*set_effort) __P((void *xstate, void *rstate,
957c478bd9Sstevel@tonic-gate 	    int effortlevel));
967c478bd9Sstevel@tonic-gate };
977c478bd9Sstevel@tonic-gate #endif /* PACKETPTR */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /*
1007c478bd9Sstevel@tonic-gate  * Return values for decompress routine.
1017c478bd9Sstevel@tonic-gate  * We need to make these distinctions so that we can disable certain
1027c478bd9Sstevel@tonic-gate  * useful functionality, namely sending a CCP reset-request as a result
1037c478bd9Sstevel@tonic-gate  * of an error detected after decompression.  This is to avoid infringing
1047c478bd9Sstevel@tonic-gate  * a patent held by Motorola.
1057c478bd9Sstevel@tonic-gate  * Don't you just lurve software patents.
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate #define	DECOMP_OK		0	/* everything went OK */
1087c478bd9Sstevel@tonic-gate #define	DECOMP_ERROR		1	/* error detected before decomp. */
1097c478bd9Sstevel@tonic-gate #define	DECOMP_FATALERROR	2	/* error detected after decomp. */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate  * CCP codes.
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate #define	CCP_CONFREQ	1
1157c478bd9Sstevel@tonic-gate #define	CCP_CONFACK	2
1167c478bd9Sstevel@tonic-gate #define	CCP_TERMREQ	5
1177c478bd9Sstevel@tonic-gate #define	CCP_TERMACK	6
1187c478bd9Sstevel@tonic-gate #define	CCP_RESETREQ	14
1197c478bd9Sstevel@tonic-gate #define	CCP_RESETACK	15
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Max # bytes for a CCP option
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate #define	CCP_MAX_OPTION_LENGTH	32
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  * Parts of a CCP packet.
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate #define	CCP_CODE(dp)		((dp)[0])
1307c478bd9Sstevel@tonic-gate #define	CCP_ID(dp)		((dp)[1])
1317c478bd9Sstevel@tonic-gate #define	CCP_LENGTH(dp)		(((dp)[2] << 8) + (dp)[3])
1327c478bd9Sstevel@tonic-gate #define	CCP_HDRLEN		4
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #define	CCP_OPT_CODE(dp)	((dp)[0])
1357c478bd9Sstevel@tonic-gate #define	CCP_OPT_LENGTH(dp)	((dp)[1])
1367c478bd9Sstevel@tonic-gate #define	CCP_OPT_MINLEN		2
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * Definitions for BSD-Compress.
1407c478bd9Sstevel@tonic-gate  */
1417c478bd9Sstevel@tonic-gate #define	CI_BSD_COMPRESS		21	/* config. option for BSD-Compress */
1427c478bd9Sstevel@tonic-gate #define	CILEN_BSD_COMPRESS	3	/* length of config. option */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate /* Macros for handling the 3rd byte of the BSD-Compress config option. */
1457c478bd9Sstevel@tonic-gate #define	BSD_NBITS(x)		((x) & 0x1F)	/* number of bits requested */
1467c478bd9Sstevel@tonic-gate #define	BSD_VERSION(x)		((x) >> 5)	/* version of option format */
1477c478bd9Sstevel@tonic-gate #define	BSD_CURRENT_VERSION	1		/* current version number */
1487c478bd9Sstevel@tonic-gate #define	BSD_MAKE_OPT(v, n)	(((v) << 5) | (n))
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #define	BSD_MIN_BITS		9	/* smallest code size supported */
1517c478bd9Sstevel@tonic-gate #define	BSD_MAX_BITS		15	/* largest code size supported */
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate  * Definitions for Deflate.
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate #define	CI_DEFLATE		26	/* config option for Deflate */
1577c478bd9Sstevel@tonic-gate #define	CI_DEFLATE_DRAFT	24	/* value used in original draft RFC */
1587c478bd9Sstevel@tonic-gate #define	CILEN_DEFLATE		4	/* length of its config option */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #define	DEFLATE_MIN_SIZE	8
1617c478bd9Sstevel@tonic-gate #define	DEFLATE_MAX_SIZE	15
1627c478bd9Sstevel@tonic-gate #define	DEFLATE_METHOD_VAL	8
1637c478bd9Sstevel@tonic-gate #define	DEFLATE_SIZE(x)		(((x) >> 4) + DEFLATE_MIN_SIZE)
1647c478bd9Sstevel@tonic-gate #define	DEFLATE_METHOD(x)	((x) & 0x0F)
1657c478bd9Sstevel@tonic-gate #define	DEFLATE_MAKE_OPT(w)	((((w) - DEFLATE_MIN_SIZE) << 4) \
1667c478bd9Sstevel@tonic-gate 				    + DEFLATE_METHOD_VAL)
1677c478bd9Sstevel@tonic-gate #define	DEFLATE_CHK_SEQUENCE	0
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * Definitions for other, as yet unsupported, compression methods.
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate #define	CI_PREDICTOR_1		1	/* config option for Predictor-1 */
1737c478bd9Sstevel@tonic-gate #define	CILEN_PREDICTOR_1	2	/* length of its config option */
1747c478bd9Sstevel@tonic-gate #define	CI_PREDICTOR_2		2	/* config option for Predictor-2 */
1757c478bd9Sstevel@tonic-gate #define	CILEN_PREDICTOR_2	2	/* length of its config option */
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  * Note that some systems emit requests for STAC using a length of 6.
1797c478bd9Sstevel@tonic-gate  * The extra octet is 00 and should be ignored.
1807c478bd9Sstevel@tonic-gate  */
1817c478bd9Sstevel@tonic-gate #define	CI_STAC			17	/* config option for STAC LZS */
1827c478bd9Sstevel@tonic-gate #define	CILEN_STAC		5	/* length of its config option */
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #define	STAC_CHK_NONE		0	/* No checking */
1857c478bd9Sstevel@tonic-gate #define	STAC_CHK_LCB		1	/* Longitudinal Check Bytes */
1867c478bd9Sstevel@tonic-gate #define	STAC_CHK_CRC		2	/* Cyclic Redundancy Check */
1877c478bd9Sstevel@tonic-gate #define	STAC_CHK_SEQ		3	/* Sequence Number */
1887c478bd9Sstevel@tonic-gate #define	STAC_CHK_EXTENDED	4	/* Extended (Microsoft) */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate #define	CI_MPPC			18	/* config option for MS-PPC */
1917c478bd9Sstevel@tonic-gate #define	CILEN_MPPC		6	/* length of its config option */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #define	MPPC_COMP		0x00000001	/* Compression */
1947c478bd9Sstevel@tonic-gate #define	MPPC_40LANM		0x00000010	/* MPPE, 40 bit LANManager */
1957c478bd9Sstevel@tonic-gate #define	MPPC_40NT		0x00000020	/* MPPE, 40 bit NT key */
1967c478bd9Sstevel@tonic-gate #define	MPPC_128NT		0x00000040	/* MPPE, 128 bit NT key */
1977c478bd9Sstevel@tonic-gate #define	MPPC_56NT		0x00000080	/* MPPE, 56 bit NT key */
1987c478bd9Sstevel@tonic-gate #define	MPPC_PBP		0x01000000	/* Packet-by-Packet mode */
1997c478bd9Sstevel@tonic-gate #define	MPPC_MPPE		0x000000F0
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate #endif
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #endif /* _NET_PPP_COMP_H */
206