tprintf: xutils: Move tput*_safe to tprintf.c
[netsniff-ng.git] / dissector.h
blobb881064496261f0e3c90666d9eab2102323a26e2
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009 - 2013 Daniel Borkmann.
5 * Subject to the GPL, version 2.
6 */
8 #ifndef DISSECTOR_H
9 #define DISSECTOR_H
11 #include <stdlib.h>
12 #include <stdint.h>
14 #include "ring.h"
15 #include "tprintf.h"
16 #include "pcap.h"
18 #define PRINT_NORM 0
19 #define PRINT_LESS 1
20 #define PRINT_HEX 2
21 #define PRINT_ASCII 3
22 #define PRINT_HEX_ASCII 4
23 #define PRINT_NONE 5
25 static const char * const packet_types[256]={
26 "<", /* Incoming */
27 "B", /* Broadcast */
28 "M", /* Multicast */
29 "P", /* Promisc */
30 ">", /* Outgoing */
31 "?", /* Unknown */
34 extern char *if_indextoname(unsigned ifindex, char *ifname);
36 static inline void show_frame_hdr(struct frame_map *hdr, int mode,
37 enum ring_mode rmode)
39 char tmp[IFNAMSIZ];
41 if (mode == PRINT_NONE)
42 return;
44 switch (mode) {
45 case PRINT_LESS:
46 tprintf("%s %s %u",
47 packet_types[hdr->s_ll.sll_pkttype] ? : "?",
48 if_indextoname(hdr->s_ll.sll_ifindex, tmp) ? : "?",
49 hdr->tp_h.tp_len);
50 break;
51 default:
52 tprintf("%s %s %u %us.%uns\n",
53 packet_types[hdr->s_ll.sll_pkttype] ? : "?",
54 if_indextoname(hdr->s_ll.sll_ifindex, tmp) ? : "?",
55 hdr->tp_h.tp_len, hdr->tp_h.tp_sec,
56 hdr->tp_h.tp_nsec);
57 break;
61 extern void dissector_init_all(int fnttype);
62 extern void dissector_entry_point(uint8_t *packet, size_t len, int linktype, int mode);
63 extern void dissector_cleanup_all(void);
64 extern int dissector_set_print_type(void *ptr, int type);
66 #endif /* DISSECTOR_H */