diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | Makefile.nmake | 4 | ||||
-rw-r--r-- | epan/packet_info.h | 17 | ||||
-rw-r--r-- | packet-brdwlk.c | 57 | ||||
-rw-r--r-- | packet-fc.c | 192 | ||||
-rw-r--r-- | packet-fc.h | 5 | ||||
-rw-r--r-- | packet-fcels.c | 9 | ||||
-rw-r--r-- | packet-fcels.h | 4 | ||||
-rw-r--r-- | packet-fcip.c | 23 | ||||
-rw-r--r-- | packet-fcsb3.c | 1001 | ||||
-rwxr-xr-x | packet-fcsb3.h | 74 | ||||
-rwxr-xr-x | packet-fcsp.c | 575 | ||||
-rwxr-xr-x | packet-fcsp.h | 55 | ||||
-rw-r--r-- | packet-fcswils.c | 10 | ||||
-rw-r--r-- | packet-fcswils.h | 3 | ||||
-rw-r--r-- | packet-mdshdr.c | 18 |
17 files changed, 1998 insertions, 58 deletions
@@ -1118,7 +1118,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 (over IP) support + Fibre Channel (over IP) support, and support for various + protocols running atop FC Cisco MDS switch Debug Port Adapter (Boardwalk) FC-inside-Ethernet dissector Cisco MDS switch internal FC-inside-Ethernet dissector diff --git a/Makefile.am b/Makefile.am index e5b9a430b5..f5f3e869d1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.647 2003/10/28 07:02:35 guy Exp $ +# $Id: Makefile.am,v 1.648 2003/10/30 02:06:11 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -215,6 +215,8 @@ DISSECTOR_SRC = \ packet-fcip.c \ packet-fclctl.c \ packet-fcp.c \ + packet-fcsb3.c \ + packet-fcsp.c \ packet-fcswils.c \ packet-fddi.c \ packet-fix.c \ @@ -632,6 +634,8 @@ noinst_HEADERS = \ packet-fcfzs.h \ packet-fclctl.h \ packet-fcp.h \ + packet-fcsb3.h \ + packet-fcsp.h \ packet-fcswils.h \ packet-fddi.h \ packet-frame.h \ diff --git a/Makefile.nmake b/Makefile.nmake index 601c106095..822c654a99 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.353 2003/10/28 06:44:21 guy Exp $ +# $Id: Makefile.nmake,v 1.354 2003/10/30 02:06:11 guy Exp $ include config.nmake include <win32.mak> @@ -155,6 +155,8 @@ DISSECTOR_SRC = \ packet-fcip.c \ packet-fclctl.c \ packet-fcp.c \ + packet-fcsb3.c \ + packet-fcsp.c \ packet-fcswils.c \ packet-fddi.c \ packet-fix.c \ diff --git a/epan/packet_info.h b/epan/packet_info.h index 4ae417ff23..183b606357 100644 --- a/epan/packet_info.h +++ b/epan/packet_info.h @@ -1,7 +1,7 @@ /* packet_info.h * Definitions for packet info structures and routines * - * $Id: packet_info.h,v 1.33 2003/10/21 07:17:16 guy Exp $ + * $Id: packet_info.h,v 1.34 2003/10/30 02:06:13 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -108,7 +108,8 @@ typedef enum { PT_IPX, /* IPX sockets */ PT_NCP, /* NCP connection */ PT_EXCHG, /* Fibre Channel exchange */ - PT_DDP /* DDP AppleTalk connection */ + PT_DDP, /* DDP AppleTalk connection */ + PT_SBCCS /* FICON */ } port_type; /* Types of circuit IDs Ethereal knows about. */ @@ -124,6 +125,11 @@ typedef enum { #define P2P_DIR_SENT 0 #define P2P_DIR_RECV 1 +#define PINFO_SOF_FIRST_FRAME 0x1 +#define PINFO_SOF_SOFF 0x2 +#define PINFO_EOF_LAST_FRAME 0x80 +#define PINFO_EOF_INVALID 0x40 + typedef struct _packet_info { const char *current_proto; /* name of protocol currently being dissected */ column_info *cinfo; /* Column formatting information */ @@ -188,7 +194,12 @@ typedef struct _packet_info { guint16 oxid; /* next 2 fields reqd to identify fibre */ guint16 rxid; /* channel conversations */ guint8 r_ctl; /* R_CTL field in Fibre Channel Protocol */ - guint8 pad; + guint8 sof_eof; /* FC's SOF/EOF encoding passed to FC decoder + * Bit 7 set if Last frame in sequence + * Bit 6 set if invalid frame content + * Bit 2 set if SOFf + * Bit 1 set if first frame in sequence + */ guint16 src_idx; /* Source port index (Cisco MDS-specific) */ guint16 dst_idx; /* Dest port index (Cisco MDS-specific) */ guint16 vsan; /* Fibre channel/Cisco MDS-specific */ diff --git a/packet-brdwlk.c b/packet-brdwlk.c index fd0ffcaf69..a915736527 100644 --- a/packet-brdwlk.c +++ b/packet-brdwlk.c @@ -2,7 +2,7 @@ * 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.4 2003/07/21 21:52:32 guy Exp $ + * $Id: packet-brdwlk.c,v 1.5 2003/10/30 02:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -50,6 +50,7 @@ #define BRDWLK_MAX_PACKET_CNT 0xFFFF #define BRDWLK_TRUNCATED_BIT 0x8 +#define BRDWLK_HAS_PLEN 0x1 #define FCM_DELIM_SOFC1 0x01 #define FCM_DELIM_SOFI1 0x02 @@ -99,6 +100,7 @@ static int hf_brdwlk_error = -1; static int hf_brdwlk_vsan = -1; static int hf_brdwlk_pktcnt = -1; static int hf_brdwlk_drop = -1; +static int hf_brdwlk_plen = -1; /* Initialize the subtree pointers */ static gint ett_brdwlk = -1; @@ -117,6 +119,10 @@ brdwlk_err_to_str (guint8 error, char *str) if (str != NULL) { str[0] = '\0'; + if (error & 0x1) { + strcat (str, "Packet Length Present"); + } + if (error & 0x2) { strcat (str, "Empty Frame, "); } @@ -158,10 +164,10 @@ dissect_brdwlk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *brdwlk_tree = NULL; tvbuff_t *next_tvb; - guint8 error; + guint8 error, eof, sof; int hdrlen = 2, offset = 0; - gint len, reported_len; + gint len, reported_len, plen; guint16 pkt_cnt; gboolean dropped_packets; gchar errstr[512]; @@ -173,6 +179,17 @@ dissect_brdwlk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_INFO)) col_clear(pinfo->cinfo, COL_INFO); + pinfo->vsan = (tvb_get_ntohs (tvb, offset) & 0xFFF); + sof = (tvb_get_guint8 (tvb, offset) & 0xF0) >> 4; + + if ((sof == FCM_DELIM_SOFI3) || (sof == FCM_DELIM_SOFI2) || (sof == FCM_DELIM_SOFI1) + || (sof == FCM_DELIM_SOFI4)) { + pinfo->sof_eof = PINFO_SOF_FIRST_FRAME; + } + else if (sof == FCM_DELIM_SOFF) { + pinfo->sof_eof = PINFO_SOF_SOFF; + } + if (tree) { ti = proto_tree_add_protocol_format (tree, proto_brdwlk, tvb, 0, hdrlen, "Boardwalk"); @@ -182,7 +199,6 @@ dissect_brdwlk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) 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); - pinfo->vsan = (tvb_get_ntohs (tvb, offset) & 0xFFF); } /* Locate EOF which is the last 4 bytes of the frame */ @@ -271,17 +287,34 @@ dissect_brdwlk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) 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; + + eof = tvb_get_guint8 (tvb, offset+3); + if (eof != FCM_DELIM_EOFN) { + pinfo->sof_eof |= PINFO_EOF_LAST_FRAME; + } + else if (eof != FCM_DELIM_EOFT) { + pinfo->sof_eof |= PINFO_EOF_INVALID; } -#endif if (tree) { proto_tree_add_item (brdwlk_tree, hf_brdwlk_eof, tvb, offset+3, 1, 0); } + + if ((error & BRDWLK_HAS_PLEN) && tree) { + /* In newer Boardwalks, if this bit is set, the actual frame length + * is also provided. This length is the size between SOF & EOF + * including FC CRC. + */ + plen = tvb_get_ntohl (tvb, offset-4); + plen *= 4; + proto_tree_add_uint (brdwlk_tree, hf_brdwlk_plen, tvb, offset-4, + 4, plen); + + if (error & BRDWLK_TRUNCATED_BIT) { + tvb_set_reported_length (tvb, plen); + } + } } next_tvb = tvb_new_subset (tvb, 2, len, reported_len); @@ -314,7 +347,7 @@ proto_register_brdwlk (void) 0xF0, "SOF", HFILL}}, { &hf_brdwlk_eof, {"EOF", "brdwlk.eof", FT_UINT8, BASE_HEX, VALS (brdwlk_eof_vals), - 0x0, "EOF", HFILL}}, + 0x0F, "EOF", HFILL}}, { &hf_brdwlk_error, {"Error", "brdwlk.error", FT_UINT8, BASE_DEC, NULL, 0x0, "Error", HFILL}}, @@ -327,6 +360,9 @@ proto_register_brdwlk (void) { &hf_brdwlk_vsan, {"VSAN", "brdwlk.vsan", FT_UINT16, BASE_DEC, NULL, 0xFFF, "", HFILL}}, + { &hf_brdwlk_plen, + {"Original Packet Length", "brdwlk.plen", FT_UINT32, BASE_DEC, NULL, 0x0, "", + HFILL}}, }; /* Setup protocol subtree array */ @@ -357,6 +393,7 @@ proto_reg_handoff_brdwlk(void) brdwlk_handle = create_dissector_handle (dissect_brdwlk, proto_brdwlk); dissector_add("ethertype", ETHERTYPE_BRDWALK, brdwlk_handle); + dissector_add("ethertype", 0xABCD, brdwlk_handle); data_handle = find_dissector("data"); fc_dissector_handle = find_dissector ("fc"); } diff --git a/packet-fc.c b/packet-fc.c index f66f3dd036..6e24b37747 100644 --- a/packet-fc.c +++ b/packet-fc.c @@ -4,7 +4,7 @@ * Copyright 2003 Ronnie Sahlberg, exchange first/last matching and * tap listener and misc updates * - * $Id: packet-fc.c,v 1.15 2003/08/27 23:05:59 guy Exp $ + * $Id: packet-fc.c,v 1.16 2003/10/30 02:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -51,6 +51,7 @@ #include <epan/packet.h> #include "prefs.h" #include "reassemble.h" +#include <epan/conversation.h> #include "etypes.h" #include "packet-fc.h" #include "packet-fclctl.h" @@ -59,7 +60,7 @@ #define FC_HEADER_SIZE 24 #define FC_RCTL_EISL 0x50 -#define MDSHDR_TRAILER_SIZE 6 +#define MDSHDR_TRAILER_SIZE 6 /* Size of various fields in FC header in bytes */ #define FC_RCTL_SIZE 1 @@ -140,12 +141,47 @@ static gboolean fc_reassemble = TRUE; static guint32 fc_max_frame_size = 1024; static GHashTable *fc_fragment_table = NULL; +typedef struct _fcseq_conv_key { + guint32 conv_idx; +} fcseq_conv_key_t; + +typedef struct _fcseq_conv_data { + guint32 seq_cnt; +} fcseq_conv_data_t; + +GHashTable *fcseq_req_hash = NULL; +GMemChunk *fcseq_req_keys = NULL; +GMemChunk *fcseq_req_vals = NULL; +guint32 fcseq_init_count = 25; static GHashTable *fc_exchange_unmatched = NULL; static GHashTable *fc_exchange_matched = NULL; static GMemChunk *fc_exchange_vals = NULL; static guint32 fc_exchange_init_count = 200; +/* + * Hash Functions + */ +static gint +fcseq_equal(gconstpointer v, gconstpointer w) +{ + fcseq_conv_key_t *v1 = (fcseq_conv_key_t *)v; + fcseq_conv_key_t *v2 = (fcseq_conv_key_t *)w; + + return (v1->conv_idx == v2->conv_idx); +} + +static guint +fcseq_hash (gconstpointer v) +{ + fcseq_conv_key_t *key = (fcseq_conv_key_t *)v; + guint val; + + val = key->conv_idx; + + return val; +} + static guint fc_exchange_hash_unmatched(gconstpointer v) { @@ -231,22 +267,41 @@ fc_exchange_init_protocol(void) fc_exchange_unmatched=g_hash_table_new(fc_exchange_hash_unmatched, fc_exchange_equal_unmatched); fc_exchange_matched=g_hash_table_new(fc_exchange_hash_matched, fc_exchange_equal_matched); fc_exchange_vals=g_mem_chunk_new("fc_exchange_vals", sizeof(fc_exchange_data), fc_exchange_init_count*sizeof(fc_exchange_data), G_ALLOC_AND_FREE); -} - - + fragment_table_init(&fc_fragment_table); + if (fcseq_req_keys) + g_mem_chunk_destroy (fcseq_req_keys); + if (fcseq_req_vals) + g_mem_chunk_destroy (fcseq_req_vals); + if (fcseq_req_hash) + g_hash_table_destroy(fcseq_req_hash); + + fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal); + fcseq_req_keys = g_mem_chunk_new ("fcseq_req_keys", + sizeof(fcseq_conv_key_t), + fcseq_init_count * + sizeof(fcseq_conv_key_t), + G_ALLOC_AND_FREE); + fcseq_req_vals = g_mem_chunk_new ("fcseq_req_vals", + sizeof(fcseq_conv_data_t), + fcseq_init_count * + sizeof(fcseq_conv_data_t), + G_ALLOC_AND_FREE); +} const value_string fc_fc4_val[] = { - {FC_TYPE_ELS , "Ext Link Svc"}, - {FC_TYPE_LLCSNAP , "LLC_SNAP"}, - {FC_TYPE_IP , "IP/FC"}, - {FC_TYPE_SCSI , "FCP"}, - {FC_TYPE_FCCT , "FC_CT"}, - {FC_TYPE_SWILS , "SW_ILS"}, - {FC_TYPE_AL , "AL"}, - {FC_TYPE_SNMP , "SNMP"}, + {FC_TYPE_ELS, "Ext Link Svc"}, + {FC_TYPE_LLCSNAP, "LLC_SNAP"}, + {FC_TYPE_IP, "IP/FC"}, + {FC_TYPE_SCSI, "FCP"}, + {FC_TYPE_FCCT, "FC_CT"}, + {FC_TYPE_SWILS, "SW_ILS"}, + {FC_TYPE_AL, "AL"}, + {FC_TYPE_SNMP, "SNMP"}, + {FC_TYPE_SB_FROM_CU, "SB-3(CU->Channel)"}, + {FC_TYPE_SB_TO_CU, "SB-3(Channel->CU)"}, {0, NULL}, }; @@ -261,6 +316,7 @@ static const value_string fc_ftype_vals [] = { {FC_FTYPE_LINKDATA, "Link Data"}, {FC_FTYPE_VDO, "Video Data"}, {FC_FTYPE_LINKCTL, "Link Ctl"}, + {FC_FTYPE_SBCCS, "SBCCS"}, {0, NULL}, }; @@ -317,7 +373,7 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) if (str == NULL) return (str); - if (fctl[0] & 0x80) { + if (fctl[2] & 0x80) { strcpy (str, "Exchange Responder, "); stroff += 20; } @@ -326,7 +382,7 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) stroff += 21; } - if (fctl[0] & 0x40) { + if (fctl[2] & 0x40) { strcpy (&str[stroff], "Seq Recipient, "); stroff += 15; } @@ -335,22 +391,22 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) stroff += 15; } - if (fctl[0] & 0x20) { + if (fctl[2] & 0x20) { strcpy (&str[stroff], "Exchg First, "); stroff += 13; } - if (fctl[0] & 0x10) { + if (fctl[2] & 0x10) { strcpy (&str[stroff], "Exchg Last, "); stroff += 12; } - if (fctl[0] & 0x8) { + if (fctl[2] & 0x8) { strcpy (&str[stroff], "Seq Last, "); stroff += 10; } - if (fctl[0] & 0x2) { + if (fctl[2] & 0x2) { strcpy (&str[stroff], "Priority, "); stroff += 10; } @@ -359,7 +415,7 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) stroff += 8; } - if (fctl[0] & 0x1) { + if (fctl[2] & 0x1) { strcpy (&str[stroff], "Transfer Seq Initiative, "); stroff += 25; } @@ -378,7 +434,7 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) stroff += 15; } - tmp = fctl[2] & 0xC0; + tmp = fctl[0] & 0xC0; switch (tmp) { case 0: strcpy (&str[stroff], "Last Data Frame - No Info, "); @@ -398,7 +454,7 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) break; } - tmp = fctl[2] & 0x30; + tmp = fctl[0] & 0x30; switch (tmp) { case 0: if (is_ack) { @@ -442,7 +498,7 @@ fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack) break; } - if (fctl[2] & 0x8) { + if (fctl[0] & 0x8) { strcpy (&str[stroff], "Rel Offset = 1"); stroff += 14; } @@ -533,6 +589,9 @@ fc_get_ftype (guint8 r_ctl, guint8 type) return FC_FTYPE_SCSI; case FC_TYPE_FCCT: return FC_FTYPE_FCCT; + case FC_TYPE_SB_FROM_CU: + case FC_TYPE_SB_TO_CU: + return FC_FTYPE_SBCCS; default: return FC_FTYPE_UNDEF; } @@ -673,7 +732,7 @@ dissect_fc_fctl(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, proto_tree_add_boolean(tree, hf_fc_fctl_rel_offset, tvb, offset, 3, fctl); - fctl_to_str( ((guint8 *)&fctl)+1, str, is_ack); + fctl_to_str( ((guint8 *)&fctl), str, is_ack); proto_item_append_text(item, " %s", str); } @@ -703,20 +762,25 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *fc_tree = NULL; tvbuff_t *next_tvb; int offset = 0, next_offset; - gboolean is_lastframe_inseq; + gboolean is_lastframe_inseq, is_1frame_inseq, is_valid_frame; gboolean is_exchg_resp = 0; fragment_data *fcfrag_head; guint32 frag_id; guint32 frag_size; - guint8 df_ctl; + guint8 df_ctl, seq_id; guint32 param; + guint16 real_seqcnt; guint8 ftype; gboolean is_ack; static fc_hdr fchdr; fc_exchange_data *fc_ex=NULL; + conversation_t *conversation; + fcseq_conv_data_t *cdata; + fcseq_conv_key_t ckey, *req_key; + fchdr.fced=NULL; /* Make entries in Protocol column and Info column on summary display */ @@ -744,6 +808,7 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) fchdr.oxid=tvb_get_ntohs(tvb,offset+16); fchdr.rxid=tvb_get_ntohs(tvb,offset+18); param = tvb_get_ntohl (tvb, offset+20); + seq_id = tvb_get_guint8 (tvb, offset+12); pinfo->oxid = fchdr.oxid; pinfo->rxid = fchdr.rxid; @@ -752,6 +817,22 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) is_ack = ((fchdr.r_ctl == 0xC0) || (fchdr.r_ctl == 0xC1)); + /* There are two ways to determine if this is the first frame of a + * sequence. Either: + * (i) The SOF bits indicate that this is the first frame OR + * (ii) This is an SOFf frame and seqcnt is 0. + */ + is_1frame_inseq = (((pinfo->sof_eof & PINFO_SOF_FIRST_FRAME) == PINFO_SOF_FIRST_FRAME) || + (((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) && + (fchdr.seqcnt == 0))); + + is_lastframe_inseq = ((pinfo->sof_eof & PINFO_EOF_LAST_FRAME) == PINFO_EOF_LAST_FRAME); + + if ((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) { + is_lastframe_inseq = fchdr.fctl & FC_FCTL_SEQ_LAST; + } + is_valid_frame = ((pinfo->sof_eof & 0x40) == 0x40); + ftype = fc_get_ftype (fchdr.r_ctl, fchdr.type); if (check_col (pinfo->cinfo, COL_INFO)) { @@ -1041,7 +1122,6 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ is_lastframe_inseq = TRUE; } else { - is_lastframe_inseq = fchdr.fctl & FC_FCTL_SEQ_LAST; /* XXX is this right? offset 20, shouldnt it be offset 9? */ is_exchg_resp = ((tvb_get_guint8 (tvb, offset+20) & 0x80) == 0x80); } @@ -1067,15 +1147,62 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * present, if we're configured to reassemble. */ if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) && - (!is_lastframe_inseq || fchdr.seqcnt) && fc_reassemble && - tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size)) { + (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble && + tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) { /* Add this to the list of fragments */ - frag_id = (pinfo->oxid << 16) | is_exchg_resp; + + /* In certain cases such as FICON, the SEQ_CNT is streaming + * i.e. continuously increasing. So, zero does not signify the + * first frame of the sequence. To fix this, we need to save the + * SEQ_CNT of the first frame in sequence and use this value to + * determine the actual offset into a frame. + */ + 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 = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash, + &ckey); + + if (is_1frame_inseq) { + 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->seq_cnt = fchdr.seqcnt; + } + else { + req_key = g_mem_chunk_alloc (fcseq_req_keys); + req_key->conv_idx = conversation->index; + + cdata = g_mem_chunk_alloc (fcseq_req_vals); + cdata->seq_cnt = fchdr.seqcnt; + + g_hash_table_insert (fcseq_req_hash, req_key, cdata); + } + real_seqcnt = 0; + } + else if (cdata != NULL) { + real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ; + } + else { + real_seqcnt = fchdr.seqcnt; + } + + frag_id = ((pinfo->oxid << 16) ^ seq_id) | is_exchg_resp ; /* We assume that all frames are of the same max size */ fcfrag_head = fragment_add (tvb, FC_HEADER_SIZE, pinfo, frag_id, fc_fragment_table, - fchdr.seqcnt * fc_max_frame_size, + real_seqcnt * fc_max_frame_size, frag_size, !is_lastframe_inseq); @@ -1092,7 +1219,8 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled, tvb, offset+9, 1, 1); } - } else { + } + else { if (tree) { proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled, tvb, offset+9, 1, 0); diff --git a/packet-fc.h b/packet-fc.h index f4d97c814b..fb17ba505e 100644 --- a/packet-fc.h +++ b/packet-fc.h @@ -2,7 +2,7 @@ * Basic Fibre Channel Header definitions * Copyright 2002 Dinesh G Dutt (ddutt@cisco.com) * - * $Id: packet-fc.h,v 1.4 2003/08/23 13:35:05 sahlberg Exp $ + * $Id: packet-fc.h,v 1.5 2003/10/30 02:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -45,6 +45,8 @@ #define FC_TYPE_LLCSNAP 0x4 #define FC_TYPE_IP 0x5 #define FC_TYPE_SCSI 0x8 +#define FC_TYPE_SB_TO_CU 0x1B +#define FC_TYPE_SB_FROM_CU 0x1C #define FC_TYPE_FCCT 0x20 #define FC_TYPE_SWILS 0x22 #define FC_TYPE_AL 0x23 @@ -74,6 +76,7 @@ extern const value_string fc_fc4_val[]; #define FC_FTYPE_VDO 0x9 #define FC_FTYPE_LINKCTL 0xA #define FC_FTYPE_SWILS_RSP 0xB +#define FC_FTYPE_SBCCS 0xC /* Well-known Address Definitions (in Network order) */ #define FC_WKA_MULTICAST 0xFFFFF5 diff --git a/packet-fcels.c b/packet-fcels.c index 32397ab079..7ae038d931 100644 --- a/packet-fcels.c +++ b/packet-fcels.c @@ -2,7 +2,7 @@ * Routines for FC Extended Link Services * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com> * - * $Id: packet-fcels.c,v 1.4 2003/01/31 03:17:46 guy Exp $ + * $Id: packet-fcels.c,v 1.5 2003/10/30 02:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -185,7 +185,7 @@ GMemChunk *fcels_req_keys = NULL; GMemChunk *fcels_req_vals = NULL; guint32 fcels_init_count = 25; -static dissector_handle_t data_handle; +static dissector_handle_t data_handle, fcsp_handle; /* * Hash Functions @@ -1719,6 +1719,10 @@ dissect_fcels (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case FC_ELS_RPSC: dissect_fcels_rpsc (tvb, pinfo, tree, isreq, ti); break; + case FC_ELS_AUTH: + if (isreq && fcsp_handle) + call_dissector (fcsp_handle, tvb, pinfo, tree); + break; default: /* proto_tree_add_text ( */ call_dissector (data_handle, tvb, pinfo, tree); @@ -1982,4 +1986,5 @@ proto_reg_handoff_fcels (void) dissector_add("fc.ftype", FC_FTYPE_ELS, els_handle); data_handle = find_dissector ("data"); + fcsp_handle = find_dissector ("fcsp"); } diff --git a/packet-fcels.h b/packet-fcels.h index cb6a39b2da..23d0f03f6f 100644 --- a/packet-fcels.h +++ b/packet-fcels.h @@ -2,7 +2,7 @@ * Fibre Channel Extended Link Services Definitions (ddutt@cisco.com) * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com> * - * $Id: packet-fcels.h,v 1.1 2002/12/08 02:32:17 gerald Exp $ + * $Id: packet-fcels.h,v 1.2 2003/10/30 02:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -56,6 +56,7 @@ #define FC_ELS_LIRR 0x7A #define FC_ELS_SRL 0x7B #define FC_ELS_RPSC 0x7D +#define FC_ELS_AUTH 0x90 static const value_string fc_els_proto_val[] = { {FC_ELS_LSRJT , "LS_RJT"}, @@ -88,6 +89,7 @@ static const value_string fc_els_proto_val[] = { {FC_ELS_LIRR , "LIRR"}, {FC_ELS_SRL , "SRL"}, {FC_ELS_RPSC , "RPSC"}, + {FC_ELS_AUTH , "AUTH"}, {0, NULL}, }; diff --git a/packet-fcip.c b/packet-fcip.c index d1a7e9dd8e..5cc7bef5bf 100644 --- a/packet-fcip.c +++ b/packet-fcip.c @@ -2,7 +2,7 @@ * Routines for FCIP dissection * Copyright 2001, Dinesh G Dutt (ddutt@cisco.com) * - * $Id: packet-fcip.c,v 1.7 2003/09/09 05:02:35 guy Exp $ + * $Id: packet-fcip.c,v 1.8 2003/10/30 02:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -382,7 +382,7 @@ dissect_fcip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) start = 0, frame_len = 0; gint bytes_remaining = tvb_length_remaining (tvb, offset); - guint8 pflags, sof, eof; + guint8 pflags, sof = 0, eof = 0; /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; proto_tree *fcip_tree = NULL; @@ -482,6 +482,25 @@ dissect_fcip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Call the FC Dissector if this is carrying an FC frame */ if (!FCIP_IS_SF(pflags)) { + /* Set the SOF/EOF flags in the packet_info header */ + pinfo->sof_eof = 0; + + if (sof) { + if ((sof == FCIP_SOFi3) || (sof == FCIP_SOFi2) || (sof == FCIP_SOFi4)) { + pinfo->sof_eof = PINFO_SOF_FIRST_FRAME; + } + else if (sof == FCIP_SOFf) { + pinfo->sof_eof = PINFO_SOF_SOFF; + } + + if (eof != FCIP_EOFn) { + pinfo->sof_eof |= PINFO_EOF_LAST_FRAME; + } + else if (eof != FCIP_EOFt) { + pinfo->sof_eof |= PINFO_EOF_INVALID; + } + } + /* Special frame bit is not set */ next_tvb = tvb_new_subset (tvb, FCIP_ENCAP_HEADER_LEN+4, -1, -1); if (fc_handle) { diff --git a/packet-fcsb3.c b/packet-fcsb3.c new file mode 100644 index 0000000000..fb5cd161c2 --- /dev/null +++ b/packet-fcsb3.c @@ -0,0 +1,1001 @@ +/* packet-fc-sb3.c + * Routines for Fibre Channel Single Byte Protocol (SBCCS); used in FICON. + * This decoder is for FC-SB3 version 1.4 + * Copyright 2003, Dinesh G Dutt <ddutt@cisco.com> + * + * $Id: packet-fcsb3.c,v 1.1 2003/10/30 02:06:12 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 "prefs.h" +#include <epan/packet.h> +#include <epan/conversation.h> +#include "etypes.h" +#include "packet-fc.h" +#include "packet-fcsb3.h" + +/* Initialize the protocol and registered fields */ +static int proto_fc_sbccs = -1; +static int hf_sbccs_chid = -1; +static int hf_sbccs_cuid = -1; +static int hf_sbccs_devaddr = -1; +static int hf_sbccs_iui = -1; +static int hf_sbccs_dhflags = -1; +static int hf_sbccs_ccw = -1; +static int hf_sbccs_token = -1; +static int hf_sbccs_dib_iucnt = -1; +static int hf_sbccs_dib_datacnt = -1; +static int hf_sbccs_dib_ccw_cmd = -1; +static int hf_sbccs_dib_ccw_flags = -1; +static int hf_sbccs_dib_ccw_cnt = -1; +static int hf_sbccs_dib_statusflags = -1; +static int hf_sbccs_dib_status = -1; +static int hf_sbccs_dib_residualcnt = -1; +static int hf_sbccs_dib_qtuf = -1; +static int hf_sbccs_dib_qtu = -1; +static int hf_sbccs_dib_dtuf = -1; +static int hf_sbccs_dib_dtu = -1; +static int hf_sbccs_dib_ctlfn = -1; +static int hf_sbccs_dib_ctlparam = -1; +static int hf_sbccs_lrc = -1; +static int hf_sbccs_dib_iupacing = -1; +static int hf_sbccs_dev_xcp_code = -1; +static int hf_sbccs_prg_pth_errcode = -1; +static int hf_sbccs_prg_rsp_errcode = -1; +static int hf_sbccs_dib_ctccntr = -1; +static int hf_sbccs_dib_lprcode = -1; +static int hf_sbccs_dib_tin_imgid_cnt = -1; +static int hf_sbccs_dib_lrjcode = -1; +static int hf_sbccs_dib_ioprio = -1; +static int hf_sbccs_dib_cmdflags = -1; +static int hf_sbccs_dib_linkctlfn = -1; +static int hf_sbccs_dib_linkctlinfo = -1; + +/* Initialize the subtree pointers */ +static gint ett_fc_sbccs = -1; + +static dissector_handle_t data_handle; + +typedef struct { + guint32 conv_id; + guint32 task_id; +} sb3_task_id_t; + +static const value_string fc_sbccs_iu_val[] = { + {FC_SBCCS_IU_DATA, "Data"}, + {FC_SBCCS_IU_CMD_HDR, "Command Header"}, + {FC_SBCCS_IU_STATUS, "Status"}, + {FC_SBCCS_IU_CTL, "Control"}, + {FC_SBCCS_IU_CMD_DATA, "Command Header & Data"}, + {FC_SBCCS_IU_CMD_LINK_CTL, "Link Control"}, + {0x6, "Reserved"}, + {0x7, "Reserved"}, + {0x0, NULL}, +}; + +static const value_string fc_sbccs_dib_cmd_val[] = { + {0, "Reserved"}, + {1, "Write"}, + {2, "Read"}, + {3, "Control"}, + {4, "Sense"}, + {5, "Write (Modifier)"}, + {6, "Read (Modifier)"}, + {7, "Control (Modifier)"}, + {8, "Reserved"}, + {9, "Write (Modifier)"}, + {10, "Read (Modifier)"}, + {11, "Control (Modifier)"}, + {12, "Read Backward"}, + {13, "Write (Modifier)"}, + {14, "Read (Modifier)"}, + {15, "Control (Modifier)"}, + {0, NULL}, +}; + +static const value_string fc_sbccs_dib_ctl_fn_val[] = { + {FC_SBCCS_CTL_FN_CTL_END, "Control End"}, + {FC_SBCCS_CTL_FN_CMD_RSP, "Command Response"}, + {FC_SBCCS_CTL_FN_STK_STS, "Stack Status"}, + {FC_SBCCS_CTL_FN_CANCEL, "Cancel"}, + {FC_SBCCS_CTL_FN_SYS_RST, "System Reset"}, + {FC_SBCCS_CTL_FN_SEL_RST, "Selective Reset"}, + {FC_SBCCS_CTL_FN_REQ_STS, "Request Status"}, + {FC_SBCCS_CTL_FN_DEV_XCP, "Device Level Exception"}, + {FC_SBCCS_CTL_FN_STS_ACC, "Status Accepted"}, + {FC_SBCCS_CTL_FN_DEV_ACK, "Device-Level Ack"}, + {FC_SBCCS_CTL_FN_PRG_PTH, "Purge Path"}, + {FC_SBCCS_CTL_FN_PRG_RSP, "Purge Path Response"}, + {0, NULL}, +}; + +static const value_string fc_sbccs_dib_dev_xcpcode_val[] = { + {1, "Address Exception"}, + {0, NULL}, +}; + +static const value_string fc_sbccs_dib_purge_path_err_val[] = { + {0, "Error Code Xfer Not Supported"}, + {1, "SB-3 Protocol Timeout"}, + {2, "SB-3 Link Failure"}, + {3, "Reserved"}, + {4, "SB-3 Offline Condition"}, + {5, "FC-PH Link Failure"}, + {6, "SB-3 Length Error"}, + {7, "LRC Error"}, + {8, "SB-3 CRC Error"}, + {9, "IU Count Error"}, + {10, "SB-3 Link Level Protocol Error"}, + {11, "SB-3 Device Level Protocol Error"}, + {12, "Receive ABTS"}, + {13, "Cancel Function Timeout"}, + {14, "Abnormal Termination of Xchg"}, + {15, "Reserved"}, + {0, NULL}, +}; + +static const value_string fc_sbccs_dib_purge_path_rsp_err_val[] = { + {0, "No Errors"}, + {1, "SB-3 Protocol Timeout"}, + {2, "SB-3 Link Failure"}, + {3, "Logical Path Timeout Error"}, + {4, "SB-3 Offline Condition"}, + {5, "FC-PH Link Failure"}, + {6, "SB-3 Length Error"}, + {7, "LRC Error"}, + {8, "SB-3 CRC Error"}, + {9, "IU Count Error"}, + {10, "SB-3 Link Level Protocol Error"}, + {11, "SB-3 Device Level Protocol Error"}, + {12, "Receive ABTS"}, + {13, "Reserved"}, + {14, "Abnormal Termination of Xchg"}, + {15, "Logical Path Not Estd"}, + {16, "Test Init Result Error"}, + {0, NULL}, +}; + +static const value_string fc_sbccs_dib_link_ctl_fn_val[] = { + {FC_SBCCS_LINK_CTL_FN_ELP, "ELP"}, + {FC_SBCCS_LINK_CTL_FN_RLP, "RLP"}, + {FC_SBCCS_LINK_CTL_FN_TIN, "TIN"}, + {FC_SBCCS_LINK_CTL_FN_LPE, "LPE"}, + {FC_SBCCS_LINK_CTL_FN_LPR, "LPR"}, + {FC_SBCCS_LINK_CTL_FN_TIR, "TIR"}, + {FC_SBCCS_LINK_CTL_FN_LRJ, "LRJ"}, + {FC_SBCCS_LINK_CTL_FN_LBY, "LBY"}, + {FC_SBCCS_LINK_CTL_FN_LACK, "LACK"}, + {0, NULL}, +}; + +static const value_string fc_sbccs_dib_lpr_errcode_val[] = { + {0x0, "Response to RLP"}, + {0x1, "Optional Features Conflict"}, + {0x2, "Out of Resources"}, + {0x3, "Device Init In Progress"}, + {0x4, "No CU Image"}, + {0x0, NULL}, +}; + +static const value_string fc_sbccs_dib_lrj_errcode_val[] = { + {0x6, "Logical Path Not Estd"}, + {0x9, "Protocol Error"}, + {0x0, NULL}, +}; + +static gchar *get_iui_string (guint8 iui, gchar *buffer) +{ + guint pos = 0; + buffer[0] = '\0'; + + if (iui & 0x10) { + strcpy (&buffer[pos], "AS, "); + pos += 4; + } + + if (iui & 0x8) { + strcpy (&buffer[pos], "ES, "); + pos += 4; + } + + strcpy (&buffer[pos], val_to_str (iui & 0x7, fc_sbccs_iu_val, "0x%x")); + + return (buffer); +} + +static gchar *get_dhflags_string (guint8 dhflags, gchar *buffer) +{ + guint pos = 0; + buffer[0] = '\0'; + + if (dhflags & 0x80) { + strcpy (&buffer[pos], "End, "); + pos += 5; + } + + if (dhflags & 0x10) { + strcpy (&buffer[pos], "Chaining, "); + pos += 10; + } + + if (dhflags & 0x8) { + strcpy (&buffer[pos], "Early End, "); + pos += 11; + } + + if (dhflags & 0x4) { + strcpy (&buffer[pos], "No CRC"); + } + + return (buffer); +} + +static gchar *get_ccw_flags_string (guint8 ccw_flags, gchar *buffer) +{ + guint pos = 0; + + buffer[0] = '\0'; + + if (ccw_flags & 0x80) { + strcpy (&buffer[pos], "CD, "); + pos += 4; + } + + if (ccw_flags & 0x40) { + strcpy (&buffer[pos], "CC, "); + pos += 4; + } + + if (ccw_flags & 0x20) { + strcpy (&buffer[pos], "SLI, "); + pos += 5; + } + + if (ccw_flags & 0x8) { + strcpy (&buffer[pos], "CRR"); + pos += 5; + } + + return (buffer); +} + +static gchar *get_cmd_flag_string (guint8 cmd_flag, gchar *buffer) +{ + guint pos = 0; + + buffer[0] = '\0'; + + if (cmd_flag & 0x10) { + strcpy (&buffer[pos], "DU, "); + pos += 4; + } + + if (cmd_flag & 0x8) { + strcpy (&buffer[pos], "COC, "); + pos += 4; + } + + if (cmd_flag & 0x4) { + strcpy (&buffer[pos], "SYR, "); + pos += 5; + } + + if (cmd_flag & 0x2) { + strcpy (&buffer[pos], "REX, "); + pos += 5; + } + + if (cmd_flag & 0x1) { + strcpy (&buffer[pos], "SSS"); + pos += 5; + } + + return (buffer); +} + +static gchar *get_status_flag_string (guint8 status_flag, gchar *buffer) +{ + guint pos = 0; + guint8 ffc = (status_flag & 0xD0) >> 5; + + buffer[0] = '\0'; + + switch (ffc) { + case 0: + break; /* to avoid the catch clause below */ + case 1: + strcpy (&buffer[pos], "FFC:Queuing Information Valid, "); + pos += 31; + break; + case 2: + strcpy (&buffer[pos], "FFC:Resetting Event, "); + pos += 21; + break; + default: + strcpy (&buffer[pos], "Reserved"); + break; + } + + if (status_flag & 10) { + strcpy (&buffer[pos], "CI, "); + pos += 4; + } + + if (status_flag & 0x4) { + strcpy (&buffer[pos], "CR, "); + pos += 4; + } + + if (status_flag & 0x2) { + strcpy (&buffer[pos], "LRI, "); + pos += 5; + } + + if (status_flag & 0x1) { + strcpy (&buffer[pos], "RV"); + } + + return (buffer); +} + +static gchar *get_status_string (guint8 status, gchar *buffer) +{ + guint pos = 0; + + buffer[0] = '\0'; + + if (status & 0x80) { + strcpy (&buffer[pos], "Attention, "); + pos += 11; + } + + if (status & 0x40) { + strcpy (&buffer[pos], "Status Modifier, "); + pos += 17; + } + + if (status & 0x20) { + strcpy (&buffer[pos], "Control-Unit End, "); + pos += 18; + } + + if (status & 0x10) { + strcpy (&buffer[pos], "Busy, "); + pos += 6; + } + + if (status & 0x8) { + strcpy (&buffer[pos], "Channel End, "); + pos += 12; + } + + if (status & 0x4) { + strcpy (&buffer[pos], "Device End, "); + pos += 12; + } + + if (status & 0x2) { + strcpy (&buffer[pos], "Unit Check, "); + pos += 12; + } + + if (status & 0x1) { + strcpy (&buffer[pos], "Unit Exception"); + } + + return (buffer); +} + +static gchar *get_sel_rst_param_string (guint8 ctlparam, gchar *buffer) +{ + guint pos = 0; + + buffer[0] = '\0'; + + if (ctlparam & 0x80) { + strcpy (&buffer[pos], "RC, "); + pos += 4; + } + if (ctlparam & 0x10) { + strcpy (&buffer[pos], "RU, "); + pos += 4; + } + if (ctlparam & 0x8) { + strcpy (&buffer[pos], "RO"); + } + + return (buffer); +} + +static void get_fc_sbccs_conv_data (tvbuff_t *tvb, guint offset, + guint16 *ch_cu_id, guint16 *dev_addr, + guint16 *ccw) +{ + *ch_cu_id = *dev_addr = *ccw = 0; + + *ch_cu_id = (tvb_get_guint8 (tvb, offset+1)) << 8; + *ch_cu_id |= tvb_get_guint8 (tvb, offset+3); + *dev_addr = tvb_get_ntohs (tvb, offset+4); + *ccw = tvb_get_ntohs (tvb, offset+10); +} + +/* Decode both the SB-3 and basic IU header */ +static void +dissect_fc_sbccs_sb3_iu_hdr (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, + guint offset) +{ + proto_item *subti; + proto_tree *sb3hdr_tree; + proto_tree *iuhdr_tree; + gchar buffer[256]; + guint8 iui, dhflags; + guint type; + + /* Decode the basic SB3 and IU header and determine type of frame */ + type = get_fc_sbccs_iu_type (tvb, offset); + + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, val_to_str (type, fc_sbccs_iu_val, + "0x%x")); + } + + if (tree) { + /* Dissect SB3 header first */ + subti = proto_tree_add_text (tree, tvb, offset, FC_SBCCS_SB3_HDR_SIZE, + "SB-3 Header"); + sb3hdr_tree = proto_item_add_subtree (subti, ett_fc_sbccs); + + proto_tree_add_item (sb3hdr_tree, hf_sbccs_chid, tvb, offset+1, 1, 0); + proto_tree_add_item (sb3hdr_tree, hf_sbccs_cuid, tvb, offset+3, 1, 0); + proto_tree_add_item (sb3hdr_tree, hf_sbccs_devaddr, tvb, offset+4, 2, 0); + + /* Dissect IU Header */ + subti = proto_tree_add_text (tree, tvb, offset + FC_SBCCS_SB3_HDR_SIZE, + FC_SBCCS_IU_HDR_SIZE, "IU Header"); + iuhdr_tree = proto_item_add_subtree (subti, ett_fc_sbccs); + offset += FC_SBCCS_SB3_HDR_SIZE; + + iui = tvb_get_guint8 (tvb, offset); + proto_tree_add_uint_format (iuhdr_tree, hf_sbccs_iui, tvb, offset, 1, + iui, "Information Unit Identifier: 0x%x (%s)", + iui, get_iui_string (iui, buffer)); + dhflags = tvb_get_guint8 (tvb, offset+1); + proto_tree_add_uint_format (iuhdr_tree, hf_sbccs_dhflags, tvb, offset, 1, + dhflags, "DH Flags: 0x%x (%s)", + dhflags, get_dhflags_string (dhflags, buffer)); + + proto_tree_add_item (iuhdr_tree, hf_sbccs_ccw, tvb, offset+2, 2, 0); + proto_tree_add_item (iuhdr_tree, hf_sbccs_token, tvb, offset+5, 3, 0); + } +} + +static void dissect_fc_sbccs_dib_data_hdr (tvbuff_t *tvb, + packet_info *pinfo _U_, + proto_tree *tree, guint offset) +{ + if (tree) { + proto_tree_add_item (tree, hf_sbccs_dib_iucnt, tvb, offset+9, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_datacnt, tvb, offset+10, 2, 0); + proto_tree_add_item (tree, hf_sbccs_lrc, tvb, offset+12, 4, 0); + } +} + +static void dissect_fc_sbccs_dib_cmd_hdr (tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, guint offset) +{ + guint8 flags; + gchar buffer[64]; + + if (check_col (pinfo->cinfo, COL_INFO)) { + col_append_fstr (pinfo->cinfo, COL_INFO, + ": %s", val_to_str (tvb_get_guint8 (tvb, offset), + fc_sbccs_dib_cmd_val, + "0x%x")); + } + + if (tree) { + proto_tree_add_item (tree, hf_sbccs_dib_ccw_cmd, tvb, offset, 1, 0); + + flags = tvb_get_guint8 (tvb, offset+1); + proto_tree_add_uint_format (tree, hf_sbccs_dib_ccw_flags, tvb, + offset+1, 1, flags, + "CCW Control Flags: 0x%x(%s)", flags, + get_ccw_flags_string (flags, buffer)); + proto_tree_add_item (tree, hf_sbccs_dib_ccw_cnt, tvb, offset+2, 2, 0); + proto_tree_add_item (tree, hf_sbccs_dib_ioprio, tvb, offset+5, 1, 0); + + flags = tvb_get_guint8 (tvb, offset+7); + proto_tree_add_uint_format (tree, hf_sbccs_dib_cmdflags, tvb, offset+7, + 1, flags, "Command Flags: 0x%x(%s)", flags, + get_cmd_flag_string (flags, buffer)); + proto_tree_add_item (tree, hf_sbccs_dib_iucnt, tvb, offset+9, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_datacnt, tvb, offset+10, 2, 0); + proto_tree_add_item (tree, hf_sbccs_lrc, tvb, offset+12, 4, 0); + + } +} + +static void dissect_fc_sbccs_dib_status_hdr (tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, guint offset) +{ + guint8 flags; + gboolean rv_valid, qparam_valid; + gchar buffer[128]; + tvbuff_t *next_tvb; + guint16 supp_status_cnt = 0; + + if (check_col (pinfo->cinfo, COL_INFO)) { + col_append_fstr (pinfo->cinfo, COL_INFO, + ": %s", + get_status_string (tvb_get_guint8 (tvb, offset+1), + buffer)); + } + + if (tree) { + flags = tvb_get_guint8 (tvb, offset); + rv_valid = flags & 0x1; /* if residual count is valid */ + qparam_valid = (((flags & 0xD0) >> 5) == 0x1); /* From the FFC field */ + proto_tree_add_uint_format (tree, hf_sbccs_dib_statusflags, tvb, offset, + 1, flags, "Status Flags: 0x%x(%s)", + flags, get_status_flag_string (flags, + buffer)); + + flags = tvb_get_guint8 (tvb, offset+1); + proto_tree_add_uint_format (tree, hf_sbccs_dib_status, tvb, offset+1, + 1, flags, "Status: 0x%x(%s)", flags, + get_status_string (flags, buffer)); + if (rv_valid) { + proto_tree_add_item (tree, hf_sbccs_dib_residualcnt, tvb, offset+2, + 2, 0); + } + else { + proto_tree_add_item (tree, hf_sbccs_dib_iupacing, tvb, offset+3, + 1, 0); + } + + if (qparam_valid) { + proto_tree_add_item (tree, hf_sbccs_dib_qtuf, tvb, offset+4, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_qtu, tvb, offset+4, 2, 0); + } + + proto_tree_add_item (tree, hf_sbccs_dib_dtuf, tvb, offset+6, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_dtu, tvb, offset+6, 2, 0); + + proto_tree_add_item (tree, hf_sbccs_dib_iucnt, tvb, offset+9, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_datacnt, tvb, offset+10, 2, 0); + supp_status_cnt = tvb_get_ntohs (tvb, offset+10); + proto_tree_add_item (tree, hf_sbccs_lrc, tvb, offset+12, 4, 0); + + if (supp_status_cnt) { + next_tvb = tvb_new_subset (tvb, offset+FC_SBCCS_DIB_LRC_HDR_SIZE, + -1, -1); + call_dissector (data_handle, next_tvb, pinfo, tree); + } + } +} + +static void dissect_fc_sbccs_dib_ctl_hdr (tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, guint offset) +{ + guint32 ctlfn; + gchar buffer[128]; + + ctlfn = tvb_get_guint8 (tvb, offset); + if (check_col (pinfo->cinfo, COL_INFO)) { + col_append_fstr (pinfo->cinfo, COL_INFO, + ": %s", + val_to_str (ctlfn, + fc_sbccs_dib_ctl_fn_val, + "0x%x")); + } + if (tree) { + proto_tree_add_item (tree, hf_sbccs_dib_ctlfn, tvb, offset, 1, 0); + + /* Control Function Parameter is to be interpreted in some cases */ + switch (ctlfn) { + case FC_SBCCS_CTL_FN_SEL_RST: + proto_tree_add_uint_format (tree, hf_sbccs_dib_ctlparam, tvb, + offset+1, 3, + tvb_get_ntoh24 (tvb, offset+1), + "Control Parameter: 0x%x(%s)", + tvb_get_ntoh24 (tvb, offset+1), + get_sel_rst_param_string (ctlfn, + buffer)); + break; + case FC_SBCCS_CTL_FN_DEV_XCP: + proto_tree_add_item (tree, hf_sbccs_dev_xcp_code, tvb, offset+1, + 1, 0); + break; + case FC_SBCCS_CTL_FN_PRG_PTH: + proto_tree_add_item (tree, hf_sbccs_prg_pth_errcode, tvb, offset+1, + 1, 0); + break; + default: + proto_tree_add_item (tree, hf_sbccs_dib_ctlparam, tvb, offset+1, + 3, 0); + break; + } + + proto_tree_add_item (tree, hf_sbccs_dib_iucnt, tvb, offset+9, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_datacnt, tvb, offset+10, 2, 0); + proto_tree_add_item (tree, hf_sbccs_lrc, tvb, offset+12, 4, 0); + + if (ctlfn == FC_SBCCS_CTL_FN_PRG_RSP) { + /* Need to decode the LESBs */ + proto_tree_add_item (tree, hf_sbccs_prg_rsp_errcode, tvb, offset+60, + 1, 0); + } + } +} + +static void dissect_fc_sbccs_dib_link_hdr (tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, guint offset) +{ + guint8 link_ctl; + guint16 ctl_info; + gchar buffer[128]; + guint link_payload_len, i; + gchar *lpath_ptr; + + if (check_col (pinfo->cinfo, COL_INFO)) { + col_append_fstr (pinfo->cinfo, COL_INFO, + ": %s", + val_to_str (tvb_get_guint8 (tvb, offset+1), + fc_sbccs_dib_link_ctl_fn_val, + "0x%x")); + } + + if (tree) { + link_ctl = tvb_get_guint8 (tvb, offset+1); + proto_tree_add_item (tree, hf_sbccs_dib_linkctlfn, tvb, offset+1, 1, 0); + + ctl_info = tvb_get_ntohs (tvb, offset+2); + switch (link_ctl) { + case FC_SBCCS_LINK_CTL_FN_ELP: + case FC_SBCCS_LINK_CTL_FN_LPE: + buffer[0] = '\0'; + if (ctl_info & 0x1) { + strcpy (buffer, "Enhanced CRC Gen, "); + } + if (ctl_info & 0x80) { + strcpy (&buffer[18], "CTC Conn"); + } + + proto_tree_add_uint_format (tree, hf_sbccs_dib_linkctlinfo, tvb, + offset+2, 2, ctl_info, + "Link Control Info: 0x%x(%s)", ctl_info, + buffer); + break; + case FC_SBCCS_LINK_CTL_FN_LPR: + proto_tree_add_item (tree, hf_sbccs_dib_lprcode, tvb, offset+2, 1, + 0); + break; + case FC_SBCCS_LINK_CTL_FN_TIN: + proto_tree_add_item (tree, hf_sbccs_dib_tin_imgid_cnt, tvb, + offset+3, 1, 0); + break; + case FC_SBCCS_LINK_CTL_FN_TIR: + proto_tree_add_item (tree, hf_sbccs_dib_tin_imgid_cnt, tvb, + offset+3, 1, 0); + break; + case FC_SBCCS_LINK_CTL_FN_LRJ: + proto_tree_add_item (tree, hf_sbccs_dib_lrjcode, tvb, offset+2, + 1, 0); + break; + default: + /* Do Nothing */ + break; + } + + proto_tree_add_item (tree, hf_sbccs_dib_ctccntr, tvb, offset+4, 2, 0); + proto_tree_add_item (tree, hf_sbccs_dib_iucnt, tvb, offset+9, 1, 0); + proto_tree_add_item (tree, hf_sbccs_dib_datacnt, tvb, offset+10, 2, 0); + proto_tree_add_item (tree, hf_sbccs_lrc, tvb, offset+12, 4, 0); + + if (link_ctl == FC_SBCCS_LINK_CTL_FN_TIR) { + link_payload_len = tvb_get_ntohs (tvb, offset+10); + i = 0; + offset += 16; + lpath_ptr = (gchar *)tvb_get_ptr (tvb, offset, link_payload_len/4); + + while (i < link_payload_len) { + proto_tree_add_text (tree, tvb, offset, 4, + "Logical Paths %d-%d: %x:%x:%x:%x", + i*8, ((i+4)*8) - 1, lpath_ptr[i], + lpath_ptr[i+1], lpath_ptr[i+2], + lpath_ptr[i+3]); + i += 4; + offset += 4; + } + } + } +} + +static void dissect_fc_sbccs (tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree) +{ + guint8 type; + guint16 ch_cu_id, dev_addr, ccw; + guint offset = 0; + proto_item *ti; + proto_tree *sb3_tree = NULL, + *dib_tree = NULL; + tvbuff_t *next_tvb; + conversation_t *conversation; + sb3_task_id_t task_key; + + /* 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-SB3"); + + /* Decode the basic SB3 and IU header and determine type of frame */ + type = get_fc_sbccs_iu_type (tvb, offset); + get_fc_sbccs_conv_data (tvb, offset, &ch_cu_id, &dev_addr, &ccw); + + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, val_to_str (type, fc_sbccs_iu_val, + "0x%x")); + } + + /* Retrieve conversation state to determine expected payload */ + conversation = find_conversation (&pinfo->src, &pinfo->dst, + PT_SBCCS, ch_cu_id, dev_addr, 0); + + if (conversation) { + task_key.conv_id = conversation->index; + task_key.task_id = ccw; + pinfo->private_data = (void *)&task_key; + + } + else if ((type == FC_SBCCS_IU_CMD_HDR) || + (type != FC_SBCCS_IU_CMD_DATA)) { + conversation = conversation_new (&pinfo->src, &pinfo->dst, + PT_SBCCS, ch_cu_id, dev_addr, 0); + task_key.conv_id = conversation->index; + task_key.task_id = ccw; + pinfo->private_data = (void *)&task_key; + } + else { + pinfo->private_data = NULL; + } + + if (tree) { + ti = proto_tree_add_protocol_format (tree, proto_fc_sbccs, tvb, 0, -1, + "FC-SB3"); + sb3_tree = proto_item_add_subtree (ti, ett_fc_sbccs); + + dissect_fc_sbccs_sb3_iu_hdr (tvb, pinfo, sb3_tree, offset); + offset += (FC_SBCCS_SB3_HDR_SIZE + FC_SBCCS_IU_HDR_SIZE); + + ti = proto_tree_add_text (sb3_tree, tvb, offset, + FC_SBCCS_DIB_LRC_HDR_SIZE, "DIB Header"); + dib_tree = proto_item_add_subtree (ti, ett_fc_sbccs); + } + else { + offset += (FC_SBCCS_SB3_HDR_SIZE + FC_SBCCS_IU_HDR_SIZE); + } + + switch (type) { + case FC_SBCCS_IU_DATA: + dissect_fc_sbccs_dib_data_hdr (tvb, pinfo, dib_tree, offset); + break; + case FC_SBCCS_IU_CMD_HDR: + case FC_SBCCS_IU_CMD_DATA: + dissect_fc_sbccs_dib_cmd_hdr (tvb, pinfo, dib_tree, offset); + break; + case FC_SBCCS_IU_STATUS: + dissect_fc_sbccs_dib_status_hdr (tvb, pinfo, dib_tree, offset); + break; + case FC_SBCCS_IU_CTL: + dissect_fc_sbccs_dib_ctl_hdr (tvb, pinfo, dib_tree, offset); + break; + case FC_SBCCS_IU_CMD_LINK_CTL: + dissect_fc_sbccs_dib_link_hdr (tvb, pinfo, dib_tree, offset); + break; + default: + next_tvb = tvb_new_subset (tvb, offset, -1, -1); + call_dissector (data_handle, next_tvb, pinfo, dib_tree); + break; + } + + if ((get_fc_sbccs_iu_type (tvb, 0) != FC_SBCCS_IU_CTL) && + (get_fc_sbccs_iu_type (tvb, 0) != FC_SBCCS_IU_CMD_LINK_CTL)) { + next_tvb = tvb_new_subset (tvb, offset+FC_SBCCS_DIB_LRC_HDR_SIZE, + -1, -1); + call_dissector (data_handle, next_tvb, pinfo, tree); + } +} + +/* 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_fcsbccs (void) +{ + /* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_sbccs_chid, + {"Channel Image ID", "sbccs.chid", FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_cuid, + {"Control Unit Image ID", "sbccs.cuid", FT_UINT8, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_sbccs_devaddr, + {"Device Address", "sbccs.devaddr", FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_iui, + {"Information Unit Identifier", "sbccs.iui", FT_UINT8, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_sbccs_dhflags, + {"DH Flags", "sbccs.dhflags", FT_UINT8, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_sbccs_ccw, + {"CCW Number", "sbccs.ccw", FT_UINT16, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_sbccs_token, + {"Token", "sbccs.token", FT_UINT24, BASE_DEC, NULL, 0x0, "", + HFILL}}, + { &hf_sbccs_dib_iucnt, + {"DIB IU Count", "sbccs.iucnt", FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_dib_datacnt, + {"DIB Data Byte Count", "sbccs.databytecnt", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_sbccs_dib_ccw_cmd, + {"CCW Command", "sbccs.ccwcmd", FT_UINT8, BASE_HEX, + VALS (fc_sbccs_dib_cmd_val), 0x0, "", HFILL}}, + { &hf_sbccs_dib_ccw_flags, + {"CCW Control Flags", "sbccs.ccwflags", FT_UINT8, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_sbccs_dib_ccw_cnt, + {"CCW Count", "sbccs.ccwcnt", FT_UINT16, BASE_DEC, NULL, 0x0, "", + HFILL}}, + { &hf_sbccs_dib_ioprio, + {"I/O Priority", "sbccs.ioprio", FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_dib_cmdflags, + {"Command Flags", "sbccs.cmdflags", FT_UINT8, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_dib_statusflags, + {"Status Flags", "sbccs.statusflags", FT_UINT8, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_sbccs_dib_status, + {"Status", "sbccs.status", FT_UINT8, BASE_DEC, NULL, 0x0, "", + HFILL}}, + { &hf_sbccs_dib_residualcnt, + {"Residual Count", "sbccs.residualcnt", FT_UINT8, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_sbccs_dib_iupacing, + {"IU Pacing", "sbccs.iupacing", FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_dib_qtuf, + {"Queue-Time Unit Factor", "sbccs.qtuf", FT_UINT8, BASE_DEC, + NULL, 0xF0, "", HFILL}}, + { &hf_sbccs_dib_qtu, + {"Queue-Time Unit", "sbccs.qtu", FT_UINT16, BASE_DEC, NULL, 0xFFF, + "", HFILL}}, + { &hf_sbccs_dib_dtuf, + {"Defer-Time Unit Function", "sbccs.dtuf", FT_UINT8, BASE_DEC, + NULL, 0xF0, "", HFILL}}, + { &hf_sbccs_dib_dtu, + {"Defer-Time Unit", "sbccs.dtu", FT_UINT16, BASE_DEC, NULL, 0xFFF, + "", HFILL}}, + { &hf_sbccs_dib_ctlfn, + {"Control Function", "sbccs.ctlfn", FT_UINT8, BASE_HEX, + VALS (fc_sbccs_dib_ctl_fn_val), 0x0, "", HFILL}}, + { &hf_sbccs_dib_ctlparam, + {"Control Parameters", "sbccs.ctlparam", FT_UINT24, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_sbccs_dib_linkctlfn, + {"Link Control Function", "sbccs.linkctlfn", FT_UINT8, BASE_HEX, + VALS (fc_sbccs_dib_link_ctl_fn_val), 0x0, "", HFILL}}, + { &hf_sbccs_dib_linkctlinfo, + {"Link Control Information", "sbccs.linkctlinfo", FT_UINT16, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_sbccs_dib_ctccntr, + {"CTC Counter", "sbccs.ctccntr", FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_sbccs_lrc, + {"LRC", "sbccs.lrc", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_sbccs_dev_xcp_code, + {"Device Level Exception Code", "sbccs.dip.xcpcode", FT_UINT8, + BASE_DEC, VALS (fc_sbccs_dib_dev_xcpcode_val), 0x0, "", HFILL}}, + { &hf_sbccs_prg_pth_errcode, + {"Purge Path Error Code", "sbccs.purgepathcode", FT_UINT8, + BASE_DEC, VALS (fc_sbccs_dib_purge_path_err_val), 0x0, "", HFILL}}, + { &hf_sbccs_prg_rsp_errcode, + {"Purge Path Response Error Code", "sbccs.purgepathrspcode", + FT_UINT8, BASE_DEC, VALS (fc_sbccs_dib_purge_path_rsp_err_val), + 0x0, "", HFILL}}, + { &hf_sbccs_dib_lprcode, + {"LPR Reason Code", "sbccs.lprcode", FT_UINT8, BASE_DEC, + VALS (fc_sbccs_dib_lpr_errcode_val), 0xF, "", HFILL}}, + { &hf_sbccs_dib_tin_imgid_cnt, + {"TIN Image ID", "sbccs.tinimageidcnt", FT_UINT8, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_sbccs_dib_lrjcode, + {"LRJ Reaspn Code", "sbccs.lrjcode", FT_UINT8, BASE_HEX, + VALS (fc_sbccs_dib_lrj_errcode_val), 0x7F, "", HFILL}}, + }; + + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_fc_sbccs, + }; + + /* Register the protocol name and description */ + proto_fc_sbccs = proto_register_protocol ("Fibre Channel Single Byte Command", + "FC-SB3", "sb3"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fc_sbccs, 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_fcsbccs (void) +{ + dissector_handle_t fc_sbccs_handle; + + fc_sbccs_handle = create_dissector_handle (dissect_fc_sbccs, + proto_fc_sbccs); + + dissector_add("fc.ftype", FC_FTYPE_SBCCS, fc_sbccs_handle); + + data_handle = find_dissector ("data"); +} + + diff --git a/packet-fcsb3.h b/packet-fcsb3.h new file mode 100755 index 0000000000..1375e85f33 --- /dev/null +++ b/packet-fcsb3.h @@ -0,0 +1,74 @@ +/* packet-fc-sb3.h + * Routines for Fibre Channel Single Byte Protocol (SBCCS); used in FICON. + * This decoder is for FC-SB3 version 1.4 + * Copyright 2003 Dinesh G Dutt (ddutt@cisco.com) + * + * $Id: packet-fcsb3.h,v 1.1 2003/10/30 02:06:12 guy Exp $ + * + * 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_FCSB3_H_ +#define __PACKET_FCSB3_H_ + +/* SB-3 IU Types */ +#define FC_SBCCS_IU_DATA 0x0 +#define FC_SBCCS_IU_CMD_HDR 0x1 +#define FC_SBCCS_IU_STATUS 0x2 +#define FC_SBCCS_IU_CTL 0x3 +#define FC_SBCCS_IU_CMD_DATA 0x4 +#define FC_SBCCS_IU_CMD_LINK_CTL 0x5 + +/* Control Function Types */ +#define FC_SBCCS_CTL_FN_CTL_END 0x0 +#define FC_SBCCS_CTL_FN_CMD_RSP 0x10 +#define FC_SBCCS_CTL_FN_STK_STS 0x20 +#define FC_SBCCS_CTL_FN_CANCEL 0x30 +#define FC_SBCCS_CTL_FN_SYS_RST 0x40 +#define FC_SBCCS_CTL_FN_SEL_RST 0x50 +#define FC_SBCCS_CTL_FN_REQ_STS 0x70 +#define FC_SBCCS_CTL_FN_DEV_XCP 0x80 +#define FC_SBCCS_CTL_FN_STS_ACC 0xA0 +#define FC_SBCCS_CTL_FN_DEV_ACK 0xB0 +#define FC_SBCCS_CTL_FN_PRG_PTH 0xC1 +#define FC_SBCCS_CTL_FN_PRG_RSP 0xD0 + +/* Link Control Function Types */ +#define FC_SBCCS_LINK_CTL_FN_ELP 0x41 +#define FC_SBCCS_LINK_CTL_FN_RLP 0x49 +#define FC_SBCCS_LINK_CTL_FN_TIN 0x09 +#define FC_SBCCS_LINK_CTL_FN_LPE 0x51 +#define FC_SBCCS_LINK_CTL_FN_LPR 0x59 +#define FC_SBCCS_LINK_CTL_FN_TIR 0x01 +#define FC_SBCCS_LINK_CTL_FN_LRJ 0x11 +#define FC_SBCCS_LINK_CTL_FN_LBY 0x21 +#define FC_SBCCS_LINK_CTL_FN_LACK 0x61 + +#define FC_SBCCS_SB3_HDR_SIZE 8 +#define FC_SBCCS_IU_HDR_SIZE 8 +#define FC_SBCCS_DIB_LRC_HDR_SIZE 16 + +/* Decodes the DIB Type from the IU header and returns type */ +static inline guint get_fc_sbccs_iu_type (tvbuff_t *tvb, guint offset) +{ + /* This is in the IUI field of the IU header */ + return (tvb_get_guint8 (tvb, offset+FC_SBCCS_SB3_HDR_SIZE) & 0x7); +} + +#endif diff --git a/packet-fcsp.c b/packet-fcsp.c new file mode 100755 index 0000000000..e9cc9609d1 --- /dev/null +++ b/packet-fcsp.c @@ -0,0 +1,575 @@ +/* packet-fc-sp.c + * Routines for Fibre Channel Security Protocol (FC-SP) + * This decoder is for FC-SP version 1.1 + * Copyright 2003, Dinesh G Dutt <ddutt@cisco.com> + * + * $Id: packet-fcsp.c,v 1.1 2003/10/30 02:06:12 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 "prefs.h" +#include <epan/packet.h> +#include <epan/conversation.h> +#include "etypes.h" +#include "packet-fc.h" +#include "packet-fcsp.h" + +/* Initialize the protocol and registered fields */ +static int proto_fcsp = -1; +static int hf_auth_proto_ver = -1; +static int hf_auth_msg_code = -1; +static int hf_auth_flags = -1; +static int hf_auth_len = -1; +static int hf_auth_tid = -1; +static int hf_auth_initiator_wwn = -1; +static int hf_auth_initiator_name = -1; +static int hf_auth_usable_proto = -1; +static int hf_auth_rjt_code = -1; +static int hf_auth_rjt_codedet = -1; +static int hf_auth_responder_wwn = -1; +static int hf_auth_responder_name = -1; +static int hf_auth_dhchap_groupid = -1; +static int hf_auth_dhchap_hashid = -1; +static int hf_auth_dhchap_chal_len = -1; +static int hf_auth_dhchap_val_len = -1; +static int hf_auth_dhchap_rsp_len = -1; +static int hf_auth_initiator_name_type = -1; +static int hf_auth_initiator_name_len = -1; +static int hf_auth_responder_name_len = -1; +static int hf_auth_responder_name_type = -1; +static int hf_auth_proto_type = -1; +static int hf_auth_proto_param_len = -1; +static int hf_auth_dhchap_param_tag = -1; +static int hf_auth_dhchap_param_len = -1; +static int hf_auth_dhchap_hash_type = -1; +static int hf_auth_dhchap_group_type = -1; +static int hf_auth_dhchap_dhvalue = -1; +static int hf_auth_dhchap_chal_value = -1; +static int hf_auth_dhchap_rsp_value = -1; + +/* Initialize the subtree pointers */ +static gint ett_fcsp = -1; + +static dissector_handle_t data_handle; + +static const value_string fcauth_msgcode_vals[] = { + {FC_AUTH_MSG_AUTH_REJECT, "AUTH_Reject"}, + {FC_AUTH_MSG_AUTH_NEGOTIATE, "AUTH_Negotiate"}, + {FC_AUTH_MSG_AUTH_DONE, "AUTH_Done"}, + {FC_AUTH_DHCHAP_CHALLENGE, "DHCHAP_Challenge"}, + {FC_AUTH_DHCHAP_REPLY, "DHCHAP_Reply"}, + {FC_AUTH_DHCHAP_SUCCESS, "DHCHAP_Success"}, + {FC_AUTH_FCAP_REQUEST, "FCAP_Request"}, + {FC_AUTH_FCAP_ACKNOWLEDGE, "FCAP_Acknowledge"}, + {FC_AUTH_FCAP_CONFIRM, "FCAP_Confirm"}, + {FC_AUTH_FCPAP_INIT, "FCPAP_Init"}, + {FC_AUTH_FCPAP_ACCEPT, "FCPAP_Accept"}, + {FC_AUTH_FCPAP_COMPLETE, "FCPAP_Complete"}, + {0, NULL}, +}; + +static const value_string fcauth_rjtcode_vals[] = { + {0x01, "Authentication Failure"}, + {0x02, "Logical Error"}, + {0, NULL}, +}; + +static const value_string fcauth_rjtcode_detail_vals[] = { + {0x01, "Authentication Mechanism Not Usable"}, + {0x02, "DH Group Not Usable"}, + {0x03, "Hash Algorithm Not Usable"}, + {0x04, "Authentication Protocol Instance Already Started"}, + {0x05, "Authentication Failed "}, + {0x06, "Incorrect Payload "}, + {0x07, "Incorrect Authentication Protocol Message"}, + {0x08, "Protocol Reset"}, + {0, NULL}, +}; + +static const value_string fcauth_dhchap_param_vals[] = { + {FC_AUTH_DHCHAP_PARAM_HASHLIST, "HashList"}, + {FC_AUTH_DHCHAP_PARAM_DHgIDLIST, "DHgIDList"}, + {0, NULL}, +}; + +static const value_string fcauth_dhchap_hash_algo_vals[] = { + {FC_AUTH_DHCHAP_HASH_MD5, "MD5"}, + {FC_AUTH_DHCHAP_HASH_SHA1, "SHA-1"}, + {0, NULL}, +}; + +static const value_string fcauth_name_type_vals[] = { + {FC_AUTH_NAME_TYPE_WWN, "WWN"}, + {0, NULL}, +}; + +static const value_string fcauth_proto_type_vals[] = { + {FC_AUTH_PROTO_TYPE_DHCHAP, "DHCHAP"}, + {FC_AUTH_PROTO_TYPE_FCAP, "FCAP"}, + {0, NULL}, +}; + +static const value_string fcauth_dhchap_dhgid_vals[] = { + {0, "DH NULL"}, + {1, "DH Group 1024"}, + {2, "DH Group 1280"}, + {3, "DH Group 1536"}, + {4, "DH Group 2048"}, + {0, NULL}, +}; + +/* this format is required because a script is used to build the C function + that calls all the protocol registration. +*/ + +void dissect_fcsp_dhchap_auth_param (tvbuff_t *tvb, proto_tree *tree, + int offset, gint32 total_len) +{ + guint16 auth_param_tag; + guint16 param_len = 0, i; + + if (tree) { + proto_tree_add_item (tree, hf_auth_proto_type, tvb, offset, 4, 0); + + auth_param_tag = tvb_get_ntohs (tvb, offset+4); + offset += 4; + total_len -= 4; + + while (total_len > 0) { + proto_tree_add_item (tree, hf_auth_dhchap_param_tag, tvb, offset, + 2, 0); + proto_tree_add_item (tree, hf_auth_dhchap_param_len, tvb, offset+2, + 2, 0); + + auth_param_tag = tvb_get_ntohs (tvb, offset); + param_len = tvb_get_ntohs (tvb, offset+2); + + switch (auth_param_tag) { + case FC_AUTH_DHCHAP_PARAM_HASHLIST: + offset += 4; + total_len -= 4; + for (i = 0; i < param_len; i += 4) { + proto_tree_add_item (tree, hf_auth_dhchap_hash_type, tvb, + offset, 4, 0); + offset += 4; + } + break; + case FC_AUTH_DHCHAP_PARAM_DHgIDLIST: + offset += 4; + total_len -= 4; + for (i = 0; i < param_len; i += 4) { + proto_tree_add_item (tree, hf_auth_dhchap_group_type, tvb, + offset, 4, 0); + offset += 4; + } + break; + default: + break; + } + + total_len -= param_len; + } + } +} + +void dissect_fcsp_dhchap_challenge (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 12; + guint16 name_type; + guint16 param_len, name_len; + + if (tree) { + proto_tree_add_item (tree, hf_auth_responder_name_type, tvb, offset, + 2, 0); + name_type = tvb_get_ntohs (tvb, offset); + + proto_tree_add_item (tree, hf_auth_responder_name_len, tvb, offset+2, + 2, 0); + + name_len = tvb_get_ntohs (tvb, offset+2); + + if (name_type == FC_AUTH_NAME_TYPE_WWN) { + proto_tree_add_string (tree, hf_auth_responder_wwn, tvb, offset+4, + 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+4, + 8))); + } + else { + proto_tree_add_bytes (tree, hf_auth_responder_name, tvb, offset+4, + name_len, tvb_get_ptr (tvb, offset+4, name_len)); + } + offset += (4+name_len); + + proto_tree_add_item (tree, hf_auth_dhchap_hash_type, tvb, offset, + 4, 0); + proto_tree_add_item (tree, hf_auth_dhchap_group_type, tvb, offset+4, + 4, 0); + proto_tree_add_item (tree, hf_auth_dhchap_chal_len, tvb, offset+8, + 4, 0); + param_len = tvb_get_ntohl (tvb, offset+8); + + proto_tree_add_bytes (tree, hf_auth_dhchap_chal_value, tvb, offset+12, + param_len, + tvb_get_ptr (tvb, offset+12, param_len)); + offset += (param_len + 12); + + proto_tree_add_item (tree, hf_auth_dhchap_val_len, tvb, offset, 4, 0); + param_len = tvb_get_ntohl (tvb, offset); + + proto_tree_add_bytes (tree, hf_auth_dhchap_dhvalue, tvb, offset+4, + param_len, + tvb_get_ptr (tvb, offset+4, param_len)); + } +} + + +void dissect_fcsp_dhchap_reply (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 12; + guint32 param_len; + + if (tree) { + proto_tree_add_item (tree, hf_auth_dhchap_rsp_len, tvb, offset, 4, 0); + param_len = tvb_get_ntohl (tvb, offset); + + proto_tree_add_bytes (tree, hf_auth_dhchap_rsp_value, tvb, offset+4, + param_len, + tvb_get_ptr (tvb, offset+4, param_len)); + offset += (param_len + 4); + + proto_tree_add_item (tree, hf_auth_dhchap_val_len, tvb, offset, 4, 0); + param_len = tvb_get_ntohl (tvb, offset); + + proto_tree_add_bytes (tree, hf_auth_dhchap_dhvalue, tvb, offset+4, + param_len, + tvb_get_ptr (tvb, offset+4, param_len)); + offset += (param_len + 4); + + proto_tree_add_item (tree, hf_auth_dhchap_chal_len, tvb, offset, 4, 0); + param_len = tvb_get_ntohl (tvb, offset); + + proto_tree_add_bytes (tree, hf_auth_dhchap_chal_value, tvb, offset+4, + param_len, + tvb_get_ptr (tvb, offset+4, param_len)); + } +} + +void dissect_fcsp_dhchap_success (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 12; + guint32 param_len; + + if (tree) { + proto_tree_add_item (tree, hf_auth_dhchap_rsp_len, tvb, offset, 4, 0); + param_len = tvb_get_ntohl (tvb, offset); + + proto_tree_add_bytes (tree, hf_auth_dhchap_rsp_value, tvb, offset+4, + param_len, + tvb_get_ptr (tvb, offset+4, param_len)); + } +} + + +void dissect_fcsp_auth_negotiate (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 12; + guint16 name_type, name_len, proto_type, param_len; + guint32 num_protos, i; + + if (tree) { + proto_tree_add_item (tree, hf_auth_initiator_name_type, tvb, offset, + 2, 0); + name_type = tvb_get_ntohs (tvb, offset); + + proto_tree_add_item (tree, hf_auth_initiator_name_len, tvb, offset+2, + 2, 0); + name_len = tvb_get_ntohs (tvb, offset+2); + + if (name_type == FC_AUTH_NAME_TYPE_WWN) { + proto_tree_add_string (tree, hf_auth_initiator_wwn, tvb, offset+4, 8, + fcwwn_to_str (tvb_get_ptr (tvb, offset+4, 8))); + } + else { + proto_tree_add_bytes (tree, hf_auth_initiator_name, tvb, offset+4, + name_len, tvb_get_ptr (tvb, offset+4, + name_len)); + } + + offset += (4+name_len); + + proto_tree_add_item (tree, hf_auth_usable_proto, tvb, offset, 4, 0); + num_protos = tvb_get_ntohl (tvb, offset); + offset += 4; + + for (i = 0; i < num_protos; i++) { + proto_type = tvb_get_ntohs (tvb, offset); + proto_tree_add_item (tree, hf_auth_proto_type, tvb, offset, 2, 0); + proto_tree_add_item (tree, hf_auth_proto_param_len, tvb, offset+2, 2, 0); + param_len = tvb_get_ntohs (tvb, offset+2)*4; + + if (tvb_bytes_exist (tvb, offset, param_len)) { + switch (proto_type) { + case FC_AUTH_PROTO_TYPE_DHCHAP: + dissect_fcsp_dhchap_auth_param (tvb, tree, offset+4, param_len); + break; + case FC_AUTH_PROTO_TYPE_FCAP: + break; + default: + break; + } + } + offset += param_len; + } + } +} + +void dissect_fcsp_auth_done (tvbuff_t *tvb _U_, proto_tree *tree _U_) +{ +} + +void dissect_fcsp_auth_rjt (tvbuff_t *tvb, proto_tree *tree) +{ + int offset = 12; + + if (tree) { + proto_tree_add_item (tree, hf_auth_rjt_code, tvb, offset, 1, 0); + proto_tree_add_item (tree, hf_auth_rjt_codedet, tvb, offset+1, 1, 0); + } +} + +void dissect_fcsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *ti = NULL; + guint8 opcode; + int offset = 0; + proto_tree *fcsp_tree = NULL; + + /* Make entry in the Info column on summary display */ + opcode = tvb_get_guint8 (tvb, 2); + + if (check_col (pinfo->cinfo, COL_INFO)) { + col_set_str (pinfo->cinfo, COL_INFO, + val_to_str (opcode, fcauth_msgcode_vals, "0x%x")); + } + + if (tree) { + ti = proto_tree_add_protocol_format (tree, proto_fcsp, tvb, 0, + tvb_length (tvb), "FC-SP"); + fcsp_tree = proto_item_add_subtree (ti, ett_fcsp); + + proto_tree_add_item (fcsp_tree, hf_auth_flags, tvb, offset+1, 1, 0); + proto_tree_add_item (fcsp_tree, hf_auth_msg_code, tvb, offset+2, 1, 0); + proto_tree_add_item (fcsp_tree, hf_auth_proto_ver, tvb, offset+3, 1, + 0); + proto_tree_add_item (fcsp_tree, hf_auth_len, tvb, offset+4, 4, 0); + proto_tree_add_item (fcsp_tree, hf_auth_tid, tvb, offset+8, 4, 0); + + switch (opcode) { + case FC_AUTH_MSG_AUTH_REJECT: + dissect_fcsp_auth_rjt (tvb, tree); + break; + case FC_AUTH_MSG_AUTH_NEGOTIATE: + dissect_fcsp_auth_negotiate (tvb, tree); + break; + case FC_AUTH_MSG_AUTH_DONE: + dissect_fcsp_auth_done (tvb, tree); + break; + case FC_AUTH_DHCHAP_CHALLENGE: + dissect_fcsp_dhchap_challenge (tvb, tree); + break; + case FC_AUTH_DHCHAP_REPLY: + dissect_fcsp_dhchap_reply (tvb, tree); + break; + case FC_AUTH_DHCHAP_SUCCESS: + dissect_fcsp_dhchap_success (tvb, tree); + break; + case FC_AUTH_FCAP_REQUEST: + case FC_AUTH_FCAP_ACKNOWLEDGE: + case FC_AUTH_FCAP_CONFIRM: + case FC_AUTH_FCPAP_INIT: + case FC_AUTH_FCPAP_ACCEPT: + case FC_AUTH_FCPAP_COMPLETE: + proto_tree_add_text (fcsp_tree, tvb, offset+12, tvb_length (tvb), + "FCAP Decoding Not Supported"); + break; + default: + break; + } + } +} + +void +proto_register_fcsp (void) +{ + /* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_auth_proto_ver, + {"Protocol Version", "fcsp.version", FT_UINT8, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_auth_msg_code, + {"Message Code", "fcsp.opcode", FT_UINT8, BASE_HEX, + VALS (fcauth_msgcode_vals), 0x0, "", HFILL}}, + { &hf_auth_flags, + {"Flags", "fcsp.flags", FT_UINT8, BASE_HEX, NULL, 0x0, "", + HFILL}}, + { &hf_auth_len, + {"Packet Length", "fcsp.len", FT_UINT32, BASE_DEC, NULL, 0x0, + "", HFILL}}, + { &hf_auth_tid, + {"Transaction Identifier", "fcsp.tid", FT_UINT32, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_auth_initiator_wwn, + {"Initiator Name (WWN)", "fcsp.initwwn", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_auth_initiator_name, + {"Initiator Name (Unknown Type)", "fcsp.initname", FT_BYTES, + BASE_HEX, NULL, 0x0, "", HFILL}}, + { &hf_auth_initiator_name_type, + {"Initiator Name Type", "fcsp.initnametype", FT_UINT16, BASE_HEX, + VALS (fcauth_name_type_vals), 0x0, "", HFILL}}, + { &hf_auth_initiator_name_len, + {"Initiator Name Length", "fcsp.initnamelen", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_auth_usable_proto, + {"Number of Usable Protocols", "fcsp.usableproto", FT_UINT32, + BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_auth_rjt_code, + {"Reason Code", "fcsp.rjtcode", FT_UINT8, BASE_DEC, + VALS (fcauth_rjtcode_vals), 0x0, "", HFILL}}, + { &hf_auth_rjt_codedet, + {"Reason Code Explanation", "fcsp.rjtcodet", FT_UINT8, BASE_DEC, + VALS (fcauth_rjtcode_detail_vals), 0x0, "", HFILL}}, + { &hf_auth_responder_wwn, + {"Responder Name (WWN)", "fcsp.rspwwn", FT_STRING, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_auth_responder_name, + {"Responder Name (Unknown Type)", "fcsp.rspname", FT_BYTES, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_auth_responder_name_type, + {"Responder Name Type", "fcsp.rspnametype", FT_UINT16, BASE_HEX, + VALS (fcauth_name_type_vals), 0x0, "", HFILL}}, + { &hf_auth_responder_name_len, + {"Responder Name Type", "fcsp.rspnamelen", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_auth_dhchap_hashid, + {"Hash Identifier", "fcsp.dhchap.hashid", FT_UINT32, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_auth_dhchap_groupid, + {"DH Group Identifier", "fcsp.dhchap.groupid", FT_UINT32, BASE_HEX, NULL, + 0x0, "", HFILL}}, + { &hf_auth_dhchap_chal_len, + {"Challenge Value Length", "fcsp.dhchap.challen", FT_UINT32, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_auth_dhchap_val_len, + {"DH Value Length", "fcsp.dhchap.vallen", FT_UINT32, BASE_DEC, NULL, + 0x0, "", HFILL}}, + { &hf_auth_dhchap_rsp_len, + {"Response Value Length", "fcsp.dhchap.rsplen", FT_UINT32, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_auth_proto_type, + {"Authentication Protocol Type", "fcsp.proto", FT_UINT32, BASE_DEC, + VALS (fcauth_proto_type_vals), 0x0, "", HFILL}}, + { &hf_auth_proto_param_len, + {"Protocol Parameters Length", "fcsp.protoparamlen", FT_UINT32, + BASE_DEC, NULL, 0x0, "", HFILL}}, + { &hf_auth_dhchap_param_tag, + {"Parameter Tag", "fcsp.dhchap.paramtype", FT_UINT16, BASE_HEX, + VALS (fcauth_dhchap_param_vals), 0x0, "", HFILL}}, + { &hf_auth_dhchap_param_len, + {"Parameter Length", "fcsp.dhchap.paramlen", FT_UINT16, BASE_DEC, + NULL, 0x0, "", HFILL}}, + { &hf_auth_dhchap_hash_type, + {"Hash Algorithm", "fcsp.dhchap.hashtype", FT_UINT32, BASE_DEC, + VALS (fcauth_dhchap_hash_algo_vals), 0x0, "", HFILL}}, + { &hf_auth_dhchap_group_type, + {"DH Group", "fcsp.dhchap.dhgid", FT_UINT32, BASE_DEC, + VALS (fcauth_dhchap_dhgid_vals), 0x0, "", HFILL}}, + { &hf_auth_dhchap_chal_value, + {"Challenge Value", "fcsp.dhchap.chalval", FT_BYTES, BASE_HEX, + NULL, 0x0, "", HFILL}}, + { &hf_auth_dhchap_dhvalue, + {"DH Value", "fcsp.dhchap.dhvalue", FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL}}, + { &hf_auth_dhchap_rsp_value, + {"Response Value", "fcsp.dhchap.rspval", FT_BYTES, BASE_HEX, NULL, + 0x0, "", HFILL}}, + + }; + + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_fcsp, + }; + + /* Register the protocol name and description */ + proto_fcsp = proto_register_protocol ("Fibre Channel Security Protocol", + "FC-SP", "fcsp"); + + register_dissector("fcsp", dissect_fcsp, proto_fcsp); + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_fcsp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + data_handle = find_dissector("data"); +} + +/* 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_fcsp (void) +{ + dissector_handle_t fcsp_handle; + + fcsp_handle = create_dissector_handle (dissect_fcsp, proto_fcsp); + + data_handle = find_dissector ("data"); +} + diff --git a/packet-fcsp.h b/packet-fcsp.h new file mode 100755 index 0000000000..2c1f9ef5a8 --- /dev/null +++ b/packet-fcsp.h @@ -0,0 +1,55 @@ +/* packet-fc-sp.h + * Routines for Fibre Channel Security Protocol + * This decoder is for FC-SP version 1.1 + * Copyright 2003 Dinesh G Dutt (ddutt@cisco.com) + * + * 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_FCSP_H_ +#define __PACKET_FCSP_H_ + +/* Message Codes */ +#define FC_AUTH_MSG_AUTH_REJECT 0x0A +#define FC_AUTH_MSG_AUTH_NEGOTIATE 0x0B +#define FC_AUTH_MSG_AUTH_DONE 0x0C +#define FC_AUTH_DHCHAP_CHALLENGE 0x10 +#define FC_AUTH_DHCHAP_REPLY 0x11 +#define FC_AUTH_DHCHAP_SUCCESS 0x12 +#define FC_AUTH_FCAP_REQUEST 0x13 +#define FC_AUTH_FCAP_ACKNOWLEDGE 0x14 +#define FC_AUTH_FCAP_CONFIRM 0x15 +#define FC_AUTH_FCPAP_INIT 0x16 +#define FC_AUTH_FCPAP_ACCEPT 0x17 +#define FC_AUTH_FCPAP_COMPLETE 0x18 + +#define FC_AUTH_NAME_TYPE_WWN 0x1 + +#define FC_AUTH_PROTO_TYPE_DHCHAP 0x1 +#define FC_AUTH_PROTO_TYPE_FCAP 0x2 + +#define FC_AUTH_DHCHAP_HASH_MD5 0x5 +#define FC_AUTH_DHCHAP_HASH_SHA1 0x6 + +#define FC_AUTH_DHCHAP_PARAM_HASHLIST 0x1 +#define FC_AUTH_DHCHAP_PARAM_DHgIDLIST 0x2 + +void dissect_fcsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); + +#endif diff --git a/packet-fcswils.c b/packet-fcswils.c index 7e5fc2f78c..809362ddde 100644 --- a/packet-fcswils.c +++ b/packet-fcswils.c @@ -2,7 +2,7 @@ * Routines for FC Inter-switch link services * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com> * - * $Id: packet-fcswils.c,v 1.5 2003/06/30 21:58:41 guy Exp $ + * $Id: packet-fcswils.c,v 1.6 2003/10/30 02:06:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -200,6 +200,7 @@ static const value_string fc_swils_opcode_key_val[] = { {FC_SWILS_SFC , "SFC"}, {FC_SWILS_UFC , "UFC"}, {FC_SWILS_ESC , "ESC"}, + {FC_SWILS_AUTH_ILS, "AUTH_ILS"}, {0, NULL}, }; @@ -382,7 +383,7 @@ GMemChunk *fcswils_req_keys = NULL; GMemChunk *fcswils_req_vals = NULL; guint32 fcswils_init_count = 25; -static dissector_handle_t data_handle; +static dissector_handle_t data_handle, fcsp_handle; static gint get_zoneobj_len (tvbuff_t *tvb, gint offset); @@ -1589,6 +1590,10 @@ dissect_fcswils (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case FC_SWILS_ESC: dissect_swils_esc (tvb, swils_tree, isreq); break; + case FC_SWILS_AUTH_ILS: + if (isreq && fcsp_handle) + call_dissector (fcsp_handle, tvb, pinfo, swils_tree); + break; default: next_tvb = tvb_new_subset (tvb, offset+4, -1, -1); call_dissector (data_handle, next_tvb, pinfo, tree); @@ -1911,6 +1916,7 @@ proto_reg_handoff_fcswils (void) dissector_add("fc.ftype", FC_FTYPE_SWILS, swils_handle); data_handle = find_dissector ("data"); + fcsp_handle = find_dissector ("fcsp"); } diff --git a/packet-fcswils.h b/packet-fcswils.h index 0a8d5e9105..42fc99de44 100644 --- a/packet-fcswils.h +++ b/packet-fcswils.h @@ -2,7 +2,7 @@ * Fibre Channel Switch InterLink Services Definitions * Copyright 2001 Dinesh G Dutt (ddutt@cisco.com) * - * $Id: packet-fcswils.h,v 1.2 2003/06/30 21:50:18 guy Exp $ + * $Id: packet-fcswils.h,v 1.3 2003/10/30 02:06:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -48,6 +48,7 @@ #define FC_SWILS_SFC 0x25 #define FC_SWILS_UFC 0x26 #define FC_SWILS_ESC 0x30 +#define FC_SWILS_AUTH_ILS 0x40 /* Reject reason codes */ diff --git a/packet-mdshdr.c b/packet-mdshdr.c index acea6cfce5..e8567ab56a 100644 --- a/packet-mdshdr.c +++ b/packet-mdshdr.c @@ -2,7 +2,7 @@ * Routines for dissection of Cisco MDS Switch Internal Header * Copyright 2001, Dinesh G Dutt <ddutt@andiamo.com> * - * $Id: packet-mdshdr.c,v 1.7 2003/10/27 19:30:55 guy Exp $ + * $Id: packet-mdshdr.c,v 1.8 2003/10/30 02:06:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -197,6 +197,22 @@ dissect_mdshdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->src_idx = (tvb_get_ntohs (tvb, MDSHDR_SIDX_OFFSET) & 0x3FF); pinfo->dst_idx = (tvb_get_ntohs (tvb, MDSHDR_DIDX_OFFSET) & 0xFFC) >> 6; pinfo->vsan = vsan; + pinfo->sof_eof = 0; + + if ((sof == MDSHDR_SOFi3) || (sof == MDSHDR_SOFi2) || (sof == MDSHDR_SOFi1) + || (sof == MDSHDR_SOFi4)) { + pinfo->sof_eof = PINFO_SOF_FIRST_FRAME; + } + else if (sof == MDSHDR_SOFf) { + pinfo->sof_eof = PINFO_SOF_SOFF; + } + + if (eof != MDSHDR_EOFn) { + pinfo->sof_eof |= PINFO_EOF_LAST_FRAME; + } + else if (eof != MDSHDR_EOFt) { + pinfo->sof_eof |= PINFO_EOF_INVALID; + } /* In the interest of speed, if "tree" is NULL, don't do any work not necessary to generate protocol tree items. */ |