From 257493390b8f103f792fa99c823b0bf7c46020a2 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Thu, 6 Nov 2014 18:35:12 +0100 Subject: [PATCH] log incoming packet payload as hex (not verbatim) --- src/route.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/route.c b/src/route.c index 1cb60d87..92a360ff 100644 --- a/src/route.c +++ b/src/route.c @@ -56,9 +56,16 @@ void route(meshlink_handle_t *mesh, node_t *source, vpn_packet_t *packet) { } if(owner == mesh->self) { - logger(mesh, MESHLINK_DEBUG, "I received a packet for me with payload: %s \n", packet->data + sizeof *hdr); + const void *payload = packet->data + sizeof *hdr; + size_t len = packet->len - sizeof *hdr; + + char hex[len*2 + 1]; + if(mesh->log_level >= MESHLINK_DEBUG) + bin2hex(payload, hex, len); // don't do this unless it's going to be logged + logger(mesh, MESHLINK_DEBUG, "I received a packet for me with payload: %s\n", hex); + if(mesh->receive_cb) - mesh->receive_cb(mesh, (meshlink_node_t *)source, packet->data + sizeof *hdr, packet->len - sizeof *hdr); + mesh->receive_cb(mesh, (meshlink_node_t *)source, payload, len); return; } -- 2.39.5