| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * ppp-comp.h - Definitions for doing PPP packet compression. | 
|  | 3 | * | 
|  | 4 | * Copyright (c) 1994 The Australian National University. | 
|  | 5 | * All rights reserved. | 
|  | 6 | * | 
|  | 7 | * Permission to use, copy, modify, and distribute this software and its | 
|  | 8 | * documentation is hereby granted, provided that the above copyright | 
|  | 9 | * notice appears in all copies.  This software is provided without any | 
|  | 10 | * warranty, express or implied. The Australian National University | 
|  | 11 | * makes no representations about the suitability of this software for | 
|  | 12 | * any purpose. | 
|  | 13 | * | 
|  | 14 | * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY | 
|  | 15 | * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES | 
|  | 16 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | 
|  | 17 | * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY | 
|  | 18 | * OF SUCH DAMAGE. | 
|  | 19 | * | 
|  | 20 | * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, | 
|  | 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 
|  | 22 | * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS | 
|  | 23 | * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO | 
|  | 24 | * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, | 
|  | 25 | * OR MODIFICATIONS. | 
|  | 26 | * | 
|  | 27 | * $Id: ppp-comp.h,v 1.6 1997/11/27 06:04:44 paulus Exp $ | 
|  | 28 | */ | 
|  | 29 |  | 
|  | 30 | /* | 
|  | 31 | *  ==FILEVERSION 980319== | 
|  | 32 | * | 
|  | 33 | *  NOTE TO MAINTAINERS: | 
|  | 34 | *     If you modify this file at all, please set the above date. | 
|  | 35 | *     ppp-comp.h is shipped with a PPP distribution as well as with the kernel; | 
|  | 36 | *     if everyone increases the FILEVERSION number above, then scripts | 
|  | 37 | *     can do the right thing when deciding whether to install a new ppp-comp.h | 
|  | 38 | *     file.  Don't change the format of that line otherwise, so the | 
|  | 39 | *     installation script can recognize it. | 
|  | 40 | */ | 
|  | 41 |  | 
|  | 42 | #ifndef _NET_PPP_COMP_H | 
|  | 43 | #define _NET_PPP_COMP_H | 
|  | 44 |  | 
|  | 45 | struct module; | 
|  | 46 |  | 
|  | 47 | /* | 
|  | 48 | * The following symbols control whether we include code for | 
|  | 49 | * various compression methods. | 
|  | 50 | */ | 
|  | 51 |  | 
|  | 52 | #ifndef DO_BSD_COMPRESS | 
|  | 53 | #define DO_BSD_COMPRESS	1	/* by default, include BSD-Compress */ | 
|  | 54 | #endif | 
|  | 55 | #ifndef DO_DEFLATE | 
|  | 56 | #define DO_DEFLATE	1	/* by default, include Deflate */ | 
|  | 57 | #endif | 
|  | 58 | #define DO_PREDICTOR_1	0 | 
|  | 59 | #define DO_PREDICTOR_2	0 | 
|  | 60 |  | 
|  | 61 | /* | 
|  | 62 | * Structure giving methods for compression/decompression. | 
|  | 63 | */ | 
|  | 64 |  | 
|  | 65 | struct compressor { | 
|  | 66 | int	compress_proto;	/* CCP compression protocol number */ | 
|  | 67 |  | 
|  | 68 | /* Allocate space for a compressor (transmit side) */ | 
|  | 69 | void	*(*comp_alloc) (unsigned char *options, int opt_len); | 
|  | 70 |  | 
|  | 71 | /* Free space used by a compressor */ | 
|  | 72 | void	(*comp_free) (void *state); | 
|  | 73 |  | 
|  | 74 | /* Initialize a compressor */ | 
|  | 75 | int	(*comp_init) (void *state, unsigned char *options, | 
|  | 76 | int opt_len, int unit, int opthdr, int debug); | 
|  | 77 |  | 
|  | 78 | /* Reset a compressor */ | 
|  | 79 | void	(*comp_reset) (void *state); | 
|  | 80 |  | 
|  | 81 | /* Compress a packet */ | 
|  | 82 | int     (*compress) (void *state, unsigned char *rptr, | 
|  | 83 | unsigned char *obuf, int isize, int osize); | 
|  | 84 |  | 
|  | 85 | /* Return compression statistics */ | 
|  | 86 | void	(*comp_stat) (void *state, struct compstat *stats); | 
|  | 87 |  | 
|  | 88 | /* Allocate space for a decompressor (receive side) */ | 
|  | 89 | void	*(*decomp_alloc) (unsigned char *options, int opt_len); | 
|  | 90 |  | 
|  | 91 | /* Free space used by a decompressor */ | 
|  | 92 | void	(*decomp_free) (void *state); | 
|  | 93 |  | 
|  | 94 | /* Initialize a decompressor */ | 
|  | 95 | int	(*decomp_init) (void *state, unsigned char *options, | 
|  | 96 | int opt_len, int unit, int opthdr, int mru, | 
|  | 97 | int debug); | 
|  | 98 |  | 
|  | 99 | /* Reset a decompressor */ | 
|  | 100 | void	(*decomp_reset) (void *state); | 
|  | 101 |  | 
|  | 102 | /* Decompress a packet. */ | 
|  | 103 | int	(*decompress) (void *state, unsigned char *ibuf, int isize, | 
|  | 104 | unsigned char *obuf, int osize); | 
|  | 105 |  | 
|  | 106 | /* Update state for an incompressible packet received */ | 
|  | 107 | void	(*incomp) (void *state, unsigned char *ibuf, int icnt); | 
|  | 108 |  | 
|  | 109 | /* Return decompression statistics */ | 
|  | 110 | void	(*decomp_stat) (void *state, struct compstat *stats); | 
|  | 111 |  | 
|  | 112 | /* Used in locking compressor modules */ | 
|  | 113 | struct module *owner; | 
| Matt Domsch | b3f9b92 | 2005-11-08 09:40:47 -0800 | [diff] [blame] | 114 | /* Extra skb space needed by the compressor algorithm */ | 
|  | 115 | unsigned int comp_extra; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | }; | 
|  | 117 |  | 
|  | 118 | /* | 
|  | 119 | * The return value from decompress routine is the length of the | 
|  | 120 | * decompressed packet if successful, otherwise DECOMP_ERROR | 
|  | 121 | * or DECOMP_FATALERROR if an error occurred. | 
|  | 122 | * | 
|  | 123 | * We need to make this distinction so that we can disable certain | 
|  | 124 | * useful functionality, namely sending a CCP reset-request as a result | 
|  | 125 | * of an error detected after decompression.  This is to avoid infringing | 
|  | 126 | * a patent held by Motorola. | 
|  | 127 | * Don't you just lurve software patents. | 
|  | 128 | */ | 
|  | 129 |  | 
|  | 130 | #define DECOMP_ERROR		-1	/* error detected before decomp. */ | 
|  | 131 | #define DECOMP_FATALERROR	-2	/* error detected after decomp. */ | 
|  | 132 |  | 
|  | 133 | /* | 
|  | 134 | * CCP codes. | 
|  | 135 | */ | 
|  | 136 |  | 
|  | 137 | #define CCP_CONFREQ	1 | 
|  | 138 | #define CCP_CONFACK	2 | 
|  | 139 | #define CCP_TERMREQ	5 | 
|  | 140 | #define CCP_TERMACK	6 | 
|  | 141 | #define CCP_RESETREQ	14 | 
|  | 142 | #define CCP_RESETACK	15 | 
|  | 143 |  | 
|  | 144 | /* | 
|  | 145 | * Max # bytes for a CCP option | 
|  | 146 | */ | 
|  | 147 |  | 
|  | 148 | #define CCP_MAX_OPTION_LENGTH	32 | 
|  | 149 |  | 
|  | 150 | /* | 
|  | 151 | * Parts of a CCP packet. | 
|  | 152 | */ | 
|  | 153 |  | 
|  | 154 | #define CCP_CODE(dp)		((dp)[0]) | 
|  | 155 | #define CCP_ID(dp)		((dp)[1]) | 
|  | 156 | #define CCP_LENGTH(dp)		(((dp)[2] << 8) + (dp)[3]) | 
|  | 157 | #define CCP_HDRLEN		4 | 
|  | 158 |  | 
|  | 159 | #define CCP_OPT_CODE(dp)	((dp)[0]) | 
|  | 160 | #define CCP_OPT_LENGTH(dp)	((dp)[1]) | 
|  | 161 | #define CCP_OPT_MINLEN		2 | 
|  | 162 |  | 
|  | 163 | /* | 
|  | 164 | * Definitions for BSD-Compress. | 
|  | 165 | */ | 
|  | 166 |  | 
|  | 167 | #define CI_BSD_COMPRESS		21	/* config. option for BSD-Compress */ | 
|  | 168 | #define CILEN_BSD_COMPRESS	3	/* length of config. option */ | 
|  | 169 |  | 
|  | 170 | /* Macros for handling the 3rd byte of the BSD-Compress config option. */ | 
|  | 171 | #define BSD_NBITS(x)		((x) & 0x1F)	/* number of bits requested */ | 
|  | 172 | #define BSD_VERSION(x)		((x) >> 5)	/* version of option format */ | 
|  | 173 | #define BSD_CURRENT_VERSION	1		/* current version number */ | 
|  | 174 | #define BSD_MAKE_OPT(v, n)	(((v) << 5) | (n)) | 
|  | 175 |  | 
|  | 176 | #define BSD_MIN_BITS		9	/* smallest code size supported */ | 
|  | 177 | #define BSD_MAX_BITS		15	/* largest code size supported */ | 
|  | 178 |  | 
|  | 179 | /* | 
|  | 180 | * Definitions for Deflate. | 
|  | 181 | */ | 
|  | 182 |  | 
|  | 183 | #define CI_DEFLATE		26	/* config option for Deflate */ | 
|  | 184 | #define CI_DEFLATE_DRAFT	24	/* value used in original draft RFC */ | 
|  | 185 | #define CILEN_DEFLATE		4	/* length of its config option */ | 
|  | 186 |  | 
|  | 187 | #define DEFLATE_MIN_SIZE	9 | 
|  | 188 | #define DEFLATE_MAX_SIZE	15 | 
|  | 189 | #define DEFLATE_METHOD_VAL	8 | 
|  | 190 | #define DEFLATE_SIZE(x)		(((x) >> 4) + 8) | 
|  | 191 | #define DEFLATE_METHOD(x)	((x) & 0x0F) | 
|  | 192 | #define DEFLATE_MAKE_OPT(w)	((((w) - 8) << 4) + DEFLATE_METHOD_VAL) | 
|  | 193 | #define DEFLATE_CHK_SEQUENCE	0 | 
|  | 194 |  | 
|  | 195 | /* | 
| Matt Domsch | b3f9b92 | 2005-11-08 09:40:47 -0800 | [diff] [blame] | 196 | * Definitions for MPPE. | 
|  | 197 | */ | 
|  | 198 |  | 
|  | 199 | #define CI_MPPE                18      /* config option for MPPE */ | 
|  | 200 | #define CILEN_MPPE              6      /* length of config option */ | 
|  | 201 |  | 
|  | 202 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | * Definitions for other, as yet unsupported, compression methods. | 
|  | 204 | */ | 
|  | 205 |  | 
|  | 206 | #define CI_PREDICTOR_1		1	/* config option for Predictor-1 */ | 
|  | 207 | #define CILEN_PREDICTOR_1	2	/* length of its config option */ | 
|  | 208 | #define CI_PREDICTOR_2		2	/* config option for Predictor-2 */ | 
|  | 209 | #define CILEN_PREDICTOR_2	2	/* length of its config option */ | 
|  | 210 |  | 
|  | 211 | #ifdef __KERNEL__ | 
|  | 212 | extern int ppp_register_compressor(struct compressor *); | 
|  | 213 | extern void ppp_unregister_compressor(struct compressor *); | 
|  | 214 | #endif /* __KERNEL__ */ | 
|  | 215 |  | 
|  | 216 | #endif /* _NET_PPP_COMP_H */ |