[PATCH v2 6/8] netlink: print unrecognized netlink messages in hex
JingPiao Chen
chenjingpiao at gmail.com
Fri Jul 7 03:23:52 UTC 2017
* netlink.c (fetch_nlmsghdr): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/netlink_protocol.c (send_query): Update expected output.
---
netlink.c | 2 +-
tests/netlink_protocol.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/netlink.c b/netlink.c
index cd1296f..d09724f 100644
--- a/netlink.c
+++ b/netlink.c
@@ -53,7 +53,7 @@ fetch_nlmsghdr(struct tcb *const tcp, struct nlmsghdr *const nlmsghdr,
const kernel_ulong_t addr, const kernel_ulong_t len)
{
if (len < sizeof(struct nlmsghdr)) {
- printstrn(tcp, addr, len);
+ printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
return false;
}
diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c
index ebb93c4..b021a8e 100644
--- a/tests/netlink_protocol.c
+++ b/tests/netlink_protocol.c
@@ -83,7 +83,8 @@ send_query(const int fd)
/* whole message length < sizeof(struct nlmsghdr) */
rc = sendto(fd, req->magic, sizeof(req->magic), MSG_DONTWAIT, NULL, 0);
- printf("sendto(%d, \"abcd\", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+ printf("sendto(%d, \"\\x61\\x62\\x63\\x64\""
+ ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, (unsigned) sizeof(req->magic), sprintrc(rc));
/* a single message with some data */
@@ -155,8 +156,8 @@ send_query(const int fd)
printf("sendto(%d, [{{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
", seq=0, pid=0}, \"\\x61\\x62\\x63\\x64\"}, ",
fd, reqs->req1.nlh.nlmsg_len, NLM_F_DUMP);
- print_quoted_memory((void *) &reqs->req2.nlh,
- sizeof(reqs->req2) - sizeof(req->nlh));
+ print_quoted_hex((void *) &reqs->req2.nlh,
+ sizeof(reqs->req2) - sizeof(req->nlh));
printf("], %u, MSG_DONTWAIT, NULL, 0) = %s\n",
(unsigned) (sizeof(*reqs) - sizeof(req->nlh)), errstr);
--
2.7.4
More information about the Strace-devel
mailing list