diff options
author | Yunchih Chen <yunchih.cat@gmail.com> | 2018-03-18 11:59:54 +0800 |
---|---|---|
committer | Yunchih Chen <yunchih.cat@gmail.com> | 2018-03-18 11:59:54 +0800 |
commit | 147d862098fe5c3a640dad0608d928a8edd64e9f (patch) | |
tree | 2731642cc3edc383285c77344105dd756fb19c3d /lib | |
parent | 2bf88e23cd67c7a8857611a4536ee9cabaf0a460 (diff) | |
download | nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.tar nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.tar.gz nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.tar.bz2 nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.tar.lz nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.tar.xz nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.tar.zst nfcollect-147d862098fe5c3a640dad0608d928a8edd64e9f.zip |
Fix format output ipaddr
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/common.c b/lib/common.c index 2b99dc6..20ef29f 100644 --- a/lib/common.c +++ b/lib/common.c @@ -1,4 +1,5 @@ #include "common.h" +#include <arpa/inet.h> #include <assert.h> #include <errno.h> #include <limits.h> @@ -106,15 +107,13 @@ void nfl_cal_entries(uint32_t trunk_size, uint32_t *entries_cnt) { } void nfl_format_output(char *output, nflog_entry_t *entry) { - char dest_ip[16]; - snprintf(dest_ip, 16, "%pI4", &entry->daddr); sprintf(output, "t=%ld\t" "daddr=%s\t" "proto=%s\t" "uid=%d\t" "sport=%d\t" "dport=%d", - entry->timestamp, dest_ip, + entry->timestamp, inet_ntoa(entry->daddr), entry->protocol == IPPROTO_TCP ? "TCP" : "UDP", entry->uid, entry->sport, entry->dport); } |