ipv4(3)
๐ ipv4 โ IPv4 helper functions ๐
okay bestie, welcome to ipv4(3) from the Library Functions Manual โจ this is the lil squad of helper functions that deal with your IPv4 headers when you're messing around with libnetfilter_queue. she's short, she's sweet, she's giving "i know exactly what i'm doing" energy ๐
๐ธ SYNOPSIS ๐ธ
๐ฆ Modules
Internal IP 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)
int nfq_ip_mangle (struct pkt_buff *pktb, 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 โจ
no cap, this is where the real tea lives ๐ scroll down for the actual function docs, they're all here, nothing skipped, we're doing this properly fr fr ๐
๐ Function Documentation ๐
๐ซถ struct iphdr * nfq_ip_get_hdr (struct pkt_buff * pktb)
nfq_ip_get_hdr โ get the IPv4 header ๐
Parameters
pktbโ Pointer to user-space network packet buffer
Returns
a validated pointer to the IPv4 header, or NULL if the IP is malformed or it's not version 4 ๐ญ
lowkey most programs will not need to call this function. a possible use is to figure out what the layer 4 protocol is ๐ง the validation here is that the buffer is big enough for the declared lengths in the header, i.e. it's an extra check for packet truncation.
Definition at line 40 of file ipv4.c.
๐ฅ int nfq_ip_mangle (struct pkt_buff * pktb, 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
pktbโ Pointer to user-space network packet bufferdataoffโ Offset to layer 4 header, or zero to mangle IP headermatch_offsetโ Offset to content that you want to manglematch_lenโ Length of the existing content you want to manglerep_bufferโ Pointer to data you want to use to replace current contentrep_lenโ Length of data you want to use to replace current content
Returns
1 for success and 0 for failure. see pktb_mangle() for the failure case ๐
Note
this function updates the IPv4 length if necessary and recalculates the IPv4 checksum. so yeah, she's doing the math for you, iconic behavior fr ๐งฎโจ
Definition at line 127 of file ipv4.c.
๐ int nfq_ip_set_transport_header (struct pkt_buff * pktb, struct iphdr * iph)
nfq_ip_set_transport_header โ set the transport_header field in pktb ๐ฆ
Parameters
pktbโ Pointer to user-space network packet bufferiphโ Pointer to the IPv4 header
Returns
0 on success or -1 if a minimal validation check fails ๐ฌ
Note
most programs should callnfq_ip_set_transport_headeras soon as possible, because most layer 4 helper functions assume thetransport_headerfield is valid. like, they assume it. don't leave them hanging bestie ๐ซถ
Definition at line 73 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
bufโ Pointer to buffer that will be used to print the headersizeโ Size of the buffer (or remaining room in it)iphโ Pointer to a valid IPv4 header
Returns
same as snprintf ๐ซ
See also
Definition at line 153 of file ipv4.c.
๐ Author ๐
Generated automatically by Doxygen for libnetfilter_queue from the source code. (yes bestie, a robot wrote this one, and honestly? she ate ๐ค๐)
and that's the whole page, no crumbs left, we kept every detail, every param, every return value, every line number ๐
libnetfilter_queue ยท Version 1.0.5 ยท ipv4(3) โ mwah, go forth and mangle responsibly, ily ๐โจ๐ฆ
๐ฆ 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