Watt-32 tcp/ip  2.2 dev-rel.10
ppp-comp.h
Go to the documentation of this file.
1 
5 /* $NetBSD: ppp-comp.h,v 1.3 1997/03/12 20:26:55 christos Exp $ */
6 
7 /*
8  * ppp-comp.h - Definitions for doing PPP packet compression.
9  *
10  * Copyright (c) 1994 The Australian National University.
11  * All rights reserved.
12  *
13  * Permission to use, copy, modify, and distribute this software and its
14  * documentation is hereby granted, provided that the above copyright
15  * notice appears in all copies. This software is provided without any
16  * warranty, express or implied. The Australian National University
17  * makes no representations about the suitability of this software for
18  * any purpose.
19  *
20  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
21  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
22  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
23  * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
24  * OF SUCH DAMAGE.
25  *
26  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
27  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
28  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
29  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
30  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
31  * OR MODIFICATIONS.
32  *
33  * Id: ppp-comp.h,v 1.10 1996/09/26 06:30:11 paulus Exp
34  */
35 
36 #ifndef __NET_PPP_COMP_H
37 #define __NET_PPP_COMP_H
38 
39 /*
40  * The following symbols control whether we include code for
41  * various compression methods.
42  */
43 #ifndef DO_BSD_COMPRESS
44 #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
45 #endif
46 
47 #ifndef DO_DEFLATE
48 #define DO_DEFLATE 1 /* by default, include Deflate */
49 #endif
50 
51 #define DO_PREDICTOR_1 0
52 #define DO_PREDICTOR_2 0
53 
54 /*
55  * Structure giving methods for compression/decompression.
56  */
57 #ifdef PACKETPTR
58 struct compressor {
59  int compress_proto; /* CCP compression protocol number */
60 
61  /* Allocate space for a compressor (transmit side) */
62  void *(*comp_alloc) (u_char *options, int opt_len);
63 
64  /* Free space used by a compressor */
65  void (*comp_free) (void *state);
66 
67  /* Initialize a compressor */
68  int (*comp_init) (void *state, u_char *options, int opt_len,
69  int unit, int hdrlen, int debug);
70  /* Reset a compressor */
71  void (*comp_reset) (void *state);
72 
73  /* Compress a packet */
74  int (*compress) (void *state, PACKETPTR *mret,
75  PACKETPTR mp, int orig_len, int max_len);
76 
77  /* Return compression statistics */
78  void (*comp_stat) (void *state, struct compstat *stats);
79 
80  /* Allocate space for a decompressor (receive side) */
81  void *(*decomp_alloc) (u_char *options, int opt_len);
82 
83  /* Free space used by a decompressor */
84  void (*decomp_free) (void *state);
85 
86  /* Initialize a decompressor */
87  int (*decomp_init) (void *state, u_char *options, int opt_len,
88  int unit, int hdrlen, int mru, int debug);
89  /* Reset a decompressor */
90  void (*decomp_reset) (void *state);
91 
92  /* Decompress a packet. */
93  int (*decompress) (void *state, PACKETPTR mp, PACKETPTR *dmpp);
94 
95  /* Update state for an incompressible packet received */
96  void (*incomp) (void *state, PACKETPTR mp);
97 
98  /* Return decompression statistics */
99  void (*decomp_stat) (void *state, struct compstat *stats);
100 };
101 #endif /* PACKETPTR */
102 
103 /*
104  * Return values for decompress routine.
105  * We need to make these distinctions so that we can disable certain
106  * useful functionality, namely sending a CCP reset-request as a result
107  * of an error detected after decompression. This is to avoid infringing
108  * a patent held by Motorola.
109  * Don't you just lurve software patents.
110  */
111 #define DECOMP_OK 0 /* everything went OK */
112 #define DECOMP_ERROR 1 /* error detected before decomp. */
113 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
114 
115 /*
116  * CCP codes.
117  */
118 #define CCP_CONFREQ 1
119 #define CCP_CONFACK 2
120 #define CCP_TERMREQ 5
121 #define CCP_TERMACK 6
122 #define CCP_RESETREQ 14
123 #define CCP_RESETACK 15
124 
125 /*
126  * Max # bytes for a CCP option
127  */
128 #define CCP_MAX_OPTION_LENGTH 32
129 
130 /*
131  * Parts of a CCP packet.
132  */
133 #define CCP_CODE(dp) ((dp)[0])
134 #define CCP_ID(dp) ((dp)[1])
135 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
136 #define CCP_HDRLEN 4
137 
138 #define CCP_OPT_CODE(dp) ((dp)[0])
139 #define CCP_OPT_LENGTH(dp) ((dp)[1])
140 #define CCP_OPT_MINLEN 2
141 
142 /*
143  * Definitions for BSD-Compress.
144  */
145 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
146 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
147 
148 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
149 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
150 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
151 #define BSD_CURRENT_VERSION 1 /* current version number */
152 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
153 
154 #define BSD_MIN_BITS 9 /* smallest code size supported */
155 #define BSD_MAX_BITS 15 /* largest code size supported */
156 
157 /*
158  * Definitions for Deflate.
159  */
160 #define CI_DEFLATE 24 /* config option for Deflate */
161 #define CILEN_DEFLATE 4 /* length of its config option */
162 
163 #define DEFLATE_MIN_SIZE 8
164 #define DEFLATE_MAX_SIZE 15
165 #define DEFLATE_METHOD_VAL 8
166 #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
167 #define DEFLATE_METHOD(x) ((x) & 0x0F)
168 #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
169  + DEFLATE_METHOD_VAL)
170 #define DEFLATE_CHK_SEQUENCE 0
171 
172 /*
173  * Definitions for other, as yet unsupported, compression methods.
174  */
175 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
176 #define CILEN_PREDICTOR_1 2 /* length of its config option */
177 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
178 #define CILEN_PREDICTOR_2 2 /* length of its config option */
179 
180 #endif