]> The Tcpdump Group git mirrors - libpcap/commitdiff
From Stephen Donnelly:
authorguy <guy>
Fri, 9 Nov 2007 00:57:01 +0000 (00:57 +0000)
committerguy <guy>
Fri, 9 Nov 2007 00:57:01 +0000 (00:57 +0000)
Changing the behaviour when the ERF type is unknown, and for ERF
TYPE_PAD.

Unknown ERF types can always be captured as DLT_ERF.  TYPE_PAD
records are dropped silently.

pcap-dag.c
pcap-dag.h

index 2c5d4e500d3a5cdabecc0f954a917f9fa5a484bf..583cee963894a4dcbe573af7de47e2083c81d99f 100644 (file)
@@ -17,7 +17,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-       "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.31.2.2 2007-11-05 21:45:29 guy Exp $ (LBL)";
+       "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.31.2.3 2007-11-09 00:57:01 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -315,6 +315,32 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
                }
                p->md.dag_mem_bottom += rlen;
 
+               /* Count lost packets. */
+               switch((header->type & 0x7f)) {
+                       /* in these types the color value overwrites the lctr */
+               case TYPE_COLOR_HDLC_POS:
+               case TYPE_COLOR_ETH:
+               case TYPE_DSM_COLOR_HDLC_POS:
+               case TYPE_DSM_COLOR_ETH:
+               case TYPE_COLOR_MC_HDLC_POS:
+               case TYPE_COLOR_HASH_ETH:
+               case TYPE_COLOR_HASH_POS:
+                       break;
+
+               default:
+                       if (header->lctr) {
+                               if (p->md.stat.ps_drop > (UINT_MAX - ntohs(header->lctr))) {
+                                       p->md.stat.ps_drop = UINT_MAX;
+                               } else {
+                                       p->md.stat.ps_drop += ntohs(header->lctr);
+                               }
+                       }
+               }
+               
+               if ((header->type & 0x7f) == TYPE_PAD) {
+                       continue;
+               }
+
                num_ext_hdr = dag_erf_ext_header_count(dp, rlen);
 
                /* ERF encapsulation */
@@ -479,28 +505,6 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
                if (caplen > p->snapshot)
                        caplen = p->snapshot;
 
-               /* Count lost packets. */
-               switch((header->type & 0x7f)) {
-                       /* in these types the color value overwrites the lctr */
-               case TYPE_COLOR_HDLC_POS:
-               case TYPE_COLOR_ETH:
-               case TYPE_DSM_COLOR_HDLC_POS:
-               case TYPE_DSM_COLOR_ETH:
-               case TYPE_COLOR_MC_HDLC_POS:
-               case TYPE_COLOR_HASH_ETH:
-               case TYPE_COLOR_HASH_POS:
-                       break;
-
-               default:
-                       if (header->lctr) {
-                               if (p->md.stat.ps_drop > (UINT_MAX - ntohs(header->lctr))) {
-                                       p->md.stat.ps_drop = UINT_MAX;
-                               } else {
-                                       p->md.stat.ps_drop += ntohs(header->lctr);
-                               }
-                       }
-               }
-               
                /* Run the packet filter if there is one. */
                if ((p->fcode.bf_insns == NULL) || bpf_filter(p->fcode.bf_insns, dp, packet_len, caplen)) {
                        
@@ -1103,13 +1107,16 @@ dag_get_datalink(pcap_t *p)
                        break;
 
                case TYPE_LEGACY:
-                       if(!p->linktype)
-                               p->linktype = DLT_NULL;
-                       break;
-
+               case TYPE_MC_RAW:
+               case TYPE_MC_RAW_CHANNEL:
+               case TYPE_IP_COUNTER:
+               case TYPE_TCP_FLOW_COUNTER:
+               case TYPE_INFINIBAND:
+               case TYPE_IPV6:
                default:
-                       snprintf(p->errbuf, sizeof(p->errbuf), "unknown DAG linktype %d", types[index]);
-                       return (-1);
+                       /* Libpcap cannot deal with these types yet */
+                       /* Add no DLTs, but still covered by DLT_ERF */
+                       break;
 
                } /* switch */
                index++;
@@ -1119,5 +1126,8 @@ dag_get_datalink(pcap_t *p)
 
        p->dlt_count = dlt_index;
 
+       if(!p->linktype)
+               p->linktype = DLT_ERF;
+
        return p->linktype;
 }
index 71985c13bdf729f6b4e282d0c18167740f98efb6..738f21296f951411f50ffc3ad501c1de843d7f6c 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Author: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com)
  *
- * @(#) $Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.4.2.1 2007-11-05 21:45:29 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.4.2.2 2007-11-09 00:58:46 guy Exp $ (LBL)
  */
 
 pcap_t *dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf);
@@ -92,3 +92,9 @@ int dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf);
 #ifndef TYPE_IPV6
 #define TYPE_IPV6               23
 #endif
+
+
+
+#ifndef TYPE_PAD
+#define TYPE_PAD                48
+#endif