From Kovarththanan Rajaratnam via bug 3548:
[obnox/wireshark/wip.git] / epan / dissectors / packet-fcsp.c
1 /* packet-fc-sp.c
2  * Routines for Fibre Channel Security Protocol (FC-SP)
3  * This decoder is for FC-SP version 1.1
4  * Copyright 2003, Dinesh G Dutt <ddutt@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  * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED"
13  * is a dissector file; if you just copied this from README.developer,
14  * don't bother with the "Copied from" - you don't even need to put
15  * in a "Copied from" if you copied an existing dissector, especially
16  * if the bulk of the code in the new dissector is your code)
17  * 
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  * 
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  * 
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40
41 #ifdef HAVE_SYS_TYPES_H
42 # include <sys/types.h>
43 #endif
44
45 #ifdef HAVE_NETINET_IN_H
46 # include <netinet/in.h>
47 #endif
48
49 #include <glib.h>
50
51 #include <epan/packet.h>
52 #include <epan/conversation.h>
53 #include <epan/etypes.h>
54 #include "packet-scsi.h"
55 #include "packet-fc.h"
56
57 /* Message Codes */
58 #define FC_AUTH_MSG_AUTH_REJECT        0x0A 
59 #define FC_AUTH_MSG_AUTH_NEGOTIATE     0x0B 
60 #define FC_AUTH_MSG_AUTH_DONE          0x0C 
61 #define FC_AUTH_DHCHAP_CHALLENGE       0x10 
62 #define FC_AUTH_DHCHAP_REPLY           0x11 
63 #define FC_AUTH_DHCHAP_SUCCESS         0x12 
64 #define FC_AUTH_FCAP_REQUEST           0x13 
65 #define FC_AUTH_FCAP_ACKNOWLEDGE       0x14 
66 #define FC_AUTH_FCAP_CONFIRM           0x15 
67 #define FC_AUTH_FCPAP_INIT             0x16 
68 #define FC_AUTH_FCPAP_ACCEPT           0x17 
69 #define FC_AUTH_FCPAP_COMPLETE         0x18
70
71 #define FC_AUTH_NAME_TYPE_WWN          0x1
72
73 #define FC_AUTH_PROTO_TYPE_DHCHAP      0x1
74 #define FC_AUTH_PROTO_TYPE_FCAP        0x2
75
76 #define FC_AUTH_DHCHAP_HASH_MD5        0x5
77 #define FC_AUTH_DHCHAP_HASH_SHA1       0x6
78
79 #define FC_AUTH_DHCHAP_PARAM_HASHLIST  0x1
80 #define FC_AUTH_DHCHAP_PARAM_DHgIDLIST 0x2
81
82 /* Initialize the protocol and registered fields */
83 static int proto_fcsp              = -1;
84 static int hf_auth_proto_ver       = -1;
85 static int hf_auth_msg_code        = -1;
86 static int hf_auth_flags           = -1;
87 static int hf_auth_len             = -1;
88 static int hf_auth_tid             = -1;
89 static int hf_auth_initiator_wwn   = -1;
90 static int hf_auth_initiator_name  = -1;
91 static int hf_auth_usable_proto    = -1;
92 static int hf_auth_rjt_code        = -1;
93 static int hf_auth_rjt_codedet     = -1;
94 static int hf_auth_responder_wwn   = -1;
95 static int hf_auth_responder_name  = -1;
96 static int hf_auth_dhchap_groupid  = -1;
97 static int hf_auth_dhchap_hashid   = -1;
98 static int hf_auth_dhchap_chal_len = -1;
99 static int hf_auth_dhchap_val_len  = -1;
100 static int hf_auth_dhchap_rsp_len  = -1;
101 static int hf_auth_initiator_name_type = -1;
102 static int hf_auth_initiator_name_len = -1;
103 static int hf_auth_responder_name_len = -1;
104 static int hf_auth_responder_name_type = -1;
105 static int hf_auth_proto_type = -1;
106 static int hf_auth_proto_param_len = -1;
107 static int hf_auth_dhchap_param_tag = -1;
108 static int hf_auth_dhchap_param_len = -1;
109 static int hf_auth_dhchap_hash_type = -1;
110 static int hf_auth_dhchap_group_type = -1;
111 static int hf_auth_dhchap_dhvalue = -1;
112 static int hf_auth_dhchap_chal_value = -1;
113 static int hf_auth_dhchap_rsp_value = -1;
114
115 /* Initialize the subtree pointers */
116 static gint ett_fcsp = -1;
117
118 static dissector_handle_t data_handle;
119
120 static const value_string fcauth_msgcode_vals[] = {
121     {FC_AUTH_MSG_AUTH_REJECT, "AUTH_Reject"},
122     {FC_AUTH_MSG_AUTH_NEGOTIATE, "AUTH_Negotiate"},
123     {FC_AUTH_MSG_AUTH_DONE, "AUTH_Done"},
124     {FC_AUTH_DHCHAP_CHALLENGE, "DHCHAP_Challenge"},
125     {FC_AUTH_DHCHAP_REPLY, "DHCHAP_Reply"},
126     {FC_AUTH_DHCHAP_SUCCESS, "DHCHAP_Success"},
127     {FC_AUTH_FCAP_REQUEST, "FCAP_Request"},
128     {FC_AUTH_FCAP_ACKNOWLEDGE, "FCAP_Acknowledge"},
129     {FC_AUTH_FCAP_CONFIRM, "FCAP_Confirm"},
130     {FC_AUTH_FCPAP_INIT, "FCPAP_Init"},
131     {FC_AUTH_FCPAP_ACCEPT, "FCPAP_Accept"},
132     {FC_AUTH_FCPAP_COMPLETE, "FCPAP_Complete"},
133     {0, NULL},
134 };
135
136 static const value_string fcauth_rjtcode_vals[] = {
137     {0x01, "Authentication Failure"},
138     {0x02, "Logical Error"},
139     {0, NULL},
140 };
141
142 static const value_string fcauth_rjtcode_detail_vals[] = {
143     {0x01, "Authentication Mechanism Not Usable"},
144     {0x02, "DH Group Not Usable"},
145     {0x03, "Hash Algorithm Not Usable"},
146     {0x04, "Authentication Protocol Instance Already Started"},
147     {0x05, "Authentication Failed "},
148     {0x06, "Incorrect Payload "},
149     {0x07, "Incorrect Authentication Protocol Message"},
150     {0x08, "Protocol Reset"},
151     {0, NULL},
152 };
153
154 static const value_string fcauth_dhchap_param_vals[] = {
155     {FC_AUTH_DHCHAP_PARAM_HASHLIST, "HashList"},
156     {FC_AUTH_DHCHAP_PARAM_DHgIDLIST, "DHgIDList"},
157     {0, NULL},
158 };
159
160 static const value_string fcauth_dhchap_hash_algo_vals[] = {
161     {FC_AUTH_DHCHAP_HASH_MD5, "MD5"},
162     {FC_AUTH_DHCHAP_HASH_SHA1, "SHA-1"},
163     {0, NULL},
164 };
165
166 static const value_string fcauth_name_type_vals[] = {
167     {FC_AUTH_NAME_TYPE_WWN, "WWN"},
168     {0, NULL},
169 };
170
171 static const value_string fcauth_proto_type_vals[] = {
172     {FC_AUTH_PROTO_TYPE_DHCHAP, "DHCHAP"},
173     {FC_AUTH_PROTO_TYPE_FCAP, "FCAP"},
174     {0, NULL},
175 };
176
177 static const value_string fcauth_dhchap_dhgid_vals[] = {
178     {0, "DH NULL"},
179     {1, "DH Group 1024"},
180     {2, "DH Group 1280"},
181     {3, "DH Group 1536"},
182     {4, "DH Group 2048"},
183     {0, NULL},
184 };
185
186 /* this format is required because a script is used to build the C function
187    that calls all the protocol registration.
188 */
189
190 static void dissect_fcsp_dhchap_auth_param (tvbuff_t *tvb, proto_tree *tree,
191                                      int offset, gint32 total_len)
192 {
193     guint16 auth_param_tag;
194     guint16 param_len = 0, i;
195     
196     if (tree) {
197         auth_param_tag = tvb_get_ntohs (tvb, offset);
198         total_len -= 4;
199         
200         while (total_len > 0) {
201             proto_tree_add_item (tree, hf_auth_dhchap_param_tag, tvb, offset,
202                                  2, 0);
203             proto_tree_add_item (tree, hf_auth_dhchap_param_len, tvb, offset+2,
204                                  2, 0);
205
206             auth_param_tag = tvb_get_ntohs (tvb, offset);
207             param_len = tvb_get_ntohs (tvb, offset+2)*4;
208
209             switch (auth_param_tag) {
210             case FC_AUTH_DHCHAP_PARAM_HASHLIST:
211                 offset += 4;
212                 total_len -= 4;
213                 for (i = 0; i < param_len; i += 4) {
214                     proto_tree_add_item (tree, hf_auth_dhchap_hash_type, tvb,
215                                          offset, 4, 0);
216                     offset += 4;
217                 }
218                 break;
219             case FC_AUTH_DHCHAP_PARAM_DHgIDLIST:
220                 offset += 4;
221                 total_len -= 4;
222                 for (i = 0; i < param_len; i += 4) {
223                     proto_tree_add_item (tree, hf_auth_dhchap_group_type, tvb,
224                                          offset, 4, 0);
225                     offset += 4;
226                 }
227                 break;
228             default:
229                 break;
230             }
231
232             total_len -= param_len;
233         }
234     }
235 }
236
237 static void dissect_fcsp_dhchap_challenge (tvbuff_t *tvb, proto_tree *tree)
238 {
239     int offset = 12;
240     guint16 name_type;
241     guint16 param_len, name_len;
242     
243     if (tree) {
244         proto_tree_add_item (tree, hf_auth_responder_name_type, tvb, offset,
245                              2, 0);
246         name_type = tvb_get_ntohs (tvb, offset);
247
248         proto_tree_add_item (tree, hf_auth_responder_name_len, tvb, offset+2,
249                              2, 0);
250
251         name_len = tvb_get_ntohs (tvb, offset+2);
252         
253         if (name_type == FC_AUTH_NAME_TYPE_WWN) {
254             proto_tree_add_string (tree, hf_auth_responder_wwn, tvb, offset+4,
255                                    8,
256                                    fcwwn_to_str (tvb_get_ptr (tvb, offset+4,
257                                                               8)));
258         }
259         else {
260             proto_tree_add_bytes (tree, hf_auth_responder_name, tvb, offset+4,
261                                   name_len, tvb_get_ptr (tvb, offset+4, name_len));
262         }
263         offset += (4+name_len);
264         
265         proto_tree_add_item (tree, hf_auth_dhchap_hash_type, tvb, offset,
266                              4, 0);
267         proto_tree_add_item (tree, hf_auth_dhchap_group_type, tvb, offset+4,
268                              4, 0);
269         proto_tree_add_item (tree, hf_auth_dhchap_chal_len, tvb, offset+8,
270                              4, 0);
271         param_len = tvb_get_ntohl (tvb, offset+8);
272         
273         proto_tree_add_bytes (tree, hf_auth_dhchap_chal_value, tvb, offset+12,
274                               param_len,
275                               tvb_get_ptr (tvb, offset+12, param_len));
276         offset += (param_len + 12);
277
278         proto_tree_add_item (tree, hf_auth_dhchap_val_len, tvb, offset, 4, 0);
279         param_len = tvb_get_ntohl (tvb, offset);
280         
281         proto_tree_add_bytes (tree, hf_auth_dhchap_dhvalue, tvb, offset+4,
282                               param_len,
283                               tvb_get_ptr (tvb, offset+4, param_len));
284     }
285 }
286
287
288 static void dissect_fcsp_dhchap_reply (tvbuff_t *tvb, proto_tree *tree)
289 {
290     int offset = 12;
291     guint32 param_len;
292     
293     if (tree) {
294         proto_tree_add_item (tree, hf_auth_dhchap_rsp_len, tvb, offset, 4, 0);
295         param_len = tvb_get_ntohl (tvb, offset);
296
297         proto_tree_add_bytes (tree, hf_auth_dhchap_rsp_value, tvb, offset+4,
298                               param_len,
299                               tvb_get_ptr (tvb, offset+4, param_len));
300         offset += (param_len + 4);
301
302         proto_tree_add_item (tree, hf_auth_dhchap_val_len, tvb, offset, 4, 0);
303         param_len = tvb_get_ntohl (tvb, offset);
304
305         proto_tree_add_bytes (tree, hf_auth_dhchap_dhvalue, tvb, offset+4,
306                               param_len,
307                               tvb_get_ptr (tvb, offset+4, param_len));
308         offset += (param_len + 4);
309
310         proto_tree_add_item (tree, hf_auth_dhchap_chal_len, tvb, offset, 4, 0);
311         param_len = tvb_get_ntohl (tvb, offset);
312
313         proto_tree_add_bytes (tree, hf_auth_dhchap_chal_value, tvb, offset+4,
314                               param_len,
315                               tvb_get_ptr (tvb, offset+4, param_len));
316     }
317 }
318
319 static void dissect_fcsp_dhchap_success (tvbuff_t *tvb, proto_tree *tree)
320 {
321     int offset = 12;
322     guint32 param_len;
323     
324     if (tree) {
325         proto_tree_add_item (tree, hf_auth_dhchap_rsp_len, tvb, offset, 4, 0);
326         param_len = tvb_get_ntohl (tvb, offset);
327
328         proto_tree_add_bytes (tree, hf_auth_dhchap_rsp_value, tvb, offset+4,
329                               param_len,
330                               tvb_get_ptr (tvb, offset+4, param_len));
331     }
332 }
333
334
335 static void dissect_fcsp_auth_negotiate (tvbuff_t *tvb, proto_tree *tree)
336 {
337     int offset = 12;
338     guint16 name_type, name_len, proto_type, param_len;
339     guint32 num_protos, i;
340
341     if (tree) {
342         proto_tree_add_item (tree, hf_auth_initiator_name_type, tvb, offset,
343                              2, 0);
344         name_type = tvb_get_ntohs (tvb, offset);
345
346         proto_tree_add_item (tree, hf_auth_initiator_name_len, tvb, offset+2,
347                              2, 0);
348         name_len = tvb_get_ntohs (tvb, offset+2);
349
350         if (name_type == FC_AUTH_NAME_TYPE_WWN) {
351             proto_tree_add_string (tree, hf_auth_initiator_wwn, tvb, offset+4, 8,
352                                    fcwwn_to_str (tvb_get_ptr (tvb, offset+4, 8)));
353         }
354         else {
355             proto_tree_add_bytes (tree, hf_auth_initiator_name, tvb, offset+4,
356                                   name_len, tvb_get_ptr (tvb, offset+4,
357                                                          name_len));
358         }
359
360         offset += (4+name_len);
361
362         proto_tree_add_item (tree, hf_auth_usable_proto, tvb, offset, 4, 0);
363         num_protos = tvb_get_ntohl (tvb, offset);
364         offset += 4;
365         
366         for (i = 0; i < num_protos; i++) {
367             proto_tree_add_item (tree, hf_auth_proto_param_len, tvb, offset, 4, 0);
368             param_len = tvb_get_ntohl (tvb, offset);
369             offset += 4;
370             
371             if (tvb_bytes_exist (tvb, offset, param_len)) {
372                 proto_type = tvb_get_ntohl (tvb, offset);
373
374                 proto_tree_add_item (tree, hf_auth_proto_type, tvb, offset, 4, 0);
375                 switch (proto_type) {
376                 case FC_AUTH_PROTO_TYPE_DHCHAP:
377                     dissect_fcsp_dhchap_auth_param (tvb, tree, offset+4, param_len);
378                     break;
379                 case FC_AUTH_PROTO_TYPE_FCAP:
380                     break;
381                 default:
382                     break;
383                 }
384             }
385             offset += param_len;
386         }
387     }
388 }
389
390 static void dissect_fcsp_auth_done (tvbuff_t *tvb _U_, proto_tree *tree _U_)
391 {
392 }
393
394 static void dissect_fcsp_auth_rjt (tvbuff_t *tvb, proto_tree *tree)
395 {
396     int offset = 12;
397     
398     if (tree) {
399         proto_tree_add_item (tree, hf_auth_rjt_code, tvb, offset, 1, 0);
400         proto_tree_add_item (tree, hf_auth_rjt_codedet, tvb, offset+1, 1, 0);
401     }
402 }
403
404 static void dissect_fcsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
405 {
406     proto_item *ti = NULL;
407     guint8 opcode;
408     int offset = 0;
409     proto_tree *fcsp_tree = NULL;
410
411     /* Make entry in the Info column on summary display */
412     opcode = tvb_get_guint8 (tvb, 2);
413
414     if (check_col (pinfo->cinfo, COL_INFO)) {
415         col_add_str (pinfo->cinfo, COL_INFO,
416                      val_to_str (opcode, fcauth_msgcode_vals, "0x%x"));
417     }
418     
419     if (tree) {
420         ti = proto_tree_add_protocol_format (tree, proto_fcsp, tvb, 0,
421                                              tvb_length (tvb), "FC-SP");
422         fcsp_tree = proto_item_add_subtree (ti, ett_fcsp);
423
424         proto_tree_add_item (fcsp_tree, hf_auth_flags, tvb, offset+1, 1, 0);
425         proto_tree_add_item (fcsp_tree, hf_auth_msg_code, tvb, offset+2, 1, 0);
426         proto_tree_add_item (fcsp_tree, hf_auth_proto_ver, tvb, offset+3, 1,
427                              0);
428         proto_tree_add_item (fcsp_tree, hf_auth_len, tvb, offset+4, 4, 0);
429         proto_tree_add_item (fcsp_tree, hf_auth_tid, tvb, offset+8, 4, 0);
430
431         switch (opcode) {
432         case FC_AUTH_MSG_AUTH_REJECT:
433             dissect_fcsp_auth_rjt (tvb, tree);
434             break;
435         case FC_AUTH_MSG_AUTH_NEGOTIATE:
436             dissect_fcsp_auth_negotiate (tvb, tree);
437             break;
438         case FC_AUTH_MSG_AUTH_DONE:
439             dissect_fcsp_auth_done (tvb, tree);
440             break;
441         case FC_AUTH_DHCHAP_CHALLENGE:
442             dissect_fcsp_dhchap_challenge (tvb, tree);
443             break;
444         case FC_AUTH_DHCHAP_REPLY:
445             dissect_fcsp_dhchap_reply (tvb, tree);
446             break;
447         case FC_AUTH_DHCHAP_SUCCESS:
448             dissect_fcsp_dhchap_success (tvb, tree);
449             break;
450         case FC_AUTH_FCAP_REQUEST:
451         case FC_AUTH_FCAP_ACKNOWLEDGE:
452         case FC_AUTH_FCAP_CONFIRM:
453         case FC_AUTH_FCPAP_INIT:
454         case FC_AUTH_FCPAP_ACCEPT:
455         case FC_AUTH_FCPAP_COMPLETE:
456             proto_tree_add_text (fcsp_tree, tvb, offset+12, tvb_length (tvb),
457                                  "FCAP Decoding Not Supported");
458             break;
459         default:
460             break;
461         }
462     }
463 }
464
465 void
466 proto_register_fcsp (void)
467 {                 
468     /* Setup list of header fields  See Section 1.6.1 for details*/
469     static hf_register_info hf[] = {
470         { &hf_auth_proto_ver,
471           {"Protocol Version", "fcsp.version", FT_UINT8, BASE_HEX, NULL,
472            0x0, NULL, HFILL}},
473         { &hf_auth_msg_code,
474           {"Message Code", "fcsp.opcode", FT_UINT8, BASE_HEX,
475            VALS (fcauth_msgcode_vals), 0x0, NULL, HFILL}},
476         { &hf_auth_flags,
477           {"Flags", "fcsp.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL,
478            HFILL}},
479         { &hf_auth_len,
480           {"Packet Length", "fcsp.len", FT_UINT32, BASE_DEC, NULL, 0x0,
481            NULL, HFILL}},
482         { &hf_auth_tid,
483           {"Transaction Identifier", "fcsp.tid", FT_UINT32, BASE_HEX, NULL,
484            0x0, NULL, HFILL}},
485         { &hf_auth_initiator_wwn,
486           {"Initiator Name (WWN)", "fcsp.initwwn", FT_STRING, BASE_NONE, NULL,
487            0x0, NULL, HFILL}},
488         { &hf_auth_initiator_name,
489           {"Initiator Name (Unknown Type)", "fcsp.initname", FT_BYTES,
490            BASE_NONE, NULL, 0x0, NULL, HFILL}},
491         { &hf_auth_initiator_name_type,
492           {"Initiator Name Type", "fcsp.initnametype", FT_UINT16, BASE_HEX,
493            VALS (fcauth_name_type_vals), 0x0, NULL, HFILL}},
494         { &hf_auth_initiator_name_len,
495           {"Initiator Name Length", "fcsp.initnamelen", FT_UINT16, BASE_DEC,
496            NULL, 0x0, NULL, HFILL}},
497         { &hf_auth_usable_proto,
498           {"Number of Usable Protocols", "fcsp.usableproto", FT_UINT32,
499            BASE_DEC, NULL, 0x0, NULL, HFILL}},
500         { &hf_auth_rjt_code,
501           {"Reason Code", "fcsp.rjtcode", FT_UINT8, BASE_DEC,
502            VALS (fcauth_rjtcode_vals), 0x0, NULL, HFILL}},
503         { &hf_auth_rjt_codedet,
504           {"Reason Code Explanation", "fcsp.rjtcodet", FT_UINT8, BASE_DEC,
505            VALS (fcauth_rjtcode_detail_vals), 0x0, NULL, HFILL}},
506         { &hf_auth_responder_wwn,
507           {"Responder Name (WWN)", "fcsp.rspwwn", FT_STRING, BASE_NONE, NULL,
508            0x0, NULL, HFILL}},
509         { &hf_auth_responder_name,
510           {"Responder Name (Unknown Type)", "fcsp.rspname", FT_BYTES, BASE_NONE,
511            NULL, 0x0, NULL, HFILL}},
512         { &hf_auth_responder_name_type,
513           {"Responder Name Type", "fcsp.rspnametype", FT_UINT16, BASE_HEX,
514            VALS (fcauth_name_type_vals), 0x0, NULL, HFILL}},
515         { &hf_auth_responder_name_len,
516           {"Responder Name Type", "fcsp.rspnamelen", FT_UINT16, BASE_DEC,
517            NULL, 0x0, NULL, HFILL}},
518         { &hf_auth_dhchap_hashid,
519           {"Hash Identifier", "fcsp.dhchap.hashid", FT_UINT32, BASE_HEX, NULL, 0x0,
520            NULL, HFILL}},
521         { &hf_auth_dhchap_groupid,
522           {"DH Group Identifier", "fcsp.dhchap.groupid", FT_UINT32, BASE_HEX, NULL,
523            0x0, NULL, HFILL}},
524         { &hf_auth_dhchap_chal_len,
525           {"Challenge Value Length", "fcsp.dhchap.challen", FT_UINT32, BASE_DEC,
526            NULL, 0x0, NULL, HFILL}},
527         { &hf_auth_dhchap_val_len,
528           {"DH Value Length", "fcsp.dhchap.vallen", FT_UINT32, BASE_DEC, NULL,
529            0x0, NULL, HFILL}},
530         { &hf_auth_dhchap_rsp_len,
531           {"Response Value Length", "fcsp.dhchap.rsplen", FT_UINT32, BASE_DEC,
532            NULL, 0x0, NULL, HFILL}},
533         { &hf_auth_proto_type,
534           {"Authentication Protocol Type", "fcsp.proto", FT_UINT32, BASE_DEC,
535            VALS (fcauth_proto_type_vals), 0x0, NULL, HFILL}},
536         { &hf_auth_proto_param_len,
537           {"Protocol Parameters Length", "fcsp.protoparamlen", FT_UINT32,
538            BASE_DEC, NULL, 0x0, NULL, HFILL}},
539         { &hf_auth_dhchap_param_tag,
540           {"Parameter Tag", "fcsp.dhchap.paramtype", FT_UINT16, BASE_HEX,
541            VALS (fcauth_dhchap_param_vals), 0x0, NULL, HFILL}},
542         { &hf_auth_dhchap_param_len,
543           {"Parameter Length", "fcsp.dhchap.paramlen", FT_UINT16, BASE_DEC,
544            NULL, 0x0, NULL, HFILL}},
545         { &hf_auth_dhchap_hash_type,
546           {"Hash Algorithm", "fcsp.dhchap.hashtype", FT_UINT32, BASE_DEC,
547            VALS (fcauth_dhchap_hash_algo_vals), 0x0, NULL, HFILL}},
548         { &hf_auth_dhchap_group_type,
549           {"DH Group", "fcsp.dhchap.dhgid", FT_UINT32, BASE_DEC,
550            VALS (fcauth_dhchap_dhgid_vals), 0x0, NULL, HFILL}},
551         { &hf_auth_dhchap_chal_value,
552           {"Challenge Value", "fcsp.dhchap.chalval", FT_BYTES, BASE_NONE,
553            NULL, 0x0, NULL, HFILL}},
554         { &hf_auth_dhchap_dhvalue,
555           {"DH Value", "fcsp.dhchap.dhvalue", FT_BYTES, BASE_NONE, NULL, 0x0,
556            NULL, HFILL}},
557         { &hf_auth_dhchap_rsp_value,
558           {"Response Value", "fcsp.dhchap.rspval", FT_BYTES, BASE_NONE, NULL,
559            0x0, NULL, HFILL}},
560           
561     };
562
563
564     /* Setup protocol subtree array */
565     static gint *ett[] = {
566         &ett_fcsp,
567     };
568
569     /* Register the protocol name and description */
570     proto_fcsp = proto_register_protocol ("Fibre Channel Security Protocol",
571                                            "FC-SP", "fcsp");
572
573     register_dissector("fcsp", dissect_fcsp, proto_fcsp);
574     /* Required function calls to register the header fields and subtrees used */
575     proto_register_field_array(proto_fcsp, hf, array_length(hf));
576     proto_register_subtree_array(ett, array_length(ett));
577 }
578
579 /* If this dissector uses sub-dissector registration add a registration routine.
580    This format is required because a script is used to find these routines and
581    create the code that calls these routines.
582 */
583 void
584 proto_reg_handoff_fcsp (void)
585 {
586     data_handle = find_dissector ("data");
587 }
588