From 147d862098fe5c3a640dad0608d928a8edd64e9f Mon Sep 17 00:00:00 2001 From: Yunchih Chen Date: Sun, 18 Mar 2018 11:59:54 +0800 Subject: Fix format output ipaddr --- lib/common.c | 5 ++--- 1 file 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 #include #include #include @@ -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); } -- cgit v1.2.3