nlmsg(3)

okay so this is the manual page for nlmsg from the libnetfilter_log library (that's the 3 in the name β€” it's a library function, not a command, iykyk). it's the whole Netlink message helper situation. buckle up, there's a lot of cute little functions in here and we're gonna go through every single one. πŸŽ€


✨ 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 β€” adds a command attribute to an nflog netlink message. literally just slots that command in there, no cap. ✨

Parameters

  • nlh β€” pointer to the 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 β€” adds a mode attribute to an nflog netlink message. the vibe-setter of attributes fr fr. πŸ’–

Parameters

  • nlh β€” pointer to the 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 β€” sets the nlattrs from a netlink message. it's giving "unpack the message, bestie". 🧚

Parameters

  • nlh β€” pointer to the 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 β€” populates a memory buffer with nflog Netlink headers. it's the header-glow-up function. ✨

Parameters

  • buf β€” pointer to memory buffer
  • type β€” either NFULNL_MSG_PACKET or NFULNL_MSG_CONFIG (that's the 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. iconic behaviour honestly.

Returns

pointer to the 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 β€” prints nflog nlattrs into a buffer. the main character of this whole page ngl. πŸ’…

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 tells 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. stack 'em, bestie. 🫢

Returns

-1 on failure, else same as snprintf

Errors

EOPNOTSUPP β€” type is unsupported (i.e. not NFLOG_OUTPUT_XML)

ok so heads up: if you pass a type that isn't NFLOG_OUTPUT_XML, you get EOPNOTSUPP and that's it, that's the whole list. no other types live here yet. 😭

See also

snprintf(3)

Definition at line 196 of file nlmsg.c.


🌟 Author 🌟

Generated automatically by Doxygen for libnetfilter_log from the source code. (yes, a robot wrote it, and honestly? it ate. πŸ’…)


and that's the whole page bestie!! tysm for reading, love u, go write some netlink messages πŸ’–

libnetfilter_log β€” Version 1.0.2 🌸 β€” mwah, that's the sign-off, periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from