libnetfilter_log  1.0.1
Functions
Message parsing functions

Functions

struct nfulnl_msg_packet_hdr * nflog_get_msg_packet_hdr (struct nflog_data *nfad)
 
u_int16_t nflog_get_hwtype (struct nflog_data *nfad)
 
u_int16_t nflog_get_msg_packet_hwhdrlen (struct nflog_data *nfad)
 
char * nflog_get_msg_packet_hwhdr (struct nflog_data *nfad)
 
u_int32_t nflog_get_nfmark (struct nflog_data *nfad)
 
int nflog_get_timestamp (struct nflog_data *nfad, struct timeval *tv)
 
u_int32_t nflog_get_indev (struct nflog_data *nfad)
 
u_int32_t nflog_get_physindev (struct nflog_data *nfad)
 
u_int32_t nflog_get_outdev (struct nflog_data *nfad)
 
u_int32_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, u_int32_t *uid)
 
int nflog_get_gid (struct nflog_data *nfad, u_int32_t *gid)
 
int nflog_get_seq (struct nflog_data *nfad, u_int32_t *seq)
 
int nflog_get_seq_global (struct nflog_data *nfad, u_int32_t *seq)
 

Detailed Description

Function Documentation

◆ nflog_get_gid()

int nflog_get_gid ( struct nflog_data nfad,
u_int32_t *  gid 
)

nflog_get_gid - get the GID of the user that has generated the packet

Parameters
nfadNetlink packet data handle passed to callback function
Returns
the GID of the user that has genered the packet, if any.

Definition at line 835 of file libnetfilter_log.c.

◆ nflog_get_hwtype()

u_int16_t nflog_get_hwtype ( struct nflog_data nfad)

nflog_get_hwtype - get the hardware link layer type from logging data

Parameters
nfadpointer to logging data
Returns
the hardware link layer type.

Definition at line 637 of file libnetfilter_log.c.

◆ nflog_get_indev()

u_int32_t nflog_get_indev ( struct nflog_data nfad)

nflog_get_indev - get the interface that the packet was received through

Parameters
nfadNetlink 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?).
Warning
all nflog_get_dev() functions return 0 if not set, since linux only allows ifindex >= 1, see net/core/dev.c:2600 (in 2.6.13.1)

Definition at line 710 of file libnetfilter_log.c.

◆ nflog_get_msg_packet_hdr()

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
nfadNetlink 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().

The nfulnl_msg_packet_hdr structure is defined in libnetfilter_log.h as:

        struct nfulnl_msg_packet_hdr {
                u_int16_t       hw_protocol;    // hw protocol (network order)
                u_int8_t        hook;           // netfilter hook
                u_int8_t        _pad;
        } __attribute__ ((packed));

Definition at line 625 of file libnetfilter_log.c.

◆ nflog_get_msg_packet_hwhdr()

char* nflog_get_msg_packet_hwhdr ( struct nflog_data nfad)

nflog_get_msg_packet_hwhdr - get the hardware link layer header

Parameters
nfadpointer to logging data
Returns
the hardware link layer header

Definition at line 659 of file libnetfilter_log.c.

◆ nflog_get_msg_packet_hwhdrlen()

u_int16_t nflog_get_msg_packet_hwhdrlen ( struct nflog_data nfad)

nflog_get_hwhdrlen - get the length of the hardware link layer header

Parameters
nfadpointer to logging data
Returns
the size of the hardware link layer header

Definition at line 648 of file libnetfilter_log.c.

◆ nflog_get_nfmark()

u_int32_t nflog_get_nfmark ( struct nflog_data nfad)

nflog_get_nfmark - get the packet mark

Parameters
nfadNetlink packet data handle passed to callback function
Returns
the netfilter mark currently assigned to the logged packet.

Definition at line 670 of file libnetfilter_log.c.

◆ nflog_get_outdev()

u_int32_t nflog_get_outdev ( struct nflog_data nfad)

nflog_get_outdev - gets the interface that the packet will be routed out

Parameters
nfadNetlink packet data handle passed to callback function
Returns
The index of the device the packet will be sent out. If the returned index is 0, the packet is destined for localhost or the output interface is not yet known (ie. PREROUTING?).

Definition at line 736 of file libnetfilter_log.c.

◆ nflog_get_packet_hw()

struct nfulnl_msg_packet_hw* nflog_get_packet_hw ( struct nflog_data nfad)

nflog_get_packet_hw - get hardware address

Parameters
nfadNetlink 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.

The nfulnl_msg_packet_hw structure is defined in libnetfilter_log.h as:

        struct nfulnl_msg_packet_hw {
                u_int16_t       hw_addrlen;
                u_int16_t       _pad;
                u_int8_t        hw_addr[8];
        } __attribute__ ((packed));

Definition at line 776 of file libnetfilter_log.c.

◆ nflog_get_payload()

int nflog_get_payload ( struct nflog_data nfad,
char **  data 
)

nflog_get_payload - get payload of the logged packet

Parameters
nfadNetlink packet data handle passed to callback function
dataPointer 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.

Returns
-1 on error, otherwise > 0.

Definition at line 793 of file libnetfilter_log.c.

◆ nflog_get_physindev()

u_int32_t nflog_get_physindev ( struct nflog_data nfad)

nflog_get_physindev - get the physical interface that the packet was received

Parameters
nfadNetlink 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?).

Definition at line 723 of file libnetfilter_log.c.

◆ nflog_get_physoutdev()

u_int32_t nflog_get_physoutdev ( struct nflog_data nfad)

nflog_get_physoutdev - get the physical interface that the packet output

Parameters
nfadNetlink packet data handle passed to callback function

The index of the physical device the packet will be sent out. If the returned index is 0, the packet is destined for localhost or the physical output interface is not yet known (ie. PREROUTING?).

Returns
The index of physical interface that the packet output will be routed out.

Definition at line 752 of file libnetfilter_log.c.

◆ nflog_get_prefix()

char* nflog_get_prefix ( struct nflog_data nfad)

nflog_get_prefix - get the logging string prefix

Parameters
nfadNetlink packet data handle passed to callback function
Returns
the string prefix that is specified as argument to the iptables' NFLOG target.

Definition at line 809 of file libnetfilter_log.c.

◆ nflog_get_seq()

int nflog_get_seq ( struct nflog_data nfad,
u_int32_t *  seq 
)

nflog_get_seq - get the local nflog sequence number

Parameters
nfadNetlink packet data handle passed to callback function

You must enable this via nflog_set_flags().

Returns
the local nflog sequence number.

Definition at line 852 of file libnetfilter_log.c.

◆ nflog_get_seq_global()

int nflog_get_seq_global ( struct nflog_data nfad,
u_int32_t *  seq 
)

nflog_get_seq_global - get the global nflog sequence number

Parameters
nfadNetlink packet data handle passed to callback function

You must enable this via nflog_set_flags().

Returns
the global nflog sequence number.

Definition at line 869 of file libnetfilter_log.c.

◆ nflog_get_timestamp()

int nflog_get_timestamp ( struct nflog_data nfad,
struct timeval *  tv 
)

nflog_get_timestamp - get the packet timestamp

Parameters
nfadNetlink packet data handle passed to callback function
tvstructure to fill with timestamp info

Retrieves the received timestamp when the given logged packet.

Returns
0 on success, a negative value on failure.

Definition at line 684 of file libnetfilter_log.c.

◆ nflog_get_uid()

int nflog_get_uid ( struct nflog_data nfad,
u_int32_t *  uid 
)

nflog_get_uid - get the UID of the user that has generated the packet

Parameters
nfadNetlink packet data handle passed to callback function
Returns
the UID of the user that has genered the packet, if any.

Definition at line 820 of file libnetfilter_log.c.