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 call nfq_ip_set_transport_header() or nfq_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 header
  • pktb β€” 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 header
  • pktb β€” 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 buffer
  • match_offset β€” Offset from start of UDP 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. 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 buffer
  • match_offset β€” Offset from start of UDP 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. 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 object
  • size β€” 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

snprintf(3)

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