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
7 * $Id: packet-fc.c,v 1.18 2004/02/19 00:29:15 gerald Exp $
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 #ifdef NEED_SNPRINTF_H
48 # include "snprintf.h"
51 #include <epan/packet.h>
53 #include "reassemble.h"
54 #include <epan/conversation.h>
56 #include "packet-fc.h"
57 #include "packet-fclctl.h"
58 #include "packet-fcbls.h"
61 #define FC_HEADER_SIZE 24
62 #define FC_RCTL_EISL 0x50
63 #define MDSHDR_TRAILER_SIZE 6
65 /* Size of various fields in FC header in bytes */
66 #define FC_RCTL_SIZE 1
68 #define FC_CSCTL_SIZE 1
70 #define FC_TYPE_SIZE 1
71 #define FC_FCTL_SIZE 3
72 #define FC_SEQID_SIZE 1
73 #define FC_DFCTL_SIZE 1
74 #define FC_SEQCNT_SIZE 2
75 #define FC_OXID_SIZE 2
76 #define FC_RXID_SIZE 2
77 #define FC_PARAM_SIZE 4
79 /* Initialize the protocol and registered fields */
80 static int proto_fc = -1;
81 static int hf_fc_time = -1;
82 static int hf_fc_exchange_first_frame = -1;
83 static int hf_fc_exchange_last_frame = -1;
84 static int hf_fc_rctl = -1;
85 static int hf_fc_did = -1;
86 static int hf_fc_csctl = -1;
87 static int hf_fc_sid = -1;
88 static int hf_fc_id = -1;
89 static int hf_fc_type = -1;
90 static int hf_fc_fctl = -1;
91 static int hf_fc_fctl_exchange_responder = -1;
92 static int hf_fc_fctl_seq_recipient = -1;
93 static int hf_fc_fctl_exchange_first = -1;
94 static int hf_fc_fctl_exchange_last = -1;
95 static int hf_fc_fctl_seq_last = -1;
96 static int hf_fc_fctl_priority = -1;
97 static int hf_fc_fctl_transfer_seq_initiative = -1;
98 static int hf_fc_fctl_rexmitted_seq = -1;
99 static int hf_fc_fctl_rel_offset = -1;
100 static int hf_fc_fctl_abts_ack = -1;
101 static int hf_fc_fctl_abts_not_ack = -1;
102 static int hf_fc_fctl_last_data_frame = -1;
103 static int hf_fc_fctl_ack_0_1 = -1;
104 static int hf_fc_seqid = -1;
105 static int hf_fc_dfctl = -1;
106 static int hf_fc_seqcnt = -1;
107 static int hf_fc_oxid = -1;
108 static int hf_fc_rxid = -1;
109 static int hf_fc_param = -1;
110 static int hf_fc_ftype = -1; /* Derived field, non-existent in FC hdr */
111 static int hf_fc_reassembled = -1;
112 static int hf_fc_eisl = -1;
114 /* Network_Header fields */
115 static int hf_fc_nh_da = -1;
116 static int hf_fc_nh_sa = -1;
118 /* For Basic Link Svc */
119 static int hf_fc_bls_seqid_vld = -1;
120 static int hf_fc_bls_lastvld_seqid = -1;
121 static int hf_fc_bls_oxid = -1;
122 static int hf_fc_bls_rxid = -1;
123 static int hf_fc_bls_lowseqcnt = -1;
124 static int hf_fc_bls_hiseqcnt = -1;
125 static int hf_fc_bls_rjtcode = -1;
126 static int hf_fc_bls_rjtdetail = -1;
127 static int hf_fc_bls_vendor = -1;
130 /* Initialize the subtree pointers */
131 static gint ett_fc = -1;
132 static gint ett_fctl = -1;
133 static gint ett_fcbls = -1;
135 static dissector_table_t fcftype_dissector_table;
136 static dissector_handle_t data_handle;
138 static int fc_tap = -1;
140 /* Reassembly stuff */
141 static gboolean fc_reassemble = TRUE;
142 static guint32 fc_max_frame_size = 1024;
143 static GHashTable *fc_fragment_table = NULL;
145 typedef struct _fcseq_conv_key {
149 typedef struct _fcseq_conv_data {
153 GHashTable *fcseq_req_hash = NULL;
154 GMemChunk *fcseq_req_keys = NULL;
155 GMemChunk *fcseq_req_vals = NULL;
156 guint32 fcseq_init_count = 25;
158 static GHashTable *fc_exchange_unmatched = NULL;
159 static GHashTable *fc_exchange_matched = NULL;
160 static GMemChunk *fc_exchange_vals = NULL;
161 static guint32 fc_exchange_init_count = 200;
167 fcseq_equal(gconstpointer v, gconstpointer w)
169 fcseq_conv_key_t *v1 = (fcseq_conv_key_t *)v;
170 fcseq_conv_key_t *v2 = (fcseq_conv_key_t *)w;
172 return (v1->conv_idx == v2->conv_idx);
176 fcseq_hash (gconstpointer v)
178 fcseq_conv_key_t *key = (fcseq_conv_key_t *)v;
187 fc_exchange_hash_unmatched(gconstpointer v)
189 const fc_exchange_data *fced=(const fc_exchange_data *)v;
194 fc_exchange_equal_unmatched(gconstpointer v1, gconstpointer v2)
196 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
197 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
199 /* oxid must match */
200 if(fced1->oxid!=fced2->oxid){
203 /* compare s_id, d_id and treat the fc address
204 s_id==00.00.00 as a wildcard matching anything */
205 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) ){
208 if(CMP_ADDRESS(&fced1->d_id, &fced2->d_id)){
216 fc_exchange_hash_matched(gconstpointer v)
218 const fc_exchange_data *fced=(const fc_exchange_data *)v;
223 fc_exchange_equal_matched(gconstpointer v1, gconstpointer v2)
225 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
226 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
227 guint32 fef1, fef2, lef1, lef2;
229 /* oxid must match */
230 if(fced1->oxid!=fced2->oxid){
233 fef1=fced1->first_exchange_frame;
234 fef2=fced2->first_exchange_frame;
235 lef1=fced1->last_exchange_frame;
236 lef2=fced2->last_exchange_frame;
253 fc_exchange_init_protocol(void)
255 if(fc_exchange_vals){
256 g_mem_chunk_destroy(fc_exchange_vals);
257 fc_exchange_vals=NULL;
259 if(fc_exchange_unmatched){
260 g_hash_table_destroy(fc_exchange_unmatched);
261 fc_exchange_unmatched=NULL;
263 if(fc_exchange_matched){
264 g_hash_table_destroy(fc_exchange_matched);
265 fc_exchange_matched=NULL;
268 fc_exchange_unmatched=g_hash_table_new(fc_exchange_hash_unmatched, fc_exchange_equal_unmatched);
269 fc_exchange_matched=g_hash_table_new(fc_exchange_hash_matched, fc_exchange_equal_matched);
270 fc_exchange_vals=g_mem_chunk_new("fc_exchange_vals", sizeof(fc_exchange_data), fc_exchange_init_count*sizeof(fc_exchange_data), G_ALLOC_AND_FREE);
272 fragment_table_init(&fc_fragment_table);
275 g_mem_chunk_destroy (fcseq_req_keys);
277 g_mem_chunk_destroy (fcseq_req_vals);
279 g_hash_table_destroy(fcseq_req_hash);
281 fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal);
282 fcseq_req_keys = g_mem_chunk_new ("fcseq_req_keys",
283 sizeof(fcseq_conv_key_t),
285 sizeof(fcseq_conv_key_t),
287 fcseq_req_vals = g_mem_chunk_new ("fcseq_req_vals",
288 sizeof(fcseq_conv_data_t),
290 sizeof(fcseq_conv_data_t),
295 const value_string fc_fc4_val[] = {
296 {FC_TYPE_ELS, "Ext Link Svc"},
297 {FC_TYPE_LLCSNAP, "LLC_SNAP"},
298 {FC_TYPE_IP, "IP/FC"},
299 {FC_TYPE_SCSI, "FCP"},
300 {FC_TYPE_FCCT, "FC_CT"},
301 {FC_TYPE_SWILS, "SW_ILS"},
303 {FC_TYPE_SNMP, "SNMP"},
304 {FC_TYPE_SB_FROM_CU, "SB-3(CU->Channel)"},
305 {FC_TYPE_SB_TO_CU, "SB-3(Channel->CU)"},
309 static const value_string fc_ftype_vals [] = {
310 {FC_FTYPE_UNDEF , "Unknown frame"},
311 {FC_FTYPE_SWILS, "SW_ILS"},
312 {FC_FTYPE_IP , "IP/FC"},
313 {FC_FTYPE_SCSI , "FCP"},
314 {FC_FTYPE_BLS , "Basic Link Svc"},
315 {FC_FTYPE_ELS , "ELS"},
316 {FC_FTYPE_FCCT , "FC_CT"},
317 {FC_FTYPE_LINKDATA, "Link Data"},
318 {FC_FTYPE_VDO, "Video Data"},
319 {FC_FTYPE_LINKCTL, "Link Ctl"},
320 {FC_FTYPE_SBCCS, "SBCCS"},
324 static const value_string fc_wka_vals[] = {
325 {FC_WKA_MULTICAST, "Multicast Server"},
326 {FC_WKA_CLKSYNC, "Clock Sync Server"},
327 {FC_WKA_KEYDIST, "Key Distribution Server"},
328 {FC_WKA_ALIAS, "Alias Server"},
329 {FC_WKA_QOSF, "QoS Facilitator"},
330 {FC_WKA_MGMT, "Management Server"},
331 {FC_WKA_TIME, "Time Server"},
332 {FC_WKA_DNS, "Directory Server"},
333 {FC_WKA_FABRIC_CTRLR, "Fabric Ctlr"},
334 {FC_WKA_FPORT, "F_Port Server"},
335 {FC_WKA_BCAST, "Broadcast ID"},
339 static const value_string fc_routing_val[] = {
340 {FC_RCTL_DEV_DATA, "Device_Data"},
341 {FC_RCTL_ELS, "Extended Link Services"},
342 {FC_RCTL_LINK_DATA, "FC-4 Link_Data"},
343 {FC_RCTL_VIDEO, "Video_Data"},
344 {FC_RCTL_BLS, "Basic Link Services"},
345 {FC_RCTL_LINK_CTL, "Link_Control Frame"},
349 static const value_string fc_iu_val[] = {
350 {FC_IU_UNCATEGORIZED , "Uncategorized Data"},
351 {FC_IU_SOLICITED_DATA , "Solicited Data"},
352 {FC_IU_UNSOLICITED_CTL , "Unsolicited Control"},
353 {FC_IU_SOLICITED_CTL , "Solicited Control"},
354 {FC_IU_UNSOLICITED_DATA, "Solicited Data"},
355 {FC_IU_DATA_DESCRIPTOR , "Data Descriptor"},
356 {FC_IU_UNSOLICITED_CMD , "Unsolicited Command"},
357 {FC_IU_CMD_STATUS , "Command Status"},
362 static void fc_defragment_init(void)
364 fragment_table_init(&fc_fragment_table);
369 fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack)
377 if (fctl[2] & 0x80) {
378 strcpy (str, "Exchange Responder, ");
382 strcpy (str, "Exchange Originator, ");
386 if (fctl[2] & 0x40) {
387 strcpy (&str[stroff], "Seq Recipient, ");
391 strcpy (&str[stroff], "Seq Initiator, ");
395 if (fctl[2] & 0x20) {
396 strcpy (&str[stroff], "Exchg First, ");
400 if (fctl[2] & 0x10) {
401 strcpy (&str[stroff], "Exchg Last, ");
406 strcpy (&str[stroff], "Seq Last, ");
411 strcpy (&str[stroff], "Priority, ");
415 strcpy (&str[stroff], "CS_CTL, ");
420 strcpy (&str[stroff], "Transfer Seq Initiative, ");
424 if (fctl[1] & 0x30) {
425 strcpy (&str[stroff], "ACK_0 Reqd, ");
428 else if (fctl[1] & 0x10) {
429 strcpy (&str[stroff], "ACK_1 Reqd, ");
434 strcpy (&str[stroff], "Rexmitted Seq, ");
438 tmp = fctl[0] & 0xC0;
441 strcpy (&str[stroff], "Last Data Frame - No Info, ");
445 strcpy (&str[stroff], "Last Data Frame - Seq Imm, ");
449 strcpy (&str[stroff], "Last Data Frame - Seq Soon, ");
453 strcpy (&str[stroff], "Last Data Frame - Seq Delyd, ");
458 tmp = fctl[0] & 0x30;
462 strcpy (&str[stroff], "ABTS - Cont, ");
466 strcpy (&str[stroff], "ABTS - Abort/MS, ");
472 strcpy (&str[stroff], "ABTS - AbortABTS - Abort, ");
476 strcpy (&str[stroff], "ABTS - Abort/SS, ");
482 strcpy (&str[stroff], "ABTS - Stop, ");
486 strcpy (&str[stroff], "ABTS - Process/IB, ");
492 strcpy (&str[stroff], "ABTS - Imm Seq Retx, ");
496 strcpy (&str[stroff], "ABTS - Discard/MS/Imm Retx, ");
503 strcpy (&str[stroff], "Rel Offset = 1");
510 /* BA_ACC & BA_RJT are decoded in this file itself instead of a traditional
511 * dedicated file and dissector format because the dissector would require some
512 * fields of the FC_HDR such as param in some cases, type in some others, the
513 * lower 4 bits of r_ctl in some other cases etc. So, we decode BLS & Link Ctl
514 * in this file itself.
517 dissect_fc_ba_acc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
519 /* Set up structures needed to add the protocol subtree and manage it */
521 proto_tree *acc_tree;
524 /* Make entries in Protocol column and Info column on summary display */
525 if (check_col(pinfo->cinfo, COL_PROTOCOL))
526 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
528 if (check_col(pinfo->cinfo, COL_INFO))
529 col_set_str(pinfo->cinfo, COL_INFO, "BA_ACC");
532 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
533 acc_tree = proto_item_add_subtree (ti, ett_fcbls);
535 proto_tree_add_item (acc_tree, hf_fc_bls_seqid_vld, tvb, offset++, 1, FALSE);
536 proto_tree_add_item (acc_tree, hf_fc_bls_lastvld_seqid, tvb, offset++, 1, FALSE);
537 offset += 2; /* Skip reserved field */
538 proto_tree_add_item (acc_tree, hf_fc_bls_oxid, tvb, offset, 2, FALSE);
540 proto_tree_add_item (acc_tree, hf_fc_bls_rxid, tvb, offset, 2, FALSE);
542 proto_tree_add_item (acc_tree, hf_fc_bls_lowseqcnt, tvb, offset, 2, FALSE);
544 proto_tree_add_item (acc_tree, hf_fc_bls_hiseqcnt, tvb, offset, 2, FALSE);
549 dissect_fc_ba_rjt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
551 /* Set up structures needed to add the protocol subtree and manage it */
553 proto_tree *rjt_tree;
556 /* Make entries in Protocol column and Info column on summary display */
557 if (check_col(pinfo->cinfo, COL_PROTOCOL))
558 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
560 if (check_col(pinfo->cinfo, COL_INFO))
561 col_set_str(pinfo->cinfo, COL_INFO, "BA_RJT");
564 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
565 rjt_tree = proto_item_add_subtree (ti, ett_fcbls);
567 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtcode, tvb, offset+1, 1, FALSE);
568 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtdetail, tvb, offset+2, 1, FALSE);
569 proto_tree_add_item (rjt_tree, hf_fc_bls_vendor, tvb, offset+3, 1, FALSE);
574 fc_get_ftype (guint8 r_ctl, guint8 type)
576 /* A simple attempt to determine the upper level protocol based on the
577 * r_ctl & type fields.
579 switch (r_ctl & 0xF0) {
580 case FC_RCTL_DEV_DATA:
583 if ((r_ctl == 0x2) || (r_ctl == 0x3))
584 return FC_FTYPE_SWILS;
586 return FC_FTYPE_UNDEF;
590 return FC_FTYPE_SCSI;
592 return FC_FTYPE_FCCT;
593 case FC_TYPE_SB_FROM_CU:
594 case FC_TYPE_SB_TO_CU:
595 return FC_FTYPE_SBCCS;
597 return FC_FTYPE_UNDEF;
601 if (((r_ctl & 0x0F) == 0x2) || ((r_ctl & 0x0F) == 0x3))
604 return FC_FTYPE_UNDEF;
606 case FC_RCTL_LINK_DATA:
607 return FC_FTYPE_LINKDATA;
616 return FC_FTYPE_UNDEF;
618 case FC_RCTL_LINK_CTL:
619 return FC_FTYPE_LINKCTL;
622 return FC_FTYPE_UNDEF;
627 static const value_string abts_ack_vals[] = {
628 {0x000000, "ABTS - Cont"},
629 {0x000010, "ABTS - Abort"},
630 {0x000020, "ABTS - Stop"},
631 {0x000030, "ABTS - Imm Seq Retx"},
634 static const value_string abts_not_ack_vals[] = {
635 {0x000000, "ABTS - Abort/MS"},
636 {0x000010, "ABTS - Abort/SS"},
637 {0x000020, "ABTS - Process/IB"},
638 {0x000030, "ABTS - Discard/MS/Imm Retx"},
641 static const value_string last_data_frame_vals[] = {
642 {0x000000, "Last Data Frame - No Info"},
643 {0x004000, "Last Data Frame - Seq Imm"},
644 {0x008000, "Last Data Frame - Seq Soon"},
645 {0x00c000, "Last Data Frame - Seq Delyd"},
648 static const value_string ack_0_1_vals[] = {
649 {0x003000, "ACK_0 Required"},
650 {0x002000, "ACK_0 Required"},
651 {0x001000, "ACK_1 Required"},
652 {0x000000, "no ack required"},
655 static const true_false_string tfs_fc_fctl_exchange_responder = {
656 "Exchange Responder",
657 "Exchange Originator"
659 static const true_false_string tfs_fc_fctl_seq_recipient = {
663 static const true_false_string tfs_fc_fctl_exchange_first = {
667 static const true_false_string tfs_fc_fctl_exchange_last = {
671 static const true_false_string tfs_fc_fctl_seq_last = {
675 static const true_false_string tfs_fc_fctl_priority = {
679 static const true_false_string tfs_fc_fctl_transfer_seq_initiative = {
680 "Transfer Seq Initiative",
681 "NOT transfer seq initiative"
683 static const true_false_string tfs_fc_fctl_rexmitted_seq = {
684 "Retransmitted Sequence",
685 "NOT retransmitted sequence"
687 static const true_false_string tfs_fc_fctl_rel_offset = {
695 /* code to dissect the F_CTL bitmask */
697 dissect_fc_fctl(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gboolean is_ack, guint32 fctl)
703 item=proto_tree_add_uint(parent_tree, hf_fc_fctl, tvb, offset, 3, fctl);
704 tree=proto_item_add_subtree(item, ett_fctl);
707 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_responder, tvb, offset, 3, fctl);
709 proto_tree_add_boolean(tree, hf_fc_fctl_seq_recipient, tvb, offset, 3, fctl);
711 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_first, tvb, offset, 3, fctl);
713 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_last, tvb, offset, 3, fctl);
715 proto_tree_add_boolean(tree, hf_fc_fctl_seq_last, tvb, offset, 3, fctl);
717 proto_tree_add_boolean(tree, hf_fc_fctl_priority, tvb, offset, 3, fctl);
719 proto_tree_add_boolean(tree, hf_fc_fctl_transfer_seq_initiative, tvb, offset, 3, fctl);
721 proto_tree_add_uint(tree, hf_fc_fctl_last_data_frame, tvb, offset, 3, fctl);
723 proto_tree_add_uint(tree, hf_fc_fctl_ack_0_1, tvb, offset, 3, fctl);
726 proto_tree_add_boolean(tree, hf_fc_fctl_rexmitted_seq, tvb, offset, 3, fctl);
729 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, fctl);
731 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, fctl);
734 proto_tree_add_boolean(tree, hf_fc_fctl_rel_offset, tvb, offset, 3, fctl);
736 fctl_to_str( ((guint8 *)&fctl), str, is_ack);
737 proto_item_append_text(item, " %s", str);
740 static const value_string fc_bls_proto_val[] = {
741 {FC_BLS_NOP , "NOP"},
742 {FC_BLS_ABTS , "ABTS"},
743 {FC_BLS_RMC , "RMC"},
744 {FC_BLS_BAACC , "BA_ACC"},
745 {FC_BLS_BARJT , "BA_RJT"},
746 {FC_BLS_PRMT , "PRMT"},
750 static const value_string fc_els_proto_val[] = {
751 {0x01 , "Solicited Data"},
757 /* Code to actually dissect the packets */
759 dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
761 /* Set up structures needed to add the protocol subtree and manage it */
763 proto_tree *fc_tree = NULL;
765 int offset = 0, next_offset, eisl_offset = -1;
766 gboolean is_lastframe_inseq, is_1frame_inseq, is_valid_frame;
767 gboolean is_exchg_resp = 0;
768 fragment_data *fcfrag_head;
771 guint8 df_ctl, seq_id;
779 fc_exchange_data *fc_ex=NULL;
781 conversation_t *conversation;
782 fcseq_conv_data_t *cdata;
783 fcseq_conv_key_t ckey, *req_key;
787 /* Make entries in Protocol column and Info column on summary display */
788 if (check_col(pinfo->cinfo, COL_PROTOCOL))
789 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC");
791 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
793 /* If the R_CTL is the EISL field, skip the first 8 bytes to retrieve the
794 * real FC header. EISL is Cisco-proprietary and is not decoded.
796 if (fchdr.r_ctl == FC_RCTL_EISL) {
797 eisl_offset = offset;
799 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
802 SET_ADDRESS (&pinfo->dst, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
803 SET_ADDRESS (&fchdr.d_id, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
804 SET_ADDRESS (&pinfo->src, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
805 SET_ADDRESS (&fchdr.s_id, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
806 fchdr.cs_ctl = tvb_get_guint8 (tvb, offset+4);
807 fchdr.type = tvb_get_guint8 (tvb, offset+8);
808 fchdr.fctl=tvb_get_ntoh24(tvb,offset+9);
809 fchdr.seqcnt = tvb_get_ntohs (tvb, offset+14);
810 fchdr.oxid=tvb_get_ntohs(tvb,offset+16);
811 fchdr.rxid=tvb_get_ntohs(tvb,offset+18);
812 param = tvb_get_ntohl (tvb, offset+20);
813 seq_id = tvb_get_guint8 (tvb, offset+12);
815 pinfo->oxid = fchdr.oxid;
816 pinfo->rxid = fchdr.rxid;
817 pinfo->ptype = PT_EXCHG;
818 pinfo->r_ctl = fchdr.r_ctl;
820 is_ack = ((fchdr.r_ctl == 0xC0) || (fchdr.r_ctl == 0xC1));
822 /* There are two ways to determine if this is the first frame of a
824 * (i) The SOF bits indicate that this is the first frame OR
825 * (ii) This is an SOFf frame and seqcnt is 0.
827 is_1frame_inseq = (((pinfo->sof_eof & PINFO_SOF_FIRST_FRAME) == PINFO_SOF_FIRST_FRAME) ||
828 (((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) &&
829 (fchdr.seqcnt == 0)));
831 is_lastframe_inseq = ((pinfo->sof_eof & PINFO_EOF_LAST_FRAME) == PINFO_EOF_LAST_FRAME);
833 if ((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) {
834 is_lastframe_inseq = fchdr.fctl & FC_FCTL_SEQ_LAST;
836 is_valid_frame = ((pinfo->sof_eof & 0x40) == 0x40);
838 ftype = fc_get_ftype (fchdr.r_ctl, fchdr.type);
840 if (check_col (pinfo->cinfo, COL_INFO)) {
841 col_add_str (pinfo->cinfo, COL_INFO, match_strval (ftype, fc_ftype_vals));
843 if (ftype == FC_FTYPE_LINKCTL)
844 col_append_fstr (pinfo->cinfo, COL_INFO, ", %s",
845 match_strval ((fchdr.r_ctl & 0x0F),
849 /* In the interest of speed, if "tree" is NULL, don't do any work not
850 necessary to generate protocol tree items. */
852 ti = proto_tree_add_protocol_format (tree, proto_fc, tvb, offset,
853 FC_HEADER_SIZE, "Fibre Channel");
854 fc_tree = proto_item_add_subtree (ti, ett_fc);
857 /* Highlight EISL header, if present */
858 if (eisl_offset != -1) {
859 proto_tree_add_item (fc_tree, hf_fc_eisl, tvb, eisl_offset, 8, 0);
862 /* match first exchange with last exchange */
863 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
864 if(!pinfo->fd->flags.visited){
865 fc_exchange_data fced, *old_fced;
867 /* first check if we already have seen this exchange and it
868 is still open/unmatched.
870 fced.oxid=fchdr.oxid;
871 SET_ADDRESS(&fced.s_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
872 SET_ADDRESS(&fced.d_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
873 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
875 g_hash_table_remove(fc_exchange_unmatched, old_fced);
877 old_fced=g_mem_chunk_alloc(fc_exchange_vals);
878 old_fced->oxid=fchdr.oxid;
879 COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id);
880 COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id);
881 old_fced->first_exchange_frame=pinfo->fd->num;
882 old_fced->fc_time.nsecs = pinfo->fd->abs_usecs*1000;
883 old_fced->fc_time.secs = pinfo->fd->abs_secs;
884 g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced);
887 fc_exchange_data fced, *old_fced;
888 fced.oxid=fchdr.oxid;
889 fced.first_exchange_frame=pinfo->fd->num;
890 fced.last_exchange_frame=0;
891 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
895 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
896 if(!pinfo->fd->flags.visited){
897 fc_exchange_data fced, *old_fced;
899 fced.oxid=fchdr.oxid;
900 SET_ADDRESS(&fced.s_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
901 SET_ADDRESS(&fced.d_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
902 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
904 g_hash_table_remove(fc_exchange_unmatched, old_fced);
905 old_fced->last_exchange_frame=pinfo->fd->num;
906 g_hash_table_insert(fc_exchange_matched, old_fced, old_fced);
910 fc_exchange_data fced, *old_fced;
911 fced.oxid=fchdr.oxid;
912 fced.first_exchange_frame=0;
913 fced.last_exchange_frame=pinfo->fd->num;
914 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
919 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
920 proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame);
922 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
924 proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame);
925 delta_time.secs = pinfo->fd->abs_secs - fc_ex->fc_time.secs;
926 delta_time.nsecs = pinfo->fd->abs_usecs*1000 - fc_ex->fc_time.nsecs;
927 if (delta_time.nsecs<0){
928 delta_time.nsecs+=1000000000;
931 proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_time);
936 switch (fchdr.r_ctl & 0xF0) {
938 case FC_RCTL_DEV_DATA:
939 case FC_RCTL_LINK_DATA:
941 /* the lower 4 bits of R_CTL are the information category */
942 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
943 FC_RCTL_SIZE, fchdr.r_ctl,
944 "R_CTL: 0x%x(%s/%s)",
946 val_to_str ((fchdr.r_ctl & 0xF0),
947 fc_routing_val, "0x%x"),
948 val_to_str ((fchdr.r_ctl & 0x0F),
952 case FC_RCTL_LINK_CTL:
953 /* the lower 4 bits of R_CTL indicate the type of link ctl frame */
954 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
955 FC_RCTL_SIZE, fchdr.r_ctl,
956 "R_CTL: 0x%x(%s/%s)",
958 val_to_str ((fchdr.r_ctl & 0xF0),
959 fc_routing_val, "0x%x"),
960 val_to_str ((fchdr.r_ctl & 0x0F),
961 fc_lctl_proto_val, "0x%x"));
965 switch (fchdr.type) {
968 /* the lower 4 bits of R_CTL indicate the type of BLS frame */
969 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
970 FC_RCTL_SIZE, fchdr.r_ctl,
971 "R_CTL: 0x%x(%s/%s)",
973 val_to_str ((fchdr.r_ctl & 0xF0),
974 fc_routing_val, "0x%x"),
975 val_to_str ((fchdr.r_ctl & 0x0F),
976 fc_bls_proto_val, "0x%x"));
980 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
981 FC_RCTL_SIZE, fchdr.r_ctl,
982 "R_CTL: 0x%x(%s/0x%x)",
984 val_to_str ((fchdr.r_ctl & 0xF0),
985 fc_routing_val, "0x%x"),
992 switch (fchdr.type) {
995 /* the lower 4 bits of R_CTL indicate the type of ELS frame */
996 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
997 FC_RCTL_SIZE, fchdr.r_ctl,
998 "R_CTL: 0x%x(%s/%s)",
1000 val_to_str ((fchdr.r_ctl & 0xF0),
1001 fc_routing_val, "0x%x"),
1002 val_to_str ((fchdr.r_ctl & 0x0F),
1003 fc_els_proto_val, "0x%x"));
1007 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
1008 FC_RCTL_SIZE, fchdr.r_ctl,
1009 "R_CTL: 0x%x(%s/0x%x)",
1011 val_to_str ((fchdr.r_ctl & 0xF0),
1012 fc_routing_val, "0x%x"),
1013 fchdr.r_ctl & 0x0F);
1019 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
1020 FC_RCTL_SIZE, fchdr.r_ctl,
1021 "R_CTL: 0x%x(%s/0x%x)",
1023 val_to_str ((fchdr.r_ctl & 0xF0),
1024 fc_routing_val, "0x%x"),
1025 fchdr.r_ctl & 0x0F);
1029 proto_tree_add_uint_hidden (fc_tree, hf_fc_ftype, tvb, offset, 1,
1032 /* XXX - use "fc_wka_vals[]" on this? */
1033 proto_tree_add_string (fc_tree, hf_fc_did, tvb, offset+1, 3,
1034 fc_to_str (fchdr.d_id.data));
1035 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+1, 3,
1036 fc_to_str (fchdr.d_id.data));
1038 proto_tree_add_uint (fc_tree, hf_fc_csctl, tvb, offset+4, 1, fchdr.cs_ctl);
1040 /* XXX - use "fc_wka_vals[]" on this? */
1041 proto_tree_add_string (fc_tree, hf_fc_sid, tvb, offset+5, 3,
1042 fc_to_str (fchdr.s_id.data));
1043 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+5, 3,
1044 fc_to_str (fchdr.s_id.data));
1046 if (ftype == FC_FTYPE_LINKCTL) {
1047 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYB) ||
1048 ((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYL)) {
1049 /* for F_BSY frames, the upper 4 bits of the type field specify the
1050 * reason for the BSY.
1052 proto_tree_add_uint_format (fc_tree, hf_fc_type, tvb,
1053 offset+8, FC_TYPE_SIZE,
1054 fchdr.type,"Type: 0x%x(%s)", fchdr.type,
1055 fclctl_get_typestr ((guint8) (fchdr.r_ctl & 0x0F),
1058 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1061 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1065 dissect_fc_fctl(pinfo, fc_tree, tvb, offset+9, is_ack, fchdr.fctl);
1068 proto_tree_add_item (fc_tree, hf_fc_seqid, tvb, offset+12, 1, FALSE);
1070 df_ctl = tvb_get_guint8(tvb, offset+13);
1072 proto_tree_add_uint (fc_tree, hf_fc_dfctl, tvb, offset+13, 1, df_ctl);
1073 proto_tree_add_uint (fc_tree, hf_fc_seqcnt, tvb, offset+14, 2, fchdr.seqcnt);
1074 proto_tree_add_uint (fc_tree, hf_fc_oxid, tvb, offset+16, 2, fchdr.oxid);
1075 proto_tree_add_uint (fc_tree, hf_fc_rxid, tvb, offset+18, 2, fchdr.rxid);
1077 if (ftype == FC_FTYPE_LINKCTL) {
1078 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FRJT) ||
1079 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PRJT) ||
1080 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PBSY)) {
1081 /* In all these cases of Link Ctl frame, the parameter field
1082 * encodes the detailed error message
1084 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1085 offset+20, 4, param,
1086 "Parameter: 0x%x(%s)", param,
1087 fclctl_get_paramstr ((fchdr.r_ctl & 0x0F),
1090 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1092 } else if (ftype == FC_FTYPE_BLS) {
1093 if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
1094 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1095 offset+20, 4, param,
1096 "Parameter: 0x%x(%s)", param,
1097 ((param & 0x0F) == 1 ? "Abort Sequence" :
1100 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20,
1104 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1107 /* Skip the Frame_Header */
1108 next_offset = offset + FC_HEADER_SIZE;
1110 /* Network_Header present? */
1111 if (df_ctl & FC_DFCTL_NH) {
1112 /* Yes - dissect it. */
1114 proto_tree_add_string (fc_tree, hf_fc_nh_da, tvb, next_offset, 8,
1115 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
1116 proto_tree_add_string (fc_tree, hf_fc_nh_sa, tvb, offset+8, 8,
1117 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
1122 /* XXX - handle Association_Header and Device_Header here */
1124 if (ftype == FC_FTYPE_LINKCTL) {
1125 /* ACK_1 frames and other LINK_CTL frames echo the last seq bit if the
1126 * packet they're ack'ing did not have it set. So, we'll incorrectly
1127 * flag them as being fragmented when they're not. This fixes the
1130 is_lastframe_inseq = TRUE;
1132 /* XXX is this right? offset 20, shouldnt it be offset 9? */
1133 is_exchg_resp = ((tvb_get_guint8 (tvb, offset+20) & 0x80) == 0x80);
1136 frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE;
1138 /* If there is an MDS header, we need to subtract the MDS trailer size */
1139 if ((pinfo->ethertype == ETHERTYPE_UNK) || (pinfo->ethertype == ETHERTYPE_FCFT)) {
1140 frag_size -= MDSHDR_TRAILER_SIZE;
1141 } else if (pinfo->ethertype == ETHERTYPE_BRDWALK) {
1142 frag_size -= 8; /* 4 byte of FC CRC +
1143 4 bytes of error+EOF = 8 bytes */
1146 if (!is_lastframe_inseq) {
1147 /* Show this only as a fragmented FC frame */
1148 if (check_col (pinfo->cinfo, COL_INFO)) {
1149 col_append_str (pinfo->cinfo, COL_INFO, " (Fragmented)");
1153 /* If this is a fragment, attempt to check if fully reassembled frame is
1154 * present, if we're configured to reassemble.
1156 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
1157 (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble &&
1158 tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) {
1159 /* Add this to the list of fragments */
1161 /* In certain cases such as FICON, the SEQ_CNT is streaming
1162 * i.e. continuously increasing. So, zero does not signify the
1163 * first frame of the sequence. To fix this, we need to save the
1164 * SEQ_CNT of the first frame in sequence and use this value to
1165 * determine the actual offset into a frame.
1167 conversation = find_conversation (&pinfo->src, &pinfo->dst,
1168 pinfo->ptype, pinfo->oxid,
1169 pinfo->rxid, NO_PORT2);
1170 if (!conversation) {
1171 conversation = conversation_new (&pinfo->src, &pinfo->dst,
1172 pinfo->ptype, pinfo->oxid,
1173 pinfo->rxid, NO_PORT2);
1176 ckey.conv_idx = conversation->index;
1178 cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash,
1181 if (is_1frame_inseq) {
1183 /* Since we never free the memory used by an exchange, this maybe a
1184 * case of another request using the same exchange as a previous
1187 cdata->seq_cnt = fchdr.seqcnt;
1190 req_key = g_mem_chunk_alloc (fcseq_req_keys);
1191 req_key->conv_idx = conversation->index;
1193 cdata = g_mem_chunk_alloc (fcseq_req_vals);
1194 cdata->seq_cnt = fchdr.seqcnt;
1196 g_hash_table_insert (fcseq_req_hash, req_key, cdata);
1200 else if (cdata != NULL) {
1201 real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ;
1204 real_seqcnt = fchdr.seqcnt;
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);
1241 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1242 tvb, offset+9, 1, 0);
1244 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1247 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS)) {
1248 if (!dissector_try_port (fcftype_dissector_table, ftype, next_tvb,
1250 call_dissector (data_handle, next_tvb, pinfo, tree);
1252 } else if (ftype == FC_FTYPE_BLS) {
1253 if ((fchdr.r_ctl & 0x0F) == FC_BLS_BAACC) {
1254 dissect_fc_ba_acc (next_tvb, pinfo, tree);
1255 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_BARJT) {
1256 dissect_fc_ba_rjt (next_tvb, pinfo, tree);
1260 tap_queue_packet(fc_tap, pinfo, &fchdr);
1264 /* Register the protocol with Ethereal */
1266 /* this format is require because a script is used to build the C function
1267 that calls all the protocol registration.
1271 proto_register_fc(void)
1274 /* Setup list of header fields See Section 1.6.1 for details*/
1275 static hf_register_info hf[] = {
1277 { "R_CTL", "fc.r_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1280 {"Frame type", "fc.ftype", FT_UINT8, BASE_HEX, VALS(fc_ftype_vals),
1281 0x0, "Derived Type", HFILL}},
1283 { "Dest Addr", "fc.d_id", FT_STRING, BASE_HEX, NULL, 0x0,
1284 "Destination Address", HFILL}},
1286 {"CS_CTL", "fc.cs_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1289 {"Src Addr", "fc.s_id", FT_STRING, BASE_HEX, NULL, 0x0,
1290 "Source Address", HFILL}},
1292 {"Addr", "fc.id", FT_STRING, BASE_HEX, NULL, 0x0,
1293 "Source or Destination Address", HFILL}},
1295 {"Type", "fc.type", FT_UINT8, BASE_HEX, VALS (fc_fc4_val), 0x0,
1298 {"F_CTL", "fc.f_ctl", FT_UINT24, BASE_HEX, NULL, 0x0, "", HFILL}},
1300 {"SEQ_ID", "fc.seq_id", FT_UINT8, BASE_HEX, NULL, 0x0,
1301 "Sequence ID", HFILL}},
1303 {"DF_CTL", "fc.df_ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1305 {"SEQ_CNT", "fc.seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0,
1306 "Sequence Count", HFILL}},
1308 {"OX_ID", "fc.ox_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Originator ID",
1311 {"RX_ID", "fc.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Receiver ID",
1314 {"Parameter", "fc.parameter", FT_UINT32, BASE_HEX, NULL, 0x0, "Parameter",
1317 { &hf_fc_reassembled,
1318 {"Reassembled Frame", "fc.reassembled", FT_BOOLEAN, BASE_HEX, NULL,
1321 {"Network DA", "fc.nethdr.da", FT_STRING, BASE_HEX, NULL,
1324 {"Network SA", "fc.nethdr.sa", FT_STRING, BASE_HEX, NULL,
1327 /* Basic Link Svc field definitions */
1328 { &hf_fc_bls_seqid_vld,
1329 {"SEQID Valid", "fc.bls_seqidvld", FT_UINT8, BASE_HEX,
1330 VALS (fc_bls_seqid_val), 0x0, "", HFILL}},
1331 { &hf_fc_bls_lastvld_seqid,
1332 {"Last Valid SEQID", "fc.bls_lastseqid", FT_UINT8, BASE_HEX, NULL,
1335 {"OXID", "fc.bls_oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1337 {"RXID", "fc.bls_rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1338 { &hf_fc_bls_lowseqcnt,
1339 {"Low SEQCNT", "fc.bls_lseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1341 { &hf_fc_bls_hiseqcnt,
1342 {"High SEQCNT", "fc.bls_hseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1344 { &hf_fc_bls_rjtcode,
1345 {"Reason", "fc.bls_reason", FT_UINT8, BASE_HEX, VALS(fc_bls_barjt_val),
1347 { &hf_fc_bls_rjtdetail,
1348 {"Reason Explanantion", "fc.bls_rjtdetail", FT_UINT8, BASE_HEX,
1349 VALS (fc_bls_barjt_det_val), 0x0, "", HFILL}},
1350 { &hf_fc_bls_vendor,
1351 {"Vendor Unique Reason", "fc.bls_vnduniq", FT_UINT8, BASE_HEX, NULL,
1353 { &hf_fc_fctl_exchange_responder,
1354 {"ExgRpd", "fc.fctl.exchange_responder", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_responder),
1355 FC_FCTL_EXCHANGE_RESPONDER, "Exchange Responder?", HFILL}},
1356 { &hf_fc_fctl_seq_recipient,
1357 {"SeqRec", "fc.fctl.seq_recipient", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_recipient),
1358 FC_FCTL_SEQ_RECIPIENT, "Seq Recipient?", HFILL}},
1359 { &hf_fc_fctl_exchange_first,
1360 {"ExgFst", "fc.fctl.exchange_first", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_first),
1361 FC_FCTL_EXCHANGE_FIRST, "First Exchange?", HFILL}},
1362 { &hf_fc_fctl_exchange_last,
1363 {"ExgLst", "fc.fctl.exchange_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_last),
1364 FC_FCTL_EXCHANGE_LAST, "Last Exchange?", HFILL}},
1365 { &hf_fc_fctl_seq_last,
1366 {"SeqLst", "fc.fctl.seq_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_last),
1367 FC_FCTL_SEQ_LAST, "Last Sequence?", HFILL}},
1368 { &hf_fc_fctl_priority,
1369 {"Pri", "fc.fctl.priority", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_priority),
1370 FC_FCTL_PRIORITY, "Priority", HFILL}},
1371 { &hf_fc_fctl_transfer_seq_initiative,
1372 {"TSI", "fc.fctl.transfer_seq_initiative", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_transfer_seq_initiative),
1373 FC_FCTL_TRANSFER_SEQ_INITIATIVE, "Transfer Seq Initiative", HFILL}},
1374 { &hf_fc_fctl_rexmitted_seq,
1375 {"RetSeq", "fc.fctl.rexmitted_seq", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rexmitted_seq),
1376 FC_FCTL_REXMITTED_SEQ, "Retransmitted Sequence", HFILL}},
1377 { &hf_fc_fctl_rel_offset,
1378 {"RelOff", "fc.fctl.rel_offset", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rel_offset),
1379 FC_FCTL_REL_OFFSET, "rel offset", HFILL}},
1380 { &hf_fc_fctl_last_data_frame,
1381 {"LDF", "fc.fctl.last_data_frame", FT_UINT24, BASE_HEX, VALS(last_data_frame_vals),
1382 FC_FCTL_LAST_DATA_FRAME_MASK, "Last Data Frame?", HFILL}},
1383 { &hf_fc_fctl_ack_0_1,
1384 {"A01", "fc.fctl.ack_0_1", FT_UINT24, BASE_HEX, VALS(ack_0_1_vals),
1385 FC_FCTL_ACK_0_1_MASK, "Ack 0/1 value", HFILL}},
1386 { &hf_fc_fctl_abts_ack,
1387 {"AA", "fc.fctl.abts_ack", FT_UINT24, BASE_HEX, VALS(abts_ack_vals),
1388 FC_FCTL_ABTS_MASK, "ABTS ACK values", HFILL}},
1389 { &hf_fc_fctl_abts_not_ack,
1390 {"AnA", "fc.fctl.abts_not_ack", FT_UINT24, BASE_HEX, VALS(abts_not_ack_vals),
1391 FC_FCTL_ABTS_MASK, "ABTS not ACK vals", HFILL}},
1392 { &hf_fc_exchange_first_frame,
1393 { "Exchange First In", "fc.exchange_first_frame", FT_FRAMENUM, BASE_NONE, NULL,
1394 0, "The first frame of this exchange is in this frame", HFILL }},
1395 { &hf_fc_exchange_last_frame,
1396 { "Exchange Last In", "fc.exchange_last_frame", FT_FRAMENUM, BASE_NONE, NULL,
1397 0, "The last frame of this exchange is in this frame", HFILL }},
1399 { "Time from Exchange First", "fc.time", FT_RELATIVE_TIME, BASE_NONE, NULL,
1400 0, "Time since the first frame of the Exchange", HFILL }},
1402 {"EISL Header", "fc.eisl", FT_BYTES, BASE_HEX, NULL, 0, "EISL Header", HFILL}},
1405 /* Setup protocol subtree array */
1406 static gint *ett[] = {
1412 module_t *fc_module;
1414 /* Register the protocol name and description */
1415 proto_fc = proto_register_protocol ("Fibre Channel", "FC", "fc");
1416 register_dissector ("fc", dissect_fc, proto_fc);
1417 fc_tap = register_tap("fc");
1419 /* Required function calls to register the header fields and subtrees used */
1420 proto_register_field_array(proto_fc, hf, array_length(hf));
1421 proto_register_subtree_array(ett, array_length(ett));
1423 fcftype_dissector_table = register_dissector_table ("fc.ftype",
1425 FT_UINT8, BASE_HEX);
1427 /* Register preferences */
1428 fc_module = prefs_register_protocol (proto_fc, NULL);
1429 prefs_register_bool_preference (fc_module,
1431 "Reassemble multi-frame sequences",
1432 "If enabled, reassembly of multi-frame "
1433 "sequences is done",
1435 prefs_register_uint_preference (fc_module,
1436 "max_frame_size", "Max FC Frame Size",
1437 "This is the size of non-last frames in a "
1438 "multi-frame sequence", 10,
1439 &fc_max_frame_size);
1441 register_init_routine(fc_defragment_init);
1442 register_init_routine (fc_exchange_init_protocol);
1446 /* If this dissector uses sub-dissector registration add a registration routine.
1447 This format is required because a script is used to find these routines and
1448 create the code that calls these routines.
1451 proto_reg_handoff_fc (void)
1453 data_handle = find_dissector("data");