fuzz: re-enable cmdline, cleanups
[netsniff-ng.git] / src / dissector.h
bloba6f7a6de0c663a5329f899e1c481c14db4185041
1 /*
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.
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"
17 #define LINKTYPE_NULL 0 /* BSD loopback encapsulation */
18 #define LINKTYPE_EN10MB 1 /* Ethernet (10Mb) */
19 #define LINKTYPE_EN3MB 2 /* Experimental Ethernet (3Mb) */
20 #define LINKTYPE_AX25 3 /* Amateur Radio AX.25 */
21 #define LINKTYPE_PRONET 4 /* Proteon ProNET Token Ring */
22 #define LINKTYPE_CHAOS 5 /* Chaos */
23 #define LINKTYPE_IEEE802 6 /* 802.5 Token Ring */
24 #define LINKTYPE_ARCNET 7 /* ARCNET, with BSD-style header */
25 #define LINKTYPE_SLIP 8 /* Serial Line IP */
26 #define LINKTYPE_PPP 9 /* Point-to-point Protocol */
27 #define LINKTYPE_FDDI 10 /* FDDI */
29 #define FNTTYPE_PRINT_NORM 0
30 #define FNTTYPE_PRINT_LESS 1
31 #define FNTTYPE_PRINT_HEX 2
32 #define FNTTYPE_PRINT_ASCII 3
33 #define FNTTYPE_PRINT_NONE 4
35 extern void dissector_init_all(int fnttype);
36 extern void dissector_entry_point(uint8_t *packet, size_t len, int linktype, int mode);
37 extern void dissector_cleanup_all(void);
38 extern int dissector_set_print_type(void *ptr, int type);
40 static char *packet_types[]={
41 "<", /* Incoming */
42 "B", /* Broadcast */
43 "M", /* Multicast */
44 "P", /* Promisc */
45 ">", /* Outgoing */
46 "?", /* Unknown */
49 static inline void show_frame_hdr(struct frame_map *hdr, int mode,
50 enum ring_mode rmode)
52 if (mode == FNTTYPE_PRINT_NONE)
53 return;
55 switch (mode) {
56 case FNTTYPE_PRINT_LESS:
57 if (rmode == RING_MODE_INGRESS) {
58 tprintf("%s %u %u",
59 packet_types[hdr->s_ll.sll_pkttype],
60 hdr->s_ll.sll_ifindex, hdr->tp_h.tp_len);
61 } else {
62 tprintf("%u ", hdr->tp_h.tp_len);
64 break;
65 case FNTTYPE_PRINT_NORM:
66 case FNTTYPE_PRINT_HEX:
67 case FNTTYPE_PRINT_ASCII:
68 default:
69 if (rmode == RING_MODE_INGRESS) {
70 tprintf("%s %u %u %u.%06u\n",
71 packet_types[hdr->s_ll.sll_pkttype],
72 hdr->s_ll.sll_ifindex, hdr->tp_h.tp_len,
73 hdr->tp_h.tp_sec, hdr->tp_h.tp_usec);
74 } else {
75 tprintf("%u %u.%06u\n", hdr->tp_h.tp_len,
76 hdr->tp_h.tp_sec, hdr->tp_h.tp_usec);
78 break;
82 #endif /* DISSECTOR_H */