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