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