Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 12-03-2004, 12:54 PM   #1
LQ Newbie
Registered: Dec 2004
Location: Worcester, MA
Posts: 2

Rep: Reputation: 0
How to retrieve an sk_buff from libipq

Ok so I need to capture some packets using libipq to mess with them. Done. Now I need to store them and I want to reinject them LATER. Here's the problem; in userspace where my packets are directed I capture them using ipq_read and ipq_get_packet. This gives me a buffer of type ipq_packet_msg. This type looks like this:


/* Messages sent from kernel */
typedef struct ipq_packet_msg {
       unsigned long packet_id;        /* ID of queued packet */
       unsigned long mark;             /* Netfilter mark value */
       long timestamp_sec;             /* Packet arrival time (seconds) */
       long timestamp_usec;            /* Packet arrvial time (+useconds) */
       unsigned int hook;              /* Netfilter hook we rode in on */
       char indev_name[IFNAMSIZ];      /* Name of incoming interface */
       char outdev_name[IFNAMSIZ];     /* Name of outgoing interface */
       unsigned short hw_protocol;     /* Hardw  Dec 3 2004, 10:43 AM
Average number of posts peare protocol (network order) */
       unsigned short hw_type;         /* Hardware type */
       unsigned char hw_addrlen;       /* Hardware address length */
       unsigned char hw_addr[8];       /* Hardware address */
       size_t data_len;                /* Length of packet data */
       unsigned char payload[0];       /* Optional packet data */
} ipq_packet_msg_t;
To reinject a packet, presumably by using the nf_reinject function (see include/linux/netfilter.h) I require as inputs an sk_buff and an nf_info, two structs usually associated with packets in the netfilter context. But all I have is that ipq_packet_msg buffer which has the packet and a few random tidbits of info.

Yes I've looked at Rusty's HOWTO on how to do everything in life and then some, there just isn't very good documentation on queueing to userspace, not to mention reinjecting packets back afterward. And once again I do mean reinject, not just NF_ACCEPT something, I mean take it out and put it back in.

I would really really appreciate anyone's input if they've done this or if they know how to retrieve a packet's sk_buff/nf_info in userspace, thanks!!!!!

Old 03-20-2006, 03:29 AM   #2
Registered: Mar 2006
Posts: 47

Rep: Reputation: 15

i think u have meddled much with skbuff to answer my Q.
I am doing a project on grouping packets in betn link and Ip layers
for this we have to catch packets and many things like this ,
Can u provide me a pointer to catching ip packets
Old 03-20-2006, 04:16 AM   #3
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259

Rep: Reputation: 30
u can catch packet in kernel netfilter modules at NF_IP_POST_ROUTING for outgoing packet and then u can modify in that kernel module and pass it to next layer.


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
Kernel AODV and libipq mahbub_bd Linux - Networking 1 05-19-2011 04:24 AM
Help with sk_buff cstrask Programming 0 11-23-2005 09:55 PM
how to use sk_buff wangjinyi Programming 0 10-27-2005 02:28 AM
kernel APIs related to sk_buff seong moon Linux - Networking 0 08-27-2002 04:28 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:39 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