| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * ppp-comp.h - Definitions for doing PPP packet compression. | 
 | 3 |  * | 
| Paul Mackerras | 784db3f | 2012-03-04 12:54:54 +0000 | [diff] [blame] | 4 |  * Copyright 1994-1998 Paul Mackerras. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 |  * | 
| Paul Mackerras | 784db3f | 2012-03-04 12:54:54 +0000 | [diff] [blame] | 6 |  *  This program is free software; you can redistribute it and/or | 
 | 7 |  *  modify it under the terms of the GNU General Public License | 
 | 8 |  *  version 2 as published by the Free Software Foundation. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 |  */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #ifndef _NET_PPP_COMP_H | 
 | 11 | #define _NET_PPP_COMP_H | 
 | 12 |  | 
| David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 13 | #include <uapi/linux/ppp-comp.h> | 
 | 14 |  | 
| David Howells | 8e4627d | 2012-10-13 09:58:38 +0100 | [diff] [blame] | 15 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | struct module; | 
 | 17 |  | 
 | 18 | /* | 
 | 19 |  * The following symbols control whether we include code for | 
 | 20 |  * various compression methods. | 
 | 21 |  */ | 
 | 22 |  | 
 | 23 | #ifndef DO_BSD_COMPRESS | 
 | 24 | #define DO_BSD_COMPRESS	1	/* by default, include BSD-Compress */ | 
 | 25 | #endif | 
 | 26 | #ifndef DO_DEFLATE | 
 | 27 | #define DO_DEFLATE	1	/* by default, include Deflate */ | 
 | 28 | #endif | 
 | 29 | #define DO_PREDICTOR_1	0 | 
 | 30 | #define DO_PREDICTOR_2	0 | 
 | 31 |  | 
 | 32 | /* | 
 | 33 |  * Structure giving methods for compression/decompression. | 
 | 34 |  */ | 
 | 35 |  | 
 | 36 | struct compressor { | 
 | 37 | 	int	compress_proto;	/* CCP compression protocol number */ | 
 | 38 |  | 
 | 39 | 	/* Allocate space for a compressor (transmit side) */ | 
 | 40 | 	void	*(*comp_alloc) (unsigned char *options, int opt_len); | 
 | 41 |  | 
 | 42 | 	/* Free space used by a compressor */ | 
 | 43 | 	void	(*comp_free) (void *state); | 
 | 44 |  | 
 | 45 | 	/* Initialize a compressor */ | 
 | 46 | 	int	(*comp_init) (void *state, unsigned char *options, | 
 | 47 | 			      int opt_len, int unit, int opthdr, int debug); | 
 | 48 |  | 
 | 49 | 	/* Reset a compressor */ | 
 | 50 | 	void	(*comp_reset) (void *state); | 
 | 51 |  | 
 | 52 | 	/* Compress a packet */ | 
 | 53 | 	int     (*compress) (void *state, unsigned char *rptr, | 
 | 54 | 			      unsigned char *obuf, int isize, int osize); | 
 | 55 |  | 
 | 56 | 	/* Return compression statistics */ | 
 | 57 | 	void	(*comp_stat) (void *state, struct compstat *stats); | 
 | 58 |  | 
 | 59 | 	/* Allocate space for a decompressor (receive side) */ | 
 | 60 | 	void	*(*decomp_alloc) (unsigned char *options, int opt_len); | 
 | 61 |  | 
 | 62 | 	/* Free space used by a decompressor */ | 
 | 63 | 	void	(*decomp_free) (void *state); | 
 | 64 |  | 
 | 65 | 	/* Initialize a decompressor */ | 
 | 66 | 	int	(*decomp_init) (void *state, unsigned char *options, | 
 | 67 | 				int opt_len, int unit, int opthdr, int mru, | 
 | 68 | 				int debug); | 
 | 69 |  | 
 | 70 | 	/* Reset a decompressor */ | 
 | 71 | 	void	(*decomp_reset) (void *state); | 
 | 72 |  | 
 | 73 | 	/* Decompress a packet. */ | 
 | 74 | 	int	(*decompress) (void *state, unsigned char *ibuf, int isize, | 
 | 75 | 				unsigned char *obuf, int osize); | 
 | 76 |  | 
 | 77 | 	/* Update state for an incompressible packet received */ | 
 | 78 | 	void	(*incomp) (void *state, unsigned char *ibuf, int icnt); | 
 | 79 |  | 
 | 80 | 	/* Return decompression statistics */ | 
 | 81 | 	void	(*decomp_stat) (void *state, struct compstat *stats); | 
 | 82 |  | 
 | 83 | 	/* Used in locking compressor modules */ | 
 | 84 | 	struct module *owner; | 
| Matt Domsch | b3f9b92 | 2005-11-08 09:40:47 -0800 | [diff] [blame] | 85 | 	/* Extra skb space needed by the compressor algorithm */ | 
 | 86 | 	unsigned int comp_extra; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | }; | 
 | 88 |  | 
 | 89 | /* | 
 | 90 |  * The return value from decompress routine is the length of the | 
 | 91 |  * decompressed packet if successful, otherwise DECOMP_ERROR | 
 | 92 |  * or DECOMP_FATALERROR if an error occurred. | 
 | 93 |  *  | 
 | 94 |  * We need to make this distinction so that we can disable certain | 
 | 95 |  * useful functionality, namely sending a CCP reset-request as a result | 
 | 96 |  * of an error detected after decompression.  This is to avoid infringing | 
 | 97 |  * a patent held by Motorola. | 
 | 98 |  * Don't you just lurve software patents. | 
 | 99 |  */ | 
 | 100 |  | 
 | 101 | #define DECOMP_ERROR		-1	/* error detected before decomp. */ | 
 | 102 | #define DECOMP_FATALERROR	-2	/* error detected after decomp. */ | 
 | 103 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | extern int ppp_register_compressor(struct compressor *); | 
 | 105 | extern void ppp_unregister_compressor(struct compressor *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | #endif /* _NET_PPP_COMP_H */ |