summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure11
-rw-r--r--geoip.h84
-rw-r--r--netsniff-ng/Makefile10
3 files changed, 101 insertions, 4 deletions
diff --git a/configure b/configure
index ec31bf2..53b5d03 100755
--- a/configure
+++ b/configure
@@ -14,6 +14,7 @@ TOOLS_NOBUILD=""
HAVE_LIBPCAP=0
HAVE_HWTSTAMP=0
+HAVE_LIBGEOIP=0
[ -z $CC ] && CC=cc
@@ -292,12 +293,14 @@ EOF
$CC -o $TMPDIR/geoiptest $TMPDIR/geoiptest.c -lGeoIP >> $TMPDIR/config.log 2>&1
if [ ! -x $TMPDIR/geoiptest ] ; then
echo "[NO]"
+ echo "CONFIG_LIBGEOIP=0" >> Config
MISSING_DEFS=1
- tools_remove "netsniff-ng"
tools_remove "astraceroute"
tools_remove "flowtop"
else
echo "[YES]"
+ echo "CONFIG_LIBGEOIP=1" >> Config
+ HAVE_LIBGEOIP=1
fi
}
@@ -503,6 +506,7 @@ gen_config_hdr()
{
local _version="`git describe --always`"
local _have_libpcap=""
+ local _have_libgeoip=""
local _have_hwts=""
echo "[*] Generating config.h ... "
@@ -515,6 +519,10 @@ gen_config_hdr()
_have_hwts="#define HAVE_HARDWARE_TIMESTAMPING 1"
fi
+ if [ "$HAVE_LIBGEOIP" == "1" ] ; then
+ _have_libgeoip="#define HAVE_GEOIP 1"
+ fi
+
cat > config.h << EOF
#ifndef CONFIG_H
#define CONFIG_H
@@ -525,6 +533,7 @@ gen_config_hdr()
#define FILE_USERNAM ".curvetun/username"
#define GITVERSION "$_version"
$_have_libpcap
+$_have_libgeoip
$_have_hwts
#endif /* CONFIG_H */
EOF
diff --git a/geoip.h b/geoip.h
index b6884e7..c84b335 100644
--- a/geoip.h
+++ b/geoip.h
@@ -1,8 +1,13 @@
#ifndef GEOIPH_H
#define GEOIPH_H
+#include <stdio.h>
#include <netinet/in.h>
+#include "config.h"
+#include "die.h"
+
+#ifdef HAVE_GEOIP
extern void init_geoip(int enforce);
extern void update_geoip(void);
extern int geoip_working(void);
@@ -19,5 +24,84 @@ extern float geoip6_latitude(struct sockaddr_in6 sa);
extern const char *geoip4_as_name(struct sockaddr_in sa);
extern const char *geoip6_as_name(struct sockaddr_in6 sa);
extern void destroy_geoip(void);
+#else
+static inline void init_geoip(int enforce)
+{
+}
+
+static inline void destroy_geoip(void)
+{
+}
+
+static inline void update_geoip(void)
+{
+ panic("No built-in geoip support!\n");
+}
+
+static inline int geoip_working(void)
+{
+ return 0;
+}
+
+static inline const char *geoip4_city_name(struct sockaddr_in sa)
+{
+ return NULL;
+}
+
+static inline const char *geoip6_city_name(struct sockaddr_in6 sa)
+{
+ return NULL;
+}
+
+static inline const char *geoip4_region_name(struct sockaddr_in sa)
+{
+ return NULL;
+}
+
+static inline const char *geoip6_region_name(struct sockaddr_in6 sa)
+{
+ return NULL;
+}
+
+static inline const char *geoip4_country_name(struct sockaddr_in sa)
+{
+ return NULL;
+}
+
+static inline const char *geoip6_country_name(struct sockaddr_in6 sa)
+{
+ return NULL;
+}
+
+static inline float geoip4_longitude(struct sockaddr_in sa)
+{
+ return .0f;
+}
+
+static inline float geoip4_latitude(struct sockaddr_in sa)
+{
+ return .0f;
+}
+
+static inline float geoip6_longitude(struct sockaddr_in6 sa)
+{
+ return .0f;
+}
+
+static inline float geoip6_latitude(struct sockaddr_in6 sa)
+{
+ return .0f;
+}
+
+static inline const char *geoip4_as_name(struct sockaddr_in sa)
+{
+ return NULL;
+}
+
+static inline const char *geoip6_as_name(struct sockaddr_in6 sa)
+{
+ return NULL;
+}
+#endif
#endif /* GEOIPH_H */
diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile
index 2f64c0f..fb913d6 100644
--- a/netsniff-ng/Makefile
+++ b/netsniff-ng/Makefile
@@ -1,5 +1,4 @@
-netsniff-ng-libs = -lGeoIP \
- $(shell pkg-config --libs libnl-3.0) \
+netsniff-ng-libs = $(shell pkg-config --libs libnl-3.0) \
$(shell pkg-config --libs libnl-genl-3.0) \
-lpthread \
-lz
@@ -7,6 +6,9 @@ netsniff-ng-libs = -lGeoIP \
ifeq ($(CONFIG_LIBPCAP), 1)
netsniff-ng-libs += -lpcap
endif
+ifeq ($(CONFIG_LIBGEOIP), 1)
+netsniff-ng-libs += -lGeoIP
+endif
netsniff-ng-objs = dissector.o \
dissector_eth.o \
@@ -58,13 +60,15 @@ netsniff-ng-objs = dissector.o \
ring.o \
tprintf.o \
timer.o \
- geoip.o \
mac80211.o \
netsniff-ng.o
ifeq ($(CONFIG_LIBPCAP), 1)
netsniff-ng-objs += bpf_comp.o
endif
+ifeq ($(CONFIG_LIBGEOIP), 1)
+netsniff-ng-objs += geoip.o
+endif
ifeq ($(CONFIG_HWTSTAMP), 1)
netsniff-ng-objs += tstamping.o
endif