autoconf update to ensure libpcap is not linked against in --enable-udp-server mode

This commit is contained in:
Michael Rash 2014-09-28 22:40:50 -04:00
parent 52d34a70a2
commit ddbba5bc90
7 changed files with 34 additions and 23 deletions

View File

@ -166,19 +166,15 @@ if test "x$want_fuzzing_interfaces" = "xyes"; then
AC_DEFINE([FUZZING_INTERFACES], [1], [Define for fuzzing interfaces support])
fi
dnl Decide whether or not to enable UDP listener mode (no libpcap dependency)
dnl Decide whether or not to enable UDP server mode (no libpcap dependency)
dnl
want_udp_listener=no
want_udp_server=no
AC_ARG_ENABLE([udp-server],
[AS_HELP_STRING([--enable-udp-server],
[Enable UDP listener mode (no libpcap dependency) @<:@default is to disable@:>@])],
[want_udp_listener=$enableval],
[Enable UDP server mode for no libpcap dependency @<:@default is to disable@:>@])],
[want_udp_server=$enableval],
[])
AM_CONDITIONAL([UDP_LISTENER], [test "$want_udp_listener" = yes])
#if test "$want_udp_listener" = yes; then
# AC_DEFINE([UDP_LISTENER], [1], [Define for UDP listener mode])
#fi
AM_CONDITIONAL([UDP_SERVER], [test "$want_udp_server" = yes])
dnl Decide whether or not to enable all warnings with -Wall
dnl
@ -445,17 +441,16 @@ dnl Check for libpcap, gdbm (or ndbm) if we are building the server component
dnl
AS_IF([test "$want_server" = yes], [
use_libpcap=no
AS_IF([test "$want_udp_listener" = no], [
have_libpcap=no
AS_IF([test "$want_udp_server" = no], [
# Looking for libpcap
#
AC_CHECK_LIB([pcap],[pcap_open_live],
[ AC_DEFINE([HAVE_LIBPCAP], [1], [Define if you have libpcap]) ],
[ AC_DEFINE([USE_LIBPCAP], [1], [Define if you have libpcap]) ],
[ AC_MSG_ERROR([fwknopd needs libpcap])]
)
use_libpcap=yes
have_libpcap=yes
])
AM_CONDITIONAL([USE_LIBPCAP], [test x$use_libpcap = xyes])
AS_IF([test "$want_digest_cache" = yes], [
use_ndbm=no
@ -694,8 +689,8 @@ if [test "$want_server" = "yes" ]; then
firewall type: $FIREWALL_TYPE
firewall program path: $FIREWALL_EXE
"
if [test "$want_udp_listener" = "yes" ]; then
echo " UDP listener mode enabled, no libpcap dependency
if [test "$want_udp_server" = "yes" ]; then
echo " UDP server mode enabled, no libpcap dependency
"
fi

View File

@ -16,7 +16,7 @@ fwknopd_SOURCES = fwknopd.c fwknopd.h config_init.c config_init.h \
fwknopd_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a
if USE_LIBPCAP
if !UDP_SERVER
fwknopd_LDADD += -lpcap
endif

View File

@ -815,7 +815,15 @@ validate_options(fko_srv_options_t *opts)
/* Enable UDP server.
*/
if(opts->config[CONF_ENABLE_UDP_SERVER] == NULL)
{
if((strncasecmp(DEF_ENABLE_UDP_SERVER, "Y", 1) == 0) &&
!opts->enable_udp_server)
{
log_msg(LOG_ERR, "pcap capture not enabled, forcing UDP server mode");
opts->enable_udp_server = 1;
}
set_config_entry(opts, CONF_ENABLE_UDP_SERVER, DEF_ENABLE_UDP_SERVER);
}
/* UDP Server port.
*/

View File

@ -31,7 +31,6 @@
#include "fwknopd.h"
#include "access.h"
#include "config_init.h"
#include "pcap_capture.h"
#include "log_msg.h"
#include "utils.h"
#include "fw_util.h"
@ -40,6 +39,10 @@
#include "tcp_server.h"
#include "udp_server.h"
#if USE_LIBPCAP
#include "pcap_capture.h"
#endif
/* Prototypes
*/
static int check_dir_path(const char * const path,

View File

@ -41,7 +41,7 @@
#include <sys/stat.h>
#endif
#if HAVE_LIBPCAP
#if USE_LIBPCAP
#include <pcap.h>
#endif
@ -101,7 +101,11 @@
#define DEF_ENABLE_SPA_OVER_HTTP "N"
#define DEF_ENABLE_TCP_SERVER "N"
#define DEF_TCPSERV_PORT "62201"
#define DEF_ENABLE_UDP_SERVER "N"
#if USE_LIBPCAP
#define DEF_ENABLE_UDP_SERVER "N"
#else
#define DEF_ENABLE_UDP_SERVER "Y"
#endif
#define DEF_UDPSERV_PORT "62201"
#define DEF_UDPSERV_SELECT_TIMEOUT "500000" /* half a second (in microseconds) */
#define DEF_SYSLOG_IDENTITY MY_NAME

View File

@ -29,7 +29,6 @@
*****************************************************************************
*/
#if HAVE_LIBPCAP
#include <pcap.h>
@ -46,6 +45,8 @@
#include <sys/wait.h>
#endif
#if USE_LIBPCAP
/* The pcap capture routine.
*/
int
@ -335,6 +336,6 @@ pcap_capture(fko_srv_options_t *opts)
return(0);
}
#endif /* HAVE_LIBPCAP */
#endif /* USE_LIBPCAP */
/***EOF***/

View File

@ -46,7 +46,7 @@
/* Prototypes
*/
#if HAVE_LIBPCAP
#if USE_LIBPCAP
void process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header, const unsigned char *packet);
#endif