summaryrefslogtreecommitdiff
path: root/pcap-dag.c
diff options
context:
space:
mode:
authorguy <guy>2007-09-29 19:33:29 +0000
committerguy <guy>2007-09-29 19:33:29 +0000
commitafbb1ce7227dc5edb291f242ed8d95cd3762fc51 (patch)
treeb97a5fcce33e0057a47caacef86a360b0721db53 /pcap-dag.c
parent29dc375264623f60a198eeae36e8fc84f513e1b0 (diff)
downloadlibpcap-afbb1ce7227dc5edb291f242ed8d95cd3762fc51.tar.gz
Based on work from Florent Drouin, split the 32-bit link-layer type
field in a capture file into: a 16-bit link-layer type field (it's 16 bits in pcap-NG, and that'll probably be enough for the foreseeable future); a 10-bit "class" field, indicating the group of link-layer type values to which the link-layer type belongs - class 0 is for regular DLT_ values, and class 0x224 grandfathers in the NetBSD "raw address family" link-layer types; a 6-bit "extension" field, storing information about the capture, such an indication of whether the packets include an FCS and, if so, how many bytes of FCS are present.
Diffstat (limited to 'pcap-dag.c')
-rw-r--r--pcap-dag.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/pcap-dag.c b/pcap-dag.c
index 477c632a..86df4f68 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -17,7 +17,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.29 2007-06-22 06:32:06 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.30 2007-09-29 19:33:29 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -644,24 +644,45 @@ dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebu
*/
handle->md.dag_mem_bottom = 0;
handle->md.dag_mem_top = 0;
- handle->md.dag_fcs_bits = 32;
- /* Query the card first for special cases. */
+ /*
+ * Find out how many FCS bits we should strip.
+ * First, query the card to see if it strips the FCS.
+ */
daginf = dag_info(handle->fd);
- if ((0x4200 == daginf->device_code) || (0x4230 == daginf->device_code))
- {
+ if ((0x4200 == daginf->device_code) || (0x4230 == daginf->device_code)) {
/* DAG 4.2S and 4.23S already strip the FCS. Stripping the final word again truncates the packet. */
handle->md.dag_fcs_bits = 0;
- }
- /* Then allow an environment variable to override. */
- if ((s = getenv("ERF_FCS_BITS")) != NULL) {
- if ((n = atoi(s)) == 0 || n == 16|| n == 32) {
- handle->md.dag_fcs_bits = n;
- } else {
- snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "pcap_open_live %s: bad ERF_FCS_BITS value (%d) in environment\n", device, n);
- goto failstop;
+ /* Note that no FCS will be supplied. */
+ handle->linktype_ext = LT_FCS_DATALINK_EXT(0);
+ } else {
+ /*
+ * Start out assuming it's 32 bits.
+ */
+ handle->md.dag_fcs_bits = 32;
+
+ /* Allow an environment variable to override. */
+ if ((s = getenv("ERF_FCS_BITS")) != NULL) {
+ if ((n = atoi(s)) == 0 || n == 16 || n == 32) {
+ handle->md.dag_fcs_bits = n;
+ } else {
+ snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ "pcap_open_live %s: bad ERF_FCS_BITS value (%d) in environment\n", device, n);
+ goto failstop;
+ }
+ }
+
+ /*
+ * Did the user request that they not be stripped?
+ */
+ if ((s = getenv("ERF_DONT_STRIP_FCS")) != NULL) {
+ /* Yes. Note the number of bytes that will be
+ supplied. */
+ handle->linktype_ext = LT_FCS_DATALINK_EXT(handle->md.dag_fcs_bits/16);
+
+ /* And don't strip them. */
+ handle->md.dag_fcs_bits = 0;
}
}