Update and clean Tomato RAF files
[tomato.git] / release / src / router / pptpd / pptpdefs.h
blob00bcec90ee130131da119166e9d4bfc10cc80d35
1 /*
2 * pptpdefs.h
4 * PPTP structs and defines
6 * $Id: pptpdefs.h,v 1.4 2006/12/08 00:01:40 quozl Exp $
7 */
9 #ifndef _PPTPD_PPTPDEFS_H
10 #define _PPTPD_PPTPDEFS_H
12 /* define "portable" htons, etc, copied to make Ananian's gre stuff work. */
13 #define hton8(x) (x)
14 #define ntoh8(x) (x)
15 #define hton16(x) htons(x)
16 #define ntoh16(x) ntohs(x)
17 #define hton32(x) htonl(x)
18 #define ntoh32(x) ntohl(x)
20 #include <sys/types.h>
22 /* PPTP ctrl message port */
23 #define PPTP_PORT 1723
25 /* PPTP gre prototype */
26 #define PPTP_PROTO 47
28 /* PPTP version */
29 #define PPTP_VERSION 0x0100
30 #define PPTP_FIRMWARE_VERSION 0x0001
32 /* Hostname and Vendor */
33 #define PPTP_HOSTNAME "local"
34 #define PPTP_VENDOR "linux"
36 #define MAX_HOSTNAME_SIZE 64
37 #define MAX_VENDOR_SIZE 64
39 /* Magic Cookie */
40 #define PPTP_MAGIC_COOKIE 0x1a2b3c4d
42 /* Message types */
43 #define PPTP_CTRL_MESSAGE 1
45 /* Maximum size of any PPTP control packet we will get */
46 #define PPTP_MAX_CTRL_PCKT_SIZE 220
48 /* Control Connection Management */
49 #define START_CTRL_CONN_RQST 1
50 #define START_CTRL_CONN_RPLY 2
51 #define STOP_CTRL_CONN_RQST 3
52 #define STOP_CTRL_CONN_RPLY 4
53 #define ECHO_RQST 5
54 #define ECHO_RPLY 6
56 /* Call Management */
57 #define OUT_CALL_RQST 7
58 #define OUT_CALL_RPLY 8
59 #define IN_CALL_RQST 9
60 #define IN_CALL_RPLY 10
61 #define IN_CALL_CONN 11
62 #define CALL_CLR_RQST 12
63 #define CALL_DISCONN_NTFY 13
65 /* Error Reporting */
66 #define WAN_ERR_NTFY 14
68 /* PPP Session Control */
69 #define SET_LINK_INFO 15
71 /* how long before a link is idle? (seconds) */
72 #define IDLE_WAIT 60
74 /* how long should we wait for an echo reply? (seconds) */
75 #define MAX_ECHO_WAIT 60
77 #define RESERVED 0x0000
79 /* Start Control Connection Reply */
80 #define ASYNCHRONOUS_FRAMING 0x00000001
81 #define SYNCHRONOUS_FRAMING 0x00000002
82 #define ANALOG_ACCESS 0x00000001
83 #define DIGITAL_ACCESS 0x00000002
85 /* Our properties - we don't actually have any physical serial i/f's and only want
86 * one call per client!
88 #define OUR_FRAMING 0x00000000
89 #define OUR_BEARER 0x00000000
90 #define MAX_CHANNELS 0x0001
92 /* Out Call Reply Defines */
93 #define PCKT_RECV_WINDOW_SIZE 0x0001
94 #define PCKT_PROCESS_DELAY 0x0000
95 #define CHANNEL_ID 0x00000000
97 /* ERROR CODES */
98 #define NO_ERROR 0x00
100 /* CALL_CLEAR RESULT CODES */
101 #define LOST_CARRIER 0x01
102 #define ADMIN_SHUTDOWN 0x03
103 #define CALL_CLEAR_REQUEST 0x04
105 /* RESULT CODES */
106 #define CONNECTED 0x01
107 #define DISCONNECTED 0x01
108 #define GENERAL_ERROR 0x02 /* also for ERROR CODES, CALL CLEAR */
109 #define NO_CARRIER 0x03
110 #define BUSY 0x04
111 #define NO_DIAL_TONE 0x05
112 #define TIME_OUT 0x06
113 #define DO_NOT_ACCEPT 0x07
115 /* CTRL CLOSE CODES */
116 #define GENERAL_STOP_CTRL 0x01
117 #define STOP_PROTOCOL 0x02
118 #define STOP_LOCAL_SHUTDOWN 0x03
120 /* PPTP CTRL structs */
122 struct pptp_header {
123 u_int16_t length; /* pptp message length incl header */
124 u_int16_t pptp_type; /* pptp message type */
125 u_int32_t magic; /* magic cookie */
126 u_int16_t ctrl_type; /* control message type */
127 u_int16_t reserved0; /* reserved */
130 struct pptp_start_ctrl_conn_rqst {
131 struct pptp_header header; /* pptp header */
132 u_int16_t version; /* pptp protocol version */
133 u_int16_t reserved1; /* reserved */
134 u_int32_t framing_cap; /* framing capabilities */
135 u_int32_t bearer_cap; /* bearer capabilities */
136 u_int16_t max_channels; /* maximum channels */
137 u_int16_t firmware_rev; /* firmware revision */
138 u_int8_t hostname[MAX_HOSTNAME_SIZE]; /* hostname */
139 u_int8_t vendor[MAX_VENDOR_SIZE]; /* vendor */
142 struct pptp_start_ctrl_conn_rply {
143 struct pptp_header header; /* pptp header */
144 u_int16_t version; /* pptp protocol version */
145 u_int8_t result_code; /* result code */
146 u_int8_t error_code; /* error code */
147 u_int32_t framing_cap; /* framing capabilities */
148 u_int32_t bearer_cap; /* bearer capabilities */
149 u_int16_t max_channels; /* maximum channels */
150 u_int16_t firmware_rev; /* firmware revision */
151 u_int8_t hostname[MAX_HOSTNAME_SIZE]; /* hostname */
152 u_int8_t vendor[MAX_VENDOR_SIZE]; /* vendor */
155 struct pptp_stop_ctrl_conn_rqst {
156 struct pptp_header header; /* header */
157 u_int8_t reason; /* reason for closing */
158 u_int8_t reserved1; /* reserved */
159 u_int16_t reserved2; /* reserved */
162 struct pptp_stop_ctrl_conn_rply {
163 struct pptp_header header; /* header */
164 u_int8_t result_code; /* result code */
165 u_int8_t error_code; /* error code */
166 u_int16_t reserved1; /* reserved */
169 struct pptp_echo_rqst {
170 struct pptp_header header; /* header */
171 u_int32_t identifier; /* value to match rply with rqst */
174 struct pptp_echo_rply {
175 struct pptp_header header; /* header */
176 u_int32_t identifier; /* identifier of echo rqst */
177 u_int8_t result_code; /* result code */
178 u_int8_t error_code; /* error code */
179 u_int16_t reserved1; /* reserved */
182 struct pptp_out_call_rqst {
183 struct pptp_header header; /* header */
184 u_int16_t call_id; /* unique identifier to PAC-PNS pair */
185 u_int16_t call_serial; /* session identifier */
186 u_int32_t min_bps; /* minimum line speed */
187 u_int32_t max_bps; /* maximum line speed */
188 u_int32_t bearer_type; /* bearer type */
189 u_int32_t framing_type; /* framing type */
190 u_int16_t pckt_recv_size; /* packet recv window size */
191 u_int16_t pckt_delay; /* packet processing delay */
192 u_int16_t phone_len; /* phone number length */
193 u_int16_t reserved1; /* reserved */
194 u_int8_t phone_num[64]; /* phone number */
195 u_int8_t subaddress[64]; /* additional dialing info */
198 struct pptp_out_call_rply {
199 struct pptp_header header; /* header */
200 u_int16_t call_id; /* unique identifier to PAC-PNS pair */
201 u_int16_t call_id_peer; /* set to call_id of the call rqst */
202 u_int8_t result_code; /* result code */
203 u_int8_t error_code; /* error code */
204 u_int16_t cause_code; /* additional failure information */
205 u_int32_t speed; /* actual connection speed */
206 u_int16_t pckt_recv_size; /* packet recv window size */
207 u_int16_t pckt_delay; /* packet processing delay */
208 u_int32_t channel_id; /* physical channel ID */
211 struct pptp_in_call_rqst {
212 struct pptp_header header; /* header */
213 u_int16_t call_id; /* unique identifier for tunnel */
214 u_int16_t call_serial; /* session identifier */
215 u_int32_t bearer_type; /* bearer capability */
216 u_int32_t channel_id; /* channel ID */
217 u_int16_t dialed_len; /* dialed length */
218 u_int16_t dialing_len; /* dialing length */
219 u_int8_t dialed_num[64]; /* number that was dialed by the caller */
220 u_int8_t dialing_num[64]; /* the number from which the call was placed */
221 u_int8_t subaddress[64]; /* additional dialing information */
224 struct pptp_in_call_rply {
225 struct pptp_header header; /* header */
226 u_int16_t call_id; /* unique identifier for the tunnel */
227 u_int16_t peers_call_id; /* set to rcvd call ID */
228 u_int8_t result_code; /* result code */
229 u_int8_t error_code; /* error code */
230 u_int16_t pckt_recv_size; /* packet recv window size */
231 u_int16_t pckt_delay; /* packet transmit delay */
232 u_int16_t reserved1; /* reserved */
235 struct pptp_in_call_connect {
236 struct pptp_header header; /* header */
237 u_int16_t peers_call_id; /* set to rcvd call ID */
238 u_int16_t reserved1; /* reserved */
239 u_int32_t speed; /* connect speed */
240 u_int16_t pckt_recv_size; /* packet rcvd window size */
241 u_int16_t pckt_delay; /* packet transmit delay */
242 u_int32_t framing_type; /* framing type */
245 struct pptp_call_clr_rqst {
246 struct pptp_header header; /* header */
247 u_int16_t call_id; /* call ID assigned by the PNS */
248 u_int16_t reserved1; /* reserved */
251 struct pptp_call_disconn_ntfy {
252 struct pptp_header header; /* header */
253 u_int16_t call_id; /* call ID assigned by the PAC */
254 u_int8_t result_code; /* result code */
255 u_int8_t error_code; /* error code */
256 u_int16_t cause_code; /* additional disconnect info */
257 u_int16_t reserved1; /* reserved */
258 u_int8_t call_stats[128]; /* vendor specific call stats */
261 struct pptp_wan_err_ntfy {
262 struct pptp_header header; /* header */
263 u_int16_t peers_call_id; /* call ID assigned by PNS */
264 u_int16_t reserved1; /* reserved */
265 u_int32_t crc_errors; /* # of PPP frames rcvd with CRC errors */
266 u_int32_t framing_errors; /* # of improperly framed PPP pckts */
267 u_int32_t hardware_overruns; /* # of receive buffer overruns */
268 u_int32_t buff_overruns; /* # of buffer overruns */
269 u_int32_t timeout_errors; /* # of timeouts */
270 u_int32_t align_errors; /* # of alignment errors */
273 struct pptp_set_link_info {
274 struct pptp_header header;
275 u_int16_t peers_call_id; /* call ID assigned by PAC */
276 u_int16_t reserved1; /* reserved */
277 u_int32_t send_accm; /* send ACCM value the client should use */
278 u_int32_t recv_accm; /* recv ACCM value the client should use */
281 /* GRE and PPP structs */
283 /* Copied from C. S. Ananian */
285 #define HDLC_FLAG 0x7E
286 #define HDLC_ESCAPE 0x7D
288 #define PPTP_GRE_PROTO 0x880B
289 #define PPTP_GRE_VER 0x1
291 #define PPTP_GRE_FLAG_C 0x80
292 #define PPTP_GRE_FLAG_R 0x40
293 #define PPTP_GRE_FLAG_K 0x20
294 #define PPTP_GRE_FLAG_S 0x10
295 #define PPTP_GRE_FLAG_A 0x80
297 #define PPTP_GRE_IS_C(f) ((f)&PPTP_GRE_FLAG_C)
298 #define PPTP_GRE_IS_R(f) ((f)&PPTP_GRE_FLAG_R)
299 #define PPTP_GRE_IS_K(f) ((f)&PPTP_GRE_FLAG_K)
300 #define PPTP_GRE_IS_S(f) ((f)&PPTP_GRE_FLAG_S)
301 #define PPTP_GRE_IS_A(f) ((f)&PPTP_GRE_FLAG_A)
303 struct pptp_gre_header {
304 u_int8_t flags; /* bitfield */
305 u_int8_t ver; /* should be PPTP_GRE_VER (enhanced GRE) */
306 u_int16_t protocol; /* should be PPTP_GRE_PROTO (ppp-encaps) */
307 u_int16_t payload_len; /* size of ppp payload, not inc. gre header */
308 u_int16_t call_id; /* peer's call_id for this session */
309 u_int32_t seq; /* sequence number. Present if S==1 */
310 u_int32_t ack; /* seq number of highest packet recieved by */
311 /* sender in this session */
314 /* For our call ID pairs */
315 #define PNS_VALUE 0
316 #define PAC_VALUE 1
318 #define GET_VALUE(which, where) ((which ## _VALUE) ? ((where) & 0xffff) : ((where) >> 16))
320 #define NOTE_VALUE(which, where, what) ((which ## _VALUE) \
321 ? ((where) = ((where) & 0xffff0000) | (what)) \
322 : ((where) = ((where) & 0xffff) | ((what) << 16)))
324 #endif /* !_PPTPD_PPTPDEFS_H */