ppp-comp.h revision 1.2 1 1.2 paulus /* $NetBSD: ppp-comp.h,v 1.2 1996/03/15 02:28:07 paulus Exp $ */
2 1.1 paulus
3 1.1 paulus /*
4 1.1 paulus * ppp-comp.h - Definitions for doing PPP packet compression.
5 1.1 paulus *
6 1.1 paulus * Copyright (c) 1994 The Australian National University.
7 1.1 paulus * All rights reserved.
8 1.1 paulus *
9 1.1 paulus * Permission to use, copy, modify, and distribute this software and its
10 1.1 paulus * documentation is hereby granted, provided that the above copyright
11 1.1 paulus * notice appears in all copies. This software is provided without any
12 1.1 paulus * warranty, express or implied. The Australian National University
13 1.1 paulus * makes no representations about the suitability of this software for
14 1.1 paulus * any purpose.
15 1.1 paulus *
16 1.1 paulus * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
17 1.1 paulus * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
18 1.1 paulus * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
19 1.1 paulus * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
20 1.1 paulus * OF SUCH DAMAGE.
21 1.1 paulus *
22 1.1 paulus * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 1.1 paulus * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 1.1 paulus * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
25 1.1 paulus * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
26 1.1 paulus * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
27 1.1 paulus * OR MODIFICATIONS.
28 1.1 paulus *
29 1.1 paulus */
30 1.1 paulus
31 1.1 paulus #ifndef _NET_PPP_COMP_H
32 1.1 paulus #define _NET_PPP_COMP_H
33 1.1 paulus
34 1.1 paulus /*
35 1.1 paulus * The following symbols control whether we include code for
36 1.1 paulus * various compression methods.
37 1.1 paulus */
38 1.1 paulus #ifndef DO_BSD_COMPRESS
39 1.1 paulus #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
40 1.1 paulus #endif
41 1.2 paulus #ifndef DO_DEFLATE
42 1.2 paulus #define DO_DEFLATE 1 /* by default, include Deflate */
43 1.2 paulus #endif
44 1.2 paulus #define DO_PREDICTOR_1 0
45 1.2 paulus #define DO_PREDICTOR_2 0
46 1.1 paulus
47 1.1 paulus /*
48 1.1 paulus * Structure giving methods for compression/decompression.
49 1.1 paulus */
50 1.1 paulus #ifdef PACKETPTR
51 1.1 paulus struct compressor {
52 1.1 paulus int compress_proto; /* CCP compression protocol number */
53 1.1 paulus
54 1.1 paulus /* Allocate space for a compressor (transmit side) */
55 1.1 paulus void *(*comp_alloc) __P((u_char *options, int opt_len));
56 1.1 paulus /* Free space used by a compressor */
57 1.1 paulus void (*comp_free) __P((void *state));
58 1.1 paulus /* Initialize a compressor */
59 1.1 paulus int (*comp_init) __P((void *state, u_char *options, int opt_len,
60 1.1 paulus int unit, int hdrlen, int debug));
61 1.1 paulus /* Reset a compressor */
62 1.1 paulus void (*comp_reset) __P((void *state));
63 1.1 paulus /* Compress a packet */
64 1.1 paulus int (*compress) __P((void *state, PACKETPTR *mret,
65 1.1 paulus PACKETPTR mp, int orig_len, int max_len));
66 1.1 paulus /* Return compression statistics */
67 1.1 paulus void (*comp_stat) __P((void *state, struct compstat *stats));
68 1.1 paulus
69 1.1 paulus /* Allocate space for a decompressor (receive side) */
70 1.1 paulus void *(*decomp_alloc) __P((u_char *options, int opt_len));
71 1.1 paulus /* Free space used by a decompressor */
72 1.1 paulus void (*decomp_free) __P((void *state));
73 1.1 paulus /* Initialize a decompressor */
74 1.1 paulus int (*decomp_init) __P((void *state, u_char *options, int opt_len,
75 1.1 paulus int unit, int hdrlen, int mru, int debug));
76 1.1 paulus /* Reset a decompressor */
77 1.1 paulus void (*decomp_reset) __P((void *state));
78 1.1 paulus /* Decompress a packet. */
79 1.1 paulus int (*decompress) __P((void *state, PACKETPTR mp,
80 1.1 paulus PACKETPTR *dmpp));
81 1.1 paulus /* Update state for an incompressible packet received */
82 1.1 paulus void (*incomp) __P((void *state, PACKETPTR mp));
83 1.1 paulus /* Return decompression statistics */
84 1.1 paulus void (*decomp_stat) __P((void *state, struct compstat *stats));
85 1.1 paulus };
86 1.1 paulus #endif /* PACKETPTR */
87 1.1 paulus
88 1.1 paulus /*
89 1.1 paulus * Return values for decompress routine.
90 1.1 paulus * We need to make these distinctions so that we can disable certain
91 1.1 paulus * useful functionality, namely sending a CCP reset-request as a result
92 1.1 paulus * of an error detected after decompression. This is to avoid infringing
93 1.1 paulus * a patent held by Motorola.
94 1.1 paulus * Don't you just lurve software patents.
95 1.1 paulus */
96 1.1 paulus #define DECOMP_OK 0 /* everything went OK */
97 1.1 paulus #define DECOMP_ERROR 1 /* error detected before decomp. */
98 1.1 paulus #define DECOMP_FATALERROR 2 /* error detected after decomp. */
99 1.1 paulus
100 1.1 paulus /*
101 1.1 paulus * CCP codes.
102 1.1 paulus */
103 1.1 paulus #define CCP_CONFREQ 1
104 1.1 paulus #define CCP_CONFACK 2
105 1.1 paulus #define CCP_TERMREQ 5
106 1.1 paulus #define CCP_TERMACK 6
107 1.1 paulus #define CCP_RESETREQ 14
108 1.1 paulus #define CCP_RESETACK 15
109 1.1 paulus
110 1.1 paulus /*
111 1.1 paulus * Max # bytes for a CCP option
112 1.1 paulus */
113 1.1 paulus #define CCP_MAX_OPTION_LENGTH 32
114 1.1 paulus
115 1.1 paulus /*
116 1.1 paulus * Parts of a CCP packet.
117 1.1 paulus */
118 1.1 paulus #define CCP_CODE(dp) ((dp)[0])
119 1.1 paulus #define CCP_ID(dp) ((dp)[1])
120 1.1 paulus #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
121 1.1 paulus #define CCP_HDRLEN 4
122 1.1 paulus
123 1.1 paulus #define CCP_OPT_CODE(dp) ((dp)[0])
124 1.1 paulus #define CCP_OPT_LENGTH(dp) ((dp)[1])
125 1.1 paulus #define CCP_OPT_MINLEN 2
126 1.1 paulus
127 1.1 paulus /*
128 1.1 paulus * Definitions for BSD-Compress.
129 1.1 paulus */
130 1.1 paulus #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
131 1.1 paulus #define CILEN_BSD_COMPRESS 3 /* length of config. option */
132 1.1 paulus
133 1.1 paulus /* Macros for handling the 3rd byte of the BSD-Compress config option. */
134 1.1 paulus #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
135 1.1 paulus #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
136 1.1 paulus #define BSD_CURRENT_VERSION 1 /* current version number */
137 1.1 paulus #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
138 1.1 paulus
139 1.1 paulus #define BSD_MIN_BITS 9 /* smallest code size supported */
140 1.1 paulus #define BSD_MAX_BITS 15 /* largest code size supported */
141 1.2 paulus
142 1.2 paulus /*
143 1.2 paulus * Definitions for other, as yet unsupported, compression methods.
144 1.2 paulus */
145 1.2 paulus #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
146 1.2 paulus #define CILEN_PREDICTOR_1 2 /* length of its config option */
147 1.2 paulus #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
148 1.2 paulus #define CILEN_PREDICTOR_2 2 /* length of its config option */
149 1.2 paulus
150 1.2 paulus #define CI_DEFLATE 24 /* config option for Deflate */
151 1.2 paulus #define CILEN_DEFLATE 4 /* length of its config option */
152 1.2 paulus
153 1.2 paulus #define DEFLATE_MIN_SIZE 8
154 1.2 paulus #define DEFLATE_MAX_SIZE 15
155 1.2 paulus #define DEFLATE_METHOD_VAL 8
156 1.2 paulus #define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
157 1.2 paulus #define DEFLATE_METHOD(x) ((x) & 0x0F)
158 1.2 paulus #define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
159 1.2 paulus + DEFLATE_METHOD_VAL)
160 1.2 paulus #define DEFLATE_CHK_SEQUENCE 0
161 1.1 paulus
162 1.1 paulus #endif /* _NET_PPP_COMP_H */
163