Clean up capture_enc(), export it, and use it in the capture window.
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 6 Dec 2005 22:56:37 +0000 (22:56 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 6 Dec 2005 22:56:37 +0000 (22:56 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16709 f5534014-38df-0310-8fa8-9805f1628bb7

capture_info.c
epan/dissectors/Makefile.common
epan/dissectors/packet-enc.c
epan/dissectors/packet-enc.h [new file with mode: 0644]

index 192c64ce0c25861b93af2d6ce47b496841aee749..66ec62e6c2b30a97ba9dcad4fc2d43c771a9c854 100644 (file)
@@ -54,8 +54,7 @@
 #include <epan/dissectors/packet-prism.h>
 #include <epan/dissectors/packet-ipfc.h>
 #include <epan/dissectors/packet-arcnet.h>
-
-
+#include <epan/dissectors/packet-enc.h>
 
 static void capture_info_packet(
 packet_counts *counts, gint wtap_linktype, const guchar *pd, guint32 caplen, union wtap_pseudo_header *pseudo_header);
@@ -216,6 +215,9 @@ capture_info_packet(packet_counts *counts, gint wtap_linktype, const guchar *pd,
     case WTAP_ENCAP_FRELAY_WITH_PHDR:
       capture_fr(pd, 0, caplen, counts);
       break;
+    case WTAP_ENCAP_ENC:
+      capture_enc(pd, caplen, counts);
+      break;
     /* XXX - some ATM drivers on FreeBSD might prepend a 4-byte ATM
        pseudo-header to DLT_ATM_RFC1483, with LLC header following;
        we might have to implement that at some point. */
index 027e4b29ed396bd86e0750c96de75cbd2e177d34..aeec3870535c090475642f383d31fb8dfc8580a7 100644 (file)
@@ -728,6 +728,7 @@ DISSECTOR_INCLUDES =        \
        packet-dvmrp.h  \
        packet-e164.h   \
        packet-edonkey.h        \
+       packet-enc.h    \
        packet-esis.h   \
        packet-ess.h    \
        packet-eth.h    \
index 701e2294e91c40127d106a50398453145d3a5238..7e81cfe10bdf478c349ee2c5d35a033adcfb6fd8 100644 (file)
@@ -32,6 +32,7 @@
 #include <epan/packet.h>
 #include <epan/etypes.h>
 #include <epan/addr_resolv.h>
+#include "packet-enc.h"
 #include "packet-ip.h"
 #include "packet-ipv6.h"
 
@@ -67,33 +68,26 @@ static int hf_enc_flags = -1;
 
 static gint ett_enc = -1;
 
-static void
-capture_enc(const guchar *pd, int offset, int len, packet_counts *ld)
+void
+capture_enc(const guchar *pd, int len, packet_counts *ld)
 {
-  struct enchdr ench;
+  guint32 af;
 
-  if (!BYTES_ARE_IN_FRAME(offset, len, (int)ENC_HDRLEN)) {
+  if (!BYTES_ARE_IN_FRAME(0, len, (int)ENC_HDRLEN)) {
     ld->other++;
     return;
   }
 
-  offset += ENC_HDRLEN;
-
-  /* Copy out the enc header to insure alignment */
-  memcpy(&ench, pd, sizeof(ench));
-  ench.af = g_ntohl(ench.af);
-
-  switch (ench.af) {
+  af = pntohl(pd + offsetof(struct enchdr, af));
+  switch (af) {
 
   case BSD_ENC_INET:
-    capture_ip(pd, offset, len, ld);
+    capture_ip(pd, ENC_HDRLEN, len, ld);
     break;
 
-#ifdef notyet
   case BSD_ENC_INET6:
-    capture_ipv6(pd, offset, len, ld);
+    capture_ipv6(pd, ENC_HDRLEN, len, ld);
     break;
-#endif
 
   default:
     ld->other++;
diff --git a/epan/dissectors/packet-enc.h b/epan/dissectors/packet-enc.h
new file mode 100644 (file)
index 0000000..c6795a3
--- /dev/null
@@ -0,0 +1,29 @@
+/* packet-enc.h
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef __PACKET_ENC_H__
+#define __PACKET_ENC_H__
+
+void capture_enc(const guchar *, int, packet_counts *);
+
+#endif