2 * ppp_comp.h - Definitions for doing PPP packet compression.
6 * Copyright (c) 1994 The Australian National University.
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation is hereby granted, provided that the above copyright
11 * notice appears in all copies. This software is provided without any
12 * warranty, express or implied. The Australian National University
13 * makes no representations about the suitability of this software for
16 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
17 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
18 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
19 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
22 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
25 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
26 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
32 #ifndef _NET_PPP_COMP_H
33 #define _NET_PPP_COMP_H
36 * Structure giving methods for compression/decompression.
40 int compress_proto; /* CCP compression protocol number */
42 /* Allocate space for a compressor (transmit side) */
43 void *(*comp_alloc)(u_char *options, int opt_len);
44 /* Free space used by a compressor */
45 void (*comp_free)(void *state);
46 /* Initialize a compressor */
47 int (*comp_init)(void *state, u_char *options, int opt_len,
48 int unit, int hdrlen, int debug);
49 /* Reset a compressor */
50 void (*comp_reset)(void *state);
51 /* Compress a packet */
52 int (*compress)(void *state, PACKETPTR *mret, PACKETPTR mp,
53 int orig_len, int max_len);
54 /* Return compression statistics */
55 void (*comp_stat)(void *state, struct compstat *stats);
57 /* Allocate space for a decompressor (receive side) */
58 void *(*decomp_alloc)(u_char *options, int opt_len);
59 /* Free space used by a decompressor */
60 void (*decomp_free)(void *state);
61 /* Initialize a decompressor */
62 int (*decomp_init)(void *state, u_char *options, int opt_len,
63 int unit, int hdrlen, int mru, int debug);
64 /* Reset a decompressor */
65 void (*decomp_reset)(void *state);
66 /* Decompress a packet. */
67 int (*decompress)(void *state, PACKETPTR mp, PACKETPTR *dmpp);
68 /* Update state for an incompressible packet received */
69 void (*incomp)(void *state, PACKETPTR mp);
70 /* Return decompression statistics */
71 void (*decomp_stat)(void *state, struct compstat *stats);
73 #endif /* PACKETPTR */
76 * Return values for decompress routine.
77 * We need to make these distinctions so that we can disable certain
78 * useful functionality, namely sending a CCP reset-request as a result
79 * of an error detected after decompression. This is to avoid infringing
80 * a patent held by Motorola.
81 * Don't you just lurve software patents.
83 #define DECOMP_OK 0 /* everything went OK */
84 #define DECOMP_ERROR 1 /* error detected before decomp. */
85 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
94 #define CCP_RESETREQ 14
95 #define CCP_RESETACK 15
98 * Max # bytes for a CCP option
100 #define CCP_MAX_OPTION_LENGTH 32
103 * Parts of a CCP packet.
105 #define CCP_CODE(dp) ((dp)[0])
106 #define CCP_ID(dp) ((dp)[1])
107 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
110 #define CCP_OPT_CODE(dp) ((dp)[0])
111 #define CCP_OPT_LENGTH(dp) ((dp)[1])
112 #define CCP_OPT_MINLEN 2
115 * Definitions for BSD-Compress.
117 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
118 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
120 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
121 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
122 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
123 #define BSD_CURRENT_VERSION 1 /* current version number */
124 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
126 #define BSD_MIN_BITS 9 /* smallest code size supported */
127 #define BSD_MAX_BITS 15 /* largest code size supported */
130 * Definitions for Deflate.
132 #define CI_DEFLATE 26 /* config option for Deflate */
133 #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
134 #define CILEN_DEFLATE 4 /* length of its config option */
136 #define DEFLATE_MIN_SIZE 8
137 #define DEFLATE_MAX_SIZE 15
138 #define DEFLATE_METHOD_VAL 8
139 #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
140 #define DEFLATE_METHOD(x) ((x) & 0x0F)
141 #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
142 + DEFLATE_METHOD_VAL)
143 #define DEFLATE_CHK_SEQUENCE 0
146 * Definitions for other, as yet unsupported, compression methods.
148 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
149 #define CILEN_PREDICTOR_1 2 /* length of its config option */
150 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
151 #define CILEN_PREDICTOR_2 2 /* length of its config option */
153 #endif /* _NET_PPP_COMP_H */