00001 #ifndef _LIBNETFILTER_ACCT_H_ 00002 #define _LIBNETFILTER_ACCT_H_ 00003 00004 #include <sys/types.h> 00005 #include <linux/netfilter/nfnetlink_acct.h> 00006 00007 struct nfacct; 00008 00009 enum nfacct_attr_type { 00010 NFACCT_ATTR_NAME = 0, 00011 NFACCT_ATTR_PKTS, 00012 NFACCT_ATTR_BYTES, 00013 }; 00014 00015 struct nfacct *nfacct_alloc(void); 00016 void nfacct_free(struct nfacct *nfacct); 00017 00018 void nfacct_attr_set(struct nfacct *nfacct, enum nfacct_attr_type type, const void *data); 00019 void nfacct_attr_set_str(struct nfacct *nfacct, enum nfacct_attr_type type, const char *name); 00020 void nfacct_attr_set_u64(struct nfacct *nfacct, enum nfacct_attr_type type, uint64_t value); 00021 void nfacct_attr_unset(struct nfacct *nfacct, enum nfacct_attr_type type); 00022 00023 const void *nfacct_attr_get(struct nfacct *nfacct, enum nfacct_attr_type type); 00024 const char *nfacct_attr_get_str(struct nfacct *nfacct, enum nfacct_attr_type type); 00025 uint64_t nfacct_attr_get_u64(struct nfacct *nfacct, enum nfacct_attr_type type); 00026 00027 struct nlmsghdr; 00028 00029 struct nlmsghdr *nfacct_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq); 00030 void nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct); 00031 int nfacct_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfacct *nfacct); 00032 00033 #define NFACCT_SNPRINTF_F_FULL (1 << 0) 00034 00035 #define NFACCT_SNPRINTF_T_PLAIN 0 00036 #define NFACCT_SNPRINTF_T_XML 1 00037 00038 int nfacct_snprintf(char *buf, size_t size, struct nfacct *nfacct, uint16_t type, uint16_t flags); 00039 00040 #endif