LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 12-21-2004, 08:51 PM   #1
linux_lover2005
Member
 
Registered: Dec 2004
Posts: 44

Rep: Reputation: 15
print 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
dumping packet data linux_lover2005 Programming 0 12-22-2004 11:31 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
data packet fragmenter?? N_A_J_M Linux - General 0 04-29-2003 06:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:36 PM.

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