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