libnetfilter_log  1.0.1
Functions
Netlink message helper functions

Functions

struct nlmsghdr * nflog_nlmsg_put_header (char *buf, uint8_t type, uint8_t family, uint16_t qnum)
 
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)
 

Detailed Description

Function Documentation

int nflog_attr_put_cfg_cmd ( struct nlmsghdr *  nlh,
uint8_t  cmd 
)

nflog_attr_put_cfg_cmd - add a cmd attribute to nflog netlink message

Parameters
nlhpointer to the netlink message
cmdcommand one of the enum nfulnl_msg_config_cmds

this function returns -1 and errno is explicitly set on error. On success, this function returns 1.

Definition at line 78 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
nlhpointer to the netlink message
modecopy mode defined in linux/netfilter/nfnetlink_log.h
rangecopy range

this function returns -1 and errno is explicitly set on error. On success, this function returns 1.

Definition at line 57 of file nlmsg.c.

int nflog_nlmsg_parse ( const struct nlmsghdr *  nlh,
struct nlattr **  attr 
)

nflog_nlmsg_parse - set nlattrs from netlink message

Parameters
nlhnetlink message that you want to read.
attrpointer to the array of nlattr which size is NFULA_MAX + 1

This function returns MNL_CB_ERROR if any error occurs, or MNL_CB_OK on success.

Definition at line 157 of file nlmsg.c.

struct nlmsghdr* nflog_nlmsg_put_header ( char *  buf,
uint8_t  type,
uint8_t  family,
uint16_t  qnum 
)

nflog_nlmsg_put_header - reserve and prepare room for nflog Netlink header

Parameters
bufmemory already allocated to store the Netlink header
typemessage type one of the enum nfulnl_msg_types
familyprotocol family to be an object of
qnumqueue number to be an object of

This function creates Netlink header in the memory buffer passed as parameter that will send to nfnetlink log. This function returns a pointer to the Netlink header structure.

Definition at line 32 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
bufbuffer used to build the printable nflog
bufsizsize of the buffer
nlhnetlink message (to get queue num in the futuer)
attrpointer to a nflog attrs
typeprint message type in enum nflog_output_type
flagsThe flag that tell what to print into the buffer

This function supports the following type - 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 this flags with an binary OR.

this function returns -1 and errno is explicitly set in case of failure, otherwise the length of the string that would have been printed into the buffer (in case that there is enough room in it). See snprintf() return value for more information.

Definition at line 191 of file nlmsg.c.