LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2010, 01:35 AM   #1
Anumathew
LQ Newbie
 
Registered: Oct 2010
Posts: 4

Rep: Reputation: 0
printing data in an ip packet


Currently i am working with linux code. I need help in printing data in ip packet.
In my program i am defined the headers and defined ip packets. But I am having problems with printing data in the ip. I am thinking that for loop has to be used, but what parameters to use

Last edited by Anumathew; 10-06-2010 at 01:40 AM.
 
Old 10-06-2010, 01:36 AM   #2
vishesh
Member
 
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 661

Rep: Reputation: 66
Use wireshark
 
Old 10-06-2010, 01:56 AM   #3
Anumathew
LQ Newbie
 
Registered: Oct 2010
Posts: 4

Original Poster
Rep: Reputation: 0
thanks for replying
but I am asked to do using commands
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/skbuff.h>
#include <linux/udp.h>
#include <linux/ip.h>
static struct nf_hook_ops nfho;
struct sk_buff *sock_buff;
struct udphdr *udp_header;
struct iphdr *ip_header;
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 *))
{
sock_buff = *skb;
ip_header = (struct iphdr *)skb_network_header(sock_buff);
if(!sock_buff) { return NF_ACCEPT;}
}
return NF_ACCEPT;
}
int init_module()
{
nfho.hook = hook_func;
nfho.hooknum = NF_IP_PRE_ROUTING;
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
return 0;
}
void cleanup_module()

{
nf_unregister_hook(&nfho);
}

This is my program. and i have to add portions for capturing ip packet and printing data in the packet

Last edited by Anumathew; 10-06-2010 at 02:01 AM.
 
  


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
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
dump packet data to file, but no packet header Nathanael Linux - Networking 3 02-08-2006 10:27 AM
dumping packet data linux_lover2005 Programming 0 12-22-2004 11:31 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


All times are GMT -5. The time now is 08:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration