diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | Makefile.am | 11 | ||||
-rw-r--r-- | Makefile.nmake | 7 | ||||
-rw-r--r-- | etypes.h | 6 | ||||
-rw-r--r-- | packet-brdwlk.c | 298 | ||||
-rw-r--r-- | packet-fcct.c | 280 | ||||
-rw-r--r-- | packet-fcct.h | 126 | ||||
-rw-r--r-- | packet-fcdns.c | 1942 | ||||
-rw-r--r-- | packet-fcdns.h | 227 | ||||
-rw-r--r-- | packet-fcfcs.c | 1185 | ||||
-rw-r--r-- | packet-fcfcs.h | 254 | ||||
-rw-r--r-- | packet-fcfzs.c | 942 | ||||
-rw-r--r-- | packet-fcfzs.h | 119 |
13 files changed, 5396 insertions, 4 deletions
@@ -1079,7 +1079,8 @@ Jayaram V.R <vjayar[AT]cisco.com> { Dinesh Dutt <ddutt[AT]cisco.com> { SCSI dissector, for use by iSCSI and other protocols that transport SCSI operations - Fibre Channel dissector + Fibre Channel (over IP) support + MDS Debug Port Adapter (Boardwalk) FC-inside-Ethernet dissector } Nagarjuna Venna <nvenna[AT]Brixnet.com> { diff --git a/Makefile.am b/Makefile.am index 098ae1b0d7..c7deb629c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.536 2003/01/11 10:16:21 guy Exp $ +# $Id: Makefile.am,v 1.537 2003/01/14 01:17:44 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -103,6 +103,7 @@ DISSECTOR_SRC = \ packet-bootp.c \ packet-bootparams.c \ packet-bpdu.c \ + packet-brdwlk.c \ packet-bvlc.c \ packet-cdp.c \ packet-cgmp.c \ @@ -180,7 +181,11 @@ DISSECTOR_SRC = \ packet-eth.c \ packet-ethertype.c \ packet-fc.c \ + packet-fcct.c \ + packet-fcdns.c \ packet-fcels.c \ + packet-fcfcs.c \ + packet-fcfzs.c \ packet-fcip.c \ packet-fclctl.c \ packet-fcp.c \ @@ -519,7 +524,11 @@ noinst_HEADERS = \ packet-eth.h \ packet-fc.h \ packet-fcbls.h \ + packet-fcct.h \ + packet-fcdns.h \ packet-fcels.h \ + packet-fcfcs.h \ + packet-fcfzs.h \ packet-fclctl.h \ packet-fcp.h \ packet-fcswils.h \ diff --git a/Makefile.nmake b/Makefile.nmake index 6ca32ebffe..5bc2ff988d 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake # -# $Id: Makefile.nmake,v 1.269 2003/01/08 05:03:51 guy Exp $ +# $Id: Makefile.nmake,v 1.270 2003/01/14 01:17:44 guy Exp $ include config.nmake include <win32.mak> @@ -46,6 +46,7 @@ DISSECTOR_SRC = \ packet-bootp.c \ packet-bootparams.c \ packet-bpdu.c \ + packet-brdwlk.c \ packet-bvlc.c \ packet-cdp.c \ packet-cgmp.c \ @@ -123,7 +124,11 @@ DISSECTOR_SRC = \ packet-eth.c \ packet-ethertype.c \ packet-fc.c \ + packet-fcct.c \ + packet-fcdns.c \ packet-fcels.c \ + packet-fcfcs.c \ + packet-fcfzs.c \ packet-fcip.c \ packet-fclctl.c \ packet-fcp.c \ @@ -1,7 +1,7 @@ /* etypes.h * Defines ethernet packet types, similar to tcpdump's ethertype.h * - * $Id: etypes.h,v 1.29 2003/01/11 10:16:22 guy Exp $ + * $Id: etypes.h,v 1.30 2003/01/14 01:17:44 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -187,6 +187,10 @@ #define ETHERTYPE_LOOP 0x9000 /* used for layer 2 testing (do i see my own frames on the wire) */ #endif +#ifndef ETHERTYPE_BRDWALK +#define ETHERTYPE_BRDWALK 0x88AE +#endif + extern const value_string etype_vals[]; #endif /* etypes.h */ diff --git a/packet-brdwlk.c b/packet-brdwlk.c new file mode 100644 index 0000000000..59a327f52c --- /dev/null +++ b/packet-brdwlk.c @@ -0,0 +1,298 @@ +/* packet-brdwlk.c + * Routines for decoding MDS Port Analyzer Adapter (FC in Eth) Header + * Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com> + * + * $Id: packet-brdwlk.c,v 1.1 2003/01/14 01:17:44 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED" + * is a dissector file; if you just copied this from README.developer, + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <glib.h> + +#ifdef NEED_SNPRINTF_H +# include "snprintf.h" +#endif + +#include <epan/packet.h> +#include "etypes.h" + +#define BRDWLK_MAX_PACKET_CNT 0xFFFF +#define BRDWLK_TRUNCATED_BIT 0x8 + +#define FCM_DELIM_SOFC1 0x01 +#define FCM_DELIM_SOFI1 0x02 +#define FCM_DELIM_SOFI2 0x04 +#define FCM_DELIM_SOFI3 0x06 +#define FCM_DELIM_SOFN1 0x03 +#define FCM_DELIM_SOFN2 0x05 +#define FCM_DELIM_SOFN3 0x07 +#define FCM_DELIM_SOFF 0x08 +#define FCM_DELIM_SOFC4 0x09 +#define FCM_DELIM_SOFI4 0x0A +#define FCM_DELIM_SOFN4 0x0B + +#define FCM_DELIM_EOFT 0x01 +#define FCM_DELIM_EOFDT 0x02 +#define FCM_DELIM_EOFN 0x03 +#define FCM_DELIM_EOFA 0x04 +#define FCM_DELIM_EOFNI 0x07 +#define FCM_DELIM_EOFDTI 0x06 +#define FCM_DELIM_EOFRT 0x0A +#define FCM_DELIM_EOFRTI 0x0E +#define FCM_DELIM_NOEOF 0xF0 +#define FCM_DELIM_EOFJUMBO 0xF1 + +static const value_string brdwlk_sof_vals[] = { + {FCM_DELIM_SOFI1, "SOFi1"}, + {FCM_DELIM_SOFI2, "SOFi2"}, + {FCM_DELIM_SOFI3, "SOFi3"}, + {FCM_DELIM_SOFN1, "SOFn1"}, + {FCM_DELIM_SOFN2, "SOFn2"}, + {FCM_DELIM_SOFN3, "SOFn3"}, + {FCM_DELIM_SOFF, "SOFf"}, + {0, NULL}, +}; + +static const value_string brdwlk_eof_vals[] = { + {FCM_DELIM_EOFDT, "EOFdt"}, + {FCM_DELIM_EOFA, "EOFa"}, + {FCM_DELIM_EOFN, "EOFn"}, + {FCM_DELIM_EOFT, "EOFt"}, + {0, NULL}, +}; + +static const value_string brdwlk_frametype_vals[] = { + {0, NULL}, +}; + +static const value_string brdwlk_error_vals[] = { + {0, NULL}, +}; + +static int hf_brdwlk_sof = -1; +static int hf_brdwlk_eof = -1; +static int hf_brdwlk_error = -1; +static int hf_brdwlk_vsan = -1; +static int hf_brdwlk_pktcnt = -1; +static int hf_brdwlk_drop = -1; + +/* Initialize the subtree pointers */ +static gint ett_brdwlk = -1; + +static gint proto_brdwlk = -1; + +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 gchar * +brdwlk_err_to_str (guint8 error, char *str) +{ + if (str != NULL) { + str[0] = '\0'; + + if (error & 0x2) { + strcat (str, "Empty Frame, "); + } + + if (error & 0x4) { + strcat (str, "No Data, "); + } + + if (error & 0x8) { + strcat (str, "Truncated, "); + } + + if (error & 0x10) { + strcat (str, "Bad FC CRC, "); + } + + if (error & 0x20) { + strcat (str, "Fifo Full, "); + } + + if (error & 0x40) { + strcat (str, "Jumbo FC Frame, "); + } + + if (error & 0x80) { + strcat (str, "Ctrl Char Inside Frame"); + } + } + + return (str); +} + +/* Code to actually dissect the packets */ +static void +dissect_brdwlk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + +/* Set up structures needed to add the protocol subtree and manage it */ + proto_item *ti; + proto_tree *brdwlk_tree; + tvbuff_t *next_tvb; + guint8 error; + int hdrlen = 2, + offset = 0; + guint16 pkt_cnt; + gchar errstr[512]; + + /* 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, "Boardwalk"); + + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); + + if (tree) { + ti = proto_tree_add_protocol_format (tree, proto_brdwlk, tvb, 0, + hdrlen, "Boardwalk"); + + brdwlk_tree = proto_item_add_subtree (ti, ett_brdwlk); + + proto_tree_add_item (brdwlk_tree, hf_brdwlk_sof, tvb, offset, 1, 0); + proto_tree_add_item (brdwlk_tree, hf_brdwlk_vsan, tvb, offset, 2, 0); + + /* Locate EOF which is the last 4 bytes of the frame */ + offset = tvb_reported_length (tvb) - 4; + proto_tree_add_item (brdwlk_tree, hf_brdwlk_pktcnt, tvb, offset, + 2, 0); + pkt_cnt = tvb_get_ntohs (tvb, offset); + if (pkt_cnt != packet_count + 1) { + if (first_pkt || + (!pkt_cnt && (packet_count == BRDWLK_MAX_PACKET_CNT))) { + proto_tree_add_boolean_hidden (brdwlk_tree, hf_brdwlk_drop, tvb, + offset, 1, 0); + } + else { + proto_tree_add_boolean_hidden (brdwlk_tree, hf_brdwlk_drop, tvb, + offset, 1, 1); + } + } + packet_count = pkt_cnt; + + error = tvb_get_guint8 (tvb, offset+2); + proto_tree_add_uint_format (brdwlk_tree, hf_brdwlk_error, tvb, offset+2, + 1, error, "Error: 0x%x (%s)", + error, brdwlk_err_to_str (error, errstr)); +#if 0 + /* If received frame is truncated, set is_truncated flag */ + if (error & BRDWLK_TRUNCATED_BIT) { + pinfo->is_truncated = TRUE; + } +#endif + + proto_tree_add_item (brdwlk_tree, hf_brdwlk_eof, tvb, offset+3, + 1, 0); + } + + next_tvb = tvb_new_subset (tvb, 2, -1, -1); + if (fc_dissector_handle) { + call_dissector (fc_dissector_handle, next_tvb, pinfo, tree); + } +} + + +/* 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. +*/ + +void +proto_register_brdwlk (void) +{ + +/* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_brdwlk_sof, + {"SOF", "brdwlk.sof", FT_UINT8, BASE_HEX, VALS (brdwlk_sof_vals), + 0xF0, "SOF", HFILL}}, + { &hf_brdwlk_eof, + {"EOF", "brdwlk.eof", FT_UINT8, BASE_HEX, VALS (brdwlk_eof_vals), + 0x0, "EOF", HFILL}}, + { &hf_brdwlk_error, + {"Error", "brdwlk.error", FT_UINT8, BASE_DEC, NULL, 0x0, "Error", + HFILL}}, + { &hf_brdwlk_pktcnt, + {"Packet Count", "brdwlk.pktcnt", FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_brdwlk_drop, + {"Packet Dropped", "brdwlk.drop", FT_BOOLEAN, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_brdwlk_vsan, + {"VSAN", "brdwlk.vsan", FT_UINT16, BASE_DEC, NULL, 0xFFF, "", + HFILL}}, + }; + +/* Setup protocol subtree array */ + static gint *ett[] = { + &ett_brdwlk, + }; + +/* Register the protocol name and description */ + proto_brdwlk = proto_register_protocol("Boardwalk", + "Boardwalk", "brdwlk"); + +/* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_brdwlk, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + +} + + +/* If this dissector uses sub-dissector registration add a registration routine. + This format is required because a script is used to find these routines and + create the code that calls these routines. +*/ +void +proto_reg_handoff_brdwlk(void) +{ + dissector_handle_t brdwlk_handle; + + brdwlk_handle = create_dissector_handle (dissect_brdwlk, proto_brdwlk); + dissector_add("ethertype", ETHERTYPE_BRDWALK, brdwlk_handle); + data_handle = find_dissector("data"); + fc_dissector_handle = find_dissector ("fc"); +} diff --git a/packet-fcct.c b/packet-fcct.c new file mode 100644 index 0000000000..05b3da5719 --- /dev/null +++ b/packet-fcct.c @@ -0,0 +1,280 @@ +/* packet-fcct.c + * Routines for FC Common Transport Protocol (used by GS3 services) + * Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com> + * + * $Id: packet-fcct.c,v 1.1 2003/01/14 01:17:44 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED" + * is a dissector file; if you just copied this from README.developer, + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <glib.h> + +#ifdef NEED_SNPRINTF_H +# include "snprintf.h" +#endif + +#include <epan/packet.h> +#include "etypes.h" +#include "packet-fc.h" +#include "packet-fcct.h" + +/* Initialize the protocol and registered fields */ +static int proto_fcct = -1; +static int hf_fcct_revision = -1; +static int hf_fcct_inid = -1; +static int hf_fcct_gstype = -1; +static int hf_fcct_gssubtype = -1; +static int hf_fcct_options = -1; +static int hf_fcct_server = -1; /* derived field */ + +/* Extended preamble fields */ +static int hf_fcct_ext_said = -1; +static int hf_fcct_ext_tid = -1; +static int hf_fcct_ext_reqname = -1; +static int hf_fcct_ext_tstamp = -1; +static int hf_fcct_ext_authblk = -1; + +/* Initialize the subtree pointers */ +static gint ett_fcct = -1; +static gint ett_fcct_ext = -1; /* for the extended header */ + +static dissector_table_t fcct_gserver_table; +static dissector_handle_t data_handle; + +static guint8 +get_gs_server (guint8 gstype, guint8 gssubtype) +{ + switch (gstype) { + case FCCT_GSTYPE_KEYSVC: + return FCCT_GSRVR_KS; + case FCCT_GSTYPE_ALIASSVC: + if (gssubtype == FCCT_GSSUBTYPE_AS) + return FCCT_GSRVR_AS; + return FCCT_GSRVR_UNKNOWN; + case FCCT_GSTYPE_MGMTSVC: + if (gssubtype == FCCT_GSSUBTYPE_FCS) + return FCCT_GSRVR_FCS; + else if (gssubtype == FCCT_GSSUBTYPE_UNS) + return FCCT_GSRVR_UNS; + else if (gssubtype == FCCT_GSSUBTYPE_FZS) + return FCCT_GSRVR_FZS; + else return FCCT_GSRVR_UNKNOWN; + case FCCT_GSTYPE_TIMESVC: + if (gssubtype == FCCT_GSSUBTYPE_TS) + return FCCT_GSRVR_TS; + return FCCT_GSRVR_UNKNOWN; + case FCCT_GSTYPE_DIRSVC: + if (gssubtype == FCCT_GSSUBTYPE_DNS) + return FCCT_GSRVR_DNS; + else if (gssubtype == FCCT_GSSUBTYPE_IP) + return FCCT_GSRVR_IP; + return FCCT_GSRVR_UNKNOWN; + default: + return FCCT_GSRVR_UNKNOWN; + } +} + +/* Code to actually dissect the packets */ +static void +dissect_fcct (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + +/* Set up structures needed to add the protocol subtree and manage it */ + proto_item *ti; + proto_tree *fcct_tree; + tvbuff_t *next_tvb; + int in_id, + offset = 0; + guint8 server; + fc_ct_preamble cthdr; + + /* 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, "FC_CT"); + + /* + cthdr.revision = tvb_get_guint8 (tvb, offset++); + cthdr.in_id = tvb_get_ntoh24 (tvb, offset); + offset += 3; + + cthdr.gstype = tvb_get_guint8 (tvb, offset++); + cthdr.options = tvb_get_guint8 (tvb, offset++); + */ + tvb_memcpy (tvb, (guint8 *)&cthdr, offset, FCCT_PRMBL_SIZE); + cthdr.revision = tvb_get_guint8 (tvb, offset++); + cthdr.in_id = tvb_get_ntoh24 (tvb, offset); + cthdr.opcode = ntohs (cthdr.opcode); + cthdr.maxres_size = ntohs (cthdr.maxres_size); + + if (check_col (pinfo->cinfo, COL_INFO)) { + if (cthdr.opcode < FCCT_MSG_REQ_MAX) { + col_append_str (pinfo->cinfo, COL_INFO, " Request"); + } + else if (cthdr.opcode == FCCT_MSG_ACC) { + col_append_str (pinfo->cinfo, COL_INFO, " Accept"); + } + else if (cthdr.opcode == FCCT_MSG_RJT) { + col_append_fstr (pinfo->cinfo, COL_INFO, " Reject (%s)", + val_to_str (cthdr.rjt_code, fc_ct_rjt_code_vals, "0x%x")); + } + else { + col_append_str (pinfo->cinfo, COL_INFO, " Reserved"); + } + } + + in_id = cthdr.in_id; + in_id = htonl (in_id) >> 8; + + /* Determine server */ + server = get_gs_server (cthdr.gstype, cthdr.gssubtype); + + if (tree) { + offset = 0; + ti = proto_tree_add_protocol_format (tree, proto_fcct, tvb, 0, FCCT_PRMBL_SIZE, + "FC_CT"); + fcct_tree = proto_item_add_subtree (ti, ett_fcct); + + proto_tree_add_item (fcct_tree, hf_fcct_revision, tvb, offset++, + sizeof (guint8), 0); + proto_tree_add_string (fcct_tree, hf_fcct_inid, tvb, offset, 3, + fc_to_str ((guint8 *)&in_id)); + offset += 3; /* sizeof FC address */ + + proto_tree_add_item (fcct_tree, hf_fcct_gstype, tvb, offset++, + sizeof (guint8), 0); + proto_tree_add_item (fcct_tree, hf_fcct_gssubtype, tvb, offset, + sizeof (guint8), 0); + proto_tree_add_uint (fcct_tree, hf_fcct_server, tvb, offset++, 1, + server); + proto_tree_add_item (fcct_tree, hf_fcct_options, tvb, offset++, + sizeof (guint8), 0); + + } + /* We do not change the starting offset for the next protocol in the + * chain since the fc_ct header is common to the sub-protocols. + */ + next_tvb = tvb_new_subset (tvb, 0, -1, -1); + if (!dissector_try_port (fcct_gserver_table, server, next_tvb, pinfo, + tree)) { + call_dissector (data_handle, next_tvb, pinfo, tree); + } +} + +/* 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. +*/ + +void +proto_register_fcct(void) +{ + +/* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_fcct_revision, + {"Revision", "fcct.revision", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcct_inid, + {"IN_ID", "fcct.in_id", FT_STRING, BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcct_gstype, + {"GS Type", "fcct.gstype", FT_UINT8, BASE_HEX, VALS(fc_ct_gstype_vals), + 0x0, "", HFILL}}, + { &hf_fcct_gssubtype, + {"GS Subtype", "fcct.gssubtype", FT_UINT8, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_fcct_server, + {"Server", "fcct.server", FT_UINT8, BASE_HEX, + VALS (fc_ct_gsserver_vals), 0x0, + "Derived from GS Type & Subtype fields", HFILL}}, + { &hf_fcct_options, + {"Options", "fcct.options", FT_UINT8, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcct_ext_said, + {"Auth SAID", "fcct.ext_said", FT_UINT32, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcct_ext_tid, + {"Transaction ID", "fcct.ext_tid", FT_UINT32, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcct_ext_reqname, + {"Requestor Port Name", "fcct_ext_reqnm", FT_BYTES, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcct_ext_tstamp, + {"Timestamp", "fcct_ext_tstamp", FT_BYTES, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcct_ext_authblk, + {"Auth Hash Blk", "fcct_ext_authblk", FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL}}, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_fcct, + &ett_fcct_ext, + }; + + /* Register the protocol name and description */ + proto_fcct = proto_register_protocol("Fibre Channel Common Transport", "FC_CT", "fcct"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fcct, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + fcct_gserver_table = register_dissector_table ("fcct.server", + "Server", + FT_UINT8, BASE_HEX); +} + +/* If this dissector uses sub-dissector registration add a registration routine. + This format is required because a script is used to find these routines and + create the code that calls these routines. +*/ +void +proto_reg_handoff_fcct (void) +{ + dissector_handle_t fcct_handle; + + fcct_handle = create_dissector_handle (dissect_fcct, proto_fcct); + dissector_add("fc.ftype", FC_FTYPE_FCCT, fcct_handle); + + data_handle = find_dissector ("data"); +} + + diff --git a/packet-fcct.h b/packet-fcct.h new file mode 100644 index 0000000000..77b259161b --- /dev/null +++ b/packet-fcct.h @@ -0,0 +1,126 @@ +/* packet-fcct.h + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * 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. + */ + +#ifndef __PACKET_FCCT_H_ +#define __PACKET_FCCT_H_ + +/* Well-known GSTYPEs */ +#define FCCT_GSTYPE_KEYSVC 0xF7 +#define FCCT_GSTYPE_ALIASSVC 0xF8 +#define FCCT_GSTYPE_MGMTSVC 0xFA +#define FCCT_GSTYPE_TIMESVC 0xFB +#define FCCT_GSTYPE_DIRSVC 0xFC + +/* Well-known GSSUBTYPES */ +/* Actual servers serving the directory service type identified by subtype */ +#define FCCT_GSSUBTYPE_DNS 0x02 +#define FCCT_GSSUBTYPE_IP 0x03 +#define FCCT_GSSUBTYPE_FCS 0x01 +#define FCCT_GSSUBTYPE_UNS 0x02 +#define FCCT_GSSUBTYPE_FZS 0x03 +#define FCCT_GSSUBTYPE_AS 0x01 +#define FCCT_GSSUBTYPE_TS 0x01 + +/* Derived field: Server servicing the request */ +#define FCCT_GSRVR_DNS 0x1 +#define FCCT_GSRVR_IP 0x2 +#define FCCT_GSRVR_FCS 0x3 +#define FCCT_GSRVR_UNS 0x4 +#define FCCT_GSRVR_FZS 0x5 +#define FCCT_GSRVR_AS 0x6 +#define FCCT_GSRVR_TS 0x7 +#define FCCT_GSRVR_KS 0x8 +#define FCCT_GSRVR_UNKNOWN 0xFF + +/* Reject code definitions */ +#define FCCT_RJT_INVCMDCODE 0x1 +#define FCCT_RJT_INVVERSION 0x2 +#define FCCT_RJT_LOGICALERR 0x3 +#define FCCT_RJT_INVSIZE 0x4 +#define FCCT_RJT_LOGICALBSY 0x5 +#define FCCT_RJT_PROTOERR 0x7 +#define FCCT_RJT_GENFAIL 0x9 +#define FCCT_RJT_CMDNOTSUPP 0xB + +#define FCCT_MSG_REQ_MAX 0x8000 /* All opcodes below this are requests */ +#define FCCT_MSG_RJT 0x8001 /* Reject CT message */ +#define FCCT_MSG_ACC 0x8002 /* Accept CT message */ + +#define FCCT_PRMBL_SIZE 16 +#define FCCT_EXTPRMBL_SIZE 88 + +static const value_string fc_ct_rjt_code_vals [] = { + {FCCT_RJT_INVCMDCODE, "Invalid Cmd Code"}, + {FCCT_RJT_INVVERSION, "Invalid Version Level"}, + {FCCT_RJT_LOGICALERR, "Logical Error"}, + {FCCT_RJT_INVSIZE, "Invalid CT_IU Size"}, + {FCCT_RJT_LOGICALBSY, "Logical Busy"}, + {FCCT_RJT_PROTOERR, "Protocol Error"}, + {FCCT_RJT_GENFAIL, "Unable to Perform Cmd"}, + {FCCT_RJT_CMDNOTSUPP, "Cmd Not Supported"}, + {0, NULL}, +}; + +static const value_string fc_ct_gstype_vals[] = { + {FCCT_GSTYPE_KEYSVC, "Key Service"}, + {FCCT_GSTYPE_ALIASSVC, "Alias Service"}, + {FCCT_GSTYPE_MGMTSVC, "Management Service"}, + {FCCT_GSTYPE_TIMESVC, "Time Service"}, + {FCCT_GSTYPE_DIRSVC, "Directory Service"}, + {0, NULL}, +}; + +static const value_string fc_ct_gsserver_vals[] = { + {FCCT_GSRVR_DNS, "dNS"}, + {FCCT_GSRVR_IP, "IP"}, + {FCCT_GSRVR_FCS, "Fabric Config Server"}, + {FCCT_GSRVR_UNS, "Unzoned Name Server"}, + {FCCT_GSRVR_FZS, "Fabric Zone Server"}, + {FCCT_GSRVR_TS, "Time Server"}, + {FCCT_GSRVR_KS, "Key Server"}, + {FCCT_GSRVR_AS, "Alias Server"}, + {0, NULL}, +}; + +typedef struct _fc_ct_preamble { + guint32 in_id:24, + revision:8; + guint8 gstype; + guint8 gssubtype; + guint8 options; + guint8 rsvd1; + guint16 opcode; + guint16 maxres_size; + guint8 rsvd2; + guint8 rjt_code; + guint8 rjt_code_det; + guint8 rjt_code_vendor; +} fc_ct_preamble; + +typedef struct _fc_ct_ext_hdr { + guint32 auth_said; + guint32 tid; + guint32 req_pname[2]; + guint32 timestamp[2]; + guint32 auth_hashblk[15]; +} fc_ct_ext_hdr; + +#endif diff --git a/packet-fcdns.c b/packet-fcdns.c new file mode 100644 index 0000000000..0429079a93 --- /dev/null +++ b/packet-fcdns.c @@ -0,0 +1,1942 @@ +/* packet-fc-dns.c + * Routines for FC distributed Name Server (dNS) + * Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com> + * + * $Id: packet-fcdns.c,v 1.1 2003/01/14 01:17:44 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED" + * is a dissector file; if you just copied this from README.developer, + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <glib.h> + +#ifdef NEED_SNPRINTF_H +# include "snprintf.h" +#endif + +#include <epan/packet.h> +#include <epan/conversation.h> +#include "etypes.h" +#include "packet-fc.h" +#include "packet-fcct.h" +#include "packet-fcdns.h" +#include "packet-fcswils.h" + +/* Initialize the protocol and registered fields */ +static int proto_fcdns = -1; +static int hf_fcdns_gssubtype = -1; +static int hf_fcdns_opcode = -1; +static int hf_fcdns_reason = -1; +static int hf_fcdns_vendor = -1; +static int hf_fcdns_req_portid = -1; +static int hf_fcdns_rply_pname = -1; +static int hf_fcdns_rply_nname = -1; +static int hf_fcdns_rply_cos = -1; +static int hf_fcdns_rply_gft = -1; +static int hf_fcdns_rply_snamelen = -1; +static int hf_fcdns_rply_sname = -1; +static int hf_fcdns_rply_ptype = -1; +static int hf_fcdns_rply_fpname = -1; +static int hf_fcdns_fc4type = -1; +static int hf_fcdns_rply_fc4type = -1; +static int hf_fcdns_rply_fc4desc = -1; +static int hf_fcdns_rply_fc4feat = -1; +static int hf_fcdns_req_pname = -1; +static int hf_fcdns_rply_portid = -1; +static int hf_fcdns_req_nname = -1; +static int hf_fcdns_req_domainscope = -1; +static int hf_fcdns_req_areascope = -1; +static int hf_fcdns_req_fc4type = -1; +static int hf_fcdns_req_ptype = -1; +static int hf_fcdns_req_fc4feature = -1; +static int hf_fcdns_req_cos = -1; +static int hf_fcdns_req_fc4types = -1; +static int hf_fcdns_req_snamelen = -1; +static int hf_fcdns_req_sname = -1; +static int hf_fcdns_rply_spnamelen = -1; +static int hf_fcdns_rply_spname = -1; +static int hf_fcdns_req_spnamelen = -1; +static int hf_fcdns_req_spname = -1; +static int hf_fcdns_rply_ipa = -1; +static int hf_fcdns_rply_ipnode = -1; +static int hf_fcdns_rply_ipport = -1; +static int hf_fcdns_rply_fc4desclen = -1; +static int hf_fcdns_rply_hrdaddr = -1; +static int hf_fcdns_req_fdesclen = -1; +static int hf_fcdns_req_fdesc = -1; +static int hf_fcdns_req_ip = -1; +static int hf_fcdns_rjtdetail = -1; +static int hf_fcdns_zone_mbrtype = -1; +static int hf_fcdns_zone_mbrid = -1; +static int hf_fcdns_zonenm = -1; +static int hf_fcdns_portip = -1; +static int hf_fcdns_sw2_objfmt = -1; +static int hf_fcdns_num_fc4desc = -1; +static int hf_fcdns_rply_ownerid = -1; +static int hf_fcdns_maxres_size = -1; + + +/* Initialize the subtree pointers */ +static gint ett_fcdns = -1; + +typedef struct _fcdns_conv_key { + guint32 conv_idx; +} fcdns_conv_key_t; + +typedef struct _fcdns_conv_data { + guint32 opcode; +} fcdns_conv_data_t; + +GHashTable *fcdns_req_hash = NULL; +GMemChunk *fcdns_req_keys = NULL; +GMemChunk *fcdns_req_vals = NULL; +guint32 fcdns_init_count = 25; + +static dissector_handle_t data_handle; + +/* + * Hash Functions + */ +static gint +fcdns_equal(gconstpointer v, gconstpointer w) +{ + fcdns_conv_key_t *v1 = (fcdns_conv_key_t *)v; + fcdns_conv_key_t *v2 = (fcdns_conv_key_t *)w; + + return (v1->conv_idx == v2->conv_idx); +} + +static guint +fcdns_hash (gconstpointer v) +{ + fcdns_conv_key_t *key = (fcdns_conv_key_t *)v; + guint val; + + val = key->conv_idx; + + return val; +} + +/* + * Protocol initialization + */ +static void +fcdns_init_protocol(void) +{ + if (fcdns_req_keys) + g_mem_chunk_destroy (fcdns_req_keys); + if (fcdns_req_vals) + g_mem_chunk_destroy (fcdns_req_vals); + if (fcdns_req_hash) + g_hash_table_destroy(fcdns_req_hash); + + fcdns_req_hash = g_hash_table_new(fcdns_hash, fcdns_equal); + fcdns_req_keys = g_mem_chunk_new ("fcdns_req_keys", + sizeof(fcdns_conv_key_t), + fcdns_init_count * + sizeof(fcdns_conv_key_t), + G_ALLOC_AND_FREE); + fcdns_req_vals = g_mem_chunk_new ("fcdns_req_vals", + sizeof(fcdns_conv_data_t), + fcdns_init_count * + sizeof(fcdns_conv_data_t), + G_ALLOC_AND_FREE); +} + +static gchar * +fccos_to_str (tvbuff_t *tvb, int offset, gchar *cosstr) +{ + int stroff = 0, + cos = 0; + + if (cosstr == NULL) + return NULL; + + cos = tvb_get_ntohl (tvb, offset); + + cosstr[0] = '\0'; + + if (cos & 0x1) { + strcpy (cosstr, "F, "); + stroff += 3; + } + + if (cos & 0x2) { + strcpy (&cosstr[stroff], "1, "); + stroff += 3; + } + + if (cos & 0x4) { + strcpy (&cosstr[stroff], "2, "); + stroff += 3; + } + + if (cos & 0x8) { + strcpy (&cosstr[stroff], "3, "); + stroff += 3; + } + + if (cos & 0x10) { + strcpy (&cosstr[stroff], "4, "); + stroff += 3; + } + + if (cos & 0x40) { + strcpy (&cosstr[stroff], "6"); + } + + return (cosstr); +} + +/* The feature routines just decode FCP's FC-4 features field */ +static gchar * +fc4feature_to_str (guint8 fc4feature, guint8 fc4type, gchar *str) +{ + int stroff = 0; + + *str = '\0'; + + if (fc4type == FC_TYPE_SCSI) { + if (fc4feature & 0x1) { + strcpy (str, "T, "); + stroff += 3; + } + + if (fc4feature & 0x2) { + strcpy (&str[stroff], "I"); + } + } + else { + sprintf (str, "0x%x", fc4feature); + } + return (str); +} + +static gchar * +fc4ftrs_to_str (tvbuff_t *tvb, int offset, gchar *str) +{ + guint8 fc4feature; + int stroff = 0; + + if (str == NULL) { + return NULL; + } + + *str = '\0'; + fc4feature = tvb_get_guint8 (tvb, offset+7); + + if (fc4feature & 0x1) { + strcpy (str, "T, "); + stroff += 3; + } + + if (fc4feature & 0x2) { + strcpy (&str[stroff], "I"); + } + + return (str); +} + +/* Decodes LLC/SNAP, IP, FCP, VI, GS, SW_ILS types only */ +/* Max len of str to be allocated by caller is 40 */ +static gchar * +fc4type_to_str (tvbuff_t *tvb, int offset, gchar *str) +{ + guint32 fc4tword; + int stroff = 0; + + if (str == NULL) { + return NULL; + } + + *str = '\0'; + + fc4tword = tvb_get_ntohl (tvb, offset); + + if (fc4tword & 0x10) { + strcpy (str, "LLC/SNAP, "); + stroff += 10; + } + + if (fc4tword & 0x20) { + strcpy (&str[stroff], "IP, "); + stroff += 4; + } + + if (fc4tword & 0x0100) { + strcpy (&str[stroff], "FCP, "); + stroff += 5; + } + + fc4tword = tvb_get_ntohl (tvb, offset+4); + + if (fc4tword & 0x1) { + strcpy (&str[stroff], "GS3, "); + stroff += 5; + } + + if (fc4tword & 0x4) { + strcpy (&str[stroff], "SNMP, "); + stroff += 6; + } + + if (fc4tword & 0x10) { + strcpy (&str[stroff], "SW_ILS, "); + stroff += 8; + } + + fc4tword = tvb_get_ntohl (tvb, offset+8); + if (fc4tword & 0x1) { + strcpy (&str[stroff], "VI, "); + stroff += 3; + } + return (str); +} + +/* Code to actually dissect the packets */ + +/* A bunch of get routines have a similar req packet format. The first few + * routines deal with this decoding. All assume that tree is valid */ +static void +dissect_fcdns_req_portid (tvbuff_t *tvb, proto_tree *tree, int offset) +{ + if (tree) { + proto_tree_add_string (tree, hf_fcdns_req_portid, tvb, offset, 3, + fc_to_str (tvb_get_ptr (tvb, offset, 3))); + } +} + +static void +dissect_fcdns_ganxt (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 len; + gchar str[128]; + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_item (req_tree, hf_fcdns_rply_ptype, tvb, offset, + 1, 0); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, 3))); + proto_tree_add_string (req_tree, hf_fcdns_rply_pname, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+4, + 8))); + len = tvb_get_guint8 (tvb, offset+12); + proto_tree_add_item (req_tree, hf_fcdns_rply_spnamelen, tvb, + offset+12, 1, 0); + if (!tvb_offset_exists (tvb, 29+len)) + return; + + if (len) { + proto_tree_add_item (req_tree, hf_fcdns_rply_spname, tvb, + offset+13, len, 0); + } + + if (tvb_offset_exists (tvb, 292)) { + proto_tree_add_string (req_tree, hf_fcdns_rply_nname, tvb, + offset+268, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+268, + 0))); + } + if (tvb_offset_exists (tvb, 548)) { + len = tvb_get_guint8 (tvb, offset+276); + proto_tree_add_item (req_tree, hf_fcdns_rply_snamelen, tvb, + offset+276, 1, 0); + if (len) { + proto_tree_add_item (req_tree, hf_fcdns_rply_sname, tvb, + offset+277, len, 0); + } + } + if (tvb_offset_exists (tvb, 556)) { + proto_tree_add_item (req_tree, hf_fcdns_rply_ipa, tvb, + offset+532, 8, 0); + } + if (tvb_offset_exists (tvb, 572)) { + proto_tree_add_item (req_tree, hf_fcdns_rply_ipnode, tvb, + offset+540, 16, 0); + } + if (tvb_offset_exists (tvb, 576)) { + proto_tree_add_string (req_tree, hf_fcdns_rply_cos, tvb, offset+556, + 4, + fccos_to_str (tvb, offset+556, str)); + } + if (tvb_offset_exists (tvb, 608)) { + proto_tree_add_string (req_tree, hf_fcdns_rply_gft, tvb, offset+560, + 32, + fc4type_to_str (tvb, offset+560, str)); + } + if (tvb_offset_exists (tvb, 624)) { + proto_tree_add_item (req_tree, hf_fcdns_rply_ipport, tvb, + offset+592, 16, 0); + } + if (tvb_offset_exists (tvb, 632)) { + proto_tree_add_string (req_tree, hf_fcdns_rply_fpname, tvb, + offset+608, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+608, + 8))); + } + if (tvb_offset_exists (tvb, 635)) { + proto_tree_add_string (req_tree, hf_fcdns_rply_hrdaddr, tvb, + offset+617, 3, + fc_to_str (tvb_get_ptr (tvb, offset+617, + 3))); + } + } + } +} + +static void +dissect_fcdns_gpnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_pname, tvb, offset, + 8, fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + } +} + +static void +dissect_fcdns_gnnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_nname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + } +} + +static void +dissect_fcdns_gcsid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar cosstr[64]; + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_cos, tvb, + offset, 4, + fccos_to_str (tvb, offset, cosstr)); + } + } +} + +static void +dissect_fcdns_gftid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar fc4str[64]; + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_gft, tvb, + offset, 32, + fc4type_to_str (tvb, offset, fc4str)); + } + } +} + +static void +dissect_fcdns_gspnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 len; + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (req_tree, hf_fcdns_rply_spnamelen, + tvb, offset, 1, 0); + proto_tree_add_string (req_tree, hf_fcdns_rply_spname, tvb, + offset+1, len, + tvb_get_ptr (tvb, offset+1, len)); + } + } +} + +static void +dissect_fcdns_gptid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_item (req_tree, hf_fcdns_rply_ptype, tvb, + offset, 1, 0); + } + } +} + +static void +dissect_fcdns_gfpnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_fpname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + } + +} + +static void +dissect_fcdns_gfdid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar fc4str[128]; + int tot_len, desclen; + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + proto_tree_add_string (req_tree, hf_fcdns_fc4type, tvb, offset+4, + 32, + fc4type_to_str (tvb, offset+4, fc4str)); + } + else { + tot_len = tvb_length (tvb) - offset; /* excluding CT header */ + while (tot_len > 0) { + /* The count of the descriptors is not returned and so we have + * to track the display by the length field */ + desclen = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (req_tree, hf_fcdns_rply_fc4desc, tvb, + offset, desclen, 0); + tot_len -= 255; /* descriptors are aligned to 255 bytes */ + offset += 256; + } + } + } +} + +static void +dissect_fcdns_gffid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar fc4fstr[128]; + + if (req_tree) { + if (isreq) { + dissect_fcdns_req_portid (tvb, req_tree, offset+1); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_fc4feat, tvb, + offset, 128, + fc4ftrs_to_str (tvb, offset, fc4fstr)); + } + } +} + +static void +dissect_fcdns_gidpn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_pname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + else { + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + } + } +} + +static void +dissect_fcdns_gipppn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_pname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + else { + proto_tree_add_item (req_tree, hf_fcdns_rply_ipport, tvb, offset, + 16, 0); + } + } +} + +static void +dissect_fcdns_gidnn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + offset += 4; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gipnn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + else { + proto_tree_add_item (req_tree, hf_fcdns_rply_ipnode, tvb, offset, + 16, 0); + } + } +} + +static void +dissect_fcdns_gpnnn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_rply_pname, + tvb, offset+8, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+8, + 8))); + offset += 16; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gsnnnn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 len; + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, + offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + } + else { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (req_tree, hf_fcdns_rply_snamelen, tvb, + offset, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_rply_sname, tvb, + offset+1, len, 0); + } + } +} + +static void +dissect_fcdns_gidft (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + + if (req_tree) { + if (isreq) { + proto_tree_add_item (req_tree, hf_fcdns_req_domainscope, + tvb, offset+1, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_areascope, + tvb, offset+2, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, + tvb, offset+3, 1, 0); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + offset += 4; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gpnft (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + + if (req_tree) { + if (isreq) { + proto_tree_add_item (req_tree, hf_fcdns_req_domainscope, + tvb, offset+1, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_areascope, + tvb, offset+2, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, + tvb, offset+3, 1, 0); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_rply_pname, + tvb, offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+8, + 8))); + offset += 16; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gnnft (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + + if (req_tree) { + if (isreq) { + proto_tree_add_item (req_tree, hf_fcdns_req_domainscope, + tvb, offset+1, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_areascope, + tvb, offset+2, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, + tvb, offset+3, 1, 0); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_rply_nname, + tvb, offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+8, + 8))); + offset += 16; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gidpt (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast = 0; + + if (req_tree) { + if (isreq) { + proto_tree_add_item (req_tree, hf_fcdns_req_ptype, + tvb, offset, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_domainscope, + tvb, offset+1, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_areascope, + tvb, offset+2, 1, 0); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + offset += 4; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gidipp (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + + if (req_tree) { + if (isreq) { + proto_tree_add_item (req_tree, hf_fcdns_req_ip, tvb, offset, + 16, 0); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + offset += 4; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_gidff (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 islast; + gchar str[64]; + + if (req_tree) { + if (isreq) { + proto_tree_add_item (req_tree, hf_fcdns_req_domainscope, tvb, + offset+1, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_areascope, tvb, + offset+2, 1, 0); + proto_tree_add_string (req_tree, hf_fcdns_req_fc4feature, tvb, + offset+6, 1, + fc4feature_to_str (tvb_get_guint8 (tvb, offset+6), + tvb_get_guint8 (tvb, offset+7), + str)); + proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, tvb, + offset+7, 1, 0); + } + else { + do { + islast = tvb_get_guint8 (tvb, offset); + proto_tree_add_string (req_tree, hf_fcdns_rply_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + offset += 4; + } while (!(islast & 0x80)); + } + } +} + +static void +dissect_fcdns_rpnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_req_pname, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+4, + 8))); + } + } +} + +static void +dissect_fcdns_rnnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree) { + if (isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, + tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+4, + 8))); + } + } +} + +static void +dissect_fcdns_rcsid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar cos[64]; + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_req_cos, tvb, + offset+4, 4, + fccos_to_str (tvb, offset+4, cos)); + } +} + +static void +dissect_fcdns_rptid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_item (req_tree, hf_fcdns_req_ptype, tvb, + offset+4, 1, 0); + } +} + +static void +dissect_fcdns_rftid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar fc4str[128]; + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_req_fc4types, tvb, + offset+4, 32, + fc4type_to_str (tvb, offset+4, fc4str)); + } +} + +static void +dissect_fcdns_rspnid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 len; + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_item (req_tree, hf_fcdns_req_spnamelen, tvb, + offset+4, 1, 0); + len = tvb_get_guint8 (tvb, offset+4); + + proto_tree_add_item (req_tree, hf_fcdns_req_spname, tvb, offset+5, + len, 0); + } +} + +static void +dissect_fcdns_rippid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_item (req_tree, hf_fcdns_req_ip, tvb, + offset+4, 16, 0); + } +} + +static void +dissect_fcdns_rfdid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len, dlen; + gchar fc4str[128]; + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, + offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_string (req_tree, hf_fcdns_req_fc4types, tvb, + offset+4, 32, + fc4type_to_str (tvb, offset+4, fc4str)); + + len = tvb_length (tvb) - offset - 36; + offset += 36; + + while (len > 0) { + dlen = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (req_tree, hf_fcdns_req_fdesclen, tvb, offset, + 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_fdesc, tvb, offset+1, + len, 0); + offset += 256; + len -= 256; + } + } +} + +static void +dissect_fcdns_rffid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar fc4str[64]; + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, 3))); + proto_tree_add_string (req_tree, hf_fcdns_req_fc4feature, tvb, + offset+6, 1, + fc4feature_to_str (tvb_get_guint8 (tvb, + offset+6), + tvb_get_guint8 (tvb, + offset+7), + fc4str)); + proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, tvb, offset+7, + 1, 0); + } +} + +static void +dissect_fcdns_ripnn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + proto_tree_add_item (req_tree, hf_fcdns_req_ip, tvb, offset+8, 16, 0); + } +} + +static void +dissect_fcdns_rsnnnn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + guint8 len; + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + len = tvb_get_guint8 (tvb, offset+8); + + proto_tree_add_item (req_tree, hf_fcdns_req_snamelen, tvb, offset+8, + 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_req_sname, tvb, offset+9, + len, 0); + } +} + +static void +dissect_fcdns_daid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (req_tree && isreq) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, 3))); + } +} + +static gchar * +zonenm_to_str (tvbuff_t *tvb, gint offset) +{ + int len = tvb_get_guint8 (tvb, offset); + return ((gchar *)tvb_get_ptr (tvb, offset+4, len)); +} + +static void +dissect_fcdns_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset) +{ + int mbrlen = 4 + tvb_get_guint8 (tvb, offset+3); + + proto_tree_add_item (zmbr_tree, hf_fcdns_zone_mbrtype, tvb, + offset, 1, 0); + proto_tree_add_text (zmbr_tree, tvb, offset+2, 1, "Flags: 0x%x", + tvb_get_guint8 (tvb, offset+2)); + proto_tree_add_text (zmbr_tree, tvb, offset+3, 1, + "Identifier Length: %d", + tvb_get_guint8 (tvb, offset+3)); + switch (tvb_get_guint8 (tvb, offset)) { + case FC_SWILS_ZONEMBR_WWN: + proto_tree_add_string (zmbr_tree, hf_fcdns_zone_mbrid, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+4, + 8))); + break; + case FC_SWILS_ZONEMBR_DP: + proto_tree_add_string_format (zmbr_tree, + hf_fcdns_zone_mbrid, + tvb, offset+4, 4, " ", + "0x%x", + tvb_get_ntohl (tvb, + offset+4)); + break; + case FC_SWILS_ZONEMBR_FCID: + proto_tree_add_string (zmbr_tree, hf_fcdns_zone_mbrid, tvb, + offset+4, 4, + fc_to_str (tvb_get_ptr (tvb, + offset+4, + 3))); + break; + case FC_SWILS_ZONEMBR_ALIAS: + proto_tree_add_string (zmbr_tree, hf_fcdns_zone_mbrid, tvb, + offset+4, + tvb_get_guint8 (tvb, offset+3), + zonenm_to_str (tvb, offset+4)); + break; + default: + proto_tree_add_string (zmbr_tree, hf_fcdns_zone_mbrid, tvb, + offset+4, mbrlen, + "Unknown member type format"); + + } +} + +static void +dissect_fcdns_swils_entries (tvbuff_t *tvb, proto_tree *tree, int offset) +{ + int numrec, i, len; + guint8 objfmt; + gchar str[512]; + + numrec = tvb_get_ntohl (tvb, offset); + + if (tree) { + proto_tree_add_text (tree, tvb, offset, 4, "Number of Entries: %d", + numrec); + offset += 4; + + for (i = 0; i < numrec; i++) { + objfmt = tvb_get_guint8 (tvb, offset); + + proto_tree_add_item (tree, hf_fcdns_sw2_objfmt, tvb, offset, 1, 0); + proto_tree_add_string (tree, hf_fcdns_rply_ownerid, tvb, offset+1, + 3, fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + proto_tree_add_item (tree, hf_fcdns_rply_ptype, tvb, offset+4, + 1, 0); + proto_tree_add_string (tree, hf_fcdns_rply_portid, tvb, offset+5, 3, + fc_to_str (tvb_get_ptr (tvb, offset+5, 3))); + proto_tree_add_string (tree, hf_fcdns_rply_pname, tvb, offset+8, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+8, + 8))); + offset += 16; + if (!(objfmt & 0x1)) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcdns_rply_spnamelen, tvb, + offset, 1, 0); + proto_tree_add_item (tree, hf_fcdns_rply_spname, tvb, + offset+1, len, 0); + offset += 256; + } + proto_tree_add_string (tree, hf_fcdns_rply_nname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + offset += 8; + if (!(objfmt & 0x1)) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcdns_rply_snamelen, tvb, + offset, 1, 0); + proto_tree_add_item (tree, hf_fcdns_rply_sname, tvb, + offset+1, len, 0); + offset += 256; + } + proto_tree_add_item (tree, hf_fcdns_rply_ipa, tvb, offset, 8, 0); + proto_tree_add_item (tree, hf_fcdns_rply_ipnode, tvb, offset+8, 16, + 0); + proto_tree_add_string (tree, hf_fcdns_rply_cos, tvb, offset+24, 4, + fccos_to_str (tvb, offset+24, str)); + proto_tree_add_string (tree, hf_fcdns_rply_gft, tvb, offset+28, + 32, + fc4type_to_str (tvb, offset+28, str)); + proto_tree_add_item (tree, hf_fcdns_rply_ipport, tvb, offset+60, + 16, 0); + proto_tree_add_string (tree, hf_fcdns_rply_fpname, tvb, offset+76, + 8, fcwwn_to_str (tvb_get_ptr (tvb, + offset+76, + 8))); + proto_tree_add_string (tree, hf_fcdns_rply_hrdaddr, tvb, offset+85, + 3, fc_to_str (tvb_get_ptr (tvb, offset+85, + 3))); + offset += 88; + if (objfmt & 0x2) { + proto_tree_add_string (tree, hf_fcdns_rply_fc4feat, tvb, + offset, 128, + fc4ftrs_to_str (tvb, offset, str)); + if (tvb_get_guint8 (tvb, offset+129)) { + proto_tree_add_item (tree, hf_fcdns_rply_fc4type, tvb, + offset+128, 1, 0); + proto_tree_add_item (tree, hf_fcdns_num_fc4desc, tvb, + offset+129, 1, 0); + len = tvb_get_guint8 (tvb, offset+132); + proto_tree_add_item (tree, hf_fcdns_rply_fc4desclen, tvb, + offset+132, 1, 0); + proto_tree_add_item (tree, hf_fcdns_rply_fc4desc, tvb, + offset+133, len, 0); + } + else { + proto_tree_add_item (tree, hf_fcdns_num_fc4desc, tvb, + offset+129, 1, 0); + } + offset += 388; /* FC4 desc is 260 bytes, maybe padded */ + } + } + } +} + +static void +dissect_fcdns_geid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (isreq) { + if (req_tree) { + proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, offset+1, + 3, fc_to_str (tvb_get_ptr (tvb, offset+1, + 3))); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_gepn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + if (isreq) { + if (req_tree) { + proto_tree_add_string (req_tree, hf_fcdns_req_pname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_genn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (isreq) { + if (req_tree) { + proto_tree_add_string (req_tree, hf_fcdns_req_nname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_geip (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (isreq) { + if (req_tree) { + proto_tree_add_item (req_tree, hf_fcdns_req_ip, tvb, offset, 16, 0); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_geft (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar str[128]; + + if (isreq) { + if (req_tree) { + proto_tree_add_string (req_tree, hf_fcdns_fc4type, tvb, offset, 32, + fc4type_to_str (tvb, offset, str)); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_gept (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (isreq) { + if (req_tree) { + proto_tree_add_item (req_tree, hf_fcdns_req_ptype, tvb, offset+3, + 1, 0); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_gezm (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (isreq) { + if (req_tree) { + dissect_fcdns_zone_mbr (tvb, req_tree, offset); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_gezn (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int strlen; + + if (isreq) { + if (req_tree) { + strlen = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (req_tree, tvb, offset, 1, "Name Length: %d", + strlen); + proto_tree_add_string (req_tree, hf_fcdns_zonenm, tvb, offset+3, + strlen, tvb_get_ptr (tvb, offset+3, strlen)); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_geipp (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (isreq) { + if (req_tree) { + proto_tree_add_item (req_tree, hf_fcdns_portip, tvb, offset, 4, 0); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_geff (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + gchar str[256]; + + if (isreq) { + if (req_tree) { + proto_tree_add_string (req_tree, hf_fcdns_req_fc4feature, tvb, offset, + 128, fc4ftrs_to_str (tvb, offset, str)); + } + } + else { + dissect_fcdns_swils_entries (tvb, req_tree, offset); + } +} + +static void +dissect_fcdns_rjt (tvbuff_t *tvb, proto_tree *req_tree) +{ + int offset = 0; + + if (req_tree) { + proto_tree_add_item (req_tree, hf_fcdns_reason, tvb, offset+13, 1, 0); + proto_tree_add_item (req_tree, hf_fcdns_rjtdetail, tvb, offset+14, 1, + 0); + proto_tree_add_item (req_tree, hf_fcdns_vendor, tvb, offset+15, 1, 0); + } +} + +static void +dissect_fcdns (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + /* Set up structures needed to add the protocol subtree and manage it */ + proto_item *ti = NULL; + proto_tree *fcdns_tree = NULL; + int offset = 0; + int opcode, + failed_opcode = 0; + int isreq = 1; + fc_ct_preamble cthdr; + conversation_t *conversation; + fcdns_conv_data_t *cdata; + fcdns_conv_key_t ckey, *req_key; + + tvb_memcpy (tvb, (guint8 *)&cthdr, offset, FCCT_PRMBL_SIZE); + cthdr.revision = tvb_get_guint8 (tvb, offset); + cthdr.in_id = tvb_get_ntoh24 (tvb, offset+1); + cthdr.opcode = ntohs (cthdr.opcode); + opcode = cthdr.opcode; + cthdr.maxres_size = ntohs (cthdr.maxres_size); + + /* Determine the type of server the request/response is for */ + if (check_col(pinfo->cinfo, COL_PROTOCOL)) { + if (cthdr.gstype == FCCT_GSTYPE_DIRSVC) + col_set_str (pinfo->cinfo, COL_PROTOCOL, "dNS"); + else + col_set_str (pinfo->cinfo, COL_PROTOCOL, "Unzoned NS"); + } + + if (tree) { + if (cthdr.gstype == FCCT_GSTYPE_DIRSVC) { + ti = proto_tree_add_protocol_format (tree, proto_fcdns, tvb, 0, + tvb_reported_length (tvb), + "dNS"); + fcdns_tree = proto_item_add_subtree (ti, ett_fcdns); + } + else { + ti = proto_tree_add_protocol_format (tree, proto_fcdns, tvb, 0, + tvb_reported_length (tvb), + "Unzoned NS"); + fcdns_tree = proto_item_add_subtree (ti, ett_fcdns); + } + } + + if ((opcode != FCCT_MSG_ACC) && (opcode != FCCT_MSG_RJT)) { + conversation = find_conversation (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + if (!conversation) { + conversation = conversation_new (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + } + + ckey.conv_idx = conversation->index; + + cdata = (fcdns_conv_data_t *)g_hash_table_lookup (fcdns_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. + */ + cdata->opcode = opcode; + } + else { + req_key = g_mem_chunk_alloc (fcdns_req_keys); + req_key->conv_idx = conversation->index; + + cdata = g_mem_chunk_alloc (fcdns_req_vals); + cdata->opcode = opcode; + + g_hash_table_insert (fcdns_req_hash, req_key, cdata); + } + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, fc_dns_opcode_val, + "0x%x")); + } + } + else { + /* Opcode is ACC or RJT */ + conversation = find_conversation (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + isreq = 0; + if (!conversation) { + if (tree && (opcode == FCCT_MSG_ACC)) { + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, + val_to_str (opcode, fc_dns_opcode_val, + "0x%x")); + } + /* No record of what this accept is for. Can't decode */ + proto_tree_add_text (fcdns_tree, tvb, 0, tvb_length (tvb), + "No record of Exchg. Unable to decode MSG_ACC/RJT"); + return; + } + } + else { + ckey.conv_idx = conversation->index; + + cdata = (fcdns_conv_data_t *)g_hash_table_lookup (fcdns_req_hash, &ckey); + + if (cdata != NULL) { + if (opcode == FCCT_MSG_ACC) { + opcode = cdata->opcode; + } + else + failed_opcode = cdata->opcode; + } + + if (check_col (pinfo->cinfo, COL_INFO)) { + if (opcode != FCCT_MSG_RJT) { + col_add_fstr (pinfo->cinfo, COL_INFO, "ACC (%s)", + val_to_str (opcode, fc_dns_opcode_val, + "0x%x")); + } + else { + col_add_fstr (pinfo->cinfo, COL_INFO, "RJT (%s)", + val_to_str (failed_opcode, + fc_dns_opcode_val, + "0x%x")); + } + } + + if (tree) { + if ((cdata == NULL) && (opcode != FCCT_MSG_RJT)) { + /* No record of what this accept is for. Can't decode */ + proto_tree_add_text (fcdns_tree, tvb, 0, tvb_length (tvb), + "No record of Exchg. Unable to decode MSG_ACC/RJT"); + return; + } + } + } + } + + if (tree) { + proto_tree_add_item (fcdns_tree, hf_fcdns_opcode, tvb, offset+8, 2, 0); + proto_tree_add_item (fcdns_tree, hf_fcdns_maxres_size, tvb, offset+10, + 2, 0); + } + + switch (opcode) { + case FCCT_MSG_RJT: + dissect_fcdns_rjt (tvb, fcdns_tree); + break; + case FCDNS_GA_NXT: + dissect_fcdns_ganxt (tvb, fcdns_tree, isreq); + break; + case FCDNS_GPN_ID: + dissect_fcdns_gpnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GNN_ID: + dissect_fcdns_gnnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GCS_ID: + dissect_fcdns_gcsid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GFT_ID: + dissect_fcdns_gftid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GSPN_ID: + dissect_fcdns_gspnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GPT_ID: + dissect_fcdns_gptid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GFPN_ID: + dissect_fcdns_gfpnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GFD_ID: + dissect_fcdns_gfdid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GFF_ID: + dissect_fcdns_gffid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GID_PN: + dissect_fcdns_gidpn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GIPP_PN: + dissect_fcdns_gipppn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GID_NN: + dissect_fcdns_gidnn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GPN_NN: + dissect_fcdns_gpnnn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GIP_NN: + dissect_fcdns_gipnn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GSNN_NN: + dissect_fcdns_gsnnnn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GID_FT: + dissect_fcdns_gidft (tvb, fcdns_tree, isreq); + break; + case FCDNS_GPN_FT: + dissect_fcdns_gpnft (tvb, fcdns_tree, isreq); + break; + case FCDNS_GNN_FT: + dissect_fcdns_gnnft (tvb, fcdns_tree, isreq); + break; + case FCDNS_GID_PT: + dissect_fcdns_gidpt (tvb, fcdns_tree, isreq); + break; + case FCDNS_GID_IPP: + dissect_fcdns_gidipp (tvb, fcdns_tree, isreq); + break; + case FCDNS_GID_FF: + dissect_fcdns_gidff (tvb, fcdns_tree, isreq); + break; + case FCDNS_RPN_ID: + dissect_fcdns_rpnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RNN_ID: + dissect_fcdns_rnnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RCS_ID: + dissect_fcdns_rcsid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RPT_ID: + dissect_fcdns_rptid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RFT_ID: + dissect_fcdns_rftid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RSPN_ID: + dissect_fcdns_rspnid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RIPP_ID: + dissect_fcdns_rippid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RFD_ID: + dissect_fcdns_rfdid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RFF_ID: + dissect_fcdns_rffid (tvb, fcdns_tree, isreq); + break; + case FCDNS_RIP_NN: + dissect_fcdns_ripnn (tvb, fcdns_tree, isreq); + break; + case FCDNS_RSNN_NN: + dissect_fcdns_rsnnnn (tvb, fcdns_tree, isreq); + break; + case FCDNS_DA_ID: + dissect_fcdns_daid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_ID: + dissect_fcdns_geid (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_PN: + dissect_fcdns_gepn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_NN: + dissect_fcdns_genn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_IP: + dissect_fcdns_geip (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_FT: + dissect_fcdns_geft (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_PT: + dissect_fcdns_gept (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_ZM: + dissect_fcdns_gezm (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_ZN: + dissect_fcdns_gezn (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_IPP: + dissect_fcdns_geipp (tvb, fcdns_tree, isreq); + break; + case FCDNS_GE_FF: + dissect_fcdns_geff (tvb, fcdns_tree, isreq); + break; + default: + break; + } +} + +/* Register the protocol with Ethereal */ + +/* this format is required because a script is used to build the C function + that calls all the protocol registration. +*/ + +void +proto_register_fcdns (void) +{ + +/* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_fcdns_gssubtype, + {"GS_Subtype", "fcdns.gssubtype", FT_UINT8, BASE_HEX, + VALS (fc_dns_subtype_val), 0x0, "", HFILL}}, + {&hf_fcdns_opcode, + {"Opcode", "fcdns.opcode", FT_UINT16, BASE_HEX, VALS (fc_dns_opcode_val), + 0x0, "", HFILL}}, + { &hf_fcdns_req_portid, + {"Port Identifier", "fcdns.req.portid", FT_STRING, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_fcdns_rply_pname, + {"Port Name", "fcdns.rply.pname", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcdns_rply_nname, + {"Node Name", "fcdns.rply.nname", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcdns_rply_cos, + {"Class of Service Supported", "fcdns.rply.cos", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_gft, + {"FC-4 Types Supported", "fcdns.rply.fc4type", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_snamelen, + {"Symbolic Node Name Length", "fcdns.rply.snamelen", FT_UINT8, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_sname, + {"Symbolic Node Name", "fcdns.rply.sname", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_ptype, + {"Port Type", "fcdns.rply.porttype", FT_UINT8, BASE_HEX, + VALS (fc_dns_port_type_val), 0x0, "", HFILL}}, + { &hf_fcdns_rply_fpname, + {"Fabric Port Name", "fcdns.rply.fpname", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_fc4type, + {"FC-4 Type", "fcdns.req.fc4type", FT_STRING, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_fcdns_rply_fc4desc, + {"FC-4 Descriptor", "fcdns.rply.fc4desc", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_fc4feat, + {"FC-4 Features", "fcdns.rply.fc4features", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_req_pname, + {"Port Name", "fcdns.req.portname", FT_STRING, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_fcdns_rply_portid, + {"Port Identifier", "fcdns.rply.portid", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_req_nname, + {"Node Name", "fcdns.req.nname", FT_STRING, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_fcdns_req_domainscope, + {"Domain ID Scope", "fcdns.req.domainid", FT_UINT8, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_req_areascope, + {"Area ID Scope", "fcdns.req.areaid", FT_UINT8, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_req_fc4type, + {"FC-4 Type", "fcdns.req.fc4type", FT_UINT8, BASE_HEX, + VALS (fc_fc4_val), 0x0, "", HFILL}}, + { &hf_fcdns_req_ptype, + {"Port Type", "fcdns.req.porttype", FT_UINT8, BASE_HEX, + VALS (fc_dns_port_type_val), 0x0, "", HFILL}}, + { &hf_fcdns_req_ip, + {"IP Address", "fcdns.req.ip", FT_IPv6, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_fcdns_req_fc4feature, + {"FC-4 Feature Bits", "fcdns.req.fc4feature", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_req_cos, + {"Class of Service Supported", "fcdns.req.class", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_req_fc4types, + {"FC-4 TYPEs Supported", "fcdns.req.fc4types", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_fc4type, + {"FC-4 Descriptor Type", "fcdns.rply.fc4type", FT_UINT8, BASE_HEX, + VALS (fc_fc4_val), 0x0, "", HFILL}}, + { &hf_fcdns_req_snamelen, + {"Symbolic Name Length", "fcdns.req.snamelen", FT_UINT8, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_req_sname, + {"Symbolic Port Name", "fcdns.req.sname", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_spnamelen, + {"Symbolic Port Name Length", "fcdns.rply.spnamelen", FT_UINT8, + BASE_DEC, NULL, 0x0, "", HFILL}}, + {&hf_fcdns_rply_spname, + {"Symbolic Port Name", "fcdns.rply.spname", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_ipa, + {"Initial Process Associator", "fcdns.rply.ipa", FT_BYTES, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_ipnode, + {"Node IP Address", "fcdns.rply.ipnode", FT_IPv6, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_ipport, + {"Port IP Address", "fcdns.rply.ipport", FT_IPv6, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_fc4desclen, + {"FC-4 Descriptor Length", "fcdns.rply.fc4desclen", FT_UINT8, + BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_fc4desc, + {"FC-4 Descriptor", "fcdns.rply.fc4desc", FT_BYTES, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_rply_hrdaddr, + {"Hard Address", "fcdns.rply.hrdaddr", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_req_fdesclen, + {"FC-4 Descriptor Length", "fcdns.req.fc4desclen", FT_UINT8, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_req_fdesc, + {"FC-4 Descriptor", "fcdns.req.fc4desc", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_req_spnamelen, + {"Symbolic Port Name Length", "fcdns.req.spnamelen", FT_UINT8, + BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_req_spname, + {"Symbolic Port Name", "fcdns.req.spname", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_reason, + {"Reason Code", "fcdns.rply.reason", FT_UINT8, BASE_HEX, + VALS (fc_ct_rjt_code_vals), 0x0, "", HFILL}}, + { &hf_fcdns_rjtdetail, + {"Reason Code Explanantion", "fcdns.rply.reasondet", FT_UINT8, + BASE_HEX, VALS (fc_dns_rjt_det_code_val), 0x0, "", HFILL}}, + { &hf_fcdns_vendor, + {"Vendor Unique Reject Code", "fcdns.rply.vendor", FT_UINT8, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_zone_mbrtype, + {"Zone Member Type", "fcdns.zone.mbrtype", FT_UINT8, BASE_HEX, + VALS (fc_swils_zonembr_type_val), 0x0, "", HFILL}}, + { &hf_fcdns_zone_mbrid, + {"Member Identifier", "swils.zone.mbrid", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcdns_zonenm, + {"Zone Name", "fcdns.zonename", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcdns_portip, + {"Port IP Address", "fcdns.portip", FT_IPv4, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_fcdns_sw2_objfmt, + {"Name Entry Object Format", "fcdns.entry.objfmt", FT_UINT8, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcdns_num_fc4desc, + {"Number of FC4 Descriptors Registered", "fcdns.entry.numfc4desc", + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcdns_rply_ownerid, + {"Owner Id", "fcdns.rply.ownerid", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcdns_maxres_size, + {"Maximum/Residual Size", "fcdns.maxres_size", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + }; + + static gint *ett[] = { + &ett_fcdns, + }; + + /* Register the protocol name and description */ + proto_fcdns = proto_register_protocol("Fibre Channel Name Server", + "FC-dNS", "FC-dNS"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fcdns, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + register_init_routine (&fcdns_init_protocol); +} + +/* If this dissector uses sub-dissector registration add a registration routine. + This format is required because a script is used to find these routines and + create the code that calls these routines. +*/ +void +proto_reg_handoff_fcdns (void) +{ + dissector_handle_t dns_handle; + + dns_handle = create_dissector_handle (dissect_fcdns, proto_fcdns); + dissector_add("fcct.server", FCCT_GSRVR_DNS, dns_handle); + dissector_add("fcct.server", FCCT_GSRVR_UNS, dns_handle); + + data_handle = find_dissector ("data"); +} + + diff --git a/packet-fcdns.h b/packet-fcdns.h new file mode 100644 index 0000000000..99e838f4dc --- /dev/null +++ b/packet-fcdns.h @@ -0,0 +1,227 @@ +/* packet-fcdns.h + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * 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. + */ + +#ifndef __PACKET_FCDNS_H_ +#define __PACKET_FCDNS_H_ + +/* Opcode definitions */ +#define FCDNS_GA_NXT 0x0100 +#define FCDNS_GID_A 0x0101 +#define FCDNS_GPN_ID 0x0112 +#define FCDNS_GNN_ID 0x0113 +#define FCDNS_GCS_ID 0x0114 +#define FCDNS_GFT_ID 0x0117 +#define FCDNS_GSPN_ID 0x0118 +#define FCDNS_GPT_ID 0x011A +#define FCDNS_GIPP_ID 0x011B +#define FCDNS_GFPN_ID 0x011C +#define FCDNS_GHA_ID 0x011D +#define FCDNS_GFD_ID 0x011E +#define FCDNS_GFF_ID 0x011F +#define FCDNS_GID_PN 0x0121 +#define FCDNS_GIPP_PN 0x012B +#define FCDNS_GID_NN 0x0131 +#define FCDNS_GPN_NN 0x0132 +#define FCDNS_GIP_NN 0x0135 +#define FCDNS_GIPA_NN 0x0136 +#define FCDNS_GSNN_NN 0x0139 +#define FCDNS_GNN_IP 0x0153 +#define FCDNS_GIPA_IP 0x0156 +#define FCDNS_GID_FT 0x0171 +#define FCDNS_GPN_FT 0x0172 +#define FCDNS_GNN_FT 0x0173 +#define FCDNS_GID_PT 0x01A1 +#define FCDNS_GID_IPP 0x01B1 +#define FCDNS_GPN_IPP 0x01B2 +#define FCDNS_GID_FF 0x01F1 +#define FCDNS_RPN_ID 0x0212 +#define FCDNS_RNN_ID 0x0213 +#define FCDNS_RCS_ID 0x0214 +#define FCDNS_RFT_ID 0x0217 +#define FCDNS_RSPN_ID 0x0218 +#define FCDNS_RPT_ID 0x021A +#define FCDNS_RIPP_ID 0x021B +#define FCDNS_RHA_ID 0x021D +#define FCDNS_RFD_ID 0x021E +#define FCDNS_RFF_ID 0x021F +#define FCDNS_RIP_NN 0x0235 +#define FCDNS_RSNN_NN 0x0239 +#define FCDNS_DA_ID 0x0300 +/* dNS messages defined by FC-SW2 */ +#define FCDNS_RA 0x0 +#define FCDNS_GE_ID 0x0410 +#define FCDNS_GE_PN 0x0420 +#define FCDNS_GE_NN 0x0430 +#define FCDNS_GE_IP 0x0450 +#define FCDNS_GE_FT 0x0470 +#define FCDNS_GE_PT 0x04A0 +#define FCDNS_GE_ZM 0x04B0 +#define FCDNS_GE_ZN 0x04C0 +#define FCDNS_GE_IPP 0x04D0 +#define FCDNS_GE_FF 0x04E0 + +static const value_string fc_dns_opcode_val[] = { + {FCDNS_GA_NXT, "GA_NXT" }, + {FCDNS_GID_A, "GID_A" }, + {FCDNS_GPN_ID, "GPN_ID" }, + {FCDNS_GNN_ID, "GNN_ID" }, + {FCDNS_GCS_ID, "GCS_ID" }, + {FCDNS_GFT_ID, "GFT_ID" }, + {FCDNS_GSPN_ID, "GSPN_ID" }, + {FCDNS_GPT_ID, "GPT_ID" }, + {FCDNS_GIPP_ID, "GIPP_ID" }, + {FCDNS_GFPN_ID, "GFPN_ID" }, + {FCDNS_GHA_ID, "GHA_ID" }, + {FCDNS_GFD_ID, "GFD_ID" }, + {FCDNS_GFF_ID, "GFF_ID" }, + {FCDNS_GID_PN, "GID_PN" }, + {FCDNS_GIPP_PN, "GIPP_PN" }, + {FCDNS_GID_NN, "GID_NN" }, + {FCDNS_GPN_NN, "GPN_NN" }, + {FCDNS_GIP_NN, "GIP_NN" }, + {FCDNS_GIPA_NN, "GIPA_NN" }, + {FCDNS_GSNN_NN, "GSNN_NN" }, + {FCDNS_GNN_IP, "GNN_IP" }, + {FCDNS_GIPA_IP, "GIPA_IP" }, + {FCDNS_GID_FT, "GID_FT" }, + {FCDNS_GPN_FT, "GPN_FT" }, + {FCDNS_GNN_FT, "GNN_FT" }, + {FCDNS_GID_PT, "GID_PT" }, + {FCDNS_GID_IPP, "GID_IPP" }, + {FCDNS_GPN_IPP, "GPN_IPP" }, + {FCDNS_GID_FF, "GID_FF" }, + {FCDNS_RPN_ID, "RPN_ID" }, + {FCDNS_RNN_ID, "RNN_ID" }, + {FCDNS_RCS_ID, "RCS_ID" }, + {FCDNS_RFT_ID, "RFT_ID" }, + {FCDNS_RSPN_ID, "RSPN_ID" }, + {FCDNS_RPT_ID, "RPT_ID" }, + {FCDNS_RIPP_ID, "RIPP_ID" }, + {FCDNS_RHA_ID, "RHA_ID" }, + {FCDNS_RFD_ID, "RFD_ID" }, + {FCDNS_RFF_ID, "RFF_ID" }, + {FCDNS_RIP_NN, "RIP_NN" }, + {FCDNS_RSNN_NN, "RSNN_NN"}, + {FCDNS_DA_ID, "DA_ID"}, + {FCDNS_GE_ID, "GE_ID"}, + {FCDNS_GE_PN, "GE_PN"}, + {FCDNS_GE_NN, "GE_NN"}, + {FCDNS_GE_IP, "GE_IP"}, + {FCDNS_GE_FT, "GE_FT"}, + {FCDNS_GE_PT, "GE_PT"}, + {FCDNS_GE_ZM, "GE_ZM"}, + {FCDNS_GE_ZN, "GE_ZN"}, + {FCDNS_GE_IPP, "GE_IPP"}, + {FCDNS_GE_FF, "GE_FF"}, + {FCCT_MSG_ACC, "MSG_ACC"}, + {FCCT_MSG_RJT, "MSG_RJT"}, + {0, NULL}, +}; + +/* Port type definitions */ +#define FCDNS_PTYPE_UNDEF 0x00 +#define FCDNS_PTYPE_NPORT 0x01 +#define FCDNS_PTYPE_NLPORT 0x02 +#define FCDNS_PTYPE_FNLPORT 0x03 +#define FCDNS_PTYPE_NXPORT 0x7F +#define FCDNS_PTYPE_FPORT 0x81 +#define FCDNS_PTYPE_FLPORT 0x82 +#define FCDNS_PTYPE_EPORT 0x84 +#define FCDNS_PTYPE_BPORT 0x85 + +static const value_string fc_dns_port_type_val [] = { + {FCDNS_PTYPE_UNDEF , "Undefined Port Type"}, + {FCDNS_PTYPE_NPORT , "N_Port"}, + {FCDNS_PTYPE_NLPORT , "NL_Port"}, + {FCDNS_PTYPE_FNLPORT , "F/NL_Port"}, + {FCDNS_PTYPE_NXPORT , "Nx_Port"}, + {FCDNS_PTYPE_FPORT , "F_Port"}, + {FCDNS_PTYPE_FLPORT , "FL_Port"}, + {FCDNS_PTYPE_EPORT , "E_Port"}, + {FCDNS_PTYPE_BPORT , "B_Port"}, + {0, NULL}, +}; + +/* Reject Detailed Reason code definitions for dNS */ +#define FCDNS_RJT_NOREASON 0x00 +#define FCDNS_RJT_PIDNOTREG 0x01 +#define FCDNS_RJT_PNAMENOTREG 0x02 +#define FCDNS_RJT_NNAMENOTREG 0x03 +#define FCDNS_RJT_CLASSNOTREG 0x04 +#define FCDNS_RJT_IPNNOTREG 0x05 +#define FCDNS_RJT_IPANOTREG 0x06 +#define FCDNS_RJT_FC4NOTREG 0x07 +#define FCDNS_RJT_SPNAMENOTREG 0x08 +#define FCDNS_RJT_SNNAMENOTREG 0x09 +#define FCDNS_RJT_PTYPENOTREG 0x0A +#define FCDNS_RJT_IPPNOTREG 0x0B +#define FCDNS_RJT_FPNAMENOTREG 0x0C +#define FCDNS_RJT_HRDADDNOTREG 0x0D +#define FCDNS_RJT_FC4DESNOTREG 0x0E +#define FCDNS_RJT_FC4FEANOTREG 0x0F +#define FCDNS_RJT_ACCRJT 0x10 +#define FCDNS_RJT_PTYPEFMT 0x11 +#define FCDNS_RJT_DBEMPTY 0x12 +#define FCDNS_RJT_NOOBJSCOPE 0x13 +#define FCDNS_RJT_AUTHRZN_EXCEPTION 0xF0 +#define FCDNS_RJT_AUTH_EXCEPTION 0xF1 +#define FCDNS_RJT_DB_FULL 0xF2 +#define FCDNS_RJT_DB_EMPTY 0xF3 + +static const value_string fc_dns_rjt_det_code_val [] = { + {FCDNS_RJT_NOREASON , "No Additional Info"}, + {FCDNS_RJT_PIDNOTREG , "PortID Not Regd."}, + {FCDNS_RJT_PNAMENOTREG , "PortName Not Regd."}, + {FCDNS_RJT_NNAMENOTREG , "NodeName Not Regd."}, + {FCDNS_RJT_CLASSNOTREG , "Class Not Regd."}, + {FCDNS_RJT_IPNNOTREG , "IP Addr (Node) Not Regd."}, + {FCDNS_RJT_IPANOTREG , "IPA Not Regd."}, + {FCDNS_RJT_FC4NOTREG , "FC4 TYPEs Not Regd."}, + {FCDNS_RJT_SPNAMENOTREG, "Symbolic PortName Not Regd."}, + {FCDNS_RJT_SNNAMENOTREG, "Symbolic NodeName Not Regd."}, + {FCDNS_RJT_PTYPENOTREG , "PortType Not Regd."}, + {FCDNS_RJT_IPPNOTREG , "IP Addr (Port) Not Regd."}, + {FCDNS_RJT_FPNAMENOTREG, "Fabric Port Name Not Regd."}, + {FCDNS_RJT_HRDADDNOTREG, "Hard Addr Not Regd."}, + {FCDNS_RJT_FC4DESNOTREG, "FC4 Descriptors Not Regd."}, + {FCDNS_RJT_FC4FEANOTREG, "FC4 Features Not Regd."}, + {FCDNS_RJT_ACCRJT , "Access Denied"}, + {FCDNS_RJT_PTYPEFMT , "Unacceptable PortId"}, + {FCDNS_RJT_DBEMPTY , "Database Empty"}, + {FCDNS_RJT_NOOBJSCOPE , "No Objects Regd. in Scope"}, + {FCDNS_RJT_AUTHRZN_EXCEPTION, "Authorization Exception"}, + {FCDNS_RJT_AUTH_EXCEPTION, "Authentication Exception"}, + {FCDNS_RJT_DB_FULL, "Database Full"}, + {FCDNS_RJT_DB_EMPTY, "Database Empty"}, + {0, NULL}, +}; + +/* Actual servers serving the directory service type identified by subtype */ +#define FCDNS_GSSUBTYPE_DNS 0x02 +#define FCDNS_GSSUBTYPE_IP 0x03 + +static const value_string fc_dns_subtype_val[] = { + {FCDNS_GSSUBTYPE_DNS, "dNS"}, + {FCDNS_GSSUBTYPE_IP, "IP"}, + {0, NULL}, +}; + +#endif diff --git a/packet-fcfcs.c b/packet-fcfcs.c new file mode 100644 index 0000000000..316fc7bd00 --- /dev/null +++ b/packet-fcfcs.c @@ -0,0 +1,1185 @@ +/* packet-fcfcs.c + * Routines for FC Fabric Configuration Server + * Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com> + * + * $Id: packet-fcfcs.c,v 1.1 2003/01/14 01:17:44 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED" + * is a dissector file; if you just copied this from README.developer, + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <glib.h> + +#ifdef NEED_SNPRINTF_H +# include "snprintf.h" +#endif + +#include <epan/packet.h> +#include <epan/conversation.h> +#include "etypes.h" +#include "packet-fc.h" +#include "packet-fcct.h" +#include "packet-fcfcs.h" + +/* Initialize the protocol and registered fields */ +static int proto_fcfcs = -1; +static int hf_fcs_opcode = -1; +static int hf_fcs_iename = -1; +static int hf_fcs_ietype = -1; +static int hf_fcs_iedomainid = -1; +static int hf_fcs_mgmtid = -1; +static int hf_fcs_fabricname = -1; +static int hf_fcs_mgmtaddr = -1; +static int hf_fcs_lname = -1; +static int hf_fcs_vendorname = -1; +static int hf_fcs_modelname = -1; +static int hf_fcs_portname = -1; +static int hf_fcs_portmodtype = -1; +static int hf_fcs_porttxtype = -1; +static int hf_fcs_porttype = -1; +static int hf_fcs_physportnum = -1; +static int hf_fcs_portflags = -1; +static int hf_fcs_portstate = -1; +static int hf_fcs_platformname = -1; +static int hf_fcs_platformnname = -1; +static int hf_fcs_platformtype = -1; +static int hf_fcs_platformaddr = -1; +static int hf_fcs_reason = -1; +static int hf_fcs_rjtdetail = -1; +static int hf_fcs_vendor = -1; +static int hf_fcs_numcap = -1; +static int hf_fcs_mgmt_subtype = -1; +static int hf_fcs_unsmask = -1; +static int hf_fcs_vnd_capmask = -1; +static int hf_fcs_fcsmask = -1; +static int hf_fcs_maxres_size = -1; +static int hf_fcs_releasecode = -1; + + +/* Initialize the subtree pointers */ +static gint ett_fcfcs = -1; + +typedef struct _fcfcs_conv_key { + guint32 conv_idx; +} fcfcs_conv_key_t; + +typedef struct _fcfcs_conv_data { + guint32 opcode; +} fcfcs_conv_data_t; + +GHashTable *fcfcs_req_hash = NULL; +GMemChunk *fcfcs_req_keys = NULL; +GMemChunk *fcfcs_req_vals = NULL; +guint32 fcfcs_init_count = 25; + +static dissector_handle_t data_handle; + +/* + * Hash Functions + */ +static gint +fcfcs_equal(gconstpointer v, gconstpointer w) +{ + fcfcs_conv_key_t *v1 = (fcfcs_conv_key_t *)v; + fcfcs_conv_key_t *v2 = (fcfcs_conv_key_t *)w; + + return (v1->conv_idx == v2->conv_idx); +} + +static guint +fcfcs_hash (gconstpointer v) +{ + fcfcs_conv_key_t *key = (fcfcs_conv_key_t *)v; + guint val; + + val = key->conv_idx; + + return val; +} + +/* + * Protocol initialization + */ +static void +fcfcs_init_protocol(void) +{ + if (fcfcs_req_keys) + g_mem_chunk_destroy (fcfcs_req_keys); + if (fcfcs_req_vals) + g_mem_chunk_destroy (fcfcs_req_vals); + if (fcfcs_req_hash) + g_hash_table_destroy (fcfcs_req_hash); + + fcfcs_req_hash = g_hash_table_new(fcfcs_hash, fcfcs_equal); + fcfcs_req_keys = g_mem_chunk_new ("fcfcs_req_keys", + sizeof(fcfcs_conv_key_t), + fcfcs_init_count * + sizeof(fcfcs_conv_key_t), + G_ALLOC_AND_FREE); + fcfcs_req_vals = g_mem_chunk_new ("fcfcs_req_vals", + sizeof(fcfcs_conv_data_t), + fcfcs_init_count * + sizeof(fcfcs_conv_data_t), + G_ALLOC_AND_FREE); +} + +/* Code to actually dissect the packets */ +static void +dissect_fcfcs_giel (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the ct header */ + int numelem, i; + + if (!isreq && tree) { + numelem = tvb_get_ntohl (tvb, offset); + + proto_tree_add_text (tree, tvb, offset, 4, "Number of IE entries: 0x%d", + numelem); + offset += 4; + for (i = 0; i < numelem; i++) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + proto_tree_add_item (tree, hf_fcs_ietype, tvb, offset+11, 1, 0); + offset += 12; + } + } +} + +static void +dissect_fcfcs_giet (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_item (tree, hf_fcs_ietype, tvb, offset+3, 1, 0); + } + } +} + +static void +dissect_fcfcs_gdid (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_item (tree, hf_fcs_iedomainid, tvb, offset+1, 1, 0); + } + } +} + +static void +dissect_fcfcs_gmid (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_string (tree, hf_fcs_mgmtid, tvb, offset+1, 3, + fc_to_str (tvb_get_ptr (tvb, offset+1, 3))); + } + } +} + +static void +dissect_fcfcs_gfn (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_string (tree, hf_fcs_fabricname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + } +} + +static void +dissect_fcfcs_gieln (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_text (tree, tvb, offset, 1, "Name Length: %d", + tvb_get_guint8 (tvb, offset)); + proto_tree_add_item (tree, hf_fcs_lname, tvb, offset+1, + tvb_get_guint8 (tvb, offset), 0); + } + } +} + +static void +dissect_fcfcs_gmal (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int numelem, i; + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + numelem = tvb_get_ntohl (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Mgmt. Addresses: 0x%d", numelem); + + offset += 4; + for (i = 0; i < numelem; i++) { + proto_tree_add_text (tree, tvb, offset, 1, "Name Length: %d", + tvb_get_guint8 (tvb, offset)); + proto_tree_add_item (tree, hf_fcs_mgmtaddr, tvb, offset+1, + tvb_get_guint8 (tvb, offset), 0); + offset += 256; + } + } + } +} + +static void +dissect_fcfcs_gieil (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + gchar *str; + int len, tot_len, prevlen; + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + tot_len = tvb_get_guint8 (tvb, offset+3); + proto_tree_add_text (tree, tvb, offset+3, 1, "List Length: %d", + tot_len); + + prevlen = 0; + str = (gchar *)tvb_get_ptr (tvb, offset+4, tot_len); + len = strlen (str); + if (len) { + proto_tree_add_item (tree, hf_fcs_vendorname, tvb, offset+4, + len, 0); + } + + prevlen += (len+1); + str = (gchar *)tvb_get_ptr (tvb, offset+4+prevlen, tot_len-prevlen); + len = strlen (str); + + if (len) { + proto_tree_add_item (tree, hf_fcs_modelname, tvb, offset+4+prevlen, + len, 0); + } + + prevlen += (len+1); + str = (gchar *)tvb_get_ptr (tvb, offset+4+prevlen, tot_len-prevlen); + len = strlen (str); + + if (len) { + proto_tree_add_item (tree, hf_fcs_releasecode, tvb, + offset+4+prevlen, len, 0); + } + + prevlen += (len+1); + offset += (4+prevlen); + while (tot_len > prevlen) { + str = (gchar *)tvb_get_ptr (tvb, offset, tot_len-prevlen); + len = strlen (str); + if (len) { + proto_tree_add_text (tree, tvb, offset, len, + "Vendor-specific Information: %s", + str); + } + prevlen += (len+1); + offset += (len+1); + } + } + } +} + +static void +dissect_fcfcs_gpl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int numelem, i; + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + numelem = tvb_get_ntohl (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Port Entries: %d", + numelem); + offset += 4; + + for (i = 0; i < numelem; i++) { + proto_tree_add_string (tree, hf_fcs_portname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + proto_tree_add_item (tree, hf_fcs_portmodtype, tvb, offset+9, + 1, 0); + proto_tree_add_item (tree, hf_fcs_porttxtype, tvb, offset+10, + 1, 0); + proto_tree_add_item (tree, hf_fcs_porttype, tvb, offset+11, + 1, 0); + offset += 12; + } + } + } +} + +static void +dissect_fcfcs_gpt (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_portname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_item (tree, hf_fcs_porttype, tvb, offset+3, 1, 0); + } + } +} + +static void +dissect_fcfcs_gppn (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_portname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_item (tree, hf_fcs_physportnum, tvb, offset, 4, 0); + } + } +} + +static void +dissect_fcfcs_gapnl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int numelem, i; + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_portname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + numelem = tvb_get_ntohl (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Attached Port Entries: %d", + numelem); + offset += 4; + for (i = 0; i < numelem; i++) { + proto_tree_add_string (tree, hf_fcs_portname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + proto_tree_add_item (tree, hf_fcs_portflags, tvb, offset+10, + 1, 0); + proto_tree_add_item (tree, hf_fcs_porttype, tvb, offset+11, + 1, 0); + offset += 12; + } + } + } +} + +static void +dissect_fcfcs_gps (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_portname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + proto_tree_add_item (tree, hf_fcs_porttype, tvb, offset+3, 1, 0); + proto_tree_add_item (tree, hf_fcs_portstate, tvb, offset+7, 1, 0); + } + } +} + +static void +dissect_fcfcs_gplnl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int numelem, i, len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + } + else { + numelem = tvb_get_ntohl (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Platform Node Name Entries: %d", + numelem); + offset += 4; + for (i = 0; i < numelem; i++) { + proto_tree_add_string (tree, hf_fcs_platformnname, tvb, offset, + 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + offset += 8; + } + } + } +} + +static void +dissect_fcfcs_gplt (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + } + else { + proto_tree_add_item (tree, hf_fcs_platformtype, tvb, offset+3, + 1, 0); + } + } +} + +static void +dissect_fcfcs_gplml (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int numelem, i, len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + } + else { + numelem = tvb_get_ntohl (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Mgmt. Address Entries: %d", + numelem); + offset += 4; + for (i = 0; i < numelem; i++) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Mgmt Address Length: %d", + len); + proto_tree_add_item (tree, hf_fcs_platformaddr, tvb, offset+1, + len, 0); + offset += 256; + } + } + } +} + +static void +dissect_fcfcs_gnpl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int len; + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_platformnname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + else { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + } + } +} + +static void +dissect_fcfcs_gpnl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fcct header */ + int numelem, i, len; + + if (tree) { + if (!isreq) { + numelem = tvb_get_ntohl (tvb, offset); + + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Platform Name Entries: %d", + numelem); + offset += 4; + for (i = 0; i < numelem; i++) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", + len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + offset += 256; + } + } + } +} + +static void +dissect_fcfcs_rieln (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + len = tvb_get_guint8 (tvb, offset+8); + proto_tree_add_text (tree, tvb, offset+8, 1, + "Logical Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_lname, tvb, offset+9, len, 0); + } + } +} + +static void +dissect_fcfcs_rpl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int numelem, i, len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + proto_tree_add_item (tree, hf_fcs_platformtype, tvb, offset+259, 1, + 0); + numelem = tvb_get_ntohl (tvb, offset+260); + proto_tree_add_text (tree, tvb, offset+260, 4, + "Number of Mgmt. Addr Entries: %d", numelem); + offset += 264; + for (i = 0; i < numelem; i++) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Mgmt. Addr Length: %d", len); + proto_tree_add_item (tree, hf_fcs_mgmtaddr, tvb, offset+1, + len, 0); + offset += 256; + } + + numelem = tvb_get_ntohl (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 4, + "Number of Platform Node Name Entries: %d", + numelem); + offset += 4; + for (i = 0; i < numelem; i++) { + proto_tree_add_string (tree, hf_fcs_platformnname, tvb, offset, + 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, + 8))); + offset += 8; + } + } + } +} + +static void +dissect_fcfcs_rpln (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + proto_tree_add_string (tree, hf_fcs_platformnname, tvb, offset+256, + 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+256, + 8))); + } + } +} + +static void +dissect_fcfcs_rplt (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + proto_tree_add_item (tree, hf_fcs_platformtype, tvb, offset+259, + 4, 0); + } + } +} + +static void +dissect_fcfcs_rplm (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + len = tvb_get_guint8 (tvb, offset+256); + proto_tree_add_text (tree, tvb, offset+256, 1, + "Platform Mgmt. Address Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformaddr, tvb, offset+257, + len, 0); + } + } +} + +static void +dissect_fcfcs_dpl (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + } + } +} + +static void +dissect_fcfcs_dpln (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + + if (tree) { + if (isreq) { + proto_tree_add_string (tree, hf_fcs_platformnname, tvb, offset, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset, 8))); + } + } +} + +static void +dissect_fcfcs_dplml (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_text (tree, tvb, offset, 1, + "Platform Name Length: %d", len); + proto_tree_add_item (tree, hf_fcs_platformname, tvb, offset+1, + len, 0); + } + } +} + +static void +dissect_fcfcs_gcap (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) +{ + int offset = 16; /* past the fc_ct header */ + int numrec, i; + guint8 subtype; + + if (tree) { + if (!isreq) { + numrec = tvb_get_ntohl (tvb, offset); + proto_tree_add_item (tree, hf_fcs_numcap, tvb, offset, 4, 0); + + offset += 4; + for (i = 0; i < numrec; i++) { + proto_tree_add_item (tree, hf_fcs_mgmt_subtype, tvb, offset, + 1, 0); + subtype = tvb_get_guint8 (tvb, offset); + + proto_tree_add_item (tree, hf_fcs_vnd_capmask, tvb, offset+1, + 3, 0); + if (subtype == FCCT_GSSUBTYPE_FCS) { + proto_tree_add_item (tree, hf_fcs_fcsmask, tvb, offset+4, + 4, 0); + } + else if (subtype == FCCT_GSSUBTYPE_UNS) { + proto_tree_add_item (tree, hf_fcs_unsmask, tvb, offset+4, + 4, 0); + } + } + } + } +} + +static void +dissect_fcfcs_rjt (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 0; + + if (tree) { + proto_tree_add_item (tree, hf_fcs_reason, tvb, offset+13, 1, 0); + proto_tree_add_item (tree, hf_fcs_rjtdetail, tvb, offset+14, 1, + 0); + proto_tree_add_item (tree, hf_fcs_vendor, tvb, offset+15, 1, 0); + } + +} + +static void +dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + +/* Set up structures needed to add the protocol subtree and manage it */ + int offset = 0; + proto_item *ti; + proto_tree *fcfcs_tree = NULL; + fc_ct_preamble cthdr; + gboolean isreq = 1; + conversation_t *conversation; + fcfcs_conv_data_t *cdata; + fcfcs_conv_key_t ckey, *req_key; + int opcode, + failed_opcode = 0; + + /* 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, "FC-FCS"); + + if (tree) { + ti = proto_tree_add_protocol_format (tree, proto_fcfcs, tvb, 0, + tvb_reported_length (tvb), + "FCS"); + fcfcs_tree = proto_item_add_subtree (ti, ett_fcfcs); + } + + tvb_memcpy (tvb, (guint8 *)&cthdr, offset, FCCT_PRMBL_SIZE); + cthdr.revision = tvb_get_guint8 (tvb, offset); + cthdr.in_id = tvb_get_ntoh24 (tvb, offset+1); + cthdr.opcode = ntohs (cthdr.opcode); + opcode = tvb_get_ntohs (tvb, offset+8); + cthdr.maxres_size = ntohs (cthdr.maxres_size); + + if ((opcode != FCCT_MSG_ACC) && (opcode != FCCT_MSG_RJT)) { + conversation = find_conversation (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + if (!conversation) { + conversation = conversation_new (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + } + + ckey.conv_idx = conversation->index; + + cdata = (fcfcs_conv_data_t *)g_hash_table_lookup (fcfcs_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. + */ + cdata->opcode = opcode; + } + else { + req_key = g_mem_chunk_alloc (fcfcs_req_keys); + req_key->conv_idx = conversation->index; + + cdata = g_mem_chunk_alloc (fcfcs_req_vals); + cdata->opcode = opcode; + + g_hash_table_insert (fcfcs_req_hash, req_key, cdata); + } + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, + val_to_str (opcode, fc_fcs_opcode_abbrev_val, "0x%x")); + } + } + else { + /* Opcode is ACC or RJT */ + conversation = find_conversation (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + isreq = 0; + if (!conversation) { + if (tree && (opcode == FCCT_MSG_ACC)) { + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, + val_to_str (opcode, fc_fcs_opcode_abbrev_val, + "0x%x")); + } + /* No record of what this accept is for. Can't decode */ + proto_tree_add_text (fcfcs_tree, tvb, 0, tvb_length (tvb), + "No record of Exchg. Unable to decode MSG_ACC/RJT"); + return; + } + } + else { + ckey.conv_idx = conversation->index; + + cdata = (fcfcs_conv_data_t *)g_hash_table_lookup (fcfcs_req_hash, + &ckey); + + if (cdata != NULL) { + if (opcode == FCCT_MSG_ACC) + opcode = cdata->opcode; + 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)", + val_to_str (opcode, fc_fcs_opcode_abbrev_val, + "0x%x")); + } + else { + col_add_fstr (pinfo->cinfo, COL_INFO, "MSG_RJT (%s)", + val_to_str (failed_opcode, + fc_fcs_opcode_abbrev_val, + "0x%x")); + } + } + + if (tree) { + if ((cdata == NULL) && (opcode != FCCT_MSG_RJT)) { + /* No record of what this accept is for. Can't decode */ + proto_tree_add_text (fcfcs_tree, tvb, 0, tvb_length (tvb), + "No record of Exchg. Unable to decode MSG_ACC/RJT"); + return; + } + } + } + } + + + if (tree) { + proto_tree_add_item (fcfcs_tree, hf_fcs_opcode, tvb, offset+8, 2, 0); + proto_tree_add_item (fcfcs_tree, hf_fcs_maxres_size, tvb, offset+10, + 2, 0); + } + + switch (opcode) { + case FCCT_MSG_RJT: + dissect_fcfcs_rjt (tvb, fcfcs_tree); + break; + case FCFCS_GIEL: + dissect_fcfcs_giel (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GIET: + dissect_fcfcs_giet (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GDID: + dissect_fcfcs_gdid (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GMID: + dissect_fcfcs_gmid (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GFN: + dissect_fcfcs_gfn (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GIELN: + dissect_fcfcs_gieln (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GMAL: + dissect_fcfcs_gmal (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GIEIL: + dissect_fcfcs_gieil (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPL: + dissect_fcfcs_gpl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPT: + dissect_fcfcs_gpt (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPPN: + dissect_fcfcs_gppn (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GAPNL: + dissect_fcfcs_gapnl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPS: + dissect_fcfcs_gps (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPLNL: + dissect_fcfcs_gplnl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPLT: + dissect_fcfcs_gplt (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPLML: + dissect_fcfcs_gplml (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GNPL: + dissect_fcfcs_gnpl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GPNL: + dissect_fcfcs_gpnl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_RIELN: + dissect_fcfcs_rieln (tvb, fcfcs_tree, isreq); + break; + case FCFCS_RPL: + dissect_fcfcs_rpl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_RPLN: + dissect_fcfcs_rpln (tvb, fcfcs_tree, isreq); + break; + case FCFCS_RPLT: + dissect_fcfcs_rplt (tvb, fcfcs_tree, isreq); + break; + case FCFCS_RPLM: + dissect_fcfcs_rplm (tvb, fcfcs_tree, isreq); + break; + case FCFCS_DPL: + dissect_fcfcs_dpl (tvb, fcfcs_tree, isreq); + break; + case FCFCS_DPLN: + dissect_fcfcs_dpln (tvb, fcfcs_tree, isreq); + break; + case FCFCS_DPLML: + dissect_fcfcs_dplml (tvb, fcfcs_tree, isreq); + break; + case FCFCS_GCAP: + dissect_fcfcs_gcap (tvb, fcfcs_tree, isreq); + break; + default: + call_dissector (data_handle, tvb, pinfo, fcfcs_tree); + break; + } +} + +/* 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. +*/ + +void +proto_register_fcfcs (void) +{ + +/* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_fcs_opcode, + {"Opcode", "fcs.opcode", FT_UINT16, BASE_HEX, + VALS (fc_fcs_opcode_val), 0x0, "", HFILL}}, + { &hf_fcs_iename, + {"Interconnect Element Name", "fcs.ie.name", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcs_ietype, + {"Interconnect Element Type", "fcs.ie.type", FT_UINT8, BASE_HEX, + VALS (fc_fcs_ietype_val), 0x0, "", HFILL}}, + { &hf_fcs_iedomainid, + {"Interconnect Element Domain ID", "fcs.ie.domainid", FT_UINT8, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcs_mgmtid, + {"Interconnect Element Mgmt. ID", "fcs.ie.mgmtid", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcs_fabricname, + {"Interconnect Element Fabric Name", "fcs.ie.fname", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcs_mgmtaddr, + {"Interconnect Element Mgmt. Address", "fcs.ie.mgmtaddr", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcs_lname, + {"Interconnect Element Logical Name", "fcs.ie.logname", FT_STRING, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcs_vendorname, + {"Vendor Name", "fcs.vendorname", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcs_modelname, + {"Model Name/Number", "fcs.modelname", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcs_portname, + {"Port Name", "fcs.port.name", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcs_portmodtype, + {"Port Module Type", "fcs.port.moduletype", FT_UINT8, BASE_HEX, + VALS (fc_fcs_port_modtype_val), 0x0, "", HFILL}}, + { &hf_fcs_porttxtype, + {"Port TX Type", "fcs.port.txtype", FT_UINT8, BASE_HEX, + VALS (fc_fcs_port_txtype_val), 0x0, "", HFILL}}, + { &hf_fcs_porttype, + {"Port Type", "fcs.port.type", FT_UINT8, BASE_HEX, + VALS (fc_fcs_port_type_val), 0x0, "", HFILL}}, + { &hf_fcs_physportnum, + {"Physical Port Number", "fcs.port.physportnum", FT_BYTES, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcs_portflags, + {"Port Flags", "fcs.port.flags", FT_BOOLEAN, BASE_NONE, + TFS (&fc_fcs_portflags_tfs), 0x0, "", HFILL}}, + { &hf_fcs_portstate, + {"Port State", "fcs.port.state", FT_UINT8, BASE_HEX, + VALS (fc_fcs_port_state_val), 0x0, "", HFILL}}, + { &hf_fcs_platformname, + {"Platform Name", "fcs.platform.name", FT_STRING, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_fcs_platformnname, + {"Platform Node Name", "fcs.platform.nodename", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcs_platformtype, + {"Platform Type", "fcs.platform.type", FT_UINT8, BASE_HEX, + VALS (fc_fcs_plat_type_val), 0x0, "", HFILL}}, + { &hf_fcs_platformaddr, + {"Management Address", "fcs.platform.mgmtaddr", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcs_reason, + {"Reason Code", "fcs.reason", FT_UINT8, BASE_HEX, + VALS (fc_ct_rjt_code_vals), 0x0, "", HFILL}}, + { &hf_fcs_rjtdetail, + {"Reason Code Explanantion", "fcs.reasondet", FT_UINT8, BASE_HEX, + VALS (fc_fcs_rjt_code_val), 0x0, "", HFILL}}, + { &hf_fcs_vendor, + {"Vendor Unique Reject Code", "fcs.err.vendor", FT_UINT8, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcs_numcap, + {"Number of Capabilities", "fcs.numcap", FT_UINT32, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_fcs_mgmt_subtype, + {"Management GS Subtype", "fcs.gssubtype", FT_UINT8, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcs_vnd_capmask, + {"Vendor Unique Capability Bitmask", "fcs.vbitmask", FT_UINT24, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_fcs_fcsmask, + {"Subtype Capability Bitmask", "fcs.fcsmask", FT_UINT32, BASE_HEX, + VALS (fc_fcs_fcsmask_val), 0x0, "", HFILL}}, + { &hf_fcs_unsmask, + {"Subtype Capability Bitmask", "fcs.unsmask", FT_UINT32, BASE_HEX, + VALS (fc_fcs_unsmask_val), 0x0, "", HFILL}}, + { &hf_fcs_maxres_size, + {"Maximum/Residual Size", "fcs.maxres_size", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcs_releasecode, + {"Release Code", "fcs.releasecode", FT_STRING, BASE_HEX, NULL, 0x0, + "", HFILL}}, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_fcfcs, + }; + + /* Register the protocol name and description */ + proto_fcfcs = proto_register_protocol("FC Fabric Configuration Server", + "FC-FCS", "fcs"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fcfcs, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + register_init_routine (&fcfcs_init_protocol); +} + +/* If this dissector uses sub-dissector registration add a registration routine. + This format is required because a script is used to find these routines and + create the code that calls these routines. +*/ +void +proto_reg_handoff_fcfcs (void) +{ + dissector_handle_t fcs_handle; + + fcs_handle = create_dissector_handle (dissect_fcfcs, proto_fcfcs); + + dissector_add("fcct.server", FCCT_GSRVR_FCS, fcs_handle); + + data_handle = find_dissector ("data"); +} + + diff --git a/packet-fcfcs.h b/packet-fcfcs.h new file mode 100644 index 0000000000..81a2490b54 --- /dev/null +++ b/packet-fcfcs.h @@ -0,0 +1,254 @@ +/* packet-fcfcs.h + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * 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. + */ + +#ifndef __PACKET_FCFCS_H_ +#define __PACKET_FCFCS_H_ + +#define FCFCS_GTIN 0x100 +#define FCFCS_GIEL 0x101 +#define FCFCS_GIET 0x111 +#define FCFCS_GDID 0x112 +#define FCFCS_GMID 0x113 +#define FCFCS_GFN 0x114 +#define FCFCS_GIELN 0x115 +#define FCFCS_GMAL 0x116 +#define FCFCS_GIEIL 0x117 +#define FCFCS_GPL 0x118 +#define FCFCS_GPT 0x121 +#define FCFCS_GPPN 0x122 +#define FCFCS_GAPNL 0x124 +#define FCFCS_GPS 0x126 +#define FCFCS_GATIN 0x128 +#define FCFCS_GPLNL 0x191 +#define FCFCS_GPLT 0x192 +#define FCFCS_GPLML 0x193 +#define FCFCS_GNPL 0x1A1 +#define FCFCS_GPNL 0x1A2 +#define FCFCS_GNID 0x1B1 +#define FCFCS_RIELN 0x215 +#define FCFCS_RPL 0x280 +#define FCFCS_RPLN 0x291 +#define FCFCS_RPLT 0x292 +#define FCFCS_RPLM 0x293 +#define FCFCS_DPL 0x380 +#define FCFCS_DPLN 0x391 +#define FCFCS_DPLML 0x393 +#define FCFCS_GCAP 0xe020 + +/* Used in protocol detail window */ +static const value_string fc_fcs_opcode_val[] = { + {FCCT_MSG_ACC, "MSG_ACC"}, + {FCCT_MSG_RJT, "MSG_RJT"}, + {FCFCS_GTIN, "Get Topology Info"}, + {FCFCS_GIEL, "Get Interconnect Element List"}, + {FCFCS_GIET, "Get Interconnect Element Type"}, + {FCFCS_GDID, "Get Interconnect Element Domain ID"}, + {FCFCS_GMID, "Get Interconnect Element Mgmt ID"}, + {FCFCS_GFN, "Get Interconnect Element Fabric Name"}, + {FCFCS_GIELN, "Get Interconnect Element Logical Name"}, + {FCFCS_GMAL, "Get Interconnect Element Mgmt Addr List"}, + {FCFCS_GIEIL, "Get Interconnect Element Info List"}, + {FCFCS_GPL, "Get Port List"}, + {FCFCS_GPT, "Get Port Type"}, + {FCFCS_GPPN, "Get Physical Port Number"}, + {FCFCS_GAPNL, "Get Physical Port Name List"}, + {FCFCS_GPS, "Get Port State"}, + {FCFCS_GATIN, "Get Attached Topology Info"}, + {FCFCS_GPLNL, "Get Platform Node Name List"}, + {FCFCS_GPLT, "Get Platform Type"}, + {FCFCS_GPLML, "Get Platform Mgmt Addr List"}, + {FCFCS_GNPL, "Get Platform Node Name List"}, + {FCFCS_GPNL, "Get Platform Name List"}, + {FCFCS_GNID, "Get Node Identification Data"}, + {FCFCS_RIELN, "Register Interconnect Element Logical Name"}, + {FCFCS_RPL, "Register Platform"}, + {FCFCS_RPLN, "Register Platform Node Name"}, + {FCFCS_RPLT, "Register Platform Type"}, + {FCFCS_RPLM, "Register Platform Mgmt. Address"}, + {FCFCS_DPL, "Deregister Platform"}, + {FCFCS_DPLN, "Deregister Platform Node Name"}, + {FCFCS_DPLML, "Deregister Platform Mgmt. Address List"}, + {FCFCS_GCAP, "Get Capabilities"}, + {0, NULL}, +}; + +/* Used in protocol summary window */ +static const value_string fc_fcs_opcode_abbrev_val[] = { + {FCCT_MSG_ACC, "MSG_ACC"}, + {FCCT_MSG_RJT, "MSG_RJT"}, + {FCFCS_GTIN, "GTIN"}, + {FCFCS_GIEL, "GIEL"}, + {FCFCS_GIET, "GIET"}, + {FCFCS_GDID, "GDID"}, + {FCFCS_GMID, "GMID"}, + {FCFCS_GFN, "GFN"}, + {FCFCS_GIELN, "GIELN"}, + {FCFCS_GMAL, "GMAL"}, + {FCFCS_GIEIL, "GIEIL"}, + {FCFCS_GPL, "GPL"}, + {FCFCS_GPT, "GPT"}, + {FCFCS_GPPN, "GPPN"}, + {FCFCS_GAPNL, "GAPNL"}, + {FCFCS_GPS, "GPS"}, + {FCFCS_GATIN, "GATIN"}, + {FCFCS_GPLNL, "GPLNL"}, + {FCFCS_GPLT, "GPLT"}, + {FCFCS_GPLML, "GPLML"}, + {FCFCS_GNPL, "GNPL"}, + {FCFCS_GPNL, "GPNL"}, + {FCFCS_GNID, "GNID"}, + {FCFCS_RIELN, "RIELN"}, + {FCFCS_RPL, "RPL"}, + {FCFCS_RPLN, "RPLN"}, + {FCFCS_RPLT, "RPLT"}, + {FCFCS_RPLM, "RPLM"}, + {FCFCS_DPL, "DPL"}, + {FCFCS_DPLN, "DPLN"}, + {FCFCS_DPLML, "DPLML"}, + {FCFCS_GCAP, "GCAP"}, + {0, NULL}, +}; + +static const value_string fc_fcs_ietype_val[] = { + {0, "Unknown"}, + {1, "Switch"}, + {2, "Hub"}, + {3, "Bridge"}, + {0, NULL}, +}; + +/* Port type definitions, same as in dNS (fcdns.h) */ +#define FCFCS_PTYPE_UNDEF 0x00 +#define FCFCS_PTYPE_NPORT 0x01 +#define FCFCS_PTYPE_NLPORT 0x02 +#define FCFCS_PTYPE_FNLPORT 0x03 +#define FCFCS_PTYPE_NXPORT 0x7F +#define FCFCS_PTYPE_FPORT 0x81 +#define FCFCS_PTYPE_FLPORT 0x82 +#define FCFCS_PTYPE_EPORT 0x84 +#define FCFCS_PTYPE_BPORT 0x85 + +static const value_string fc_fcs_port_type_val[] = { + {FCFCS_PTYPE_UNDEF , "Undefined Port Type"}, + {FCFCS_PTYPE_NPORT , "N_Port"}, + {FCFCS_PTYPE_NLPORT , "NL_Port"}, + {FCFCS_PTYPE_FNLPORT , "F/NL_Port"}, + {FCFCS_PTYPE_NXPORT , "Nx_Port"}, + {FCFCS_PTYPE_FPORT , "F_Port"}, + {FCFCS_PTYPE_FLPORT , "FL_Port"}, + {FCFCS_PTYPE_EPORT , "E_Port"}, + {FCFCS_PTYPE_BPORT , "B_Port"}, + {0, NULL}, +}; + +static const value_string fc_fcs_port_txtype_val[] = { + {1, "Unknown"}, + {2, "Long Wave Laser"}, + {3, "Short Wave Laser"}, + {4, "Long Wave Laser Cost Reduced"}, + {5, "Electrical"}, + {0, NULL}, +}; + +static const value_string fc_fcs_port_modtype_val[] = { + {1, "Unknown"}, + {2, "Other"}, + {3, "GBIC"}, + {4, "Embedded"}, + {5, "GLM"}, + {6, "GBIC with Serial ID"}, + {7, "GBIC without Serial ID"}, + {8, "SFP with Serial ID"}, + {9, "SFP without Serial ID"}, + {0, NULL}, +}; + +static const value_string fc_fcs_port_state_val[] = { + {0, "Unknown"}, + {1, "Online"}, + {2, "Offline"}, + {3, "Testing"}, + {4, "Fault"}, + {0, NULL}, +}; + +static const value_string fc_fcs_plat_type_val[] = { + {1, "Unknown"}, + {2, "Other"}, + {5, "Gateway"}, + {6, "Converter"}, + {7, "HBA"}, + {8, "Software Proxy Agent"}, + {9, "Storage Device"}, + {10, "Host Computer"}, + {11, "Storage Subsystem"}, + {12, "Module"}, + {13, "Software Driver"}, + {14, "Storage Access Device"}, + {0, NULL}, +}; + +static const value_string fc_fcs_rjt_code_val[] = { + {0x00, "No Additional Explanation"}, + {0x01, "Invalid Name_Identifier for Interconnect Element or Port"}, + {0x10, "Interconnect Element List Not Available"}, + {0x11, "Interconnect Element Type Not Available"}, + {0x12, "Domain ID Not Available"}, + {0x13, "Mgmt. ID Not Available"}, + {0x14, "Fabric Name Not Available"}, + {0x15, "Interconnect Element Logical Name Not Available"}, + {0x16, "Mgmt. Address Not Available"}, + {0x17, "Interconnect Element Information List Not Available"}, + {0x30, "Port List Not Available"}, + {0x31, "Port Type Not Available"}, + {0x32, "Physical Port Number Not Available"}, + {0x34, "Attached Port Name List Not Available"}, + {0x36, "Port State Not Available"}, + {0x50, "Unable to Register Interconnect Element Logical Name"}, + {0x60, "Platform Name Does Not Exist"}, + {0x61, "Platform Name Already Exists"}, + {0x62, "Platform Node Name Does Not Exist"}, + {0x63, "Platform Node Name Already Exists"}, + {0, NULL}, +}; + +static const true_false_string fc_fcs_portflags_tfs = { + "RTIN ELS Supported", + "RTIN ELS Not Supported", +}; + +static const value_string fc_fcs_fcsmask_val[] = { + {1, "Basic Configuration Service"}, + {2, "Platform Configuration Service"}, + {3, "Basic+Platform Configuration Service"}, + {4, "Topology Discovery Configuration Service"}, + {5, "Basic+Topology Discovery Configuration Service"}, + {6, "Platform+Topology Discovery Configuration Service"}, + {7, "Basic+Platform+Topology Discovery Configuration Service"}, + {0, NULL}, +}; + +static const value_string fc_fcs_unsmask_val[] = { + {1, "Basic Unzoned Name Service"}, + {0, NULL}, +}; + +#endif diff --git a/packet-fcfzs.c b/packet-fcfzs.c new file mode 100644 index 0000000000..c5a0dcd56d --- /dev/null +++ b/packet-fcfzs.c @@ -0,0 +1,942 @@ +/* packet-fcfzs.c + * Routines for FC Fabric Zone Server + * Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com> + * + * $Id: packet-fcfzs.c,v 1.1 2003/01/14 01:17:44 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED" + * is a dissector file; if you just copied this from README.developer, + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <glib.h> + +#ifdef NEED_SNPRINTF_H +# include "snprintf.h" +#endif + +#include <epan/packet.h> +#include <epan/conversation.h> +#include "etypes.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_zonesetname = -1; +static int hf_fcfzs_numzones = -1; +static int hf_fcfzs_numzonesetattrs = -1; +static int hf_fcfzs_zonenmlen = -1; +static int hf_fcfzs_zonename = -1; +static int hf_fcfzs_nummbrs = -1; +static int hf_fcfzs_nummbrentries = -1; +static int hf_fcfzs_mbrid = -1; +static int hf_fcfzs_mbridlen = -1; +static int hf_fcfzs_mbrtype = -1; +static int hf_fcfzs_reason = -1; +static int hf_fcfzs_rjtdetail = -1; +static int hf_fcfzs_rjtvendor = -1; +static int hf_fcfzs_maxres_size = -1; +static int hf_fcfzs_mbrid_lun = -1; + + +/* Initialize the subtree pointers */ +static gint ett_fcfzs = -1; + +typedef struct _fcfzs_conv_key { + guint32 conv_idx; +} fcfzs_conv_key_t; + +typedef struct _fcfzs_conv_data { + guint32 opcode; +} 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; + +/* + * Hash Functions + */ +static gint +fcfzs_equal(gconstpointer v, gconstpointer w) +{ + fcfzs_conv_key_t *v1 = (fcfzs_conv_key_t *)v; + fcfzs_conv_key_t *v2 = (fcfzs_conv_key_t *)w; + + return (v1->conv_idx == v2->conv_idx); +} + +static guint +fcfzs_hash (gconstpointer v) +{ + fcfzs_conv_key_t *key = (fcfzs_conv_key_t *)v; + guint val; + + val = key->conv_idx; + + return val; +} + +/* + * Protocol initialization + */ +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 void +dissect_fcfzs_zoneset (tvbuff_t *tvb, proto_tree *tree, int offset) +{ + int numzones, nummbrs, i, j, len; + + /* The zoneset structure has the following format */ + /* number of zones, + * for each zone, + * Zone name (len, name, pad), num zone mbrs + * for each zone mbr, + * zone mbr id type, zone mbr id (len, name, pad) + */ + if (tree) { + numzones = tvb_get_ntohl (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_numzonesetattrs, tvb, offset, 4, 0); + + offset += 4; + for (i = 0; i < numzones; i++) { + 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+1, + len, 0); + offset += len; + + nummbrs = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_nummbrentries, tvb, offset, + 4, 0); + + 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: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+4, + 8))); + break; + case FC_FZS_ZONEMBR_DP: + proto_tree_add_string_format (tree, + hf_fcfzs_mbrid, + tvb, offset+4, 3, " ", + "0x%x", + tvb_get_ntoh24 (tvb, + offset+4)); + break; + case FC_FZS_ZONEMBR_FCID: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 4, + fc_to_str (tvb_get_ptr (tvb, + offset+4, + 3))); + break; + case FC_FZS_ZONEMBR_PWWN_LUN: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+4, + 8))); + proto_tree_add_item (tree, hf_fcfzs_mbrid_lun, tvb, + offset+8, 8, 0); + break; + case FC_FZS_ZONEMBR_DP_LUN: + proto_tree_add_string_format (tree, + hf_fcfzs_mbrid, + tvb, offset+4, 3, " ", + "0x%x", + tvb_get_ntoh24 (tvb, + offset+4)); + proto_tree_add_item (tree, hf_fcfzs_mbrid_lun, tvb, + offset+4, 8, 0); + break; + case FC_FZS_ZONEMBR_FCID_LUN: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 4, + fc_to_str (tvb_get_ptr (tvb, + offset+4, + 3))); + proto_tree_add_item (tree, hf_fcfzs_mbrid_lun, tvb, + offset+4, 8, 0); + break; + default: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + "Unknown member type format"); + } + offset += 12; + } + } + } +} + +static void +dissect_fcfzs_gzc (tvbuff_t *tvb, proto_tree *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); + } + } +} + +static void +dissect_fcfzs_gest (tvbuff_t *tvb, proto_tree *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); + } + } +} + +static void +dissect_fcfzs_gzsn (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int numrec, i, len; + int offset = 16; /* past the fc_ct header */ + + if (tree) { + if (!isreq) { + numrec = tvb_get_ntohl (tvb, offset); + + proto_tree_add_item (tree, hf_fcfzs_numzonesetattrs, tvb, offset, + 4, 0); + + offset += 4; + for (i = 0; i < numrec; i++) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+1, + len, 0); + offset += len + 1 + (len % 4); + proto_tree_add_item (tree, hf_fcfzs_numzones, tvb, offset, + 4, 0); + offset += 4; + } + } + } +} + +static void +dissect_fcfzs_gzd (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + 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_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+1, + len, 0); + } + else { + numrec = tvb_get_ntohl (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); + proto_tree_add_item (tree, hf_fcfzs_zonenmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonename, tvb, offset+1, + len, 0); + offset += len + 1 + (len % 4); + proto_tree_add_item (tree, hf_fcfzs_nummbrs, tvb, offset, + 4, 0); + offset += 4; + } + } + } +} + +static void +dissect_fcfzs_gzm (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + 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_zonenmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonename, tvb, offset+1, + len, 0); + } + else { + numrec = tvb_get_ntohl (tvb, offset); + + proto_tree_add_item (tree, hf_fcfzs_nummbrentries, tvb, offset, + 4, 0); + offset += 4; + for (i = 0; i < numrec; i++) { + 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: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+4, + 8))); + break; + case FC_FZS_ZONEMBR_DP: + proto_tree_add_string_format (tree, + hf_fcfzs_mbrid, + tvb, offset+4, 3, " ", + "0x%x", + tvb_get_ntoh24 (tvb, + offset+4)); + break; + case FC_FZS_ZONEMBR_FCID: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 4, + fc_to_str (tvb_get_ptr (tvb, + offset+4, + 3))); + break; + default: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + "Unknown member type format"); + } + offset += 12; + } + } + } +} + +static void +dissect_fcfzs_gazs (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (!isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + len, 0); + offset += (len + (len % 4)); + + dissect_fcfzs_zoneset (tvb, tree, offset); + } + } +} + +static void +dissect_fcfzs_gzs (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + len, 0); + } + else { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + len, 0); + offset += (len + (len % 4)); + + dissect_fcfzs_zoneset (tvb, tree, offset); + } + } +} + +static void +dissect_fcfzs_adzs (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + len, 0); + offset += (len + (len % 4)); + + dissect_fcfzs_zoneset (tvb, tree, offset); + } + } +} + +static void +dissect_fcfzs_azsd (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + len, 0); + offset += (len + (len % 4)); + + dissect_fcfzs_zoneset (tvb, tree, offset); + } + } +} + +static void +dissect_fcfzs_arzs (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + len, 0); + } + } +} + +static void +dissect_fcfzs_dzs (tvbuff_t *tvb _U_, proto_tree *tree _U_, guint8 isreq _U_) +{ + /* Both req & successful response contain just the FC_CT header */ + return; +} + +static void +dissect_fcfzs_arzm (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int numrec, i, len, plen; + 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_zonenmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonename, tvb, offset+1, + len, 0); + + len += (len % 4); + plen = tvb_length (tvb) - offset - len; + + numrec = plen/12; /* each mbr rec is 12 bytes long */ + + offset += len; + for (i = 0; i < numrec; i++) { + 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: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, + offset+4, + 8))); + break; + case FC_FZS_ZONEMBR_DP: + proto_tree_add_string_format (tree, + hf_fcfzs_mbrid, + tvb, offset+4, 3, " ", + "0x%x", + tvb_get_ntoh24 (tvb, + offset+4)); + break; + case FC_FZS_ZONEMBR_FCID: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 4, + fc_to_str (tvb_get_ptr (tvb, + offset+4, + 3))); + break; + default: + proto_tree_add_string (tree, hf_fcfzs_mbrid, tvb, + offset+4, 8, + "Unknown member type format"); + } + offset += 12; + } + } + } +} + +static void +dissect_fcfzs_arzd (tvbuff_t *tvb, proto_tree *tree, guint8 isreq) +{ + int offset = 16; /* past the fc_ct header */ + int len; + + if (tree) { + if (isreq) { + len = tvb_get_guint8 (tvb, offset); + proto_tree_add_item (tree, hf_fcfzs_zonesetnmlen, tvb, offset, + 1, 0); + proto_tree_add_item (tree, hf_fcfzs_zonesetname, tvb, offset+4, + 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, + len, 0); + } + } +} + +static void +dissect_fcfzs_rjt (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 0; + + 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); + } +} + +static void +dissect_fcfzs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + +/* Set up structures needed to add the protocol subtree and manage it */ + proto_item *ti; + proto_tree *fcfzs_tree = NULL; + int offset = 0; + fc_ct_preamble cthdr; + int opcode, + failed_opcode = 0; + conversation_t *conversation; + fcfzs_conv_data_t *cdata; + fcfzs_conv_key_t ckey, *req_key; + guint8 isreq = 1; + + /* 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, "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); + opcode = cthdr.opcode; + cthdr.maxres_size = ntohs (cthdr.maxres_size); + + if (tree) { + ti = proto_tree_add_protocol_format (tree, proto_fcfzs, tvb, 0, + tvb_length (tvb), + "Zone Server"); + fcfzs_tree = proto_item_add_subtree (ti, ett_fcfzs); + proto_tree_add_item (fcfzs_tree, hf_fcfzs_opcode, tvb, offset+8, 2, 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->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + if (!conversation) { + conversation = conversation_new (&pinfo->src, &pinfo->dst, + 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. + */ + cdata->opcode = opcode; + } + else { + req_key = g_mem_chunk_alloc (fcfzs_req_keys); + req_key->conv_idx = conversation->index; + + cdata = g_mem_chunk_alloc (fcfzs_req_vals); + 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, + "0x%x")); + } + } + else { + /* Opcode is ACC or RJT */ + conversation = find_conversation (&pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->oxid, + pinfo->rxid, NO_PORT2); + isreq = 0; + if (!conversation) { + if (tree && (opcode == FCCT_MSG_ACC)) { + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, + val_to_str (opcode, fc_fzs_opcode_val, + "0x%x")); + } + /* No record of what this accept is for. Can't decode */ + proto_tree_add_text (fcfzs_tree, tvb, 0, tvb_length (tvb), + "No record of Exchg. Unable to decode MSG_ACC"); + return; + } + } + else { + ckey.conv_idx = conversation->index; + + cdata = (fcfzs_conv_data_t *)g_hash_table_lookup (fcfzs_req_hash, &ckey); + + if (cdata != NULL) { + if (opcode == FCCT_MSG_ACC) + opcode = cdata->opcode; + 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)", + val_to_str (opcode, + fc_fzs_opcode_val, "0x%x")); + } + else { + col_add_fstr (pinfo->cinfo, COL_INFO, "MSG_RJT (%s)", + val_to_str (failed_opcode, + 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 */ + proto_tree_add_text (fcfzs_tree, tvb, 0, tvb_length (tvb), + "No record of Exchg. Unable to decode MSG_ACC/RJT"); + return; + } + } + } + } + + switch (opcode) { + case FCCT_MSG_RJT: + dissect_fcfzs_rjt (tvb, fcfzs_tree); + break; + case FC_FZS_GZC: + dissect_fcfzs_gzc (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_GEST: + dissect_fcfzs_gest (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_GZSN: + dissect_fcfzs_gzsn (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_GZD: + dissect_fcfzs_gzd (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_GZM: + dissect_fcfzs_gzm (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_GAZS: + dissect_fcfzs_gazs (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_GZS: + dissect_fcfzs_gzs (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_ADZS: + dissect_fcfzs_adzs (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_AZSD: + dissect_fcfzs_azsd (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_AZS: + dissect_fcfzs_arzs (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_DZS: + dissect_fcfzs_dzs (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_AZM: + dissect_fcfzs_arzm (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_AZD: + dissect_fcfzs_arzd (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_RZM: + dissect_fcfzs_arzm (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_RZD: + dissect_fcfzs_arzd (tvb, fcfzs_tree, isreq); + break; + case FC_FZS_RZS: + dissect_fcfzs_arzs (tvb, fcfzs_tree, isreq); + break; + default: + call_dissector (data_handle, tvb, pinfo, tree); + break; + } +} + +/* 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. +*/ + +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_numzoneattrs, + {"Number of Zone Attribute Entries", "fcfzs.zone.numattrs", + FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_zonesetnmlen, + {"Zone Set Name Length", "fcfzs.zoneset.namelen", FT_UINT8, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_zonesetname, + {"Zone Set Name", "fcfzs.zoneset.name", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_fcfzs_numzones, + {"Number of Zones", "fcfzs.zoneset.numzones", FT_UINT32, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_numzonesetattrs, + {"Number of Zone Set Attribute Entries", "fcfzs.zoneset.numattrs", + FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_zonenmlen, + {"Zone Name Length", "fcfzs.zone.namelen", FT_UINT8, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_fcfzs_zonename, + {"Zone Name", "fcfzs.zone.name", FT_STRING, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_fcfzs_nummbrs, + {"Number of Zone Members", "fcfzs.zone.nummbrs", FT_UINT32, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_nummbrentries, + {"Number of Zone Member Attribute Entries", "fcfzs.zonembr.numattrs", + FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_mbrtype, + {"Zone Member Identifier Type", "fcfzs.zonembr.idtype", FT_UINT8, + BASE_HEX, VALS (fc_fzs_zonembr_type_val), 0x0, "", HFILL}}, + { &hf_fcfzs_mbridlen, + {"Zone Member Identifier Length", "fcfzs.zonembr.idlen", FT_UINT8, + BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_mbrid, + {"Zone Member Identifier", "fcfzs.zone.mbrid", FT_STRING, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_reason, + {"Reason Code", "fcfzs.reason", FT_UINT8, BASE_HEX, + VALS (fc_ct_rjt_code_vals), 0x0, "", HFILL}}, + { &hf_fcfzs_rjtdetail, + {"Reason Code Explanation", "fcfzs.rjtdetail", FT_UINT8, BASE_HEX, + VALS (fc_fzs_rjt_code_val), 0x0, "", HFILL}}, + { &hf_fcfzs_rjtvendor, + {"Vendor Specific Reason", "fcfzs.rjtvendor", FT_UINT8, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_maxres_size, + {"Maximum/Residual Size", "fcfzs.maxres_size", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_fcfzs_mbrid_lun, + {"LUN", "fcfzs.zone.lun", FT_BYTES, BASE_HEX, NULL, 0x0, "", + HFILL}}, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_fcfzs, + }; + + /* Register the protocol name and description */ + proto_fcfzs = proto_register_protocol("Fibre Channel Fabric Zone Server", "FC FZS", "FZS"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fcfzs, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + register_init_routine (&fcfzs_init_protocol); + +} + +/* If this dissector uses sub-dissector registration add a registration routine. + This format is required because a script is used to find these routines and + create the code that calls these routines. +*/ +void +proto_reg_handoff_fcfzs (void) +{ + dissector_handle_t fzs_handle; + + fzs_handle = create_dissector_handle (dissect_fcfzs, proto_fcfzs); + dissector_add("fcct.server", FCCT_GSRVR_FZS, fzs_handle); + + data_handle = find_dissector ("data"); +} + + diff --git a/packet-fcfzs.h b/packet-fcfzs.h new file mode 100644 index 0000000000..b67a55a158 --- /dev/null +++ b/packet-fcfzs.h @@ -0,0 +1,119 @@ +/* packet-fcfzs.h + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * 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. + */ + +#ifndef __PACKET_FCFZS_H_ +#define __PACKET_FCFZS_H_ + +/* Opcode definitions */ +#define FC_FZS_GZC 0x100 +#define FC_FZS_GEST 0x111 +#define FC_FZS_GZSN 0x112 +#define FC_FZS_GZD 0x113 +#define FC_FZS_GZM 0x114 +#define FC_FZS_GAZS 0x115 +#define FC_FZS_GZS 0x116 +#define FC_FZS_ADZS 0x200 +#define FC_FZS_AZSD 0x201 +#define FC_FZS_AZS 0x202 +#define FC_FZS_DZS 0x203 +#define FC_FZS_AZM 0x204 +#define FC_FZS_AZD 0x205 +#define FC_FZS_RZM 0x300 +#define FC_FZS_RZD 0x301 +#define FC_FZS_RZS 0x302 + +static const value_string fc_fzs_opcode_val[] = { + {FC_FZS_GZC , "Get Capabilities"}, + {FC_FZS_GEST , "Get Enforcement State"}, + {FC_FZS_GZSN , "Get Zone Set List"}, + {FC_FZS_GZD , "Get Zone List"}, + {FC_FZS_GZM , "Get Zone Member List"}, + {FC_FZS_GAZS , "Get Active Zone Set"}, + {FC_FZS_GZS , "Get Zone Set"}, + {FC_FZS_ADZS , "Add Zone Set"}, + {FC_FZS_AZSD , "Activate Zone Set Direct"}, + {FC_FZS_AZS , "Activate Zone Set"}, + {FC_FZS_DZS , "Deactivate Zone Set"}, + {FC_FZS_AZM , "Add Zone Members"}, + {FC_FZS_AZD , "Add Zone"}, + {FC_FZS_RZM , "Remove Zone Members"}, + {FC_FZS_RZD , "Remove Zone"}, + {FC_FZS_RZS , "Remove Zone Set"}, + {FCCT_MSG_ACC , "MSG_ACC"}, + {FCCT_MSG_RJT , "MSG_RJT"}, + {0, NULL}, +}; + +/* Reason code explanantions */ +#define FC_FZS_RJT_NODETAIL 0x0 +#define FC_FZS_RJT_ZONENOTSUPPORTED 0x1 +#define FC_FZS_RJT_ZSNUNKNOWN 0x10 +#define FC_FZS_RJT_NZSACTIVE 0x11 +#define FC_FZS_RJT_ZONEUNKNOWN 0x12 +#define FC_FZS_RJT_ZONESTATEUNKNOWN 0x13 +#define FC_FZS_RJT_INVLDPLEN 0x14 +#define FC_FZS_RJT_ZSTOOLARGE 0x15 +#define FC_FZS_RJT_DZSFAIL 0x16 +#define FC_FZS_RJT_NOTSUPPORTED 0x17 +#define FC_FZS_RJT_CAPNOTSUPPORTED 0x18 +#define FC_FZS_RJT_ZMIDTYPEUNKNOWN 0x19 +#define FC_FZS_RJT_INVLDZSDEF 0x1A + +static const value_string fc_fzs_rjt_code_val[] = { + {FC_FZS_RJT_NODETAIL , "No Additional Explanantion"}, + {FC_FZS_RJT_ZONENOTSUPPORTED , "Zones Not Supported"}, + {FC_FZS_RJT_ZSNUNKNOWN , "Zone Set Name Unknown"}, + {FC_FZS_RJT_NZSACTIVE , "No Zone Set Active"}, + {FC_FZS_RJT_ZONEUNKNOWN , "Zone Name Unknown"}, + {FC_FZS_RJT_ZONESTATEUNKNOWN , "Zone State Unknown"}, + {FC_FZS_RJT_INVLDPLEN , "Incorrect Payload Length"}, + {FC_FZS_RJT_ZSTOOLARGE , "Zone Set to be Activated Too Large"}, + {FC_FZS_RJT_DZSFAIL , "Deactive Zone Set Failed"}, + {FC_FZS_RJT_NOTSUPPORTED , "Request Not Supported"}, + {FC_FZS_RJT_CAPNOTSUPPORTED , "Capability Not Supported"}, + {FC_FZS_RJT_ZMIDTYPEUNKNOWN , "Zone Member Identifier Type Not Supported"}, + {FC_FZS_RJT_INVLDZSDEF , "Invalid Zone Set Definition"}, + {0, NULL}, +}; + +/* Zone Member Identifier Types */ + +#define FC_FZS_ZONEMBR_PWWN 1 +#define FC_FZS_ZONEMBR_DP 2 +#define FC_FZS_ZONEMBR_FCID 3 +#define FC_FZS_ZONEMBR_NWWN 4 +#define FC_FZS_ZONEMBR_PWWN_LUN 0xE1 +#define FC_FZS_ZONEMBR_DP_LUN 0xE2 +#define FC_FZS_ZONEMBR_FCID_LUN 0xE3 + +static const value_string fc_fzs_zonembr_type_val[] = { + {0, "Reserved"}, + {FC_FZS_ZONEMBR_PWWN, "N_Port WWN"}, + {FC_FZS_ZONEMBR_DP, "Domain/Physical Port (0x00ddpppp)"}, + {FC_FZS_ZONEMBR_FCID, "FC Address"}, + {FC_FZS_ZONEMBR_NWWN, "Node WWN"}, + {FC_FZS_ZONEMBR_PWWN_LUN, "N_Port WWN+LUN"}, + {FC_FZS_ZONEMBR_DP_LUN, "Domain/Physical Port+LUN"}, + {FC_FZS_ZONEMBR_FCID_LUN, "FC Address+LUN"}, + {0, NULL}, +}; + +#endif |