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.16 2003/10/30 02:06:11 guy 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;
113 /* Network_Header fields */
114 static int hf_fc_nh_da = -1;
115 static int hf_fc_nh_sa = -1;
117 /* For Basic Link Svc */
118 static int hf_fc_bls_seqid_vld = -1;
119 static int hf_fc_bls_lastvld_seqid = -1;
120 static int hf_fc_bls_oxid = -1;
121 static int hf_fc_bls_rxid = -1;
122 static int hf_fc_bls_lowseqcnt = -1;
123 static int hf_fc_bls_hiseqcnt = -1;
124 static int hf_fc_bls_rjtcode = -1;
125 static int hf_fc_bls_rjtdetail = -1;
126 static int hf_fc_bls_vendor = -1;
129 /* Initialize the subtree pointers */
130 static gint ett_fc = -1;
131 static gint ett_fctl = -1;
132 static gint ett_fcbls = -1;
134 static dissector_table_t fcftype_dissector_table;
135 static dissector_handle_t data_handle;
137 static int fc_tap = -1;
139 /* Reassembly stuff */
140 static gboolean fc_reassemble = TRUE;
141 static guint32 fc_max_frame_size = 1024;
142 static GHashTable *fc_fragment_table = NULL;
144 typedef struct _fcseq_conv_key {
148 typedef struct _fcseq_conv_data {
152 GHashTable *fcseq_req_hash = NULL;
153 GMemChunk *fcseq_req_keys = NULL;
154 GMemChunk *fcseq_req_vals = NULL;
155 guint32 fcseq_init_count = 25;
157 static GHashTable *fc_exchange_unmatched = NULL;
158 static GHashTable *fc_exchange_matched = NULL;
159 static GMemChunk *fc_exchange_vals = NULL;
160 static guint32 fc_exchange_init_count = 200;
166 fcseq_equal(gconstpointer v, gconstpointer w)
168 fcseq_conv_key_t *v1 = (fcseq_conv_key_t *)v;
169 fcseq_conv_key_t *v2 = (fcseq_conv_key_t *)w;
171 return (v1->conv_idx == v2->conv_idx);
175 fcseq_hash (gconstpointer v)
177 fcseq_conv_key_t *key = (fcseq_conv_key_t *)v;
186 fc_exchange_hash_unmatched(gconstpointer v)
188 const fc_exchange_data *fced=(const fc_exchange_data *)v;
193 fc_exchange_equal_unmatched(gconstpointer v1, gconstpointer v2)
195 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
196 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
198 /* oxid must match */
199 if(fced1->oxid!=fced2->oxid){
202 /* compare s_id, d_id and treat the fc address
203 s_id==00.00.00 as a wildcard matching anything */
204 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) ){
207 if(CMP_ADDRESS(&fced1->d_id, &fced2->d_id)){
215 fc_exchange_hash_matched(gconstpointer v)
217 const fc_exchange_data *fced=(const fc_exchange_data *)v;
222 fc_exchange_equal_matched(gconstpointer v1, gconstpointer v2)
224 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
225 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
226 guint32 fef1, fef2, lef1, lef2;
228 /* oxid must match */
229 if(fced1->oxid!=fced2->oxid){
232 fef1=fced1->first_exchange_frame;
233 fef2=fced2->first_exchange_frame;
234 lef1=fced1->last_exchange_frame;
235 lef2=fced2->last_exchange_frame;
252 fc_exchange_init_protocol(void)
254 if(fc_exchange_vals){
255 g_mem_chunk_destroy(fc_exchange_vals);
256 fc_exchange_vals=NULL;
258 if(fc_exchange_unmatched){
259 g_hash_table_destroy(fc_exchange_unmatched);
260 fc_exchange_unmatched=NULL;
262 if(fc_exchange_matched){
263 g_hash_table_destroy(fc_exchange_matched);
264 fc_exchange_matched=NULL;
267 fc_exchange_unmatched=g_hash_table_new(fc_exchange_hash_unmatched, fc_exchange_equal_unmatched);
268 fc_exchange_matched=g_hash_table_new(fc_exchange_hash_matched, fc_exchange_equal_matched);
269 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);
271 fragment_table_init(&fc_fragment_table);
274 g_mem_chunk_destroy (fcseq_req_keys);
276 g_mem_chunk_destroy (fcseq_req_vals);
278 g_hash_table_destroy(fcseq_req_hash);
280 fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal);
281 fcseq_req_keys = g_mem_chunk_new ("fcseq_req_keys",
282 sizeof(fcseq_conv_key_t),
284 sizeof(fcseq_conv_key_t),
286 fcseq_req_vals = g_mem_chunk_new ("fcseq_req_vals",
287 sizeof(fcseq_conv_data_t),
289 sizeof(fcseq_conv_data_t),
294 const value_string fc_fc4_val[] = {
295 {FC_TYPE_ELS, "Ext Link Svc"},
296 {FC_TYPE_LLCSNAP, "LLC_SNAP"},
297 {FC_TYPE_IP, "IP/FC"},
298 {FC_TYPE_SCSI, "FCP"},
299 {FC_TYPE_FCCT, "FC_CT"},
300 {FC_TYPE_SWILS, "SW_ILS"},
302 {FC_TYPE_SNMP, "SNMP"},
303 {FC_TYPE_SB_FROM_CU, "SB-3(CU->Channel)"},
304 {FC_TYPE_SB_TO_CU, "SB-3(Channel->CU)"},
308 static const value_string fc_ftype_vals [] = {
309 {FC_FTYPE_UNDEF , "Unknown frame"},
310 {FC_FTYPE_SWILS, "SW_ILS"},
311 {FC_FTYPE_IP , "IP/FC"},
312 {FC_FTYPE_SCSI , "FCP"},
313 {FC_FTYPE_BLS , "Basic Link Svc"},
314 {FC_FTYPE_ELS , "ELS"},
315 {FC_FTYPE_FCCT , "FC_CT"},
316 {FC_FTYPE_LINKDATA, "Link Data"},
317 {FC_FTYPE_VDO, "Video Data"},
318 {FC_FTYPE_LINKCTL, "Link Ctl"},
319 {FC_FTYPE_SBCCS, "SBCCS"},
323 static const value_string fc_wka_vals[] = {
324 {FC_WKA_MULTICAST, "Multicast Server"},
325 {FC_WKA_CLKSYNC, "Clock Sync Server"},
326 {FC_WKA_KEYDIST, "Key Distribution Server"},
327 {FC_WKA_ALIAS, "Alias Server"},
328 {FC_WKA_QOSF, "QoS Facilitator"},
329 {FC_WKA_MGMT, "Management Server"},
330 {FC_WKA_TIME, "Time Server"},
331 {FC_WKA_DNS, "Directory Server"},
332 {FC_WKA_FABRIC_CTRLR, "Fabric Ctlr"},
333 {FC_WKA_FPORT, "F_Port Server"},
334 {FC_WKA_BCAST, "Broadcast ID"},
338 static const value_string fc_routing_val[] = {
339 {FC_RCTL_DEV_DATA, "Device_Data"},
340 {FC_RCTL_ELS, "Extended Link Services"},
341 {FC_RCTL_LINK_DATA, "FC-4 Link_Data"},
342 {FC_RCTL_VIDEO, "Video_Data"},
343 {FC_RCTL_BLS, "Basic Link Services"},
344 {FC_RCTL_LINK_CTL, "Link_Control Frame"},
348 static const value_string fc_iu_val[] = {
349 {FC_IU_UNCATEGORIZED , "Uncategorized Data"},
350 {FC_IU_SOLICITED_DATA , "Solicited Data"},
351 {FC_IU_UNSOLICITED_CTL , "Unsolicited Control"},
352 {FC_IU_SOLICITED_CTL , "Solicited Control"},
353 {FC_IU_UNSOLICITED_DATA, "Solicited Data"},
354 {FC_IU_DATA_DESCRIPTOR , "Data Descriptor"},
355 {FC_IU_UNSOLICITED_CMD , "Unsolicited Command"},
356 {FC_IU_CMD_STATUS , "Command Status"},
361 static void fc_defragment_init(void)
363 fragment_table_init(&fc_fragment_table);
368 fctl_to_str (const guint8 *fctl, gchar *str, gboolean is_ack)
376 if (fctl[2] & 0x80) {
377 strcpy (str, "Exchange Responder, ");
381 strcpy (str, "Exchange Originator, ");
385 if (fctl[2] & 0x40) {
386 strcpy (&str[stroff], "Seq Recipient, ");
390 strcpy (&str[stroff], "Seq Initiator, ");
394 if (fctl[2] & 0x20) {
395 strcpy (&str[stroff], "Exchg First, ");
399 if (fctl[2] & 0x10) {
400 strcpy (&str[stroff], "Exchg Last, ");
405 strcpy (&str[stroff], "Seq Last, ");
410 strcpy (&str[stroff], "Priority, ");
414 strcpy (&str[stroff], "CS_CTL, ");
419 strcpy (&str[stroff], "Transfer Seq Initiative, ");
423 if (fctl[1] & 0x30) {
424 strcpy (&str[stroff], "ACK_0 Reqd, ");
427 else if (fctl[1] & 0x10) {
428 strcpy (&str[stroff], "ACK_1 Reqd, ");
433 strcpy (&str[stroff], "Rexmitted Seq, ");
437 tmp = fctl[0] & 0xC0;
440 strcpy (&str[stroff], "Last Data Frame - No Info, ");
444 strcpy (&str[stroff], "Last Data Frame - Seq Imm, ");
448 strcpy (&str[stroff], "Last Data Frame - Seq Soon, ");
452 strcpy (&str[stroff], "Last Data Frame - Seq Delyd, ");
457 tmp = fctl[0] & 0x30;
461 strcpy (&str[stroff], "ABTS - Cont, ");
465 strcpy (&str[stroff], "ABTS - Abort/MS, ");
471 strcpy (&str[stroff], "ABTS - AbortABTS - Abort, ");
475 strcpy (&str[stroff], "ABTS - Abort/SS, ");
481 strcpy (&str[stroff], "ABTS - Stop, ");
485 strcpy (&str[stroff], "ABTS - Process/IB, ");
491 strcpy (&str[stroff], "ABTS - Imm Seq Retx, ");
495 strcpy (&str[stroff], "ABTS - Discard/MS/Imm Retx, ");
502 strcpy (&str[stroff], "Rel Offset = 1");
509 /* BA_ACC & BA_RJT are decoded in this file itself instead of a traditional
510 * dedicated file and dissector format because the dissector would require some
511 * fields of the FC_HDR such as param in some cases, type in some others, the
512 * lower 4 bits of r_ctl in some other cases etc. So, we decode BLS & Link Ctl
513 * in this file itself.
516 dissect_fc_ba_acc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
518 /* Set up structures needed to add the protocol subtree and manage it */
520 proto_tree *acc_tree;
523 /* Make entries in Protocol column and Info column on summary display */
524 if (check_col(pinfo->cinfo, COL_PROTOCOL))
525 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
527 if (check_col(pinfo->cinfo, COL_INFO))
528 col_set_str(pinfo->cinfo, COL_INFO, "BA_ACC");
531 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
532 acc_tree = proto_item_add_subtree (ti, ett_fcbls);
534 proto_tree_add_item (acc_tree, hf_fc_bls_seqid_vld, tvb, offset++, 1, FALSE);
535 proto_tree_add_item (acc_tree, hf_fc_bls_lastvld_seqid, tvb, offset++, 1, FALSE);
536 offset += 2; /* Skip reserved field */
537 proto_tree_add_item (acc_tree, hf_fc_bls_oxid, tvb, offset, 2, FALSE);
539 proto_tree_add_item (acc_tree, hf_fc_bls_rxid, tvb, offset, 2, FALSE);
541 proto_tree_add_item (acc_tree, hf_fc_bls_lowseqcnt, tvb, offset, 2, FALSE);
543 proto_tree_add_item (acc_tree, hf_fc_bls_hiseqcnt, tvb, offset, 2, FALSE);
548 dissect_fc_ba_rjt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
550 /* Set up structures needed to add the protocol subtree and manage it */
552 proto_tree *rjt_tree;
555 /* Make entries in Protocol column and Info column on summary display */
556 if (check_col(pinfo->cinfo, COL_PROTOCOL))
557 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
559 if (check_col(pinfo->cinfo, COL_INFO))
560 col_set_str(pinfo->cinfo, COL_INFO, "BA_RJT");
563 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
564 rjt_tree = proto_item_add_subtree (ti, ett_fcbls);
566 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtcode, tvb, offset+1, 1, FALSE);
567 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtdetail, tvb, offset+2, 1, FALSE);
568 proto_tree_add_item (rjt_tree, hf_fc_bls_vendor, tvb, offset+3, 1, FALSE);
573 fc_get_ftype (guint8 r_ctl, guint8 type)
575 /* A simple attempt to determine the upper level protocol based on the
576 * r_ctl & type fields.
578 switch (r_ctl & 0xF0) {
579 case FC_RCTL_DEV_DATA:
582 if ((r_ctl == 0x2) || (r_ctl == 0x3))
583 return FC_FTYPE_SWILS;
585 return FC_FTYPE_UNDEF;
589 return FC_FTYPE_SCSI;
591 return FC_FTYPE_FCCT;
592 case FC_TYPE_SB_FROM_CU:
593 case FC_TYPE_SB_TO_CU:
594 return FC_FTYPE_SBCCS;
596 return FC_FTYPE_UNDEF;
600 if (((r_ctl & 0x0F) == 0x2) || ((r_ctl & 0x0F) == 0x3))
603 return FC_FTYPE_UNDEF;
605 case FC_RCTL_LINK_DATA:
606 return FC_FTYPE_LINKDATA;
615 return FC_FTYPE_UNDEF;
617 case FC_RCTL_LINK_CTL:
618 return FC_FTYPE_LINKCTL;
621 return FC_FTYPE_UNDEF;
626 static const value_string abts_ack_vals[] = {
627 {0x000000, "ABTS - Cont"},
628 {0x000010, "ABTS - Abort"},
629 {0x000020, "ABTS - Stop"},
630 {0x000030, "ABTS - Imm Seq Retx"},
633 static const value_string abts_not_ack_vals[] = {
634 {0x000000, "ABTS - Abort/MS"},
635 {0x000010, "ABTS - Abort/SS"},
636 {0x000020, "ABTS - Process/IB"},
637 {0x000030, "ABTS - Discard/MS/Imm Retx"},
640 static const value_string last_data_frame_vals[] = {
641 {0x000000, "Last Data Frame - No Info"},
642 {0x004000, "Last Data Frame - Seq Imm"},
643 {0x008000, "Last Data Frame - Seq Soon"},
644 {0x00c000, "Last Data Frame - Seq Delyd"},
647 static const value_string ack_0_1_vals[] = {
648 {0x003000, "ACK_0 Required"},
649 {0x002000, "ACK_0 Required"},
650 {0x001000, "ACK_1 Required"},
651 {0x000000, "no ack required"},
654 static const true_false_string tfs_fc_fctl_exchange_responder = {
655 "Exchange Responder",
656 "Exchange Originator"
658 static const true_false_string tfs_fc_fctl_seq_recipient = {
662 static const true_false_string tfs_fc_fctl_exchange_first = {
666 static const true_false_string tfs_fc_fctl_exchange_last = {
670 static const true_false_string tfs_fc_fctl_seq_last = {
674 static const true_false_string tfs_fc_fctl_priority = {
678 static const true_false_string tfs_fc_fctl_transfer_seq_initiative = {
679 "Transfer Seq Initiative",
680 "NOT transfer seq initiative"
682 static const true_false_string tfs_fc_fctl_rexmitted_seq = {
683 "Retransmitted Sequence",
684 "NOT retransmitted sequence"
686 static const true_false_string tfs_fc_fctl_rel_offset = {
694 /* code to dissect the F_CTL bitmask */
696 dissect_fc_fctl(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gboolean is_ack, guint32 fctl)
702 item=proto_tree_add_uint(parent_tree, hf_fc_fctl, tvb, offset, 3, fctl);
703 tree=proto_item_add_subtree(item, ett_fctl);
706 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_responder, tvb, offset, 3, fctl);
708 proto_tree_add_boolean(tree, hf_fc_fctl_seq_recipient, tvb, offset, 3, fctl);
710 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_first, tvb, offset, 3, fctl);
712 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_last, tvb, offset, 3, fctl);
714 proto_tree_add_boolean(tree, hf_fc_fctl_seq_last, tvb, offset, 3, fctl);
716 proto_tree_add_boolean(tree, hf_fc_fctl_priority, tvb, offset, 3, fctl);
718 proto_tree_add_boolean(tree, hf_fc_fctl_transfer_seq_initiative, tvb, offset, 3, fctl);
720 proto_tree_add_uint(tree, hf_fc_fctl_last_data_frame, tvb, offset, 3, fctl);
722 proto_tree_add_uint(tree, hf_fc_fctl_ack_0_1, tvb, offset, 3, fctl);
725 proto_tree_add_boolean(tree, hf_fc_fctl_rexmitted_seq, tvb, offset, 3, fctl);
728 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, fctl);
730 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, fctl);
733 proto_tree_add_boolean(tree, hf_fc_fctl_rel_offset, tvb, offset, 3, fctl);
735 fctl_to_str( ((guint8 *)&fctl), str, is_ack);
736 proto_item_append_text(item, " %s", str);
739 static const value_string fc_bls_proto_val[] = {
740 {FC_BLS_NOP , "NOP"},
741 {FC_BLS_ABTS , "ABTS"},
742 {FC_BLS_RMC , "RMC"},
743 {FC_BLS_BAACC , "BA_ACC"},
744 {FC_BLS_BARJT , "BA_RJT"},
745 {FC_BLS_PRMT , "PRMT"},
749 static const value_string fc_els_proto_val[] = {
750 {0x01 , "Solicited Data"},
756 /* Code to actually dissect the packets */
758 dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
760 /* Set up structures needed to add the protocol subtree and manage it */
762 proto_tree *fc_tree = NULL;
764 int offset = 0, next_offset;
765 gboolean is_lastframe_inseq, is_1frame_inseq, is_valid_frame;
766 gboolean is_exchg_resp = 0;
767 fragment_data *fcfrag_head;
770 guint8 df_ctl, seq_id;
778 fc_exchange_data *fc_ex=NULL;
780 conversation_t *conversation;
781 fcseq_conv_data_t *cdata;
782 fcseq_conv_key_t ckey, *req_key;
786 /* Make entries in Protocol column and Info column on summary display */
787 if (check_col(pinfo->cinfo, COL_PROTOCOL))
788 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC");
790 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
792 /* If the R_CTL is the EISL field, skip the first 8 bytes to retrieve the
793 * real FC header. EISL is Cisco-proprietary and is not decoded.
795 if (fchdr.r_ctl == FC_RCTL_EISL) {
797 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
800 SET_ADDRESS (&pinfo->dst, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
801 SET_ADDRESS (&fchdr.d_id, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
802 SET_ADDRESS (&pinfo->src, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
803 SET_ADDRESS (&fchdr.s_id, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
804 fchdr.cs_ctl = tvb_get_guint8 (tvb, offset+4);
805 fchdr.type = tvb_get_guint8 (tvb, offset+8);
806 fchdr.fctl=tvb_get_ntoh24(tvb,offset+9);
807 fchdr.seqcnt = tvb_get_ntohs (tvb, offset+14);
808 fchdr.oxid=tvb_get_ntohs(tvb,offset+16);
809 fchdr.rxid=tvb_get_ntohs(tvb,offset+18);
810 param = tvb_get_ntohl (tvb, offset+20);
811 seq_id = tvb_get_guint8 (tvb, offset+12);
813 pinfo->oxid = fchdr.oxid;
814 pinfo->rxid = fchdr.rxid;
815 pinfo->ptype = PT_EXCHG;
816 pinfo->r_ctl = fchdr.r_ctl;
818 is_ack = ((fchdr.r_ctl == 0xC0) || (fchdr.r_ctl == 0xC1));
820 /* There are two ways to determine if this is the first frame of a
822 * (i) The SOF bits indicate that this is the first frame OR
823 * (ii) This is an SOFf frame and seqcnt is 0.
825 is_1frame_inseq = (((pinfo->sof_eof & PINFO_SOF_FIRST_FRAME) == PINFO_SOF_FIRST_FRAME) ||
826 (((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) &&
827 (fchdr.seqcnt == 0)));
829 is_lastframe_inseq = ((pinfo->sof_eof & PINFO_EOF_LAST_FRAME) == PINFO_EOF_LAST_FRAME);
831 if ((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) {
832 is_lastframe_inseq = fchdr.fctl & FC_FCTL_SEQ_LAST;
834 is_valid_frame = ((pinfo->sof_eof & 0x40) == 0x40);
836 ftype = fc_get_ftype (fchdr.r_ctl, fchdr.type);
838 if (check_col (pinfo->cinfo, COL_INFO)) {
839 col_add_str (pinfo->cinfo, COL_INFO, match_strval (ftype, fc_ftype_vals));
841 if (ftype == FC_FTYPE_LINKCTL)
842 col_append_fstr (pinfo->cinfo, COL_INFO, ", %s",
843 match_strval ((fchdr.r_ctl & 0x0F),
847 /* In the interest of speed, if "tree" is NULL, don't do any work not
848 necessary to generate protocol tree items. */
850 ti = proto_tree_add_protocol_format (tree, proto_fc, tvb, offset,
851 FC_HEADER_SIZE, "Fibre Channel");
852 fc_tree = proto_item_add_subtree (ti, ett_fc);
855 /* match first exchange with last exchange */
856 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
857 if(!pinfo->fd->flags.visited){
858 fc_exchange_data fced, *old_fced;
860 /* first check if we already have seen this exchange and it
861 is still open/unmatched.
863 fced.oxid=fchdr.oxid;
864 SET_ADDRESS(&fced.s_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
865 SET_ADDRESS(&fced.d_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
866 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
868 g_hash_table_remove(fc_exchange_unmatched, old_fced);
870 old_fced=g_mem_chunk_alloc(fc_exchange_vals);
871 old_fced->oxid=fchdr.oxid;
872 COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id);
873 COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id);
874 old_fced->first_exchange_frame=pinfo->fd->num;
875 old_fced->fc_time.nsecs = pinfo->fd->abs_usecs*1000;
876 old_fced->fc_time.secs = pinfo->fd->abs_secs;
877 g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced);
880 fc_exchange_data fced, *old_fced;
881 fced.oxid=fchdr.oxid;
882 fced.first_exchange_frame=pinfo->fd->num;
883 fced.last_exchange_frame=0;
884 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
888 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
889 if(!pinfo->fd->flags.visited){
890 fc_exchange_data fced, *old_fced;
892 fced.oxid=fchdr.oxid;
893 SET_ADDRESS(&fced.s_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
894 SET_ADDRESS(&fced.d_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
895 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
897 g_hash_table_remove(fc_exchange_unmatched, old_fced);
898 old_fced->last_exchange_frame=pinfo->fd->num;
899 g_hash_table_insert(fc_exchange_matched, old_fced, old_fced);
903 fc_exchange_data fced, *old_fced;
904 fced.oxid=fchdr.oxid;
905 fced.first_exchange_frame=0;
906 fced.last_exchange_frame=pinfo->fd->num;
907 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
912 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
913 proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame);
915 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
917 proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame);
918 delta_time.secs = pinfo->fd->abs_secs - fc_ex->fc_time.secs;
919 delta_time.nsecs = pinfo->fd->abs_usecs*1000 - fc_ex->fc_time.nsecs;
920 if (delta_time.nsecs<0){
921 delta_time.nsecs+=1000000000;
924 proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_time);
929 switch (fchdr.r_ctl & 0xF0) {
931 case FC_RCTL_DEV_DATA:
932 case FC_RCTL_LINK_DATA:
934 /* the lower 4 bits of R_CTL are the information category */
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),
945 case FC_RCTL_LINK_CTL:
946 /* the lower 4 bits of R_CTL indicate the type of link ctl frame */
947 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
948 FC_RCTL_SIZE, fchdr.r_ctl,
949 "R_CTL: 0x%x(%s/%s)",
951 val_to_str ((fchdr.r_ctl & 0xF0),
952 fc_routing_val, "0x%x"),
953 val_to_str ((fchdr.r_ctl & 0x0F),
954 fc_lctl_proto_val, "0x%x"));
958 switch (fchdr.type) {
961 /* the lower 4 bits of R_CTL indicate the type of BLS frame */
962 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
963 FC_RCTL_SIZE, fchdr.r_ctl,
964 "R_CTL: 0x%x(%s/%s)",
966 val_to_str ((fchdr.r_ctl & 0xF0),
967 fc_routing_val, "0x%x"),
968 val_to_str ((fchdr.r_ctl & 0x0F),
969 fc_bls_proto_val, "0x%x"));
973 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
974 FC_RCTL_SIZE, fchdr.r_ctl,
975 "R_CTL: 0x%x(%s/0x%x)",
977 val_to_str ((fchdr.r_ctl & 0xF0),
978 fc_routing_val, "0x%x"),
985 switch (fchdr.type) {
988 /* the lower 4 bits of R_CTL indicate the type of ELS frame */
989 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
990 FC_RCTL_SIZE, fchdr.r_ctl,
991 "R_CTL: 0x%x(%s/%s)",
993 val_to_str ((fchdr.r_ctl & 0xF0),
994 fc_routing_val, "0x%x"),
995 val_to_str ((fchdr.r_ctl & 0x0F),
996 fc_els_proto_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);
1012 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
1013 FC_RCTL_SIZE, fchdr.r_ctl,
1014 "R_CTL: 0x%x(%s/0x%x)",
1016 val_to_str ((fchdr.r_ctl & 0xF0),
1017 fc_routing_val, "0x%x"),
1018 fchdr.r_ctl & 0x0F);
1022 proto_tree_add_uint_hidden (fc_tree, hf_fc_ftype, tvb, offset, 1,
1025 /* XXX - use "fc_wka_vals[]" on this? */
1026 proto_tree_add_string (fc_tree, hf_fc_did, tvb, offset+1, 3,
1027 fc_to_str (fchdr.d_id.data));
1028 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+1, 3,
1029 fc_to_str (fchdr.d_id.data));
1031 proto_tree_add_uint (fc_tree, hf_fc_csctl, tvb, offset+4, 1, fchdr.cs_ctl);
1033 /* XXX - use "fc_wka_vals[]" on this? */
1034 proto_tree_add_string (fc_tree, hf_fc_sid, tvb, offset+5, 3,
1035 fc_to_str (fchdr.s_id.data));
1036 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+5, 3,
1037 fc_to_str (fchdr.s_id.data));
1039 if (ftype == FC_FTYPE_LINKCTL) {
1040 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYB) ||
1041 ((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYL)) {
1042 /* for F_BSY frames, the upper 4 bits of the type field specify the
1043 * reason for the BSY.
1045 proto_tree_add_uint_format (fc_tree, hf_fc_type, tvb,
1046 offset+8, FC_TYPE_SIZE,
1047 fchdr.type,"Type: 0x%x(%s)", fchdr.type,
1048 fclctl_get_typestr (fchdr.r_ctl & 0x0F,
1051 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1054 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1058 dissect_fc_fctl(pinfo, fc_tree, tvb, offset+9, is_ack, fchdr.fctl);
1061 proto_tree_add_item (fc_tree, hf_fc_seqid, tvb, offset+12, 1, FALSE);
1063 df_ctl = tvb_get_guint8(tvb, offset+13);
1065 proto_tree_add_uint (fc_tree, hf_fc_dfctl, tvb, offset+13, 1, df_ctl);
1066 proto_tree_add_uint (fc_tree, hf_fc_seqcnt, tvb, offset+14, 2, fchdr.seqcnt);
1067 proto_tree_add_uint (fc_tree, hf_fc_oxid, tvb, offset+16, 2, fchdr.oxid);
1068 proto_tree_add_uint (fc_tree, hf_fc_rxid, tvb, offset+18, 2, fchdr.rxid);
1070 if (ftype == FC_FTYPE_LINKCTL) {
1071 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FRJT) ||
1072 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PRJT) ||
1073 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PBSY)) {
1074 /* In all these cases of Link Ctl frame, the parameter field
1075 * encodes the detailed error message
1077 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1078 offset+20, 4, param,
1079 "Parameter: 0x%x(%s)", param,
1080 fclctl_get_paramstr ((fchdr.r_ctl & 0x0F),
1083 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1085 } else if (ftype == FC_FTYPE_BLS) {
1086 if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
1087 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1088 offset+20, 4, param,
1089 "Parameter: 0x%x(%s)", param,
1090 ((param & 0x0F) == 1 ? "Abort Sequence" :
1093 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20,
1097 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1100 /* Skip the Frame_Header */
1101 next_offset = offset + FC_HEADER_SIZE;
1103 /* Network_Header present? */
1104 if (df_ctl & FC_DFCTL_NH) {
1105 /* Yes - dissect it. */
1107 proto_tree_add_string (fc_tree, hf_fc_nh_da, tvb, next_offset, 8,
1108 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
1109 proto_tree_add_string (fc_tree, hf_fc_nh_sa, tvb, offset+8, 8,
1110 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
1115 /* XXX - handle Association_Header and Device_Header here */
1117 if (ftype == FC_FTYPE_LINKCTL) {
1118 /* ACK_1 frames and other LINK_CTL frames echo the last seq bit if the
1119 * packet they're ack'ing did not have it set. So, we'll incorrectly
1120 * flag them as being fragmented when they're not. This fixes the
1123 is_lastframe_inseq = TRUE;
1125 /* XXX is this right? offset 20, shouldnt it be offset 9? */
1126 is_exchg_resp = ((tvb_get_guint8 (tvb, offset+20) & 0x80) == 0x80);
1129 frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE;
1131 /* If there is an MDS header, we need to subtract the MDS trailer size */
1132 if ((pinfo->ethertype == ETHERTYPE_UNK) || (pinfo->ethertype == ETHERTYPE_FCFT)) {
1133 frag_size -= MDSHDR_TRAILER_SIZE;
1134 } else if (pinfo->ethertype == ETHERTYPE_BRDWALK) {
1135 frag_size -= 8; /* 4 byte of FC CRC +
1136 4 bytes of error+EOF = 8 bytes */
1139 if (!is_lastframe_inseq) {
1140 /* Show this only as a fragmented FC frame */
1141 if (check_col (pinfo->cinfo, COL_INFO)) {
1142 col_append_str (pinfo->cinfo, COL_INFO, " (Fragmented)");
1146 /* If this is a fragment, attempt to check if fully reassembled frame is
1147 * present, if we're configured to reassemble.
1149 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
1150 (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble &&
1151 tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) {
1152 /* Add this to the list of fragments */
1154 /* In certain cases such as FICON, the SEQ_CNT is streaming
1155 * i.e. continuously increasing. So, zero does not signify the
1156 * first frame of the sequence. To fix this, we need to save the
1157 * SEQ_CNT of the first frame in sequence and use this value to
1158 * determine the actual offset into a frame.
1160 conversation = find_conversation (&pinfo->src, &pinfo->dst,
1161 pinfo->ptype, pinfo->oxid,
1162 pinfo->rxid, NO_PORT2);
1163 if (!conversation) {
1164 conversation = conversation_new (&pinfo->src, &pinfo->dst,
1165 pinfo->ptype, pinfo->oxid,
1166 pinfo->rxid, NO_PORT2);
1169 ckey.conv_idx = conversation->index;
1171 cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash,
1174 if (is_1frame_inseq) {
1176 /* Since we never free the memory used by an exchange, this maybe a
1177 * case of another request using the same exchange as a previous
1180 cdata->seq_cnt = fchdr.seqcnt;
1183 req_key = g_mem_chunk_alloc (fcseq_req_keys);
1184 req_key->conv_idx = conversation->index;
1186 cdata = g_mem_chunk_alloc (fcseq_req_vals);
1187 cdata->seq_cnt = fchdr.seqcnt;
1189 g_hash_table_insert (fcseq_req_hash, req_key, cdata);
1193 else if (cdata != NULL) {
1194 real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ;
1197 real_seqcnt = fchdr.seqcnt;
1200 frag_id = ((pinfo->oxid << 16) ^ seq_id) | is_exchg_resp ;
1202 /* We assume that all frames are of the same max size */
1203 fcfrag_head = fragment_add (tvb, FC_HEADER_SIZE, pinfo, frag_id,
1205 real_seqcnt * fc_max_frame_size,
1207 !is_lastframe_inseq);
1210 next_tvb = tvb_new_real_data (fcfrag_head->data,
1211 fcfrag_head->datalen,
1212 fcfrag_head->datalen);
1213 tvb_set_child_real_data_tvbuff(tvb, next_tvb);
1215 /* Add the defragmented data to the data source list. */
1216 add_new_data_source(pinfo, next_tvb, "Reassembled FC");
1219 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1220 tvb, offset+9, 1, 1);
1225 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1226 tvb, offset+9, 1, 0);
1228 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1229 call_dissector (data_handle, next_tvb, pinfo, tree);
1234 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1235 tvb, offset+9, 1, 0);
1237 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1240 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS)) {
1241 if (!dissector_try_port (fcftype_dissector_table, ftype, next_tvb,
1243 call_dissector (data_handle, next_tvb, pinfo, tree);
1245 } else if (ftype == FC_FTYPE_BLS) {
1246 if ((fchdr.r_ctl & 0x0F) == FC_BLS_BAACC) {
1247 dissect_fc_ba_acc (next_tvb, pinfo, tree);
1248 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_BARJT) {
1249 dissect_fc_ba_rjt (next_tvb, pinfo, tree);
1253 tap_queue_packet(fc_tap, pinfo, &fchdr);
1257 /* Register the protocol with Ethereal */
1259 /* this format is require because a script is used to build the C function
1260 that calls all the protocol registration.
1264 proto_register_fc(void)
1267 /* Setup list of header fields See Section 1.6.1 for details*/
1268 static hf_register_info hf[] = {
1270 { "R_CTL", "fc.r_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1273 {"Frame type", "fc.ftype", FT_UINT8, BASE_HEX, VALS(fc_ftype_vals),
1274 0x0, "Derived Type", HFILL}},
1276 { "Dest Addr", "fc.d_id", FT_STRING, BASE_HEX, NULL, 0x0,
1277 "Destination Address", HFILL}},
1279 {"CS_CTL", "fc.cs_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1282 {"Src Addr", "fc.s_id", FT_STRING, BASE_HEX, NULL, 0x0,
1283 "Source Address", HFILL}},
1285 {"Addr", "fc.id", FT_STRING, BASE_HEX, NULL, 0x0,
1286 "Source or Destination Address", HFILL}},
1288 {"Type", "fc.type", FT_UINT8, BASE_HEX, VALS (fc_fc4_val), 0x0,
1291 {"F_CTL", "fc.f_ctl", FT_UINT24, BASE_HEX, NULL, 0x0, "", HFILL}},
1293 {"SEQ_ID", "fc.seq_id", FT_UINT8, BASE_HEX, NULL, 0x0,
1294 "Sequence ID", HFILL}},
1296 {"DF_CTL", "fc.df_ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1298 {"SEQ_CNT", "fc.seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0,
1299 "Sequence Count", HFILL}},
1301 {"OX_ID", "fc.ox_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Originator ID",
1304 {"RX_ID", "fc.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Receiver ID",
1307 {"Parameter", "fc.parameter", FT_UINT32, BASE_HEX, NULL, 0x0, "Parameter",
1310 { &hf_fc_reassembled,
1311 {"Reassembled Frame", "fc.reassembled", FT_BOOLEAN, BASE_HEX, NULL,
1314 {"Network DA", "fc.nethdr.da", FT_STRING, BASE_HEX, NULL,
1317 {"Network SA", "fc.nethdr.sa", FT_STRING, BASE_HEX, NULL,
1320 /* Basic Link Svc field definitions */
1321 { &hf_fc_bls_seqid_vld,
1322 {"SEQID Valid", "fc.bls_seqidvld", FT_UINT8, BASE_HEX,
1323 VALS (fc_bls_seqid_val), 0x0, "", HFILL}},
1324 { &hf_fc_bls_lastvld_seqid,
1325 {"Last Valid SEQID", "fc.bls_lastseqid", FT_UINT8, BASE_HEX, NULL,
1328 {"OXID", "fc.bls_oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1330 {"RXID", "fc.bls_rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1331 { &hf_fc_bls_lowseqcnt,
1332 {"Low SEQCNT", "fc.bls_lseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1334 { &hf_fc_bls_hiseqcnt,
1335 {"High SEQCNT", "fc.bls_hseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1337 { &hf_fc_bls_rjtcode,
1338 {"Reason", "fc.bls_reason", FT_UINT8, BASE_HEX, VALS(fc_bls_barjt_val),
1340 { &hf_fc_bls_rjtdetail,
1341 {"Reason Explanantion", "fc.bls_rjtdetail", FT_UINT8, BASE_HEX,
1342 VALS (fc_bls_barjt_det_val), 0x0, "", HFILL}},
1343 { &hf_fc_bls_vendor,
1344 {"Vendor Unique Reason", "fc.bls_vnduniq", FT_UINT8, BASE_HEX, NULL,
1346 { &hf_fc_fctl_exchange_responder,
1347 {"ExgRpd", "fc.fctl.exchange_responder", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_responder),
1348 FC_FCTL_EXCHANGE_RESPONDER, "Exchange Responder?", HFILL}},
1349 { &hf_fc_fctl_seq_recipient,
1350 {"SeqRec", "fc.fctl.seq_recipient", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_recipient),
1351 FC_FCTL_SEQ_RECIPIENT, "Seq Recipient?", HFILL}},
1352 { &hf_fc_fctl_exchange_first,
1353 {"ExgFst", "fc.fctl.exchange_first", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_first),
1354 FC_FCTL_EXCHANGE_FIRST, "First Exchange?", HFILL}},
1355 { &hf_fc_fctl_exchange_last,
1356 {"ExgLst", "fc.fctl.exchange_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_last),
1357 FC_FCTL_EXCHANGE_LAST, "Last Exchange?", HFILL}},
1358 { &hf_fc_fctl_seq_last,
1359 {"SeqLst", "fc.fctl.seq_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_last),
1360 FC_FCTL_SEQ_LAST, "Last Sequence?", HFILL}},
1361 { &hf_fc_fctl_priority,
1362 {"Pri", "fc.fctl.priority", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_priority),
1363 FC_FCTL_PRIORITY, "Priority", HFILL}},
1364 { &hf_fc_fctl_transfer_seq_initiative,
1365 {"TSI", "fc.fctl.transfer_seq_initiative", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_transfer_seq_initiative),
1366 FC_FCTL_TRANSFER_SEQ_INITIATIVE, "Transfer Seq Initiative", HFILL}},
1367 { &hf_fc_fctl_rexmitted_seq,
1368 {"RetSeq", "fc.fctl.rexmitted_seq", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rexmitted_seq),
1369 FC_FCTL_REXMITTED_SEQ, "Retransmitted Sequence", HFILL}},
1370 { &hf_fc_fctl_rel_offset,
1371 {"RelOff", "fc.fctl.rel_offset", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rel_offset),
1372 FC_FCTL_REL_OFFSET, "rel offset", HFILL}},
1373 { &hf_fc_fctl_last_data_frame,
1374 {"LDF", "fc.fctl.last_data_frame", FT_UINT24, BASE_HEX, VALS(last_data_frame_vals),
1375 FC_FCTL_LAST_DATA_FRAME_MASK, "Last Data Frame?", HFILL}},
1376 { &hf_fc_fctl_ack_0_1,
1377 {"A01", "fc.fctl.ack_0_1", FT_UINT24, BASE_HEX, VALS(ack_0_1_vals),
1378 FC_FCTL_ACK_0_1_MASK, "Ack 0/1 value", HFILL}},
1379 { &hf_fc_fctl_abts_ack,
1380 {"AA", "fc.fctl.abts_ack", FT_UINT24, BASE_HEX, VALS(abts_ack_vals),
1381 FC_FCTL_ABTS_MASK, "ABTS ACK values", HFILL}},
1382 { &hf_fc_fctl_abts_not_ack,
1383 {"AnA", "fc.fctl.abts_not_ack", FT_UINT24, BASE_HEX, VALS(abts_not_ack_vals),
1384 FC_FCTL_ABTS_MASK, "ABTS not ACK vals", HFILL}},
1385 { &hf_fc_exchange_first_frame,
1386 { "Exchange First In", "fc.exchange_first_frame", FT_FRAMENUM, BASE_NONE, NULL,
1387 0, "The first frame of this exchange is in this frame", HFILL }},
1388 { &hf_fc_exchange_last_frame,
1389 { "Exchange Last In", "fc.exchange_last_frame", FT_FRAMENUM, BASE_NONE, NULL,
1390 0, "The last frame of this exchange is in this frame", HFILL }},
1392 { "Time from Exchange First", "fc.time", FT_RELATIVE_TIME, BASE_NONE, NULL,
1393 0, "Time since the first frame of the Exchange", HFILL }},
1396 /* Setup protocol subtree array */
1397 static gint *ett[] = {
1403 module_t *fc_module;
1405 /* Register the protocol name and description */
1406 proto_fc = proto_register_protocol ("Fibre Channel", "FC", "fc");
1407 register_dissector ("fc", dissect_fc, proto_fc);
1408 fc_tap = register_tap("fc");
1410 /* Required function calls to register the header fields and subtrees used */
1411 proto_register_field_array(proto_fc, hf, array_length(hf));
1412 proto_register_subtree_array(ett, array_length(ett));
1414 fcftype_dissector_table = register_dissector_table ("fc.ftype",
1416 FT_UINT8, BASE_HEX);
1418 /* Register preferences */
1419 fc_module = prefs_register_protocol (proto_fc, NULL);
1420 prefs_register_bool_preference (fc_module,
1422 "Reassemble multi-frame sequences",
1423 "If enabled, reassembly of multi-frame "
1424 "sequences is done",
1426 prefs_register_uint_preference (fc_module,
1427 "max_frame_size", "Max FC Frame Size",
1428 "This is the size of non-last frames in a "
1429 "multi-frame sequence", 10,
1430 &fc_max_frame_size);
1432 register_init_routine(fc_defragment_init);
1433 register_init_routine (fc_exchange_init_protocol);
1437 /* If this dissector uses sub-dissector registration add a registration routine.
1438 This format is required because a script is used to find these routines and
1439 create the code that calls these routines.
1442 proto_reg_handoff_fc (void)
1444 data_handle = find_dissector("data");