Ok so I need to capture some packets using ipqueue to mess with them. Done. Now I need to store them and 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!!!!!