Hi!
I'm trying to make a new conntrack module, but it doesn't seem to be
receiving packets that I've set the tuple for. See code below.
As you can see, at this point it's very similar to the sample code in the
netfilter howtos, and it compiles cleanly. I've included the compile
options specified at the end of the source. It's not supposed to do
anything useful yet, just print debug messages.
It should printk an "ICQ packet received" whenever an icq packet goes by,
but it doesn't. It does print the "I'm in!" and "I'm out!" printk's at
module load and release, though.
What am I missing here? Any assistance would be greatly appreciated.
Cheers,
Scott <sshore@escape.ca>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/netfilter.h>
#include <linux/ip.h>
#include <linux/ctype.h>
#include <net/checksum.h>
#include <net/udp.h>
#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
#define ICQ_PORT 4000
#define DEBUGP(format, args...) printk(KERN_DEBUG __FILE__ ":" __FUNCTION__ \
":" format, ## args)
static int icq_help(const struct iphdr *iph, size_t len,
struct ip_conntrack *ct,
enum ip_conntrack_info ct_info)
{
DEBUGP("ICQ packet received\n");
return NF_ACCEPT;
}
static struct ip_conntrack_helper icq;
static int __init init(void)
{
memset(&icq, 0, sizeof(struct ip_conntrack_helper));
icq.tuple.dst.protonum = IPPROTO_UDP;
icq.tuple.dst.u.udp.port = htons(ICQ_PORT);
icq.mask.dst.protonum = 0xFFFF;
icq.mask.dst.u.udp.port = 0xFFFF;
icq.help = icq_help;
DEBUGP("I'm in!\n");
return ip_conntrack_helper_register(&icq);
}
static void __exit fini(void)
{
DEBUGP("I'm out!\n");
ip_conntrack_helper_unregister(&icq);
}
module_init(init);
module_exit(fini);
/* gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2
-fomit-frame-pointer -fno-strict-aliasing -pipe -march=i486 -DMODULE -c -o
test.o test.c */
I'm trying to make a new conntrack module, but it doesn't seem to be
receiving packets that I've set the tuple for. See code below.
As you can see, at this point it's very similar to the sample code in the
netfilter howtos, and it compiles cleanly. I've included the compile
options specified at the end of the source. It's not supposed to do
anything useful yet, just print debug messages.
It should printk an "ICQ packet received" whenever an icq packet goes by,
but it doesn't. It does print the "I'm in!" and "I'm out!" printk's at
module load and release, though.
What am I missing here? Any assistance would be greatly appreciated.
Cheers,
Scott <sshore@escape.ca>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/netfilter.h>
#include <linux/ip.h>
#include <linux/ctype.h>
#include <net/checksum.h>
#include <net/udp.h>
#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
#define ICQ_PORT 4000
#define DEBUGP(format, args...) printk(KERN_DEBUG __FILE__ ":" __FUNCTION__ \
":" format, ## args)
static int icq_help(const struct iphdr *iph, size_t len,
struct ip_conntrack *ct,
enum ip_conntrack_info ct_info)
{
DEBUGP("ICQ packet received\n");
return NF_ACCEPT;
}
static struct ip_conntrack_helper icq;
static int __init init(void)
{
memset(&icq, 0, sizeof(struct ip_conntrack_helper));
icq.tuple.dst.protonum = IPPROTO_UDP;
icq.tuple.dst.u.udp.port = htons(ICQ_PORT);
icq.mask.dst.protonum = 0xFFFF;
icq.mask.dst.u.udp.port = 0xFFFF;
icq.help = icq_help;
DEBUGP("I'm in!\n");
return ip_conntrack_helper_register(&icq);
}
static void __exit fini(void)
{
DEBUGP("I'm out!\n");
ip_conntrack_helper_unregister(&icq);
}
module_init(init);
module_exit(fini);
/* gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2
-fomit-frame-pointer -fno-strict-aliasing -pipe -march=i486 -DMODULE -c -o
test.o test.c */