2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
13 #include "dissector.h"
14 #include "dissector_eth.h"
18 struct hash_table eth_lay2
;
19 struct hash_table eth_lay3
;
21 static inline void dissector_init_entry(int type
)
23 dissector_set_print_type(ðernet_ops
, type
);
26 static inline void dissector_init_exit(int type
)
28 dissector_set_print_type(&none_ops
, type
);
31 static void dissector_init_layer_2(int type
)
34 INSERT_HASH_PROTOS(arp_ops
, eth_lay2
);
35 INSERT_HASH_PROTOS(lldp_ops
, eth_lay2
);
36 INSERT_HASH_PROTOS(vlan_ops
, eth_lay2
);
37 INSERT_HASH_PROTOS(ipv4_ops
, eth_lay2
);
38 INSERT_HASH_PROTOS(ipv6_ops
, eth_lay2
);
39 INSERT_HASH_PROTOS(QinQ_ops
, eth_lay2
);
40 INSERT_HASH_PROTOS(mpls_uc_ops
, eth_lay2
);
41 for_each_hash_int(ð_lay2
, dissector_set_print_type
, type
);
44 static void dissector_init_layer_3(int type
)
47 INSERT_HASH_PROTOS(icmpv4_ops
, eth_lay3
);
48 INSERT_HASH_PROTOS(icmpv6_ops
, eth_lay3
);
49 INSERT_HASH_PROTOS(igmp_ops
, eth_lay3
);
50 INSERT_HASH_PROTOS(ip_auth_ops
, eth_lay3
);
51 INSERT_HASH_PROTOS(ip_esp_ops
, eth_lay3
);
52 INSERT_HASH_PROTOS(ipv6_dest_opts_ops
, eth_lay3
);
53 INSERT_HASH_PROTOS(ipv6_fragm_ops
, eth_lay3
);
54 INSERT_HASH_PROTOS(ipv6_hop_by_hop_ops
, eth_lay3
);
55 INSERT_HASH_PROTOS(ipv6_in_ipv4_ops
, eth_lay3
);
56 INSERT_HASH_PROTOS(ipv6_mobility_ops
, eth_lay3
);
57 INSERT_HASH_PROTOS(ipv6_no_next_header_ops
, eth_lay3
);
58 INSERT_HASH_PROTOS(ipv6_routing_ops
, eth_lay3
);
59 INSERT_HASH_PROTOS(tcp_ops
, eth_lay3
);
60 INSERT_HASH_PROTOS(udp_ops
, eth_lay3
);
61 for_each_hash_int(ð_lay3
, dissector_set_print_type
, type
);
64 void dissector_init_ethernet(int fnttype
)
66 dissector_init_entry(fnttype
);
67 dissector_init_layer_2(fnttype
);
68 dissector_init_layer_3(fnttype
);
69 dissector_init_exit(fnttype
);
73 lookup_init_ports(PORTS_UDP
);
74 lookup_init_ports(PORTS_TCP
);
75 lookup_init_ports(PORTS_ETHER
);
78 void dissector_cleanup_ethernet(void)
83 lookup_cleanup_ports(PORTS_ETHER
);
84 lookup_cleanup_ports(PORTS_TCP
);
85 lookup_cleanup_ports(PORTS_UDP
);
87 dissector_cleanup_oui();