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 <carlo...@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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to