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 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
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-scsi.h"
53 #include "packet-fc.h"
54 #include "packet-fclctl.h"
55 #include "packet-fcbls.h"
57 #include <epan/emem.h>
59 #define FC_HEADER_SIZE 24
60 #define FC_RCTL_VFT 0x50
61 #define MDSHDR_TRAILER_SIZE 6
63 /* Size of various fields in FC header in bytes */
64 #define FC_RCTL_SIZE 1
66 #define FC_CSCTL_SIZE 1
68 #define FC_TYPE_SIZE 1
69 #define FC_FCTL_SIZE 3
70 #define FC_SEQID_SIZE 1
71 #define FC_DFCTL_SIZE 1
72 #define FC_SEQCNT_SIZE 2
73 #define FC_OXID_SIZE 2
74 #define FC_RXID_SIZE 2
75 #define FC_PARAM_SIZE 4
77 /* Initialize the protocol and registered fields */
78 static int proto_fc = -1;
79 static int hf_fc_time = -1;
80 static int hf_fc_exchange_first_frame = -1;
81 static int hf_fc_exchange_last_frame = -1;
82 static int hf_fc_rctl = -1;
83 static int hf_fc_did = -1;
84 static int hf_fc_csctl = -1;
85 static int hf_fc_sid = -1;
86 static int hf_fc_id = -1;
87 static int hf_fc_type = -1;
88 static int hf_fc_fctl = -1;
89 static int hf_fc_fctl_exchange_responder = -1;
90 static int hf_fc_fctl_seq_recipient = -1;
91 static int hf_fc_fctl_exchange_first = -1;
92 static int hf_fc_fctl_exchange_last = -1;
93 static int hf_fc_fctl_seq_last = -1;
94 static int hf_fc_fctl_priority = -1;
95 static int hf_fc_fctl_transfer_seq_initiative = -1;
96 static int hf_fc_fctl_rexmitted_seq = -1;
97 static int hf_fc_fctl_rel_offset = -1;
98 static int hf_fc_fctl_abts_ack = -1;
99 static int hf_fc_fctl_abts_not_ack = -1;
100 static int hf_fc_fctl_last_data_frame = -1;
101 static int hf_fc_fctl_ack_0_1 = -1;
102 static int hf_fc_seqid = -1;
103 static int hf_fc_dfctl = -1;
104 static int hf_fc_seqcnt = -1;
105 static int hf_fc_oxid = -1;
106 static int hf_fc_rxid = -1;
107 static int hf_fc_param = -1;
108 static int hf_fc_ftype = -1; /* Derived field, non-existent in FC hdr */
109 static int hf_fc_reassembled = -1;
110 static int hf_fc_relative_offset = -1;
113 static int hf_fc_vft = -1;
114 static int hf_fc_vft_rctl = -1;
115 static int hf_fc_vft_ver = -1;
116 static int hf_fc_vft_type = -1;
117 static int hf_fc_vft_pri = -1;
118 static int hf_fc_vft_vf_id = -1;
119 static int hf_fc_vft_hop_ct = -1;
121 /* Network_Header fields */
122 static int hf_fc_nh_da = -1;
123 static int hf_fc_nh_sa = -1;
125 /* For Basic Link Svc */
126 static int hf_fc_bls_seqid_vld = -1;
127 static int hf_fc_bls_lastvld_seqid = -1;
128 static int hf_fc_bls_oxid = -1;
129 static int hf_fc_bls_rxid = -1;
130 static int hf_fc_bls_lowseqcnt = -1;
131 static int hf_fc_bls_hiseqcnt = -1;
132 static int hf_fc_bls_rjtcode = -1;
133 static int hf_fc_bls_rjtdetail = -1;
134 static int hf_fc_bls_vendor = -1;
137 /* Initialize the subtree pointers */
138 static gint ett_fc = -1;
139 static gint ett_fctl = -1;
140 static gint ett_fcbls = -1;
141 static gint ett_fc_vft = -1;
143 static dissector_table_t fcftype_dissector_table;
144 static dissector_handle_t data_handle;
146 static int fc_tap = -1;
148 typedef struct _fc_conv_data_t {
149 emem_tree_t *exchanges;
153 /* Reassembly stuff */
154 static gboolean fc_reassemble = TRUE;
155 static guint32 fc_max_frame_size = 1024;
156 static GHashTable *fc_fragment_table = NULL;
158 typedef struct _fcseq_conv_key {
162 typedef struct _fcseq_conv_data {
166 GHashTable *fcseq_req_hash = NULL;
172 fcseq_equal(gconstpointer v, gconstpointer w)
174 const fcseq_conv_key_t *v1 = v;
175 const fcseq_conv_key_t *v2 = w;
177 return (v1->conv_idx == v2->conv_idx);
181 fcseq_hash (gconstpointer v)
183 const fcseq_conv_key_t *key = v;
192 fc_exchange_init_protocol(void)
194 fragment_table_init(&fc_fragment_table);
197 g_hash_table_destroy(fcseq_req_hash);
199 fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal);
203 const value_string fc_fc4_val[] = {
204 {FC_TYPE_BLS, "Basic Link Svc"},
205 {FC_TYPE_ELS, "Ext Link Svc"},
206 {FC_TYPE_LLCSNAP, "LLC_SNAP"},
207 {FC_TYPE_IP, "IP/FC"},
208 {FC_TYPE_SCSI, "FCP"},
209 {FC_TYPE_FCCT, "FC_CT"},
210 {FC_TYPE_SWILS, "SW_ILS"},
212 {FC_TYPE_SNMP, "SNMP"},
213 {FC_TYPE_SB_FROM_CU, "SB-3(CU->Channel)"},
214 {FC_TYPE_SB_TO_CU, "SB-3(Channel->CU)"},
218 static const value_string fc_ftype_vals [] = {
219 {FC_FTYPE_UNDEF , "Unknown frame"},
220 {FC_FTYPE_SWILS, "SW_ILS"},
221 {FC_FTYPE_IP , "IP/FC"},
222 {FC_FTYPE_SCSI , "FCP"},
223 {FC_FTYPE_BLS , "Basic Link Svc"},
224 {FC_FTYPE_ELS , "ELS"},
225 {FC_FTYPE_FCCT , "FC_CT"},
226 {FC_FTYPE_LINKDATA, "Link Data"},
227 {FC_FTYPE_VDO, "Video Data"},
228 {FC_FTYPE_LINKCTL, "Link Ctl"},
229 {FC_FTYPE_SBCCS, "SBCCS"},
230 {FC_FTYPE_OHMS, "OHMS(Cisco MDS)"},
234 static const value_string fc_wka_vals[] _U_ = {
235 {FC_WKA_MULTICAST, "Multicast Server"},
236 {FC_WKA_CLKSYNC, "Clock Sync Server"},
237 {FC_WKA_KEYDIST, "Key Distribution Server"},
238 {FC_WKA_ALIAS, "Alias Server"},
239 {FC_WKA_QOSF, "QoS Facilitator"},
240 {FC_WKA_MGMT, "Management Server"},
241 {FC_WKA_TIME, "Time Server"},
242 {FC_WKA_DNS, "Directory Server"},
243 {FC_WKA_FABRIC_CTRLR, "Fabric Ctlr"},
244 {FC_WKA_FPORT, "F_Port Server"},
245 {FC_WKA_BCAST, "Broadcast ID"},
249 static const value_string fc_routing_val[] = {
250 {FC_RCTL_DEV_DATA, "Device_Data"},
251 {FC_RCTL_ELS, "Extended Link Services"},
252 {FC_RCTL_LINK_DATA, "FC-4 Link_Data"},
253 {FC_RCTL_VIDEO, "Video_Data"},
254 {FC_RCTL_BLS, "Basic Link Services"},
255 {FC_RCTL_LINK_CTL, "Link_Control Frame"},
259 static const value_string fc_iu_val[] = {
260 {FC_IU_UNCATEGORIZED , "Uncategorized Data"},
261 {FC_IU_SOLICITED_DATA , "Solicited Data"},
262 {FC_IU_UNSOLICITED_CTL , "Unsolicited Control"},
263 {FC_IU_SOLICITED_CTL , "Solicited Control"},
264 {FC_IU_UNSOLICITED_DATA, "Solicited Data"},
265 {FC_IU_DATA_DESCRIPTOR , "Data Descriptor"},
266 {FC_IU_UNSOLICITED_CMD , "Unsolicited Command"},
267 {FC_IU_CMD_STATUS , "Command Status"},
272 static void fc_defragment_init(void)
274 fragment_table_init (&fc_fragment_table);
277 /* BA_ACC & BA_RJT are decoded in this file itself instead of a traditional
278 * dedicated file and dissector format because the dissector would require some
279 * fields of the FC_HDR such as param in some cases, type in some others, the
280 * lower 4 bits of r_ctl in some other cases etc. So, we decode BLS & Link Ctl
281 * in this file itself.
284 dissect_fc_ba_acc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
286 /* Set up structures needed to add the protocol subtree and manage it */
288 proto_tree *acc_tree;
291 /* Make entries in Protocol column and Info column on summary display */
292 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
294 if (check_col(pinfo->cinfo, COL_INFO))
295 col_set_str(pinfo->cinfo, COL_INFO, "BA_ACC");
298 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
299 acc_tree = proto_item_add_subtree (ti, ett_fcbls);
301 proto_tree_add_item (acc_tree, hf_fc_bls_seqid_vld, tvb, offset++, 1, FALSE);
302 proto_tree_add_item (acc_tree, hf_fc_bls_lastvld_seqid, tvb, offset++, 1, FALSE);
303 offset += 2; /* Skip reserved field */
304 proto_tree_add_item (acc_tree, hf_fc_bls_oxid, tvb, offset, 2, FALSE);
306 proto_tree_add_item (acc_tree, hf_fc_bls_rxid, tvb, offset, 2, FALSE);
308 proto_tree_add_item (acc_tree, hf_fc_bls_lowseqcnt, tvb, offset, 2, FALSE);
310 proto_tree_add_item (acc_tree, hf_fc_bls_hiseqcnt, tvb, offset, 2, FALSE);
315 dissect_fc_ba_rjt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
317 /* Set up structures needed to add the protocol subtree and manage it */
319 proto_tree *rjt_tree;
322 /* Make entries in Protocol column and Info column on summary display */
323 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
325 if (check_col(pinfo->cinfo, COL_INFO))
326 col_set_str(pinfo->cinfo, COL_INFO, "BA_RJT");
329 ti = proto_tree_add_text (tree, tvb, 0, tvb_length (tvb), "Basic Link Svc");
330 rjt_tree = proto_item_add_subtree (ti, ett_fcbls);
332 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtcode, tvb, offset+1, 1, FALSE);
333 proto_tree_add_item (rjt_tree, hf_fc_bls_rjtdetail, tvb, offset+2, 1, FALSE);
334 proto_tree_add_item (rjt_tree, hf_fc_bls_vendor, tvb, offset+3, 1, FALSE);
339 fc_get_ftype (guint8 r_ctl, guint8 type)
341 /* A simple attempt to determine the upper level protocol based on the
342 * r_ctl & type fields.
344 switch (r_ctl & 0xF0) {
345 case FC_RCTL_DEV_DATA:
348 if ((r_ctl == 0x2) || (r_ctl == 0x3))
349 return FC_FTYPE_SWILS;
351 return FC_FTYPE_UNDEF;
355 return FC_FTYPE_SCSI;
357 return FC_FTYPE_FCCT;
358 case FC_TYPE_SB_FROM_CU:
359 case FC_TYPE_SB_TO_CU:
360 return FC_FTYPE_SBCCS;
362 return FC_FTYPE_OHMS;
364 return FC_FTYPE_UNDEF;
367 if (((r_ctl & 0x0F) == 0x2) || ((r_ctl & 0x0F) == 0x3))
369 else if (type == FC_TYPE_ELS)
370 return FC_FTYPE_OHMS;
372 return FC_FTYPE_UNDEF;
373 case FC_RCTL_LINK_DATA:
374 return FC_FTYPE_LINKDATA;
381 return FC_FTYPE_UNDEF;
382 case FC_RCTL_LINK_CTL:
383 return FC_FTYPE_LINKCTL;
385 return FC_FTYPE_UNDEF;
389 static const value_string abts_ack_vals[] = {
390 {0x000000, "ABTS - Cont"},
391 {0x000010, "ABTS - Abort"},
392 {0x000020, "ABTS - Stop"},
393 {0x000030, "ABTS - Imm Seq Retx"},
396 static const value_string abts_not_ack_vals[] = {
397 {0x000000, "ABTS - Abort/MS"},
398 {0x000010, "ABTS - Abort/SS"},
399 {0x000020, "ABTS - Process/IB"},
400 {0x000030, "ABTS - Discard/MS/Imm Retx"},
403 static const value_string last_data_frame_vals[] = {
404 {0x000000, "Last Data Frame - No Info"},
405 {0x004000, "Last Data Frame - Seq Imm"},
406 {0x008000, "Last Data Frame - Seq Soon"},
407 {0x00c000, "Last Data Frame - Seq Delyd"},
410 static const value_string ack_0_1_vals[] = {
411 {0x003000, "ACK_0 Required"},
412 {0x002000, "ACK_0 Required"},
413 {0x001000, "ACK_1 Required"},
414 {0x000000, "no ack required"},
417 static const true_false_string tfs_fc_fctl_exchange_responder = {
418 "Exchange Responder",
419 "Exchange Originator"
421 static const true_false_string tfs_fc_fctl_seq_recipient = {
425 static const true_false_string tfs_fc_fctl_exchange_first = {
429 static const true_false_string tfs_fc_fctl_exchange_last = {
433 static const true_false_string tfs_fc_fctl_seq_last = {
437 static const true_false_string tfs_fc_fctl_priority = {
441 static const true_false_string tfs_fc_fctl_transfer_seq_initiative = {
442 "Transfer Seq Initiative",
443 "NOT transfer seq initiative"
445 static const true_false_string tfs_fc_fctl_rexmitted_seq = {
446 "Retransmitted Sequence",
447 "NOT retransmitted sequence"
449 static const true_false_string tfs_fc_fctl_rel_offset = {
455 * Dissect the VFT header.
458 dissect_fc_vft(proto_tree *parent_tree,
459 tvbuff_t *tvb, int offset)
461 proto_item *item = NULL;
462 proto_tree *tree = NULL;
470 rctl = tvb_get_guint8(tvb, offset);
471 type = tvb_get_guint8(tvb, offset + 1);
472 ver = (type >> 6) & 3;
473 type = (type >> 2) & 0xf;
474 vf_id = tvb_get_ntohs(tvb, offset + 2);
475 pri = (vf_id >> 13) & 7;
476 vf_id = (vf_id >> 1) & 0xfff;
477 hop_ct = tvb_get_guint8(tvb, offset + 4);
480 item = proto_tree_add_uint_format(parent_tree, hf_fc_vft, tvb, offset,
481 8, vf_id, "VFT Header: "
482 "VF_ID %d Pri %d Hop Count %d",
484 tree = proto_item_add_subtree(item, ett_fc_vft);
486 proto_tree_add_uint(tree, hf_fc_vft_rctl, tvb, offset, 1, rctl);
487 proto_tree_add_uint(tree, hf_fc_vft_ver, tvb, offset + 1, 1, ver);
488 proto_tree_add_uint(tree, hf_fc_vft_type, tvb, offset + 1, 1, type);
489 proto_tree_add_uint(tree, hf_fc_vft_pri, tvb, offset + 2, 1, pri);
490 proto_tree_add_uint(tree, hf_fc_vft_vf_id, tvb, offset + 2, 2, vf_id);
491 proto_tree_add_uint(tree, hf_fc_vft_hop_ct, tvb, offset + 4, 1, hop_ct);
494 /* code to dissect the F_CTL bitmask */
496 dissect_fc_fctl(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset)
498 proto_item *item=NULL;
499 proto_tree *tree=NULL;
502 flags = tvb_get_guint8 (tvb, offset);
503 flags = (flags<<8) | tvb_get_guint8 (tvb, offset+1);
504 flags = (flags<<8) | tvb_get_guint8 (tvb, offset+2);
507 item=proto_tree_add_uint(parent_tree, hf_fc_fctl, tvb, offset, 3, flags);
508 tree=proto_item_add_subtree(item, ett_fctl);
511 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_responder, tvb, offset, 3, flags);
512 if (flags&FC_FCTL_EXCHANGE_RESPONDER){
513 proto_item_append_text(item, " Exchange Responder");
514 if (flags & (~( FC_FCTL_EXCHANGE_RESPONDER )))
515 proto_item_append_text(item, ",");
517 proto_item_append_text(item, " Exchange Originator");
518 if (flags & (~( FC_FCTL_EXCHANGE_RESPONDER )))
519 proto_item_append_text(item, ",");
521 flags&=(~( FC_FCTL_EXCHANGE_RESPONDER ));
523 proto_tree_add_boolean(tree, hf_fc_fctl_seq_recipient, tvb, offset, 3, flags);
524 if (flags&FC_FCTL_SEQ_RECIPIENT){
525 proto_item_append_text(item, " Seq Recipient");
526 if (flags & (~( FC_FCTL_SEQ_RECIPIENT )))
527 proto_item_append_text(item, ",");
529 proto_item_append_text(item, " Seq Initiator");
530 if (flags & (~( FC_FCTL_SEQ_RECIPIENT )))
531 proto_item_append_text(item, ",");
533 flags&=(~( FC_FCTL_SEQ_RECIPIENT ));
535 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_first, tvb, offset, 3, flags);
536 if (flags&FC_FCTL_EXCHANGE_FIRST){
537 proto_item_append_text(item, " Exchg First");
538 if (flags & (~( FC_FCTL_EXCHANGE_FIRST )))
539 proto_item_append_text(item, ",");
541 flags&=(~( FC_FCTL_EXCHANGE_FIRST ));
543 proto_tree_add_boolean(tree, hf_fc_fctl_exchange_last, tvb, offset, 3, flags);
544 if (flags&FC_FCTL_EXCHANGE_LAST){
545 proto_item_append_text(item, " Exchg Last");
546 if (flags & (~( FC_FCTL_EXCHANGE_LAST )))
547 proto_item_append_text(item, ",");
549 flags&=(~( FC_FCTL_EXCHANGE_LAST ));
551 proto_tree_add_boolean(tree, hf_fc_fctl_seq_last, tvb, offset, 3, flags);
552 if (flags&FC_FCTL_SEQ_LAST){
553 proto_item_append_text(item, " Seq Last");
554 if (flags & (~( FC_FCTL_SEQ_LAST )))
555 proto_item_append_text(item, ",");
557 flags&=(~( FC_FCTL_SEQ_LAST ));
559 proto_tree_add_boolean(tree, hf_fc_fctl_priority, tvb, offset, 3, flags);
560 if (flags&FC_FCTL_PRIORITY){
561 proto_item_append_text(item, " Priority");
562 if (flags & (~( FC_FCTL_PRIORITY )))
563 proto_item_append_text(item, ",");
565 proto_item_append_text(item, " CS_CTL");
566 if (flags & (~( FC_FCTL_PRIORITY )))
567 proto_item_append_text(item, ",");
569 flags&=(~( FC_FCTL_PRIORITY ));
571 proto_tree_add_boolean(tree, hf_fc_fctl_transfer_seq_initiative, tvb, offset, 3, flags);
572 if (flags&FC_FCTL_TRANSFER_SEQ_INITIATIVE){
573 proto_item_append_text(item, " Transfer Seq Initiative");
574 if (flags & (~( FC_FCTL_TRANSFER_SEQ_INITIATIVE )))
575 proto_item_append_text(item, ",");
577 flags&=(~( FC_FCTL_TRANSFER_SEQ_INITIATIVE ));
579 proto_tree_add_uint(tree, hf_fc_fctl_last_data_frame, tvb, offset, 3, flags);
581 proto_tree_add_uint(tree, hf_fc_fctl_ack_0_1, tvb, offset, 3, flags);
583 proto_tree_add_boolean(tree, hf_fc_fctl_rexmitted_seq, tvb, offset, 3, flags);
584 if (flags&FC_FCTL_REXMITTED_SEQ){
585 proto_item_append_text(item, " Rexmitted Seq");
586 if (flags & (~( FC_FCTL_REXMITTED_SEQ )))
587 proto_item_append_text(item, ",");
589 flags&=(~( FC_FCTL_REXMITTED_SEQ ));
591 proto_tree_add_uint(tree, hf_fc_fctl_abts_ack, tvb, offset, 3, flags);
593 proto_tree_add_boolean(tree, hf_fc_fctl_rel_offset, tvb, offset, 3, flags);
594 if (flags&FC_FCTL_REL_OFFSET){
595 proto_item_append_text(item, " Rel Offset");
596 if (flags & (~( FC_FCTL_REL_OFFSET )))
597 proto_item_append_text(item, ",");
599 flags&=(~( FC_FCTL_REL_OFFSET ));
603 static const value_string fc_bls_proto_val[] = {
604 {FC_BLS_NOP , "NOP"},
605 {FC_BLS_ABTS , "ABTS"},
606 {FC_BLS_RMC , "RMC"},
607 {FC_BLS_BAACC , "BA_ACC"},
608 {FC_BLS_BARJT , "BA_RJT"},
609 {FC_BLS_PRMT , "PRMT"},
613 static const value_string fc_els_proto_val[] = {
614 {0x01 , "Solicited Data"},
620 /* Code to actually dissect the packets */
622 dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_ifcp)
624 /* Set up structures needed to add the protocol subtree and manage it */
625 proto_item *ti=NULL, *hidden_item;
626 proto_tree *fc_tree = NULL;
628 int offset = 0, next_offset;
630 gboolean is_lastframe_inseq, is_1frame_inseq, is_valid_frame;
631 gboolean is_exchg_resp = 0;
632 fragment_data *fcfrag_head;
635 guint8 df_ctl, seq_id;
644 itlq_nexus_t *fc_ex=NULL;
645 fc_conv_data_t *fc_conv_data=NULL;
647 conversation_t *conversation;
648 fcseq_conv_data_t *cdata;
649 fcseq_conv_key_t ckey, *req_key;
653 /* Make entries in Protocol column and Info column on summary display */
654 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC");
656 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
659 * If the frame contains a VFT (virtual fabric tag), decode it
660 * as a separate header before the FC frame header.
662 * This used to be called the Cisco-proprietary EISL field, but is now
663 * standardized in FC-FS-2. See section 10.2.4.
665 if (fchdr.r_ctl == FC_RCTL_VFT) {
666 pinfo->vsan = (tvb_get_ntohs(tvb, offset + 2) >> 1) & 0xfff;
669 fchdr.r_ctl = tvb_get_guint8 (tvb, offset);
672 /* Each fc endpoint pair gets its own TCP session in iFCP but
673 * the src/dst ids are undefined(==semi-random) in the FC header.
674 * This means we can no track conversations for FC over iFCP by using
675 * the FC src/dst addresses.
676 * For iFCP: Do not update the pinfo src/dst struct and let it remain
677 * being tcpip src/dst so that request/response matching in the FCP layer
678 * will use ip addresses instead and still work.
681 SET_ADDRESS (&pinfo->dst, AT_FC, 3, tvb_get_ptr(tvb,offset+1,3));
682 SET_ADDRESS (&pinfo->src, AT_FC, 3, tvb_get_ptr(tvb,offset+5,3));
686 SET_ADDRESS(&fchdr.d_id, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
687 SET_ADDRESS(&fchdr.s_id, pinfo->src.type, pinfo->src.len, pinfo->src.data);
689 fchdr.cs_ctl = tvb_get_guint8 (tvb, offset+4);
690 fchdr.type = tvb_get_guint8 (tvb, offset+8);
691 fchdr.fctl=tvb_get_ntoh24(tvb,offset+9);
692 fchdr.seqcnt = tvb_get_ntohs (tvb, offset+14);
693 fchdr.oxid=tvb_get_ntohs(tvb,offset+16);
694 fchdr.rxid=tvb_get_ntohs(tvb,offset+18);
695 fchdr.relative_offset=0;
696 param = tvb_get_ntohl (tvb, offset+20);
697 seq_id = tvb_get_guint8 (tvb, offset+12);
699 pinfo->oxid = fchdr.oxid;
700 pinfo->rxid = fchdr.rxid;
701 pinfo->ptype = PT_EXCHG;
702 pinfo->r_ctl = fchdr.r_ctl;
704 /* set up a conversation and conversation data */
705 /* TODO treat the fc address s_id==00.00.00 as a wildcard matching anything */
706 conversation=find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
707 pinfo->ptype, pinfo->srcport,
710 conversation=conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
711 pinfo->ptype, pinfo->srcport,
714 fchdr.conversation=conversation;
715 fc_conv_data=conversation_get_proto_data(conversation, proto_fc);
717 fc_conv_data=se_alloc(sizeof(fc_conv_data_t));
718 fc_conv_data->exchanges=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "FC Exchanges");
719 conversation_add_proto_data(conversation, proto_fc, fc_conv_data);
722 /* set up the exchange data */
723 /* XXX we should come up with a way to handle when the 16bit oxid wraps
724 * so that large traces will work
726 fc_ex=(itlq_nexus_t *)se_tree_lookup32(fc_conv_data->exchanges, fchdr.oxid);
728 fc_ex=se_alloc(sizeof(itlq_nexus_t));
729 fc_ex->first_exchange_frame=0;
730 fc_ex->last_exchange_frame=0;
732 fc_ex->scsi_opcode=0xffff;
734 fc_ex->data_length=0;
735 fc_ex->bidir_data_length=0;
736 fc_ex->fc_time=pinfo->fd->abs_ts;
739 fc_ex->extra_data=NULL;
740 se_tree_insert32(fc_conv_data->exchanges, fchdr.oxid, fc_ex);
742 /* populate the exchange struct */
743 if(!pinfo->fd->flags.visited){
744 if(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST){
745 fc_ex->first_exchange_frame=pinfo->fd->num;
746 fc_ex->fc_time = pinfo->fd->abs_ts;
748 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
749 fc_ex->last_exchange_frame=pinfo->fd->num;
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 /* put some nice exchange data in the tree */
763 if(!(fchdr.fctl&FC_FCTL_EXCHANGE_FIRST)){
765 it=proto_tree_add_uint(fc_tree, hf_fc_exchange_first_frame, tvb, 0, 0, fc_ex->first_exchange_frame);
766 PROTO_ITEM_SET_GENERATED(it);
767 if(fchdr.fctl&FC_FCTL_EXCHANGE_LAST){
769 nstime_delta(&delta_ts, &pinfo->fd->abs_ts, &fc_ex->fc_time);
770 it=proto_tree_add_time(ti, hf_fc_time, tvb, 0, 0, &delta_ts);
771 PROTO_ITEM_SET_GENERATED(it);
774 if(!(fchdr.fctl&FC_FCTL_EXCHANGE_LAST)){
776 it=proto_tree_add_uint(fc_tree, hf_fc_exchange_last_frame, tvb, 0, 0, fc_ex->last_exchange_frame);
777 PROTO_ITEM_SET_GENERATED(it);
782 is_ack = ((fchdr.r_ctl == 0xC0) || (fchdr.r_ctl == 0xC1));
784 /* There are two ways to determine if this is the first frame of a
786 * (i) The SOF bits indicate that this is the first frame OR
787 * (ii) This is an SOFf frame and seqcnt is 0.
789 is_1frame_inseq = (((pinfo->sof_eof & PINFO_SOF_FIRST_FRAME) == PINFO_SOF_FIRST_FRAME) ||
790 (((pinfo->sof_eof & PINFO_SOF_SOFF) == PINFO_SOF_SOFF) &&
791 (fchdr.seqcnt == 0)));
793 is_lastframe_inseq = ((pinfo->sof_eof & PINFO_EOF_LAST_FRAME) == PINFO_EOF_LAST_FRAME);
795 is_lastframe_inseq |= fchdr.fctl & FC_FCTL_SEQ_LAST;
796 is_valid_frame = ((pinfo->sof_eof & 0x40) == 0x40);
798 ftype = fc_get_ftype (fchdr.r_ctl, fchdr.type);
800 if (check_col (pinfo->cinfo, COL_INFO)) {
801 col_add_str (pinfo->cinfo, COL_INFO, val_to_str (ftype, fc_ftype_vals,
802 "Unknown Type (0x%x)"));
804 if (ftype == FC_FTYPE_LINKCTL)
805 col_append_fstr (pinfo->cinfo, COL_INFO, ", %s",
806 val_to_str ((fchdr.r_ctl & 0x0F),
811 if (vft_offset >= 0) {
812 dissect_fc_vft(fc_tree, tvb, vft_offset);
814 switch (fchdr.r_ctl & 0xF0) {
816 case FC_RCTL_DEV_DATA:
817 case FC_RCTL_LINK_DATA:
819 /* the lower 4 bits of R_CTL are the information category */
820 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
821 FC_RCTL_SIZE, fchdr.r_ctl,
822 "R_CTL: 0x%x(%s/%s)",
824 val_to_str ((fchdr.r_ctl & 0xF0),
825 fc_routing_val, "0x%x"),
826 val_to_str ((fchdr.r_ctl & 0x0F),
830 case FC_RCTL_LINK_CTL:
831 /* the lower 4 bits of R_CTL indicate the type of link ctl frame */
832 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
833 FC_RCTL_SIZE, fchdr.r_ctl,
834 "R_CTL: 0x%x(%s/%s)",
836 val_to_str ((fchdr.r_ctl & 0xF0),
837 fc_routing_val, "0x%x"),
838 val_to_str ((fchdr.r_ctl & 0x0F),
839 fc_lctl_proto_val, "0x%x"));
843 switch (fchdr.type) {
846 /* the lower 4 bits of R_CTL indicate the type of BLS frame */
847 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
848 FC_RCTL_SIZE, fchdr.r_ctl,
849 "R_CTL: 0x%x(%s/%s)",
851 val_to_str ((fchdr.r_ctl & 0xF0),
852 fc_routing_val, "0x%x"),
853 val_to_str ((fchdr.r_ctl & 0x0F),
854 fc_bls_proto_val, "0x%x"));
858 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
859 FC_RCTL_SIZE, fchdr.r_ctl,
860 "R_CTL: 0x%x(%s/0x%x)",
862 val_to_str ((fchdr.r_ctl & 0xF0),
863 fc_routing_val, "0x%x"),
870 switch (fchdr.type) {
873 /* the lower 4 bits of R_CTL indicate the type of ELS frame */
874 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
875 FC_RCTL_SIZE, fchdr.r_ctl,
876 "R_CTL: 0x%x(%s/%s)",
878 val_to_str ((fchdr.r_ctl & 0xF0),
879 fc_routing_val, "0x%x"),
880 val_to_str ((fchdr.r_ctl & 0x0F),
881 fc_els_proto_val, "0x%x"));
885 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
886 FC_RCTL_SIZE, fchdr.r_ctl,
887 "R_CTL: 0x%x(%s/0x%x)",
889 val_to_str ((fchdr.r_ctl & 0xF0),
890 fc_routing_val, "0x%x"),
897 proto_tree_add_uint_format (fc_tree, hf_fc_rctl, tvb, offset,
898 FC_RCTL_SIZE, fchdr.r_ctl,
899 "R_CTL: 0x%x(%s/0x%x)",
901 val_to_str ((fchdr.r_ctl & 0xF0),
902 fc_routing_val, "0x%x"),
907 hidden_item = proto_tree_add_uint (fc_tree, hf_fc_ftype, tvb, offset, 1,
909 PROTO_ITEM_SET_HIDDEN(hidden_item);
911 /* XXX - use "fc_wka_vals[]" on this? */
912 proto_tree_add_string (fc_tree, hf_fc_did, tvb, offset+1, 3,
913 fc_to_str (fchdr.d_id.data));
914 hidden_item = proto_tree_add_string (fc_tree, hf_fc_id, tvb, offset+1, 3,
915 fc_to_str (fchdr.d_id.data));
916 PROTO_ITEM_SET_HIDDEN(hidden_item);
918 proto_tree_add_uint (fc_tree, hf_fc_csctl, tvb, offset+4, 1, fchdr.cs_ctl);
920 /* XXX - use "fc_wka_vals[]" on this? */
921 proto_tree_add_string (fc_tree, hf_fc_sid, tvb, offset+5, 3,
922 fc_to_str (fchdr.s_id.data));
923 hidden_item = proto_tree_add_string (fc_tree, hf_fc_id, tvb, offset+5, 3,
924 fc_to_str (fchdr.s_id.data));
925 PROTO_ITEM_SET_HIDDEN(hidden_item);
927 if (ftype == FC_FTYPE_LINKCTL) {
928 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYB) ||
929 ((fchdr.r_ctl & 0x0F) == FC_LCTL_FBSYL)) {
930 /* for F_BSY frames, the upper 4 bits of the type field specify the
931 * reason for the BSY.
933 proto_tree_add_uint_format (fc_tree, hf_fc_type, tvb,
934 offset+8, FC_TYPE_SIZE,
935 fchdr.type,"Type: 0x%x(%s)", fchdr.type,
936 fclctl_get_typestr ((guint8) (fchdr.r_ctl & 0x0F),
939 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
942 proto_tree_add_item (fc_tree, hf_fc_type, tvb, offset+8, 1, FALSE);
946 dissect_fc_fctl(pinfo, fc_tree, tvb, offset+9);
947 f_ctl = tvb_get_ntoh24(tvb, offset+9);
950 proto_tree_add_item (fc_tree, hf_fc_seqid, tvb, offset+12, 1, FALSE);
952 df_ctl = tvb_get_guint8(tvb, offset+13);
954 proto_tree_add_uint (fc_tree, hf_fc_dfctl, tvb, offset+13, 1, df_ctl);
955 proto_tree_add_uint (fc_tree, hf_fc_seqcnt, tvb, offset+14, 2, fchdr.seqcnt);
956 proto_tree_add_uint (fc_tree, hf_fc_oxid, tvb, offset+16, 2, fchdr.oxid);
957 proto_tree_add_uint (fc_tree, hf_fc_rxid, tvb, offset+18, 2, fchdr.rxid);
959 if (ftype == FC_FTYPE_LINKCTL) {
960 if (((fchdr.r_ctl & 0x0F) == FC_LCTL_FRJT) ||
961 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PRJT) ||
962 ((fchdr.r_ctl & 0x0F) == FC_LCTL_PBSY)) {
963 /* In all these cases of Link Ctl frame, the parameter field
964 * encodes the detailed error message
966 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
968 "Parameter: 0x%x(%s)", param,
969 fclctl_get_paramstr ((fchdr.r_ctl & 0x0F),
972 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
974 } else if (ftype == FC_FTYPE_BLS) {
975 if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
976 proto_tree_add_uint_format (fc_tree, hf_fc_param, tvb,
978 "Parameter: 0x%x(%s)", param,
979 ((param & 0x0F) == 1 ? "Abort Sequence" :
982 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20,
985 } else if (ftype == FC_FTYPE_SCSI ) {
986 if (f_ctl&FC_FCTL_REL_OFFSET){
987 proto_tree_add_item (fc_tree, hf_fc_relative_offset, tvb, offset+20, 4, FALSE);
988 fchdr.relative_offset=tvb_get_ntohl(tvb, offset+20);
990 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
993 proto_tree_add_item (fc_tree, hf_fc_param, tvb, offset+20, 4, FALSE);
996 /* Skip the Frame_Header */
997 next_offset = offset + FC_HEADER_SIZE;
999 /* Network_Header present? */
1000 if (df_ctl & FC_DFCTL_NH) {
1001 /* Yes - dissect it. */
1003 proto_tree_add_string (fc_tree, hf_fc_nh_da, tvb, next_offset, 8,
1004 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
1005 proto_tree_add_string (fc_tree, hf_fc_nh_sa, tvb, offset+8, 8,
1006 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
1011 /* XXX - handle Association_Header and Device_Header here */
1013 if (ftype == FC_FTYPE_LINKCTL) {
1014 /* ACK_1 frames and other LINK_CTL frames echo the last seq bit if the
1015 * packet they're ack'ing did not have it set. So, we'll incorrectly
1016 * flag them as being fragmented when they're not. This fixes the
1019 is_lastframe_inseq = TRUE;
1021 is_exchg_resp = (f_ctl & FC_FCTL_EXCHANGE_RESPONDER) != 0;
1024 if (tvb_reported_length (tvb) < FC_HEADER_SIZE)
1025 THROW(ReportedBoundsError);
1027 frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE;
1029 /* If there is an MDS header, we need to subtract the MDS trailer size
1030 * Link Ctl, BLS & OHMS are all (encap header + FC Header + encap trailer)
1031 * and are never fragmented and so we ignore the frag_size assertion for
1034 if ((pinfo->ethertype == ETHERTYPE_UNK) || (pinfo->ethertype == ETHERTYPE_FCFT)) {
1035 if ((frag_size < MDSHDR_TRAILER_SIZE) ||
1036 ((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) &&
1037 (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS)))
1038 THROW(ReportedBoundsError);
1039 frag_size -= MDSHDR_TRAILER_SIZE;
1040 } else if (pinfo->ethertype == ETHERTYPE_BRDWALK) {
1041 if ((frag_size <= 8) ||
1042 ((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) &&
1043 (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS)))
1044 THROW(ReportedBoundsError);
1045 frag_size -= 8; /* 4 byte of FC CRC +
1046 4 bytes of error+EOF = 8 bytes */
1049 if (!is_lastframe_inseq) {
1050 /* Show this only as a fragmented FC frame */
1051 if (check_col (pinfo->cinfo, COL_INFO)) {
1052 col_append_str (pinfo->cinfo, COL_INFO, " (Fragmented)");
1056 /* If this is a fragment, attempt to check if fully reassembled frame is
1057 * present, if we're configured to reassemble.
1059 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
1060 (ftype != FC_FTYPE_OHMS) &&
1061 (!is_lastframe_inseq || !is_1frame_inseq) && fc_reassemble &&
1062 tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size) && tree) {
1063 /* Add this to the list of fragments */
1065 /* In certain cases such as FICON, the SEQ_CNT is streaming
1066 * i.e. continuously increasing. So, zero does not signify the
1067 * first frame of the sequence. To fix this, we need to save the
1068 * SEQ_CNT of the first frame in sequence and use this value to
1069 * determine the actual offset into a frame.
1071 ckey.conv_idx = conversation->index;
1073 cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash,
1076 if (is_1frame_inseq) {
1078 /* Since we never free the memory used by an exchange, this maybe a
1079 * case of another request using the same exchange as a previous
1082 cdata->seq_cnt = fchdr.seqcnt;
1085 req_key = se_alloc (sizeof(fcseq_conv_key_t));
1086 req_key->conv_idx = conversation->index;
1088 cdata = se_alloc (sizeof(fcseq_conv_data_t));
1089 cdata->seq_cnt = fchdr.seqcnt;
1091 g_hash_table_insert (fcseq_req_hash, req_key, cdata);
1095 else if (cdata != NULL) {
1096 real_seqcnt = fchdr.seqcnt - cdata->seq_cnt ;
1099 real_seqcnt = fchdr.seqcnt;
1102 /* Verify that this is a valid fragment */
1103 if (is_lastframe_inseq && !is_1frame_inseq && !real_seqcnt) {
1104 /* This is a frame that purports to be the last frame in a
1105 * sequence, is not the first frame, but has a seqcnt that is
1106 * 0. This is a bogus frame, don't attempt to reassemble it.
1108 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1109 if (check_col (pinfo->cinfo, COL_INFO)) {
1110 col_append_str (pinfo->cinfo, COL_INFO, " (Bogus Fragment)");
1114 frag_id = ((pinfo->oxid << 16) ^ seq_id) | is_exchg_resp ;
1116 /* We assume that all frames are of the same max size */
1117 fcfrag_head = fragment_add (tvb, FC_HEADER_SIZE, pinfo, frag_id,
1119 real_seqcnt * fc_max_frame_size,
1121 !is_lastframe_inseq);
1124 next_tvb = tvb_new_child_real_data(tvb, fcfrag_head->data,
1125 fcfrag_head->datalen,
1126 fcfrag_head->datalen);
1128 /* Add the defragmented data to the data source list. */
1129 add_new_data_source(pinfo, next_tvb, "Reassembled FC");
1132 hidden_item = proto_tree_add_boolean (fc_tree, hf_fc_reassembled,
1133 tvb, offset+9, 1, 1);
1134 PROTO_ITEM_SET_HIDDEN(hidden_item);
1139 hidden_item = proto_tree_add_boolean (fc_tree, hf_fc_reassembled,
1140 tvb, offset+9, 1, 0);
1141 PROTO_ITEM_SET_HIDDEN(hidden_item);
1143 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1144 call_dissector (data_handle, next_tvb, pinfo, tree);
1150 hidden_item = proto_tree_add_boolean (fc_tree, hf_fc_reassembled,
1151 tvb, offset+9, 1, 0);
1152 PROTO_ITEM_SET_HIDDEN(hidden_item);
1154 next_tvb = tvb_new_subset (tvb, next_offset, -1, -1);
1157 if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS)) {
1158 /* If relative offset is used, only dissect the pdu with
1159 * offset 0 (param) */
1160 if( (fchdr.fctl&FC_FCTL_REL_OFFSET) && param ){
1161 call_dissector (data_handle, next_tvb, pinfo, tree);
1163 void *saved_private_data;
1164 saved_private_data = pinfo->private_data;
1165 pinfo->private_data = &fchdr;
1166 if (!dissector_try_port (fcftype_dissector_table, ftype,
1167 next_tvb, pinfo, tree)) {
1168 call_dissector (data_handle, next_tvb, pinfo, tree);
1170 pinfo->private_data = saved_private_data;
1172 } else if (ftype == FC_FTYPE_BLS) {
1173 if ((fchdr.r_ctl & 0x0F) == FC_BLS_BAACC) {
1174 dissect_fc_ba_acc (next_tvb, pinfo, tree);
1175 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_BARJT) {
1176 dissect_fc_ba_rjt (next_tvb, pinfo, tree);
1177 } else if ((fchdr.r_ctl & 0x0F) == FC_BLS_ABTS) {
1178 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
1179 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLS");
1181 if (check_col(pinfo->cinfo, COL_INFO)) {
1182 col_set_str(pinfo->cinfo, COL_INFO, "ABTS");
1186 tap_queue_packet(fc_tap, pinfo, &fchdr);
1190 dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1192 dissect_fc_helper (tvb, pinfo, tree, FALSE);
1195 dissect_fc_ifcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1197 dissect_fc_helper (tvb, pinfo, tree, TRUE);
1200 /* Register the protocol with Wireshark */
1202 /* this format is require because a script is used to build the C function
1203 that calls all the protocol registration.
1207 proto_register_fc(void)
1210 /* Setup list of header fields See Section 1.6.1 for details*/
1211 static hf_register_info hf[] = {
1213 { "R_CTL", "fc.r_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1216 {"Frame type", "fc.ftype", FT_UINT8, BASE_HEX, VALS(fc_ftype_vals),
1217 0x0, "Derived Type", HFILL}},
1219 { "Dest Addr", "fc.d_id", FT_STRING, BASE_NONE, NULL, 0x0,
1220 "Destination Address", HFILL}},
1222 {"CS_CTL", "fc.cs_ctl", FT_UINT8, BASE_HEX, NULL, 0x0,
1225 {"Src Addr", "fc.s_id", FT_STRING, BASE_NONE, NULL, 0x0,
1226 "Source Address", HFILL}},
1228 {"Addr", "fc.id", FT_STRING, BASE_NONE, NULL, 0x0,
1229 "Source or Destination Address", HFILL}},
1231 {"Type", "fc.type", FT_UINT8, BASE_HEX, VALS (fc_fc4_val), 0x0,
1234 {"F_CTL", "fc.f_ctl", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
1236 {"SEQ_ID", "fc.seq_id", FT_UINT8, BASE_HEX, NULL, 0x0,
1237 "Sequence ID", HFILL}},
1239 {"DF_CTL", "fc.df_ctl", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
1241 {"SEQ_CNT", "fc.seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0,
1242 "Sequence Count", HFILL}},
1244 {"OX_ID", "fc.ox_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Originator ID",
1247 {"RX_ID", "fc.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Receiver ID",
1250 {"Parameter", "fc.parameter", FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
1253 { &hf_fc_reassembled,
1254 {"Reassembled Frame", "fc.reassembled", FT_BOOLEAN, BASE_NONE, NULL,
1257 {"Network DA", "fc.nethdr.da", FT_STRING, BASE_NONE, NULL,
1260 {"Network SA", "fc.nethdr.sa", FT_STRING, BASE_NONE, NULL,
1263 /* Basic Link Svc field definitions */
1264 { &hf_fc_bls_seqid_vld,
1265 {"SEQID Valid", "fc.bls_seqidvld", FT_UINT8, BASE_HEX,
1266 VALS (fc_bls_seqid_val), 0x0, NULL, HFILL}},
1267 { &hf_fc_bls_lastvld_seqid,
1268 {"Last Valid SEQID", "fc.bls_lastseqid", FT_UINT8, BASE_HEX, NULL,
1271 {"OXID", "fc.bls_oxid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
1273 {"RXID", "fc.bls_rxid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
1274 { &hf_fc_bls_lowseqcnt,
1275 {"Low SEQCNT", "fc.bls_lseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, NULL,
1277 { &hf_fc_bls_hiseqcnt,
1278 {"High SEQCNT", "fc.bls_hseqcnt", FT_UINT16, BASE_HEX, NULL, 0x0, NULL,
1280 { &hf_fc_bls_rjtcode,
1281 {"Reason", "fc.bls_reason", FT_UINT8, BASE_HEX, VALS(fc_bls_barjt_val),
1283 { &hf_fc_bls_rjtdetail,
1284 {"Reason Explanation", "fc.bls_rjtdetail", FT_UINT8, BASE_HEX,
1285 VALS (fc_bls_barjt_det_val), 0x0, NULL, HFILL}},
1286 { &hf_fc_bls_vendor,
1287 {"Vendor Unique Reason", "fc.bls_vnduniq", FT_UINT8, BASE_HEX, NULL,
1289 { &hf_fc_fctl_exchange_responder,
1290 {"ExgRpd", "fc.fctl.exchange_responder", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_responder),
1291 FC_FCTL_EXCHANGE_RESPONDER, "Exchange Responder?", HFILL}},
1292 { &hf_fc_fctl_seq_recipient,
1293 {"SeqRec", "fc.fctl.seq_recipient", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_recipient),
1294 FC_FCTL_SEQ_RECIPIENT, "Seq Recipient?", HFILL}},
1295 { &hf_fc_fctl_exchange_first,
1296 {"ExgFst", "fc.fctl.exchange_first", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_first),
1297 FC_FCTL_EXCHANGE_FIRST, "First Exchange?", HFILL}},
1298 { &hf_fc_fctl_exchange_last,
1299 {"ExgLst", "fc.fctl.exchange_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_exchange_last),
1300 FC_FCTL_EXCHANGE_LAST, "Last Exchange?", HFILL}},
1301 { &hf_fc_fctl_seq_last,
1302 {"SeqLst", "fc.fctl.seq_last", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_seq_last),
1303 FC_FCTL_SEQ_LAST, "Last Sequence?", HFILL}},
1304 { &hf_fc_fctl_priority,
1305 {"Pri", "fc.fctl.priority", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_priority),
1306 FC_FCTL_PRIORITY, "Priority", HFILL}},
1307 { &hf_fc_fctl_transfer_seq_initiative,
1308 {"TSI", "fc.fctl.transfer_seq_initiative", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_transfer_seq_initiative),
1309 FC_FCTL_TRANSFER_SEQ_INITIATIVE, "Transfer Seq Initiative", HFILL}},
1310 { &hf_fc_fctl_rexmitted_seq,
1311 {"RetSeq", "fc.fctl.rexmitted_seq", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rexmitted_seq),
1312 FC_FCTL_REXMITTED_SEQ, "Retransmitted Sequence", HFILL}},
1313 { &hf_fc_fctl_rel_offset,
1314 {"RelOff", "fc.fctl.rel_offset", FT_BOOLEAN, 24, TFS(&tfs_fc_fctl_rel_offset),
1315 FC_FCTL_REL_OFFSET, "rel offset", HFILL}},
1316 { &hf_fc_fctl_last_data_frame,
1317 {"LDF", "fc.fctl.last_data_frame", FT_UINT24, BASE_HEX, VALS(last_data_frame_vals),
1318 FC_FCTL_LAST_DATA_FRAME_MASK, "Last Data Frame?", HFILL}},
1319 { &hf_fc_fctl_ack_0_1,
1320 {"A01", "fc.fctl.ack_0_1", FT_UINT24, BASE_HEX, VALS(ack_0_1_vals),
1321 FC_FCTL_ACK_0_1_MASK, "Ack 0/1 value", HFILL}},
1322 { &hf_fc_fctl_abts_ack,
1323 {"AA", "fc.fctl.abts_ack", FT_UINT24, BASE_HEX, VALS(abts_ack_vals),
1324 FC_FCTL_ABTS_MASK, "ABTS ACK values", HFILL}},
1325 { &hf_fc_fctl_abts_not_ack,
1326 {"AnA", "fc.fctl.abts_not_ack", FT_UINT24, BASE_HEX, VALS(abts_not_ack_vals),
1327 FC_FCTL_ABTS_MASK, "ABTS not ACK vals", HFILL}},
1328 { &hf_fc_exchange_first_frame,
1329 { "Exchange First In", "fc.exchange_first_frame", FT_FRAMENUM, BASE_NONE, NULL,
1330 0, "The first frame of this exchange is in this frame", HFILL }},
1331 { &hf_fc_exchange_last_frame,
1332 { "Exchange Last In", "fc.exchange_last_frame", FT_FRAMENUM, BASE_NONE, NULL,
1333 0, "The last frame of this exchange is in this frame", HFILL }},
1335 { "Time from Exchange First", "fc.time", FT_RELATIVE_TIME, BASE_NONE, NULL,
1336 0, "Time since the first frame of the Exchange", HFILL }},
1337 { &hf_fc_relative_offset,
1338 {"Relative Offset", "fc.relative_offset", FT_UINT32, BASE_DEC, NULL,
1339 0, "Relative offset of data", HFILL}},
1341 {"VFT Header", "fc.vft", FT_UINT16, BASE_DEC, NULL,
1344 {"R_CTL", "fc.vft.rctl", FT_UINT8, BASE_HEX, NULL,
1347 {"Version", "fc.vft.ver", FT_UINT8, BASE_DEC, NULL,
1348 0, "Version of VFT header", HFILL}},
1350 {"Type", "fc.vft.type", FT_UINT8, BASE_DEC, NULL,
1351 0, "Type of tagged frame", HFILL}},
1353 {"Priority", "fc.vft.type", FT_UINT8, BASE_DEC, NULL,
1354 0, "QoS Priority", HFILL}},
1356 {"VF_ID", "fc.vft.vf_id", FT_UINT16, BASE_DEC, NULL,
1357 0, "Virtual Fabric ID", HFILL}},
1358 { &hf_fc_vft_hop_ct,
1359 {"HopCT", "fc.vft.hop_ct", FT_UINT8, BASE_DEC, NULL,
1360 0, "Hop Count", HFILL}},
1363 /* Setup protocol subtree array */
1364 static gint *ett[] = {
1371 module_t *fc_module;
1373 /* Register the protocol name and description */
1374 proto_fc = proto_register_protocol ("Fibre Channel", "FC", "fc");
1375 register_dissector ("fc", dissect_fc, proto_fc);
1376 register_dissector ("fc_ifcp", dissect_fc_ifcp, proto_fc);
1377 fc_tap = register_tap("fc");
1379 /* Required function calls to register the header fields and subtrees used */
1380 proto_register_field_array(proto_fc, hf, array_length(hf));
1381 proto_register_subtree_array(ett, array_length(ett));
1383 /* subdissectors called through this table will find the fchdr structure
1384 * through pinfo->private_data
1386 fcftype_dissector_table = register_dissector_table ("fc.ftype",
1388 FT_UINT8, BASE_HEX);
1390 /* Register preferences */
1391 fc_module = prefs_register_protocol (proto_fc, NULL);
1392 prefs_register_bool_preference (fc_module,
1394 "Reassemble multi-frame sequences",
1395 "If enabled, reassembly of multi-frame "
1396 "sequences is done",
1398 prefs_register_uint_preference (fc_module,
1399 "max_frame_size", "Max FC Frame Size",
1400 "This is the size of non-last frames in a "
1401 "multi-frame sequence", 10,
1402 &fc_max_frame_size);
1404 register_init_routine(fc_defragment_init);
1405 register_init_routine (fc_exchange_init_protocol);
1409 /* If this dissector uses sub-dissector registration add a registration routine.
1410 This format is required because a script is used to find these routines and
1411 create the code that calls these routines.
1414 proto_reg_handoff_fc (void)
1416 dissector_handle_t fc_handle;
1418 fc_handle = find_dissector("fc");
1419 dissector_add("wtap_encap", WTAP_ENCAP_FIBRE_CHANNEL_FC2, fc_handle);
1421 data_handle = find_dissector("data");