root/include/linux/ppp-comp.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   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.7 1995/05/01 01:43:37 paulus Exp $
  28  */
  29 
  30 /*
  31  *  ==FILEVERSION 3==
  32  *
  33  *  NOTE TO MAINTAINERS:
  34  *     If you modify this file at all, increment the number above.
  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 /*
  46  * The following symbols control whether we include code for
  47  * various compression methods.
  48  */
  49 
  50 #ifndef DO_BSD_COMPRESS
  51 #define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
  52 #endif
  53 
  54 #define DO_PREDICTOR_1  0
  55 #define DO_PREDICTOR_2  0
  56 #define DO_DEFLATE      0
  57 
  58 /*
  59  * Structure giving methods for compression/decompression.
  60  */
  61 
  62 #ifdef PACKETPTR
  63 struct compressor {
  64         int     compress_proto; /* CCP compression protocol number */
  65 
  66         /* Allocate space for a compressor (transmit side) */
  67         void    *(*comp_alloc) (unsigned char *options, int opt_len);
  68 
  69         /* Free space used by a compressor */
  70         void    (*comp_free) (void *state);
  71 
  72         /* Initialize a compressor */
  73         int     (*comp_init) (void *state, unsigned char *options,
  74                               int opt_len, int unit, int opthdr, int debug);
  75 
  76         /* Reset a compressor */
  77         void    (*comp_reset) (void *state);
  78 
  79         /* Compress a packet */
  80         int     (*compress) (void *state, unsigned char *rptr,
  81                               unsigned char *obuf, int isize, int osize);
  82 
  83         /* Return compression statistics */
  84         void    (*comp_stat) (void *state, struct compstat *stats);
  85 
  86         /* Allocate space for a decompressor (receive side) */
  87         void    *(*decomp_alloc) (unsigned char *options, int opt_len);
  88 
  89         /* Free space used by a decompressor */
  90         void    (*decomp_free) (void *state);
  91 
  92         /* Initialize a decompressor */
  93         int     (*decomp_init) (void *state, unsigned char *options,
  94                                 int opt_len, int unit, int opthdr, int mru,
  95                                 int debug);
  96 
  97         /* Reset a decompressor */
  98         void    (*decomp_reset) (void *state);
  99 
 100         /* Decompress a packet. */
 101         int     (*decompress) (void *state, unsigned char *ibuf, int isize,
 102                                 unsigned char *obuf, int osize);
 103 
 104         /* Update state for an incompressible packet received */
 105         void    (*incomp) (void *state, unsigned char *ibuf, int icnt);
 106 
 107         /* Return decompression statistics */
 108         void    (*decomp_stat) (void *state, struct compstat *stats);
 109 };
 110 #endif /* PACKETPTR */
 111 
 112 /*
 113  * Return values for decompress routine.
 114  * We need to make these distinctions so that we can disable certain
 115  * useful functionality, namely sending a CCP reset-request as a result
 116  * of an error detected after decompression.  This is to avoid infringing
 117  * a patent held by Motorola.
 118  * Don't you just lurve software patents.
 119  */
 120 
 121 #define DECOMP_OK               0       /* everything went OK */
 122 #define DECOMP_ERROR            1       /* error detected before decomp. */
 123 #define DECOMP_FATALERROR       2       /* error detected after decomp. */
 124 
 125 /*
 126  * CCP codes.
 127  */
 128 
 129 #define CCP_CONFREQ     1
 130 #define CCP_CONFACK     2
 131 #define CCP_TERMREQ     5
 132 #define CCP_TERMACK     6
 133 #define CCP_RESETREQ    14
 134 #define CCP_RESETACK    15
 135 
 136 /*
 137  * Max # bytes for a CCP option
 138  */
 139 
 140 #define CCP_MAX_OPTION_LENGTH   32
 141 
 142 /*
 143  * Parts of a CCP packet.
 144  */
 145 
 146 #define CCP_CODE(dp)            ((dp)[0])
 147 #define CCP_ID(dp)              ((dp)[1])
 148 #define CCP_LENGTH(dp)          (((dp)[2] << 8) + (dp)[3])
 149 #define CCP_HDRLEN              4
 150 
 151 #define CCP_OPT_CODE(dp)        ((dp)[0])
 152 #define CCP_OPT_LENGTH(dp)      ((dp)[1])
 153 #define CCP_OPT_MINLEN          2
 154 
 155 /*
 156  * Definitions for BSD-Compress.
 157  */
 158 
 159 #define CI_BSD_COMPRESS         21      /* config. option for BSD-Compress */
 160 #define CILEN_BSD_COMPRESS      3       /* length of config. option */
 161 
 162 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
 163 #define BSD_NBITS(x)            ((x) & 0x1F)    /* number of bits requested */
 164 #define BSD_VERSION(x)          ((x) >> 5)      /* version of option format */
 165 #define BSD_CURRENT_VERSION     1               /* current version number */
 166 #define BSD_MAKE_OPT(v, n)      (((v) << 5) | (n))
 167 
 168 #define BSD_MIN_BITS            9       /* smallest code size supported */
 169 #define BSD_MAX_BITS            15      /* largest code size supported */
 170 
 171 /*
 172  * Definitions for other, as yet unsupported, compression methods.
 173  */
 174 
 175 #define CI_PREDICTOR_1          1       /* config option for Predictor-1 */
 176 #define CILEN_PREDICTOR_1       2       /* length of its config option */
 177 #define CI_PREDICTOR_2          2       /* config option for Predictor-2 */
 178 #define CILEN_PREDICTOR_2       2       /* length of its config option */
 179 
 180 #define CI_DEFLATE              24      /* config option for Deflate */
 181 #define CILEN_DEFLATE           4       /* length of its config option */
 182 
 183 #define DEFLATE_MIN_SIZE        8
 184 #define DEFLATE_MAX_SIZE        15
 185 #define DEFLATE_METHOD_VAL      8
 186 #define DEFLATE_SIZE(x)         (((x) >> 4) + DEFLATE_MIN_SIZE)
 187 #define DEFLATE_METHOD(x)       ((x) & 0x0F)
 188 #define DEFLATE_MAKE_OPT(w)     ((((w) - DEFLATE_MIN_SIZE) << 4) \
 189                                  + DEFLATE_METHOD_VAL)
 190 #define DEFLATE_CHK_SEQUENCE    0
 191 
 192 #endif /* _NET_PPP_COMP_H */

/* [previous][next][first][last][top][bottom][index][help] */