]> git.ozlabs.org Git - ppp.git/blob - include/net/ppp-comp.h
define DO_BSD_COMPRESS
[ppp.git] / include / net / ppp-comp.h
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 #ifndef _NET_PPP_COMP_H
31 #define _NET_PPP_COMP_H
32
33 /*
34  * The following symbols control whether we include code for
35  * various compression methods.
36  */
37 #ifndef DO_BSD_COMPRESS
38 #define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
39 #endif
40
41 /*
42  * Structure giving methods for compression/decompression.
43  */
44 #ifdef PACKETPTR
45 struct compressor {
46         int     compress_proto; /* CCP compression protocol number */
47
48         /* Allocate space for a compressor (transmit side) */
49         void    *(*comp_alloc) __P((u_char *options, int opt_len));
50         /* Free space used by a compressor */
51         void    (*comp_free) __P((void *state));
52         /* Initialize a compressor */
53         int     (*comp_init) __P((void *state, u_char *options, int opt_len,
54                                   int unit, int hdrlen, int debug));
55         /* Reset a compressor */
56         void    (*comp_reset) __P((void *state));
57         /* Compress a packet */
58         int     (*compress) __P((void *state, PACKETPTR *mret,
59                                  PACKETPTR mp, int orig_len, int max_len));
60         /* Return compression statistics */
61         void    (*comp_stat) __P((void *state, struct compstat *stats));
62
63         /* Allocate space for a decompressor (receive side) */
64         void    *(*decomp_alloc) __P((u_char *options, int opt_len));
65         /* Free space used by a decompressor */
66         void    (*decomp_free) __P((void *state));
67         /* Initialize a decompressor */
68         int     (*decomp_init) __P((void *state, u_char *options, int opt_len,
69                                     int unit, int hdrlen, int mru, int debug));
70         /* Reset a decompressor */
71         void    (*decomp_reset) __P((void *state));
72         /* Decompress a packet. */
73         int     (*decompress) __P((void *state, PACKETPTR mp,
74                                    PACKETPTR *dmpp));
75         /* Update state for an incompressible packet received */
76         void    (*incomp) __P((void *state, PACKETPTR mp));
77         /* Return decompression statistics */
78         void    (*decomp_stat) __P((void *state, struct compstat *stats));
79 };
80 #endif /* PACKETPTR */
81
82 /*
83  * Return values for decompress routine.
84  * We need to make these distinctions so that we can disable certain
85  * useful functionality, namely sending a CCP reset-request as a result
86  * of an error detected after decompression.  This is to avoid infringing
87  * a patent held by Motorola.
88  * Don't you just lurve software patents.
89  */
90 #define DECOMP_OK               0       /* everything went OK */
91 #define DECOMP_ERROR            1       /* error detected before decomp. */
92 #define DECOMP_FATALERROR       2       /* error detected after decomp. */
93
94 /*
95  * CCP codes.
96  */
97 #define CCP_CONFREQ     1
98 #define CCP_CONFACK     2
99 #define CCP_TERMREQ     5
100 #define CCP_TERMACK     6
101 #define CCP_RESETREQ    14
102 #define CCP_RESETACK    15
103
104 /*
105  * Max # bytes for a CCP option
106  */
107 #define CCP_MAX_OPTION_LENGTH   32
108
109 /*
110  * Parts of a CCP packet.
111  */
112 #define CCP_CODE(dp)            ((dp)[0])
113 #define CCP_ID(dp)              ((dp)[1])
114 #define CCP_LENGTH(dp)          (((dp)[2] << 8) + (dp)[3])
115 #define CCP_HDRLEN              4
116
117 #define CCP_OPT_CODE(dp)        ((dp)[0])
118 #define CCP_OPT_LENGTH(dp)      ((dp)[1])
119 #define CCP_OPT_MINLEN          2
120
121 /*
122  * Definitions for BSD-Compress.
123  */
124 #define CI_BSD_COMPRESS         21      /* config. option for BSD-Compress */
125 #define CILEN_BSD_COMPRESS      3       /* length of config. option */
126
127 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
128 #define BSD_NBITS(x)            ((x) & 0x1F)    /* number of bits requested */
129 #define BSD_VERSION(x)          ((x) >> 5)      /* version of option format */
130 #define BSD_CURRENT_VERSION     1               /* current version number */
131 #define BSD_MAKE_OPT(v, n)      (((v) << 5) | (n))
132
133 #define BSD_MIN_BITS            9       /* smallest code size supported */
134 #define BSD_MAX_BITS            15      /* largest code size supported */
135
136 #endif /* _NET_PPP_COMP_H */