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