1/* PPTP constants and structs */
2#ifndef _CONNTRACK_PPTP_H
3#define _CONNTRACK_PPTP_H
4
5/* state of the control session */
6enum pptp_ctrlsess_state {
7	PPTP_SESSION_NONE,			/* no session present */
8	PPTP_SESSION_ERROR,			/* some session error */
9	PPTP_SESSION_STOPREQ,			/* stop_sess request seen */
10	PPTP_SESSION_REQUESTED,			/* start_sess request seen */
11	PPTP_SESSION_CONFIRMED,			/* session established */
12};
13
14/* state of the call inside the control session */
15enum pptp_ctrlcall_state {
16	PPTP_CALL_NONE,
17	PPTP_CALL_ERROR,
18	PPTP_CALL_OUT_REQ,
19	PPTP_CALL_OUT_CONF,
20	PPTP_CALL_IN_REQ,
21	PPTP_CALL_IN_REP,
22	PPTP_CALL_IN_CONF,
23	PPTP_CALL_CLEAR_REQ,
24};
25
26
27/* conntrack private data */
28struct ip_ct_pptp_master {
29	enum pptp_ctrlsess_state sstate;	/* session state */
30
31	/* everything below is going to be per-expectation in newnat,
32	 * since there could be more than one call within one session */
33	enum pptp_ctrlcall_state cstate;	/* call state */
34	u_int16_t pac_call_id;			/* call id of PAC, host byte order */
35	u_int16_t pns_call_id;			/* call id of PNS, host byte order */
36};
37
38/* conntrack_expect private member */
39struct ip_ct_pptp_expect {
40	enum pptp_ctrlcall_state cstate; 	/* call state */
41	u_int16_t pac_call_id;			/* call id of PAC */
42	u_int16_t pns_call_id;			/* call id of PNS */
43};
44
45
46#ifdef __KERNEL__
47
48#include <linux/netfilter_ipv4/lockhelp.h>
49DECLARE_LOCK_EXTERN(ip_pptp_lock);
50
51#define IP_CONNTR_PPTP		PPTP_CONTROL_PORT
52
53union pptp_ctrl_union {
54                void				*rawreq;
55		struct PptpStartSessionRequest	*sreq;
56		struct PptpStartSessionReply	*srep;
57		struct PptpStopSessionReqest	*streq;
58		struct PptpStopSessionReply	*strep;
59                struct PptpOutCallRequest       *ocreq;
60                struct PptpOutCallReply         *ocack;
61                struct PptpInCallRequest        *icreq;
62                struct PptpInCallReply          *icack;
63                struct PptpInCallConnected      *iccon;
64		struct PptpClearCallRequest	*clrreq;
65                struct PptpCallDisconnectNotify *disc;
66                struct PptpWanErrorNotify       *wanerr;
67                struct PptpSetLinkInfo          *setlink;
68};
69
70
71
72#define PPTP_CONTROL_PORT	1723
73
74#define PPTP_PACKET_CONTROL	1
75#define PPTP_PACKET_MGMT	2
76
77#define PPTP_MAGIC_COOKIE	0x1a2b3c4d
78
79struct pptp_pkt_hdr {
80	__u16	packetLength;
81	__u16	packetType;
82	__u32	magicCookie;
83};
84
85/* PptpControlMessageType values */
86#define PPTP_START_SESSION_REQUEST	1
87#define PPTP_START_SESSION_REPLY	2
88#define PPTP_STOP_SESSION_REQUEST	3
89#define PPTP_STOP_SESSION_REPLY		4
90#define PPTP_ECHO_REQUEST		5
91#define PPTP_ECHO_REPLY			6
92#define PPTP_OUT_CALL_REQUEST		7
93#define PPTP_OUT_CALL_REPLY		8
94#define PPTP_IN_CALL_REQUEST		9
95#define PPTP_IN_CALL_REPLY		10
96#define PPTP_IN_CALL_CONNECT		11
97#define PPTP_CALL_CLEAR_REQUEST		12
98#define PPTP_CALL_DISCONNECT_NOTIFY	13
99#define PPTP_WAN_ERROR_NOTIFY		14
100#define PPTP_SET_LINK_INFO		15
101
102#define PPTP_MSG_MAX			15
103
104/* PptpGeneralError values */
105#define PPTP_ERROR_CODE_NONE		0
106#define PPTP_NOT_CONNECTED		1
107#define PPTP_BAD_FORMAT			2
108#define PPTP_BAD_VALUE			3
109#define PPTP_NO_RESOURCE		4
110#define PPTP_BAD_CALLID			5
111#define PPTP_REMOVE_DEVICE_ERROR	6
112
113struct PptpControlHeader {
114	__u16	messageType;
115	__u16	reserved;
116};
117
118/* FramingCapability Bitmap Values */
119#define PPTP_FRAME_CAP_ASYNC		0x1
120#define PPTP_FRAME_CAP_SYNC		0x2
121
122/* BearerCapability Bitmap Values */
123#define PPTP_BEARER_CAP_ANALOG		0x1
124#define PPTP_BEARER_CAP_DIGITAL		0x2
125
126struct PptpStartSessionRequest {
127	__u16	protocolVersion;
128	__u8	reserved1;
129	__u8	reserved2;
130	__u32	framingCapability;
131	__u32	bearerCapability;
132	__u16	maxChannels;
133	__u16	firmwareRevision;
134	__u8	hostName[64];
135	__u8	vendorString[64];
136};
137
138/* PptpStartSessionResultCode Values */
139#define PPTP_START_OK			1
140#define PPTP_START_GENERAL_ERROR	2
141#define PPTP_START_ALREADY_CONNECTED	3
142#define PPTP_START_NOT_AUTHORIZED	4
143#define PPTP_START_UNKNOWN_PROTOCOL	5
144
145struct PptpStartSessionReply {
146	__u16	protocolVersion;
147	__u8	resultCode;
148	__u8	generalErrorCode;
149	__u32	framingCapability;
150	__u32	bearerCapability;
151	__u16	maxChannels;
152	__u16	firmwareRevision;
153	__u8	hostName[64];
154	__u8	vendorString[64];
155};
156
157/* PptpStopReasons */
158#define PPTP_STOP_NONE			1
159#define PPTP_STOP_PROTOCOL		2
160#define PPTP_STOP_LOCAL_SHUTDOWN	3
161
162struct PptpStopSessionRequest {
163	__u8	reason;
164};
165
166/* PptpStopSessionResultCode */
167#define PPTP_STOP_OK			1
168#define PPTP_STOP_GENERAL_ERROR		2
169
170struct PptpStopSessionReply {
171	__u8	resultCode;
172	__u8	generalErrorCode;
173};
174
175struct PptpEchoRequest {
176	__u32 identNumber;
177};
178
179/* PptpEchoReplyResultCode */
180#define PPTP_ECHO_OK			1
181#define PPTP_ECHO_GENERAL_ERROR		2
182
183struct PptpEchoReply {
184	__u32	identNumber;
185	__u8	resultCode;
186	__u8	generalErrorCode;
187	__u16	reserved;
188};
189
190/* PptpFramingType */
191#define PPTP_ASYNC_FRAMING		1
192#define PPTP_SYNC_FRAMING		2
193#define PPTP_DONT_CARE_FRAMING		3
194
195/* PptpCallBearerType */
196#define PPTP_ANALOG_TYPE		1
197#define PPTP_DIGITAL_TYPE		2
198#define PPTP_DONT_CARE_BEARER_TYPE	3
199
200struct PptpOutCallRequest {
201	__u16	callID;
202	__u16	callSerialNumber;
203	__u32	minBPS;
204	__u32	maxBPS;
205	__u32	bearerType;
206	__u32	framingType;
207	__u16	packetWindow;
208	__u16	packetProcDelay;
209	__u16	reserved1;
210	__u16	phoneNumberLength;
211	__u16	reserved2;
212	__u8	phoneNumber[64];
213	__u8	subAddress[64];
214};
215
216/* PptpCallResultCode */
217#define PPTP_OUTCALL_CONNECT		1
218#define PPTP_OUTCALL_GENERAL_ERROR	2
219#define PPTP_OUTCALL_NO_CARRIER		3
220#define PPTP_OUTCALL_BUSY		4
221#define PPTP_OUTCALL_NO_DIAL_TONE	5
222#define PPTP_OUTCALL_TIMEOUT		6
223#define PPTP_OUTCALL_DONT_ACCEPT	7
224
225struct PptpOutCallReply {
226	__u16	callID;
227	__u16	peersCallID;
228	__u8	resultCode;
229	__u8	generalErrorCode;
230	__u16	causeCode;
231	__u32	connectSpeed;
232	__u16	packetWindow;
233	__u16	packetProcDelay;
234	__u32	physChannelID;
235};
236
237struct PptpInCallRequest {
238	__u16	callID;
239	__u16	callSerialNumber;
240	__u32	callBearerType;
241	__u32	physChannelID;
242	__u16	dialedNumberLength;
243	__u16	dialingNumberLength;
244	__u8	dialedNumber[64];
245	__u8	dialingNumber[64];
246	__u8	subAddress[64];
247};
248
249/* PptpInCallResultCode */
250#define PPTP_INCALL_ACCEPT		1
251#define PPTP_INCALL_GENERAL_ERROR	2
252#define PPTP_INCALL_DONT_ACCEPT		3
253
254struct PptpInCallReply {
255	__u16	callID;
256	__u16	peersCallID;
257	__u8	resultCode;
258	__u8	generalErrorCode;
259	__u16	packetWindow;
260	__u16	packetProcDelay;
261	__u16	reserved;
262};
263
264struct PptpInCallConnected {
265	__u16	peersCallID;
266	__u16	reserved;
267	__u32	connectSpeed;
268	__u16	packetWindow;
269	__u16	packetProcDelay;
270	__u32	callFramingType;
271};
272
273struct PptpClearCallRequest {
274	__u16	callID;
275	__u16	reserved;
276};
277
278struct PptpCallDisconnectNotify {
279	__u16	callID;
280	__u8	resultCode;
281	__u8	generalErrorCode;
282	__u16	causeCode;
283	__u16	reserved;
284	__u8	callStatistics[128];
285};
286
287struct PptpWanErrorNotify {
288	__u16	peersCallID;
289	__u16	reserved;
290	__u32	crcErrors;
291	__u32	framingErrors;
292	__u32	hardwareOverRuns;
293	__u32	bufferOverRuns;
294	__u32	timeoutErrors;
295	__u32	alignmentErrors;
296};
297
298struct PptpSetLinkInfo {
299	__u16	peersCallID;
300	__u16	reserved;
301	__u32	sendAccm;
302	__u32	recvAccm;
303};
304
305
306struct pptp_priv_data {
307	__u16	call_id;
308	__u16	mcall_id;
309	__u16	pcall_id;
310};
311
312#endif /* __KERNEL__ */
313#endif /* _CONNTRACK_PPTP_H */
314