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

Data Structures

union  tcp_word_hdr
 

Macros

#define tcp_flag_word(tp)   ( ((union tcp_word_hdr *)(tp))->words[3])
 

Functions

struct tcphdr * nfq_tcp_get_hdr (struct pkt_buff *pktb)
 nfq_tcp_get - get the TCP header More...
 
 EXPORT_SYMBOL (nfq_tcp_get_hdr)
 
void * nfq_tcp_get_payload (struct tcphdr *tcph, struct pkt_buff *pktb)
 nfq_tcp_get_payload - get the TCP packet payload More...
 
 EXPORT_SYMBOL (nfq_tcp_get_payload)
 
unsigned int nfq_tcp_get_payload_len (struct tcphdr *tcph, struct pkt_buff *pktb)
 nfq_tcp_get_payload_len - get the tcp packet payload More...
 
 EXPORT_SYMBOL (nfq_tcp_get_payload_len)
 
void nfq_tcp_compute_checksum_ipv4 (struct tcphdr *tcph, struct iphdr *iph)
 nfq_tcp_set_checksum_ipv4 - computes IPv4/TCP packet checksum More...
 
 EXPORT_SYMBOL (nfq_tcp_compute_checksum_ipv4)
 
void nfq_tcp_compute_checksum_ipv6 (struct tcphdr *tcph, struct ip6_hdr *ip6h)
 nfq_tcp_set_checksum_ipv6 - computes IPv6/TCP packet checksum More...
 
 EXPORT_SYMBOL (nfq_tcp_compute_checksum_ipv6)
 
int nfq_tcp_snprintf (char *buf, size_t size, const struct tcphdr *tcph)
 nfq_pkt_snprintf_tcp_hdr - print tcp header into one buffer in a humnan readable way More...
 
 EXPORT_SYMBOL (nfq_tcp_snprintf)
 
int nfq_tcp_mangle_ipv4 (struct pkt_buff *pkt, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
 nfq_tcp_mangle_ipv4 - mangle TCP/IPv4 packet buffer More...
 
 EXPORT_SYMBOL (nfq_tcp_mangle_ipv4)
 

Detailed Description

Macro Definition Documentation

#define tcp_flag_word (   tp)    ( ((union tcp_word_hdr *)(tp))->words[3])

Referenced by nfq_tcp_snprintf().

Function Documentation

EXPORT_SYMBOL ( nfq_tcp_get_hdr  )
EXPORT_SYMBOL ( nfq_tcp_get_payload  )
EXPORT_SYMBOL ( nfq_tcp_get_payload_len  )
EXPORT_SYMBOL ( nfq_tcp_compute_checksum_ipv4  )
EXPORT_SYMBOL ( nfq_tcp_compute_checksum_ipv6  )
EXPORT_SYMBOL ( nfq_tcp_snprintf  )
EXPORT_SYMBOL ( nfq_tcp_mangle_ipv4  )
void nfq_tcp_compute_checksum_ipv4 ( struct tcphdr *  tcph,
struct iphdr *  iph 
)

nfq_tcp_set_checksum_ipv4 - computes IPv4/TCP packet checksum

Parameters
tcphpointer to the TCP header
iphpointer to the IPv4 header

References nfq_checksum_tcpudp_ipv4().

Referenced by nfq_tcp_mangle_ipv4().

Here is the call graph for this function:

Here is the caller graph for this function:

void nfq_tcp_compute_checksum_ipv6 ( struct tcphdr *  tcph,
struct ip6_hdr *  ip6h 
)

nfq_tcp_set_checksum_ipv6 - computes IPv6/TCP packet checksum

Parameters
tcphpointer to the TCP header
iphpointer to the IPv6 header

References nfq_checksum_tcpudp_ipv6().

Here is the call graph for this function:

struct tcphdr* nfq_tcp_get_hdr ( struct pkt_buff pktb)

nfq_tcp_get - get the TCP header

Parameters
pktbpointer to user-space network packet buffer

This function returns NULL if an invalid TCP header is found. On success, it returns the TCP header.

Note
You have to call nfq_ip_set_transport_header or nfq_ip6_set_transport_header first to access the TCP header.

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

void* nfq_tcp_get_payload ( struct tcphdr *  tcph,
struct pkt_buff pktb 
)

nfq_tcp_get_payload - get the TCP packet payload

Parameters
tcphpointer to the TCP header
pktbpointer to user-space network packet buffer

References len, NULL, pkt_buff::tail, and pkt_buff::transport_header.

unsigned int nfq_tcp_get_payload_len ( struct tcphdr *  tcph,
struct pkt_buff pktb 
)

nfq_tcp_get_payload_len - get the tcp packet payload

Parameters
tcphpointer to the TCP header
pktbpointer to user-space network packet buffer

References pkt_buff::tail, and pkt_buff::transport_header.

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

nfq_tcp_mangle_ipv4 - mangle TCP/IPv4 packet buffer

Parameters
pktbpointer to network packet buffer
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 and TCP checksums for you.

References pkt_buff::network_header, nfq_ip_mangle(), and nfq_tcp_compute_checksum_ipv4().

Here is the call graph for this function:

int nfq_tcp_snprintf ( char *  buf,
size_t  size,
const struct tcphdr *  tcph 
)

nfq_pkt_snprintf_tcp_hdr - print tcp header into one buffer in a humnan readable way

Parameters
bufpointer to buffer that is used to print the object
sizesize of the buffer (or remaining room in it).
tcppointer to a valid tcp header.

References len, tcp_flag_word, and TCP_RESERVED_BITS.