CPU: Wrong CPU Load %.
[tomato.git] / release / src / router / ppp / pppdump / ppp-comp.h
blobf4510083a2abd96e1885a0c9cbb862c3734c8c6d
1 /*
2 * ppp-comp.h - Definitions for doing PPP packet compression.
4 * Copyright (c) 1994 The Australian National University.
5 * All rights reserved.
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.
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.
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.
27 * $Id: ppp-comp.h,v 1.1.1.4 2003/10/14 08:09:54 sparq Exp $
30 #ifndef _NET_PPP_COMP_H
31 #define _NET_PPP_COMP_H
34 * The following symbols control whether we include code for
35 * various compression methods.
37 #ifndef DO_BSD_COMPRESS
38 #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
39 #endif
40 #ifndef DO_DEFLATE
41 #define DO_DEFLATE 1 /* by default, include Deflate */
42 #endif
43 #define DO_PREDICTOR_1 0
44 #define DO_PREDICTOR_2 0
47 * Structure giving methods for compression/decompression.
49 struct compressor {
50 int compress_proto; /* CCP compression protocol number */
52 /* Allocate space for a decompressor (receive side) */
53 void *(*decomp_alloc) __P((u_char *options, int opt_len));
54 /* Free space used by a decompressor */
55 void (*decomp_free) __P((void *state));
56 /* Initialize a decompressor */
57 int (*decomp_init) __P((void *state, u_char *options, int opt_len,
58 int unit, int hdrlen, int mru, int debug));
59 /* Reset a decompressor */
60 void (*decomp_reset) __P((void *state));
61 /* Decompress a packet. */
62 int (*decompress) __P((void *state, u_char *mp, int inlen,
63 u_char *dmp, int *outlen));
64 /* Update state for an incompressible packet received */
65 void (*incomp) __P((void *state, u_char *mp, int len));
66 /* Return decompression statistics */
67 void (*decomp_stat) __P((void *state, struct compstat *stats));
71 * Return values for decompress routine.
72 * We need to make these distinctions so that we can disable certain
73 * useful functionality, namely sending a CCP reset-request as a result
74 * of an error detected after decompression. This is to avoid infringing
75 * a patent held by Motorola.
76 * Don't you just lurve software patents.
78 #define DECOMP_OK 0 /* everything went OK */
79 #define DECOMP_ERROR 1 /* error detected before decomp. */
80 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
83 * CCP codes.
85 #define CCP_CONFREQ 1
86 #define CCP_CONFACK 2
87 #define CCP_CONFNAK 3
88 #define CCP_CONFREJ 4
89 #define CCP_TERMREQ 5
90 #define CCP_TERMACK 6
91 #define CCP_RESETREQ 14
92 #define CCP_RESETACK 15
95 * Max # bytes for a CCP option
97 #define CCP_MAX_OPTION_LENGTH 32
100 * Parts of a CCP packet.
102 #define CCP_CODE(dp) ((dp)[0])
103 #define CCP_ID(dp) ((dp)[1])
104 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
105 #define CCP_HDRLEN 4
107 #define CCP_OPT_CODE(dp) ((dp)[0])
108 #define CCP_OPT_LENGTH(dp) ((dp)[1])
109 #define CCP_OPT_MINLEN 2
112 * Definitions for BSD-Compress.
114 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
115 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
117 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
118 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
119 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
120 #define BSD_CURRENT_VERSION 1 /* current version number */
121 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
123 #define BSD_MIN_BITS 9 /* smallest code size supported */
124 #define BSD_MAX_BITS 15 /* largest code size supported */
127 * Definitions for Deflate.
129 #define CI_DEFLATE 26 /* config option for Deflate */
130 #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
131 #define CILEN_DEFLATE 4 /* length of its config option */
133 #define DEFLATE_MIN_SIZE 8
134 #define DEFLATE_MAX_SIZE 15
135 #define DEFLATE_METHOD_VAL 8
136 #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
137 #define DEFLATE_METHOD(x) ((x) & 0x0F)
138 #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
139 + DEFLATE_METHOD_VAL)
140 #define DEFLATE_CHK_SEQUENCE 0
143 * Definitions for other, as yet unsupported, compression methods.
145 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
146 #define CILEN_PREDICTOR_1 2 /* length of its config option */
147 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
148 #define CILEN_PREDICTOR_2 2 /* length of its config option */
150 #endif /* _NET_PPP_COMP_H */