*
* $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"
#include <glib.h>
-#ifdef NEED_SNPRINTF_H
-# include "snprintf.h"
-#endif
-
#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 */
}
}
+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
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);
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.
{ &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 */
- proto_fcfzs = proto_register_protocol("Fibre Channel Fabric Zone Server", "FC FZS", "FZS");
+ proto_fcfzs = proto_register_protocol("Fibre Channel Fabric Zone Server", "FC FZS", "fcfzs");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_fcfzs, hf, array_length(hf));