* Routines for decoding MDS Port Analyzer Adapter (FC in Eth) Header
* Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com>
*
- * $Id$
- *
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
#include "config.h"
-#include <glib.h>
-
#include <epan/packet.h>
#include <epan/etypes.h>
+#include "packet-fc.h"
#define BRDWLK_MAX_PACKET_CNT 0xFFFF
#define BRDWLK_TRUNCATED_BIT 0x8
static guint16 packet_count = 0;
static gboolean first_pkt = TRUE; /* start of capture */
-static dissector_handle_t data_handle;
static dissector_handle_t fc_dissector_handle;
static void
dissect_brdwlk_err(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
{
- proto_item *item = NULL;
- proto_tree *tree = NULL;
- guint8 flags;
-
- flags = tvb_get_guint8(tvb, offset);
- if (parent_tree) {
- item=proto_tree_add_uint(parent_tree, hf_brdwlk_error,
- tvb, offset, 1, flags);
- tree=proto_item_add_subtree(item, ett_brdwlk_error);
- }
-
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_plp, tvb, offset, 1, flags);
- if (flags & 0x01) {
- proto_item_append_text(item, " Packet Length Present");
- }
- flags &= (~( 0x01 ));
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_ef, tvb, offset, 1, flags);
- if (flags & 0x02) {
- proto_item_append_text(item, " Empty Frame");
- }
- flags &= (~( 0x02 ));
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_nd, tvb, offset, 1, flags);
- if (flags & 0x04) {
- proto_item_append_text(item, " No Data");
- }
- flags &= (~( 0x04 ));
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_tr, tvb, offset, 1, flags);
- if (flags & 0x08) {
- proto_item_append_text(item, " Truncated");
- }
- flags &= (~( 0x08 ));
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_badcrc, tvb, offset, 1, flags);
- if (flags & 0x10) {
- proto_item_append_text(item, " Bad FC CRC");
- }
- flags &= (~( 0x10 ));
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_ff, tvb, offset, 1, flags);
- if (flags & 0x20) {
- proto_item_append_text(item, " Fifo Full");
- }
- flags &= (~( 0x20 ));
-
- proto_tree_add_boolean(tree, hf_brdwlk_error_jumbo, tvb, offset, 1, flags);
- if (flags & 0x40) {
- proto_item_append_text(item, " Jumbo FC Frame");
- }
- flags &= (~( 0x40 ));
+ static const int * flags[] = {
+ &hf_brdwlk_error_plp,
+ &hf_brdwlk_error_ef,
+ &hf_brdwlk_error_nd,
+ &hf_brdwlk_error_tr,
+ &hf_brdwlk_error_badcrc,
+ &hf_brdwlk_error_ff,
+ &hf_brdwlk_error_jumbo,
+ &hf_brdwlk_error_ctrl,
+ NULL
+ };
- proto_tree_add_boolean(tree, hf_brdwlk_error_ctrl, tvb, offset, 1, flags);
- if (flags & 0x80) {
- proto_item_append_text(item, " Ctrl Char Inside Frame");
- }
- /*flags &= (~( 0x80 ));*/
+ proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_brdwlk_error, ett_brdwlk_error, flags, ENC_NA, BMT_NO_FALSE|BMT_NO_TFS);
}
/* Code to actually dissect the packets */
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti, *hidden_item;
- proto_tree *brdwlk_tree = NULL;
+ proto_tree *brdwlk_tree;
tvbuff_t *next_tvb;
guint8 error, eof, sof;
int hdrlen = 2,
gint len, reported_len, plen;
guint16 pkt_cnt;
gboolean dropped_packets;
+ fc_data_t fc_data;
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Boardwalk");
col_clear(pinfo->cinfo, COL_INFO);
- pinfo->vsan = (tvb_get_ntohs(tvb, offset) & 0xFFF);
sof = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
+ fc_data.sof_eof = 0;
if ((sof == FCM_DELIM_SOFI3) || (sof == FCM_DELIM_SOFI2) || (sof == FCM_DELIM_SOFI1)
|| (sof == FCM_DELIM_SOFI4)) {
- pinfo->sof_eof = PINFO_SOF_FIRST_FRAME;
+ fc_data.sof_eof = FC_DATA_SOF_FIRST_FRAME;
}
else if (sof == FCM_DELIM_SOFF) {
- pinfo->sof_eof = PINFO_SOF_SOFF;
+ fc_data.sof_eof = FC_DATA_SOF_SOFF;
}
- if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_brdwlk, tvb, 0,
- hdrlen, "Boardwalk");
+ ti = proto_tree_add_protocol_format(tree, proto_brdwlk, tvb, 0,
+ hdrlen, "Boardwalk");
- brdwlk_tree = proto_item_add_subtree(ti, ett_brdwlk);
+ brdwlk_tree = proto_item_add_subtree(ti, ett_brdwlk);
- proto_tree_add_item(brdwlk_tree, hf_brdwlk_sof, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(brdwlk_tree, hf_brdwlk_vsan, tvb, offset, 2, ENC_BIG_ENDIAN);
-
- }
+ proto_tree_add_item(brdwlk_tree, hf_brdwlk_sof, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(brdwlk_tree, hf_brdwlk_vsan, tvb, offset, 2, ENC_BIG_ENDIAN);
/* Locate EOF which is the last 4 bytes of the frame */
- len = tvb_length_remaining(tvb, hdrlen);
+ len = tvb_captured_length_remaining(tvb, hdrlen);
reported_len = tvb_reported_length_remaining(tvb, hdrlen);
if (reported_len < 4) {
/*
* We therefore attach a non-null pointer as frame data to
* any frame preceded by dropped packets.
*/
- if (p_get_proto_data(pinfo->fd, proto_brdwlk, 0) != NULL)
+ if (p_get_proto_data(wmem_file_scope(), pinfo, proto_brdwlk, 0) != NULL)
dropped_packets = TRUE;
} else {
/*
* packets. (The data we use as the frame data doesn't
* matter - it just matters that it's non-null.)
*/
- p_add_proto_data(pinfo->fd, proto_brdwlk, 0, &packet_count);
+ p_add_proto_data(wmem_file_scope(), pinfo, proto_brdwlk, 0, &packet_count);
}
}
}
- if (tree) {
- hidden_item = proto_tree_add_boolean(brdwlk_tree, hf_brdwlk_drop,
- tvb, offset, 0, dropped_packets);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- }
+
+ hidden_item = proto_tree_add_boolean(brdwlk_tree, hf_brdwlk_drop,
+ tvb, offset, 0, dropped_packets);
+ PROTO_ITEM_SET_HIDDEN(hidden_item);
packet_count = pkt_cnt;
eof = tvb_get_guint8(tvb, offset+3);
if (eof != FCM_DELIM_EOFN) {
- pinfo->sof_eof |= PINFO_EOF_LAST_FRAME;
+ fc_data.sof_eof |= FC_DATA_EOF_LAST_FRAME;
}
else if (eof != FCM_DELIM_EOFT) {
- pinfo->sof_eof |= PINFO_EOF_INVALID;
+ fc_data.sof_eof |= FC_DATA_EOF_INVALID;
}
- if (tree) {
- proto_tree_add_item(brdwlk_tree, hf_brdwlk_eof, tvb, offset+3,
- 1, ENC_BIG_ENDIAN);
- }
+ proto_tree_add_item(brdwlk_tree, hf_brdwlk_eof, tvb, offset+3,
+ 1, ENC_BIG_ENDIAN);
if ((error & BRDWLK_HAS_PLEN) && tree) {
/* In newer Boardwalks, if this bit is set, the actual frame length
}
}
+ fc_data.ethertype = ETHERTYPE_BRDWALK;
next_tvb = tvb_new_subset(tvb, 2, len, reported_len);
- if (fc_dissector_handle) {
- call_dissector(fc_dissector_handle, next_tvb, pinfo, tree);
- }
+ call_dissector_with_data(fc_dissector_handle, next_tvb, pinfo, tree, &fc_data);
}
static void
brdwlk_handle = create_dissector_handle(dissect_brdwlk, proto_brdwlk);
dissector_add_uint("ethertype", ETHERTYPE_BRDWALK, brdwlk_handle);
dissector_add_uint("ethertype", 0xABCD, brdwlk_handle);
- data_handle = find_dissector("data");
fc_dissector_handle = find_dissector("fc");
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */