source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/ppp-comp.h

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 6.1 KB
Line 
1/*
2 * ppp-comp.h - Definitions for doing PPP packet compression.
3 *
4 * Copyright (c) 1994 The Australian National University.
5 * All rights reserved.
6 *
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation is hereby granted, provided that the above copyright
9 * notice appears in all copies.  This software is provided without any
10 * warranty, express or implied. The Australian National University
11 * makes no representations about the suitability of this software for
12 * any purpose.
13 *
14 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
15 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
17 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
18 * OF SUCH DAMAGE.
19 *
20 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
24 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
25 * OR MODIFICATIONS.
26 *
27 */
28
29/*
30 *  ==FILEVERSION 980319==
31 *
32 *  NOTE TO MAINTAINERS:
33 *     If you modify this file at all, please set the above date.
34 *     ppp-comp.h is shipped with a PPP distribution as well as with the kernel;
35 *     if everyone increases the FILEVERSION number above, then scripts
36 *     can do the right thing when deciding whether to install a new ppp-comp.h
37 *     file.  Don't change the format of that line otherwise, so the
38 *     installation script can recognize it.
39 */
40
41#ifndef _NET_PPP_COMP_H
42#define _NET_PPP_COMP_H
43
44struct module;
45
46/*
47 * The following symbols control whether we include code for
48 * various compression methods.
49 */
50
51#ifndef DO_BSD_COMPRESS
52#define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
53#endif
54#ifndef DO_DEFLATE
55#define DO_DEFLATE      1       /* by default, include Deflate */
56#endif
57#define DO_PREDICTOR_1  0
58#define DO_PREDICTOR_2  0
59
60/*
61 * Structure giving methods for compression/decompression.
62 */
63
64struct compressor {
65        int     compress_proto; /* CCP compression protocol number */
66
67        /* Allocate space for a compressor (transmit side) */
68        void    *(*comp_alloc) (unsigned char *options, int opt_len);
69
70        /* Free space used by a compressor */
71        void    (*comp_free) (void *state);
72
73        /* Initialize a compressor */
74        int     (*comp_init) (void *state, unsigned char *options,
75                              int opt_len, int unit, int opthdr, int debug);
76
77        /* Reset a compressor */
78        void    (*comp_reset) (void *state);
79
80        /* Compress a packet */
81        int     (*compress) (void *state, unsigned char *rptr,
82                              unsigned char *obuf, int isize, int osize);
83
84        /* Return compression statistics */
85        void    (*comp_stat) (void *state, struct compstat *stats);
86
87        /* Allocate space for a decompressor (receive side) */
88        void    *(*decomp_alloc) (unsigned char *options, int opt_len);
89
90        /* Free space used by a decompressor */
91        void    (*decomp_free) (void *state);
92
93        /* Initialize a decompressor */
94        int     (*decomp_init) (void *state, unsigned char *options,
95                                int opt_len, int unit, int opthdr, int mru,
96                                int debug);
97
98        /* Reset a decompressor */
99        void    (*decomp_reset) (void *state);
100
101        /* Decompress a packet. */
102        int     (*decompress) (void *state, unsigned char *ibuf, int isize,
103                                unsigned char *obuf, int osize);
104
105        /* Update state for an incompressible packet received */
106        void    (*incomp) (void *state, unsigned char *ibuf, int icnt);
107
108        /* Return decompression statistics */
109        void    (*decomp_stat) (void *state, struct compstat *stats);
110
111        /* Used in locking compressor modules */
112        struct module *owner;
113};
114
115/*
116 * The return value from decompress routine is the length of the
117 * decompressed packet if successful, otherwise DECOMP_ERROR
118 * or DECOMP_FATALERROR if an error occurred.
119 *
120 * We need to make this distinction so that we can disable certain
121 * useful functionality, namely sending a CCP reset-request as a result
122 * of an error detected after decompression.  This is to avoid infringing
123 * a patent held by Motorola.
124 * Don't you just lurve software patents.
125 */
126
127#define DECOMP_ERROR            -1      /* error detected before decomp. */
128#define DECOMP_FATALERROR       -2      /* error detected after decomp. */
129
130/*
131 * CCP codes.
132 */
133
134#define CCP_CONFREQ     1
135#define CCP_CONFACK     2
136#define CCP_TERMREQ     5
137#define CCP_TERMACK     6
138#define CCP_RESETREQ    14
139#define CCP_RESETACK    15
140
141/*
142 * Max # bytes for a CCP option
143 */
144
145#define CCP_MAX_OPTION_LENGTH   32
146
147/*
148 * Parts of a CCP packet.
149 */
150
151#define CCP_CODE(dp)            ((dp)[0])
152#define CCP_ID(dp)              ((dp)[1])
153#define CCP_LENGTH(dp)          (((dp)[2] << 8) + (dp)[3])
154#define CCP_HDRLEN              4
155
156#define CCP_OPT_CODE(dp)        ((dp)[0])
157#define CCP_OPT_LENGTH(dp)      ((dp)[1])
158#define CCP_OPT_MINLEN          2
159
160/*
161 * Definitions for BSD-Compress.
162 */
163
164#define CI_BSD_COMPRESS         21      /* config. option for BSD-Compress */
165#define CILEN_BSD_COMPRESS      3       /* length of config. option */
166
167/* Macros for handling the 3rd byte of the BSD-Compress config option. */
168#define BSD_NBITS(x)            ((x) & 0x1F)    /* number of bits requested */
169#define BSD_VERSION(x)          ((x) >> 5)      /* version of option format */
170#define BSD_CURRENT_VERSION     1               /* current version number */
171#define BSD_MAKE_OPT(v, n)      (((v) << 5) | (n))
172
173#define BSD_MIN_BITS            9       /* smallest code size supported */
174#define BSD_MAX_BITS            15      /* largest code size supported */
175
176/*
177 * Definitions for Deflate.
178 */
179
180#define CI_DEFLATE              26      /* config option for Deflate */
181#define CI_DEFLATE_DRAFT        24      /* value used in original draft RFC */
182#define CILEN_DEFLATE           4       /* length of its config option */
183
184#define DEFLATE_MIN_SIZE        9
185#define DEFLATE_MAX_SIZE        15
186#define DEFLATE_METHOD_VAL      8
187#define DEFLATE_SIZE(x)         (((x) >> 4) + 8)
188#define DEFLATE_METHOD(x)       ((x) & 0x0F)
189#define DEFLATE_MAKE_OPT(w)     ((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
190#define DEFLATE_CHK_SEQUENCE    0
191
192/*
193 * Definitions for other, as yet unsupported, compression methods.
194 */
195
196#define CI_PREDICTOR_1          1       /* config option for Predictor-1 */
197#define CILEN_PREDICTOR_1       2       /* length of its config option */
198#define CI_PREDICTOR_2          2       /* config option for Predictor-2 */
199#define CILEN_PREDICTOR_2       2       /* length of its config option */
200
201#endif /* _NET_PPP_COMP_H */
Note: See TracBrowser for help on using the repository browser.