From 29e56c77acaf53cdae09dbe30777ac2abf2234bd Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 11 May 2011 14:15:45 -0300 Subject: [PATCH] tools/dirtpan/: -d now generates terse output; -d -d dumps full content - dirtpan.c (debug_ip): only dump local packets if debug > 1 - dirtpan.c (debug_dirt): dump packet content only if debug > 1 - dirtpan.c (debug_dirt): made packet content dump more readable - dirtpan.c (debug_dirt): added terse debug output for debug == 1 - dirtpan.c (usage): doubling -d now has a meaning --- tools/dirtpan/dirtpan.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/dirtpan/dirtpan.c b/tools/dirtpan/dirtpan.c index 660fe78..4cb3c01 100644 --- a/tools/dirtpan/dirtpan.c +++ b/tools/dirtpan/dirtpan.c @@ -110,7 +110,7 @@ static void dump(const void *buf, int size) static void debug_ip(const char *label, void *buf, int size) { - if (!debug) + if (debug < 2) return; debug_label(label); fprintf(stderr, ", %d: ", size); @@ -125,10 +125,18 @@ static void debug_dirt(const char *label, void *buf, int size) if (!debug) return; + if (debug == 1) { + if (size) { + fprintf(stderr, "%c%d", + (label[1] == '>' ? "FNA?" : "fna?")[*p & PT_MASK], + *p & SEQ ? 0 : 1); + } + return; + } debug_label(label); - fprintf(stderr, ", %d", size); + fprintf(stderr, ", %d+1: ", size-1); if (size) { - fprintf(stderr, ": %02x(%c%d) ", + fprintf(stderr, "%02x(%c%d) | ", *p, "FNA?"[*p & PT_MASK], *p & SEQ ? 0 : 1); dump(buf+1, size-1); } @@ -481,7 +489,8 @@ static int open_tun(void) static void usage(const char *name) { - fprintf(stderr, "usage: %s [-d] pan_id src_addr dst_addr\n", name); + fprintf(stderr, "usage: %s [-d [-d]] pan_id src_addr dst_addr\n", + name); exit(1); }