build: flowtop: Only build ioops with GeoIP support enabled
[netsniff-ng.git] / proto_none.c
blob41835a0e3914e99087ec969487eb8e10c0b67053
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
5 */
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <ctype.h>
11 #include "proto.h"
12 #include "pkt_buff.h"
14 void empty(struct pkt_buff *pkt __maybe_unused) {}
16 static void _hex(uint8_t *ptr, size_t len)
18 if (!len)
19 return;
21 tprintf(" [ Hex ");
22 for (; ptr && len-- > 0; ptr++)
23 tprintf(" %.2x", *ptr);
24 tprintf(" ]\n");
27 void hex(struct pkt_buff *pkt)
29 size_t len = pkt_len(pkt);
31 if (!len)
32 return;
34 _hex(pkt_pull(pkt, len), len);
35 tprintf("\n");
38 static void _ascii(uint8_t *ptr, size_t len)
40 if (!len)
41 return;
43 tprintf(" [ Chr ");
44 for (; ptr && len-- > 0; ptr++)
45 tprintf("%c", isprint(*ptr) ? *ptr : '.');
46 tprintf(" ]\n");
49 void ascii(struct pkt_buff *pkt)
51 size_t len = pkt_len(pkt);
53 if (!len)
54 return;
56 _ascii(pkt_pull(pkt, len), len);
57 tprintf("\n");
60 void hex_ascii(struct pkt_buff *pkt)
62 size_t len = pkt_len(pkt);
63 uint8_t *ptr = pkt_pull(pkt, len);
65 if (len) {
66 _ascii(ptr, len);
67 _hex(ptr, len);
70 tprintf("\n");
73 static void none_less(struct pkt_buff *pkt __maybe_unused)
75 tprintf("\n");
78 struct protocol none_ops = {
79 .key = 0x01,
80 .print_full = hex_ascii,
81 .print_less = none_less,