summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-01-23 04:04:01 +0000
committerGuy Harris <guy@alum.mit.edu>2003-01-23 04:04:01 +0000
commit8e6518ea607984b4fb76d0e04c28fed8631b368c (patch)
treef214615d7ccc4c35e113ba59059839b4f3a043dd
parent46ce1e6079557ec10c18d4d8908edaad7bc9354f (diff)
downloadwireshark-8e6518ea607984b4fb76d0e04c28fed8631b368c.tar.gz
In the BSDs, ARCNET packets don't have an offset field between the
addresses and the protocol type, as supplied by BPF; on Linux, they *do* have an offset field, as supplied by PF_PACKET sockets. Add a new WTAP_ENCAP_ARCNET_LINUX, with packets that include the offset field, and don't dissect an offset in WTAP_ENCAP_ARCNET packets. Map a libpcap link-layer type of 129 to WTAP_ENCAP_ARCNET_LINUX; that value was recently assigned to Linux-style ARCNET. Add some more ARCNET protocol IDs. For most protocol IDs, dissect an ATA 878.2 fragmentation header; don't do it for RFC 1051 IP and ARP, and Diagnose packets. Set the length of the ARCNET protocol tree item appropriately. Dissect both the RFC 1051 and RFC 1201 styles of IP and ARP over ARCNET, and dissect the RFC 1201 style of RARP as well. svn path=/trunk/; revision=6981
-rw-r--r--arcnet_pids.h35
-rw-r--r--packet-arcnet.c132
-rw-r--r--packet-arp.c6
-rw-r--r--packet-ip.c5
-rw-r--r--wiretap/libpcap.c3
-rw-r--r--wiretap/wtap.c5
-rw-r--r--wiretap/wtap.h57
7 files changed, 176 insertions, 67 deletions
diff --git a/arcnet_pids.h b/arcnet_pids.h
index a9e4e999b0..72e5cea975 100644
--- a/arcnet_pids.h
+++ b/arcnet_pids.h
@@ -2,7 +2,7 @@
* ARCNET protocol ID values
* Copyright 2001-2002, Peter Fales <ethereal@fales-lorenz.net>
*
- * $Id: arcnet_pids.h,v 1.1 2002/10/18 20:59:57 guy Exp $
+ * $Id: arcnet_pids.h,v 1.2 2003/01/23 04:03:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -23,6 +23,33 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#define ARCNET_PROTO_IP 0xd4
-#define ARCNET_PROTO_ARP 0xd5
-#define ARCNET_PROTO_IPX 0xfa
+/* RFC 1051 */
+#define ARCNET_PROTO_IP_1051 240
+#define ARCNET_PROTO_ARP_1051 241
+
+/* RFC 1201 */
+#define ARCNET_PROTO_IP_1201 212
+#define ARCNET_PROTO_ARP_1201 213
+#define ARCNET_PROTO_RARP_1201 214
+
+#define ARCNET_PROTO_IPX 250
+#define ARCNET_PROTO_NOVELL_EC 236
+
+#define ARCNET_PROTO_IPv6 196 /* or so BSD's arcnet.h claims */
+
+/*
+ * Raw Ethernet over ARCNET - Linux's "if_arcnet.h" calls this
+ * "MS LAanMan/WfWg 'NDIS' encapsuation".
+ */
+#define ARCNET_PROTO_ETHERNET 232
+
+#define ARCNET_PROTO_DATAPOINT_BOOT 0
+#define ARCNET_PROTO_DATAPOINT_MOUNT 1
+#define ARCNET_PROTO_POWERLAN_BEACON 8
+#define ARCNET_PROTO_POWERLAN_BEACON2 243
+#define ARCNET_PROTO_LANSOFT 251
+
+#define ARCNET_PROTO_APPLETALK 221
+#define ARCNET_PROTO_BANYAN 247 /* Banyan VINES */
+
+#define ARCNET_PROTO_DIAGNOSE 128 /* as per ANSI/ATA 878.1 */
diff --git a/packet-arcnet.c b/packet-arcnet.c
index 547c578597..acb61223bc 100644
--- a/packet-arcnet.c
+++ b/packet-arcnet.c
@@ -2,7 +2,7 @@
* Routines for arcnet dissection
* Copyright 2001-2002, Peter Fales <ethereal@fales-lorenz.net>
*
- * $Id: packet-arcnet.c,v 1.3 2002/10/18 21:40:12 guy Exp $
+ * $Id: packet-arcnet.c,v 1.4 2003/01/23 04:03:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,7 +40,10 @@
static int proto_arcnet = -1;
static int hf_arcnet_src = -1;
static int hf_arcnet_dst = -1;
+static int hf_arcnet_offset = -1;
static int hf_arcnet_protID = -1;
+static int hf_arcnet_split_flag = -1;
+static int hf_arcnet_sequence = -1;
/* Initialize the subtree pointers */
static gint ett_arcnet = -1;
@@ -50,16 +53,15 @@ static dissector_handle_t data_handle;
/* Code to actually dissect the packets */
static void
-dissect_arcnet (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
+dissect_arcnet_common (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
+ gboolean has_offset)
{
+ int offset = 0;
guint8 dst, src, protID;
tvbuff_t *next_tvb;
+ proto_item *ti = NULL;
+ proto_tree *arcnet_tree = NULL;
-/* Set up structures needed to add the protocol subtree and manage it */
- proto_item *ti;
- proto_tree *arcnet_tree;
-
-/* Make entries in Protocol column and Info column on summary display */
if (check_col (pinfo->cinfo, COL_PROTOCOL))
col_set_str (pinfo->cinfo, COL_PROTOCOL, "ARCNET");
@@ -75,26 +77,54 @@ dissect_arcnet (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
protID = tvb_get_guint8 (tvb, 4);
-/* In the interest of speed, if "tree" is NULL, don't do any work not
- necessary to generate protocol tree items. */
if (tree)
{
-
-/* create display subtree for the protocol */
ti =
- proto_tree_add_item (tree, proto_arcnet, tvb, 0, tvb_length (tvb),
- FALSE);
+ proto_tree_add_item (tree, proto_arcnet, tvb, 0, -1, FALSE);
arcnet_tree = proto_item_add_subtree (ti, ett_arcnet);
- proto_tree_add_uint (tree, hf_arcnet_src, tvb, 0, 1, src);
- proto_tree_add_uint (tree, hf_arcnet_dst, tvb, 1, 1, dst);
- proto_tree_add_uint (tree, hf_arcnet_protID, tvb, 4, 1, protID);
+ proto_tree_add_uint (tree, hf_arcnet_src, tvb, offset, 1, src);
}
+ offset++;
+
+ if (tree)
+ proto_tree_add_uint (tree, hf_arcnet_dst, tvb, offset, 1, dst);
+ offset++;
+
+ if (has_offset) {
+ if (tree)
+ proto_tree_add_item (tree, hf_arcnet_offset, tvb, offset, 2, FALSE);
+ offset += 2;
+ }
-/* If this protocol has a sub-dissector call it here, see section 1.8 */
+ if (tree)
+ proto_tree_add_uint (tree, hf_arcnet_protID, tvb, offset, 1, protID);
+ offset++;
+
+ switch (protID) {
+
+ case ARCNET_PROTO_IP_1051:
+ case ARCNET_PROTO_ARP_1051:
+ case ARCNET_PROTO_DIAGNOSE:
+ /* No fragmentation stuff in the header */
+ break;
+
+ default:
+ /* Show the fragmentation stuff - flag and sequence ID */
+ if (tree) {
+ proto_tree_add_item (tree, hf_arcnet_split_flag, tvb, offset, 1, FALSE);
+ proto_tree_add_item (tree, hf_arcnet_sequence, tvb, offset, 2, FALSE);
+ }
+ offset += 3;
+ break;
+ }
- next_tvb = tvb_new_subset (tvb, 8, -1, -1);
+ /* Set the length of the ARCNET header protocol tree item. */
+ if (tree)
+ proto_item_set_len(ti, offset);
+
+ next_tvb = tvb_new_subset (tvb, offset, -1, -1);
if (!dissector_try_port (arcnet_dissector_table, protID,
next_tvb, pinfo, tree))
@@ -108,18 +138,44 @@ dissect_arcnet (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
}
+/*
+ * BSD-style ARCNET headers - they don't have the offset field from the
+ * ARCNET hardware packet.
+ */
+static void
+dissect_arcnet (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
+{
+ dissect_arcnet_common (tvb, pinfo, tree, FALSE);
+}
-/* Register the protocol with Ethereal */
-
-/* this format is require because a script is used to build the C function
- that calls all the protocol registration.
-*/
+/*
+ * Linux-style ARCNET headers - they *do* have the offset field from the
+ * ARCNET hardware packet.
+ */
+static void
+dissect_arcnet_linux (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
+{
+ dissect_arcnet_common (tvb, pinfo, tree, TRUE);
+}
static const value_string arcnet_prot_id_vals[] = {
- {ARCNET_PROTO_IP, "IP packet"},
- {ARCNET_PROTO_ARP, "ARP packet"},
- {ARCNET_PROTO_IPX, "IPX packet"},
- {0, NULL}
+ {ARCNET_PROTO_IP_1051, "RFC 1051 IP"},
+ {ARCNET_PROTO_ARP_1051, "RFC 1051 ARP"},
+ {ARCNET_PROTO_IP_1201, "RFC 1201 IP"},
+ {ARCNET_PROTO_ARP_1201, "RFC 1201 ARP"},
+ {ARCNET_PROTO_RARP_1201, "RFC 1201 RARP"},
+ {ARCNET_PROTO_IPX, "IPX"},
+ {ARCNET_PROTO_NOVELL_EC, "Novell of some sort"},
+ {ARCNET_PROTO_IPv6, "IPv6"},
+ {ARCNET_PROTO_ETHERNET, "Encapsulated Ethernet"},
+ {ARCNET_PROTO_DATAPOINT_BOOT, "Datapoint boot"},
+ {ARCNET_PROTO_DATAPOINT_MOUNT, "Datapoint mount"},
+ {ARCNET_PROTO_POWERLAN_BEACON, "PowerLAN beacon"},
+ {ARCNET_PROTO_POWERLAN_BEACON2, "PowerLAN beacon2"},
+ {ARCNET_PROTO_APPLETALK, "Appletalk"},
+ {ARCNET_PROTO_BANYAN, "Banyan VINES"},
+ {ARCNET_PROTO_DIAGNOSE, "Diagnose"},
+ {0, NULL}
};
void
@@ -138,11 +194,26 @@ proto_register_arcnet (void)
FT_UINT8, BASE_HEX, NULL, 0,
"Dest ID", HFILL}
},
+ {&hf_arcnet_offset,
+ {"Offset", "arcnet.offset",
+ FT_BYTES, BASE_NONE, NULL, 0,
+ "Offset", HFILL}
+ },
{&hf_arcnet_protID,
{"Protocol ID", "arcnet.protID",
FT_UINT8, BASE_HEX, VALS(arcnet_prot_id_vals), 0,
"Proto type", HFILL}
},
+ {&hf_arcnet_split_flag,
+ {"Split Flag", "arcnet.split_flag",
+ FT_UINT8, BASE_DEC, NULL, 0,
+ "Split flag", HFILL}
+ },
+ {&hf_arcnet_sequence,
+ {"Sequence", "arcnet.sequence",
+ FT_UINT16, BASE_DEC, NULL, 0,
+ "Sequence number", HFILL}
+ },
};
/* Setup protocol subtree array */
@@ -166,10 +237,13 @@ proto_register_arcnet (void)
void
proto_reg_handoff_arcnet (void)
{
- dissector_handle_t arcnet_handle;
+ dissector_handle_t arcnet_handle, arcnet_linux_handle;
arcnet_handle = create_dissector_handle (dissect_arcnet, proto_arcnet);
-
dissector_add ("wtap_encap", WTAP_ENCAP_ARCNET, arcnet_handle);
+
+ arcnet_linux_handle = create_dissector_handle (dissect_arcnet_linux,
+ proto_arcnet);
+ dissector_add ("wtap_encap", WTAP_ENCAP_ARCNET_LINUX, arcnet_linux_handle);
data_handle = find_dissector ("data");
}
diff --git a/packet-arp.c b/packet-arp.c
index 45b73dfe76..ad0079ac36 100644
--- a/packet-arp.c
+++ b/packet-arp.c
@@ -1,7 +1,7 @@
/* packet-arp.c
* Routines for ARP packet disassembly
*
- * $Id: packet-arp.c,v 1.54 2002/10/18 20:59:57 guy Exp $
+ * $Id: packet-arp.c,v 1.55 2003/01/23 04:03:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -995,5 +995,7 @@ proto_reg_handoff_arp(void)
arp_handle = create_dissector_handle(dissect_arp, proto_arp);
dissector_add("ethertype", ETHERTYPE_ARP, arp_handle);
dissector_add("ethertype", ETHERTYPE_REVARP, arp_handle);
- dissector_add("arcnet.protocol_id", ARCNET_PROTO_ARP, arp_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_ARP_1051, arp_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_ARP_1201, arp_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_RARP_1201, arp_handle);
}
diff --git a/packet-ip.c b/packet-ip.c
index 1dea05bea5..c9bcc03b67 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.181 2003/01/22 01:16:33 sahlberg Exp $
+ * $Id: packet-ip.c,v 1.182 2003/01/23 04:03:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1755,7 +1755,8 @@ proto_reg_handoff_ip(void)
dissector_add("chdlctype", ETHERTYPE_IP, ip_handle);
dissector_add("fr.ietf", NLPID_IP, ip_handle);
dissector_add("x.25.spi", NLPID_IP, ip_handle);
- dissector_add("arcnet.protocol_id", ARCNET_PROTO_IP, ip_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_IP_1051, ip_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_IP_1201, ip_handle);
}
void
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index a9c7d8ac9e..7e74bbec42 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -1,6 +1,6 @@
/* libpcap.c
*
- * $Id: libpcap.c,v 1.90 2003/01/10 04:04:41 guy Exp $
+ * $Id: libpcap.c,v 1.91 2003/01/23 04:04:00 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -242,6 +242,7 @@ static const struct {
{ 123, WTAP_ENCAP_ATM_PDUS }, /* SunATM */
{ 127, WTAP_ENCAP_WLAN_HEADER }, /* 802.11 plus WLAN header */
{ 128, WTAP_ENCAP_TZSP }, /* Tazmen Sniffer Protocol */
+ { 129, WTAP_ENCAP_ARCNET_LINUX },
/*
* The following are entries for libpcap type values that have
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 36c1b60e23..b7cb34f826 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1,6 +1,6 @@
/* wtap.c
*
- * $Id: wtap.c,v 1.78 2003/01/08 05:03:54 guy Exp $
+ * $Id: wtap.c,v 1.79 2003/01/23 04:04:01 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -86,6 +86,9 @@ static const struct encap_type_info {
/* WTAP_ENCAP_ARCNET */
{ "ARCNET", "arcnet" },
+ /* WTAP_ENCAP_ARCNET_LINUX */
+ { "Linux ARCNET", "arcnet_linux" },
+
/* WTAP_ENCAP_ATM_RFC1483 */
{ "RFC 1483 ATM", "atm-rfc1483" },
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 06fabbe77d..2a514ad4b7 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.132 2003/01/10 04:04:42 guy Exp $
+ * $Id: wtap.h,v 1.133 2003/01/23 04:04:01 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -98,35 +98,36 @@
#define WTAP_ENCAP_FDDI_BITSWAPPED 6
#define WTAP_ENCAP_RAW_IP 7
#define WTAP_ENCAP_ARCNET 8
-#define WTAP_ENCAP_ATM_RFC1483 9
-#define WTAP_ENCAP_LINUX_ATM_CLIP 10
-#define WTAP_ENCAP_LAPB 11
-#define WTAP_ENCAP_ATM_PDUS 12
-#define WTAP_ENCAP_ATM_PDUS_UNTRUNCATED 13
-#define WTAP_ENCAP_NULL 14
-#define WTAP_ENCAP_ASCEND 15
-#define WTAP_ENCAP_ISDN 16
-#define WTAP_ENCAP_IP_OVER_FC 17
-#define WTAP_ENCAP_PPP_WITH_PHDR 18
-#define WTAP_ENCAP_IEEE_802_11 19
-#define WTAP_ENCAP_IEEE_802_11_WITH_RADIO 20
-#define WTAP_ENCAP_SLL 21
-#define WTAP_ENCAP_FRELAY 22
-#define WTAP_ENCAP_CHDLC 23
-#define WTAP_ENCAP_CISCO_IOS 24
-#define WTAP_ENCAP_LOCALTALK 25
-#define WTAP_ENCAP_PRISM_HEADER 26
-#define WTAP_ENCAP_PFLOG 27
-#define WTAP_ENCAP_HHDLC 28
-#define WTAP_ENCAP_DOCSIS 29
-#define WTAP_ENCAP_COSINE 30
-#define WTAP_ENCAP_WLAN_HEADER 31
-#define WTAP_ENCAP_WFLEET_HDLC 32
-#define WTAP_ENCAP_SDLC 33
-#define WTAP_ENCAP_TZSP 34
+#define WTAP_ENCAP_ARCNET_LINUX 9
+#define WTAP_ENCAP_ATM_RFC1483 10
+#define WTAP_ENCAP_LINUX_ATM_CLIP 11
+#define WTAP_ENCAP_LAPB 12
+#define WTAP_ENCAP_ATM_PDUS 13
+#define WTAP_ENCAP_ATM_PDUS_UNTRUNCATED 14
+#define WTAP_ENCAP_NULL 15
+#define WTAP_ENCAP_ASCEND 16
+#define WTAP_ENCAP_ISDN 17
+#define WTAP_ENCAP_IP_OVER_FC 18
+#define WTAP_ENCAP_PPP_WITH_PHDR 19
+#define WTAP_ENCAP_IEEE_802_11 20
+#define WTAP_ENCAP_IEEE_802_11_WITH_RADIO 21
+#define WTAP_ENCAP_SLL 22
+#define WTAP_ENCAP_FRELAY 23
+#define WTAP_ENCAP_CHDLC 24
+#define WTAP_ENCAP_CISCO_IOS 25
+#define WTAP_ENCAP_LOCALTALK 26
+#define WTAP_ENCAP_PRISM_HEADER 27
+#define WTAP_ENCAP_PFLOG 28
+#define WTAP_ENCAP_HHDLC 29
+#define WTAP_ENCAP_DOCSIS 30
+#define WTAP_ENCAP_COSINE 31
+#define WTAP_ENCAP_WLAN_HEADER 32
+#define WTAP_ENCAP_WFLEET_HDLC 33
+#define WTAP_ENCAP_SDLC 34
+#define WTAP_ENCAP_TZSP 35
/* last WTAP_ENCAP_ value + 1 */
-#define WTAP_NUM_ENCAP_TYPES 35
+#define WTAP_NUM_ENCAP_TYPES 36
/* File types that can be read by wiretap.
We support writing some many of these file types, too, so we