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

# nflog\_nlmsg\_parse(3)

Netlink message helper functions

## NAME

nflog\_nlmsg\_put\_header, nflog\_attr\_put\_cfg\_mode, nflog\_attr\_put\_cfg\_cmd, nflog\_nlmsg\_parse, nflog\_nlmsg\_snprintf - Netlink message helper functions

## SYNOPSIS

```
#include <netinet/in.h>
#include <libnetfilter_log/libnetfilter_log.h>
struct nlmsghdr * nflog_nlmsg_put_header (char *buf, uint8_t type, uint8_t family, uint16_t gnum)
int nflog_attr_put_cfg_mode (struct nlmsghdr *nlh, uint8_t mode, uint32_t range)
int nflog_attr_put_cfg_cmd (struct nlmsghdr *nlh, uint8_t cmd)
int nflog_nlmsg_parse (const struct nlmsghdr *nlh, struct nlattr **attr)
int nflog_nlmsg_snprintf (char *buf, size_t bufsiz, const struct nlmsghdr *nlh, struct nlattr **attr, enum nflog_output_type type, uint32_t flags)
```

## Function Documentation

### int nflog\_attr\_put\_cfg\_cmd (struct nlmsghdr \* nlh, uint8\_t cmd)

**nflog\_attr\_put\_cfg\_cmd - add a command attribute to nflog netlink message**

**Parameters**

*nlh* **pointer to netlink message** \
 *cmd* **one of the enum nfulnl\_msg\_config\_cmds**

**Returns**

**0**

**Definition at line 84 of file nlmsg.c.**

### int nflog\_attr\_put\_cfg\_mode (struct nlmsghdr \* nlh, uint8\_t mode, uint32\_t range)

**nflog\_attr\_put\_cfg\_mode - add a mode attribute to nflog netlink message**

**Parameters**

*nlh* **pointer to netlink message** \
 *mode* **copy mode: NFULNL\_COPY\_NONE, NFULNL\_COPY\_META or NFULNL\_COPY\_PACKET** \
 *range* **copy range**

**Returns**

**0**

**Definition at line 64 of file nlmsg.c.**

### int nflog\_nlmsg\_parse (const struct nlmsghdr \* nlh, struct nlattr \*\* attr)

**nflog\_nlmsg\_parse - set nlattrs from netlink message**

**Parameters**

*nlh* **pointer to netlink message** \
 *attr* **pointer to an array of nlattr of size NFULA\_MAX + 1**

**Returns**

**0**

**Definition at line 162 of file nlmsg.c.**

### struct nlmsghdr \* nflog\_nlmsg\_put\_header (char \* buf, uint8\_t type, uint8\_t family, uint16\_t gnum)

**nflog\_nlmsg\_put\_header - populate memory buffer with nflog Netlink headers**

**Parameters**

*buf* **pointer to memory buffer** \
 *type* **either NFULNL\_MSG\_PACKET or NFULNL\_MSG\_CONFIG (enum nfulnl\_msg\_types)** \
 *family* **protocol family** \
 *gnum* **group number**

**Initialises** *buf* **to start with a netlink header for the log subsystem followed by an nfnetlink header with the log group**

**Returns**

**pointer to created Netlink header structure**

**Definition at line 39 of file nlmsg.c.**

### int nflog\_nlmsg\_snprintf (char \* buf, size\_t bufsiz, const struct nlmsghdr \* nlh, struct nlattr \*\* attr, enum nflog\_output\_type type, uint32\_t flags)

**nflog\_nlmsg\_snprintf - print a nflog nlattrs to a buffer**

**Parameters**

*buf* **buffer used to build the printable nflog** \
 *bufsiz* **size of the buffer** \
 *nlh* **pointer to netlink message (to get queue num in the future)** \
 *attr* **pointer to an array of nlattr of size NFULA\_MAX + 1** \
 *type* **print message type in enum nflog\_output\_type** \
 *flags* **The flag that tell what to print into the buffer**

**This function supports the following types / flags:**

**type: NFLOG\_OUTPUT\_XML**

- •

  **NFLOG\_XML\_PREFIX: include the string prefix**

- •

  **NFLOG\_XML\_HW: include the hardware link layer address**

- •

  **NFLOG\_XML\_MARK: include the packet mark**

- •

  **NFLOG\_XML\_DEV: include the device information**

- •

  **NFLOG\_XML\_PHYSDEV: include the physical device information**

- •

  **NFLOG\_XML\_PAYLOAD: include the payload (in hexadecimal)**

- •

  **NFLOG\_XML\_TIME: include the timestamp**

- •

  **NFLOG\_XML\_ALL: include all the logging information (all flags set)**

**You can combine these flags with a bitwise OR.**

**Returns**

**-1 on failure else same as snprintf**

**Errors**

**EOPNOTSUPP** *type* **is unsupported (i.e. not NFLOG\_OUTPUT\_XML)**

**See also**

**[snprintf(3)](/snprintf/3.md)**

**Definition at line 196 of file nlmsg.c.**

## Author

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