]> git.ozlabs.org Git - ppp.git/blob - pppdump/ppp-comp.h
pppd man page: Update header to refer to pppd 2.5.x
[ppp.git] / pppdump / ppp-comp.h
1 /*
2  * ppp-comp.h - Definitions for doing PPP packet compression.
3  *
4  * Copyright (c) 1994 Paul Mackerras. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
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
16  *    distribution.
17  *
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.
21  *
22  * 4. Redistributions of any form whatsoever must retain the following
23  *    acknowledgment:
24  *    "This product includes software developed by Paul Mackerras
25  *     <paulus@samba.org>".
26  *
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.
34  *
35  * $Id: ppp-comp.h,v 1.2 2002/12/06 09:49:16 paulus Exp $
36  */
37
38 #ifndef _NET_PPP_COMP_H
39 #define _NET_PPP_COMP_H
40
41 /*
42  * The following symbols control whether we include code for
43  * various compression methods.
44  */
45 #ifndef DO_BSD_COMPRESS
46 #define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
47 #endif
48 #ifndef DO_DEFLATE
49 #define DO_DEFLATE      1       /* by default, include Deflate */
50 #endif
51 #define DO_PREDICTOR_1  0
52 #define DO_PREDICTOR_2  0
53
54 #if defined(SOL2)
55 #include <net/ppp_defs.h>
56 #else
57 #include <linux/ppp_defs.h>
58 #endif
59
60 /*
61  * Structure giving methods for compression/decompression.
62  */
63 struct compressor {
64         int     compress_proto; /* CCP compression protocol number */
65
66         /* Allocate space for a decompressor (receive side) */
67         void    *(*decomp_alloc)(u_char *options, int opt_len);
68         /* Free space used by a decompressor */
69         void    (*decomp_free)(void *state);
70         /* Initialize a decompressor */
71         int     (*decomp_init)(void *state, u_char *options, int opt_len,
72                                int unit, int hdrlen, int mru, int debug);
73         /* Reset a decompressor */
74         void    (*decomp_reset)(void *state);
75         /* Decompress a packet. */
76         int     (*decompress)(void *state, u_char *mp, int inlen,
77                               u_char *dmp, int *outlen);
78         /* Update state for an incompressible packet received */
79         void    (*incomp)(void *state, u_char *mp, int len);
80         /* Return decompression statistics */
81         void    (*decomp_stat)(void *state, struct compstat *stats);
82 };
83
84 /*
85  * Return values for decompress routine.
86  * We need to make these distinctions so that we can disable certain
87  * useful functionality, namely sending a CCP reset-request as a result
88  * of an error detected after decompression.  This is to avoid infringing
89  * a patent held by Motorola.
90  * Don't you just lurve software patents.
91  */
92 #define DECOMP_OK               0       /* everything went OK */
93 #define DECOMP_ERROR            1       /* error detected before decomp. */
94 #define DECOMP_FATALERROR       2       /* error detected after decomp. */
95
96 /*
97  * CCP codes.
98  */
99 #define CCP_CONFREQ     1
100 #define CCP_CONFACK     2
101 #define CCP_CONFNAK     3
102 #define CCP_CONFREJ     4
103 #define CCP_TERMREQ     5
104 #define CCP_TERMACK     6
105 #define CCP_RESETREQ    14
106 #define CCP_RESETACK    15
107
108 /*
109  * Max # bytes for a CCP option
110  */
111 #define CCP_MAX_OPTION_LENGTH   32
112
113 /*
114  * Parts of a CCP packet.
115  */
116 #define CCP_CODE(dp)            ((dp)[0])
117 #define CCP_ID(dp)              ((dp)[1])
118 #define CCP_LENGTH(dp)          (((dp)[2] << 8) + (dp)[3])
119 #define CCP_HDRLEN              4
120
121 #define CCP_OPT_CODE(dp)        ((dp)[0])
122 #define CCP_OPT_LENGTH(dp)      ((dp)[1])
123 #define CCP_OPT_MINLEN          2
124
125 /*
126  * Definitions for BSD-Compress.
127  */
128 #define CI_BSD_COMPRESS         21      /* config. option for BSD-Compress */
129 #define CILEN_BSD_COMPRESS      3       /* length of config. option */
130
131 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
132 #define BSD_NBITS(x)            ((x) & 0x1F)    /* number of bits requested */
133 #define BSD_VERSION(x)          ((x) >> 5)      /* version of option format */
134 #define BSD_CURRENT_VERSION     1               /* current version number */
135 #define BSD_MAKE_OPT(v, n)      (((v) << 5) | (n))
136
137 #define BSD_MIN_BITS            9       /* smallest code size supported */
138 #define BSD_MAX_BITS            15      /* largest code size supported */
139
140 /*
141  * Definitions for Deflate.
142  */
143 #define CI_DEFLATE              26      /* config option for Deflate */
144 #define CI_DEFLATE_DRAFT        24      /* value used in original draft RFC */
145 #define CILEN_DEFLATE           4       /* length of its config option */
146
147 #define DEFLATE_MIN_SIZE        8
148 #define DEFLATE_MAX_SIZE        15
149 #define DEFLATE_METHOD_VAL      8
150 #define DEFLATE_SIZE(x)         (((x) >> 4) + DEFLATE_MIN_SIZE)
151 #define DEFLATE_METHOD(x)       ((x) & 0x0F)
152 #define DEFLATE_MAKE_OPT(w)     ((((w) - DEFLATE_MIN_SIZE) << 4) \
153                                  + DEFLATE_METHOD_VAL)
154 #define DEFLATE_CHK_SEQUENCE    0
155
156 /*
157  * Definitions for other, as yet unsupported, compression methods.
158  */
159 #define CI_PREDICTOR_1          1       /* config option for Predictor-1 */
160 #define CILEN_PREDICTOR_1       2       /* length of its config option */
161 #define CI_PREDICTOR_2          2       /* config option for Predictor-2 */
162 #define CILEN_PREDICTOR_2       2       /* length of its config option */
163
164 #endif /* _NET_PPP_COMP_H */