From Didier Gautheron:
[obnox/wireshark/wip.git] / epan / dissectors / packet-fip.c
1 /*
2  * packet-fip.c
3  * Routines for FIP dissection - FCoE Initialization Protocol
4  * Copyright (c) 2008 Cisco Systems, Inc. (jeykholt@cisco.com)
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
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)
14  *
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.
19  *
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.
24  *
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28  */
29
30 /*
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
35  */
36
37 #ifdef HAVE_CONFIG_H
38 # include "config.h"
39 #endif
40
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44
45 #include <glib.h>
46
47 #include <epan/packet.h>
48 #include <epan/etypes.h>
49 #include <epan/expert.h>
50
51 void proto_reg_handoff_fip(void);
52
53 /*
54  * FIP protocol information.
55  */
56 #define FIP_HEADER_LEN  10
57 #define FIP_BPW         4               /* bytes per descriptor length unit */
58
59 /*
60  * FIP opcodes and subcodes.
61  */
62 enum fip_opcode {
63         FIP_OP_DISC =   1,              /* discovery, advertisement, etc. */
64         FIP_OP_LS = 2,                  /* Link Service request or reply */
65         FIP_OP_CTRL =   3,              /* control */
66         FIP_OP_VLAN =   4               /* VLAN request or reply */
67 };
68
69 /*
70  * Subcodes for FIP_OP_DISC.
71  */
72 enum fip_disc_subcode {
73         FIP_SC_SOL =    1,              /* solicitation */
74         FIP_SC_ADV =    2               /* advertisement */
75 };
76
77 /*
78  * Subcodes for FIP_OP_LS.
79  */
80 enum fip_ls_subcode {
81         FIP_SC_REQ =    1,              /* request */
82         FIP_SC_REP =    2               /* reply */
83 };
84
85 enum fip_ctrl_subcode {
86         FIP_SC_KA =     1,              /* keep-alive */
87         FIP_SC_CVL =    2               /* clear virtual link */
88 };
89
90 enum fip_vlan_subcode {
91         FIP_VL_REQ =    1,              /* request */
92         FIP_VL_REP =    2               /* reply */
93 };
94
95 static const value_string fip_opcodes[] = {
96         { FIP_OP_DISC,      "Discovery" },
97         { FIP_OP_LS,        "Link Service" },
98         { FIP_OP_CTRL,      "Control" },
99         { FIP_OP_VLAN,      "VLAN" },
100         { 0,                NULL }
101 };
102
103 static const value_string fip_disc_subcodes[] = {
104         { FIP_SC_SOL,       "Solicitation" },
105         { FIP_SC_ADV,       "Advertisement" },
106         { 0,    NULL }
107 };
108
109 static const value_string fip_ls_subcodes[] = {
110         { FIP_SC_REQ,       "ELS Request" },
111         { FIP_SC_REP,       "ELS Response" },
112         { 0,    NULL }
113 };
114
115 static const value_string fip_ctrl_subcodes[] = {
116         { FIP_SC_KA,       "Keep-Alive" },
117         { FIP_SC_CVL,      "Clear Virtual Link" },
118         { 0,    NULL }
119 };
120
121 static const value_string fip_vlan_subcodes[] = {
122         { FIP_VL_REQ,       "VLAN Request" },
123         { FIP_VL_REP,       "VLAN Response" },
124         { 0,    NULL }
125 };
126
127 /*
128  * Descriptor types.
129  */
130 enum fip_desc_type {
131         FIP_DT_PRI =    1,              /* priority for forwarder selection */
132         FIP_DT_MAC =    2,              /* MAC address */
133         FIP_DT_MAP_OUI = 3,             /* FC-MAP OUI */
134         FIP_DT_NAME =   4,              /* switch name or node name */
135         FIP_DT_FAB =    5,              /* fabric descriptor */
136         FIP_DT_FCOE_SIZE = 6,           /* max FCoE frame size */
137         FIP_DT_FLOGI =  7,              /* FLOGI request or response */
138         FIP_DT_FDISC =  8,              /* FDISC request or response */
139         FIP_DT_LOGO =   9,              /* LOGO request or response */
140         FIP_DT_ELP =    10,             /* ELP request or response */
141         FIP_DT_VN =     11,             /* VN_Port Info */
142         FIP_DT_FKA =    12,             /* FIP keep-alive / advert. period */
143         FIP_DT_VEND =   13,             /* Vendor-specific TLV */
144         FIP_DT_VLAN =   14              /* VLAN number */
145 };
146
147 static const value_string fip_desc_types[] = {
148         { FIP_DT_PRI,   "Priority" },
149         { FIP_DT_MAC,   "MAC Address" },
150         { FIP_DT_MAP_OUI, "FPMA MAP OUI" },
151         { FIP_DT_NAME,  "Switch or Node Name" },
152         { FIP_DT_FAB,   "Fabric Descriptor" },
153         { FIP_DT_FCOE_SIZE, "Max FCoE frame size" },
154         { FIP_DT_FLOGI, "FLOGI Encapsulation" },
155         { FIP_DT_FDISC, "FDISC Encapsulation" },
156         { FIP_DT_LOGO,  "LOGO Encapsulation" },
157         { FIP_DT_ELP,   "ELP Encapsulation" },
158         { FIP_DT_VN,    "VN_Port Info" },
159         { FIP_DT_FKA,   "FKA_ADV_Period" },
160         { FIP_DT_VEND,  "Vendor_ID" },
161         { FIP_DT_VLAN,  "VLAN" },
162         { 0,    NULL }
163 };
164
165 /*
166  * flags in header fip_flags.
167  */
168 enum fip_flag {
169         FIP_FL_FPMA =   0x8000,         /* supports FPMA fabric-provided MACs */
170         FIP_FL_SPMA =   0x4000,         /* supports SPMA server-provided MACs */
171         FIP_FL_AVAIL =  0x0004,         /* available for FLOGI */
172         FIP_FL_SOL =    0x0002,         /* this is a solicited message */
173         FIP_FL_FPORT =  0x0001          /* sent from an F port */
174 };
175
176 static int proto_fip            = -1;
177 static int hf_fip_ver           = -1;
178 static int hf_fip_op            = -1;
179 static int hf_fip_disc_subcode  = -1;
180 static int hf_fip_ls_subcode    = -1;
181 static int hf_fip_ctrl_subcode  = -1;
182 static int hf_fip_vlan_subcode  = -1;
183 static int hf_fip_hex_subcode   = -1;
184 static int hf_fip_dlen          = -1;
185 static int hf_fip_flags         = -1;
186 static int hf_fip_flag_fpma     = -1;
187 static int hf_fip_flag_spma     = -1;
188 static int hf_fip_flag_avail    = -1;
189 static int hf_fip_flag_sol      = -1;
190 static int hf_fip_flag_fport    = -1;
191
192 static const int *hf_fip_flags_fields[] = {
193     &hf_fip_flag_fpma,
194     &hf_fip_flag_spma,
195     &hf_fip_flag_avail,
196     &hf_fip_flag_sol,
197     &hf_fip_flag_fport,
198     NULL
199 };
200
201 static int hf_fip_desc_type     = -1;
202 static int hf_fip_desc_len      = -1;
203 static int hf_fip_desc_pri      = -1;
204 static int hf_fip_desc_mac      = -1;
205 static int hf_fip_desc_map      = -1;
206 static int hf_fip_desc_name     = -1;
207 static int hf_fip_desc_fab_vfid = -1;
208 static int hf_fip_desc_fab_map  = -1;
209 static int hf_fip_desc_fab_name = -1;
210 static int hf_fip_desc_fcoe_size = -1;
211 static int hf_fip_desc_vn_mac   = -1;
212 static int hf_fip_desc_vn_fid   = -1;
213 static int hf_fip_desc_vn_wwpn  = -1;
214 static int hf_fip_desc_fka      = -1;
215 static int hf_fip_desc_vend     = -1;
216 static int hf_fip_desc_vend_data = -1;
217 static int hf_fip_desc_vlan     = -1;
218 static int hf_fip_desc_unk      = -1;
219
220 static int ett_fip              = -1;
221 static int ett_fip_flags        = -1;
222 static int ett_fip_dt_pri       = -1;
223 static int ett_fip_dt_mac       = -1;
224 static int ett_fip_dt_map       = -1;
225 static int ett_fip_dt_name      = -1;
226 static int ett_fip_dt_fab       = -1;
227 static int ett_fip_dt_mdl       = -1;
228 static int ett_fip_dt_caps      = -1;
229 static int ett_fip_dt_vn        = -1;
230 static int ett_fip_dt_fka       = -1;
231 static int ett_fip_dt_vend      = -1;
232 static int ett_fip_dt_vlan      = -1;
233 static int ett_fip_dt_unk       = -1;
234
235 static dissector_handle_t fc_handle;
236
237 /*
238  * Insert common descriptor type and length fields.
239  */
240 static void
241 fip_desc_type_len(proto_tree *tree, tvbuff_t *tvb)
242 {
243     proto_tree_add_item(tree, hf_fip_desc_type, tvb, 0, 1, FALSE);
244     proto_tree_add_item(tree, hf_fip_desc_len, tvb, 1, 1, FALSE);
245 }
246
247 static void
248 dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
249 {
250     guint op;
251     guint sub;
252     guint rlen;
253     proto_item *ti;
254     proto_item *item;
255     proto_tree *fip_tree;
256     proto_tree *subtree;
257     guint dtype;
258     guint dlen;
259     guint desc_offset;
260     guint val;
261     tvbuff_t *desc_tvb;
262     tvbuff_t *ls_tvb = NULL;
263     const char *info;
264     char *text;
265
266     col_set_str(pinfo->cinfo, COL_PROTOCOL, "FIP");
267
268     if (!tvb_bytes_exist(tvb, 0, FIP_HEADER_LEN)) {
269         col_set_str(pinfo->cinfo, COL_INFO, "[packet too short]");
270         if (tree)
271             proto_tree_add_protocol_format(tree, proto_fip, tvb, 0,
272                                             -1, "FIP [packet too short]");
273         return;
274     }
275
276     op = tvb_get_ntohs(tvb, 2);
277     sub = tvb_get_guint8(tvb, 5);
278
279     switch (op) {
280     case FIP_OP_DISC:
281         info = val_to_str(sub, fip_disc_subcodes, "Discovery 0x%x");
282         break;
283     case FIP_OP_LS:
284         info = val_to_str(sub, fip_ls_subcodes, "Link Service 0x%x");
285         break;
286     case FIP_OP_CTRL:
287         info = val_to_str(sub, fip_ctrl_subcodes, "Control 0x%x");
288         break;
289     case FIP_OP_VLAN:
290         info = val_to_str(sub, fip_vlan_subcodes, "VLAN 0x%x");
291         break;
292     default:
293         info = val_to_str(op, fip_opcodes, "Unknown op 0x%x");
294         break;
295     }
296
297     col_set_str(pinfo->cinfo, COL_INFO, info);
298
299     rlen = tvb_get_ntohs(tvb, 6);
300
301     ti = proto_tree_add_protocol_format(tree, proto_fip, tvb, 0,
302                                         FIP_HEADER_LEN + rlen * FIP_BPW,
303                                         "FIP %s", info);
304     fip_tree = proto_item_add_subtree(ti, ett_fip);
305     proto_tree_add_item(fip_tree, hf_fip_ver, tvb, 0, 1, FALSE);
306     proto_tree_add_item(fip_tree, hf_fip_op, tvb, 2, 2, FALSE);
307     switch (op) {
308     case FIP_OP_DISC:
309         proto_tree_add_item(fip_tree, hf_fip_disc_subcode, tvb, 5, 1, FALSE);
310         break;
311     case FIP_OP_LS:
312         proto_tree_add_item(fip_tree, hf_fip_ls_subcode, tvb, 5, 1, FALSE);
313         break;
314     case FIP_OP_CTRL:
315         proto_tree_add_item(fip_tree, hf_fip_ctrl_subcode, tvb, 5, 1, FALSE);
316         break;
317     case FIP_OP_VLAN:
318         proto_tree_add_item(fip_tree, hf_fip_vlan_subcode, tvb, 5, 1, FALSE);
319         break;
320     default:
321         proto_tree_add_item(fip_tree, hf_fip_hex_subcode, tvb, 5, 1, FALSE);
322         break;
323     }
324     proto_tree_add_item(fip_tree, hf_fip_dlen, tvb, 6, 2, FALSE);
325
326     proto_tree_add_bitmask(fip_tree, tvb, 8, hf_fip_flags,
327             ett_fip_flags, hf_fip_flags_fields, FALSE);
328
329     desc_offset = FIP_HEADER_LEN;
330     rlen *= FIP_BPW;
331     proto_tree_add_text(fip_tree, tvb, desc_offset, rlen, "Descriptors:");
332
333     while (rlen > 0 && tvb_bytes_exist(tvb, desc_offset, 2)) {
334         dlen = tvb_get_guint8(tvb, desc_offset + 1) * FIP_BPW;
335         if (!dlen) {
336             proto_tree_add_text(fip_tree, tvb, desc_offset, -1,
337                     "Descriptor [length error]");
338             break;
339         }
340         if (!tvb_bytes_exist(tvb, desc_offset, dlen) || dlen > rlen) {
341             break;
342         }
343         desc_tvb = tvb_new_subset(tvb, desc_offset, dlen, -1);
344         dtype = tvb_get_guint8(desc_tvb, 0);
345         desc_offset += dlen;
346         rlen -= dlen;
347
348         item = proto_tree_add_text(fip_tree, desc_tvb, 0, -1, "Descriptor: %s ",
349           val_to_str(dtype, fip_desc_types, "Unknown 0x%x"));
350
351         switch (dtype) {
352         case FIP_DT_PRI:
353             subtree = proto_item_add_subtree(item, ett_fip_dt_pri);
354             fip_desc_type_len(subtree, desc_tvb);
355             proto_tree_add_item(subtree, hf_fip_desc_pri, desc_tvb,
356                     3, 1, FALSE);
357             proto_item_append_text(item, "%u", tvb_get_guint8(desc_tvb, 3));
358             break;
359         case FIP_DT_MAC:
360             subtree = proto_item_add_subtree(item, ett_fip_dt_mac);
361             fip_desc_type_len(subtree, desc_tvb);
362             proto_tree_add_item(subtree, hf_fip_desc_mac, desc_tvb,
363                     2, 6, FALSE);
364             proto_item_append_text(item, "%s",
365                     tvb_bytes_to_str_punct(desc_tvb, 2, 6, ':'));
366             break;
367         case FIP_DT_MAP_OUI:
368             subtree = proto_item_add_subtree(item, ett_fip_dt_map);
369             fip_desc_type_len(subtree, desc_tvb);
370             text = fc_to_str(tvb_get_ptr(desc_tvb, 5, 3));
371             proto_tree_add_string(subtree, hf_fip_desc_map, desc_tvb,
372                     5, 3, text);
373             proto_item_append_text(item, "%s", text);
374             break;
375         case FIP_DT_NAME:
376             subtree = proto_item_add_subtree(item, ett_fip_dt_name);
377             fip_desc_type_len(subtree, desc_tvb);
378             text = fcwwn_to_str(tvb_get_ptr(desc_tvb, 4, 8));
379             proto_tree_add_string(subtree, hf_fip_desc_name,
380                     desc_tvb, 4, 8, text);
381             proto_item_append_text(item, "%s", text);
382             break;
383         case FIP_DT_FAB:
384             subtree = proto_item_add_subtree(item, ett_fip_dt_fab);
385             fip_desc_type_len(subtree, desc_tvb);
386             proto_tree_add_item(subtree, hf_fip_desc_fab_vfid, desc_tvb,
387                     2, 2, FALSE);
388             text = fc_to_str(tvb_get_ptr(desc_tvb, 5, 3));
389             proto_tree_add_string(subtree, hf_fip_desc_fab_map, desc_tvb,
390                     5, 3, text);
391             text = fcwwn_to_str(tvb_get_ptr(desc_tvb, 8, 8));
392             proto_tree_add_string(subtree, hf_fip_desc_fab_name,
393                     desc_tvb, 8, 8, text);
394             proto_item_append_text(item, "%s", text);
395             break;
396         case FIP_DT_FCOE_SIZE:
397             subtree = proto_item_add_subtree(item, ett_fip_dt_mdl);
398             fip_desc_type_len(subtree, desc_tvb);
399             proto_tree_add_item(subtree, hf_fip_desc_fcoe_size, desc_tvb,
400                     2, 2, FALSE);
401             proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2));
402             break;
403         case FIP_DT_FLOGI:
404         case FIP_DT_FDISC:
405         case FIP_DT_LOGO:
406         case FIP_DT_ELP:
407             subtree = proto_item_add_subtree(item, ett_fip_dt_caps);
408             fip_desc_type_len(subtree, desc_tvb);
409             ls_tvb = tvb_new_subset(desc_tvb, 4, dlen - 4, -1);
410             call_dissector(fc_handle, ls_tvb, pinfo, subtree);
411             proto_item_append_text(item, "%u bytes", dlen - 4);
412             break;
413         case FIP_DT_VN:
414             subtree = proto_item_add_subtree(item, ett_fip_dt_vn);
415             fip_desc_type_len(subtree, desc_tvb);
416             proto_tree_add_item(subtree, hf_fip_desc_vn_mac, desc_tvb,
417                     2, 6, FALSE);
418             proto_tree_add_item(subtree, hf_fip_desc_vn_fid, desc_tvb,
419                     9, 3, FALSE);
420             text = fcwwn_to_str(tvb_get_ptr(desc_tvb, 12, 8));
421             proto_tree_add_string(subtree, hf_fip_desc_vn_wwpn,
422                     desc_tvb, 12, 8, text);
423             proto_item_append_text(item, "MAC %s  FC_ID %6.6x",
424                     tvb_bytes_to_str_punct(desc_tvb, 2, 6, ':'),
425                     tvb_get_ntoh24(desc_tvb, 9));
426             break;
427         case FIP_DT_FKA:
428             subtree = proto_item_add_subtree(item, ett_fip_dt_fka);
429             fip_desc_type_len(subtree, desc_tvb);
430             val = tvb_get_ntohl(desc_tvb, 4);
431             proto_tree_add_uint_format_value(subtree, hf_fip_desc_fka,
432                     desc_tvb, 4, 4, val, "%u ms", val);
433             proto_item_append_text(item, "%u ms", val);
434             break;
435         case FIP_DT_VEND:
436             subtree = proto_item_add_subtree(item, ett_fip_dt_vend);
437             fip_desc_type_len(subtree, desc_tvb);
438             proto_tree_add_item(subtree, hf_fip_desc_vend, desc_tvb,
439                     4, 8, FALSE);
440             if (tvb_bytes_exist(desc_tvb, 9, -1)) {
441                 proto_tree_add_item(subtree, hf_fip_desc_vend_data,
442                      desc_tvb, 9, -1, FALSE);
443             }
444             break;
445         case FIP_DT_VLAN:
446             subtree = proto_item_add_subtree(item, ett_fip_dt_vlan);
447             fip_desc_type_len(subtree, desc_tvb);
448             proto_tree_add_item(subtree, hf_fip_desc_vlan, desc_tvb,
449                     2, 2, FALSE);
450             proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2));
451             break;
452         default:
453             subtree = proto_item_add_subtree(item, ett_fip_dt_unk);
454             fip_desc_type_len(subtree, desc_tvb);
455             proto_tree_add_item(subtree, hf_fip_desc_unk, desc_tvb,
456                     2, -1, FALSE);
457             break;
458         }
459     }
460 }
461
462 void
463 proto_register_fip(void)
464 {
465     /* Setup list of header fields  See Section 1.6.1 for details*/
466     static hf_register_info hf[] = {
467         /*
468          * FIP header fields.
469          */
470         { &hf_fip_ver,
471           {"Version", "fip.ver", FT_UINT8, BASE_DEC,
472             NULL, 0xf0, NULL, HFILL}},
473         { &hf_fip_op,
474           {"Opcode", "fip.opcode", FT_UINT16, BASE_HEX,
475            VALS(fip_opcodes), 0, NULL, HFILL}},
476         { &hf_fip_disc_subcode,
477           {"Discovery Subcode", "fip.disc_subcode", FT_UINT8, BASE_HEX,
478            VALS(fip_disc_subcodes), 0, NULL, HFILL}},
479         { &hf_fip_ls_subcode,
480           {"Link Service Subcode", "fip.ls.subcode", FT_UINT8, BASE_HEX,
481            VALS(fip_ls_subcodes), 0, NULL, HFILL}},
482         { &hf_fip_ctrl_subcode,
483           {"Control Subcode", "fip.ctrl_subcode", FT_UINT8, BASE_HEX,
484            VALS(fip_ctrl_subcodes), 0, NULL, HFILL}},
485         { &hf_fip_vlan_subcode,
486           {"VLAN Subcode", "fip.vlan_subcode", FT_UINT8, BASE_HEX,
487            VALS(fip_vlan_subcodes), 0, NULL, HFILL}},
488         { &hf_fip_hex_subcode,
489           {"Unknown Subcode", "fip.subcode", FT_UINT8, BASE_HEX,
490            NULL, 0, NULL, HFILL}},
491         { &hf_fip_dlen,
492           {"Length of Descriptors (words)", "fip.dl_len", FT_UINT16, BASE_DEC,
493             NULL, 0, NULL, HFILL}},
494         { &hf_fip_flags,
495           {"Flags", "fip.flags", FT_UINT16, BASE_HEX,
496             NULL, 0, NULL, HFILL}},
497         { &hf_fip_flag_fpma,
498           {"Fabric Provided MAC addr", "fip.flags.fpma", FT_BOOLEAN, 16,
499             NULL, FIP_FL_FPMA, NULL, HFILL}},
500         { &hf_fip_flag_spma,
501           {"Server Provided MAC addr", "fip.flags.spma", FT_BOOLEAN, 16,
502             NULL, FIP_FL_SPMA, NULL, HFILL}},
503         { &hf_fip_flag_avail,
504           {"Available", "fip.flags.available", FT_BOOLEAN, 16,
505             NULL, FIP_FL_AVAIL, NULL, HFILL}},
506         { &hf_fip_flag_sol,
507           {"Solicited", "fip.flags.sol", FT_BOOLEAN, 16,
508             NULL, FIP_FL_SOL, NULL, HFILL}},
509         { &hf_fip_flag_fport,
510           {"F_Port", "fip.flags.fport", FT_BOOLEAN, 16,
511             NULL, FIP_FL_FPORT, NULL, HFILL}},
512         { &hf_fip_desc_type,
513           {"Descriptor Type", "fip.desc_type", FT_UINT8, BASE_HEX,
514             VALS(fip_desc_types), 0, NULL, HFILL}},
515         { &hf_fip_desc_len,
516           {"Descriptor Length (words)", "fip.desc_len", FT_UINT8, BASE_DEC,
517             NULL, 0, NULL, HFILL}},
518         /*
519          * Various descriptor fields.
520          */
521         { &hf_fip_desc_pri,
522           {"Priority", "fip.pri", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL}},
523         { &hf_fip_desc_mac,
524           {"MAC Address", "fip.mac", FT_ETHER, BASE_NONE, NULL,
525             0, NULL, HFILL}},
526         { &hf_fip_desc_map,
527           {"FC-MAP-OUI", "fip.map", FT_STRING, BASE_NONE, NULL,
528             0, NULL, HFILL}},
529         { &hf_fip_desc_name,
530           {"Switch or Node Name", "fip.name", FT_STRING, BASE_NONE, NULL,
531             0, NULL, HFILL}},
532         { &hf_fip_desc_fab_vfid,
533           {"VFID", "fip.fab.vfid", FT_UINT16, BASE_DEC, NULL,
534             0, NULL, HFILL}},
535         { &hf_fip_desc_fab_map,
536           {"FC-MAP", "fip.fab.map", FT_STRING, BASE_NONE, NULL,
537             0, NULL, HFILL}},
538         { &hf_fip_desc_fab_name,
539           {"Fabric Name", "fip.fab.name", FT_STRING, BASE_NONE, NULL,
540             0, NULL, HFILL}},
541         { &hf_fip_desc_fcoe_size,
542           {"Max FCoE frame size", "fip.fcoe_size", FT_UINT16, BASE_DEC, NULL,
543             0, NULL, HFILL}},
544         { &hf_fip_desc_vn_mac,
545           {"VN_Port MAC Address", "fip.vn.mac", FT_ETHER, BASE_NONE, NULL,
546             0, NULL, HFILL}},
547         { &hf_fip_desc_vn_fid,
548           {"VN_Port FC_ID", "fip.vn.fc_id", FT_UINT32, BASE_HEX, NULL,
549             0, NULL, HFILL}},
550         { &hf_fip_desc_vn_wwpn,
551           {"Port Name", "fip.vn.pwwn", FT_STRING, BASE_NONE, NULL,
552             0, NULL, HFILL}},
553         { &hf_fip_desc_fka,
554           {"FKA_ADV_Period", "fip.fka", FT_UINT32, BASE_DEC, NULL,
555             0, NULL, HFILL}},
556         { &hf_fip_desc_vend,
557           {"Vendor-ID", "fip.vendor", FT_BYTES, BASE_NONE, NULL,
558             0, NULL, HFILL}},
559         { &hf_fip_desc_vend_data,
560           {"Vendor-specific data", "fip.vendor.data", FT_BYTES, BASE_NONE, NULL,
561             0, NULL, HFILL}},
562         { &hf_fip_desc_vlan,
563           {"VLAN", "fip.vlan", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL}},
564         { &hf_fip_desc_unk,
565           {"Unknown Descriptor", "fip.desc", FT_BYTES, BASE_NONE, NULL,
566             0, NULL, HFILL}}
567     };
568     static gint *ett[] = {
569         &ett_fip,
570         &ett_fip_flags,
571         &ett_fip_dt_pri,
572         &ett_fip_dt_mac,
573         &ett_fip_dt_map,
574         &ett_fip_dt_name,
575         &ett_fip_dt_fab,
576         &ett_fip_dt_mdl,
577         &ett_fip_dt_caps,
578         &ett_fip_dt_vn,
579         &ett_fip_dt_fka,
580         &ett_fip_dt_vend,
581         &ett_fip_dt_vlan,
582         &ett_fip_dt_unk
583     };
584
585     /* Register the protocol name and description */
586     proto_fip = proto_register_protocol("FCoE Initialization Protocol",
587         "FIP", "fip");
588
589     /* Required function calls to register the header fields and
590      * subtrees used */
591     proto_register_field_array(proto_fip, hf, array_length(hf));
592     proto_register_subtree_array(ett, array_length(ett));
593 }
594
595 /*
596  * This function name is required because a script is used to find these
597  * routines and create the code that calls these routines.
598  */
599 void
600 proto_reg_handoff_fip(void)
601 {
602     dissector_handle_t fip_handle;
603
604     fip_handle = create_dissector_handle(dissect_fip, proto_fip);
605     dissector_add("ethertype", ETHERTYPE_FIP, fip_handle);
606     fc_handle = find_dissector("fc");
607 }