1 //==========================================================================
3 // include/net/ppp_comp.h
5 //==========================================================================
6 //####ECOSGPLCOPYRIGHTBEGIN####
7 // -------------------------------------------
8 // This file is part of eCos, the Embedded Configurable Operating System.
9 // Portions created by Nick Garnett are
10 // Copyright (C) 2003 eCosCentric Ltd.
12 // eCos is free software; you can redistribute it and/or modify it under
13 // the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 2 or (at your option) any later version.
16 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
17 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 // You should have received a copy of the GNU General Public License along
22 // with eCos; if not, write to the Free Software Foundation, Inc.,
23 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 // As a special exception, if other files instantiate templates or use macros
26 // or inline functions from this file, or you compile this file and link it
27 // with other works to produce a work based on this file, this file does not
28 // by itself cause the resulting work to be covered by the GNU General Public
29 // License. However the source code for this file must still be made available
30 // in accordance with section (3) of the GNU General Public License.
32 // This exception does not invalidate any other reasons why a work based on
33 // this file might be covered by the GNU General Public License.
35 // -------------------------------------------
36 //####ECOSGPLCOPYRIGHTEND####
37 //####BSDCOPYRIGHTBEGIN####
39 // -------------------------------------------
41 // Portions of this software may have been derived from OpenBSD,
42 // FreeBSD or other sources, and are covered by the appropriate
43 // copyright disclaimers included herein.
45 // -------------------------------------------
47 //####BSDCOPYRIGHTEND####
48 //==========================================================================
51 * ppp_comp.h - Definitions for doing PPP packet compression.
53 * Copyright (c) 1994 The Australian National University.
54 * All rights reserved.
56 * Permission to use, copy, modify, and distribute this software and its
57 * documentation is hereby granted, provided that the above copyright
58 * notice appears in all copies. This software is provided without any
59 * warranty, express or implied. The Australian National University
60 * makes no representations about the suitability of this software for
63 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
64 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
65 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
66 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
69 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
70 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
71 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
72 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
73 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
76 * $FreeBSD: src/sys/net/ppp_comp.h,v 1.8 1999/08/28 00:48:25 peter Exp $
79 #ifndef _NET_PPP_COMP_H
80 #define _NET_PPP_COMP_H
82 #include <cyg/ppp/names.h>
85 * The following symbols control whether we include code for
86 * various compression methods.
88 #ifndef DO_BSD_COMPRESS
89 #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
92 #define DO_DEFLATE 1 /* by default, include Deflate */
94 #define DO_PREDICTOR_1 0
95 #define DO_PREDICTOR_2 0
98 * Structure giving methods for compression/decompression.
102 int compress_proto; /* CCP compression protocol number */
104 /* Allocate space for a compressor (transmit side) */
105 void *(*comp_alloc) __P((u_char *options, int opt_len));
106 /* Free space used by a compressor */
107 void (*comp_free) __P((void *state));
108 /* Initialize a compressor */
109 int (*comp_init) __P((void *state, u_char *options, int opt_len,
110 int unit, int hdrlen, int debug));
111 /* Reset a compressor */
112 void (*comp_reset) __P((void *state));
113 /* Compress a packet */
114 int (*compress) __P((void *state, PACKETPTR *mret,
115 PACKETPTR mp, int orig_len, int max_len));
116 /* Return compression statistics */
117 void (*comp_stat) __P((void *state, struct compstat *stats));
119 /* Allocate space for a decompressor (receive side) */
120 void *(*decomp_alloc) __P((u_char *options, int opt_len));
121 /* Free space used by a decompressor */
122 void (*decomp_free) __P((void *state));
123 /* Initialize a decompressor */
124 int (*decomp_init) __P((void *state, u_char *options, int opt_len,
125 int unit, int hdrlen, int mru, int debug));
126 /* Reset a decompressor */
127 void (*decomp_reset) __P((void *state));
128 /* Decompress a packet. */
129 int (*decompress) __P((void *state, PACKETPTR mp,
131 /* Update state for an incompressible packet received */
132 void (*incomp) __P((void *state, PACKETPTR mp));
133 /* Return decompression statistics */
134 void (*decomp_stat) __P((void *state, struct compstat *stats));
136 #endif /* PACKETPTR */
139 * Return values for decompress routine.
140 * We need to make these distinctions so that we can disable certain
141 * useful functionality, namely sending a CCP reset-request as a result
142 * of an error detected after decompression. This is to avoid infringing
143 * a patent held by Motorola.
144 * Don't you just lurve software patents.
146 #define DECOMP_OK 0 /* everything went OK */
147 #define DECOMP_ERROR 1 /* error detected before decomp. */
148 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
153 #define CCP_CONFREQ 1
154 #define CCP_CONFACK 2
155 #define CCP_TERMREQ 5
156 #define CCP_TERMACK 6
157 #define CCP_RESETREQ 14
158 #define CCP_RESETACK 15
161 * Max # bytes for a CCP option
163 #define CCP_MAX_OPTION_LENGTH 32
166 * Parts of a CCP packet.
168 #define CCP_CODE(dp) ((dp)[0])
169 #define CCP_ID(dp) ((dp)[1])
170 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
173 #define CCP_OPT_CODE(dp) ((dp)[0])
174 #define CCP_OPT_LENGTH(dp) ((dp)[1])
175 #define CCP_OPT_MINLEN 2
178 * Definitions for BSD-Compress.
180 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
181 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
183 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
184 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
185 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
186 #define BSD_CURRENT_VERSION 1 /* current version number */
187 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
189 #define BSD_MIN_BITS 9 /* smallest code size supported */
190 #define BSD_MAX_BITS 15 /* largest code size supported */
193 * Definitions for Deflate.
195 #define CI_DEFLATE 26 /* config option for Deflate */
196 #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
197 #define CILEN_DEFLATE 4 /* length of its config option */
199 #define DEFLATE_MIN_SIZE 8
200 #define DEFLATE_MAX_SIZE 15
201 #define DEFLATE_METHOD_VAL 8
202 #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
203 #define DEFLATE_METHOD(x) ((x) & 0x0F)
204 #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
205 + DEFLATE_METHOD_VAL)
206 #define DEFLATE_CHK_SEQUENCE 0
209 * Definitions for other, as yet unsupported, compression methods.
211 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
212 #define CILEN_PREDICTOR_1 2 /* length of its config option */
213 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
214 #define CILEN_PREDICTOR_2 2 /* length of its config option */
216 #endif /* _NET_PPP_COMP_H */