how to program a conntrack module

Fai Yip
Sat, 27 Oct 2001 00:04:50 +0800

Dear Scottie Shore,
Thanks for you help, it really works now, but there is another things
confusing me that the following help function code cannot properly

static int
tcp_help( const struct iphdr *iph, size_t len,
struct ip_conntrack *ct,
enum ip_conntrack_info ctinfo )
struct tcphdr *th = ( struct tcphdr *)(iph+iph->ihl*4 );

printk("ctinfo = %u\n", ctinfo );
printk( "[tcp_help()]: source %d.%d.%d.%d dst %d.%d.%d.%d sport %u dport
%u\n", NIPQUAD( iph->sad
dr), NIPQUAD( iph->daddr ), th->source, th->dest );

return NF_ACCEPT;

The part printing the "dport" and "sport" doesn't seems alright with the
following result

Oct 26 23:56:16 suifai kernel: [tcp_help()]: source dst sport 0 dport 0

Obviously, the information is about a packet from port 80, otherwise it
wouldn't printed out. However, the outcome information doesn't have the
expected port no. shown. I use the same method that the ftp connection
track helper used to grep tcp header information. If this failed, does
it mean the ftp connection track helper might failed too or I missed
something else????

Thanks again for your help.