June 2025 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 1 | 2 | 3 | 4 | 5 | 6 |
001: /* 002: * ppp-comp.h - Definitions for doing PPP packet compression. 003: * 004: * Copyright (c) 1994 The Australian National University. 005: * All rights reserved. 006: * 007: * Permission to use, copy, modify, and distribute this software and its 008: * documentation is hereby granted, provided that the above copyright 009: * notice appears in all copies. This software is provided without any 010: * warranty, express or implied. The Australian National University 011: * makes no representations about the suitability of this software for 012: * any purpose. 013: * 014: * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY 015: * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 016: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 017: * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY 018: * OF SUCH DAMAGE. 019: * 020: * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, 021: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 022: * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 023: * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO 024: * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 025: * OR MODIFICATIONS. 026: */ 027: 028: /* 029: * ==FILEVERSION 980319== 030: * 031: * NOTE TO MAINTAINERS: 032: * If you modify this file at all, please set the above date. 033: * ppp-comp.h is shipped with a PPP distribution as well as with the kernel; 034: * if everyone increases the FILEVERSION number above, then scripts 035: * can do the right thing when deciding whether to install a new ppp-comp.h 036: * file. Don't change the format of that line otherwise, so the 037: * installation script can recognize it. 038: */ 039: 040: #ifndef _NET_PPP_COMP_H 041: #define _NET_PPP_COMP_H 042: 043: struct module; 044: 045: /* 046: * The following symbols control whether we include code for 047: * various compression methods. 048: */ 049: 050: #ifndef DO_BSD_COMPRESS 051: #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */ 052: #endif 053: #ifndef DO_DEFLATE 054: #define DO_DEFLATE 1 /* by default, include Deflate */ 055: #endif 056: #define DO_PREDICTOR_1 0 057: #define DO_PREDICTOR_2 0 058: 059: /* 060: * Structure giving methods for compression/decompression. 061: */ 062: 063: struct compressor { 064: int compress_proto; /* CCP compression protocol number */ 065: 066: /* Allocate space for a compressor (transmit side) */ 067: void *(*comp_alloc) (unsigned char *options, int opt_len); 068: 069: /* Free space used by a compressor */ 070: void (*comp_free) (void *state); 071: 072: /* Initialize a compressor */ 073: int (*comp_init) (void *state, unsigned char *options, 074: int opt_len, int unit, int opthdr, int debug); 075: 076: /* Reset a compressor */ 077: void (*comp_reset) (void *state); 078: 079: /* Compress a packet */ 080: int (*compress) (void *state, unsigned char *rptr, 081: unsigned char *obuf, int isize, int osize); 082: 083: /* Return compression statistics */ 084: void (*comp_stat) (void *state, struct compstat *stats); 085: 086: /* Allocate space for a decompressor (receive side) */ 087: void *(*decomp_alloc) (unsigned char *options, int opt_len); 088: 089: /* Free space used by a decompressor */ 090: void (*decomp_free) (void *state); 091: 092: /* Initialize a decompressor */ 093: int (*decomp_init) (void *state, unsigned char *options, 094: int opt_len, int unit, int opthdr, int mru, 095: int debug); 096: 097: /* Reset a decompressor */ 098: void (*decomp_reset) (void *state); 099: 100: /* Decompress a packet. */ 101: int (*decompress) (void *state, unsigned char *ibuf, int isize, 102: unsigned char *obuf, int osize); 103: 104: /* Update state for an incompressible packet received */ 105: void (*incomp) (void *state, unsigned char *ibuf, int icnt); 106: 107: /* Return decompression statistics */ 108: void (*decomp_stat) (void *state, struct compstat *stats); 109: 110: /* Used in locking compressor modules */ 111: struct module *owner; 112: /* Extra skb space needed by the compressor algorithm */ 113: unsigned int comp_extra; 114: }; 115: 116: /* 117: * The return value from decompress routine is the length of the 118: * decompressed packet if successful, otherwise DECOMP_ERROR 119: * or DECOMP_FATALERROR if an error occurred. 120: * 121: * We need to make this distinction so that we can disable certain 122: * useful functionality, namely sending a CCP reset-request as a result 123: * of an error detected after decompression. This is to avoid infringing 124: * a patent held by Motorola. 125: * Don't you just lurve software patents. 126: */ 127: 128: #define DECOMP_ERROR -1 /* error detected before decomp. */ 129: #define DECOMP_FATALERROR -2 /* error detected after decomp. */ 130: 131: /* 132: * CCP codes. 133: */ 134: 135: #define CCP_CONFREQ 1 136: #define CCP_CONFACK 2 137: #define CCP_TERMREQ 5 138: #define CCP_TERMACK 6 139: #define CCP_RESETREQ 14 140: #define CCP_RESETACK 15 141: 142: /* 143: * Max # bytes for a CCP option 144: */ 145: 146: #define CCP_MAX_OPTION_LENGTH 32 147: 148: /* 149: * Parts of a CCP packet. 150: */ 151: 152: #define CCP_CODE(dp) ((dp)[0]) 153: #define CCP_ID(dp) ((dp)[1]) 154: #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3]) 155: #define CCP_HDRLEN 4 156: 157: #define CCP_OPT_CODE(dp) ((dp)[0]) 158: #define CCP_OPT_LENGTH(dp) ((dp)[1]) 159: #define CCP_OPT_MINLEN 2 160: 161: /* 162: * Definitions for BSD-Compress. 163: */ 164: 165: #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */ 166: #define CILEN_BSD_COMPRESS 3 /* length of config. option */ 167: 168: /* Macros for handling the 3rd byte of the BSD-Compress config option. */ 169: #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */ 170: #define BSD_VERSION(x) ((x) >> 5) /* version of option format */ 171: #define BSD_CURRENT_VERSION 1 /* current version number */ 172: #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n)) 173: 174: #define BSD_MIN_BITS 9 /* smallest code size supported */ 175: #define BSD_MAX_BITS 15 /* largest code size supported */ 176: 177: /* 178: * Definitions for Deflate. 179: */ 180: 181: #define CI_DEFLATE 26 /* config option for Deflate */ 182: #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */ 183: #define CILEN_DEFLATE 4 /* length of its config option */ 184: 185: #define DEFLATE_MIN_SIZE 9 186: #define DEFLATE_MAX_SIZE 15 187: #define DEFLATE_METHOD_VAL 8 188: #define DEFLATE_SIZE(x) (((x) >> 4) + 8) 189: #define DEFLATE_METHOD(x) ((x) & 0x0F) 190: #define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) 191: #define DEFLATE_CHK_SEQUENCE 0 192: 193: /* 194: * Definitions for MPPE. 195: */ 196: 197: #define CI_MPPE 18 /* config option for MPPE */ 198: #define CILEN_MPPE 6 /* length of config option */ 199: 200: /* 201: * Definitions for other, as yet unsupported, compression methods. 202: */ 203: 204: #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */ 205: #define CILEN_PREDICTOR_1 2 /* length of its config option */ 206: #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */ 207: #define CILEN_PREDICTOR_2 2 /* length of its config option */ 208: 209: 210: #endif /* _NET_PPP_COMP_H */ 211: