From: Sven M. Hallberg Date: Thu, 6 Nov 2014 17:35:12 +0000 (+0100) Subject: log incoming packet payload as hex (not verbatim) X-Git-Url: http://git.meshlink.io/?p=meshlink;a=commitdiff_plain;h=257493390b8f103f792fa99c823b0bf7c46020a2 log incoming packet payload as hex (not verbatim) --- 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; }