Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-fip.c
blob4b79d552a1a4b0fa95f28650ba1623e75370e677
1 /*
2 * packet-fip.c
3 * Routines for FIP dissection - FCoE Initialization Protocol
4 * Copyright (c) 2008 Cisco Systems, Inc. (jeykholt@cisco.com)
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * Based on packet-fcoe.c, Copyright 2006, Nuova Systems, (jre@nuovasystems.com)
11 * Based on packet-fcp.c, Copyright 2001, Dinesh G Dutt (ddutt@cisco.com)
13 * SPDX-License-Identifier: GPL-2.0-or-later
17 * For FIP protocol details, see http://t11.org.
18 * This version uses preliminary details not yet standardized.
19 * Based on http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf
20 * and http://www.t11.org/ftp/t11/pub/fc/bb-5/08-545v1.pdf
23 #include "config.h"
25 #include <epan/packet.h>
26 #include <epan/to_str.h>
27 #include <epan/expert.h>
28 #include "packet-fc.h"
30 void proto_register_fip(void);
31 void proto_reg_handoff_fip(void);
33 static dissector_handle_t fip_handle;
36 * FIP protocol information.
38 #define FIP_HEADER_LEN 10
39 #define FIP_BPW 4 /* bytes per descriptor length unit */
42 * FIP opcodes and subcodes.
44 enum fip_opcode {
45 FIP_OP_DISC = 1, /* discovery, advertisement, etc. */
46 FIP_OP_LS = 2, /* Link Service request or reply */
47 FIP_OP_CTRL = 3, /* control */
48 FIP_OP_VLAN = 4, /* VLAN request or reply */
49 FIP_OP_VN2VN = 5 /* VN_port to VN_port operation */
53 * Subcodes for FIP_OP_DISC.
55 enum fip_disc_subcode {
56 FIP_SC_SOL = 1, /* solicitation */
57 FIP_SC_ADV = 2 /* advertisement */
61 * Subcodes for FIP_OP_LS.
63 enum fip_ls_subcode {
64 FIP_SC_REQ = 1, /* request */
65 FIP_SC_REP = 2 /* reply */
68 enum fip_ctrl_subcode {
69 FIP_SC_KA = 1, /* keep-alive */
70 FIP_SC_CVL = 2 /* clear virtual link */
73 enum fip_vlan_subcode {
74 FIP_VL_REQ = 1, /* request */
75 FIP_VL_REP = 2 /* reply */
79 * Subcodes for FIP_OP_VN2VN.
80 * XXX proposal
82 enum fip_vn2vn_subcode {
83 FIP_SC_VN_PROBE_REQ = 1, /* probe request */
84 FIP_SC_VN_PROBE_REP = 2, /* probe reply */
85 FIP_SC_VN_CLAIM_NOTIFY = 3, /* claim notification */
86 FIP_SC_VN_CLAIM_REP = 4, /* claim response */
87 FIP_SC_VN_BEACON = 5 /* beacon */
90 static const value_string fip_opcodes[] = {
91 { FIP_OP_DISC, "Discovery" },
92 { FIP_OP_LS, "Link Service" },
93 { FIP_OP_CTRL, "Control" },
94 { FIP_OP_VLAN, "VLAN" },
95 { FIP_OP_VN2VN, "VN2VN" },
96 { 0, NULL }
99 static const value_string fip_disc_subcodes[] = {
100 { FIP_SC_SOL, "Solicitation" },
101 { FIP_SC_ADV, "Advertisement" },
102 { 0, NULL }
105 static const value_string fip_ls_subcodes[] = {
106 { FIP_SC_REQ, "ELS Request" },
107 { FIP_SC_REP, "ELS Response" },
108 { 0, NULL }
111 static const value_string fip_ctrl_subcodes[] = {
112 { FIP_SC_KA, "Keep-Alive" },
113 { FIP_SC_CVL, "Clear Virtual Link" },
114 { 0, NULL }
117 static const value_string fip_vlan_subcodes[] = {
118 { FIP_VL_REQ, "VLAN Request" },
119 { FIP_VL_REP, "VLAN Response" },
120 { 0, NULL }
123 static const value_string fip_vn2vn_subcodes[] = {
124 { FIP_SC_VN_PROBE_REQ, "Probe Request" },
125 { FIP_SC_VN_PROBE_REP, "Probe Reply" },
126 { FIP_SC_VN_CLAIM_NOTIFY, "Claim Notification" },
127 { FIP_SC_VN_CLAIM_REP, "Claim Response" },
128 { FIP_SC_VN_BEACON, "Beacon" },
129 { 0, NULL }
133 * Descriptor types.
135 enum fip_desc_type {
136 FIP_DT_PRI = 1, /* priority for forwarder selection */
137 FIP_DT_MAC = 2, /* MAC address */
138 FIP_DT_MAP_OUI = 3, /* FC-MAP OUI */
139 FIP_DT_NAME = 4, /* switch name or node name */
140 FIP_DT_FAB = 5, /* fabric descriptor */
141 FIP_DT_FCOE_SIZE = 6, /* max FCoE frame size */
142 FIP_DT_FLOGI = 7, /* FLOGI request or response */
143 FIP_DT_FDISC = 8, /* FDISC request or response */
144 FIP_DT_LOGO = 9, /* LOGO request or response */
145 FIP_DT_ELP = 10, /* ELP request or response */
146 FIP_DT_VN = 11, /* VN_Port Info */
147 FIP_DT_FKA = 12, /* FIP keep-alive / advert. period */
148 FIP_DT_VEND = 13, /* Vendor-specific TLV */
149 FIP_DT_VLAN = 14, /* VLAN number */
150 FIP_DT_FC4F = 15 /* FC-4 features */
153 static const value_string fip_desc_types[] = {
154 { FIP_DT_PRI, "Priority" },
155 { FIP_DT_MAC, "MAC Address" },
156 { FIP_DT_MAP_OUI, "FPMA MAP OUI" },
157 { FIP_DT_NAME, "Switch or Node Name" },
158 { FIP_DT_FAB, "Fabric Descriptor" },
159 { FIP_DT_FCOE_SIZE, "Max FCoE frame size" },
160 { FIP_DT_FLOGI, "FLOGI Encapsulation" },
161 { FIP_DT_FDISC, "FDISC Encapsulation" },
162 { FIP_DT_LOGO, "LOGO Encapsulation" },
163 { FIP_DT_ELP, "ELP Encapsulation" },
164 { FIP_DT_VN, "VN_Port Info" },
165 { FIP_DT_FKA, "FKA_ADV_Period" },
166 { FIP_DT_VEND, "Vendor_ID" },
167 { FIP_DT_VLAN, "VLAN" },
168 { FIP_DT_FC4F, "FC-4 features" },
169 { 0, NULL }
171 static value_string_ext fip_desc_types_ext = VALUE_STRING_EXT_INIT(fip_desc_types);
174 * flags in header fip_flags.
176 enum fip_flag {
177 FIP_FL_FPMA = 0x8000, /* supports FPMA fabric-provided MACs */
178 FIP_FL_SPMA = 0x4000, /* supports SPMA server-provided MACs */
179 FIP_FL_REC_P2P = 0x0008, /* recorded addr or point-to-point */
180 FIP_FL_AVAIL = 0x0004, /* available for FLOGI */
181 FIP_FL_SOL = 0x0002, /* this is a solicited message */
182 FIP_FL_FPORT = 0x0001 /* sent from an F port */
185 static int proto_fip;
186 static int hf_fip_ver;
187 static int hf_fip_reserved12;
188 static int hf_fip_op;
189 static int hf_fip_reserved8;
190 static int hf_fip_disc_subcode;
191 static int hf_fip_ls_subcode;
192 static int hf_fip_ctrl_subcode;
193 static int hf_fip_vlan_subcode;
194 static int hf_fip_vn2vn_subcode;
195 static int hf_fip_hex_subcode;
196 static int hf_fip_dlen;
197 static int hf_fip_flags;
198 static int hf_fip_flag_fpma;
199 static int hf_fip_flag_spma;
200 static int hf_fip_flag_rec_p2p;
201 static int hf_fip_flag_avail;
202 static int hf_fip_flag_sol;
203 static int hf_fip_flag_fport;
204 static int hf_fip_descriptors;
206 static int * const hf_fip_flags_fields[] = {
207 &hf_fip_flag_fpma,
208 &hf_fip_flag_spma,
209 &hf_fip_flag_rec_p2p,
210 &hf_fip_flag_avail,
211 &hf_fip_flag_sol,
212 &hf_fip_flag_fport,
213 NULL
216 static int hf_fip_desc_type;
217 static int hf_fip_desc_len;
218 static int hf_fip_desc_pri;
219 static int hf_fip_desc_mac;
220 static int hf_fip_desc_map;
221 static int hf_fip_desc_name;
222 static int hf_fip_desc_fab_vfid;
223 static int hf_fip_desc_fab_map;
224 static int hf_fip_desc_fab_name;
225 static int hf_fip_desc_fcoe_size;
226 static int hf_fip_desc_vn_mac;
227 static int hf_fip_desc_vn_fid;
228 static int hf_fip_desc_vn_wwpn;
229 static int hf_fip_desc_fka;
230 static int hf_fip_desc_vend;
231 static int hf_fip_desc_vend_data;
232 static int hf_fip_desc_vlan;
233 static int hf_fip_desc_unk;
234 static int hf_fip_desc_fc4f_types;
235 static int hf_fip_desc_fcp_feat;
236 static int hf_fip_type_ip;
237 static int hf_fip_type_fcp;
238 static int hf_fip_type_gs3;
239 static int hf_fip_fcp_feat_i;
240 static int hf_fip_fcp_feat_t;
242 static int ett_fip;
243 static int ett_fip_flags;
244 static int ett_fip_dt_pri;
245 static int ett_fip_dt_mac;
246 static int ett_fip_dt_map;
247 static int ett_fip_dt_name;
248 static int ett_fip_dt_fab;
249 static int ett_fip_dt_mdl;
250 static int ett_fip_dt_caps;
251 static int ett_fip_dt_vn;
252 static int ett_fip_dt_fka;
253 static int ett_fip_dt_vend;
254 static int ett_fip_dt_vlan;
255 static int ett_fip_dt_unk;
256 static int ett_fip_dt_fc4f;
257 static int ett_fip_dt_fc4f_types;
258 static int ett_fip_dt_fcp_feat;
260 static expert_field ei_fip_descriptors;
262 static dissector_handle_t fc_handle;
265 * Insert common descriptor type and length fields.
267 static proto_tree*
268 fip_desc_type_len(proto_tree *tree, tvbuff_t *tvb, uint8_t dtype, int ett, proto_item** item)
270 proto_tree* ret_tree;
272 ret_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett, item,
273 "Descriptor: %s ", val_to_str_ext(dtype, &fip_desc_types_ext, "Unknown 0x%x"));
274 proto_tree_add_item(ret_tree, hf_fip_desc_type, tvb, 0, 1, ENC_BIG_ENDIAN);
275 proto_tree_add_item(ret_tree, hf_fip_desc_len, tvb, 1, 1, ENC_BIG_ENDIAN);
277 return ret_tree;
281 * Dissect the FC-4 type features descriptor.
283 static void
284 fip_desc_fc4f(tvbuff_t *tvb, proto_tree *tree, proto_item *item)
286 unsigned mask;
287 unsigned offset;
289 static int * const types_word0[] = { /* types 0 - 31 */
290 &hf_fip_type_ip,
291 &hf_fip_type_fcp,
292 NULL
294 static int * const types_word1[] = { /* types 32 - 63 */
295 &hf_fip_type_gs3,
296 NULL
298 static int * const fcp_feat[] = {
299 &hf_fip_fcp_feat_t,
300 &hf_fip_fcp_feat_i,
301 NULL
305 * First the 256-bit bitmask of types supported.
307 offset = 4;
308 proto_tree_add_bitmask(tree, tvb, offset, hf_fip_desc_fc4f_types,
309 ett_fip_dt_fc4f_types, types_word0, ENC_BIG_ENDIAN);
310 offset += 4;
311 proto_tree_add_bitmask(tree, tvb, offset, hf_fip_desc_fc4f_types,
312 ett_fip_dt_fc4f_types, types_word1, ENC_BIG_ENDIAN);
313 offset += 256 / 8 - 4; /* skip to end of bitmask (32 bytes) */
316 * Next the 4-bit capabilities per type.
317 * Only decode FCP (type 8) for now.
319 offset += 8 / 2; /* skip first 8 types, 2 types per byte */
320 proto_tree_add_bitmask(tree, tvb, offset, hf_fip_desc_fcp_feat,
321 ett_fip_dt_fcp_feat, fcp_feat, ENC_BIG_ENDIAN);
322 mask = tvb_get_ntohl(tvb, offset);
323 if (mask & 1) {
324 proto_item_append_text(item, "FCP Target ");
326 if (mask & 2) {
327 proto_item_append_text(item, "FCP Initiator ");
331 static int
332 dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
334 unsigned op;
335 unsigned sub;
336 unsigned rlen;
337 proto_item *ti;
338 proto_item *item;
339 proto_tree *fip_tree;
340 proto_tree *subtree;
341 unsigned dtype;
342 unsigned dlen;
343 unsigned desc_offset;
344 unsigned val;
345 tvbuff_t *desc_tvb;
346 const char *info;
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 proto_tree_add_protocol_format(tree, proto_fip, tvb, 0,
354 -1, "FIP [packet too short]");
355 return tvb_captured_length(tvb);
358 op = tvb_get_ntohs(tvb, 2);
359 sub = tvb_get_uint8(tvb, 5);
361 switch (op) {
362 case FIP_OP_DISC:
363 info = val_to_str(sub, fip_disc_subcodes, "Discovery 0x%x");
364 break;
365 case FIP_OP_LS:
366 info = val_to_str(sub, fip_ls_subcodes, "Link Service 0x%x");
367 break;
368 case FIP_OP_CTRL:
369 info = val_to_str(sub, fip_ctrl_subcodes, "Control 0x%x");
370 break;
371 case FIP_OP_VLAN:
372 info = val_to_str(sub, fip_vlan_subcodes, "VLAN 0x%x");
373 break;
374 case FIP_OP_VN2VN:
375 info = val_to_str(sub, fip_vn2vn_subcodes, "VN2VN 0x%x");
376 break;
377 default:
378 info = val_to_str(op, fip_opcodes, "Unknown op 0x%x");
379 break;
382 col_add_str(pinfo->cinfo, COL_INFO, info);
384 rlen = tvb_get_ntohs(tvb, 6);
386 ti = proto_tree_add_protocol_format(tree, proto_fip, tvb, 0,
387 FIP_HEADER_LEN + rlen * FIP_BPW,
388 "FIP %s", info);
389 fip_tree = proto_item_add_subtree(ti, ett_fip);
390 proto_tree_add_item(fip_tree, hf_fip_ver, tvb, 0, 1, ENC_BIG_ENDIAN);
391 proto_tree_add_item(fip_tree, hf_fip_reserved12, tvb, 0, 2, ENC_BIG_ENDIAN);
392 proto_tree_add_item(fip_tree, hf_fip_op, tvb, 2, 2, ENC_BIG_ENDIAN);
393 proto_tree_add_item(fip_tree, hf_fip_reserved8, tvb, 4, 1, ENC_NA);
394 switch (op) {
395 case FIP_OP_DISC:
396 proto_tree_add_item(fip_tree, hf_fip_disc_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
397 break;
398 case FIP_OP_LS:
399 proto_tree_add_item(fip_tree, hf_fip_ls_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
400 break;
401 case FIP_OP_CTRL:
402 proto_tree_add_item(fip_tree, hf_fip_ctrl_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
403 break;
404 case FIP_OP_VLAN:
405 proto_tree_add_item(fip_tree, hf_fip_vlan_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
406 break;
407 case FIP_OP_VN2VN:
408 proto_tree_add_item(fip_tree, hf_fip_vn2vn_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
409 break;
410 default:
411 proto_tree_add_item(fip_tree, hf_fip_hex_subcode, tvb, 5, 1, ENC_BIG_ENDIAN);
412 break;
414 proto_tree_add_item(fip_tree, hf_fip_dlen, tvb, 6, 2, ENC_BIG_ENDIAN);
416 proto_tree_add_bitmask(fip_tree, tvb, 8, hf_fip_flags,
417 ett_fip_flags, hf_fip_flags_fields, ENC_BIG_ENDIAN);
419 desc_offset = FIP_HEADER_LEN;
420 rlen *= FIP_BPW;
421 proto_tree_add_bytes_format(fip_tree, hf_fip_descriptors, tvb, desc_offset, rlen, NULL, "Descriptors");
423 while ((rlen > 0) && tvb_bytes_exist(tvb, desc_offset, 2)) {
424 dlen = tvb_get_uint8(tvb, desc_offset + 1) * FIP_BPW;
425 if (!dlen) {
426 proto_tree_add_expert(fip_tree, pinfo, &ei_fip_descriptors, tvb, desc_offset, -1);
427 break;
429 if (!tvb_bytes_exist(tvb, desc_offset, dlen) || dlen > rlen) {
430 break;
432 desc_tvb = tvb_new_subset_length_caplen(tvb, desc_offset, dlen, -1);
433 dtype = tvb_get_uint8(desc_tvb, 0);
434 desc_offset += dlen;
435 rlen -= dlen;
437 switch (dtype) {
438 case FIP_DT_PRI:
439 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_pri, &item);
440 proto_tree_add_item(subtree, hf_fip_desc_pri, desc_tvb,
441 3, 1, ENC_BIG_ENDIAN);
442 proto_item_append_text(item, "%u", tvb_get_uint8(desc_tvb, 3));
443 break;
444 case FIP_DT_MAC:
445 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_mac, &item);
446 proto_tree_add_item(subtree, hf_fip_desc_mac, desc_tvb,
447 2, 6, ENC_NA);
448 proto_item_append_text(item, "%s",
449 tvb_bytes_to_str_punct(pinfo->pool, desc_tvb, 2, 6, ':'));
450 break;
451 case FIP_DT_MAP_OUI:
452 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_map, &item);
453 proto_tree_add_item(subtree, hf_fip_desc_map, desc_tvb,
454 5, 3, ENC_NA);
455 proto_item_append_text(item, "%s", tvb_fc_to_str(pinfo->pool, desc_tvb, 5));
456 break;
457 case FIP_DT_NAME:
458 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_name, &item);
459 proto_tree_add_item(subtree, hf_fip_desc_name, desc_tvb, 4, 8, ENC_NA);
460 proto_item_append_text(item, "%s", tvb_fcwwn_to_str(pinfo->pool, desc_tvb, 4));
461 break;
462 case FIP_DT_FAB:
463 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_fab, &item);
464 proto_tree_add_item(subtree, hf_fip_desc_fab_vfid, desc_tvb,
465 2, 2, ENC_BIG_ENDIAN);
466 proto_tree_add_item(subtree, hf_fip_desc_fab_map, desc_tvb,
467 5, 3, ENC_NA);
468 proto_tree_add_item(subtree, hf_fip_desc_fab_name, desc_tvb, 8, 8, ENC_NA);
469 proto_item_append_text(item, "%s", tvb_fcwwn_to_str(pinfo->pool, desc_tvb, 8));
470 break;
471 case FIP_DT_FCOE_SIZE:
472 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_mdl, &item);
473 proto_tree_add_item(subtree, hf_fip_desc_fcoe_size, desc_tvb,
474 2, 2, ENC_BIG_ENDIAN);
475 proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2));
476 break;
477 case FIP_DT_FLOGI:
478 case FIP_DT_FDISC:
479 case FIP_DT_LOGO:
480 case FIP_DT_ELP: {
481 tvbuff_t *ls_tvb;
482 fc_data_t fc_data = {ETHERTYPE_FIP, 0};
484 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_caps, &item);
485 ls_tvb = tvb_new_subset_length_caplen(desc_tvb, 4, dlen - 4, -1);
486 call_dissector_with_data(fc_handle, ls_tvb, pinfo, subtree, &fc_data);
487 proto_item_append_text(item, "%u bytes", dlen - 4);
489 break;
490 case FIP_DT_VN:
491 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_vn, &item);
492 proto_tree_add_item(subtree, hf_fip_desc_vn_mac, desc_tvb,
493 2, 6, ENC_NA);
494 proto_tree_add_item(subtree, hf_fip_desc_vn_fid, desc_tvb,
495 9, 3, ENC_BIG_ENDIAN);
496 proto_tree_add_item(subtree, hf_fip_desc_vn_wwpn,
497 desc_tvb, 12, 8, ENC_NA);
498 proto_item_append_text(item, "MAC %s FC_ID %6.6x",
499 tvb_bytes_to_str_punct(pinfo->pool, desc_tvb, 2, 6, ':'),
500 tvb_get_ntoh24(desc_tvb, 9));
501 break;
502 case FIP_DT_FKA:
503 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_fka, &item);
504 val = tvb_get_ntohl(desc_tvb, 4);
505 proto_tree_add_uint_format_value(subtree, hf_fip_desc_fka,
506 desc_tvb, 4, 4, val, "%u ms", val);
507 proto_item_append_text(item, "%u ms", val);
508 break;
509 case FIP_DT_VEND:
510 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_vend, &item);
511 proto_tree_add_item(subtree, hf_fip_desc_vend, desc_tvb,
512 4, 8, ENC_NA);
513 if (tvb_reported_length_remaining(desc_tvb, 9)) {
514 proto_tree_add_item(subtree, hf_fip_desc_vend_data,
515 desc_tvb, 9, -1, ENC_NA);
517 break;
518 case FIP_DT_VLAN:
519 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_vlan, &item);
520 proto_tree_add_item(subtree, hf_fip_desc_vlan, desc_tvb,
521 2, 2, ENC_BIG_ENDIAN);
522 proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2));
523 break;
524 case FIP_DT_FC4F:
525 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_fc4f, &item);
526 fip_desc_fc4f(desc_tvb, subtree, item);
527 break;
528 default:
529 subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_unk, &item);
530 proto_tree_add_item(subtree, hf_fip_desc_unk, desc_tvb,
531 2, -1, ENC_NA);
532 break;
535 return tvb_captured_length(tvb);
538 void
539 proto_register_fip(void)
541 /* Setup list of header fields See Section 1.6.1 for details*/
542 static hf_register_info hf[] = {
544 * FIP header fields.
546 { &hf_fip_ver,
547 { "Version", "fip.ver",
548 FT_UINT8, BASE_DEC, NULL, 0xf0,
549 NULL, HFILL}},
551 { &hf_fip_reserved12,
552 { "Reserved", "fip.reserved",
553 FT_UINT16, BASE_HEX, NULL, 0x0fff,
554 NULL, HFILL}},
556 { &hf_fip_op,
557 { "Opcode", "fip.opcode",
558 FT_UINT16, BASE_HEX, VALS(fip_opcodes), 0,
559 NULL, HFILL}},
561 { &hf_fip_reserved8,
562 { "Reserved", "fip.reserved",
563 FT_UINT8, BASE_HEX, NULL, 0x0,
564 NULL, HFILL}},
566 { &hf_fip_disc_subcode,
567 { "Discovery Subcode", "fip.disc_subcode",
568 FT_UINT8, BASE_HEX, VALS(fip_disc_subcodes), 0,
569 NULL, HFILL}},
571 { &hf_fip_ls_subcode,
572 { "Link Service Subcode", "fip.ls.subcode",
573 FT_UINT8, BASE_HEX, VALS(fip_ls_subcodes), 0,
574 NULL, HFILL}},
576 { &hf_fip_ctrl_subcode,
577 { "Control Subcode", "fip.ctrl_subcode",
578 FT_UINT8, BASE_HEX, VALS(fip_ctrl_subcodes), 0,
579 NULL, HFILL}},
581 { &hf_fip_vlan_subcode,
582 { "VLAN Subcode", "fip.vlan_subcode",
583 FT_UINT8, BASE_HEX, VALS(fip_vlan_subcodes), 0,
584 NULL, HFILL}},
586 { &hf_fip_vn2vn_subcode,
587 { "VN2VN Subcode", "fip.vn2vn_subcode",
588 FT_UINT8, BASE_HEX, VALS(fip_vn2vn_subcodes), 0,
589 NULL, HFILL}},
591 { &hf_fip_hex_subcode,
592 { "Unknown Subcode", "fip.subcode",
593 FT_UINT8, BASE_HEX, NULL, 0,
594 NULL, HFILL}},
596 { &hf_fip_dlen,
597 { "Length of Descriptors (words)", "fip.dl_len",
598 FT_UINT16, BASE_DEC, NULL, 0,
599 NULL, HFILL}},
601 { &hf_fip_flags,
602 { "Flags", "fip.flags",
603 FT_UINT16, BASE_HEX, NULL, 0,
604 NULL, HFILL}},
606 { &hf_fip_flag_fpma,
607 { "Fabric Provided MAC addr", "fip.flags.fpma",
608 FT_BOOLEAN, 16, NULL, FIP_FL_FPMA,
609 NULL, HFILL}},
611 { &hf_fip_flag_spma,
612 { "Server Provided MAC addr", "fip.flags.spma",
613 FT_BOOLEAN, 16, NULL, FIP_FL_SPMA,
614 NULL, HFILL}},
616 { &hf_fip_flag_rec_p2p,
617 { "REC/P2P", "fip.flags.rec_p2p",
618 FT_BOOLEAN, 16, NULL, FIP_FL_REC_P2P,
619 NULL, HFILL}},
621 { &hf_fip_flag_avail,
622 { "Available", "fip.flags.available",
623 FT_BOOLEAN, 16, NULL, FIP_FL_AVAIL,
624 NULL, HFILL}},
626 { &hf_fip_flag_sol,
627 { "Solicited", "fip.flags.sol",
628 FT_BOOLEAN, 16, NULL, FIP_FL_SOL,
629 NULL, HFILL}},
631 { &hf_fip_flag_fport,
632 { "F_Port", "fip.flags.fport",
633 FT_BOOLEAN, 16, NULL, FIP_FL_FPORT,
634 NULL, HFILL}},
636 { &hf_fip_desc_type,
637 { "Descriptor Type", "fip.desc_type",
638 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &fip_desc_types_ext, 0,
639 NULL, HFILL}},
641 { &hf_fip_desc_len,
642 { "Descriptor Length (words)", "fip.desc_len",
643 FT_UINT8, BASE_DEC, NULL, 0,
644 NULL, HFILL}},
647 * Various descriptor fields.
649 { &hf_fip_desc_pri,
650 { "Priority", "fip.pri",
651 FT_UINT8, BASE_DEC, NULL, 0,
652 NULL, HFILL}},
654 { &hf_fip_desc_mac,
655 { "MAC Address", "fip.mac",
656 FT_ETHER, BASE_NONE, NULL, 0,
657 NULL, HFILL}},
659 { &hf_fip_desc_map,
660 { "FC-MAP-OUI", "fip.map",
661 FT_BYTES, SEP_DOT, NULL, 0,
662 NULL, HFILL}},
664 { &hf_fip_desc_name,
665 { "Switch or Node Name", "fip.name",
666 FT_FCWWN, BASE_NONE, NULL, 0,
667 NULL, HFILL}},
669 { &hf_fip_desc_fab_vfid,
670 { "VFID", "fip.fab.vfid",
671 FT_UINT16, BASE_DEC, NULL, 0,
672 NULL, HFILL}},
674 { &hf_fip_desc_fab_map,
675 { "FC-MAP", "fip.fab.map",
676 FT_BYTES, SEP_DOT, NULL, 0,
677 NULL, HFILL}},
679 { &hf_fip_desc_fab_name,
680 { "Fabric Name", "fip.fab.name",
681 FT_FCWWN, BASE_NONE, NULL, 0,
682 NULL, HFILL}},
684 { &hf_fip_desc_fcoe_size,
685 { "Max FCoE frame size", "fip.fcoe_size",
686 FT_UINT16, BASE_DEC, NULL, 0,
687 NULL, HFILL}},
689 { &hf_fip_desc_vn_mac,
690 { "VN_Port MAC Address", "fip.vn.mac",
691 FT_ETHER, BASE_NONE, NULL, 0,
692 NULL, HFILL}},
694 { &hf_fip_desc_vn_fid,
695 { "VN_Port FC_ID", "fip.vn.fc_id",
696 FT_UINT32, BASE_HEX, NULL, 0,
697 NULL, HFILL}},
699 { &hf_fip_desc_vn_wwpn,
700 { "Port Name", "fip.vn.pwwn",
701 FT_FCWWN, BASE_NONE, NULL, 0,
702 NULL, HFILL}},
704 { &hf_fip_desc_fka,
705 { "FKA_ADV_Period", "fip.fka",
706 FT_UINT32, BASE_DEC, NULL, 0,
707 NULL, HFILL}},
709 { &hf_fip_desc_vend,
710 { "Vendor-ID", "fip.vendor",
711 FT_BYTES, BASE_NONE, NULL, 0,
712 NULL, HFILL}},
714 { &hf_fip_desc_vend_data,
715 { "Vendor-specific data", "fip.vendor.data",
716 FT_BYTES, BASE_NONE, NULL, 0,
717 NULL, HFILL}},
719 { &hf_fip_desc_vlan,
720 { "VLAN", "fip.vlan",
721 FT_UINT16, BASE_DEC, NULL, 0,
722 NULL, HFILL}},
724 { &hf_fip_desc_fc4f_types,
725 { "FC4 Types", "fip.fc4f.types",
726 FT_UINT32, BASE_HEX, NULL, 0,
727 NULL, HFILL}},
729 { &hf_fip_desc_fcp_feat,
730 { "FCP Features", "fip.fc4f.feat.fcp",
731 FT_UINT32, BASE_HEX, NULL, 0xf,
732 NULL, HFILL}},
734 { &hf_fip_type_ip,
735 { "IP", "fip.fc4f.ip",
736 FT_BOOLEAN, 32, NULL, 1 << 5,
737 NULL, HFILL}},
739 { &hf_fip_type_fcp,
740 { "FCP", "fip.fc4f.fcp",
741 FT_BOOLEAN, 32, NULL, 1 << 8,
742 NULL, HFILL}},
744 { &hf_fip_type_gs3,
745 { "GS3", "fip.fc4f.gs3",
746 FT_BOOLEAN, 32, NULL, 1 << 0,
747 NULL, HFILL}},
749 { &hf_fip_fcp_feat_t,
750 { "FCP Target", "fip.fc4f.feat.fcp.target",
751 FT_BOOLEAN, 32, NULL, 1,
752 NULL, HFILL}},
754 { &hf_fip_fcp_feat_i,
755 { "FCP Initiator", "fip.fc4f.feat.fcp.initiator",
756 FT_BOOLEAN, 32, NULL, 2,
757 NULL, HFILL}},
759 { &hf_fip_desc_unk,
760 { "Unknown Descriptor", "fip.desc_unk",
761 FT_BYTES, BASE_NONE, NULL, 0,
762 NULL, HFILL}},
764 { &hf_fip_descriptors,
765 { "Descriptors", "fip.descriptors",
766 FT_BYTES, BASE_NONE, NULL, 0,
767 NULL, HFILL}},
770 static int *ett[] = {
771 &ett_fip,
772 &ett_fip_flags,
773 &ett_fip_dt_pri,
774 &ett_fip_dt_mac,
775 &ett_fip_dt_map,
776 &ett_fip_dt_name,
777 &ett_fip_dt_fab,
778 &ett_fip_dt_mdl,
779 &ett_fip_dt_caps,
780 &ett_fip_dt_vn,
781 &ett_fip_dt_fka,
782 &ett_fip_dt_vend,
783 &ett_fip_dt_vlan,
784 &ett_fip_dt_fc4f,
785 &ett_fip_dt_fc4f_types,
786 &ett_fip_dt_fcp_feat,
787 &ett_fip_dt_unk
790 static ei_register_info ei[] = {
791 { &ei_fip_descriptors, { "fip.descriptors.length_error", PI_MALFORMED, PI_ERROR, "Descriptor [length error]", EXPFILL }},
794 expert_module_t* expert_fip;
796 /* Register the protocol name and description */
797 proto_fip = proto_register_protocol("FCoE Initialization Protocol",
798 "FIP", "fip");
799 fip_handle = register_dissector("fip", dissect_fip, proto_fip);
801 /* Required function calls to register the header fields and
802 * subtrees used */
803 proto_register_field_array(proto_fip, hf, array_length(hf));
804 proto_register_subtree_array(ett, array_length(ett));
805 expert_fip = expert_register_protocol(proto_fip);
806 expert_register_field_array(expert_fip, ei, array_length(ei));
810 * This function name is required because a script is used to find these
811 * routines and create the code that calls these routines.
813 void
814 proto_reg_handoff_fip(void)
816 dissector_add_uint("ethertype", ETHERTYPE_FIP, fip_handle);
817 fc_handle = find_dissector_add_dependency("fc", proto_fip);
821 * Editor modelines - https://www.wireshark.org/tools/modelines.html
823 * Local variables:
824 * c-basic-offset: 4
825 * tab-width: 8
826 * indent-tabs-mode: nil
827 * End:
829 * vi: set shiftwidth=4 tabstop=8 expandtab:
830 * :indentSize=4:tabSize=8:noTabs=true: