11 #include <linux/module.h>
14 #include <linux/tcp.h>
15 #include <linux/netfilter_ipv4.h>
20 #include <linux/netfilter/nf_conntrack_ftp.h>
36 return snprintf(buffer, buflen,
"%u,%u,%u,%u,%u,%u",
37 ((
unsigned char *)&addr->
ip)[0],
38 ((
unsigned char *)&addr->
ip)[1],
39 ((
unsigned char *)&addr->
ip)[2],
40 ((
unsigned char *)&addr->
ip)[3],
45 return snprintf(buffer, buflen,
"|1|%pI4|%u|",
48 return snprintf(buffer, buflen,
"|2|%pI6|%u|",
51 return snprintf(buffer, buflen,
"|||%u|", port);
59 static unsigned int nf_nat_ftp(
struct sk_buff *
skb,
63 unsigned int matchoff,
64 unsigned int matchlen,
74 pr_debug(
"FTP_NAT: type %i, off %u len %u\n", type, matchoff, matchlen);
77 newaddr = ct->
tuplehash[!dir].tuple.dst.u3;
78 exp->saved_proto.tcp.port = exp->
tuple.dst.u.tcp.port;
86 for (port =
ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
90 ret = nf_ct_expect_related(exp);
93 else if (ret != -
EBUSY) {
102 buflen = nf_nat_ftp_fmt_cmd(ct, type, buffer,
sizeof(buffer),
107 pr_debug(
"calling nf_nat_mangle_tcp_packet\n");
109 if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff, matchoff,
110 matchlen, buffer, buflen))
120 static void __exit nf_nat_ftp_fini(
void)
126 static int __init nf_nat_ftp_init(
void)
137 ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n");