Netlink message helper functions

## Functions

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)

## Detailed Description

## Function Documentation

## nflog_attr_put_cfg_cmd()

int nflog_attr_put_cfg_cmd | ( | struct nlmsghdr * | nlh,
|  | uint8_t | cmd )

nflog_attr_put_cfg_cmd - add a command attribute to nflog netlink message

Parameters

  nlh | pointer to netlink message
  cmd | one of the enum nfulnl_msg_config_cmds

Returns
  0

Definition at line 84 of file nlmsg.c.

## nflog_attr_put_cfg_mode()

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

  nlh | pointer to 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.

## nflog_nlmsg_parse()

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

nflog_nlmsg_parse - set nlattrs from netlink message

Parameters

  nlh | pointer to netlink message
  attr | pointer to an array of nlattr of size NFULA_MAX + 1

Returns
  0

Definition at line 162 of file nlmsg.c.

## nflog_nlmsg_put_header()

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

nflog_nlmsg_put_header - populate memory buffer with nflog Netlink headers

Parameters

  buf | pointer to memory buffer
  type | either NFULNL_MSG_PACKET or NFULNL_MSG_CONFIG (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

Returns
  pointer to created Netlink header structure

Definition at line 39 of file nlmsg.c.

## nflog_nlmsg_snprintf()

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

  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 tell 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.

Returns
  -1 on failure else same as snprintf

Errors
  EOPNOTSUPP type is unsupported (i.e. not NFLOG_OUTPUT_XML)

See also
  snprintf(3)

Definition at line 196 of file nlmsg.c.