2 * Routines for FC Extended Link Services
3 * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
5 * $Id: packet-fcels.c,v 1.6 2003/11/07 08:50:43 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * TODO Still (Complete compliance with FC-MI):
39 #ifdef HAVE_SYS_TYPES_H
40 # include <sys/types.h>
43 #ifdef HAVE_NETINET_IN_H
44 # include <netinet/in.h>
49 #ifdef NEED_SNPRINTF_H
50 # include "snprintf.h"
53 #include <epan/packet.h>
54 #include <epan/conversation.h>
56 #include "packet-fc.h"
57 #include "packet-fcels.h"
62 /* Initialize the protocol and registered fields */
63 static int proto_fcels = -1;
64 static int hf_fcels_opcode = -1;
65 static int hf_fcels_rjtcode = -1;
66 static int hf_fcels_rjtdetcode = -1;
67 static int hf_fcels_vnduniq = -1;
68 static int hf_fcels_b2b = -1;
69 static int hf_fcels_cmnfeatures = -1;
70 static int hf_fcels_bbscnum = -1;
71 static int hf_fcels_rcvsize = -1;
72 static int hf_fcels_maxconseq = -1;
73 static int hf_fcels_reloffset = -1;
74 static int hf_fcels_edtov = -1;
75 static int hf_fcels_npname = -1;
76 static int hf_fcels_fnname = -1;
77 static int hf_fcels_cls1param = -1;
78 static int hf_fcels_cls2param = -1;
79 static int hf_fcels_cls3param = -1;
80 static int hf_fcels_cls4param = -1;
81 static int hf_fcels_vendorvers = -1;
82 static int hf_fcels_svcavail = -1;
83 static int hf_fcels_clsflags = -1;
84 static int hf_fcels_initctl = -1;
85 static int hf_fcels_rcptctl = -1;
86 static int hf_fcels_clsrcvsize = -1;
87 static int hf_fcels_conseq = -1;
88 static int hf_fcels_e2e = -1;
89 static int hf_fcels_openseq = -1;
90 static int hf_fcels_nportid = -1;
91 static int hf_fcels_oxid = -1;
92 static int hf_fcels_rxid = -1;
93 static int hf_fcels_recovqual = -1;
94 static int hf_fcels_fabricaddr = -1;
95 static int hf_fcels_fabricpname = -1;
96 static int hf_fcels_failedrcvr = -1;
97 static int hf_fcels_flacompliance = -1;
98 static int hf_fcels_loopstate = -1;
99 static int hf_fcels_publicloop_bmap = -1;
100 static int hf_fcels_pvtloop_bmap = -1;
101 static int hf_fcels_alpa_map = -1;
102 static int hf_fcels_scrregn = -1;
103 static int hf_fcels_farp_matchcodept = -1;
104 static int hf_fcels_farp_respaction = -1;
105 static int hf_fcels_resportid = -1;
106 static int hf_fcels_respname = -1;
107 static int hf_fcels_respnname = -1;
108 static int hf_fcels_reqipaddr = -1;
109 static int hf_fcels_respipaddr = -1;
110 static int hf_fcels_hardaddr = -1;
111 static int hf_fcels_rps_flag = -1;
112 static int hf_fcels_rps_portnum = -1;
113 static int hf_fcels_rps_portstatus = -1;
114 static int hf_fcels_rnft_fc4type = -1;
115 static int hf_fcels_rscn_evqual = -1;
116 static int hf_fcels_rscn_addrfmt = -1;
117 static int hf_fcels_rscn_domain = -1;
118 static int hf_fcels_rscn_area = -1;
119 static int hf_fcels_rscn_port = -1;
120 static int hf_fcels_nodeidfmt = -1;
121 static int hf_fcels_spidlen = -1;
122 static int hf_fcels_vendoruniq = -1;
123 static int hf_fcels_vendorsp = -1;
124 static int hf_fcels_asstype = -1;
125 static int hf_fcels_physport = -1;
126 static int hf_fcels_attnodes = -1;
127 static int hf_fcels_nodemgmt = -1;
128 static int hf_fcels_ipvers = -1;
129 static int hf_fcels_tcpport = -1;
130 static int hf_fcels_ip = -1;
132 static gint ett_fcels;
133 static gint ett_fcels_lsrjt;
134 static gint ett_fcels_acc;
135 static gint ett_fcels_logi;
136 static gint ett_fcels_logi_cmnsvc;
137 static gint ett_fcels_logi_clssvc;
138 static gint ett_fcels_logo;
139 static gint ett_fcels_abtx;
140 static gint ett_fcels_rsi;
141 static gint ett_fcels_rrq;
142 static gint ett_fcels_prli;
143 static gint ett_fcels_prli_svcpg;
144 static gint ett_fcels_adisc;
145 static gint ett_fcels_farp;
146 static gint ett_fcels_rps;
147 static gint ett_fcels_rpl;
148 static gint ett_fcels_rplpb;
149 static gint ett_fcels_fan;
150 static gint ett_fcels_rscn;
151 static gint ett_fcels_rscn_rec;
152 static gint ett_fcels_scr;
153 static gint ett_fcels_rnft;
154 static gint ett_fcels_rnft_fc4;
155 static gint ett_fcels_lsts;
156 static gint ett_fcels_rnid;
157 static gint ett_fcels_rlir;
158 static gint ett_fcels_lirr;
159 static gint ett_fcels_srl;
160 static gint ett_fcels_rpsc;
162 static const value_string fc_prli_fc4_val[] = {
163 {FC_TYPE_SCSI , "FCP"},
164 {FC_TYPE_IP , "IP/FC"},
165 {FC_TYPE_LLCSNAP , "LLC_SNAP"},
166 {FC_TYPE_ELS , "Ext Link Svc"},
167 {FC_TYPE_FCCT , "FC_CT"},
168 {FC_TYPE_SWILS , "SW_ILS"},
170 {FC_TYPE_SNMP , "SNMP"},
171 {FC_TYPE_CMNSVC , "Common to all FC-4 Types"},
175 typedef struct _fcels_conv_key {
179 typedef struct _fcels_conv_data {
183 GHashTable *fcels_req_hash = NULL;
184 GMemChunk *fcels_req_keys = NULL;
185 GMemChunk *fcels_req_vals = NULL;
186 guint32 fcels_init_count = 25;
188 static dissector_handle_t data_handle, fcsp_handle;
194 fcels_equal(gconstpointer v, gconstpointer w)
196 fcels_conv_key_t *v1 = (fcels_conv_key_t *)v;
197 fcels_conv_key_t *v2 = (fcels_conv_key_t *)w;
199 return (v1->conv_idx == v2->conv_idx);
203 fcels_hash (gconstpointer v)
205 fcels_conv_key_t *key = (fcels_conv_key_t *)v;
214 * Protocol initialization
217 fcels_init_protocol(void)
220 g_mem_chunk_destroy(fcels_req_keys);
222 g_mem_chunk_destroy(fcels_req_vals);
224 g_hash_table_destroy(fcels_req_hash);
226 fcels_req_hash = g_hash_table_new(fcels_hash, fcels_equal);
227 fcels_req_keys = g_mem_chunk_new ("fcels_req_keys",
228 sizeof(fcels_conv_key_t),
230 sizeof(fcels_conv_key_t),
232 fcels_req_vals = g_mem_chunk_new ("fcels_req_vals",
233 sizeof(fcels_conv_data_t),
235 sizeof(fcels_conv_data_t),
240 construct_cmnsvc_string (guint16 flag, gchar *flagstr, guint8 opcode)
248 strcpy (flagstr, "Cont. Incr. Offset Supported");
253 sprintf (&flagstr[stroff], "%sRRO Supported", punc);
259 sprintf (flagstr, "%sValid Vendor Version Level", punc);
265 sprintf (&flagstr[stroff], "%sAlt B2B Credit Mgmt", punc);
270 sprintf (&flagstr[stroff], "%sNormal B2B Credit Mgmt", punc);
275 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
277 strcpy (&flagstr[stroff], ", E_D_TOV Resolution in ns");
280 strcpy (&flagstr[stroff], ", E_D_TOV Resolution in ms");
285 strcpy (&flagstr[stroff], ", Simplex Dedicated Conn Supported");
291 strcpy (&flagstr[stroff], ", Multicast Supported");
296 strcpy (&flagstr[stroff], ", Broadcast Supported");
301 strcpy (&flagstr[stroff], ", Security Bit");
306 strcpy (&flagstr[stroff], ", Clk Sync Prim Capable");
310 strcpy (&flagstr[stroff], ", DHD Capable");
314 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
316 strcpy (&flagstr[stroff], ", Cont. Incr SEQCNT rules");
320 strcpy (&flagstr[stroff], ", Normal SEQCNT rules");
326 sprintf (&flagstr[stroff], ", Payload Len=256 bytes");
329 sprintf (&flagstr[stroff], ", Payload Len=116 bytes");
333 /* The next 3 routines decode only Class 2 & Class 3 relevant bits */
335 construct_clssvc_string (guint16 flag, gchar *flagstr, guint8 opcode)
339 if (!(flag & 0x8000)) {
340 strcpy (flagstr, "Class Not Supported");
344 if ((opcode == FC_ELS_FLOGI) || (opcode == FC_ELS_FDISC)) {
346 strcpy (flagstr, "Seq Delivery Requested");
350 strcpy (flagstr, "Out of Order Delivery Requested");
356 strcpy (&flagstr[stroff], ", Priority/preemption supported");
360 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
362 strcpy (&flagstr[stroff], "Non-zero CS_CTL Tolerated");
365 strcpy (&flagstr[stroff], "Non-zero CS_CTL Maybe Tolerated");
371 construct_initctl_string (guint16 flag, gchar *flagstr, guint8 opcode)
375 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
376 switch ((flag & 0x3000)) {
378 strcpy (flagstr, "Initial P_A Not Supported");
382 strcpy (flagstr, "Initial P_A Supported");
386 strcpy (flagstr, "Initial P_A Required & Supported");
392 strcpy (&flagstr[stroff], ", ACK0 Capable");
397 strcpy (&flagstr[stroff], ", ACK Generation Assistance Avail");
401 strcpy (&flagstr[stroff], ", Clock Sync ELS Supported");
406 strcpy (&flagstr[stroff], "Clock Sync ELS Supported");
412 construct_rcptctl_string (guint16 flag, gchar *flagstr, guint8 opcode)
419 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
421 strcpy (flagstr, "ACK_0 Supported");
425 strcpy (flagstr, "ACK_0 Not Supported");
430 strcpy (&flagstr[stroff], ", X_ID Interlock Reqd");
434 switch (flag & 0x1800) {
436 strcpy (&flagstr[stroff], ", Error Policy: Discard Policy only");
440 strcpy (&flagstr[stroff], ", Error Policy: Both discard and process policies supported");
444 strcpy (&flagstr[stroff], ", Error Policy: Reserved");
448 strcpy (&flagstr[stroff], ", Error Policy: Reserved");
453 switch (flag & 0x0030) {
455 strcpy (&flagstr[stroff], ", 1 Category/Seq");
459 strcpy (&flagstr[stroff], ", 2 Categories/Seq");
463 strcpy (&flagstr[stroff], ", More than 2 Categories/Seq");
469 strcpy (&flagstr[stroff], ", Clk Sync ELS Supported");
474 strcpy (&flagstr[stroff], "Clk Sync ELS Supported");
481 dissect_fcels_logi (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
482 proto_item *ti, guint8 opcode)
484 /* Set up structures needed to add the protocol subtree and manage it */
488 proto_tree *logi_tree, *cmnsvc_tree;
494 logi_tree = proto_item_add_subtree (ti, ett_fcels_logi);
495 proto_tree_add_item (logi_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
497 subti = proto_tree_add_text (logi_tree, tvb, offset+4, 16,
498 "Common Svc Parameters");
499 cmnsvc_tree = proto_item_add_subtree (subti, ett_fcels_logi_cmnsvc);
500 proto_tree_add_item (cmnsvc_tree, hf_fcels_b2b, tvb, offset+6, 2, FALSE);
501 flag = tvb_get_ntohs (tvb, offset+8);
507 construct_cmnsvc_string (flag, flagstr, opcode);
508 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_cmnfeatures, tvb,
510 "Common Svc Parameters: 0x%x (%s)",
513 proto_tree_add_item (cmnsvc_tree, hf_fcels_bbscnum, tvb, offset+10, 1, FALSE);
514 proto_tree_add_item (cmnsvc_tree, hf_fcels_rcvsize, tvb, offset+10, 2, FALSE);
515 proto_tree_add_item (cmnsvc_tree, hf_fcels_maxconseq, tvb, offset+12, 2, FALSE);
516 proto_tree_add_item (cmnsvc_tree, hf_fcels_reloffset, tvb, offset+14, 2, FALSE);
517 proto_tree_add_item (cmnsvc_tree, hf_fcels_edtov, tvb, offset+16, 4, FALSE);
518 proto_tree_add_string (cmnsvc_tree, hf_fcels_npname, tvb, offset+20, 8,
519 fcwwn_to_str (tvb_get_ptr (tvb, offset+20, 8)));
520 proto_tree_add_string (cmnsvc_tree, hf_fcels_fnname, tvb, offset+28, 8,
521 fcwwn_to_str (tvb_get_ptr (tvb, offset+28, 8)));
523 /* Add subtree for class paramters */
525 for (class = 1; class < 5; class++) {
526 subti = proto_tree_add_text (logi_tree, tvb, offset, 16,
527 "Class %d Svc Parameters", class);
528 cmnsvc_tree = proto_item_add_subtree (subti, ett_fcels_logi_cmnsvc);
530 flag = tvb_get_ntohs (tvb, offset);
531 construct_clssvc_string (flag, flagstr, opcode);
532 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_clsflags, tvb,
534 "Service Options: 0x%x(%s)", flag,
537 flag = tvb_get_ntohs (tvb, offset+2);
538 construct_initctl_string (flag, flagstr, opcode);
539 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_initctl, tvb,
541 "Initiator Control: 0x%x(%s)", flag,
544 flag = tvb_get_ntohs (tvb, offset+4);
545 construct_rcptctl_string (flag, flagstr, opcode);
546 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_initctl, tvb,
548 "Recipient Control: 0x%x(%s)", flag,
551 proto_tree_add_item (cmnsvc_tree, hf_fcels_clsrcvsize, tvb,
553 proto_tree_add_item (cmnsvc_tree, hf_fcels_conseq, tvb,
555 proto_tree_add_item (cmnsvc_tree, hf_fcels_e2e, tvb,
556 offset+10, 2, FALSE);
557 proto_tree_add_item (cmnsvc_tree, hf_fcels_openseq, tvb,
558 offset+12, 2, FALSE);
562 proto_tree_add_item (logi_tree, hf_fcels_vendorvers, tvb, offset, 16, FALSE);
564 proto_tree_add_item (logi_tree, hf_fcels_svcavail, tvb, offset+32, 8, FALSE);
570 dissect_fcels_plogi (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
571 guint8 isreq _U_, proto_item *ti)
573 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_PLOGI);
577 dissect_fcels_flogi (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
578 guint8 isreq _U_, proto_item *ti)
580 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_FLOGI);
584 dissect_fcels_logout (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
585 guint8 isreq, proto_item *ti)
587 /* Set up structures needed to add the protocol subtree and manage it */
588 int offset = 5; /* bypass opcode+rsvd field */
589 proto_tree *logo_tree;
592 logo_tree = proto_item_add_subtree (ti, ett_fcels_logo);
594 proto_tree_add_item (logo_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
597 /* Accept has no payload */
601 proto_tree_add_string (logo_tree, hf_fcels_nportid, tvb, offset, 3,
602 fc_to_str (tvb_get_ptr (tvb, offset, 3)));
603 proto_tree_add_string (logo_tree, hf_fcels_npname, tvb, offset+3, 6,
604 fcwwn_to_str (tvb_get_ptr (tvb, offset+3, 6)));
609 dissect_fcels_abtx (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
610 guint8 isreq, proto_item *ti)
612 /* Set up structures needed to add the protocol subtree and manage it */
614 proto_tree *abtx_tree;
617 abtx_tree = proto_item_add_subtree (ti, ett_fcels_abtx);
619 proto_tree_add_item (abtx_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
625 proto_tree_add_text (abtx_tree, tvb, offset+4, 1,
626 "Recovery Qualifier Status: 0x%x",
627 tvb_get_guint8 (tvb, offset+4));
628 proto_tree_add_string (abtx_tree, hf_fcels_nportid, tvb, offset+5, 3,
629 fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
630 proto_tree_add_item (abtx_tree, hf_fcels_oxid, tvb, offset+8, 2, FALSE);
631 proto_tree_add_item (abtx_tree, hf_fcels_rxid, tvb, offset+10, 2, FALSE);
636 dissect_fcels_rsi (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
637 guint8 isreq, proto_item *ti)
639 /* Set up structures needed to add the protocol subtree and manage it */
641 proto_tree *rsi_tree;
644 rsi_tree = proto_item_add_subtree (ti, ett_fcels_rsi);
646 proto_tree_add_item (rsi_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
650 proto_tree_add_item (rsi_tree, hf_fcels_recovqual, tvb, offset, 1, FALSE);
651 proto_tree_add_string (rsi_tree, hf_fcels_nportid, tvb, offset+1, 3,
652 fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
653 proto_tree_add_item (rsi_tree, hf_fcels_rxid, tvb, offset+4, 2, FALSE);
654 proto_tree_add_item (rsi_tree, hf_fcels_oxid, tvb, offset+6, 2, FALSE);
659 dissect_fcels_rrq (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
660 guint8 isreq, proto_item *ti)
662 /* Set up structures needed to add the protocol subtree and manage it */
664 proto_tree *rrq_tree;
667 rrq_tree = proto_item_add_subtree (ti, ett_fcels_rrq);
669 proto_tree_add_item (rrq_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
673 proto_tree_add_string (rrq_tree, hf_fcels_nportid, tvb, offset+5, 3,
674 fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
675 proto_tree_add_item (rrq_tree, hf_fcels_oxid, tvb, offset+8, 2, FALSE);
676 proto_tree_add_item (rrq_tree, hf_fcels_rxid, tvb, offset+10, 2, FALSE);
681 dissect_fcels_pdisc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
682 guint8 isreq _U_, proto_item *ti)
684 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_PDISC);
688 dissect_fcels_fdisc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
689 guint8 isreq _U_, proto_item *ti)
691 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_FDISC);
695 dissect_fcels_adisc (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
696 guint8 isreq _U_, proto_item *ti)
698 /* Set up structures needed to add the protocol subtree and manage it */
700 proto_tree *adisc_tree;
703 adisc_tree = proto_item_add_subtree (ti, ett_fcels_adisc);
705 proto_tree_add_item (adisc_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
707 proto_tree_add_string (adisc_tree, hf_fcels_hardaddr, tvb, offset, 3,
708 fc_to_str (tvb_get_ptr (tvb, offset, 3)));
709 proto_tree_add_string (adisc_tree, hf_fcels_npname, tvb, offset+3, 8,
710 fcwwn_to_str (tvb_get_ptr (tvb, offset+3, 8)));
711 proto_tree_add_string (adisc_tree, hf_fcels_fnname, tvb, offset+11, 8,
712 fcwwn_to_str (tvb_get_ptr (tvb, offset+11, 8)));
713 proto_tree_add_string (adisc_tree, hf_fcels_nportid, tvb, offset+20, 3,
714 fc_to_str (tvb_get_ptr (tvb, offset+20, 3)));
720 dissect_fcels_farp (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
724 proto_tree *farp_tree;
727 farp_tree = proto_item_add_subtree (ti, ett_fcels_farp);
729 proto_tree_add_item (farp_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
731 proto_tree_add_item (farp_tree, hf_fcels_farp_matchcodept,
732 tvb, offset, 1, FALSE);
733 proto_tree_add_string (farp_tree, hf_fcels_nportid, tvb, offset+1,
734 3, fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
735 proto_tree_add_item (farp_tree, hf_fcels_farp_respaction, tvb,
737 proto_tree_add_string (farp_tree, hf_fcels_resportid, tvb, offset+5,
738 3, fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
739 proto_tree_add_string (farp_tree, hf_fcels_npname, tvb, offset+8,
740 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
741 proto_tree_add_string (farp_tree, hf_fcels_fnname, tvb, offset+16,
742 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+16, 8)));
743 proto_tree_add_string (farp_tree, hf_fcels_respname, tvb, offset+24,
744 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+24, 8)));
745 proto_tree_add_string (farp_tree, hf_fcels_respnname, tvb, offset+32,
746 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+32, 8)));
747 proto_tree_add_item (farp_tree, hf_fcels_reqipaddr, tvb, offset+40,
749 proto_tree_add_item (farp_tree, hf_fcels_respipaddr, tvb, offset+56,
755 dissect_fcels_farp_req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
756 guint8 isreq _U_, proto_item *ti)
758 dissect_fcels_farp (tvb, pinfo, tree, ti);
762 dissect_fcels_farp_rply (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
763 guint8 isreq _U_, proto_item *ti)
765 dissect_fcels_farp (tvb, pinfo, tree, ti);
769 dissect_fcels_rps (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
770 guint8 isreq, proto_item *ti)
772 /* Set up structures needed to add the protocol subtree and manage it */
775 proto_tree *rps_tree;
777 flag = tvb_get_guint8 (tvb, offset);
780 rps_tree = proto_item_add_subtree (ti, ett_fcels_rps);
783 proto_tree_add_item (rps_tree, hf_fcels_rps_flag, tvb, offset, 1, FALSE);
785 proto_tree_add_item (rps_tree, hf_fcels_opcode, tvb, offset-3, 1, FALSE);
788 proto_tree_add_string (rps_tree, hf_fcels_npname, tvb, offset+1,
789 8, fcwwn_to_str (tvb_get_ptr (tvb,
793 else if (flag & 0x1) {
794 proto_tree_add_item (rps_tree, hf_fcels_rps_portnum, tvb,
799 proto_tree_add_item (rps_tree, hf_fcels_rps_flag, tvb, offset, 1, FALSE);
800 proto_tree_add_item (rps_tree, hf_fcels_rps_portstatus, tvb,
802 /* Next 6 fields are from Link Error Status Block (LESB) */
803 proto_tree_add_text (rps_tree, tvb, offset+5, 4,
804 "Link Failure Count: %u",
805 tvb_get_ntohl (tvb, offset+5));
806 proto_tree_add_text (rps_tree, tvb, offset+9, 4,
807 "Loss of Sync Count: %u",
808 tvb_get_ntohl (tvb, offset+9));
809 proto_tree_add_text (rps_tree, tvb, offset+13, 4,
810 "Loss of Signal Count: %u",
811 tvb_get_ntohl (tvb, offset+13));
812 proto_tree_add_text (rps_tree, tvb, offset+17, 4,
813 "Primitive Seq Protocol Err: %u",
814 tvb_get_ntohl (tvb, offset+17));
815 proto_tree_add_text (rps_tree, tvb, offset+21, 4,
816 "Invalid Xmission Word: %u",
817 tvb_get_ntohl (tvb, offset+21));
818 proto_tree_add_text (rps_tree, tvb, offset+25, 4,
819 "Invalid CRC Count: %u",
820 tvb_get_ntohl (tvb, offset+25));
822 /* Next 6 fields are from L_Port Extension field */
823 proto_tree_add_text (rps_tree, tvb, offset+31, 2,
824 "L_Port Status: 0x%x",
825 tvb_get_ntohs (tvb, offset+31));
826 proto_tree_add_text (rps_tree, tvb, offset+36, 1,
828 tvb_get_guint8 (tvb, offset+36));
829 proto_tree_add_text (rps_tree, tvb, offset+37, 4,
830 "LIP F7 Initiated Count: %u",
831 tvb_get_ntohl (tvb, offset+37));
832 proto_tree_add_text (rps_tree, tvb, offset+41, 4,
833 "LIP F7 Received Count: %u",
834 tvb_get_ntohl (tvb, offset+41));
835 proto_tree_add_text (rps_tree, tvb, offset+45, 4,
836 "LIP F8 Initiated Count: %u",
837 tvb_get_ntohl (tvb, offset+45));
838 proto_tree_add_text (rps_tree, tvb, offset+49, 4,
839 "LIP F8 Received Count: %u",
840 tvb_get_ntohl (tvb, offset+49));
841 proto_tree_add_text (rps_tree, tvb, offset+53, 4,
842 "LIP Reset Initiated Count: %u",
843 tvb_get_ntohl (tvb, offset+53));
844 proto_tree_add_text (rps_tree, tvb, offset+57, 4,
845 "LIP Reset Received Count: %u",
846 tvb_get_ntohl (tvb, offset+57));
853 dissect_fcels_rpl (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
854 guint8 isreq, proto_item *ti)
856 /* Set up structures needed to add the protocol subtree and manage it */
858 proto_tree *rpl_tree, *pb_tree;
863 rpl_tree = proto_item_add_subtree (ti, ett_fcels_rpl);
865 proto_tree_add_item (rpl_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
868 proto_tree_add_text (rpl_tree, tvb, offset+6, 2,
870 tvb_get_ntohs (tvb, offset+6));
871 proto_tree_add_text (rpl_tree, tvb, offset+9, 3,
873 tvb_get_ntoh24 (tvb, offset+9));
876 /* Reply consists of a header and a number of port blocks */
877 proto_tree_add_text (rpl_tree, tvb, offset+2, 2,
878 "Payload Length: %u",
879 tvb_get_ntohs (tvb, offset+2));
880 proto_tree_add_text (rpl_tree, tvb, offset+5, 3,
882 tvb_get_ntoh24 (tvb, offset+5));
883 proto_tree_add_text (rpl_tree, tvb, offset+9, 3,
884 "Index of I Port Block: %u",
885 tvb_get_ntoh24 (tvb, offset+9));
887 /* The following loop is for dissecting the port blocks */
888 for (loop = tvb_get_ntoh24 (tvb, 5); loop > 0; loop--) {
889 subti = proto_tree_add_text (rpl_tree, tvb, offset+12, 16,
890 "Port Block %u", loop);
891 pb_tree = proto_item_add_subtree (subti, ett_fcels_rplpb);
893 proto_tree_add_text (pb_tree, tvb, offset, 4,
894 "Physical Port #: %u",
895 tvb_get_ntohl (tvb, offset));
896 proto_tree_add_text (pb_tree, tvb, offset+5, 3,
897 "Port Identifier: %s",
898 fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
899 proto_tree_add_text (pb_tree, tvb, offset+8, 8,
901 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
909 dissect_fcels_fan (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
910 guint8 isreq _U_, proto_item *ti)
912 /* Set up structures needed to add the protocol subtree and manage it */
914 proto_tree *fan_tree;
917 fan_tree = proto_item_add_subtree (ti, ett_fcels_fan);
919 proto_tree_add_item (fan_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
921 proto_tree_add_string (fan_tree, hf_fcels_fabricaddr, tvb, offset, 3,
922 fc_to_str (tvb_get_ptr (tvb, offset, 3)));
923 proto_tree_add_string (fan_tree, hf_fcels_fabricpname, tvb, offset+3,
924 8, fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
925 proto_tree_add_string (fan_tree, hf_fcels_fnname, tvb, offset+11, 8,
926 fcwwn_to_str (tvb_get_ptr (tvb, offset+11, 8)));
931 dissect_fcels_rscn (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
932 guint8 isreq, proto_item *ti)
934 /* Set up structures needed to add the protocol subtree and manage it */
936 proto_tree *rscn_tree, *rectree;
941 rscn_tree = proto_item_add_subtree (ti, ett_fcels_rscn);
943 proto_tree_add_item (rscn_tree, hf_fcels_opcode, tvb, offset-1, 1, FALSE);
947 proto_tree_add_text (rscn_tree, tvb, offset, 1,
948 "Page Len: %u", tvb_get_guint8 (tvb, offset));
949 plen = tvb_get_ntohs (tvb, offset+1);
950 proto_tree_add_text (rscn_tree, tvb, offset+1, 2,
951 "Payload Len: %u", plen);
952 numrec = (plen - 4)/4;
955 for (i = 0; i < numrec; i++) {
956 subti = proto_tree_add_text (rscn_tree, tvb, offset, 4,
957 "Affected N_Port Page %u", i);
958 rectree = proto_item_add_subtree (subti, ett_fcels_rscn_rec);
960 proto_tree_add_item (rectree, hf_fcels_rscn_evqual, tvb, offset,
962 proto_tree_add_item (rectree, hf_fcels_rscn_addrfmt, tvb, offset,
964 proto_tree_add_item (rectree, hf_fcels_rscn_domain, tvb, offset+1,
966 proto_tree_add_item (rectree, hf_fcels_rscn_area, tvb, offset+2,
968 proto_tree_add_item (rectree, hf_fcels_rscn_port, tvb, offset+3,
976 dissect_fcels_scr (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
977 guint8 isreq, proto_item *ti)
979 /* Set up structures needed to add the protocol subtree and manage it */
981 proto_tree *scr_tree;
984 scr_tree = proto_item_add_subtree (ti, ett_fcels_scr);
985 proto_tree_add_item (scr_tree, hf_fcels_opcode, tvb, offset-7, 1, FALSE);
987 proto_tree_add_item (scr_tree, hf_fcels_scrregn, tvb, offset, 1, FALSE);
992 dissect_fcels_rnft (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
993 guint8 isreq, proto_item *ti)
997 proto_tree *rnft_tree, *fc4_tree;
1001 rnft_tree = proto_item_add_subtree (ti, ett_fcels_rnft);
1003 proto_tree_add_item (rnft_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
1006 proto_tree_add_text (rnft_tree, tvb, offset+2, 2,
1007 "Max Size: %u", tvb_get_ntohs (tvb, offset+2));
1008 proto_tree_add_text (rnft_tree, tvb, offset+7, 1,
1009 "Index: %u", tvb_get_guint8 (tvb, offset+7));
1012 proto_tree_add_text (rnft_tree, tvb, offset+2, 2,
1014 tvb_get_ntohs (tvb, offset+2));
1015 numrec = tvb_get_guint8 (tvb, offset+5);
1016 proto_tree_add_text (rnft_tree, tvb, offset+5, 1,
1017 "List Length: %u", numrec);
1018 proto_tree_add_text (rnft_tree, tvb, offset+7, 1,
1019 "Index of First Rec in List: %u",
1020 tvb_get_guint8 (tvb, offset+7));
1022 for (i = 0; i < numrec; i++) {
1023 subti = proto_tree_add_text (rnft_tree, tvb, offset, 4,
1024 "FC-4 Entry #%u", i);
1025 fc4_tree = proto_item_add_subtree (subti, ett_fcels_rnft_fc4);
1027 proto_tree_add_item (fc4_tree, hf_fcels_rnft_fc4type, tvb,
1029 proto_tree_add_text (fc4_tree, tvb, offset+1, 3,
1030 "FC-4 Qualifier 0x%x",
1031 tvb_get_ntoh24 (tvb, offset+1));
1039 dissect_fcels_lsts (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1040 guint8 isreq, proto_item *ti)
1042 /* Set up structures needed to add the protocol subtree and manage it */
1044 proto_tree *lsts_tree;
1047 lsts_tree = proto_item_add_subtree (ti, ett_fcels_lsts);
1049 proto_tree_add_item (lsts_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
1051 /* In case of LSTS, the reply has the meat */
1054 proto_tree_add_item (lsts_tree, hf_fcels_failedrcvr, tvb, offset, 1, FALSE);
1055 proto_tree_add_item (lsts_tree, hf_fcels_flacompliance, tvb, offset+1,
1057 proto_tree_add_item (lsts_tree, hf_fcels_loopstate, tvb, offset+2, 1, FALSE);
1058 proto_tree_add_item (lsts_tree, hf_fcels_publicloop_bmap, tvb, offset+3,
1060 proto_tree_add_item (lsts_tree, hf_fcels_pvtloop_bmap, tvb, offset+19,
1062 proto_tree_add_item (lsts_tree, hf_fcels_alpa_map, tvb, offset+35,
1068 dissect_fcels_prlilo_payload (tvbuff_t *tvb, packet_info *pinfo _U_,
1069 guint8 isreq, proto_item *ti, guint8 opcode)
1074 proto_tree *prli_tree, *svcpg_tree;
1075 int num_svcpg, payload_len, i, flag;
1079 /* We're assuming that we're invoked only if tree is not NULL i.e.
1080 * we don't do the usual "if (tree)" check here, the caller must.
1082 prli_tree = proto_item_add_subtree (ti, ett_fcels_prli);
1084 proto_tree_add_item (prli_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
1086 proto_tree_add_text (prli_tree, tvb, offset+1, 1,
1088 tvb_get_guint8 (tvb, offset+1));
1089 payload_len = tvb_get_ntohs (tvb, offset+2);
1090 proto_tree_add_text (prli_tree, tvb, offset+2, 2,
1091 "Payload Length: %u", payload_len);
1092 num_svcpg = payload_len/16;
1095 for (i = 0; i < num_svcpg; i++) {
1096 subti = proto_tree_add_text (prli_tree, tvb, offset, 16,
1097 "Service Parameter Page %u", i);
1098 svcpg_tree = proto_item_add_subtree (subti, ett_fcels_prli_svcpg);
1100 type = tvb_get_guint8 (tvb, offset);
1101 proto_tree_add_text (svcpg_tree, tvb, offset, 1,
1104 fc_prli_fc4_val, "0x%x"));
1105 proto_tree_add_text (svcpg_tree, tvb, offset+1, 1,
1106 "TYPE Code Extension: %u",
1107 tvb_get_guint8 (tvb, offset+1));
1109 flag = tvb_get_guint8 (tvb, offset+2);
1112 if (opcode != FC_ELS_TPRLO) {
1114 strcpy (flagstr, "Orig PA Valid, ");
1118 strcpy (&flagstr[stroff], "Resp PA Valid, ");
1122 if (opcode == FC_ELS_PRLI) {
1125 strcpy (&flagstr[stroff], "Image Pair Estd., ");
1129 strcpy (&flagstr[stroff], "Image Pair Not Estd., ");
1135 strcpy (&flagstr[stroff], "Est Image Pair & Exchg Svc Param, ");
1139 strcpy (&flagstr[stroff], "Exchange Svc Param Only, ");
1145 else { /* Assuming opcode is TPRLO */
1147 strcpy (flagstr, "3rd Party Orig PA Valid, ");
1151 strcpy (&flagstr[stroff], "Resp PA Valid, ");
1155 strcpy (&flagstr[stroff], "3rd Party N_Port Valid, ");
1159 strcpy (&flagstr[stroff], "Global PRLO, ");
1164 proto_tree_add_text (svcpg_tree, tvb, offset+2, 1,
1165 "Flags: %s", flagstr);
1166 if (!isreq && (opcode != FC_ELS_TPRLO)) {
1167 /* This is valid only for ACC */
1168 proto_tree_add_text (svcpg_tree, tvb, offset+2, 1,
1169 "Response Code: 0x%x",
1170 (tvb_get_guint8 (tvb, offset+2) & 0x0F));
1172 if (opcode != FC_ELS_TPRLO) {
1173 proto_tree_add_text (svcpg_tree, tvb, offset+4, 4,
1174 "Originator PA: 0x%x",
1175 tvb_get_ntohl (tvb, offset+4));
1178 proto_tree_add_text (svcpg_tree, tvb, offset+4, 4,
1179 "3rd Party Originator PA: 0x%x",
1180 tvb_get_ntohl (tvb, offset+4));
1182 proto_tree_add_text (svcpg_tree, tvb, offset+8, 4,
1183 "Responder PA: 0x%x",
1184 tvb_get_ntohl (tvb, offset+8));
1186 if (type == FC_TYPE_SCSI) {
1187 flag = tvb_get_ntohs (tvb, offset+14);
1191 if (flag & 0x2000) {
1193 strcpy (flagstr, "Task Retry Ident Req, ");
1197 strcpy (flagstr, "Task Retry Ident Acc, ");
1201 if (flag & 0x1000) {
1202 strcpy (&flagstr[stroff], "Retry Possible, ");
1205 if (flag & 0x0080) {
1206 strcpy (&flagstr[stroff], "Confirmed Comp, ");
1209 if (flag & 0x0040) {
1210 strcpy (&flagstr[stroff], "Data Overlay, ");
1213 if (flag & 0x0020) {
1214 strcpy (&flagstr[stroff], "Initiator, ");
1217 if (flag & 0x0010) {
1218 strcpy (&flagstr[stroff], "Target, ");
1221 if (flag & 0x0002) {
1222 strcpy (&flagstr[stroff], "Rd Xfer_Rdy Dis, ");
1225 if (flag & 0x0001) {
1226 strcpy (&flagstr[stroff], "Wr Xfer_Rdy Dis");
1229 proto_tree_add_text (svcpg_tree, tvb, offset+12, 4,
1230 "FCP Flags: 0x%x (%s)", flag,
1233 else if ((opcode == FC_ELS_PRLI) && !isreq) {
1234 proto_tree_add_text (svcpg_tree, tvb, offset+12, 4,
1235 "Service Parameter Response: 0x%x",
1236 tvb_get_ntohl (tvb, offset+12));
1238 else if (opcode == FC_ELS_TPRLO) {
1239 proto_tree_add_text (svcpg_tree, tvb, offset+13, 3,
1240 "3rd Party N_Port Id: %s",
1241 fc_to_str (tvb_get_ptr (tvb, offset+13, 3)));
1247 dissect_fcels_prli (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1248 guint8 isreq, proto_item *ti)
1251 dissect_fcels_prlilo_payload (tvb, pinfo, isreq, ti, FC_ELS_PRLI);
1256 dissect_fcels_prlo (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1257 guint8 isreq, proto_item *ti)
1259 /* Set up structures needed to add the protocol subtree and manage it */
1261 dissect_fcels_prlilo_payload (tvb, pinfo, isreq, ti, FC_ELS_PRLO);
1266 dissect_fcels_tprlo (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1267 guint8 isreq, proto_item *ti)
1269 /* Set up structures needed to add the protocol subtree and manage it */
1272 dissect_fcels_prlilo_payload (tvb, pinfo, isreq, ti, FC_ELS_TPRLO);
1277 dissect_fcels_lirr (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1278 guint8 isreq _U_, proto_item *ti)
1280 /* Set up structures needed to add the protocol subtree and manage it */
1282 proto_tree *lirr_tree;
1286 lirr_tree = proto_item_add_subtree (ti, ett_fcels_lirr);
1288 proto_tree_add_item (lirr_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
1290 proto_tree_add_text (lirr_tree, tvb, offset, 1,
1291 "Regn. Function: %s",
1292 val_to_str (tvb_get_guint8 (tvb, offset),
1293 fc_els_lirr_regfunc_val,
1294 "Reserved (0x%x)"));
1295 lirr_fmt = tvb_get_guint8 (tvb, offset+1);
1297 /* This scheme is resorted to because the value 0 has a string in
1298 * the value_string that is not what we want displayed here.
1300 proto_tree_add_text (lirr_tree, tvb, offset, 1,
1301 "Regn. Format: Common Format");
1304 proto_tree_add_text (lirr_tree, tvb, offset, 1,
1306 val_to_str (lirr_fmt, fc_fc4_val, "0x%x"));
1312 dissect_fcels_srl (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1313 guint8 isreq, proto_item *ti)
1315 /* Set up structures needed to add the protocol subtree and manage it */
1318 proto_tree *srl_tree;
1321 srl_tree = proto_item_add_subtree (ti, ett_fcels_srl);
1323 proto_tree_add_item (srl_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
1327 flag = tvb_get_guint8 (tvb, offset);
1329 proto_tree_add_text (srl_tree, tvb, offset, 1,
1330 "Flag: Scan only specified FL Port");
1333 proto_tree_add_text (srl_tree, tvb, offset, 1,
1334 "Flag: Scan all loops in domain");
1336 proto_tree_add_text (srl_tree, tvb, offset+1, 3,
1338 fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
1343 dissect_fcels_rpsc (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1344 guint8 isreq, proto_item *ti)
1346 /* Set up structures needed to add the protocol subtree and manage it */
1348 int num_entries, i, cap;
1349 gchar speed_str[40];
1351 proto_tree *rpsc_tree;
1354 rpsc_tree = proto_item_add_subtree (ti, ett_fcels_rpsc);
1356 proto_tree_add_item (rpsc_tree, hf_fcels_opcode, tvb, offset-2, 1, FALSE);
1360 num_entries = tvb_get_ntohs (tvb, offset);
1361 proto_tree_add_text (rpsc_tree, tvb, offset, 2,
1362 "Number of Entries: %u", num_entries);
1364 for (i = 0; i < num_entries; i++) {
1365 cap = tvb_get_ntohs (tvb, offset);
1366 speed_str[0] = '\0';
1369 strcpy (speed_str, "1,");
1373 strcpy (speed_str, "2,");
1377 strcpy (speed_str, "4,");
1381 strcpy (speed_str, "10");
1384 strcpy (&speed_str[stroff], "Gb");
1385 proto_tree_add_text (rpsc_tree, tvb, offset, 2,
1386 "Port Speed Capabilities (Port %u): %s", i,
1388 cap = tvb_get_ntohs (tvb, offset+2);
1389 proto_tree_add_text (rpsc_tree, tvb, offset+2, 2,
1390 "Port Oper Speed: %s",
1391 val_to_str (cap, fc_els_portspeed_val,
1398 dissect_fcels_rnid (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1399 guint8 isreq, proto_item *ti)
1401 /* Set up structures needed to add the protocol subtree and manage it */
1404 proto_tree *rnid_tree;
1407 rnid_tree = proto_item_add_subtree (ti, ett_fcels_rnid);
1409 proto_tree_add_item (rnid_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
1411 proto_tree_add_item (rnid_tree, hf_fcels_nodeidfmt, tvb, offset+4,
1415 /* We only decode responses to nodeid fmt DF */
1416 proto_tree_add_item (rnid_tree, hf_fcels_nodeidfmt, tvb, offset+4,
1418 clen = tvb_get_guint8 (tvb, offset+5);
1419 proto_tree_add_text (rnid_tree, tvb, offset+5, 1,
1420 "Common Identification Data Length: %u", clen);
1421 slen = tvb_get_guint8 (tvb, offset+7);
1422 proto_tree_add_item (rnid_tree, hf_fcels_spidlen, tvb, offset+7,
1425 proto_tree_add_string (rnid_tree, hf_fcels_npname, tvb,
1427 fcwwn_to_str (tvb_get_ptr (tvb, offset+8,
1429 proto_tree_add_string (rnid_tree, hf_fcels_fnname, tvb,
1431 fcwwn_to_str (tvb_get_ptr (tvb,
1435 if (tvb_get_guint8 (tvb, offset+4) == 0xDF) {
1436 /* Decode the Specific Node ID Format as this is known */
1437 proto_tree_add_item (rnid_tree, hf_fcels_vendoruniq, tvb,
1438 offset+24, 16, FALSE);
1439 proto_tree_add_item (rnid_tree, hf_fcels_asstype, tvb,
1440 offset+40, 4, FALSE);
1441 proto_tree_add_item (rnid_tree, hf_fcels_physport, tvb,
1442 offset+44, 4, FALSE);
1443 proto_tree_add_item (rnid_tree, hf_fcels_attnodes, tvb,
1444 offset+48, 4, FALSE);
1445 proto_tree_add_item (rnid_tree, hf_fcels_nodemgmt, tvb,
1446 offset+52, 1, FALSE);
1447 proto_tree_add_item (rnid_tree, hf_fcels_ipvers, tvb,
1448 offset+53, 1, FALSE);
1449 proto_tree_add_item (rnid_tree, hf_fcels_tcpport, tvb,
1450 offset+54, 2, FALSE);
1451 proto_tree_add_item (rnid_tree, hf_fcels_ip, tvb, offset+56,
1453 proto_tree_add_item (rnid_tree, hf_fcels_vendorsp, tvb,
1454 offset+74, 2, FALSE);
1461 dissect_fcels_rlir (tvbuff_t *tvb _U_, packet_info *pinfo _U_,
1462 proto_tree *tree, guint8 isreq _U_,
1465 /* Set up structures needed to add the protocol subtree and manage it */
1472 dissect_fcels_lsrjt (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1473 guint8 isreq _U_, proto_item *ti)
1475 /* Set up structures needed to add the protocol subtree and manage it */
1477 proto_tree *lsrjt_tree;
1480 lsrjt_tree = proto_item_add_subtree (ti, ett_fcels_lsrjt);
1482 proto_tree_add_item (lsrjt_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
1484 proto_tree_add_item (lsrjt_tree, hf_fcels_rjtcode, tvb, offset++, 1, FALSE);
1485 proto_tree_add_item (lsrjt_tree, hf_fcels_rjtdetcode, tvb, offset++, 1, FALSE);
1486 proto_tree_add_item (lsrjt_tree, hf_fcels_vnduniq, tvb, offset, 1, FALSE);
1491 dissect_fcels (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1494 /* Set up structures needed to add the protocol subtree and manage it */
1495 proto_item *ti = NULL;
1496 proto_tree *acc_tree;
1497 guint8 isreq = FC_ELS_REQ;
1501 conversation_t *conversation;
1502 fcels_conv_data_t *cdata;
1503 fcels_conv_key_t ckey, *req_key;
1508 /* Make entries in Protocol column and Info column on summary display */
1509 if (check_col(pinfo->cinfo, COL_PROTOCOL))
1510 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC ELS");
1512 /* decoding of this is done by each individual opcode handler */
1513 opcode = tvb_get_guint8 (tvb, 0);
1516 ti = proto_tree_add_protocol_format (tree, proto_fcels, tvb, 0,
1517 tvb_length (tvb), "FC ELS");
1520 /* Register conversation in case this is not a response */
1521 if ((opcode != FC_ELS_LSRJT) && (opcode != FC_ELS_ACC)) {
1522 if (opcode == FC_ELS_FLOGI) {
1523 if (pinfo->src.data[2]) {
1524 /* If it is a loop port, we'll need to remember the ALPA */
1528 options = NO_PORT2 | NO_ADDR2;
1534 conversation = find_conversation (&pinfo->dst, &pinfo->src,
1535 pinfo->ptype, pinfo->oxid,
1536 pinfo->rxid, options);
1538 if (!conversation) {
1539 conversation = conversation_new (&pinfo->dst, &pinfo->src,
1540 pinfo->ptype, pinfo->oxid,
1541 pinfo->rxid, options);
1544 ckey.conv_idx = conversation->index;
1546 cdata = (fcels_conv_data_t *)g_hash_table_lookup (fcels_req_hash,
1549 /* Since we never free the memory used by an exchange, this maybe a
1550 * case of another request using the same exchange as a previous
1553 cdata->opcode = opcode;
1556 req_key = g_mem_chunk_alloc (fcels_req_keys);
1557 req_key->conv_idx = conversation->index;
1559 cdata = g_mem_chunk_alloc (fcels_req_vals);
1560 cdata->opcode = opcode;
1562 g_hash_table_insert (fcels_req_hash, req_key, cdata);
1566 isreq = FC_ELS_RPLY;
1569 conversation = find_conversation (&pinfo->dst, &pinfo->src,
1570 pinfo->ptype, pinfo->oxid,
1571 pinfo->rxid, options);
1572 if (!conversation) {
1573 /* FLOGI has two ways to save state: without the src and using just
1574 * the port (ALPA) part of the address. Try both.
1576 addrdata[0] = addrdata[1] = 0;
1577 addrdata[2] = pinfo->dst.data[2];
1578 SET_ADDRESS (&dstaddr, AT_FC, 3, addrdata);
1579 conversation = find_conversation (&dstaddr, &pinfo->src,
1580 pinfo->ptype, pinfo->oxid,
1581 pinfo->rxid, options);
1584 if (!conversation) {
1585 /* Finally check for FLOGI with both NO_PORT2 and NO_ADDR2 set */
1586 options = NO_ADDR2 | NO_PORT2;
1587 conversation = find_conversation (&pinfo->src, &pinfo->dst,
1588 pinfo->ptype, pinfo->oxid,
1589 pinfo->rxid, options);
1590 if (!conversation) {
1591 if (tree && (opcode == FC_ELS_ACC)) {
1592 /* No record of what this accept is for. Can't decode */
1593 acc_tree = proto_item_add_subtree (ti, ett_fcels_acc);
1594 proto_tree_add_text (acc_tree, tvb, offset, tvb_length (tvb),
1595 "No record of Exchange. Unable to decode ACC");
1603 ckey.conv_idx = conversation->index;
1605 cdata = (fcels_conv_data_t *)g_hash_table_lookup (fcels_req_hash, &ckey);
1607 if (cdata != NULL) {
1608 if ((options & NO_ADDR2) && (cdata->opcode != FC_ELS_FLOGI)) {
1609 /* only FLOGI can have this special check */
1610 if (tree && (opcode == FC_ELS_ACC)) {
1611 /* No record of what this accept is for. Can't decode */
1612 acc_tree = proto_item_add_subtree (ti,
1614 proto_tree_add_text (acc_tree, tvb, offset,
1616 "No record of Exchg. Unable to decode ACC");
1620 if (opcode == FC_ELS_ACC)
1621 opcode = cdata->opcode;
1623 failed_opcode = cdata->opcode;
1627 if ((cdata == NULL) && (opcode != FC_ELS_LSRJT)) {
1628 /* No record of what this accept is for. Can't decode */
1629 acc_tree = proto_item_add_subtree (ti, ett_fcels_acc);
1630 proto_tree_add_text (acc_tree, tvb, offset, tvb_length (tvb),
1631 "No record of ELS Req. Unable to decode ACC");
1638 if (check_col (pinfo->cinfo, COL_INFO)) {
1639 if (isreq == FC_ELS_REQ) {
1640 col_add_str (pinfo->cinfo, COL_INFO,
1641 val_to_str (opcode, fc_els_proto_val, "0x%x"));
1643 else if (opcode == FC_ELS_LSRJT) {
1644 col_add_fstr (pinfo->cinfo, COL_INFO, "LS_RJT (%s)",
1645 val_to_str (failed_opcode, fc_els_proto_val, "0x%x"));
1648 col_add_fstr (pinfo->cinfo, COL_INFO, "ACC (%s)",
1649 val_to_str (opcode, fc_els_proto_val, "0x%x"));
1655 dissect_fcels_lsrjt (tvb, pinfo, tree, isreq, ti);
1658 dissect_fcels_plogi (tvb, pinfo, tree, isreq, ti);
1661 dissect_fcels_flogi (tvb, pinfo, tree, isreq, ti);
1664 dissect_fcels_logout (tvb, pinfo, tree, isreq, ti);
1667 dissect_fcels_abtx (tvb, pinfo, tree, isreq, ti);
1670 dissect_fcels_rsi (tvb, pinfo, tree, isreq, ti);
1673 dissect_fcels_rrq (tvb, pinfo, tree, isreq, ti);
1676 dissect_fcels_prli (tvb, pinfo, tree, isreq, ti);
1679 dissect_fcels_prlo (tvb, pinfo, tree, isreq, ti);
1682 dissect_fcels_tprlo (tvb, pinfo, tree, isreq, ti);
1685 dissect_fcels_pdisc (tvb, pinfo, tree, isreq, ti);
1688 dissect_fcels_fdisc (tvb, pinfo, tree, isreq, ti);
1691 dissect_fcels_adisc (tvb, pinfo, tree, isreq, ti);
1693 case FC_ELS_FARP_REQ:
1694 dissect_fcels_farp_req (tvb, pinfo, tree, isreq, ti);
1696 case FC_ELS_FARP_RPLY:
1697 dissect_fcels_farp_rply (tvb, pinfo, tree, isreq, ti);
1700 dissect_fcels_rps (tvb, pinfo, tree, isreq, ti);
1703 dissect_fcels_rpl (tvb, pinfo, tree, isreq, ti);
1706 dissect_fcels_fan (tvb, pinfo, tree, isreq, ti);
1709 dissect_fcels_rscn (tvb, pinfo, tree, isreq, ti);
1712 dissect_fcels_scr (tvb, pinfo, tree, isreq, ti);
1715 dissect_fcels_rnft (tvb, pinfo, tree, isreq, ti);
1718 dissect_fcels_lsts (tvb, pinfo, tree, isreq, ti);
1721 dissect_fcels_rnid (tvb, pinfo, tree, isreq, ti);
1724 dissect_fcels_rlir (tvb, pinfo, tree, isreq, ti);
1727 dissect_fcels_lirr (tvb, pinfo, tree, isreq, ti);
1730 dissect_fcels_srl (tvb, pinfo, tree, isreq, ti);
1733 dissect_fcels_rpsc (tvb, pinfo, tree, isreq, ti);
1736 if (isreq && fcsp_handle)
1737 call_dissector (fcsp_handle, tvb, pinfo, tree);
1740 /* proto_tree_add_text ( */
1741 call_dissector (data_handle, tvb, pinfo, tree);
1747 proto_register_fcels (void)
1750 /* Setup list of header fields See Section 1.6.1 for details*/
1751 static hf_register_info hf[] = {
1753 {"Cmd Code", "fcels.opcode", FT_UINT8, BASE_HEX,
1754 VALS (fc_els_proto_val), 0x0, "", HFILL}},
1755 { &hf_fcels_rjtcode,
1756 {"Reason Code", "fcels.rjt.reason", FT_UINT8, BASE_HEX,
1757 VALS (fc_els_rjt_val), 0x0, "", HFILL}},
1758 { &hf_fcels_rjtdetcode,
1759 {"Reason Explanation", "fcels.rjt.detail", FT_UINT8, BASE_HEX,
1760 VALS (fc_els_rjt_det_val), 0x0, "", HFILL}},
1761 { &hf_fcels_vnduniq,
1762 {"Vendor Unique", "fcels.rjt.vnduniq", FT_UINT8, BASE_HEX, NULL,
1765 {"B2B Credit", "fcels.logi.b2b", FT_UINT8, BASE_DEC, NULL, 0x0, "",
1767 { &hf_fcels_cmnfeatures,
1768 {"Common Features", "fcels.logi.cmnfeatures", FT_UINT16, BASE_HEX, NULL,
1770 { &hf_fcels_bbscnum,
1771 {"BB_SC Number", "fcels.logi.bbscnum", FT_UINT8, BASE_DEC, NULL, 0xF0, "",
1773 { &hf_fcels_rcvsize,
1774 {"Receive Size", "fcels.logi.rcvsize", FT_UINT16, BASE_DEC, NULL, 0x0FFF, "",
1776 { &hf_fcels_maxconseq,
1777 {"Max Concurrent Seq", "fcels.logi.maxconseq", FT_UINT16, BASE_DEC, NULL,
1779 { &hf_fcels_reloffset,
1780 {"Relative Offset By Info Cat", "fcels.logi.reloff", FT_UINT16, BASE_DEC,
1781 NULL, 0x0, "", HFILL}},
1783 {"E_D_TOV", "fcels.edtov", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}},
1785 {"N_Port Port_Name", "fcels.npname", FT_STRING, BASE_HEX, NULL, 0x0,
1788 {"Fabric/Node Name", "fcels.fnname", FT_STRING, BASE_HEX, NULL, 0x0,
1790 { &hf_fcels_cls1param,
1791 {"Class 1 Svc Param", "fcels.logi.cls1param", FT_BYTES, BASE_HEX, NULL, 0x0,
1793 { &hf_fcels_cls2param,
1794 {"Class 2 Svc Param", "fcels.logi.cls2param", FT_BYTES, BASE_HEX, NULL, 0x0,
1796 { &hf_fcels_cls3param,
1797 {"Class 3 Svc Param", "fcels.logi.cls3param", FT_BYTES, BASE_HEX, NULL, 0x0,
1799 { &hf_fcels_cls4param,
1800 {"Class 4 Svc Param", "fcels.logi.cls4param", FT_BYTES, BASE_HEX, NULL, 0x0,
1802 { &hf_fcels_vendorvers,
1803 {"Vendor Version", "fcels.logi.vendvers", FT_BYTES, BASE_HEX, NULL, 0x0, "",
1805 { &hf_fcels_svcavail,
1806 {"Services Availability", "fcels.logi.svcavail", FT_BYTES, BASE_HEX, NULL,
1808 { &hf_fcels_clsflags,
1809 {"Class Flags", "fcels.logi.clsflags", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1811 { &hf_fcels_initctl,
1812 {"Initiator Ctl", "fcels.logi.initctl", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1814 { &hf_fcels_rcptctl,
1815 {"Recipient Ctl", "fcels.logi.rcptctl", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1817 { &hf_fcels_clsrcvsize,
1818 {"Class Recv Size", "fcels.logi.clsrcvsize", FT_UINT16, BASE_DEC, NULL,
1821 {"Total Concurrent Seq", "fcels.logi.totconseq", FT_UINT8, BASE_DEC, NULL,
1824 {"End2End Credit", "fcels.logi.e2e", FT_UINT16, BASE_DEC, NULL, 0x0, "",
1826 { &hf_fcels_openseq,
1827 {"Open Seq Per Exchg", "fcels.logi.openseq", FT_UINT8, BASE_DEC, NULL, 0x0,
1829 { &hf_fcels_nportid,
1830 {"Originator S_ID", "fcels.portid", FT_STRING, BASE_HEX, NULL, 0x0,
1833 {"OXID", "fcels.oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1835 {"RXID", "fcels.rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1836 { &hf_fcels_recovqual,
1837 {"Recovery Qualifier", "fcels.rcovqual", FT_UINT8, BASE_HEX, NULL,
1839 { &hf_fcels_fabricaddr,
1840 {"Fabric Address", "fcels.faddr", FT_STRING, BASE_HEX, NULL, 0x0, "",
1842 { &hf_fcels_fabricpname,
1843 {"Fabric Port Name", "fcels.fpname", FT_STRING, BASE_HEX, NULL, 0x0,
1845 { &hf_fcels_failedrcvr,
1846 {"Failed Receiver AL_PA", "fcels.faildrcvr", FT_UINT8, BASE_HEX, NULL,
1848 { &hf_fcels_flacompliance,
1849 {"FC-FLA Compliance", "fcels.flacompliance", FT_UINT8, BASE_HEX,
1850 VALS (fc_els_flacompliance_val), 0x0, "", HFILL}},
1851 { &hf_fcels_loopstate,
1852 {"Loop State", "fcels.loopstate", FT_UINT8, BASE_HEX,
1853 VALS (fc_els_loopstate_val), 0x0, "", HFILL}},
1854 { &hf_fcels_publicloop_bmap,
1855 {"Public Loop Device Bitmap", "fcels.pubdev_bmap", FT_BYTES, BASE_HEX,
1856 NULL, 0x0, "", HFILL}},
1857 { &hf_fcels_pvtloop_bmap,
1858 {"Private Loop Device Bitmap", "fcels.pvtdev_bmap", FT_BYTES,
1859 BASE_HEX, NULL, 0x0, "", HFILL}},
1860 { &hf_fcels_alpa_map,
1861 {"AL_PA Map", "fcels.alpa", FT_BYTES, BASE_HEX, NULL, 0x0, "",
1863 { &hf_fcels_scrregn,
1864 {"Registration Function", "fcels.scr.regn", FT_UINT8, BASE_HEX,
1865 VALS (fc_els_scr_reg_val), 0x0, "", HFILL}},
1866 { &hf_fcels_farp_matchcodept,
1867 {"Match Address Code Points", "fcels.matchcp", FT_UINT8, BASE_DEC,
1868 NULL, 0x0, "", HFILL}},
1869 { &hf_fcels_farp_respaction,
1870 {"Responder Action", "fcels.respaction", FT_UINT8, BASE_HEX,
1871 VALS (fc_els_farp_respaction_val), 0x0, "", HFILL}},
1872 { &hf_fcels_resportid,
1873 {"Responding Port ID", "fcels.resportid", FT_STRING, BASE_HEX,
1874 NULL, 0x0, "", HFILL}},
1875 { &hf_fcels_respname,
1876 {"Responding Port Name", "fcels.respname", FT_STRING, BASE_HEX,
1877 NULL, 0x0, "", HFILL}},
1878 { &hf_fcels_respnname,
1879 {"Responding Node Name", "fcels.respnname", FT_STRING, BASE_HEX,
1880 NULL, 0x0, "", HFILL}},
1881 { &hf_fcels_reqipaddr,
1882 {"Requesting IP Address", "fcels.reqipaddr", FT_IPv6, BASE_DEC,
1883 NULL, 0x0, "", HFILL}},
1884 { &hf_fcels_respipaddr,
1885 {"Responding IP Address", "fcels.respipaddr", FT_IPv6, BASE_DEC,
1886 NULL, 0x0, "", HFILL}},
1887 { &hf_fcels_hardaddr,
1888 {"Hard Address of Originator", "fcels.hrdaddr", FT_STRING, BASE_HEX,
1889 NULL, 0x0, "", HFILL}},
1890 { &hf_fcels_rps_flag,
1891 {"Flag", "fcels.flag", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1892 { &hf_fcels_rps_portnum,
1893 {"Physical Port Number", "fcels.portnum", FT_UINT32, BASE_HEX, NULL,
1895 { &hf_fcels_rps_portstatus,
1896 {"Port Status", "fcels.portstatus", FT_UINT16, BASE_HEX,
1897 VALS(fc_els_portstatus_val), 0x0, "", HFILL}},
1898 { &hf_fcels_rnft_fc4type,
1899 {"FC-4 Type", "fcels.rnft.fc4type", FT_UINT8, BASE_HEX,
1900 VALS (fc_fc4_val), 0x0, "", HFILL}},
1901 { &hf_fcels_rscn_evqual,
1902 {"Event Qualifier", "fcels.rscn.evqual", FT_UINT8, BASE_HEX,
1903 VALS (fc_els_rscn_evqual_val), 0x3C, "", HFILL}},
1904 { &hf_fcels_rscn_addrfmt,
1905 {"Address Format", "fcels.rscn.addrfmt", FT_UINT8, BASE_HEX,
1906 VALS (fc_els_rscn_addrfmt_val), 0x03, "", HFILL}},
1907 { &hf_fcels_rscn_domain,
1908 {"Affected Domain", "fcels.rscn.domain", FT_UINT8, BASE_HEX,
1909 NULL, 0x0, "", HFILL}},
1910 { &hf_fcels_rscn_area,
1911 {"Affected Area", "fcels.rscn.area", FT_UINT8, BASE_HEX,
1912 NULL, 0x0, "", HFILL}},
1913 { &hf_fcels_rscn_port,
1914 {"Affected Port", "fcels.rscn.port", FT_UINT8, BASE_HEX,
1915 NULL, 0x0, "", HFILL}},
1916 { &hf_fcels_nodeidfmt,
1917 {"Node Identification Format", "fcels.rnid.nodeidfmt", FT_UINT8,
1918 BASE_HEX, VALS (fc_els_nodeid_val), 0x0, "", HFILL}},
1919 { &hf_fcels_spidlen,
1920 {"Specific Id Length", "fcels.rnid.spidlen", FT_UINT8, BASE_DEC, NULL,
1922 { &hf_fcels_vendoruniq,
1923 {"Vendor Unique", "fcels.rnid.vendoruniq", FT_BYTES, BASE_HEX, NULL,
1925 { &hf_fcels_vendorsp,
1926 {"Vendor Specific", "fcels.rnid.vendorsp", FT_UINT16, BASE_HEX, NULL,
1928 { &hf_fcels_asstype,
1929 {"Associated Type", "fcels.rnid.asstype", FT_UINT32, BASE_HEX,
1930 VALS (fc_els_rnid_asstype_val), 0x0, "", HFILL}},
1931 { &hf_fcels_physport,
1932 {"Physical Port Number", "fcels.rnid.physport", FT_UINT32, BASE_HEX,
1933 NULL, 0x0, "", HFILL}},
1934 { &hf_fcels_attnodes,
1935 {"Number of Attached Nodes", "fcels.rnid.attnodes", FT_UINT32,
1936 BASE_HEX, NULL, 0x0, "", HFILL}},
1937 { &hf_fcels_nodemgmt,
1938 {"Node Management", "fcels.rnid.nodemgmt", FT_UINT8, BASE_HEX,
1939 VALS (fc_els_rnid_mgmt_val), 0x0, "", HFILL}},
1941 {"IP Version", "fcels.rnid.ipvers", FT_UINT8, BASE_HEX,
1942 VALS (fc_els_rnid_ipvers_val), 0x0, "", HFILL}},
1943 { &hf_fcels_tcpport,
1944 {"TCP/UDP Port Number", "fcels.rnid.tcpport", FT_UINT16, BASE_DEC,
1945 NULL, 0x0, "", HFILL}},
1947 {"IP Address", "fcels.rnid.ip", FT_IPv6, BASE_HEX, NULL, 0x0, "",
1951 static gint *ett[] = {
1957 &ett_fcels_logi_cmnsvc,
1958 &ett_fcels_logi_clssvc,
1964 &ett_fcels_prli_svcpg,
1972 &ett_fcels_rscn_rec,
1975 &ett_fcels_rnft_fc4,
1984 /* Register the protocol name and description */
1985 proto_fcels = proto_register_protocol("FC Extended Link Svc", "FC ELS", "els");
1987 /* Required function calls to register the header fields and subtrees used */
1988 proto_register_field_array(proto_fcels, hf, array_length(hf));
1989 proto_register_subtree_array(ett, array_length(ett));
1990 register_init_routine (&fcels_init_protocol);
1994 proto_reg_handoff_fcels (void)
1996 dissector_handle_t els_handle;
1998 els_handle = create_dissector_handle (dissect_fcels, proto_fcels);
1999 dissector_add("fc.ftype", FC_FTYPE_ELS, els_handle);
2001 data_handle = find_dissector ("data");
2002 fcsp_handle = find_dissector ("fcsp");