my hook function code, called at PRE_ROUTING
unsigned int in_hook(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
print_string("Packet reached IN_HOOK.");
struct iphdr *my_ipheader;
print_string("out is: ");
// compare the out device with the list of rules
// TODO: replace by matches_rule()
if (strcmp(out->name, "eth1") == 0)
print_string("packet matches rule");
if(skb == NULL)
my_ipheader = skb->nh->iph;
//this_address = *my_ipheader->saddr;
//printk("the ip is : %d.%d.%d.%d\n",NIPQUAD(*my_ipheader->saddr));
print_string("out is null");
return NF_QUEUE; /* Drop ALL packets */
line 150 is: my_ipheader = skb->nh->iph;
on compile, I get this error:
[root@whatever spider]# make -C /usr/src/kernels/`uname -r`-i686 SUBDIRS=$PWD modules
make: Entering directory `/usr/src/kernels/2.6.12-1.1447_FC4-i686'
CC [M] /home/jc/code/spider/spider.o
/home/jc/code/spider/spider.c: In function ‘in_hook’:
/home/jc/code/spider/spider.c:126: warning: ISO C90 forbids mixed declarations and code
/home/jc/code/spider/spider.c:134: warning: passing argument 1 of ‘print_string’ discards qualifiers from pointer target type
/home/jc/code/spider/spider.c:150: error: request for member ‘nh’ in something not a structure or union
I've seen that statement being made more than a number of times, so what am I doing wrong??
I need to change the saddr (source address) in that if to another one (basicly, NATing it). How will I commit that change to the skb and then send it back into the stack?
thanx in advance...