aboutsummaryrefslogtreecommitdiffstats
path: root/packet-arcnet.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-01-23 04:04:01 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-01-23 04:04:01 +0000
commitd1712829377d25e382fd8196339c1e5f8c4e51bc (patch)
treef214615d7ccc4c35e113ba59059839b4f3a043dd /packet-arcnet.c
parent55a516aa8ae097a2cf1aadb14630cad99e35634c (diff)
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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6981 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-arcnet.c')
-rw-r--r--packet-arcnet.c132
1 files changed, 103 insertions, 29 deletions
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");
}