LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   printing data in an ip packet (https://www.linuxquestions.org/questions/linux-newbie-8/printing-data-in-an-ip-packet-836468/)

Anumathew 10-06-2010 01:35 AM

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

vishesh 10-06-2010 01:36 AM

Use wireshark

Anumathew 10-06-2010 01:56 AM

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


All times are GMT -5. The time now is 10:42 PM.