summaryrefslogtreecommitdiffstats
path: root/pimd/pim_util.c
diff options
context:
space:
mode:
authorEverton Marques <everton.marques@gmail.com>2009-11-18 10:44:13 -0200
committerDavid Lamparter <equinox@opensourcerouting.org>2015-02-04 06:07:52 +0100
commit627380420e60a4b944646eb1ce2b1552e6e03565 (patch)
treedcf89c31ad5fa3157d2ea8faf8f8f897341b3dbd /pimd/pim_util.c
parente0b8b9b6e465bc8ae4a416e5297fa682d7feb39e (diff)
downloadquagga-627380420e60a4b944646eb1ce2b1552e6e03565.tar.bz2
quagga-627380420e60a4b944646eb1ce2b1552e6e03565.tar.xz
[pim] Packet dump debugging
Diffstat (limited to 'pimd/pim_util.c')
-rw-r--r--pimd/pim_util.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/pimd/pim_util.c b/pimd/pim_util.c
index 5bc8d07e..13230c0c 100644
--- a/pimd/pim_util.c
+++ b/pimd/pim_util.c
@@ -20,6 +20,10 @@
$QuaggaId: $Format:%an, %ai, %h$ $
*/
+#include <zebra.h>
+
+#include "log.h"
+
#include "pim_util.h"
/*
@@ -130,3 +134,26 @@ uint16_t pim_inet_checksum(const char *buf, int size)
return checksum;
}
#endif /* PIM_USE_QUAGGA_INET_CHECKSUM */
+
+void pim_pkt_dump(const char *label, const char *buf, int size)
+{
+ char dump_buf[1000];
+ int i = 0;
+ int j = 0;
+
+ for (; i < size; ++i, j += 3) {
+ int left = sizeof(dump_buf) - j;
+ if (left < 4) {
+ if (left > 1) {
+ strcat(dump_buf + j, "!"); /* mark as truncated */
+ }
+ break;
+ }
+ snprintf(dump_buf + j, left, " %02x", buf[i]);
+ }
+
+ zlog_debug("%s: pkt dump size=%d:%s",
+ label,
+ size,
+ dump_buf);
+}