5 #include <libmnl/libmnl.h>
6 #include <libnetfilter_acct/libnetfilter_acct.h>
8 int main(
int argc,
char *argv[])
10 struct mnl_socket *nl;
11 char buf[MNL_SOCKET_BUFFER_SIZE];
14 struct nfacct *nfacct;
18 fprintf(stderr,
"Usage: %s [name]\n", argv[0]);
37 nl = mnl_socket_open(NETLINK_NETFILTER);
39 perror(
"mnl_socket_open");
43 if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
44 perror(
"mnl_socket_bind");
47 portid = mnl_socket_get_portid(nl);
49 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
50 perror(
"mnl_socket_send");
54 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
56 ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL);
59 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
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)
void nfacct_free(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)