Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-06-2010, 02:35 AM   #1
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 02:40 AM.
Old 10-06-2010, 02:36 AM   #2
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 661

Rep: Reputation: 66
Use wireshark
Old 10-06-2010, 02:56 AM   #3
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; = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
return 0;
void cleanup_module()


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 03:01 AM.


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 06:09 AM
dump packet data to file, but no packet header Nathanael Linux - Networking 3 02-08-2006 11:27 AM
dumping packet data linux_lover2005 Programming 0 12-23-2004 12:31 AM
print packet data linux_lover2005 Linux - Networking 0 12-21-2004 09:51 PM
how to get data from packet jooboo Programming 2 11-25-2003 01:39 PM > Forums > Linux Forums > Linux - Newbie

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

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