Format debug packet output for Wireshark import, as default.

This commit is contained in:
dak664 2011-05-18 12:48:02 -04:00
parent 580efaa412
commit 3cde7e58e3

View file

@ -33,6 +33,9 @@
*
*/
/* Below define allows importing saved output into Wireshark as "Raw IP" packet type */
#define WIRESHARK_IMPORT_FORMAT 1
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@ -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");
}
}