2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
16 void empty(struct pkt_buff
*pkt
) {}
18 static void _hex(uint8_t *ptr
, size_t len
)
24 for (; ptr
&& len
-- > 0; ptr
++)
25 tprintf(" %.2x", *ptr
);
29 void hex(struct pkt_buff
*pkt
)
31 size_t len
= pkt_len(pkt
);
36 _hex(pkt_pull(pkt
, len
), len
);
40 static void _ascii(uint8_t *ptr
, size_t len
)
46 for (; ptr
&& len
-- > 0; ptr
++)
47 tprintf("%c", isprint(*ptr
) ? *ptr
: '.');
51 void ascii(struct pkt_buff
*pkt
)
53 size_t len
= pkt_len(pkt
);
58 _ascii(pkt_pull(pkt
, len
), len
);
62 void hex_ascii(struct pkt_buff
*pkt
)
64 size_t len
= pkt_len(pkt
);
65 uint8_t *ptr
= pkt_pull(pkt
, len
);
75 static void none_less(struct pkt_buff
*pkt
)
80 struct protocol none_ops
= {
82 .print_full
= hex_ascii
,
83 .print_less
= none_less
,