Permalink
Browse files

The SITA code in pcap-linux.c shares very little with the Linux code;

move it into pcap-sita.c, and make --with-sita set the pcap type to
"sita", so we build pcap-sita.c instead of, rather than in addition to,
pcap-linux.c.

Use "bpf_u_int32" rather than "ulong" in the SITA code, as it's intended
to be 32 bits long (the "l" in "htonl()" and "ntohl()" is historical -
they work on 32-bit quantities, and the "l" dates back to the days when
32-bit processors were a bit newer and 16-bit Unix was more common).

Those changes also, at least in theory, makes the SITA support work on
other Unix-compatible platforms; note that in README.sita.

Clean up pcap-sita.c, making routines no longer called outside it
static, folding trivial wrappers, and fixing various warnings.

Put the routines used by fad-sita.c and defined by pcap-sita.c into
pcap-sita.h.  Remove from pcap-sita.h the files that are now static to
pcap-sita.c.  Include pcap-sita.h in both fad-sita.c and pcap-sita.c, so
that we do cross-file prototype checking.
  • Loading branch information...
1 parent 92c5d33 commit f57d847d09ec7bbbedcda357c87b1895ce397872 @yuguy yuguy committed Jan 6, 2008
Showing with 157 additions and 98 deletions.
  1. +6 −3 README.sita
  2. +25 −18 configure
  3. +15 −9 configure.in
  4. +2 −3 fad-sita.c
  5. +7 −5 pcap-int.h
  6. +1 −28 pcap-linux.c
  7. +99 −28 pcap-sita.c
  8. +2 −4 pcap-sita.h
View
9 README.sita
@@ -2,6 +2,9 @@ The following instructions apply if you have a Linux platform and want
libpcap to support the 'ACN' WAN/LAN router product from from SITA
(http://www.sita.aero)
+This might also work on non-Linux Unix-compatible platforms, but that
+has not been tested.
+
See also the libpcap INSTALL.txt file for further libpcap configuration
options.
@@ -48,9 +51,9 @@ All captured packets are then forwarded across that TCP session
back to the local 'top layer' for forwarding to the actual
sniffing program (wireshark...)
-Note that the DLT_SITA protocol includes a proprietary header
-that is documented as part of the SITA dissector of Wireshark
-and is also described in 'pcap-sita.html' for posterity sake.
+Note that the DLT_SITA link-layer type includes a proprietary header
+that is documented as part of the SITA dissector of Wireshark and is
+also described in 'pcap-sita.html' for posterity sake.
That header provides:
- Packet direction (in/out) (1 octet)
View
43 configure
@@ -1,5 +1,5 @@
#! /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.
#
@@ -856,8 +856,8 @@ Optional Packages:
--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
@@ -5931,6 +5931,27 @@ fi
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;}
@@ -6356,6 +6377,8 @@ fi
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.
@@ -6685,22 +6708,6 @@ cat >>confdefs.h <<\_ACEOF
_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)
View
24 configure.in
@@ -1,12 +1,12 @@
-dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.143 2008-01-01 03:49:11 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.144 2008-01-06 20:23:17 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
dnl
dnl Process this file with autoconf to produce a configure script.
dnl
-AC_REVISION($Revision: 1.143 $)
+AC_REVISION($Revision: 1.144 $)
AC_PREREQ(2.50)
AC_INIT(pcap.c)
@@ -197,6 +197,18 @@ if test "$enable_protochain" = "disabled"; then
fi
AC_MSG_RESULT(${enable_protochain})
+#
+# SITA support is mutually exclusive with native capture support;
+# "--with-sita" selects SITA support.
+#
+AC_ARG_WITH(sita, [ --with-sita include SITA support],
+[
+ AC_DEFINE(SITA,1,[include ACN support])
+ AC_MSG_NOTICE(Enabling SITA ACN support)
+ V_PCAP=sita
+ V_FINDALLDEVS=sita
+],
+[
dnl
dnl Not all versions of test support -c (character special) but it's a
dnl better way of testing since the device might be protected. So we
@@ -335,6 +347,7 @@ else
;;
esac])
fi
+])
AC_MSG_CHECKING(if --enable-ipv6 option is specified)
AC_ARG_ENABLE(ipv6, [ --enable-ipv6 build IPv6-capable version])
@@ -396,13 +409,6 @@ linux)
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
fi
AC_LBL_TPACKET_STATS
- AC_ARG_WITH(sita, [ --with-sita include SITA support],
- [
- AC_DEFINE(SITA,1,[include ACN support])
- SSRC="pcap-sita.c"
- AC_MSG_NOTICE(Enabling SITA ACN support)
- V_FINDALLDEVS=sita
- ])
;;
dag)
View
5 fad-sita.c
@@ -33,10 +33,9 @@
#include <string.h>
#include "pcap-int.h"
-extern pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
+#include "pcap-sita.h"
-extern int acn_parse_hosts_file(char *errbuf);
-extern int acn_findalldevs(char *errbuf);
+extern pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) {
View
12 pcap-int.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.86 2007-10-17 18:52:41 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.87 2008-01-06 20:23:17 guy Exp $ (LBL)
*/
#ifndef pcap_int_h
@@ -114,20 +114,22 @@ struct pcap_md {
char *device; /* device name */
#ifdef linux
int sock_packet; /* using Linux 2.0 compatible interface */
- int timeout; /* timeout specified to pcap_open_live */
- int clear_promisc; /* must clear promiscuous mode when we close */
int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
int ifindex; /* interface index of device we're bound to */
int lo_ifindex; /* interface index of the loopback device */
struct pcap *next; /* list of open promiscuous sock_packet pcaps */
u_int packets_read; /* count of packets read with recvfrom() */
-#endif
+#endif /* linux */
+#if defined(linux) || defined(SITA)
+ int timeout; /* timeout specified to pcap_open_live */
+ int clear_promisc; /* must clear promiscuous mode when we close */
+#endif /* linux || SITA */
#ifdef HAVE_DAG_API
#ifdef HAVE_DAG_STREAMS_API
u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */
u_char *dag_mem_top; /* DAG card current memory top pointer */
-#else
+#else /* HAVE_DAG_STREAMS_API */
void *dag_mem_base; /* DAG card memory base address */
u_int dag_mem_bottom; /* DAG card current memory bottom offset */
u_int dag_mem_top; /* DAG card current memory top offset */
View
29 pcap-linux.c
@@ -34,7 +34,7 @@
#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
/*
@@ -103,10 +103,6 @@ static const char rcsid[] _U_ =
#include "pcap-bt-linux.h"
#endif
-#ifdef SITA
-#include "pcap-sita.h"
-#endif
-
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
@@ -332,14 +328,8 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
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
@@ -375,12 +365,6 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
* 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)
@@ -391,7 +375,6 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
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
@@ -405,7 +388,6 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
return NULL;
}
-#ifndef SITA
/*
* Compute the buffer size.
*
@@ -488,7 +470,6 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
}
handle->bufsize = handle->snapshot;
}
-#endif
/* Allocate the buffer */
@@ -986,9 +967,6 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
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)
@@ -1104,7 +1082,6 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
#endif /* SO_ATTACH_FILTER */
return 0;
-#endif /* SITA */
}
/*
@@ -2107,9 +2084,6 @@ static void pcap_close_all(void)
static void pcap_close_linux( pcap_t *handle )
{
-#ifdef SITA
- pcap_close_acn(handle);
-#else
struct pcap *p, *prevp;
struct ifreq ifr;
@@ -2178,7 +2152,6 @@ static void pcap_close_linux( pcap_t *handle )
free(handle->md.device);
handle->md.device = NULL;
pcap_close_common(handle);
-#endif /* SITA */
}
/*
View
127 pcap-sita.c
@@ -42,6 +42,8 @@
#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 */
@@ -81,7 +83,7 @@ static char static_buf[32];
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;
@@ -114,19 +116,17 @@ static void dump_interface_list() {
}
}
-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;
@@ -144,7 +144,7 @@ static void dump_interface_list_p() {
}
}
-static void dump_unit_table() {
+static void dump_unit_table(void) {
int chassis, geoslot;
iface_t *p;
@@ -209,7 +209,6 @@ static void empty_unit_iface(unit_t *u) {
}
static void empty_unit(int chassis, int geoslot) {
- iface_t *p, *cur;
unit_t *u = &units[chassis][geoslot];
empty_unit_iface(u);
@@ -218,7 +217,7 @@ static void empty_unit(int chassis, int geoslot) {
}
}
-static void empty_unit_table() {
+static void empty_unit_table(void) {
int chassis, geoslot;
for (chassis = 0; chassis <= MAX_CHASSIS; chassis++) {
@@ -345,7 +344,7 @@ static void close_with_IOP(int chassis, int geoslot, int flag) {
}
}
-void pcap_close_acn(pcap_t *handle) {
+static void pcap_close_acn(pcap_t *handle) {
int chassis, geoslot;
unit_t *u;
@@ -373,7 +372,7 @@ static void send_to_fd(int fd, int len, unsigned char *str) {
}
}
-static void acn_freealldevs() {
+static void acn_freealldevs(void) {
pcap_if_t *iff, *next_iff;
pcap_addr_t *addr, *next_addr;
@@ -408,7 +407,7 @@ static char *unified_port_num(unit_t *u, int IOPportnum) {
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];
@@ -489,7 +488,7 @@ static int if_sort(char *s1, char *s2) {
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;
@@ -534,7 +533,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
int address_count;
struct sockaddr_in *s;
char *newname;
- ulong interfaceType;
+ bpf_u_int32 interfaceType;
unsigned char flags;
prev_iff = 0;
@@ -574,7 +573,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
}
ptr++;
- interfaceType = ntohl(*(ulong *)ptr);
+ interfaceType = ntohl(*(bpf_u_int32 *)ptr);
ptr += 4; /* skip over the interface type */
flags = *ptr++;
@@ -599,7 +598,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
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 */
@@ -611,7 +610,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
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++;
@@ -623,7 +622,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
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++;
@@ -635,7 +634,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
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++;
@@ -672,7 +671,7 @@ static int read_client_data (int fd) {
return 1;
}
-static void wait_for_all_answers() {
+static void wait_for_all_answers(void) {
int retval;
struct timeval tv;
int fd;
@@ -719,9 +718,10 @@ static char *get_error_response(int fd, char *errbuf) { /* return a pointer on
*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; }
+ }
}
}
@@ -755,7 +755,7 @@ int acn_findalldevs(char *errbuf) { /* returns: -1 = error, 0 = OK */
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 */
@@ -769,7 +769,7 @@ int pcap_stats_acn(pcap_t *handle, struct pcap_stat *ps) {
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;
@@ -787,7 +787,7 @@ int acn_open_live(char *name, char *errbuf, int *linktype) { /* returns 0 on er
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 */
}
@@ -796,10 +796,10 @@ int acn_open_live(char *name, char *errbuf, int *linktype) { /* returns 0 on er
}
}
}
- 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;
@@ -818,7 +818,14 @@ void acn_start_monitor(int fd, int snaplen, int timeout, int promiscuous, int di
//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;
@@ -843,7 +850,13 @@ int acn_setfilter(int fd, struct bpf_program *bpf) {
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;
@@ -880,7 +893,7 @@ int acn_read_n_bytes_with_timeout(pcap_t *handle, int count) {
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;
@@ -903,3 +916,61 @@ int pcap_read_acn(pcap_t *handle, int max_packets, pcap_handler callback, u_char
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;
+}
View
6 pcap-sita.h
@@ -6,7 +6,5 @@
* @(#) $Header: /tcpdump/master/libpcap/pcap-sita.h
*/
-void pcap_close_acn(pcap_t *handle);
-int pcap_stats_acn(pcap_t *handle, struct pcap_stat *ps);
-int pcap_read_acn(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user);
-
+extern int acn_parse_hosts_file(char *errbuf);
+extern int acn_findalldevs(char *errbuf);

0 comments on commit f57d847

Please sign in to comment.