From 1a3c075be1cf57dc248f38a974a8a01457e6b6e2 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Wed, 11 Nov 2015 01:54:01 +0100 Subject: src: add trace infrastructure support parses trace monitor netlink messages from the kernel and builds nftnl_trace struct that contains the dissected information. Provides getters to access these attributes. Signed-off-by: Florian Westphal --- include/libnftnl/Makefile.am | 1 + include/libnftnl/trace.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 include/libnftnl/trace.h (limited to 'include/libnftnl') diff --git a/include/libnftnl/Makefile.am b/include/libnftnl/Makefile.am index a20aaee..84f01b6 100644 --- a/include/libnftnl/Makefile.am +++ b/include/libnftnl/Makefile.am @@ -1,5 +1,6 @@ pkginclude_HEADERS = batch.h \ table.h \ + trace.h \ chain.h \ rule.h \ expr.h \ diff --git a/include/libnftnl/trace.h b/include/libnftnl/trace.h new file mode 100644 index 0000000..674bc16 --- /dev/null +++ b/include/libnftnl/trace.h @@ -0,0 +1,55 @@ +#ifndef _LIBNFTNL_TRACE_H_ +#define _LIBNFTNL_TRACE_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum nftnl_trace_attr { + NFTNL_TRACE_CHAIN = 0, + NFTNL_TRACE_FAMILY, + NFTNL_TRACE_ID, + NFTNL_TRACE_IIF, + NFTNL_TRACE_IIFTYPE, + NFTNL_TRACE_JUMP_TARGET, + NFTNL_TRACE_OIF, + NFTNL_TRACE_OIFTYPE, + NFTNL_TRACE_MARK, + NFTNL_TRACE_LL_HEADER, + NFTNL_TRACE_NETWORK_HEADER, + NFTNL_TRACE_TRANSPORT_HEADER, + NFTNL_TRACE_TABLE, + NFTNL_TRACE_TYPE, + NFTNL_TRACE_RULE_HANDLE, + NFTNL_TRACE_VERDICT, + NFTNL_TRACE_NFPROTO, + NFTNL_TRACE_POLICY, + __NFTNL_TRACE_MAX, +}; +#define NFTNL_TRACE_MAX (__NFTNL_TRACE_MAX - 1) + +struct nftnl_trace; + +struct nftnl_trace *nftnl_trace_alloc(void); +void nftnl_trace_free(struct nftnl_trace *trace); + +bool nftnl_trace_is_set(const struct nftnl_trace *trace, uint16_t type); + +const void *nftnl_trace_get_data(const struct nftnl_trace *trace, + uint16_t type, uint32_t *data_len); + +uint16_t nftnl_trace_get_u16(const struct nftnl_trace *trace, uint16_t type); +uint32_t nftnl_trace_get_u32(const struct nftnl_trace *trace, uint16_t type); +uint64_t nftnl_trace_get_u64(const struct nftnl_trace *trace, uint16_t type); +const char *nftnl_trace_get_str(const struct nftnl_trace *trace, uint16_t type); + +int nftnl_trace_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_trace *t); +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* _LIBNFTNL_TRACE_H_ */ -- cgit v1.2.3