ppp-comp.h 3.1 KB

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