Merge branch 'master' of git://github.com/borkmann/netsniff-ng
[netsniff-ng.git] / src / proto_struct.h
blob98502cdaaa9c28a7ab9fd5120be72980c1179ab5
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>.
4 * Copyright (C) 2009, 2010 Daniel Borkmann
5 * Copyright (C) 2012 Christoph Jaeger <christoph@netsniff-ng.org>
6 * Subject to the GPL, version 2.
7 */
9 #ifndef PROTO_H
10 #define PROTO_H
12 #include <stdint.h>
14 #include "hash.h"
15 #include "tprintf.h"
17 /* necessary forward declarations */
18 struct pkt_buff;
19 static inline unsigned int pkt_len(struct pkt_buff *pkt);
20 static uint8_t *pkt_pull(struct pkt_buff *pkt, unsigned int len);
22 struct protocol {
23 /* Needs to be filled out by user */
24 unsigned int key;
25 void (*print_full) (struct pkt_buff *pkt);
26 void (*print_less) (struct pkt_buff *pkt);
27 /* Used by program logic */
28 struct protocol *next;
29 void (*process) (struct pkt_buff *pkt);
32 static inline void empty(struct pkt_buff *pkt) {}
34 static inline void hex(struct pkt_buff *pkt)
36 uint8_t *buff;
37 unsigned int len = pkt_len(pkt);
39 for (buff = pkt_pull(pkt, len); buff && len-- > 0; buff++)
40 tprintf("%.2x ", *buff);
43 #endif /* PROTO_H */