2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010, 2011, 2012 Daniel Borkmann.
5 * Subject to the GPL, version 2.
14 #include "dissector.h"
15 #include "dissector_eth.h"
17 #include "proto_struct.h"
19 int dissector_set_print_type(void *ptr
, int type
)
21 struct protocol
*proto
= (struct protocol
*) ptr
;
23 while (proto
!= NULL
) {
25 case FNTTYPE_PRINT_NORM
:
26 proto
->process
= proto
->print_full
;
28 case FNTTYPE_PRINT_LESS
:
29 proto
->process
= proto
->print_less
;
32 case FNTTYPE_PRINT_NONE
:
33 proto
->process
= NULL
;
43 static void dissector_main(struct pkt_buff
*pkt
, struct protocol
*start
,
46 struct protocol
*proto
;
48 for (pkt
->proto
= start
; pkt
->proto
!= NULL
;) {
49 if (unlikely(!pkt
->proto
->process
))
58 if (likely(end
->process
))
64 void dissector_entry_point(uint8_t *packet
, size_t len
, int linktype
, int mode
)
66 struct protocol
*proto_start
= NULL
;
67 struct protocol
*proto_end
= NULL
;
68 struct pkt_buff
*pkt
= NULL
;
70 if (mode
== FNTTYPE_PRINT_NONE
)
73 pkt
= pkt_alloc(packet
, len
);
77 proto_start
= dissector_get_ethernet_entry_point();
78 proto_end
= dissector_get_ethernet_exit_point();
81 panic("Linktype not supported!\n");
84 dissector_main(pkt
, proto_start
, proto_end
);
89 void dissector_init_all(int fnttype
)
91 dissector_init_ethernet(fnttype
);
94 void dissector_cleanup_all(void)
96 dissector_cleanup_ethernet();