netsniff-ng: fix --bind-cpu option in example command line
[netsniff-ng-new.git] / dissector_eth.c
blob7041aac3d8a9b983482d50c564829ba977ffd090
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
5 */
7 #include <stdint.h>
9 #include "hash.h"
10 #include "proto.h"
11 #include "protos.h"
12 #include "dissector.h"
13 #include "dissector_eth.h"
14 #include "lookup.h"
15 #include "xmalloc.h"
17 struct hash_table eth_lay2;
18 struct hash_table eth_lay3;
20 static inline void dissector_init_entry(int type)
22 dissector_set_print_type(&ethernet_ops, type);
25 static inline void dissector_init_exit(int type)
27 dissector_set_print_type(&none_ops, type);
30 static void dissector_init_layer_2(int type)
32 init_hash(&eth_lay2);
33 INSERT_HASH_PROTOS(arp_ops, eth_lay2);
34 INSERT_HASH_PROTOS(lldp_ops, eth_lay2);
35 INSERT_HASH_PROTOS(vlan_ops, eth_lay2);
36 INSERT_HASH_PROTOS(ipv4_ops, eth_lay2);
37 INSERT_HASH_PROTOS(ipv6_ops, eth_lay2);
38 INSERT_HASH_PROTOS(QinQ_ops, eth_lay2);
39 INSERT_HASH_PROTOS(mpls_uc_ops, eth_lay2);
40 for_each_hash_int(&eth_lay2, dissector_set_print_type, type);
43 static void dissector_init_layer_3(int type)
45 init_hash(&eth_lay3);
46 INSERT_HASH_PROTOS(icmpv4_ops, eth_lay3);
47 INSERT_HASH_PROTOS(icmpv6_ops, eth_lay3);
48 INSERT_HASH_PROTOS(igmp_ops, eth_lay3);
49 INSERT_HASH_PROTOS(ip_auth_ops, eth_lay3);
50 INSERT_HASH_PROTOS(ip_esp_ops, eth_lay3);
51 INSERT_HASH_PROTOS(ipv6_dest_opts_ops, eth_lay3);
52 INSERT_HASH_PROTOS(ipv6_fragm_ops, eth_lay3);
53 INSERT_HASH_PROTOS(ipv6_hop_by_hop_ops, eth_lay3);
54 INSERT_HASH_PROTOS(ipv6_in_ipv4_ops, eth_lay3);
55 INSERT_HASH_PROTOS(ipv6_mobility_ops, eth_lay3);
56 INSERT_HASH_PROTOS(ipv6_no_next_header_ops, eth_lay3);
57 INSERT_HASH_PROTOS(ipv6_routing_ops, eth_lay3);
58 INSERT_HASH_PROTOS(tcp_ops, eth_lay3);
59 INSERT_HASH_PROTOS(udp_ops, eth_lay3);
60 for_each_hash_int(&eth_lay3, dissector_set_print_type, type);
63 void dissector_init_ethernet(int fnttype)
65 dissector_init_entry(fnttype);
66 dissector_init_layer_2(fnttype);
67 dissector_init_layer_3(fnttype);
68 dissector_init_exit(fnttype);
70 lookup_init(LT_PORTS_UDP);
71 lookup_init(LT_PORTS_TCP);
72 lookup_init(LT_ETHERTYPES);
73 lookup_init(LT_OUI);
76 void dissector_cleanup_ethernet(void)
78 free_hash(&eth_lay2);
79 free_hash(&eth_lay3);
81 lookup_cleanup(LT_OUI);
82 lookup_cleanup(LT_ETHERTYPES);
83 lookup_cleanup(LT_PORTS_TCP);
84 lookup_cleanup(LT_PORTS_UDP);