Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * ppp-comp.h - Definitions for doing PPP packet compression.
0004  *
0005  * Copyright 1994-1998 Paul Mackerras.
0006  */
0007 #ifndef _NET_PPP_COMP_H
0008 #define _NET_PPP_COMP_H
0009 
0010 #include <uapi/linux/ppp-comp.h>
0011 
0012 struct compstat;
0013 struct module;
0014 
0015 /*
0016  * The following symbols control whether we include code for
0017  * various compression methods.
0018  */
0019 
0020 #ifndef DO_BSD_COMPRESS
0021 #define DO_BSD_COMPRESS 1   /* by default, include BSD-Compress */
0022 #endif
0023 #ifndef DO_DEFLATE
0024 #define DO_DEFLATE  1   /* by default, include Deflate */
0025 #endif
0026 #define DO_PREDICTOR_1  0
0027 #define DO_PREDICTOR_2  0
0028 
0029 /*
0030  * Structure giving methods for compression/decompression.
0031  */
0032 
0033 struct compressor {
0034     int compress_proto; /* CCP compression protocol number */
0035 
0036     /* Allocate space for a compressor (transmit side) */
0037     void    *(*comp_alloc) (unsigned char *options, int opt_len);
0038 
0039     /* Free space used by a compressor */
0040     void    (*comp_free) (void *state);
0041 
0042     /* Initialize a compressor */
0043     int (*comp_init) (void *state, unsigned char *options,
0044                   int opt_len, int unit, int opthdr, int debug);
0045 
0046     /* Reset a compressor */
0047     void    (*comp_reset) (void *state);
0048 
0049     /* Compress a packet */
0050     int     (*compress) (void *state, unsigned char *rptr,
0051                   unsigned char *obuf, int isize, int osize);
0052 
0053     /* Return compression statistics */
0054     void    (*comp_stat) (void *state, struct compstat *stats);
0055 
0056     /* Allocate space for a decompressor (receive side) */
0057     void    *(*decomp_alloc) (unsigned char *options, int opt_len);
0058 
0059     /* Free space used by a decompressor */
0060     void    (*decomp_free) (void *state);
0061 
0062     /* Initialize a decompressor */
0063     int (*decomp_init) (void *state, unsigned char *options,
0064                 int opt_len, int unit, int opthdr, int mru,
0065                 int debug);
0066 
0067     /* Reset a decompressor */
0068     void    (*decomp_reset) (void *state);
0069 
0070     /* Decompress a packet. */
0071     int (*decompress) (void *state, unsigned char *ibuf, int isize,
0072                 unsigned char *obuf, int osize);
0073 
0074     /* Update state for an incompressible packet received */
0075     void    (*incomp) (void *state, unsigned char *ibuf, int icnt);
0076 
0077     /* Return decompression statistics */
0078     void    (*decomp_stat) (void *state, struct compstat *stats);
0079 
0080     /* Used in locking compressor modules */
0081     struct module *owner;
0082     /* Extra skb space needed by the compressor algorithm */
0083     unsigned int comp_extra;
0084 };
0085 
0086 /*
0087  * The return value from decompress routine is the length of the
0088  * decompressed packet if successful, otherwise DECOMP_ERROR
0089  * or DECOMP_FATALERROR if an error occurred.
0090  * 
0091  * We need to make this distinction so that we can disable certain
0092  * useful functionality, namely sending a CCP reset-request as a result
0093  * of an error detected after decompression.  This is to avoid infringing
0094  * a patent held by Motorola.
0095  * Don't you just lurve software patents.
0096  */
0097 
0098 #define DECOMP_ERROR        -1  /* error detected before decomp. */
0099 #define DECOMP_FATALERROR   -2  /* error detected after decomp. */
0100 
0101 extern int ppp_register_compressor(struct compressor *);
0102 extern void ppp_unregister_compressor(struct compressor *);
0103 #endif /* _NET_PPP_COMP_H */