Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor autoconf changes to port to openbsd #101

Merged
merged 1 commit into from Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions bootstrap
@@ -0,0 +1,19 @@
#!/bin/sh
#
# desc: simple script to run all auto commands
#
####

# defines needed for OpenBSD
AUTOMAKE_VERSION=1.15;export AUTOMAKE_VERSION
AUTOCONF_VERSION=2.69;export AUTOCONF_VERSION

if [ ! -d config ]; then
mkdir config
fi

aclocal
automake --gnu --add-missing
autoconf
autoheader

46 changes: 46 additions & 0 deletions configure.ac
Expand Up @@ -10,6 +10,52 @@ AC_CONFIG_HEADERS([src/config.h])
# Checks for programs.
AC_PROG_CC

AC_CANONICAL_HOST

dnl Checks for OS type.
case "$host" in
*-freebsd*)
AC_DEFINE([BSD_DERIVED],1,BSD_DERIVED)
AC_DEFINE([FREEBSD],1,FREEBSD)
LDFLAGS="${LDFLAGS}"
;;
*-netbsd*)
AC_DEFINE([BSD_DERIVED],1,BSD_DERIVED)
AC_DEFINE([NETBSD],1,NETBSD)
;;
*-openbsd*)
AC_DEFINE([BSD_DERIVED],1,BSD_DERIVED)
AC_DEFINE([OPENBSD],1,OPENBSD)
CFLAGS="${CFLAGS} -Wbounded"
LDFLAGS="${LDFLAGS}"
;;
*-apple*)
AC_DEFINE([BSD_DERIVED],1,BSD_DERIVED)
AC_DEFINE([MACOS],1,MACOS)
LDFLAGS="${LDFLAGS} -L/sw/lib"
AC_SUBST(more_incl)
more_incl=-I/sw/include
;;
*-linux*)
AC_DEFINE([SYSV_DERIVED],1,SYSV_DERIVED)
AC_DEFINE([LINUX],1,LINUX)
LDFLAGS="${LDFLAGS}"
;;
*-solaris*)
AC_DEFINE([SYSV_DERIVED],1,SYSV_DERIVED)
AC_DEFINE([SOLARIS],1,SOLARIS)
LDFLAGS="${LDFLAGS}"
;;
*-aix*)
AC_DEFINE([SYSV_DERIVED],1,SYSV_DERIVED)
AC_DEFINE([AIX],1,AIX)
;;
*-hpux*)
AC_DEFINE([SYSV_DERIVED],1,SYSV_DERIVED)
AC_DEFINE([HPUX],1,HPUX)
;;
esac

# Enable debug output.
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debug output]))
Expand Down
12 changes: 6 additions & 6 deletions src/dns.c
Expand Up @@ -563,7 +563,7 @@ void update_pdns_record_asset(packetinfo *pi, pdns_record *pr,
/* We have this, update and if its over 24h since last print -
print it, then return */
passet->seen++;
passet->last_seen = pi->pheader->ts;
memcpy( &passet->last_seen, &pi->pheader->ts, sizeof( struct timeval ) );
passet->af = pi->cxt->af;
passet->cip = pi->cxt->s_ip; /* This should always be the client IP */
passet->sip = pi->cxt->d_ip; /* This should always be the server IP */
Expand Down Expand Up @@ -606,8 +606,8 @@ void update_pdns_record_asset(packetinfo *pi, pdns_record *pr,
passet->next = NULL;

/* Populate new values */
passet->first_seen = pi->pheader->ts;
passet->last_seen = pi->pheader->ts;
memcpy( &passet->first_seen, &pi->pheader->ts, sizeof( struct timeval ) );
memcpy( &passet->last_seen, &pi->pheader->ts, sizeof( struct timeval ) );
passet->af = pi->cxt->af;
passet->cip = pi->cxt->s_ip; /* This should always be the client IP */
passet->sip = pi->cxt->d_ip; /* This should always be the server IP */
Expand Down Expand Up @@ -1193,7 +1193,7 @@ pdns_record *get_pdns_record(uint64_t dnshash, packetinfo *pi,
if (strcmp((const char *)domain_name,
(const char *)pdnsr->qname) == 0) {
/* match :) */
pdnsr->last_seen = pi->pheader->ts;
memcpy( &pdnsr->last_seen, &pi->pheader->ts, sizeof( struct timeval ) );
pdnsr->af = pi->cxt->af;
pdnsr->cip = pi->cxt->s_ip; /* This should always be the client IP */
pdnsr->sip = pi->cxt->d_ip; /* This should always be the server IP */
Expand All @@ -1213,8 +1213,8 @@ pdns_record *get_pdns_record(uint64_t dnshash, packetinfo *pi,
head->prev = pdnsr;

/* Populate new values */
pdnsr->first_seen = pi->pheader->ts;
pdnsr->last_seen = pi->pheader->ts;
memcpy( &pdnsr->first_seen, &pi->pheader->ts, sizeof( struct timeval ) );
memcpy( &pdnsr->last_seen, &pi->pheader->ts, sizeof( struct timeval ) );
pdnsr->af = pi->cxt->af;
pdnsr->nxflag = 0;
pdnsr->cip = pi->cxt->s_ip; /* This should always be the client IP */
Expand Down
14 changes: 13 additions & 1 deletion src/passivedns.c
Expand Up @@ -130,7 +130,7 @@ void got_packet(u_char *useless, const struct pcap_pkthdr *pheader,
pi->packet = packet;
pi->pheader = pheader;
set_pkt_end_ptr (pi);
config.tstamp = pi->pheader->ts; /* Global */
memcpy( &config.tstamp, &pi->pheader->ts, sizeof( struct timeval ) ); /* Global */

if (signal_reopen_log_files)
reopen_log_files();
Expand All @@ -144,9 +144,11 @@ void got_packet(u_char *useless, const struct pcap_pkthdr *pheader,
case DLT_RAW:
prepare_raw(pi);
break;
#ifdef DLT_LINUX_SSL
case DLT_LINUX_SLL:
prepare_sll(pi);
break;
#endif
default:
prepare_eth(pi);
check_vlan(pi);
Expand Down Expand Up @@ -431,8 +433,13 @@ int connection_tracking(packetinfo *pi)
ip_dst = &PI_IP6DST(pi);
}
else {
#ifdef BSD_DERIVED
ips.__u6_addr.__u6_addr32[0] = pi->ip4->ip_src;
ipd.__u6_addr.__u6_addr32[0] = pi->ip4->ip_dst;
#else
ips.s6_addr32[0] = pi->ip4->ip_src;
ipd.s6_addr32[0] = pi->ip4->ip_dst;
#endif
ip_src = &ips;
ip_dst = &ipd;
}
Expand Down Expand Up @@ -524,8 +531,13 @@ connection *cxt_new(packetinfo *pi)
cxt->d_ip = PI_IP6DST(pi);
}
else {
#ifdef BSD_DERIVED
ips.__u6_addr.__u6_addr32[0] = pi->ip4->ip_src;
ipd.__u6_addr.__u6_addr32[0] = pi->ip4->ip_dst;
#else
ips.s6_addr32[0] = pi->ip4->ip_src;
ipd.s6_addr32[0] = pi->ip4->ip_dst;
#endif
cxt->s_ip = ips;
cxt->d_ip = ipd;
}
Expand Down
8 changes: 4 additions & 4 deletions src/passivedns.h
Expand Up @@ -269,7 +269,7 @@ typedef struct _connection {
#define ISSET_SERVICE_UNKNOWN(pi) (pi->cxt->check & CXT_SERVICE_UNKNOWN_SET)
#define ISSET_CLIENT_UNKNOWN(pi) (pi->cxt->check & CXT_CLIENT_UNKNOWN_SET)

#ifdef OSX
#ifdef BSD_DERIVED
// sidds darwin ports
#define IP4ADDR(ip) (ip)->__u6_addr.__u6_addr32[0]

Expand Down Expand Up @@ -330,7 +330,7 @@ typedef struct _connection {
CMP_PORT((cxt1)->s_port, (sp)) && CMP_PORT((cxt1)->d_port, (dp))))

/* clear the address structure by setting all fields to 0 */
#ifdef OSX
#ifdef BSD_DERIVED
#define CLEAR_ADDR(a) { \
(a)->__u6_addr.__u6_addr32[0] = 0; \
(a)->__u6_addr.__u6_addr32[1] = 0; \
Expand All @@ -349,7 +349,7 @@ typedef struct _connection {
#define CXT_HASH4(src,dst,sp,dp,pr) \
((src + dst + sp + dp + pr) % BUCKET_SIZE)

#ifndef OSX
#ifndef BSD_DERIVED
#define CXT_HASH6(src,dst,sp,dp,pr) \
(( \
(src)->s6_addr32[0] + (src)->s6_addr32[1] + \
Expand All @@ -358,7 +358,7 @@ typedef struct _connection {
(dst)->s6_addr32[2] + (dst)->s6_addr32[3] + \
sp + dp + pr ) % BUCKET_SIZE)
#else
#define CXT_HASH6(src,dest,sp,dp,pr) \
#define CXT_HASH6(src,dst,sp,dp,pr) \
(( \
(src)->__u6_addr.__u6_addr32[0] + (src)->__u6_addr.__u6_addr32[1] + \
(src)->__u6_addr.__u6_addr32[2] + (src)->__u6_addr.__u6_addr32[3] + \
Expand Down