nlmsg(3)
π nlmsg(3) β the Netlink message helper functions page, bestie π
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 messagecmdβ one of theenum 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 messagemodeβ copy mode:NFULNL_COPY_NONE,NFULNL_COPY_METAorNFULNL_COPY_PACKETrangeβ 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 messageattrβ pointer to an array ofnlattrof sizeNFULA_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 buffertypeβ eitherNFULNL_MSG_PACKETorNFULNL_MSG_CONFIG(that's theenum nfulnl_msg_types)familyβ protocol familygnumβ 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 nflogbufsizβ size of the buffernlhβ pointer to netlink message (to get queue num in the future)attrβ pointer to an array ofnlattrof sizeNFULA_MAX + 1typeβ print message type inenum nflog_output_typeflagsβ 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 prefixNFLOG_XML_HW: include the hardware link layer addressNFLOG_XML_MARK: include the packet markNFLOG_XML_DEV: include the device informationNFLOG_XML_PHYSDEV: include the physical device informationNFLOG_XML_PAYLOAD: include the payload (in hexadecimal)NFLOG_XML_TIME: include the timestampNFLOG_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'tNFLOG_OUTPUT_XML, you getEOPNOTSUPPand that's it, that's the whole list. no other types live here yet. π
See also
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
- ubuntu noble: libnetfilter-log-doc 1.0.2-4build1 Β· GPL-2.0-or-later
- ubuntu questing: libnetfilter-log-doc 1.0.2-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms