You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
828 B
C

1 year ago
#ifndef DEBUG_IMPORTED
#define DEBUG_IMPORTED
/* string stuff(memset, strcmp, strlen, etc) */
#include<string.h>
/* isprint() */
#include <ctype.h>
/**
* Check the payload of the packet for errors (use it for debug).
* Prints payload in format recognizable by wireshark.
*/
static void dump_payload(char *p, int len)
{
char buf[128];
int i, j, k = 0, i0;
/* hexdump routine */
for (i = 0; i < len; ) {
memset(buf, sizeof(buf), ' ');
sprintf(buf, "%04d: ", k);
i0 = i;
for (j=0; j < 16 && i < len; i++, j++)
sprintf(buf+6+j*3, "%02x ", (uint8_t)(p[i]));
i = i0;
for (j=0; j < 16 && i < len; i++, j++)
sprintf(buf+6+j + 48, "%c",
isprint(p[i]) ? p[i] : '.');
printf("%s\n", buf);
k = k+10;
}
}
#endif