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