2 * Routines for Fibre Channel Decoding (FC Header, Link Ctl & Basic Link Svc)
3 * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
4 * Copyright 2003 Ronnie Sahlberg, exchange first/last matching and
5 * tap listener and misc updates
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #ifdef HAVE_SYS_TYPES_H
38 # include <sys/types.h>
41 #ifdef HAVE_NETINET_IN_H
42 # include <netinet/in.h>
47 #include <epan/packet.h>
48 #include <epan/prefs.h>
49 #include <epan/reassemble.h>
50 #include <epan/conversation.h>
52 #include "packet-fc.h"
53 #include "packet-fclctl.h"
54 #include "packet-fcbls.h"
56 #include <epan/emem.h>
58 #define FC_HEADER_SIZE 24
59 #define FC_RCTL_EISL 0x50
60 #define MDSHDR_TRAILER_SIZE 6
62 /* Size of various fields in FC header in bytes */
63 #define FC_RCTL_SIZE 1
65 #define FC_CSCTL_SIZE 1
67 #define FC_TYPE_SIZE 1
68 #define FC_FCTL_SIZE 3
69 #define FC_SEQID_SIZE 1
70 #define FC_DFCTL_SIZE 1
71 #define FC_SEQCNT_SIZE 2
72 #define FC_OXID_SIZE 2
73 #define FC_RXID_SIZE 2
74 #define FC_PARAM_SIZE 4
76 /* Initialize the protocol and registered fields */
77 static int proto_fc = -1;
78 static int hf_fc_time = -1;
79 static int hf_fc_exchange_first_frame = -1;
80 static int hf_fc_exchange_last_frame = -1;
81 static int hf_fc_rctl = -1;
82 static int hf_fc_did = -1;
83 static int hf_fc_csctl = -1;
84 static int hf_fc_sid = -1;
85 static int hf_fc_id = -1;
86 static int hf_fc_type = -1;
87 static int hf_fc_fctl = -1;
88 static int hf_fc_fctl_exchange_responder = -1;
89 static int hf_fc_fctl_seq_recipient = -1;
90 static int hf_fc_fctl_exchange_first = -1;
91 static int hf_fc_fctl_exchange_last = -1;
92 static int hf_fc_fctl_seq_last = -1;
93 static int hf_fc_fctl_priority = -1;
94 static int hf_fc_fctl_transfer_seq_initiative = -1;
95 static int hf_fc_fctl_rexmitted_seq = -1;
96 static int hf_fc_fctl_rel_offset = -1;
97 static int hf_fc_fctl_abts_ack = -1;
98 static int hf_fc_fctl_abts_not_ack = -1;
99 static int hf_fc_fctl_last_data_frame = -1;
100 static int hf_fc_fctl_ack_0_1 = -1;
101 static int hf_fc_seqid = -1;
102 static int hf_fc_dfctl = -1;
103 static int hf_fc_seqcnt = -1;
104 static int hf_fc_oxid = -1;
105 static int hf_fc_rxid = -1;
106 static int hf_fc_param = -1;
107 static int hf_fc_ftype = -1; /* Derived field, non-existent in FC hdr */
108 static int hf_fc_reassembled = -1;
109 static int hf_fc_eisl = -1;
111 /* Network_Header fields */
112 static int hf_fc_nh_da = -1;
113 static int hf_fc_nh_sa = -1;
115 /* For Basic Link Svc */
116 static int hf_fc_bls_seqid_vld = -1;
117 static int hf_fc_bls_lastvld_seqid = -1;
118 static int hf_fc_bls_oxid = -1;
119 static int hf_fc_bls_rxid = -1;
120 static int hf_fc_bls_lowseqcnt = -1;
121 static int hf_fc_bls_hiseqcnt = -1;
122 static int hf_fc_bls_rjtcode = -1;
123 static int hf_fc_bls_rjtdetail = -1;
124 static int hf_fc_bls_vendor = -1;
127 /* Initialize the subtree pointers */
128 static gint ett_fc = -1;
129 static gint ett_fctl = -1;
130 static gint ett_fcbls = -1;
132 static dissector_table_t fcftype_dissector_table;
133 static dissector_handle_t data_handle;
135 static int fc_tap = -1;
137 /* Reassembly stuff */
138 static gboolean fc_reassemble = TRUE;
139 static guint32 fc_max_frame_size = 1024;
140 static GHashTable *fc_fragment_table = NULL;
142 typedef struct _fcseq_conv_key {
146 typedef struct _fcseq_conv_data {
150 GHashTable *fcseq_req_hash = NULL;
152 static GHashTable *fc_exchange_unmatched = NULL;
153 static GHashTable *fc_exchange_matched = NULL;
159 fcseq_equal(gconstpointer v, gconstpointer w)
161 const fcseq_conv_key_t *v1 = v;
162 const fcseq_conv_key_t *v2 = w;
164 return (v1->conv_idx == v2->conv_idx);
168 fcseq_hash (gconstpointer v)
170 const fcseq_conv_key_t *key = v;
179 fc_exchange_hash_unmatched(gconstpointer v)
181 const fc_exchange_data *fced=(const fc_exchange_data *)v;
186 fc_exchange_equal_unmatched(gconstpointer v1, gconstpointer v2)
188 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
189 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
191 /* oxid must match */
192 if(fced1->oxid!=fced2->oxid){
195 /* compare s_id, d_id and treat the fc address
196 s_id==00.00.00 as a wildcard matching anything */
197 if( ((fced1->s_id.data[0]!=0)||(fced1->s_id.data[1]!=0)||(fced1->s_id.data[2]!=0)) && CMP_ADDRESS(&fced1->s_id, &fced2->s_id) ){
200 if(CMP_ADDRESS(&fced1->d_id, &fced2->d_id)){
208 fc_exchange_hash_matched(gconstpointer v)
210 const fc_exchange_data *fced=(const fc_exchange_data *)v;
215 fc_exchange_equal_matched(gconstpointer v1, gconstpointer v2)
217 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
218 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
219 guint32 fef1, fef2, lef1, lef2;
221 /* oxid must match */
222 if(fced1->oxid!=fced2->oxid){
225 fef1=fced1->first_exchange_frame;
226 fef2=fced2->first_exchange_frame;
227 lef1=fced1->last_exchange_frame;
228 lef2=fced2->last_exchange_frame;
245 fc_exchange_init_protocol(void)
247 if(fc_exchange_unmatched){
248 g_hash_table_destroy(fc_exchange_unmatched);
249 fc_exchange_unmatched=NULL;
251 if(fc_exchange_matched){
252 g_hash_table_destroy(fc_exchange_matched);
253 fc_exchange_matched=NULL;
256 fc_exchange_unmatched=g_hash_table_new(fc_exchange_hash_unmatched, fc_exchange_equal_unmatched);
257 fc_exchange_matched=g_hash_table_new(fc_exchange_hash_matched, fc_exchange_equal_matched);
259 fragment_table_init(&fc_fragment_table);
262 g_hash_table_destroy(fcseq_req_hash);
264 fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal);
268 const value_string fc_fc4_val[] = {
269 {FC_TYPE_ELS, "Ext Link Svc"},
270 {FC_TYPE_LLCSNAP, "LLC_SNAP"},
271 {FC_TYPE_IP, "IP/FC"},
272 {FC_TYPE_SCSI, "FCP"},
273 {FC_TYPE_FCCT, "FC_CT"},
274 {FC_TYPE_SWILS, "SW_ILS"},
276 {FC_TYPE_SNMP, "SNMP"},
277 {FC_TYPE_SB_FROM_CU, "SB-3(CU->Channel)"},
278 {FC_TYPE_SB_TO_CU, "SB-3(Channel->CU)"},
282 static const value_string fc_ftype_vals [] = {
283 {FC_FTYPE_UNDEF , "Unknown frame"},
284 {FC_FTYPE_SWILS, "SW_ILS"},
285 {FC_FTYPE_IP , "IP/FC"},
286 {FC_FTYPE_SCSI , "FCP"},
287 {FC_FTYPE_BLS , "Basic Link Svc"},
288 {FC_FTYPE_ELS , "ELS"},
289 {FC_FTYPE_FCCT , "FC_CT"},
290 {FC_FTYPE_LINKDATA, "Link Data"},
291 {FC_FTYPE_VDO, "Video Data"},
292 {FC_FTYPE_LINKCTL, "Link Ctl"},
293 {FC_FTYPE_SBCCS, "SBCCS"},
297 static const value_string fc_wka_vals[] = {
298 {FC_WKA_MULTICAST, "Multicast Server"},
299 {FC_WKA_CLKSYNC, "Clock Sync Server"},
300 {FC_WKA_KEYDIST, "Key Distribution Server"},
301 {FC_WKA_ALIAS, "Alias Server"},
302 {FC_WKA_QOSF, "QoS Facilitator"},
303 {FC_WKA_MGMT, "Management Server"},
304 {FC_WKA_TIME, "Time Server"},
305 {FC_WKA_DNS, "Directory Server"},
306 {FC_WKA_FABRIC_CTRLR, "Fabric Ctlr"},
307 {FC_WKA_FPORT, "F_Port Server"},
308 {FC_WKA_BCAST, "Broadcast ID"},
312 static const value_string fc_routing_val[] = {
313 {FC_RCTL_DEV_DATA, "Device_Data"},
314 {FC_RCTL_ELS, "Extended Link Services"},
315 {FC_RCTL_LINK_DATA, "FC-4 Link_Data"},
316 {FC_RCTL_VIDEO, "Video_Data"},
317 {FC_RCTL_BLS, "Basic Link Services"},
318 {FC_RCTL_LINK_CTL, "Link_Control Frame"},
322 static const value_string fc_iu_val[] = {
323 {FC_IU_UNCATEGORIZED , "Uncategorized Data"},
324 {FC_IU_SOLICITED_DATA , "Solicited Data"},
325 {FC_IU_UNSOLICITED_CTL , "Unsolicited Control"},
326 {FC_IU_SOLICITED_CTL , "Solicited Control"},
327 {FC_IU_UNSOLICITED_DATA, "Solicited Data"},
328 {FC_IU_DATA_DESCRIPTOR , "Data Descriptor"},
329 {FC_IU_UNSOLICITED_CMD , "Unsolicited Command"},
330 {FC_IU_CMD_STATUS , "Command Status"},
335 static void fc_defragment_init(void)
337 fragment_table_init (&fc_fragment_table);
342 fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack)
350 if (fctl[2] & 0x80) {
351 strcpy (str, "Exchange Responder, ");
355 strcpy (str, "Exchange Originator, ");
359 if (fctl[2] & 0x40) {
360 strcpy (&str[stroff], "Seq Recipient, ");
364 strcpy (&str[stroff], "Seq Initiator, ");
368 if (fctl[2] & 0x20) {
369 strcpy (&str[stroff], "Exchg First, ");
373 if (fctl[2] & 0x10) {
374 strcpy (&str[stroff], "Exchg Last, ");
379 strcpy (&str[stroff], "Seq Last, ");
384 strcpy (&str[stroff], "Priority, ");
388 strcpy (&str[stroff], "CS_CTL, ");
393 strcpy (&str[stroff], "Transfer Seq Initiative, ");
397 if (fctl[1] & 0x30) {
398 strcpy (&str[stroff], "ACK_0 Reqd, ");
401 else if (fctl[1] & 0x10) {
402 strcpy (&str[stroff], "ACK_1 Reqd, ");
407 strcpy (&str[stroff], "Rexmitted Seq, ");
411 tmp = fctl[0] & 0xC0;
414 strcpy (&str[stroff], "Last Data Frame - No Info, ");
418 strcpy (&str[stroff], "Last Data Frame - Seq Imm, ");
422 strcpy (&str[stroff], "Last Data Frame - Seq Soon, ");
426 strcpy (&str[stroff], "Last Data Frame - Seq Delyd, ");
431 tmp = fctl[0] & 0x30;
435 strcpy (&str[stroff], "ABTS - Cont, ");
439 strcpy (&str[stroff], "ABTS - Abort/MS, ");
445 strcpy (&str[stroff], "ABTS - AbortABTS - Abort, ");
449 strcpy (&str[stroff], "ABTS - Abort/SS, ");
455 strcpy (&str[stroff], "ABTS - Stop, ");
459 strcpy (&str[stroff], "ABTS - Process/IB, ");
465 strcpy (&str[stroff], "ABTS - Imm Seq Retx, ");
469 strcpy (&str[stroff], "ABTS - Discard/MS/Imm Retx, ");
476 strcpy (&str[stroff], "Rel Offset = 1");
483 /* BA_ACC & BA_RJT are decoded in this file itself instead of a traditional
484 * dedicated file and dissector format because the dissector would require some
485 * fields of the FC_HDR such as param in some cases, type in some others, the
486 * lower 4 bits of r_ctl in some other cases etc. So, we decode BLS & Link Ctl
487 * in this file itself.
490 dissect_fc_ba_acc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
492 /* Set up structures needed to add the protocol subtree and manage it */
494 proto_tree *acc_tree;
497 /* Make entries in Protocol column and Info column on summary display */
498 if (check_col(pinfo->cinfo, COL_PROTOCOL))
499 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
501 if (check_col(pinfo->cinfo, COL_INFO))
502 col_set_str(pinfo->cinfo, COL_INFO, "BA_ACC");
505 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
506 acc_tree = proto_item_add_subtree (ti, ett_fcbls);
508 proto_tree_add_item (acc_tree, hf_fc_bls_seqid_vld, tvb, offset++, 1, FALSE);
509 proto_tree_add_item (acc_tree, hf_fc_bls_lastvld_seqid, tvb, offset++, 1, FALSE);
510 offset += 2; /* Skip reserved field */
511 proto_tree_add_item (acc_tree, hf_fc_bls_oxid, tvb, offset, 2, FALSE);
513 proto_tree_add_item (acc_tree, hf_fc_bls_rxid, tvb, offset, 2, FALSE);
515 proto_tree_add_item (acc_tree, hf_fc_bls_lowseqcnt, tvb, offset, 2, FALSE);
517 proto_tree_add_item (acc_tree, hf_fc_bls_hiseqcnt, tvb, offset, 2, FALSE);
522 dissect_fc_ba_rjt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
524 /* Set up structures needed to add the protocol subtree and manage it */
526 proto_tree *rjt_tree;
529 /* Make entries in Protocol column and Info column on summary display */
530 if (check_col(pinfo->cinfo, COL_PROTOCOL))
531 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
533 if (check_col(pinfo->cinfo, COL_INFO))
534 col_set_str(pinfo->cinfo, COL_INFO, "BA_RJT");
537 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
538 rjt_tree = proto_item_add_subtree (ti, ett_fcbls);
540 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtcode, tvb, offset+1, 1, FALSE);
541 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtdetail, tvb, offset+2, 1, FALSE);
542 proto_tree_add_item (rjt_tree, hf_fc_bls_vendor, tvb, offset+3, 1, FALSE);
547 fc_get_ftype (guint8 r_ctl, guint8 type)
549 /* A simple attempt to determine the upper level protocol based on the
550 * r_ctl & type fields.
552 switch (r_ctl & 0xF0) {
553 case FC_RCTL_DEV_DATA:
556 if ((r_ctl == 0x2) || (r_ctl == 0x3))
557 return FC_FTYPE_SWILS;
559 return FC_FTYPE_UNDEF;
563 return FC_FTYPE_SCSI;
565 return FC_FTYPE_FCCT;
566 case FC_TYPE_SB_FROM_CU:
567 case FC_TYPE_SB_TO_CU:
568 return FC_FTYPE_SBCCS;
570 return FC_FTYPE_UNDEF;
573 if (((r_ctl & 0x0F) == 0x2) || ((r_ctl & 0x0F) == 0x3))
576 return FC_FTYPE_UNDEF;
577 case FC_RCTL_LINK_DATA:
578 return FC_FTYPE_LINKDATA;
585 return FC_FTYPE_UNDEF;
586 case FC_RCTL_LINK_CTL:
587 return FC_FTYPE_LINKCTL;
589 return FC_FTYPE_UNDEF;
593 static const value_string abts_ack_vals[] = {
594 {0x000000, "ABTS - Cont"},
595 {0x000010, "ABTS - Abort"},
596 {0x000020, "ABTS - Stop"},
597 {0x000030, "ABTS - Imm Seq Retx"},
600 static const value_string abts_not_ack_vals[] = {
601 {0x000000, "ABTS - Abort/MS"},
602 {0x000010, "ABTS - Abort/SS"},
603 {0x000020, "ABTS - Process/IB"},
604 {0x000030, "ABTS - Discard/MS/Imm Retx"},
607 static const value_string last_data_frame_vals[] = {
608 {0x000000, "Last Data Frame - No Info"},
609 {0x004000, "Last Data Frame - Seq Imm"},
610 {0x008000, "Last Data Frame - Seq Soon"},
611 {0x00c000, "Last Data Frame - Seq Delyd"},
614 static const value_string ack_0_1_vals[] = {
615 {0x003000, "ACK_0 Required"},
616 {0x002000, "ACK_0 Required"},
617 {0x001000, "ACK_1 Required"},
618 {0x000000, "no ack required"},
621 static const true_false_string tfs_fc_fctl_exchange_responder = {
622 "Exchange Responder",
623 "Exchange Originator"
625 static const true_false_string tfs_fc_fctl_seq_recipient = {
629 static const true_false_string tfs_fc_fctl_exchange_first = {
633 static const true_false_string tfs_fc_fctl_exchange_last = {
637 static const true_false_string tfs_fc_fctl_seq_last = {
641 static const true_false_string tfs_fc_fctl_priority = {
645 static const true_false_string tfs_fc_fctl_transfer_seq_initiative = {
646 "Transfer Seq Initiative",
647 "NOT transfer seq initiative"
649 static const true_false_string tfs_fc_fctl_rexmitted_seq = {
650 "Retransmitted Sequence",
651 "NOT retransmitted sequence"
653 static const true_false_string tfs_fc_fctl_rel_offset = {
661 /* code to dissect the F_CTL bitmask */
663 dissect_fc_fctl(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gboolean is_ack, guint32 fctl)
669 item=proto_tree_add_uint(parent_tree, hf_fc_fctl, tvb, offset, 3, fctl);
670 tree=proto_item_add_subtree(item, ett_fctl);
673 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_responder, tvb, offset, 3, fctl);
675 proto_tree_add_boolean(tree, hf_fc_fctl_seq_recipient, tvb, offset, 3, fctl);
677 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_first, tvb, offset, 3, fctl);
679 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_last, tvb, offset, 3, fctl);
681 proto_tree_add_boolean(tree, hf_fc_fctl_seq_last, tvb, offset, 3, fctl);
683 proto_tree_add_boolean(tree, hf_fc_fctl_priority, tvb, offset, 3, fctl);
685 proto_tree_add_boolean(tree, hf_fc_fctl_transfer_seq_initiative, tvb, offset, 3, fctl);
687 proto_tree_add_uint(tree, hf_fc_fctl_last_data_frame, tvb, offset, 3, fctl);
689 proto_tree_add_uint(tree, hf_fc_fctl_ack_0_1, tvb, offset, 3, fctl);
692 proto_tree_add_boolean(tree, hf_fc_fctl_rexmitted_seq, tvb, offset, 3, fctl);
695 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, fctl);
697 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, fctl);
700 proto_tree_add_boolean(tree, hf_fc_fctl_rel_offset, tvb, offset, 3, fctl);
702 fctl_to_str( ((guint8 *)&fctl), str, is_ack);
703 proto_item_append_text(item, " %s", str);
706 static const value_string fc_bls_proto_val[] = {
707 {FC_BLS_NOP , "NOP"},
708 {FC_BLS_ABTS , "ABTS"},
709 {FC_BLS_RMC , "RMC"},
710 {FC_BLS_BAACC , "BA_ACC"},
711 {FC_BLS_BARJT , "BA_RJT"},
712 {FC_BLS_PRMT , "PRMT"},
716 static const value_string fc_els_proto_val[] = {
717 {0x01 , "Solicited Data"},
723 /* Code to actually dissect the packets */
725 dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_ifcp)
727 /* Set up structures needed to add the protocol subtree and manage it */
729 proto_tree *fc_tree = NULL;
731 int offset = 0, next_offset, eisl_offset = -1;
732 gboolean is_lastframe_inseq, is_1frame_inseq, is_valid_frame;
733 gboolean is_exchg_resp = 0;
734 fragment_data *fcfrag_head;
737 guint8 df_ctl, seq_id;
745 fc_exchange_data *fc_ex=NULL;
747 conversation_t *conversation;
748 fcseq_conv_data_t *cdata;
749 fcseq_conv_key_t ckey, *req_key;
753 /* Make entries in Protocol column and Info column on summary display */
754 if (check_col(pinfo->cinfo, COL_PROTOCOL))
755 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC");
757 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
759 /* If the R_CTL is the EISL field, skip the first 8 bytes to retrieve the
760 * real FC header. EISL is Cisco-proprietary and is not decoded.
762 if (fchdr.r_ctl == FC_RCTL_EISL) {
763 eisl_offset = offset;
765 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
768 /* Each fc endpoint pair gets its own TCP session in iFCP but
769 * the src/dst ids are undefined(==semi-random) in the FC header.
770 * This means we can no track conversations for FC over iFCP by using
771 * the FC src/dst addresses.
772 * For iFCP: Do not update the pinfo src/dst struct and let it remain
773 * being tcpip src/dst so that request/response matching in the FCP layer
774 * will use ip addresses instead and still work.
777 SET_ADDRESS (&pinfo->dst, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
778 SET_ADDRESS (&pinfo->src, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
782 SET_ADDRESS (&fchdr.d_id, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
783 SET_ADDRESS (&fchdr.s_id, pinfo->src.type, pinfo->src.len, pinfo->src.data);
785 fchdr.cs_ctl = tvb_get_guint8 (tvb, offset+4);
786 fchdr.type = tvb_get_guint8 (tvb, offset+8);
787 fchdr.fctl=tvb_get_ntoh24(tvb,offset+9);
788 fchdr.seqcnt = tvb_get_ntohs (tvb, offset+14);
789 fchdr.oxid=tvb_get_ntohs(tvb,offset+16);
790 fchdr.rxid=tvb_get_ntohs(tvb,offset+18);
791 param = tvb_get_ntohl (tvb, offset+20);
792 seq_id = tvb_get_guint8 (tvb, offset+12);
794 pinfo->oxid = fchdr.oxid;
795 pinfo->rxid = fchdr.rxid;
796 pinfo->ptype = PT_EXCHG;
797 pinfo->r_ctl = fchdr.r_ctl;
799 is_ack = ((fchdr.r_ctl == 0xC0) || (fchdr.r_ctl == 0xC1));
801 /* There are two ways to determine if this is the first frame of a
803 * (i) The SOF bits indicate that this is the first frame OR
804 * (ii) This is an SOFf frame and seqcnt is 0.
806 is_1frame_inseq = (((pinfo->sof_eof & PINFO_SOF_FIRST_FRAME) == PINFO_SOF_FIRST_FRAME) ||
807 (((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) &&
808 (fchdr.seqcnt == 0)));
810 is_lastframe_inseq = ((pinfo->sof_eof & PINFO_EOF_LAST_FRAME) == PINFO_EOF_LAST_FRAME);
812 if ((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) {
813 is_lastframe_inseq = fchdr.fctl & FC_FCTL_SEQ_LAST;
815 is_valid_frame = ((pinfo->sof_eof & 0x40) == 0x40);
817 ftype = fc_get_ftype (fchdr.r_ctl, fchdr.type);
819 if (check_col (pinfo->cinfo, COL_INFO)) {
820 col_add_str (pinfo->cinfo, COL_INFO, val_to_str (ftype, fc_ftype_vals,
821 "Unknown Type (0x%x)"));
823 if (ftype == FC_FTYPE_LINKCTL)
824 col_append_fstr (pinfo->cinfo, COL_INFO, ", %s",
825 val_to_str ((fchdr.r_ctl & 0x0F),
830 /* In the interest of speed, if "tree" is NULL, don't do any work not
831 necessary to generate protocol tree items. */
833 ti = proto_tree_add_protocol_format (tree, proto_fc, tvb, offset,
834 FC_HEADER_SIZE, "Fibre Channel");
835 fc_tree = proto_item_add_subtree (ti, ett_fc);
838 /* Highlight EISL header, if present */
839 if (eisl_offset != -1) {
840 proto_tree_add_item (fc_tree, hf_fc_eisl, tvb, eisl_offset, 8, 0);
843 /* match first exchange with last exchange */
844 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
845 if(!pinfo->fd->flags.visited){
846 fc_exchange_data fced, *old_fced;
848 /* first check if we already have seen this exchange and it
849 is still open/unmatched.
851 fced.oxid=fchdr.oxid;
852 SET_ADDRESS(&fced.s_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
853 SET_ADDRESS(&fced.d_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
854 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
856 g_hash_table_remove(fc_exchange_unmatched, old_fced);
858 old_fced=se_alloc(sizeof(fc_exchange_data));
859 old_fced->oxid=fchdr.oxid;
860 COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id);
861 COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id);
862 old_fced->first_exchange_frame=pinfo->fd->num;
863 old_fced->fc_time.nsecs = pinfo->fd->abs_usecs*1000;
864 old_fced->fc_time.secs = pinfo->fd->abs_secs;
865 g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced);
868 fc_exchange_data fced, *old_fced;
869 fced.oxid=fchdr.oxid;
870 fced.first_exchange_frame=pinfo->fd->num;
871 fced.last_exchange_frame=0;
872 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
876 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
877 if(!pinfo->fd->flags.visited){
878 fc_exchange_data fced, *old_fced;
880 fced.oxid=fchdr.oxid;
881 SET_ADDRESS(&fced.s_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
882 SET_ADDRESS(&fced.d_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
883 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
885 g_hash_table_remove(fc_exchange_unmatched, old_fced);
886 old_fced->last_exchange_frame=pinfo->fd->num;
887 g_hash_table_insert(fc_exchange_matched, old_fced, old_fced);
891 fc_exchange_data fced, *old_fced;
892 fced.oxid=fchdr.oxid;
893 fced.first_exchange_frame=0;
894 fced.last_exchange_frame=pinfo->fd->num;
895 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
900 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
901 proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame);
903 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
905 proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame);
906 delta_time.secs = pinfo->fd->abs_secs - fc_ex->fc_time.secs;
907 delta_time.nsecs = pinfo->fd->abs_usecs*1000 - fc_ex->fc_time.nsecs;
908 if (delta_time.nsecs<0){
909 delta_time.nsecs+=1000000000;
912 proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_time);
917 switch (fchdr.r_ctl & 0xF0) {
919 case FC_RCTL_DEV_DATA:
920 case FC_RCTL_LINK_DATA:
922 /* the lower 4 bits of R_CTL are the information category */
923 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
924 FC_RCTL_SIZE, fchdr.r_ctl,
925 "R_CTL: 0x%x(%s/%s)",
927 val_to_str ((fchdr.r_ctl & 0xF0),
928 fc_routing_val, "0x%x"),
929 val_to_str ((fchdr.r_ctl & 0x0F),
933 case FC_RCTL_LINK_CTL:
934 /* the lower 4 bits of R_CTL indicate the type of link ctl frame */
935 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
936 FC_RCTL_SIZE, fchdr.r_ctl,
937 "R_CTL: 0x%x(%s/%s)",
939 val_to_str ((fchdr.r_ctl & 0xF0),
940 fc_routing_val, "0x%x"),
941 val_to_str ((fchdr.r_ctl & 0x0F),
942 fc_lctl_proto_val, "0x%x"));
946 switch (fchdr.type) {
949 /* the lower 4 bits of R_CTL indicate the type of BLS frame */
950 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
951 FC_RCTL_SIZE, fchdr.r_ctl,
952 "R_CTL: 0x%x(%s/%s)",
954 val_to_str ((fchdr.r_ctl & 0xF0),
955 fc_routing_val, "0x%x"),
956 val_to_str ((fchdr.r_ctl & 0x0F),
957 fc_bls_proto_val, "0x%x"));
961 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
962 FC_RCTL_SIZE, fchdr.r_ctl,
963 "R_CTL: 0x%x(%s/0x%x)",
965 val_to_str ((fchdr.r_ctl & 0xF0),
966 fc_routing_val, "0x%x"),
973 switch (fchdr.type) {
976 /* the lower 4 bits of R_CTL indicate the type of ELS frame */
977 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
978 FC_RCTL_SIZE, fchdr.r_ctl,
979 "R_CTL: 0x%x(%s/%s)",
981 val_to_str ((fchdr.r_ctl & 0xF0),
982 fc_routing_val, "0x%x"),
983 val_to_str ((fchdr.r_ctl & 0x0F),
984 fc_els_proto_val, "0x%x"));
988 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
989 FC_RCTL_SIZE, fchdr.r_ctl,
990 "R_CTL: 0x%x(%s/0x%x)",
992 val_to_str ((fchdr.r_ctl & 0xF0),
993 fc_routing_val, "0x%x"),
1000 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
1001 FC_RCTL_SIZE, fchdr.r_ctl,
1002 "R_CTL: 0x%x(%s/0x%x)",
1004 val_to_str ((fchdr.r_ctl & 0xF0),
1005 fc_routing_val, "0x%x"),
1006 fchdr.r_ctl & 0x0F);
1010 proto_tree_add_uint_hidden (fc_tree, hf_fc_ftype, tvb, offset, 1,
1013 /* XXX - use "fc_wka_vals[]" on this? */
1014 proto_tree_add_string (fc_tree, hf_fc_did, tvb, offset+1, 3,
1015 fc_to_str (fchdr.d_id.data));
1016 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+1, 3,
1017 fc_to_str (fchdr.d_id.data));
1019 proto_tree_add_uint (fc_tree, hf_fc_csctl, tvb, offset+4, 1, fchdr.cs_ctl);
1021 /* XXX - use "fc_wka_vals[]" on this? */
1022 proto_tree_add_string (fc_tree, hf_fc_sid, tvb, offset+5, 3,
1023 fc_to_str (fchdr.s_id.data));
1024 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+5, 3,
1025 fc_to_str (fchdr.s_id.data));
1027 if (ftype == FC_FTYPE_LINKCTL) {
1028 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYB) ||
1029 ((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYL)) {
1030 /* for F_BSY frames, the upper 4 bits of the type field specify the
1031 * reason for the BSY.
1033 proto_tree_add_uint_format (fc_tree, hf_fc_type, tvb,
1034 offset+8, FC_TYPE_SIZE,
1035 fchdr.type,"Type: 0x%x(%s)", fchdr.type,
1036 fclctl_get_typestr ((guint8) (fchdr.r_ctl & 0x0F),
1039 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1042 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1046 dissect_fc_fctl(pinfo, fc_tree, tvb, offset+9, is_ack, fchdr.fctl);
1049 proto_tree_add_item (fc_tree, hf_fc_seqid, tvb, offset+12, 1, FALSE);
1051 df_ctl = tvb_get_guint8(tvb, offset+13);
1053 proto_tree_add_uint (fc_tree, hf_fc_dfctl, tvb, offset+13, 1, df_ctl);
1054 proto_tree_add_uint (fc_tree, hf_fc_seqcnt, tvb, offset+14, 2, fchdr.seqcnt);
1055 proto_tree_add_uint (fc_tree, hf_fc_oxid, tvb, offset+16, 2, fchdr.oxid);
1056 proto_tree_add_uint (fc_tree, hf_fc_rxid, tvb, offset+18, 2, fchdr.rxid);
1058 if (ftype == FC_FTYPE_LINKCTL) {
1059 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FRJT) ||
1060 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PRJT) ||
1061 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PBSY)) {
1062 /* In all these cases of Link Ctl frame, the parameter field
1063 * encodes the detailed error message
1065 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1066 offset+20, 4, param,
1067 "Parameter: 0x%x(%s)", param,
1068 fclctl_get_paramstr ((fchdr.r_ctl & 0x0F),
1071 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1073 } else if (ftype == FC_FTYPE_BLS) {
1074 if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
1075 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1076 offset+20, 4, param,
1077 "Parameter: 0x%x(%s)", param,
1078 ((param & 0x0F) == 1 ? "Abort Sequence" :
1081 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20,
1085 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1088 /* Skip the Frame_Header */
1089 next_offset = offset + FC_HEADER_SIZE;
1091 /* Network_Header present? */
1092 if (df_ctl & FC_DFCTL_NH) {
1093 /* Yes - dissect it. */
1095 proto_tree_add_string (fc_tree, hf_fc_nh_da, tvb, next_offset, 8,
1096 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
1097 proto_tree_add_string (fc_tree, hf_fc_nh_sa, tvb, offset+8, 8,
1098 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
1103 /* XXX - handle Association_Header and Device_Header here */
1105 if (ftype == FC_FTYPE_LINKCTL) {
1106 /* ACK_1 frames and other LINK_CTL frames echo the last seq bit if the
1107 * packet they're ack'ing did not have it set. So, we'll incorrectly
1108 * flag them as being fragmented when they're not. This fixes the
1111 is_lastframe_inseq = TRUE;
1113 /* XXX is this right? offset 20, shouldnt it be offset 9? */
1114 is_exchg_resp = ((tvb_get_guint8 (tvb, offset+20) & 0x80) == 0x80);
1117 if (tvb_reported_length (tvb) <= FC_HEADER_SIZE)
1118 THROW(ReportedBoundsError);
1120 frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE;
1122 /* If there is an MDS header, we need to subtract the MDS trailer size */
1123 if ((pinfo->ethertype == ETHERTYPE_UNK) || (pinfo->ethertype == ETHERTYPE_FCFT)) {
1124 if (frag_size <= MDSHDR_TRAILER_SIZE)
1125 THROW(ReportedBoundsError);
1126 frag_size -= MDSHDR_TRAILER_SIZE;
1127 } else if (pinfo->ethertype == ETHERTYPE_BRDWALK) {
1129 THROW(ReportedBoundsError);
1130 frag_size -= 8; /* 4 byte of FC CRC +
1131 4 bytes of error+EOF = 8 bytes */
1134 if (!is_lastframe_inseq) {
1135 /* Show this only as a fragmented FC frame */
1136 if (check_col (pinfo->cinfo, COL_INFO)) {
1137 col_append_str (pinfo->cinfo, COL_INFO, " (Fragmented)");
1141 /* If this is a fragment, attempt to check if fully reassembled frame is
1142 * present, if we're configured to reassemble.
1144 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
1145 (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble &&
1146 tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) {
1147 /* Add this to the list of fragments */
1149 /* In certain cases such as FICON, the SEQ_CNT is streaming
1150 * i.e. continuously increasing. So, zero does not signify the
1151 * first frame of the sequence. To fix this, we need to save the
1152 * SEQ_CNT of the first frame in sequence and use this value to
1153 * determine the actual offset into a frame.
1155 conversation = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
1156 pinfo->ptype, pinfo->oxid,
1157 pinfo->rxid, NO_PORT2);
1158 if (!conversation) {
1159 conversation = conversation_new (pinfo->fd->num, &pinfo->src, &pinfo->dst,
1160 pinfo->ptype, pinfo->oxid,
1161 pinfo->rxid, NO_PORT2);
1164 ckey.conv_idx = conversation->index;
1166 cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash,
1169 if (is_1frame_inseq) {
1171 /* Since we never free the memory used by an exchange, this maybe a
1172 * case of another request using the same exchange as a previous
1175 cdata->seq_cnt = fchdr.seqcnt;
1178 req_key = se_alloc (sizeof(fcseq_conv_key_t));
1179 req_key->conv_idx = conversation->index;
1181 cdata = se_alloc (sizeof(fcseq_conv_data_t));
1182 cdata->seq_cnt = fchdr.seqcnt;
1184 g_hash_table_insert (fcseq_req_hash, req_key, cdata);
1188 else if (cdata != NULL) {
1189 real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ;
1192 real_seqcnt = fchdr.seqcnt;
1195 /* Verify that this is a valid fragment */
1196 if (is_lastframe_inseq && !is_1frame_inseq && !real_seqcnt) {
1197 /* This is a frame that purports to be the last frame in a
1198 * sequence, is not the first frame, but has a seqcnt that is
1199 * 0. This is a bogus frame, don't attempt to reassemble it.
1201 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1202 if (check_col (pinfo->cinfo, COL_INFO)) {
1203 col_append_str (pinfo->cinfo, COL_INFO, " (Bogus Fragment)");
1207 frag_id = ((pinfo->oxid << 16) ^ seq_id) | is_exchg_resp ;
1209 /* We assume that all frames are of the same max size */
1210 fcfrag_head = fragment_add (tvb, FC_HEADER_SIZE, pinfo, frag_id,
1212 real_seqcnt * fc_max_frame_size,
1214 !is_lastframe_inseq);
1217 next_tvb = tvb_new_real_data (fcfrag_head->data,
1218 fcfrag_head->datalen,
1219 fcfrag_head->datalen);
1220 tvb_set_child_real_data_tvbuff(tvb, next_tvb);
1222 /* Add the defragmented data to the data source list. */
1223 add_new_data_source(pinfo, next_tvb, "Reassembled FC");
1226 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1227 tvb, offset+9, 1, 1);
1232 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1233 tvb, offset+9, 1, 0);
1235 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1236 call_dissector (data_handle, next_tvb, pinfo, tree);
1242 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1243 tvb, offset+9, 1, 0);
1245 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1248 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS)) {
1249 /* If relative offset is used, only dissect the pdu with
1250 * offset 0 (param) */
1251 if( (fchdr.fctl&FC_FCTL_REL_OFFSET) && param ){
1252 call_dissector (data_handle, next_tvb, pinfo, tree);
1254 if (!dissector_try_port (fcftype_dissector_table, ftype,
1255 next_tvb, pinfo, tree)) {
1256 call_dissector (data_handle, next_tvb, pinfo, tree);
1259 } else if (ftype == FC_FTYPE_BLS) {
1260 if ((fchdr.r_ctl & 0x0F) == FC_BLS_BAACC) {
1261 dissect_fc_ba_acc (next_tvb, pinfo, tree);
1262 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_BARJT) {
1263 dissect_fc_ba_rjt (next_tvb, pinfo, tree);
1267 tap_queue_packet(fc_tap, pinfo, &fchdr);
1271 dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1273 dissect_fc_helper (tvb, pinfo, tree, FALSE);
1276 dissect_fc_ifcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1278 dissect_fc_helper (tvb, pinfo, tree, TRUE);
1281 /* Register the protocol with Ethereal */
1283 /* this format is require because a script is used to build the C function
1284 that calls all the protocol registration.
1288 proto_register_fc(void)
1291 /* Setup list of header fields See Section 1.6.1 for details*/
1292 static hf_register_info hf[] = {
1294 { "R_CTL", "fc.r_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1297 {"Frame type", "fc.ftype", FT_UINT8, BASE_HEX, VALS(fc_ftype_vals),
1298 0x0, "Derived Type", HFILL}},
1300 { "Dest Addr", "fc.d_id", FT_STRING, BASE_HEX, NULL, 0x0,
1301 "Destination Address", HFILL}},
1303 {"CS_CTL", "fc.cs_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1306 {"Src Addr", "fc.s_id", FT_STRING, BASE_HEX, NULL, 0x0,
1307 "Source Address", HFILL}},
1309 {"Addr", "fc.id", FT_STRING, BASE_HEX, NULL, 0x0,
1310 "Source or Destination Address", HFILL}},
1312 {"Type", "fc.type", FT_UINT8, BASE_HEX, VALS (fc_fc4_val), 0x0,
1315 {"F_CTL", "fc.f_ctl", FT_UINT24, BASE_HEX, NULL, 0x0, "", HFILL}},
1317 {"SEQ_ID", "fc.seq_id", FT_UINT8, BASE_HEX, NULL, 0x0,
1318 "Sequence ID", HFILL}},
1320 {"DF_CTL", "fc.df_ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1322 {"SEQ_CNT", "fc.seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0,
1323 "Sequence Count", HFILL}},
1325 {"OX_ID", "fc.ox_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Originator ID",
1328 {"RX_ID", "fc.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Receiver ID",
1331 {"Parameter", "fc.parameter", FT_UINT32, BASE_HEX, NULL, 0x0, "Parameter",
1334 { &hf_fc_reassembled,
1335 {"Reassembled Frame", "fc.reassembled", FT_BOOLEAN, BASE_HEX, NULL,
1338 {"Network DA", "fc.nethdr.da", FT_STRING, BASE_HEX, NULL,
1341 {"Network SA", "fc.nethdr.sa", FT_STRING, BASE_HEX, NULL,
1344 /* Basic Link Svc field definitions */
1345 { &hf_fc_bls_seqid_vld,
1346 {"SEQID Valid", "fc.bls_seqidvld", FT_UINT8, BASE_HEX,
1347 VALS (fc_bls_seqid_val), 0x0, "", HFILL}},
1348 { &hf_fc_bls_lastvld_seqid,
1349 {"Last Valid SEQID", "fc.bls_lastseqid", FT_UINT8, BASE_HEX, NULL,
1352 {"OXID", "fc.bls_oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1354 {"RXID", "fc.bls_rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1355 { &hf_fc_bls_lowseqcnt,
1356 {"Low SEQCNT", "fc.bls_lseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1358 { &hf_fc_bls_hiseqcnt,
1359 {"High SEQCNT", "fc.bls_hseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1361 { &hf_fc_bls_rjtcode,
1362 {"Reason", "fc.bls_reason", FT_UINT8, BASE_HEX, VALS(fc_bls_barjt_val),
1364 { &hf_fc_bls_rjtdetail,
1365 {"Reason Explanantion", "fc.bls_rjtdetail", FT_UINT8, BASE_HEX,
1366 VALS (fc_bls_barjt_det_val), 0x0, "", HFILL}},
1367 { &hf_fc_bls_vendor,
1368 {"Vendor Unique Reason", "fc.bls_vnduniq", FT_UINT8, BASE_HEX, NULL,
1370 { &hf_fc_fctl_exchange_responder,
1371 {"ExgRpd", "fc.fctl.exchange_responder", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_responder),
1372 FC_FCTL_EXCHANGE_RESPONDER, "Exchange Responder?", HFILL}},
1373 { &hf_fc_fctl_seq_recipient,
1374 {"SeqRec", "fc.fctl.seq_recipient", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_recipient),
1375 FC_FCTL_SEQ_RECIPIENT, "Seq Recipient?", HFILL}},
1376 { &hf_fc_fctl_exchange_first,
1377 {"ExgFst", "fc.fctl.exchange_first", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_first),
1378 FC_FCTL_EXCHANGE_FIRST, "First Exchange?", HFILL}},
1379 { &hf_fc_fctl_exchange_last,
1380 {"ExgLst", "fc.fctl.exchange_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_last),
1381 FC_FCTL_EXCHANGE_LAST, "Last Exchange?", HFILL}},
1382 { &hf_fc_fctl_seq_last,
1383 {"SeqLst", "fc.fctl.seq_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_last),
1384 FC_FCTL_SEQ_LAST, "Last Sequence?", HFILL}},
1385 { &hf_fc_fctl_priority,
1386 {"Pri", "fc.fctl.priority", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_priority),
1387 FC_FCTL_PRIORITY, "Priority", HFILL}},
1388 { &hf_fc_fctl_transfer_seq_initiative,
1389 {"TSI", "fc.fctl.transfer_seq_initiative", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_transfer_seq_initiative),
1390 FC_FCTL_TRANSFER_SEQ_INITIATIVE, "Transfer Seq Initiative", HFILL}},
1391 { &hf_fc_fctl_rexmitted_seq,
1392 {"RetSeq", "fc.fctl.rexmitted_seq", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rexmitted_seq),
1393 FC_FCTL_REXMITTED_SEQ, "Retransmitted Sequence", HFILL}},
1394 { &hf_fc_fctl_rel_offset,
1395 {"RelOff", "fc.fctl.rel_offset", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rel_offset),
1396 FC_FCTL_REL_OFFSET, "rel offset", HFILL}},
1397 { &hf_fc_fctl_last_data_frame,
1398 {"LDF", "fc.fctl.last_data_frame", FT_UINT24, BASE_HEX, VALS(last_data_frame_vals),
1399 FC_FCTL_LAST_DATA_FRAME_MASK, "Last Data Frame?", HFILL}},
1400 { &hf_fc_fctl_ack_0_1,
1401 {"A01", "fc.fctl.ack_0_1", FT_UINT24, BASE_HEX, VALS(ack_0_1_vals),
1402 FC_FCTL_ACK_0_1_MASK, "Ack 0/1 value", HFILL}},
1403 { &hf_fc_fctl_abts_ack,
1404 {"AA", "fc.fctl.abts_ack", FT_UINT24, BASE_HEX, VALS(abts_ack_vals),
1405 FC_FCTL_ABTS_MASK, "ABTS ACK values", HFILL}},
1406 { &hf_fc_fctl_abts_not_ack,
1407 {"AnA", "fc.fctl.abts_not_ack", FT_UINT24, BASE_HEX, VALS(abts_not_ack_vals),
1408 FC_FCTL_ABTS_MASK, "ABTS not ACK vals", HFILL}},
1409 { &hf_fc_exchange_first_frame,
1410 { "Exchange First In", "fc.exchange_first_frame", FT_FRAMENUM, BASE_NONE, NULL,
1411 0, "The first frame of this exchange is in this frame", HFILL }},
1412 { &hf_fc_exchange_last_frame,
1413 { "Exchange Last In", "fc.exchange_last_frame", FT_FRAMENUM, BASE_NONE, NULL,
1414 0, "The last frame of this exchange is in this frame", HFILL }},
1416 { "Time from Exchange First", "fc.time", FT_RELATIVE_TIME, BASE_NONE, NULL,
1417 0, "Time since the first frame of the Exchange", HFILL }},
1419 {"EISL Header", "fc.eisl", FT_BYTES, BASE_HEX, NULL, 0, "EISL Header", HFILL}},
1422 /* Setup protocol subtree array */
1423 static gint *ett[] = {
1429 module_t *fc_module;
1431 /* Register the protocol name and description */
1432 proto_fc = proto_register_protocol ("Fibre Channel", "FC", "fc");
1433 register_dissector ("fc", dissect_fc, proto_fc);
1434 register_dissector ("fc_ifcp", dissect_fc_ifcp, proto_fc);
1435 fc_tap = register_tap("fc");
1437 /* Required function calls to register the header fields and subtrees used */
1438 proto_register_field_array(proto_fc, hf, array_length(hf));
1439 proto_register_subtree_array(ett, array_length(ett));
1441 fcftype_dissector_table = register_dissector_table ("fc.ftype",
1443 FT_UINT8, BASE_HEX);
1445 /* Register preferences */
1446 fc_module = prefs_register_protocol (proto_fc, NULL);
1447 prefs_register_bool_preference (fc_module,
1449 "Reassemble multi-frame sequences",
1450 "If enabled, reassembly of multi-frame "
1451 "sequences is done",
1453 prefs_register_uint_preference (fc_module,
1454 "max_frame_size", "Max FC Frame Size",
1455 "This is the size of non-last frames in a "
1456 "multi-frame sequence", 10,
1457 &fc_max_frame_size);
1459 register_init_routine(fc_defragment_init);
1460 register_init_routine (fc_exchange_init_protocol);
1464 /* If this dissector uses sub-dissector registration add a registration routine.
1465 This format is required because a script is used to find these routines and
1466 create the code that calls these routines.
1469 proto_reg_handoff_fc (void)
1471 data_handle = find_dissector("data");