BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * ccp.h - Definitions for PPP Compression Control Protocol.
3 *
4 * Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. The name(s) of the authors of this software must not be used to
14 * endorse or promote products derived from this software without
15 * prior written permission.
16 *
17 * 3. Redistributions of any form whatsoever must retain the following
18 * acknowledgment:
19 * "This product includes software developed by Paul Mackerras
20 * <paulus@samba.org>".
21 *
22 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
23 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
28 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 *
30 * $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $
31 */
32  
33 #include "netif/ppp/ppp_opts.h"
34 #if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */
35  
36 #ifndef CCP_H
37 #define CCP_H
38  
39 /*
40 * CCP codes.
41 */
42  
43 #define CCP_CONFREQ 1
44 #define CCP_CONFACK 2
45 #define CCP_TERMREQ 5
46 #define CCP_TERMACK 6
47 #define CCP_RESETREQ 14
48 #define CCP_RESETACK 15
49  
50 /*
51 * Max # bytes for a CCP option
52 */
53  
54 #define CCP_MAX_OPTION_LENGTH 32
55  
56 /*
57 * Parts of a CCP packet.
58 */
59  
60 #define CCP_CODE(dp) ((dp)[0])
61 #define CCP_ID(dp) ((dp)[1])
62 #define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
63 #define CCP_HDRLEN 4
64  
65 #define CCP_OPT_CODE(dp) ((dp)[0])
66 #define CCP_OPT_LENGTH(dp) ((dp)[1])
67 #define CCP_OPT_MINLEN 2
68  
69 #if BSDCOMPRESS_SUPPORT
70 /*
71 * Definitions for BSD-Compress.
72 */
73  
74 #define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
75 #define CILEN_BSD_COMPRESS 3 /* length of config. option */
76  
77 /* Macros for handling the 3rd byte of the BSD-Compress config option. */
78 #define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
79 #define BSD_VERSION(x) ((x) >> 5) /* version of option format */
80 #define BSD_CURRENT_VERSION 1 /* current version number */
81 #define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
82  
83 #define BSD_MIN_BITS 9 /* smallest code size supported */
84 #define BSD_MAX_BITS 15 /* largest code size supported */
85 #endif /* BSDCOMPRESS_SUPPORT */
86  
87 #if DEFLATE_SUPPORT
88 /*
89 * Definitions for Deflate.
90 */
91  
92 #define CI_DEFLATE 26 /* config option for Deflate */
93 #define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
94 #define CILEN_DEFLATE 4 /* length of its config option */
95  
96 #define DEFLATE_MIN_SIZE 9
97 #define DEFLATE_MAX_SIZE 15
98 #define DEFLATE_METHOD_VAL 8
99 #define DEFLATE_SIZE(x) (((x) >> 4) + 8)
100 #define DEFLATE_METHOD(x) ((x) & 0x0F)
101 #define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
102 #define DEFLATE_CHK_SEQUENCE 0
103 #endif /* DEFLATE_SUPPORT */
104  
105 #if MPPE_SUPPORT
106 /*
107 * Definitions for MPPE.
108 */
109  
110 #define CI_MPPE 18 /* config option for MPPE */
111 #define CILEN_MPPE 6 /* length of config option */
112 #endif /* MPPE_SUPPORT */
113  
114 #if PREDICTOR_SUPPORT
115 /*
116 * Definitions for other, as yet unsupported, compression methods.
117 */
118  
119 #define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
120 #define CILEN_PREDICTOR_1 2 /* length of its config option */
121 #define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
122 #define CILEN_PREDICTOR_2 2 /* length of its config option */
123 #endif /* PREDICTOR_SUPPORT */
124  
125 typedef struct ccp_options {
126 #if DEFLATE_SUPPORT
127 unsigned int deflate :1; /* do Deflate? */
128 unsigned int deflate_correct :1; /* use correct code for deflate? */
129 unsigned int deflate_draft :1; /* use draft RFC code for deflate? */
130 #endif /* DEFLATE_SUPPORT */
131 #if BSDCOMPRESS_SUPPORT
132 unsigned int bsd_compress :1; /* do BSD Compress? */
133 #endif /* BSDCOMPRESS_SUPPORT */
134 #if PREDICTOR_SUPPORT
135 unsigned int predictor_1 :1; /* do Predictor-1? */
136 unsigned int predictor_2 :1; /* do Predictor-2? */
137 #endif /* PREDICTOR_SUPPORT */
138  
139 #if MPPE_SUPPORT
140 u8_t mppe; /* MPPE bitfield */
141 #endif /* MPPE_SUPPORT */
142 #if BSDCOMPRESS_SUPPORT
143 u_short bsd_bits; /* # bits/code for BSD Compress */
144 #endif /* BSDCOMPRESS_SUPPORT */
145 #if DEFLATE_SUPPORT
146 u_short deflate_size; /* lg(window size) for Deflate */
147 #endif /* DEFLATE_SUPPORT */
148 u8_t method; /* code for chosen compression method */
149 } ccp_options;
150  
151 extern const struct protent ccp_protent;
152  
153 void ccp_resetrequest(ppp_pcb *pcb); /* Issue a reset-request. */
154  
155 #endif /* CCP_H */
156 #endif /* PPP_SUPPORT && CCP_SUPPORT */