#! /bin/sh
-# From configure.in Revision: 1.143 .
+# From configure.in Revision: 1.144 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59.
#
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--without-gcc don't use gcc
- --with-pcap=TYPE use packet capture TYPE
--with-sita include SITA support
+ --with-pcap=TYPE use packet capture TYPE
--with-dag[=DIR] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)
--with-dag-includes=DIR Endace DAG include directory
--with-dag-libraries=DIR Endace DAG library directory
echo "$as_me:$LINENO: result: ${enable_protochain}" >&5
echo "${ECHO_T}${enable_protochain}" >&6
+#
+# SITA support is mutually exclusive with native capture support;
+# "--with-sita" selects SITA support.
+#
+
+# Check whether --with-sita or --without-sita was given.
+if test "${with_sita+set}" = set; then
+ withval="$with_sita"
+
+
+cat >>confdefs.h <<\_ACEOF
+#define SITA 1
+_ACEOF
+
+ { echo "$as_me:$LINENO: Enabling SITA ACN support" >&5
+echo "$as_me: Enabling SITA ACN support" >&6;}
+ V_PCAP=sita
+ V_FINDALLDEVS=sita
+
+else
+
if test -z "$with_pcap" && test "$cross_compiling" = yes; then
{ { echo "$as_me:$LINENO: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&5
echo "$as_me: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&2;}
fi
+fi;
+
echo "$as_me:$LINENO: checking if --enable-ipv6 option is specified" >&5
echo $ECHO_N "checking if --enable-ipv6 option is specified... $ECHO_C" >&6
# Check whether --enable-ipv6 or --disable-ipv6 was given.
_ACEOF
fi
-
-# Check whether --with-sita or --without-sita was given.
-if test "${with_sita+set}" = set; then
- withval="$with_sita"
-
-
-cat >>confdefs.h <<\_ACEOF
-#define SITA 1
-_ACEOF
-
- SSRC="pcap-sita.c"
- { echo "$as_me:$LINENO: Enabling SITA ACN support" >&5
-echo "$as_me: Enabling SITA ACN support" >&6;}
- V_FINDALLDEVS=sita
-
-fi;
;;
dag)
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.132 2008-01-05 22:32:31 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.133 2008-01-06 20:23:17 guy Exp $ (LBL)";
#endif
/*
#include "pcap-bt-linux.h"
#endif
-#ifdef SITA
-#include "pcap-sita.h"
-#endif
-
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
handle->getnonblock_op = pcap_getnonblock_fd;
handle->setnonblock_op = pcap_setnonblock_fd;
handle->close_op = pcap_close_linux;
-
-#ifdef SITA
- handle->read_op = pcap_read_acn;
- handle->stats_op = pcap_stats_acn;
-#else
handle->read_op = pcap_read_linux;
handle->stats_op = pcap_stats_linux;
-#endif
/*
* NULL and "any" are special devices which give us the hint to
* trying both methods with the newer method preferred.
*/
-#ifdef SITA
- live_open_ok = acn_open_live((unsigned char *)device, ebuf, &handle->linktype);
- handle->md.clear_promisc = promisc;
- handle->fd = live_open_ok;
- handle->bufsize = handle->snapshot;
-#else
if ((err = live_open_new(handle, device, promisc, to_ms, ebuf)) == 1) {
live_open_ok = 1;
if (live_open_mmap(handle, ebuf) == 1)
if (live_open_old(handle, device, promisc, to_ms, ebuf))
live_open_ok = 1;
}
-#endif
if (!live_open_ok) {
/*
* Both methods to open the packet socket failed. Tidy
return NULL;
}
-#ifndef SITA
/*
* Compute the buffer size.
*
}
handle->bufsize = handle->snapshot;
}
-#endif
/* Allocate the buffer */
return -1;
}
-#ifdef SITA
- return acn_setfilter(handle->fd, filter);
-#else
/* Make our private copy of the filter */
if (install_bpf_program(handle, filter) < 0)
#endif /* SO_ATTACH_FILTER */
return 0;
-#endif /* SITA */
}
/*
static void pcap_close_linux( pcap_t *handle )
{
-#ifdef SITA
- pcap_close_acn(handle);
-#else
struct pcap *p, *prevp;
struct ifreq ifr;
free(handle->md.device);
handle->md.device = NULL;
pcap_close_common(handle);
-#endif /* SITA */
}
/*
#include <arpa/inet.h>
#include "pcap-int.h"
+#include "pcap-sita.h"
+
/* non-configureable manifests follow */
#define IOP_SNIFFER_PORT 49152 /* TCP port on the IOP used for 'distributed pcap' usage */
pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
-static void dump_interface_list() {
+static void dump_interface_list(void) {
pcap_if_t *iff;
pcap_addr_t *addr;
int longest_name_len = 0;
}
}
-static dump(unsigned char *ptr, int i, int indent) {
+static void dump(unsigned char *ptr, int i, int indent) {
fprintf(stderr, "%*s", indent, " ");
for (; i > 0; i--) {
fprintf(stderr, "%2.2x ", *ptr++);
fprintf(stderr, "\n");
}
-static void dump_interface_list_p() {
+static void dump_interface_list_p(void) {
pcap_if_t *iff;
pcap_addr_t *addr;
- int longest_name_len = 0;
- char *n, *d, *f;
int if_number = 0;
iff = acn_if_list;
}
}
-static void dump_unit_table() {
+static void dump_unit_table(void) {
int chassis, geoslot;
iface_t *p;
}
static void empty_unit(int chassis, int geoslot) {
- iface_t *p, *cur;
unit_t *u = &units[chassis][geoslot];
empty_unit_iface(u);
}
}
-static void empty_unit_table() {
+static void empty_unit_table(void) {
int chassis, geoslot;
for (chassis = 0; chassis <= MAX_CHASSIS; chassis++) {
}
}
-void pcap_close_acn(pcap_t *handle) {
+static void pcap_close_acn(pcap_t *handle) {
int chassis, geoslot;
unit_t *u;
}
}
-static void acn_freealldevs() {
+static void acn_freealldevs(void) {
pcap_if_t *iff, *next_iff;
pcap_addr_t *addr, *next_addr;
return static_buf;
}
-static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, ulong iftype) {
+static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, bpf_u_int32 iftype) {
iface_t *iface_ptr, *iface;
char *name;
char buf[32];
return strcmp(s1_p2, s2_p2); /* otherwise we return the result of comparing the 2nd half of the string */
}
-static void sort_if_table() {
+static void sort_if_table(void) {
pcap_if_t *p1, *p2, *prev, *temp;
int has_swapped;
int address_count;
struct sockaddr_in *s;
char *newname;
- ulong interfaceType;
+ bpf_u_int32 interfaceType;
unsigned char flags;
prev_iff = 0;
}
ptr++;
- interfaceType = ntohl(*(ulong *)ptr);
+ interfaceType = ntohl(*(bpf_u_int32 *)ptr);
ptr += 4; /* skip over the interface type */
flags = *ptr++;
bzero((char *)s, sizeof(struct sockaddr_in));
addr->addr = (struct sockaddr *)s;
s->sin_family = AF_INET;
- s->sin_addr.s_addr = *(ulong *)(ptr + 1); /* copy the address in */
+ s->sin_addr.s_addr = *(bpf_u_int32 *)(ptr + 1); /* copy the address in */
ptr += *ptr; /* now move the pointer forwards according to the specified length of the address */
}
ptr++; /* then forwards one more for the 'length of the address' field */
bzero((char *)s, sizeof(struct sockaddr_in));
addr->netmask = (struct sockaddr *)s;
s->sin_family = AF_INET;
- s->sin_addr.s_addr = *(ulong*)(ptr + 1);
+ s->sin_addr.s_addr = *(bpf_u_int32*)(ptr + 1);
ptr += *ptr;
}
ptr++;
bzero((char *)s, sizeof(struct sockaddr_in));
addr->broadaddr = (struct sockaddr *)s;
s->sin_family = AF_INET;
- s->sin_addr.s_addr = *(ulong*)(ptr + 1);
+ s->sin_addr.s_addr = *(bpf_u_int32*)(ptr + 1);
ptr += *ptr;
}
ptr++;
bzero((char *)s, sizeof(struct sockaddr_in));
addr->dstaddr = (struct sockaddr *)s;
s->sin_family = AF_INET;
- s->sin_addr.s_addr = *(ulong*)(ptr + 1);
+ s->sin_addr.s_addr = *(bpf_u_int32*)(ptr + 1);
ptr += *ptr;
}
ptr++;
return 1;
}
-static void wait_for_all_answers() {
+static void wait_for_all_answers(void) {
int retval;
struct timeval tv;
int fd;
*errbuf++ = byte; /* stick it in */
*errbuf = '\0'; /* ensure the string is null terminated just in case we might exceed the buffer's size */
}
- if (byte == '\0')
+ if (byte == '\0') {
if (len > 1) { return errbuf; }
else { return NULL; }
+ }
}
}
return 0;
}
-int pcap_stats_acn(pcap_t *handle, struct pcap_stat *ps) {
+static int pcap_stats_acn(pcap_t *handle, struct pcap_stat *ps) {
unsigned char buf[12];
send_to_fd(handle->fd, 1, (unsigned char *)"S"); /* send the get_stats command to the IOP */
return 0;
}
-int acn_open_live(char *name, char *errbuf, int *linktype) { /* returns 0 on error, else returns the file descriptor */
+static int acn_open_live(const char *name, char *errbuf, int *linktype) { /* returns 0 on error, else returns the file descriptor */
int chassis, geoslot;
unit_t *u;
iface_t *p;
open_with_IOP(u, LIVE); /* start a connection with that IOP */
send_to_fd(u->fd, strlen(p->IOPname)+1, (unsigned char *)p->IOPname); /* send the IOP's interface name, and a terminating null */
if (get_error_response(u->fd, errbuf)) {
- return 0;
+ return -1;
}
return u->fd; /* and return that open descriptor */
}
}
}
}
- return 0; /* if the interface wasn't found, return an error */
+ return -1; /* if the interface wasn't found, return an error */
}
-void acn_start_monitor(int fd, int snaplen, int timeout, int promiscuous, int direction) {
+static void acn_start_monitor(int fd, int snaplen, int timeout, int promiscuous, int direction) {
unsigned char buf[8];
unit_t *u;
//printf("acn_start_monitor() complete\n"); // fulko
}
-int acn_setfilter(int fd, struct bpf_program *bpf) {
+static int pcap_inject_acn(pcap_t *p, const void *buf _U_, size_t size _U_) {
+ strlcpy(p->errbuf, "Sending packets isn't supported on ACN adapters",
+ PCAP_ERRBUF_SIZE);
+ return (-1);
+}
+
+static int pcap_setfilter_acn(pcap_t *handle, struct bpf_program *bpf) {
+ int fd = handle->fd;
int count;
struct bpf_insn *p;
uint16_t shortInt;
return 0;
}
-int acn_read_n_bytes_with_timeout(pcap_t *handle, int count) {
+static int pcap_setdirection_acn(pcap_t *handle, pcap_direction_t d) {
+ snprintf(handle->errbuf, sizeof(handle->errbuf),
+ "Setting direction is not supported on ACN adapters");
+ return -1;
+}
+
+static int acn_read_n_bytes_with_timeout(pcap_t *handle, int count) {
struct timeval tv;
int retval, fd;
fd_set r_fds;
return 0;
}
-int pcap_read_acn(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user) {
+static int pcap_read_acn(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user) {
#define HEADER_SIZE (4 * 4)
unsigned char packet_header[HEADER_SIZE];
struct pcap_pkthdr pcap_header;
callback(user, &pcap_header, handle->bp); /* call the user supplied callback function */
return 1;
}
+
+pcap_t *pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf) {
+ pcap_t *handle;
+ int fd;
+
+ /* Allocate a handle for this session. */
+
+ handle = malloc(sizeof(*handle));
+ if (handle == NULL) {
+ snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
+ pcap_strerror(errno));
+ return NULL;
+ }
+
+ /* Initialize some components of the pcap structure. */
+
+ memset(handle, 0, sizeof(*handle));
+ handle->snapshot = snaplen;
+ handle->md.timeout = to_ms;
+
+ handle->inject_op = pcap_inject_acn;
+ handle->setfilter_op = pcap_setfilter_acn;
+ handle->setdirection_op = pcap_setdirection_acn;
+ handle->set_datalink_op = NULL; /* can't change data link type */
+ handle->getnonblock_op = pcap_getnonblock_fd;
+ handle->setnonblock_op = pcap_setnonblock_fd;
+ handle->close_op = pcap_close_acn;
+ handle->read_op = pcap_read_acn;
+ handle->stats_op = pcap_stats_acn;
+
+ fd = acn_open_live(device, ebuf, &handle->linktype);
+ if (fd == -1) {
+ free(handle);
+ return NULL;
+ }
+ handle->md.clear_promisc = promisc;
+ handle->fd = fd;
+ handle->bufsize = handle->snapshot;
+
+ /* Allocate the buffer */
+
+ handle->buffer = malloc(handle->bufsize + handle->offset);
+ if (!handle->buffer) {
+ snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ pcap_close_acn(handle);
+ free(handle);
+ return NULL;
+ }
+
+ /*
+ * "handle->fd" is a socket, so "select()" and "poll()"
+ * should work on it.
+ */
+ handle->selectable_fd = handle->fd;
+
+ return handle;
+}