18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ppp-comp.h - Definitions for doing PPP packet compression. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 1994-1998 Paul Mackerras. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef _NET_PPP_COMP_H 88c2ecf20Sopenharmony_ci#define _NET_PPP_COMP_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <uapi/linux/ppp-comp.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct module; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * The following symbols control whether we include code for 178c2ecf20Sopenharmony_ci * various compression methods. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#ifndef DO_BSD_COMPRESS 218c2ecf20Sopenharmony_ci#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */ 228c2ecf20Sopenharmony_ci#endif 238c2ecf20Sopenharmony_ci#ifndef DO_DEFLATE 248c2ecf20Sopenharmony_ci#define DO_DEFLATE 1 /* by default, include Deflate */ 258c2ecf20Sopenharmony_ci#endif 268c2ecf20Sopenharmony_ci#define DO_PREDICTOR_1 0 278c2ecf20Sopenharmony_ci#define DO_PREDICTOR_2 0 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * Structure giving methods for compression/decompression. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct compressor { 348c2ecf20Sopenharmony_ci int compress_proto; /* CCP compression protocol number */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci /* Allocate space for a compressor (transmit side) */ 378c2ecf20Sopenharmony_ci void *(*comp_alloc) (unsigned char *options, int opt_len); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* Free space used by a compressor */ 408c2ecf20Sopenharmony_ci void (*comp_free) (void *state); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci /* Initialize a compressor */ 438c2ecf20Sopenharmony_ci int (*comp_init) (void *state, unsigned char *options, 448c2ecf20Sopenharmony_ci int opt_len, int unit, int opthdr, int debug); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci /* Reset a compressor */ 478c2ecf20Sopenharmony_ci void (*comp_reset) (void *state); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci /* Compress a packet */ 508c2ecf20Sopenharmony_ci int (*compress) (void *state, unsigned char *rptr, 518c2ecf20Sopenharmony_ci unsigned char *obuf, int isize, int osize); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci /* Return compression statistics */ 548c2ecf20Sopenharmony_ci void (*comp_stat) (void *state, struct compstat *stats); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* Allocate space for a decompressor (receive side) */ 578c2ecf20Sopenharmony_ci void *(*decomp_alloc) (unsigned char *options, int opt_len); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* Free space used by a decompressor */ 608c2ecf20Sopenharmony_ci void (*decomp_free) (void *state); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* Initialize a decompressor */ 638c2ecf20Sopenharmony_ci int (*decomp_init) (void *state, unsigned char *options, 648c2ecf20Sopenharmony_ci int opt_len, int unit, int opthdr, int mru, 658c2ecf20Sopenharmony_ci int debug); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci /* Reset a decompressor */ 688c2ecf20Sopenharmony_ci void (*decomp_reset) (void *state); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci /* Decompress a packet. */ 718c2ecf20Sopenharmony_ci int (*decompress) (void *state, unsigned char *ibuf, int isize, 728c2ecf20Sopenharmony_ci unsigned char *obuf, int osize); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci /* Update state for an incompressible packet received */ 758c2ecf20Sopenharmony_ci void (*incomp) (void *state, unsigned char *ibuf, int icnt); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci /* Return decompression statistics */ 788c2ecf20Sopenharmony_ci void (*decomp_stat) (void *state, struct compstat *stats); 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci /* Used in locking compressor modules */ 818c2ecf20Sopenharmony_ci struct module *owner; 828c2ecf20Sopenharmony_ci /* Extra skb space needed by the compressor algorithm */ 838c2ecf20Sopenharmony_ci unsigned int comp_extra; 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* 878c2ecf20Sopenharmony_ci * The return value from decompress routine is the length of the 888c2ecf20Sopenharmony_ci * decompressed packet if successful, otherwise DECOMP_ERROR 898c2ecf20Sopenharmony_ci * or DECOMP_FATALERROR if an error occurred. 908c2ecf20Sopenharmony_ci * 918c2ecf20Sopenharmony_ci * We need to make this distinction so that we can disable certain 928c2ecf20Sopenharmony_ci * useful functionality, namely sending a CCP reset-request as a result 938c2ecf20Sopenharmony_ci * of an error detected after decompression. This is to avoid infringing 948c2ecf20Sopenharmony_ci * a patent held by Motorola. 958c2ecf20Sopenharmony_ci * Don't you just lurve software patents. 968c2ecf20Sopenharmony_ci */ 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define DECOMP_ERROR -1 /* error detected before decomp. */ 998c2ecf20Sopenharmony_ci#define DECOMP_FATALERROR -2 /* error detected after decomp. */ 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ciextern int ppp_register_compressor(struct compressor *); 1028c2ecf20Sopenharmony_ciextern void ppp_unregister_compressor(struct compressor *); 1038c2ecf20Sopenharmony_ci#endif /* _NET_PPP_COMP_H */ 104