trafgen uses libnl only to inject mac80211 frames but
it might be not needed in some embedded or switch environments,
so lets make possible to disable this feature.

In case if --rfraw option will be used - user will get the panic message.

Signed-off-by: Vadim Kochan <vadi...@gmail.com>
---
 mac80211.c       |  1 -
 mac80211.h       | 15 +++++++++++++++
 trafgen/Makefile | 21 +++++++++++++++------
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/mac80211.c b/mac80211.c
index f22b600..9aea5a0 100644
--- a/mac80211.c
+++ b/mac80211.c
@@ -24,7 +24,6 @@
 #include <netlink/msg.h>
 #include <netlink/attr.h>
 
-#include "die.h"
 #include "str.h"
 #include "dev.h"
 #include "mac80211.h"
diff --git a/mac80211.h b/mac80211.h
index dea4ae0..692de4c 100644
--- a/mac80211.h
+++ b/mac80211.h
@@ -1,7 +1,22 @@
 #ifndef MAC80211_H
 #define MAC80211_H
 
+#include "die.h"
+#include "config.h"
+
+#ifndef CONFIG_LIBNL
+static inline void enter_rfmon_mac80211(const char *device, char **mondev)
+{
+    panic("enter_rfmon_mac80211: CONFIG_LIBNL option needs to be enabled\n");
+}
+
+static inline void leave_rfmon_mac80211(const char *mondev)
+{
+    panic("leave_rfmon_mac80211: CONFIG_LIBNL option needs to be enabled\n");
+}
+#else
 extern void enter_rfmon_mac80211(const char *device, char **mondev);
 extern void leave_rfmon_mac80211(const char *mondev);
+#endif /* CONFIG_LIBNL */
 
 #endif /* MAC80211_H */
diff --git a/trafgen/Makefile b/trafgen/Makefile
index 3f78f07..876ed93 100644
--- a/trafgen/Makefile
+++ b/trafgen/Makefile
@@ -1,6 +1,9 @@
-trafgen-libs = $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --libs 
libnl-3.0) \
-               $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --libs 
libnl-genl-3.0) \
-               -lm
+trafgen-libs = -lm
+
+ifeq ($(CONFIG_LIBNL), 1)
+trafgen-libs +=        $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) 
$(PKG_CONFIG) --libs libnl-3.0) \
+               $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --libs 
libnl-genl-3.0)
+endif
 
 trafgen-objs = xmalloc.o \
                die.o \
@@ -13,7 +16,6 @@ trafgen-objs =        xmalloc.o \
                str.o \
                sig.o \
                sock.o \
-               mac80211.o \
                ring_tx.o \
                ring.o \
                timer.o \
@@ -27,13 +29,20 @@ trafgen-objs =      xmalloc.o \
                trafgen_parser.tab.o \
                trafgen.o
 
+ifeq ($(CONFIG_LIBNL), 1)
+trafgen-objs += mac80211.o
+endif
+
 trafgen-lex =  trafgen_lexer.yy.o
 
 trafgen-yaac = trafgen_parser.tab.o
 
+trafgen-eflags = -I..
+
+ifeq ($(CONFIG_LIBNL), 1)
 trafgen-eflags = $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) 
--cflags libnl-3.0) \
-                $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) 
--cflags libnl-genl-3.0) \
-                -I..
+                $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) 
--cflags libnl-genl-3.0)
+endif
 
 trafgen-confs =        trafgen_stddef.h
 
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to