netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
IPv4 helper functions

Functions

struct iphdr * nfq_ip_get_hdr (struct pkt_buff *pktb)
 nfq_ip_get_hdr - get IPv4 header More...
 
 EXPORT_SYMBOL (nfq_ip_get_hdr)
 
int nfq_ip_set_transport_header (struct pkt_buff *pktb, struct iphdr *iph)
 nfq_ip_set_transport_header - set transport header More...
 
 EXPORT_SYMBOL (nfq_ip_set_transport_header)
 
void nfq_ip_set_checksum (struct iphdr *iph)
 nfq_ip_set_checksum - set IPv4 checksum More...
 
 EXPORT_SYMBOL (nfq_ip_set_checksum)
 
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 More...
 
 EXPORT_SYMBOL (nfq_ip_mangle)
 
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 More...
 
 EXPORT_SYMBOL (nfq_ip_snprintf)
 

Detailed Description

Function Documentation

EXPORT_SYMBOL ( nfq_ip_get_hdr  )
EXPORT_SYMBOL ( nfq_ip_set_transport_header  )
EXPORT_SYMBOL ( nfq_ip_set_checksum  )
EXPORT_SYMBOL ( nfq_ip_mangle  )
EXPORT_SYMBOL ( nfq_ip_snprintf  )
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.

References pkt_buff::network_header, NULL, and pkt_buff::tail.

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).

References pkt_buff::len, pkt_buff::network_header, nfq_ip_set_checksum(), and pktb_mangle().

Referenced by nfq_tcp_mangle_ipv4(), and nfq_udp_mangle_ipv4().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

References nfq_checksum().

Referenced by nfq_ip_mangle().

Here is the call graph for this function:

Here is the caller graph for this function:

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

References pkt_buff::len, pkt_buff::network_header, and pkt_buff::transport_header.

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.