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