correct way to print packet ip address thro' module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  hello,
    Please help me. how can i print an incoming packets ip address through following module skeleton?

          #define __KERNEL__
          #define MODULE
          #include <linux/module.h>
          #include <linux/kernel.h>
          #include <linux/skbuff.h>
          #include <linux/ip.h>             
          #include <linux/netfilter.h>
          #include <linux/netfilter_ipv4.h>

          static struct nf_hook_ops nfho;
          unsigned int hook_func(unsigned int hooknum,
                                struct sk_buff **skb,
                                const struct net_device *in,
                                const struct net_device *out,
                                int (*okfn)(struct sk_buff *))
          {
              struct sk_buff *sb = *skb;
              printk(KERN_DEBUG "calling hook_func NF_IP_LOCAL_IN\n");
........
????????how to use this sb->nh.iph->saddr variable that contains ip address to print it in like 127.0.0.1????????
          
          }

        int init_module()
          {
              nfho.hook    = hook_func;
              nfho.hooknum  = NF_IP_LOCAL_IN;
              nfho.pf      = PF_INET;
              nfho.priority = NF_IP_PRI_FIRST;           
              nf_register_hook(&nfho);
              return 0;
          }
         
       void cleanup_module()
          {
              nf_unregister_hook(&nfho);
          }

what statement should be added at place of ...... in above code to work it?
regards,
bunty.




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux