Parsing(3)
π Parsing(3) π
okay bestie, welcome to the Parsing page of the libnetfilter_log library functions manual, and honestly? it's giving "lowkey crucial". buckle up π
β¨ NAME β¨
nflog_get_msg_packet_hdr, nflog_get_hwtype, nflog_get_msg_packet_hwhdrlen, nflog_get_msg_packet_hwhdr, nflog_get_nfmark, nflog_get_timestamp, nflog_get_indev, nflog_get_physindev, nflog_get_outdev, nflog_get_physoutdev, nflog_get_packet_hw, nflog_get_payload, nflog_get_prefix, nflog_get_uid, nflog_get_gid, nflog_get_seq, nflog_get_seq_global, nflog_get_ctid β these are the Message parsing functions, and yes that's a whole squad, not a typo π
β¨ SYNOPSIS β¨
#include <stddef.h>
#include <libnetfilter_log/libnetfilter_log.h>
struct nfulnl_msg_packet_hdr * nflog_get_msg_packet_hdr (struct nflog_data *nfad)
uint16_t nflog_get_hwtype (struct nflog_data *nfad)
uint16_t nflog_get_msg_packet_hwhdrlen (struct nflog_data *nfad)
char * nflog_get_msg_packet_hwhdr (struct nflog_data *nfad)
uint32_t nflog_get_nfmark (struct nflog_data *nfad)
int nflog_get_timestamp (struct nflog_data *nfad, struct timeval *tv)
uint32_t nflog_get_indev (struct nflog_data *nfad)
uint32_t nflog_get_physindev (struct nflog_data *nfad)
uint32_t nflog_get_outdev (struct nflog_data *nfad)
uint32_t nflog_get_physoutdev (struct nflog_data *nfad)
struct nfulnl_msg_packet_hw * nflog_get_packet_hw (struct nflog_data *nfad)
int nflog_get_payload (struct nflog_data *nfad, char **data)
char * nflog_get_prefix (struct nflog_data *nfad)
int nflog_get_uid (struct nflog_data *nfad, uint32_t *uid)
int nflog_get_gid (struct nflog_data *nfad, uint32_t *gid)
int nflog_get_seq (struct nflog_data *nfad, uint32_t *seq)
int nflog_get_seq_global (struct nflog_data *nfad, uint32_t *seq)
int nflog_get_ctid (struct nflog_data *nfad, uint32_t *id)
β¨ Function Documentation β¨
okay now the main event β one by one, no skips, we're covering everybody π«Ά
πΈ int nflog_get_ctid (struct nflog_data * nfad, uint32_t * id)
nflog_get_ct_id β grab the conntrack id, bestie π¦
Parameters
- nfad β the Netlink packet data handle that got passed to your callback function
- id β the conntrack id, but only if the function returns zero
β οΈ you must enable this via nflog_set_flags(). no flags, no ctid, periodt.
Returns
0 on success, or -1 if conntrack itself or its id was unavailable π
Definition at line 990 of file libnetfilter_log.c.
πΈ int nflog_get_gid (struct nflog_data * nfad, uint32_t * gid)
nflog_get_gid β get the GID of the user that has generated the packet π
Parameters
- nfad β the Netlink packet data handle passed to your callback function
- gid β the GID of the user that generated the packet, if the function returns zero
Returns
0 on success, or -1 if the GID was unavailable (and heads up, gid is then invalid π)
Definition at line 932 of file libnetfilter_log.c.
πΈ uint16_t nflog_get_hwtype (struct nflog_data * nfad)
nflog_get_hwtype β get the hardware link layer type from the logging data π
Parameters
- nfad β pointer to logging data
Returns
the hardware link layer type β¨
Definition at line 724 of file libnetfilter_log.c.
πΈ uint32_t nflog_get_indev (struct nflog_data * nfad)
nflog_get_indev β get the interface that the packet was received through π
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
The index of the device the packet was received via. If the returned index is 0, the packet was locally generated or the input interface is not known (ie. POSTROUTING?). no cap, it's just vibes and mystery at that point π«
β οΈ Warning: allnflog_get_dev()functions return0if not set, since Linux only allowsifindex >= 1, seenet/core/dev.c:9819(in5.14.3). iconic of Linux tbh.
Definition at line 799 of file libnetfilter_log.c.
πΈ struct nfulnl_msg_packet_hdr * nflog_get_msg_packet_hdr (struct nflog_data * nfad)
nflog_get_msg_packet_hdr β return the metaheader that wraps the packet π
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
the netfilter log netlink packet header for the given nflog_data argument. Typically, the nflog_data value is passed as the 3rd parameter to the callback function set by a call to nflog_callback_register(). iykyk π
The nfulnl_msg_packet_hdr structure is defined in libnetfilter_log.h as:
struct nfulnl_msg_packet_hdr {
uint16_t hw_protocol; // hw protocol (network order)
uint8_t hook; // netfilter hook
uint8_t _pad;
} __attribute__ ((packed));
Definition at line 712 of file libnetfilter_log.c.
πΈ char * nflog_get_msg_packet_hwhdr (struct nflog_data * nfad)
nflog_get_msg_packet_hwhdr β get the hardware link layer header π¦
Parameters
- nfad β pointer to logging data
Returns
the hardware link layer header π
Definition at line 746 of file libnetfilter_log.c.
πΈ uint16_t nflog_get_msg_packet_hwhdrlen (struct nflog_data * nfad)
nflog_get_hwhdrlen β get the length of the hardware link layer header π
Parameters
- nfad β pointer to logging data
Returns
the size of the hardware link layer header β¨
Definition at line 735 of file libnetfilter_log.c.
πΈ uint32_t nflog_get_nfmark (struct nflog_data * nfad)
nflog_get_nfmark β get the packet mark π₯
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
the netfilter mark currently assigned to the logged packet π
Definition at line 757 of file libnetfilter_log.c.
πΈ uint32_t nflog_get_outdev (struct nflog_data * nfad)
nflog_get_outdev β gets the interface that the packet will be routed to π
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
The index of the device the packet will be sent to. If the returned index is 0, the packet is destined for localhost or the output interface is not yet known (ie. PREROUTING?). the future is unknowable sometimes bestie π
Definition at line 826 of file libnetfilter_log.c.
πΈ struct nfulnl_msg_packet_hw * nflog_get_packet_hw (struct nflog_data * nfad)
nflog_get_packet_hw β get hardware address πΈ
Parameters
- nfad β Netlink packet data handle passed to callback function
Retrieves the hardware address associated with the given packet. For ethernet packets, the hardware address returned (if any) will be the MAC address of the packet source host. The destination MAC address is not known until after POSTROUTING and a successful ARP request, so cannot currently be retrieved. yeah, that one's just not available yet, don't come for me π
The nfulnl_msg_packet_hw structure is defined in libnetfilter_log.h as:
struct nfulnl_msg_packet_hw {
uint16_t hw_addrlen; // Network Byte Order
uint16_t _pad;
uint8_t hw_addr[8];
} __attribute__ ((packed));
Returns
Pointer to struct nfulnl_msg_packet_hw from originating host or NULL if none available (e.g. locally-originated packet not for lo interface). π
Definition at line 867 of file libnetfilter_log.c.
πΈ int nflog_get_payload (struct nflog_data * nfad, char ** data)
nflog_get_payload β get payload of the logged packet π¦
Parameters
- nfad β Netlink packet data handle passed to callback function
- data β Pointer of pointer that will be pointed to the payload
Retrieve the payload for a logged packet. The actual amount and type of data retrieved by this function will depend on the mode set with the nflog_set_mode() function. so like, mode matters, okay? π
Returns
payload length, or -1 if this is not available π
Definition at line 884 of file libnetfilter_log.c.
πΈ uint32_t nflog_get_physindev (struct nflog_data * nfad)
nflog_get_physindev β get the physical interface that the packet was received through π
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
The index of the physical device the packet was received via. If the returned index is 0, the packet was locally generated or the physical input interface is no longer known (ie. POSTROUTING?). girl, it forgor π
Definition at line 813 of file libnetfilter_log.c.
πΈ uint32_t nflog_get_physoutdev (struct nflog_data * nfad)
nflog_get_physoutdev β get the physical interface for packet output π
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
Index of physical device the packet will be routed to. If the returned index is 0, the packet is destined for localhost or the physical output interface is not yet known (ie. PREROUTING?). still cooking π
Definition at line 839 of file libnetfilter_log.c.
πΈ char * nflog_get_prefix (struct nflog_data * nfad)
nflog_get_prefix β get the logging string prefix π·οΈ
Parameters
- nfad β Netlink packet data handle passed to callback function
Returns
the string prefix that is specified as argument to the iptables' NFLOG target or NULL if this is not available β¨
Definition at line 900 of file libnetfilter_log.c.
πΈ int nflog_get_seq (struct nflog_data * nfad, uint32_t * seq)
nflog_get_seq β get the local nflog sequence number π’
Parameters
- nfad β Netlink packet data handle passed to callback function
- seq β local nflog sequence number, if the function returns zero
β οΈ you must enable this via nflog_set_flags(). periodt.
Returns
0 on success, or -1 if the sequence number was unavailable (seq is then invalid π)
Definition at line 952 of file libnetfilter_log.c.
πΈ int nflog_get_seq_global (struct nflog_data * nfad, uint32_t * seq)
nflog_get_seq_global β get the global nflog sequence number π
Parameters
- nfad β Netlink packet data handle passed to callback function
- seq β global nflog sequence number, if the function returns zero
β οΈ you must enable this via nflog_set_flags(). no flags, no seq, bestie.
Returns
0 on success, or -1 if the sequence number was unavailable (seq is then invalid π)
Definition at line 972 of file libnetfilter_log.c.
πΈ int nflog_get_timestamp (struct nflog_data * nfad, struct timeval * tv)
nflog_get_timestamp β get the packet timestamp β°
Parameters
- nfad β Netlink packet data handle passed to callback function
- tv β structure to fill with timestamp info
Retrieves the received timestamp from the given logged packet. so it's giving "when did this happen" energy π
Returns
0 on success, -1 on failure with errno set.
Errors
from underlying calls, in exceptional circumstances π
Definition at line 773 of file libnetfilter_log.c.
πΈ int nflog_get_uid (struct nflog_data * nfad, uint32_t * uid)
nflog_get_uid β get the UID of the user that generated the packet π
Parameters
- nfad β Netlink packet data handle passed to callback function
- uid β UID of the user that generated the packet, if the function returns zero
Returns
0 on success, or -1 if the UID was unavailable (uid is then invalid π)
Definition at line 914 of file libnetfilter_log.c.
β¨ Author β¨
Generated automatically by Doxygen for libnetfilter_log from the source code. π€ (yes, the robots wrote this one, and honestly? they ate.)
and that's the whole page bestie, every single function accounted for, nothing skipped, we ate and left no crumbs π β¨ this was libnetfilter_log, Version 1.0.2, and you just read Parsing(3) β stay slaying, go parse some packets, mwah π«Άππ¦
π¦ 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