libnetfilter_queue  1.0.5
Modules | Functions
TCP helper functions
Collaboration diagram for TCP helper functions:

Modules

 Internal TCP functions
 

Functions

struct tcphdr * nfq_tcp_get_hdr (struct pkt_buff *pktb)
 
void * nfq_tcp_get_payload (struct tcphdr *tcph, struct pkt_buff *pktb)
 
unsigned int nfq_tcp_get_payload_len (struct tcphdr *tcph, struct pkt_buff *pktb)
 
int nfq_tcp_snprintf (char *buf, size_t size, const struct tcphdr *tcph)
 
int nfq_tcp_mangle_ipv4 (struct pkt_buff *pktb, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
 
int nfq_tcp_mangle_ipv6 (struct pkt_buff *pktb, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
 

Detailed Description

Function Documentation

◆ nfq_tcp_get_hdr()

struct tcphdr* nfq_tcp_get_hdr ( struct pkt_buff *  pktb)

nfq_tcp_get_hdr - get the TCP header

Parameters
pktbpointer to user-space network packet buffer
Returns
validated pointer to the TCP header or NULL if the TCP header was not set or if a minimal length check fails.
Note
You have to call nfq_ip_set_transport_header() or nfq_ip6_set_transport_header() first to set the TCP header.

Definition at line 43 of file tcp.c.

◆ nfq_tcp_get_payload()

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
Returns
Pointer to the TCP payload, or NULL if malformed TCP packet.

Definition at line 62 of file tcp.c.

◆ nfq_tcp_get_payload_len()

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
Returns
Length of TCP payload (user data)

Definition at line 84 of file tcp.c.

◆ nfq_tcp_mangle_ipv4()

int nfq_tcp_mangle_ipv4 ( struct pkt_buff *  pktb,
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
Returns
1 for success and 0 for failure. See pktb_mangle() for failure case
Note
This function updates the IPv4 length and recalculates the IPv4 & TCP checksums for you.
Warning
After changing the length of a TCP message, the application will need to mangle sequence numbers in both directions until another change puts them in sync again

Definition at line 219 of file tcp.c.

◆ nfq_tcp_mangle_ipv6()

int nfq_tcp_mangle_ipv6 ( struct pkt_buff *  pktb,
unsigned int  match_offset,
unsigned int  match_len,
const char *  rep_buffer,
unsigned int  rep_len 
)

nfq_tcp_mangle_ipv6 - Mangle TCP/IPv6 packet buffer

Parameters
pktbPointer to network packet buffer
match_offsetOffset from start of TCP data of 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
Returns
1 for success and 0 for failure. See pktb_mangle() for failure case
Note
This function updates the IPv6 length and recalculates the TCP checksum for you.
Warning
After changing the length of a TCP message, the application will need to mangle sequence numbers in both directions until another change puts them in sync again

Definition at line 254 of file tcp.c.

◆ nfq_tcp_snprintf()

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).
tcphpointer to a valid tcp header.
Returns
Same as snprintf
See also
snprintf(3)

Definition at line 160 of file tcp.c.