dect
/
libpcap
Archived
13
0
Fork 0

From Stephen Donnelly:

If the DAG API supports asking a card for the set of ERF types
	it supports, use that capability, to handle cards that support
	multiple ERF types.  This is to support channelised/fractional
	T1/E1.

	Don't set the snapshot length - some DAG cards support multiple
	capture streams, but the snapshot length is global, so it'd
	affect other captures.

	Update README.dag.
This commit is contained in:
guy 2006-04-07 07:07:25 +00:00
parent cbcd540a75
commit b64aff479f
5 changed files with 1194 additions and 524 deletions

View File

@ -77,11 +77,32 @@ RX stream buffer overflow, this count is before filters are applied (it will
include packets that would have been dropped by the filter). The RX stream
buffer size is user configurable outside libpcap, typically 16-512MB.
pcap_get_selectable_fd() is not supported, DAG cards do not support
pcap_get_selectable_fd() is not supported, as DAG cards do not support
poll/select methods.
pcap_inject() and pcap_sendpacket() are not supported.
Some DAG cards now support capturing to multiple virtual interfaces, called
streams. Capture streams have even numbers. These are available via libpcap
as separate interfaces, e.g. dag0:0, dag0:2, dag0:4 etc. dag0:0 is the same
as dag0. These are visible via pcap_findalldevs().
libpcap now does NOT set the card's hardware snaplen (slen). This must now be
set using the appropriate DAG coniguration program, e.g. dagthree, dagfour,
dagsix, dagconfig. This is because the snaplen is currently shared between
all of the streams. In future this may change if per-stream slen is
implemented.
DAG cards by default capture entire packets including the L2
CRC/FCS. If the card is not configured to discard the CRC/FCS, this
can confuse applications that use libpcap if they're not prepared for
packets to have an FCS. Libpcap now reads the environment variable
ERF_FCS_BITS to determine how many bits of CRC/FCS to strip from the
end of the captured frame. This defaults to 32 for use with
Ethernet. If the card is configured to strip the CRC/FCS, then set
ERF_FCS_BITS=0. If used with a HDLC/PoS/PPP/Frame Relay link with 16
bit CRC/FCS, then set ERF_FCS_BITS=16.
----------------------------------------------------------------------
Please submit bug reports via <support@endace.com>.

View File

@ -13,6 +13,9 @@
/* define if you have the DAG API */
#undef HAVE_DAG_API
/* define if you have dag_get_erf_types() */
#undef HAVE_DAG_GET_ERF_TYPES
/* define if you have streams capable DAG API */
#undef HAVE_DAG_STREAMS_API

1488
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.127 2005-07-07 06:55:19 guy Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.128 2006-04-07 07:07:25 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -6,7 +6,7 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_REVISION($Revision: 1.127 $)
AC_REVISION($Revision: 1.128 $)
AC_PREREQ(2.50)
AC_INIT(pcap.c)
@ -567,6 +567,9 @@ if test $ac_cv_lbl_dag_api = yes; then
saved_ldflags=$LDFLAGS
LDFLAGS="-L$dag_lib_dir"
AC_CHECK_LIB([dag], [dag_attach_stream], [dag_version="2.5.x"], [dag_version="2.4.x"])
AC_CHECK_LIB([dag],[dag_get_erf_types], [
AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])]
)
LDFLAGS=$saved_ldflags
if test "$dag_version" = 2.5.x; then

View File

@ -17,7 +17,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.24 2005-07-10 22:09:16 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.25 2006-04-07 07:07:25 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -46,8 +46,6 @@ struct rtentry; /* declarations in <net/if.h> */
#include "dagnew.h"
#include "dagapi.h"
#define MIN_DAG_SNAPLEN 12
#define MAX_DAG_SNAPLEN 2040
#define ATM_CELL_SIZE 52
#define ATM_HDR_SIZE 4
@ -222,7 +220,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
* If non-block is specified it will return immediately. The user
* is then responsible for efficiency.
*/
p->md.dag_mem_top = dag_advance_stream(p->fd, p->md.dag_stream, (void**)&(p->md.dag_mem_bottom));
p->md.dag_mem_top = dag_advance_stream(p->fd, p->md.dag_stream, &(p->md.dag_mem_bottom));
#else
/* dag_offset does not support timeouts */
p->md.dag_mem_top = dag_offset(p->fd, &(p->md.dag_mem_bottom), flags);
@ -282,8 +280,14 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
p->md.dag_mem_bottom += rlen;
switch(header->type) {
case TYPE_AAL5:
case TYPE_ATM:
#ifdef TYPE_AAL5
case TYPE_AAL5:
if (header->type == TYPE_AAL5) {
packet_len = ntohs(header->wlen);
caplen = rlen - dag_record_size;
}
#endif
#ifdef TYPE_MC_ATM
case TYPE_MC_ATM:
if (header->type == TYPE_MC_ATM) {
@ -299,10 +303,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
dp+=4;
}
#endif
if (header->type == TYPE_AAL5) {
packet_len = ntohs(header->wlen);
caplen = rlen - dag_record_size;
} else if(header->type == TYPE_ATM) {
if (header->type == TYPE_ATM) {
caplen = packet_len = ATM_CELL_SIZE;
}
if (p->linktype == DLT_SUNATM) {
@ -557,7 +558,14 @@ dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebu
#endif /* HAVE_DAG_STREAMS_API */
/* XXX Not calling dag_configure() to set slen; this is unsafe in
* multi-stream environments as the gpp config is global.
* Once the firmware provides 'per-stream slen' this can be supported
* again via the Config API without side-effects */
#if 0
/* set the card snap length to the specified snaplen parameter */
/* This is a really bad idea, as different cards have different
* valid slen ranges. Should fix in Config API. */
if (snaplen == 0 || snaplen > MAX_DAG_SNAPLEN) {
snaplen = MAX_DAG_SNAPLEN;
} else if (snaplen < MIN_DAG_SNAPLEN) {
@ -570,6 +578,7 @@ dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebu
snprintf(ebuf, PCAP_ERRBUF_SIZE,"dag_configure %s: %s\n", device, pcap_strerror(errno));
goto fail;
}
#endif
#ifdef HAVE_DAG_STREAMS_API
if(dag_start_stream(handle->fd, handle->md.dag_stream) < 0) {
@ -806,81 +815,113 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
static int
dag_get_datalink(pcap_t *p)
{
int daglinktype;
int index=0;
uint8_t types[255];
if (p->dlt_list == NULL && (p->dlt_list = malloc(2*sizeof(*(p->dlt_list)))) == NULL) {
memset(types, 0, 255);
if (p->dlt_list == NULL && (p->dlt_list = malloc(255*sizeof(*(p->dlt_list)))) == NULL) {
(void)snprintf(p->errbuf, sizeof(p->errbuf), "malloc: %s", pcap_strerror(errno));
return (-1);
}
/* Check the type through a dagapi call. */
daglinktype = dag_linktype(p->fd);
p->linktype = 0;
switch(daglinktype) {
case TYPE_HDLC_POS:
case TYPE_COLOR_HDLC_POS:
if (p->dlt_list != NULL) {
p->dlt_count = 2;
p->dlt_list[0] = DLT_CHDLC;
p->dlt_list[1] = DLT_PPP_SERIAL;
p->dlt_list[2] = DLT_FRELAY;
}
p->linktype = DLT_CHDLC;
break;
case TYPE_ETH:
case TYPE_COLOR_ETH:
/*
* This is (presumably) a real Ethernet capture; give it a
* link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so
* that an application can let you choose it, in case you're
* capturing DOCSIS traffic that a Cisco Cable Modem
* Termination System is putting out onto an Ethernet (it
* doesn't put an Ethernet header onto the wire, it puts raw
* DOCSIS frames out on the wire inside the low-level
* Ethernet framing).
*/
if (p->dlt_list != NULL) {
p->dlt_count = 2;
p->dlt_list[0] = DLT_EN10MB;
p->dlt_list[1] = DLT_DOCSIS;
}
p->linktype = DLT_EN10MB;
break;
case TYPE_AAL5:
case TYPE_ATM:
case TYPE_MC_ATM:
case TYPE_MC_AAL5:
if (p->dlt_list != NULL) {
p->dlt_count = 2;
p->dlt_list[0] = DLT_ATM_RFC1483;
p->dlt_list[1] = DLT_SUNATM;
}
p->linktype = DLT_ATM_RFC1483;
break;
case TYPE_MC_HDLC:
if (p->dlt_list != NULL) {
p->dlt_count = 4;
p->dlt_list[0] = DLT_CHDLC;
p->dlt_list[1] = DLT_PPP_SERIAL;
p->dlt_list[2] = DLT_FRELAY;
p->dlt_list[3] = DLT_MTP2;
}
p->linktype = DLT_CHDLC;
break;
case TYPE_LEGACY:
p->linktype = DLT_NULL;
break;
default:
snprintf(p->errbuf, sizeof(p->errbuf), "unknown DAG linktype %d\n", daglinktype);
#ifdef HAVE_DAG_GET_ERF_TYPES
/* Get list of possible ERF types for this card */
if (dag_get_erf_types(p->fd, types, 255) < 0) {
snprintf(p->errbuf, sizeof(p->errbuf), "dag_get_erf_types: %s", pcap_strerror(errno));
return (-1);
}
while (types[index]) {
#else
/* Check the type through a dagapi call. */
types[index] = dag_linktype(p->fd);
{
#endif
switch(types[index]) {
case TYPE_HDLC_POS:
#ifdef TYPE_COLOR_HDLC_POS
case TYPE_COLOR_HDLC_POS:
#endif
if (p->dlt_list != NULL) {
p->dlt_list[index++] = DLT_CHDLC;
p->dlt_list[index++] = DLT_PPP_SERIAL;
p->dlt_list[index++] = DLT_FRELAY;
}
if(!p->linktype)
p->linktype = DLT_CHDLC;
break;
case TYPE_ETH:
#ifdef TYPE_COLOR_ETH
case TYPE_COLOR_ETH:
#endif
/*
* This is (presumably) a real Ethernet capture; give it a
* link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so
* that an application can let you choose it, in case you're
* capturing DOCSIS traffic that a Cisco Cable Modem
* Termination System is putting out onto an Ethernet (it
* doesn't put an Ethernet header onto the wire, it puts raw
* DOCSIS frames out on the wire inside the low-level
* Ethernet framing).
*/
if (p->dlt_list != NULL) {
p->dlt_list[index++] = DLT_EN10MB;
p->dlt_list[index++] = DLT_DOCSIS;
}
if(!p->linktype)
p->linktype = DLT_EN10MB;
break;
case TYPE_ATM:
#ifdef TYPE_AAL5
case TYPE_AAL5:
#endif
#ifdef TYPE_MC_ATM
case TYPE_MC_ATM:
#endif
#ifdef TYPE_MC_AAL5
case TYPE_MC_AAL5:
#endif
if (p->dlt_list != NULL) {
p->dlt_list[index++] = DLT_ATM_RFC1483;
p->dlt_list[index++] = DLT_SUNATM;
}
if(!p->linktype)
p->linktype = DLT_ATM_RFC1483;
break;
#ifdef TYPE_MC_HDLC
case TYPE_MC_HDLC:
if (p->dlt_list != NULL) {
p->dlt_list[index++] = DLT_CHDLC;
p->dlt_list[index++] = DLT_PPP_SERIAL;
p->dlt_list[index++] = DLT_FRELAY;
p->dlt_list[index++] = DLT_MTP2;
}
if(!p->linktype)
p->linktype = DLT_CHDLC;
break;
#endif
case TYPE_LEGACY:
if(!p->linktype)
p->linktype = DLT_NULL;
break;
default:
snprintf(p->errbuf, sizeof(p->errbuf), "unknown DAG linktype %d", types[index]);
return (-1);
} /* switch */
}
p->dlt_count = index;
return p->linktype;
}