HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-fip.c
blob46fd6d29c0aa1d6bd5c5e09953a82bdc006b0352
1 /*
2 * packet-fip.c
3 * Routines for FIP dissection - FCoE Initialization Protocol
4 * Copyright (c) 2008 Cisco Systems, Inc. (jeykholt@cisco.com)
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * Based on packet-fcoe.c, Copyright 2006, Nuova Systems, (jre@nuovasystems.com)
13 * Based on packet-fcp.c, Copyright 2001, Dinesh G Dutt (ddutt@cisco.com)
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 * For FIP protocol details, see http://t11.org.
32 * This version uses preliminary details not yet standardized.
33 * Based on http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf
34 * and http://www.t11.org/ftp/t11/pub/fc/bb-5/08-545v1.pdf
37 #include "config.h"
39 #include <glib.h>
41 #include <epan/packet.h>
42 #include <epan/to_str.h>
43 #include <epan/etypes.h>
44 #include <epan/expert.h>
47 * FIP protocol information.
49 #define FIP_HEADER_LEN 10
50 #define FIP_BPW 4 /* bytes per descriptor length unit */
53 * FIP opcodes and subcodes.
55 enum fip_opcode {
56 FIP_OP_DISC = 1, /* discovery, advertisement, etc. */
57 FIP_OP_LS = 2, /* Link Service request or reply */
58 FIP_OP_CTRL = 3, /* control */
59 FIP_OP_VLAN = 4, /* VLAN request or reply */
60 FIP_OP_VN2VN = 5 /* VN_port to VN_port operation */
64 * Subcodes for FIP_OP_DISC.
66 enum fip_disc_subcode {
67 FIP_SC_SOL = 1, /* solicitation */
68 FIP_SC_ADV = 2 /* advertisement */
72 * Subcodes for FIP_OP_LS.
74 enum fip_ls_subcode {
75 FIP_SC_REQ = 1, /* request */
76 FIP_SC_REP = 2 /* reply */
79 enum fip_ctrl_subcode {
80 FIP_SC_KA = 1, /* keep-alive */
81 FIP_SC_CVL = 2 /* clear virtual link */
84 enum fip_vlan_subcode {
85 FIP_VL_REQ = 1, /* request */
86 FIP_VL_REP = 2 /* reply */
90 * Subcodes for FIP_OP_VN2VN.
91 * XXX proposal
93 enum fip_vn2vn_subcode {
94 FIP_SC_VN_PROBE_REQ = 1, /* probe request */
95 FIP_SC_VN_PROBE_REP = 2, /* probe reply */
96 FIP_SC_VN_CLAIM_NOTIFY = 3, /* claim notification */
97 FIP_SC_VN_CLAIM_REP = 4, /* claim response */
98 FIP_SC_VN_BEACON = 5 /* beacon */
101 static const value_string fip_opcodes[] = {
102 { FIP_OP_DISC, "Discovery" },
103 { FIP_OP_LS, "Link Service" },
104 { FIP_OP_CTRL, "Control" },
105 { FIP_OP_VLAN, "VLAN" },
106 { FIP_OP_VN2VN, "VN2VN" },
107 { 0, NULL }
110 static const value_string fip_disc_subcodes[] = {
111 { FIP_SC_SOL, "Solicitation" },
112 { FIP_SC_ADV, "Advertisement" },
113 { 0, NULL }
116 static const value_string fip_ls_subcodes[] = {
117 { FIP_SC_REQ, "ELS Request" },
118 { FIP_SC_REP, "ELS Response" },
119 { 0, NULL }
122 static const value_string fip_ctrl_subcodes[] = {
123 { FIP_SC_KA, "Keep-Alive" },
124 { FIP_SC_CVL, "Clear Virtual Link" },
125 { 0, NULL }
128 static const value_string fip_vlan_subcodes[] = {
129 { FIP_VL_REQ, "VLAN Request" },
130 { FIP_VL_REP, "VLAN Response" },
131 { 0, NULL }
134 static const value_string fip_vn2vn_subcodes[] = {
135 { FIP_SC_VN_PROBE_REQ, "Probe Request" },
136 { FIP_SC_VN_PROBE_REP, "Probe Reply" },
137 { FIP_SC_VN_CLAIM_NOTIFY, "Claim Notification" },
138 { FIP_SC_VN_CLAIM_REP, "Claim Response" },
139 { FIP_SC_VN_BEACON, "Beacon" },
140 { 0, NULL }
144 * Descriptor types.
146 enum fip_desc_type {
147 FIP_DT_PRI = 1, /* priority for forwarder selection */
148 FIP_DT_MAC = 2, /* MAC address */
149 FIP_DT_MAP_OUI = 3, /* FC-MAP OUI */
150 FIP_DT_NAME = 4, /* switch name or node name */
151 FIP_DT_FAB = 5, /* fabric descriptor */
152 FIP_DT_FCOE_SIZE = 6, /* max FCoE frame size */
153 FIP_DT_FLOGI = 7, /* FLOGI request or response */
154 FIP_DT_FDISC = 8, /* FDISC request or response */
155 FIP_DT_LOGO = 9, /* LOGO request or response */
156 FIP_DT_ELP = 10, /* ELP request or response */
157 FIP_DT_VN = 11, /* VN_Port Info */
158 FIP_DT_FKA = 12, /* FIP keep-alive / advert. period */
159 FIP_DT_VEND = 13, /* Vendor-specific TLV */
160 FIP_DT_VLAN = 14, /* VLAN number */
161 FIP_DT_FC4F = 15 /* FC-4 features */
164 static const value_string fip_desc_types[] = {
165 { FIP_DT_PRI, "Priority" },
166 { FIP_DT_MAC, "MAC Address" },
167 { FIP_DT_MAP_OUI, "FPMA MAP OUI" },
168 { FIP_DT_NAME, "Switch or Node Name" },
169 { FIP_DT_FAB, "Fabric Descriptor" },
170 { FIP_DT_FCOE_SIZE, "Max FCoE frame size" },
171 { FIP_DT_FLOGI, "FLOGI Encapsulation" },
172 { FIP_DT_FDISC, "FDISC Encapsulation" },
173 { FIP_DT_LOGO, "LOGO Encapsulation" },
174 { FIP_DT_ELP, "ELP Encapsulation" },
175 { FIP_DT_VN, "VN_Port Info" },
176 { FIP_DT_FKA, "FKA_ADV_Period" },
177 { FIP_DT_VEND, "Vendor_ID" },
178 { FIP_DT_VLAN, "VLAN" },
179 { FIP_DT_FC4F, "FC-4 features" },
180 { 0, NULL }
184 * flags in header fip_flags.
186 enum fip_flag {
187 FIP_FL_FPMA = 0x8000, /* supports FPMA fabric-provided MACs */
188 FIP_FL_SPMA = 0x4000, /* supports SPMA server-provided MACs */
189 FIP_FL_REC_P2P = 0x0008, /* recorded addr or point-to-point */
190 FIP_FL_AVAIL = 0x0004, /* available for FLOGI */
191 FIP_FL_SOL = 0x0002, /* this is a solicited message */
192 FIP_FL_FPORT = 0x0001 /* sent from an F port */
195 static int proto_fip = -1;
196 static int hf_fip_ver = -1;
197 static int hf_fip_op = -1;
198 static int hf_fip_disc_subcode = -1;
199 static int hf_fip_ls_subcode = -1;
200 static int hf_fip_ctrl_subcode = -1;
201 static int hf_fip_vlan_subcode = -1;
202 static int hf_fip_vn2vn_subcode = -1;
203 static int hf_fip_hex_subcode = -1;
204 static int hf_fip_dlen = -1;
205 static int hf_fip_flags = -1;
206 static int hf_fip_flag_fpma = -1;
207 static int hf_fip_flag_spma = -1;
208 static int hf_fip_flag_rec_p2p = -1;
209 static int hf_fip_flag_avail = -1;
210 static int hf_fip_flag_sol = -1;
211 static int hf_fip_flag_fport = -1;
213 static const int *hf_fip_flags_fields[] = {
214 &hf_fip_flag_fpma,
215 &hf_fip_flag_spma,
216 &hf_fip_flag_rec_p2p,
217 &hf_fip_flag_avail,
218 &hf_fip_flag_sol,
219 &hf_fip_flag_fport,
220 NULL
223 static int hf_fip_desc_type = -1;
224 static int hf_fip_desc_len = -1;
225 static int hf_fip_desc_pri = -1;
226 static int hf_fip_desc_mac = -1;
227 static int hf_fip_desc_map = -1;
228 static int hf_fip_desc_name = -1;
229 static int hf_fip_desc_fab_vfid = -1;
230 static int hf_fip_desc_fab_map = -1;
231 static int hf_fip_desc_fab_name = -1;
232 static int hf_fip_desc_fcoe_size = -1;
233 static int hf_fip_desc_vn_mac = -1;
234 static int hf_fip_desc_vn_fid = -1;
235 static int hf_fip_desc_vn_wwpn = -1;
236 static int hf_fip_desc_fka = -1;
237 static int hf_fip_desc_vend = -1;
238 static int hf_fip_desc_vend_data = -1;
239 static int hf_fip_desc_vlan = -1;
240 static int hf_fip_desc_unk = -1;
241 static int hf_fip_desc_fc4f_types = -1;
242 static int hf_fip_desc_fcp_feat = -1;
243 static int hf_fip_type_ip = -1;
244 static int hf_fip_type_fcp = -1;
245 static int hf_fip_type_gs3 = -1;
246 static int hf_fip_fcp_feat_i = -1;
247 static int hf_fip_fcp_feat_t = -1;
249 static int ett_fip = -1;
250 static int ett_fip_flags = -1;
251 static int ett_fip_dt_pri = -1;
252 static int ett_fip_dt_mac = -1;
253 static int ett_fip_dt_map = -1;
254 static int ett_fip_dt_name = -1;
255 static int ett_fip_dt_fab = -1;
256 static int ett_fip_dt_mdl = -1;
257 static int ett_fip_dt_caps = -1;
258 static int ett_fip_dt_vn = -1;
259 static int ett_fip_dt_fka = -1;
260 static int ett_fip_dt_vend = -1;
261 static int ett_fip_dt_vlan = -1;
262 static int ett_fip_dt_unk = -1;
263 static int ett_fip_dt_fc4f = -1;
264 static int ett_fip_dt_fc4f_types = -1;
265 static int ett_fip_dt_fcp_feat = -1;
267 static dissector_handle_t fc_handle;
270 * Insert common descriptor type and length fields.
272 static void
273 fip_desc_type_len(proto_tree *tree, tvbuff_t *tvb)
275 proto_tree_add_item(tree, hf_fip_desc_type, tvb, 0, 1, ENC_BIG_ENDIAN);
276 proto_tree_add_item(tree, hf_fip_desc_len, tvb, 1, 1, ENC_BIG_ENDIAN);
280 * Dissect the FC-4 type features descriptor.
282 static void
283 fip_desc_fc4f(tvbuff_t *tvb, proto_tree *tree, proto_item *item)
285 guint mask;
286 guint offset;
288 static const int *types_word0[] = { /* types 0 - 31 */
289 &hf_fip_type_ip,
290 &hf_fip_type_fcp,
291 NULL
293 static const int *types_word1[] = { /* types 32 - 63 */
294 &hf_fip_type_gs3,
295 NULL
297 static const int *fcp_feat[] = {
298 &hf_fip_fcp_feat_t,
299 &hf_fip_fcp_feat_i,
300 NULL
304 * First the 256-bit bitmask of types supported.
306 offset = 4;
307 proto_tree_add_bitmask(tree, tvb, offset, hf_fip_desc_fc4f_types,
308 ett_fip_dt_fc4f_types, types_word0, ENC_BIG_ENDIAN);
309 offset += 4;
310 proto_tree_add_bitmask(tree, tvb, offset, hf_fip_desc_fc4f_types,
311 ett_fip_dt_fc4f_types, types_word1, ENC_BIG_ENDIAN);
312 offset += 256 / 8 - 4; /* skip to end of bitmask (32 bytes) */
315 * Next the 4-bit capabilities per type.
316 * Only decode FCP (type 8) for now.
318 offset += 8 / 2; /* skip first 8 types, 2 types per byte */
319 proto_tree_add_bitmask(tree, tvb, offset, hf_fip_desc_fcp_feat,
320 ett_fip_dt_fcp_feat, fcp_feat, ENC_BIG_ENDIAN);
321 mask = tvb_get_ntohl(tvb, offset);
322 if (mask & 1) {
323 proto_item_append_text(item, "FCP Target ");
325 if (mask & 2) {
326 proto_item_append_text(item, "FCP Initiator ");
330 static void
331 dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
333 guint op;
334 guint sub;
335 guint rlen;
336 proto_item *ti;
337 proto_item *item;
338 proto_tree *fip_tree;
339 proto_tree *subtree;
340 guint dtype;
341 guint dlen;
342 guint desc_offset;
343 guint val;
344 tvbuff_t *desc_tvb;
345 const char *info;
346 const char *text;
348 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FIP");
349 col_clear(pinfo->cinfo, COL_INFO);
351 if (!tvb_bytes_exist(tvb, 0, FIP_HEADER_LEN)) {
352 col_set_str(pinfo->cinfo, COL_INFO, "[packet too short]");
353 if (tree)
354 proto_tree_add_protocol_format(tree, proto_fip, tvb, 0,
355 -1, "FIP [packet too short]");
356 return;
359 op = tvb_get_ntohs(tvb, 2);
360 sub = tvb_get_guint8(tvb, 5);
362 switch (op) {
363 case FIP_OP_DISC:
364 info = val_to_str(sub, fip_disc_subcodes, "Discovery 0x%x");
365 break;
366 case FIP_OP_LS:
367 info = val_to_str(sub, fip_ls_subcodes, "Link Service 0x%x");
368 break;
369 case FIP_OP_CTRL:
370 info = val_to_str(sub, fip_ctrl_subcodes, "Control 0x%x");
371 break;
372 case FIP_OP_VLAN:
373 info = val_to_str(sub, fip_vlan_subcodes, "VLAN 0x%x");
374 break;
375 case FIP_OP_VN2VN:
376 info = val_to_str(sub, fip_vn2vn_subcodes, "VN2VN 0x%x");
377 break;
378 default:
379 info = val_to_str(op, fip_opcodes, "Unknown op 0x%x");
380 break;
383 col_add_str(pinfo->cinfo, COL_INFO, info);
385 rlen = tvb_get_ntohs(tvb, 6);
387 ti = proto_tree_add_protocol_format(tree, proto_fip, tvb, 0,
388 FIP_HEADER_LEN + rlen * FIP_BPW,
389 "FIP %s", info);
390 fip_tree = proto_item_add_subtree(ti, ett_fip);
391 proto_tree_add_item(fip_tree, hf_fip_ver, tvb, 0, 1, ENC_BIG_ENDIAN);
392 proto_tree_add_item(fip_tree, hf_fip_op, tvb, 2, 2, ENC_BIG_ENDIAN);
393 switch (op) {
394 case FIP_OP_DISC:
395 proto_tree_add_item(fip_tree, hf_fip_disc_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
396 break;
397 case FIP_OP_LS:
398 proto_tree_add_item(fip_tree, hf_fip_ls_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
399 break;
400 case FIP_OP_CTRL:
401 proto_tree_add_item(fip_tree, hf_fip_ctrl_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
402 break;
403 case FIP_OP_VLAN:
404 proto_tree_add_item(fip_tree, hf_fip_vlan_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
405 break;
406 case FIP_OP_VN2VN:
407 proto_tree_add_item(fip_tree, hf_fip_vn2vn_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
408 break;
409 default:
410 proto_tree_add_item(fip_tree, hf_fip_hex_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
411 break;
413 proto_tree_add_item(fip_tree, hf_fip_dlen, tvb, 6, 2, ENC_BIG_ENDIAN);
415 proto_tree_add_bitmask(fip_tree, tvb, 8, hf_fip_flags,
416 ett_fip_flags, hf_fip_flags_fields, ENC_BIG_ENDIAN);
418 desc_offset = FIP_HEADER_LEN;
419 rlen *= FIP_BPW;
420 proto_tree_add_text(fip_tree, tvb, desc_offset, rlen, "Descriptors:");
422 while ((rlen > 0) && tvb_bytes_exist(tvb, desc_offset, 2)) {
423 dlen = tvb_get_guint8(tvb, desc_offset + 1) * FIP_BPW;
424 if (!dlen) {
425 proto_tree_add_text(fip_tree, tvb, desc_offset, -1,
426 "Descriptor [length error]");
427 break;
429 if (!tvb_bytes_exist(tvb, desc_offset, dlen) || dlen > rlen) {
430 break;
432 desc_tvb = tvb_new_subset(tvb, desc_offset, dlen, -1);
433 dtype = tvb_get_guint8(desc_tvb, 0);
434 desc_offset += dlen;
435 rlen -= dlen;
437 item = proto_tree_add_text(fip_tree, desc_tvb, 0, -1, "Descriptor: %s ",
438 val_to_str(dtype, fip_desc_types, "Unknown 0x%x"));
440 switch (dtype) {
441 case FIP_DT_PRI:
442 subtree = proto_item_add_subtree(item, ett_fip_dt_pri);
443 fip_desc_type_len(subtree, desc_tvb);
444 proto_tree_add_item(subtree, hf_fip_desc_pri, desc_tvb,
445 3, 1, ENC_BIG_ENDIAN);
446 proto_item_append_text(item, "%u", tvb_get_guint8(desc_tvb, 3));
447 break;
448 case FIP_DT_MAC:
449 subtree = proto_item_add_subtree(item, ett_fip_dt_mac);
450 fip_desc_type_len(subtree, desc_tvb);
451 proto_tree_add_item(subtree, hf_fip_desc_mac, desc_tvb,
452 2, 6, ENC_NA);
453 proto_item_append_text(item, "%s",
454 tvb_bytes_to_str_punct(desc_tvb, 2, 6, ':'));
455 break;
456 case FIP_DT_MAP_OUI:
457 subtree = proto_item_add_subtree(item, ett_fip_dt_map);
458 fip_desc_type_len(subtree, desc_tvb);
459 text = tvb_fc_to_str(desc_tvb, 5);
460 proto_tree_add_string(subtree, hf_fip_desc_map, desc_tvb,
461 5, 3, text);
462 proto_item_append_text(item, "%s", text);
463 break;
464 case FIP_DT_NAME:
465 subtree = proto_item_add_subtree(item, ett_fip_dt_name);
466 fip_desc_type_len(subtree, desc_tvb);
467 text = tvb_fcwwn_to_str(desc_tvb, 4);
468 proto_tree_add_string(subtree, hf_fip_desc_name,
469 desc_tvb, 4, 8, text);
470 proto_item_append_text(item, "%s", text);
471 break;
472 case FIP_DT_FAB:
473 subtree = proto_item_add_subtree(item, ett_fip_dt_fab);
474 fip_desc_type_len(subtree, desc_tvb);
475 proto_tree_add_item(subtree, hf_fip_desc_fab_vfid, desc_tvb,
476 2, 2, ENC_BIG_ENDIAN);
477 text = tvb_fc_to_str(desc_tvb, 5);
478 proto_tree_add_string(subtree, hf_fip_desc_fab_map, desc_tvb,
479 5, 3, text);
480 text = tvb_fcwwn_to_str(desc_tvb, 8);
481 proto_tree_add_string(subtree, hf_fip_desc_fab_name,
482 desc_tvb, 8, 8, text);
483 proto_item_append_text(item, "%s", text);
484 break;
485 case FIP_DT_FCOE_SIZE:
486 subtree = proto_item_add_subtree(item, ett_fip_dt_mdl);
487 fip_desc_type_len(subtree, desc_tvb);
488 proto_tree_add_item(subtree, hf_fip_desc_fcoe_size, desc_tvb,
489 2, 2, ENC_BIG_ENDIAN);
490 proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2));
491 break;
492 case FIP_DT_FLOGI:
493 case FIP_DT_FDISC:
494 case FIP_DT_LOGO:
495 case FIP_DT_ELP: {
496 tvbuff_t *ls_tvb;
497 subtree = proto_item_add_subtree(item, ett_fip_dt_caps);
498 fip_desc_type_len(subtree, desc_tvb);
499 ls_tvb = tvb_new_subset(desc_tvb, 4, dlen - 4, -1);
500 call_dissector(fc_handle, ls_tvb, pinfo, subtree);
501 proto_item_append_text(item, "%u bytes", dlen - 4);
503 break;
504 case FIP_DT_VN:
505 subtree = proto_item_add_subtree(item, ett_fip_dt_vn);
506 fip_desc_type_len(subtree, desc_tvb);
507 proto_tree_add_item(subtree, hf_fip_desc_vn_mac, desc_tvb,
508 2, 6, ENC_NA);
509 proto_tree_add_item(subtree, hf_fip_desc_vn_fid, desc_tvb,
510 9, 3, ENC_BIG_ENDIAN);
511 text = tvb_fcwwn_to_str(desc_tvb, 12);
512 proto_tree_add_string(subtree, hf_fip_desc_vn_wwpn,
513 desc_tvb, 12, 8, text);
514 proto_item_append_text(item, "MAC %s FC_ID %6.6x",
515 tvb_bytes_to_str_punct(desc_tvb, 2, 6, ':'),
516 tvb_get_ntoh24(desc_tvb, 9));
517 break;
518 case FIP_DT_FKA:
519 subtree = proto_item_add_subtree(item, ett_fip_dt_fka);
520 fip_desc_type_len(subtree, desc_tvb);
521 val = tvb_get_ntohl(desc_tvb, 4);
522 proto_tree_add_uint_format_value(subtree, hf_fip_desc_fka,
523 desc_tvb, 4, 4, val, "%u ms", val);
524 proto_item_append_text(item, "%u ms", val);
525 break;
526 case FIP_DT_VEND:
527 subtree = proto_item_add_subtree(item, ett_fip_dt_vend);
528 fip_desc_type_len(subtree, desc_tvb);
529 proto_tree_add_item(subtree, hf_fip_desc_vend, desc_tvb,
530 4, 8, ENC_NA);
531 if (tvb_bytes_exist(desc_tvb, 9, -1)) {
532 proto_tree_add_item(subtree, hf_fip_desc_vend_data,
533 desc_tvb, 9, -1, ENC_NA);
535 break;
536 case FIP_DT_VLAN:
537 subtree = proto_item_add_subtree(item, ett_fip_dt_vlan);
538 fip_desc_type_len(subtree, desc_tvb);
539 proto_tree_add_item(subtree, hf_fip_desc_vlan, desc_tvb,
540 2, 2, ENC_BIG_ENDIAN);
541 proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2));
542 break;
543 case FIP_DT_FC4F:
544 subtree = proto_item_add_subtree(item, ett_fip_dt_fc4f);
545 fip_desc_type_len(subtree, desc_tvb);
546 fip_desc_fc4f(desc_tvb, subtree, item);
547 break;
548 default:
549 subtree = proto_item_add_subtree(item, ett_fip_dt_unk);
550 fip_desc_type_len(subtree, desc_tvb);
551 proto_tree_add_item(subtree, hf_fip_desc_unk, desc_tvb,
552 2, -1, ENC_NA);
553 break;
558 void
559 proto_register_fip(void)
561 /* Setup list of header fields See Section 1.6.1 for details*/
562 static hf_register_info hf[] = {
564 * FIP header fields.
566 { &hf_fip_ver,
567 { "Version", "fip.ver",
568 FT_UINT8, BASE_DEC, NULL, 0xf0,
569 NULL, HFILL}},
572 { &hf_fip_op,
573 { "Opcode", "fip.opcode",
574 FT_UINT16, BASE_HEX, VALS(fip_opcodes), 0,
575 NULL, HFILL}},
577 { &hf_fip_disc_subcode,
578 { "Discovery Subcode", "fip.disc_subcode",
579 FT_UINT8, BASE_HEX, VALS(fip_disc_subcodes), 0,
580 NULL, HFILL}},
582 { &hf_fip_ls_subcode,
583 { "Link Service Subcode", "fip.ls.subcode",
584 FT_UINT8, BASE_HEX, VALS(fip_ls_subcodes), 0,
585 NULL, HFILL}},
587 { &hf_fip_ctrl_subcode,
588 { "Control Subcode", "fip.ctrl_subcode",
589 FT_UINT8, BASE_HEX, VALS(fip_ctrl_subcodes), 0,
590 NULL, HFILL}},
592 { &hf_fip_vlan_subcode,
593 { "VLAN Subcode", "fip.vlan_subcode",
594 FT_UINT8, BASE_HEX, VALS(fip_vlan_subcodes), 0,
595 NULL, HFILL}},
597 { &hf_fip_vn2vn_subcode,
598 { "VN2VN Subcode", "fip.vn2vn_subcode",
599 FT_UINT8, BASE_HEX, VALS(fip_vn2vn_subcodes), 0,
600 NULL, HFILL}},
602 { &hf_fip_hex_subcode,
603 { "Unknown Subcode", "fip.subcode",
604 FT_UINT8, BASE_HEX, NULL, 0,
605 NULL, HFILL}},
607 { &hf_fip_dlen,
608 { "Length of Descriptors (words)", "fip.dl_len",
609 FT_UINT16, BASE_DEC, NULL, 0,
610 NULL, HFILL}},
612 { &hf_fip_flags,
613 { "Flags", "fip.flags",
614 FT_UINT16, BASE_HEX, NULL, 0,
615 NULL, HFILL}},
617 { &hf_fip_flag_fpma,
618 { "Fabric Provided MAC addr", "fip.flags.fpma",
619 FT_BOOLEAN, 16, NULL, FIP_FL_FPMA,
620 NULL, HFILL}},
622 { &hf_fip_flag_spma,
623 { "Server Provided MAC addr", "fip.flags.spma",
624 FT_BOOLEAN, 16, NULL, FIP_FL_SPMA,
625 NULL, HFILL}},
627 { &hf_fip_flag_rec_p2p,
628 { "REC/P2P", "fip.flags.rec_p2p",
629 FT_BOOLEAN, 16, NULL, FIP_FL_REC_P2P,
630 NULL, HFILL}},
632 { &hf_fip_flag_avail,
633 { "Available", "fip.flags.available",
634 FT_BOOLEAN, 16, NULL, FIP_FL_AVAIL,
635 NULL, HFILL}},
637 { &hf_fip_flag_sol,
638 { "Solicited", "fip.flags.sol",
639 FT_BOOLEAN, 16, NULL, FIP_FL_SOL,
640 NULL, HFILL}},
642 { &hf_fip_flag_fport,
643 { "F_Port", "fip.flags.fport",
644 FT_BOOLEAN, 16, NULL, FIP_FL_FPORT,
645 NULL, HFILL}},
647 { &hf_fip_desc_type,
648 { "Descriptor Type", "fip.desc_type",
649 FT_UINT8, BASE_HEX, VALS(fip_desc_types), 0,
650 NULL, HFILL}},
652 { &hf_fip_desc_len,
653 { "Descriptor Length (words)", "fip.desc_len",
654 FT_UINT8, BASE_DEC, NULL, 0,
655 NULL, HFILL}},
658 * Various descriptor fields.
660 { &hf_fip_desc_pri,
661 { "Priority", "fip.pri",
662 FT_UINT8, BASE_DEC, NULL, 0,
663 NULL, HFILL}},
665 { &hf_fip_desc_mac,
666 { "MAC Address", "fip.mac",
667 FT_ETHER, BASE_NONE, NULL, 0,
668 NULL, HFILL}},
670 { &hf_fip_desc_map,
671 { "FC-MAP-OUI", "fip.map",
672 FT_STRING, BASE_NONE, NULL, 0,
673 NULL, HFILL}},
675 { &hf_fip_desc_name,
676 { "Switch or Node Name", "fip.name",
677 FT_STRING, BASE_NONE, NULL, 0,
678 NULL, HFILL}},
680 { &hf_fip_desc_fab_vfid,
681 { "VFID", "fip.fab.vfid",
682 FT_UINT16, BASE_DEC, NULL, 0,
683 NULL, HFILL}},
685 { &hf_fip_desc_fab_map,
686 { "FC-MAP", "fip.fab.map",
687 FT_STRING, BASE_NONE, NULL, 0,
688 NULL, HFILL}},
690 { &hf_fip_desc_fab_name,
691 { "Fabric Name", "fip.fab.name",
692 FT_STRING, BASE_NONE, NULL, 0,
693 NULL, HFILL}},
695 { &hf_fip_desc_fcoe_size,
696 { "Max FCoE frame size", "fip.fcoe_size",
697 FT_UINT16, BASE_DEC, NULL, 0,
698 NULL, HFILL}},
700 { &hf_fip_desc_vn_mac,
701 { "VN_Port MAC Address", "fip.vn.mac",
702 FT_ETHER, BASE_NONE, NULL, 0,
703 NULL, HFILL}},
705 { &hf_fip_desc_vn_fid,
706 { "VN_Port FC_ID", "fip.vn.fc_id",
707 FT_UINT32, BASE_HEX, NULL, 0,
708 NULL, HFILL}},
710 { &hf_fip_desc_vn_wwpn,
711 { "Port Name", "fip.vn.pwwn",
712 FT_STRING, BASE_NONE, NULL, 0,
713 NULL, HFILL}},
715 { &hf_fip_desc_fka,
716 { "FKA_ADV_Period", "fip.fka",
717 FT_UINT32, BASE_DEC, NULL, 0,
718 NULL, HFILL}},
720 { &hf_fip_desc_vend,
721 { "Vendor-ID", "fip.vendor",
722 FT_BYTES, BASE_NONE, NULL, 0,
723 NULL, HFILL}},
725 { &hf_fip_desc_vend_data,
726 { "Vendor-specific data", "fip.vendor.data",
727 FT_BYTES, BASE_NONE, NULL, 0,
728 NULL, HFILL}},
730 { &hf_fip_desc_vlan,
731 { "VLAN", "fip.vlan",
732 FT_UINT16, BASE_DEC, NULL, 0,
733 NULL, HFILL}},
735 { &hf_fip_desc_fc4f_types,
736 { "FC4 Types", "fip.fc4f.types",
737 FT_UINT32, BASE_HEX, NULL, 0,
738 NULL, HFILL}},
740 { &hf_fip_desc_fcp_feat,
741 { "FCP Features", "fip.fc4f.feat.fcp",
742 FT_UINT32, BASE_HEX, NULL, 0xf,
743 NULL, HFILL}},
745 { &hf_fip_type_ip,
746 { "IP", "fip.fc4f.ip",
747 FT_BOOLEAN, 32, NULL, 1 << 5,
748 NULL, HFILL}},
750 { &hf_fip_type_fcp,
751 { "FCP", "fip.fc4f.fcp",
752 FT_BOOLEAN, 32, NULL, 1 << 8,
753 NULL, HFILL}},
755 { &hf_fip_type_gs3,
756 { "GS3", "fip.fc4f.gs3",
757 FT_BOOLEAN, 32, NULL, 1 << 0,
758 NULL, HFILL}},
760 { &hf_fip_fcp_feat_t,
761 { "FCP Target", "fip.fc4f.feat.fcp.target",
762 FT_BOOLEAN, 32, NULL, 1,
763 NULL, HFILL}},
765 { &hf_fip_fcp_feat_i,
766 { "FCP Initiator", "fip.fc4f.feat.fcp.initiator",
767 FT_BOOLEAN, 32, NULL, 2,
768 NULL, HFILL}},
770 { &hf_fip_desc_unk,
771 { "Unknown Descriptor", "fip.desc",
772 FT_BYTES, BASE_NONE, NULL, 0,
773 NULL, HFILL}}
776 static gint *ett[] = {
777 &ett_fip,
778 &ett_fip_flags,
779 &ett_fip_dt_pri,
780 &ett_fip_dt_mac,
781 &ett_fip_dt_map,
782 &ett_fip_dt_name,
783 &ett_fip_dt_fab,
784 &ett_fip_dt_mdl,
785 &ett_fip_dt_caps,
786 &ett_fip_dt_vn,
787 &ett_fip_dt_fka,
788 &ett_fip_dt_vend,
789 &ett_fip_dt_vlan,
790 &ett_fip_dt_fc4f,
791 &ett_fip_dt_fc4f_types,
792 &ett_fip_dt_fcp_feat,
793 &ett_fip_dt_unk
796 /* Register the protocol name and description */
797 proto_fip = proto_register_protocol("FCoE Initialization Protocol",
798 "FIP", "fip");
800 /* Required function calls to register the header fields and
801 * subtrees used */
802 proto_register_field_array(proto_fip, hf, array_length(hf));
803 proto_register_subtree_array(ett, array_length(ett));
807 * This function name is required because a script is used to find these
808 * routines and create the code that calls these routines.
810 void
811 proto_reg_handoff_fip(void)
813 dissector_handle_t fip_handle;
815 fip_handle = create_dissector_handle(dissect_fip, proto_fip);
816 dissector_add_uint("ethertype", ETHERTYPE_FIP, fip_handle);
817 fc_handle = find_dissector("fc");