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