]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/ppp_comp.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * ppp_comp.h - Definitions for doing PPP packet compression.
25 * Copyright (c) 1994 The Australian National University.
26 * All rights reserved.
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
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
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,
50 #ifndef _NET_PPP_COMP_H
51 #define _NET_PPP_COMP_H
52 #include <sys/appleapiopts.h>
53 #ifdef __APPLE_API_UNSTABLE
55 * The following symbols control whether we include code for
56 * various compression methods.
58 #ifndef DO_BSD_COMPRESS
59 #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
62 #define DO_DEFLATE 1 /* by default, include Deflate */
64 #define DO_PREDICTOR_1 0
65 #define DO_PREDICTOR_2 0
68 * Structure giving methods for compression/decompression.
72 int compress_proto
; /* CCP compression protocol number */
74 /* Allocate space for a compressor (transmit side) */
75 void *(*comp_alloc
) __P((u_char
*options
, int opt_len
));
76 /* Free space used by a compressor */
77 void (*comp_free
) __P((void *state
));
78 /* Initialize a compressor */
79 int (*comp_init
) __P((void *state
, u_char
*options
, int opt_len
,
80 int unit
, int hdrlen
, int debug
));
81 /* Reset a compressor */
82 void (*comp_reset
) __P((void *state
));
83 /* Compress a packet */
84 int (*compress
) __P((void *state
, PACKETPTR
*mret
,
85 PACKETPTR mp
, int orig_len
, int max_len
));
86 /* Return compression statistics */
87 void (*comp_stat
) __P((void *state
, struct compstat
*stats
));
89 /* Allocate space for a decompressor (receive side) */
90 void *(*decomp_alloc
) __P((u_char
*options
, int opt_len
));
91 /* Free space used by a decompressor */
92 void (*decomp_free
) __P((void *state
));
93 /* Initialize a decompressor */
94 int (*decomp_init
) __P((void *state
, u_char
*options
, int opt_len
,
95 int unit
, int hdrlen
, int mru
, int debug
));
96 /* Reset a decompressor */
97 void (*decomp_reset
) __P((void *state
));
98 /* Decompress a packet. */
99 int (*decompress
) __P((void *state
, PACKETPTR mp
,
101 /* Update state for an incompressible packet received */
102 void (*incomp
) __P((void *state
, PACKETPTR mp
));
103 /* Return decompression statistics */
104 void (*decomp_stat
) __P((void *state
, struct compstat
*stats
));
106 #endif /* PACKETPTR */
109 * Return values for decompress routine.
110 * We need to make these distinctions so that we can disable certain
111 * useful functionality, namely sending a CCP reset-request as a result
112 * of an error detected after decompression. This is to avoid infringing
113 * a patent held by Motorola.
114 * Don't you just lurve software patents.
116 #define DECOMP_OK 0 /* everything went OK */
117 #define DECOMP_ERROR 1 /* error detected before decomp. */
118 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
123 #define CCP_CONFREQ 1
124 #define CCP_CONFACK 2
125 #define CCP_TERMREQ 5
126 #define CCP_TERMACK 6
127 #define CCP_RESETREQ 14
128 #define CCP_RESETACK 15
131 * Max # bytes for a CCP option
133 #define CCP_MAX_OPTION_LENGTH 32
136 * Parts of a CCP packet.
138 #define CCP_CODE(dp) ((dp)[0])
139 #define CCP_ID(dp) ((dp)[1])
140 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
143 #define CCP_OPT_CODE(dp) ((dp)[0])
144 #define CCP_OPT_LENGTH(dp) ((dp)[1])
145 #define CCP_OPT_MINLEN 2
148 * Definitions for BSD-Compress.
150 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
151 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
153 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
154 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
155 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
156 #define BSD_CURRENT_VERSION 1 /* current version number */
157 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
159 #define BSD_MIN_BITS 9 /* smallest code size supported */
160 #define BSD_MAX_BITS 15 /* largest code size supported */
163 * Definitions for Deflate.
165 #define CI_DEFLATE 26 /* config option for Deflate */
166 #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
167 #define CILEN_DEFLATE 4 /* length of its config option */
169 #define DEFLATE_MIN_SIZE 8
170 #define DEFLATE_MAX_SIZE 15
171 #define DEFLATE_METHOD_VAL 8
172 #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
173 #define DEFLATE_METHOD(x) ((x) & 0x0F)
174 #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
175 + DEFLATE_METHOD_VAL)
176 #define DEFLATE_CHK_SEQUENCE 0
179 * Definitions for other, as yet unsupported, compression methods.
181 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
182 #define CILEN_PREDICTOR_1 2 /* length of its config option */
183 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
184 #define CILEN_PREDICTOR_2 2 /* length of its config option */
186 #endif /* __APPLE_API_UNSTABLE */
187 #endif /* _NET_PPP_COMP_H */