As the gtk2 directory is no longer needed (GTK1 and 2 are using the same sources...
[obnox/wireshark/wip.git] / epan / dissectors / packet-isns.c
1 /* XXX fixme   can not reassemple multiple isns PDU fragments into one
2   isns PDU
3 */
4
5 /* packet-isns.c
6  * Routines for iSNS dissection
7  * Copyright 2003, Elipsan, Gareth Bushell <gbushell@elipsan.com>
8  * (c) 2004 Ronnie Sahlberg   updates
9  *
10  * $Id$
11  *
12  * Ethereal - Network traffic analyzer
13  * By Gerald Combs <gerald@ethereal.com>
14  * Copyright 1998 Gerald Combs
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * 
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29  */
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #ifdef HAVE_SYS_TYPES_H
40 # include <sys/types.h>
41 #endif
42
43 #ifdef HAVE_NETINET_IN_H
44 # include <netinet/in.h>
45 #endif
46
47 #include <glib.h>
48
49 #ifdef NEED_SNPRINTF_H
50 # include "snprintf.h"
51 #endif
52
53 #include <epan/packet.h>
54 #include <epan/conversation.h>
55 #include "packet-tcp.h"
56 #include "prefs.h"
57
58
59 #define ISNS_PROTO_VER 0x1
60 #define ISNS_HEADER_SIZE 12
61
62 #define ISNS_TCP_PORT 3205
63 #define ISNS_UDP_PORT 3205
64
65 #define ISNS_OTHER_PORT 0
66 #define ISNS_ESI_PORT 1
67 #define ISNS_SCN_PORT 2
68
69
70 dissector_handle_t isns_tcp_handle;
71 dissector_handle_t isns_udp_handle;
72
73 static gint ett_isns_flags = -1;
74 static gint ett_isns_payload = -1;
75 static gint ett_isns_attribute = -1;
76 static gint ett_isns_port = -1;
77 static gint ett_isns_isnt = -1;
78
79 static guint AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree,
80                           guint offset, guint16 function_id);
81
82 /* Initialize the protocol and registered fields */
83 static int proto_isns = -1;
84
85
86 /* Header Stuff */
87 static int hf_isns_version = -1;
88 static int hf_isns_function_id = -1;
89 static int hf_isns_pdu_length = -1;
90 static int hf_isns_flags = -1;
91 static int hf_isns_transaction_id = -1;
92 static int hf_isns_sequence_id = -1;
93 static int hf_isns_payload = -1;
94 static int hf_isns_first_pdu = -1;
95 static int hf_isns_last_pdu = -1;
96 static int hf_isns_replace = -1;
97 static int hf_isns_auth = -1;
98 static int hf_isns_server = -1;
99 static int hf_isns_client = -1;
100
101 /* Payload stuff */
102 static int hf_isns_scn_bitmap                                      = -1;
103 static int hf_isns_scn_bitmap_initiator_and_self_information_only  = -1;
104 static int hf_isns_scn_bitmap_target_and_self_information_only     = -1;
105 static int hf_isns_scn_bitmap_management_registration_scn          = -1;
106 static int hf_isns_scn_bitmap_object_removed                       = -1;
107 static int hf_isns_scn_bitmap_object_added                         = -1;
108 static int hf_isns_scn_bitmap_object_updated                       = -1;
109 static int hf_isns_scn_bitmap_dd_dds_member_removed                = -1;
110 static int hf_isns_scn_bitmap_dd_dds_member_added                  = -1;
111 static int hf_isns_isnt_control = -1;
112 static int hf_isns_isnt_initiator = -1;
113 static int hf_isns_isnt_target = -1;
114
115 static int hf_isns_psb = -1;
116 static int hf_isns_psb_tunnel_mode = -1;
117 static int hf_isns_psb_transport_mode = -1;
118 static int hf_isns_psb_pfs = -1;
119 static int hf_isns_psb_aggressive_mode = -1;
120 static int hf_isns_psb_main_mode = -1;
121 static int hf_isns_psb_ike_ipsec = -1;
122 static int hf_isns_psb_bitmap = -1;
123
124 static int hf_isns_dd_member_portal_port = -1;
125 static int hf_isns_portal_port = -1;
126 static int hf_isns_esi_port = -1;
127 static int hf_isns_scn_port = -1;
128 static int hf_isns_port_type = -1;
129
130 static int hf_isns_entity_protocol = -1;
131 static int hf_isns_iscsi_node_type = -1;
132 static int hf_isns_resp_errorcode = -1;
133 static int hf_isns_attr_tag = -1;
134 static int hf_isns_attr_len = -1;
135 static int hf_isns_heartbeat_ipv6_addr = -1;
136 static int hf_isns_heartbeat_udp_port = -1;
137 static int hf_isns_heartbeat_tcp_port = -1;
138 static int hf_isns_heartbeat_interval = -1;
139 static int hf_isns_heartbeat_counter = -1;
140
141 static int hf_isns_mgmt_ip_addr = -1;
142 static int hf_isns_node_ip_addr = -1;
143 static int hf_isns_port_ip_addr = -1;
144 static int hf_isns_portal_ip_addr = -1;
145 static int hf_isns_dd_member_portal_ip_addr = -1;
146 static int hf_isns_iscsi_name = -1;
147 static int hf_isns_switch_name = -1;
148 static int hf_isns_dd_member_iscsi_name = -1;
149 static int hf_isns_virtual_fabric_id = -1;
150 static int hf_isns_proxy_iscsi_name = -1;
151 static int hf_isns_fc4_descriptor = -1;
152 static int hf_isns_iscsi_auth_method = -1;
153 static int hf_isns_iscsi_alias = -1;
154 static int hf_isns_portal_symbolic_name = -1;
155 static int hf_isns_dd_set_symbolic_name = -1;
156 static int hf_isns_dd_symbolic_name = -1;
157 static int hf_isns_symbolic_port_name = -1;
158 static int hf_isns_symbolic_node_name = -1;
159 static int hf_isns_entity_identifier = -1;
160 static int hf_isns_dd_id_next_id = -1;
161 static int hf_isns_member_iscsi_index = -1;
162 static int hf_isns_member_portal_index = -1;
163 static int hf_isns_member_ifcp_node = -1;
164 static int hf_isns_vendor_oui = -1;
165 static int hf_isns_preferred_id = -1;
166 static int hf_isns_assigned_id = -1;
167 static int hf_isns_dd_id = -1;
168 static int hf_isns_dd_set_id = -1;
169 static int hf_isns_dd_set_next_id = -1;
170 static int hf_isns_node_index = -1;
171 static int hf_isns_node_next_index = -1;
172 static int hf_isns_entity_index = -1;
173 static int hf_isns_portal_index = -1;
174 static int hf_isns_portal_next_index = -1;
175 static int hf_isns_entity_next_index = -1;
176 static int hf_isns_timestamp = -1;
177 static int hf_isns_esi_interval = -1;
178 static int hf_isns_registration_period = -1;
179 static int hf_isns_port_id = -1;
180 static int hf_isns_hard_address = -1;
181 static int hf_isns_wwnn_token = -1;
182 static int hf_isns_node_ipa = -1;
183 static int hf_isns_fc_port_name_wwpn = -1;
184 static int hf_isns_fc_node_name_wwnn = -1;
185 static int hf_isns_fabric_port_name = -1;
186 static int hf_isns_permanent_port_name = -1;
187 static int hf_isns_delimiter = -1;
188 static int hf_isns_not_decoded_yet = -1;
189 static int hf_isns_portal_group_tag = -1;
190 static int hf_isns_pg_portal_ip_addr = -1;
191 static int hf_isns_pg_portal_port = -1;
192
193
194
195 /* Desegment iSNS over TCP messages */
196 static gboolean isns_desegment = TRUE;
197
198 /* Function Id's */
199 #define ISNS_FUNC_DEVATTRREG     0x0001
200 #define ISNS_FUNC_DEVATTRQRY     0x0002
201 #define ISNS_FUNC_DEVGETNEXT     0x0003
202 #define ISNS_FUNC_DEREGDEV       0x0004
203 #define ISNS_FUNC_SCNREG         0x0005
204 #define ISNS_FUNC_SCNDEREG       0x0006
205 #define ISNS_FUNC_SCNEVENT       0x0007
206 #define ISNS_FUNC_SCN            0x0008
207 #define ISNS_FUNC_DDREG          0x0009
208 #define ISNS_FUNC_DDDEREG        0x000a
209 #define ISNS_FUNC_DDSREG         0x000b
210 #define ISNS_FUNC_DDSDEREG       0x000c
211 #define ISNS_FUNC_ESI            0x000d
212 #define ISNS_FUNC_HEARTBEAT      0x000e
213
214 #define ISNS_FUNC_RSP_DEVATTRREG 0x8001
215 #define ISNS_FUNC_RSP_DEVATTRQRY 0x8002
216 #define ISNS_FUNC_RSP_DEVGETNEXT 0x8003
217 #define ISNS_FUNC_RSP_DEREGDEV   0x8004
218 #define ISNS_FUNC_RSP_SCNREG     0x8005
219 #define ISNS_FUNC_RSP_SCNDEREG   0x8006
220 #define ISNS_FUNC_RSP_SCNEVENT   0x8007
221 #define ISNS_FUNC_RSP_SCN        0x8008
222 #define ISNS_FUNC_RSP_DDREG      0x8009
223 #define ISNS_FUNC_RSP_DDDEREG    0x800a
224 #define ISNS_FUNC_RSP_DDSREG     0x800b
225 #define ISNS_FUNC_RSP_DDSDEREG   0x800c
226 #define ISNS_FUNC_RSP_ESI        0x800d
227
228 static const value_string isns_function_ids[] = {
229 /* Requests*/
230     {ISNS_FUNC_DEVATTRREG,     "DevAttrReg"},
231     {ISNS_FUNC_DEVATTRQRY,     "DevAttrQry"},
232     {ISNS_FUNC_DEVGETNEXT,     "DevGetNext"},
233     {ISNS_FUNC_DEREGDEV,       "DeregDev"},
234     {ISNS_FUNC_SCNREG,         "SCNReg"},
235     {ISNS_FUNC_SCNDEREG,       "SCNDereg"},
236     {ISNS_FUNC_SCNEVENT,       "SCNEvent"},
237     {ISNS_FUNC_SCN,            "SCN"},
238     {ISNS_FUNC_DDREG,          "DDReg"},
239     {ISNS_FUNC_DDDEREG,        "DDDereg"},
240     {ISNS_FUNC_DDSREG,         "DDSReg"},
241     {ISNS_FUNC_DDSDEREG,       "DDSDereg"},
242     {ISNS_FUNC_ESI,            "ESI"},
243     {ISNS_FUNC_HEARTBEAT,      "Heartbeat"},
244
245 /* Responses */
246     {ISNS_FUNC_RSP_DEVATTRREG, "DevAttrRegRsp"},
247     {ISNS_FUNC_RSP_DEVATTRQRY, "DevAttrQryRsp"},
248     {ISNS_FUNC_RSP_DEVGETNEXT, "DevGetNextRsp"},
249     {ISNS_FUNC_RSP_DEREGDEV,   "DeregDevRsp"},
250     {ISNS_FUNC_RSP_SCNREG,     "SCNRegRsp"},
251     {ISNS_FUNC_RSP_SCNDEREG,   "SCNDeregRsp"},
252     {ISNS_FUNC_RSP_SCNEVENT,   "SCNEventRsp"},
253     {ISNS_FUNC_RSP_SCN,        "SCNRsp"},
254     {ISNS_FUNC_RSP_DDREG,      "DDRegRsp"},
255     {ISNS_FUNC_RSP_DDDEREG,    "DDDeregRsp"},
256     {ISNS_FUNC_RSP_DDSREG,     "DDSRegRsp"},
257     {ISNS_FUNC_RSP_DDSDEREG,   "DDSDeregRsp"},
258     {ISNS_FUNC_RSP_ESI,        "ESIRsp"},
259
260     {0x0,NULL},
261 };
262
263 #define ISNS_ENTITY_PROTOCOL_NO_PROTOCOL 1
264 #define ISNS_ENTITY_PROTOCOL_ISCSI       2
265 #define ISNS_ENTITY_PROTOCOL_IFCP        3
266
267
268 static const value_string isns_entity_protocol[] = {
269     {ISNS_ENTITY_PROTOCOL_NO_PROTOCOL, "No Protocol"},
270     {ISNS_ENTITY_PROTOCOL_ISCSI,       "iSCSI"},
271     {ISNS_ENTITY_PROTOCOL_IFCP,        "iFCP"}, 
272
273     {0x0,NULL},
274 };
275
276 static const value_string isns_errorcode[] = {
277     { 0,"No Error"},
278     { 1,"Unknown Error"},
279     { 2,"Message Format Error"},
280     { 3,"Invalid Registration"},
281     { 4,"Requested ESI Period Too short"},
282     { 5,"Invalid Query"},
283     { 6,"Authentication Unknown"},
284     { 7,"Authentication Absent"},
285     { 8,"Authentication Failed"},
286     { 9,"No such Entry"},
287     {10,"Version Not Supported"},
288     {11,"Internal Bus Error"},
289     {12,"Busy Now"},
290     {13,"Option Not Understood"},
291     {14,"Invalid Update"},
292     {15,"Message Not supported"},
293     {16,"SCN Event Rejected"},
294     {17,"SCN Registration Rejected"},
295     {18,"Attribute Not Implemented"},
296     {19,"SWITCH_ID Not available"},
297     {20,"SWITCH_ID not allocated"},
298     {21,"ESI Not Available"},
299
300     {0x0,NULL}
301 };
302
303
304 #define ISNS_ATTR_TAG_DELIMITER                     0
305 #define ISNS_ATTR_TAG_ENTITY_IDENTIFIER             1
306 #define ISNS_ATTR_TAG_ENTITY_PROTOCOL               2
307 #define ISNS_ATTR_TAG_MGMT_IP_ADDRESS               3
308 #define ISNS_ATTR_TAG_TIMESTAMP                     4
309 #define ISNS_ATTR_TAG_PROTOCOL_VERSION_RANGE        5
310 #define ISNS_ATTR_TAG_REGISTRATION_PERIOD           6
311 #define ISNS_ATTR_TAG_ENTITY_INDEX                  7
312 #define ISNS_ATTR_TAG_ENTITY_NEXT_INDEX             8
313 #define ISNS_ATTR_TAG_ENTITY_ISAKMP_PHASE_1         11
314 #define ISNS_ATTR_TAG_ENTITY_CERTIFICATE            12
315 #define ISNS_ATTR_TAG_PORTAL_IP_ADDRESS             16
316 #define ISNS_ATTR_TAG_PORTAL_PORT                   17
317 #define ISNS_ATTR_TAG_PORTAL_SYMBOLIC_NAME          18
318 #define ISNS_ATTR_TAG_ESI_INTERVAL                  19
319 #define ISNS_ATTR_TAG_ESI_PORT                      20
320 #define ISNS_ATTR_TAG_PORTAL_GROUP                  21
321 #define ISNS_ATTR_TAG_PORTAL_INDEX                  22
322 #define ISNS_ATTR_TAG_SCN_PORT                      23
323 #define ISNS_ATTR_TAG_PORTAL_NEXT_INDEX             24
324 #define ISNS_ATTR_TAG_PORTAL_SECURITY_BITMAP        27
325 #define ISNS_ATTR_TAG_PORTAL_ISAKMP_PHASE_1         28
326 #define ISNS_ATTR_TAG_PORTAL_ISAKMP_PHASE_2         29
327 #define ISNS_ATTR_TAG_PORTAL_CERTIFICATE            31
328 #define ISNS_ATTR_TAG_ISCSI_NAME                    32
329 #define ISNS_ATTR_TAG_ISCSI_NODE_TYPE               33
330 #define ISNS_ATTR_TAG_ISCSI_ALIAS                   34
331 #define ISNS_ATTR_TAG_ISCSI_SCN_BITMAP              35
332 #define ISNS_ATTR_TAG_ISCSI_NODE_INDEX              36
333 #define ISNS_ATTR_TAG_WWNN_TOKEN                    37
334 #define ISNS_ATTR_TAG_ISCSI_NODE_NEXT_INDEX         38
335 #define ISNS_ATTR_TAG_ISCSI_AUTH_METHOD             42
336 #define ISNS_ATTR_TAG_ISCSI_NODE_CERTIFICATE        43
337 #define ISNS_ATTR_TAG_PG_PORTAL_IP_ADDR             49
338 #define ISNS_ATTR_TAG_PG_PORTAL_PORT                50
339 #define ISNS_ATTR_TAG_PORTAL_GROUP_TAG              51
340 #define ISNS_ATTR_TAG_FC_PORT_NAME_WWPN             64
341 #define ISNS_ATTR_TAG_PORT_ID                       65
342 #define ISNS_ATTR_TAG_FC_PORT_TYPE                  66
343 #define ISNS_ATTR_TAG_SYMBOLIC_PORT_NAME            67
344 #define ISNS_ATTR_TAG_FABRIC_PORT_NAME              68
345 #define ISNS_ATTR_TAG_HARD_ADDRESS                  69
346 #define ISNS_ATTR_TAG_PORT_IP_ADDRESS               70
347 #define ISNS_ATTR_TAG_CLASS_OF_SERVICE              71
348 #define ISNS_ATTR_TAG_FC4_TYPES                     72
349 #define ISNS_ATTR_TAG_FC4_DESCRIPTOR                73
350 #define ISNS_ATTR_TAG_FC4_FEATURES                  74
351 #define ISNS_ATTR_TAG_IFCP_SCN_BITMAP               75
352 #define ISNS_ATTR_TAG_PORT_ROLE                     76
353 #define ISNS_ATTR_TAG_PERMANENT_PORT_NAME           77
354 #define ISNS_ATTR_TAG_PORT_CERTIFICATE              83
355 #define ISNS_ATTR_TAG_FC4_TYPE_CODE                 95
356 #define ISNS_ATTR_TAG_FC_NODE_NAME_WWNN             96
357 #define ISNS_ATTR_TAG_SYMBOLIC_NODE_NAME            97
358 #define ISNS_ATTR_TAG_NODE_IP_ADDRESS               98
359 #define ISNS_ATTR_TAG_NODE_IPA                      99
360 #define ISNS_ATTR_TAG_NODE_CERTIFICATE              100
361 #define ISNS_ATTR_TAG_PROXY_ISCSI_NAME              101
362 #define ISNS_ATTR_TAG_SWITCH_NAME                   128
363 #define ISNS_ATTR_TAG_PREFERRED_ID                  129
364 #define ISNS_ATTR_TAG_ASSIGNED_ID                   130
365 #define ISNS_ATTR_TAG_VIRTUAL_FABRIC_ID             131
366 #define ISNS_ATTR_TAG_VENDOR_OUI                    256
367 #define ISNS_ATTR_TAG_DD_SET_ID                     2049
368 #define ISNS_ATTR_TAG_DD_SET_SYMBOLIC_NAME          2050
369 #define ISNS_ATTR_TAG_DD_SET_STATUS                 2051
370 #define ISNS_ATTR_TAG_DD_SET_NEXT_ID                2052
371 #define ISNS_ATTR_TAG_DD_ID                         2065
372 #define ISNS_ATTR_TAG_DD_SYMBOLIC_NAME              2066
373 #define ISNS_ATTR_TAG_DD_MEMBER_ISCSI_INDEX         2067
374 #define ISNS_ATTR_TAG_DD_MEMBER_ISCSI_NAME          2068
375 #define ISNS_ATTR_TAG_DD_MEMBER_IFCP_NODE           2069
376 #define ISNS_ATTR_TAG_DD_MEMBER_PORTAL_INDEX        2070
377 #define ISNS_ATTR_TAG_DD_MEMBER_PORTAL_IP_ADDRESS   2071
378 #define ISNS_ATTR_TAG_DD_MEMBER_PORTAL_PORT         2072
379 #define ISNS_ATTR_TAG_DD_FEATURES                   2078
380 #define ISNS_ATTR_TAG_DD_ID_NEXT_ID                 2079
381
382
383 static const value_string isns_attribute_tags[] = {
384     {ISNS_ATTR_TAG_DELIMITER,                   "Delimiter"},
385     {ISNS_ATTR_TAG_ENTITY_IDENTIFIER,           "Entity Identifier (EID)"},
386     {ISNS_ATTR_TAG_ENTITY_PROTOCOL,             "Entity Protocol"},
387     {ISNS_ATTR_TAG_MGMT_IP_ADDRESS,             "Management IP Address"},
388     {ISNS_ATTR_TAG_TIMESTAMP,                   "Timestamp"},
389     {ISNS_ATTR_TAG_PROTOCOL_VERSION_RANGE,      "Protocol Version Range"},
390     {ISNS_ATTR_TAG_REGISTRATION_PERIOD,         "Registration Period"},
391     {ISNS_ATTR_TAG_ENTITY_INDEX,                "Entity Index"},
392     {ISNS_ATTR_TAG_ENTITY_NEXT_INDEX,           "Entity Next Index"},
393     {ISNS_ATTR_TAG_ENTITY_ISAKMP_PHASE_1,       "Entity ISAKMP Phase-1"},
394     {ISNS_ATTR_TAG_ENTITY_CERTIFICATE,          "Entity Certificate"},
395     {ISNS_ATTR_TAG_PORTAL_IP_ADDRESS,           "Portal IP Address"},
396     {ISNS_ATTR_TAG_PORTAL_PORT,                 "Portal TCP/UDP Port"},
397     {ISNS_ATTR_TAG_PORTAL_SYMBOLIC_NAME,        "Portal Symbolic Name"},
398     {ISNS_ATTR_TAG_ESI_INTERVAL,                "ESI Interval"},
399     {ISNS_ATTR_TAG_ESI_PORT,                    "ESI Port"},
400     {ISNS_ATTR_TAG_PORTAL_GROUP,                "Portal Group Tag"},
401     {ISNS_ATTR_TAG_PORTAL_INDEX,                "Portal Index"},
402     {ISNS_ATTR_TAG_SCN_PORT,                    "SCN Port"},
403     {ISNS_ATTR_TAG_PORTAL_NEXT_INDEX,           "Portal Next Index"},
404     {ISNS_ATTR_TAG_PORTAL_SECURITY_BITMAP,      "Portal Security Bitmap"},
405     {ISNS_ATTR_TAG_PORTAL_ISAKMP_PHASE_1,       "Portal ISAKMP Phase-1"},
406     {ISNS_ATTR_TAG_PORTAL_ISAKMP_PHASE_2,       "Portal ISAKMP Phase-2"},
407     {ISNS_ATTR_TAG_PORTAL_CERTIFICATE,          "Portal Certificate"},
408     {ISNS_ATTR_TAG_ISCSI_NAME,                  "iSCSI Name"},
409     {ISNS_ATTR_TAG_ISCSI_NODE_TYPE,             "iSCSI Node Type"},
410     {ISNS_ATTR_TAG_ISCSI_ALIAS,                 "iSCSI Alias"},
411     {ISNS_ATTR_TAG_ISCSI_SCN_BITMAP,            "iSCSI SCN Bitmap"},
412     {ISNS_ATTR_TAG_ISCSI_NODE_INDEX,            "iSCSI Node Index"},
413     {ISNS_ATTR_TAG_WWNN_TOKEN,                  "WWNN Token"},
414     {ISNS_ATTR_TAG_ISCSI_NODE_NEXT_INDEX,       "iSCSI Node Next Index"},
415     {ISNS_ATTR_TAG_ISCSI_AUTH_METHOD,           "iSCSI AuthMethod"},
416     {ISNS_ATTR_TAG_ISCSI_NODE_CERTIFICATE,      "iSCSI Node Certificate"},
417     {ISNS_ATTR_TAG_PG_PORTAL_IP_ADDR,           "PG Portal IP Addr"},
418     {ISNS_ATTR_TAG_PG_PORTAL_PORT,              "PG Portal Port"},
419     {ISNS_ATTR_TAG_PORTAL_GROUP_TAG,            "Portal Group Tag"},
420     {ISNS_ATTR_TAG_FC_PORT_NAME_WWPN,           "FC Port Name WWPN"},
421     {ISNS_ATTR_TAG_PORT_ID,                     "Port ID"},
422     {ISNS_ATTR_TAG_FC_PORT_TYPE,                "FC Port Type"},
423     {ISNS_ATTR_TAG_SYMBOLIC_PORT_NAME,          "Symbolic Port Name"},
424     {ISNS_ATTR_TAG_FABRIC_PORT_NAME,            "Fabric Port Name"},
425     {ISNS_ATTR_TAG_HARD_ADDRESS,                "Hard Address"},
426     {ISNS_ATTR_TAG_PORT_IP_ADDRESS,             "Port IP-Address"},
427     {ISNS_ATTR_TAG_CLASS_OF_SERVICE,            "Class of Service"},
428     {ISNS_ATTR_TAG_FC4_TYPES,                   "FC-4 Types"},
429     {ISNS_ATTR_TAG_FC4_DESCRIPTOR,              "FC-4 Descriptor"},
430     {ISNS_ATTR_TAG_FC4_FEATURES,                "FC-4 Features"},
431     {ISNS_ATTR_TAG_IFCP_SCN_BITMAP,             "iFCP SCN bitmap"},
432     {ISNS_ATTR_TAG_PORT_ROLE,                   "Port Role"},
433     {ISNS_ATTR_TAG_PERMANENT_PORT_NAME,         "Permanent Port Name"},
434     {ISNS_ATTR_TAG_PORT_CERTIFICATE,            "Port Certificate"},
435     {ISNS_ATTR_TAG_FC4_TYPE_CODE,               "FC-4 Type Code"},
436     {ISNS_ATTR_TAG_FC_NODE_NAME_WWNN,           "FC Node Name WWNN"},
437     {ISNS_ATTR_TAG_SYMBOLIC_NODE_NAME,          "Symbolic Node Name"},
438     {ISNS_ATTR_TAG_NODE_IP_ADDRESS,             "Node IP-Address"},
439     {ISNS_ATTR_TAG_NODE_IPA,                    "Node IPA"},
440     {ISNS_ATTR_TAG_NODE_CERTIFICATE,            "Node Certificate"},
441     {ISNS_ATTR_TAG_PROXY_ISCSI_NAME,            "Proxy iSCSI Name"},
442     {ISNS_ATTR_TAG_SWITCH_NAME,                 "Switch Name"},
443     {ISNS_ATTR_TAG_PREFERRED_ID,                "Preferred ID"},
444     {ISNS_ATTR_TAG_ASSIGNED_ID,                 "Assigned ID"},
445     {ISNS_ATTR_TAG_VIRTUAL_FABRIC_ID,           "Virtual_Fabric_ID"},
446     {ISNS_ATTR_TAG_VENDOR_OUI,                  "iSNS Server Vendor OUI"},
447     {ISNS_ATTR_TAG_DD_SET_ID,                   "DD_Set ID"},
448     {ISNS_ATTR_TAG_DD_SET_SYMBOLIC_NAME,        "DD_Set Sym Name"},
449     {ISNS_ATTR_TAG_DD_SET_STATUS,               "DD_Set Status"},
450     {ISNS_ATTR_TAG_DD_SET_NEXT_ID,              "DD_Set_Next_ID"},
451     {ISNS_ATTR_TAG_DD_ID,                       "DD_ID"},
452     {ISNS_ATTR_TAG_DD_SYMBOLIC_NAME,            "DD_Symbolic Name"},
453     {ISNS_ATTR_TAG_DD_MEMBER_ISCSI_INDEX,       "DD_Member iSCSI Index"},
454     {ISNS_ATTR_TAG_DD_MEMBER_ISCSI_NAME,        "DD_Member iSCSI Name"},
455     {ISNS_ATTR_TAG_DD_MEMBER_IFCP_NODE,         "DD_Member iFCP Node"},
456     {ISNS_ATTR_TAG_DD_MEMBER_PORTAL_INDEX,      "DD Member Portal Index"},
457     {ISNS_ATTR_TAG_DD_MEMBER_PORTAL_IP_ADDRESS, "DD_Member Portal IP Addr"},
458     {ISNS_ATTR_TAG_DD_MEMBER_PORTAL_PORT,       "DD Member Portal TCP/UDP"},
459     {ISNS_ATTR_TAG_DD_FEATURES,                 "DD_Features"},
460     {ISNS_ATTR_TAG_DD_ID_NEXT_ID,               "DD_ID Next ID"},
461
462     {0,NULL}
463 };
464
465
466 /* iSNS flags */
467 #define ISNS_FLAGS_CLIENT       0x8000
468 #define ISNS_FLAGS_SERVER       0x4000
469 #define ISNS_FLAGS_AUTH         0x2000
470 #define ISNS_FLAGS_REPLACE      0x1000
471 #define ISNS_FLAGS_LAST_PDU     0x0800
472 #define ISNS_FLAGS_FIRST_PDU    0x0400
473
474
475 static const true_false_string isns_scn_bitmap_initiator_and_self_information_only = {
476     "True",
477     "False"
478 };
479 static const true_false_string isns_scn_bitmap_target_and_self_information_only    = {
480     "True",
481     "False"
482 };
483 static const true_false_string isns_scn_bitmap_management_registration_scn         = {
484     "True",
485     "False"
486 };
487 static const true_false_string isns_scn_bitmap_object_removed                      = {
488     "True",
489     "False"
490 };
491 static const true_false_string isns_scn_bitmap_object_added                        = {
492     "True",
493     "False"
494 };
495 static const true_false_string isns_scn_bitmap_object_updated                      = {
496     "True",
497     "False"
498 };
499 static const true_false_string isns_scn_bitmap_dd_dds_member_removed               = {
500     "True",
501     "False"
502 };
503 static const true_false_string isns_scn_bitmap_dd_dds_member_added                 = {
504     "True",
505     "False"
506 };
507
508 static const true_false_string isns_psb_tunnel_mode = {
509     "Preferred",
510     "No Preference"
511 };
512 static const true_false_string isns_psb_transport_mode = {
513     "Preferred",
514     "No Preference"
515 };
516 static const true_false_string isns_psb_pfs = {
517     "Enabled",
518     "Disabled"
519 };
520 static const true_false_string isns_psb_aggressive_mode = {
521     "Enabled",
522     "Disabled"
523 };
524 static const true_false_string isns_psb_main_mode = {
525     "Enabled",
526     "Disabled"
527 };
528 static const true_false_string isns_psb_ike_ipsec = {
529     "Enabled",
530     "Disabled"
531 };
532 static const true_false_string isns_psb_bitmap = {
533     "VALID",
534     "INVALID"
535 };
536
537 static const true_false_string isns_isnt_control = {
538     "Yes",
539     "No"
540 };
541 static const true_false_string isns_isnt_initiator = {
542     "Yes",
543     "No"
544 };
545 static const true_false_string isns_isnt_target = {
546     "Yes",
547     "No"
548 };
549
550 static const true_false_string isns_port_type = {
551     "UDP",
552     "TCP"
553 };
554
555 static const true_false_string isns_flag_first_pdu = {
556     "First PDU of iSNS Message",
557     "Not the first PDU of iSNS Message"
558 };
559
560 static const true_false_string isns_flag_last_pdu = {
561     "Last PDU of iSNS Message",
562     "Not the Last PDU of iSNS Message"
563 };
564
565 static const true_false_string isns_flag_replace = {
566     "Replace",
567     "Don't replace"
568 };
569
570 static const true_false_string isns_flag_auth = {
571     "Authentication Block is PRESENT",
572     "No authentication block"
573 };
574
575 static const true_false_string isns_flag_server = {
576     "Sender is iSNS server",
577     "Sender is not iSNS server"
578 };
579
580 static const true_false_string isns_flag_client = {
581     "Sender is iSNS client",
582     "Sender is not iSNS client"
583 };
584
585
586 /* Initialize the subtree pointers */
587 static gint ett_isns = -1;
588
589
590 /* Code to actually dissect the packets */
591 static void
592 dissect_isns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
593 {
594     guint offset = 0;
595     guint16 function_id;
596     guint16 isns_protocol_version;
597     guint32 packet_len = tvb_length_remaining(tvb, offset);
598     char * function_id_str;
599     /* Set up structures needed to add the protocol subtree and manage it */
600     proto_item *ti = NULL;
601     proto_tree *isns_tree = NULL;
602     
603     if( packet_len < 12 )
604         return;
605
606     /* Make entries in Protocol column and Info column on summary display */
607     if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
608         col_set_str(pinfo->cinfo, COL_PROTOCOL, "isns");
609     if (check_col(pinfo->cinfo, COL_INFO)) 
610         col_clear(pinfo->cinfo, COL_INFO);
611
612     /* Get the function id from the packet */
613     function_id =  tvb_get_ntohs(tvb, offset + 2);
614     function_id_str = match_strval(function_id, isns_function_ids);
615     
616     /* Get the protocol version - only version one at the moment*/ 
617     isns_protocol_version = tvb_get_ntohs(tvb, offset + 0);
618     if( (function_id_str == NULL) || (isns_protocol_version != ISNS_PROTO_VER) )
619         return;
620     
621     /* Add the function name in the info col */
622     if (check_col(pinfo->cinfo, COL_INFO)) 
623         col_add_str(pinfo->cinfo, COL_INFO, function_id_str);
624     
625     /* In the interest of speed, if "tree" is NULL, don't do any work not
626      * necessary to generate protocol tree items. 
627      */
628     if (tree) {
629         guint16 b;      
630         guint16 flags;  
631         proto_tree *tt;
632         proto_item *tflags;
633         proto_item *tpayload;
634
635         /* NOTE: The offset and length values in the call to
636          * "proto_tree_add_item()" define what data bytes to highlight in the hex
637          * display window when the line in the protocol tree display
638          * corresponding to that item is selected.
639          *  tvb_length(tvb) is a handy way to highlight all data from the offset to
640          *  the end of the packet. 
641          */
642
643         /* create display subtree for the protocol */
644         ti = proto_tree_add_item(tree, proto_isns, tvb, 0, -1, FALSE);
645         isns_tree = proto_item_add_subtree(ti, ett_isns);
646
647         /* OK... Sort out the header */
648         b = tvb_get_ntohs(tvb, offset);
649         proto_tree_add_uint(isns_tree, hf_isns_version, tvb, offset, 2, b);
650
651         b = tvb_get_ntohs(tvb, offset + 2);
652         proto_tree_add_uint(isns_tree, hf_isns_function_id, tvb, offset+2, 2, b);
653
654         b = tvb_get_ntohs(tvb, offset + 4);
655         proto_tree_add_uint(isns_tree, hf_isns_pdu_length, tvb, offset+4, 2, b);
656
657         /*FLAGS*/
658         flags = tvb_get_ntohs(tvb, offset + 6);
659         tflags = proto_tree_add_uint(isns_tree, hf_isns_flags, tvb, offset+6, 2, flags);
660         tt = proto_item_add_subtree(tflags, ett_isns_flags);
661
662         proto_tree_add_boolean(tt, hf_isns_client, tvb, offset+6, 2, flags);
663         proto_tree_add_boolean(tt, hf_isns_server, tvb, offset+6, 2, flags);
664         proto_tree_add_boolean(tt, hf_isns_auth, tvb, offset+6, 2, flags);
665         proto_tree_add_boolean(tt, hf_isns_replace, tvb, offset+6, 2, flags);
666         proto_tree_add_boolean(tt, hf_isns_last_pdu, tvb, offset+6, 2, flags);
667         proto_tree_add_boolean(tt, hf_isns_first_pdu, tvb, offset+6, 2, flags);
668
669         b = tvb_get_ntohs(tvb, offset + 8);
670         proto_tree_add_uint(isns_tree, hf_isns_transaction_id, tvb, offset+8, 2, b);
671
672         b = tvb_get_ntohs(tvb, offset + 10);
673         proto_tree_add_uint(isns_tree, hf_isns_sequence_id, tvb, offset+10, 2, b);
674
675         tpayload = proto_tree_add_item(isns_tree, hf_isns_payload, tvb, offset+12, packet_len - 12 , FALSE);
676         tt = proto_item_add_subtree(tpayload, ett_isns_payload);
677
678         /* Now set the offset to the start of the payload */
679         offset += ISNS_HEADER_SIZE;
680
681         /* Decode those attributes baby - Yeah!*/
682         switch (function_id)
683         {
684         case ISNS_FUNC_HEARTBEAT:
685         {
686             guint8 hb_ipv6[16];
687             guint16 port;
688             guint32 c;
689             tvb_memcpy(tvb,hb_ipv6,offset,16);
690             proto_tree_add_ipv6(tt,hf_isns_heartbeat_ipv6_addr, tvb, offset, 16, hb_ipv6);
691             offset += 16;
692
693             port = tvb_get_ntohs(tvb, offset);
694             proto_tree_add_uint(tt,hf_isns_heartbeat_tcp_port, tvb, offset, 2, port);
695             offset += 2;
696
697             port = tvb_get_ntohs(tvb, offset);
698             proto_tree_add_uint(tt,hf_isns_heartbeat_udp_port, tvb, offset, 2, port);
699             offset += 2;
700
701             c = tvb_get_ntohl(tvb, offset);
702             proto_tree_add_uint(tt,hf_isns_heartbeat_interval, tvb, offset, 4, c);
703             offset += 4;
704
705             c = tvb_get_ntohl(tvb, offset);
706             proto_tree_add_uint(tt,hf_isns_heartbeat_counter, tvb, offset, 4, c);
707             offset += 4;
708             break;
709         }
710         /* Responses */
711         case ISNS_FUNC_RSP_DEVATTRREG:
712         case ISNS_FUNC_RSP_DEVATTRQRY:
713         case ISNS_FUNC_RSP_DEVGETNEXT:
714         case ISNS_FUNC_RSP_DEREGDEV:
715         case ISNS_FUNC_RSP_SCNREG:
716         case ISNS_FUNC_RSP_SCNDEREG:
717         case ISNS_FUNC_RSP_SCNEVENT:
718         case ISNS_FUNC_RSP_SCN:
719         case ISNS_FUNC_RSP_DDREG:
720         case ISNS_FUNC_RSP_DDDEREG:
721         case ISNS_FUNC_RSP_DDSREG:
722         case ISNS_FUNC_RSP_DDSDEREG:
723         case ISNS_FUNC_RSP_ESI:
724         {
725             /* Get the Error message of the response */
726             guint32 errorcode =  tvb_get_ntohl(tvb, offset);
727             proto_tree_add_uint(tt,hf_isns_resp_errorcode, tvb, offset, 4, errorcode);
728             offset += 4;
729             /* Messages */
730         }
731         case ISNS_FUNC_DEVATTRREG:
732         case ISNS_FUNC_DEVATTRQRY:
733         case ISNS_FUNC_DEVGETNEXT: 
734         case ISNS_FUNC_DEREGDEV:
735         case ISNS_FUNC_SCNREG:
736         case ISNS_FUNC_SCNDEREG:
737         case ISNS_FUNC_SCNEVENT:
738         case ISNS_FUNC_SCN:
739         case ISNS_FUNC_DDREG:
740         case ISNS_FUNC_DDDEREG:
741         case ISNS_FUNC_DDSREG:
742         case ISNS_FUNC_DDSDEREG:
743         case ISNS_FUNC_ESI:
744         default:
745             /* we can only look at the attributes for the first PDU */
746             if(!(flags&ISNS_FLAGS_FIRST_PDU)){
747                 proto_tree_add_text(tt, tvb, offset, packet_len-offset, "This is not the first PDU. The attributes are not decoded");
748                 return;
749             }
750
751             while( offset < packet_len )
752             {
753                 offset = AddAttribute(pinfo, tvb, tt, offset, function_id);
754             }
755         }
756     }
757
758     return;
759 }
760
761 static guint
762 get_isns_pdu_len(tvbuff_t *tvb, int offset)
763 {
764     guint16 isns_len;
765
766     isns_len = tvb_get_ntohs(tvb, offset+4);
767     return (isns_len+12);
768 }
769
770 static void
771 dissect_isns_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
772 {       
773         /* Make entries in Protocol column and Info column on summary display*/
774         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
775                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "isns");
776         if (check_col(pinfo->cinfo, COL_INFO)) 
777                 col_clear(pinfo->cinfo, COL_INFO);
778
779         tcp_dissect_pdus(tvb, pinfo, tree, isns_desegment, 12, get_isns_pdu_len,
780                 dissect_isns_pdu);
781
782
783 }
784
785 static void
786 dissect_isns_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
787 {       
788         /* Make entries in Protocol column and Info column on summary display*/
789         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
790                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "isns");
791         if (check_col(pinfo->cinfo, COL_INFO)) 
792                 col_clear(pinfo->cinfo, COL_INFO);
793
794         dissect_isns_pdu(tvb, pinfo, tree);
795 }
796
797
798 static guint
799 dissect_isns_attr_ip_address(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
800 {
801         proto_item *item=NULL;
802         proto_tree *tree=NULL;
803
804         if(parent_tree){
805                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
806                 tree = proto_item_add_subtree(item, ett_isns_attribute);
807         }
808
809         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
810         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
811
812         return offset+8+len;
813 }
814
815 static guint
816 dissect_isns_attr_string(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
817 {
818         proto_item *item=NULL;
819         proto_tree *tree=NULL;
820
821         if(parent_tree){
822                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
823                 tree = proto_item_add_subtree(item, ett_isns_attribute);
824         }
825
826         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
827         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
828
829         return offset+8+len;
830 }
831
832 static guint
833 dissect_isns_attr_integer(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len, guint16 function_id)
834 {
835         proto_item *item=NULL;
836         proto_tree *tree=NULL;
837
838         /*
839          * 5.6.5.1
840          * in a DevAttrReg , the PGT (tag 51) may be sent as 0 length
841          * which then means that we wish to register the portal group tag
842          * as NULL.
843          * (At least) some servers will respond with PGT as a 0 length 
844          * value in these instances in the DevAttrRegRsp (eventhough I can
845          * not find this mentioned in the standard) so allow it for the 
846          * response as well.
847          */
848         if(len){
849                 if(parent_tree){
850                         item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
851                         tree = proto_item_add_subtree(item, ett_isns_attribute);
852                 }
853         } else if((tag==ISNS_ATTR_TAG_PORTAL_GROUP_TAG)&&((function_id==ISNS_FUNC_DEVATTRREG)||(function_id==ISNS_FUNC_RSP_DEVATTRREG))){
854                 /* 5.6.5.1 */
855                 if(parent_tree){
856                         item=proto_tree_add_uint_format(parent_tree, hf_isns_portal_group_tag, tvb, offset, 8, 0, "PG Tag: <NULL>");
857                         tree = proto_item_add_subtree(item, ett_isns_attribute);
858                 }
859         } else {
860                 if(parent_tree){
861                         item=proto_tree_add_text(parent_tree, tvb, offset, 8, "Oops, you surprised me here. a 0 byte integer.");
862                         tree = proto_item_add_subtree(item, ett_isns_attribute);
863                 }
864         }
865
866         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
867         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
868
869         return offset+8+len;
870 }
871
872 static guint
873 dissect_isns_attr_port(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len,
874                        guint16 port_type, packet_info *pinfo)
875 {
876         proto_item *tree=NULL;
877         proto_item *item=NULL;
878         guint16 port = tvb_get_ntohs(tvb, offset + 10);
879         guint16 isudp = tvb_get_ntohs(tvb, offset + 8)&0x01;
880         conversation_t *conversation;
881
882         if(parent_tree){
883             item = proto_tree_add_uint(parent_tree, hf_index, tvb, offset+8, 4, port);
884             tree = proto_item_add_subtree(item, ett_isns_port);
885         }
886
887         proto_tree_add_boolean(tree, hf_isns_port_type, tvb, offset+8, 2, isudp);
888
889         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
890         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
891
892         if ((port_type == ISNS_ESI_PORT) || (port_type == ISNS_SCN_PORT)) {
893             if (isudp) {
894                 conversation = find_conversation (&pinfo->src, &pinfo->dst, PT_UDP,
895                                                   port, 0, NO_PORT_B);
896                 if (conversation == NULL) {
897                     conversation = conversation_new (&pinfo->src, &pinfo->dst,
898                                                      PT_UDP, port, 0, NO_PORT2_FORCE);
899                     conversation_set_dissector (conversation, isns_udp_handle);
900                 }
901             }
902             else {
903                 conversation = find_conversation (&pinfo->src, &pinfo->dst, PT_TCP,
904                                                   port, 0, NO_PORT_B);
905                 if (conversation == NULL) {
906                     conversation = conversation_new (&pinfo->src, &pinfo->dst,
907                                                      PT_TCP, port, 0, NO_PORT2_FORCE);
908                     conversation_set_dissector (conversation, isns_tcp_handle);
909                 }
910             }
911         }
912
913         return offset+8+len;
914 }
915
916 static guint
917 dissect_isns_attr_none(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
918 {
919         proto_item *tree=NULL;
920         proto_item *item=NULL;
921
922         if(parent_tree){
923                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset, 8, FALSE);
924                 tree = proto_item_add_subtree(item, ett_isns_port);
925         }
926
927         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
928         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
929
930         return offset+8+len;
931 }
932
933 static guint
934 dissect_isns_attr_not_decoded_yet(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
935 {
936         proto_item *tree=NULL;
937         proto_item *item=NULL;
938
939         if(parent_tree){
940                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
941                 tree = proto_item_add_subtree(item, ett_isns_port);
942         }
943
944         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
945         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
946
947         return offset+8+len;
948 }
949
950 static guint
951 dissect_isns_attr_iscsi_node_type(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
952 {
953         proto_item *item=NULL;
954         proto_tree *tree=NULL;
955         guint32 node_type=tvb_get_ntohl(tvb, offset + 8);
956
957         if(parent_tree){
958                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
959                 tree = proto_item_add_subtree(item, ett_isns_attribute);
960         }
961
962         proto_tree_add_boolean(tree, hf_isns_isnt_control,   tvb, offset+8, 4, node_type);
963         if(node_type&0x00000004){
964                 proto_item_append_text(item, " Control");
965         }
966         proto_tree_add_boolean(tree, hf_isns_isnt_initiator, tvb, offset+8, 4, node_type);
967         if(node_type&0x00000002){
968                 proto_item_append_text(item, " Initiator");
969         }
970         proto_tree_add_boolean(tree, hf_isns_isnt_target,    tvb, offset+8, 4, node_type);
971         if(node_type&0x00000001){
972                 proto_item_append_text(item, " Target");
973         }
974
975         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
976         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
977
978         return offset+8+len;
979 }
980
981
982
983 static guint
984 dissect_isns_attr_portal_security_bitmap(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
985 {
986         proto_item *item=NULL;
987         proto_tree *tree=NULL;
988         guint32 psb=tvb_get_ntohl(tvb, offset + 8);
989
990         if(parent_tree){
991                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
992                 tree = proto_item_add_subtree(item, ett_isns_attribute);
993         }
994
995         proto_tree_add_boolean(tree, hf_isns_psb_tunnel_mode,     tvb, offset+8, 4, psb);
996         proto_tree_add_boolean(tree, hf_isns_psb_transport_mode,  tvb, offset+8, 4, psb);
997         proto_tree_add_boolean(tree, hf_isns_psb_pfs,             tvb, offset+8, 4, psb);
998         proto_tree_add_boolean(tree, hf_isns_psb_aggressive_mode, tvb, offset+8, 4, psb);
999         proto_tree_add_boolean(tree, hf_isns_psb_main_mode,       tvb, offset+8, 4, psb);
1000         proto_tree_add_boolean(tree, hf_isns_psb_ike_ipsec,       tvb, offset+8, 4, psb);
1001         proto_tree_add_boolean(tree, hf_isns_psb_bitmap,          tvb, offset+8, 4, psb);
1002
1003         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
1004         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
1005
1006         return offset+8+len;
1007 }
1008
1009
1010
1011 static guint
1012 dissect_isns_attr_scn_bitmap(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len)
1013 {
1014         proto_item *item=NULL;
1015         proto_tree *tree=NULL;
1016         guint32 scn_bitmap=tvb_get_ntohl(tvb, offset + 8);
1017
1018         if(parent_tree){
1019                 item=proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, FALSE);
1020                 tree = proto_item_add_subtree(item, ett_isns_attribute);
1021         }
1022
1023
1024         /*
1025          24              INITIATOR AND SELF INFORMATION ONLY 
1026          25              TARGET AND SELF INFORMATION ONLY  
1027          26              MANAGEMENT REGISTRATION/SCN 
1028          27              OBJECT REMOVED 
1029          28              OBJECT ADDED 
1030          29              OBJECT UPDATED 
1031          30              DD/DDS MEMBER REMOVED (Mgmt Reg/SCN only) 
1032          31 (Lsb)        DD/DDS MEMBER ADDED (Mgmt Reg/SCN only) 
1033         */
1034         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_initiator_and_self_information_only, tvb, offset+8, 4, scn_bitmap);
1035         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_target_and_self_information_only,    tvb, offset+8, 4, scn_bitmap);
1036         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_management_registration_scn,         tvb, offset+8, 4, scn_bitmap);
1037         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_object_removed,                      tvb, offset+8, 4, scn_bitmap);
1038         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_object_added,                        tvb, offset+8, 4, scn_bitmap);
1039         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_object_updated,                      tvb, offset+8, 4, scn_bitmap);
1040         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_dd_dds_member_removed,               tvb, offset+8, 4, scn_bitmap);
1041         proto_tree_add_boolean(tree, hf_isns_scn_bitmap_dd_dds_member_added,                 tvb, offset+8, 4, scn_bitmap);
1042
1043         proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
1044         proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
1045
1046         return offset+8+len;
1047 }
1048
1049
1050
1051
1052 static guint
1053 AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
1054              guint16 function_id)
1055 {
1056     guint32 tag,len;
1057
1058
1059     /* Get the Tag */
1060     tag = tvb_get_ntohl(tvb, offset);
1061
1062     /* Now the Length */
1063     len = tvb_get_ntohl(tvb, offset + 4);
1064
1065     if (!len) {
1066         if (tree) {
1067             proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag);
1068             proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len);
1069         }
1070         return (offset+8);
1071     }
1072     
1073     switch( tag )
1074     {
1075     case ISNS_ATTR_TAG_DELIMITER:
1076         offset = dissect_isns_attr_none(tvb, offset, tree, hf_isns_delimiter, tag, len);
1077         break;
1078     case ISNS_ATTR_TAG_ENTITY_IDENTIFIER:
1079         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_entity_identifier, tag, len);
1080         break;
1081     case ISNS_ATTR_TAG_ENTITY_PROTOCOL:
1082         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_entity_protocol, tag, len, function_id);
1083         break;
1084     case ISNS_ATTR_TAG_MGMT_IP_ADDRESS:
1085         offset = dissect_isns_attr_ip_address(tvb, offset, tree, hf_isns_mgmt_ip_addr, tag, len);
1086         break;
1087     case ISNS_ATTR_TAG_TIMESTAMP:
1088         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_timestamp, tag, len, function_id);
1089         break;
1090     case ISNS_ATTR_TAG_PROTOCOL_VERSION_RANGE:
1091         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1092         break;
1093     case ISNS_ATTR_TAG_REGISTRATION_PERIOD:
1094         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_registration_period, tag, len, function_id);
1095         break;
1096     case ISNS_ATTR_TAG_ENTITY_INDEX:
1097         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_entity_index, tag, len, function_id);
1098         break;
1099     case ISNS_ATTR_TAG_ENTITY_NEXT_INDEX:
1100         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_entity_next_index, tag, len, function_id);
1101         break;
1102     case ISNS_ATTR_TAG_ENTITY_ISAKMP_PHASE_1:
1103         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1104         break;
1105     case ISNS_ATTR_TAG_ENTITY_CERTIFICATE:
1106         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1107         break;
1108     case ISNS_ATTR_TAG_PORTAL_IP_ADDRESS:
1109         offset = dissect_isns_attr_ip_address(tvb, offset, tree, hf_isns_portal_ip_addr, tag, len);
1110         break;
1111     case ISNS_ATTR_TAG_PORTAL_PORT:
1112         offset = dissect_isns_attr_port(tvb, offset, tree, hf_isns_portal_port, tag, len, ISNS_OTHER_PORT, pinfo);
1113         break;
1114     case ISNS_ATTR_TAG_PORTAL_SYMBOLIC_NAME:
1115         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_portal_symbolic_name, tag, len);
1116         break;
1117     case ISNS_ATTR_TAG_ESI_INTERVAL:
1118         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_esi_interval, tag, len, function_id);
1119         break;
1120     case ISNS_ATTR_TAG_ESI_PORT:
1121         offset = dissect_isns_attr_port(tvb, offset, tree, hf_isns_esi_port, tag, len, ISNS_ESI_PORT, pinfo);
1122         break;
1123     case ISNS_ATTR_TAG_PORTAL_GROUP:
1124         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1125         break;
1126     case ISNS_ATTR_TAG_PORTAL_INDEX:
1127         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_portal_index, tag, len, function_id);
1128         break;
1129     case ISNS_ATTR_TAG_SCN_PORT:
1130         offset = dissect_isns_attr_port(tvb, offset, tree, hf_isns_scn_port, tag, len, ISNS_SCN_PORT, pinfo);
1131         break;
1132     case ISNS_ATTR_TAG_PORTAL_NEXT_INDEX:
1133         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_portal_next_index, tag, len, function_id);
1134         break;
1135     case ISNS_ATTR_TAG_PORTAL_SECURITY_BITMAP:
1136         offset = dissect_isns_attr_portal_security_bitmap(tvb, offset, tree, hf_isns_psb, tag, len);
1137         break;
1138     case ISNS_ATTR_TAG_PORTAL_ISAKMP_PHASE_1:
1139         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1140         break;
1141     case ISNS_ATTR_TAG_PORTAL_ISAKMP_PHASE_2:
1142         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1143         break;
1144     case ISNS_ATTR_TAG_PORTAL_CERTIFICATE:
1145         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1146         break;
1147     case ISNS_ATTR_TAG_ISCSI_NAME:
1148         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_iscsi_name, tag, len);
1149         break;
1150     case ISNS_ATTR_TAG_ISCSI_NODE_TYPE:
1151         offset = dissect_isns_attr_iscsi_node_type(tvb, offset, tree, hf_isns_iscsi_node_type, tag, len);
1152         break;
1153     case ISNS_ATTR_TAG_ISCSI_ALIAS:
1154         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_iscsi_alias, tag, len);
1155         break;
1156     case ISNS_ATTR_TAG_ISCSI_SCN_BITMAP:
1157         offset = dissect_isns_attr_scn_bitmap(tvb, offset, tree, hf_isns_scn_bitmap, tag, len);
1158         break;
1159     case ISNS_ATTR_TAG_ISCSI_NODE_INDEX:
1160         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_node_index, tag, len, function_id);
1161         break;
1162     case ISNS_ATTR_TAG_WWNN_TOKEN:
1163         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_wwnn_token, tag, len, function_id);
1164         break;
1165     case ISNS_ATTR_TAG_ISCSI_NODE_NEXT_INDEX:
1166         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_node_next_index, tag, len, function_id);
1167         break;
1168     case ISNS_ATTR_TAG_ISCSI_AUTH_METHOD:
1169         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_iscsi_auth_method, tag, len);
1170         break;
1171     case ISNS_ATTR_TAG_ISCSI_NODE_CERTIFICATE:
1172         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1173         break;
1174     case ISNS_ATTR_TAG_PG_PORTAL_IP_ADDR:
1175         offset = dissect_isns_attr_ip_address(tvb, offset, tree, hf_isns_pg_portal_ip_addr, tag, len);
1176         break;
1177     case ISNS_ATTR_TAG_PG_PORTAL_PORT:
1178         offset = dissect_isns_attr_port(tvb, offset, tree, hf_isns_pg_portal_port, tag, len, ISNS_OTHER_PORT, pinfo);
1179         break;
1180     case ISNS_ATTR_TAG_PORTAL_GROUP_TAG:
1181         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_portal_group_tag, tag, len, function_id);
1182         break;
1183     case ISNS_ATTR_TAG_FC_PORT_NAME_WWPN:
1184         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_fc_port_name_wwpn, tag, len, function_id);
1185         break;
1186     case ISNS_ATTR_TAG_PORT_ID:
1187         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_port_id, tag, len, function_id);
1188         break;
1189     case ISNS_ATTR_TAG_FC_PORT_TYPE:
1190         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1191         break;
1192         /*
1193           0x0000           Unidentified/Null Entry 
1194           0x0001           Fibre Channel N_Port 
1195           0x0002           Fibre Channel NL_Port 
1196           0x0003           Fibre Channel F/NL_Port 
1197           0x0081           Fibre Channel F_Port 
1198           0x0082           Fibre Channel FL_Port 
1199           0x0084           Fibre Channel E_Port 
1200           0xFF12           iFCP Port 
1201         */
1202     case ISNS_ATTR_TAG_SYMBOLIC_PORT_NAME:
1203         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_symbolic_port_name, tag, len);
1204         break;
1205     case ISNS_ATTR_TAG_FABRIC_PORT_NAME:
1206         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_fabric_port_name, tag, len, function_id);
1207         break;
1208     case ISNS_ATTR_TAG_HARD_ADDRESS:
1209         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_hard_address, tag, len, function_id);
1210         break;
1211     case ISNS_ATTR_TAG_PORT_IP_ADDRESS:
1212         offset = dissect_isns_attr_ip_address(tvb, offset, tree, hf_isns_port_ip_addr, tag, len);
1213         break;
1214     case ISNS_ATTR_TAG_CLASS_OF_SERVICE:
1215         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1216         break;
1217         /*
1218           bit 29             Fibre Channel Class 2 Supported
1219           bit 28             Fibre Channel Class 3 Supported
1220         */
1221     case ISNS_ATTR_TAG_FC4_TYPES:
1222         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1223         break;
1224     case ISNS_ATTR_TAG_FC4_DESCRIPTOR:
1225         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_fc4_descriptor, tag, len);
1226         break;
1227     case ISNS_ATTR_TAG_FC4_FEATURES:
1228         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1229         break;
1230     case ISNS_ATTR_TAG_IFCP_SCN_BITMAP:
1231         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1232         break;
1233         /*
1234           bit 24              INITIATOR AND SELF INFORMATION ONLY
1235           bit 25              TARGET AND SELF INFORMATION ONLY
1236           bit 26              MANAGEMENT REGISTRATION/SCN
1237           bit 27              OBJECT REMOVED
1238           bit 28              OBJECT ADDED
1239           bit 29              OBJECT UPDATED
1240           bit 30              DD/DDS MEMBER REMOVED (Mgmt Reg/SCN only)
1241           bit 31 (Lsb)        DD/DDS MEMBER ADDED (Mgmt Reg/SCN only)
1242         */
1243     case ISNS_ATTR_TAG_PORT_ROLE:
1244         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1245         break;
1246         /*
1247           bit 29              Control 
1248           bit 30              FCP Initiator 
1249           bit 31 (Lsb)        FCP Target 
1250         */
1251     case ISNS_ATTR_TAG_PERMANENT_PORT_NAME:
1252         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_permanent_port_name, tag, len, function_id);
1253         break;
1254     case ISNS_ATTR_TAG_PORT_CERTIFICATE:
1255         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1256         break;
1257     case ISNS_ATTR_TAG_FC4_TYPE_CODE:
1258         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1259         break;
1260         /* 8bit type code in byte0 */
1261     case ISNS_ATTR_TAG_FC_NODE_NAME_WWNN:
1262         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_fc_node_name_wwnn, tag, len, function_id);
1263         break;
1264     case ISNS_ATTR_TAG_SYMBOLIC_NODE_NAME:
1265         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_symbolic_node_name, tag, len);
1266         break;
1267     case ISNS_ATTR_TAG_NODE_IP_ADDRESS:
1268         offset = dissect_isns_attr_ip_address(tvb, offset, tree, hf_isns_node_ip_addr, tag, len);
1269         break;
1270     case ISNS_ATTR_TAG_NODE_IPA:
1271         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_node_ipa, tag, len, function_id);
1272         break;
1273     case ISNS_ATTR_TAG_NODE_CERTIFICATE:
1274         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1275         break;
1276     case ISNS_ATTR_TAG_PROXY_ISCSI_NAME:
1277         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_proxy_iscsi_name, tag, len);
1278         break;
1279     case ISNS_ATTR_TAG_SWITCH_NAME:
1280         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_switch_name, tag, len, function_id);
1281         break;
1282     case ISNS_ATTR_TAG_PREFERRED_ID:
1283         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_preferred_id, tag, len, function_id);
1284         break;
1285     case ISNS_ATTR_TAG_ASSIGNED_ID:
1286         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_assigned_id, tag, len, function_id);
1287         break;
1288     case ISNS_ATTR_TAG_VIRTUAL_FABRIC_ID:
1289         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_virtual_fabric_id, tag, len);
1290         break;
1291     case ISNS_ATTR_TAG_VENDOR_OUI:
1292         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_vendor_oui, tag, len, function_id);
1293         break;
1294     case ISNS_ATTR_TAG_DD_SET_ID:
1295         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_dd_set_id, tag, len, function_id);
1296         break;
1297     case ISNS_ATTR_TAG_DD_SET_SYMBOLIC_NAME:
1298         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_dd_set_symbolic_name, tag, len);
1299         break;
1300     case ISNS_ATTR_TAG_DD_SET_STATUS:
1301         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1302         break;
1303     case ISNS_ATTR_TAG_DD_SET_NEXT_ID:
1304         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_dd_set_next_id, tag, len, function_id);
1305         break;
1306     case ISNS_ATTR_TAG_DD_ID:
1307         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_dd_id, tag, len, function_id);
1308         break;
1309     case ISNS_ATTR_TAG_DD_SYMBOLIC_NAME:
1310         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_dd_symbolic_name, tag, len);
1311         break;
1312     case ISNS_ATTR_TAG_DD_MEMBER_ISCSI_INDEX:
1313         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_member_iscsi_index, tag, len, function_id);
1314         break;
1315     case ISNS_ATTR_TAG_DD_MEMBER_ISCSI_NAME:
1316         offset = dissect_isns_attr_string(tvb, offset, tree, hf_isns_dd_member_iscsi_name, tag, len);
1317         break;
1318     case ISNS_ATTR_TAG_DD_MEMBER_IFCP_NODE:
1319         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_member_ifcp_node, tag, len, function_id);
1320         break;
1321     case ISNS_ATTR_TAG_DD_MEMBER_PORTAL_INDEX:
1322         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_member_portal_index, tag, len, function_id);
1323         break;
1324     case ISNS_ATTR_TAG_DD_MEMBER_PORTAL_IP_ADDRESS:
1325         offset = dissect_isns_attr_ip_address(tvb, offset, tree, hf_isns_dd_member_portal_ip_addr, tag, len);
1326         break;
1327     case ISNS_ATTR_TAG_DD_MEMBER_PORTAL_PORT:
1328         offset = dissect_isns_attr_port(tvb, offset, tree, hf_isns_dd_member_portal_port,
1329                                         tag, len, ISNS_OTHER_PORT, pinfo);
1330         break;
1331     case ISNS_ATTR_TAG_DD_FEATURES:
1332         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1333         break;
1334     case ISNS_ATTR_TAG_DD_ID_NEXT_ID:
1335         offset = dissect_isns_attr_integer(tvb, offset, tree, hf_isns_dd_id_next_id, tag, len, function_id);
1336         break;
1337     default:
1338         offset = dissect_isns_attr_not_decoded_yet(tvb, offset, tree, hf_isns_not_decoded_yet, tag, len);
1339     }
1340
1341     
1342     /* move on the offset to next attribute */
1343
1344     return offset;    
1345 }
1346
1347
1348
1349 /* Register the protocol with Ethereal */
1350
1351 /* this format is require because a script is used to build the C function
1352    that calls all the protocol registration.
1353 */
1354
1355 void proto_register_isns(void)
1356 {
1357     /* Setup list of header fields  See Section 1.6.1 for details*/
1358     static hf_register_info hf[] = {
1359         /* The Header Stuff */
1360         { &hf_isns_version,
1361           { "iSNSP Version","isns.PVer",
1362             FT_UINT16, BASE_DEC, NULL, 0,          
1363             "iSNS Protocol Version" ,HFILL}
1364         },
1365         { &hf_isns_function_id,
1366           { "Function ID","isns.functionid",        
1367             FT_UINT16, BASE_DEC,VALS(&isns_function_ids),0,          
1368             "iSNS Function ID" ,HFILL}
1369         },
1370         { &hf_isns_pdu_length,
1371           { "PDU Length","isns.pdulength",
1372             FT_UINT16, BASE_DEC,NULL,0,
1373             "iSNS PDU Length" ,HFILL}
1374         },
1375
1376         { &hf_isns_flags,
1377           { "Flags","isns.flags",
1378             FT_UINT16, BASE_HEX,NULL,0,
1379             "iSNS Flags" ,HFILL}
1380         },
1381         { &hf_isns_client,
1382           { "Client    ","isns.flags.client",
1383             FT_BOOLEAN, 16, TFS(&isns_flag_client), ISNS_FLAGS_CLIENT,
1384             "iSNS Client" ,HFILL}
1385         },
1386         { &hf_isns_server,
1387           { "Server    ","isns.flags.server",
1388             FT_BOOLEAN, 16, TFS(&isns_flag_server), ISNS_FLAGS_SERVER,
1389             "iSNS Server" ,HFILL}
1390         },
1391         { &hf_isns_auth,
1392           { "Auth      ","isns.flags.authentication_block",
1393             FT_BOOLEAN, 16, TFS(&isns_flag_auth), ISNS_FLAGS_AUTH,
1394             "is iSNS Authentication Block present?" ,HFILL}
1395         },
1396         { &hf_isns_replace,
1397           { "Replace   ","isns.flags.replace",
1398             FT_BOOLEAN, 16, TFS(&isns_flag_replace), ISNS_FLAGS_REPLACE,
1399             "iSNS Replace" ,HFILL}
1400         },
1401         { &hf_isns_last_pdu,
1402           { "Last PDU  ","isns.flags.lastpdu",
1403             FT_BOOLEAN, 16, TFS(&isns_flag_last_pdu), ISNS_FLAGS_LAST_PDU,
1404             "iSNS Last PDU" ,HFILL}
1405         },
1406         { &hf_isns_first_pdu,
1407           { "First PDU ","isns.flags.firstpdu",
1408             FT_BOOLEAN, 16, TFS(&isns_flag_first_pdu), ISNS_FLAGS_FIRST_PDU,
1409             "iSNS First PDU",HFILL }
1410         },
1411
1412
1413         { &hf_isns_transaction_id,
1414           { "Transaction ID","isns.transactionid",
1415             FT_UINT16, BASE_DEC,NULL,0,
1416             "iSNS transaction ID" ,HFILL}
1417         },
1418         { &hf_isns_sequence_id,
1419           { "Sequence ID","isns.sequenceid",
1420             FT_UINT16, BASE_DEC,NULL,0,
1421             "iSNS sequence ID" ,HFILL}
1422         },
1423
1424         { &hf_isns_entity_protocol,
1425           { "Entity Protocol","isns.entity_protocol",
1426             FT_UINT32, BASE_DEC,VALS(isns_entity_protocol),0,
1427             "iSNS Entity Protocol" ,HFILL}
1428         },
1429         /* The Payload stuff */
1430
1431         { &hf_isns_dd_member_portal_port,
1432           { "DD Member Portal Port","isns.dd_member_portal_port",
1433             FT_UINT32, BASE_DEC, NULL, 0,
1434             "TCP/UDP DD Member Portal Port", HFILL }
1435         },
1436
1437         { &hf_isns_iscsi_node_type,
1438           { "iSCSI Node Type","isns.iscsi.node_type",
1439             FT_UINT32, BASE_HEX, NULL, 0,
1440             "iSCSI Node Type", HFILL }
1441         },
1442
1443         { &hf_isns_esi_port,
1444           { "ESI Port","isns.esi_port",
1445             FT_UINT32, BASE_DEC, NULL, 0,
1446             "TCP/UDP ESI Port", HFILL }
1447         },
1448
1449         { &hf_isns_scn_port,
1450           { "SCN Port","isns.scn_port",
1451             FT_UINT32, BASE_DEC, NULL, 0,
1452             "TCP/UDP SCN Port", HFILL }
1453         },
1454
1455         { &hf_isns_portal_port,
1456           { "Portal Port","isns.portal_port",
1457             FT_UINT32, BASE_DEC, NULL, 0,
1458             "TCP/UDP Portal Port", HFILL }
1459         },
1460
1461         { &hf_isns_pg_portal_port,
1462           { "PG Portal Port","isns.pg.portal_port",
1463             FT_UINT32, BASE_DEC, NULL, 0,
1464             "PG Portal TCP/UDP Port", HFILL }
1465         },
1466
1467         { &hf_isns_port_type,
1468           { "Port Type","isns.port.port_type",
1469             FT_BOOLEAN, 16, TFS(&isns_port_type), 0x01, /* bit 15 (or bit 1 of a 16bit word) */
1470             "Port Type",HFILL }
1471         },
1472
1473         { &hf_isns_psb,
1474           { "Portal Security Bitmap","isns.psb",
1475             FT_UINT32, BASE_HEX, NULL, 0,
1476             "Portal Security Bitmap", HFILL }
1477         },
1478         { &hf_isns_psb_tunnel_mode,
1479           { "Tunnel Mode     ","isns.psb.tunnel",
1480             FT_BOOLEAN, 32, TFS(&isns_psb_tunnel_mode),     0x0040, /* bit 25 */
1481             "Tunnel Mode Preferred",HFILL }
1482         },
1483         { &hf_isns_psb_transport_mode,
1484           { "Transport Mode  ","isns.psb.transport",
1485             FT_BOOLEAN, 32, TFS(&isns_psb_transport_mode),  0x0020, /* bit 26 */
1486             "Transport Mode",HFILL }
1487         },
1488         { &hf_isns_psb_pfs,
1489           { "PFS             ","isns.psb.pfs",
1490             FT_BOOLEAN, 32, TFS(&isns_psb_pfs),        0x0010, /* bit 27 */
1491             "PFS",HFILL }
1492         },
1493         { &hf_isns_psb_aggressive_mode,
1494           { "Aggressive Mode ","isns.psb.aggressive_mode",
1495             FT_BOOLEAN, 32, TFS(&isns_psb_aggressive_mode), 0x0008, /* bit 28 */
1496             "Aggressive Mode",HFILL }
1497         },
1498         { &hf_isns_psb_main_mode,
1499           { "Main Mode       ","isns.psb.main_mode",
1500             FT_BOOLEAN, 32, TFS(&isns_psb_main_mode),  0x0004, /* bit 29 */
1501             "Main Mode",HFILL }
1502         },
1503         { &hf_isns_psb_ike_ipsec,
1504           { "IKE/IPSec       ","isns.psb.ike_ipsec",
1505             FT_BOOLEAN, 32, TFS(&isns_psb_ike_ipsec),  0x0002, /* bit 30 */
1506             "IKE/IPSec",HFILL }
1507         },
1508         { &hf_isns_psb_bitmap,
1509           { "Bitmap          ","isns.psb.bitmap",
1510             FT_BOOLEAN, 32, TFS(&isns_psb_bitmap),     0x0001, /* bit 31 */
1511             "Bitmap",HFILL }
1512         },
1513
1514
1515
1516         { &hf_isns_scn_bitmap,
1517           { "iSCSI SCN Bitmap","isns.scn_bitmap",
1518             FT_UINT32, BASE_HEX, NULL, 0,
1519             "iSCSI SCN Bitmap", HFILL }
1520         },
1521         { &hf_isns_scn_bitmap_initiator_and_self_information_only,
1522           { "Initiator And Self Information Only","isns.scn_bitmap.initiator_and_self_information_only",
1523             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_initiator_and_self_information_only),     0x0080, /* bit 24 */
1524             "Initiator And Self Information Only",HFILL }
1525         },
1526         { &hf_isns_scn_bitmap_target_and_self_information_only,
1527           { "Target And Self Information Only","isns.scn_bitmap.target_and_self_information_only",
1528             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_target_and_self_information_only),     0x0040, /* bit 25 */
1529             "Target And Self Information Only",HFILL }
1530         },
1531         { &hf_isns_scn_bitmap_management_registration_scn,
1532           { "Management Registration/SCN","isns.scn_bitmap.management_registration_scn",
1533             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_management_registration_scn),     0x0020, /* bit 26 */
1534             "Management Registration/SCN",HFILL }
1535         },
1536         { &hf_isns_scn_bitmap_object_removed,
1537           { "Object Removed","isns.scn_bitmap.object_removed",
1538             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_object_removed),     0x0010, /* bit 27 */
1539             "Object Removed",HFILL }
1540         },
1541         { &hf_isns_scn_bitmap_object_added,
1542           { "Object Added","isns.scn_bitmap.object_added",
1543             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_object_added),     0x0008, /* bit 28 */
1544             "Object Added",HFILL }
1545         },
1546         { &hf_isns_scn_bitmap_object_updated,
1547           { "Object Updated","isns.scn_bitmap.object_updated",
1548             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_object_updated),     0x0004, /* bit 29 */
1549             "Object Updated",HFILL }
1550         },
1551         { &hf_isns_scn_bitmap_dd_dds_member_removed,
1552           { "DD/DDS Member Removed (Mgmt Reg/SCN only)","isns.scn_bitmap.dd_dds_member_removed",
1553             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_dd_dds_member_removed),     0x0002, /* bit 30 */
1554             "DD/DDS Member Removed (Mgmt Reg/SCN only)",HFILL }
1555         },
1556         { &hf_isns_scn_bitmap_dd_dds_member_added,
1557           { "DD/DDS Member Added (Mgmt Reg/SCN only)","isns.scn_bitmap.dd_dds_member_added",
1558             FT_BOOLEAN, 32, TFS(&isns_scn_bitmap_dd_dds_member_added),     0x0001, /* bit 31 */
1559             "DD/DDS Member Added (Mgmt Reg/SCN only)",HFILL }
1560         },
1561
1562
1563         { &hf_isns_isnt_control,
1564           { "Control   ","isns.isnt.control",
1565             FT_BOOLEAN, 32, TFS(&isns_isnt_control),  0x0004, /* bit 29 */
1566             "Control",HFILL }
1567         },
1568         { &hf_isns_isnt_initiator,
1569           { "Initiator ","isns.isnt.initiator",
1570             FT_BOOLEAN, 32, TFS(&isns_isnt_initiator),  0x0002, /* bit 30 */
1571             "Initiator",HFILL }
1572         },
1573         { &hf_isns_isnt_target,
1574           { "Target    ","isns.isnt.target",
1575             FT_BOOLEAN, 32, TFS(&isns_isnt_target),     0x0001, /* bit 31 */
1576             "Target",HFILL }
1577         },
1578
1579
1580         { &hf_isns_resp_errorcode,
1581           { "ErrorCode","isns.errorcode",
1582             FT_UINT32, BASE_DEC,TFS(isns_errorcode),0,
1583             "iSNS Response Error Code" ,HFILL}
1584         },
1585
1586         { &hf_isns_attr_tag,
1587           { "Attribute Tag","isns.attr.tag",
1588             FT_UINT32, BASE_DEC,TFS(isns_attribute_tags),0,
1589             "iSNS Attribute Tag" ,HFILL}
1590         },
1591
1592         { &hf_isns_attr_len,
1593           { "Attribute Length","isns.attr.len",
1594             FT_UINT32, BASE_DEC,NULL,0,
1595             "iSNS Attribute Length" ,HFILL}
1596         },
1597
1598         { &hf_isns_delimiter,
1599           { "Delimiter","isns.delimiter",
1600             FT_NONE, BASE_NONE, NULL,0,
1601             "iSNS Delimiter" ,HFILL}
1602         },
1603
1604         { &hf_isns_not_decoded_yet,
1605           { "Not Decoded Yet","isns.not_decoded_yet",
1606             FT_NONE, BASE_NONE, NULL,0,
1607             "This tag is not yet decoded by ethereal" ,HFILL}
1608         },
1609
1610         { &hf_isns_heartbeat_ipv6_addr,
1611           { "Heartbeat Address (ipv6)","isns.heartbeat.address",
1612             FT_IPv6, BASE_NONE, NULL, 0x0,
1613             "Server IPv6 Address", HFILL }},
1614
1615         { &hf_isns_heartbeat_tcp_port,
1616           { "Heartbeat TCP Port","isns.heartbeat.tcpport",
1617             FT_UINT16, BASE_DEC, NULL, 0x0,
1618             "Server TCP Port", HFILL }},
1619
1620         { &hf_isns_heartbeat_udp_port,
1621           { "Heartbeat UDP Port","isns.heartbeat.udpport",
1622             FT_UINT16, BASE_DEC, NULL, 0x0,
1623             "Server UDP Port", HFILL }},
1624
1625
1626         { &hf_isns_heartbeat_interval,
1627           { "Heartbeat Interval (secs)","isns.heartbeat.interval",
1628             FT_UINT32, BASE_DEC, NULL, 0x0,
1629             "Server Heartbeat interval", HFILL }},
1630
1631         { &hf_isns_heartbeat_counter,
1632           { "Heartbeat counter","isns.heartbeat.counter",
1633             FT_UINT32, BASE_DEC, NULL, 0x0,
1634             "Server Heartbeat Counter", HFILL }},
1635
1636         { &hf_isns_iscsi_name,
1637           { "iSCSI Name","isns.iscsi_name",
1638             FT_STRING, BASE_NONE, NULL, 0x0,
1639             "iSCSI Name of device", HFILL }},
1640
1641         { &hf_isns_dd_member_iscsi_name,
1642           { "DD Member iSCSI Name","isns.dd_member.iscsi_name",
1643             FT_STRING, BASE_NONE, NULL, 0x0,
1644             "DD Member iSCSI Name of device", HFILL }},
1645
1646         { &hf_isns_virtual_fabric_id,
1647           { "Virtual Fabric ID","isns.virtual_fabric_id",
1648             FT_STRING, BASE_NONE, NULL, 0x0,
1649             "Virtual fabric ID", HFILL }},
1650
1651         { &hf_isns_proxy_iscsi_name,
1652           { "Proxy iSCSI Name","isns.proxy_iscsi_name",
1653             FT_STRING, BASE_NONE, NULL, 0x0,
1654             "Proxy iSCSI Name", HFILL }},
1655
1656         { &hf_isns_fc4_descriptor,
1657           { "FC4 Descriptor","isns.fc4_descriptor",
1658             FT_STRING, BASE_NONE, NULL, 0x0,
1659             "FC4 Descriptor of this device", HFILL }},
1660
1661         { &hf_isns_iscsi_auth_method,
1662           { "iSCSI Auth Method","isns.iscsi_auth_method",
1663             FT_STRING, BASE_NONE, NULL, 0x0,
1664             "Authentication Method required by this device", HFILL }},
1665
1666         { &hf_isns_iscsi_alias,
1667           { "iSCSI Alias","isns.iscsi_alias",
1668             FT_STRING, BASE_NONE, NULL, 0x0,
1669             "iSCSI Alias of device", HFILL }},
1670
1671         { &hf_isns_portal_symbolic_name,
1672           { "Portal Symbolic Name","isns.portal.symbolic_name",
1673             FT_STRING, BASE_NONE, NULL, 0x0,
1674             "Symbolic name of this portal", HFILL }},
1675
1676         { &hf_isns_dd_set_symbolic_name,
1677           { "DD Set Symbolic Name","isns.dd_set.symbolic_name",
1678             FT_STRING, BASE_NONE, NULL, 0x0,
1679             "Symbolic name of this DD Set", HFILL }},
1680
1681         { &hf_isns_dd_symbolic_name,
1682           { "DD Symbolic Name","isns.dd.symbolic_name",
1683             FT_STRING, BASE_NONE, NULL, 0x0,
1684             "Symbolic name of this DD", HFILL }},
1685
1686         { &hf_isns_symbolic_port_name,
1687           { "Symbolic Port Name","isns.port.symbolic_name",
1688             FT_STRING, BASE_NONE, NULL, 0x0,
1689             "Symbolic name of this port", HFILL }},
1690
1691         { &hf_isns_symbolic_node_name,
1692           { "Symbolic Node Name","isns.node.symbolic_name",
1693             FT_STRING, BASE_NONE, NULL, 0x0,
1694             "Symbolic name of this node", HFILL }},
1695
1696         { &hf_isns_entity_identifier,
1697           { "Entity Identifier","isns.entity_identifier",
1698             FT_STRING, BASE_NONE, NULL, 0x0,
1699             "Entity Identifier of this object", HFILL }},
1700
1701         { &hf_isns_mgmt_ip_addr,
1702           { "Management IP Address","isns.mgmt.ip_address",
1703             FT_IPv6, BASE_NONE, NULL, 0x0,
1704             "Management IPv4/IPv6 Address", HFILL }},
1705
1706         { &hf_isns_node_ip_addr,
1707           { "Node IP Address","isns.node.ip_address",
1708             FT_IPv6, BASE_NONE, NULL, 0x0,
1709             "Node IPv4/IPv6 Address", HFILL }},
1710
1711         { &hf_isns_port_ip_addr,
1712           { "Port IP Address","isns.port.ip_address",
1713             FT_IPv6, BASE_NONE, NULL, 0x0,
1714             "Port IPv4/IPv6 Address", HFILL }},
1715
1716         { &hf_isns_portal_ip_addr,
1717           { "Portal IP Address","isns.portal.ip_address",
1718             FT_IPv6, BASE_NONE, NULL, 0x0,
1719             "Portal IPv4/IPv6 Address", HFILL }},
1720
1721         { &hf_isns_dd_member_portal_ip_addr,
1722           { "DD Member Portal IP Address","isns.dd.member_portal.ip_address",
1723             FT_IPv6, BASE_NONE, NULL, 0x0,
1724             "DD Member Portal IPv4/IPv6 Address", HFILL }},
1725
1726         { &hf_isns_pg_portal_ip_addr,
1727           { "PG Portal IP Address","isns.pg_portal.ip_address",
1728             FT_IPv6, BASE_NONE, NULL, 0x0,
1729             "PG Portal IPv4/IPv6 Address", HFILL }},
1730
1731         { &hf_isns_dd_id_next_id,
1732           { "DD ID Next ID","isns.index",
1733             FT_UINT32, BASE_DEC, NULL, 0x0,
1734             "DD ID Next ID", HFILL }},
1735
1736         { &hf_isns_member_iscsi_index,
1737           { "Member iSCSI Index","isns.member_iscsi_index",
1738             FT_UINT32, BASE_DEC, NULL, 0x0,
1739             "Member iSCSI Index", HFILL }},
1740
1741         { &hf_isns_member_portal_index,
1742           { "Member Portal Index","isns.member_portal_index",
1743             FT_UINT32, BASE_DEC, NULL, 0x0,
1744             "Member Portal Index", HFILL }},
1745
1746         { &hf_isns_member_ifcp_node,
1747           { "Member iFCP Node","isns.member_ifcp_node",
1748             FT_UINT32, BASE_DEC, NULL, 0x0,
1749             "Member iFCP Node", HFILL }},
1750
1751         { &hf_isns_vendor_oui,
1752           { "Vendor OUI","isns.index",
1753             FT_UINT32, BASE_DEC, NULL, 0x0,
1754             "Vendor OUI", HFILL }},
1755
1756         { &hf_isns_preferred_id,
1757           { "Preferred ID","isns.preferred_id",
1758             FT_UINT32, BASE_DEC, NULL, 0x0,
1759             "Preferred ID", HFILL }},
1760
1761         { &hf_isns_dd_set_id,
1762           { "DD Set ID","isns.dd_set_id",
1763             FT_UINT32, BASE_DEC, NULL, 0x0,
1764             "DD Set ID", HFILL }},
1765
1766         { &hf_isns_dd_id,
1767           { "DD ID","isns.dd_id",
1768             FT_UINT32, BASE_DEC, NULL, 0x0,
1769             "DD ID", HFILL }},
1770
1771         { &hf_isns_port_id,
1772           { "Port ID","isns.port_id",
1773             FT_UINT24, BASE_HEX, NULL, 0x0,
1774             "Port ID", HFILL }},
1775
1776         { &hf_isns_hard_address,
1777           { "Hard Address","isns.hard_address",
1778             FT_UINT24, BASE_HEX, NULL, 0x0,
1779             "Hard Address", HFILL }},
1780
1781         { &hf_isns_wwnn_token,
1782           { "WWNN Token","isns.wwnn_token",
1783             FT_UINT64, BASE_HEX, NULL, 0x0,
1784             "WWNN Token", HFILL }},
1785
1786         { &hf_isns_fc_port_name_wwpn,
1787           { "FC Port Name WWPN","isns.fc_port_name_wwpn",
1788             FT_UINT64, BASE_HEX, NULL, 0x0,
1789             "FC Port Name WWPN", HFILL }},
1790
1791         { &hf_isns_fc_node_name_wwnn,
1792           { "FC Node Name WWNN","isns.fc_node_name_wwnn",
1793             FT_UINT64, BASE_HEX, NULL, 0x0,
1794             "FC Node Name WWNN", HFILL }},
1795
1796         { &hf_isns_node_ipa,
1797           { "Node IPA","isns.node_ipa",
1798             FT_UINT64, BASE_HEX, NULL, 0x0,
1799             "Node IPA", HFILL }},
1800
1801         { &hf_isns_fabric_port_name,
1802           { "Fabric Port Name","isns.fabric_port_name",
1803             FT_UINT64, BASE_HEX, NULL, 0x0,
1804             "Fabric Port Name", HFILL }},
1805
1806         { &hf_isns_permanent_port_name,
1807           { "Permanent Port Name","isns.permanent_port_name",
1808             FT_UINT64, BASE_HEX, NULL, 0x0,
1809             "Permanent Port Name", HFILL }},
1810
1811         { &hf_isns_switch_name,
1812           { "Switch Name","isns.switch_name",
1813             FT_UINT64, BASE_HEX, NULL, 0x0,
1814             "Switch Name", HFILL }},
1815
1816         { &hf_isns_dd_set_next_id,
1817           { "DD Set Next ID","isns.dd_set_next_id",
1818             FT_UINT32, BASE_DEC, NULL, 0x0,
1819             "DD Set Next ID", HFILL }},
1820
1821         { &hf_isns_assigned_id,
1822           { "Assigned ID","isns.assigned_id",
1823             FT_UINT32, BASE_DEC, NULL, 0x0,
1824             "Assigned ID", HFILL }},
1825
1826         { &hf_isns_node_index,
1827           { "Node Index","isns.node.index",
1828             FT_UINT32, BASE_DEC, NULL, 0x0,
1829             "Node Index", HFILL }},
1830
1831         { &hf_isns_node_next_index,
1832           { "Node Next Index","isns.node.next_index",
1833             FT_UINT32, BASE_DEC, NULL, 0x0,
1834             "Node INext ndex", HFILL }},
1835
1836         { &hf_isns_portal_index,
1837           { "Portal Index","isns.portal.index",
1838             FT_UINT32, BASE_DEC, NULL, 0x0,
1839             "Portal Index", HFILL }},
1840
1841         { &hf_isns_portal_next_index,
1842           { "Portal Next Index","isns.portal.next_index",
1843             FT_UINT32, BASE_DEC, NULL, 0x0,
1844             "Portal Next Index", HFILL }},
1845
1846         { &hf_isns_entity_index,
1847           { "Entity Index","isns.entity.index",
1848             FT_UINT32, BASE_DEC, NULL, 0x0,
1849             "Entity Index", HFILL }},
1850
1851         { &hf_isns_entity_next_index,
1852           { "Entity Next Index","isns.entity.next_index",
1853             FT_UINT32, BASE_DEC, NULL, 0x0,
1854             "Next Entity Index", HFILL }},
1855
1856         { &hf_isns_timestamp,
1857           { "Timestamp","isns.timestamp",
1858             FT_UINT64, BASE_DEC, NULL, 0x0,
1859             "Timestamp in Seconds", HFILL }},
1860
1861         { &hf_isns_esi_interval,
1862           { "ESI Interval","isns.esi_interval",
1863             FT_UINT32, BASE_DEC, NULL, 0x0,
1864             "ESI Interval in Seconds", HFILL }},
1865
1866         { &hf_isns_registration_period,
1867           { "Registration Period","isns.registration_period",
1868             FT_UINT32, BASE_DEC, NULL, 0x0,
1869             "Registration Period in Seconds", HFILL }},
1870
1871         { &hf_isns_portal_group_tag,
1872           { "PG Tag","isns.portal_group_tag",
1873             FT_UINT32, BASE_DEC, NULL, 0x0,
1874             "Portal Group Tag", HFILL }},
1875
1876         { &hf_isns_payload,
1877           { "Payload", "isns.payload",
1878             FT_BYTES, BASE_HEX, NULL, 0,
1879             "Payload" ,HFILL}
1880         }
1881     };
1882
1883 /* Setup protocol subtree array */
1884     static gint *ett[] = {
1885         &ett_isns,
1886         &ett_isns_flags,
1887         &ett_isns_payload,
1888         &ett_isns_attribute,
1889         &ett_isns_port,
1890         &ett_isns_isnt
1891     };
1892     module_t *isns_module;
1893
1894 /* Register the protocol name and description */
1895     proto_isns = proto_register_protocol("iSNS",
1896                                          "iSNS", "isns");
1897     proto_register_field_array(proto_isns, hf, array_length(hf));
1898     proto_register_subtree_array(ett, array_length(ett));
1899
1900     /* Register preferences */
1901     isns_module = prefs_register_protocol(proto_isns, NULL);
1902     prefs_register_bool_preference(isns_module, "desegment",
1903         "Desegment iSNS over TCP messages",
1904         "Whether the dissector should desegment "
1905         "multi-segment iSNS messages", &isns_desegment);
1906
1907 }
1908
1909 /* If this dissector uses sub-dissector registration add a registration routine.
1910    This format is required because a script is used to find these routines and
1911    create the code that calls these routines.
1912 */
1913
1914 void
1915 proto_reg_handoff_isns(void)
1916 {
1917     isns_tcp_handle = create_dissector_handle(dissect_isns_tcp,proto_isns);
1918     isns_udp_handle = create_dissector_handle(dissect_isns_udp,proto_isns);
1919
1920     dissector_add("tcp.port",ISNS_TCP_PORT,isns_tcp_handle);
1921     dissector_add("udp.port",ISNS_UDP_PORT,isns_udp_handle);
1922 }