udp(3)
β¨ udp(3) β UDP helper functions π
Library Functions Manual Β· udp Β· bestie you're in the right place π«Ά
πΈ NAME πΈ
udp β UDP helper functions. That's it, that's the whole vibe. These are the little besties that crack open UDP packets for you: grab the header, grab the payload, measure the payload, and (my personal fave) mangle stuff inside IPv4 and IPv6 UDP packets like it's nothing. π₯
β¨ SYNOPSIS β¨
π¦ Modules
- Internal UDP functions β yes bestie, the internal ones, they live here
π οΈ Functions
struct udphdr * nfq_udp_get_hdr (struct pkt_buff *pktb)
void * nfq_udp_get_payload (struct udphdr *udph, struct pkt_buff *pktb)
unsigned int nfq_udp_get_payload_len (struct udphdr *udph, struct pkt_buff *pktb)
int nfq_udp_mangle_ipv4 (struct pkt_buff *pktb, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
int nfq_udp_mangle_ipv6 (struct pkt_buff *pktb, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
int nfq_udp_snprintf (char *buf, size_t size, const struct udphdr *udph)
π¦ Detailed Description π¦
Okay so, this is the UDP corner of the library. Everything you need to poke at a UDP packet inside a pkt_buff β get its header, get its payload, find out how long that payload is, rewrite bytes inside it, and pretty-print the header. The functions are documented one by one down below. Scroll, bestie. π
π Function Documentation π
π struct udphdr * nfq_udp_get_hdr (struct pkt_buff * pktb)
nfq_udp_get_hdr β get the UDP header.
Parameters
pktbβ Pointer to userspace network packet buffer
Returns
A validated pointer to the UDP header, or NULL if the UDP header was not set, or if a minimal length check fails. So likeβ¦ always check for NULL, okay? π
Note: You have to callnfq_ip_set_transport_header()ornfq_ip6_set_transport_header()first to set the UDP header. No skipping steps, bestie, that's the rules. π
Definition at line 43 of file udp.c.
π void * nfq_udp_get_payload (struct udphdr * udph, struct pkt_buff * pktb)
nfq_udp_get_payload β get the UDP packet payload.
Parameters
udphβ Pointer to UDP headerpktbβ Pointer to userspace network packet buffer
Returns
Pointer to the UDP payload, or NULL if malformed UDP packet. A malformed packet is giving π© energy, so handle it.
Definition at line 62 of file udp.c.
π unsigned int nfq_udp_get_payload_len (struct udphdr * udph, struct pkt_buff * pktb)
nfq_udp_get_payload_len β get the udp packet payload.
Parameters
udphβ Pointer to UDP headerpktbβ Pointer to userspace network packet buffer
Returns
Length of UDP payload (user data). Just the number. Clean, simple, iconic. β¨
Definition at line 84 of file udp.c.
π₯ int nfq_udp_mangle_ipv4 (struct pkt_buff * pktb, unsigned int match_offset, unsigned int match_len, const char * rep_buffer, unsigned int rep_len)
nfq_udp_mangle_ipv4 β Mangle UDP/IPv4 packet buffer. Yes, mangle. It's giving main character energy and it fully ate. π
Parameters
pktbβ Pointer to network packet buffermatch_offsetβ Offset from start of UDP data of 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 failure case.
Note: This function updates the IPv4 and UDP lengths and recalculates their checksums for you. So you literally don't have to do the math. Obsessed. π
Definition at line 150 of file udp.c.
π int nfq_udp_mangle_ipv6 (struct pkt_buff * pktb, unsigned int match_offset, unsigned int match_len, const char * rep_buffer, unsigned int rep_len)
nfq_udp_mangle_ipv6 β Mangle UDP/IPv6 packet buffer. Same energy, next-gen address family. π
Parameters
pktbβ Pointer to network packet buffermatch_offsetβ Offset from start of UDP data of 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 failure case.
Note: This function updates the IPv6 and UDP lengths and recalculates the UDP checksum for you. β¨ (Just the UDP checksum, bestie β read it again, I said what I said.)
Definition at line 184 of file udp.c.
π int nfq_udp_snprintf (char * buf, size_t size, const struct udphdr * udph)
nfq_pkt_snprintf_udp_hdr β print udp header into one buffer in a humnan readable way. (That typo is in the source, and honestly? It's giving "humnan" and we respect it. π«Ά)
Parameters
bufβ pointer to buffer that is used to print the objectsizeβ size of the buffer (or remaining room in it).udphβ pointer to a valid udp header.
Returns
The number of characters notionally written (excluding trailing NUL).
See also
Definition at line 220 of file udp.c.
π Author π
Generated automatically by Doxygen for libnetfilter_queue from the source code. Not a human, not a girlie, just a doc generator doing its little thing. π€β¨
This was udp(3) from libnetfilter_queue, Version 1.0.5. That's the whole page, bestie β go forth and mangle some packets responsibly. Byeee! πππ¦πΈπ
π¦ 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