pktbuff(3)
π pktbuff β the user-space network packet buffer π
okay bestie, so pktbuff is a library function set from libnetfilter_queue and it's literally the moment your packets get a lil home in userspace π β¨
β¨ NAME β¨
pktbuff β user-space network packet buffer π«Ά
πΈ SYNOPSIS πΈ
π Modules
- Other functions
π¦ Functions
struct pkt_buff * pktb_alloc (int family, void *data, size_t len, size_t extra)
uint8_t * pktb_data (struct pkt_buff *pktb)
uint32_t pktb_len (struct pkt_buff *pktb)
void pktb_free (struct pkt_buff *pktb)
int pktb_mangle (struct pkt_buff *pktb, int dataoff, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
bool pktb_mangled (const struct pkt_buff *pktb)
π Detailed Description π
This library hands you the user-space network packet buffer. The whole abstraction is strongly inspired by the Linux kernel network buffer β you know, the one and only sk_buff π iykyk.
π Function Documentation π
β struct pkt_buff * pktb_alloc (int family, void * data, size_t len, size_t extra)
pktb_alloc β allocate a new packet buffer πΌβ¨
Parameters
familyβ tell it which family you're on. Currently supported families areAF_BRIDGE,AF_INET&AF_INET6. periodt.dataβ pointer to packet datalenβ packet lengthextraβ extra memory in the tail to be allocated (for mangling) πͺ
This function returns a packet buffer that contains the packet data and some extra memory room in the tail (if requested).
Returns
Pointer to a new userspace packet buffer or NULL on failure. π
Errors
ENOMEMβ fromcalloc()EPROTONOSUPPORTβfamilywasAF_BRIDGEand this is not an IP packet (v4 or v6)
See also
Definition at line 52 of file pktbuff.c.
β uint8_t * pktb_data (struct pkt_buff * pktb)
pktb_data β get pointer to network packet π
Parameters
pktbβ pointer to userspace packet buffer
Returns
Pointer to start of network packet data within pktb.
It is appropriate to use pktb_data as the second argument of nfq_nlmsg_verdict_put_pkt() π
Definition at line 105 of file pktbuff.c.
β void pktb_free (struct pkt_buff * pktb)
pktb_free β release packet buffer ποΈ
Parameters
pktbβ pointer to userspace packet buffer
Definition at line 129 of file pktbuff.c.
β uint32_t pktb_len (struct pkt_buff * pktb)
pktb_len β get length of packet buffer π
Parameters
pktbβ pointer to userspace packet buffer
Returns
Length of packet contained within pktb.
It is appropriate to use pktb_len as the third argument of nfq_nlmsg_verdict_put_pkt() π
Definition at line 119 of file pktbuff.c.
β int pktb_mangle (struct pkt_buff * pktb, int dataoff, unsigned int match_offset, unsigned int match_len, const char * rep_buffer, unsigned int rep_len)
pktb_mangle β adjust contents of a packet βοΈβ¨ (glow up but for bytes)
Parameters
pktbβ pointer to userspace packet bufferdataoffβ supplementary offset, usually the offset from the layer 3 (IP) header to the layer 4 (TCP or UDP) header. Specify zero to access the layer 3 header. Ifpktbwas created in familyAF_BRIDGE, specify-ETH_HLEN(a negative offset) to access the layer 2 (MAC) header.match_offsetβ further 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. Failure will occur if the extra argument to the pktb_alloc() call that created pktb is less than the excess of rep_len over match_len. π
Warning π¨ bestie listen to me:pktb_mangledoes not update any checksums. Developers should use the appropriate mangler for the protocol level:nfq_ip_mangle(),nfq_tcp_mangle_ipv4()ornfq_udp_mangle_ipv4(). IPv6 versions are planned. π
It is appropriate to use pktb_mangle to change the MAC header.
Definition at line 314 of file pktbuff.c.
β bool pktb_mangled (const struct pkt_buff * pktb)
pktb_mangled β test whether packet has been mangled π€
Parameters
pktbβ pointer to userspace packet buffer
Returns
true if packet has been mangled (modified), else false.
When assembling a verdict, it is not necessary to return the contents of un-modified packets. Use pktb_mangled to decide whether packet contents need to be returned. lowkey efficient π
Definition at line 359 of file pktbuff.c.
π Author π
Generated automatically by Doxygen for libnetfilter_queue from the source code. no cap, a robot wrote the author section and honestly? slay π€β¨
and that's the whole page bestie π«Ά this was Version 1.0.5, dated with the libnetfilter_queue manpage energy, and yes the footer said pktbuff(3) too β go forth and mangle responsibly πΈππ§
π¦ 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