xref: /illumos-gate/usr/src/uts/common/net/ppp-comp.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * ppp-comp.h - Definitions for doing PPP packet compression.
24*7c478bd9Sstevel@tonic-gate  *
25*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000 by Sun Microsystems, Inc.
26*7c478bd9Sstevel@tonic-gate  * All rights reserved.
27*7c478bd9Sstevel@tonic-gate  *
28*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
29*7c478bd9Sstevel@tonic-gate  * All rights reserved.
30*7c478bd9Sstevel@tonic-gate  *
31*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
32*7c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
33*7c478bd9Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
34*7c478bd9Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
35*7c478bd9Sstevel@tonic-gate  * makes no representations about the suitability of this software for
36*7c478bd9Sstevel@tonic-gate  * any purpose.
37*7c478bd9Sstevel@tonic-gate  *
38*7c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
39*7c478bd9Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
40*7c478bd9Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
41*7c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
42*7c478bd9Sstevel@tonic-gate  * OF SUCH DAMAGE.
43*7c478bd9Sstevel@tonic-gate  *
44*7c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
45*7c478bd9Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
46*7c478bd9Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
47*7c478bd9Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
48*7c478bd9Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
49*7c478bd9Sstevel@tonic-gate  * OR MODIFICATIONS.
50*7c478bd9Sstevel@tonic-gate  *
51*7c478bd9Sstevel@tonic-gate  * $Id: ppp-comp.h,v 1.11 1998/03/25 03:33:34 paulus Exp $
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #ifndef _NET_PPP_COMP_H
55*7c478bd9Sstevel@tonic-gate #define	_NET_PPP_COMP_H
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
60*7c478bd9Sstevel@tonic-gate extern "C" {
61*7c478bd9Sstevel@tonic-gate #endif
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * The following symbols control whether we include code for
65*7c478bd9Sstevel@tonic-gate  * various compression methods.
66*7c478bd9Sstevel@tonic-gate  */
67*7c478bd9Sstevel@tonic-gate #ifndef DO_BSD_COMPRESS
68*7c478bd9Sstevel@tonic-gate #define	DO_BSD_COMPRESS	1	/* by default, include BSD-Compress */
69*7c478bd9Sstevel@tonic-gate #endif
70*7c478bd9Sstevel@tonic-gate #ifndef DO_DEFLATE
71*7c478bd9Sstevel@tonic-gate #define	DO_DEFLATE	1	/* by default, include Deflate */
72*7c478bd9Sstevel@tonic-gate #endif
73*7c478bd9Sstevel@tonic-gate #define	DO_PREDICTOR_1	0
74*7c478bd9Sstevel@tonic-gate #define	DO_PREDICTOR_2	0
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /*
77*7c478bd9Sstevel@tonic-gate  * Structure giving methods for compression/decompression.
78*7c478bd9Sstevel@tonic-gate  */
79*7c478bd9Sstevel@tonic-gate #ifdef PACKETPTR
80*7c478bd9Sstevel@tonic-gate struct compressor {
81*7c478bd9Sstevel@tonic-gate 	int	compress_proto;	/* CCP compression protocol number */
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate 	/* Allocate space for a compressor (transmit side) */
84*7c478bd9Sstevel@tonic-gate 	void	*(*comp_alloc) __P((uchar_t *options, int opt_len));
85*7c478bd9Sstevel@tonic-gate 	/* Free space used by a compressor */
86*7c478bd9Sstevel@tonic-gate 	void	(*comp_free) __P((void *state));
87*7c478bd9Sstevel@tonic-gate 	/* Initialize a compressor */
88*7c478bd9Sstevel@tonic-gate 	int	(*comp_init) __P((void *state, uchar_t *options, int opt_len,
89*7c478bd9Sstevel@tonic-gate 	    int unit, int hdrlen, int debug));
90*7c478bd9Sstevel@tonic-gate 	/* Reset a compressor */
91*7c478bd9Sstevel@tonic-gate 	void	(*comp_reset) __P((void *state));
92*7c478bd9Sstevel@tonic-gate 	/* Compress a packet */
93*7c478bd9Sstevel@tonic-gate 	int	(*compress) __P((void *state, PACKETPTR *mret,
94*7c478bd9Sstevel@tonic-gate 	    PACKETPTR mp, int orig_len, int max_len));
95*7c478bd9Sstevel@tonic-gate 	/* Return compression statistics */
96*7c478bd9Sstevel@tonic-gate 	void	(*comp_stat) __P((void *state, struct compstat *stats));
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 	/* Allocate space for a decompressor (receive side) */
99*7c478bd9Sstevel@tonic-gate 	void	*(*decomp_alloc) __P((uchar_t *options, int opt_len));
100*7c478bd9Sstevel@tonic-gate 	/* Free space used by a decompressor */
101*7c478bd9Sstevel@tonic-gate 	void	(*decomp_free) __P((void *state));
102*7c478bd9Sstevel@tonic-gate 	/* Initialize a decompressor */
103*7c478bd9Sstevel@tonic-gate 	int	(*decomp_init) __P((void *state, uchar_t *options, int opt_len,
104*7c478bd9Sstevel@tonic-gate 				    int unit, int hdrlen, int mru, int debug));
105*7c478bd9Sstevel@tonic-gate 	/* Reset a decompressor */
106*7c478bd9Sstevel@tonic-gate 	void	(*decomp_reset) __P((void *state));
107*7c478bd9Sstevel@tonic-gate 	/* Decompress a packet. */
108*7c478bd9Sstevel@tonic-gate 	int	(*decompress) __P((void *state, PACKETPTR *mp));
109*7c478bd9Sstevel@tonic-gate 	/* Update state for an incompressible packet received */
110*7c478bd9Sstevel@tonic-gate 	int	(*incomp) __P((void *state, PACKETPTR mp));
111*7c478bd9Sstevel@tonic-gate 	/* Return decompression statistics */
112*7c478bd9Sstevel@tonic-gate 	void	(*decomp_stat) __P((void *state, struct compstat *stats));
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate 	/* Set or change compression effort level */
115*7c478bd9Sstevel@tonic-gate 	int	(*set_effort) __P((void *xstate, void *rstate,
116*7c478bd9Sstevel@tonic-gate 	    int effortlevel));
117*7c478bd9Sstevel@tonic-gate };
118*7c478bd9Sstevel@tonic-gate #endif /* PACKETPTR */
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate /*
121*7c478bd9Sstevel@tonic-gate  * Return values for decompress routine.
122*7c478bd9Sstevel@tonic-gate  * We need to make these distinctions so that we can disable certain
123*7c478bd9Sstevel@tonic-gate  * useful functionality, namely sending a CCP reset-request as a result
124*7c478bd9Sstevel@tonic-gate  * of an error detected after decompression.  This is to avoid infringing
125*7c478bd9Sstevel@tonic-gate  * a patent held by Motorola.
126*7c478bd9Sstevel@tonic-gate  * Don't you just lurve software patents.
127*7c478bd9Sstevel@tonic-gate  */
128*7c478bd9Sstevel@tonic-gate #define	DECOMP_OK		0	/* everything went OK */
129*7c478bd9Sstevel@tonic-gate #define	DECOMP_ERROR		1	/* error detected before decomp. */
130*7c478bd9Sstevel@tonic-gate #define	DECOMP_FATALERROR	2	/* error detected after decomp. */
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate  * CCP codes.
134*7c478bd9Sstevel@tonic-gate  */
135*7c478bd9Sstevel@tonic-gate #define	CCP_CONFREQ	1
136*7c478bd9Sstevel@tonic-gate #define	CCP_CONFACK	2
137*7c478bd9Sstevel@tonic-gate #define	CCP_TERMREQ	5
138*7c478bd9Sstevel@tonic-gate #define	CCP_TERMACK	6
139*7c478bd9Sstevel@tonic-gate #define	CCP_RESETREQ	14
140*7c478bd9Sstevel@tonic-gate #define	CCP_RESETACK	15
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate /*
143*7c478bd9Sstevel@tonic-gate  * Max # bytes for a CCP option
144*7c478bd9Sstevel@tonic-gate  */
145*7c478bd9Sstevel@tonic-gate #define	CCP_MAX_OPTION_LENGTH	32
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate /*
148*7c478bd9Sstevel@tonic-gate  * Parts of a CCP packet.
149*7c478bd9Sstevel@tonic-gate  */
150*7c478bd9Sstevel@tonic-gate #define	CCP_CODE(dp)		((dp)[0])
151*7c478bd9Sstevel@tonic-gate #define	CCP_ID(dp)		((dp)[1])
152*7c478bd9Sstevel@tonic-gate #define	CCP_LENGTH(dp)		(((dp)[2] << 8) + (dp)[3])
153*7c478bd9Sstevel@tonic-gate #define	CCP_HDRLEN		4
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #define	CCP_OPT_CODE(dp)	((dp)[0])
156*7c478bd9Sstevel@tonic-gate #define	CCP_OPT_LENGTH(dp)	((dp)[1])
157*7c478bd9Sstevel@tonic-gate #define	CCP_OPT_MINLEN		2
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /*
160*7c478bd9Sstevel@tonic-gate  * Definitions for BSD-Compress.
161*7c478bd9Sstevel@tonic-gate  */
162*7c478bd9Sstevel@tonic-gate #define	CI_BSD_COMPRESS		21	/* config. option for BSD-Compress */
163*7c478bd9Sstevel@tonic-gate #define	CILEN_BSD_COMPRESS	3	/* length of config. option */
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate /* Macros for handling the 3rd byte of the BSD-Compress config option. */
166*7c478bd9Sstevel@tonic-gate #define	BSD_NBITS(x)		((x) & 0x1F)	/* number of bits requested */
167*7c478bd9Sstevel@tonic-gate #define	BSD_VERSION(x)		((x) >> 5)	/* version of option format */
168*7c478bd9Sstevel@tonic-gate #define	BSD_CURRENT_VERSION	1		/* current version number */
169*7c478bd9Sstevel@tonic-gate #define	BSD_MAKE_OPT(v, n)	(((v) << 5) | (n))
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate #define	BSD_MIN_BITS		9	/* smallest code size supported */
172*7c478bd9Sstevel@tonic-gate #define	BSD_MAX_BITS		15	/* largest code size supported */
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate /*
175*7c478bd9Sstevel@tonic-gate  * Definitions for Deflate.
176*7c478bd9Sstevel@tonic-gate  */
177*7c478bd9Sstevel@tonic-gate #define	CI_DEFLATE		26	/* config option for Deflate */
178*7c478bd9Sstevel@tonic-gate #define	CI_DEFLATE_DRAFT	24	/* value used in original draft RFC */
179*7c478bd9Sstevel@tonic-gate #define	CILEN_DEFLATE		4	/* length of its config option */
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate #define	DEFLATE_MIN_SIZE	8
182*7c478bd9Sstevel@tonic-gate #define	DEFLATE_MAX_SIZE	15
183*7c478bd9Sstevel@tonic-gate #define	DEFLATE_METHOD_VAL	8
184*7c478bd9Sstevel@tonic-gate #define	DEFLATE_SIZE(x)		(((x) >> 4) + DEFLATE_MIN_SIZE)
185*7c478bd9Sstevel@tonic-gate #define	DEFLATE_METHOD(x)	((x) & 0x0F)
186*7c478bd9Sstevel@tonic-gate #define	DEFLATE_MAKE_OPT(w)	((((w) - DEFLATE_MIN_SIZE) << 4) \
187*7c478bd9Sstevel@tonic-gate 				    + DEFLATE_METHOD_VAL)
188*7c478bd9Sstevel@tonic-gate #define	DEFLATE_CHK_SEQUENCE	0
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate /*
191*7c478bd9Sstevel@tonic-gate  * Definitions for other, as yet unsupported, compression methods.
192*7c478bd9Sstevel@tonic-gate  */
193*7c478bd9Sstevel@tonic-gate #define	CI_PREDICTOR_1		1	/* config option for Predictor-1 */
194*7c478bd9Sstevel@tonic-gate #define	CILEN_PREDICTOR_1	2	/* length of its config option */
195*7c478bd9Sstevel@tonic-gate #define	CI_PREDICTOR_2		2	/* config option for Predictor-2 */
196*7c478bd9Sstevel@tonic-gate #define	CILEN_PREDICTOR_2	2	/* length of its config option */
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate /*
199*7c478bd9Sstevel@tonic-gate  * Note that some systems emit requests for STAC using a length of 6.
200*7c478bd9Sstevel@tonic-gate  * The extra octet is 00 and should be ignored.
201*7c478bd9Sstevel@tonic-gate  */
202*7c478bd9Sstevel@tonic-gate #define	CI_STAC			17	/* config option for STAC LZS */
203*7c478bd9Sstevel@tonic-gate #define	CILEN_STAC		5	/* length of its config option */
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate #define	STAC_CHK_NONE		0	/* No checking */
206*7c478bd9Sstevel@tonic-gate #define	STAC_CHK_LCB		1	/* Longitudinal Check Bytes */
207*7c478bd9Sstevel@tonic-gate #define	STAC_CHK_CRC		2	/* Cyclic Redundancy Check */
208*7c478bd9Sstevel@tonic-gate #define	STAC_CHK_SEQ		3	/* Sequence Number */
209*7c478bd9Sstevel@tonic-gate #define	STAC_CHK_EXTENDED	4	/* Extended (Microsoft) */
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate #define	CI_MPPC			18	/* config option for MS-PPC */
212*7c478bd9Sstevel@tonic-gate #define	CILEN_MPPC		6	/* length of its config option */
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate #define	MPPC_COMP		0x00000001	/* Compression */
215*7c478bd9Sstevel@tonic-gate #define	MPPC_40LANM		0x00000010	/* MPPE, 40 bit LANManager */
216*7c478bd9Sstevel@tonic-gate #define	MPPC_40NT		0x00000020	/* MPPE, 40 bit NT key */
217*7c478bd9Sstevel@tonic-gate #define	MPPC_128NT		0x00000040	/* MPPE, 128 bit NT key */
218*7c478bd9Sstevel@tonic-gate #define	MPPC_56NT		0x00000080	/* MPPE, 56 bit NT key */
219*7c478bd9Sstevel@tonic-gate #define	MPPC_PBP		0x01000000	/* Packet-by-Packet mode */
220*7c478bd9Sstevel@tonic-gate #define	MPPC_MPPE		0x000000F0
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
223*7c478bd9Sstevel@tonic-gate }
224*7c478bd9Sstevel@tonic-gate #endif
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate #endif /* _NET_PPP_COMP_H */
227