summaryrefslogtreecommitdiffstats
path: root/usr.sbin/switchd/util.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2016-09-29 20:46:06 +0000
committerreyk <reyk@openbsd.org>2016-09-29 20:46:06 +0000
commitee986a86933d66133833fc3c7a42b048ec70de9c (patch)
tree916b164b543d873a87ef94009cccaa8ec7d39d2b /usr.sbin/switchd/util.c
parenttypo: send ofp messages instead of massages. (diff)
downloadwireguard-openbsd-ee986a86933d66133833fc3c7a42b048ec70de9c.tar.xz
wireguard-openbsd-ee986a86933d66133833fc3c7a42b048ec70de9c.zip
Add print_hex() for debugging of received packets (from iked)
Diffstat (limited to 'usr.sbin/switchd/util.c')
-rw-r--r--usr.sbin/switchd/util.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/usr.sbin/switchd/util.c b/usr.sbin/switchd/util.c
index 620c650b3c7..716423c7460 100644
--- a/usr.sbin/switchd/util.c
+++ b/usr.sbin/switchd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.2 2016/09/29 18:13:50 reyk Exp $ */
+/* $OpenBSD: util.c,v 1.3 2016/09/29 20:46:06 reyk Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
@@ -293,6 +293,27 @@ print_verbose(const char *emsg, ...)
}
}
+void
+print_hex(uint8_t *buf, off_t offset, size_t length)
+{
+ unsigned int i;
+ extern int verbose;
+
+ if (verbose < 3 || !length)
+ return;
+
+ for (i = 0; i < length; i++) {
+ if (i && (i % 4) == 0) {
+ if ((i % 32) == 0)
+ print_debug("\n");
+ else
+ print_debug(" ");
+ }
+ print_debug("%02x", buf[offset + i]);
+ }
+ print_debug("\n");
+}
+
int
parsehostport(const char *str, struct sockaddr *sa, socklen_t salen)
{