2 * ppp-comp.h - Definitions for doing PPP packet compression.
4 * Copyright (c) 1994 Paul Mackerras. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * 3. The name(s) of the authors of this software must not be used to
19 * endorse or promote products derived from this software without
20 * prior written permission.
22 * 4. Redistributions of any form whatsoever must retain the following
24 * "This product includes software developed by Paul Mackerras
25 * <paulus@samba.org>".
27 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
28 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
30 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
31 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
32 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
33 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35 * $Id: ppp-comp.h,v 1.2 2002/12/06 09:49:16 paulus Exp $
38 #ifndef _NET_PPP_COMP_H
39 #define _NET_PPP_COMP_H
42 * The following symbols control whether we include code for
43 * various compression methods.
45 #ifndef DO_BSD_COMPRESS
46 #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
49 #define DO_DEFLATE 1 /* by default, include Deflate */
51 #define DO_PREDICTOR_1 0
52 #define DO_PREDICTOR_2 0
55 * Structure giving methods for compression/decompression.
58 int compress_proto
; /* CCP compression protocol number */
60 /* Allocate space for a decompressor (receive side) */
61 void *(*decomp_alloc
) __P((u_char
*options
, int opt_len
));
62 /* Free space used by a decompressor */
63 void (*decomp_free
) __P((void *state
));
64 /* Initialize a decompressor */
65 int (*decomp_init
) __P((void *state
, u_char
*options
, int opt_len
,
66 int unit
, int hdrlen
, int mru
, int debug
));
67 /* Reset a decompressor */
68 void (*decomp_reset
) __P((void *state
));
69 /* Decompress a packet. */
70 int (*decompress
) __P((void *state
, u_char
*mp
, int inlen
,
71 u_char
*dmp
, int *outlen
));
72 /* Update state for an incompressible packet received */
73 void (*incomp
) __P((void *state
, u_char
*mp
, int len
));
74 /* Return decompression statistics */
75 void (*decomp_stat
) __P((void *state
, struct compstat
*stats
));
79 * Return values for decompress routine.
80 * We need to make these distinctions so that we can disable certain
81 * useful functionality, namely sending a CCP reset-request as a result
82 * of an error detected after decompression. This is to avoid infringing
83 * a patent held by Motorola.
84 * Don't you just lurve software patents.
86 #define DECOMP_OK 0 /* everything went OK */
87 #define DECOMP_ERROR 1 /* error detected before decomp. */
88 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
99 #define CCP_RESETREQ 14
100 #define CCP_RESETACK 15
103 * Max # bytes for a CCP option
105 #define CCP_MAX_OPTION_LENGTH 32
108 * Parts of a CCP packet.
110 #define CCP_CODE(dp) ((dp)[0])
111 #define CCP_ID(dp) ((dp)[1])
112 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
115 #define CCP_OPT_CODE(dp) ((dp)[0])
116 #define CCP_OPT_LENGTH(dp) ((dp)[1])
117 #define CCP_OPT_MINLEN 2
120 * Definitions for BSD-Compress.
122 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
123 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
125 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
126 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
127 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
128 #define BSD_CURRENT_VERSION 1 /* current version number */
129 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
131 #define BSD_MIN_BITS 9 /* smallest code size supported */
132 #define BSD_MAX_BITS 15 /* largest code size supported */
135 * Definitions for Deflate.
137 #define CI_DEFLATE 26 /* config option for Deflate */
138 #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
139 #define CILEN_DEFLATE 4 /* length of its config option */
141 #define DEFLATE_MIN_SIZE 8
142 #define DEFLATE_MAX_SIZE 15
143 #define DEFLATE_METHOD_VAL 8
144 #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
145 #define DEFLATE_METHOD(x) ((x) & 0x0F)
146 #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
147 + DEFLATE_METHOD_VAL)
148 #define DEFLATE_CHK_SEQUENCE 0
151 * Definitions for other, as yet unsupported, compression methods.
153 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
154 #define CILEN_PREDICTOR_1 2 /* length of its config option */
155 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
156 #define CILEN_PREDICTOR_2 2 /* length of its config option */
158 #endif /* _NET_PPP_COMP_H */