*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED"
* don't bother with the "Copied from" - you don't even need to put
* in a "Copied from" if you copied an existing dissector, especially
* if the bulk of the code in the new dissector is your code)
- *
+ *
* 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.
#include <glib.h>
#include <epan/packet.h>
+#include <epan/emem.h>
#include <epan/conversation.h>
-#include "etypes.h"
+#include <epan/etypes.h>
+#include "packet-scsi.h"
#include "packet-fc.h"
#include "packet-fcct.h"
#include "packet-fcfzs.h"
/* Initialize the protocol and registered fields */
static int proto_fcfzs = -1;
static int hf_fcfzs_opcode = -1;
-static int hf_fcfzs_gzc_flags = -1;
static int hf_fcfzs_gzc_vendor = -1;
-static int hf_fcfzs_zone_state = -1;
static int hf_fcfzs_gest_vendor = -1;
static int hf_fcfzs_numzoneattrs = -1;
static int hf_fcfzs_zonesetnmlen = -1;
static int hf_fcfzs_rjtvendor = -1;
static int hf_fcfzs_maxres_size = -1;
static int hf_fcfzs_mbrid_lun = -1;
-
+static int hf_fcfzs_gzc_flags = -1;
+static int hf_fcfzs_gzc_flags_hard_zones = -1;
+static int hf_fcfzs_gzc_flags_soft_zones = -1;
+static int hf_fcfzs_gzc_flags_zoneset_db = -1;
+static int hf_fcfzs_zone_state = -1;
+static int hf_fcfzs_soft_zone_set_enforced = -1;
+static int hf_fcfzs_hard_zone_set_enforced = -1;
/* Initialize the subtree pointers */
static gint ett_fcfzs = -1;
+static gint ett_fcfzs_gzc_flags = -1;
+static gint ett_fcfzs_zone_state = -1;
typedef struct _fcfzs_conv_key {
guint32 conv_idx;
} fcfzs_conv_data_t;
GHashTable *fcfzs_req_hash = NULL;
-GMemChunk *fcfzs_req_keys = NULL;
-GMemChunk *fcfzs_req_vals = NULL;
-guint32 fcfzs_init_count = 25;
static dissector_handle_t data_handle;
static void
fcfzs_init_protocol(void)
{
- if (fcfzs_req_keys)
- g_mem_chunk_destroy (fcfzs_req_keys);
- if (fcfzs_req_vals)
- g_mem_chunk_destroy (fcfzs_req_vals);
if (fcfzs_req_hash)
g_hash_table_destroy (fcfzs_req_hash);
fcfzs_req_hash = g_hash_table_new (fcfzs_hash, fcfzs_equal);
- fcfzs_req_keys = g_mem_chunk_new ("fcfzs_req_keys",
- sizeof(fcfzs_conv_key_t),
- fcfzs_init_count *
- sizeof(fcfzs_conv_key_t),
- G_ALLOC_AND_FREE);
- fcfzs_req_vals = g_mem_chunk_new ("fcfzs_req_vals",
- sizeof(fcfzs_conv_data_t),
- fcfzs_init_count *
- sizeof(fcfzs_conv_data_t),
- G_ALLOC_AND_FREE);
}
/* Code to actually dissect the packets */
dissect_fcfzs_zoneset (tvbuff_t *tvb, proto_tree *tree, int offset)
{
int numzones, nummbrs, i, j, len;
-
+
/* The zoneset structure has the following format */
/* zoneset name (len[not including pad], name, pad),
* number of zones,
*/
if (tree) {
- /* Zoneset Name */
+ /* Zoneset Name */
len = tvb_get_guint8 (tvb, offset);
proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset,
1, 0);
len, 0);
offset += 4 + len + (4-(len % 4));
-
- /* Number of zones */
+
+ /* Number of zones */
numzones = tvb_get_ntohl (tvb, offset);
proto_tree_add_item (tree, hf_fcfzs_numzones, tvb, offset, 4, 0);
offset += 4;
-
- /* For each zone... */
+
+ /* For each zone... */
for (i = 0; i < numzones; i++) {
len = tvb_get_guint8 (tvb, offset);
proto_tree_add_item (tree, hf_fcfzs_zonenmlen, tvb, offset,
offset += 4;
for (j = 0; j < nummbrs; j++) {
proto_tree_add_item (tree, hf_fcfzs_mbrtype, tvb, offset, 1, 0);
-
+
switch (tvb_get_guint8 (tvb, offset)) {
case FC_FZS_ZONEMBR_PWWN:
case FC_FZS_ZONEMBR_NWWN:
}
}
+static const true_false_string tfs_fc_fcfzs_gzc_flags_hard_zones = {
+ "Hard Zones Supported",
+ "Hard zones NOT supported"
+};
+static const true_false_string tfs_fc_fcfzs_gzc_flags_soft_zones = {
+ "Soft Zones Supported",
+ "Soft zones NOT supported"
+};
+static const true_false_string tfs_fc_fcfzs_gzc_flags_zoneset_db = {
+ "Zone Set Database is Available",
+ "Zone set database is NOT available"
+};
+
static void
-dissect_fcfzs_gzc (tvbuff_t *tvb, proto_tree *tree, guint8 isreq)
+dissect_fcfzs_gzc (tvbuff_t *tvb, int offset, proto_tree *parent_tree, guint8 isreq)
{
- guint8 flags;
- gchar str[128];
- int offset = 16; /* past the fc_ct header */
- int stroff = 0;
-
- if (tree) {
- if (!isreq) {
- flags = tvb_get_guint8 (tvb, offset);
-
- /* Disect the flags field */
- str[0] = '\0';
- if (flags & 0x80) {
- strcpy (str, "Hard Zones, ");
- stroff += 12;
- }
-
- if (flags & 0x40) {
- strcpy (&str[stroff], "Soft Zones Supported, ");
- stroff += 22;
- }
-
- if (flags & 0x01) {
- strcpy (&str[stroff], "ZoneSet Database Available");
- stroff += 26;
- }
-
- proto_tree_add_uint_format (tree, hf_fcfzs_gzc_flags, tvb, offset,
- 1, flags, "Capabilities: 0x%x (%s)",
- flags, str);
- proto_tree_add_item (tree, hf_fcfzs_gzc_vendor, tvb, offset+4, 4, 0);
- }
- }
+ if (!isreq) {
+ guint8 flags;
+ proto_item *item=NULL;
+ proto_tree *tree=NULL;
+
+ flags = tvb_get_guint8 (tvb, offset);
+ if(parent_tree){
+ item=proto_tree_add_uint(parent_tree, hf_fcfzs_gzc_flags, tvb, offset, 1, flags);
+ tree=proto_item_add_subtree(item, ett_fcfzs_gzc_flags);
+ }
+
+ proto_tree_add_boolean(tree, hf_fcfzs_gzc_flags_hard_zones, tvb, offset, 1, flags);
+ if (flags&0x80){
+ proto_item_append_text(item, " Hard Zones");
+ }
+ flags&=(~( 0x80 ));
+
+ proto_tree_add_boolean(tree, hf_fcfzs_gzc_flags_soft_zones, tvb, offset, 1, flags);
+ if (flags&0x40){
+ proto_item_append_text(item, " Soft Zones");
+ }
+ flags&=(~( 0x40 ));
+
+ proto_tree_add_boolean(tree, hf_fcfzs_gzc_flags_zoneset_db, tvb, offset, 1, flags);
+ if (flags&0x01){
+ proto_item_append_text(item, " ZoneSet Database Available");
+ }
+ flags&=(~( 0x01 ));
+
+ proto_tree_add_item (tree, hf_fcfzs_gzc_vendor, tvb, offset+4, 4, 0);
+ }
}
+static const true_false_string tfs_fc_fcfzs_soft_zone_set_enforced = {
+ "Soft Zone Set is ENFORCED",
+ "Soft zone set is NOT enforced"
+};
+static const true_false_string tfs_fc_fcfzs_hard_zone_set_enforced = {
+ "Hard Zone Set is ENFORCED",
+ "Hard zone set is NOT enforced"
+};
+
static void
-dissect_fcfzs_gest (tvbuff_t *tvb, proto_tree *tree, guint8 isreq)
+dissect_fcfzs_gest (tvbuff_t *tvb, proto_tree *parent_tree, guint8 isreq)
{
- guint8 flags;
- gchar str[128];
- int offset = 16; /* past the fc_ct header */
- int stroff = 0;
-
- if (tree) {
- if (!isreq) {
- flags = tvb_get_guint8 (tvb, offset);
- str[0] = '\0';
-
- /* dissect the flags field */
- if (flags & 0x80) {
- strcpy (str, "Soft Zone Set Enforced, ");
- stroff += 24;
- }
-
- if (flags & 0x40) {
- strcpy (str, "Hard Zone Set Enforced");
- stroff += 24;
- }
-
- proto_tree_add_uint_format (tree, hf_fcfzs_zone_state, tvb, offset,
- 1, flags, "Zone State: 0x%x (%s)",
- flags, str);
- proto_tree_add_item (tree, hf_fcfzs_gest_vendor, tvb, offset+4, 4, 0);
- }
- }
+ int offset = 16; /* past the fc_ct header */
+
+ if (!isreq) {
+ guint8 flags;
+ proto_item *item=NULL;
+ proto_tree *tree=NULL;
+
+ flags = tvb_get_guint8 (tvb, offset);
+ if(parent_tree){
+ item=proto_tree_add_uint(parent_tree, hf_fcfzs_zone_state, tvb, offset, 1, flags);
+ tree=proto_item_add_subtree(item, ett_fcfzs_zone_state);
+ }
+
+ proto_tree_add_boolean(tree, hf_fcfzs_soft_zone_set_enforced, tvb, offset, 1, flags);
+ if (flags&0x80){
+ proto_item_append_text(item, " Soft Zone Set Enforced");
+ }
+ flags&=(~( 0x80 ));
+
+ proto_tree_add_boolean(tree, hf_fcfzs_hard_zone_set_enforced, tvb, offset, 1, flags);
+ if (flags&0x40){
+ proto_item_append_text(item, " Hard Zone Set Enforced");
+ }
+ flags&=(~( 0x40 ));
+
+
+ proto_tree_add_item (parent_tree, hf_fcfzs_gest_vendor, tvb, offset+4, 4, 0);
+ }
}
static void
{
int numrec, i, len;
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (!isreq) {
numrec = tvb_get_ntohl (tvb, offset);
{
int numrec, i, len;
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (isreq) {
len = tvb_get_guint8 (tvb, offset);
proto_tree_add_item (tree, hf_fcfzs_numzoneattrs, tvb, offset,
4, 0);
-
+
offset += 4;
for (i = 0; i < numrec; i++) {
len = tvb_get_guint8 (tvb, offset);
{
int numrec, i, len;
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (isreq) {
len = tvb_get_guint8 (tvb, offset);
dissect_fcfzs_gazs (tvbuff_t *tvb, proto_tree *tree, guint8 isreq)
{
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (!isreq) {
dissect_fcfzs_zoneset (tvb, tree, offset);
{
int offset = 16; /* past the fc_ct header */
int len;
-
+
if (tree) {
if (isreq) {
len = tvb_get_guint8 (tvb, offset);
dissect_fcfzs_adzs (tvbuff_t *tvb, proto_tree *tree, guint8 isreq)
{
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (isreq) {
dissect_fcfzs_zoneset (tvb, tree, offset);
dissect_fcfzs_azsd (tvbuff_t *tvb, proto_tree *tree, guint8 isreq)
{
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (isreq) {
dissect_fcfzs_zoneset (tvb, tree, offset);
{
int offset = 16; /* past the fc_ct header */
int len;
-
+
if (tree) {
if (isreq) {
len = tvb_get_guint8 (tvb, offset);
{
int numrec, i, len, plen;
int offset = 16; /* past the fc_ct header */
-
+
if (tree) {
if (isreq) {
len = tvb_get_guint8 (tvb, offset);
{
int offset = 16; /* past the fc_ct header */
int len;
-
+
if (tree) {
if (isreq) {
len = tvb_get_guint8 (tvb, offset);
len, 0);
len += (len % 4);
offset += len;
-
+
len = tvb_get_guint8 (tvb, offset);
proto_tree_add_item (tree, hf_fcfzs_zonenmlen, tvb, offset, 1, 0);
proto_tree_add_item (tree, hf_fcfzs_zonename, tvb, offset+4,
if (tree) {
proto_tree_add_item (tree, hf_fcfzs_reason, tvb, offset+13, 1, 0);
proto_tree_add_item (tree, hf_fcfzs_rjtdetail, tvb, offset+14, 1, 0);
- proto_tree_add_item (tree, hf_fcfzs_rjtvendor, tvb, offset+15, 1, 0);
+ proto_tree_add_item (tree, hf_fcfzs_rjtvendor, tvb, offset+15, 1, 0);
}
}
guint8 isreq = 1;
/* Make entries in Protocol column and Info column on summary display */
- if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Zone Server");
-
-
+
+
tvb_memcpy (tvb, (guint8 *)&cthdr, offset, FCCT_PRMBL_SIZE);
cthdr.revision = tvb_get_guint8 (tvb, offset+1);
cthdr.in_id = tvb_get_ntoh24 (tvb, offset);
- cthdr.opcode = ntohs (cthdr.opcode);
+ cthdr.opcode = g_ntohs (cthdr.opcode);
opcode = cthdr.opcode;
- cthdr.maxres_size = ntohs (cthdr.maxres_size);
+ cthdr.maxres_size = g_ntohs (cthdr.maxres_size);
if (tree) {
ti = proto_tree_add_protocol_format (tree, proto_fcfzs, tvb, 0,
proto_tree_add_item (fcfzs_tree, hf_fcfzs_maxres_size, tvb, offset+10,
2, 0);
}
-
+
if ((opcode != FCCT_MSG_ACC) && (opcode != FCCT_MSG_RJT)) {
conversation = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
pinfo->ptype, pinfo->oxid,
pinfo->ptype, pinfo->oxid,
pinfo->rxid, NO_PORT2);
}
-
+
ckey.conv_idx = conversation->index;
-
+
cdata = (fcfzs_conv_data_t *)g_hash_table_lookup (fcfzs_req_hash,
&ckey);
if (cdata) {
/* Since we never free the memory used by an exchange, this maybe a
* case of another request using the same exchange as a previous
- * req.
+ * req.
*/
cdata->opcode = opcode;
}
else {
- req_key = g_mem_chunk_alloc (fcfzs_req_keys);
+ req_key = se_alloc (sizeof(fcfzs_conv_key_t));
req_key->conv_idx = conversation->index;
-
- cdata = g_mem_chunk_alloc (fcfzs_req_vals);
+
+ cdata = se_alloc (sizeof(fcfzs_conv_data_t));
cdata->opcode = opcode;
-
+
g_hash_table_insert (fcfzs_req_hash, req_key, cdata);
}
if (check_col (pinfo->cinfo, COL_INFO)) {
- col_set_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, fc_fzs_opcode_val,
+ col_add_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, fc_fzs_opcode_val,
"0x%x"));
}
}
if (!conversation) {
if (tree && (opcode == FCCT_MSG_ACC)) {
if (check_col (pinfo->cinfo, COL_INFO)) {
- col_set_str (pinfo->cinfo, COL_INFO,
+ col_add_str (pinfo->cinfo, COL_INFO,
val_to_str (opcode, fc_fzs_opcode_val,
"0x%x"));
}
else
failed_opcode = cdata->opcode;
}
-
+
if (check_col (pinfo->cinfo, COL_INFO)) {
if (opcode != FCCT_MSG_RJT) {
col_add_fstr (pinfo->cinfo, COL_INFO, "MSG_ACC (%s)",
fc_fzs_opcode_val, "0x%x"));
}
}
-
+
if (tree) {
if ((cdata == NULL) && (opcode != FCCT_MSG_RJT)) {
/* No record of what this accept is for. Can't decode */
dissect_fcfzs_rjt (tvb, fcfzs_tree);
break;
case FC_FZS_GZC:
- dissect_fcfzs_gzc (tvb, fcfzs_tree, isreq);
+ dissect_fcfzs_gzc (tvb, 16, fcfzs_tree, isreq);
break;
case FC_FZS_GEST:
dissect_fcfzs_gest (tvb, fcfzs_tree, isreq);
}
}
-/* Register the protocol with Ethereal */
+/* Register the protocol with Wireshark */
/* this format is require because a script is used to build the C function
that calls all the protocol registration.
void
proto_register_fcfzs(void)
-{
+{
/* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = {
{ &hf_fcfzs_opcode,
{"Opcode", "fcfzs.opcode", FT_UINT16, BASE_HEX,
VALS (fc_fzs_opcode_val), 0x0, "", HFILL}},
- { &hf_fcfzs_gzc_flags,
- {"Capabilities", "fcfzs.gzc.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
- "", HFILL}},
{ &hf_fcfzs_gzc_vendor,
{"Vendor Specific Flags", "fcfzs.gzc.vendor", FT_UINT32, BASE_HEX,
NULL, 0x0, "", HFILL}},
- { &hf_fcfzs_zone_state,
- {"Zone State", "fcfzs.zone.state", FT_UINT8, BASE_HEX, NULL, 0x0,
- "", HFILL}},
{ &hf_fcfzs_gest_vendor,
{"Vendor Specific State", "fcfzs.gest.vendor", FT_UINT32, BASE_HEX,
NULL, 0x0, "", HFILL}},
{ &hf_fcfzs_mbrid_lun,
{"LUN", "fcfzs.zone.lun", FT_BYTES, BASE_HEX, NULL, 0x0, "",
HFILL}},
+ { &hf_fcfzs_gzc_flags,
+ {"Capabilities", "fcfzs.gzc.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "", HFILL}},
+ { &hf_fcfzs_gzc_flags_hard_zones,
+ {"Hard Zones", "fcfzs.gzc.flags.hard_zones", FT_BOOLEAN, 8,
+ TFS(&tfs_fc_fcfzs_gzc_flags_hard_zones), 0x80, "", HFILL}},
+ { &hf_fcfzs_gzc_flags_soft_zones,
+ {"Soft Zones", "fcfzs.gzc.flags.soft_zones", FT_BOOLEAN, 8,
+ TFS(&tfs_fc_fcfzs_gzc_flags_soft_zones), 0x40, "", HFILL}},
+ { &hf_fcfzs_gzc_flags_zoneset_db,
+ {"ZoneSet Database", "fcfzs.gzc.flags.zoneset_db", FT_BOOLEAN, 8,
+ TFS(&tfs_fc_fcfzs_gzc_flags_zoneset_db), 0x01, "", HFILL}},
+ { &hf_fcfzs_zone_state,
+ {"Zone State", "fcfzs.zone.state", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "", HFILL}},
+ { &hf_fcfzs_soft_zone_set_enforced,
+ {"Soft Zone Set", "fcfzs.soft_zone_set.enforced", FT_BOOLEAN, 8,
+ TFS(&tfs_fc_fcfzs_soft_zone_set_enforced), 0x80, "", HFILL}},
+ { &hf_fcfzs_hard_zone_set_enforced,
+ {"Hard Zone Set", "fcfzs.hard_zone_set.enforced", FT_BOOLEAN, 8,
+ TFS(&tfs_fc_fcfzs_hard_zone_set_enforced), 0x40, "", HFILL}},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_fcfzs,
+ &ett_fcfzs_gzc_flags,
+ &ett_fcfzs_zone_state,
};
/* Register the protocol name and description */