blob: 4ea1d377e1ad9d567ab22bd277652724742798d1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ppp-comp.h - Definitions for doing PPP packet compression.
3 *
Paul Mackerras784db3f2012-03-04 12:54:54 +00004 * Copyright 1994-1998 Paul Mackerras.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Paul Mackerras784db3f2012-03-04 12:54:54 +00006 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#ifndef _NET_PPP_COMP_H
11#define _NET_PPP_COMP_H
12
David Howells607ca462012-10-13 10:46:48 +010013#include <uapi/linux/ppp-comp.h>
14
David Howells8e4627dd2012-10-13 09:58:38 +010015
Linus Torvalds1da177e2005-04-16 15:20:36 -070016struct module;
17
18/*
19 * The following symbols control whether we include code for
20 * various compression methods.
21 */
22
23#ifndef DO_BSD_COMPRESS
24#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
25#endif
26#ifndef DO_DEFLATE
27#define DO_DEFLATE 1 /* by default, include Deflate */
28#endif
29#define DO_PREDICTOR_1 0
30#define DO_PREDICTOR_2 0
31
32/*
33 * Structure giving methods for compression/decompression.
34 */
35
36struct compressor {
37 int compress_proto; /* CCP compression protocol number */
38
39 /* Allocate space for a compressor (transmit side) */
40 void *(*comp_alloc) (unsigned char *options, int opt_len);
41
42 /* Free space used by a compressor */
43 void (*comp_free) (void *state);
44
45 /* Initialize a compressor */
46 int (*comp_init) (void *state, unsigned char *options,
47 int opt_len, int unit, int opthdr, int debug);
48
49 /* Reset a compressor */
50 void (*comp_reset) (void *state);
51
52 /* Compress a packet */
53 int (*compress) (void *state, unsigned char *rptr,
54 unsigned char *obuf, int isize, int osize);
55
56 /* Return compression statistics */
57 void (*comp_stat) (void *state, struct compstat *stats);
58
59 /* Allocate space for a decompressor (receive side) */
60 void *(*decomp_alloc) (unsigned char *options, int opt_len);
61
62 /* Free space used by a decompressor */
63 void (*decomp_free) (void *state);
64
65 /* Initialize a decompressor */
66 int (*decomp_init) (void *state, unsigned char *options,
67 int opt_len, int unit, int opthdr, int mru,
68 int debug);
69
70 /* Reset a decompressor */
71 void (*decomp_reset) (void *state);
72
73 /* Decompress a packet. */
74 int (*decompress) (void *state, unsigned char *ibuf, int isize,
75 unsigned char *obuf, int osize);
76
77 /* Update state for an incompressible packet received */
78 void (*incomp) (void *state, unsigned char *ibuf, int icnt);
79
80 /* Return decompression statistics */
81 void (*decomp_stat) (void *state, struct compstat *stats);
82
83 /* Used in locking compressor modules */
84 struct module *owner;
Matt Domschb3f9b922005-11-08 09:40:47 -080085 /* Extra skb space needed by the compressor algorithm */
86 unsigned int comp_extra;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
89/*
90 * The return value from decompress routine is the length of the
91 * decompressed packet if successful, otherwise DECOMP_ERROR
92 * or DECOMP_FATALERROR if an error occurred.
93 *
94 * We need to make this distinction so that we can disable certain
95 * useful functionality, namely sending a CCP reset-request as a result
96 * of an error detected after decompression. This is to avoid infringing
97 * a patent held by Motorola.
98 * Don't you just lurve software patents.
99 */
100
101#define DECOMP_ERROR -1 /* error detected before decomp. */
102#define DECOMP_FATALERROR -2 /* error detected after decomp. */
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern int ppp_register_compressor(struct compressor *);
105extern void ppp_unregister_compressor(struct compressor *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#endif /* _NET_PPP_COMP_H */