2 * ip_conntrack_pptp.c - Version 3.0
4 * Connection tracking support for PPTP (Point to Point Tunneling Protocol).
5 * PPTP is a a protocol for creating virtual private networks.
6 * It is a specification defined by Microsoft and some vendors
7 * working with Microsoft. PPTP is built on top of a modified
8 * version of the Internet Generic Routing Encapsulation Protocol.
9 * GRE is defined in RFC 1701 and RFC 1702. Documentation of
10 * PPTP can be found in RFC 2637
12 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
14 * Development of this code funded by Astaro AG (http://www.astaro.com/)
17 * - We blindly assume that control connections are always
18 * established in PNS->PAC direction. This is a violation
20 * - We can only support one single call within each session
23 * - testing of incoming PPTP calls
26 * 2002-02-05 - Version 1.3
27 * - Call ip_conntrack_unexpect_related() from
28 * pptp_destroy_siblings() to destroy expectations in case
29 * CALL_DISCONNECT_NOTIFY or tcp fin packet was seen
30 * (Philip Craig <philipc@snapgear.com>)
31 * - Add Version information at module loadtime
32 * 2002-02-10 - Version 1.6
33 * - move to C99 style initializers
34 * - remove second expectation if first arrives
35 * 2004-10-22 - Version 2.0
36 * - merge Mandrake's 2.6.x port with recent 2.6.x API changes
37 * - fix lots of linear skb assumptions from Mandrake's port
38 * 2005-06-10 - Version 2.1
39 * - use ip_conntrack_expect_free() instead of kfree() on the
40 * expect's (which are from the slab for quite some time)
41 * 2005-06-10 - Version 3.0
42 * - port helper to post-2.6.11 API changes,
43 * funded by Oxcoda NetBox Blue (http://www.netboxblue.com/)
44 * 2005-07-30 - Version 3.1
45 * - port helper to 2.6.13 API changes
49 #include <linux/module.h>
50 #include <linux/netfilter.h>
52 #include <net/checksum.h>
55 #include <linux/netfilter_ipv4/ip_conntrack.h>
56 #include <linux/netfilter_ipv4/ip_conntrack_core.h>
57 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
58 #include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
59 #include <linux/netfilter_ipv4/ip_conntrack_pptp.h>
61 #define IP_CT_PPTP_VERSION "3.1"
63 MODULE_LICENSE("GPL");
64 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
65 MODULE_DESCRIPTION("Netfilter connection tracking helper module for PPTP");
67 static DEFINE_SPINLOCK(ip_pptp_lock
);
70 (*ip_nat_pptp_hook_outbound
)(struct sk_buff
**pskb
,
71 struct ip_conntrack
*ct
,
72 enum ip_conntrack_info ctinfo
,
73 struct PptpControlHeader
*ctlh
,
74 union pptp_ctrl_union
*pptpReq
);
77 (*ip_nat_pptp_hook_inbound
)(struct sk_buff
**pskb
,
78 struct ip_conntrack
*ct
,
79 enum ip_conntrack_info ctinfo
,
80 struct PptpControlHeader
*ctlh
,
81 union pptp_ctrl_union
*pptpReq
);
84 (*ip_nat_pptp_hook_exp_gre
)(struct ip_conntrack_expect
*expect_orig
,
85 struct ip_conntrack_expect
*expect_reply
);
88 (*ip_nat_pptp_hook_expectfn
)(struct ip_conntrack
*ct
,
89 struct ip_conntrack_expect
*exp
);
92 /* PptpControlMessageType names */
93 const char *pptp_msg_name
[] = {
95 "START_SESSION_REQUEST",
96 "START_SESSION_REPLY",
97 "STOP_SESSION_REQUEST",
106 "CALL_CLEAR_REQUEST",
107 "CALL_DISCONNECT_NOTIFY",
111 EXPORT_SYMBOL(pptp_msg_name
);
112 #define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, __FUNCTION__, ## args)
114 #define DEBUGP(format, args...)
118 #define MINS * 60 SECS
119 #define HOURS * 60 MINS
121 #define PPTP_GRE_TIMEOUT (10 MINS)
122 #define PPTP_GRE_STREAM_TIMEOUT (5 HOURS)
124 static void pptp_expectfn(struct ip_conntrack
*ct
,
125 struct ip_conntrack_expect
*exp
)
127 typeof(ip_nat_pptp_hook_expectfn
) ip_nat_pptp_expectfn
;
129 DEBUGP("increasing timeouts\n");
131 /* increase timeout of GRE data channel conntrack entry */
132 ct
->proto
.gre
.timeout
= PPTP_GRE_TIMEOUT
;
133 ct
->proto
.gre
.stream_timeout
= PPTP_GRE_STREAM_TIMEOUT
;
135 /* Can you see how rusty this code is, compared with the pre-2.6.11
136 * one? That's what happened to my shiny newnat of 2002 ;( -HW */
139 ip_nat_pptp_expectfn
= rcu_dereference(ip_nat_pptp_hook_expectfn
);
140 if (!ip_nat_pptp_expectfn
) {
141 struct ip_conntrack_tuple inv_t
;
142 struct ip_conntrack_expect
*exp_other
;
144 /* obviously this tuple inversion only works until you do NAT */
145 invert_tuplepr(&inv_t
, &exp
->tuple
);
146 DEBUGP("trying to unexpect other dir: ");
149 exp_other
= ip_conntrack_expect_find_get(&inv_t
);
151 /* delete other expectation. */
153 ip_conntrack_unexpect_related(exp_other
);
154 ip_conntrack_expect_put(exp_other
);
156 DEBUGP("not found\n");
159 /* we need more than simple inversion */
160 ip_nat_pptp_expectfn(ct
, exp
);
165 static int destroy_sibling_or_exp(const struct ip_conntrack_tuple
*t
)
167 struct ip_conntrack_tuple_hash
*h
;
168 struct ip_conntrack_expect
*exp
;
170 DEBUGP("trying to timeout ct or exp for tuple ");
173 h
= ip_conntrack_find_get(t
, NULL
);
175 struct ip_conntrack
*sibling
= tuplehash_to_ctrack(h
);
176 DEBUGP("setting timeout of conntrack %p to 0\n", sibling
);
177 sibling
->proto
.gre
.timeout
= 0;
178 sibling
->proto
.gre
.stream_timeout
= 0;
179 if (del_timer(&sibling
->timeout
))
180 sibling
->timeout
.function((unsigned long)sibling
);
181 ip_conntrack_put(sibling
);
184 exp
= ip_conntrack_expect_find_get(t
);
186 DEBUGP("unexpect_related of expect %p\n", exp
);
187 ip_conntrack_unexpect_related(exp
);
188 ip_conntrack_expect_put(exp
);
197 /* timeout GRE data connections */
198 static void pptp_destroy_siblings(struct ip_conntrack
*ct
)
200 struct ip_conntrack_tuple t
;
202 ip_ct_gre_keymap_destroy(ct
);
203 /* Since ct->sibling_list has literally rusted away in 2.6.11,
204 * we now need another way to find out about our sibling
205 * contrack and expects... -HW */
207 /* try original (pns->pac) tuple */
208 memcpy(&t
, &ct
->tuplehash
[IP_CT_DIR_ORIGINAL
].tuple
, sizeof(t
));
209 t
.dst
.protonum
= IPPROTO_GRE
;
210 t
.src
.u
.gre
.key
= ct
->help
.ct_pptp_info
.pns_call_id
;
211 t
.dst
.u
.gre
.key
= ct
->help
.ct_pptp_info
.pac_call_id
;
213 if (!destroy_sibling_or_exp(&t
))
214 DEBUGP("failed to timeout original pns->pac ct/exp\n");
216 /* try reply (pac->pns) tuple */
217 memcpy(&t
, &ct
->tuplehash
[IP_CT_DIR_REPLY
].tuple
, sizeof(t
));
218 t
.dst
.protonum
= IPPROTO_GRE
;
219 t
.src
.u
.gre
.key
= ct
->help
.ct_pptp_info
.pac_call_id
;
220 t
.dst
.u
.gre
.key
= ct
->help
.ct_pptp_info
.pns_call_id
;
222 if (!destroy_sibling_or_exp(&t
))
223 DEBUGP("failed to timeout reply pac->pns ct/exp\n");
226 /* expect GRE connections (PNS->PAC and PAC->PNS direction) */
228 exp_gre(struct ip_conntrack
*ct
,
232 struct ip_conntrack_expect
*exp_orig
, *exp_reply
;
234 typeof(ip_nat_pptp_hook_exp_gre
) ip_nat_pptp_exp_gre
;
236 exp_orig
= ip_conntrack_expect_alloc(ct
);
237 if (exp_orig
== NULL
)
240 exp_reply
= ip_conntrack_expect_alloc(ct
);
241 if (exp_reply
== NULL
)
244 /* original direction, PNS->PAC */
245 exp_orig
->tuple
.src
.ip
= ct
->tuplehash
[IP_CT_DIR_ORIGINAL
].tuple
.src
.ip
;
246 exp_orig
->tuple
.src
.u
.gre
.key
= peer_callid
;
247 exp_orig
->tuple
.dst
.ip
= ct
->tuplehash
[IP_CT_DIR_ORIGINAL
].tuple
.dst
.ip
;
248 exp_orig
->tuple
.dst
.u
.gre
.key
= callid
;
249 exp_orig
->tuple
.dst
.protonum
= IPPROTO_GRE
;
251 exp_orig
->mask
.src
.ip
= htonl(0xffffffff);
252 exp_orig
->mask
.src
.u
.all
= 0;
253 exp_orig
->mask
.dst
.u
.gre
.key
= htons(0xffff);
254 exp_orig
->mask
.dst
.ip
= htonl(0xffffffff);
255 exp_orig
->mask
.dst
.protonum
= 0xff;
257 exp_orig
->master
= ct
;
258 exp_orig
->expectfn
= pptp_expectfn
;
261 /* both expectations are identical apart from tuple */
262 memcpy(exp_reply
, exp_orig
, sizeof(*exp_reply
));
264 /* reply direction, PAC->PNS */
265 exp_reply
->tuple
.src
.ip
= ct
->tuplehash
[IP_CT_DIR_REPLY
].tuple
.src
.ip
;
266 exp_reply
->tuple
.src
.u
.gre
.key
= callid
;
267 exp_reply
->tuple
.dst
.ip
= ct
->tuplehash
[IP_CT_DIR_REPLY
].tuple
.dst
.ip
;
268 exp_reply
->tuple
.dst
.u
.gre
.key
= peer_callid
;
269 exp_reply
->tuple
.dst
.protonum
= IPPROTO_GRE
;
271 ip_nat_pptp_exp_gre
= rcu_dereference(ip_nat_pptp_hook_exp_gre
);
272 if (ip_nat_pptp_exp_gre
)
273 ip_nat_pptp_exp_gre(exp_orig
, exp_reply
);
274 if (ip_conntrack_expect_related(exp_orig
) != 0)
276 if (ip_conntrack_expect_related(exp_reply
) != 0)
277 goto out_unexpect_orig
;
279 /* Add GRE keymap entries */
280 if (ip_ct_gre_keymap_add(ct
, &exp_orig
->tuple
, 0) != 0)
281 goto out_unexpect_both
;
282 if (ip_ct_gre_keymap_add(ct
, &exp_reply
->tuple
, 1) != 0) {
283 ip_ct_gre_keymap_destroy(ct
);
284 goto out_unexpect_both
;
289 ip_conntrack_expect_put(exp_reply
);
291 ip_conntrack_expect_put(exp_orig
);
296 ip_conntrack_unexpect_related(exp_reply
);
298 ip_conntrack_unexpect_related(exp_orig
);
303 pptp_inbound_pkt(struct sk_buff
**pskb
,
304 struct PptpControlHeader
*ctlh
,
305 union pptp_ctrl_union
*pptpReq
,
307 struct ip_conntrack
*ct
,
308 enum ip_conntrack_info ctinfo
)
310 struct ip_ct_pptp_master
*info
= &ct
->help
.ct_pptp_info
;
312 __be16 cid
= 0, pcid
= 0;
313 typeof(ip_nat_pptp_hook_inbound
) ip_nat_pptp_inbound
;
315 msg
= ntohs(ctlh
->messageType
);
316 DEBUGP("inbound control message %s\n", pptp_msg_name
[msg
]);
319 case PPTP_START_SESSION_REPLY
:
320 /* server confirms new control session */
321 if (info
->sstate
< PPTP_SESSION_REQUESTED
)
323 if (pptpReq
->srep
.resultCode
== PPTP_START_OK
)
324 info
->sstate
= PPTP_SESSION_CONFIRMED
;
326 info
->sstate
= PPTP_SESSION_ERROR
;
329 case PPTP_STOP_SESSION_REPLY
:
330 /* server confirms end of control session */
331 if (info
->sstate
> PPTP_SESSION_STOPREQ
)
333 if (pptpReq
->strep
.resultCode
== PPTP_STOP_OK
)
334 info
->sstate
= PPTP_SESSION_NONE
;
336 info
->sstate
= PPTP_SESSION_ERROR
;
339 case PPTP_OUT_CALL_REPLY
:
340 /* server accepted call, we now expect GRE frames */
341 if (info
->sstate
!= PPTP_SESSION_CONFIRMED
)
343 if (info
->cstate
!= PPTP_CALL_OUT_REQ
&&
344 info
->cstate
!= PPTP_CALL_OUT_CONF
)
347 cid
= pptpReq
->ocack
.callID
;
348 pcid
= pptpReq
->ocack
.peersCallID
;
349 if (info
->pns_call_id
!= pcid
)
351 DEBUGP("%s, CID=%X, PCID=%X\n", pptp_msg_name
[msg
],
352 ntohs(cid
), ntohs(pcid
));
354 if (pptpReq
->ocack
.resultCode
== PPTP_OUTCALL_CONNECT
) {
355 info
->cstate
= PPTP_CALL_OUT_CONF
;
356 info
->pac_call_id
= cid
;
357 exp_gre(ct
, cid
, pcid
);
359 info
->cstate
= PPTP_CALL_NONE
;
362 case PPTP_IN_CALL_REQUEST
:
363 /* server tells us about incoming call request */
364 if (info
->sstate
!= PPTP_SESSION_CONFIRMED
)
367 cid
= pptpReq
->icreq
.callID
;
368 DEBUGP("%s, CID=%X\n", pptp_msg_name
[msg
], ntohs(cid
));
369 info
->cstate
= PPTP_CALL_IN_REQ
;
370 info
->pac_call_id
= cid
;
373 case PPTP_IN_CALL_CONNECT
:
374 /* server tells us about incoming call established */
375 if (info
->sstate
!= PPTP_SESSION_CONFIRMED
)
377 if (info
->cstate
!= PPTP_CALL_IN_REP
&&
378 info
->cstate
!= PPTP_CALL_IN_CONF
)
381 pcid
= pptpReq
->iccon
.peersCallID
;
382 cid
= info
->pac_call_id
;
384 if (info
->pns_call_id
!= pcid
)
387 DEBUGP("%s, PCID=%X\n", pptp_msg_name
[msg
], ntohs(pcid
));
388 info
->cstate
= PPTP_CALL_IN_CONF
;
390 /* we expect a GRE connection from PAC to PNS */
391 exp_gre(ct
, cid
, pcid
);
394 case PPTP_CALL_DISCONNECT_NOTIFY
:
395 /* server confirms disconnect */
396 cid
= pptpReq
->disc
.callID
;
397 DEBUGP("%s, CID=%X\n", pptp_msg_name
[msg
], ntohs(cid
));
398 info
->cstate
= PPTP_CALL_NONE
;
400 /* untrack this call id, unexpect GRE packets */
401 pptp_destroy_siblings(ct
);
404 case PPTP_WAN_ERROR_NOTIFY
:
405 case PPTP_ECHO_REQUEST
:
406 case PPTP_ECHO_REPLY
:
407 /* I don't have to explain these ;) */
413 ip_nat_pptp_inbound
= rcu_dereference(ip_nat_pptp_hook_inbound
);
414 if (ip_nat_pptp_inbound
)
415 return ip_nat_pptp_inbound(pskb
, ct
, ctinfo
, ctlh
, pptpReq
);
419 DEBUGP("invalid %s: type=%d cid=%u pcid=%u "
420 "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n",
421 msg
<= PPTP_MSG_MAX
? pptp_msg_name
[msg
] : pptp_msg_name
[0],
422 msg
, ntohs(cid
), ntohs(pcid
), info
->cstate
, info
->sstate
,
423 ntohs(info
->pns_call_id
), ntohs(info
->pac_call_id
));
428 pptp_outbound_pkt(struct sk_buff
**pskb
,
429 struct PptpControlHeader
*ctlh
,
430 union pptp_ctrl_union
*pptpReq
,
432 struct ip_conntrack
*ct
,
433 enum ip_conntrack_info ctinfo
)
435 struct ip_ct_pptp_master
*info
= &ct
->help
.ct_pptp_info
;
437 __be16 cid
= 0, pcid
= 0;
438 typeof(ip_nat_pptp_hook_outbound
) ip_nat_pptp_outbound
;
440 msg
= ntohs(ctlh
->messageType
);
441 DEBUGP("outbound control message %s\n", pptp_msg_name
[msg
]);
444 case PPTP_START_SESSION_REQUEST
:
445 /* client requests for new control session */
446 if (info
->sstate
!= PPTP_SESSION_NONE
)
448 info
->sstate
= PPTP_SESSION_REQUESTED
;
450 case PPTP_STOP_SESSION_REQUEST
:
451 /* client requests end of control session */
452 info
->sstate
= PPTP_SESSION_STOPREQ
;
455 case PPTP_OUT_CALL_REQUEST
:
456 /* client initiating connection to server */
457 if (info
->sstate
!= PPTP_SESSION_CONFIRMED
)
459 info
->cstate
= PPTP_CALL_OUT_REQ
;
460 /* track PNS call id */
461 cid
= pptpReq
->ocreq
.callID
;
462 DEBUGP("%s, CID=%X\n", pptp_msg_name
[msg
], ntohs(cid
));
463 info
->pns_call_id
= cid
;
465 case PPTP_IN_CALL_REPLY
:
466 /* client answers incoming call */
467 if (info
->cstate
!= PPTP_CALL_IN_REQ
&&
468 info
->cstate
!= PPTP_CALL_IN_REP
)
471 cid
= pptpReq
->icack
.callID
;
472 pcid
= pptpReq
->icack
.peersCallID
;
473 if (info
->pac_call_id
!= pcid
)
475 DEBUGP("%s, CID=%X PCID=%X\n", pptp_msg_name
[msg
],
476 ntohs(cid
), ntohs(pcid
));
478 if (pptpReq
->icack
.resultCode
== PPTP_INCALL_ACCEPT
) {
479 /* part two of the three-way handshake */
480 info
->cstate
= PPTP_CALL_IN_REP
;
481 info
->pns_call_id
= cid
;
483 info
->cstate
= PPTP_CALL_NONE
;
486 case PPTP_CALL_CLEAR_REQUEST
:
487 /* client requests hangup of call */
488 if (info
->sstate
!= PPTP_SESSION_CONFIRMED
)
490 /* FUTURE: iterate over all calls and check if
491 * call ID is valid. We don't do this without newnat,
492 * because we only know about last call */
493 info
->cstate
= PPTP_CALL_CLEAR_REQ
;
495 case PPTP_SET_LINK_INFO
:
496 case PPTP_ECHO_REQUEST
:
497 case PPTP_ECHO_REPLY
:
498 /* I don't have to explain these ;) */
504 ip_nat_pptp_outbound
= rcu_dereference(ip_nat_pptp_hook_outbound
);
505 if (ip_nat_pptp_outbound
)
506 return ip_nat_pptp_outbound(pskb
, ct
, ctinfo
, ctlh
, pptpReq
);
510 DEBUGP("invalid %s: type=%d cid=%u pcid=%u "
511 "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n",
512 msg
<= PPTP_MSG_MAX
? pptp_msg_name
[msg
] : pptp_msg_name
[0],
513 msg
, ntohs(cid
), ntohs(pcid
), info
->cstate
, info
->sstate
,
514 ntohs(info
->pns_call_id
), ntohs(info
->pac_call_id
));
518 static const unsigned int pptp_msg_size
[] = {
519 [PPTP_START_SESSION_REQUEST
] = sizeof(struct PptpStartSessionRequest
),
520 [PPTP_START_SESSION_REPLY
] = sizeof(struct PptpStartSessionReply
),
521 [PPTP_STOP_SESSION_REQUEST
] = sizeof(struct PptpStopSessionRequest
),
522 [PPTP_STOP_SESSION_REPLY
] = sizeof(struct PptpStopSessionReply
),
523 [PPTP_OUT_CALL_REQUEST
] = sizeof(struct PptpOutCallRequest
),
524 [PPTP_OUT_CALL_REPLY
] = sizeof(struct PptpOutCallReply
),
525 [PPTP_IN_CALL_REQUEST
] = sizeof(struct PptpInCallRequest
),
526 [PPTP_IN_CALL_REPLY
] = sizeof(struct PptpInCallReply
),
527 [PPTP_IN_CALL_CONNECT
] = sizeof(struct PptpInCallConnected
),
528 [PPTP_CALL_CLEAR_REQUEST
] = sizeof(struct PptpClearCallRequest
),
529 [PPTP_CALL_DISCONNECT_NOTIFY
] = sizeof(struct PptpCallDisconnectNotify
),
530 [PPTP_WAN_ERROR_NOTIFY
] = sizeof(struct PptpWanErrorNotify
),
531 [PPTP_SET_LINK_INFO
] = sizeof(struct PptpSetLinkInfo
),
534 /* track caller id inside control connection, call expect_related */
536 conntrack_pptp_help(struct sk_buff
**pskb
,
537 struct ip_conntrack
*ct
, enum ip_conntrack_info ctinfo
)
540 int dir
= CTINFO2DIR(ctinfo
);
541 struct ip_ct_pptp_master
*info
= &ct
->help
.ct_pptp_info
;
542 struct tcphdr _tcph
, *tcph
;
543 struct pptp_pkt_hdr _pptph
, *pptph
;
544 struct PptpControlHeader _ctlh
, *ctlh
;
545 union pptp_ctrl_union _pptpReq
, *pptpReq
;
546 unsigned int tcplen
= (*pskb
)->len
- (*pskb
)->nh
.iph
->ihl
* 4;
547 unsigned int datalen
, reqlen
, nexthdr_off
;
548 int oldsstate
, oldcstate
;
552 /* don't do any tracking before tcp handshake complete */
553 if (ctinfo
!= IP_CT_ESTABLISHED
554 && ctinfo
!= IP_CT_ESTABLISHED
+IP_CT_IS_REPLY
) {
555 DEBUGP("ctinfo = %u, skipping\n", ctinfo
);
559 nexthdr_off
= (*pskb
)->nh
.iph
->ihl
*4;
560 tcph
= skb_header_pointer(*pskb
, nexthdr_off
, sizeof(_tcph
), &_tcph
);
562 nexthdr_off
+= tcph
->doff
* 4;
563 datalen
= tcplen
- tcph
->doff
* 4;
565 pptph
= skb_header_pointer(*pskb
, nexthdr_off
, sizeof(_pptph
), &_pptph
);
567 DEBUGP("no full PPTP header, can't track\n");
570 nexthdr_off
+= sizeof(_pptph
);
571 datalen
-= sizeof(_pptph
);
573 /* if it's not a control message we can't do anything with it */
574 if (ntohs(pptph
->packetType
) != PPTP_PACKET_CONTROL
||
575 ntohl(pptph
->magicCookie
) != PPTP_MAGIC_COOKIE
) {
576 DEBUGP("not a control packet\n");
580 ctlh
= skb_header_pointer(*pskb
, nexthdr_off
, sizeof(_ctlh
), &_ctlh
);
583 nexthdr_off
+= sizeof(_ctlh
);
584 datalen
-= sizeof(_ctlh
);
587 msg
= ntohs(ctlh
->messageType
);
588 if (msg
> 0 && msg
<= PPTP_MSG_MAX
&& reqlen
< pptp_msg_size
[msg
])
590 if (reqlen
> sizeof(*pptpReq
))
591 reqlen
= sizeof(*pptpReq
);
593 pptpReq
= skb_header_pointer(*pskb
, nexthdr_off
, reqlen
, &_pptpReq
);
597 oldsstate
= info
->sstate
;
598 oldcstate
= info
->cstate
;
600 spin_lock_bh(&ip_pptp_lock
);
602 /* FIXME: We just blindly assume that the control connection is always
603 * established from PNS->PAC. However, RFC makes no guarantee */
604 if (dir
== IP_CT_DIR_ORIGINAL
)
605 /* client -> server (PNS -> PAC) */
606 ret
= pptp_outbound_pkt(pskb
, ctlh
, pptpReq
, reqlen
, ct
,
609 /* server -> client (PAC -> PNS) */
610 ret
= pptp_inbound_pkt(pskb
, ctlh
, pptpReq
, reqlen
, ct
,
612 DEBUGP("sstate: %d->%d, cstate: %d->%d\n",
613 oldsstate
, info
->sstate
, oldcstate
, info
->cstate
);
614 spin_unlock_bh(&ip_pptp_lock
);
619 /* control protocol helper */
620 static struct ip_conntrack_helper pptp
= {
621 .list
= { NULL
, NULL
},
626 .tuple
= { .src
= { .ip
= 0,
627 .u
= { .tcp
= { .port
=
628 __constant_htons(PPTP_CONTROL_PORT
) } }
632 .protonum
= IPPROTO_TCP
635 .mask
= { .src
= { .ip
= 0,
636 .u
= { .tcp
= { .port
= __constant_htons(0xffff) } }
643 .help
= conntrack_pptp_help
,
644 .destroy
= pptp_destroy_siblings
,
647 extern void ip_ct_proto_gre_fini(void);
648 extern int __init
ip_ct_proto_gre_init(void);
650 /* ip_conntrack_pptp initialization */
651 static int __init
ip_conntrack_helper_pptp_init(void)
655 retcode
= ip_ct_proto_gre_init();
659 DEBUGP(" registering helper\n");
660 if ((retcode
= ip_conntrack_helper_register(&pptp
))) {
661 printk(KERN_ERR
"Unable to register conntrack application "
662 "helper for pptp: %d\n", retcode
);
663 ip_ct_proto_gre_fini();
667 printk("ip_conntrack_pptp version %s loaded\n", IP_CT_PPTP_VERSION
);
671 static void __exit
ip_conntrack_helper_pptp_fini(void)
673 ip_conntrack_helper_unregister(&pptp
);
674 ip_ct_proto_gre_fini();
675 printk("ip_conntrack_pptp version %s unloaded\n", IP_CT_PPTP_VERSION
);
678 module_init(ip_conntrack_helper_pptp_init
);
679 module_exit(ip_conntrack_helper_pptp_fini
);
681 EXPORT_SYMBOL(ip_nat_pptp_hook_outbound
);
682 EXPORT_SYMBOL(ip_nat_pptp_hook_inbound
);
683 EXPORT_SYMBOL(ip_nat_pptp_hook_exp_gre
);
684 EXPORT_SYMBOL(ip_nat_pptp_hook_expectfn
);