diff options
author | Ken-ichirou MATSUZAWA <chamaken@gmail.com> | 2015-08-21 09:30:33 +0900 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-08-24 20:42:29 +0200 |
commit | 6b2f3c08adc2c84c0b5f969af6cfb4d44940e560 (patch) | |
tree | 3ce6910ba96235b223c0b951af38188ad2b0c292 /utils | |
parent | 7ceefe50a1690d9b6d0125c9b9f53c959ae7a128 (diff) |
nlmsg: add printf function in conjunction with libmnl
To printf nflog netlink message in XML, nflog_snprintf_xml can be
used after converting nflog nlattrs to nflog_data, but we should not
have any code that mixes both new and old, which handles nflog_data,
APIs. The idea is to deprecate libnfnetlink and any client of that
library at some point, that will take quite time though since we'll
have to mark those old interfaces as deprecated.
Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/nf-log.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/utils/nf-log.c b/utils/nf-log.c index d575b77..5f2a192 100644 --- a/utils/nf-log.c +++ b/utils/nf-log.c @@ -14,6 +14,7 @@ static int log_cb(const struct nlmsghdr *nlh, void *data) struct nfulnl_msg_packet_hdr *ph = NULL; const char *prefix = NULL; uint32_t mark = 0; + char buf[4096]; int ret; ret = nflog_nlmsg_parse(nlh, attrs); @@ -31,6 +32,12 @@ static int log_cb(const struct nlmsghdr *nlh, void *data) prefix ? prefix : "", ntohs(ph->hw_protocol), ph->hook, mark); + ret = nflog_nlmsg_snprintf(buf, sizeof(buf), nlh, attrs, + NFLOG_OUTPUT_XML, NFLOG_XML_ALL); + if (ret < 0) + return MNL_CB_ERROR; + printf("%s (ret=%d)\n", buf, ret); + return MNL_CB_OK; } |