Home | History | Annotate | Line # | Download | only in net
ppp-comp.h revision 1.1
      1  1.1  paulus /*	$NetBSD: ppp-comp.h,v 1.1 1995/07/04 06:28:24 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  * $Id: ppp-comp.h,v 1.1 1995/07/04 06:28:24 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.1  paulus 
     43  1.1  paulus /*
     44  1.1  paulus  * Structure giving methods for compression/decompression.
     45  1.1  paulus  */
     46  1.1  paulus #ifdef PACKETPTR
     47  1.1  paulus struct compressor {
     48  1.1  paulus 	int	compress_proto;	/* CCP compression protocol number */
     49  1.1  paulus 
     50  1.1  paulus 	/* Allocate space for a compressor (transmit side) */
     51  1.1  paulus 	void	*(*comp_alloc) __P((u_char *options, int opt_len));
     52  1.1  paulus 	/* Free space used by a compressor */
     53  1.1  paulus 	void	(*comp_free) __P((void *state));
     54  1.1  paulus 	/* Initialize a compressor */
     55  1.1  paulus 	int	(*comp_init) __P((void *state, u_char *options, int opt_len,
     56  1.1  paulus 				  int unit, int hdrlen, int debug));
     57  1.1  paulus 	/* Reset a compressor */
     58  1.1  paulus 	void	(*comp_reset) __P((void *state));
     59  1.1  paulus 	/* Compress a packet */
     60  1.1  paulus 	int	(*compress) __P((void *state, PACKETPTR *mret,
     61  1.1  paulus 				 PACKETPTR mp, int orig_len, int max_len));
     62  1.1  paulus 	/* Return compression statistics */
     63  1.1  paulus 	void	(*comp_stat) __P((void *state, struct compstat *stats));
     64  1.1  paulus 
     65  1.1  paulus 	/* Allocate space for a decompressor (receive side) */
     66  1.1  paulus 	void	*(*decomp_alloc) __P((u_char *options, int opt_len));
     67  1.1  paulus 	/* Free space used by a decompressor */
     68  1.1  paulus 	void	(*decomp_free) __P((void *state));
     69  1.1  paulus 	/* Initialize a decompressor */
     70  1.1  paulus 	int	(*decomp_init) __P((void *state, u_char *options, int opt_len,
     71  1.1  paulus 				    int unit, int hdrlen, int mru, int debug));
     72  1.1  paulus 	/* Reset a decompressor */
     73  1.1  paulus 	void	(*decomp_reset) __P((void *state));
     74  1.1  paulus 	/* Decompress a packet. */
     75  1.1  paulus 	int	(*decompress) __P((void *state, PACKETPTR mp,
     76  1.1  paulus 				   PACKETPTR *dmpp));
     77  1.1  paulus 	/* Update state for an incompressible packet received */
     78  1.1  paulus 	void	(*incomp) __P((void *state, PACKETPTR mp));
     79  1.1  paulus 	/* Return decompression statistics */
     80  1.1  paulus 	void	(*decomp_stat) __P((void *state, struct compstat *stats));
     81  1.1  paulus };
     82  1.1  paulus #endif /* PACKETPTR */
     83  1.1  paulus 
     84  1.1  paulus /*
     85  1.1  paulus  * Return values for decompress routine.
     86  1.1  paulus  * We need to make these distinctions so that we can disable certain
     87  1.1  paulus  * useful functionality, namely sending a CCP reset-request as a result
     88  1.1  paulus  * of an error detected after decompression.  This is to avoid infringing
     89  1.1  paulus  * a patent held by Motorola.
     90  1.1  paulus  * Don't you just lurve software patents.
     91  1.1  paulus  */
     92  1.1  paulus #define DECOMP_OK		0	/* everything went OK */
     93  1.1  paulus #define DECOMP_ERROR		1	/* error detected before decomp. */
     94  1.1  paulus #define DECOMP_FATALERROR	2	/* error detected after decomp. */
     95  1.1  paulus 
     96  1.1  paulus /*
     97  1.1  paulus  * CCP codes.
     98  1.1  paulus  */
     99  1.1  paulus #define CCP_CONFREQ	1
    100  1.1  paulus #define CCP_CONFACK	2
    101  1.1  paulus #define CCP_TERMREQ	5
    102  1.1  paulus #define CCP_TERMACK	6
    103  1.1  paulus #define CCP_RESETREQ	14
    104  1.1  paulus #define CCP_RESETACK	15
    105  1.1  paulus 
    106  1.1  paulus /*
    107  1.1  paulus  * Max # bytes for a CCP option
    108  1.1  paulus  */
    109  1.1  paulus #define CCP_MAX_OPTION_LENGTH	32
    110  1.1  paulus 
    111  1.1  paulus /*
    112  1.1  paulus  * Parts of a CCP packet.
    113  1.1  paulus  */
    114  1.1  paulus #define CCP_CODE(dp)		((dp)[0])
    115  1.1  paulus #define CCP_ID(dp)		((dp)[1])
    116  1.1  paulus #define CCP_LENGTH(dp)		(((dp)[2] << 8) + (dp)[3])
    117  1.1  paulus #define CCP_HDRLEN		4
    118  1.1  paulus 
    119  1.1  paulus #define CCP_OPT_CODE(dp)	((dp)[0])
    120  1.1  paulus #define CCP_OPT_LENGTH(dp)	((dp)[1])
    121  1.1  paulus #define CCP_OPT_MINLEN		2
    122  1.1  paulus 
    123  1.1  paulus /*
    124  1.1  paulus  * Definitions for BSD-Compress.
    125  1.1  paulus  */
    126  1.1  paulus #define CI_BSD_COMPRESS		21	/* config. option for BSD-Compress */
    127  1.1  paulus #define CILEN_BSD_COMPRESS	3	/* length of config. option */
    128  1.1  paulus 
    129  1.1  paulus /* Macros for handling the 3rd byte of the BSD-Compress config option. */
    130  1.1  paulus #define BSD_NBITS(x)		((x) & 0x1F)	/* number of bits requested */
    131  1.1  paulus #define BSD_VERSION(x)		((x) >> 5)	/* version of option format */
    132  1.1  paulus #define BSD_CURRENT_VERSION	1		/* current version number */
    133  1.1  paulus #define BSD_MAKE_OPT(v, n)	(((v) << 5) | (n))
    134  1.1  paulus 
    135  1.1  paulus #define BSD_MIN_BITS		9	/* smallest code size supported */
    136  1.1  paulus #define BSD_MAX_BITS		15	/* largest code size supported */
    137  1.1  paulus 
    138  1.1  paulus #endif /* _NET_PPP_COMP_H */
    139