2 * Routines for Fibre Channel Decoding (FC Header, Link Ctl & Basic Link Svc)
3 * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
4 * Copyright 2003 Ronnie Sahlberg, exchange first/last matching and
5 * tap listener and misc updates
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #ifdef HAVE_SYS_TYPES_H
38 # include <sys/types.h>
41 #ifdef HAVE_NETINET_IN_H
42 # include <netinet/in.h>
47 #include <epan/packet.h>
48 #include <epan/prefs.h>
49 #include <epan/reassemble.h>
50 #include <epan/conversation.h>
51 #include <epan/etypes.h>
52 #include "packet-fc.h"
53 #include "packet-fclctl.h"
54 #include "packet-fcbls.h"
56 #include <epan/emem.h>
58 #define FC_HEADER_SIZE 24
59 #define FC_RCTL_EISL 0x50
60 #define MDSHDR_TRAILER_SIZE 6
62 /* Size of various fields in FC header in bytes */
63 #define FC_RCTL_SIZE 1
65 #define FC_CSCTL_SIZE 1
67 #define FC_TYPE_SIZE 1
68 #define FC_FCTL_SIZE 3
69 #define FC_SEQID_SIZE 1
70 #define FC_DFCTL_SIZE 1
71 #define FC_SEQCNT_SIZE 2
72 #define FC_OXID_SIZE 2
73 #define FC_RXID_SIZE 2
74 #define FC_PARAM_SIZE 4
76 /* Initialize the protocol and registered fields */
77 static int proto_fc = -1;
78 static int hf_fc_time = -1;
79 static int hf_fc_exchange_first_frame = -1;
80 static int hf_fc_exchange_last_frame = -1;
81 static int hf_fc_rctl = -1;
82 static int hf_fc_did = -1;
83 static int hf_fc_csctl = -1;
84 static int hf_fc_sid = -1;
85 static int hf_fc_id = -1;
86 static int hf_fc_type = -1;
87 static int hf_fc_fctl = -1;
88 static int hf_fc_fctl_exchange_responder = -1;
89 static int hf_fc_fctl_seq_recipient = -1;
90 static int hf_fc_fctl_exchange_first = -1;
91 static int hf_fc_fctl_exchange_last = -1;
92 static int hf_fc_fctl_seq_last = -1;
93 static int hf_fc_fctl_priority = -1;
94 static int hf_fc_fctl_transfer_seq_initiative = -1;
95 static int hf_fc_fctl_rexmitted_seq = -1;
96 static int hf_fc_fctl_rel_offset = -1;
97 static int hf_fc_fctl_abts_ack = -1;
98 static int hf_fc_fctl_abts_not_ack = -1;
99 static int hf_fc_fctl_last_data_frame = -1;
100 static int hf_fc_fctl_ack_0_1 = -1;
101 static int hf_fc_seqid = -1;
102 static int hf_fc_dfctl = -1;
103 static int hf_fc_seqcnt = -1;
104 static int hf_fc_oxid = -1;
105 static int hf_fc_rxid = -1;
106 static int hf_fc_param = -1;
107 static int hf_fc_ftype = -1; /* Derived field, non-existent in FC hdr */
108 static int hf_fc_reassembled = -1;
109 static int hf_fc_eisl = -1;
111 /* Network_Header fields */
112 static int hf_fc_nh_da = -1;
113 static int hf_fc_nh_sa = -1;
115 /* For Basic Link Svc */
116 static int hf_fc_bls_seqid_vld = -1;
117 static int hf_fc_bls_lastvld_seqid = -1;
118 static int hf_fc_bls_oxid = -1;
119 static int hf_fc_bls_rxid = -1;
120 static int hf_fc_bls_lowseqcnt = -1;
121 static int hf_fc_bls_hiseqcnt = -1;
122 static int hf_fc_bls_rjtcode = -1;
123 static int hf_fc_bls_rjtdetail = -1;
124 static int hf_fc_bls_vendor = -1;
127 /* Initialize the subtree pointers */
128 static gint ett_fc = -1;
129 static gint ett_fctl = -1;
130 static gint ett_fcbls = -1;
132 static dissector_table_t fcftype_dissector_table;
133 static dissector_handle_t data_handle;
135 static int fc_tap = -1;
137 /* Reassembly stuff */
138 static gboolean fc_reassemble = TRUE;
139 static guint32 fc_max_frame_size = 1024;
140 static GHashTable *fc_fragment_table = NULL;
142 typedef struct _fcseq_conv_key {
146 typedef struct _fcseq_conv_data {
150 GHashTable *fcseq_req_hash = NULL;
152 static GHashTable *fc_exchange_unmatched = NULL;
153 static GHashTable *fc_exchange_matched = NULL;
159 fcseq_equal(gconstpointer v, gconstpointer w)
161 const fcseq_conv_key_t *v1 = v;
162 const fcseq_conv_key_t *v2 = w;
164 return (v1->conv_idx == v2->conv_idx);
168 fcseq_hash (gconstpointer v)
170 const fcseq_conv_key_t *key = v;
179 fc_exchange_hash_unmatched(gconstpointer v)
181 const fc_exchange_data *fced=(const fc_exchange_data *)v;
186 fc_exchange_equal_unmatched(gconstpointer v1, gconstpointer v2)
188 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
189 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
191 /* oxid must match */
192 if(fced1->oxid!=fced2->oxid){
195 /* compare s_id, d_id and treat the fc address
196 s_id==00.00.00 as a wildcard matching anything */
197 if( ((fced1->s_id.data[0]!=0)||(fced1->s_id.data[1]!=0)||(fced1->s_id.data[2]!=0)) && CMP_ADDRESS(&fced1->s_id, &fced2->s_id) ){
200 if(CMP_ADDRESS(&fced1->d_id, &fced2->d_id)){
208 fc_exchange_hash_matched(gconstpointer v)
210 const fc_exchange_data *fced=(const fc_exchange_data *)v;
215 fc_exchange_equal_matched(gconstpointer v1, gconstpointer v2)
217 const fc_exchange_data *fced1=(const fc_exchange_data *)v1;
218 const fc_exchange_data *fced2=(const fc_exchange_data *)v2;
219 guint32 fef1, fef2, lef1, lef2;
221 /* oxid must match */
222 if(fced1->oxid!=fced2->oxid){
225 fef1=fced1->first_exchange_frame;
226 fef2=fced2->first_exchange_frame;
227 lef1=fced1->last_exchange_frame;
228 lef2=fced2->last_exchange_frame;
245 fc_exchange_init_protocol(void)
247 if(fc_exchange_unmatched){
248 g_hash_table_destroy(fc_exchange_unmatched);
249 fc_exchange_unmatched=NULL;
251 if(fc_exchange_matched){
252 g_hash_table_destroy(fc_exchange_matched);
253 fc_exchange_matched=NULL;
256 fc_exchange_unmatched=g_hash_table_new(fc_exchange_hash_unmatched, fc_exchange_equal_unmatched);
257 fc_exchange_matched=g_hash_table_new(fc_exchange_hash_matched, fc_exchange_equal_matched);
259 fragment_table_init(&fc_fragment_table);
262 g_hash_table_destroy(fcseq_req_hash);
264 fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal);
268 const value_string fc_fc4_val[] = {
269 {FC_TYPE_ELS, "Ext Link Svc"},
270 {FC_TYPE_LLCSNAP, "LLC_SNAP"},
271 {FC_TYPE_IP, "IP/FC"},
272 {FC_TYPE_SCSI, "FCP"},
273 {FC_TYPE_FCCT, "FC_CT"},
274 {FC_TYPE_SWILS, "SW_ILS"},
276 {FC_TYPE_SNMP, "SNMP"},
277 {FC_TYPE_SB_FROM_CU, "SB-3(CU->Channel)"},
278 {FC_TYPE_SB_TO_CU, "SB-3(Channel->CU)"},
282 static const value_string fc_ftype_vals [] = {
283 {FC_FTYPE_UNDEF , "Unknown frame"},
284 {FC_FTYPE_SWILS, "SW_ILS"},
285 {FC_FTYPE_IP , "IP/FC"},
286 {FC_FTYPE_SCSI , "FCP"},
287 {FC_FTYPE_BLS , "Basic Link Svc"},
288 {FC_FTYPE_ELS , "ELS"},
289 {FC_FTYPE_FCCT , "FC_CT"},
290 {FC_FTYPE_LINKDATA, "Link Data"},
291 {FC_FTYPE_VDO, "Video Data"},
292 {FC_FTYPE_LINKCTL, "Link Ctl"},
293 {FC_FTYPE_SBCCS, "SBCCS"},
294 {FC_FTYPE_OHMS, "OHMS(Cisco MDS)"},
298 static const value_string fc_wka_vals[] = {
299 {FC_WKA_MULTICAST, "Multicast Server"},
300 {FC_WKA_CLKSYNC, "Clock Sync Server"},
301 {FC_WKA_KEYDIST, "Key Distribution Server"},
302 {FC_WKA_ALIAS, "Alias Server"},
303 {FC_WKA_QOSF, "QoS Facilitator"},
304 {FC_WKA_MGMT, "Management Server"},
305 {FC_WKA_TIME, "Time Server"},
306 {FC_WKA_DNS, "Directory Server"},
307 {FC_WKA_FABRIC_CTRLR, "Fabric Ctlr"},
308 {FC_WKA_FPORT, "F_Port Server"},
309 {FC_WKA_BCAST, "Broadcast ID"},
313 static const value_string fc_routing_val[] = {
314 {FC_RCTL_DEV_DATA, "Device_Data"},
315 {FC_RCTL_ELS, "Extended Link Services"},
316 {FC_RCTL_LINK_DATA, "FC-4 Link_Data"},
317 {FC_RCTL_VIDEO, "Video_Data"},
318 {FC_RCTL_BLS, "Basic Link Services"},
319 {FC_RCTL_LINK_CTL, "Link_Control Frame"},
323 static const value_string fc_iu_val[] = {
324 {FC_IU_UNCATEGORIZED , "Uncategorized Data"},
325 {FC_IU_SOLICITED_DATA , "Solicited Data"},
326 {FC_IU_UNSOLICITED_CTL , "Unsolicited Control"},
327 {FC_IU_SOLICITED_CTL , "Solicited Control"},
328 {FC_IU_UNSOLICITED_DATA, "Solicited Data"},
329 {FC_IU_DATA_DESCRIPTOR , "Data Descriptor"},
330 {FC_IU_UNSOLICITED_CMD , "Unsolicited Command"},
331 {FC_IU_CMD_STATUS , "Command Status"},
336 static void fc_defragment_init(void)
338 fragment_table_init (&fc_fragment_table);
341 /* BA_ACC & BA_RJT are decoded in this file itself instead of a traditional
342 * dedicated file and dissector format because the dissector would require some
343 * fields of the FC_HDR such as param in some cases, type in some others, the
344 * lower 4 bits of r_ctl in some other cases etc. So, we decode BLS & Link Ctl
345 * in this file itself.
348 dissect_fc_ba_acc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
350 /* Set up structures needed to add the protocol subtree and manage it */
352 proto_tree *acc_tree;
355 /* Make entries in Protocol column and Info column on summary display */
356 if (check_col(pinfo->cinfo, COL_PROTOCOL))
357 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
359 if (check_col(pinfo->cinfo, COL_INFO))
360 col_set_str(pinfo->cinfo, COL_INFO, "BA_ACC");
363 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
364 acc_tree = proto_item_add_subtree (ti, ett_fcbls);
366 proto_tree_add_item (acc_tree, hf_fc_bls_seqid_vld, tvb, offset++, 1, FALSE);
367 proto_tree_add_item (acc_tree, hf_fc_bls_lastvld_seqid, tvb, offset++, 1, FALSE);
368 offset += 2; /* Skip reserved field */
369 proto_tree_add_item (acc_tree, hf_fc_bls_oxid, tvb, offset, 2, FALSE);
371 proto_tree_add_item (acc_tree, hf_fc_bls_rxid, tvb, offset, 2, FALSE);
373 proto_tree_add_item (acc_tree, hf_fc_bls_lowseqcnt, tvb, offset, 2, FALSE);
375 proto_tree_add_item (acc_tree, hf_fc_bls_hiseqcnt, tvb, offset, 2, FALSE);
380 dissect_fc_ba_rjt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
382 /* Set up structures needed to add the protocol subtree and manage it */
384 proto_tree *rjt_tree;
387 /* Make entries in Protocol column and Info column on summary display */
388 if (check_col(pinfo->cinfo, COL_PROTOCOL))
389 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
391 if (check_col(pinfo->cinfo, COL_INFO))
392 col_set_str(pinfo->cinfo, COL_INFO, "BA_RJT");
395 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
396 rjt_tree = proto_item_add_subtree (ti, ett_fcbls);
398 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtcode, tvb, offset+1, 1, FALSE);
399 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtdetail, tvb, offset+2, 1, FALSE);
400 proto_tree_add_item (rjt_tree, hf_fc_bls_vendor, tvb, offset+3, 1, FALSE);
405 fc_get_ftype (guint8 r_ctl, guint8 type)
407 /* A simple attempt to determine the upper level protocol based on the
408 * r_ctl & type fields.
410 switch (r_ctl & 0xF0) {
411 case FC_RCTL_DEV_DATA:
414 if ((r_ctl == 0x2) || (r_ctl == 0x3))
415 return FC_FTYPE_SWILS;
417 return FC_FTYPE_UNDEF;
421 return FC_FTYPE_SCSI;
423 return FC_FTYPE_FCCT;
424 case FC_TYPE_SB_FROM_CU:
425 case FC_TYPE_SB_TO_CU:
426 return FC_FTYPE_SBCCS;
428 return FC_FTYPE_OHMS;
430 return FC_FTYPE_UNDEF;
433 if (((r_ctl & 0x0F) == 0x2) || ((r_ctl & 0x0F) == 0x3))
435 else if (type == FC_TYPE_ELS)
436 return FC_FTYPE_OHMS;
438 return FC_FTYPE_UNDEF;
439 case FC_RCTL_LINK_DATA:
440 return FC_FTYPE_LINKDATA;
447 return FC_FTYPE_UNDEF;
448 case FC_RCTL_LINK_CTL:
449 return FC_FTYPE_LINKCTL;
451 return FC_FTYPE_UNDEF;
455 static const value_string abts_ack_vals[] = {
456 {0x000000, "ABTS - Cont"},
457 {0x000010, "ABTS - Abort"},
458 {0x000020, "ABTS - Stop"},
459 {0x000030, "ABTS - Imm Seq Retx"},
462 static const value_string abts_not_ack_vals[] = {
463 {0x000000, "ABTS - Abort/MS"},
464 {0x000010, "ABTS - Abort/SS"},
465 {0x000020, "ABTS - Process/IB"},
466 {0x000030, "ABTS - Discard/MS/Imm Retx"},
469 static const value_string last_data_frame_vals[] = {
470 {0x000000, "Last Data Frame - No Info"},
471 {0x004000, "Last Data Frame - Seq Imm"},
472 {0x008000, "Last Data Frame - Seq Soon"},
473 {0x00c000, "Last Data Frame - Seq Delyd"},
476 static const value_string ack_0_1_vals[] = {
477 {0x003000, "ACK_0 Required"},
478 {0x002000, "ACK_0 Required"},
479 {0x001000, "ACK_1 Required"},
480 {0x000000, "no ack required"},
483 static const true_false_string tfs_fc_fctl_exchange_responder = {
484 "Exchange Responder",
485 "Exchange Originator"
487 static const true_false_string tfs_fc_fctl_seq_recipient = {
491 static const true_false_string tfs_fc_fctl_exchange_first = {
495 static const true_false_string tfs_fc_fctl_exchange_last = {
499 static const true_false_string tfs_fc_fctl_seq_last = {
503 static const true_false_string tfs_fc_fctl_priority = {
507 static const true_false_string tfs_fc_fctl_transfer_seq_initiative = {
508 "Transfer Seq Initiative",
509 "NOT transfer seq initiative"
511 static const true_false_string tfs_fc_fctl_rexmitted_seq = {
512 "Retransmitted Sequence",
513 "NOT retransmitted sequence"
515 static const true_false_string tfs_fc_fctl_rel_offset = {
523 /* code to dissect the F_CTL bitmask */
525 dissect_fc_fctl(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset)
527 proto_item *item=NULL;
528 proto_tree *tree=NULL;
531 flags = tvb_get_guint8 (tvb, offset);
532 flags = (flags<<8) | tvb_get_guint8 (tvb, offset+1);
533 flags = (flags<<8) | tvb_get_guint8 (tvb, offset+2);
536 item=proto_tree_add_uint(parent_tree, hf_fc_fctl, tvb, offset, 3, flags);
537 tree=proto_item_add_subtree(item, ett_fctl);
540 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_responder, tvb, offset, 3, flags);
541 if (flags&FC_FCTL_EXCHANGE_RESPONDER){
542 proto_item_append_text(item, " Exchange Responder");
543 if (flags & (~( FC_FCTL_EXCHANGE_RESPONDER )))
544 proto_item_append_text(item, ",");
546 proto_item_append_text(item, " Exchange Originator");
547 if (flags & (~( FC_FCTL_EXCHANGE_RESPONDER )))
548 proto_item_append_text(item, ",");
550 flags&=(~( FC_FCTL_EXCHANGE_RESPONDER ));
552 proto_tree_add_boolean(tree, hf_fc_fctl_seq_recipient, tvb, offset, 3, flags);
553 if (flags&FC_FCTL_SEQ_RECIPIENT){
554 proto_item_append_text(item, " Seq Recipient");
555 if (flags & (~( FC_FCTL_SEQ_RECIPIENT )))
556 proto_item_append_text(item, ",");
558 proto_item_append_text(item, " Seq Initiator");
559 if (flags & (~( FC_FCTL_SEQ_RECIPIENT )))
560 proto_item_append_text(item, ",");
562 flags&=(~( FC_FCTL_SEQ_RECIPIENT ));
564 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_first, tvb, offset, 3, flags);
565 if (flags&FC_FCTL_EXCHANGE_FIRST){
566 proto_item_append_text(item, " Exchg First");
567 if (flags & (~( FC_FCTL_EXCHANGE_FIRST )))
568 proto_item_append_text(item, ",");
570 flags&=(~( FC_FCTL_EXCHANGE_FIRST ));
572 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_last, tvb, offset, 3, flags);
573 if (flags&FC_FCTL_EXCHANGE_LAST){
574 proto_item_append_text(item, " Exchg Last");
575 if (flags & (~( FC_FCTL_EXCHANGE_LAST )))
576 proto_item_append_text(item, ",");
578 flags&=(~( FC_FCTL_EXCHANGE_LAST ));
580 proto_tree_add_boolean(tree, hf_fc_fctl_seq_last, tvb, offset, 3, flags);
581 if (flags&FC_FCTL_SEQ_LAST){
582 proto_item_append_text(item, " Seq Last");
583 if (flags & (~( FC_FCTL_SEQ_LAST )))
584 proto_item_append_text(item, ",");
586 flags&=(~( FC_FCTL_SEQ_LAST ));
588 proto_tree_add_boolean(tree, hf_fc_fctl_priority, tvb, offset, 3, flags);
589 if (flags&FC_FCTL_PRIORITY){
590 proto_item_append_text(item, " Priority");
591 if (flags & (~( FC_FCTL_PRIORITY )))
592 proto_item_append_text(item, ",");
594 proto_item_append_text(item, " CS_CTL");
595 if (flags & (~( FC_FCTL_PRIORITY )))
596 proto_item_append_text(item, ",");
598 flags&=(~( FC_FCTL_PRIORITY ));
600 proto_tree_add_boolean(tree, hf_fc_fctl_transfer_seq_initiative, tvb, offset, 3, flags);
601 if (flags&FC_FCTL_TRANSFER_SEQ_INITIATIVE){
602 proto_item_append_text(item, " Transfer Seq Initiative");
603 if (flags & (~( FC_FCTL_TRANSFER_SEQ_INITIATIVE )))
604 proto_item_append_text(item, ",");
606 flags&=(~( FC_FCTL_TRANSFER_SEQ_INITIATIVE ));
608 proto_tree_add_uint(tree, hf_fc_fctl_last_data_frame, tvb, offset, 3, flags);
610 proto_tree_add_uint(tree, hf_fc_fctl_ack_0_1, tvb, offset, 3, flags);
612 proto_tree_add_boolean(tree, hf_fc_fctl_rexmitted_seq, tvb, offset, 3, flags);
613 if (flags&FC_FCTL_REXMITTED_SEQ){
614 proto_item_append_text(item, " Rexmitted Seq");
615 if (flags & (~( FC_FCTL_REXMITTED_SEQ )))
616 proto_item_append_text(item, ",");
618 flags&=(~( FC_FCTL_REXMITTED_SEQ ));
620 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, flags);
622 proto_tree_add_boolean(tree, hf_fc_fctl_rel_offset, tvb, offset, 3, flags);
623 if (flags&FC_FCTL_REL_OFFSET){
624 proto_item_append_text(item, " Rel Offset");
625 if (flags & (~( FC_FCTL_REL_OFFSET )))
626 proto_item_append_text(item, ",");
628 flags&=(~( FC_FCTL_REL_OFFSET ));
632 static const value_string fc_bls_proto_val[] = {
633 {FC_BLS_NOP , "NOP"},
634 {FC_BLS_ABTS , "ABTS"},
635 {FC_BLS_RMC , "RMC"},
636 {FC_BLS_BAACC , "BA_ACC"},
637 {FC_BLS_BARJT , "BA_RJT"},
638 {FC_BLS_PRMT , "PRMT"},
642 static const value_string fc_els_proto_val[] = {
643 {0x01 , "Solicited Data"},
649 /* Code to actually dissect the packets */
651 dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_ifcp)
653 /* Set up structures needed to add the protocol subtree and manage it */
655 proto_tree *fc_tree = NULL;
657 int offset = 0, next_offset, eisl_offset = -1;
658 gboolean is_lastframe_inseq, is_1frame_inseq, is_valid_frame;
659 gboolean is_exchg_resp = 0;
660 fragment_data *fcfrag_head;
663 guint8 df_ctl, seq_id;
671 fc_exchange_data *fc_ex=NULL;
673 conversation_t *conversation;
674 fcseq_conv_data_t *cdata;
675 fcseq_conv_key_t ckey, *req_key;
679 /* Make entries in Protocol column and Info column on summary display */
680 if (check_col(pinfo->cinfo, COL_PROTOCOL))
681 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC");
683 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
685 /* If the R_CTL is the EISL field, skip the first 8 bytes to retrieve the
686 * real FC header. EISL is Cisco-proprietary and is not decoded.
688 if (fchdr.r_ctl == FC_RCTL_EISL) {
689 eisl_offset = offset;
691 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
694 /* Each fc endpoint pair gets its own TCP session in iFCP but
695 * the src/dst ids are undefined(==semi-random) in the FC header.
696 * This means we can no track conversations for FC over iFCP by using
697 * the FC src/dst addresses.
698 * For iFCP: Do not update the pinfo src/dst struct and let it remain
699 * being tcpip src/dst so that request/response matching in the FCP layer
700 * will use ip addresses instead and still work.
703 SET_ADDRESS (&pinfo->dst, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
704 SET_ADDRESS (&pinfo->src, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
708 SET_ADDRESS (&fchdr.d_id, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
709 SET_ADDRESS (&fchdr.s_id, pinfo->src.type, pinfo->src.len, pinfo->src.data);
711 fchdr.cs_ctl = tvb_get_guint8 (tvb, offset+4);
712 fchdr.type = tvb_get_guint8 (tvb, offset+8);
713 fchdr.fctl=tvb_get_ntoh24(tvb,offset+9);
714 fchdr.seqcnt = tvb_get_ntohs (tvb, offset+14);
715 fchdr.oxid=tvb_get_ntohs(tvb,offset+16);
716 fchdr.rxid=tvb_get_ntohs(tvb,offset+18);
717 param = tvb_get_ntohl (tvb, offset+20);
718 seq_id = tvb_get_guint8 (tvb, offset+12);
720 pinfo->oxid = fchdr.oxid;
721 pinfo->rxid = fchdr.rxid;
722 pinfo->ptype = PT_EXCHG;
723 pinfo->r_ctl = fchdr.r_ctl;
725 is_ack = ((fchdr.r_ctl == 0xC0) || (fchdr.r_ctl == 0xC1));
727 /* There are two ways to determine if this is the first frame of a
729 * (i) The SOF bits indicate that this is the first frame OR
730 * (ii) This is an SOFf frame and seqcnt is 0.
732 is_1frame_inseq = (((pinfo->sof_eof & PINFO_SOF_FIRST_FRAME) == PINFO_SOF_FIRST_FRAME) ||
733 (((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) &&
734 (fchdr.seqcnt == 0)));
736 is_lastframe_inseq = ((pinfo->sof_eof & PINFO_EOF_LAST_FRAME) == PINFO_EOF_LAST_FRAME);
738 is_lastframe_inseq |= fchdr.fctl & FC_FCTL_SEQ_LAST;
739 is_valid_frame = ((pinfo->sof_eof & 0x40) == 0x40);
741 ftype = fc_get_ftype (fchdr.r_ctl, fchdr.type);
743 if (check_col (pinfo->cinfo, COL_INFO)) {
744 col_add_str (pinfo->cinfo, COL_INFO, val_to_str (ftype, fc_ftype_vals,
745 "Unknown Type (0x%x)"));
747 if (ftype == FC_FTYPE_LINKCTL)
748 col_append_fstr (pinfo->cinfo, COL_INFO, ", %s",
749 val_to_str ((fchdr.r_ctl & 0x0F),
754 /* In the interest of speed, if "tree" is NULL, don't do any work not
755 necessary to generate protocol tree items. */
757 ti = proto_tree_add_protocol_format (tree, proto_fc, tvb, offset,
758 FC_HEADER_SIZE, "Fibre Channel");
759 fc_tree = proto_item_add_subtree (ti, ett_fc);
762 /* Highlight EISL header, if present */
763 if (eisl_offset != -1) {
764 proto_tree_add_item (fc_tree, hf_fc_eisl, tvb, eisl_offset, 8, 0);
767 /* match first exchange with last exchange */
768 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
769 if(!pinfo->fd->flags.visited){
770 fc_exchange_data fced, *old_fced;
772 /* first check if we already have seen this exchange and it
773 is still open/unmatched.
775 fced.oxid=fchdr.oxid;
776 SET_ADDRESS(&fced.s_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
777 SET_ADDRESS(&fced.d_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
778 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
780 g_hash_table_remove(fc_exchange_unmatched, old_fced);
782 old_fced=se_alloc(sizeof(fc_exchange_data));
783 old_fced->oxid=fchdr.oxid;
784 COPY_ADDRESS(&old_fced->s_id, &fchdr.s_id);
785 COPY_ADDRESS(&old_fced->d_id, &fchdr.d_id);
786 old_fced->first_exchange_frame=pinfo->fd->num;
787 old_fced->fc_time = pinfo->fd->abs_ts;
788 g_hash_table_insert(fc_exchange_unmatched, old_fced, old_fced);
791 fc_exchange_data fced, *old_fced;
792 fced.oxid=fchdr.oxid;
793 fced.first_exchange_frame=pinfo->fd->num;
794 fced.last_exchange_frame=0;
795 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
799 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
800 if(!pinfo->fd->flags.visited){
801 fc_exchange_data fced, *old_fced;
803 fced.oxid=fchdr.oxid;
804 SET_ADDRESS(&fced.s_id, fchdr.d_id.type, fchdr.d_id.len, fchdr.d_id.data);
805 SET_ADDRESS(&fced.d_id, fchdr.s_id.type, fchdr.s_id.len, fchdr.s_id.data);
806 old_fced=g_hash_table_lookup(fc_exchange_unmatched, &fced);
808 g_hash_table_remove(fc_exchange_unmatched, old_fced);
809 old_fced->last_exchange_frame=pinfo->fd->num;
810 g_hash_table_insert(fc_exchange_matched, old_fced, old_fced);
814 fc_exchange_data fced, *old_fced;
815 fced.oxid=fchdr.oxid;
816 fced.first_exchange_frame=0;
817 fced.last_exchange_frame=pinfo->fd->num;
818 old_fced=g_hash_table_lookup(fc_exchange_matched, &fced);
823 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
824 proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame);
826 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
828 proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame);
829 nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &fc_ex->fc_time);
830 proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_ts);
835 switch (fchdr.r_ctl & 0xF0) {
837 case FC_RCTL_DEV_DATA:
838 case FC_RCTL_LINK_DATA:
840 /* the lower 4 bits of R_CTL are the information category */
841 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
842 FC_RCTL_SIZE, fchdr.r_ctl,
843 "R_CTL: 0x%x(%s/%s)",
845 val_to_str ((fchdr.r_ctl & 0xF0),
846 fc_routing_val, "0x%x"),
847 val_to_str ((fchdr.r_ctl & 0x0F),
851 case FC_RCTL_LINK_CTL:
852 /* the lower 4 bits of R_CTL indicate the type of link ctl frame */
853 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
854 FC_RCTL_SIZE, fchdr.r_ctl,
855 "R_CTL: 0x%x(%s/%s)",
857 val_to_str ((fchdr.r_ctl & 0xF0),
858 fc_routing_val, "0x%x"),
859 val_to_str ((fchdr.r_ctl & 0x0F),
860 fc_lctl_proto_val, "0x%x"));
864 switch (fchdr.type) {
867 /* the lower 4 bits of R_CTL indicate the type of BLS frame */
868 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
869 FC_RCTL_SIZE, fchdr.r_ctl,
870 "R_CTL: 0x%x(%s/%s)",
872 val_to_str ((fchdr.r_ctl & 0xF0),
873 fc_routing_val, "0x%x"),
874 val_to_str ((fchdr.r_ctl & 0x0F),
875 fc_bls_proto_val, "0x%x"));
879 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
880 FC_RCTL_SIZE, fchdr.r_ctl,
881 "R_CTL: 0x%x(%s/0x%x)",
883 val_to_str ((fchdr.r_ctl & 0xF0),
884 fc_routing_val, "0x%x"),
891 switch (fchdr.type) {
894 /* the lower 4 bits of R_CTL indicate the type of ELS frame */
895 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
896 FC_RCTL_SIZE, fchdr.r_ctl,
897 "R_CTL: 0x%x(%s/%s)",
899 val_to_str ((fchdr.r_ctl & 0xF0),
900 fc_routing_val, "0x%x"),
901 val_to_str ((fchdr.r_ctl & 0x0F),
902 fc_els_proto_val, "0x%x"));
906 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
907 FC_RCTL_SIZE, fchdr.r_ctl,
908 "R_CTL: 0x%x(%s/0x%x)",
910 val_to_str ((fchdr.r_ctl & 0xF0),
911 fc_routing_val, "0x%x"),
918 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
919 FC_RCTL_SIZE, fchdr.r_ctl,
920 "R_CTL: 0x%x(%s/0x%x)",
922 val_to_str ((fchdr.r_ctl & 0xF0),
923 fc_routing_val, "0x%x"),
928 proto_tree_add_uint_hidden (fc_tree, hf_fc_ftype, tvb, offset, 1,
931 /* XXX - use "fc_wka_vals[]" on this? */
932 proto_tree_add_string (fc_tree, hf_fc_did, tvb, offset+1, 3,
933 fc_to_str (fchdr.d_id.data));
934 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+1, 3,
935 fc_to_str (fchdr.d_id.data));
937 proto_tree_add_uint (fc_tree, hf_fc_csctl, tvb, offset+4, 1, fchdr.cs_ctl);
939 /* XXX - use "fc_wka_vals[]" on this? */
940 proto_tree_add_string (fc_tree, hf_fc_sid, tvb, offset+5, 3,
941 fc_to_str (fchdr.s_id.data));
942 proto_tree_add_string_hidden (fc_tree, hf_fc_id, tvb, offset+5, 3,
943 fc_to_str (fchdr.s_id.data));
945 if (ftype == FC_FTYPE_LINKCTL) {
946 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYB) ||
947 ((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYL)) {
948 /* for F_BSY frames, the upper 4 bits of the type field specify the
949 * reason for the BSY.
951 proto_tree_add_uint_format (fc_tree, hf_fc_type, tvb,
952 offset+8, FC_TYPE_SIZE,
953 fchdr.type,"Type: 0x%x(%s)", fchdr.type,
954 fclctl_get_typestr ((guint8) (fchdr.r_ctl & 0x0F),
957 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
960 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
964 dissect_fc_fctl(pinfo, fc_tree, tvb, offset+9);
967 proto_tree_add_item (fc_tree, hf_fc_seqid, tvb, offset+12, 1, FALSE);
969 df_ctl = tvb_get_guint8(tvb, offset+13);
971 proto_tree_add_uint (fc_tree, hf_fc_dfctl, tvb, offset+13, 1, df_ctl);
972 proto_tree_add_uint (fc_tree, hf_fc_seqcnt, tvb, offset+14, 2, fchdr.seqcnt);
973 proto_tree_add_uint (fc_tree, hf_fc_oxid, tvb, offset+16, 2, fchdr.oxid);
974 proto_tree_add_uint (fc_tree, hf_fc_rxid, tvb, offset+18, 2, fchdr.rxid);
976 if (ftype == FC_FTYPE_LINKCTL) {
977 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FRJT) ||
978 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PRJT) ||
979 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PBSY)) {
980 /* In all these cases of Link Ctl frame, the parameter field
981 * encodes the detailed error message
983 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
985 "Parameter: 0x%x(%s)", param,
986 fclctl_get_paramstr ((fchdr.r_ctl & 0x0F),
989 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
991 } else if (ftype == FC_FTYPE_BLS) {
992 if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
993 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
995 "Parameter: 0x%x(%s)", param,
996 ((param & 0x0F) == 1 ? "Abort Sequence" :
999 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20,
1003 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
1006 /* Skip the Frame_Header */
1007 next_offset = offset + FC_HEADER_SIZE;
1009 /* Network_Header present? */
1010 if (df_ctl & FC_DFCTL_NH) {
1011 /* Yes - dissect it. */
1013 proto_tree_add_string (fc_tree, hf_fc_nh_da, tvb, next_offset, 8,
1014 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
1015 proto_tree_add_string (fc_tree, hf_fc_nh_sa, tvb, offset+8, 8,
1016 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
1021 /* XXX - handle Association_Header and Device_Header here */
1023 if (ftype == FC_FTYPE_LINKCTL) {
1024 /* ACK_1 frames and other LINK_CTL frames echo the last seq bit if the
1025 * packet they're ack'ing did not have it set. So, we'll incorrectly
1026 * flag them as being fragmented when they're not. This fixes the
1029 is_lastframe_inseq = TRUE;
1031 /* XXX is this right? offset 20, shouldnt it be offset 9? */
1032 is_exchg_resp = ((tvb_get_guint8 (tvb, offset+20) & 0x80) == 0x80);
1035 if (tvb_reported_length (tvb) <= FC_HEADER_SIZE)
1036 THROW(ReportedBoundsError);
1038 frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE;
1040 /* If there is an MDS header, we need to subtract the MDS trailer size
1041 * Link Ctl, BLS & OHMS are all (encap header + FC Header + encap trailer)
1042 * and are never fragmented and so we ignore the frag_size assertion for
1045 if ((pinfo->ethertype == ETHERTYPE_UNK) || (pinfo->ethertype == ETHERTYPE_FCFT)) {
1046 if ((frag_size <= MDSHDR_TRAILER_SIZE) ||
1047 ((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) &&
1048 (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS)))
1049 THROW(ReportedBoundsError);
1050 frag_size -= MDSHDR_TRAILER_SIZE;
1051 } else if (pinfo->ethertype == ETHERTYPE_BRDWALK) {
1052 if ((frag_size <= 8) ||
1053 ((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) &&
1054 (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS)))
1055 THROW(ReportedBoundsError);
1056 frag_size -= 8; /* 4 byte of FC CRC +
1057 4 bytes of error+EOF = 8 bytes */
1060 if (!is_lastframe_inseq) {
1061 /* Show this only as a fragmented FC frame */
1062 if (check_col (pinfo->cinfo, COL_INFO)) {
1063 col_append_str (pinfo->cinfo, COL_INFO, " (Fragmented)");
1067 /* If this is a fragment, attempt to check if fully reassembled frame is
1068 * present, if we're configured to reassemble.
1070 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
1071 (ftype != FC_FTYPE_OHMS) &&
1072 (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble &&
1073 tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) {
1074 /* Add this to the list of fragments */
1076 /* In certain cases such as FICON, the SEQ_CNT is streaming
1077 * i.e. continuously increasing. So, zero does not signify the
1078 * first frame of the sequence. To fix this, we need to save the
1079 * SEQ_CNT of the first frame in sequence and use this value to
1080 * determine the actual offset into a frame.
1082 conversation = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
1083 pinfo->ptype, pinfo->oxid,
1084 pinfo->rxid, NO_PORT2);
1085 if (!conversation) {
1086 conversation = conversation_new (pinfo->fd->num, &pinfo->src, &pinfo->dst,
1087 pinfo->ptype, pinfo->oxid,
1088 pinfo->rxid, NO_PORT2);
1091 ckey.conv_idx = conversation->index;
1093 cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash,
1096 if (is_1frame_inseq) {
1098 /* Since we never free the memory used by an exchange, this maybe a
1099 * case of another request using the same exchange as a previous
1102 cdata->seq_cnt = fchdr.seqcnt;
1105 req_key = se_alloc (sizeof(fcseq_conv_key_t));
1106 req_key->conv_idx = conversation->index;
1108 cdata = se_alloc (sizeof(fcseq_conv_data_t));
1109 cdata->seq_cnt = fchdr.seqcnt;
1111 g_hash_table_insert (fcseq_req_hash, req_key, cdata);
1115 else if (cdata != NULL) {
1116 real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ;
1119 real_seqcnt = fchdr.seqcnt;
1122 /* Verify that this is a valid fragment */
1123 if (is_lastframe_inseq && !is_1frame_inseq && !real_seqcnt) {
1124 /* This is a frame that purports to be the last frame in a
1125 * sequence, is not the first frame, but has a seqcnt that is
1126 * 0. This is a bogus frame, don't attempt to reassemble it.
1128 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1129 if (check_col (pinfo->cinfo, COL_INFO)) {
1130 col_append_str (pinfo->cinfo, COL_INFO, " (Bogus Fragment)");
1134 frag_id = ((pinfo->oxid << 16) ^ seq_id) | is_exchg_resp ;
1136 /* We assume that all frames are of the same max size */
1137 fcfrag_head = fragment_add (tvb, FC_HEADER_SIZE, pinfo, frag_id,
1139 real_seqcnt * fc_max_frame_size,
1141 !is_lastframe_inseq);
1144 next_tvb = tvb_new_real_data (fcfrag_head->data,
1145 fcfrag_head->datalen,
1146 fcfrag_head->datalen);
1147 tvb_set_child_real_data_tvbuff(tvb, next_tvb);
1149 /* Add the defragmented data to the data source list. */
1150 add_new_data_source(pinfo, next_tvb, "Reassembled FC");
1153 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1154 tvb, offset+9, 1, 1);
1159 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1160 tvb, offset+9, 1, 0);
1162 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1163 call_dissector (data_handle, next_tvb, pinfo, tree);
1169 proto_tree_add_boolean_hidden (fc_tree, hf_fc_reassembled,
1170 tvb, offset+9, 1, 0);
1172 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1175 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS)) {
1176 /* If relative offset is used, only dissect the pdu with
1177 * offset 0 (param) */
1178 if( (fchdr.fctl&FC_FCTL_REL_OFFSET) && param ){
1179 call_dissector (data_handle, next_tvb, pinfo, tree);
1181 if (!dissector_try_port (fcftype_dissector_table, ftype,
1182 next_tvb, pinfo, tree)) {
1183 call_dissector (data_handle, next_tvb, pinfo, tree);
1186 } else if (ftype == FC_FTYPE_BLS) {
1187 if ((fchdr.r_ctl & 0x0F) == FC_BLS_BAACC) {
1188 dissect_fc_ba_acc (next_tvb, pinfo, tree);
1189 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_BARJT) {
1190 dissect_fc_ba_rjt (next_tvb, pinfo, tree);
1194 tap_queue_packet(fc_tap, pinfo, &fchdr);
1198 dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1200 dissect_fc_helper (tvb, pinfo, tree, FALSE);
1203 dissect_fc_ifcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1205 dissect_fc_helper (tvb, pinfo, tree, TRUE);
1208 /* Register the protocol with Ethereal */
1210 /* this format is require because a script is used to build the C function
1211 that calls all the protocol registration.
1215 proto_register_fc(void)
1218 /* Setup list of header fields See Section 1.6.1 for details*/
1219 static hf_register_info hf[] = {
1221 { "R_CTL", "fc.r_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1224 {"Frame type", "fc.ftype", FT_UINT8, BASE_HEX, VALS(fc_ftype_vals),
1225 0x0, "Derived Type", HFILL}},
1227 { "Dest Addr", "fc.d_id", FT_STRING, BASE_HEX, NULL, 0x0,
1228 "Destination Address", HFILL}},
1230 {"CS_CTL", "fc.cs_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1233 {"Src Addr", "fc.s_id", FT_STRING, BASE_HEX, NULL, 0x0,
1234 "Source Address", HFILL}},
1236 {"Addr", "fc.id", FT_STRING, BASE_HEX, NULL, 0x0,
1237 "Source or Destination Address", HFILL}},
1239 {"Type", "fc.type", FT_UINT8, BASE_HEX, VALS (fc_fc4_val), 0x0,
1242 {"F_CTL", "fc.f_ctl", FT_UINT24, BASE_HEX, NULL, 0x0, "", HFILL}},
1244 {"SEQ_ID", "fc.seq_id", FT_UINT8, BASE_HEX, NULL, 0x0,
1245 "Sequence ID", HFILL}},
1247 {"DF_CTL", "fc.df_ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}},
1249 {"SEQ_CNT", "fc.seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0,
1250 "Sequence Count", HFILL}},
1252 {"OX_ID", "fc.ox_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Originator ID",
1255 {"RX_ID", "fc.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Receiver ID",
1258 {"Parameter", "fc.parameter", FT_UINT32, BASE_HEX, NULL, 0x0, "Parameter",
1261 { &hf_fc_reassembled,
1262 {"Reassembled Frame", "fc.reassembled", FT_BOOLEAN, BASE_HEX, NULL,
1265 {"Network DA", "fc.nethdr.da", FT_STRING, BASE_HEX, NULL,
1268 {"Network SA", "fc.nethdr.sa", FT_STRING, BASE_HEX, NULL,
1271 /* Basic Link Svc field definitions */
1272 { &hf_fc_bls_seqid_vld,
1273 {"SEQID Valid", "fc.bls_seqidvld", FT_UINT8, BASE_HEX,
1274 VALS (fc_bls_seqid_val), 0x0, "", HFILL}},
1275 { &hf_fc_bls_lastvld_seqid,
1276 {"Last Valid SEQID", "fc.bls_lastseqid", FT_UINT8, BASE_HEX, NULL,
1279 {"OXID", "fc.bls_oxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1281 {"RXID", "fc.bls_rxid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}},
1282 { &hf_fc_bls_lowseqcnt,
1283 {"Low SEQCNT", "fc.bls_lseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1285 { &hf_fc_bls_hiseqcnt,
1286 {"High SEQCNT", "fc.bls_hseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, "",
1288 { &hf_fc_bls_rjtcode,
1289 {"Reason", "fc.bls_reason", FT_UINT8, BASE_HEX, VALS(fc_bls_barjt_val),
1291 { &hf_fc_bls_rjtdetail,
1292 {"Reason Explanantion", "fc.bls_rjtdetail", FT_UINT8, BASE_HEX,
1293 VALS (fc_bls_barjt_det_val), 0x0, "", HFILL}},
1294 { &hf_fc_bls_vendor,
1295 {"Vendor Unique Reason", "fc.bls_vnduniq", FT_UINT8, BASE_HEX, NULL,
1297 { &hf_fc_fctl_exchange_responder,
1298 {"ExgRpd", "fc.fctl.exchange_responder", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_responder),
1299 FC_FCTL_EXCHANGE_RESPONDER, "Exchange Responder?", HFILL}},
1300 { &hf_fc_fctl_seq_recipient,
1301 {"SeqRec", "fc.fctl.seq_recipient", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_recipient),
1302 FC_FCTL_SEQ_RECIPIENT, "Seq Recipient?", HFILL}},
1303 { &hf_fc_fctl_exchange_first,
1304 {"ExgFst", "fc.fctl.exchange_first", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_first),
1305 FC_FCTL_EXCHANGE_FIRST, "First Exchange?", HFILL}},
1306 { &hf_fc_fctl_exchange_last,
1307 {"ExgLst", "fc.fctl.exchange_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_last),
1308 FC_FCTL_EXCHANGE_LAST, "Last Exchange?", HFILL}},
1309 { &hf_fc_fctl_seq_last,
1310 {"SeqLst", "fc.fctl.seq_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_last),
1311 FC_FCTL_SEQ_LAST, "Last Sequence?", HFILL}},
1312 { &hf_fc_fctl_priority,
1313 {"Pri", "fc.fctl.priority", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_priority),
1314 FC_FCTL_PRIORITY, "Priority", HFILL}},
1315 { &hf_fc_fctl_transfer_seq_initiative,
1316 {"TSI", "fc.fctl.transfer_seq_initiative", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_transfer_seq_initiative),
1317 FC_FCTL_TRANSFER_SEQ_INITIATIVE, "Transfer Seq Initiative", HFILL}},
1318 { &hf_fc_fctl_rexmitted_seq,
1319 {"RetSeq", "fc.fctl.rexmitted_seq", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rexmitted_seq),
1320 FC_FCTL_REXMITTED_SEQ, "Retransmitted Sequence", HFILL}},
1321 { &hf_fc_fctl_rel_offset,
1322 {"RelOff", "fc.fctl.rel_offset", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rel_offset),
1323 FC_FCTL_REL_OFFSET, "rel offset", HFILL}},
1324 { &hf_fc_fctl_last_data_frame,
1325 {"LDF", "fc.fctl.last_data_frame", FT_UINT24, BASE_HEX, VALS(last_data_frame_vals),
1326 FC_FCTL_LAST_DATA_FRAME_MASK, "Last Data Frame?", HFILL}},
1327 { &hf_fc_fctl_ack_0_1,
1328 {"A01", "fc.fctl.ack_0_1", FT_UINT24, BASE_HEX, VALS(ack_0_1_vals),
1329 FC_FCTL_ACK_0_1_MASK, "Ack 0/1 value", HFILL}},
1330 { &hf_fc_fctl_abts_ack,
1331 {"AA", "fc.fctl.abts_ack", FT_UINT24, BASE_HEX, VALS(abts_ack_vals),
1332 FC_FCTL_ABTS_MASK, "ABTS ACK values", HFILL}},
1333 { &hf_fc_fctl_abts_not_ack,
1334 {"AnA", "fc.fctl.abts_not_ack", FT_UINT24, BASE_HEX, VALS(abts_not_ack_vals),
1335 FC_FCTL_ABTS_MASK, "ABTS not ACK vals", HFILL}},
1336 { &hf_fc_exchange_first_frame,
1337 { "Exchange First In", "fc.exchange_first_frame", FT_FRAMENUM, BASE_NONE, NULL,
1338 0, "The first frame of this exchange is in this frame", HFILL }},
1339 { &hf_fc_exchange_last_frame,
1340 { "Exchange Last In", "fc.exchange_last_frame", FT_FRAMENUM, BASE_NONE, NULL,
1341 0, "The last frame of this exchange is in this frame", HFILL }},
1343 { "Time from Exchange First", "fc.time", FT_RELATIVE_TIME, BASE_NONE, NULL,
1344 0, "Time since the first frame of the Exchange", HFILL }},
1346 {"EISL Header", "fc.eisl", FT_BYTES, BASE_HEX, NULL, 0, "EISL Header", HFILL}},
1349 /* Setup protocol subtree array */
1350 static gint *ett[] = {
1356 module_t *fc_module;
1358 /* Register the protocol name and description */
1359 proto_fc = proto_register_protocol ("Fibre Channel", "FC", "fc");
1360 register_dissector ("fc", dissect_fc, proto_fc);
1361 register_dissector ("fc_ifcp", dissect_fc_ifcp, proto_fc);
1362 fc_tap = register_tap("fc");
1364 /* Required function calls to register the header fields and subtrees used */
1365 proto_register_field_array(proto_fc, hf, array_length(hf));
1366 proto_register_subtree_array(ett, array_length(ett));
1368 fcftype_dissector_table = register_dissector_table ("fc.ftype",
1370 FT_UINT8, BASE_HEX);
1372 /* Register preferences */
1373 fc_module = prefs_register_protocol (proto_fc, NULL);
1374 prefs_register_bool_preference (fc_module,
1376 "Reassemble multi-frame sequences",
1377 "If enabled, reassembly of multi-frame "
1378 "sequences is done",
1380 prefs_register_uint_preference (fc_module,
1381 "max_frame_size", "Max FC Frame Size",
1382 "This is the size of non-last frames in a "
1383 "multi-frame sequence", 10,
1384 &fc_max_frame_size);
1386 register_init_routine(fc_defragment_init);
1387 register_init_routine (fc_exchange_init_protocol);
1391 /* If this dissector uses sub-dissector registration add a registration routine.
1392 This format is required because a script is used to find these routines and
1393 create the code that calls these routines.
1396 proto_reg_handoff_fc (void)
1398 data_handle = find_dissector("data");