This commit was manufactured by cvs2svn to create branch
[linux-2.6.git] / include / linux / netfilter_ipv4 / ip_conntrack_pptp.h
1 /* PPTP constants and structs */
2 #ifndef _CONNTRACK_PPTP_H
3 #define _CONNTRACK_PPTP_H
4
5 /* state of the control session */
6 enum 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 */
15 enum 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 */
28 struct 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         /* in pre-2.6.11 this used to be per-expect. Now it is per-conntrack
38          * and therefore imposes a fixed limit on the number of maps */
39         struct ip_ct_gre_keymap *keymap_orig, *keymap_reply;
40 };
41
42 /* conntrack_expect private member */
43 struct ip_ct_pptp_expect {
44         enum pptp_ctrlcall_state cstate;        /* call state */
45         u_int16_t pac_call_id;                  /* call id of PAC */
46         u_int16_t pns_call_id;                  /* call id of PNS */
47 };
48
49
50 #ifdef __KERNEL__
51
52
53 #include <linux/netfilter_ipv4/lockhelp.h>
54 DECLARE_LOCK_EXTERN(ip_pptp_lock);
55
56 #define IP_CONNTR_PPTP          PPTP_CONTROL_PORT
57
58 #define PPTP_CONTROL_PORT       1723
59
60 #define PPTP_PACKET_CONTROL     1
61 #define PPTP_PACKET_MGMT        2
62
63 #define PPTP_MAGIC_COOKIE       0x1a2b3c4d
64
65 struct pptp_pkt_hdr {
66         __u16   packetLength;
67         __u16   packetType;
68         __u32   magicCookie;
69 };
70
71 /* PptpControlMessageType values */
72 #define PPTP_START_SESSION_REQUEST      1
73 #define PPTP_START_SESSION_REPLY        2
74 #define PPTP_STOP_SESSION_REQUEST       3
75 #define PPTP_STOP_SESSION_REPLY         4
76 #define PPTP_ECHO_REQUEST               5
77 #define PPTP_ECHO_REPLY                 6
78 #define PPTP_OUT_CALL_REQUEST           7
79 #define PPTP_OUT_CALL_REPLY             8
80 #define PPTP_IN_CALL_REQUEST            9
81 #define PPTP_IN_CALL_REPLY              10
82 #define PPTP_IN_CALL_CONNECT            11
83 #define PPTP_CALL_CLEAR_REQUEST         12
84 #define PPTP_CALL_DISCONNECT_NOTIFY     13
85 #define PPTP_WAN_ERROR_NOTIFY           14
86 #define PPTP_SET_LINK_INFO              15
87
88 #define PPTP_MSG_MAX                    15
89
90 /* PptpGeneralError values */
91 #define PPTP_ERROR_CODE_NONE            0
92 #define PPTP_NOT_CONNECTED              1
93 #define PPTP_BAD_FORMAT                 2
94 #define PPTP_BAD_VALUE                  3
95 #define PPTP_NO_RESOURCE                4
96 #define PPTP_BAD_CALLID                 5
97 #define PPTP_REMOVE_DEVICE_ERROR        6
98
99 struct PptpControlHeader {
100         __u16   messageType;
101         __u16   reserved;
102 };
103
104 /* FramingCapability Bitmap Values */
105 #define PPTP_FRAME_CAP_ASYNC            0x1
106 #define PPTP_FRAME_CAP_SYNC             0x2
107
108 /* BearerCapability Bitmap Values */
109 #define PPTP_BEARER_CAP_ANALOG          0x1
110 #define PPTP_BEARER_CAP_DIGITAL         0x2
111
112 struct PptpStartSessionRequest {
113         __u16   protocolVersion;
114         __u8    reserved1;
115         __u8    reserved2;
116         __u32   framingCapability;
117         __u32   bearerCapability;
118         __u16   maxChannels;
119         __u16   firmwareRevision;
120         __u8    hostName[64];
121         __u8    vendorString[64];
122 };
123
124 /* PptpStartSessionResultCode Values */
125 #define PPTP_START_OK                   1
126 #define PPTP_START_GENERAL_ERROR        2
127 #define PPTP_START_ALREADY_CONNECTED    3
128 #define PPTP_START_NOT_AUTHORIZED       4
129 #define PPTP_START_UNKNOWN_PROTOCOL     5
130
131 struct PptpStartSessionReply {
132         __u16   protocolVersion;
133         __u8    resultCode;
134         __u8    generalErrorCode;
135         __u32   framingCapability;
136         __u32   bearerCapability;
137         __u16   maxChannels;
138         __u16   firmwareRevision;
139         __u8    hostName[64];
140         __u8    vendorString[64];
141 };
142
143 /* PptpStopReasons */
144 #define PPTP_STOP_NONE                  1
145 #define PPTP_STOP_PROTOCOL              2
146 #define PPTP_STOP_LOCAL_SHUTDOWN        3
147
148 struct PptpStopSessionRequest {
149         __u8    reason;
150 };
151
152 /* PptpStopSessionResultCode */
153 #define PPTP_STOP_OK                    1
154 #define PPTP_STOP_GENERAL_ERROR         2
155
156 struct PptpStopSessionReply {
157         __u8    resultCode;
158         __u8    generalErrorCode;
159 };
160
161 struct PptpEchoRequest {
162         __u32 identNumber;
163 };
164
165 /* PptpEchoReplyResultCode */
166 #define PPTP_ECHO_OK                    1
167 #define PPTP_ECHO_GENERAL_ERROR         2
168
169 struct PptpEchoReply {
170         __u32   identNumber;
171         __u8    resultCode;
172         __u8    generalErrorCode;
173         __u16   reserved;
174 };
175
176 /* PptpFramingType */
177 #define PPTP_ASYNC_FRAMING              1
178 #define PPTP_SYNC_FRAMING               2
179 #define PPTP_DONT_CARE_FRAMING          3
180
181 /* PptpCallBearerType */
182 #define PPTP_ANALOG_TYPE                1
183 #define PPTP_DIGITAL_TYPE               2
184 #define PPTP_DONT_CARE_BEARER_TYPE      3
185
186 struct PptpOutCallRequest {
187         __u16   callID;
188         __u16   callSerialNumber;
189         __u32   minBPS;
190         __u32   maxBPS;
191         __u32   bearerType;
192         __u32   framingType;
193         __u16   packetWindow;
194         __u16   packetProcDelay;
195         __u16   reserved1;
196         __u16   phoneNumberLength;
197         __u16   reserved2;
198         __u8    phoneNumber[64];
199         __u8    subAddress[64];
200 };
201
202 /* PptpCallResultCode */
203 #define PPTP_OUTCALL_CONNECT            1
204 #define PPTP_OUTCALL_GENERAL_ERROR      2
205 #define PPTP_OUTCALL_NO_CARRIER         3
206 #define PPTP_OUTCALL_BUSY               4
207 #define PPTP_OUTCALL_NO_DIAL_TONE       5
208 #define PPTP_OUTCALL_TIMEOUT            6
209 #define PPTP_OUTCALL_DONT_ACCEPT        7
210
211 struct PptpOutCallReply {
212         __u16   callID;
213         __u16   peersCallID;
214         __u8    resultCode;
215         __u8    generalErrorCode;
216         __u16   causeCode;
217         __u32   connectSpeed;
218         __u16   packetWindow;
219         __u16   packetProcDelay;
220         __u32   physChannelID;
221 };
222
223 struct PptpInCallRequest {
224         __u16   callID;
225         __u16   callSerialNumber;
226         __u32   callBearerType;
227         __u32   physChannelID;
228         __u16   dialedNumberLength;
229         __u16   dialingNumberLength;
230         __u8    dialedNumber[64];
231         __u8    dialingNumber[64];
232         __u8    subAddress[64];
233 };
234
235 /* PptpInCallResultCode */
236 #define PPTP_INCALL_ACCEPT              1
237 #define PPTP_INCALL_GENERAL_ERROR       2
238 #define PPTP_INCALL_DONT_ACCEPT         3
239
240 struct PptpInCallReply {
241         __u16   callID;
242         __u16   peersCallID;
243         __u8    resultCode;
244         __u8    generalErrorCode;
245         __u16   packetWindow;
246         __u16   packetProcDelay;
247         __u16   reserved;
248 };
249
250 struct PptpInCallConnected {
251         __u16   peersCallID;
252         __u16   reserved;
253         __u32   connectSpeed;
254         __u16   packetWindow;
255         __u16   packetProcDelay;
256         __u32   callFramingType;
257 };
258
259 struct PptpClearCallRequest {
260         __u16   callID;
261         __u16   reserved;
262 };
263
264 struct PptpCallDisconnectNotify {
265         __u16   callID;
266         __u8    resultCode;
267         __u8    generalErrorCode;
268         __u16   causeCode;
269         __u16   reserved;
270         __u8    callStatistics[128];
271 };
272
273 struct PptpWanErrorNotify {
274         __u16   peersCallID;
275         __u16   reserved;
276         __u32   crcErrors;
277         __u32   framingErrors;
278         __u32   hardwareOverRuns;
279         __u32   bufferOverRuns;
280         __u32   timeoutErrors;
281         __u32   alignmentErrors;
282 };
283
284 struct PptpSetLinkInfo {
285         __u16   peersCallID;
286         __u16   reserved;
287         __u32   sendAccm;
288         __u32   recvAccm;
289 };
290
291
292 struct pptp_priv_data {
293         __u16   call_id;
294         __u16   mcall_id;
295         __u16   pcall_id;
296 };
297
298 union pptp_ctrl_union {
299                 struct PptpStartSessionRequest  sreq;
300                 struct PptpStartSessionReply    srep;
301                 struct PptpStopSessionRequest   streq;
302                 struct PptpStopSessionReply     strep;
303                 struct PptpOutCallRequest       ocreq;
304                 struct PptpOutCallReply         ocack;
305                 struct PptpInCallRequest        icreq;
306                 struct PptpInCallReply          icack;
307                 struct PptpInCallConnected      iccon;
308                 struct PptpClearCallRequest     clrreq;
309                 struct PptpCallDisconnectNotify disc;
310                 struct PptpWanErrorNotify       wanerr;
311                 struct PptpSetLinkInfo          setlink;
312 };
313
314 struct ip_conntrack;
315
316 extern int
317 (*ip_nat_pptp_hook_outbound)(struct sk_buff **pskb,
318                           struct ip_conntrack *ct,
319                           enum ip_conntrack_info ctinfo,
320                           struct PptpControlHeader *ctlh,
321                           union pptp_ctrl_union *pptpReq);
322
323 extern int
324 (*ip_nat_pptp_hook_inbound)(struct sk_buff **pskb,
325                           struct ip_conntrack *ct,
326                           enum ip_conntrack_info ctinfo,
327                           struct PptpControlHeader *ctlh,
328                           union pptp_ctrl_union *pptpReq);
329
330 extern int
331 (*ip_nat_pptp_hook_exp_gre)(struct ip_conntrack_expect *exp_orig,
332                             struct ip_conntrack_expect *exp_reply);
333
334 extern void
335 (*ip_nat_pptp_hook_expectfn)(struct ip_conntrack *ct,
336                              struct ip_conntrack_expect *exp);
337 #endif /* __KERNEL__ */
338 #endif /* _CONNTRACK_PPTP_H */