libnetfilter_acct  1.0.3
libnetfilter_acct.h
1 #ifndef _LIBNETFILTER_ACCT_H_
2 #define _LIBNETFILTER_ACCT_H_
3 
4 #include <stdint.h>
5 #include <linux/netfilter/nfnetlink_acct.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 struct nfacct;
12 
13 enum nfacct_attr_type {
14  NFACCT_ATTR_NAME = 0,
15  NFACCT_ATTR_PKTS,
16  NFACCT_ATTR_BYTES,
17  NFACCT_ATTR_FLAGS,
18  NFACCT_ATTR_QUOTA,
19 };
20 
21 struct nfacct *nfacct_alloc(void);
22 void nfacct_free(struct nfacct *nfacct);
23 
24 void nfacct_attr_set(struct nfacct *nfacct, enum nfacct_attr_type type, const void *data);
25 void nfacct_attr_set_str(struct nfacct *nfacct, enum nfacct_attr_type type, const char *name);
26 void nfacct_attr_set_u64(struct nfacct *nfacct, enum nfacct_attr_type type, uint64_t value);
27 void nfacct_attr_unset(struct nfacct *nfacct, enum nfacct_attr_type type);
28 
29 const void *nfacct_attr_get(struct nfacct *nfacct, enum nfacct_attr_type type);
30 const char *nfacct_attr_get_str(struct nfacct *nfacct, enum nfacct_attr_type type);
31 uint64_t nfacct_attr_get_u64(struct nfacct *nfacct, enum nfacct_attr_type type);
32 
33 struct nlmsghdr;
34 
35 struct nlmsghdr *nfacct_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq);
36 void nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct);
37 int nfacct_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfacct *nfacct);
38 
39 #define NFACCT_SNPRINTF_F_FULL (1 << 0)
40 #define NFACCT_SNPRINTF_F_TIME (1 << 1)
41 
42 #define NFACCT_SNPRINTF_T_PLAIN 0
43 #define NFACCT_SNPRINTF_T_XML 1
44 #define NFACCT_SNPRINTF_T_JSON 2
45 
46 int nfacct_snprintf(char *buf, size_t size, struct nfacct *nfacct, uint16_t type, uint16_t flags);
47 
48 #ifdef __cplusplus
49 } /* extern "C" */
50 #endif
51 
52 #endif
const void * nfacct_attr_get(struct nfacct *nfacct, enum nfacct_attr_type type)
void nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct)
void nfacct_attr_set(struct nfacct *nfacct, enum nfacct_attr_type type, const void *data)
const char * nfacct_attr_get_str(struct nfacct *nfacct, enum nfacct_attr_type type)
void nfacct_attr_unset(struct nfacct *nfacct, enum nfacct_attr_type type)
void nfacct_free(struct nfacct *nfacct)
uint64_t nfacct_attr_get_u64(struct nfacct *nfacct, enum nfacct_attr_type type)
int nfacct_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfacct *nfacct)
struct nlmsghdr * nfacct_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq)
struct nfacct * nfacct_alloc(void)
int nfacct_snprintf(char *buf, size_t size, struct nfacct *nfacct, uint16_t type, uint16_t flags)
void nfacct_attr_set_str(struct nfacct *nfacct, enum nfacct_attr_type type, const char *name)
void nfacct_attr_set_u64(struct nfacct *nfacct, enum nfacct_attr_type type, uint64_t value)