Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 11-18-2004, 01:39 PM   #1
Registered: Nov 2004
Location: india
Distribution: Fedora core 1
Posts: 67

Rep: Reputation: 15
logging incoming packets ip address

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


int init_module()
nfho.hook = hook_func;
nfho.hooknum = NF_IP_LOCAL_IN; = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
return 0;

void cleanup_module()

what statement should be added at place of ...... in above code to work it?
Old 11-18-2004, 02:17 PM   #2
Registered: Feb 2004
Location: USA
Distribution: Debian
Posts: 174

Rep: Reputation: 16
Try looking in the netfilter LOG module source - ipt_LOG.c I believe has code that does it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging All Incoming / Outbound Traffic technick Linux - Security 1 10-24-2005 02:32 PM
Logging incoming/outgoing mail - how to? ziphem Linux - Newbie 0 09-23-2004 03:25 PM
drop incoming/outgoing packets using iptables doshiaj Linux - Security 1 06-08-2004 10:38 AM
Why Sendmail takes so much time to handle incoming SMTP packets? maxerg Linux - Networking 0 01-28-2004 08:07 PM
Red Hat 9 eth0 not accepting incoming packets. BinkyTheOracle Linux - Networking 21 01-25-2004 02:28 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration