2 * Routines for FC Extended Link Services
3 * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
5 * $Id: packet-fcels.c,v 1.3 2003/01/22 06:26:33 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;
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)
247 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
249 strcpy (flagstr, "Cont. Incr. Offset Supported");
254 sprintf (&flagstr[stroff], "%sRRO Supported", punc);
261 sprintf (flagstr, "%sValid Vendor Version Level", punc);
267 sprintf (&flagstr[stroff], "%sAlt B2B Credit Mgmt", punc);
272 sprintf (&flagstr[stroff], "%sNormal B2B Credit Mgmt", punc);
277 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
279 strcpy (&flagstr[stroff], ", E_D_TOV Resolution in ns");
282 strcpy (&flagstr[stroff], ", E_D_TOV Resolution in ms");
287 strcpy (&flagstr[stroff], ", Simplex Dedicated Conn Supported");
293 strcpy (&flagstr[stroff], ", Clk Sync Prim Capable");
297 strcpy (&flagstr[stroff], ", DHD Capable");
301 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
303 strcpy (&flagstr[stroff], ", Cont. Incr SEQCNT rules");
307 strcpy (&flagstr[stroff], ", Normal SEQCNT rules");
313 sprintf (&flagstr[stroff], ", Payload Len=256 bytes");
316 sprintf (&flagstr[stroff], ", Payload Len=116 bytes");
320 /* The next 3 routines decode only Class 2 & Class 3 relevant bits */
322 construct_clssvc_string (guint16 flag, gchar *flagstr, guint8 opcode)
326 if (!(flag & 0x8000)) {
327 strcpy (flagstr, "Class Not Supported");
331 if ((opcode == FC_ELS_FLOGI) || (opcode == FC_ELS_FDISC)) {
333 strcpy (flagstr, "Seq Delivery Requested");
337 strcpy (flagstr, "Out of Order Delivery Requested");
343 strcpy (&flagstr[stroff], ", Priority/preemption supported");
347 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
349 strcpy (&flagstr[stroff], "Non-zero CS_CTL Tolerated");
352 strcpy (&flagstr[stroff], "Non-zero CS_CTL Maybe Tolerated");
358 construct_initctl_string (guint16 flag, gchar *flagstr, guint8 opcode)
362 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
363 switch ((flag & 0x3000)) {
365 strcpy (flagstr, "Initial P_A Not Supported");
369 strcpy (flagstr, "Initial P_A Supported");
373 strcpy (flagstr, "Initial P_A Required & Supported");
379 strcpy (&flagstr[stroff], ", ACK0 Capable");
384 strcpy (&flagstr[stroff], ", ACK Generation Assistance Avail");
388 strcpy (&flagstr[stroff], ", Clock Sync ELS Supported");
393 strcpy (&flagstr[stroff], "Clock Sync ELS Supported");
399 construct_rcptctl_string (guint16 flag, gchar *flagstr, guint8 opcode)
406 if ((opcode == FC_ELS_PLOGI) || (opcode == FC_ELS_PDISC)) {
408 strcpy (flagstr, "ACK_0 Supported");
412 strcpy (flagstr, "ACK_0 Not Supported");
417 strcpy (&flagstr[stroff], ", X_ID Interlock Reqd");
421 switch (flag & 0x1800) {
423 strcpy (&flagstr[stroff], ", Error Policy: Discard Policy only");
427 strcpy (&flagstr[stroff], ", Error Policy: Both discard and process policies supported");
431 strcpy (&flagstr[stroff], ", Error Policy: Reserved");
435 strcpy (&flagstr[stroff], ", Error Policy: Reserved");
440 switch (flag & 0x0030) {
442 strcpy (&flagstr[stroff], ", 1 Category/Seq");
446 strcpy (&flagstr[stroff], ", 2 Categories/Seq");
450 strcpy (&flagstr[stroff], ", More than 2 Categories/Seq");
456 strcpy (&flagstr[stroff], ", Clk Sync ELS Supported");
461 strcpy (&flagstr[stroff], "Clk Sync ELS Supported");
468 dissect_fcels_logi (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
469 proto_item *ti, guint8 opcode)
471 /* Set up structures needed to add the protocol subtree and manage it */
475 proto_tree *logi_tree, *cmnsvc_tree;
481 logi_tree = proto_item_add_subtree (ti, ett_fcels_logi);
482 proto_tree_add_item (logi_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
484 subti = proto_tree_add_text (logi_tree, tvb, offset+4, 16,
485 "Common Svc Parameters");
486 cmnsvc_tree = proto_item_add_subtree (subti, ett_fcels_logi_cmnsvc);
487 proto_tree_add_item (cmnsvc_tree, hf_fcels_b2b, tvb, offset+6, 2, FALSE);
488 flag = tvb_get_ntohs (tvb, offset+8);
494 construct_cmnsvc_string (flag, flagstr, opcode);
495 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_cmnfeatures, tvb,
497 "Common Svc Parameters: 0x%x (%s)",
500 proto_tree_add_item (cmnsvc_tree, hf_fcels_bbscnum, tvb, offset+10, 1, FALSE);
501 proto_tree_add_item (cmnsvc_tree, hf_fcels_rcvsize, tvb, offset+10, 2, FALSE);
502 proto_tree_add_item (cmnsvc_tree, hf_fcels_maxconseq, tvb, offset+12, 2, FALSE);
503 proto_tree_add_item (cmnsvc_tree, hf_fcels_reloffset, tvb, offset+14, 2, FALSE);
504 proto_tree_add_item (cmnsvc_tree, hf_fcels_edtov, tvb, offset+16, 4, FALSE);
505 proto_tree_add_string (cmnsvc_tree, hf_fcels_npname, tvb, offset+20, 8,
506 fcwwn_to_str (tvb_get_ptr (tvb, offset+20, 8)));
507 proto_tree_add_string (cmnsvc_tree, hf_fcels_fnname, tvb, offset+28, 8,
508 fcwwn_to_str (tvb_get_ptr (tvb, offset+28, 8)));
510 /* Add subtree for class paramters */
512 for (class = 1; class < 5; class++) {
513 subti = proto_tree_add_text (logi_tree, tvb, offset, 16,
514 "Class %d Svc Parameters", class);
515 cmnsvc_tree = proto_item_add_subtree (subti, ett_fcels_logi_cmnsvc);
517 flag = tvb_get_ntohs (tvb, offset);
518 construct_clssvc_string (flag, flagstr, opcode);
519 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_clsflags, tvb,
521 "Service Options: 0x%x(%s)", flag,
524 flag = tvb_get_ntohs (tvb, offset+2);
525 construct_initctl_string (flag, flagstr, opcode);
526 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_initctl, tvb,
528 "Initiator Control: 0x%x(%s)", flag,
531 flag = tvb_get_ntohs (tvb, offset+4);
532 construct_rcptctl_string (flag, flagstr, opcode);
533 proto_tree_add_uint_format (cmnsvc_tree, hf_fcels_initctl, tvb,
535 "Recipient Control: 0x%x(%s)", flag,
538 proto_tree_add_item (cmnsvc_tree, hf_fcels_clsrcvsize, tvb,
540 proto_tree_add_item (cmnsvc_tree, hf_fcels_conseq, tvb,
542 proto_tree_add_item (cmnsvc_tree, hf_fcels_e2e, tvb,
543 offset+10, 2, FALSE);
544 proto_tree_add_item (cmnsvc_tree, hf_fcels_openseq, tvb,
545 offset+12, 2, FALSE);
549 proto_tree_add_item (logi_tree, hf_fcels_vendorvers, tvb, offset, 16, FALSE);
551 proto_tree_add_item (logi_tree, hf_fcels_svcavail, tvb, offset+32, 8, FALSE);
557 dissect_fcels_plogi (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
558 guint8 isreq _U_, proto_item *ti)
560 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_PLOGI);
564 dissect_fcels_flogi (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
565 guint8 isreq _U_, proto_item *ti)
567 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_FLOGI);
571 dissect_fcels_logout (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
572 guint8 isreq, proto_item *ti)
574 /* Set up structures needed to add the protocol subtree and manage it */
575 int offset = 5; /* bypass opcode+rsvd field */
576 proto_tree *logo_tree;
579 logo_tree = proto_item_add_subtree (ti, ett_fcels_logo);
581 proto_tree_add_item (logo_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
584 /* Accept has no payload */
588 proto_tree_add_string (logo_tree, hf_fcels_nportid, tvb, offset, 3,
589 fc_to_str (tvb_get_ptr (tvb, offset, 3)));
590 proto_tree_add_string (logo_tree, hf_fcels_npname, tvb, offset+3, 6,
591 fcwwn_to_str (tvb_get_ptr (tvb, offset+3, 6)));
596 dissect_fcels_abtx (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
597 guint8 isreq, proto_item *ti)
599 /* Set up structures needed to add the protocol subtree and manage it */
601 proto_tree *abtx_tree;
604 abtx_tree = proto_item_add_subtree (ti, ett_fcels_abtx);
606 proto_tree_add_item (abtx_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
612 proto_tree_add_text (abtx_tree, tvb, offset+4, 1,
613 "Recovery Qualifier Status: 0x%x",
614 tvb_get_guint8 (tvb, offset+4));
615 proto_tree_add_string (abtx_tree, hf_fcels_nportid, tvb, offset+5, 3,
616 fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
617 proto_tree_add_item (abtx_tree, hf_fcels_oxid, tvb, offset+8, 2, FALSE);
618 proto_tree_add_item (abtx_tree, hf_fcels_rxid, tvb, offset+10, 2, FALSE);
623 dissect_fcels_rsi (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
624 guint8 isreq, proto_item *ti)
626 /* Set up structures needed to add the protocol subtree and manage it */
628 proto_tree *rsi_tree;
631 rsi_tree = proto_item_add_subtree (ti, ett_fcels_rsi);
633 proto_tree_add_item (rsi_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
637 proto_tree_add_item (rsi_tree, hf_fcels_recovqual, tvb, offset, 1, FALSE);
638 proto_tree_add_string (rsi_tree, hf_fcels_nportid, tvb, offset+1, 3,
639 fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
640 proto_tree_add_item (rsi_tree, hf_fcels_rxid, tvb, offset+4, 2, FALSE);
641 proto_tree_add_item (rsi_tree, hf_fcels_oxid, tvb, offset+6, 2, FALSE);
646 dissect_fcels_rrq (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
647 guint8 isreq, proto_item *ti)
649 /* Set up structures needed to add the protocol subtree and manage it */
651 proto_tree *rrq_tree;
654 rrq_tree = proto_item_add_subtree (ti, ett_fcels_rrq);
656 proto_tree_add_item (rrq_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
660 proto_tree_add_string (rrq_tree, hf_fcels_nportid, tvb, offset+5, 3,
661 fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
662 proto_tree_add_item (rrq_tree, hf_fcels_oxid, tvb, offset+8, 2, FALSE);
663 proto_tree_add_item (rrq_tree, hf_fcels_rxid, tvb, offset+10, 2, FALSE);
668 dissect_fcels_pdisc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
669 guint8 isreq _U_, proto_item *ti)
671 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_PDISC);
675 dissect_fcels_fdisc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
676 guint8 isreq _U_, proto_item *ti)
678 dissect_fcels_logi (tvb, pinfo, tree, ti, FC_ELS_FDISC);
682 dissect_fcels_adisc (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
683 guint8 isreq _U_, proto_item *ti)
685 /* Set up structures needed to add the protocol subtree and manage it */
687 proto_tree *adisc_tree;
690 adisc_tree = proto_item_add_subtree (ti, ett_fcels_adisc);
692 proto_tree_add_item (adisc_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
694 proto_tree_add_string (adisc_tree, hf_fcels_hardaddr, tvb, offset, 3,
695 fc_to_str (tvb_get_ptr (tvb, offset, 3)));
696 proto_tree_add_string (adisc_tree, hf_fcels_npname, tvb, offset+3, 8,
697 fcwwn_to_str (tvb_get_ptr (tvb, offset+3, 8)));
698 proto_tree_add_string (adisc_tree, hf_fcels_fnname, tvb, offset+11, 8,
699 fcwwn_to_str (tvb_get_ptr (tvb, offset+11, 8)));
700 proto_tree_add_string (adisc_tree, hf_fcels_nportid, tvb, offset+20, 3,
701 fc_to_str (tvb_get_ptr (tvb, offset+20, 3)));
707 dissect_fcels_farp (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
711 proto_tree *farp_tree;
714 farp_tree = proto_item_add_subtree (ti, ett_fcels_farp);
716 proto_tree_add_item (farp_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
718 proto_tree_add_item (farp_tree, hf_fcels_farp_matchcodept,
719 tvb, offset, 1, FALSE);
720 proto_tree_add_string (farp_tree, hf_fcels_nportid, tvb, offset+1,
721 3, fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
722 proto_tree_add_item (farp_tree, hf_fcels_farp_respaction, tvb,
724 proto_tree_add_string (farp_tree, hf_fcels_resportid, tvb, offset+5,
725 3, fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
726 proto_tree_add_string (farp_tree, hf_fcels_npname, tvb, offset+8,
727 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
728 proto_tree_add_string (farp_tree, hf_fcels_fnname, tvb, offset+16,
729 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+16, 8)));
730 proto_tree_add_string (farp_tree, hf_fcels_respname, tvb, offset+24,
731 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+24, 8)));
732 proto_tree_add_string (farp_tree, hf_fcels_respnname, tvb, offset+32,
733 8, fcwwn_to_str (tvb_get_ptr (tvb, offset+32, 8)));
734 proto_tree_add_item (farp_tree, hf_fcels_reqipaddr, tvb, offset+40,
736 proto_tree_add_item (farp_tree, hf_fcels_respipaddr, tvb, offset+56,
742 dissect_fcels_farp_req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
743 guint8 isreq _U_, proto_item *ti)
745 dissect_fcels_farp (tvb, pinfo, tree, ti);
749 dissect_fcels_farp_rply (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
750 guint8 isreq _U_, proto_item *ti)
752 dissect_fcels_farp (tvb, pinfo, tree, ti);
756 dissect_fcels_rps (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
757 guint8 isreq, proto_item *ti)
759 /* Set up structures needed to add the protocol subtree and manage it */
762 proto_tree *rps_tree;
764 flag = tvb_get_guint8 (tvb, offset);
767 rps_tree = proto_item_add_subtree (ti, ett_fcels_rps);
770 proto_tree_add_item (rps_tree, hf_fcels_rps_flag, tvb, offset, 1, FALSE);
772 proto_tree_add_item (rps_tree, hf_fcels_opcode, tvb, offset-3, 1, FALSE);
775 proto_tree_add_string (rps_tree, hf_fcels_npname, tvb, offset+1,
776 8, fcwwn_to_str (tvb_get_ptr (tvb,
780 else if (flag & 0x1) {
781 proto_tree_add_item (rps_tree, hf_fcels_rps_portnum, tvb,
786 proto_tree_add_item (rps_tree, hf_fcels_rps_flag, tvb, offset, 1, FALSE);
787 proto_tree_add_item (rps_tree, hf_fcels_rps_portstatus, tvb,
789 /* Next 6 fields are from Link Error Status Block (LESB) */
790 proto_tree_add_text (rps_tree, tvb, offset+5, 4,
791 "Link Failure Count: %u",
792 tvb_get_ntohl (tvb, offset+5));
793 proto_tree_add_text (rps_tree, tvb, offset+9, 4,
794 "Loss of Sync Count: %u",
795 tvb_get_ntohl (tvb, offset+9));
796 proto_tree_add_text (rps_tree, tvb, offset+13, 4,
797 "Loss of Signal Count: %u",
798 tvb_get_ntohl (tvb, offset+13));
799 proto_tree_add_text (rps_tree, tvb, offset+17, 4,
800 "Primitive Seq Protocol Err: %u",
801 tvb_get_ntohl (tvb, offset+17));
802 proto_tree_add_text (rps_tree, tvb, offset+21, 4,
803 "Invalid Xmission Word: %u",
804 tvb_get_ntohl (tvb, offset+21));
805 proto_tree_add_text (rps_tree, tvb, offset+25, 4,
806 "Invalid CRC Count: %u",
807 tvb_get_ntohl (tvb, offset+25));
809 /* Next 6 fields are from L_Port Extension field */
810 proto_tree_add_text (rps_tree, tvb, offset+31, 2,
811 "L_Port Status: 0x%x",
812 tvb_get_ntohs (tvb, offset+31));
813 proto_tree_add_text (rps_tree, tvb, offset+36, 1,
815 tvb_get_guint8 (tvb, offset+36));
816 proto_tree_add_text (rps_tree, tvb, offset+37, 4,
817 "LIP F7 Initiated Count: %u",
818 tvb_get_ntohl (tvb, offset+37));
819 proto_tree_add_text (rps_tree, tvb, offset+41, 4,
820 "LIP F7 Received Count: %u",
821 tvb_get_ntohl (tvb, offset+41));
822 proto_tree_add_text (rps_tree, tvb, offset+45, 4,
823 "LIP F8 Initiated Count: %u",
824 tvb_get_ntohl (tvb, offset+45));
825 proto_tree_add_text (rps_tree, tvb, offset+49, 4,
826 "LIP F8 Received Count: %u",
827 tvb_get_ntohl (tvb, offset+49));
828 proto_tree_add_text (rps_tree, tvb, offset+53, 4,
829 "LIP Reset Initiated Count: %u",
830 tvb_get_ntohl (tvb, offset+53));
831 proto_tree_add_text (rps_tree, tvb, offset+57, 4,
832 "LIP Reset Received Count: %u",
833 tvb_get_ntohl (tvb, offset+57));
840 dissect_fcels_rpl (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
841 guint8 isreq, proto_item *ti)
843 /* Set up structures needed to add the protocol subtree and manage it */
845 proto_tree *rpl_tree, *pb_tree;
850 rpl_tree = proto_item_add_subtree (ti, ett_fcels_rpl);
852 proto_tree_add_item (rpl_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
855 proto_tree_add_text (rpl_tree, tvb, offset+6, 2,
857 tvb_get_ntohs (tvb, offset+6));
858 proto_tree_add_text (rpl_tree, tvb, offset+9, 3,
860 tvb_get_ntoh24 (tvb, offset+9));
863 /* Reply consists of a header and a number of port blocks */
864 proto_tree_add_text (rpl_tree, tvb, offset+2, 2,
865 "Payload Length: %u",
866 tvb_get_ntohs (tvb, offset+2));
867 proto_tree_add_text (rpl_tree, tvb, offset+5, 3,
869 tvb_get_ntoh24 (tvb, offset+5));
870 proto_tree_add_text (rpl_tree, tvb, offset+9, 3,
871 "Index of I Port Block: %u",
872 tvb_get_ntoh24 (tvb, offset+9));
874 /* The following loop is for dissecting the port blocks */
875 for (loop = tvb_get_ntoh24 (tvb, 5); loop > 0; loop--) {
876 subti = proto_tree_add_text (rpl_tree, tvb, offset+12, 16,
877 "Port Block %u", loop);
878 pb_tree = proto_item_add_subtree (subti, ett_fcels_rplpb);
880 proto_tree_add_text (pb_tree, tvb, offset, 4,
881 "Physical Port #: %u",
882 tvb_get_ntohl (tvb, offset));
883 proto_tree_add_text (pb_tree, tvb, offset+5, 3,
884 "Port Identifier: %s",
885 fc_to_str (tvb_get_ptr (tvb, offset+5, 3)));
886 proto_tree_add_text (pb_tree, tvb, offset+8, 8,
888 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
896 dissect_fcels_fan (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
897 guint8 isreq _U_, proto_item *ti)
899 /* Set up structures needed to add the protocol subtree and manage it */
901 proto_tree *fan_tree;
904 fan_tree = proto_item_add_subtree (ti, ett_fcels_fan);
906 proto_tree_add_item (fan_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
908 proto_tree_add_string (fan_tree, hf_fcels_fabricaddr, tvb, offset, 3,
909 fc_to_str (tvb_get_ptr (tvb, offset, 3)));
910 proto_tree_add_string (fan_tree, hf_fcels_fabricpname, tvb, offset+3,
911 8, fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
912 proto_tree_add_string (fan_tree, hf_fcels_fnname, tvb, offset+11, 8,
913 fcwwn_to_str (tvb_get_ptr (tvb, offset+11, 8)));
918 dissect_fcels_rscn (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
919 guint8 isreq, proto_item *ti)
921 /* Set up structures needed to add the protocol subtree and manage it */
923 proto_tree *rscn_tree, *rectree;
928 rscn_tree = proto_item_add_subtree (ti, ett_fcels_rscn);
930 proto_tree_add_item (rscn_tree, hf_fcels_opcode, tvb, offset-1, 1, FALSE);
934 proto_tree_add_text (rscn_tree, tvb, offset, 1,
935 "Page Len: %u", tvb_get_guint8 (tvb, offset));
936 plen = tvb_get_ntohs (tvb, offset+1);
937 proto_tree_add_text (rscn_tree, tvb, offset+1, 2,
938 "Payload Len: %u", plen);
939 numrec = (plen - 4)/4;
942 for (i = 0; i < numrec; i++) {
943 subti = proto_tree_add_text (rscn_tree, tvb, offset, 4,
944 "Affected N_Port Page %u", i);
945 rectree = proto_item_add_subtree (subti, ett_fcels_rscn_rec);
947 proto_tree_add_item (rectree, hf_fcels_rscn_evqual, tvb, offset,
949 proto_tree_add_item (rectree, hf_fcels_rscn_addrfmt, tvb, offset,
951 proto_tree_add_item (rectree, hf_fcels_rscn_domain, tvb, offset+1,
953 proto_tree_add_item (rectree, hf_fcels_rscn_area, tvb, offset+2,
955 proto_tree_add_item (rectree, hf_fcels_rscn_port, tvb, offset+3,
963 dissect_fcels_scr (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
964 guint8 isreq, proto_item *ti)
966 /* Set up structures needed to add the protocol subtree and manage it */
968 proto_tree *scr_tree;
971 scr_tree = proto_item_add_subtree (ti, ett_fcels_scr);
972 proto_tree_add_item (scr_tree, hf_fcels_opcode, tvb, offset-7, 1, FALSE);
974 proto_tree_add_item (scr_tree, hf_fcels_scrregn, tvb, offset, 1, FALSE);
979 dissect_fcels_rnft (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
980 guint8 isreq, proto_item *ti)
984 proto_tree *rnft_tree, *fc4_tree;
988 rnft_tree = proto_item_add_subtree (ti, ett_fcels_rnft);
990 proto_tree_add_item (rnft_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
993 proto_tree_add_text (rnft_tree, tvb, offset+2, 2,
994 "Max Size: %u", tvb_get_ntohs (tvb, offset+2));
995 proto_tree_add_text (rnft_tree, tvb, offset+7, 1,
996 "Index: %u", tvb_get_guint8 (tvb, offset+7));
999 proto_tree_add_text (rnft_tree, tvb, offset+2, 2,
1001 tvb_get_ntohs (tvb, offset+2));
1002 numrec = tvb_get_guint8 (tvb, offset+5);
1003 proto_tree_add_text (rnft_tree, tvb, offset+5, 1,
1004 "List Length: %u", numrec);
1005 proto_tree_add_text (rnft_tree, tvb, offset+7, 1,
1006 "Index of First Rec in List: %u",
1007 tvb_get_guint8 (tvb, offset+7));
1009 for (i = 0; i < numrec; i++) {
1010 subti = proto_tree_add_text (rnft_tree, tvb, offset, 4,
1011 "FC-4 Entry #%u", i);
1012 fc4_tree = proto_item_add_subtree (subti, ett_fcels_rnft_fc4);
1014 proto_tree_add_item (fc4_tree, hf_fcels_rnft_fc4type, tvb,
1016 proto_tree_add_text (fc4_tree, tvb, offset+1, 3,
1017 "FC-4 Qualifier 0x%x",
1018 tvb_get_ntoh24 (tvb, offset+1));
1026 dissect_fcels_lsts (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1027 guint8 isreq, proto_item *ti)
1029 /* Set up structures needed to add the protocol subtree and manage it */
1031 proto_tree *lsts_tree;
1034 lsts_tree = proto_item_add_subtree (ti, ett_fcels_lsts);
1036 proto_tree_add_item (lsts_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
1038 /* In case of LSTS, the reply has the meat */
1041 proto_tree_add_item (lsts_tree, hf_fcels_failedrcvr, tvb, offset, 1, FALSE);
1042 proto_tree_add_item (lsts_tree, hf_fcels_flacompliance, tvb, offset+1,
1044 proto_tree_add_item (lsts_tree, hf_fcels_loopstate, tvb, offset+2, 1, FALSE);
1045 proto_tree_add_item (lsts_tree, hf_fcels_publicloop_bmap, tvb, offset+3,
1047 proto_tree_add_item (lsts_tree, hf_fcels_pvtloop_bmap, tvb, offset+19,
1049 proto_tree_add_item (lsts_tree, hf_fcels_alpa_map, tvb, offset+35,
1055 dissect_fcels_prlilo_payload (tvbuff_t *tvb, packet_info *pinfo _U_,
1056 guint8 isreq, proto_item *ti, guint8 opcode)
1061 proto_tree *prli_tree, *svcpg_tree;
1062 int num_svcpg, payload_len, i, flag;
1066 /* We're assuming that we're invoked only if tree is not NULL i.e.
1067 * we don't do the usual "if (tree)" check here, the caller must.
1069 prli_tree = proto_item_add_subtree (ti, ett_fcels_prli);
1071 proto_tree_add_item (prli_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
1073 proto_tree_add_text (prli_tree, tvb, offset+1, 1,
1075 tvb_get_guint8 (tvb, offset+1));
1076 payload_len = tvb_get_ntohs (tvb, offset+2);
1077 proto_tree_add_text (prli_tree, tvb, offset+2, 2,
1078 "Payload Length: %u", payload_len);
1079 num_svcpg = payload_len/16;
1082 for (i = 0; i < num_svcpg; i++) {
1083 subti = proto_tree_add_text (prli_tree, tvb, offset, 16,
1084 "Service Parameter Page %u", i);
1085 svcpg_tree = proto_item_add_subtree (subti, ett_fcels_prli_svcpg);
1087 type = tvb_get_guint8 (tvb, offset);
1088 proto_tree_add_text (svcpg_tree, tvb, offset, 1,
1091 fc_prli_fc4_val, "0x%x"));
1092 proto_tree_add_text (svcpg_tree, tvb, offset+1, 1,
1093 "TYPE Code Extension: %u",
1094 tvb_get_guint8 (tvb, offset+1));
1096 flag = tvb_get_guint8 (tvb, offset+2);
1099 if (opcode != FC_ELS_TPRLO) {
1101 strcpy (flagstr, "Orig PA Valid, ");
1105 strcpy (&flagstr[stroff], "Resp PA Valid, ");
1109 if (opcode == FC_ELS_PRLI) {
1112 strcpy (&flagstr[stroff], "Image Pair Estd., ");
1116 strcpy (&flagstr[stroff], "Image Pair Not Estd., ");
1122 strcpy (&flagstr[stroff], "Est Image Pair & Exchg Svc Param, ");
1126 strcpy (&flagstr[stroff], "Exchange Svc Param Only, ");
1132 else { /* Assuming opcode is TPRLO */
1134 strcpy (flagstr, "3rd Party Orig PA Valid, ");
1138 strcpy (&flagstr[stroff], "Resp PA Valid, ");
1142 strcpy (&flagstr[stroff], "3rd Party N_Port Valid, ");
1146 strcpy (&flagstr[stroff], "Global PRLO, ");
1151 proto_tree_add_text (svcpg_tree, tvb, offset+2, 1,
1152 "Flags: %s", flagstr);
1153 if (!isreq && (opcode != FC_ELS_TPRLO)) {
1154 /* This is valid only for ACC */
1155 proto_tree_add_text (svcpg_tree, tvb, offset+2, 1,
1156 "Response Code: 0x%x",
1157 (tvb_get_guint8 (tvb, offset+2) & 0x0F));
1159 if (opcode != FC_ELS_TPRLO) {
1160 proto_tree_add_text (svcpg_tree, tvb, offset+4, 4,
1161 "Originator PA: 0x%x",
1162 tvb_get_ntohl (tvb, offset+4));
1165 proto_tree_add_text (svcpg_tree, tvb, offset+4, 4,
1166 "3rd Party Originator PA: 0x%x",
1167 tvb_get_ntohl (tvb, offset+4));
1169 proto_tree_add_text (svcpg_tree, tvb, offset+8, 4,
1170 "Responder PA: 0x%x",
1171 tvb_get_ntohl (tvb, offset+8));
1173 if (type == FC_TYPE_SCSI) {
1174 flag = tvb_get_ntohs (tvb, offset+14);
1178 if (flag & 0x2000) {
1180 strcpy (flagstr, "Task Retry Ident Req, ");
1184 strcpy (flagstr, "Task Retry Ident Acc, ");
1188 if (flag & 0x1000) {
1189 strcpy (&flagstr[stroff], "Retry Possible, ");
1192 if (flag & 0x0080) {
1193 strcpy (&flagstr[stroff], "Confirmed Comp, ");
1196 if (flag & 0x0040) {
1197 strcpy (&flagstr[stroff], "Data Overlay, ");
1200 if (flag & 0x0020) {
1201 strcpy (&flagstr[stroff], "Initiator, ");
1204 if (flag & 0x0010) {
1205 strcpy (&flagstr[stroff], "Target, ");
1208 if (flag & 0x0002) {
1209 strcpy (&flagstr[stroff], "Rd Xfer_Rdy Dis, ");
1212 if (flag & 0x0001) {
1213 strcpy (&flagstr[stroff], "Wr Xfer_Rdy Dis");
1216 proto_tree_add_text (svcpg_tree, tvb, offset+12, 4,
1217 "FCP Flags: 0x%x (%s)", flag,
1220 else if ((opcode == FC_ELS_PRLI) && !isreq) {
1221 proto_tree_add_text (svcpg_tree, tvb, offset+12, 4,
1222 "Service Parameter Response: 0x%x",
1223 tvb_get_ntohl (tvb, offset+12));
1225 else if (opcode == FC_ELS_TPRLO) {
1226 proto_tree_add_text (svcpg_tree, tvb, offset+13, 3,
1227 "3rd Party N_Port Id: %s",
1228 fc_to_str (tvb_get_ptr (tvb, offset+13, 3)));
1234 dissect_fcels_prli (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1235 guint8 isreq, proto_item *ti)
1238 dissect_fcels_prlilo_payload (tvb, pinfo, isreq, ti, FC_ELS_PRLI);
1243 dissect_fcels_prlo (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1244 guint8 isreq, proto_item *ti)
1246 /* Set up structures needed to add the protocol subtree and manage it */
1248 dissect_fcels_prlilo_payload (tvb, pinfo, isreq, ti, FC_ELS_PRLO);
1253 dissect_fcels_tprlo (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1254 guint8 isreq, proto_item *ti)
1256 /* Set up structures needed to add the protocol subtree and manage it */
1259 dissect_fcels_prlilo_payload (tvb, pinfo, isreq, ti, FC_ELS_TPRLO);
1264 dissect_fcels_lirr (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1265 guint8 isreq _U_, proto_item *ti)
1267 /* Set up structures needed to add the protocol subtree and manage it */
1269 proto_tree *lirr_tree;
1273 lirr_tree = proto_item_add_subtree (ti, ett_fcels_lirr);
1275 proto_tree_add_item (lirr_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
1277 proto_tree_add_text (lirr_tree, tvb, offset, 1,
1278 "Regn. Function: %s",
1279 val_to_str (tvb_get_guint8 (tvb, offset),
1280 fc_els_lirr_regfunc_val,
1281 "Reserved (0x%x)"));
1282 lirr_fmt = tvb_get_guint8 (tvb, offset+1);
1284 /* This scheme is resorted to because the value 0 has a string in
1285 * the value_string that is not what we want displayed here.
1287 proto_tree_add_text (lirr_tree, tvb, offset, 1,
1288 "Regn. Format: Common Format");
1291 proto_tree_add_text (lirr_tree, tvb, offset, 1,
1293 val_to_str (lirr_fmt, fc_fc4_val, "0x%x"));
1299 dissect_fcels_srl (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1300 guint8 isreq, proto_item *ti)
1302 /* Set up structures needed to add the protocol subtree and manage it */
1305 proto_tree *srl_tree;
1308 srl_tree = proto_item_add_subtree (ti, ett_fcels_srl);
1310 proto_tree_add_item (srl_tree, hf_fcels_opcode, tvb, offset-4, 1, FALSE);
1314 flag = tvb_get_guint8 (tvb, offset);
1316 proto_tree_add_text (srl_tree, tvb, offset, 1,
1317 "Flag: Scan only specified FL Port");
1320 proto_tree_add_text (srl_tree, tvb, offset, 1,
1321 "Flag: Scan all loops in domain");
1323 proto_tree_add_text (srl_tree, tvb, offset+1, 3,
1325 fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
1330 dissect_fcels_rpsc (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1331 guint8 isreq, proto_item *ti)
1333 /* Set up structures needed to add the protocol subtree and manage it */
1335 int num_entries, i, cap;
1336 gchar speed_str[40];
1338 proto_tree *rpsc_tree;
1341 rpsc_tree = proto_item_add_subtree (ti, ett_fcels_rpsc);
1343 proto_tree_add_item (rpsc_tree, hf_fcels_opcode, tvb, offset-2, 1, FALSE);
1347 num_entries = tvb_get_ntohs (tvb, offset);
1348 proto_tree_add_text (rpsc_tree, tvb, offset, 2,
1349 "Number of Entries: %u", num_entries);
1351 for (i = 0; i < num_entries; i++) {
1352 cap = tvb_get_ntohs (tvb, offset);
1353 speed_str[0] = '\0';
1356 strcpy (speed_str, "1,");
1360 strcpy (speed_str, "2,");
1364 strcpy (speed_str, "4,");
1368 strcpy (speed_str, "10");
1371 strcpy (&speed_str[stroff], "Gb");
1372 proto_tree_add_text (rpsc_tree, tvb, offset, 2,
1373 "Port Speed Capabilities (Port %u): %s", i,
1375 cap = tvb_get_ntohs (tvb, offset+2);
1376 proto_tree_add_text (rpsc_tree, tvb, offset+2, 2,
1377 "Port Oper Speed: %s",
1378 val_to_str (cap, fc_els_portspeed_val,
1385 dissect_fcels_rnid (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1386 guint8 isreq, proto_item *ti)
1388 /* Set up structures needed to add the protocol subtree and manage it */
1391 proto_tree *rnid_tree;
1394 rnid_tree = proto_item_add_subtree (ti, ett_fcels_rnid);
1396 proto_tree_add_item (rnid_tree, hf_fcels_opcode, tvb, offset, 1, FALSE);
1398 proto_tree_add_item (rnid_tree, hf_fcels_nodeidfmt, tvb, offset+4,
1402 /* We only decode responses to nodeid fmt DF */
1403 proto_tree_add_item (rnid_tree, hf_fcels_nodeidfmt, tvb, offset+4,
1405 clen = tvb_get_guint8 (tvb, offset+5);
1406 proto_tree_add_text (rnid_tree, tvb, offset+5, 1,
1407 "Common Identification Data Length: %u", clen);
1408 slen = tvb_get_guint8 (tvb, offset+7);
1409 proto_tree_add_item (rnid_tree, hf_fcels_spidlen, tvb, offset+7,
1412 proto_tree_add_string (rnid_tree, hf_fcels_npname, tvb,
1414 fcwwn_to_str (tvb_get_ptr (tvb, offset+8,
1416 proto_tree_add_string (rnid_tree, hf_fcels_fnname, tvb,
1418 fcwwn_to_str (tvb_get_ptr (tvb,
1422 if (tvb_get_guint8 (tvb, offset+4) == 0xDF) {
1423 /* Decode the Specific Node ID Format as this is known */
1424 proto_tree_add_item (rnid_tree, hf_fcels_vendoruniq, tvb,
1425 offset+24, 16, FALSE);
1426 proto_tree_add_item (rnid_tree, hf_fcels_asstype, tvb,
1427 offset+40, 4, FALSE);
1428 proto_tree_add_item (rnid_tree, hf_fcels_physport, tvb,
1429 offset+44, 4, FALSE);
1430 proto_tree_add_item (rnid_tree, hf_fcels_attnodes, tvb,
1431 offset+48, 4, FALSE);
1432 proto_tree_add_item (rnid_tree, hf_fcels_nodemgmt, tvb,
1433 offset+52, 1, FALSE);
1434 proto_tree_add_item (rnid_tree, hf_fcels_ipvers, tvb,
1435 offset+53, 1, FALSE);
1436 proto_tree_add_item (rnid_tree, hf_fcels_tcpport, tvb,
1437 offset+54, 2, FALSE);
1438 proto_tree_add_item (rnid_tree, hf_fcels_ip, tvb, offset+56,
1440 proto_tree_add_item (rnid_tree, hf_fcels_vendorsp, tvb,
1441 offset+74, 2, FALSE);
1448 dissect_fcels_rlir (tvbuff_t *tvb _U_, packet_info *pinfo _U_,
1449 proto_tree *tree, guint8 isreq _U_,
1452 /* Set up structures needed to add the protocol subtree and manage it */
1459 dissect_fcels_lsrjt (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1460 guint8 isreq _U_, proto_item *ti)
1462 /* Set up structures needed to add the protocol subtree and manage it */
1464 proto_tree *lsrjt_tree;
1467 lsrjt_tree = proto_item_add_subtree (ti, ett_fcels_lsrjt);
1469 proto_tree_add_item (lsrjt_tree, hf_fcels_opcode, tvb, offset-5, 1, FALSE);
1471 proto_tree_add_item (lsrjt_tree, hf_fcels_rjtcode, tvb, offset++, 1, FALSE);
1472 proto_tree_add_item (lsrjt_tree, hf_fcels_rjtdetcode, tvb, offset++, 1, FALSE);
1473 proto_tree_add_item (lsrjt_tree, hf_fcels_vnduniq, tvb, offset, 1, FALSE);
1478 dissect_fcels (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1481 /* Set up structures needed to add the protocol subtree and manage it */
1482 proto_item *ti = NULL;
1483 proto_tree *acc_tree;
1484 guint8 isreq = FC_ELS_REQ;
1488 conversation_t *conversation;
1489 fcels_conv_data_t *cdata;
1490 fcels_conv_key_t ckey, *req_key;
1495 /* Make entries in Protocol column and Info column on summary display */
1496 if (check_col(pinfo->cinfo, COL_PROTOCOL))
1497 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC ELS");
1499 /* decoding of this is done by each individual opcode handler */
1500 opcode = tvb_get_guint8 (tvb, 0);
1503 ti = proto_tree_add_protocol_format (tree, proto_fcels, tvb, 0,
1504 tvb_length (tvb), "FC ELS");
1507 /* Register conversation in case this is not a response */
1508 if ((opcode != FC_ELS_LSRJT) && (opcode != FC_ELS_ACC)) {
1509 if (opcode == FC_ELS_FLOGI) {
1510 if (pinfo->src.data[2]) {
1511 /* If it is a loop port, we'll need to remember the ALPA */
1515 options = NO_PORT2 | NO_ADDR2;
1521 conversation = find_conversation (&pinfo->dst, &pinfo->src,
1522 pinfo->ptype, pinfo->oxid,
1523 pinfo->rxid, options);
1525 if (!conversation) {
1526 conversation = conversation_new (&pinfo->dst, &pinfo->src,
1527 pinfo->ptype, pinfo->oxid,
1528 pinfo->rxid, options);
1531 ckey.conv_idx = conversation->index;
1533 cdata = (fcels_conv_data_t *)g_hash_table_lookup (fcels_req_hash,
1536 /* Since we never free the memory used by an exchange, this maybe a
1537 * case of another request using the same exchange as a previous
1540 cdata->opcode = opcode;
1543 req_key = g_mem_chunk_alloc (fcels_req_keys);
1544 req_key->conv_idx = conversation->index;
1546 cdata = g_mem_chunk_alloc (fcels_req_vals);
1547 cdata->opcode = opcode;
1549 g_hash_table_insert (fcels_req_hash, req_key, cdata);
1553 isreq = FC_ELS_RPLY;
1556 conversation = find_conversation (&pinfo->dst, &pinfo->src,
1557 pinfo->ptype, pinfo->oxid,
1558 pinfo->rxid, options);
1559 if (!conversation) {
1560 /* FLOGI has two ways to save state: without the src and using just
1561 * the port (ALPA) part of the address. Try both.
1563 addrdata[0] = addrdata[1] = 0;
1564 addrdata[2] = pinfo->dst.data[2];
1565 SET_ADDRESS (&dstaddr, AT_FC, 3, addrdata);
1566 conversation = find_conversation (&dstaddr, &pinfo->src,
1567 pinfo->ptype, pinfo->oxid,
1568 pinfo->rxid, options);
1571 if (!conversation) {
1572 /* Finally check for FLOGI with both NO_PORT2 and NO_ADDR2 set */
1573 options = NO_ADDR2 | NO_PORT2;
1574 conversation = find_conversation (&pinfo->src, &pinfo->dst,
1575 pinfo->ptype, pinfo->oxid,
1576 pinfo->rxid, options);
1577 if (!conversation) {
1578 if (tree && (opcode == FC_ELS_ACC)) {
1579 /* No record of what this accept is for. Can't decode */
1580 acc_tree = proto_item_add_subtree (ti, ett_fcels_acc);
1581 proto_tree_add_text (acc_tree, tvb, offset, tvb_length (tvb),
1582 "No record of Exchange. Unable to decode ACC");
1590 ckey.conv_idx = conversation->index;
1592 cdata = (fcels_conv_data_t *)g_hash_table_lookup (fcels_req_hash, &ckey);
1594 if (cdata != NULL) {
1595 if ((options & NO_ADDR2) && (cdata->opcode != FC_ELS_FLOGI)) {
1596 /* only FLOGI can have this special check */
1597 if (tree && (opcode == FC_ELS_ACC)) {
1598 /* No record of what this accept is for. Can't decode */
1599 acc_tree = proto_item_add_subtree (ti,
1601 proto_tree_add_text (acc_tree, tvb, offset,
1603 "No record of Exchg. Unable to decode ACC");
1607 if (opcode == FC_ELS_ACC)
1608 opcode = cdata->opcode;
1610 failed_opcode = cdata->opcode;
1614 if ((cdata == NULL) && (opcode != FC_ELS_LSRJT)) {
1615 /* No record of what this accept is for. Can't decode */
1616 acc_tree = proto_item_add_subtree (ti, ett_fcels_acc);
1617 proto_tree_add_text (acc_tree, tvb, offset, tvb_length (tvb),
1618 "No record of ELS Req. Unable to decode ACC");
1625 if (check_col (pinfo->cinfo, COL_INFO)) {
1626 if (isreq == FC_ELS_REQ) {
1627 col_add_str (pinfo->cinfo, COL_INFO,
1628 val_to_str (opcode, fc_els_proto_val, "0x%x"));
1630 else if (opcode == FC_ELS_LSRJT) {
1631 col_add_fstr (pinfo->cinfo, COL_INFO, "LS_RJT (%s)",
1632 val_to_str (failed_opcode, fc_els_proto_val, "0x%x"));
1635 col_add_fstr (pinfo->cinfo, COL_INFO, "ACC (%s)",
1636 val_to_str (opcode, fc_els_proto_val, "0x%x"));
1642 dissect_fcels_lsrjt (tvb, pinfo, tree, isreq, ti);
1645 dissect_fcels_plogi (tvb, pinfo, tree, isreq, ti);
1648 dissect_fcels_flogi (tvb, pinfo, tree, isreq, ti);
1651 dissect_fcels_logout (tvb, pinfo, tree, isreq, ti);
1654 dissect_fcels_abtx (tvb, pinfo, tree, isreq, ti);
1657 dissect_fcels_rsi (tvb, pinfo, tree, isreq, ti);
1660 dissect_fcels_rrq (tvb, pinfo, tree, isreq, ti);
1663 dissect_fcels_prli (tvb, pinfo, tree, isreq, ti);
1666 dissect_fcels_prlo (tvb, pinfo, tree, isreq, ti);
1669 dissect_fcels_tprlo (tvb, pinfo, tree, isreq, ti);
1672 dissect_fcels_pdisc (tvb, pinfo, tree, isreq, ti);
1675 dissect_fcels_fdisc (tvb, pinfo, tree, isreq, ti);
1678 dissect_fcels_adisc (tvb, pinfo, tree, isreq, ti);
1680 case FC_ELS_FARP_REQ:
1681 dissect_fcels_farp_req (tvb, pinfo, tree, isreq, ti);
1683 case FC_ELS_FARP_RPLY:
1684 dissect_fcels_farp_rply (tvb, pinfo, tree, isreq, ti);
1687 dissect_fcels_rps (tvb, pinfo, tree, isreq, ti);
1690 dissect_fcels_rpl (tvb, pinfo, tree, isreq, ti);
1693 dissect_fcels_fan (tvb, pinfo, tree, isreq, ti);
1696 dissect_fcels_rscn (tvb, pinfo, tree, isreq, ti);
1699 dissect_fcels_scr (tvb, pinfo, tree, isreq, ti);
1702 dissect_fcels_rnft (tvb, pinfo, tree, isreq, ti);
1705 dissect_fcels_lsts (tvb, pinfo, tree, isreq, ti);
1708 dissect_fcels_rnid (tvb, pinfo, tree, isreq, ti);
1711 dissect_fcels_rlir (tvb, pinfo, tree, isreq, ti);
1714 dissect_fcels_lirr (tvb, pinfo, tree, isreq, ti);
1717 dissect_fcels_srl (tvb, pinfo, tree, isreq, ti);
1720 dissect_fcels_rpsc (tvb, pinfo, tree, isreq, ti);
1723 /* proto_tree_add_text ( */
1724 call_dissector (data_handle, tvb, pinfo, tree);
1730 proto_register_fcels (void)
1733 /* Setup list of header fields See Section 1.6.1 for details*/
1734 static hf_register_info hf[] = {
1736 {"Cmd Code", "fcels.opcode", FT_UINT8, BASE_HEX,
1737 VALS (fc_els_proto_val), 0x0, "", HFILL}},
1738 { &hf_fcels_rjtcode,
1739 {"Reason Code", "fcels.rjt.reason", FT_UINT8, BASE_HEX,
1740 VALS (fc_els_rjt_val), 0x0, "", HFILL}},
1741 { &hf_fcels_rjtdetcode,
1742 {"Reason Explanation", "fcels.rjt.detail", FT_UINT8, BASE_HEX,
1743 VALS (fc_els_rjt_det_val), 0x0, "", HFILL}},
1744 { &hf_fcels_vnduniq,
1745 {"Vendor Unique", "fcels.rjt.vnduniq", FT_UINT8, BASE_HEX, NULL,
1748 {"B2B Credit", "fcels.logi.b2b", FT_UINT8, BASE_DEC, NULL, 0x0, "",
1750 { &hf_fcels_cmnfeatures,
1751 {"Common Features", "fcels.logi.cmnfeatures", FT_UINT16, BASE_HEX, NULL,
1753 { &hf_fcels_bbscnum,
1754 {"BB_SC Number", "fcels.logi.bbscnum", FT_UINT8, BASE_DEC, NULL, 0xF0, "",
1756 { &hf_fcels_rcvsize,
1757 {"Receive Size", "fcels.logi.rcvsize", FT_UINT16, BASE_DEC, NULL, 0x0FFF, "",
1759 { &hf_fcels_maxconseq,
1760 {"Max Concurrent Seq", "fcels.logi.maxconseq", FT_UINT16, BASE_DEC, NULL,
1762 { &hf_fcels_reloffset,
1763 {"Relative Offset By Info Cat", "fcels.logi.reloff", FT_UINT16, BASE_DEC,
1764 NULL, 0x0, "", HFILL}},
1766 {"E_D_TOV", "fcels.edtov", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}},
1768 {"N_Port Port_Name", "fcels.npname", FT_STRING, BASE_HEX, NULL, 0x0,
1771 {"Fabric/Node Name", "fcels.fnname", FT_STRING, BASE_HEX, NULL, 0x0,
1773 { &hf_fcels_cls1param,
1774 {"Class 1 Svc Param", "fcels.logi.cls1param", FT_BYTES, BASE_HEX, NULL, 0x0,
1776 { &hf_fcels_cls2param,
1777 {"Class 2 Svc Param", "fcels.logi.cls2param", FT_BYTES, BASE_HEX, NULL, 0x0,
1779 { &hf_fcels_cls3param,
1780 {"Class 3 Svc Param", "fcels.logi.cls3param", FT_BYTES, BASE_HEX, NULL, 0x0,
1782 { &hf_fcels_cls4param,
1783 {"Class 4 Svc Param", "fcels.logi.cls4param", FT_BYTES, BASE_HEX, NULL, 0x0,
1785 { &hf_fcels_vendorvers,
1786 {"Vendor Version", "fcels.logi.vendvers", FT_BYTES, BASE_HEX, NULL, 0x0, "",
1788 { &hf_fcels_svcavail,
1789 {"Services Availability", "fcels.logi.svcavail", FT_BYTES, BASE_HEX, NULL,
1791 { &hf_fcels_clsflags,
1792 {"Class Flags", "fcels.logi.clsflags", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1794 { &hf_fcels_initctl,
1795 {"Initiator Ctl", "fcels.logi.initctl", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1797 { &hf_fcels_rcptctl,
1798 {"Recipient Ctl", "fcels.logi.rcptctl", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1800 { &hf_fcels_clsrcvsize,
1801 {"Class Recv Size", "fcels.logi.clsrcvsize", FT_UINT16, BASE_DEC, NULL,
1804 {"Total Concurrent Seq", "fcels.logi.totconseq", FT_UINT8, BASE_DEC, NULL,
1807 {"End2End Credit", "fcels.logi.e2e", FT_UINT16, BASE_DEC, NULL, 0x0, "",
1809 { &hf_fcels_openseq,
1810 {"Open Seq Per Exchg", "fcels.logi.openseq", FT_UINT8, BASE_DEC, NULL, 0x0,
1812 { &hf_fcels_nportid,
1813 {"Originator S_ID", "fcels.portid", FT_STRING, BASE_HEX, NULL, 0x0,
1816 {"OXID", "fcels.oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1818 {"RXID", "fcels.rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1819 { &hf_fcels_recovqual,
1820 {"Recovery Qualifier", "fcels.rcovqual", FT_UINT8, BASE_HEX, NULL,
1822 { &hf_fcels_fabricaddr,
1823 {"Fabric Address", "fcels.faddr", FT_STRING, BASE_HEX, NULL, 0x0, "",
1825 { &hf_fcels_fabricpname,
1826 {"Fabric Port Name", "fcels.fpname", FT_STRING, BASE_HEX, NULL, 0x0,
1828 { &hf_fcels_failedrcvr,
1829 {"Failed Receiver AL_PA", "fcels.faildrcvr", FT_UINT8, BASE_HEX, NULL,
1831 { &hf_fcels_flacompliance,
1832 {"FC-FLA Compliance", "fcels.flacompliance", FT_UINT8, BASE_HEX,
1833 VALS (fc_els_flacompliance_val), 0x0, "", HFILL}},
1834 { &hf_fcels_loopstate,
1835 {"Loop State", "fcels.loopstate", FT_UINT8, BASE_HEX,
1836 VALS (fc_els_loopstate_val), 0x0, "", HFILL}},
1837 { &hf_fcels_publicloop_bmap,
1838 {"Public Loop Device Bitmap", "fcels.pubdev_bmap", FT_BYTES, BASE_HEX,
1839 NULL, 0x0, "", HFILL}},
1840 { &hf_fcels_pvtloop_bmap,
1841 {"Private Loop Device Bitmap", "fcels.pvtdev_bmap", FT_BYTES,
1842 BASE_HEX, NULL, 0x0, "", HFILL}},
1843 { &hf_fcels_alpa_map,
1844 {"AL_PA Map", "fcels.alpa", FT_BYTES, BASE_HEX, NULL, 0x0, "",
1846 { &hf_fcels_scrregn,
1847 {"Registration Function", "fcels.scr.regn", FT_UINT8, BASE_HEX,
1848 VALS (fc_els_scr_reg_val), 0x0, "", HFILL}},
1849 { &hf_fcels_farp_matchcodept,
1850 {"Match Address Code Points", "fcels.matchcp", FT_UINT8, BASE_BIN,
1851 NULL, 0x0, "", HFILL}},
1852 { &hf_fcels_farp_respaction,
1853 {"Responder Action", "fcels.respaction", FT_UINT8, BASE_HEX,
1854 VALS (fc_els_farp_respaction_val), 0x0, "", HFILL}},
1855 { &hf_fcels_resportid,
1856 {"Responding Port ID", "fcels.resportid", FT_STRING, BASE_HEX,
1857 NULL, 0x0, "", HFILL}},
1858 { &hf_fcels_respname,
1859 {"Responding Port Name", "fcels.respname", FT_STRING, BASE_HEX,
1860 NULL, 0x0, "", HFILL}},
1861 { &hf_fcels_respnname,
1862 {"Responding Node Name", "fcels.respnname", FT_STRING, BASE_HEX,
1863 NULL, 0x0, "", HFILL}},
1864 { &hf_fcels_reqipaddr,
1865 {"Requesting IP Address", "fcels.reqipaddr", FT_IPv6, BASE_DEC,
1866 NULL, 0x0, "", HFILL}},
1867 { &hf_fcels_respipaddr,
1868 {"Responding IP Address", "fcels.respipaddr", FT_IPv6, BASE_DEC,
1869 NULL, 0x0, "", HFILL}},
1870 { &hf_fcels_hardaddr,
1871 {"Hard Address of Originator", "fcels.hrdaddr", FT_STRING, BASE_HEX,
1872 NULL, 0x0, "", HFILL}},
1873 { &hf_fcels_rps_flag,
1874 {"Flag", "fcels.flag", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1875 { &hf_fcels_rps_portnum,
1876 {"Physical Port Number", "fcels.portnum", FT_UINT32, BASE_HEX, NULL,
1878 { &hf_fcels_rps_portstatus,
1879 {"Port Status", "fcels.portstatus", FT_UINT16, BASE_HEX,
1880 VALS(fc_els_portstatus_val), 0x0, "", HFILL}},
1881 { &hf_fcels_rnft_fc4type,
1882 {"FC-4 Type", "fcels.rnft.fc4type", FT_UINT8, BASE_HEX,
1883 VALS (fc_fc4_val), 0x0, "", HFILL}},
1884 { &hf_fcels_rscn_evqual,
1885 {"Event Qualifier", "fcels.rscn.evqual", FT_UINT8, BASE_HEX,
1886 VALS (fc_els_rscn_evqual_val), 0x3C, "", HFILL}},
1887 { &hf_fcels_rscn_addrfmt,
1888 {"Address Format", "fcels.rscn.addrfmt", FT_UINT8, BASE_HEX,
1889 VALS (fc_els_rscn_addrfmt_val), 0x03, "", HFILL}},
1890 { &hf_fcels_rscn_domain,
1891 {"Affected Domain", "fcels.rscn.domain", FT_UINT8, BASE_HEX,
1892 NULL, 0x0, "", HFILL}},
1893 { &hf_fcels_rscn_area,
1894 {"Affected Area", "fcels.rscn.area", FT_UINT8, BASE_HEX,
1895 NULL, 0x0, "", HFILL}},
1896 { &hf_fcels_rscn_port,
1897 {"Affected Port", "fcels.rscn.port", FT_UINT8, BASE_HEX,
1898 NULL, 0x0, "", HFILL}},
1899 { &hf_fcels_nodeidfmt,
1900 {"Node Identification Format", "fcels.rnid.nodeidfmt", FT_UINT8,
1901 BASE_HEX, VALS (fc_els_nodeid_val), 0x0, "", HFILL}},
1902 { &hf_fcels_spidlen,
1903 {"Specific Id Length", "fcels.rnid.spidlen", FT_UINT8, BASE_DEC, NULL,
1905 { &hf_fcels_vendoruniq,
1906 {"Vendor Unique", "fcels.rnid.vendoruniq", FT_BYTES, BASE_HEX, NULL,
1908 { &hf_fcels_vendorsp,
1909 {"Vendor Specific", "fcels.rnid.vendorsp", FT_UINT16, BASE_HEX, NULL,
1911 { &hf_fcels_asstype,
1912 {"Associated Type", "fcels.rnid.asstype", FT_UINT32, BASE_HEX,
1913 VALS (fc_els_rnid_asstype_val), 0x0, "", HFILL}},
1914 { &hf_fcels_physport,
1915 {"Physical Port Number", "fcels.rnid.physport", FT_UINT32, BASE_HEX,
1916 NULL, 0x0, "", HFILL}},
1917 { &hf_fcels_attnodes,
1918 {"Number of Attached Nodes", "fcels.rnid.attnodes", FT_UINT32,
1919 BASE_HEX, NULL, 0x0, "", HFILL}},
1920 { &hf_fcels_nodemgmt,
1921 {"Node Management", "fcels.rnid.nodemgmt", FT_UINT8, BASE_HEX,
1922 VALS (fc_els_rnid_mgmt_val), 0x0, "", HFILL}},
1924 {"IP Version", "fcels.rnid.ipvers", FT_UINT8, BASE_HEX,
1925 VALS (fc_els_rnid_ipvers_val), 0x0, "", HFILL}},
1926 { &hf_fcels_tcpport,
1927 {"TCP/UDP Port Number", "fcels.rnid.tcpport", FT_UINT16, BASE_DEC,
1928 NULL, 0x0, "", HFILL}},
1930 {"IP Address", "fcels.rnid.ip", FT_IPv6, BASE_HEX, NULL, 0x0, "",
1934 static gint *ett[] = {
1940 &ett_fcels_logi_cmnsvc,
1941 &ett_fcels_logi_clssvc,
1947 &ett_fcels_prli_svcpg,
1955 &ett_fcels_rscn_rec,
1958 &ett_fcels_rnft_fc4,
1967 /* Register the protocol name and description */
1968 proto_fcels = proto_register_protocol("FC Extended Link Svc", "FC ELS", "els");
1970 /* Required function calls to register the header fields and subtrees used */
1971 proto_register_field_array(proto_fcels, hf, array_length(hf));
1972 proto_register_subtree_array(ett, array_length(ett));
1973 register_init_routine (&fcels_init_protocol);
1977 proto_reg_handoff_fcels (void)
1979 dissector_handle_t els_handle;
1981 els_handle = create_dissector_handle (dissect_fcels, proto_fcels);
1982 dissector_add("fc.ftype", FC_FTYPE_ELS, els_handle);
1984 data_handle = find_dissector ("data");