summaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c
index a54bc29..7d1538a 100644
--- a/src/log.c
+++ b/src/log.c
@@ -107,6 +107,15 @@ static size_t snprint_peer_str(char *buffer, size_t size, const fastd_peer_t *pe
return snprintf_safe(buffer, size, "(null)");
}
+/** Add a hexdump to a string buffer */
+static size_t snprint_hexdump(char *buffer, size_t size, const uint8_t *d, size_t len) {
+ size_t n = 0, i;
+ for (i = 0; i < len && n < size; i++)
+ n += snprintf_safe(buffer+n, size-n, "%02x", d[i]);
+
+ return n;
+}
+
/** vsnprintf-like function using different conversion specifiers */
static int fastd_vsnprintf(char *buffer, size_t size, const char *format, va_list ap) {
char *buffer_start = buffer;
@@ -171,6 +180,11 @@ static int fastd_vsnprintf(char *buffer, size_t size, const char *format, va_lis
buffer += snprint_peer_str(buffer, buffer_end-buffer, va_arg(ap, const fastd_peer_t *));
break;
+ case 'H':
+ p = va_arg(ap, const uint8_t *);
+ buffer += snprint_hexdump(buffer, buffer_end-buffer, p, va_arg(ap, size_t));
+ break;
+
case 'I':
case 'B':
case 'L':