LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-22-2004, 11:31 PM   #1
linux_lover2005
Member
 
Registered: Dec 2004
Posts: 44

Rep: Reputation: 15
dumping packet data


I want to print skb->data contents in kernel module using netfilter module at
NF_HOOK NF_IP_LOCAL_OUT. How can i do that? I know how to write netfilter
module like this one
#define MODULE
#define __KERNEL__

#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 nfho1;
static unsigned char *packet_ip = "\x7f\x00\x00\x0b";

unsigned int hook_func1(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 at NF_IP_LOCAL_OUT\n");
if (sb->nh.iph->saddr == *(unsigned int *)packet_ip)
{
/*CODE REQUIRE TO BE INCLUDED HERE*/
return NF_ACCEPT;
}
else
return NF_ACCEPT;

}


static int __init init(void)
{
nfho1.hook = hook_func1;
nfho1.hooknum = NF_IP_LOCAL_OUT;
nfho1.pf = PF_INET;
nfho1.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho1);
return 0;
}

static void __exit fini(void)
{
nf_unregister_hook(&nfho1);
}
module_init(init);
module_exit(fini);
MODULE_LICENSE("GPL");

But how can i print those HEX codes in packet?
 
  


Reply



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
how do i read the data in the packet that i have captured after packet capture? gajaykrishnan Programming 23 04-19-2006 05:09 AM
Novell is dumping KDE, so I'll be dumping SuSE KimVette SUSE / openSUSE 10 11-12-2005 08:09 PM
print packet data linux_lover2005 Linux - Networking 0 12-21-2004 08:51 PM
how to get data from packet jooboo Programming 2 11-25-2003 12:39 PM
Raw Packet Data vanibhat Linux - Security 1 08-01-2003 07:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration