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 #ifdef NEED_SNPRINTF_H
48 # include "snprintf.h"
51 #include <epan/packet.h>
52 #include <epan/prefs.h>
53 #include <epan/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 const fcseq_conv_key_t *v1 = v;
170 const fcseq_conv_key_t *v2 = w;
172 return (v1->conv_idx == v2->conv_idx);
176 fcseq_hash (gconstpointer v)
178 const fcseq_conv_key_t *key = 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, val_to_str (ftype, fc_ftype_vals,
842 "Unknown Type (0x%x)"));
844 if (ftype == FC_FTYPE_LINKCTL)
845 col_append_fstr (pinfo->cinfo, COL_INFO, ", %s",
846 val_to_str ((fchdr.r_ctl & 0x0F),
851 /* In the interest of speed, if "tree" is NULL, don't do any work not
852 necessary to generate protocol tree items. */
854 ti = proto_tree_add_protocol_format (tree, proto_fc, tvb, offset,
855 FC_HEADER_SIZE, "Fibre Channel");
856 fc_tree = proto_item_add_subtree (ti, ett_fc);
859 /* Highlight EISL header, if present */
860 if (eisl_offset != -1) {
861 proto_tree_add_item (fc_tree, hf_fc_eisl, tvb, eisl_offset, 8, 0);
864 /* match first exchange with last exchange */
865 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
866 if(!pinfo->fd->flags.visited){
867 fc_exchange_data fced, *old_fced;
869 /* first check if we already have seen this exchange and it
870 is still open/unmatched.
872 fced.oxid=fchdr.oxid;
873 SET_ADDRESS(&fced.s_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
874 SET_ADDRESS(&fced.d_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
875 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
877 g_hash_table_remove(fc_exchange_unmatched, old_fced);
879 old_fced=g_mem_chunk_alloc(fc_exchange_vals);
880 old_fced->oxid=fchdr.oxid;
881 COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id);
882 COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id);
883 old_fced->first_exchange_frame=pinfo->fd->num;
884 old_fced->fc_time.nsecs = pinfo->fd->abs_usecs*1000;
885 old_fced->fc_time.secs = pinfo->fd->abs_secs;
886 g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced);
889 fc_exchange_data fced, *old_fced;
890 fced.oxid=fchdr.oxid;
891 fced.first_exchange_frame=pinfo->fd->num;
892 fced.last_exchange_frame=0;
893 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
897 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
898 if(!pinfo->fd->flags.visited){
899 fc_exchange_data fced, *old_fced;
901 fced.oxid=fchdr.oxid;
902 SET_ADDRESS(&fced.s_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
903 SET_ADDRESS(&fced.d_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
904 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
906 g_hash_table_remove(fc_exchange_unmatched, old_fced);
907 old_fced->last_exchange_frame=pinfo->fd->num;
908 g_hash_table_insert(fc_exchange_matched, old_fced, old_fced);
912 fc_exchange_data fced, *old_fced;
913 fced.oxid=fchdr.oxid;
914 fced.first_exchange_frame=0;
915 fced.last_exchange_frame=pinfo->fd->num;
916 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
921 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
922 proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame);
924 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
926 proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame);
927 delta_time.secs = pinfo->fd->abs_secs - fc_ex->fc_time.secs;
928 delta_time.nsecs = pinfo->fd->abs_usecs*1000 - fc_ex->fc_time.nsecs;
929 if (delta_time.nsecs<0){
930 delta_time.nsecs+=1000000000;
933 proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_time);
938 switch (fchdr.r_ctl & 0xF0) {
940 case FC_RCTL_DEV_DATA:
941 case FC_RCTL_LINK_DATA:
943 /* the lower 4 bits of R_CTL are the information category */
944 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
945 FC_RCTL_SIZE, fchdr.r_ctl,
946 "R_CTL: 0x%x(%s/%s)",
948 val_to_str ((fchdr.r_ctl & 0xF0),
949 fc_routing_val, "0x%x"),
950 val_to_str ((fchdr.r_ctl & 0x0F),
954 case FC_RCTL_LINK_CTL:
955 /* the lower 4 bits of R_CTL indicate the type of link ctl frame */
956 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
957 FC_RCTL_SIZE, fchdr.r_ctl,
958 "R_CTL: 0x%x(%s/%s)",
960 val_to_str ((fchdr.r_ctl & 0xF0),
961 fc_routing_val, "0x%x"),
962 val_to_str ((fchdr.r_ctl & 0x0F),
963 fc_lctl_proto_val, "0x%x"));
967 switch (fchdr.type) {
970 /* the lower 4 bits of R_CTL indicate the type of BLS frame */
971 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
972 FC_RCTL_SIZE, fchdr.r_ctl,
973 "R_CTL: 0x%x(%s/%s)",
975 val_to_str ((fchdr.r_ctl & 0xF0),
976 fc_routing_val, "0x%x"),
977 val_to_str ((fchdr.r_ctl & 0x0F),
978 fc_bls_proto_val, "0x%x"));
982 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
983 FC_RCTL_SIZE, fchdr.r_ctl,
984 "R_CTL: 0x%x(%s/0x%x)",
986 val_to_str ((fchdr.r_ctl & 0xF0),
987 fc_routing_val, "0x%x"),
994 switch (fchdr.type) {
997 /* the lower 4 bits of R_CTL indicate the type of ELS frame */
998 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
999 FC_RCTL_SIZE, fchdr.r_ctl,
1000 "R_CTL: 0x%x(%s/%s)",
1002 val_to_str ((fchdr.r_ctl & 0xF0),
1003 fc_routing_val, "0x%x"),
1004 val_to_str ((fchdr.r_ctl & 0x0F),
1005 fc_els_proto_val, "0x%x"));
1009 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
1010 FC_RCTL_SIZE, fchdr.r_ctl,
1011 "R_CTL: 0x%x(%s/0x%x)",
1013 val_to_str ((fchdr.r_ctl & 0xF0),
1014 fc_routing_val, "0x%x"),
1015 fchdr.r_ctl & 0x0F);
1021 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
1022 FC_RCTL_SIZE, fchdr.r_ctl,
1023 "R_CTL: 0x%x(%s/0x%x)",
1025 val_to_str ((fchdr.r_ctl & 0xF0),
1026 fc_routing_val, "0x%x"),
1027 fchdr.r_ctl & 0x0F);
1031 proto_tree_add_uint_hidden (fc_tree, hf_fc_ftype, tvb, offset, 1,
1034 /* XXX - use "fc_wka_vals[]" on this? */
1035 proto_tree_add_string (fc_tree, hf_fc_did, tvb, offset+1, 3,
1036 fc_to_str (fchdr.d_id.data));
1037 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+1, 3,
1038 fc_to_str (fchdr.d_id.data));
1040 proto_tree_add_uint (fc_tree, hf_fc_csctl, tvb, offset+4, 1, fchdr.cs_ctl);
1042 /* XXX - use "fc_wka_vals[]" on this? */
1043 proto_tree_add_string (fc_tree, hf_fc_sid, tvb, offset+5, 3,
1044 fc_to_str (fchdr.s_id.data));
1045 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+5, 3,
1046 fc_to_str (fchdr.s_id.data));
1048 if (ftype == FC_FTYPE_LINKCTL) {
1049 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYB) ||
1050 ((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYL)) {
1051 /* for F_BSY frames, the upper 4 bits of the type field specify the
1052 * reason for the BSY.
1054 proto_tree_add_uint_format (fc_tree, hf_fc_type, tvb,
1055 offset+8, FC_TYPE_SIZE,
1056 fchdr.type,"Type: 0x%x(%s)", fchdr.type,
1057 fclctl_get_typestr ((guint8) (fchdr.r_ctl & 0x0F),
1060 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1063 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
1067 dissect_fc_fctl(pinfo, fc_tree, tvb, offset+9, is_ack, fchdr.fctl);
1070 proto_tree_add_item (fc_tree, hf_fc_seqid, tvb, offset+12, 1, FALSE);
1072 df_ctl = tvb_get_guint8(tvb, offset+13);
1074 proto_tree_add_uint (fc_tree, hf_fc_dfctl, tvb, offset+13, 1, df_ctl);
1075 proto_tree_add_uint (fc_tree, hf_fc_seqcnt, tvb, offset+14, 2, fchdr.seqcnt);
1076 proto_tree_add_uint (fc_tree, hf_fc_oxid, tvb, offset+16, 2, fchdr.oxid);
1077 proto_tree_add_uint (fc_tree, hf_fc_rxid, tvb, offset+18, 2, fchdr.rxid);
1079 if (ftype == FC_FTYPE_LINKCTL) {
1080 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FRJT) ||
1081 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PRJT) ||
1082 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PBSY)) {
1083 /* In all these cases of Link Ctl frame, the parameter field
1084 * encodes the detailed error message
1086 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1087 offset+20, 4, param,
1088 "Parameter: 0x%x(%s)", param,
1089 fclctl_get_paramstr ((fchdr.r_ctl & 0x0F),
1092 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1094 } else if (ftype == FC_FTYPE_BLS) {
1095 if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
1096 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
1097 offset+20, 4, param,
1098 "Parameter: 0x%x(%s)", param,
1099 ((param & 0x0F) == 1 ? "Abort Sequence" :
1102 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20,
1106 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1109 /* Skip the Frame_Header */
1110 next_offset = offset + FC_HEADER_SIZE;
1112 /* Network_Header present? */
1113 if (df_ctl & FC_DFCTL_NH) {
1114 /* Yes - dissect it. */
1116 proto_tree_add_string (fc_tree, hf_fc_nh_da, tvb, next_offset, 8,
1117 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
1118 proto_tree_add_string (fc_tree, hf_fc_nh_sa, tvb, offset+8, 8,
1119 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
1124 /* XXX - handle Association_Header and Device_Header here */
1126 if (ftype == FC_FTYPE_LINKCTL) {
1127 /* ACK_1 frames and other LINK_CTL frames echo the last seq bit if the
1128 * packet they're ack'ing did not have it set. So, we'll incorrectly
1129 * flag them as being fragmented when they're not. This fixes the
1132 is_lastframe_inseq = TRUE;
1134 /* XXX is this right? offset 20, shouldnt it be offset 9? */
1135 is_exchg_resp = ((tvb_get_guint8 (tvb, offset+20) & 0x80) == 0x80);
1138 if (tvb_reported_length (tvb) <= FC_HEADER_SIZE)
1139 THROW(ReportedBoundsError);
1141 frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE;
1143 /* If there is an MDS header, we need to subtract the MDS trailer size */
1144 if ((pinfo->ethertype == ETHERTYPE_UNK) || (pinfo->ethertype == ETHERTYPE_FCFT)) {
1145 if (frag_size <= MDSHDR_TRAILER_SIZE)
1146 THROW(ReportedBoundsError);
1147 frag_size -= MDSHDR_TRAILER_SIZE;
1148 } else if (pinfo->ethertype == ETHERTYPE_BRDWALK) {
1150 THROW(ReportedBoundsError);
1151 frag_size -= 8; /* 4 byte of FC CRC +
1152 4 bytes of error+EOF = 8 bytes */
1155 if (!is_lastframe_inseq) {
1156 /* Show this only as a fragmented FC frame */
1157 if (check_col (pinfo->cinfo, COL_INFO)) {
1158 col_append_str (pinfo->cinfo, COL_INFO, " (Fragmented)");
1162 /* If this is a fragment, attempt to check if fully reassembled frame is
1163 * present, if we're configured to reassemble.
1165 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
1166 (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble &&
1167 tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) {
1168 /* Add this to the list of fragments */
1170 /* In certain cases such as FICON, the SEQ_CNT is streaming
1171 * i.e. continuously increasing. So, zero does not signify the
1172 * first frame of the sequence. To fix this, we need to save the
1173 * SEQ_CNT of the first frame in sequence and use this value to
1174 * determine the actual offset into a frame.
1176 conversation = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
1177 pinfo->ptype, pinfo->oxid,
1178 pinfo->rxid, NO_PORT2);
1179 if (!conversation) {
1180 conversation = conversation_new (pinfo->fd->num, &pinfo->src, &pinfo->dst,
1181 pinfo->ptype, pinfo->oxid,
1182 pinfo->rxid, NO_PORT2);
1185 ckey.conv_idx = conversation->index;
1187 cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash,
1190 if (is_1frame_inseq) {
1192 /* Since we never free the memory used by an exchange, this maybe a
1193 * case of another request using the same exchange as a previous
1196 cdata->seq_cnt = fchdr.seqcnt;
1199 req_key = g_mem_chunk_alloc (fcseq_req_keys);
1200 req_key->conv_idx = conversation->index;
1202 cdata = g_mem_chunk_alloc (fcseq_req_vals);
1203 cdata->seq_cnt = fchdr.seqcnt;
1205 g_hash_table_insert (fcseq_req_hash, req_key, cdata);
1209 else if (cdata != NULL) {
1210 real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ;
1213 real_seqcnt = fchdr.seqcnt;
1216 /* Verify that this is a valid fragment */
1217 if (is_lastframe_inseq && !is_1frame_inseq && !real_seqcnt) {
1218 /* This is a frame that purports to be the last frame in a
1219 * sequence, is not the first frame, but has a seqcnt that is
1220 * 0. This is a bogus frame, don't attempt to reassemble it.
1222 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1223 if (check_col (pinfo->cinfo, COL_INFO)) {
1224 col_append_str (pinfo->cinfo, COL_INFO, " (Bogus Fragment)");
1228 frag_id = ((pinfo->oxid << 16) ^ seq_id) | is_exchg_resp ;
1230 /* We assume that all frames are of the same max size */
1231 fcfrag_head = fragment_add (tvb, FC_HEADER_SIZE, pinfo, frag_id,
1233 real_seqcnt * fc_max_frame_size,
1235 !is_lastframe_inseq);
1238 next_tvb = tvb_new_real_data (fcfrag_head->data,
1239 fcfrag_head->datalen,
1240 fcfrag_head->datalen);
1241 tvb_set_child_real_data_tvbuff(tvb, next_tvb);
1243 /* Add the defragmented data to the data source list. */
1244 add_new_data_source(pinfo, next_tvb, "Reassembled FC");
1247 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1248 tvb, offset+9, 1, 1);
1253 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1254 tvb, offset+9, 1, 0);
1256 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1257 call_dissector (data_handle, next_tvb, pinfo, tree);
1263 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1264 tvb, offset+9, 1, 0);
1266 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1269 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS)) {
1270 if (!dissector_try_port (fcftype_dissector_table, ftype, next_tvb,
1272 call_dissector (data_handle, next_tvb, pinfo, tree);
1274 } else if (ftype == FC_FTYPE_BLS) {
1275 if ((fchdr.r_ctl & 0x0F) == FC_BLS_BAACC) {
1276 dissect_fc_ba_acc (next_tvb, pinfo, tree);
1277 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_BARJT) {
1278 dissect_fc_ba_rjt (next_tvb, pinfo, tree);
1282 tap_queue_packet(fc_tap, pinfo, &fchdr);
1286 /* Register the protocol with Ethereal */
1288 /* this format is require because a script is used to build the C function
1289 that calls all the protocol registration.
1293 proto_register_fc(void)
1296 /* Setup list of header fields See Section 1.6.1 for details*/
1297 static hf_register_info hf[] = {
1299 { "R_CTL", "fc.r_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1302 {"Frame type", "fc.ftype", FT_UINT8, BASE_HEX, VALS(fc_ftype_vals),
1303 0x0, "Derived Type", HFILL}},
1305 { "Dest Addr", "fc.d_id", FT_STRING, BASE_HEX, NULL, 0x0,
1306 "Destination Address", HFILL}},
1308 {"CS_CTL", "fc.cs_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1311 {"Src Addr", "fc.s_id", FT_STRING, BASE_HEX, NULL, 0x0,
1312 "Source Address", HFILL}},
1314 {"Addr", "fc.id", FT_STRING, BASE_HEX, NULL, 0x0,
1315 "Source or Destination Address", HFILL}},
1317 {"Type", "fc.type", FT_UINT8, BASE_HEX, VALS (fc_fc4_val), 0x0,
1320 {"F_CTL", "fc.f_ctl", FT_UINT24, BASE_HEX, NULL, 0x0, "", HFILL}},
1322 {"SEQ_ID", "fc.seq_id", FT_UINT8, BASE_HEX, NULL, 0x0,
1323 "Sequence ID", HFILL}},
1325 {"DF_CTL", "fc.df_ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1327 {"SEQ_CNT", "fc.seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0,
1328 "Sequence Count", HFILL}},
1330 {"OX_ID", "fc.ox_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Originator ID",
1333 {"RX_ID", "fc.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Receiver ID",
1336 {"Parameter", "fc.parameter", FT_UINT32, BASE_HEX, NULL, 0x0, "Parameter",
1339 { &hf_fc_reassembled,
1340 {"Reassembled Frame", "fc.reassembled", FT_BOOLEAN, BASE_HEX, NULL,
1343 {"Network DA", "fc.nethdr.da", FT_STRING, BASE_HEX, NULL,
1346 {"Network SA", "fc.nethdr.sa", FT_STRING, BASE_HEX, NULL,
1349 /* Basic Link Svc field definitions */
1350 { &hf_fc_bls_seqid_vld,
1351 {"SEQID Valid", "fc.bls_seqidvld", FT_UINT8, BASE_HEX,
1352 VALS (fc_bls_seqid_val), 0x0, "", HFILL}},
1353 { &hf_fc_bls_lastvld_seqid,
1354 {"Last Valid SEQID", "fc.bls_lastseqid", FT_UINT8, BASE_HEX, NULL,
1357 {"OXID", "fc.bls_oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1359 {"RXID", "fc.bls_rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1360 { &hf_fc_bls_lowseqcnt,
1361 {"Low SEQCNT", "fc.bls_lseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1363 { &hf_fc_bls_hiseqcnt,
1364 {"High SEQCNT", "fc.bls_hseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1366 { &hf_fc_bls_rjtcode,
1367 {"Reason", "fc.bls_reason", FT_UINT8, BASE_HEX, VALS(fc_bls_barjt_val),
1369 { &hf_fc_bls_rjtdetail,
1370 {"Reason Explanantion", "fc.bls_rjtdetail", FT_UINT8, BASE_HEX,
1371 VALS (fc_bls_barjt_det_val), 0x0, "", HFILL}},
1372 { &hf_fc_bls_vendor,
1373 {"Vendor Unique Reason", "fc.bls_vnduniq", FT_UINT8, BASE_HEX, NULL,
1375 { &hf_fc_fctl_exchange_responder,
1376 {"ExgRpd", "fc.fctl.exchange_responder", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_responder),
1377 FC_FCTL_EXCHANGE_RESPONDER, "Exchange Responder?", HFILL}},
1378 { &hf_fc_fctl_seq_recipient,
1379 {"SeqRec", "fc.fctl.seq_recipient", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_recipient),
1380 FC_FCTL_SEQ_RECIPIENT, "Seq Recipient?", HFILL}},
1381 { &hf_fc_fctl_exchange_first,
1382 {"ExgFst", "fc.fctl.exchange_first", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_first),
1383 FC_FCTL_EXCHANGE_FIRST, "First Exchange?", HFILL}},
1384 { &hf_fc_fctl_exchange_last,
1385 {"ExgLst", "fc.fctl.exchange_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_last),
1386 FC_FCTL_EXCHANGE_LAST, "Last Exchange?", HFILL}},
1387 { &hf_fc_fctl_seq_last,
1388 {"SeqLst", "fc.fctl.seq_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_last),
1389 FC_FCTL_SEQ_LAST, "Last Sequence?", HFILL}},
1390 { &hf_fc_fctl_priority,
1391 {"Pri", "fc.fctl.priority", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_priority),
1392 FC_FCTL_PRIORITY, "Priority", HFILL}},
1393 { &hf_fc_fctl_transfer_seq_initiative,
1394 {"TSI", "fc.fctl.transfer_seq_initiative", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_transfer_seq_initiative),
1395 FC_FCTL_TRANSFER_SEQ_INITIATIVE, "Transfer Seq Initiative", HFILL}},
1396 { &hf_fc_fctl_rexmitted_seq,
1397 {"RetSeq", "fc.fctl.rexmitted_seq", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rexmitted_seq),
1398 FC_FCTL_REXMITTED_SEQ, "Retransmitted Sequence", HFILL}},
1399 { &hf_fc_fctl_rel_offset,
1400 {"RelOff", "fc.fctl.rel_offset", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rel_offset),
1401 FC_FCTL_REL_OFFSET, "rel offset", HFILL}},
1402 { &hf_fc_fctl_last_data_frame,
1403 {"LDF", "fc.fctl.last_data_frame", FT_UINT24, BASE_HEX, VALS(last_data_frame_vals),
1404 FC_FCTL_LAST_DATA_FRAME_MASK, "Last Data Frame?", HFILL}},
1405 { &hf_fc_fctl_ack_0_1,
1406 {"A01", "fc.fctl.ack_0_1", FT_UINT24, BASE_HEX, VALS(ack_0_1_vals),
1407 FC_FCTL_ACK_0_1_MASK, "Ack 0/1 value", HFILL}},
1408 { &hf_fc_fctl_abts_ack,
1409 {"AA", "fc.fctl.abts_ack", FT_UINT24, BASE_HEX, VALS(abts_ack_vals),
1410 FC_FCTL_ABTS_MASK, "ABTS ACK values", HFILL}},
1411 { &hf_fc_fctl_abts_not_ack,
1412 {"AnA", "fc.fctl.abts_not_ack", FT_UINT24, BASE_HEX, VALS(abts_not_ack_vals),
1413 FC_FCTL_ABTS_MASK, "ABTS not ACK vals", HFILL}},
1414 { &hf_fc_exchange_first_frame,
1415 { "Exchange First In", "fc.exchange_first_frame", FT_FRAMENUM, BASE_NONE, NULL,
1416 0, "The first frame of this exchange is in this frame", HFILL }},
1417 { &hf_fc_exchange_last_frame,
1418 { "Exchange Last In", "fc.exchange_last_frame", FT_FRAMENUM, BASE_NONE, NULL,
1419 0, "The last frame of this exchange is in this frame", HFILL }},
1421 { "Time from Exchange First", "fc.time", FT_RELATIVE_TIME, BASE_NONE, NULL,
1422 0, "Time since the first frame of the Exchange", HFILL }},
1424 {"EISL Header", "fc.eisl", FT_BYTES, BASE_HEX, NULL, 0, "EISL Header", HFILL}},
1427 /* Setup protocol subtree array */
1428 static gint *ett[] = {
1434 module_t *fc_module;
1436 /* Register the protocol name and description */
1437 proto_fc = proto_register_protocol ("Fibre Channel", "FC", "fc");
1438 register_dissector ("fc", dissect_fc, proto_fc);
1439 fc_tap = register_tap("fc");
1441 /* Required function calls to register the header fields and subtrees used */
1442 proto_register_field_array(proto_fc, hf, array_length(hf));
1443 proto_register_subtree_array(ett, array_length(ett));
1445 fcftype_dissector_table = register_dissector_table ("fc.ftype",
1447 FT_UINT8, BASE_HEX);
1449 /* Register preferences */
1450 fc_module = prefs_register_protocol (proto_fc, NULL);
1451 prefs_register_bool_preference (fc_module,
1453 "Reassemble multi-frame sequences",
1454 "If enabled, reassembly of multi-frame "
1455 "sequences is done",
1457 prefs_register_uint_preference (fc_module,
1458 "max_frame_size", "Max FC Frame Size",
1459 "This is the size of non-last frames in a "
1460 "multi-frame sequence", 10,
1461 &fc_max_frame_size);
1463 register_init_routine(fc_defragment_init);
1464 register_init_routine (fc_exchange_init_protocol);
1468 /* If this dissector uses sub-dissector registration add a registration routine.
1469 This format is required because a script is used to find these routines and
1470 create the code that calls these routines.
1473 proto_reg_handoff_fc (void)
1475 data_handle = find_dissector("data");