libnetfilter_acct  1.0.3
Functions
Netlink message helper functions

Functions

struct nlmsghdr * nfacct_nlmsg_build_hdr (char *buf, uint8_t cmd, uint16_t flags, uint32_t seq)
 
void nfacct_nlmsg_build_payload (struct nlmsghdr *nlh, struct nfacct *nfacct)
 
int nfacct_nlmsg_parse_payload (const struct nlmsghdr *nlh, struct nfacct *nfacct)
 

Detailed Description

Function Documentation

struct nlmsghdr* nfacct_nlmsg_build_hdr ( char *  buf,
uint8_t  cmd,
uint16_t  flags,
uint32_t  seq 
)

nfacct_nlmsg_build_hdr - build netlink message header for nfacct subsystem

Parameters
bufbuffer where this function outputs the netlink message.
cmdnfacct nfnetlink command.
flagsnetlink flags.
seqsequence number for this message.

Possible commands:

  • NFNL_MSG_ACCT_NEW: new accounting object.
  • NFNL_MSG_ACCT_GET: get accounting object.
  • NFNL_MSG_ACCT_GET_CTRZERO: get accounting object and atomically reset.

Examples:

  • Command NFNL_MSG_ACCT_NEW + flags NLM_F_CREATE | NLM_F_ACK, to create one new accounting object (if it does not already exists). You receive one acknoledgment in any case with the result of the operation.
  • Command NFNL_MSG_ACCT_GET + flags NLM_F_DUMP, to obtain all the existing accounting objects.
  • Command NFNL_MSG_ACCT_GET_CTRZERO + flags NLM_F_DUMP, to atomically obtain all the existing accounting objects and reset them.
  • Command NFNL_MSG_ACCT_DEL, to delete all existing unused objects.
  • Command NFNL_MSG_ACCT_DEL, to delete one specific nfacct object (if unused, otherwise you hit EBUSY).

Definition at line 488 of file libnetfilter_acct.c.

void nfacct_nlmsg_build_payload ( struct nlmsghdr *  nlh,
struct nfacct *  nfacct 
)

nfacct_nlmsg_build_payload - build payload from accounting object

Parameters
nlhnetlink message that you want to use to add the payload.
nfacctpointer to a accounting object

Definition at line 512 of file libnetfilter_acct.c.

int nfacct_nlmsg_parse_payload ( const struct nlmsghdr *  nlh,
struct nfacct *  nfacct 
)

nfacct_nlmsg_parse_payload - set accounting object attributes from message

Parameters
nlhnetlink message that you want to use to add the payload.
nfacctpointer to a accounting object

This function returns -1 in case that some mandatory attributes are missing. On sucess, it returns 0.

Definition at line 567 of file libnetfilter_acct.c.