summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-06-16 10:00:55 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-06-16 10:05:16 +0200
commitabec60cfddd94fa5f856c071f5b5861e81899f8a (patch)
tree2b2eb12a09ac8d54aa14b2a8bef56326ac517f8f
parent91149e038fd865e8f977d32fff4de5bfb04f9f6d (diff)
dissector: Get rid of now unnecessary HAVE_DISSECTOR_PROTOS
Since commit 1cc762a ("lookup: Move UDP/TCP port and Ethernet type lookup into own module") the netsniff-ng tool is the only one using the dissector infrastructure. Thus we no longer need to conditionally device HAVE_DISSECTOR_PROTOS, since netsniff-ng is the only tool defining this. While at it, also remove the __WITH_PROTOS macro which is checked in dissector_init_ethernet/dissector_cleanup_ethernet but is defined nowhere. This will cause the functions to be called from both the ethernet and ieee80211 dissectors, thus make sure we check the initialization state before freeing as well. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--dissector_80211.c6
-rw-r--r--dissector_80211.h11
-rw-r--r--dissector_eth.c13
-rw-r--r--dissector_eth.h11
-rw-r--r--dissector_netlink.c5
-rw-r--r--dissector_netlink.h12
-rw-r--r--netsniff-ng/Makefile2
-rw-r--r--oui.c3
-rw-r--r--trafgen/Makefile2
9 files changed, 6 insertions, 59 deletions
diff --git a/dissector_80211.c b/dissector_80211.c
index e638e1e..28f5526 100644
--- a/dissector_80211.c
+++ b/dissector_80211.c
@@ -15,7 +15,6 @@
struct hash_table ieee80211_lay2;
-#ifdef HAVE_DISSECTOR_PROTOS
static inline void dissector_init_entry(int type)
{
dissector_set_print_type(&ieee80211_ops, type);
@@ -32,11 +31,6 @@ static void dissector_init_layer_2(int type)
// INSERT_HASH_PROTOS(blubber_ops, ieee80211_lay2);
for_each_hash_int(&ieee80211_lay2, dissector_set_print_type, type);
}
-#else
-static inline void dissector_init_entry(int type __maybe_unused) {}
-static inline void dissector_init_exit(int type __maybe_unused) {}
-static void dissector_init_layer_2(int type __maybe_unused) {}
-#endif
void dissector_init_ieee80211(int fnttype)
{
diff --git a/dissector_80211.h b/dissector_80211.h
index 47b50a2..44bfc82 100644
--- a/dissector_80211.h
+++ b/dissector_80211.h
@@ -15,7 +15,6 @@ extern struct hash_table ieee80211_lay2;
extern void dissector_init_ieee80211(int fnttype);
extern void dissector_cleanup_ieee80211(void);
-#ifdef HAVE_DISSECTOR_PROTOS
static inline struct protocol *dissector_get_ieee80211_entry_point(void)
{
return &ieee80211_ops;
@@ -25,15 +24,5 @@ static inline struct protocol *dissector_get_ieee80211_exit_point(void)
{
return &none_ops;
}
-#else
-static inline struct protocol *dissector_get_ieee80211_entry_point(void)
-{
- return NULL;
-}
-static inline struct protocol *dissector_get_ieee80211_exit_point(void)
-{
- return NULL;
-}
-#endif
#endif /* DISSECTOR_80211_H */
diff --git a/dissector_eth.c b/dissector_eth.c
index 035cdfa..60d8429 100644
--- a/dissector_eth.c
+++ b/dissector_eth.c
@@ -18,7 +18,6 @@
struct hash_table eth_lay2;
struct hash_table eth_lay3;
-#ifdef HAVE_DISSECTOR_PROTOS
static inline void dissector_init_entry(int type)
{
dissector_set_print_type(&ethernet_ops, type);
@@ -61,13 +60,6 @@ static void dissector_init_layer_3(int type)
INSERT_HASH_PROTOS(udp_ops, eth_lay3);
for_each_hash_int(&eth_lay3, dissector_set_print_type, type);
}
-#else
-static inline void dissector_init_entry(int type __maybe_unused) {}
-static inline void dissector_init_exit(int type __maybe_unused) {}
-static void dissector_init_layer_2(int type __maybe_unused) {}
-static void dissector_init_layer_3(int type __maybe_unused) {}
-#endif
-
void dissector_init_ethernet(int fnttype)
{
@@ -76,9 +68,8 @@ void dissector_init_ethernet(int fnttype)
dissector_init_layer_3(fnttype);
dissector_init_exit(fnttype);
-#ifdef __WITH_PROTOS
dissector_init_oui();
-#endif
+
lookup_init_ports(PORTS_UDP);
lookup_init_ports(PORTS_TCP);
lookup_init_ports(PORTS_ETHER);
@@ -93,7 +84,5 @@ void dissector_cleanup_ethernet(void)
lookup_cleanup_ports(PORTS_TCP);
lookup_cleanup_ports(PORTS_UDP);
-#ifdef __WITH_PROTOS
dissector_cleanup_oui();
-#endif
}
diff --git a/dissector_eth.h b/dissector_eth.h
index 6d14809..79334d6 100644
--- a/dissector_eth.h
+++ b/dissector_eth.h
@@ -16,7 +16,6 @@ extern struct hash_table eth_lay3;
extern void dissector_init_ethernet(int fnttype);
extern void dissector_cleanup_ethernet(void);
-#ifdef HAVE_DISSECTOR_PROTOS
static inline struct protocol *dissector_get_ethernet_entry_point(void)
{
return &ethernet_ops;
@@ -26,15 +25,5 @@ static inline struct protocol *dissector_get_ethernet_exit_point(void)
{
return &none_ops;
}
-#else
-static inline struct protocol *dissector_get_ethernet_entry_point(void)
-{
- return NULL;
-}
-static inline struct protocol *dissector_get_ethernet_exit_point(void)
-{
- return NULL;
-}
-#endif
#endif /* DISSECTOR_ETH_H */
diff --git a/dissector_netlink.c b/dissector_netlink.c
index 387f198..2b23a99 100644
--- a/dissector_netlink.c
+++ b/dissector_netlink.c
@@ -7,7 +7,6 @@
#include "dissector.h"
#include "dissector_netlink.h"
-#ifdef HAVE_DISSECTOR_PROTOS
static inline void dissector_init_entry(int type)
{
dissector_set_print_type(&nlmsg_ops, type);
@@ -17,10 +16,6 @@ static inline void dissector_init_exit(int type)
{
dissector_set_print_type(&none_ops, type);
}
-#else
-static inline void dissector_init_entry(int type __maybe_unused) {}
-static inline void dissector_init_exit(int type __maybe_unused) {}
-#endif
void dissector_init_netlink(int fnttype)
{
diff --git a/dissector_netlink.h b/dissector_netlink.h
index 185881c..9d30e56 100644
--- a/dissector_netlink.h
+++ b/dissector_netlink.h
@@ -12,7 +12,6 @@
extern void dissector_init_netlink(int fnttype);
extern void dissector_cleanup_netlink(void);
-#ifdef HAVE_DISSECTOR_PROTOS
static inline struct protocol *dissector_get_netlink_entry_point(void)
{
return &nlmsg_ops;
@@ -22,16 +21,5 @@ static inline struct protocol *dissector_get_netlink_exit_point(void)
{
return &none_ops;
}
-#else
-static inline struct protocol *dissector_get_netlink_entry_point(void)
-{
- return NULL;
-}
-
-static inline struct protocol *dissector_get_netlink_exit_point(void)
-{
- return NULL;
-}
-#endif /* HAVE_DISSECTOR_PROTOS */
#endif /* DISSECTOR_NETLINK_H */
diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile
index c89d32b..bc5e032 100644
--- a/netsniff-ng/Makefile
+++ b/netsniff-ng/Makefile
@@ -77,7 +77,7 @@ endif
netsniff-ng-eflags = $(shell pkg-config --cflags libnl-3.0) \
$(shell pkg-config --cflags libnl-genl-3.0) \
- -DHAVE_DISSECTOR_PROTOS -DNEED_TCPDUMP_LIKE_FILTER
+ -DNEED_TCPDUMP_LIKE_FILTER
netsniff-ng-confs = ether.conf \
tcp.conf \
diff --git a/oui.c b/oui.c
index 2ef8dff..94b6ba1 100644
--- a/oui.c
+++ b/oui.c
@@ -109,6 +109,9 @@ static int dissector_cleanup_oui_hash(void *ptr)
void dissector_cleanup_oui(void)
{
+ if (!initialized)
+ return;
+
for_each_hash(&oui, dissector_cleanup_oui_hash);
free_hash(&oui);
initialized = false;
diff --git a/trafgen/Makefile b/trafgen/Makefile
index e41a6da..d395b16 100644
--- a/trafgen/Makefile
+++ b/trafgen/Makefile
@@ -26,7 +26,7 @@ trafgen-yaac = trafgen_parser.tab.o
trafgen-eflags = $(shell pkg-config --cflags libnl-3.0) \
$(shell pkg-config --cflags libnl-genl-3.0) \
- -DHAVE_DISSECTOR_PROTOS -I..
+ -I..
trafgen-confs = trafgen_stddef.h