xref: /linux/include/uapi/linux/ppp-comp.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * ppp-comp.h - Definitions for doing PPP packet compression.
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright 1994-1998 Paul Mackerras.
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  *  This program is free software; you can redistribute it and/or
8607ca46eSDavid Howells  *  modify it under the terms of the GNU General Public License
9607ca46eSDavid Howells  *  version 2 as published by the Free Software Foundation.
10607ca46eSDavid Howells  */
11607ca46eSDavid Howells #ifndef _UAPI_NET_PPP_COMP_H
12607ca46eSDavid Howells #define _UAPI_NET_PPP_COMP_H
13607ca46eSDavid Howells 
14607ca46eSDavid Howells 
15607ca46eSDavid Howells /*
16607ca46eSDavid Howells  * CCP codes.
17607ca46eSDavid Howells  */
18607ca46eSDavid Howells 
19607ca46eSDavid Howells #define CCP_CONFREQ	1
20607ca46eSDavid Howells #define CCP_CONFACK	2
21607ca46eSDavid Howells #define CCP_TERMREQ	5
22607ca46eSDavid Howells #define CCP_TERMACK	6
23607ca46eSDavid Howells #define CCP_RESETREQ	14
24607ca46eSDavid Howells #define CCP_RESETACK	15
25607ca46eSDavid Howells 
26607ca46eSDavid Howells /*
27607ca46eSDavid Howells  * Max # bytes for a CCP option
28607ca46eSDavid Howells  */
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #define CCP_MAX_OPTION_LENGTH	32
31607ca46eSDavid Howells 
32607ca46eSDavid Howells /*
33607ca46eSDavid Howells  * Parts of a CCP packet.
34607ca46eSDavid Howells  */
35607ca46eSDavid Howells 
36607ca46eSDavid Howells #define CCP_CODE(dp)		((dp)[0])
37607ca46eSDavid Howells #define CCP_ID(dp)		((dp)[1])
38607ca46eSDavid Howells #define CCP_LENGTH(dp)		(((dp)[2] << 8) + (dp)[3])
39607ca46eSDavid Howells #define CCP_HDRLEN		4
40607ca46eSDavid Howells 
41607ca46eSDavid Howells #define CCP_OPT_CODE(dp)	((dp)[0])
42607ca46eSDavid Howells #define CCP_OPT_LENGTH(dp)	((dp)[1])
43607ca46eSDavid Howells #define CCP_OPT_MINLEN		2
44607ca46eSDavid Howells 
45607ca46eSDavid Howells /*
46607ca46eSDavid Howells  * Definitions for BSD-Compress.
47607ca46eSDavid Howells  */
48607ca46eSDavid Howells 
49607ca46eSDavid Howells #define CI_BSD_COMPRESS		21	/* config. option for BSD-Compress */
50607ca46eSDavid Howells #define CILEN_BSD_COMPRESS	3	/* length of config. option */
51607ca46eSDavid Howells 
52607ca46eSDavid Howells /* Macros for handling the 3rd byte of the BSD-Compress config option. */
53607ca46eSDavid Howells #define BSD_NBITS(x)		((x) & 0x1F)	/* number of bits requested */
54607ca46eSDavid Howells #define BSD_VERSION(x)		((x) >> 5)	/* version of option format */
55607ca46eSDavid Howells #define BSD_CURRENT_VERSION	1		/* current version number */
56607ca46eSDavid Howells #define BSD_MAKE_OPT(v, n)	(((v) << 5) | (n))
57607ca46eSDavid Howells 
58607ca46eSDavid Howells #define BSD_MIN_BITS		9	/* smallest code size supported */
59607ca46eSDavid Howells #define BSD_MAX_BITS		15	/* largest code size supported */
60607ca46eSDavid Howells 
61607ca46eSDavid Howells /*
62607ca46eSDavid Howells  * Definitions for Deflate.
63607ca46eSDavid Howells  */
64607ca46eSDavid Howells 
65607ca46eSDavid Howells #define CI_DEFLATE		26	/* config option for Deflate */
66607ca46eSDavid Howells #define CI_DEFLATE_DRAFT	24	/* value used in original draft RFC */
67607ca46eSDavid Howells #define CILEN_DEFLATE		4	/* length of its config option */
68607ca46eSDavid Howells 
69607ca46eSDavid Howells #define DEFLATE_MIN_SIZE	9
70607ca46eSDavid Howells #define DEFLATE_MAX_SIZE	15
71607ca46eSDavid Howells #define DEFLATE_METHOD_VAL	8
72607ca46eSDavid Howells #define DEFLATE_SIZE(x)		(((x) >> 4) + 8)
73607ca46eSDavid Howells #define DEFLATE_METHOD(x)	((x) & 0x0F)
74607ca46eSDavid Howells #define DEFLATE_MAKE_OPT(w)	((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
75607ca46eSDavid Howells #define DEFLATE_CHK_SEQUENCE	0
76607ca46eSDavid Howells 
77607ca46eSDavid Howells /*
78607ca46eSDavid Howells  * Definitions for MPPE.
79607ca46eSDavid Howells  */
80607ca46eSDavid Howells 
81607ca46eSDavid Howells #define CI_MPPE                18      /* config option for MPPE */
82607ca46eSDavid Howells #define CILEN_MPPE              6      /* length of config option */
83607ca46eSDavid Howells 
84607ca46eSDavid Howells /*
85607ca46eSDavid Howells  * Definitions for other, as yet unsupported, compression methods.
86607ca46eSDavid Howells  */
87607ca46eSDavid Howells 
88607ca46eSDavid Howells #define CI_PREDICTOR_1		1	/* config option for Predictor-1 */
89607ca46eSDavid Howells #define CILEN_PREDICTOR_1	2	/* length of its config option */
90607ca46eSDavid Howells #define CI_PREDICTOR_2		2	/* config option for Predictor-2 */
91607ca46eSDavid Howells #define CILEN_PREDICTOR_2	2	/* length of its config option */
92607ca46eSDavid Howells 
93607ca46eSDavid Howells 
94607ca46eSDavid Howells #endif /* _UAPI_NET_PPP_COMP_H */
95