All of lore.kernel.org
 help / color / mirror / Atom feed
* netfilter hook function error...
@ 2005-09-21  0:13 JC
  2005-09-21  1:14 ` JC
  2005-09-21  5:51 ` Patrick Schaaf
  0 siblings, 2 replies; 5+ messages in thread
From: JC @ 2005-09-21  0:13 UTC (permalink / raw)
  To: netfilter-devel, netfilter

my hook function code, called at :

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;
  //u32 this_address;

  if (out)
    {
      if(out->name)
	{
	  print_string("out is: ");
	  print_string(out->name);


	  // 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)
		{
		  return -1;
		}
	
	      my_ipheader = skb->nh->iph;
	      print_string("printk-ing saddr...");
	      //this_address = *my_ipheader->saddr;
	      //printk("the ip is : %d.%d.%d.%d\n",NIPQUAD(*my_ipheader->saddr));

	    }
	}
      else
	{
	  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...

John


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-09-21  6:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4330b900.50a87b17.7179.ffffad17SMTPIN_ADDED@mx.gmail.com>
2005-09-21  1:49 ` netfilter hook function error JC
2005-09-21  0:13 JC
2005-09-21  1:14 ` JC
2005-09-21  5:51 ` Patrick Schaaf
2005-09-21  6:09   ` JC

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.