2 * ppp-comp.h - Definitions for doing PPP packet compression.
4 * Copyright (c) 1994 The Australian National University.
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
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
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,
27 * $Id: ppp-comp.h,v 1.6 1995/04/24 02:41:37 paulus Exp $
30 #ifndef _NET_PPP_COMP_H
31 #define _NET_PPP_COMP_H
35 * Structure giving methods for compression/decompression.
38 int compress_proto; /* CCP compression protocol number */
40 /* Allocate space for a compressor (transmit side) */
41 void *(*comp_alloc) __P((u_char *options, int opt_len));
42 /* Free space used by a compressor */
43 void (*comp_free) __P((void *state));
44 /* Initialize a compressor */
45 int (*comp_init) __P((void *state, u_char *options, int opt_len,
46 int unit, int hdrlen, int debug));
47 /* Reset a compressor */
48 void (*comp_reset) __P((void *state));
49 /* Compress a packet */
50 int (*compress) __P((void *state, PACKETPTR *mret,
51 PACKETPTR mp, int orig_len, int max_len));
52 /* Return compression statistics */
53 void (*comp_stat) __P((void *state, struct compstat *stats));
55 /* Allocate space for a decompressor (receive side) */
56 void *(*decomp_alloc) __P((u_char *options, int opt_len));
57 /* Free space used by a decompressor */
58 void (*decomp_free) __P((void *state));
59 /* Initialize a decompressor */
60 int (*decomp_init) __P((void *state, u_char *options, int opt_len,
61 int unit, int hdrlen, int mru, int debug));
62 /* Reset a decompressor */
63 void (*decomp_reset) __P((void *state));
64 /* Decompress a packet. */
65 int (*decompress) __P((void *state, PACKETPTR mp,
67 /* Update state for an incompressible packet received */
68 void (*incomp) __P((void *state, PACKETPTR mp));
69 /* Return decompression statistics */
70 void (*decomp_stat) __P((void *state, struct compstat *stats));
72 #endif /* PACKETPTR */
75 * Return values for decompress routine.
76 * We need to make these distinctions so that we can disable certain
77 * useful functionality, namely sending a CCP reset-request as a result
78 * of an error detected after decompression. This is to avoid infringing
79 * a patent held by Motorola.
80 * Don't you just lurve software patents.
82 #define DECOMP_OK 0 /* everything went OK */
83 #define DECOMP_ERROR 1 /* error detected before decomp. */
84 #define DECOMP_FATALERROR 2 /* error detected after decomp. */
93 #define CCP_RESETREQ 14
94 #define CCP_RESETACK 15
97 * Max # bytes for a CCP option
99 #define CCP_MAX_OPTION_LENGTH 32
102 * Parts of a CCP packet.
104 #define CCP_CODE(dp) ((dp)[0])
105 #define CCP_ID(dp) ((dp)[1])
106 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
109 #define CCP_OPT_CODE(dp) ((dp)[0])
110 #define CCP_OPT_LENGTH(dp) ((dp)[1])
111 #define CCP_OPT_MINLEN 2
114 * Definitions for BSD-Compress.
116 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
117 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
119 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
120 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
121 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
122 #define BSD_CURRENT_VERSION 1 /* current version number */
123 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
125 #define BSD_MIN_BITS 9 /* smallest code size supported */
126 #define BSD_MAX_BITS 15 /* largest code size supported */
128 #endif /* _NET_PPP_COMP_H */