summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-10-19 17:15:16 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-10-19 17:15:16 +0200
commit67fc4a906aa73700ce84edaceb7fee189ba3771f (patch)
tree2f83494605e0e7c102d38df7f2be74535f3d6f61
parentfc4646bc31e37c3e48d772fe11035f82277ece24 (diff)
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 <tklauser@distanz.ch>
-rw-r--r--proto_nlmsg.c5
1 files 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);