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