libnetfilter_queue  1.0.3
Functions
IPv4 helper functions

Functions

struct iphdr * nfq_ip_get_hdr (struct pkt_buff *pktb)
 
int nfq_ip_set_transport_header (struct pkt_buff *pktb, struct iphdr *iph)
 
void nfq_ip_set_checksum (struct iphdr *iph)
 
int nfq_ip_mangle (struct pkt_buff *pkt, unsigned int dataoff, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
 
int nfq_ip_snprintf (char *buf, size_t size, const struct iphdr *iph)
 

Detailed Description

Function Documentation

struct iphdr* nfq_ip_get_hdr ( struct pkt_buff *  pktb)

nfq_ip_get_hdr - get IPv4 header

Parameters
pktbpointer to network packet buffer

This funcion returns NULL if the IPv4 is malformed or the protocol version is not 4. On success, it returns a valid pointer to the IPv4 header.

Definition at line 35 of file ipv4.c.

int nfq_ip_mangle ( struct pkt_buff *  pkt,
unsigned int  dataoff,
unsigned int  match_offset,
unsigned int  match_len,
const char *  rep_buffer,
unsigned int  rep_len 
)

nfq_ip_mangle - mangle IPv4 packet buffer

Parameters
pktbpointer to network packet buffer
dataoffoffset to layer 4 header
match_offsetoffset to content that you want to mangle
match_lenlength of the existing content you want to mangle
rep_bufferpointer to data you want to use to replace current content
rep_lenlength of data you want to use to replace current content
Note
This function recalculates the IPv4 checksum (if needed).

Definition at line 103 of file ipv4.c.

void nfq_ip_set_checksum ( struct iphdr *  iph)

nfq_ip_set_checksum - set IPv4 checksum

Parameters
iphpointer to the IPv4 header
Note
Call to this function if you modified the IPv4 header to update the checksum.

Definition at line 83 of file ipv4.c.

int nfq_ip_set_transport_header ( struct pkt_buff *  pktb,
struct iphdr *  iph 
)

nfq_ip_set_transport_header - set transport header

Parameters
pktbpointer to network packet buffer
iphpointer to the IPv4 header

Definition at line 63 of file ipv4.c.

int nfq_ip_snprintf ( char *  buf,
size_t  size,
const struct iphdr *  iph 
)

nfq_pkt_snprintf_ip - print IPv4 header into buffer in iptables LOG format

Parameters
bufpointer to buffer that will be used to print the header
sizesize of the buffer (or remaining room in it)
ippointer to a valid IPv4 header

This function returns the number of bytes that would have been written in case that there is enough room in the buffer. Read snprintf manpage for more information to know more about this strange behaviour.

Definition at line 131 of file ipv4.c.