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