2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010, 2011, 2012 Daniel Borkmann.
4 * Subject to the GPL, version 2.
16 #include "dissector.h"
17 #include "dissector_eth.h"
18 #include "dissector_80211.h"
20 int dissector_set_print_type(void *ptr
, int type
)
22 struct protocol
*proto
;
24 for (proto
= ptr
; proto
; proto
= proto
->next
) {
27 proto
->process
= proto
->print_full
;
30 proto
->process
= proto
->print_less
;
33 proto
->process
= NULL
;
41 static void dissector_main(struct pkt_buff
*pkt
, struct protocol
*start
,
44 struct protocol
*proto
;
49 for (pkt
->proto
= start
; pkt
->proto
; ) {
50 if (unlikely(!pkt
->proto
->process
))
58 if (end
&& likely(end
->process
))
62 void dissector_entry_point(uint8_t *packet
, size_t len
, int linktype
, int mode
)
64 struct protocol
*proto_start
, *proto_end
;
65 struct pkt_buff
*pkt
= NULL
;
67 if (mode
== PRINT_NONE
)
70 pkt
= pkt_alloc(packet
, len
);
74 case ___constant_swab32(LINKTYPE_EN10MB
):
75 proto_start
= dissector_get_ethernet_entry_point();
76 proto_end
= dissector_get_ethernet_exit_point();
78 case LINKTYPE_IEEE802_11
:
79 case ___constant_swab32(LINKTYPE_IEEE802_11
):
80 proto_start
= dissector_get_ieee80211_entry_point();
81 proto_end
= dissector_get_ieee80211_exit_point();
84 panic("Linktype not supported!\n");
87 dissector_main(pkt
, proto_start
, proto_end
);
105 void dissector_init_all(int fnttype
)
107 dissector_init_ethernet(fnttype
);
108 dissector_init_ieee80211(fnttype
);
111 void dissector_cleanup_all(void)
113 dissector_cleanup_ethernet();
114 dissector_cleanup_ieee80211();