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