tcp(3)
π tcp(3) β Library Functions Manual π
okay bestie, sit down, hydrate, because we're about to talk about tcp β the TCP helper functions from libnetfilter_queue, and yes this is the section 3 manual page, so it's a library thing, not a command you type. π§β¨
πΈ NAME πΈ
tcp β TCP helper functions. that's it, that's the whole name section, she's concise, she's iconic, she ate. π
β¨ SYNOPSIS β¨
π Modules
Internal TCP functions β yes ma'am, that's the module vibe. π¦
π Functions
okay so here's the whole squad, exactly as declared, don't touch a single character, i'm watching π:
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)
six functions, all TCP, all yours. slay. π₯
π Detailed Description π
Internal TCP functions β that's the whole detailed description bestie, the Doxygen just said "go read the function docs" and honestly? valid. no cap. π
π Function Documentation π
π struct tcphdr * nfq_tcp_get_hdr (struct pkt_buff * pktb)
nfq_tcp_get_hdr β get the TCP header. it's giving "hand me the header, please and thank you." π«Ά
Parameters
- pktb β pointer to user-space network packet buffer
Returns
a validated pointer to the TCP header, or NULL if the TCP header was not set, or if a minimal length check fails. so like, it checks before it ships. queen behavior. π
Note
bestie you HAVE to callnfq_ip_set_transport_header()ornfq_ip6_set_transport_header()first to set the TCP header. no skipping steps, iykyk. β οΈ
Definition at line 43 of file tcp.c.
π void * nfq_tcp_get_payload (struct tcphdr * tcph, struct pkt_buff * pktb)
nfq_tcp_get_payload β get the TCP packet payload. the goods. the actual content. the main character. β¨
Parameters
- tcph β pointer to the TCP header
- pktb β pointer to user-space network packet buffer
Returns
pointer to the TCP payload, or NULL if the packet is malformed. if it's malformed we simply do not engage. π
Definition at line 62 of file tcp.c.
π unsigned int nfq_tcp_get_payload_len (struct tcphdr * tcph, struct pkt_buff * pktb)
nfq_tcp_get_payload_len β get the tcp packet payload length. the how much of it all. π
Parameters
- tcph β pointer to the TCP header
- pktb β pointer to user-space network packet buffer
Returns
length of TCP payload (user data). that's the number, go off. π’
Definition at line 84 of file tcp.c.
π 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. yes bestie, mangle, as in mess with it on purpose. this is the glow-up function. π
β¨
Parameters
- pktb β pointer to network packet buffer
- match_offset β offset to content that you want to mangle
- match_len β length of the existing content you want to mangle
- rep_buffer β pointer to data you want to use to replace current content
- rep_len β length of data you want to use to replace current content
Returns
1 for success and 0 for failure. for the failure case, go see pktb_mangle(). π
Note
this function updates the IPv4 length and recalculates the IPv4 & TCP checksums for you. it's doing the math so you don't have to. angel behavior fr fr. ππ
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. like, BOTH directions, until they're synced again. do not forget this part, it WILL humble you. πβ οΈ
Definition at line 219 of file tcp.c.
π 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. capital M Mangle, she's fancy like that. πΈ
Parameters
- pktb β Pointer to network packet buffer
- match_offset β Offset from start of TCP data of content that you want to mangle
- match_len β Length of the existing content you want to mangle
- rep_buffer β Pointer to data you want to use to replace current content
- rep_len β Length of data you want to use to replace current content
Returns
1 for success and 0 for failure. failure case lives in pktb_mangle(), go check her out. π¦
Note
this function updates the IPv6 length and recalculates the TCP checksum for you. note: TCP checksum only this time, not IPv4, because IPv6 said "i got this." β¨
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. same warning, same energy, do not skip it. β οΈπ€
Definition at line 254 of file tcp.c.
π 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. (yes, "humnan", that's literally what the original says, i am not fixing her typo, she's perfect as she is. ππ)
Parameters
- buf β pointer to buffer that is used to print the object
- size β size of the buffer (or remaining room in it).
- tcph β pointer to a valid tcp header.
Returns
same as snprintf. that's the whole return value, she's consistent, she's loyal. π«Ά
See also
snprintf(3) β go read that one too bestie, it's the blueprint. π
Definition at line 160 of file tcp.c.
π¦ Author π¦
Generated automatically by Doxygen for libnetfilter_queue from the source code. so like, no human author to thank, just Doxygen doing her little automated thing. still iconic. π€π
libnetfilter_queue, Version 1.0.5, tcp(3) β and that's the whole page bestie!! π you read every single option, every parameter, every warning, every "Definition at line" β i'm so proud of you. go mangle some packets responsibly, and remember: mangle sequence numbers in BOTH directions until they're in sync again. no cap. πβ¨π¦πΈπππβπ₯π
π¦ where this page comes from
- ubuntu noble: libnetfilter-queue-doc 1.0.5-4build1 Β· GPL-2.0-or-later
- ubuntu questing: libnetfilter-queue-doc 1.0.5-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms