* $Id$
*
* Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* Based on packet-fcip.c, Copyright 2001, Dinesh G Dutt (ddutt@cisco.com)
{0, NULL}
};
-void proto_reg_handoff_fcoe(void);
-
static int proto_fcoe = -1;
static int hf_fcoe_ver = -1;
static int hf_fcoe_len = -1;
gint frame_len = 0;
gint header_len = FCOE_HEADER_LEN;
guint version;
- char *ver;
+ const char *ver;
guint16 len_sof;
- gint bytes_remaining = tvb_length(tvb);
+ gint bytes_remaining;
guint8 sof = 0;
guint8 eof = 0;
const char *eof_str;
- char *crc_msg;
- char *len_msg;
+ const char *crc_msg;
+ const char *len_msg;
proto_item *ti;
proto_item *item;
proto_tree *fcoe_tree = NULL;
sof |= (sof < 8) ? 0x30 : 0x20;
version = len_sof >> 14;
ver = "pre-T11 ";
- if (version != 0) {
- int ver_buf_len = 24;
- ver = ep_alloc(ver_buf_len);
- g_snprintf(ver, ver_buf_len, "pre-T11 ver %d ", version);
- }
+ if (version != 0)
+ ver = ep_strdup_printf(ver, "pre-T11 ver %d ", version);
} else {
- frame_len = bytes_remaining - FCOE_HEADER_LEN - FCOE_TRAILER_LEN;
+ frame_len = tvb_reported_length_remaining(tvb, 0) -
+ FCOE_HEADER_LEN - FCOE_TRAILER_LEN;
sof = tvb_get_guint8(tvb, FCOE_HEADER_LEN - 1);
/*
*/
ver = "";
version = tvb_get_guint8(tvb, 0) >> 4;
- if (version != 0) {
- int ver_buf_len = 16;
- ver = ep_alloc(ver_buf_len);
- g_snprintf(ver, ver_buf_len, "ver %d ", version);
- }
+ if (version != 0)
+ ver = ep_strdup_printf(ver, "ver %d ", version);
}
- if (frame_len < 0)
- return;
- if (check_col(pinfo->cinfo, COL_PROTOCOL))
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "FCoE");
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "FCoE");
crc_offset = header_len + frame_len;
eof_offset = crc_offset + 4;
- next_tvb = tvb_new_subset(tvb, header_len, frame_len, frame_len);
+ bytes_remaining = tvb_length_remaining(tvb, header_len);
+ if (bytes_remaining > frame_len)
+ bytes_remaining = frame_len; /* backing length */
+ next_tvb = tvb_new_subset(tvb, header_len, bytes_remaining, frame_len);
if (tree) {
/*
* Create the CRC information.
*/
- item = ti;
if (crc_exists) {
if (crc == crc_computed) {
item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
"Bad FC CRC %8.8x %8.x",
crc, crc_computed);
}
+ proto_tree_set_appendix(fcoe_tree, tvb, crc_offset,
+ tvb_length_remaining (tvb, crc_offset));
+ } else {
+ item = proto_tree_add_text(fcoe_tree, tvb, crc_offset, 0,
+ "CRC: [missing]");
}
crc_tree = proto_item_add_subtree(item, ett_fcoe_crc);
ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb,
static hf_register_info hf[] = {
{ &hf_fcoe_sof,
{"SOF", "fcoe.sof", FT_UINT8, BASE_HEX, VALS(&fcoe_sof_vals), 0,
- "", HFILL}},
+ NULL, HFILL}},
{ &hf_fcoe_eof,
{"EOF", "fcoe.eof", FT_UINT8, BASE_HEX, VALS(&fcoe_eof_vals), 0,
- "", HFILL}},
+ NULL, HFILL}},
{ &hf_fcoe_ver,
- {"Version", "fcoe.ver", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL}},
+ {"Version", "fcoe.ver", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL}},
{ &hf_fcoe_len,
{"Frame length", "fcoe.len", FT_UINT32,
- BASE_DEC, NULL, 0, "", HFILL}},
+ BASE_DEC, NULL, 0, NULL, HFILL}},
{ &hf_fcoe_crc,
- {"CRC", "fcoe.crc", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL}},
+ {"CRC", "fcoe.crc", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL}},
{ &hf_fcoe_crc_good,
- {"CRC good", "fcoe.crc_good", FT_BOOLEAN, BASE_NONE, NULL, 0,
- "True: CRC matches packet content; "
- "False: doesn't match or not checked.", HFILL }},
+ {"CRC good", "fcoe.crc_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "True: CRC matches packet content; False: doesn't match or not checked.", HFILL }},
{ &hf_fcoe_crc_bad,
- {"CRC bad", "fcoe.crc_bad", FT_BOOLEAN, BASE_NONE, NULL, 0,
- "True: CRC doesn't match packet content; "
- "False: matches or not checked.", HFILL }}
+ {"CRC bad", "fcoe.crc_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "True: CRC doesn't match packet content; False: matches or not checked.", HFILL }}
};
static gint *ett[] = {
&ett_fcoe,
proto_register_field_array(proto_fcoe, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- fcoe_module = prefs_register_protocol(proto_fcoe, proto_reg_handoff_fcoe);
+ fcoe_module = prefs_register_protocol(proto_fcoe, NULL);
prefs_register_obsolete_preference(fcoe_module, "ethertype");
}