ppp-comp.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * ppp-comp.h - Definitions for doing PPP packet compression.
  4. *
  5. * Copyright 1994-1998 Paul Mackerras.
  6. */
  7. #ifndef _NET_PPP_COMP_H
  8. #define _NET_PPP_COMP_H
  9. #include <uapi/linux/ppp-comp.h>
  10. struct module;
  11. /*
  12. * The following symbols control whether we include code for
  13. * various compression methods.
  14. */
  15. #ifndef DO_BSD_COMPRESS
  16. #define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
  17. #endif
  18. #ifndef DO_DEFLATE
  19. #define DO_DEFLATE 1 /* by default, include Deflate */
  20. #endif
  21. #define DO_PREDICTOR_1 0
  22. #define DO_PREDICTOR_2 0
  23. /*
  24. * Structure giving methods for compression/decompression.
  25. */
  26. struct compressor {
  27. int compress_proto; /* CCP compression protocol number */
  28. /* Allocate space for a compressor (transmit side) */
  29. void *(*comp_alloc) (unsigned char *options, int opt_len);
  30. /* Free space used by a compressor */
  31. void (*comp_free) (void *state);
  32. /* Initialize a compressor */
  33. int (*comp_init) (void *state, unsigned char *options,
  34. int opt_len, int unit, int opthdr, int debug);
  35. /* Reset a compressor */
  36. void (*comp_reset) (void *state);
  37. /* Compress a packet */
  38. int (*compress) (void *state, unsigned char *rptr,
  39. unsigned char *obuf, int isize, int osize);
  40. /* Return compression statistics */
  41. void (*comp_stat) (void *state, struct compstat *stats);
  42. /* Allocate space for a decompressor (receive side) */
  43. void *(*decomp_alloc) (unsigned char *options, int opt_len);
  44. /* Free space used by a decompressor */
  45. void (*decomp_free) (void *state);
  46. /* Initialize a decompressor */
  47. int (*decomp_init) (void *state, unsigned char *options,
  48. int opt_len, int unit, int opthdr, int mru,
  49. int debug);
  50. /* Reset a decompressor */
  51. void (*decomp_reset) (void *state);
  52. /* Decompress a packet. */
  53. int (*decompress) (void *state, unsigned char *ibuf, int isize,
  54. unsigned char *obuf, int osize);
  55. /* Update state for an incompressible packet received */
  56. void (*incomp) (void *state, unsigned char *ibuf, int icnt);
  57. /* Return decompression statistics */
  58. void (*decomp_stat) (void *state, struct compstat *stats);
  59. /* Used in locking compressor modules */
  60. struct module *owner;
  61. /* Extra skb space needed by the compressor algorithm */
  62. unsigned int comp_extra;
  63. };
  64. /*
  65. * The return value from decompress routine is the length of the
  66. * decompressed packet if successful, otherwise DECOMP_ERROR
  67. * or DECOMP_FATALERROR if an error occurred.
  68. *
  69. * We need to make this distinction so that we can disable certain
  70. * useful functionality, namely sending a CCP reset-request as a result
  71. * of an error detected after decompression. This is to avoid infringing
  72. * a patent held by Motorola.
  73. * Don't you just lurve software patents.
  74. */
  75. #define DECOMP_ERROR -1 /* error detected before decomp. */
  76. #define DECOMP_FATALERROR -2 /* error detected after decomp. */
  77. extern int ppp_register_compressor(struct compressor *);
  78. extern void ppp_unregister_compressor(struct compressor *);
  79. #endif /* _NET_PPP_COMP_H */