#include "util.h" #include // hex_dumb display network packets in a good way void hex_dump(unsigned n, const unsigned char* buf) { int on_this_line = 0; while (n-- > 0) { fprintf(stderr, "%02X ", *buf++); on_this_line += 1; if (on_this_line == 16 || n == 0) { int i; fputs(" ", stderr); for (i = on_this_line; i < 16; i++) fputs(" ", stderr); for (i = on_this_line; i > 0; i--) fputc(isprint(buf[-i]) ? buf[-i] : '.', stderr); fputs("\n", stderr); on_this_line = 0; } } }