* [PATCH libmnl] nlmsg: Improve payload printing
@ 2016-06-08 9:17 Carlos Falgueras García
0 siblings, 0 replies; only message in thread
From: Carlos Falgueras García @ 2016-06-08 9:17 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo
It make more sense to use "isprint" than "isalnum" because we use non
alphanumeric characters like '%', '_', etc. And, in case of non printable
character, print a space is preferable to print a NULL (0) in order to keep
alignment.
Before:
...
|00012|--|00002| |len |flags| type|
| 5f 5f 73 65 | | data | s e
| 74 25 64 00 | | data | t d
...
After:
...
|00012|--|00002| |len |flags| type|
| 5f 5f 73 65 | | data | _ _ s e
| 74 25 64 00 | | data | t % d
...
Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
---
src/nlmsg.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/nlmsg.c b/src/nlmsg.c
index fd2f698..5dfbd88 100644
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -317,10 +317,10 @@ mnl_nlmsg_fprintf_payload(FILE *fd, const struct nlmsghdr *nlh,
0xff & b[i+2], 0xff & b[i+3]);
fprintf(fd, "| data |");
fprintf(fd, "\t %c %c %c %c\n",
- isalnum(b[i]) ? b[i] : 0,
- isalnum(b[i+1]) ? b[i+1] : 0,
- isalnum(b[i+2]) ? b[i+2] : 0,
- isalnum(b[i+3]) ? b[i+3] : 0);
+ isprint(b[i]) ? b[i] : ' ',
+ isprint(b[i+1]) ? b[i+1] : ' ',
+ isprint(b[i+2]) ? b[i+2] : ' ',
+ isprint(b[i+3]) ? b[i+3] : ' ');
}
}
fprintf(fd, "----------------\t------------------\n");
--
2.8.2
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-06-08 9:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-08 9:17 [PATCH libmnl] nlmsg: Improve payload printing Carlos Falgueras García
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).