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/config.h>
50 #include <linux/module.h>
51 #include <linux/netfilter.h>
53 #include <net/checksum.h>
56 #include <linux/netfilter_ipv4/ip_conntrack.h>
57 #include <linux/netfilter_ipv4/ip_conntrack_core.h>
58 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
59 #include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
60 #include <linux/netfilter_ipv4/ip_conntrack_pptp.h>
62 #define IP_CT_PPTP_VERSION "3.1"
64 MODULE_LICENSE("GPL");
65 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
66 MODULE_DESCRIPTION("Netfilter connection tracking helper module for PPTP");
68 static DEFINE_SPINLOCK(ip_pptp_lock);
71 (*ip_nat_pptp_hook_outbound)(struct sk_buff **pskb,
72 struct ip_conntrack *ct,
73 enum ip_conntrack_info ctinfo,
74 struct PptpControlHeader *ctlh,
75 union pptp_ctrl_union *pptpReq);
78 (*ip_nat_pptp_hook_inbound)(struct sk_buff **pskb,
79 struct ip_conntrack *ct,
80 enum ip_conntrack_info ctinfo,
81 struct PptpControlHeader *ctlh,
82 union pptp_ctrl_union *pptpReq);
85 (*ip_nat_pptp_hook_exp_gre)(struct ip_conntrack_expect *expect_orig,
86 struct ip_conntrack_expect *expect_reply);
89 (*ip_nat_pptp_hook_expectfn)(struct ip_conntrack *ct,
90 struct ip_conntrack_expect *exp);
93 /* PptpControlMessageType names */
94 const char *pptp_msg_name[] = {
96 "START_SESSION_REQUEST",
97 "START_SESSION_REPLY",
98 "STOP_SESSION_REQUEST",
107 "CALL_CLEAR_REQUEST",
108 "CALL_DISCONNECT_NOTIFY",
112 EXPORT_SYMBOL(pptp_msg_name);
113 #define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, __FUNCTION__, ## args)
115 #define DEBUGP(format, args...)
119 #define MINS * 60 SECS
120 #define HOURS * 60 MINS
122 #define PPTP_GRE_TIMEOUT (10 MINS)
123 #define PPTP_GRE_STREAM_TIMEOUT (5 HOURS)
125 static void pptp_expectfn(struct ip_conntrack *ct,
126 struct ip_conntrack_expect *exp)
128 DEBUGP("increasing timeouts\n");
130 /* increase timeout of GRE data channel conntrack entry */
131 ct->proto.gre.timeout = PPTP_GRE_TIMEOUT;
132 ct->proto.gre.stream_timeout = PPTP_GRE_STREAM_TIMEOUT;
134 /* Can you see how rusty this code is, compared with the pre-2.6.11
135 * one? That's what happened to my shiny newnat of 2002 ;( -HW */
137 if (!ip_nat_pptp_hook_expectfn) {
138 struct ip_conntrack_tuple inv_t;
139 struct ip_conntrack_expect *exp_other;
141 /* obviously this tuple inversion only works until you do NAT */
142 invert_tuplepr(&inv_t, &exp->tuple);
143 DEBUGP("trying to unexpect other dir: ");
146 exp_other = ip_conntrack_expect_find(&inv_t);
148 /* delete other expectation. */
150 ip_conntrack_unexpect_related(exp_other);
151 ip_conntrack_expect_put(exp_other);
153 DEBUGP("not found\n");
156 /* we need more than simple inversion */
157 ip_nat_pptp_hook_expectfn(ct, exp);
161 static int destroy_sibling_or_exp(const struct ip_conntrack_tuple *t)
163 struct ip_conntrack_tuple_hash *h;
164 struct ip_conntrack_expect *exp;
166 DEBUGP("trying to timeout ct or exp for tuple ");
169 h = ip_conntrack_find_get(t, NULL);
171 struct ip_conntrack *sibling = tuplehash_to_ctrack(h);
172 DEBUGP("setting timeout of conntrack %p to 0\n", sibling);
173 sibling->proto.gre.timeout = 0;
174 sibling->proto.gre.stream_timeout = 0;
175 if (del_timer(&sibling->timeout))
176 sibling->timeout.function((unsigned long)sibling);
177 ip_conntrack_put(sibling);
180 exp = ip_conntrack_expect_find(t);
182 DEBUGP("unexpect_related of expect %p\n", exp);
183 ip_conntrack_unexpect_related(exp);
184 ip_conntrack_expect_put(exp);
193 /* timeout GRE data connections */
194 static void pptp_destroy_siblings(struct ip_conntrack *ct)
196 struct ip_conntrack_tuple t;
198 /* Since ct->sibling_list has literally rusted away in 2.6.11,
199 * we now need another way to find out about our sibling
200 * contrack and expects... -HW */
202 /* try original (pns->pac) tuple */
203 memcpy(&t, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, sizeof(t));
204 t.dst.protonum = IPPROTO_GRE;
205 t.src.u.gre.key = htons(ct->help.ct_pptp_info.pns_call_id);
206 t.dst.u.gre.key = htons(ct->help.ct_pptp_info.pac_call_id);
208 if (!destroy_sibling_or_exp(&t))
209 DEBUGP("failed to timeout original pns->pac ct/exp\n");
211 /* try reply (pac->pns) tuple */
212 memcpy(&t, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, sizeof(t));
213 t.dst.protonum = IPPROTO_GRE;
214 t.src.u.gre.key = htons(ct->help.ct_pptp_info.pac_call_id);
215 t.dst.u.gre.key = htons(ct->help.ct_pptp_info.pns_call_id);
217 if (!destroy_sibling_or_exp(&t))
218 DEBUGP("failed to timeout reply pac->pns ct/exp\n");
221 /* expect GRE connections (PNS->PAC and PAC->PNS direction) */
223 exp_gre(struct ip_conntrack *master,
228 struct ip_conntrack_tuple inv_tuple;
229 struct ip_conntrack_tuple exp_tuples[] = {
230 /* tuple in original direction, PNS->PAC */
231 { .src = { .ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip,
232 .u = { .gre = { .key = peer_callid } }
234 .dst = { .ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip,
235 .u = { .gre = { .key = callid } },
236 .protonum = IPPROTO_GRE
239 /* tuple in reply direction, PAC->PNS */
240 { .src = { .ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip,
241 .u = { .gre = { .key = callid } }
243 .dst = { .ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip,
244 .u = { .gre = { .key = peer_callid } },
245 .protonum = IPPROTO_GRE
249 struct ip_conntrack_expect *exp_orig, *exp_reply;
252 exp_orig = ip_conntrack_expect_alloc(master);
253 if (exp_orig == NULL)
256 exp_reply = ip_conntrack_expect_alloc(master);
257 if (exp_reply == NULL)
260 memcpy(&exp_orig->tuple, &exp_tuples[0], sizeof(exp_orig->tuple));
262 exp_orig->mask.src.ip = 0xffffffff;
263 exp_orig->mask.src.u.all = 0;
264 exp_orig->mask.dst.u.all = 0;
265 exp_orig->mask.dst.u.gre.key = htons(0xffff);
266 exp_orig->mask.dst.ip = 0xffffffff;
267 exp_orig->mask.dst.protonum = 0xff;
269 exp_orig->master = master;
270 exp_orig->expectfn = pptp_expectfn;
273 /* both expectations are identical apart from tuple */
274 memcpy(exp_reply, exp_orig, sizeof(*exp_reply));
275 memcpy(&exp_reply->tuple, &exp_tuples[1], sizeof(exp_reply->tuple));
277 if (ip_nat_pptp_hook_exp_gre)
278 ret = ip_nat_pptp_hook_exp_gre(exp_orig, exp_reply);
281 DEBUGP("calling expect_related PNS->PAC");
282 DUMP_TUPLE(&exp_orig->tuple);
284 if (ip_conntrack_expect_related(exp_orig) != 0) {
285 DEBUGP("cannot expect_related()\n");
289 DEBUGP("calling expect_related PAC->PNS");
290 DUMP_TUPLE(&exp_reply->tuple);
292 if (ip_conntrack_expect_related(exp_reply) != 0) {
293 DEBUGP("cannot expect_related()\n");
294 goto out_unexpect_orig;
297 /* Add GRE keymap entries */
298 if (ip_ct_gre_keymap_add(master, &exp_reply->tuple, 0) != 0) {
299 DEBUGP("cannot keymap_add() exp\n");
300 goto out_unexpect_both;
303 invert_tuplepr(&inv_tuple, &exp_reply->tuple);
304 if (ip_ct_gre_keymap_add(master, &inv_tuple, 1) != 0) {
305 ip_ct_gre_keymap_destroy(master);
306 DEBUGP("cannot keymap_add() exp_inv\n");
307 goto out_unexpect_both;
313 ip_conntrack_expect_put(exp_reply);
315 ip_conntrack_expect_put(exp_orig);
320 ip_conntrack_unexpect_related(exp_reply);
322 ip_conntrack_unexpect_related(exp_orig);
327 pptp_inbound_pkt(struct sk_buff **pskb,
329 unsigned int nexthdr_off,
330 unsigned int datalen,
331 struct ip_conntrack *ct,
332 enum ip_conntrack_info ctinfo)
334 struct PptpControlHeader _ctlh, *ctlh;
336 union pptp_ctrl_union _pptpReq, *pptpReq;
337 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
342 ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh);
344 DEBUGP("error during skb_header_pointer\n");
347 nexthdr_off += sizeof(_ctlh);
348 datalen -= sizeof(_ctlh);
351 if (reqlen > sizeof(*pptpReq))
352 reqlen = sizeof(*pptpReq);
353 pptpReq = skb_header_pointer(*pskb, nexthdr_off, reqlen, &_pptpReq);
355 DEBUGP("error during skb_header_pointer\n");
359 msg = ntohs(ctlh->messageType);
360 DEBUGP("inbound control message %s\n", pptp_msg_name[msg]);
363 case PPTP_START_SESSION_REPLY:
364 if (reqlen < sizeof(_pptpReq.srep)) {
365 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
369 /* server confirms new control session */
370 if (info->sstate < PPTP_SESSION_REQUESTED) {
371 DEBUGP("%s without START_SESS_REQUEST\n",
375 if (pptpReq->srep.resultCode == PPTP_START_OK)
376 info->sstate = PPTP_SESSION_CONFIRMED;
378 info->sstate = PPTP_SESSION_ERROR;
381 case PPTP_STOP_SESSION_REPLY:
382 if (reqlen < sizeof(_pptpReq.strep)) {
383 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
387 /* server confirms end of control session */
388 if (info->sstate > PPTP_SESSION_STOPREQ) {
389 DEBUGP("%s without STOP_SESS_REQUEST\n",
393 if (pptpReq->strep.resultCode == PPTP_STOP_OK)
394 info->sstate = PPTP_SESSION_NONE;
396 info->sstate = PPTP_SESSION_ERROR;
399 case PPTP_OUT_CALL_REPLY:
400 if (reqlen < sizeof(_pptpReq.ocack)) {
401 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
405 /* server accepted call, we now expect GRE frames */
406 if (info->sstate != PPTP_SESSION_CONFIRMED) {
407 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
410 if (info->cstate != PPTP_CALL_OUT_REQ &&
411 info->cstate != PPTP_CALL_OUT_CONF) {
412 DEBUGP("%s without OUTCALL_REQ\n", pptp_msg_name[msg]);
415 if (pptpReq->ocack.resultCode != PPTP_OUTCALL_CONNECT) {
416 info->cstate = PPTP_CALL_NONE;
420 cid = &pptpReq->ocack.callID;
421 pcid = &pptpReq->ocack.peersCallID;
423 info->pac_call_id = ntohs(*cid);
425 if (htons(info->pns_call_id) != *pcid) {
426 DEBUGP("%s for unknown callid %u\n",
427 pptp_msg_name[msg], ntohs(*pcid));
431 DEBUGP("%s, CID=%X, PCID=%X\n", pptp_msg_name[msg],
432 ntohs(*cid), ntohs(*pcid));
434 info->cstate = PPTP_CALL_OUT_CONF;
436 seq = ntohl(tcph->seq) + sizeof(struct pptp_pkt_hdr)
437 + sizeof(struct PptpControlHeader)
438 + ((void *)pcid - (void *)pptpReq);
440 if (exp_gre(ct, seq, *cid, *pcid) != 0)
441 printk("ip_conntrack_pptp: error during exp_gre\n");
444 case PPTP_IN_CALL_REQUEST:
445 if (reqlen < sizeof(_pptpReq.icack)) {
446 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
450 /* server tells us about incoming call request */
451 if (info->sstate != PPTP_SESSION_CONFIRMED) {
452 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
455 pcid = &pptpReq->icack.peersCallID;
456 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
457 info->cstate = PPTP_CALL_IN_REQ;
458 info->pac_call_id = ntohs(*pcid);
461 case PPTP_IN_CALL_CONNECT:
462 if (reqlen < sizeof(_pptpReq.iccon)) {
463 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
467 /* server tells us about incoming call established */
468 if (info->sstate != PPTP_SESSION_CONFIRMED) {
469 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
472 if (info->cstate != PPTP_CALL_IN_REP
473 && info->cstate != PPTP_CALL_IN_CONF) {
474 DEBUGP("%s but never sent IN_CALL_REPLY\n",
479 pcid = &pptpReq->iccon.peersCallID;
480 cid = &info->pac_call_id;
482 if (info->pns_call_id != ntohs(*pcid)) {
483 DEBUGP("%s for unknown CallID %u\n",
484 pptp_msg_name[msg], ntohs(*pcid));
488 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
489 info->cstate = PPTP_CALL_IN_CONF;
491 /* we expect a GRE connection from PAC to PNS */
492 seq = ntohl(tcph->seq) + sizeof(struct pptp_pkt_hdr)
493 + sizeof(struct PptpControlHeader)
494 + ((void *)pcid - (void *)pptpReq);
496 if (exp_gre(ct, seq, *cid, *pcid) != 0)
497 printk("ip_conntrack_pptp: error during exp_gre\n");
501 case PPTP_CALL_DISCONNECT_NOTIFY:
502 if (reqlen < sizeof(_pptpReq.disc)) {
503 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
507 /* server confirms disconnect */
508 cid = &pptpReq->disc.callID;
509 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*cid));
510 info->cstate = PPTP_CALL_NONE;
512 /* untrack this call id, unexpect GRE packets */
513 pptp_destroy_siblings(ct);
516 case PPTP_WAN_ERROR_NOTIFY:
519 case PPTP_ECHO_REQUEST:
520 case PPTP_ECHO_REPLY:
521 /* I don't have to explain these ;) */
524 DEBUGP("invalid %s (TY=%d)\n", (msg <= PPTP_MSG_MAX)
525 ? pptp_msg_name[msg]:pptp_msg_name[0], msg);
530 if (ip_nat_pptp_hook_inbound)
531 return ip_nat_pptp_hook_inbound(pskb, ct, ctinfo, ctlh,
539 pptp_outbound_pkt(struct sk_buff **pskb,
541 unsigned int nexthdr_off,
542 unsigned int datalen,
543 struct ip_conntrack *ct,
544 enum ip_conntrack_info ctinfo)
546 struct PptpControlHeader _ctlh, *ctlh;
548 union pptp_ctrl_union _pptpReq, *pptpReq;
549 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
553 ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh);
556 nexthdr_off += sizeof(_ctlh);
557 datalen -= sizeof(_ctlh);
560 if (reqlen > sizeof(*pptpReq))
561 reqlen = sizeof(*pptpReq);
562 pptpReq = skb_header_pointer(*pskb, nexthdr_off, reqlen, &_pptpReq);
566 msg = ntohs(ctlh->messageType);
567 DEBUGP("outbound control message %s\n", pptp_msg_name[msg]);
570 case PPTP_START_SESSION_REQUEST:
571 /* client requests for new control session */
572 if (info->sstate != PPTP_SESSION_NONE) {
573 DEBUGP("%s but we already have one",
576 info->sstate = PPTP_SESSION_REQUESTED;
578 case PPTP_STOP_SESSION_REQUEST:
579 /* client requests end of control session */
580 info->sstate = PPTP_SESSION_STOPREQ;
583 case PPTP_OUT_CALL_REQUEST:
584 if (reqlen < sizeof(_pptpReq.ocreq)) {
585 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
589 /* client initiating connection to server */
590 if (info->sstate != PPTP_SESSION_CONFIRMED) {
591 DEBUGP("%s but no session\n",
595 info->cstate = PPTP_CALL_OUT_REQ;
596 /* track PNS call id */
597 cid = &pptpReq->ocreq.callID;
598 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*cid));
599 info->pns_call_id = ntohs(*cid);
601 case PPTP_IN_CALL_REPLY:
602 if (reqlen < sizeof(_pptpReq.icack)) {
603 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
607 /* client answers incoming call */
608 if (info->cstate != PPTP_CALL_IN_REQ
609 && info->cstate != PPTP_CALL_IN_REP) {
610 DEBUGP("%s without incall_req\n",
614 if (pptpReq->icack.resultCode != PPTP_INCALL_ACCEPT) {
615 info->cstate = PPTP_CALL_NONE;
618 pcid = &pptpReq->icack.peersCallID;
619 if (info->pac_call_id != ntohs(*pcid)) {
620 DEBUGP("%s for unknown call %u\n",
621 pptp_msg_name[msg], ntohs(*pcid));
624 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
625 /* part two of the three-way handshake */
626 info->cstate = PPTP_CALL_IN_REP;
627 info->pns_call_id = ntohs(pptpReq->icack.callID);
630 case PPTP_CALL_CLEAR_REQUEST:
631 /* client requests hangup of call */
632 if (info->sstate != PPTP_SESSION_CONFIRMED) {
633 DEBUGP("CLEAR_CALL but no session\n");
636 /* FUTURE: iterate over all calls and check if
637 * call ID is valid. We don't do this without newnat,
638 * because we only know about last call */
639 info->cstate = PPTP_CALL_CLEAR_REQ;
641 case PPTP_SET_LINK_INFO:
643 case PPTP_ECHO_REQUEST:
644 case PPTP_ECHO_REPLY:
645 /* I don't have to explain these ;) */
648 DEBUGP("invalid %s (TY=%d)\n", (msg <= PPTP_MSG_MAX)?
649 pptp_msg_name[msg]:pptp_msg_name[0], msg);
650 /* unknown: no need to create GRE masq table entry */
654 if (ip_nat_pptp_hook_outbound)
655 return ip_nat_pptp_hook_outbound(pskb, ct, ctinfo, ctlh,
662 /* track caller id inside control connection, call expect_related */
664 conntrack_pptp_help(struct sk_buff **pskb,
665 struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
668 struct pptp_pkt_hdr _pptph, *pptph;
669 struct tcphdr _tcph, *tcph;
670 u_int32_t tcplen = (*pskb)->len - (*pskb)->nh.iph->ihl * 4;
672 int dir = CTINFO2DIR(ctinfo);
673 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
674 unsigned int nexthdr_off;
676 int oldsstate, oldcstate;
679 /* don't do any tracking before tcp handshake complete */
680 if (ctinfo != IP_CT_ESTABLISHED
681 && ctinfo != IP_CT_ESTABLISHED+IP_CT_IS_REPLY) {
682 DEBUGP("ctinfo = %u, skipping\n", ctinfo);
686 nexthdr_off = (*pskb)->nh.iph->ihl*4;
687 tcph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_tcph), &_tcph);
689 nexthdr_off += tcph->doff * 4;
690 datalen = tcplen - tcph->doff * 4;
692 if (tcph->fin || tcph->rst) {
693 DEBUGP("RST/FIN received, timeouting GRE\n");
694 /* can't do this after real newnat */
695 info->cstate = PPTP_CALL_NONE;
697 /* untrack this call id, unexpect GRE packets */
698 pptp_destroy_siblings(ct);
701 pptph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_pptph), &_pptph);
703 DEBUGP("no full PPTP header, can't track\n");
706 nexthdr_off += sizeof(_pptph);
707 datalen -= sizeof(_pptph);
709 /* if it's not a control message we can't do anything with it */
710 if (ntohs(pptph->packetType) != PPTP_PACKET_CONTROL ||
711 ntohl(pptph->magicCookie) != PPTP_MAGIC_COOKIE) {
712 DEBUGP("not a control packet\n");
716 oldsstate = info->sstate;
717 oldcstate = info->cstate;
719 spin_lock_bh(&ip_pptp_lock);
721 /* FIXME: We just blindly assume that the control connection is always
722 * established from PNS->PAC. However, RFC makes no guarantee */
723 if (dir == IP_CT_DIR_ORIGINAL)
724 /* client -> server (PNS -> PAC) */
725 ret = pptp_outbound_pkt(pskb, tcph, nexthdr_off, datalen, ct,
728 /* server -> client (PAC -> PNS) */
729 ret = pptp_inbound_pkt(pskb, tcph, nexthdr_off, datalen, ct,
731 DEBUGP("sstate: %d->%d, cstate: %d->%d\n",
732 oldsstate, info->sstate, oldcstate, info->cstate);
733 spin_unlock_bh(&ip_pptp_lock);
738 /* control protocol helper */
739 static struct ip_conntrack_helper pptp = {
740 .list = { NULL, NULL },
745 .tuple = { .src = { .ip = 0,
746 .u = { .tcp = { .port =
747 __constant_htons(PPTP_CONTROL_PORT) } }
751 .protonum = IPPROTO_TCP
754 .mask = { .src = { .ip = 0,
755 .u = { .tcp = { .port = __constant_htons(0xffff) } }
762 .help = conntrack_pptp_help
765 extern void ip_ct_proto_gre_fini(void);
766 extern int __init ip_ct_proto_gre_init(void);
768 /* ip_conntrack_pptp initialization */
769 static int __init ip_conntrack_helper_pptp_init(void)
773 retcode = ip_ct_proto_gre_init();
777 DEBUGP(" registering helper\n");
778 if ((retcode = ip_conntrack_helper_register(&pptp))) {
779 printk(KERN_ERR "Unable to register conntrack application "
780 "helper for pptp: %d\n", retcode);
781 ip_ct_proto_gre_fini();
785 printk("ip_conntrack_pptp version %s loaded\n", IP_CT_PPTP_VERSION);
789 static void __exit ip_conntrack_helper_pptp_fini(void)
791 ip_conntrack_helper_unregister(&pptp);
792 ip_ct_proto_gre_fini();
793 printk("ip_conntrack_pptp version %s unloaded\n", IP_CT_PPTP_VERSION);
796 module_init(ip_conntrack_helper_pptp_init);
797 module_exit(ip_conntrack_helper_pptp_fini);
799 EXPORT_SYMBOL(ip_nat_pptp_hook_outbound);
800 EXPORT_SYMBOL(ip_nat_pptp_hook_inbound);
801 EXPORT_SYMBOL(ip_nat_pptp_hook_exp_gre);
802 EXPORT_SYMBOL(ip_nat_pptp_hook_expectfn);