1/*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 *  pptp.h
25 *  ppp
26 *
27 *  Created by Christophe Allie on Thu May 23 2002.
28 *  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
29 *
30 */
31
32#define PPTP_NKE	"PPTP.kext"
33#define PPTP_NKE_ID	"com.apple.nke.pptp"
34
35/* PPTP exit codes */
36#define EXIT_PPTP_NOSERVER  		1
37#define EXIT_PPTP_NOANSWER  		2
38#define EXIT_PPTP_PROTOCOLERROR 	5
39#define EXIT_PPTP_NETWORKCHANGED 	6
40#if TARGET_OS_EMBEDDED
41#define EXIT_PPTP_NOEDGE			7
42#endif
43
44/* define pptp messages */
45#define PPTP_CONTROL_MSG	1
46#define PPTP_MANAGEMENT_MSG	2
47
48/* define well known values */
49#define PPTP_MAGIC_COOKIE	0x1A2B3C4D	/* magic PPTP cookie */
50#define PPTP_VERSION		0x0100		/* PPTP vervion number */
51#define PPTP_TCP_PORT		1723		/* well know pptp port */
52#define PPTP_RECEIVE_WINDOW	0x40		/* let's have a window size of 64 */
53
54/* generic results codes */
55#define PPTP_RESULT_SUCCESS	1
56#define PPTP_RESULT_ERROR	2
57
58/*outgoing call result codes */
59#define PPTP_OUTGOING_CALL_RESULT_CONNECTED	1
60#define PPTP_OUTGOING_CALL_RESULT_ERROR		2
61#define PPTP_OUTGOING_CALL_RESULT_NOCARRIER	3
62#define PPTP_OUTGOING_CALL_RESULT_BUSY		4
63#define PPTP_OUTGOING_CALL_RESULT_NODIALTONE	5
64#define PPTP_OUTGOING_CALL_RESULT_TIMEOUT	6
65#define PPTP_OUTGOING_CALL_RESULT_DONOTACCEPT	7
66
67/* define pptp control messages */
68#define PPTP_START_CONTROL_CONNECTION_REQUEST	1
69#define PPTP_START_CONTROL_CONNECTION_REPLY	2
70#define PPTP_STOP_CONTROL_CONNECTION_REQUEST	3
71#define PPTP_STOP_CONTROL_CONNECTION_REPLY	4
72#define PPTP_ECHO_REQUEST			5
73#define PPTP_ECHO_REPLY				6
74#define PPTP_OUTGOING_CALL_REQUEST		7
75#define PPTP_OUTGOING_CALL_REPLY		8
76#define PPTP_INCOMING_CALL_REQUEST		9
77#define PPTP_INCOMING_CALL_REPLY		10
78#define PPTP_INCOMING_CALL_CONNECTED		11
79#define PPTP_CALL_CLEAR_REQUEST			12
80#define PPTP_CALL_DISCONNECT_NOTIFY		13
81#define PPTP_WAN_ERROR_NOTIFY			14
82#define PPTP_SET_LINK_INFO			15
83
84/* define framing capabilities */
85#define PPTP_ASYNC_FRAMING	1
86#define PPTP_SYNC_FRAMING	2
87
88/* define bearer capabilities */
89#define PPTP_ANALOG_ACCESS	1
90#define PPTP_DIGITAL_ACCESS	2
91
92
93#define PPTP_VENDOR 	"Mac OS X, Apple Computer, Inc"
94
95struct pptp_header {
96    /* header part */
97    u_int16_t	len;
98    u_int16_t	pptp_msgtype;
99    u_int32_t	magic_cookie;
100    u_int16_t	ctrl_msgtype;
101    u_int16_t	reserved0;
102};
103
104struct pptp_start_control_request {
105    /* message part */
106    u_int16_t	proto_vers;
107    u_int16_t	reserved1;
108    u_int32_t	framing_caps;
109    u_int32_t	bearer_caps;
110    u_int16_t	max_channels;
111    u_int16_t	firmware_rev;
112    u_int8_t	hostname[64];
113    u_int8_t	vendor[64];
114};
115
116struct pptp_start_control_reply {
117    /* message part */
118    u_int16_t	proto_vers;
119    u_int8_t	result_code;
120    u_int8_t	error_code;
121    u_int32_t	framing_caps;
122    u_int32_t	bearer_caps;
123    u_int16_t	max_channels;
124    u_int16_t	firmware_rev;
125    u_int8_t	hostname[64];
126    u_int8_t	vendor[64];
127};
128
129struct pptp_outgoing_call_request {
130    /* message part */
131    u_int16_t	call_id;
132    u_int16_t	serial_number;
133    u_int32_t	min_bps;
134    u_int32_t	max_bps;
135    u_int32_t	bearer_type;
136    u_int32_t	framing_type;
137    u_int16_t	recv_window;
138    u_int16_t	processing_delay;
139    u_int16_t	phone_len;
140    u_int16_t	reserved1;
141    u_int8_t	phone[64];
142    u_int8_t	subaddress[64];
143};
144
145struct pptp_outgoing_call_reply {
146    /* message part */
147    u_int16_t	call_id;
148    u_int16_t	peer_call_id;
149    u_int8_t	result_code;
150    u_int8_t	error_code;
151    u_int16_t	cause_code;
152    u_int32_t	connect_speed;
153    u_int16_t	recv_window;
154    u_int16_t	processing_delay;
155    u_int32_t	phys_channel_id;
156};
157
158struct pptp_call_clear_request {
159    /* message part */
160    u_int16_t	call_id;
161    u_int16_t	reserved1;
162};
163
164struct pptp_set_link_info {
165    /* message part */
166    u_int16_t	peer_call_id;
167    u_int16_t	reserved1;
168    u_int32_t	send_accm;
169    u_int32_t	recv_accm;
170};
171
172struct pptp_echo_request {
173    /* message part */
174    u_int32_t	identifier;
175};
176
177struct pptp_echo_reply {
178    /* message part */
179    u_int32_t	identifier;
180    u_int8_t	result_code;
181    u_int8_t	error_code;
182    u_int16_t	reserved1;
183};
184
185
186/* pptp functions */
187
188int pptp_outgoing_call(int fd,
189    u_int16_t ourcallid, u_int16_t ourwindow, u_int16_t ourppd,
190    u_int16_t *peercallid, u_int16_t *peerwindow, u_int16_t *peerppd);
191
192int pptp_incoming_call(int fd,
193    u_int16_t ourcallid, u_int16_t ourwindow, u_int16_t ourppd,
194    u_int16_t *peercallid, u_int16_t *peerwindow, u_int16_t *peerppd);
195
196int pptp_echo(int fd, u_int32_t identifier);
197
198int pptp_data_in(int fd);
199