LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

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

Rep: Reputation: 15
logging incoming packets ip address


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?
 
Old 11-18-2004, 02:17 PM   #2
slacky
Member
 
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.
 
  


Reply


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


All times are GMT -5. The time now is 02:12 PM.

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