---
name: "nfq_udp_mangle_ipv6"
section: "3"
platform: "linux"
package: "libnetfilter-queue-doc"
version: "1.0.5-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/nfq_udp_get_hdr"
---

# nfq\_udp\_mangle\_ipv6(3)

UDP helper functions

Part of [nfq\_udp\_get\_hdr(3)](/nfq_udp_get_hdr/3.md).

## NAME

udp - UDP helper functions

## SYNOPSIS

### Modules

**Internal UDP functions**\

### 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

## 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**

validated pointer to the UDP header or NULL if the UDP header was not set or if a minimal length check fails.

**Note**

You have to call **nfq\_ip\_set\_transport\_header()** or **nfq\_ip6\_set\_transport\_header()** first to set the UDP header.

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.

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)

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

**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.

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

**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.

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

**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)](/snprintf/3.md)

Definition at line **220** of file **udp.c**.

## Author

Generated automatically by Doxygen for libnetfilter\_queue from the source code.
