From 3cde7e58e35f56d535676bf2a79689277956a494 Mon Sep 17 00:00:00 2001 From: dak664 Date: Wed, 18 May 2011 12:48:02 -0400 Subject: [PATCH] Format debug packet output for Wireshark import, as default. --- tools/tunslip6.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/tunslip6.c b/tools/tunslip6.c index 2b1c28acf..0dd6c37d0 100644 --- a/tools/tunslip6.c +++ b/tools/tunslip6.c @@ -33,6 +33,9 @@ * */ + /* Below define allows importing saved output into Wireshark as "Raw IP" packet type */ +#define WIRESHARK_IMPORT_FORMAT 1 + #include #include #include @@ -250,15 +253,17 @@ serial_to_tun(FILE *inslip, int outfd) if (timestamp) stamptime(); printf("Packet from SLIP of length %d - write TUN\n", inbufptr); if (verbose>4) { +#if WIRESHARK_IMPORT_FORMAT + printf("0000"); + for(i = 0; i < inbufptr; i++) printf(" %02x",uip.inbuf[i]); +#else printf(" "); for(i = 0; i < inbufptr; i++) { printf("%02x", uip.inbuf[i]); - if((i & 3) == 3) { - printf(" "); - } - if((i & 15) == 15) - printf("\n "); + if((i & 3) == 3) printf(" "); + if((i & 15) == 15) printf("\n "); } +#endif printf("\n"); } } @@ -383,15 +388,17 @@ write_to_serial(int outfd, void *inbuf, int len) if (timestamp) stamptime(); printf("Packet from TUN of length %d - write SLIP\n", len); if (verbose>4) { +#if WIRESHARK_IMPORT_FORMAT + printf("0000"); + for(i = 0; i < len; i++) printf(" %02x", p[i]); +#else printf(" "); for(i = 0; i < len; i++) { printf("%02x", p[i]); - if((i & 3) == 3) { - printf(" "); - } - if((i & 15) == 15) - printf("\n "); + if((i & 3) == 3) printf(" "); + if((i & 15) == 15) printf("\n "); } +#endif printf("\n"); } }