From 67fc4a906aa73700ce84edaceb7fee189ba3771f Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 19 Oct 2015 17:15:16 +0200 Subject: netsniff-ng: nlmsg: Display "(none)" instead of "()" for zero flags nl_nlmsg_flags2str() returns an empty string if the provided flags argument is 0. Check this condition and display "none" instead to make the output nicer to read. Signed-off-by: Tobias Klauser --- proto_nlmsg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/proto_nlmsg.c b/proto_nlmsg.c index b621728..6f0a13d 100644 --- a/proto_nlmsg.c +++ b/proto_nlmsg.c @@ -706,6 +706,7 @@ static void rtnl_msg_print(struct nlmsghdr *hdr) static void nlmsg_print(uint16_t family, struct nlmsghdr *hdr) { + u16 nlmsg_flags = hdr->nlmsg_flags; char type[32]; char flags[128]; char procname[PATH_MAX]; @@ -733,9 +734,9 @@ static void nlmsg_print(uint16_t family, struct nlmsghdr *hdr) colorize_start(bold), nlmsg_type2str(family, hdr->nlmsg_type, type, sizeof(type)), colorize_end()); - tprintf("Flags 0x%.4x (%s%s%s), ", hdr->nlmsg_flags, + tprintf("Flags 0x%.4x (%s%s%s), ", nlmsg_flags, colorize_start(bold), - nl_nlmsg_flags2str(hdr->nlmsg_flags, flags, sizeof(flags)), + nlmsg_flags ? nl_nlmsg_flags2str(nlmsg_flags, flags, sizeof(flags)) : "none", colorize_end()); tprintf("Seq-Nr %u, ", hdr->nlmsg_seq); tprintf("PID %u", hdr->nlmsg_pid); -- cgit v1.2.3-54-g00ecf