Fixup: tvb_* -> tvb_captured
[metze/wireshark/wip.git] / epan / dissectors / packet-reload.c
1 /* packet-reload.c
2  * Routines for REsource LOcation And Discovery (RELOAD) Base Protocol
3  * Author: Stephane Bryant <sbryant@glycon.org>
4  * Copyright 2010 Stonyfish Inc.
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  * Please refer to the following specs for protocol detail:
25  * - draft-ietf-p2psip-base-18
26  * - draft-ietf-p2psip-sip-06
27  * - draft-ietf-p2psip-service-discovery-03
28  * - draft-ietf-p2psip-self-tuning-04
29  * - draft-ietf-p2psip-diagnostics-10
30  * - draft-zong-p2psip-drr-01
31  */
32
33 #include "config.h"
34
35 #include <epan/conversation.h>
36 #include <epan/prefs.h>
37 #include <epan/reassemble.h>
38 #include <epan/expert.h>
39 #include <epan/asn1.h>
40 #include <epan/uat.h>
41 #include <epan/wmem/wmem.h>
42 #include <epan/to_str.h>
43 #include <epan/dissectors/packet-x509af.h>
44 #include <packet-tcp.h>
45 #include <packet-ssl-utils.h>
46 #include <packet-reload.h>
47
48 void proto_register_reload(void);
49 void proto_reg_handoff_reload(void);
50
51 /* Initialize the protocol and registered fields */
52 static int proto_reload = -1;
53
54
55 static int hf_reload_response_in = -1;
56 static int hf_reload_response_to = -1;
57 static int hf_reload_time = -1;
58 static int hf_reload_duplicate = -1;
59 static int hf_reload_token = -1;
60 static int hf_reload_forwarding = -1;
61 static int hf_reload_overlay = -1;
62 static int hf_reload_configuration_sequence = -1;
63 static int hf_reload_version = -1;
64 static int hf_reload_ttl = -1;
65 static int hf_reload_fragment_flag = -1;
66 static int hf_reload_fragment_fragmented = -1;
67 static int hf_reload_fragment_last_fragment = -1;
68 static int hf_reload_fragment_reserved = -1;
69 static int hf_reload_fragment_offset = -1;
70 static int hf_reload_trans_id = -1;
71 static int hf_reload_max_response_length = -1;
72 static int hf_reload_via_list_length = -1;
73 static int hf_reload_destination_list_length = -1;
74 static int hf_reload_options_length = -1;
75 static int hf_reload_via_list = -1;
76 static int hf_reload_destination = -1;
77 static int hf_reload_destination_compressed_id = -1;
78 static int hf_reload_destination_type = -1;
79 static int hf_reload_nodeid = -1;
80 static int hf_reload_resourceid = -1;
81 static int hf_reload_value = -1;
82 static int hf_reload_destination_data_node_id = -1;
83 static int hf_reload_destination_data_resource_id = -1;
84 static int hf_reload_destination_data_compressed_id = -1;
85 static int hf_reload_destination_list = -1;
86 static int hf_reload_forwarding_options = -1;
87 static int hf_reload_forwarding_option = -1;
88 static int hf_reload_forwarding_option_type = -1;
89 static int hf_reload_forwarding_option_flags = -1;
90 static int hf_reload_forwarding_option_flag_response_copy = -1;
91 static int hf_reload_forwarding_option_flag_destination_critical = -1;
92 static int hf_reload_forwarding_option_flag_forward_critical = -1;
93 static int hf_reload_forwarding_option_flag_ignore_state_keeping = -1;
94 static int hf_reload_attachreqans = -1;
95 static int hf_reload_ufrag = -1;
96 static int hf_reload_password = -1;
97 static int hf_reload_role = -1;
98 static int hf_reload_sendupdate = -1;
99 static int hf_reload_icecandidates = -1;
100 static int hf_reload_icecandidate = -1;
101 static int hf_reload_icecandidate_addr_port = -1;
102 static int hf_reload_icecandidate_relay_addr = -1;
103 static int hf_reload_icecandidate_foundation = -1;
104 static int hf_reload_icecandidate_priority = -1;
105 static int hf_reload_icecandidate_type = -1;
106 static int hf_reload_overlaylink_type = -1;
107 static int hf_reload_iceextension = -1;
108 static int hf_reload_iceextensions = -1;
109 static int hf_reload_iceextension_name = -1;
110 static int hf_reload_iceextension_value = -1;
111 static int hf_reload_ipaddressport = -1;
112 static int hf_reload_ipaddressport_type = -1;
113 static int hf_reload_ipv4addrport = -1;
114 static int hf_reload_ipv4addr = -1;
115 static int hf_reload_port = -1;
116 static int hf_reload_ipv6addrport = -1;
117 static int hf_reload_ipv6addr = -1;
118 static int hf_reload_message_contents = -1;
119 static int hf_reload_message_code = -1;
120 static int hf_reload_message_body = -1;
121 static int hf_reload_message_extensions = -1;
122 static int hf_reload_message_extension = -1;
123 static int hf_reload_message_extension_type = -1;
124 static int hf_reload_message_extension_critical = -1;
125 static int hf_reload_message_extension_content = -1;
126 static int hf_reload_error_response = -1;
127 static int hf_reload_error_response_code = -1;
128 static int hf_reload_error_response_info = -1;
129 static int hf_reload_security_block = -1;
130 static int hf_reload_certificates = -1;
131 static int hf_reload_genericcertificate = -1;
132 static int hf_reload_certificate_type = -1;
133 static int hf_reload_certificate = -1;
134 static int hf_reload_signature = -1;
135 static int hf_reload_signatureandhashalgorithm = -1;
136 static int hf_reload_hash_algorithm = -1;
137 static int hf_reload_signature_algorithm = -1;
138 static int hf_reload_signeridentity = -1;
139 static int hf_reload_signeridentity_type = -1;
140 static int hf_reload_signeridentity_identity = -1;
141 static int hf_reload_signeridentity_value = -1;
142 static int hf_reload_signeridentity_value_hash_alg = -1;
143 static int hf_reload_signeridentity_value_certificate_hash = -1;
144 static int hf_reload_signeridentity_value_certificate_node_id_hash = -1;
145 static int hf_reload_signature_value = -1;
146 static int hf_reload_length_uint8 = -1;
147 static int hf_reload_length_uint16 = -1;
148 static int hf_reload_length_uint24 = -1;
149 static int hf_reload_length_uint32 = -1;
150 static int hf_reload_opaque = -1;
151 static int hf_reload_opaque_data = -1;
152 static int hf_reload_opaque_string = -1;
153 static int hf_reload_routequeryreq = -1;
154 static int hf_reload_routequeryreq_destination = -1;
155 static int hf_reload_overlay_specific = -1;
156 static int hf_reload_probereq = -1;
157 static int hf_reload_probereq_requested_info = -1;
158 static int hf_reload_probe_information_type = -1;
159 static int hf_reload_probe_information = -1;
160 static int hf_reload_probe_information_data = -1;
161 static int hf_reload_responsible_set = -1;
162 static int hf_reload_num_resources = -1;
163 static int hf_reload_uptime = -1;
164 static int hf_reload_probeans = -1;
165 static int hf_reload_probeans_probe_info = -1;
166 static int hf_reload_appattachreq = -1;
167 static int hf_reload_appattachans = -1;
168 static int hf_reload_application = -1;
169 static int hf_reload_pingreq = -1;
170 static int hf_reload_pingans = -1;
171 static int hf_reload_ping_response_id = -1;
172 static int hf_reload_ping_time = -1;
173 static int hf_reload_storeddata = -1;
174 static int hf_reload_storedmetadata = -1;
175 static int hf_reload_storeddata_storage_time =  -1;
176 static int hf_reload_storeddata_lifetime = -1;
177 static int hf_reload_datavalue = -1;
178 static int hf_reload_metadata = -1;
179 static int hf_reload_datavalue_exists = -1;
180 static int hf_reload_datavalue_value = -1;
181 static int hf_reload_metadata_value_length = -1;
182 static int hf_reload_metadata_hash_value = -1;
183 static int hf_reload_arrayentry = -1;
184 static int hf_reload_arrayentry_value = -1;
185 static int hf_reload_arrayentry_index = -1;
186 static int hf_reload_dictionaryentry = -1;
187 static int hf_reload_dictionarykey = -1;
188 static int hf_reload_dictionary_value = -1;
189 static int hf_reload_kinddata = -1;
190 static int hf_reload_findkinddata_closest = -1;
191 static int hf_reload_kinddata_kind = -1;
192 static int hf_reload_statkindresponse = -1;
193 static int hf_reload_kindid = -1;
194 static int hf_reload_kindid_list = -1;
195 static int hf_reload_generation_counter = -1;
196 static int hf_reload_values = -1;
197 static int hf_reload_storereq = -1;
198 static int hf_reload_resource = -1;
199 static int hf_reload_store_replica_num = -1;
200 static int hf_reload_store_kind_data = -1;
201 static int hf_reload_storeans = -1;
202 static int hf_reload_storeans_kind_responses = -1;
203 static int hf_reload_storekindresponse = -1;
204 static int hf_reload_replicas = -1;
205 static int hf_reload_statreq = -1;
206 static int hf_reload_fetchreq = -1;
207 static int hf_reload_fetchreq_specifiers = -1;
208 static int hf_reload_storeddataspecifier = -1;
209 static int hf_reload_storeddataspecifier_indices = -1;
210 static int hf_reload_storeddataspecifier_keys = -1;
211 static int hf_reload_arrayrange = -1;
212 static int hf_reload_fetchans = -1;
213 static int hf_reload_statans = -1;
214 static int hf_reload_findreq = -1;
215 static int hf_reload_findans = -1;
216 static int hf_reload_findkinddata = -1;
217 static int hf_reload_fragments = -1;
218 static int hf_reload_fragment = -1;
219 static int hf_reload_fragment_overlap = -1;
220 static int hf_reload_fragment_overlap_conflict = -1;
221 static int hf_reload_fragment_multiple_tails = -1;
222 static int hf_reload_fragment_too_long_fragment = -1;
223 static int hf_reload_fragment_error = -1;
224 static int hf_reload_fragment_count = -1;
225 static int hf_reload_reassembled_in = -1;
226 static int hf_reload_reassembled_length = -1;
227 static int hf_reload_configupdatereq = -1;
228 static int hf_reload_configupdatereq_type = -1;
229 static int hf_reload_configupdatereq_configdata = -1;
230 static int hf_reload_configupdatereq_kinds = -1;
231 static int hf_reload_kinddescription = -1;
232 static int hf_reload_chordupdate = -1;
233 static int hf_reload_chordupdate_type = -1;
234 static int hf_reload_chordupdate_predecessors = -1;
235 static int hf_reload_chordupdate_successors = -1;
236 static int hf_reload_chordupdate_fingers = -1;
237 static int hf_reload_chordroutequeryans = -1;
238 static int hf_reload_chordroutequeryans_next_peer = -1;
239 static int hf_reload_chordleave = -1;
240 static int hf_reload_chordleave_type = -1;
241 static int hf_reload_chordleave_predecessors = -1;
242 static int hf_reload_chordleave_successors = -1;
243 static int hf_reload_turnserver = -1;
244 static int hf_reload_turnserver_iteration = -1;
245 static int hf_reload_turnserver_server_address = -1;
246 static int hf_reload_sipregistration = -1;
247 static int hf_reload_sipregistration_type = -1;
248 static int hf_reload_sipregistration_data = -1;
249 static int hf_reload_sipregistration_data_uri = -1;
250 static int hf_reload_sipregistration_data_contact_prefs = -1;
251 static int hf_reload_sipregistration_data_destination_list = -1;
252 static int hf_reload_padding = -1;
253 static int hf_reload_redirserviceproviderdata = -1;
254 static int hf_reload_redirserviceproviderdata_serviceprovider = -1;
255 static int hf_reload_redirserviceproviderdata_namespace = -1;
256 static int hf_reload_redirserviceproviderdata_level = -1;
257 static int hf_reload_redirserviceproviderdata_node = -1;
258 static int hf_reload_redirserviceprovider = -1;
259 static int hf_reload_self_tuning_data = -1;
260 static int hf_reload_self_tuning_data_join_rate = -1;
261 static int hf_reload_self_tuning_data_leave_rate = -1;
262 static int hf_reload_self_tuning_data_network_size = -1;
263 static int hf_reload_dmflags = -1;
264 static int hf_reload_dmflag_status_info = -1;
265 static int hf_reload_dmflag_routing_table_size = -1;
266 static int hf_reload_dmflag_process_power = -1;
267 static int hf_reload_dmflag_bandwidth = -1;
268 static int hf_reload_dmflag_software_version = -1;
269 static int hf_reload_dmflag_machine_uptime = -1;
270 static int hf_reload_dmflag_app_uptime = -1;
271 static int hf_reload_dmflag_memory_footprint = -1;
272 static int hf_reload_dmflag_datasize_stored = -1;
273 static int hf_reload_dmflag_instances_stored = -1;
274 static int hf_reload_dmflag_messages_sent_rcvd = -1;
275 static int hf_reload_dmflag_ewma_bytes_sent = -1;
276 static int hf_reload_dmflag_ewma_bytes_rcvd = -1;
277 static int hf_reload_dmflag_underlay_hop = -1;
278 static int hf_reload_dmflag_battery_status = -1;
279 static int hf_reload_diagnosticrequest = -1;
280 static int hf_reload_diagnosticresponse = -1;
281 static int hf_reload_diagnosticextension = -1;
282 static int hf_reload_diagnosticextension_type = -1;
283 static int hf_reload_diagnosticextension_contents = -1;
284 static int hf_reload_diagnostic_expiration = -1;
285 static int hf_reload_diagnosticrequest_timestampinitiated = -1;
286 static int hf_reload_diagnosticrequest_extensions = -1;
287 static int hf_reload_pathtrackreq = -1;
288 static int hf_reload_pathtrackreq_destination = -1;
289 static int hf_reload_pathtrackreq_request = -1;
290 static int hf_reload_diagnosticinfo = -1;
291 static int hf_reload_diagnosticinfo_kind = -1;
292 static int hf_reload_diagnosticinfo_congestion_status = -1;
293 static int hf_reload_diagnosticinfo_number_peers = -1;
294 static int hf_reload_diagnosticinfo_processing_power = -1;
295 static int hf_reload_diagnosticinfo_bandwidth = -1;
296 static int hf_reload_diagnosticinfo_software_version = -1;
297 static int hf_reload_diagnosticinfo_machine_uptime = -1;
298 static int hf_reload_diagnosticinfo_app_uptime = -1;
299 static int hf_reload_diagnosticinfo_memory_footprint = -1;
300 static int hf_reload_diagnosticinfo_datasize_stored = -1;
301 static int hf_reload_diagnosticinfo_instances_stored = -1;
302 static int hf_reload_diagnosticinfo_instancesstored_info = -1;
303 static int hf_reload_diagnosticinfo_instancesstored_instances = -1;
304 static int hf_reload_diagnosticinfo_messages_sent_rcvd = -1;
305 static int hf_reload_diagnosticinfo_messages_sent_rcvd_info = -1;
306 static int hf_reload_diagnosticinfo_message_code = -1;
307 static int hf_reload_diagnosticinfo_messages_sent = -1;
308 static int hf_reload_diagnosticinfo_messages_rcvd = -1;
309 static int hf_reload_diagnosticinfo_ewma_bytes_sent = -1;
310 static int hf_reload_diagnosticinfo_ewma_bytes_rcvd = -1;
311 static int hf_reload_diagnosticinfo_underlay_hops = -1;
312 static int hf_reload_diagnosticinfo_battery_status = -1;
313 static int hf_reload_diagnosticresponse_timestampreceived = -1;
314 static int hf_reload_diagnosticresponse_hopcounter = -1;
315 static int hf_reload_diagnosticresponse_diagnostic_info_list = -1;
316 static int hf_reload_pathtrackans = -1;
317 static int hf_reload_pathtrackans_next_hop = -1;
318 static int hf_reload_pathtrackans_response = -1;
319 static int hf_reload_extensiveroutingmodeoption = -1;
320 static int hf_reload_routemode = -1;
321 static int hf_reload_extensiveroutingmode_transport = -1;
322 static int hf_reload_extensiveroutingmode_ipaddressport = -1;
323 static int hf_reload_extensiveroutingmode_destination = -1;
324 static int hf_reload_joinreq = -1;
325 static int hf_reload_joinreq_joining_peer_id = -1;
326 static int hf_reload_joinans = -1;
327 static int hf_reload_leavereq = -1;
328 static int hf_reload_leavereq_leaving_peer_id = -1;
329
330 static dissector_handle_t data_handle;
331 static dissector_handle_t xml_handle;
332
333
334 /* Structure containing transaction specific information */
335 typedef struct _reload_transaction_t {
336   guint32  req_frame;
337   guint32  rep_frame;
338   nstime_t req_time;
339 } reload_transaction_t;
340
341 /* Structure containing conversation specific information */
342 typedef struct _reload_conv_info_t {
343   wmem_tree_t *transaction_pdus;
344 } reload_conv_info_t;
345
346
347 /* RELOAD Message classes = (message_code & 0x1) (response = request +1) */
348 #define RELOAD_REQUEST         0x0001
349 #define RELOAD_RESPONSE        0x0000
350
351 #define RELOAD_ERROR           0xffff
352
353 #define VERSION_DRAFT          0x01
354
355 /* RELOAD Message Methods = (message_code +1) & 0xfffe*/
356 #define METHOD_INVALID                     0
357 #define METHOD_PROBE                       2
358 #define METHOD_ATTACH                      4
359 #define METHOD_STORE                       8
360 #define METHOD_FETCH                      10
361 #define METHOD_UNUSED_REMOVE              12
362 #define METHOD_FIND                       14
363 #define METHOD_JOIN                       16
364 #define METHOD_LEAVE                      18
365 #define METHOD_UPDATE                     20
366 #define METHOD_ROUTEQUERY                 22
367 #define METHOD_PING                       24
368 #define METHOD_STAT                       26
369 #define METHOD_UNUSED_ATTACHLIGHT         28
370 #define METHOD_APPATTACH                  30
371 #define METHOD_UNUSED_APP_ATTACHLIGHT     32
372 #define METHOD_CONFIGUPDATE               34
373 #define METHOD_EXP_A                      36
374 #define METHOD_EXP_B                      38
375 #define METHOD_PATH_TRACK                102
376 #define METHOD_ERROR                  0xfffe
377
378
379 /* RELOAD Destinationtype */
380 #define DESTINATIONTYPE_RESERVED            0
381 #define DESTINATIONTYPE_NODE                1
382 #define DESTINATIONTYPE_RESOURCE            2
383 #define DESTINATIONTYPE_COMPRESSED          3
384
385 /* RELOAD forwarding option type */
386 #define OPTIONTYPE_RESERVED                 0
387 #define OPTIONTYPE_EXTENSIVE_ROUTING_MODE   2
388
389 /* RELOAD CandTypes */
390 #define CANDTYPE_RESERVED        0
391 #define CANDTYPE_HOST            1
392 #define CANDTYPE_SRFLX           2
393 #define CANDTYPE_PRFLX           3
394 #define CANDTYPE_RELAY           4
395
396 /* IpAddressPort types */
397 #define IPADDRESSPORTTYPE_RESERVED 0
398 #define IPADDRESSPORTTYPE_IPV4     1
399 #define IPADDRESSPORTTYPE_IPV6     2
400
401 /* OverlayLink types */
402 #define OVERLAYLINKTYPE_RESERVED                     0
403 #define OVERLAYLINKTYPE_DTLS_UDP_SR                  1
404 #define OVERLAYLINKTYPE_DTLS_UDP_SR_NO_ICE           3
405 #define OVERLAYLINKTYPE_TLS_TCP_FH_NO_ICE            4
406 #define OVERLAYLINKTYPE_EXP_LINK                     5
407
408 #define ERRORCODE_INVALID                            0
409 #define ERRORCODE_UNUSED                             1
410 #define ERRORCODE_FORBIDDEN                          2
411 #define ERRORCODE_NOTFOUND                           3
412 #define ERRORCODE_REQUESTTIMEOUT                     4
413 #define ERRORCODE_GENERATIONCOUNTERTOOLOW            5
414 #define ERRORCODE_INCOMPATIBLEWITHOVERLAY            6
415 #define ERRORCODE_UNSUPPORTEDFORWARDINGOPTION        7
416 #define ERRORCODE_DATATOOLARGE                       8
417 #define ERRORCODE_DATATOOOLD                         9
418 #define ERRORCODE_TTLEXCEEDED                       10
419 #define ERRORCODE_MESSAGETOOLARGE                   11
420 #define ERRORCODE_UNKNOWNKIND                       12
421 #define ERRORCODE_UNKNOWNEXTENSION                  13
422 #define ERRORCODE_RESPONSETOOLARGE                  14
423 #define ERRORCODE_CONFIGTOOOLD                      15
424 #define ERRORCODE_CONFIGTOONEW                      16
425 #define ERRORCODE_INPROGRESS                        17
426 #define ERRORCODE_EXP_A                             18
427 #define ERRORCODE_EXP_B                             19
428 #define ERRORCODE_UNDERLAY_DESTINATION_UNREACHABLE 101
429 #define ERRORCODE_UNDERLAY_TIME_EXCEEDED           102
430 #define ERRORCODE_MESSAGE_EXPIRED                  103
431 #define ERRORCODE_MISROUTING                       104
432 #define ERRORCODE_LOOP_DETECTED                    105
433 #define ERRORCODE_TTL_HOPS_EXCEEDED                106
434
435
436 /* Signer identity types */
437 #define SIGNERIDENTITYTYPE_RESERVED                  0
438 #define SIGNERIDENTITYTYPE_CERTHASH                  1
439 #define SIGNERIDENTITYTYPE_CERTHASHNODEID            2
440 #define SIGNERIDENTITYTYPE_NONE                      3
441
442 /* Probe information type */
443 #define PROBEINFORMATIONTYPE_RESERVED                0
444 #define PROBEINFORMATIONTYPE_RESPONSIBLESET          1
445 #define PROBEINFORMATIONTYPE_NUMRESOURCES            2
446 #define PROBEINFORMATIONTYPE_UPTIME                  3
447 #define PROBEINFORMATIONTYPE_EXP_PROBE               4
448
449 /* Data Kind ID */
450 #define DATAKINDID_INVALID                           0
451 #define DATAKINDID_SIP_REGISTRATION                  1
452 #define DATAKINDID_TURNSERVICE                       2
453 #define DATAKINDID_CERTIFICATE_BY_NODE               3
454 #define DATAKINDID_RESERVED_ROUTING_TABLE_SIZE       4
455 #define DATAKINDID_RESERVED_SOFTWARE_VERSION         5
456 #define DATAKINDID_RESERVED_MACHINE_UPTIME           6
457 #define DATAKINDID_RESERVED_APP_UPTIME               7
458 #define DATAKINDID_RESERVED_MEMORY_FOOTPRINT         8
459 #define DATAKINDID_RESERVED_DATASIZE_STORED          9
460 #define DATAKINDID_RESERVED_INSTANCES_STORED        10
461 #define DATAKINDID_RESERVED_MESSAGES_SENT_RCVD      11
462 #define DATAKINDID_RESERVED_EWMA_BYTES_SENT         12
463 #define DATAKINDID_RESERVED_EWMA_BYTES_RCVD         13
464 #define DATAKINDID_RESERVED_LAST_CONTACT            14
465 #define DATAKINDID_RESERVED_RTT                     15
466 #define DATAKINDID_CERTIFICATE_BY_USER              16
467 #define DATAKINDID_REDIR                           104
468
469 /* Data model */
470 #define DATAMODEL_SINGLE                             1
471 #define DATAMODEL_ARRAY                              2
472 #define DATAMODEL_DICTIONARY                         3
473
474 /* Message Extension Type */
475 #define MESSAGEEXTENSIONTYPE_RESERVED                0
476 #define MESSAGEEXTENSIONTYPE_EXP_EXT                 1
477 #define MESSAGEEXTENSIONTYPE_SELF_TUNING_DATA        2 /* is 1 */
478 #define MESSAGEEXTENSIONTYPE_DIAGNOSTIC_PING         3 /* is 1 */
479
480 /* Config Update Type */
481 #define CONFIGUPDATETYPE_RESERVED                    0
482 #define CONFIGUPDATETYPE_CONFIG                      1
483 #define CONFIGUPDATETYPE_KIND                        2
484
485 /* Chord Update Type */
486 #define CHORDUPDATETYPE_RESERVED                     0
487 #define CHORDUPDATETYPE_PEER_READY                   1
488 #define CHORDUPDATETYPE_NEIGHBORS                    2
489 #define CHORDUPDATETYPE_FULL                         3
490
491 /* Chord Leave Type */
492 #define CHORDLEAVETYPE_RESERVED                      0
493 #define CHORDLEAVETYPE_FROM_SUCC                     1
494 #define CHORDLEAVETYPE_FROM_PRED                     2
495
496 /* Chord Leave Type */
497 #define SIPREGISTRATIONTYPE_URI                      1
498 #define SIPREGISTRATIONTYPE_ROUTE                    2
499
500 /* Diagnostic Kind Id Type */
501 #define DIAGNOSTICKINDID_RESERVED               0x0000
502 #define DIAGNOSTICKINDID_STATUS_INFO            0x0001
503 #define DIAGNOSTICKINDID_ROUTING_TABLE_SIZE     0x0002
504 #define DIAGNOSTICKINDID_PROCESS_POWER          0x0003
505 #define DIAGNOSTICKINDID_BANDWIDTH              0x0004
506 #define DIAGNOSTICKINDID_SOFTWARE_VERSION       0x0005
507 #define DIAGNOSTICKINDID_MACHINE_UPTIME         0x0006
508 #define DIAGNOSTICKINDID_APP_UPTIME             0x0007
509 #define DIAGNOSTICKINDID_MEMORY_FOOTPRINT       0x0008
510 #define DIAGNOSTICKINDID_DATASIZE_STORED        0x0009
511 #define DIAGNOSTICKINDID_INSTANCES_STORED       0x000A
512 #define DIAGNOSTICKINDID_MESSAGES_SENT_RCVD     0x000B
513 #define DIAGNOSTICKINDID_EWMA_BYTES_SENT        0x000C
514 #define DIAGNOSTICKINDID_EWMA_BYTES_RCVD        0x000D
515 #define DIAGNOSTICKINDID_UNDERLAY_HOP           0x000E
516 #define DIAGNOSTICKINDID_BATTERY_STATUS         0x000F
517
518 /* route modes */
519 #define ROUTEMODE_RESERVED                           0
520 #define ROUTEMODE_DDR                                1
521 #define ROUTEMODE_RPR                                2
522
523 /* Application IDs */
524 #define APPLICATIONID_INVALID                        0
525 #define APPLICATIONID_SIP_5060                    5060
526 #define APPLICATIONID_SIP_5061                    5061
527 #define APPLICATIONID_RESERVED                  0xFFFF
528
529
530 #define TOPOLOGY_PLUGIN_CHORD_RELOAD "CHORD-RELOAD"
531
532 /* reload user configuration variables */
533 static gboolean    reload_defragment      = TRUE;
534 static guint       reload_nodeid_length   = 16;
535 static const char *reload_topology_plugin = TOPOLOGY_PLUGIN_CHORD_RELOAD;
536
537
538 /* Initialize the subtree pointers */
539 static gint ett_reload = -1;
540 static gint ett_reload_forwarding = -1;
541 static gint ett_reload_message = -1;
542 static gint ett_reload_security=-1;
543 static gint ett_reload_fragment_flag=-1;
544 static gint ett_reload_destination = -1;
545 static gint ett_reload_via_list = -1;
546 static gint ett_reload_destination_list = -1;
547 static gint ett_reload_resourceid = -1;
548 static gint ett_reload_forwarding_options = -1;
549 static gint ett_reload_forwarding_option = -1;
550 static gint ett_reload_forwarding_option_flags = -1;
551 static gint ett_reload_forwarding_option_directresponseforwarding = -1;
552 static gint ett_reload_attachreqans = -1;
553 static gint ett_reload_icecandidates = -1;
554 static gint ett_reload_icecandidate = -1;
555 static gint ett_reload_icecandidate_computed_address = -1;
556 static gint ett_reload_iceextension = -1;
557 static gint ett_reload_iceextensions = -1;
558 static gint ett_reload_ipaddressport = -1;
559 static gint ett_reload_ipv4addrport = -1;
560 static gint ett_reload_ipv6addrport = -1;
561 static gint ett_reload_message_contents = -1;
562 static gint ett_reload_message_extensions = -1;
563 static gint ett_reload_message_extension = -1;
564 static gint ett_reload_error_response = -1;
565 static gint ett_reload_security_block = -1;
566 static gint ett_reload_genericcertificate = -1;
567 static gint ett_reload_certificates = -1;
568 static gint ett_reload_signature = -1;
569 static gint ett_reload_signatureandhashalgorithm = -1;
570 static gint ett_reload_signeridentity = -1;
571 static gint ett_reload_signeridentity_identity = -1;
572 static gint ett_reload_signeridentity_value = -1;
573 static gint ett_reload_opaque = -1;
574 static gint ett_reload_message_body = -1;
575 static gint ett_reload_routequeryreq = -1;
576 static gint ett_reload_probereq = -1;
577 static gint ett_reload_probereq_requested_info = -1;
578 static gint ett_reload_probe_information = -1;
579 static gint ett_reload_probe_information_data = -1;
580 static gint ett_reload_probeans = -1;
581 static gint ett_reload_probeans_probe_info = -1;
582 static gint ett_reload_appattach = -1;
583 static gint ett_reload_pingreq = -1;
584 static gint ett_reload_pingans = -1;
585 static gint ett_reload_storeddata = -1;
586 static gint ett_reload_kinddata = -1;
587 static gint ett_reload_values = -1;
588 static gint ett_reload_datavalue = -1;
589 static gint ett_reload_arrayentry = -1;
590 static gint ett_reload_dictionaryentry = -1;
591 static gint ett_reload_storereq = -1;
592 static gint ett_reload_store_kind_data = -1;
593 static gint ett_reload_storeans = -1;
594 static gint ett_reload_storekindresponse = -1;
595 static gint ett_reload_storeans_kind_responses = -1;
596 static gint ett_reload_fetchreq = -1;
597 static gint ett_reload_fetchreq_specifiers = -1;
598 static gint ett_reload_storeddataspecifier = -1;
599 static gint ett_reload_storeddataspecifier_indices = -1;
600 static gint ett_reload_storeddataspecifier_keys = -1;
601 static gint ett_reload_fetchans = -1;
602 static gint ett_reload_statans = -1;
603 static gint ett_reload_findkinddata = -1;
604 static gint ett_reload_fragments = -1;
605 static gint ett_reload_fragment  = -1;
606 static gint ett_reload_configupdatereq = -1;
607 static gint ett_reload_configupdatereq_config_data = -1;
608 static gint ett_reload_kinddescription = -1;
609 static gint ett_reload_configupdatereq_kinds = -1;
610 static gint ett_reload_storekindresponse_replicas = -1;
611 static gint ett_reload_nodeid_list = -1;
612 static gint ett_reload_chordupdate = -1;
613 static gint ett_reload_chordroutequeryans = -1;
614 static gint ett_reload_chordleave = -1;
615 static gint ett_reload_turnserver = -1;
616 static gint ett_reload_sipregistration = -1;
617 static gint ett_reload_sipregistration_data = -1;
618 static gint ett_reload_sipregistration_destination_list = -1;
619 static gint ett_reload_dictionaryentry_key = -1;
620 static gint ett_reload_overlay_specific = -1;
621 static gint ett_reload_kindid_list = -1;
622 static gint ett_reload_redirserviceproviderdata = -1;
623 static gint ett_reload_redirserviceprovider = -1;
624 static gint ett_reload_self_tuning_data = -1;
625 static gint ett_reload_findreq = -1;
626 static gint ett_reload_findans = -1;
627 static gint ett_reload_dmflags = -1;
628 static gint ett_reload_diagnosticextension = -1;
629 static gint ett_reload_diagnosticrequest = -1;
630 static gint ett_reload_diagnosticrequest_extensions = -1;
631 static gint ett_reload_pathtrackreq = -1;
632 static gint ett_reload_diagnosticinfo = -1;
633 static gint ett_reload_diagnosticinfo_instances_stored = -1;
634 static gint ett_reload_diagnosticinfo_instancesstored_info = -1;
635 static gint ett_reload_diagnosticinfo_messages_sent_rcvd = -1;
636 static gint ett_reload_diagnosticinfo_messages_sent_rcvd_info = -1;
637 static gint ett_reload_diagnosticresponse = -1;
638 static gint ett_reload_diagnosticresponse_diagnostic_info_list = -1;
639 static gint ett_reload_pathtrackans = -1;
640 static gint ett_reload_extensiveroutingmodeoption = -1;
641 static gint ett_reload_extensiveroutingmode_destination = -1;
642 static gint ett_reload_joinreq = -1;
643 static gint ett_reload_joinans = -1;
644 static gint ett_reload_leavereq = -1;
645
646 static expert_field ei_reload_truncated_field = EI_INIT;
647 static expert_field ei_reload_truncated_packet = EI_INIT;
648 static expert_field ei_reload_computed_len_too_big = EI_INIT;
649 static expert_field ei_reload_identity_type_unknown = EI_INIT;
650 static expert_field ei_reload_unknown_data_model = EI_INIT;
651 static expert_field ei_reload_no_xml_dissector = EI_INIT;
652
653 static const fragment_items reload_frag_items = {
654   &ett_reload_fragment,
655   &ett_reload_fragments,
656   &hf_reload_fragments,
657   &hf_reload_fragment,
658   &hf_reload_fragment_overlap,
659   &hf_reload_fragment_overlap_conflict,
660   &hf_reload_fragment_multiple_tails,
661   &hf_reload_fragment_too_long_fragment,
662   &hf_reload_fragment_error,
663   &hf_reload_fragment_count,
664   &hf_reload_reassembled_in,
665   &hf_reload_reassembled_length,
666   /* Reassembled data field */
667   NULL,
668   "RELOAD fragments"
669 };
670
671 static const gint *reload_dmflag_items[] = {
672   &hf_reload_dmflag_status_info,
673   &hf_reload_dmflag_routing_table_size,
674   &hf_reload_dmflag_process_power,
675   &hf_reload_dmflag_bandwidth,
676   &hf_reload_dmflag_software_version,
677   &hf_reload_dmflag_machine_uptime,
678   &hf_reload_dmflag_app_uptime,
679   &hf_reload_dmflag_memory_footprint,
680   &hf_reload_dmflag_datasize_stored,
681   &hf_reload_dmflag_instances_stored,
682   &hf_reload_dmflag_messages_sent_rcvd,
683   &hf_reload_dmflag_ewma_bytes_sent,
684   &hf_reload_dmflag_ewma_bytes_rcvd,
685   &hf_reload_dmflag_underlay_hop,
686   &hf_reload_dmflag_battery_status,
687 };
688
689 static uat_t *reloadkindids_uat = NULL;
690
691 typedef struct _Kind {
692   gchar *name;
693   guint32 id;
694   guint data_model;
695
696 } kind_t;
697
698 static kind_t predefined_kinds[] = {
699   {(gchar *)"INVALID"                        ,DATAKINDID_INVALID,                     -1},
700   {(gchar *)"SIP-REGISTRATION"               ,DATAKINDID_SIP_REGISTRATION,            DATAMODEL_DICTIONARY},
701   {(gchar *)"TURN-SERVICE"                   ,DATAKINDID_TURNSERVICE,                 DATAMODEL_SINGLE},
702   {(gchar *)"CERTIFICATE_BY_NODE"            ,DATAKINDID_CERTIFICATE_BY_NODE,         DATAMODEL_ARRAY},
703   {(gchar *)"RESERVED_ROUTING_TABLE_SIZE"    ,DATAKINDID_RESERVED_ROUTING_TABLE_SIZE, -1},
704   {(gchar *)"RESERVED_SOFTWARE_VERSION"      ,DATAKINDID_RESERVED_SOFTWARE_VERSION,   -1},
705   {(gchar *)"RESERVED_MACHINE_UPTIME"        ,DATAKINDID_RESERVED_MACHINE_UPTIME,     -1},
706   {(gchar *)"DATAKINDID_RESERVED_APP_UPTIME" ,DATAKINDID_RESERVED_APP_UPTIME,         -1},
707   {(gchar *)"RESERVED_MEMORY_FOOTPRINT"      ,DATAKINDID_RESERVED_MEMORY_FOOTPRINT,   -1},
708   {(gchar *)"RESERVED_DATASIZE_STORED"       ,DATAKINDID_RESERVED_DATASIZE_STORED,    -1},
709   {(gchar *)"RESERVED_INSTANCES_STORED"      ,DATAKINDID_RESERVED_INSTANCES_STORED,   -1},
710   {(gchar *)"RESERVED_MESSAGES_SENT_RCVD"    ,DATAKINDID_RESERVED_MESSAGES_SENT_RCVD, -1},
711   {(gchar *)"RESERVED_EWMA_BYTES_SENT"       ,DATAKINDID_RESERVED_EWMA_BYTES_SENT,    -1},
712   {(gchar *)"RESERVED_EWMA_BYTES_RCVD"       ,DATAKINDID_RESERVED_EWMA_BYTES_RCVD,    -1},
713   {(gchar *)"RESERVED_LAST_CONTACT"          ,DATAKINDID_RESERVED_LAST_CONTACT,       -1},
714   {(gchar *)"RESERVED_RTT"                   ,DATAKINDID_RESERVED_RTT,                -1},
715   {(gchar *)"CERTIFICATE_BY_USER"            ,DATAKINDID_CERTIFICATE_BY_USER,         DATAMODEL_ARRAY},
716   {(gchar *)"REDIR"                          ,DATAKINDID_REDIR,                       DATAMODEL_DICTIONARY},
717 };
718
719
720 static kind_t * kindidlist_uats = NULL;
721
722 static guint nreloadkinds = 0;
723
724 static kind_t * getKindFromId(guint32 id) {
725   guint i;
726   /* user defined kinds have precedence */
727   for (i = 0; i < nreloadkinds; i++) {
728     if (id == kindidlist_uats[i].id) {
729       return (kindidlist_uats+i);
730     }
731   }
732
733   /* then pre-defined kinds */
734   {
735     guint npredefinedkinds = sizeof(predefined_kinds) / sizeof(kind_t);
736     for (i = 0; i < npredefinedkinds; i++) {
737       if (id == predefined_kinds[i].id) {
738         return (predefined_kinds+i);
739       }
740     }
741   }
742   return NULL;
743 }
744
745 /*-------------------------------------
746  * UAT for Kind-IDs
747  *-------------------------------------
748  */
749
750
751 static void* uat_kindid_copy_cb(void* n, const void* o, size_t siz _U_) {
752   kind_t * new_record = (kind_t *)n;
753   const kind_t* old_record = (const kind_t *)o;
754
755   if (old_record->name) {
756     new_record->name = g_strdup(old_record->name);
757   } else {
758     new_record->name = NULL;
759   }
760
761   return new_record;
762 }
763
764 static void uat_kindid_record_free_cb(void*r) {
765   kind_t* rec = (kind_t *)r;
766
767   if (rec->name) g_free(rec->name);
768 }
769
770 UAT_DEC_CB_DEF(kindidlist_uats,id,kind_t)
771 UAT_CSTRING_CB_DEF(kindidlist_uats,name,kind_t)
772 UAT_VS_DEF(kindidlist_uats,data_model,kind_t,guint,0,"string")
773
774
775 #define MSG_LENGH_OFFSET                16
776 #define MIN_HDR_LENGTH                  38      /* Forwarding header till options_length member (included) */
777
778 #define RELOAD_TOKEN                    0xd2454c4f
779
780 #define IS_REQUEST(code)                (code & 0x0001)
781 #define MSGCODE_TO_METHOD(code)         ((code + 1) & 0xfffe)
782 #define MSGCODE_TO_CLASS(code)          (code & 0x0001)
783
784
785 static const value_string versions[] = {
786   {VERSION_DRAFT,                               "0.1 DRAFT"},
787   {0x00, NULL}
788 };
789
790 static const value_string classes[] = {
791   {RELOAD_REQUEST,                              "Request"},
792   {RELOAD_RESPONSE,                             "Response"},
793   {0x00, NULL}
794 };
795
796 static const value_string methods[] = {
797   {METHOD_INVALID,                              "invalid"},
798   {METHOD_PROBE,                                "Probe"},
799   {METHOD_ATTACH,                               "Attach"},
800   {METHOD_STORE,                                "Store"},
801   {METHOD_FETCH,                                "Fetch"},
802   {METHOD_UNUSED_REMOVE,                        "Remove (Unused)"},
803   {METHOD_FIND,                                 "Find"},
804   {METHOD_JOIN,                                 "Join"},
805   {METHOD_LEAVE,                                "Leave"},
806   {METHOD_UPDATE,                               "Update"},
807   {METHOD_ROUTEQUERY,                           "RouteQuery"},
808   {METHOD_PING,                                 "Ping"},
809   {METHOD_STAT,                                 "Stat"},
810   {METHOD_UNUSED_ATTACHLIGHT,                   "AttachLight (Unused)"},
811   {METHOD_APPATTACH,                            "AppAttach"},
812   {METHOD_UNUSED_APP_ATTACHLIGHT,               "AppAttachLight (Unused)"},
813   {METHOD_CONFIGUPDATE,                         "ConfigUpdate"},
814   {METHOD_EXP_A,                                "Exp_B"},
815   {METHOD_EXP_B,                                "Exp_A"},
816   {METHOD_PATH_TRACK,                           "Path_Track"},
817   {METHOD_ERROR,                                "Error"},
818   {0x00, NULL}
819 };
820
821 static const value_string classes_short[] = {
822   {RELOAD_REQUEST,                              "req"},
823   {RELOAD_RESPONSE,                             "ans"},
824   {0x00, NULL}
825 };
826
827 static const value_string classes_Short[] = {
828   {RELOAD_REQUEST,                              "Req"},
829   {RELOAD_RESPONSE,                             "Ans"},
830   {0x00, NULL}
831 };
832
833 static const value_string methods_short[] = {
834   {METHOD_INVALID,                              "invalid"},
835   {METHOD_PROBE,                                "probe"},
836   {METHOD_ATTACH,                               "attach"},
837   {METHOD_STORE,                                "store"},
838   {METHOD_FETCH,                                "fetch"},
839   {METHOD_UNUSED_REMOVE,                        "unused_remove"},
840   {METHOD_FIND,                                 "find"},
841   {METHOD_JOIN,                                 "join"},
842   {METHOD_LEAVE,                                "leave"},
843   {METHOD_UPDATE,                               "update"},
844   {METHOD_ROUTEQUERY,                           "route_query"},
845   {METHOD_PING,                                 "ping"},
846   {METHOD_STAT,                                 "stat"},
847   {METHOD_UNUSED_ATTACHLIGHT,                   "unused_attachlight"},
848   {METHOD_APPATTACH,                            "app_attach"},
849   {METHOD_UNUSED_APP_ATTACHLIGHT,               "unused_app_attachlight"},
850   {METHOD_CONFIGUPDATE,                         "config_update"},
851   {METHOD_EXP_A,                                "exp_a"},
852   {METHOD_EXP_B,                                "exp_b"},
853   {METHOD_PATH_TRACK,                           "path_track"},
854   {METHOD_ERROR,                                "error"},
855   {0x00, NULL}
856 };
857
858
859
860 static const value_string destinationtypes[] = {
861   {DESTINATIONTYPE_RESERVED,                    "reserved"},
862   {DESTINATIONTYPE_NODE,                        "node"},
863   {DESTINATIONTYPE_RESOURCE,                    "resource"},
864   {DESTINATIONTYPE_COMPRESSED,                  "compressed"},
865   {0x00, NULL}
866 };
867
868 static const value_string forwardingoptiontypes[] = {
869   {OPTIONTYPE_RESERVED,                         "reserved"},
870   {OPTIONTYPE_EXTENSIVE_ROUTING_MODE,           "extensive_routing_mode"},
871   {0x00, NULL}
872 };
873
874 static const value_string candtypes[] = {
875   {CANDTYPE_RESERVED,                           "reserved"},
876   {CANDTYPE_HOST,                               "host"},
877   {CANDTYPE_SRFLX,                              "srflx"},
878   {CANDTYPE_PRFLX,                              "prflx"},
879   {CANDTYPE_RELAY,                              "relay"},
880   {0x00, NULL}
881 };
882
883 static const value_string ipaddressporttypes [] = {
884   {IPADDRESSPORTTYPE_RESERVED,                  "reserved"},
885   {IPADDRESSPORTTYPE_IPV4,                      "IPV4"},
886   {IPADDRESSPORTTYPE_IPV6,                      "IPV6"},
887   {0x00, NULL}
888 };
889
890 static const value_string overlaylinktypes [] = {
891   {OVERLAYLINKTYPE_RESERVED,                    "reserved"},
892   {OVERLAYLINKTYPE_DTLS_UDP_SR,                 "DTLS-UDP-SR"},
893   {OVERLAYLINKTYPE_DTLS_UDP_SR_NO_ICE,          "DTLS-UDP-SR-NO-ICE"},
894   {OVERLAYLINKTYPE_TLS_TCP_FH_NO_ICE,           "TLS-TCP-FH-NO-ICE"},
895   {OVERLAYLINKTYPE_EXP_LINK,                    "EXP_LINK"},
896   {0x00, NULL}
897 };
898
899 static const value_string errorcodes [] = {
900   {ERRORCODE_INVALID,                           "invalid"},
901   {ERRORCODE_UNUSED,                            "Unused"},
902   {ERRORCODE_FORBIDDEN,                         "Error_Forbidden"},
903   {ERRORCODE_NOTFOUND,                          "Error_Not_Found"},
904   {ERRORCODE_REQUESTTIMEOUT,                    "Error_Request_Timeout"},
905   {ERRORCODE_GENERATIONCOUNTERTOOLOW,           "Error_Generation_Counter_Too_Low"},
906   {ERRORCODE_INCOMPATIBLEWITHOVERLAY,           "Error_Incompatible_with_Overlay"},
907   {ERRORCODE_UNSUPPORTEDFORWARDINGOPTION,       "Error_Unsupported_Forwarding_Option"},
908   {ERRORCODE_DATATOOLARGE,                      "Error_Data_Too_Large"},
909   {ERRORCODE_DATATOOOLD,                        "Error_Data_Too_Old"},
910   {ERRORCODE_TTLEXCEEDED,                       "Error_TTL_Exceeded"},
911   {ERRORCODE_MESSAGETOOLARGE,                   "Error_Message_Too_Large"},
912   {ERRORCODE_UNKNOWNKIND,                       "Error_Unknown_Kind"},
913   {ERRORCODE_UNKNOWNEXTENSION,                  "Error_Unknown_Extension"},
914   {ERRORCODE_RESPONSETOOLARGE,                  "Error_Response_Too_Large"},
915   {ERRORCODE_CONFIGTOOOLD,                      "Error_Config_Too_Old"},
916   {ERRORCODE_CONFIGTOONEW,                      "Error_Config_Too_New"},
917   {ERRORCODE_CONFIGTOONEW,                      "Error_Config_Too_New"},
918   {ERRORCODE_INPROGRESS,                        "Error_In_Progress"},
919   {ERRORCODE_EXP_A,                             "Error_Exp_A"},
920   {ERRORCODE_EXP_B,                             "Error_Exp_B"},
921   {ERRORCODE_UNDERLAY_DESTINATION_UNREACHABLE,  "Error_Underlay_Destination_Unreachable"},
922   {ERRORCODE_UNDERLAY_TIME_EXCEEDED,            "Error_Underlay_Time_Exceeded"},
923   {ERRORCODE_MESSAGE_EXPIRED,                   "Error_Message_Expired"},
924   {ERRORCODE_MISROUTING,                        "Error_Upstream_Misrouting"},
925   {ERRORCODE_LOOP_DETECTED,                     "Error_Loop_Detected"},
926   {ERRORCODE_TTL_HOPS_EXCEEDED,                 "Error_TTL_Hops_Exceeded"},
927   {0x00, NULL}
928 };
929
930 static const value_string signeridentitytypes[] = {
931   {SIGNERIDENTITYTYPE_RESERVED,                 "reserved"},
932   {SIGNERIDENTITYTYPE_CERTHASH,                 "cert_hash"},
933   {SIGNERIDENTITYTYPE_CERTHASHNODEID,           "cert_hash_node_id"},
934   {SIGNERIDENTITYTYPE_NONE,                     "none"},
935   {0x00, NULL}
936 };
937
938 static const value_string probeinformationtypes[] = {
939   {PROBEINFORMATIONTYPE_RESERVED,               "reserved"},
940   {PROBEINFORMATIONTYPE_RESPONSIBLESET,         "responsible_set"},
941   {PROBEINFORMATIONTYPE_NUMRESOURCES,           "num_resources"},
942   {PROBEINFORMATIONTYPE_UPTIME,                 "uptime"},
943   {PROBEINFORMATIONTYPE_EXP_PROBE,              "exp-probe"},
944   {0x00, NULL}
945 };
946
947
948 static const value_string datamodels[] = {
949   {DATAMODEL_SINGLE, "SINGLE"},
950   {DATAMODEL_ARRAY, "ARRAY"},
951   {DATAMODEL_DICTIONARY, "DICTIONARY"},
952   {0x00, NULL}
953 };
954
955 static const value_string messageextensiontypes[] = {
956   {MESSAGEEXTENSIONTYPE_RESERVED,               "reserved"},
957   {MESSAGEEXTENSIONTYPE_EXP_EXT,                "exp-ext"},
958   {MESSAGEEXTENSIONTYPE_SELF_TUNING_DATA,       "sip_tuning_data"},
959   {MESSAGEEXTENSIONTYPE_DIAGNOSTIC_PING,        "Diagnostic_Ping"},
960   {0x00, NULL}
961 };
962
963
964 static const value_string configupdatetypes[] = {
965   {CONFIGUPDATETYPE_RESERVED,                   "reserved"},
966   {CONFIGUPDATETYPE_CONFIG,                     "config"},
967   {CONFIGUPDATETYPE_KIND,                       "kind"},
968   {0x00, NULL}
969 };
970
971 static const value_string chordupdatetypes[] = {
972   {CHORDUPDATETYPE_RESERVED,                    "reserved"},
973   {CHORDUPDATETYPE_PEER_READY,                  "peer_ready"},
974   {CHORDUPDATETYPE_NEIGHBORS,                   "neighbors"},
975   {CHORDUPDATETYPE_FULL,                        "full"},
976   {0x00, NULL}
977 };
978
979 static const value_string chordleavetypes[] = {
980   {CHORDLEAVETYPE_RESERVED,                     "reserved"},
981   {CHORDLEAVETYPE_FROM_SUCC,                    "from_succ"},
982   {CHORDLEAVETYPE_FROM_PRED,                    "from_pred"},
983   {0x00, NULL}
984 };
985
986 static const value_string sipregistrationtypes[] = {
987   {SIPREGISTRATIONTYPE_URI,                     "sip_registration_uri"},
988   {SIPREGISTRATIONTYPE_ROUTE,                   "sip_registration_route"},
989   {0x00, NULL}
990 };
991
992 static const value_string diagnostickindids[] = {
993   {DIAGNOSTICKINDID_RESERVED,                   "reserved"},
994   {DIAGNOSTICKINDID_STATUS_INFO,                "STATUS_INFO"},
995   {DIAGNOSTICKINDID_ROUTING_TABLE_SIZE,         "ROUTING_TABLE_SIZ"},
996   {DIAGNOSTICKINDID_PROCESS_POWER,              "PROCESS_POWER"},
997   {DIAGNOSTICKINDID_BANDWIDTH,                  "BANDWIDTH"},
998   {DIAGNOSTICKINDID_SOFTWARE_VERSION,           "SOFTWARE_VERSION"},
999   {DIAGNOSTICKINDID_MACHINE_UPTIME,             "MACHINE_UPTIME"},
1000   {DIAGNOSTICKINDID_APP_UPTIME,                 "APP_UPTIME"},
1001   {DIAGNOSTICKINDID_MEMORY_FOOTPRINT,           "MEMORY_FOOTPRINT"},
1002   {DIAGNOSTICKINDID_DATASIZE_STORED,            "DATASIZE_STORED"},
1003   {DIAGNOSTICKINDID_INSTANCES_STORED,           "INSTANCES_STORED"},
1004   {DIAGNOSTICKINDID_MESSAGES_SENT_RCVD,         "MESSAGES_SENT_RCVD"},
1005   {DIAGNOSTICKINDID_EWMA_BYTES_SENT,            "EWMA_BYTES_SENT"},
1006   {DIAGNOSTICKINDID_EWMA_BYTES_RCVD,            "EWMA_BYTES_RCVD"},
1007   {DIAGNOSTICKINDID_UNDERLAY_HOP,               "UNDERLAY_HOP"},
1008   {DIAGNOSTICKINDID_BATTERY_STATUS,             "BATTERY_STATUS"},
1009   {0x00, NULL}
1010 };
1011
1012 static const value_string routemodes[] = {
1013   {ROUTEMODE_RESERVED,                          "reserved"},
1014   {ROUTEMODE_DDR,                               "DDR"},
1015   {ROUTEMODE_RPR,                               "RPR"},
1016   {0x00, NULL}
1017 };
1018
1019 static const value_string applicationids[] = {
1020   /* Application IDs */
1021   {APPLICATIONID_INVALID,                       "INVALID"},
1022   {APPLICATIONID_SIP_5060,                      "SIP"},
1023   {APPLICATIONID_SIP_5061,                      "SIP"},
1024   {APPLICATIONID_RESERVED,                      "Reserved"},
1025   {0x00, NULL}
1026 };
1027
1028
1029 /*
1030  * defragmentation
1031  */
1032 static reassembly_table reload_reassembly_table;
1033
1034 static void
1035 reload_defragment_init(void)
1036 {
1037   reassembly_table_init(&reload_reassembly_table,
1038                         &addresses_reassembly_table_functions);
1039 }
1040
1041
1042 static guint
1043 get_reload_message_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
1044 {
1045   guint32 length = tvb_get_ntohl(tvb, offset + MSG_LENGH_OFFSET);
1046   return length;
1047 }
1048
1049 static int
1050 get_opaque_length(tvbuff_t *tvb, guint16 offset, guint16 length_size)
1051 {
1052   int length = -1;
1053
1054   switch (length_size) {
1055   case 1:
1056     length = (gint32)tvb_get_guint8(tvb,offset);
1057     break;
1058   case 2:
1059     length = (gint32)tvb_get_ntohs(tvb, offset);
1060     break;
1061   case 3:
1062     length = ((gint32) (tvb_get_ntohs(tvb, offset) <<8) + (tvb_get_guint8(tvb, offset+2)));
1063     break;
1064   case 4:
1065     length = (gint32)tvb_get_ntohl(tvb, offset);
1066     break;
1067
1068   default:
1069     break;
1070   }
1071
1072   return length;
1073 }
1074
1075 static int
1076 dissect_opaque_string_or_data(tvbuff_t *tvb, packet_info *pinfo,proto_tree *tree, int anchor_index, guint16 offset, guint16 length_size, gint32 max_field_length, gboolean is_string)
1077 {
1078   proto_tree *opaque_tree;
1079   proto_item *ti_anchor;
1080   gint        length_index     = -1;
1081   gint32      length           = -1;
1082   int         hf               = hf_reload_opaque;
1083   int         hf_data          = hf_reload_opaque_data;
1084   guint       hf_data_encoding = ENC_NA;
1085
1086   if (anchor_index >= 0) {
1087     hf = anchor_index;
1088   }
1089
1090   if (is_string) {
1091     hf_data = hf_reload_opaque_string;
1092     hf_data_encoding = ENC_ASCII|ENC_NA;
1093   }
1094
1095   switch (length_size) {
1096   case 1:
1097     length_index = hf_reload_length_uint8;
1098     length = (gint32)tvb_get_guint8(tvb,offset);
1099     break;
1100   case 2:
1101     length_index = hf_reload_length_uint16;
1102     length = (gint32)tvb_get_ntohs(tvb, offset);
1103     break;
1104   case 3:
1105     length_index = hf_reload_length_uint24;
1106     length = ((gint32) (tvb_get_ntohs(tvb, offset) <<8) + (tvb_get_guint8(tvb, offset+2)));
1107     break;
1108   case 4:
1109     length_index = hf_reload_length_uint32;
1110     length = (gint32)tvb_get_ntohl(tvb, offset);
1111     break;
1112
1113   default:
1114     break;
1115   }
1116
1117   if (length_index < 0) return 0;
1118
1119   ti_anchor = proto_tree_add_item(tree, hf, tvb, offset, length_size + length, ENC_NA);
1120
1121   if (max_field_length > 0) {
1122     if ((length + length_size) > max_field_length) {
1123       expert_add_info(pinfo, ti_anchor, &ei_reload_computed_len_too_big);
1124       length = max_field_length - length_size;
1125     }
1126   }
1127
1128   opaque_tree = proto_item_add_subtree(ti_anchor, ett_reload_opaque);
1129   proto_tree_add_uint(opaque_tree, length_index, tvb, offset, length_size, (guint)length);
1130   if (length) {
1131     proto_tree_add_item(opaque_tree, hf_data, tvb, offset + length_size, length, hf_data_encoding);
1132   }
1133   if (hf != hf_reload_opaque) {
1134     proto_item_append_text(ti_anchor, " (opaque<%d>)", length);
1135   }
1136   else {
1137     proto_item_append_text(ti_anchor, "<%d>", length);
1138   }
1139
1140   return (length_size + length);
1141 }
1142
1143 static int
1144 dissect_opaque(tvbuff_t *tvb, packet_info *pinfo,proto_tree *tree, int anchor_index, guint16 offset, guint16 length_size, gint32 max_field_length) {
1145   return dissect_opaque_string_or_data(tvb, pinfo, tree, anchor_index, offset, length_size, max_field_length, FALSE);
1146 }
1147
1148 static int
1149 dissect_opaque_string(tvbuff_t *tvb, packet_info *pinfo,proto_tree *tree, int anchor_index, guint16 offset, guint16 length_size, gint32 max_field_length) {
1150   return dissect_opaque_string_or_data(tvb, pinfo, tree, anchor_index, offset, length_size, max_field_length, TRUE);
1151 }
1152
1153 static int dissect_length(tvbuff_t *tvb, proto_tree *tree, guint16 offset,  guint16 length_size) {
1154   switch (length_size) {
1155   case 1:
1156     proto_tree_add_item(tree, hf_reload_length_uint8, tvb, offset, 1, ENC_BIG_ENDIAN);
1157     return 1;
1158
1159   case 2:
1160     proto_tree_add_item(tree, hf_reload_length_uint16, tvb, offset, 2, ENC_BIG_ENDIAN);
1161     return 2;
1162
1163   case 3:
1164     proto_tree_add_item(tree, hf_reload_length_uint24, tvb, offset, 3, ENC_BIG_ENDIAN);
1165     return 3;
1166
1167   case 4:
1168     proto_tree_add_item(tree, hf_reload_length_uint32, tvb, offset, 4, ENC_BIG_ENDIAN);
1169     return 4;
1170
1171   default:
1172     break;
1173   }
1174   return 0;
1175 }
1176
1177 static int dissect_resourceid(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1178 {
1179   proto_item *ti_local;
1180   proto_tree *local_tree;
1181   int         hf = hf_reload_resourceid;
1182   guint8      local_length;
1183
1184   if (anchor >= 0) {
1185     hf = anchor;
1186   }
1187
1188   local_length = tvb_get_guint8(tvb, offset);
1189
1190   /* We don't know the node ID. Just assume that all the data is part of it */
1191   if (length < local_length+1) {
1192     ti_local = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1193     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated ResourceId");
1194     return length;
1195   }
1196
1197   ti_local = proto_tree_add_item(tree, hf, tvb, offset, 1+local_length, ENC_NA);
1198   local_tree = proto_item_add_subtree(ti_local, ett_reload_resourceid);
1199   proto_tree_add_item(local_tree, hf_reload_length_uint8, tvb, offset, 1, ENC_BIG_ENDIAN);
1200   proto_tree_add_item(local_tree, hf_reload_opaque_data, tvb, offset+1, local_length, ENC_NA);
1201
1202   if (hf != hf_reload_resourceid) {
1203     proto_item_append_text(ti_local, " (ResourceId<%d>)", local_length);
1204   }
1205   else {
1206     proto_item_append_text(ti_local, "<%d>", local_length);
1207   }
1208
1209   return 1+local_length;
1210 }
1211
1212 static int dissect_nodeid(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1213 {
1214   proto_item *ti_nodeid;
1215   int         hf = hf_reload_nodeid;
1216
1217   if (anchor >= 0) {
1218     hf = anchor;
1219   }
1220
1221   /* We don't know the node ID. Just assume that all the data is part of it */
1222   if (length < reload_nodeid_length) {
1223     ti_nodeid = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1224     expert_add_info_format(pinfo, ti_nodeid, &ei_reload_truncated_field, "Truncated NodeId");
1225     return length;
1226   }
1227
1228   ti_nodeid = proto_tree_add_item(tree, hf, tvb, offset, reload_nodeid_length, ENC_NA);
1229   {
1230     gboolean allZeros = TRUE;
1231     gboolean allOnes  = TRUE;
1232     guint i;
1233
1234     for (i=0; i<reload_nodeid_length; i++) {
1235       guint8 byte = tvb_get_guint8(tvb,offset+i);
1236       if (byte != 0) {
1237         allZeros = FALSE;
1238         if (allOnes == FALSE) break;
1239       }
1240       if (byte != 0xFF) {
1241         allOnes = FALSE;
1242         if (allZeros == FALSE) break;
1243       }
1244     }
1245
1246     if (allZeros) {
1247       proto_item_append_text(ti_nodeid, "\n  [Invalid]");
1248     }
1249     if (allOnes) {
1250       proto_item_append_text(ti_nodeid, "\n  [Wildcard]");
1251     }
1252
1253   }
1254
1255
1256   return reload_nodeid_length;
1257 }
1258
1259 static int
1260 dissect_destination(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1261 {
1262   guint8      destination_type;
1263   proto_tree *destination_tree;
1264   proto_item *ti_destination;
1265   guint8      destination_length = 0;
1266   int         hf                 = hf_reload_destination;
1267
1268   if (anchor >= 0) {
1269     hf = anchor;
1270   }
1271
1272   destination_type = tvb_get_guint8(tvb,offset);
1273
1274   if (destination_type & 0x80) {
1275     /* simple compressed case */
1276     ti_destination = proto_tree_add_item(tree, hf, tvb, offset, 2, ENC_NA);
1277     if (hf == anchor) {
1278       proto_item_append_text(ti_destination, " (Destination)");
1279     }
1280     proto_item_append_text(ti_destination, ": uint16");
1281     destination_tree = proto_item_add_subtree(ti_destination, ett_reload_destination);
1282     proto_tree_add_item(destination_tree,hf_reload_destination_compressed_id , tvb, offset, 2, ENC_BIG_ENDIAN);
1283     return 2;
1284   }
1285   else {
1286     /* normal case */
1287
1288     destination_length = tvb_get_guint8(tvb,offset+1);
1289     ti_destination = proto_tree_add_item(tree, hf, tvb, offset, 2+destination_length, ENC_NA);
1290     if (hf == anchor) {
1291       proto_item_append_text(ti_destination, " (Destination)");
1292     }
1293     destination_tree = proto_item_add_subtree(ti_destination, ett_reload_destination);
1294     proto_item_append_text(ti_destination, ": %s", val_to_str_const(destination_type, destinationtypes, "Unknown"));
1295
1296     proto_tree_add_item(destination_tree, hf_reload_destination_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1297     proto_tree_add_uint(destination_tree, hf_reload_length_uint8, tvb, offset+1, 1, destination_length);
1298     if (2 + destination_length > length) {
1299       expert_add_info_format(pinfo, ti_destination, &ei_reload_truncated_field, "Truncated Destination");
1300       return length;
1301     }
1302     switch(destination_type) {
1303     case DESTINATIONTYPE_NODE:
1304       dissect_nodeid(hf_reload_destination_data_node_id, tvb, pinfo, destination_tree, offset+2, destination_length);
1305       break;
1306
1307     case DESTINATIONTYPE_RESOURCE:
1308       dissect_resourceid(hf_reload_destination_data_resource_id, tvb, pinfo, destination_tree, offset+2, destination_length);
1309       break;
1310
1311     case DESTINATIONTYPE_COMPRESSED:
1312       dissect_opaque(tvb, pinfo, destination_tree, hf_reload_destination_data_compressed_id, offset+2, 1, destination_length);
1313       break;
1314     default:
1315       break;
1316     }
1317
1318   }
1319   return (2+destination_length);
1320 }
1321
1322
1323 static int
1324 dissect_destination_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *list_tree, guint16 offset, guint16 length, int *numDestinations)
1325 {
1326   gint local_offset = 0;
1327   gint local_increment;
1328
1329   *numDestinations  = 0;
1330   while (local_offset +2 <= length) {
1331     local_increment = dissect_destination(-1,tvb, pinfo, list_tree, offset + local_offset, length-local_offset);
1332     if (local_increment <= 0) break;
1333     local_offset += local_increment;
1334     (*numDestinations)++;
1335   }
1336   return local_offset;
1337 }
1338
1339 static int
1340 dissect_probe_information(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1341 {
1342   proto_item *ti_probe_information;
1343   proto_tree *probe_information_tree;
1344   guint8      type;
1345   guint8      probe_length;
1346
1347   type = tvb_get_guint8(tvb, offset);
1348   probe_length = tvb_get_guint8(tvb, offset + 1);
1349
1350   if (probe_length + 2 > length) {
1351     ti_probe_information = proto_tree_add_item(tree, hf_reload_probe_information, tvb, offset, length, ENC_NA);
1352     expert_add_info_format(pinfo, ti_probe_information, &ei_reload_truncated_field, "Truncated probe information");
1353     return length;
1354   }
1355   ti_probe_information = proto_tree_add_item(tree, hf_reload_probe_information, tvb, offset, 2 + probe_length, ENC_NA);
1356   probe_information_tree = proto_item_add_subtree(ti_probe_information, ett_reload_probe_information);
1357
1358   proto_tree_add_item(probe_information_tree, hf_reload_probe_information_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1359   proto_tree_add_uint(probe_information_tree, hf_reload_length_uint8, tvb, offset + 1, 1, probe_length);
1360
1361   {
1362     proto_item *ti_probe_information_data;
1363     proto_tree *probe_information_data_tree;
1364
1365     ti_probe_information_data = proto_tree_add_item(probe_information_tree, hf_reload_probe_information_data, tvb, offset+2, probe_length, ENC_NA);
1366     probe_information_data_tree = proto_item_add_subtree(ti_probe_information_data, ett_reload_probe_information_data);
1367
1368     switch(type) {
1369     case PROBEINFORMATIONTYPE_RESPONSIBLESET:
1370       if (probe_length < 4) {
1371         expert_add_info_format(pinfo, ti_probe_information_data, &ei_reload_truncated_field, "Truncated responsible set");
1372         return 2 + probe_length;
1373       }
1374       proto_tree_add_item(probe_information_data_tree, hf_reload_responsible_set, tvb, offset + 2, 4, ENC_BIG_ENDIAN);
1375       break;
1376     case PROBEINFORMATIONTYPE_NUMRESOURCES:
1377       if (probe_length < 4) {
1378         expert_add_info_format(pinfo, ti_probe_information_data, &ei_reload_truncated_field, "Truncated num resource info");
1379         return 2 + probe_length;
1380       }
1381       proto_tree_add_item(probe_information_data_tree, hf_reload_num_resources, tvb, offset + 2, 4, ENC_BIG_ENDIAN);
1382       break;
1383     case PROBEINFORMATIONTYPE_UPTIME:
1384       if (probe_length < 4) {
1385         expert_add_info_format(pinfo, ti_probe_information_data, &ei_reload_truncated_field, "Truncated uptime info");
1386         return 2 + probe_length;
1387       }
1388       proto_tree_add_item(probe_information_data_tree, hf_reload_uptime, tvb, offset + 2, 4, ENC_BIG_ENDIAN);
1389       break;
1390     default:
1391       break;
1392     }
1393   }
1394   return probe_length + 2;
1395 }
1396
1397
1398
1399 static int
1400 dissect_ipaddressport(int anchor, tvbuff_t *tvb, proto_tree *tree, guint16 offset)
1401 {
1402   proto_item *ti_ipaddressport;
1403   proto_tree *ipaddressport_tree;
1404   guint8      ipaddressport_type;
1405   guint8      ipaddressport_length;
1406   int         hf = hf_reload_ipaddressport;
1407
1408   if (anchor >= 0) {
1409     hf = anchor;
1410   }
1411
1412   ipaddressport_length = tvb_get_guint8(tvb, offset+1);
1413   ti_ipaddressport = proto_tree_add_item(tree, hf, tvb, offset, ipaddressport_length+2, ENC_NA);
1414   if (hf == anchor) proto_item_append_text(ti_ipaddressport, " (IpAddressPort)");
1415   ipaddressport_type = tvb_get_guint8(tvb, offset);
1416   proto_item_append_text(ti_ipaddressport, ": %s", val_to_str_const(ipaddressport_type, ipaddressporttypes,"Unknown Type"));
1417   if (ipaddressport_type == IPADDRESSPORTTYPE_IPV4) {
1418     proto_item_append_text(ti_ipaddressport, " (%s:%d)", tvb_ip_to_str(tvb, offset+2),tvb_get_ntohs(tvb,offset+2+4));
1419   }
1420   else if (ipaddressport_type == IPADDRESSPORTTYPE_IPV6) {
1421     proto_item_append_text(ti_ipaddressport, " (%s:%d)", tvb_ip6_to_str(tvb, offset+2),tvb_get_ntohs(tvb,offset+2+16));
1422   }
1423   ipaddressport_tree = proto_item_add_subtree(ti_ipaddressport, ett_reload_ipaddressport);
1424   proto_tree_add_item(ipaddressport_tree, hf_reload_ipaddressport_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1425   offset += 1;
1426   proto_tree_add_uint(ipaddressport_tree, hf_reload_length_uint8, tvb, offset, 1, ipaddressport_length);
1427   offset += 1;
1428   switch (ipaddressport_type) {
1429   case IPADDRESSPORTTYPE_IPV4:
1430   {
1431     proto_item *ti_ipv4;
1432     proto_tree *ipv4_tree;
1433     ti_ipv4 = proto_tree_add_item(ipaddressport_tree, hf_reload_ipv4addrport, tvb, offset, 6, ENC_NA);
1434     proto_item_append_text(ti_ipv4, ": %s:%d", tvb_ip_to_str(tvb, offset),tvb_get_ntohs(tvb,offset+4));
1435     ipv4_tree = proto_item_add_subtree(ti_ipv4, ett_reload_ipv4addrport);
1436     proto_tree_add_item(ipv4_tree, hf_reload_ipv4addr, tvb, offset, 4, ENC_BIG_ENDIAN);
1437     proto_tree_add_item(ipv4_tree, hf_reload_port, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
1438   }
1439   break;
1440
1441   case IPADDRESSPORTTYPE_IPV6:
1442   {
1443     proto_item *ti_ipv6;
1444     proto_tree *ipv6_tree;
1445     ti_ipv6 = proto_tree_add_item(ipaddressport_tree, hf_reload_ipv6addrport, tvb, offset, 6, ENC_NA);
1446     proto_item_append_text(ti_ipv6, ": %s:%d", tvb_ip6_to_str(tvb, offset),tvb_get_ntohs(tvb,offset+16));
1447     ipv6_tree = proto_item_add_subtree(ti_ipv6, ett_reload_ipv6addrport);
1448     proto_tree_add_item(ipv6_tree, hf_reload_ipv6addr, tvb, offset, 16, ENC_NA);
1449     proto_tree_add_item(ipv6_tree, hf_reload_port, tvb, offset + 16, 2, ENC_BIG_ENDIAN);
1450   }
1451   break;
1452
1453   default:
1454     break;
1455   }
1456
1457
1458   return (int) (2 + ipaddressport_length);
1459 }
1460
1461 static int
1462 dissect_icecandidates(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1463 {
1464   proto_item *ti_icecandidates;
1465   proto_tree *icecandidates_tree;
1466   guint32     icecandidates_offset = 0;
1467   guint32     icecandidates_length;
1468   guint32     local_offset         = 0;
1469   int         nCandidates          = 0;
1470
1471   icecandidates_length = tvb_get_ntohs(tvb, offset);
1472   /* Precalculate the length of the icecandidate list */
1473   if (2+icecandidates_length > length) {
1474     ti_icecandidates = proto_tree_add_item(tree, hf_reload_icecandidates, tvb, offset, length, ENC_NA);
1475     expert_add_info_format(pinfo, ti_icecandidates, &ei_reload_truncated_field, "Truncated ice candidates");
1476     return length;
1477   }
1478
1479   ti_icecandidates = proto_tree_add_item(tree, hf_reload_icecandidates, tvb, offset, 2+icecandidates_length, ENC_NA);
1480   proto_item_append_text(ti_icecandidates, " (IceCandidate<%d>)", icecandidates_length);
1481   icecandidates_tree = proto_item_add_subtree(ti_icecandidates, ett_reload_icecandidates);
1482   proto_tree_add_uint(icecandidates_tree, hf_reload_length_uint16, tvb, offset+local_offset, 2, icecandidates_length);
1483   local_offset += 2;
1484   while (icecandidates_offset < icecandidates_length) {
1485     proto_item *ti_icecandidate;
1486     proto_tree *icecandidate_tree;
1487     guint8 ipaddressport_length;
1488     guint8 computed_ipaddressport_length;
1489     guint16 iceextensions_length;
1490     guint8 foundation_length;
1491     guint8 candtype;
1492     guint16 icecandidate_offset = 0;
1493     /* compute the length */
1494     ipaddressport_length = tvb_get_guint8(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset+1);
1495     icecandidate_offset += 2 + ipaddressport_length;
1496     icecandidate_offset += 1;/* OverlayLink */
1497     foundation_length = tvb_get_guint8(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset);
1498     icecandidate_offset += 1 + foundation_length;
1499     icecandidate_offset += 4;/* priority */
1500     candtype = tvb_get_guint8(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset);
1501     icecandidate_offset += 1;/* candType */
1502     computed_ipaddressport_length = 0;
1503     switch (candtype) {
1504     case CANDTYPE_HOST:
1505       break;
1506     case CANDTYPE_SRFLX:
1507     case CANDTYPE_PRFLX:
1508     case CANDTYPE_RELAY:
1509       /* IpAddressPort */
1510       computed_ipaddressport_length = tvb_get_guint8(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset+1);
1511       icecandidate_offset += computed_ipaddressport_length+2;
1512       break;
1513     default:
1514       break;
1515     }
1516
1517     iceextensions_length = tvb_get_ntohs(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset);
1518     icecandidate_offset += iceextensions_length + 2;
1519
1520     /* icecandidate_offset is now equal to the length of this icecandicate */
1521     if (icecandidates_offset + icecandidate_offset > icecandidates_length) {
1522       expert_add_info_format(pinfo, ti_icecandidates, &ei_reload_truncated_field, "Truncated IceCandidate");
1523       break;
1524     }
1525     ti_icecandidate = proto_tree_add_item(icecandidates_tree, hf_reload_icecandidate, tvb, offset+local_offset+ icecandidates_offset, icecandidate_offset, ENC_NA);
1526     icecandidate_tree = proto_item_add_subtree(ti_icecandidate, ett_reload_icecandidate);
1527     /* parse from start */
1528     icecandidate_offset = 0;
1529     dissect_ipaddressport(hf_reload_icecandidate_addr_port,tvb, icecandidate_tree, offset+local_offset+icecandidates_offset+icecandidate_offset);
1530     icecandidate_offset += 2 + ipaddressport_length;
1531
1532     proto_tree_add_item(icecandidate_tree, hf_reload_overlaylink_type, tvb,
1533                         offset+local_offset+icecandidates_offset+icecandidate_offset, 1, ENC_BIG_ENDIAN);
1534
1535     icecandidate_offset += 1;
1536     icecandidate_offset += dissect_opaque_string(tvb, pinfo,icecandidate_tree,  hf_reload_icecandidate_foundation,offset+local_offset+icecandidates_offset + icecandidate_offset, 1, -1);
1537
1538     {
1539       guint32 priority;
1540
1541       priority = tvb_get_ntohl(tvb, offset+local_offset + icecandidates_offset);
1542       proto_tree_add_item(icecandidate_tree, hf_reload_icecandidate_priority, tvb, offset+local_offset + icecandidates_offset, 4, ENC_BIG_ENDIAN);
1543       icecandidate_offset += 4;
1544       proto_tree_add_item(icecandidate_tree, hf_reload_icecandidate_type, tvb,
1545                           offset+local_offset+icecandidates_offset+icecandidate_offset, 1, ENC_BIG_ENDIAN);
1546       proto_item_append_text(ti_icecandidate, ": %s, priority=%d", val_to_str_const(candtype, candtypes, "Unknown"), priority);
1547     }
1548     icecandidate_offset += 1;
1549     {
1550       int item_index = -1;
1551       switch (candtype) {
1552       case CANDTYPE_HOST:
1553         break;
1554       case CANDTYPE_SRFLX:
1555       case CANDTYPE_PRFLX:
1556       case CANDTYPE_RELAY:
1557         item_index = hf_reload_icecandidate_relay_addr;
1558         break;
1559
1560       default:
1561         break;
1562       }
1563       if (item_index != -1) {
1564         dissect_ipaddressport(item_index,tvb, icecandidate_tree,
1565                               offset+local_offset+icecandidates_offset+icecandidate_offset);
1566         icecandidate_offset += computed_ipaddressport_length + 2;
1567       }
1568     }
1569     /* Ice extensions */
1570     {
1571       guint32 iceextensions_offset = 0;
1572       proto_item *ti_iceextension, *ti_extensions;
1573       proto_tree *iceextension_tree,*extensions_tree;
1574       guint16 iceextension_name_length;
1575       guint16 iceextension_value_length;
1576       int nExtensions = 0;
1577       ti_extensions =
1578         proto_tree_add_item(icecandidate_tree, hf_reload_iceextensions, tvb,
1579                             offset+local_offset+icecandidates_offset+icecandidate_offset, 2+iceextensions_length,
1580                             ENC_NA);
1581       proto_item_append_text(ti_extensions, " (IceExtensions<%d>)", iceextensions_length);
1582       extensions_tree = proto_item_add_subtree(ti_extensions, ett_reload_iceextensions);
1583
1584       proto_tree_add_item(extensions_tree, hf_reload_length_uint16, tvb,
1585                           offset+local_offset+icecandidates_offset+icecandidate_offset, 2, ENC_BIG_ENDIAN);
1586       icecandidate_offset += 2;
1587       while (iceextensions_offset < iceextensions_length) {
1588         int local_increment;
1589         iceextension_name_length =
1590           tvb_get_ntohs(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset+iceextensions_offset);
1591         iceextension_value_length =
1592           tvb_get_ntohs(tvb, offset+local_offset+icecandidates_offset+icecandidate_offset+iceextensions_offset+iceextension_name_length + 2);
1593         if ((iceextensions_offset + 4 + iceextension_name_length + iceextension_value_length) > iceextensions_length) {
1594           expert_add_info_format(pinfo, ti_extensions, &ei_reload_truncated_field, "Truncated extensions");
1595           break;
1596         }
1597         ti_iceextension =
1598           proto_tree_add_item(extensions_tree, hf_reload_iceextension, tvb,
1599                               offset+local_offset + icecandidates_offset + icecandidate_offset + iceextensions_offset, 4 + iceextension_name_length + iceextension_value_length, ENC_NA);
1600         iceextension_tree = proto_item_add_subtree(ti_iceextension, ett_reload_iceextension);
1601         dissect_opaque(tvb, pinfo, iceextension_tree, hf_reload_iceextension_name,offset+local_offset+ icecandidates_offset + icecandidate_offset + iceextensions_offset, 2, iceextension_name_length+2);
1602         dissect_opaque(tvb, pinfo, iceextension_tree, hf_reload_iceextension_value,offset+local_offset + icecandidates_offset + icecandidate_offset + iceextensions_offset +2 + iceextension_name_length, 2, iceextension_value_length+2);
1603         local_increment = 4 + iceextension_name_length + iceextension_value_length;
1604         if (local_increment <= 0) break;
1605         iceextensions_offset += local_increment;
1606         nExtensions++;
1607       }
1608       proto_item_append_text(ti_extensions, ": %d elements", nExtensions);
1609     }
1610     icecandidate_offset += iceextensions_length;
1611     if (icecandidate_offset <= 0) break;
1612     icecandidates_offset += icecandidate_offset;
1613     nCandidates++;
1614   }
1615   proto_item_append_text(ti_icecandidates, ": %d elements", nCandidates);
1616
1617   return (2 + icecandidates_length);
1618 }
1619
1620 static int
1621 dissect_attachreqans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1622 {
1623   proto_item *ti_attachreqans;
1624   proto_tree *attachreqans_tree;
1625   guint8      ufrag_length;
1626   guint8      password_length;
1627   guint8      role_length;
1628   guint16     icecandidates_length;
1629   guint16     local_offset = 0;
1630
1631   /* variable length structures: must 1st compute the length ... */
1632   ufrag_length = tvb_get_guint8(tvb,offset+local_offset);
1633   local_offset += 1;
1634   if (local_offset + ufrag_length > length) {
1635     ti_attachreqans = proto_tree_add_item(tree, hf_reload_attachreqans, tvb, offset, length, ENC_NA);
1636     expert_add_info_format(pinfo, ti_attachreqans, &ei_reload_truncated_field, "Truncated attach_reqans");
1637     return length;
1638   }
1639   local_offset += ufrag_length;
1640   password_length = tvb_get_guint8(tvb,offset+local_offset);
1641   local_offset += 1;
1642   if (local_offset + password_length > length) {
1643     ti_attachreqans = proto_tree_add_item(tree, hf_reload_attachreqans, tvb, offset, length, ENC_NA);
1644     expert_add_info_format(pinfo, ti_attachreqans, &ei_reload_truncated_field, "Truncated attach_reqans");
1645     return length;
1646   }
1647   local_offset += password_length;
1648   role_length = tvb_get_guint8(tvb,offset+local_offset);
1649   local_offset += 1;
1650   if (local_offset + role_length > length) {
1651     ti_attachreqans = proto_tree_add_item(tree, hf_reload_attachreqans, tvb, offset, length, ENC_NA);
1652     expert_add_info_format(pinfo, ti_attachreqans, &ei_reload_truncated_field, "Truncated attach_reqans");
1653     return length;
1654   }
1655   local_offset += role_length;
1656   icecandidates_length = tvb_get_ntohs(tvb, offset+local_offset);
1657   local_offset += 2;
1658   if (local_offset +icecandidates_length > length) {
1659     ti_attachreqans = proto_tree_add_item(tree, hf_reload_attachreqans, tvb, offset, length, ENC_NA);
1660     expert_add_info_format(pinfo, ti_attachreqans, &ei_reload_truncated_field, "Truncated attach_reqans");
1661     return length;
1662   }
1663   local_offset += icecandidates_length;
1664
1665   ti_attachreqans = proto_tree_add_item(tree, hf_reload_attachreqans, tvb, offset, local_offset, ENC_NA);
1666   attachreqans_tree  = proto_item_add_subtree(ti_attachreqans, ett_reload_attachreqans);
1667
1668   /* restart parsing, field by field */
1669   local_offset = 0;
1670   local_offset += dissect_opaque_string(tvb, pinfo,attachreqans_tree, hf_reload_ufrag,offset+local_offset, 1, -1);
1671   local_offset += dissect_opaque_string(tvb, pinfo,attachreqans_tree, hf_reload_password,offset+local_offset, 1, -1);
1672   local_offset += dissect_opaque_string(tvb, pinfo,attachreqans_tree, hf_reload_role,offset+local_offset, 1, -1);
1673   local_offset += dissect_icecandidates(tvb, pinfo, attachreqans_tree, offset + local_offset, 2+icecandidates_length);
1674
1675   proto_tree_add_item(attachreqans_tree, hf_reload_sendupdate, tvb, offset+local_offset, 1, ENC_BIG_ENDIAN);
1676   local_offset += 1;
1677
1678   return local_offset;
1679 }
1680
1681
1682 static int
1683 dissect_sipregistration(tvbuff_t *tvb, packet_info *pinfo,proto_tree *tree, guint16 offset, guint16 length)
1684 {
1685   proto_item *ti_local, *ti_sipregistrationdata;
1686   proto_tree *local_tree, *sipregistrationdata_tree;
1687   int         local_offset = 0;
1688   guint16     length_field;
1689   guint8      type;
1690
1691   ti_local = proto_tree_add_item(tree, hf_reload_sipregistration, tvb, offset, length, ENC_NA);
1692   local_tree = proto_item_add_subtree(ti_local, ett_reload_sipregistration);
1693
1694   type = tvb_get_guint8(tvb, offset + local_offset);
1695   proto_tree_add_item(local_tree, hf_reload_sipregistration_type, tvb,offset+local_offset,1, ENC_BIG_ENDIAN);
1696   local_offset += 1;
1697   length_field = tvb_get_ntohs(tvb, offset+local_offset);
1698   proto_tree_add_item(local_tree, hf_reload_length_uint16, tvb,offset+local_offset,2, ENC_BIG_ENDIAN);
1699   local_offset += 2;
1700   if (length_field>0) {
1701     ti_sipregistrationdata = proto_tree_add_item(local_tree, hf_reload_sipregistration_data, tvb, offset, length_field, ENC_NA);
1702     sipregistrationdata_tree = proto_item_add_subtree(ti_sipregistrationdata, ett_reload_sipregistration_data);
1703
1704     switch(type) {
1705     case SIPREGISTRATIONTYPE_URI:
1706       dissect_opaque_string(tvb,pinfo, sipregistrationdata_tree, hf_reload_sipregistration_data_uri, offset+local_offset, 2, length_field);
1707       break;
1708
1709     case SIPREGISTRATIONTYPE_ROUTE:
1710     {
1711       guint16     route_offset    = 0;
1712       guint16     destinations_length;
1713       int         numDestinations = 0;
1714       proto_item *ti_destination_list;
1715       proto_tree *destination_list_tree;
1716       route_offset += dissect_opaque_string(tvb,pinfo, sipregistrationdata_tree, hf_reload_sipregistration_data_contact_prefs, offset+local_offset, 2, length_field);
1717       destinations_length = (guint16) get_opaque_length(tvb, offset+local_offset+route_offset, 2);
1718       ti_destination_list = proto_tree_add_item(sipregistrationdata_tree, hf_reload_sipregistration_data_destination_list, tvb,offset+local_offset+route_offset, length_field-route_offset, ENC_NA);
1719       destination_list_tree = proto_item_add_subtree(ti_destination_list, ett_reload_sipregistration_destination_list);
1720       proto_tree_add_item(destination_list_tree, hf_reload_length_uint16, tvb,offset+local_offset+route_offset, 2, ENC_BIG_ENDIAN);
1721       route_offset += 2;
1722       if (destinations_length>0) {
1723         dissect_destination_list(tvb, pinfo, destination_list_tree, offset+local_offset+route_offset,destinations_length, &numDestinations);
1724       }
1725       proto_item_append_text(ti_destination_list, " (Destination<%d>): %d elements", destinations_length,numDestinations);
1726     }
1727     break;
1728     }
1729   }
1730   local_offset += length_field;
1731
1732   return local_offset;
1733 }
1734
1735 static int
1736 dissect_turnserver(tvbuff_t *tvb, proto_tree *tree, guint16 offset, guint16 length)
1737 {
1738   proto_item *ti_local;
1739   proto_tree *local_tree;
1740   int         local_offset = 0;
1741
1742   ti_local = proto_tree_add_item(tree, hf_reload_turnserver, tvb, offset, length, ENC_NA);
1743   local_tree = proto_item_add_subtree(ti_local, ett_reload_turnserver);
1744
1745   proto_tree_add_item(local_tree, hf_reload_turnserver_iteration, tvb,offset,1, ENC_BIG_ENDIAN);
1746   local_offset += 1;
1747   local_offset += dissect_ipaddressport(hf_reload_turnserver_server_address,tvb, local_tree, offset+local_offset);
1748
1749   return local_offset;
1750 }
1751
1752 static int dissect_redirserviceproviderdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1753 {
1754   proto_item *ti_local;
1755   proto_tree *local_tree;
1756   int         local_offset = 0;
1757
1758   ti_local = proto_tree_add_item(tree, hf_reload_redirserviceproviderdata, tvb, offset, length, ENC_NA);
1759   local_tree = proto_item_add_subtree(ti_local, ett_reload_redirserviceproviderdata);
1760
1761   local_offset += dissect_nodeid(hf_reload_redirserviceproviderdata_serviceprovider, tvb, pinfo, local_tree, offset+local_offset, length);
1762   local_offset += dissect_opaque_string(tvb, pinfo, local_tree, hf_reload_redirserviceproviderdata_namespace, offset+local_offset, 2, length-local_offset);
1763   proto_tree_add_item(local_tree, hf_reload_redirserviceproviderdata_level, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
1764   local_offset += 2;
1765   proto_tree_add_item(local_tree, hf_reload_redirserviceproviderdata_node, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
1766
1767   return length;
1768 }
1769
1770 static int dissect_redirserviceprovider(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
1771 {
1772   proto_item *ti_local;
1773   proto_tree *local_tree;
1774   int         local_offset = 0;
1775   guint16     length_field;
1776
1777   length_field = tvb_get_ntohs(tvb, offset);
1778
1779   if (2+length_field>length) {
1780     ti_local = proto_tree_add_item(tree, hf_reload_redirserviceprovider, tvb, offset, length, ENC_NA);
1781     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated RedirServiceProvider");
1782     return length;
1783   }
1784
1785   ti_local = proto_tree_add_item(tree, hf_reload_redirserviceprovider, tvb, offset, length_field+2, ENC_NA);
1786   local_tree = proto_item_add_subtree(ti_local, ett_reload_redirserviceprovider);
1787
1788   proto_tree_add_item(local_tree,  hf_reload_length_uint16, tvb, offset,2, ENC_BIG_ENDIAN);
1789   local_offset += 2;
1790
1791   dissect_redirserviceproviderdata(tvb, pinfo, local_tree, offset+local_offset, length_field);
1792
1793   return (2+length_field);
1794 }
1795
1796 static int dissect_datavalue(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, gboolean meta, kind_t *kind) {
1797   proto_item *ti_datavalue;
1798   proto_tree *datavalue_tree;
1799
1800   if (meta != TRUE) {
1801     int value_length = get_opaque_length(tvb,offset+1,4);
1802     int hf           = hf_reload_datavalue;
1803
1804     if (anchor >= 0) {
1805       hf = anchor;
1806     }
1807
1808     if (1+4+value_length > length) {
1809       ti_datavalue = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1810       expert_add_info_format(pinfo, ti_datavalue, &ei_reload_truncated_field, "Truncated DataValue");
1811       return length;
1812     }
1813
1814     ti_datavalue = proto_tree_add_item(tree,  hf, tvb, offset,1+4+value_length, ENC_NA);
1815     datavalue_tree = proto_item_add_subtree(ti_datavalue,ett_reload_datavalue);
1816     proto_tree_add_item(datavalue_tree, hf_reload_datavalue_exists, tvb, offset, 1, ENC_BIG_ENDIAN);
1817     if (kind != NULL) {
1818       switch(kind->id) {
1819
1820       case DATAKINDID_TURNSERVICE:
1821       {
1822         guint32 length_field = tvb_get_ntohl(tvb, offset+1);
1823         proto_tree_add_item(datavalue_tree,  hf_reload_length_uint32, tvb, offset+1,4, ENC_BIG_ENDIAN);
1824         if (length_field>0) {
1825           dissect_turnserver(tvb, datavalue_tree, offset+1+4, length_field);
1826         }
1827       }
1828       break;
1829
1830       case DATAKINDID_SIP_REGISTRATION:
1831       {
1832         guint32 length_field = tvb_get_ntohl(tvb, offset+1);
1833         proto_tree_add_item(datavalue_tree,  hf_reload_length_uint32, tvb, offset+1,4, ENC_BIG_ENDIAN);
1834         if (length_field>0) {
1835           dissect_sipregistration(tvb, pinfo, datavalue_tree, offset+1+4, length_field);
1836         }
1837       }
1838       break;
1839
1840       case DATAKINDID_CERTIFICATE_BY_NODE:
1841       case DATAKINDID_CERTIFICATE_BY_USER:
1842       {
1843         guint32 length_field = tvb_get_ntohl(tvb, offset+1);
1844         proto_tree_add_item(datavalue_tree,  hf_reload_length_uint32, tvb, offset+1,4, ENC_BIG_ENDIAN);
1845         if (length_field>0) {
1846           asn1_ctx_t asn1_ctx;
1847
1848           asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1849           dissect_x509af_Certificate(FALSE, tvb, offset + 1 + 4, &asn1_ctx,
1850                                      datavalue_tree, hf_reload_certificate);
1851         }
1852       }
1853       break;
1854
1855       case DATAKINDID_REDIR:
1856       {
1857         guint32 length_field = tvb_get_ntohl(tvb, offset+1);
1858         proto_tree_add_item(datavalue_tree,  hf_reload_length_uint32, tvb, offset+1,4, ENC_BIG_ENDIAN);
1859         if (length_field>0) {
1860           dissect_redirserviceprovider(tvb, pinfo, datavalue_tree, offset+1+4, length_field);
1861         }
1862       }
1863       break;
1864
1865       default:
1866         dissect_opaque(tvb, pinfo, datavalue_tree, hf_reload_datavalue_value, offset +1, 4, length-1);
1867         break;
1868       }
1869     }
1870     else {
1871       dissect_opaque(tvb, pinfo, datavalue_tree, hf_reload_datavalue_value, offset +1, 4, length-1);
1872     }
1873     if (hf == anchor) {
1874       proto_item_append_text(ti_datavalue, " (DataValue)");
1875     }
1876     return (1+4+value_length);
1877   }
1878   else {
1879     /* meta data */
1880     int hash_length = get_opaque_length(tvb, offset +1+4+1,1);
1881     int hf = hf_reload_metadata;
1882
1883     if (anchor >= 0) {
1884       hf = anchor;
1885     }
1886
1887
1888     if (1+4+1+1+hash_length > length) {
1889       ti_datavalue = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1890       expert_add_info_format(pinfo, ti_datavalue, &ei_reload_truncated_field, "Truncated MetaData");
1891       return length;
1892     }
1893
1894     ti_datavalue = proto_tree_add_item(tree,  hf, tvb, offset,1+4+1+1+hash_length, ENC_NA);
1895     datavalue_tree = proto_item_add_subtree(ti_datavalue,ett_reload_datavalue);
1896     proto_tree_add_item(datavalue_tree, hf_reload_datavalue_exists, tvb, offset, 1, ENC_BIG_ENDIAN);
1897     proto_tree_add_item(datavalue_tree, hf_reload_metadata_value_length, tvb, offset+1, 4, ENC_BIG_ENDIAN);
1898     proto_tree_add_item(datavalue_tree, hf_reload_hash_algorithm, tvb, offset+1+4, 1, ENC_BIG_ENDIAN);
1899     dissect_opaque(tvb, pinfo, datavalue_tree, hf_reload_metadata_hash_value, offset +1+4+1, 1, length-1-4-1);
1900
1901     if (hf == anchor) {
1902       proto_item_append_text(ti_datavalue, " (MetaData)");
1903     }
1904
1905     return (1+4+1+hash_length);
1906   }
1907   return 0;
1908 }
1909
1910 static int getDataValueLength(tvbuff_t *tvb, guint16 offset, gboolean meta) {
1911   if (meta != TRUE) {
1912     int value_length = get_opaque_length(tvb,offset+1,4);
1913     return (1+4+value_length);
1914   }
1915   else {
1916     int hash_length = get_opaque_length(tvb, offset +1+4+1,1);
1917     return (1+4+1+1+hash_length);
1918   }
1919   return 0;
1920 }
1921
1922 static int dissect_arrayentry(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, gboolean meta, kind_t *kind) {
1923   proto_item *ti_arrayentry, *ti_index;
1924   proto_tree *arrayentry_tree;
1925   int         data_length = getDataValueLength(tvb, offset+4, meta);
1926   int         hf          = hf_reload_arrayentry;
1927
1928   if (anchor >= 0) {
1929     hf = anchor;
1930   }
1931
1932   if (4+data_length > length) {
1933     ti_arrayentry = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1934     expert_add_info_format(pinfo, ti_arrayentry, &ei_reload_truncated_field, "Truncated ArrayEntry");
1935     return length;
1936   }
1937
1938   ti_arrayentry = proto_tree_add_item(tree,  hf, tvb, offset,4+data_length, ENC_NA);
1939   arrayentry_tree = proto_item_add_subtree(ti_arrayentry,ett_reload_arrayentry);
1940   ti_index = proto_tree_add_item(arrayentry_tree, hf_reload_arrayentry_index, tvb, offset, 4, ENC_BIG_ENDIAN);
1941   if (0xffffffff == (guint32) tvb_get_ntohl(tvb, offset)) {
1942     proto_item_append_text(ti_index, "(append)");
1943   }
1944   dissect_datavalue(hf_reload_arrayentry_value,tvb, pinfo, arrayentry_tree, offset+4, length-4, meta, kind);
1945
1946   if (hf == anchor) {
1947     proto_item_append_text(ti_arrayentry, " (ArrayEntry)");
1948   }
1949
1950   return (4+data_length);
1951 }
1952
1953 static int dissect_dictionaryentry(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, gboolean meta, kind_t *kind) {
1954   proto_item *ti_dictionaryentry;
1955   proto_tree *dictionaryentry_tree;
1956   int         local_offset = 0;
1957   guint16     key_length   = 0;
1958   int         hf           = hf_reload_dictionaryentry;
1959
1960   if (anchor >= 0) {
1961     hf = anchor;
1962   }
1963
1964   if (length < 2) {
1965     ti_dictionaryentry = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1966     expert_add_info_format(pinfo, ti_dictionaryentry, &ei_reload_truncated_field, "Truncated ArrayEntry");
1967     return length;
1968   }
1969   key_length = get_opaque_length(tvb,offset,2);
1970
1971
1972   if (length < (key_length +2)) {
1973     ti_dictionaryentry = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1974     expert_add_info_format(pinfo, ti_dictionaryentry, &ei_reload_truncated_field, "Truncated ArrayEntry");
1975     return length;
1976   }
1977
1978   {
1979     int data_length = getDataValueLength(tvb, offset+2+key_length, meta);
1980     if (length < (key_length+2+data_length)) {
1981       ti_dictionaryentry = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
1982     }
1983     else {
1984       ti_dictionaryentry = proto_tree_add_item(tree, hf, tvb, offset, 2+key_length+1+4+data_length, ENC_NA);
1985     }
1986   }
1987
1988
1989   dictionaryentry_tree = proto_item_add_subtree(ti_dictionaryentry,ett_reload_dictionaryentry);
1990
1991   if (hf == anchor) {
1992     proto_item_append_text(ti_dictionaryentry, " (DictionaryEntry)");
1993   }
1994
1995   if (kind != NULL) {
1996     switch(kind->id) {
1997     case DATAKINDID_SIP_REGISTRATION:
1998     case DATAKINDID_REDIR:
1999     {
2000       proto_item *ti_key;
2001       proto_tree *key_tree;
2002       ti_key = proto_tree_add_item(dictionaryentry_tree, hf_reload_dictionarykey, tvb, offset, 2+key_length, ENC_NA);
2003       key_tree = proto_item_add_subtree(ti_key,ett_reload_dictionaryentry_key);
2004       proto_tree_add_item(key_tree, hf_reload_length_uint16, tvb, offset, 2, ENC_BIG_ENDIAN);
2005       local_offset += 2;
2006       local_offset+= dissect_nodeid(-1, tvb, pinfo, key_tree, offset+2, key_length);
2007     }
2008     break;
2009
2010     default:
2011       local_offset += dissect_opaque(tvb, pinfo, dictionaryentry_tree, hf_reload_dictionarykey, offset, 2, length);
2012       break;
2013     }
2014   }
2015   else {
2016     local_offset +=
2017       dissect_opaque(tvb, pinfo, dictionaryentry_tree, hf_reload_dictionarykey, offset, 2, length);
2018   }
2019
2020   local_offset += dissect_datavalue(hf_reload_dictionary_value,tvb, pinfo, dictionaryentry_tree, offset+local_offset, length-local_offset, meta, kind);
2021
2022   return (local_offset);
2023 }
2024
2025 static int
2026 dissect_signature(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset)
2027 {
2028   int         local_offset = 0;
2029   proto_item *ti_signature;
2030   proto_tree *signature_tree;
2031   guint16     signeridentityvalue_length;
2032   guint16     signaturevalue_length;
2033
2034
2035   signeridentityvalue_length = tvb_get_ntohs(tvb, offset +2+1);
2036   signaturevalue_length = tvb_get_ntohs(tvb, offset + 2 + 1 + 2+ signeridentityvalue_length);
2037   ti_signature = proto_tree_add_item(tree,
2038                                      hf_reload_signature, tvb, offset,
2039                                      2 +/* SignatureAndHashAlgorithm */
2040                                      1 + 2 + signeridentityvalue_length +/* SignatureIdenty length*/
2041                                      2 + signaturevalue_length,
2042                                      ENC_NA);
2043
2044   signature_tree = proto_item_add_subtree(ti_signature, ett_reload_signature);
2045
2046   {
2047     proto_item *ti_signatureandhashalgorithm;
2048     proto_tree *signatureandhashalgorithm_tree;
2049     ti_signatureandhashalgorithm = proto_tree_add_item(signature_tree, hf_reload_signatureandhashalgorithm, tvb, offset, 2, ENC_NA);
2050     signatureandhashalgorithm_tree = proto_item_add_subtree( ti_signatureandhashalgorithm, ett_reload_signatureandhashalgorithm);
2051     proto_tree_add_item(signatureandhashalgorithm_tree, hf_reload_hash_algorithm, tvb, offset, 1, ENC_BIG_ENDIAN);
2052     local_offset += 1;
2053     proto_tree_add_item(signatureandhashalgorithm_tree, hf_reload_signature_algorithm, tvb, offset + local_offset, 1, ENC_BIG_ENDIAN);
2054     local_offset += 1;
2055   }
2056   /* Signeridentity */
2057   {
2058     proto_item *ti_signeridentity;
2059     proto_tree *signeridentity_tree;
2060     guint8 identity_type;
2061     ti_signeridentity = proto_tree_add_item(signature_tree,
2062                                             hf_reload_signeridentity,
2063                                             tvb, offset+local_offset,
2064                                             1 + 2 + signeridentityvalue_length,
2065                                             ENC_NA);
2066     signeridentity_tree = proto_item_add_subtree(ti_signeridentity, ett_reload_signeridentity);
2067     identity_type = tvb_get_guint8(tvb, offset + local_offset);
2068     proto_tree_add_item(signeridentity_tree, hf_reload_signeridentity_type, tvb,
2069                         offset + local_offset, 1, ENC_BIG_ENDIAN);
2070     local_offset += 1;
2071     proto_tree_add_uint(signeridentity_tree, hf_reload_length_uint16, tvb,
2072                         offset + local_offset, 2, signeridentityvalue_length);
2073     local_offset += 2;
2074     {
2075       proto_item *ti_signeridentity_identity;
2076       proto_tree * signeridentity_identity_tree;
2077       ti_signeridentity_identity = proto_tree_add_item(signeridentity_tree,
2078                                    hf_reload_signeridentity_identity,
2079                                    tvb, offset+local_offset,
2080                                    signeridentityvalue_length,
2081                                    ENC_NA);
2082       signeridentity_identity_tree = proto_item_add_subtree(ti_signeridentity_identity, ett_reload_signeridentity_identity);
2083       proto_item_append_text(ti_signeridentity_identity, " (SignerIdentityValue[%d])",signeridentityvalue_length);
2084       {
2085         proto_item *ti_signeridentityvalue;
2086         proto_tree *signeridentityvalue_tree;
2087         if (identity_type == SIGNERIDENTITYTYPE_CERTHASH || identity_type == SIGNERIDENTITYTYPE_CERTHASHNODEID) {
2088           guint8 certificate_hash_length;
2089
2090           certificate_hash_length = tvb_get_guint8(tvb, offset + local_offset + 1);
2091           if (1 + 1 + certificate_hash_length > signeridentityvalue_length) {
2092             expert_add_info_format(pinfo, ti_signeridentity, &ei_reload_truncated_field, "Truncated signature identity value");
2093           }
2094           else {
2095             ti_signeridentityvalue= proto_tree_add_item(signeridentity_identity_tree,
2096                                     hf_reload_signeridentity_value,
2097                                     tvb, offset + local_offset,
2098                                     1 + 1 + certificate_hash_length,
2099                                     ENC_NA);
2100             signeridentityvalue_tree = proto_item_add_subtree(ti_signeridentityvalue, ett_reload_signeridentity_value);
2101             proto_tree_add_item(signeridentityvalue_tree, hf_reload_signeridentity_value_hash_alg, tvb,
2102                                 offset + local_offset, 1, ENC_BIG_ENDIAN);
2103             dissect_opaque(tvb, pinfo, signeridentityvalue_tree,
2104                            (identity_type == SIGNERIDENTITYTYPE_CERTHASH) ?
2105                            hf_reload_signeridentity_value_certificate_hash:
2106                            hf_reload_signeridentity_value_certificate_node_id_hash,
2107                            offset + local_offset +1, 1, -1);
2108           }
2109         }
2110         else {
2111           expert_add_info(pinfo, signeridentity_identity_tree, &ei_reload_identity_type_unknown);
2112         }
2113       }
2114     }
2115     local_offset += signeridentityvalue_length;
2116   }
2117   local_offset += dissect_opaque(tvb, pinfo, signature_tree, hf_reload_signature_value, offset + local_offset, 2, -1);
2118
2119   return local_offset;
2120
2121 }
2122
2123
2124 static int
2125 dissect_storeddata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, kind_t *kind, gboolean meta)
2126 {
2127   proto_item *ti_storeddata;
2128   proto_tree *storeddata_tree;
2129   guint32     storeddata_length;
2130   guint32     local_offset;
2131
2132   int hf =  hf_reload_storeddata;
2133
2134   if (meta == TRUE) {
2135     hf = hf_reload_storedmetadata;
2136   }
2137
2138   storeddata_length = tvb_get_ntohl(tvb, offset);
2139
2140   if (storeddata_length + 4 > length) {
2141     ti_storeddata = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
2142     expert_add_info_format(pinfo, ti_storeddata, &ei_reload_truncated_field, "Truncated StoredData");
2143     return length;
2144   }
2145
2146   local_offset = 0;
2147   ti_storeddata = proto_tree_add_item(tree, hf, tvb, offset, 4 + storeddata_length, ENC_NA);
2148   storeddata_tree = proto_item_add_subtree(ti_storeddata, ett_reload_storeddata);
2149
2150   proto_tree_add_uint(storeddata_tree, hf_reload_length_uint32, tvb, offset, 4, storeddata_length);
2151   local_offset += 4;
2152   {
2153     guint64 storage_time;
2154     guint32 remaining_ms;
2155     time_t storage_time_sec;
2156     nstime_t l_nsTime;
2157
2158     storage_time = tvb_get_ntoh64(tvb, offset+local_offset);
2159     storage_time_sec = (time_t)(storage_time/1000);
2160     remaining_ms = (guint32) (storage_time % 1000);
2161
2162     l_nsTime.secs = storage_time_sec;
2163     l_nsTime.nsecs =  remaining_ms*1000*1000;
2164
2165     proto_tree_add_time(storeddata_tree, hf_reload_storeddata_storage_time, tvb, offset + local_offset, 8, &l_nsTime);
2166   }
2167   local_offset += 8;
2168   proto_tree_add_item(storeddata_tree, hf_reload_storeddata_lifetime, tvb, offset + local_offset, 4, ENC_BIG_ENDIAN);
2169   local_offset += 4;
2170   if ((NULL != kind) && (kind->id != DATAKINDID_INVALID)) {
2171     switch(kind->data_model) {
2172     case DATAMODEL_SINGLE:
2173       local_offset += dissect_datavalue(hf_reload_value,tvb, pinfo, storeddata_tree, offset+local_offset, (storeddata_length-local_offset+4), meta, kind);
2174       break;
2175     case DATAMODEL_ARRAY:
2176       local_offset +=  dissect_arrayentry(hf_reload_value,tvb, pinfo, storeddata_tree, offset+local_offset, (storeddata_length-local_offset+4), meta, kind);
2177       break;
2178     case DATAMODEL_DICTIONARY:
2179       local_offset += dissect_dictionaryentry(hf_reload_value,tvb, pinfo, storeddata_tree, offset+local_offset, (storeddata_length-local_offset+4), meta, kind);
2180       break;
2181     default:
2182       expert_add_info(pinfo, ti_storeddata, &ei_reload_unknown_data_model);
2183       return  (storeddata_length + 4);
2184     }
2185     if (TRUE != meta) {
2186       dissect_signature(tvb, pinfo, storeddata_tree, offset +local_offset);
2187     }
2188   }
2189   return (storeddata_length + 4);
2190 }
2191
2192
2193
2194 static int
2195 dissect_kindid(int anchor, tvbuff_t *tvb, proto_tree *tree, guint16 offset, kind_t **kind)
2196 {
2197   proto_item *ti_kindid;
2198   guint32     kindid = 0;
2199   int         hf     = hf_reload_kindid;
2200
2201   if (anchor >= 0) {
2202     hf = anchor;
2203   }
2204
2205   *kind = NULL;
2206
2207   kindid = tvb_get_ntohl(tvb, offset);
2208   *kind = getKindFromId(kindid);
2209   ti_kindid = proto_tree_add_item(tree, hf, tvb, offset, 4, ENC_BIG_ENDIAN);
2210   if ((NULL != (*kind)) && ((*kind)->name != NULL)) {
2211     proto_item_append_text(ti_kindid, " (%s)", (*kind)->name);
2212   }
2213
2214   return 4;
2215 }
2216
2217 static int
2218 dissect_kinddata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, gboolean meta)
2219 {
2220   proto_item *ti_kinddata;
2221   proto_item *kinddata_tree;
2222   guint32     values_length;
2223   guint32     local_offset = 0;
2224   kind_t     *kind;
2225   int         hf           = hf_reload_kinddata;
2226   int         nValues      = 0;
2227
2228   if (meta) {
2229     hf = hf_reload_statkindresponse;
2230   }
2231
2232   values_length = tvb_get_ntohl(tvb, offset + 4 + 8);
2233   if (12 + values_length > length) {
2234     ti_kinddata = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
2235     expert_add_info_format(pinfo, ti_kinddata, &ei_reload_truncated_field, "Truncated kind data");
2236     return length;
2237   }
2238   ti_kinddata = proto_tree_add_item(tree, hf, tvb, offset, 16+values_length, ENC_NA);
2239   kinddata_tree = proto_item_add_subtree(ti_kinddata, ett_reload_kinddata);
2240
2241   local_offset += dissect_kindid(hf_reload_kinddata_kind,tvb, kinddata_tree, offset+local_offset, &kind);
2242
2243   proto_tree_add_item(kinddata_tree, hf_reload_generation_counter, tvb, offset+local_offset, 8, ENC_BIG_ENDIAN);
2244   local_offset += 8;
2245   {
2246     gint32 values_offset = 0;
2247     guint32 values_increment;
2248     proto_item *ti_values;
2249     proto_tree *values_tree;
2250
2251     ti_values = proto_tree_add_item(kinddata_tree, hf_reload_values, tvb, offset+local_offset, 4+values_length, ENC_NA);
2252     values_tree = proto_item_add_subtree(ti_values, ett_reload_values);
2253     if (meta) {
2254       proto_item_append_text(ti_values, " (StoredMetaData<%d>)", values_length);
2255     } else {
2256       proto_item_append_text(ti_values, " (StoredData<%d>)", values_length);
2257     }
2258
2259     proto_tree_add_uint(values_tree, hf_reload_length_uint32, tvb, offset +local_offset, 4, values_length);
2260     local_offset += 4;
2261
2262     while (values_offset >= 0 && (guint32)values_offset < values_length) {
2263       values_increment = dissect_storeddata(tvb, pinfo, values_tree, offset+local_offset+values_offset, values_length - values_offset, kind, meta);
2264       if (values_increment == 0) {
2265         break;
2266       }
2267       nValues++;
2268       values_offset += values_increment;
2269     }
2270     proto_item_append_text(ti_values, ": %d elements", nValues);
2271   }
2272
2273   local_offset += values_length;
2274   return local_offset;
2275 }
2276
2277 static int dissect_nodeid_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, int hf, int length_size)
2278 {
2279   guint16     list_length;
2280   guint16     local_offset   = 0;
2281   gint32      list_offset    = 0;
2282   guint16     list_increment = 0;
2283   int         nNodeIds       = 0;
2284   proto_item *ti_local;
2285   proto_tree *local_tree;
2286
2287   list_length= (guint16) get_opaque_length(tvb, offset, length_size);
2288
2289   if (list_length+length_size>length) {
2290     ti_local = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
2291     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated NodeId list");
2292   }
2293   ti_local = proto_tree_add_item(tree, hf, tvb, offset,  list_length+length_size, ENC_NA);
2294   proto_item_append_text(ti_local, " (NodeId<%d>)", list_length);
2295
2296   local_tree =  proto_item_add_subtree(ti_local, ett_reload_nodeid_list);
2297
2298   local_offset += dissect_length(tvb, local_tree, offset, length_size);
2299   while (list_offset >= 0 && list_offset < list_length) {
2300     dissect_nodeid(-1, tvb, pinfo, local_tree, offset+local_offset+list_offset,list_length-list_offset);
2301     list_increment = reload_nodeid_length;
2302     if (list_increment <= 0) break;
2303     list_offset += list_increment;
2304     nNodeIds++;
2305   }
2306   proto_item_append_text(ti_local, ":%d elements", nNodeIds);
2307
2308   return (list_length+length_size);
2309 }
2310
2311
2312 static int
2313 dissect_storekindresponse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2314 {
2315   proto_item *ti_local;
2316   proto_tree *local_tree;
2317   guint16     local_offset = 0;
2318   guint16     local_length = 0;
2319   guint16     replicas_length;
2320   kind_t     *kind;
2321
2322   replicas_length = tvb_get_ntohs(tvb, offset+4+8);
2323   local_length = 4+8+2+replicas_length;
2324
2325   if (length < local_length) {
2326     ti_local = proto_tree_add_item(tree, hf_reload_storekindresponse, tvb, offset, length, ENC_NA);
2327     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated StoreKindResponse");
2328     return length;
2329   }
2330   ti_local = proto_tree_add_item(tree, hf_reload_storekindresponse, tvb, offset,  4+8+2+replicas_length, ENC_NA);
2331   local_tree = proto_item_add_subtree(ti_local, ett_reload_storekindresponse);
2332
2333   local_offset += dissect_kindid(hf_reload_kinddata_kind,tvb, local_tree, offset+local_offset, &kind);
2334   proto_tree_add_item(local_tree, hf_reload_generation_counter, tvb, offset+local_offset, 8, ENC_BIG_ENDIAN);
2335   local_offset += 8;
2336   local_offset += dissect_nodeid_list(tvb, pinfo, local_tree, offset+local_offset, local_length-local_offset, hf_reload_replicas, 2);
2337
2338   return local_offset;
2339 }
2340
2341 static int
2342 dissect_storeans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2343 {
2344   proto_item *ti_local, *ti_kind_responses;
2345   proto_tree *local_tree, *kind_responses_tree;
2346   guint16     local_offset          = 0;
2347   guint16     kind_responses_length;
2348   gint32      kind_responses_offset = 0;
2349   int         nKindResponses        = 0;
2350
2351   ti_local = proto_tree_add_item(tree, hf_reload_storeans, tvb, offset, length, ENC_NA);
2352   local_tree = proto_item_add_subtree(ti_local, ett_reload_storeans);
2353   kind_responses_length = tvb_get_ntohs(tvb, offset);
2354   ti_kind_responses = proto_tree_add_item(local_tree, hf_reload_storeans_kind_responses, tvb, offset, 2+kind_responses_length, ENC_NA);
2355   kind_responses_tree = proto_item_add_subtree(ti_kind_responses, ett_reload_storeans_kind_responses);
2356   proto_item_append_text(ti_kind_responses, " (StoreKindResponse<%d>)", kind_responses_length);
2357
2358   proto_tree_add_item(kind_responses_tree, hf_reload_length_uint16, tvb, offset, 2, ENC_BIG_ENDIAN);
2359   local_offset += 2;
2360   while (kind_responses_offset >=0 && kind_responses_offset < kind_responses_length) {
2361     int local_increment = dissect_storekindresponse(tvb, pinfo, kind_responses_tree, offset+local_offset+kind_responses_offset, kind_responses_length-kind_responses_offset);
2362     if (local_increment <= 0) break;
2363     kind_responses_offset += local_increment;
2364     nKindResponses++;
2365   }
2366   local_offset += kind_responses_length;
2367   proto_item_append_text(ti_kind_responses, ": %d elements", nKindResponses);
2368
2369   return local_offset;
2370 }
2371
2372 static int
2373 dissect_storereq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2374 {
2375   proto_item *ti_storereq;
2376   proto_tree *storereq_tree;
2377   guint32     local_offset = 0;
2378   guint32     kind_data_length;
2379
2380
2381   local_offset += get_opaque_length(tvb, offset, 1) + 1; /* resource id length */
2382   if (local_offset > length) {
2383     ti_storereq = proto_tree_add_item(tree, hf_reload_storereq, tvb, offset, length, ENC_NA);
2384     expert_add_info_format(pinfo, ti_storereq, &ei_reload_truncated_field, "Truncated StoreReq: resource too long");
2385     return length;
2386   }
2387
2388   local_offset += 1; /* replica_num */
2389   if (local_offset > length) {
2390     ti_storereq = proto_tree_add_item(tree, hf_reload_storereq, tvb, offset, length, ENC_NA);
2391     expert_add_info_format(pinfo, ti_storereq, &ei_reload_truncated_field, "Truncated StoreReq: no room for replica_number");
2392     return length;
2393   }
2394
2395   kind_data_length = tvb_get_ntohl(tvb, offset + local_offset);
2396   local_offset += 4;
2397   if (local_offset + kind_data_length > length) {
2398     ti_storereq = proto_tree_add_item(tree, hf_reload_storereq, tvb, offset, length, ENC_NA);
2399     expert_add_info_format(pinfo, ti_storereq, &ei_reload_truncated_field, "Truncated StoreReq: kind_data too long");
2400     return length;
2401   }
2402   local_offset += kind_data_length;
2403
2404   ti_storereq = proto_tree_add_item(tree, hf_reload_storereq, tvb, offset, local_offset, ENC_NA);
2405   storereq_tree = proto_item_add_subtree(ti_storereq, ett_reload_storereq);
2406
2407   /* Parse from start */
2408   local_offset = 0;
2409   local_offset += dissect_resourceid(hf_reload_resource, tvb, pinfo, storereq_tree, offset+local_offset, length);
2410
2411   proto_tree_add_item(storereq_tree, hf_reload_store_replica_num, tvb, offset + local_offset, 1, ENC_BIG_ENDIAN);
2412   local_offset += 1;
2413
2414
2415   {
2416     gint32      kind_data_offset = 0;
2417     guint32     kind_data_increment;
2418     proto_item *ti_kind_data;
2419     proto_tree *kind_data_tree;
2420     int         nKindDatas       = 0;
2421
2422     ti_kind_data = proto_tree_add_item(storereq_tree, hf_reload_store_kind_data, tvb, offset+local_offset,4+kind_data_length, ENC_NA);
2423     proto_item_append_text(ti_kind_data, " (StoreKindData<%d>)", kind_data_length);
2424     kind_data_tree = proto_item_add_subtree(ti_kind_data, ett_reload_store_kind_data);
2425     proto_tree_add_item(kind_data_tree, hf_reload_length_uint32, tvb, offset + local_offset, 4, ENC_BIG_ENDIAN);
2426     local_offset += 4;
2427
2428     while (kind_data_offset >= 0 && (guint32)kind_data_offset < kind_data_length) {
2429       kind_data_increment = dissect_kinddata(tvb, pinfo, kind_data_tree, offset+local_offset+kind_data_offset, kind_data_length - kind_data_offset, FALSE);
2430       if (kind_data_increment == 0) {
2431         break;
2432       }
2433       nKindDatas++;
2434       kind_data_offset += kind_data_increment;
2435     }
2436
2437     proto_item_append_text(ti_kind_data, ": %d elements", nKindDatas);
2438   }
2439   local_offset += kind_data_length;
2440
2441   return local_offset;
2442 }
2443
2444 static int dissect_arrayrange(tvbuff_t *tvb, proto_tree *tree, guint16 offset) {
2445   proto_item *ti;
2446   gint32      first;
2447   gint32      last;
2448
2449   ti = proto_tree_add_item(tree, hf_reload_arrayrange, tvb, offset, (16), ENC_NA);
2450   first =  tvb_get_ntohl(tvb, offset);
2451   last  =  tvb_get_ntohl(tvb, offset+4);
2452
2453   proto_item_append_text(ti, " [%d-", first);
2454   if ((guint32)last != 0xFFFFFFFF) {
2455     proto_item_append_text(ti, "%d]", last);
2456   }
2457   else {
2458     proto_item_append_text(ti, "end]");
2459   }
2460   return 8;
2461
2462 }
2463 static int
2464 dissect_storeddataspecifier(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2465 {
2466   guint16     length_field, local_offset = 0;
2467   proto_item *ti_storeddataspecifier;
2468   proto_tree *storeddataspecifier_tree;
2469   kind_t     *kind                       = NULL;
2470
2471   length_field = tvb_get_ntohs(tvb, offset+4+8);
2472   if ((length_field + 4 + 8 + 2) > length) {
2473     ti_storeddataspecifier = proto_tree_add_item(tree, hf_reload_storeddataspecifier, tvb, offset, length, ENC_NA);
2474     expert_add_info_format(pinfo, ti_storeddataspecifier, &ei_reload_truncated_field, "Truncated StoredDataSpecifier");
2475     return length;
2476   }
2477
2478   ti_storeddataspecifier = proto_tree_add_item(tree, hf_reload_storeddataspecifier, tvb, offset, (length_field + 4 + 8 +2), ENC_NA);
2479   storeddataspecifier_tree = proto_item_add_subtree(ti_storeddataspecifier, ett_reload_storeddataspecifier);
2480
2481   local_offset += dissect_kindid(hf_reload_kinddata_kind,tvb,storeddataspecifier_tree, offset, &kind);
2482   proto_tree_add_item(storeddataspecifier_tree, hf_reload_generation_counter, tvb, offset+local_offset, 8, ENC_BIG_ENDIAN);
2483   local_offset += 8;
2484   proto_tree_add_item(storeddataspecifier_tree, hf_reload_length_uint16, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
2485   local_offset += 2;
2486
2487   if ((kind != NULL) && (kind->id != DATAKINDID_INVALID)) {
2488     switch(kind->data_model) {
2489     case DATAMODEL_ARRAY:
2490     {
2491       proto_item *ti_indices;
2492       proto_tree *indices_tree;
2493       gint32      indices_offset = 0;
2494       guint16     indices_length = tvb_get_ntohs(tvb, offset+local_offset);
2495       int         nIndices       = 0;
2496       ti_indices = proto_tree_add_item(storeddataspecifier_tree, hf_reload_storeddataspecifier_indices,
2497                                        tvb, offset+local_offset, 2+indices_length, ENC_NA);
2498       proto_item_append_text(ti_indices, " (ArrayRange<%d>)", indices_length);
2499       indices_tree =  proto_item_add_subtree(ti_indices, ett_reload_storeddataspecifier_indices);
2500       proto_tree_add_item(indices_tree, hf_reload_length_uint16, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
2501       local_offset += 2;
2502       while (indices_offset >= 0 && indices_offset < indices_length) {
2503         indices_offset += dissect_arrayrange(tvb, indices_tree, offset + local_offset + indices_offset);
2504         nIndices++;
2505       }
2506       proto_item_append_text(ti_indices, ": %d elements", nIndices);
2507     }
2508     break;
2509
2510     case DATAMODEL_DICTIONARY:
2511     {
2512       proto_item *ti_keys;
2513       proto_tree *keys_tree;
2514       gint32      keys_offset = 0;
2515       guint16     keys_length = tvb_get_ntohs(tvb, offset+local_offset);
2516       int         nKeys       = 0;
2517       ti_keys = proto_tree_add_item(tree, hf_reload_storeddataspecifier_keys, tvb, offset+local_offset, 2+keys_length, ENC_NA);
2518       keys_tree =  proto_item_add_subtree(ti_keys, ett_reload_storeddataspecifier_keys);
2519       while (keys_offset >= 0 && keys_offset < keys_length) {
2520         guint32 local_increment;
2521         local_increment = dissect_opaque(tvb, pinfo, keys_tree, hf_reload_dictionarykey, offset, 2, keys_length-keys_offset);
2522         if (local_increment == 0) break;
2523         keys_offset += local_increment;
2524         nKeys++;
2525       }
2526       proto_item_append_text(ti_keys, "(%d keys)", nKeys);
2527
2528     }
2529     break;
2530
2531     default:
2532       break;
2533     }
2534   }
2535   return (length_field + 4 + 8 +2);
2536 }
2537
2538
2539 static int
2540 dissect_fetchreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, gboolean meta)
2541 {
2542   proto_item *ti_fetchreq;
2543   proto_item *ti_specifiers;
2544   proto_tree *fetchreq_tree;
2545   proto_tree *specifiers_tree;
2546   guint16     resourceid_length;
2547   guint16     specifiers_length;
2548   gint32      specifiers_offset = 0;
2549   int         nSpecifiers       = 0;
2550   guint16     local_offset      = 0;
2551   guint16     local_length      = 0;
2552   int         hf                = hf_reload_fetchreq;
2553
2554   if (meta == TRUE) {
2555     hf = hf_reload_statreq;
2556   }
2557
2558   resourceid_length = get_opaque_length(tvb,offset, 1);
2559   specifiers_length = get_opaque_length(tvb, offset+1+resourceid_length, 2);
2560
2561   if (1+ resourceid_length+ 2 + specifiers_length > length) {
2562     ti_fetchreq = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
2563     expert_add_info_format(pinfo, ti_fetchreq, &ei_reload_truncated_field, "Truncated FetchReq");
2564     return length;
2565   }
2566   local_length =  1+ resourceid_length+ 2 + specifiers_length;
2567   ti_fetchreq = proto_tree_add_item(tree, hf, tvb, offset, local_length, ENC_NA);
2568   fetchreq_tree = proto_item_add_subtree(ti_fetchreq, ett_reload_fetchreq);
2569
2570   local_offset +=
2571     dissect_resourceid(hf_reload_resource, tvb, pinfo, fetchreq_tree, offset, local_length);
2572
2573   ti_specifiers = proto_tree_add_item(fetchreq_tree, hf_reload_fetchreq_specifiers, tvb, offset+local_offset, 2+specifiers_length, ENC_NA);
2574   specifiers_tree = proto_item_add_subtree(ti_specifiers, ett_reload_fetchreq_specifiers);
2575   proto_item_append_text(ti_specifiers, "(StoredDataSpecifier<%d>)", specifiers_length);
2576   proto_tree_add_item(specifiers_tree, hf_reload_length_uint16, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
2577   local_offset += 2;
2578
2579   while (specifiers_offset >= 0 && specifiers_offset < specifiers_length) {
2580     guint32 specifiers_increment;
2581     specifiers_increment = dissect_storeddataspecifier(tvb, pinfo, specifiers_tree, offset+local_offset+specifiers_offset, specifiers_length-specifiers_offset);
2582     if (specifiers_increment == 0) {
2583       break;
2584     }
2585     nSpecifiers++;
2586     specifiers_offset += specifiers_increment;
2587   }
2588   proto_item_append_text(ti_specifiers, ": %d elements", nSpecifiers);
2589
2590   return (1+ resourceid_length+ 2 + specifiers_length);
2591 }
2592
2593
2594 static int
2595 dissect_fetchans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2596 {
2597   proto_item *ti_fetchans;
2598   proto_tree *fetchans_tree;
2599   guint32     kind_responses_length;
2600   guint32     kind_responses_offset = 0;
2601
2602   kind_responses_length = tvb_get_ntohl(tvb, offset);
2603   if (4 + kind_responses_length > length) {
2604     ti_fetchans = proto_tree_add_item(tree, hf_reload_fetchans, tvb, offset, length, ENC_NA);
2605     expert_add_info_format(pinfo, ti_fetchans, &ei_reload_truncated_field, "Truncated FetchAns");
2606     return length;
2607   }
2608   ti_fetchans = proto_tree_add_item(tree, hf_reload_fetchans, tvb, offset, 4 + kind_responses_length, ENC_NA);
2609   fetchans_tree = proto_item_add_subtree(ti_fetchans, ett_reload_fetchans);
2610
2611   proto_tree_add_uint(fetchans_tree, hf_reload_length_uint32, tvb, offset, 4, kind_responses_length);
2612
2613   while (kind_responses_offset < kind_responses_length) {
2614     guint32 kind_responses_increment;
2615     kind_responses_increment = dissect_kinddata(tvb, pinfo, fetchans_tree, offset + 4 + kind_responses_offset, kind_responses_length - kind_responses_offset, FALSE);
2616     if (kind_responses_increment == 0) {
2617       break;
2618     }
2619     kind_responses_offset += kind_responses_increment;
2620   }
2621
2622   return 4 + kind_responses_length;
2623 }
2624
2625
2626 static int
2627 dissect_statans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2628 {
2629   proto_item *ti_statans;
2630   proto_tree *statans_tree;
2631   guint32     kind_responses_length;
2632   guint32     kind_responses_offset = 0;
2633   int         nResponses            = 0;
2634
2635   kind_responses_length = tvb_get_ntohl(tvb, offset);
2636
2637   if (4 + kind_responses_length > length) {
2638     ti_statans = proto_tree_add_item(tree, hf_reload_statans, tvb, offset, length, ENC_NA);
2639     expert_add_info_format(pinfo, ti_statans, &ei_reload_truncated_field, "Truncated StatAns");
2640     return length;
2641   }
2642   ti_statans = proto_tree_add_item(tree, hf_reload_statans, tvb, offset, 4 + kind_responses_length, ENC_NA);
2643   proto_item_append_text(ti_statans, " (StatKindResponse<%d>)", kind_responses_length);
2644   statans_tree = proto_item_add_subtree(ti_statans, ett_reload_statans);
2645
2646   proto_tree_add_uint(statans_tree, hf_reload_length_uint32, tvb, offset, 4, kind_responses_length);
2647
2648
2649   while (kind_responses_offset < kind_responses_length) {
2650     guint32 kind_responses_increment;
2651     kind_responses_increment = dissect_kinddata(tvb, pinfo, statans_tree, offset + 4 + kind_responses_offset, kind_responses_length - kind_responses_offset, TRUE);
2652     if (kind_responses_increment == 0) {
2653       break;
2654     }
2655     nResponses++;
2656     kind_responses_offset += kind_responses_increment;
2657   }
2658
2659   proto_item_append_text(ti_statans, ": %d elements", nResponses);
2660
2661   return 4 + kind_responses_length;
2662 }
2663
2664
2665 static int
2666 dissect_chordupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2667 {
2668   proto_item *ti_chordupdate;
2669   proto_tree *chordupdate_tree;
2670   guint16     local_offset = 0;
2671   guint8      type;
2672
2673   ti_chordupdate = proto_tree_add_item(tree, hf_reload_chordupdate, tvb, offset, length, ENC_NA);
2674   chordupdate_tree = proto_item_add_subtree(ti_chordupdate, ett_reload_chordupdate);
2675
2676   proto_tree_add_item(chordupdate_tree, hf_reload_uptime, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
2677   local_offset += 4;
2678   type = tvb_get_guint8(tvb, offset + local_offset);
2679   proto_tree_add_uint(chordupdate_tree, hf_reload_chordupdate_type, tvb, offset+local_offset, 1, type);
2680   local_offset += 1;
2681
2682   switch(type) {
2683   case CHORDUPDATETYPE_NEIGHBORS:
2684     local_offset += dissect_nodeid_list(tvb, pinfo, chordupdate_tree, offset+local_offset, length-local_offset, hf_reload_chordupdate_predecessors, 2);
2685     local_offset += dissect_nodeid_list(tvb, pinfo, chordupdate_tree, offset+local_offset, length-local_offset, hf_reload_chordupdate_successors, 2);
2686     break;
2687
2688   case CHORDUPDATETYPE_FULL:
2689     local_offset += dissect_nodeid_list(tvb, pinfo, chordupdate_tree, offset+local_offset, length-local_offset, hf_reload_chordupdate_predecessors, 2);
2690     local_offset += dissect_nodeid_list(tvb, pinfo, chordupdate_tree, offset+local_offset, length-local_offset, hf_reload_chordupdate_successors, 2);
2691     local_offset += dissect_nodeid_list(tvb, pinfo, chordupdate_tree, offset+local_offset, length-local_offset, hf_reload_chordupdate_fingers, 2);
2692     break;
2693
2694   default:
2695     break;
2696   }
2697   return local_offset;
2698 }
2699
2700
2701 static int
2702 dissect_chordroutequeryans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2703 {
2704   proto_item *ti_chordroutequeryans;
2705   proto_tree *chordroutequeryans_tree;
2706
2707   ti_chordroutequeryans = proto_tree_add_item(tree, hf_reload_chordroutequeryans, tvb, offset, length, ENC_NA);
2708   chordroutequeryans_tree = proto_item_add_subtree(ti_chordroutequeryans, ett_reload_chordroutequeryans);
2709   dissect_nodeid(hf_reload_chordroutequeryans_next_peer, tvb, pinfo, chordroutequeryans_tree, offset, length);
2710
2711   return length;
2712 }
2713
2714 static int
2715 dissect_chordleavedata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2716 {
2717   proto_item *ti_local;
2718   proto_tree *local_tree;
2719   guint16     local_offset = 0;
2720   guint8      type;
2721
2722   ti_local = proto_tree_add_item(tree, hf_reload_chordleave, tvb, offset, length, ENC_NA);
2723   local_tree = proto_item_add_subtree(ti_local, ett_reload_chordleave);
2724
2725   type = tvb_get_guint8(tvb, offset + local_offset);
2726   proto_tree_add_uint(local_tree, hf_reload_chordleave_type, tvb, offset+local_offset, 1, type);
2727   local_offset += 1;
2728
2729   switch(type) {
2730   case CHORDLEAVETYPE_FROM_SUCC:
2731     local_offset += dissect_nodeid_list(tvb, pinfo, local_tree, offset+local_offset, length-local_offset, hf_reload_chordleave_successors, 2);
2732     break;
2733
2734   case CHORDLEAVETYPE_FROM_PRED:
2735     local_offset += dissect_nodeid_list(tvb, pinfo, local_tree, offset+local_offset, length-local_offset, hf_reload_chordleave_predecessors, 2);
2736     break;
2737
2738   default:
2739     break;
2740   }
2741   return local_offset;
2742 }
2743
2744 static int dissect_kindid_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length, guint16 length_size)
2745 {
2746   proto_item *ti_local;
2747   proto_tree *local_tree;
2748   int         kinds_length = 0;
2749   int         kinds_offset = 0;
2750   int         nKinds       = 0;
2751
2752   kinds_length = get_opaque_length(tvb, offset, length_size);
2753
2754   if ((guint16)length<kinds_length+length_size) {
2755     ti_local = proto_tree_add_item(tree, hf_reload_kindid_list, tvb, offset, length, ENC_NA);
2756     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated kinds list");
2757   }
2758   ti_local = proto_tree_add_item(tree, hf_reload_kindid_list, tvb, offset, length, ENC_NA);
2759   local_tree = proto_item_add_subtree(ti_local, ett_reload_kindid_list);
2760   proto_item_append_text(ti_local, "(KindId<%d>)", kinds_length);
2761
2762   dissect_length(tvb, local_tree, offset, length_size);
2763
2764   while (kinds_offset < kinds_length) {
2765     kind_t *kind;
2766     int local_increment = dissect_kindid(-1,tvb, local_tree,offset+length_size+kinds_offset, &kind);
2767     if (local_increment <= 0) break;
2768     kinds_offset += local_increment;
2769     nKinds++;
2770   }
2771   proto_item_append_text(ti_local, ": %d elements", nKinds);
2772
2773   return (length_size+kinds_length);
2774 }
2775
2776 static int dissect_findreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length) {
2777   proto_item *ti_local;
2778   proto_tree *local_tree;
2779   guint16     local_offset = 0;
2780
2781   ti_local = proto_tree_add_item(tree, hf_reload_findreq, tvb, offset, length, ENC_NA);
2782   local_tree = proto_item_add_subtree(ti_local, ett_reload_findreq);
2783
2784   local_offset += dissect_resourceid(hf_reload_resource, tvb, pinfo, local_tree, offset, length);
2785   dissect_kindid_list(tvb, pinfo, local_tree, offset+local_offset, length-local_offset, 1);
2786
2787   return length;
2788 }
2789
2790 static int dissect_findans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length) {
2791   proto_item *ti_local;
2792   proto_tree *local_tree;
2793   guint16     results_length;
2794
2795   ti_local = proto_tree_add_item(tree, hf_reload_findans, tvb, offset, length, ENC_NA);
2796   local_tree = proto_item_add_subtree(ti_local, ett_reload_findans);
2797   results_length = tvb_get_ntohs(tvb, offset);
2798   proto_item_append_text(ti_local, " (FindKindData<%d>)", results_length);
2799   if (results_length + 2 > length) {
2800     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated FindAns");
2801   }
2802   proto_tree_add_uint(local_tree, hf_reload_length_uint16, tvb, offset, 2, results_length);
2803
2804   {
2805     gint32  results_offset = 0;
2806     int nResults           = 0;
2807     while (results_offset >= 0 && results_offset < results_length) {
2808       proto_item *ti_findkinddata;
2809       proto_tree *findkinddata_tree;
2810       guint16     findkinddata_length;
2811       kind_t     *kind;
2812       findkinddata_length = 4/*kind id */ + 1 + get_opaque_length(tvb,offset + 2 + results_offset + 4, 1)/* resourceId */;
2813       if (results_offset + findkinddata_length > results_length) {
2814         ti_findkinddata = proto_tree_add_item(local_tree, hf_reload_findkinddata, tvb, offset + results_offset, results_length - results_offset, ENC_NA);
2815         expert_add_info_format(pinfo, ti_findkinddata, &ei_reload_truncated_field, "Truncated FindKindData");
2816         break;
2817       }
2818
2819       ti_findkinddata = proto_tree_add_item(local_tree, hf_reload_findkinddata, tvb, offset + 2 + results_offset, findkinddata_length, ENC_NA);
2820       findkinddata_tree = proto_item_add_subtree(ti_findkinddata, ett_reload_findkinddata);
2821       dissect_kindid(hf_reload_kinddata_kind,tvb, findkinddata_tree, offset+2+results_offset,&kind);
2822       dissect_resourceid(hf_reload_findkinddata_closest, tvb, pinfo, findkinddata_tree, offset+2+results_offset+4,  results_length - 4 - results_offset);
2823       if (findkinddata_length <= 0) break;
2824       results_offset += findkinddata_length;
2825       nResults++;
2826     }
2827     proto_item_append_text(ti_local, ": %d elements", nResults);
2828   }
2829
2830   return length;
2831 }
2832
2833 static int dissect_selftuningdata(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
2834 {
2835   proto_item *ti_local;
2836   proto_tree *local_tree;
2837
2838   ti_local = proto_tree_add_item(tree, hf_reload_self_tuning_data, tvb, offset, 12, ENC_NA);
2839   local_tree = proto_item_add_subtree(ti_local, ett_reload_self_tuning_data);
2840
2841   proto_tree_add_item(local_tree, hf_reload_self_tuning_data_network_size, tvb, offset, 4, ENC_BIG_ENDIAN);
2842   proto_tree_add_item(local_tree, hf_reload_self_tuning_data_join_rate, tvb, offset+4, 4, ENC_BIG_ENDIAN);
2843   proto_tree_add_item(local_tree, hf_reload_self_tuning_data_leave_rate, tvb, offset+8, 4, ENC_BIG_ENDIAN);
2844
2845   return 12;
2846 }
2847
2848 static int dissect_extensiveroutingmodeoption(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2849 {
2850   proto_item *ti_local;
2851   proto_tree *local_tree;
2852   guint16     local_offset = 0;
2853
2854   ti_local = proto_tree_add_item(tree, hf_reload_extensiveroutingmodeoption, tvb, offset, length, ENC_NA);
2855   local_tree = proto_item_add_subtree(ti_local, ett_reload_extensiveroutingmodeoption);
2856
2857   proto_tree_add_item(local_tree, hf_reload_routemode, tvb, offset, 1, ENC_BIG_ENDIAN);
2858   local_offset += 1;
2859   proto_tree_add_item(local_tree, hf_reload_extensiveroutingmode_transport, tvb,
2860                       offset+local_offset, 1, ENC_BIG_ENDIAN);
2861   local_offset += 1;
2862   local_offset += dissect_ipaddressport(hf_reload_extensiveroutingmode_ipaddressport, tvb, local_tree, offset+local_offset);
2863   {
2864     proto_item *ti_destination;
2865     proto_tree *destination_tree;
2866     guint16     destination_length;
2867     int         nDestinations = 0;
2868     destination_length = tvb_get_guint8(tvb, offset+local_offset);
2869     if (destination_length+1+local_offset>length) {
2870       expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated ExtensiveRoutingModeOption");
2871       destination_length = length -1-local_offset;
2872     }
2873     ti_destination = proto_tree_add_item(local_tree, hf_reload_extensiveroutingmode_destination, tvb,offset+local_offset, 1+destination_length, ENC_NA);
2874     proto_item_append_text(ti_destination, " (Destination<%d>)", destination_length);
2875     destination_tree = proto_item_add_subtree(ti_destination, ett_reload_extensiveroutingmode_destination);
2876     proto_tree_add_item(destination_tree, hf_reload_length_uint8, tvb,offset+local_offset, 1, ENC_BIG_ENDIAN);
2877     local_offset += 1;
2878     dissect_destination_list(tvb, pinfo, destination_tree, offset+local_offset, destination_length, &nDestinations);
2879     proto_item_append_text(ti_destination, ": %d elements", nDestinations);
2880     local_offset += destination_length;
2881   }
2882   return local_offset;
2883 }
2884
2885 static int dissect_forwardingoption(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2886 {
2887   proto_item *ti_option;
2888   guint16     local_offset  = 0;
2889   guint8      option_type   = tvb_get_guint8(tvb,offset);
2890   guint8      option_flags  = tvb_get_guint8(tvb, offset+ 1);
2891   guint16     option_length = tvb_get_ntohs(tvb, offset+ 2);
2892   proto_tree *option_tree;
2893
2894   ti_option = proto_tree_add_item(tree, hf_reload_forwarding_option, tvb, offset+local_offset, option_length + 4, ENC_NA);
2895   proto_item_append_text(ti_option, " type=%s, flags=%02x, length=%d", val_to_str_const(option_type, forwardingoptiontypes, "Unknown"), option_flags, option_length);
2896
2897   option_tree = proto_item_add_subtree(ti_option, ett_reload_forwarding_option);
2898   proto_tree_add_item(option_tree, hf_reload_forwarding_option_type, tvb, offset+local_offset, 1, ENC_BIG_ENDIAN);
2899   {
2900     proto_item *ti_flags;
2901     proto_tree *flags_tree;
2902     guint32 bit_offset;
2903     ti_flags = proto_tree_add_uint(option_tree, hf_reload_forwarding_option_flags, tvb, offset+local_offset+1, 1, option_flags);
2904     flags_tree = proto_item_add_subtree(ti_flags, ett_reload_forwarding_option_flags);
2905     bit_offset = 8*(offset+local_offset+1);
2906     proto_tree_add_bits_item(flags_tree, hf_reload_forwarding_option_flag_ignore_state_keeping, tvb, bit_offset+4, 1, ENC_BIG_ENDIAN);
2907     proto_tree_add_bits_item(flags_tree, hf_reload_forwarding_option_flag_response_copy, tvb, bit_offset+5, 1, ENC_BIG_ENDIAN);
2908     proto_tree_add_bits_item(flags_tree, hf_reload_forwarding_option_flag_destination_critical, tvb, bit_offset+6, 1, ENC_BIG_ENDIAN);
2909     proto_tree_add_bits_item(flags_tree, hf_reload_forwarding_option_flag_forward_critical, tvb, bit_offset+7, 1, ENC_BIG_ENDIAN);
2910   }
2911   proto_tree_add_uint(option_tree, hf_reload_length_uint16, tvb, offset+local_offset+2, 2, option_length);
2912   local_offset += 4;
2913   if (local_offset + option_length > length) {
2914     expert_add_info_format(pinfo, ti_option, &ei_reload_truncated_field, "Truncated ForwardingOption");
2915     return length;
2916   }
2917
2918   switch (option_type) {
2919   case OPTIONTYPE_EXTENSIVE_ROUTING_MODE:
2920     dissect_extensiveroutingmodeoption(tvb, pinfo, option_tree, offset+local_offset, option_length);
2921     break;
2922
2923   default:
2924     proto_tree_add_item(option_tree, hf_reload_opaque_data, tvb, offset+local_offset, option_length, ENC_NA);
2925     break;
2926   }
2927   local_offset += option_length;
2928
2929   return local_offset;
2930 }
2931
2932 static int dissect_dmflag(tvbuff_t *tvb, proto_tree *tree, guint16 offset) {
2933   proto_item *ti_local;
2934   proto_tree *local_tree;
2935   guint       i;
2936   guint32     bit_offset = offset<<3;
2937
2938   ti_local = proto_tree_add_item(tree, hf_reload_dmflags, tvb, offset, 8, ENC_BIG_ENDIAN);
2939   local_tree = proto_item_add_subtree(ti_local, ett_reload_dmflags);
2940
2941   for (i=0; i<(sizeof(reload_dmflag_items)/sizeof(gint *)); i++) {
2942     if (reload_dmflag_items[i] != NULL) {
2943       proto_tree_add_bits_item(local_tree, *(reload_dmflag_items[i]), tvb, bit_offset+63-i, 1, ENC_BIG_ENDIAN);
2944     }
2945   }
2946   return 8;
2947 }
2948
2949 static int dissect_diagnosticextension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
2950 {
2951   proto_item *ti_local;
2952   proto_tree *local_tree;
2953   guint16     local_offset = 0;
2954   guint16     local_length = 0;
2955
2956   local_length = 2 + 4 + get_opaque_length(tvb, offset+2,4);
2957   ti_local = proto_tree_add_item(tree, hf_reload_diagnosticextension, tvb, offset, local_length, ENC_NA);
2958   local_tree = proto_item_add_subtree(ti_local, ett_reload_diagnosticextension);
2959
2960   proto_tree_add_item(local_tree, hf_reload_diagnosticextension_type, tvb, offset, 2, ENC_BIG_ENDIAN);
2961   local_offset += 2;
2962   local_offset += dissect_opaque(tvb, pinfo, local_tree, hf_reload_diagnosticextension_contents, offset + local_offset, 4, length-2);
2963
2964   return local_offset;
2965 }
2966
2967 static int dissect_diagnosticrequest(int anchor, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length) {
2968   proto_item *ti_local;
2969   proto_tree *local_tree;
2970   guint16     local_offset = 0;
2971   guint32     local_length = 0;
2972   int         hf           = hf_reload_diagnosticrequest;
2973
2974   if (anchor >= 0) {
2975     hf = anchor;
2976   }
2977
2978   ti_local = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
2979   local_tree = proto_item_add_subtree(ti_local, ett_reload_diagnosticrequest);
2980
2981   proto_tree_add_item(local_tree, hf_reload_diagnostic_expiration, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2982   local_offset += 8;
2983   proto_tree_add_item(local_tree, hf_reload_diagnosticrequest_timestampinitiated, tvb,
2984                       offset+local_offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2985   local_offset += 8;
2986   local_offset += dissect_dmflag(tvb, local_tree, offset+local_offset);
2987   local_length = tvb_get_ntohl(tvb, offset+local_offset);
2988   proto_tree_add_item(local_tree, hf_reload_length_uint32, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
2989   local_offset += 4;
2990
2991   if (local_offset+local_length > length) {
2992     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated DiagnosticRequest");
2993     local_length = length-local_offset;
2994   }
2995   if (local_length>0) {
2996     proto_item *ti_extensions;
2997     proto_tree *extensions_tree;
2998     guint32     extensions_offset = 0;
2999     guint32     extensions_length = 0;
3000     int         nExtensions       = 0;
3001
3002     ti_extensions = proto_tree_add_item(local_tree, hf_reload_diagnosticrequest_extensions, tvb, offset+local_offset, local_length, ENC_NA);
3003     extensions_tree = proto_item_add_subtree(ti_extensions, ett_reload_diagnosticrequest_extensions);
3004     extensions_length = tvb_get_ntohl(tvb, offset+local_offset);
3005     if (extensions_length+4 > local_length) {
3006       expert_add_info_format(pinfo, ti_extensions, &ei_reload_truncated_field, "Truncated Diagnostic extensions");
3007       extensions_length = local_length-4;
3008     }
3009     proto_item_append_text(ti_extensions, " (DiagnosticExtension<%d>)",extensions_length);
3010     proto_tree_add_item(extensions_tree, hf_reload_length_uint32, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3011     while (extensions_offset<extensions_length) {
3012       int local_increment = dissect_diagnosticextension(tvb, pinfo, extensions_tree, offset+4+local_offset+extensions_offset, extensions_length-extensions_offset);
3013       if (local_increment <= 0) break;
3014       extensions_offset += local_increment;
3015       nExtensions++;
3016     }
3017     proto_item_append_text(ti_extensions, " : %d elements", nExtensions);
3018   }
3019   local_offset += local_length;
3020   return local_offset;
3021 }
3022
3023 static int dissect_pathtrackreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3024 {
3025   proto_item *ti_local;
3026   proto_tree *local_tree;
3027   guint16     local_offset = 0;
3028
3029   ti_local = proto_tree_add_item(tree, hf_reload_pathtrackreq, tvb, offset, length, ENC_NA);
3030   local_tree = proto_item_add_subtree(ti_local, ett_reload_pathtrackreq);
3031   local_offset += dissect_destination(hf_reload_pathtrackreq_destination, tvb, pinfo, local_tree, offset+local_offset,length);
3032   local_offset += dissect_diagnosticrequest(hf_reload_pathtrackreq_request, tvb, pinfo, local_tree, offset+local_offset, length-local_offset);
3033
3034   return local_offset;
3035 }
3036
3037 static int dissect_diagnosticinfo(tvbuff_t *tvb, proto_tree *tree, guint16 offset, guint16 length)
3038 {
3039   proto_item *ti_local;
3040   proto_tree *local_tree;
3041   guint16     local_offset = 0;
3042   guint16     local_length = 0;
3043   guint16     kindid;
3044
3045   local_length = 2 + tvb_get_ntohs(tvb, offset+2);
3046   ti_local = proto_tree_add_item(tree, hf_reload_diagnosticinfo, tvb, offset, local_length+4, ENC_NA);
3047   local_tree = proto_item_add_subtree(ti_local, ett_reload_diagnosticinfo);
3048
3049   proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_kind, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
3050   local_offset += 2;
3051   proto_tree_add_item(local_tree, hf_reload_length_uint16, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
3052   local_offset += 2;
3053
3054   kindid = tvb_get_ntohs(tvb, offset);
3055   switch(kindid) {
3056   case DIAGNOSTICKINDID_STATUS_INFO:
3057     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_congestion_status, tvb, offset+local_offset, 1, ENC_BIG_ENDIAN);
3058     break;
3059
3060   case DIAGNOSTICKINDID_ROUTING_TABLE_SIZE:
3061     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_number_peers, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3062     break;
3063
3064   case DIAGNOSTICKINDID_PROCESS_POWER:
3065     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_processing_power, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3066     break;
3067
3068   case DIAGNOSTICKINDID_BANDWIDTH:
3069     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_bandwidth, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3070     break;
3071
3072   case DIAGNOSTICKINDID_SOFTWARE_VERSION:
3073     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_software_version, tvb, offset+local_offset, length, ENC_ASCII|ENC_NA);
3074     break;
3075
3076   case DIAGNOSTICKINDID_MACHINE_UPTIME:
3077     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_machine_uptime, tvb, offset+local_offset, 8, ENC_BIG_ENDIAN);
3078     break;
3079
3080   case DIAGNOSTICKINDID_APP_UPTIME:
3081     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_app_uptime, tvb, offset+local_offset, 8, ENC_BIG_ENDIAN);
3082     break;
3083
3084   case DIAGNOSTICKINDID_MEMORY_FOOTPRINT:
3085     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_memory_footprint, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3086     break;
3087
3088   case DIAGNOSTICKINDID_DATASIZE_STORED:
3089     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_datasize_stored, tvb, offset+local_offset, 8, ENC_BIG_ENDIAN);
3090     break;
3091
3092   case DIAGNOSTICKINDID_INSTANCES_STORED:
3093   {
3094     proto_item *ti_instances;
3095     proto_tree *instances_tree;
3096     gint32      instances_offset = 0;
3097     int         nElements        = 0;
3098
3099     ti_instances = proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_instances_stored,\
3100                                        tvb, offset+local_offset, length, ENC_NA);
3101     instances_tree = proto_item_add_subtree(ti_instances, ett_reload_diagnosticinfo_instances_stored);
3102     proto_item_append_text(ti_instances, "[%d]", length);
3103     while (instances_offset >= 0 && instances_offset < length) {
3104       proto_item *ti_instances_per_kindid;
3105       proto_tree *instances_per_kindid_tree;
3106       kind_t     *kind;
3107       guint64     instances;
3108       ti_instances_per_kindid = proto_tree_add_item(instances_tree, hf_reload_diagnosticinfo_instancesstored_info,
3109                                                     tvb, offset+local_offset+instances_offset, 12, ENC_NA);
3110       instances_per_kindid_tree = proto_item_add_subtree(ti_instances_per_kindid,
3111                                                          ett_reload_diagnosticinfo_instancesstored_info);
3112       dissect_kindid(hf_reload_kinddata_kind, tvb, instances_per_kindid_tree, offset+local_offset+instances_offset, &kind);
3113       proto_tree_add_item(instances_per_kindid_tree, hf_reload_diagnosticinfo_instancesstored_instances,
3114                           tvb, offset+local_offset+instances_offset+4, 8, ENC_BIG_ENDIAN);
3115       instances = tvb_get_ntoh64(tvb, offset+local_offset+instances_offset+4);
3116       proto_item_append_text(ti_instances_per_kindid, ": %s/%" G_GINT64_MODIFIER "d",
3117           ((kind != NULL) && (kind->name != NULL)) ? kind->name : "UNKNOWN KIND", instances);
3118       instances_offset += 12;
3119       nElements++;
3120     }
3121     if (nElements>0) {
3122       proto_item_append_text(ti_instances, ": %d", nElements);
3123     }
3124   }
3125   break;
3126
3127
3128   case DIAGNOSTICKINDID_MESSAGES_SENT_RCVD:
3129   {
3130     proto_item *ti_messages;
3131     proto_tree *messages_tree;
3132     gint32      messages_offset = 0;
3133     int         nElements       = 0;
3134
3135     ti_messages = proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_messages_sent_rcvd,
3136                                       tvb, offset+local_offset, length, ENC_NA);
3137     messages_tree = proto_item_add_subtree(ti_messages, ett_reload_diagnosticinfo_messages_sent_rcvd);
3138     proto_item_append_text(ti_messages, "[%d]", length);
3139
3140     while (messages_offset >= 0 && messages_offset < length) {
3141       proto_item *ti_sent_rcvd;
3142       proto_tree *sent_rcvd_tree;
3143       guint16     message_code;
3144
3145       ti_sent_rcvd = proto_tree_add_item(messages_tree, hf_reload_diagnosticinfo_messages_sent_rcvd_info, tvb, offset+local_offset+messages_offset, 20, ENC_NA);
3146
3147       sent_rcvd_tree = proto_item_add_subtree(ti_sent_rcvd, ett_reload_diagnosticinfo_messages_sent_rcvd_info);
3148       message_code = tvb_get_ntohs(tvb, offset+local_offset+messages_offset);
3149       if (message_code == RELOAD_ERROR) {
3150         proto_tree_add_uint_format_value(sent_rcvd_tree, hf_reload_diagnosticinfo_message_code, tvb,
3151                                          offset+local_offset+messages_offset, 2,
3152                                          message_code,
3153                                          "error");
3154
3155       }
3156       else {
3157         proto_tree_add_uint_format_value(sent_rcvd_tree, hf_reload_diagnosticinfo_message_code, tvb,
3158                                          offset+local_offset+messages_offset, 2,
3159                                          message_code,
3160                                          "%s_%s",
3161                                          val_to_str_const(MSGCODE_TO_METHOD(message_code), methods_short, "Unknown"),
3162                                          val_to_str_const(MSGCODE_TO_CLASS(message_code), classes_short, "Unknown"));
3163       }
3164       proto_tree_add_item(sent_rcvd_tree, hf_reload_diagnosticinfo_messages_sent,
3165                           tvb, offset+local_offset+messages_offset+2, 8, ENC_BIG_ENDIAN);
3166       proto_tree_add_item(sent_rcvd_tree, hf_reload_diagnosticinfo_messages_rcvd,
3167                           tvb, offset+local_offset+messages_offset+2+8, 8, ENC_BIG_ENDIAN);
3168       messages_offset += 18;
3169       nElements++;
3170     }
3171     if (nElements>0) {
3172       proto_item_append_text(ti_messages, ": %d", nElements);
3173     }
3174   }
3175   break;
3176
3177   case DIAGNOSTICKINDID_EWMA_BYTES_SENT:
3178     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_ewma_bytes_sent, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3179     break;
3180
3181   case DIAGNOSTICKINDID_EWMA_BYTES_RCVD:
3182     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_ewma_bytes_rcvd, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3183     break;
3184
3185   case DIAGNOSTICKINDID_UNDERLAY_HOP:
3186     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_underlay_hops, tvb, offset+local_offset, 1, ENC_BIG_ENDIAN);
3187     break;
3188
3189   case DIAGNOSTICKINDID_BATTERY_STATUS:
3190     proto_tree_add_item(local_tree, hf_reload_diagnosticinfo_battery_status, tvb, offset+local_offset, 1, ENC_BIG_ENDIAN);
3191     break;
3192
3193   default:
3194     proto_tree_add_item(local_tree, hf_reload_opaque_data, tvb, offset+local_offset, length, ENC_NA);
3195     break;
3196
3197   }
3198
3199   return local_length;
3200 }
3201
3202
3203 static int dissect_diagnosticresponse(int anchor, tvbuff_t *tvb, packet_info *pinfo,proto_tree *tree, guint16 offset, guint16 length) {
3204   proto_item *ti_local;
3205   proto_tree *local_tree;
3206   guint16     local_offset = 0;
3207   int         hf           = hf_reload_diagnosticresponse;
3208
3209   if (anchor >= 0) {
3210     hf = anchor;
3211   }
3212
3213   ti_local = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_NA);
3214   local_tree = proto_item_add_subtree(ti_local, ett_reload_diagnosticresponse);
3215
3216   proto_tree_add_item(local_tree, hf_reload_diagnostic_expiration, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
3217   local_offset += 8;
3218   proto_tree_add_item(local_tree, hf_reload_diagnosticresponse_timestampreceived,
3219                       tvb, offset+local_offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
3220   local_offset += 8;
3221   proto_tree_add_item(local_tree, hf_reload_diagnosticresponse_hopcounter, tvb, offset+local_offset, 1, ENC_BIG_ENDIAN);
3222
3223
3224   {
3225     proto_item *ti_diagnostics;
3226     proto_tree *diagnostics_tree;
3227     gint32      diagnostics_offset = 0;
3228     guint32     diagnostics_length = 0;
3229     int         nDiagnostics       = 0;
3230
3231     diagnostics_length = tvb_get_ntohl(tvb, offset+local_offset);
3232     if (diagnostics_length+local_offset+4>length) {
3233       expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated Diagnostic Response");
3234       diagnostics_length = length -4 -local_offset;
3235     }
3236     ti_diagnostics = proto_tree_add_item(local_tree, hf_reload_diagnosticresponse_diagnostic_info_list, tvb, offset+local_offset, diagnostics_length, ENC_NA);
3237     diagnostics_tree = proto_item_add_subtree(ti_local, ett_reload_diagnosticresponse_diagnostic_info_list);
3238     proto_item_append_text(ti_diagnostics, " (DiagnosticInfo<%d>)",diagnostics_length);
3239     proto_tree_add_item(diagnostics_tree, hf_reload_length_uint32, tvb, offset+local_offset, 4, ENC_BIG_ENDIAN);
3240     local_offset += 4;
3241     while (diagnostics_offset >= 0 && (guint32)diagnostics_offset<diagnostics_length) {
3242       int local_increment = dissect_diagnosticinfo(tvb, diagnostics_tree, offset+local_offset+diagnostics_offset, diagnostics_length-diagnostics_offset);
3243       if (local_increment <= 0) break;
3244       diagnostics_offset += local_increment;
3245       nDiagnostics++;
3246     }
3247     proto_item_append_text(ti_diagnostics, " : %d elements", nDiagnostics);
3248     local_offset += diagnostics_length;
3249   }
3250
3251   return local_offset;
3252 }
3253
3254 static int dissect_pathtrackans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3255 {
3256   proto_item *ti_local;
3257   proto_tree *local_tree;
3258   guint16     local_offset = 0;
3259
3260   ti_local = proto_tree_add_item(tree, hf_reload_pathtrackans, tvb, offset, length, ENC_NA);
3261   local_tree = proto_item_add_subtree(ti_local, ett_reload_pathtrackans);
3262   local_offset += dissect_destination(hf_reload_pathtrackans_next_hop, tvb, pinfo, local_tree, offset+local_offset,length);
3263   local_offset += dissect_diagnosticresponse(hf_reload_pathtrackans_response, tvb, pinfo, local_tree, offset+local_offset, length-local_offset);
3264
3265   return local_offset;
3266 }
3267
3268 static int dissect_joinreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3269 {
3270   proto_item *ti_local;
3271   proto_tree *local_tree;
3272   guint16     local_offset = 0;
3273
3274   ti_local = proto_tree_add_item(tree, hf_reload_joinreq, tvb, offset, length, ENC_NA);
3275   local_tree = proto_item_add_subtree(ti_local, ett_reload_joinreq);
3276
3277   local_offset += dissect_nodeid(hf_reload_joinreq_joining_peer_id, tvb, pinfo, local_tree, offset, length);
3278   local_offset += dissect_opaque(tvb, pinfo, local_tree, hf_reload_overlay_specific, offset + local_offset, 2,
3279                                  length - local_offset);
3280   return local_offset;
3281 }
3282
3283 static int dissect_joinans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3284 {
3285   proto_item *ti_local;
3286   proto_tree *local_tree;
3287   guint16     local_offset = 0;
3288
3289   ti_local = proto_tree_add_item(tree, hf_reload_joinans, tvb, offset, length, ENC_NA);
3290   local_tree = proto_item_add_subtree(ti_local, ett_reload_joinans);
3291
3292   local_offset = dissect_opaque(tvb, pinfo, local_tree, hf_reload_overlay_specific,
3293                                 offset + local_offset, 2, length );
3294   return local_offset;
3295 }
3296
3297 static int dissect_leavereq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3298 {
3299   proto_item *ti_local;
3300   proto_tree *local_tree;
3301   guint16     local_offset = 0;
3302
3303   ti_local = proto_tree_add_item(tree, hf_reload_leavereq, tvb, offset, length, ENC_NA);
3304   local_tree = proto_item_add_subtree(ti_local, ett_reload_leavereq);
3305
3306   local_offset += dissect_nodeid(hf_reload_leavereq_leaving_peer_id, tvb, pinfo, local_tree, offset, length);
3307   if (0 == strcmp(TOPOLOGY_PLUGIN_CHORD_RELOAD, reload_topology_plugin)) {
3308     proto_item *ti_overlay_specific;
3309     proto_tree *overlay_specific_tree;
3310     guint16     overlay_length;
3311
3312     ti_overlay_specific   = proto_tree_add_item(local_tree, hf_reload_overlay_specific,
3313                                               tvb,  offset+local_offset,  length - local_offset, ENC_NA);
3314     overlay_specific_tree = proto_item_add_subtree(ti_overlay_specific, ett_reload_overlay_specific);
3315     proto_tree_add_item(overlay_specific_tree, hf_reload_length_uint16, tvb,  offset+local_offset,  2, ENC_BIG_ENDIAN);
3316
3317     overlay_length = tvb_get_ntohs(tvb, offset+local_offset);
3318     local_offset+= 2;
3319     dissect_chordleavedata(tvb, pinfo, overlay_specific_tree, offset+local_offset, overlay_length);
3320     local_offset += overlay_length;
3321   }
3322   else {
3323     local_offset += dissect_opaque(tvb, pinfo, local_tree, hf_reload_overlay_specific,
3324                                    offset + reload_nodeid_length, 2, length - local_offset);
3325   }
3326
3327   return local_offset;
3328 }
3329
3330 static int dissect_probereq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3331 {
3332   proto_item *ti_local,   *ti_requested_info;
3333   proto_tree *local_tree, *requested_info_tree;
3334   guint8      info_list_length = 0;
3335
3336   ti_local            = proto_tree_add_item(tree, hf_reload_probereq, tvb, offset, length, ENC_NA);
3337   local_tree          = proto_item_add_subtree(ti_local, ett_reload_probereq);
3338   ti_requested_info   = proto_tree_add_item(local_tree, hf_reload_probereq_requested_info, tvb, offset, length, ENC_NA);
3339   requested_info_tree = proto_item_add_subtree(ti_requested_info, ett_reload_probereq_requested_info);
3340   info_list_length    = tvb_get_guint8(tvb, offset);
3341
3342   proto_item_append_text(ti_requested_info, " (ProbeInformationType<%d>)", info_list_length);
3343   proto_tree_add_uint(requested_info_tree, hf_reload_length_uint8, tvb, offset, 1, info_list_length);
3344
3345   if ((info_list_length+1) > length) {
3346     expert_add_info_format(pinfo, ti_requested_info, &ei_reload_truncated_field, "Truncated requested_info");
3347     info_list_length = length - 1;
3348   }
3349   {
3350     int probe_offset = 0;
3351     int nInfos       = 0;
3352     while (probe_offset >= 0 && probe_offset < info_list_length) {
3353       proto_tree_add_item(requested_info_tree, hf_reload_probe_information_type,
3354                           tvb, offset + 1 + probe_offset, 1, ENC_BIG_ENDIAN);
3355       probe_offset += 1;
3356       nInfos++;
3357     }
3358     proto_item_append_text(ti_requested_info, ": %d elements", nInfos);
3359   }
3360
3361   return info_list_length;
3362 }
3363
3364 static int dissect_probeans(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3365 {
3366   proto_item *ti_local,   *ti_infos;
3367   proto_tree *local_tree, *infos_tree;
3368   guint16     info_list_length = 0;
3369
3370   ti_local   = proto_tree_add_item(tree, hf_reload_probeans, tvb, offset, length, ENC_NA);
3371   local_tree = proto_item_add_subtree(ti_local, ett_reload_probeans);
3372
3373   info_list_length = tvb_get_ntohs(tvb, offset);
3374   if (info_list_length+2 >length) {
3375     expert_add_info_format(pinfo, ti_local, &ei_reload_truncated_field, "Truncated ProbeAns");
3376     info_list_length = length - 2;
3377   }
3378   ti_infos = proto_tree_add_item(local_tree, hf_reload_probeans_probe_info, tvb, offset, info_list_length, ENC_NA);
3379   proto_item_append_text(ti_infos, " (ProbeInformation<%d>)", info_list_length);
3380   infos_tree = proto_item_add_subtree(ti_infos, ett_reload_probeans_probe_info);
3381   {
3382     int probe_offset = 0;
3383     int probe_increment;
3384     int nInfos       = 0;
3385     while (probe_offset >= 0 && probe_offset < info_list_length) {
3386       probe_increment = dissect_probe_information(tvb, pinfo, infos_tree, offset + 2 + probe_offset, info_list_length - probe_offset);
3387       if (probe_increment <= 0) {
3388         break;
3389       }
3390       probe_offset += probe_increment;
3391       nInfos++;
3392     }
3393     proto_item_append_text(ti_infos, ": %d elements", nInfos);
3394   }
3395   return length;
3396 }
3397
3398 extern gint dissect_reload_messagecontents(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 offset, guint16 length)
3399 {
3400   guint32     message_body_length;
3401   guint32     extensions_length;
3402   proto_item *ti_message_contents;
3403   proto_tree *message_contents_tree;
3404   guint16     message_code;
3405
3406   message_body_length = tvb_get_ntohl(tvb, offset + 2);
3407   extensions_length   = tvb_get_ntohl(tvb, offset + 2 + 4 + message_body_length);
3408
3409   if (2 + 4 + message_body_length + 4 + extensions_length > length) {
3410     ti_message_contents = proto_tree_add_item(tree, hf_reload_message_contents, tvb, offset, length, ENC_NA);
3411     expert_add_info_format(pinfo, ti_message_contents, &ei_reload_truncated_field, "Truncated MessageContents");
3412     return length;
3413   }
3414
3415   ti_message_contents = proto_tree_add_item(tree, hf_reload_message_contents, tvb, offset, 2 + 4 + message_body_length + 4 + extensions_length, ENC_NA);
3416   message_contents_tree = proto_item_add_subtree(ti_message_contents, ett_reload_message_contents);
3417
3418   message_code = tvb_get_ntohs(tvb, offset);
3419
3420   if (message_code != RELOAD_ERROR) {
3421     proto_item *ti_message_body;
3422     proto_tree *message_body_tree;
3423     const gchar *message_type_str = NULL;
3424
3425     /* message_code was already parsed */
3426     {
3427       proto_item *ti_message_code;
3428       ti_message_code = proto_tree_add_item(message_contents_tree, hf_reload_message_code, tvb,
3429                                             offset, 2, ENC_BIG_ENDIAN);
3430       proto_item_append_text(ti_message_code, " (%s_%s)",
3431                              val_to_str(MSGCODE_TO_METHOD(message_code), methods_short, "Unknown %d"),
3432                              val_to_str(MSGCODE_TO_CLASS(message_code), classes_short, "Unknown %d"));
3433     }
3434     offset += 2;
3435     /* Message body */
3436     ti_message_body = proto_tree_add_item(message_contents_tree, hf_reload_message_body, tvb, offset, 4 + message_body_length, ENC_NA);
3437     message_body_tree = proto_item_add_subtree(ti_message_body, ett_reload_message_body);
3438     proto_tree_add_uint(message_body_tree, hf_reload_length_uint32, tvb, offset, 4, message_body_length);
3439     offset += 4;
3440
3441     if (message_body_length > 0) {
3442       switch(MSGCODE_TO_METHOD(message_code)) {
3443       case METHOD_ROUTEQUERY:
3444       {
3445         if (IS_REQUEST(message_code)) {
3446           {
3447             proto_item * ti_routequeryreq;
3448             proto_tree * routequeryreq_tree;
3449             int destination_length;
3450             message_type_str = "RouteQueryReq";
3451             ti_routequeryreq = proto_tree_add_item(message_body_tree, hf_reload_routequeryreq,
3452                                                    tvb, offset, message_body_length, ENC_NA);
3453             routequeryreq_tree = proto_item_add_subtree(ti_routequeryreq, ett_reload_routequeryreq);
3454             proto_tree_add_item(routequeryreq_tree, hf_reload_sendupdate, tvb, offset, 1, ENC_BIG_ENDIAN);
3455             destination_length = dissect_destination(hf_reload_routequeryreq_destination,
3456                                                      tvb, pinfo, routequeryreq_tree, offset + 1, message_body_length - 1 - 2);
3457             dissect_opaque(tvb, pinfo, routequeryreq_tree, hf_reload_overlay_specific, offset + 1 + destination_length, 2, (message_body_length - 1 - destination_length));
3458           }
3459         }
3460         else {
3461           message_type_str = "ChordRouteQueryAns";
3462           /* Answer is entirely Overlay-specific */
3463           if (0 == strcmp(TOPOLOGY_PLUGIN_CHORD_RELOAD, reload_topology_plugin)) {
3464             dissect_chordroutequeryans(tvb, pinfo, message_body_tree, offset, message_body_length);
3465           }
3466         }
3467       }
3468       break;
3469
3470       case METHOD_PROBE:
3471       {
3472         if (IS_REQUEST(message_code)) {
3473           message_type_str = "ProbeReq";
3474           dissect_probereq(tvb, pinfo, message_body_tree, offset, message_body_length);
3475         }
3476         else {
3477           message_type_str = "ProbeAns";
3478           dissect_probeans(tvb, pinfo, message_body_tree, offset, message_body_length);
3479         }
3480       }
3481       break;
3482
3483       case METHOD_ATTACH:
3484       {
3485         message_type_str = "AttachReqAns";
3486         dissect_attachreqans(tvb, pinfo, message_body_tree, offset, message_body_length);
3487       }
3488       break;
3489
3490       case METHOD_APPATTACH:
3491       {
3492         /* Parse AppAttachReq/Ans */
3493         {
3494           guint16 local_offset = 0;
3495           proto_item *ti_appattach;
3496           proto_tree *appattach_tree;
3497           int hf =  hf_reload_appattachans;
3498           message_type_str = "AttachAppAns";
3499           if (IS_REQUEST(message_code)) {
3500             hf =  hf_reload_appattachreq;
3501             message_type_str = "AttachAppReq";
3502           }
3503           ti_appattach = proto_tree_add_item(message_body_tree, hf, tvb, offset+local_offset, message_body_length, ENC_NA);
3504           appattach_tree  = proto_item_add_subtree(ti_appattach, ett_reload_appattach);
3505           local_offset += dissect_opaque_string(tvb, pinfo,appattach_tree, hf_reload_ufrag,offset+local_offset, 1, message_body_length-local_offset);
3506           local_offset += dissect_opaque_string(tvb, pinfo,appattach_tree, hf_reload_password,offset+local_offset, 1, message_body_length-local_offset);
3507           proto_tree_add_item(appattach_tree, hf_reload_application, tvb, offset+local_offset, 2, ENC_BIG_ENDIAN);
3508           local_offset += 2;
3509           local_offset += dissect_opaque_string(tvb, pinfo,appattach_tree, hf_reload_role,offset+local_offset, 1, message_body_length-local_offset);
3510           dissect_icecandidates(tvb, pinfo, appattach_tree, offset+local_offset, message_body_length-local_offset);
3511         }
3512       }
3513       break;
3514
3515       case METHOD_PING:
3516       {
3517         if (IS_REQUEST(message_code)) {
3518           proto_item *ti_local;
3519           proto_tree *local_tree;
3520           message_type_str = "PingReq";
3521           ti_local = proto_tree_add_item(message_body_tree, hf_reload_pingreq, tvb, offset, message_body_length, ENC_NA);
3522           local_tree = proto_item_add_subtree(ti_local, ett_reload_pingreq);
3523
3524           dissect_opaque(tvb, pinfo, local_tree, hf_reload_padding, offset, 2, message_body_length);
3525         }
3526         else {
3527           message_type_str = "PingAns";
3528           if (message_body_length < 16) {
3529             expert_add_info_format(pinfo, ti_message_contents, &ei_reload_truncated_field, "Truncated ping answer");
3530           }
3531           else {
3532             proto_item *ti_local;
3533             proto_tree *local_tree;
3534
3535             ti_local = proto_tree_add_item(message_body_tree, hf_reload_pingans, tvb, offset, message_body_length, ENC_NA);
3536             local_tree = proto_item_add_subtree(ti_local, ett_reload_pingans);
3537             proto_tree_add_item(local_tree, hf_reload_ping_response_id, tvb, offset, 8, ENC_BIG_ENDIAN);
3538             {
3539               guint64 timev;
3540               guint32 remaining_ms;
3541               time_t time_sec;
3542               nstime_t l_nsTime;
3543
3544               timev = tvb_get_ntoh64(tvb, offset+8);
3545               time_sec = (time_t)timev/1000;
3546               remaining_ms = (guint32)(timev % 1000);
3547
3548               l_nsTime.secs = time_sec;
3549               l_nsTime.nsecs =  remaining_ms*1000*1000;
3550
3551               proto_tree_add_time(local_tree, hf_reload_ping_time, tvb, offset + 8, 8, &l_nsTime);
3552             }
3553           }
3554         }
3555       }
3556       break;
3557
3558       case METHOD_CONFIGUPDATE:
3559       {
3560         if (IS_REQUEST(message_code)) {
3561           guint16 local_offset = 0;
3562           proto_item *ti_configupdate;
3563           proto_tree *configupdate_tree;
3564           guint8 configupdate_type;
3565           guint32 configupdate_length;
3566
3567           message_type_str = "ConfigUpdateReq";
3568           ti_configupdate = proto_tree_add_item(message_body_tree, hf_reload_configupdatereq, tvb, offset+local_offset, message_body_length, ENC_NA);
3569           configupdate_tree  = proto_item_add_subtree(ti_configupdate, ett_reload_configupdatereq);
3570           configupdate_type = tvb_get_guint8(tvb, offset + local_offset);
3571           proto_tree_add_uint(configupdate_tree, hf_reload_configupdatereq_type, tvb, offset+local_offset, 1, configupdate_type);
3572           local_offset += 1;
3573           configupdate_length = tvb_get_ntohl(tvb, offset + local_offset);
3574           proto_tree_add_uint(configupdate_tree, hf_reload_length_uint32, tvb,  offset + local_offset, 4, configupdate_length);
3575           if (5 + configupdate_length > message_body_length) {
3576             expert_add_info_format(pinfo, ti_configupdate, &ei_reload_truncated_field, "Truncated ConfigUpdateReq");
3577             break;
3578           }
3579           local_offset += 4;
3580           switch(configupdate_type) {
3581           case CONFIGUPDATETYPE_CONFIG:
3582           {
3583
3584             if (xml_handle == NULL) {
3585               expert_add_info(pinfo, ti_configupdate, &ei_reload_no_xml_dissector);
3586               dissect_opaque_string(tvb, pinfo, configupdate_tree, hf_reload_configupdatereq_configdata, offset+local_offset, 3, configupdate_length);
3587             }
3588             else {
3589               proto_item *ti_config_data;
3590               proto_tree *config_data_tree;
3591               guint32 config_length;
3592               config_length = tvb_get_ntoh24(tvb,offset+local_offset);
3593               ti_config_data = proto_tree_add_item(configupdate_tree, hf_reload_configupdatereq_configdata, tvb, offset+local_offset, configupdate_length, ENC_NA);
3594               config_data_tree = proto_item_add_subtree(ti_config_data, ett_reload_configupdatereq_config_data);
3595               proto_tree_add_item(config_data_tree, hf_reload_length_uint24, tvb, offset+local_offset, 3, ENC_BIG_ENDIAN);
3596               call_dissector_only(xml_handle,
3597                                   tvb_new_subset(tvb, offset+local_offset+3, config_length, length-offset-local_offset-3),
3598                                   pinfo, config_data_tree, NULL);
3599             }
3600           }
3601
3602           break;
3603
3604           case CONFIGUPDATETYPE_KIND:
3605           {
3606             proto_item *ti_kinds;
3607             proto_tree *kinds_tree;
3608             guint32     kinds_length;
3609             guint32     kinds_offset = 0;
3610             int         nKinds       = 0;
3611
3612             ti_kinds     = proto_tree_add_item(configupdate_tree, hf_reload_configupdatereq_kinds,
3613                                                tvb, offset+local_offset, configupdate_length, ENC_NA);
3614             kinds_tree   = proto_item_add_subtree(ti_kinds, ett_reload_configupdatereq_kinds);
3615             kinds_length = get_opaque_length(tvb, offset+local_offset, 3);
3616             proto_item_append_text(ti_kinds, " (KindDescription<%d>)", kinds_length);
3617             local_offset += dissect_length(tvb, kinds_tree, offset+local_offset,  3);
3618             while (kinds_offset < kinds_length) {
3619               guint16 local_increment = tvb_get_ntohs(tvb,offset+local_offset+kinds_offset);
3620               if (xml_handle == NULL) {
3621                 expert_add_info(pinfo, ti_configupdate, &ei_reload_no_xml_dissector);
3622                 dissect_opaque_string(tvb, pinfo, configupdate_tree, hf_reload_kinddescription,
3623                                       offset+local_offset+kinds_offset, 2, configupdate_length);
3624               }
3625               else {
3626                 proto_item *ti_kinddescription;
3627                 proto_tree *kinddescription_tree;
3628                 ti_kinddescription = proto_tree_add_item(kinds_tree, hf_reload_kinddescription,
3629                                                          tvb, offset+local_offset+kinds_offset, 2+local_increment, ENC_NA);
3630                 kinddescription_tree = proto_item_add_subtree(ti_kinddescription, ett_reload_kinddescription);
3631                 proto_tree_add_item(kinddescription_tree, hf_reload_length_uint16,
3632                                     tvb, offset+local_offset+kinds_offset, 2, ENC_BIG_ENDIAN);
3633                 call_dissector(xml_handle,
3634                                tvb_new_subset(tvb, offset+local_offset+kinds_offset+2,
3635                                               local_increment,
3636                                               length-(offset+local_offset+kinds_offset+2)),
3637                                pinfo, kinddescription_tree);
3638               }
3639               local_increment += 2;
3640               if (local_increment <= 0) break;
3641               kinds_offset    += local_increment;
3642               nKinds++;
3643             }
3644             proto_item_append_text(ti_kinds, ": %d elements", nKinds);
3645           }
3646           break;
3647           }
3648
3649         }
3650         else {
3651           message_type_str = "ConfigUpdateAns";
3652         }
3653         break;
3654       }
3655
3656       case METHOD_STORE:
3657       {
3658         if (IS_REQUEST(message_code)) {
3659           message_type_str = "StoreReq";
3660           dissect_storereq(tvb, pinfo, message_body_tree, offset, message_body_length);
3661         }
3662         else {
3663           message_type_str = "StoreAns";
3664           dissect_storeans(tvb, pinfo, message_body_tree, offset, message_body_length);
3665         }
3666       }
3667       break;
3668
3669       case METHOD_FETCH:
3670       {
3671         if (IS_REQUEST(message_code)) {
3672           message_type_str = "FetchReq";
3673           dissect_fetchreq(tvb, pinfo, message_body_tree, offset, message_body_length, FALSE);
3674         }
3675         else {
3676           /* response */
3677           message_type_str = "FetchAns";
3678           dissect_fetchans(tvb, pinfo, message_body_tree, offset, message_body_length);
3679         }
3680       }
3681       break;
3682
3683       case METHOD_STAT:
3684       {
3685         if (IS_REQUEST(message_code)) {
3686           message_type_str = "StatReq";
3687           dissect_fetchreq(tvb, pinfo, message_body_tree, offset, message_body_length, TRUE);
3688         }
3689         else {
3690           message_type_str = "StatAns";
3691           dissect_statans(tvb, pinfo, message_body_tree, offset, message_body_length);
3692         }
3693       }
3694       break;
3695
3696       case METHOD_FIND:
3697       {
3698         if (IS_REQUEST(message_code)) {
3699           message_type_str = "FindReq";
3700           dissect_findreq(tvb,pinfo, message_body_tree,offset,message_body_length);
3701         }
3702         else {
3703           message_type_str = "FindAns";
3704           dissect_findans(tvb, pinfo, message_body_tree, offset, message_body_length);
3705         }
3706       }
3707       break;
3708
3709       case METHOD_LEAVE:
3710       {
3711         if (IS_REQUEST(message_code)) {
3712           message_type_str = "LeaveReq";
3713           dissect_leavereq(tvb,pinfo, message_body_tree,offset,message_body_length);
3714         }
3715         else {
3716           message_type_str = "LeaveAns";
3717           dissect_opaque(tvb, pinfo, message_body_tree, hf_reload_overlay_specific, offset, 2, message_body_length);
3718         }
3719       }
3720       break;
3721
3722       case METHOD_JOIN:
3723       {
3724         if (IS_REQUEST(message_code)) {
3725           message_type_str = "JoinReq";
3726           dissect_joinreq(tvb, pinfo, message_body_tree, offset, message_body_length);
3727         }
3728         else {
3729           message_type_str = "JoinAns";
3730           dissect_joinans(tvb, pinfo, message_body_tree, offset, message_body_length);
3731         }
3732       }
3733       break;
3734
3735       case METHOD_UPDATE:
3736         if (0 == strcmp(TOPOLOGY_PLUGIN_CHORD_RELOAD, reload_topology_plugin)) {
3737           if (IS_REQUEST(message_code)) {
3738             message_type_str = "ChordUpdate";
3739             dissect_chordupdate(tvb, pinfo, message_body_tree, offset, message_body_length);
3740           }
3741         }
3742         break;
3743
3744       case METHOD_PATH_TRACK:
3745         if (IS_REQUEST(message_code)) {
3746           message_type_str = "PathTrackReck";
3747           dissect_pathtrackreq(tvb, pinfo, message_body_tree, offset, message_body_length);
3748         }
3749         else {
3750           message_type_str = "PathTrackAns";
3751           dissect_pathtrackans(tvb, pinfo, message_body_tree, offset, message_body_length);
3752         }
3753         break;
3754
3755       default:
3756         break;
3757       }
3758     }
3759     if (message_type_str!= NULL) {
3760       proto_item_append_text(ti_message_body, " (%s<%d>)", message_type_str, message_body_length);
3761     }
3762     else {
3763       proto_item_append_text(ti_message_body,
3764                              " (%s%s<%d>)",
3765                              val_to_str_const(MSGCODE_TO_METHOD(message_code),methods,"opaque"),
3766                              val_to_str_const(MSGCODE_TO_CLASS(message_code), classes_Short, ""),
3767                              message_body_length);
3768
3769     }
3770   }
3771   else {
3772     /* Error Response */
3773     guint16 error_length, error_code;
3774     proto_item *ti_message_body;
3775     proto_tree *message_body_tree;
3776     proto_item *ti_error;
3777     proto_tree *error_tree;
3778
3779     /* message_code was already parsed */
3780     proto_tree_add_uint_format_value(message_contents_tree, hf_reload_message_code,
3781                                      tvb, offset, 2, message_code, "Error");
3782     offset += 2;
3783
3784     /* Message body */
3785     ti_message_body = proto_tree_add_item(message_contents_tree, hf_reload_message_body,
3786                                           tvb, offset, 4 + message_body_length, ENC_NA);
3787     message_body_tree = proto_item_add_subtree(ti_message_body, ett_reload_message_body);
3788     error_length = tvb_get_ntohs(tvb, offset);
3789     proto_tree_add_uint(message_body_tree, hf_reload_length_uint32, tvb, offset, 4, message_body_length);
3790     offset += 4;
3791
3792     error_code = tvb_get_ntohs(tvb, offset);
3793     if (2 + 2 + error_length >length) {
3794       expert_add_info_format(pinfo, ti_message_body, &ei_reload_truncated_field, "Truncated error message");
3795       return length;
3796     }
3797
3798     ti_error = proto_tree_add_item(message_body_tree, hf_reload_error_response,
3799                                    tvb, offset, 2 + 2 + error_length, ENC_NA);
3800     error_tree = proto_item_add_subtree(ti_error, ett_reload_error_response);
3801     proto_tree_add_item(error_tree, hf_reload_error_response_code, tvb, offset, 2, ENC_BIG_ENDIAN);
3802     proto_item_append_text(ti_error, ": %s", val_to_str_const(error_code, errorcodes, "Unknown"));
3803     switch(error_code) {
3804     case ERRORCODE_GENERATIONCOUNTERTOOLOW:
3805     {
3806       guint16 local_length = tvb_get_ntohs(tvb, offset+2);
3807       proto_tree_add_item(error_tree, hf_reload_length_uint16, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3808       dissect_storeans(tvb, pinfo, error_tree, offset+4, local_length);
3809     }
3810     break;
3811
3812     case ERRORCODE_UNKNOWNKIND:
3813     {
3814       guint16 local_length = tvb_get_ntohs(tvb, offset+2);
3815       proto_tree_add_item(error_tree, hf_reload_length_uint16, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3816       dissect_kindid_list(tvb, pinfo, error_tree, offset+4, local_length,1);
3817     }
3818     break;
3819
3820     case ERRORCODE_UNDERLAY_DESTINATION_UNREACHABLE:
3821     {
3822       proto_tree_add_item(error_tree, hf_reload_opaque_string, tvb, offset+2, 32, ENC_ASCII|ENC_NA);
3823     }
3824     break;
3825
3826     default:
3827       dissect_opaque_string(tvb, pinfo, error_tree, hf_reload_error_response_info, offset+2, 2, -1);
3828       if (error_code <= 19) {
3829         guint16 info_length = tvb_get_ntohs(tvb,offset+2);
3830         if (info_length>0) {
3831           proto_item_append_text(ti_error, " (%s)", tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, info_length, ENC_ASCII));
3832         }
3833       }
3834       break;
3835     }
3836   }
3837   offset += message_body_length;
3838
3839   {
3840     proto_tree *extensions_tree;
3841     proto_item *ti_extensions;
3842     proto_tree *extension_tree;
3843     gint32 extension_offset = 0;
3844     int nExtensions = 0;
3845
3846     ti_extensions =
3847       proto_tree_add_item(message_contents_tree, hf_reload_message_extensions, tvb, offset, 4+extensions_length, ENC_NA);
3848     extensions_tree = proto_item_add_subtree(ti_extensions, ett_reload_message_extensions);
3849     proto_tree_add_item(extensions_tree, hf_reload_length_uint32, tvb, offset, 4, ENC_BIG_ENDIAN);
3850     offset += 4;
3851     while (extension_offset >= 0 && (guint32)extension_offset < extensions_length) {
3852       guint16 type;
3853       proto_item *ti_extension;
3854       guint32 extension_content_length = tvb_get_ntohl(tvb, offset + extension_offset + 3);
3855       if ((extension_offset + 3 + 4 + extension_content_length) > extensions_length) {
3856         expert_add_info_format(pinfo, ti_extensions, &ei_reload_truncated_field, "Truncated message extensions");
3857         break;
3858       }
3859       ti_extension = proto_tree_add_item(extensions_tree, hf_reload_message_extension, tvb, offset+ extension_offset, 3 + 4 + extension_content_length, ENC_NA);
3860       extension_tree = proto_item_add_subtree(ti_extension, ett_reload_message_extension);
3861       type = tvb_get_ntohs(tvb, offset+ extension_offset);
3862       proto_tree_add_item(extension_tree, hf_reload_message_extension_type, tvb, offset+ extension_offset, 2, ENC_BIG_ENDIAN);
3863       proto_tree_add_item(extension_tree, hf_reload_message_extension_critical, tvb, offset+ extension_offset + 2, 1, ENC_BIG_ENDIAN);
3864       switch(type) {
3865
3866       case MESSAGEEXTENSIONTYPE_SELF_TUNING_DATA:
3867       {
3868         guint32 extension_length;
3869         proto_tree_add_item(extension_tree, hf_reload_length_uint32, tvb, offset+extension_offset+3, 4, ENC_BIG_ENDIAN);
3870         extension_length = tvb_get_ntohl(tvb, offset+extension_offset+3);
3871         if (extension_length > 0) {
3872           dissect_selftuningdata(tvb, extension_tree, offset+extension_offset+3+4);
3873         }
3874       }
3875       break;
3876
3877       case MESSAGEEXTENSIONTYPE_DIAGNOSTIC_PING:
3878       {
3879         guint32 extension_length;
3880         proto_tree_add_item(extension_tree, hf_reload_length_uint32, tvb, offset+extension_offset+3, 4, ENC_BIG_ENDIAN);
3881         extension_length = tvb_get_ntohl(tvb, offset+extension_offset+3);
3882         if ((extension_length > 0) && (MSGCODE_TO_METHOD(message_code) == METHOD_PING)) {
3883           if (IS_REQUEST(message_code)) {
3884             dissect_diagnosticrequest(-1, tvb, pinfo, extension_tree, offset+extension_offset+3+4, extension_length);
3885           }
3886           else {
3887             dissect_diagnosticresponse(-1, tvb, pinfo, extension_tree, offset+extension_offset+3+4, extension_length);
3888           }
3889         }
3890       }
3891       break;
3892
3893       default:
3894         dissect_opaque(tvb, pinfo, extension_tree, hf_reload_message_extension_content, offset + extension_offset + 3, 4, -1);
3895         break;
3896       }
3897       extension_offset += 3 + 4 + extension_content_length;
3898       nExtensions ++;
3899     }
3900     proto_item_append_text(ti_extensions, " (%d elements)", nExtensions);
3901   }
3902
3903   return ( 2 + 4 + message_body_length + 4 + extensions_length);
3904 }
3905
3906 static int
3907 dissect_reload_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3908 {
3909   proto_item           *ti;
3910   proto_tree           *reload_tree;
3911   guint32               relo_token;
3912   guint                 effective_length;
3913   guint                 msg_length, dgram_msg_length;
3914   guint16               offset;
3915   conversation_t       *conversation;
3916   reload_conv_info_t   *reload_info;
3917   reload_transaction_t *reload_trans;
3918   wmem_tree_key_t       transaction_id_key[2];
3919   guint32               transaction_id[2];
3920   guint16               options_length;
3921   guint16               via_list_length;
3922   guint16               destination_list_length;
3923   guint16               message_code;
3924   guint16               error_code      = 0;
3925   guint32               forwarding_length;
3926   proto_tree           *reload_forwarding_tree;
3927   const char           *msg_class_str;
3928   const char           *msg_method_str  = NULL;
3929   gboolean              fragmented      = FALSE;
3930   gboolean              last_fragment   = FALSE;
3931   fragment_head        *reload_fd_head  = NULL;
3932   guint32               fragment        = 0;
3933   gboolean              save_fragmented = FALSE;
3934   gboolean              update_col_info = TRUE;
3935
3936   offset = 0;
3937   effective_length = tvb_captured_length(tvb);
3938
3939   /* First, make sure we have enough data to do the check. */
3940   if (effective_length < MIN_HDR_LENGTH)
3941     return 0;
3942
3943   /*
3944    * First check if the frame is really meant for us.
3945    */
3946   relo_token = tvb_get_ntohl(tvb,0);
3947
3948   if (relo_token != RELOAD_TOKEN) {
3949     return 0;
3950   }
3951
3952   msg_length = get_reload_message_length(pinfo, tvb, offset);
3953   dgram_msg_length = msg_length;
3954
3955   /* The message seems to be a valid reLOAD message! */
3956
3957   col_set_str(pinfo->cinfo, COL_PROTOCOL, "RELOAD");
3958   col_clear(pinfo->cinfo, COL_INFO);
3959
3960   /* Create the transaction key which may be used to track the conversation */
3961   transaction_id[0] = tvb_get_ntohl(tvb, 20);
3962   transaction_id[1] = tvb_get_ntohl(tvb, 24);
3963
3964   transaction_id_key[0].length = 2;
3965   transaction_id_key[0].key =  transaction_id;
3966   transaction_id_key[1].length = 0;
3967   transaction_id_key[1].key = NULL;
3968
3969   via_list_length = tvb_get_ntohs(tvb, 32);
3970   destination_list_length = tvb_get_ntohs(tvb, 34);
3971   options_length = tvb_get_ntohs(tvb, 36);
3972
3973   forwarding_length = MIN_HDR_LENGTH + (via_list_length + destination_list_length + options_length);
3974
3975
3976   /* Do we already have a conversation ? */
3977   conversation = find_or_create_conversation(pinfo);
3978
3979   /*
3980    * Do we already have a state structure for this conv
3981    */
3982   reload_info = (reload_conv_info_t *)conversation_get_proto_data(conversation, proto_reload);
3983   if (!reload_info) {
3984     /* No.  Attach that information to the conversation, and add
3985      * it to the list of information structures.
3986      */
3987     reload_info = wmem_new(wmem_file_scope(), reload_conv_info_t);
3988     reload_info->transaction_pdus = wmem_tree_new(wmem_file_scope());
3989     conversation_add_proto_data(conversation, proto_reload, reload_info);
3990   }
3991
3992   ti = proto_tree_add_item(tree, proto_reload, tvb, 0, -1, ENC_NA);
3993
3994   reload_tree = proto_item_add_subtree(ti, ett_reload);
3995
3996   /*
3997    * Message dissection
3998    */
3999
4000   /*
4001    * Forwarding Header
4002    */
4003   ti = proto_tree_add_item(reload_tree, hf_reload_forwarding, tvb, 0, forwarding_length, ENC_NA);
4004   reload_forwarding_tree = proto_item_add_subtree(ti, ett_reload_forwarding);
4005
4006   proto_tree_add_uint(reload_forwarding_tree, hf_reload_token, tvb, 0, 4, relo_token);
4007   proto_tree_add_item(reload_forwarding_tree, hf_reload_overlay, tvb, 4, 4, ENC_BIG_ENDIAN);
4008   {
4009     proto_item *ti_tmp;
4010     guint16     tmp;
4011     tmp = tvb_get_ntohs(tvb,8);
4012     ti_tmp = proto_tree_add_item(reload_forwarding_tree, hf_reload_configuration_sequence, tvb, 8, 2, ENC_BIG_ENDIAN);
4013     if (tmp == 0) {
4014       proto_item_append_text(ti_tmp, "\n  [sequence value not verified]");
4015     }
4016   }
4017   proto_tree_add_item(reload_forwarding_tree, hf_reload_version, tvb, 10, 1, ENC_BIG_ENDIAN);
4018
4019   proto_tree_add_item(reload_forwarding_tree, hf_reload_ttl, tvb, 11, 1, ENC_BIG_ENDIAN);
4020   {
4021     proto_item *ti_fragment;
4022     proto_tree *fragment_tree;
4023     guint32     bit_offset;
4024
4025     fragment = tvb_get_ntohl(tvb,12);
4026
4027     ti_fragment = proto_tree_add_uint(reload_forwarding_tree, hf_reload_fragment_flag, tvb, 12, 4, fragment);
4028     fragment_tree = proto_item_add_subtree(ti_fragment, ett_reload_fragment_flag);
4029     bit_offset = (12) * 8;
4030
4031     if (fragment & 0x80000000) {
4032       proto_item_append_text(ti_fragment, " (Fragment)");
4033       fragmented = TRUE;
4034     }
4035     if (fragment & 0x40000000) {
4036       proto_item_append_text(ti_fragment, " (Last)");
4037       last_fragment = TRUE;
4038     }
4039     proto_tree_add_bits_item(fragment_tree, hf_reload_fragment_fragmented, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
4040     proto_tree_add_bits_item(fragment_tree, hf_reload_fragment_last_fragment, tvb, bit_offset+1, 1, ENC_BIG_ENDIAN);
4041     proto_tree_add_bits_item(fragment_tree, hf_reload_fragment_reserved, tvb, bit_offset+2, 6, ENC_BIG_ENDIAN);
4042     fragment = fragment & 0x00ffffff;
4043     proto_tree_add_uint(fragment_tree, hf_reload_fragment_offset, tvb, 13, 3, fragment);
4044   }
4045
4046   /* msg_length is already parsed */
4047   proto_tree_add_uint(reload_forwarding_tree, hf_reload_length_uint32, tvb, 16, 4, msg_length);
4048   proto_tree_add_item(reload_forwarding_tree, hf_reload_trans_id, tvb, 20, 8, ENC_BIG_ENDIAN);
4049   {
4050     proto_item *ti_tmp;
4051     guint32 tmp;
4052     tmp = tvb_get_ntohl(tvb,28);
4053     ti_tmp = proto_tree_add_item(reload_forwarding_tree, hf_reload_max_response_length, tvb, 28, 4, ENC_BIG_ENDIAN);
4054     if (0 == tmp) {
4055       proto_item_append_text(ti_tmp, "\n  [Response length not restricted]");
4056     }
4057   }
4058   /* variable lengths fields lengths are already parsed */
4059   proto_tree_add_uint(reload_forwarding_tree, hf_reload_via_list_length, tvb, 32, 2, via_list_length);
4060   proto_tree_add_uint(reload_forwarding_tree, hf_reload_destination_list_length, tvb, 34, 2, destination_list_length);
4061   proto_tree_add_uint(reload_forwarding_tree, hf_reload_options_length, tvb, 36, 2, options_length);
4062
4063   offset += MIN_HDR_LENGTH;
4064
4065   if (((guint)offset + via_list_length) > msg_length) {
4066     expert_add_info(pinfo, ti, &ei_reload_truncated_packet);
4067     return MIN_HDR_LENGTH;
4068   }
4069
4070   if (via_list_length > 0) {
4071     proto_item *ti_vialist;
4072     proto_tree *vialist_tree;
4073     int         numDestinations = 0;
4074     ti_vialist = proto_tree_add_item(reload_forwarding_tree, hf_reload_via_list, tvb, offset, via_list_length, ENC_NA);
4075     vialist_tree = proto_item_add_subtree(ti_vialist, ett_reload_via_list);
4076
4077     dissect_destination_list(tvb, pinfo, vialist_tree, offset, via_list_length, &numDestinations);
4078     proto_item_append_text(ti_vialist, " (Destination<%d>): %d elements",via_list_length,numDestinations);
4079   }
4080   offset += via_list_length;
4081
4082   if (((guint)offset + destination_list_length) > msg_length) {
4083     expert_add_info(pinfo, ti, &ei_reload_truncated_packet);
4084     return offset;
4085   }
4086
4087   if (destination_list_length > 0) {
4088     proto_item *ti_destination_list;
4089     proto_tree *destination_list_tree;
4090     int numDestinations;
4091     ti_destination_list = proto_tree_add_item(reload_forwarding_tree, hf_reload_destination_list,
4092                                               tvb, offset, destination_list_length, ENC_NA);
4093     destination_list_tree = proto_item_add_subtree(ti_destination_list, ett_reload_destination_list);
4094
4095     dissect_destination_list(tvb, pinfo, destination_list_tree, offset, destination_list_length, &numDestinations);
4096     proto_item_append_text(ti_destination_list, " (Destination<%d>): %d elements",
4097                            destination_list_length,numDestinations);
4098   }
4099   offset += destination_list_length;
4100
4101   if (((guint)offset + options_length) > msg_length) {
4102     expert_add_info(pinfo, ti, &ei_reload_truncated_packet);
4103     return offset;
4104   }
4105
4106   if (options_length > 0) {
4107     gint32      local_offset = 0;
4108     proto_item *ti_options;
4109     proto_tree *options_tree;
4110     int         nOptions     = 0;
4111
4112     ti_options = proto_tree_add_item(reload_forwarding_tree, hf_reload_forwarding_options, tvb, offset+local_offset, options_length, ENC_NA);
4113     options_tree = proto_item_add_subtree(ti_options, ett_reload_forwarding_options);
4114     while (local_offset >=0 && local_offset < options_length) {
4115       int local_increment;
4116       local_increment = dissect_forwardingoption(tvb, pinfo, options_tree, offset+local_offset, options_length-local_offset);
4117       if (0 >= local_increment) break;
4118       local_offset += local_increment;
4119       nOptions++;
4120     }
4121     proto_item_append_text(ti_options, " (ForwardingOption<%d>): %d elements",options_length,nOptions);
4122   }
4123   offset += options_length;
4124
4125   if ((reload_defragment) && ((fragmented != FALSE) && !((fragment == 0) && (last_fragment)))) {
4126     tvbuff_t   *next_tvb = NULL;
4127     reload_fd_head = NULL;
4128
4129     if (tvb_bytes_exist(tvb, offset, msg_length - offset)) {
4130       reload_fd_head = fragment_add_check(&reload_reassembly_table, tvb, offset,
4131                          pinfo,
4132                          transaction_id[0]^transaction_id[1],
4133                          NULL,
4134                          fragment,
4135                          msg_length - offset,
4136                          !last_fragment);
4137
4138       next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled RELOAD",
4139                                           reload_fd_head, &reload_frag_items, &update_col_info, reload_tree);
4140     }
4141     if (next_tvb == NULL) {
4142       /* Just show this as a fragment. */
4143       col_add_fstr(pinfo->cinfo, COL_INFO, "Fragmented RELOAD protocol (trans id=%x%x off=%u",
4144                    transaction_id[0],transaction_id[1], fragment);
4145       if (reload_fd_head && reload_fd_head->reassembled_in != pinfo->fd->num) {
4146         col_append_fstr(pinfo->cinfo, COL_INFO, " [Reassembled in #%u]",
4147                         reload_fd_head->reassembled_in);
4148       }
4149       save_fragmented = pinfo->fragmented;
4150       pinfo->fragmented = TRUE;
4151       call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
4152       pinfo->fragmented = save_fragmented;
4153       return effective_length;
4154     }
4155     tvb = next_tvb;
4156     msg_length -= offset; /* need to adjust the length, as the new tvb starts after the forwarding header */
4157     offset = 0;
4158   }
4159
4160   effective_length = tvb_captured_length(tvb);
4161   if (effective_length < msg_length) {
4162     /* The effective length is too small for the packet */
4163     expert_add_info(pinfo, NULL, &ei_reload_truncated_packet);
4164     return 0;
4165   }
4166
4167   /*Handle retransmission after reassembly since we use message_contents for it */
4168
4169   message_code = tvb_get_ntohs(tvb, offset);
4170
4171   if (!pinfo->fd->flags.visited) {
4172
4173     if ((reload_trans = (reload_transaction_t *)
4174            wmem_tree_lookup32_array(reload_info->transaction_pdus, transaction_id_key)) == NULL) {
4175       reload_trans = wmem_new(wmem_file_scope(), reload_transaction_t);
4176       reload_trans->req_frame = 0;
4177       reload_trans->rep_frame = 0;
4178       reload_trans->req_time = pinfo->fd->abs_ts;
4179       wmem_tree_insert32_array(reload_info->transaction_pdus, transaction_id_key, (void *)reload_trans);
4180     }
4181
4182     /* check whether the message is a request or a response */
4183
4184     if (IS_REQUEST(message_code) && (message_code != RELOAD_ERROR)) {
4185       /* This is a request */
4186       if (reload_trans->req_frame == 0) {
4187         reload_trans->req_frame = pinfo->fd->num;
4188       }
4189     }
4190     else {
4191       /* This is a catch-all for all non-request messages */
4192       if (reload_trans->rep_frame == 0) {
4193         reload_trans->rep_frame = pinfo->fd->num;
4194       }
4195     }
4196   }
4197   else {
4198     reload_trans = (reload_transaction_t *)wmem_tree_lookup32_array(reload_info->transaction_pdus, transaction_id_key);
4199   }
4200
4201   if (!reload_trans) {
4202     /* create a "fake" pana_trans structure */
4203     reload_trans = wmem_new(wmem_packet_scope(), reload_transaction_t);
4204     reload_trans->req_frame = 0;
4205     reload_trans->rep_frame = 0;
4206     reload_trans->req_time = pinfo->fd->abs_ts;
4207   }
4208
4209   /* Retransmission control */
4210   if (IS_REQUEST(message_code) && (message_code != RELOAD_ERROR)) {
4211     if (reload_trans->req_frame != pinfo->fd->num) {
4212       proto_item *it;
4213       it = proto_tree_add_uint(reload_tree, hf_reload_duplicate, tvb, 0, 0, reload_trans->req_frame);
4214       PROTO_ITEM_SET_GENERATED(it);
4215     }
4216     if (reload_trans->rep_frame) {
4217       proto_item *it;
4218       it = proto_tree_add_uint(reload_tree, hf_reload_response_in, tvb, 0, 0, reload_trans->rep_frame);
4219       PROTO_ITEM_SET_GENERATED(it);
4220     }
4221   }
4222   else {
4223     /* This is a response */
4224     if (reload_trans->rep_frame != pinfo->fd->num) {
4225       proto_item *it;
4226       it = proto_tree_add_uint(reload_tree, hf_reload_duplicate, tvb, 0, 0, reload_trans->rep_frame);
4227       PROTO_ITEM_SET_GENERATED(it);
4228     }
4229
4230     if (reload_trans->req_frame) {
4231       proto_item *it;
4232       nstime_t ns;
4233
4234       it = proto_tree_add_uint(reload_tree, hf_reload_response_to, tvb, 0, 0, reload_trans->req_frame);
4235       PROTO_ITEM_SET_GENERATED(it);
4236
4237       nstime_delta(&ns, &pinfo->fd->abs_ts, &reload_trans->req_time);
4238       it = proto_tree_add_time(reload_tree, hf_reload_time, tvb, 0, 0, &ns);
4239       PROTO_ITEM_SET_GENERATED(it);
4240     }
4241   }
4242
4243   if (message_code == RELOAD_ERROR) {
4244     error_code = tvb_get_ntohs(tvb, forwarding_length + 2+4);
4245     msg_class_str = "Error Response";
4246     col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s", msg_class_str, val_to_str_const(error_code, errorcodes, "Unknown"));
4247     proto_item_append_text(ti, ": %s %s", msg_class_str, val_to_str_const(error_code, errorcodes, "Unknown"));
4248   }
4249   else {
4250     msg_class_str = val_to_str(MSGCODE_TO_CLASS(message_code), classes, "Unknown %d");
4251     msg_method_str = val_to_str(MSGCODE_TO_METHOD(message_code), methods, "Unknown %d");
4252
4253     col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
4254                  msg_method_str, msg_class_str);
4255     proto_item_append_text(ti, ": %s %s", msg_method_str, msg_class_str);
4256   }
4257
4258
4259   offset += dissect_reload_messagecontents(tvb, pinfo, reload_tree, offset, (effective_length - offset));
4260
4261   /* Security Block */
4262   {
4263     proto_item *ti_security_block;
4264     proto_tree *security_block_tree;
4265     proto_item *ti_certificates;
4266     proto_tree *certificates_tree;
4267     guint16 certificates_length;
4268     guint16 signeridentityvalue_length;
4269     guint16 signaturevalue_length;
4270     guint16 security_block_offset = 0;
4271
4272     certificates_length = tvb_get_ntohs(tvb, offset);
4273     security_block_offset += 2 + certificates_length;
4274     security_block_offset += 2; /* SignatureAndHashAlgorithm     algorithm; */
4275     security_block_offset += 1; /* SignerIdentityType     identity_type; */
4276     signeridentityvalue_length = tvb_get_ntohs(tvb, offset +security_block_offset);
4277     security_block_offset += 2;
4278     security_block_offset += signeridentityvalue_length;
4279     signaturevalue_length = tvb_get_ntohs(tvb, offset +security_block_offset);
4280     security_block_offset += 2;
4281     security_block_offset += signaturevalue_length;
4282
4283     ti_security_block = proto_tree_add_item(reload_tree, hf_reload_security_block, tvb, offset,
4284                                             security_block_offset, ENC_NA);
4285     security_block_tree = proto_item_add_subtree(ti_security_block, ett_reload_security_block);
4286     /* start parsing from the beginning */
4287     security_block_offset = 0;
4288     ti_certificates = proto_tree_add_item(security_block_tree,
4289                                           hf_reload_certificates, tvb, offset,
4290                                           2 + certificates_length,
4291                                           ENC_NA);
4292     proto_item_append_text(ti_certificates, " (GenericCertificate<%d>)", certificates_length);
4293     certificates_tree = proto_item_add_subtree(ti_certificates, ett_reload_certificates);
4294     proto_tree_add_uint(certificates_tree, hf_reload_length_uint16, tvb, offset, 2, certificates_length);
4295     security_block_offset += 2;
4296     /* certificates */
4297
4298     {
4299       gint32 certificate_offset = 0;
4300       int nCertificates = 0;
4301       while (certificate_offset >= 0 && certificate_offset < certificates_length) {
4302         proto_item *ti_genericcertificate;
4303         proto_tree *genericcertificate_tree;
4304         guint16 certificate_length;
4305
4306         certificate_length = tvb_get_ntohs(tvb, offset + security_block_offset + certificate_offset + 1);
4307         if (certificate_offset + 1 + 2 + certificate_length > certificates_length) {
4308           expert_add_info_format(pinfo, ti_security_block, &ei_reload_truncated_field, "Truncated certificate");
4309           break;
4310         }
4311         ti_genericcertificate =
4312           proto_tree_add_item(certificates_tree,
4313                               hf_reload_genericcertificate, tvb, offset + security_block_offset + certificate_offset,
4314                               1 + 2 + certificate_length,
4315                               ENC_NA);
4316         genericcertificate_tree = proto_item_add_subtree(ti_genericcertificate, ett_reload_genericcertificate);
4317
4318         proto_tree_add_item(genericcertificate_tree, hf_reload_certificate_type, tvb,
4319                             offset + security_block_offset + certificate_offset, 1, ENC_BIG_ENDIAN);
4320
4321         proto_tree_add_item(genericcertificate_tree, hf_reload_length_uint16, tvb,
4322                             offset + security_block_offset + certificate_offset+1, 2, ENC_BIG_ENDIAN);
4323
4324         switch (tvb_get_guint8(tvb, offset + security_block_offset + certificate_offset)) {
4325         case 0: {
4326           asn1_ctx_t asn1_ctx;
4327
4328           asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
4329           dissect_x509af_Certificate(FALSE, tvb, offset + security_block_offset + certificate_offset + 1 + 2, &asn1_ctx,
4330                                      genericcertificate_tree, hf_reload_certificate);
4331         }
4332         break;
4333
4334         default:
4335           dissect_opaque(tvb, pinfo, genericcertificate_tree, hf_reload_certificate, offset + security_block_offset + certificate_offset + 1, 2, -1);
4336         }
4337         certificate_offset += 1 + 2 + certificate_length;
4338         nCertificates++;
4339       }
4340       proto_item_append_text(ti_certificates, ": %d elements", nCertificates);
4341     }
4342
4343     security_block_offset += certificates_length;
4344
4345     dissect_signature(tvb, pinfo, security_block_tree, offset + security_block_offset);
4346     /* Signature */
4347   }
4348
4349
4350   return dgram_msg_length;
4351 }
4352
4353 static void
4354 dissect_reload_message_no_return(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4355 {
4356   dissect_reload_message(tvb, pinfo, tree);
4357 }
4358
4359 static gboolean
4360 dissect_reload_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4361 {
4362   if (dissect_reload_message(tvb, pinfo, tree) == 0) {
4363     /*
4364      * It wasn't a valid RELOAD message, and wasn't
4365      * dissected as such.
4366      */
4367     return FALSE;
4368   }
4369   return TRUE;
4370 }
4371
4372 void
4373 proto_register_reload(void)
4374 {
4375   module_t *reload_module;
4376   expert_module_t* expert_reload;
4377   static hf_register_info hf[] = {
4378     { &hf_reload_response_in,
4379       { "Response in",  "reload.response-in", FT_FRAMENUM,
4380         BASE_NONE, NULL, 0x0, "The response to this RELOAD Request is in this frame", HFILL
4381       }
4382     },
4383     { &hf_reload_response_to,
4384       { "Request in", "reload.response-to", FT_FRAMENUM,
4385         BASE_NONE, NULL, 0x0, "This is a response to the RELOAD Request in this frame", HFILL
4386       }
4387     },
4388     { &hf_reload_time,
4389       { "Time", "reload.time", FT_RELATIVE_TIME,
4390         BASE_NONE, NULL, 0x0, "The time between the Request and the Response", HFILL
4391       }
4392     },
4393     { &hf_reload_duplicate,
4394       { "Duplicated original message in", "reload.duplicate", FT_FRAMENUM,
4395         BASE_NONE, NULL, 0x0, "This is a duplicate of RELOAD message in this frame", HFILL
4396       }
4397     },
4398     { &hf_reload_forwarding,
4399       { "ForwardingHeader",    "reload.forwarding",  FT_NONE,
4400         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4401       }
4402     },
4403     { &hf_reload_token,
4404       { "relo_token (uint32)", "reload.forwarding.token",  FT_UINT32,
4405         BASE_HEX, NULL, 0x0,  NULL, HFILL
4406       }
4407     },
4408     { &hf_reload_overlay,
4409       { "overlay (uint32)",  "reload.forwarding.overlay",  FT_UINT32,
4410         BASE_HEX, NULL, 0x0,  NULL, HFILL
4411       }
4412     },
4413     { &hf_reload_configuration_sequence,
4414       { "configuration_sequence (uint16)", "reload.forwarding.configuration_sequence", FT_UINT16,
4415         BASE_DEC, NULL, 0x0,  NULL, HFILL
4416       }
4417     },
4418     { &hf_reload_version,
4419       { "version (uint8)",  "reload.forwarding.version",  FT_UINT8,
4420         BASE_HEX, VALS(versions), 0x0,  NULL, HFILL
4421       }
4422     },
4423     { &hf_reload_ttl,
4424       { "ttl (uint8)",  "reload.forwarding.ttl",  FT_UINT8,
4425         BASE_DEC, NULL, 0x0,  NULL, HFILL
4426       }
4427     },
4428     { &hf_reload_fragment_flag,
4429       { "fragment (uint32)", "reload.forwarding.fragment", FT_UINT32,
4430         BASE_HEX, NULL, 0x0,  NULL, HFILL
4431       }
4432     },
4433     { &hf_reload_fragment_fragmented,
4434       { "Fragmented (always set)", "reload.forwarding.fragment.fragmented", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
4435         NULL, HFILL
4436       }
4437     },
4438     { &hf_reload_fragment_last_fragment,
4439       { "Last Fragment", "reload.forwarding.fragment.last", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
4440         NULL, HFILL
4441       }
4442     },
4443     { &hf_reload_fragment_reserved,
4444       { "Reserved (always 0)", "reload.forwarding.fragment.reserved", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4445         NULL, HFILL
4446       }
4447     },
4448     { &hf_reload_fragment_offset,
4449       { "Fragment Offset","reload.forwarding.fragment.offset",  FT_UINT32,
4450         BASE_DEC, NULL, 0x0,  NULL, HFILL
4451       }
4452     },
4453     { &hf_reload_trans_id,
4454       { "transaction_id (uint32)", "reload.forwarding.trans_id", FT_UINT64,
4455         BASE_HEX, NULL, 0x0,  NULL, HFILL
4456       }
4457     },
4458     { &hf_reload_max_response_length,
4459       { "max_response_length (uint32)",  "reload.forwarding.max_response_length",  FT_UINT32,
4460         BASE_DEC, NULL, 0x0,  NULL, HFILL
4461       }
4462     },
4463     { &hf_reload_via_list_length,
4464       { "via_list_length (uint16)",  "reload.forwarding.via_list.length",  FT_UINT16,
4465         BASE_DEC, NULL, 0x0,  NULL, HFILL
4466       }
4467     },
4468     { &hf_reload_destination_list_length,
4469       { "destination_list_length (uint16)",  "reload.forwarding.destination_list.length",  FT_UINT16,
4470         BASE_DEC, NULL, 0x0,  NULL, HFILL
4471       }
4472     },
4473     { &hf_reload_options_length,
4474       { "options_length (uint16)", "reload.forwarding.options.length", FT_UINT16,
4475         BASE_DEC, NULL, 0x0,  NULL, HFILL
4476       }
4477     },
4478     { &hf_reload_via_list,
4479       { "via_list",   "reload.forwarding.via_list", FT_NONE,
4480         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4481       }
4482     },
4483     { &hf_reload_destination,
4484       { "Destination",    "reload.destination",  FT_NONE,
4485         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4486       }
4487     },
4488     { &hf_reload_destination_compressed_id,
4489       { "compressed_id (uint16)", "reload.forwarding.destination.compressed_id",  FT_UINT16,
4490         BASE_HEX, NULL,   0x0,  NULL, HFILL
4491       }
4492     },
4493     { &hf_reload_destination_type,
4494       { "type (DestinationType)",    "reload.forwarding.destination.type",  FT_UINT8,
4495         BASE_HEX, VALS(destinationtypes), 0x0,  NULL, HFILL
4496       }
4497     },
4498     { &hf_reload_destination_data_node_id,
4499       { "node_id (NodeId)",    "reload.destination.data.nodeid", FT_BYTES,
4500         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4501       }
4502     },
4503     { &hf_reload_destination_data_resource_id,
4504       { "resource_id",    "reload.destination.data.resourceid", FT_NONE,
4505         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4506       }
4507     },
4508     { &hf_reload_nodeid,
4509       { "NodeId",    "reload.nodeid", FT_BYTES,
4510         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4511       }
4512     },
4513     { &hf_reload_resourceid,
4514       { "ResourceId",    "reload.resource_id", FT_NONE,
4515         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4516       }
4517     },
4518     { &hf_reload_destination_data_compressed_id,
4519       { "compressed_id",    "reload.destination.data.compressed_id",  FT_NONE,
4520         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4521       }
4522     },
4523     { &hf_reload_destination_list,
4524       { "destination_list",   "reload.forwarding.destination_list", FT_NONE,
4525         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4526       }
4527     },
4528     { &hf_reload_forwarding_options,
4529       { "options",    "reload.forwarding.options", FT_NONE,
4530         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4531       }
4532     },
4533     { &hf_reload_forwarding_option,
4534       { "ForwardingOption",    "reload.forwarding.option", FT_NONE,
4535         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4536       }
4537     },
4538     { &hf_reload_forwarding_option_type,
4539       { "type (ForwardingOptionType)", "reload.forwarding.option.type",  FT_UINT8,
4540         BASE_DEC, VALS(forwardingoptiontypes),  0x0,  NULL, HFILL
4541       }
4542     },
4543     { &hf_reload_forwarding_option_flags,
4544       { "flags (uint8)",  "reload.forwarding.option.flags", FT_UINT8,
4545         BASE_HEX, NULL, 0x0,  NULL, HFILL
4546       }
4547     },
4548     { &hf_reload_forwarding_option_flag_ignore_state_keeping,
4549       { "IGNORE_STATE_KEEPING", "reload.forwarding.option.flag.ignore_state_keeping", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
4550         NULL, HFILL
4551       }
4552     },
4553     { &hf_reload_forwarding_option_flag_response_copy,
4554       { "RESPONSE_COPY", "reload.forwarding.option.flag.response_copy", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
4555         NULL, HFILL
4556       }
4557     },
4558     { &hf_reload_forwarding_option_flag_destination_critical,
4559       { "DESTINATION_CRITICAL", "reload.forwarding.option.flags.destination_critical", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
4560         NULL, HFILL
4561       }
4562     },
4563     { &hf_reload_forwarding_option_flag_forward_critical,
4564       { "FORWARD_CRITICAL", "reload.forwarding.option.flags.forward_critical", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
4565         NULL, HFILL
4566       }
4567     },
4568     { &hf_reload_attachreqans,
4569       { "AttachReqAns", "reload.attachreqans",  FT_NONE,
4570         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4571       }
4572     },
4573     { &hf_reload_ufrag,
4574       { "ufrag",  "reload.ufrag", FT_NONE,
4575         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4576       }
4577     },
4578     { &hf_reload_password,
4579       { "password", "reload.password",  FT_NONE,
4580         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4581       }
4582     },
4583     { &hf_reload_role,
4584       { "role", "reload.role",  FT_NONE,
4585         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4586       }
4587     },
4588     { &hf_reload_icecandidates,
4589       { "candidates",   "reload.icecandidates", FT_NONE,
4590         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4591       }
4592     },
4593     { &hf_reload_icecandidate,
4594       { "IceCandidate",    "reload.icecandidate",  FT_NONE,
4595         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4596       }
4597     },
4598     { &hf_reload_icecandidate_addr_port,
4599       { "addr_port",    "reload.icecandidate.addr_port",  FT_NONE,
4600         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4601       }
4602     },
4603     { &hf_reload_icecandidate_relay_addr,
4604       { "rel_addr_port",    "reload.icecandidate.relay_addr", FT_NONE,
4605         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4606       }
4607     },
4608     { &hf_reload_ipaddressport,
4609       { "IpAddressPort",    "reload.ipaddressport", FT_NONE,
4610         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4611       }
4612     },
4613     { &hf_reload_ipaddressport_type,
4614       { "type (AddressType)", "reload.ipaddressport.type",  FT_UINT8,
4615         BASE_HEX, VALS(ipaddressporttypes), 0x0,  NULL, HFILL
4616       }
4617     },
4618     { &hf_reload_ipv4addrport,
4619       { "IPv4AddrPort",    "reload.ipv4addrport", FT_NONE,
4620         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4621       }
4622     },
4623     { &hf_reload_ipv4addr,
4624       { "addr (uint32)", "reload.ipv4addr",  FT_IPv4,
4625         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4626       }
4627     },
4628     { &hf_reload_ipv6addrport,
4629       { "IPv6AddrPort",    "reload.ipv6addrport", FT_NONE,
4630         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4631       }
4632     },
4633     { &hf_reload_ipv6addr,
4634       { "addr (uint128)", "reload.ipv6addr",  FT_IPv6,
4635         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4636       }
4637     },
4638     { &hf_reload_port,
4639       { "port (uint16)", "reload.port",  FT_UINT16,
4640         BASE_DEC, NULL, 0x0,  NULL, HFILL
4641       }
4642     },
4643     { &hf_reload_overlaylink_type,
4644       { "overlay_link (OverlayLinkType)",  "reload.overlaylink.type",  FT_UINT8,
4645         BASE_DEC, VALS(overlaylinktypes), 0x0,  NULL, HFILL
4646       }
4647     },
4648     { &hf_reload_icecandidate_foundation,
4649       { "foundation", "reload.icecandidate.foundation", FT_NONE,
4650         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4651       }
4652     },
4653     { &hf_reload_icecandidate_priority,
4654       { "priority (uint32)", "reload.icecandidate.priority", FT_UINT32,
4655         BASE_DEC, NULL, 0x0,  NULL, HFILL
4656       }
4657     },
4658     { &hf_reload_icecandidate_type,
4659       { "Ice candidate type", "reload.icecandidate.type", FT_UINT8,
4660         BASE_DEC, VALS(candtypes),  0x0,  NULL, HFILL
4661       }
4662     },
4663     { &hf_reload_iceextensions,
4664       { "extensions",    "reload.iceextensions",  FT_NONE,
4665         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4666       }
4667     },
4668     { &hf_reload_iceextension,
4669       { "IceExtension",    "reload.iceextension",  FT_NONE,
4670         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4671       }
4672     },
4673     { &hf_reload_iceextension_name,
4674       { "name", "reload.iceextension.name", FT_NONE,
4675         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4676       }
4677     },
4678     { &hf_reload_iceextension_value,
4679       { "value",  "reload.iceextension.value",  FT_NONE,
4680         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4681       }
4682     },
4683     { &hf_reload_sendupdate,
4684       { "send_update (Boolean)", "reload.sendupdate",  FT_BOOLEAN,
4685         BASE_NONE, NULL, 0x0,  NULL, HFILL
4686       }
4687     },
4688     { &hf_reload_message_contents,
4689       { "MessageContents",   "reload.message.contents",  FT_NONE,
4690         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4691       }
4692     },
4693     { &hf_reload_message_code,
4694       { "message_code (uint16)", "reload.message.code",  FT_UINT16,
4695         BASE_DEC, NULL, 0x0,  NULL, HFILL
4696       }
4697     },
4698     { &hf_reload_message_body,
4699       { "message_body", "reload.message.body",  FT_NONE,
4700         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4701       }
4702     },
4703     { &hf_reload_message_extensions,
4704       { "extensions",  "reload.message.extensions", FT_NONE,
4705         BASE_NONE, NULL, 0x0,  NULL, HFILL
4706       }
4707     },
4708     { &hf_reload_message_extension,
4709       { "MessageExtension",    "reload.message_extension", FT_NONE,
4710         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4711       }
4712     },
4713     { &hf_reload_message_extension_type,
4714       { "type (MessageExtensionType)", "reload.message_extension.type",  FT_UINT16,
4715         BASE_DEC, VALS(messageextensiontypes), 0x0,  NULL, HFILL
4716       }
4717     },
4718     { &hf_reload_message_extension_critical,
4719       { "critical (Boolean)", "reload.message_extension.critical",  FT_BOOLEAN,
4720         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4721       }
4722     },
4723     { &hf_reload_message_extension_content,
4724       { "extension_content",  "reload.message_extension.content", FT_BYTES,
4725         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4726       }
4727     },
4728     { &hf_reload_error_response,
4729       { "ErrorResponse", "reload.error_response",  FT_NONE,
4730         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4731       }
4732     },
4733     { &hf_reload_error_response_code,
4734       { "error_code (uint16)", "reload.error_response.code", FT_UINT16,
4735         BASE_DEC, VALS(errorcodes), 0x0,  NULL, HFILL
4736       }
4737     },
4738     { &hf_reload_error_response_info,
4739       { "error_info", "reload.error_response_info", FT_NONE,
4740         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4741       }
4742     },
4743     { &hf_reload_security_block,
4744       { "SecurityBlock", "reload.security_block",  FT_NONE,
4745         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4746       }
4747     },
4748     { &hf_reload_certificates,
4749       { "certificates",  "reload.certificates", FT_NONE,
4750         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4751       }
4752     },
4753     { &hf_reload_certificate_type,
4754       { "type (CertificateType)", "reload.certificate.type",  FT_UINT8,
4755         BASE_DEC, VALS(tls_certificate_type), 0x0,  NULL, HFILL
4756       }
4757     },
4758     { &hf_reload_genericcertificate,
4759       { "GenericCertificate", "reload.genericcertificate",  FT_NONE,
4760         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4761       }
4762     },
4763     { &hf_reload_certificate,
4764       { "certificate", "reload.certificate",  FT_NONE,
4765         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4766       }
4767     },
4768     { &hf_reload_signature,
4769       { "signature (Signature)",  "reload.signature", FT_NONE,
4770         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4771       }
4772     },
4773     { &hf_reload_signatureandhashalgorithm,
4774       { "algorithm (SignatureAndHashAlgorithm)",  "reload.signatureandhashalgorithm", FT_NONE,
4775         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4776       }
4777     },
4778     { &hf_reload_hash_algorithm,
4779       { "hash (HashAlgorithm)", "reload.hash_algorithm",  FT_UINT8,
4780         BASE_DEC, VALS(tls_hash_algorithm), 0x0,  NULL, HFILL
4781       }
4782     },
4783     { &hf_reload_signeridentity_value_hash_alg,
4784       { "hash_alg (HashAlgorithm)", "reload.signeridentityvalue.hash_alg",  FT_UINT8,
4785         BASE_DEC, VALS(tls_hash_algorithm), 0x0,  NULL, HFILL
4786       }
4787     },
4788     { &hf_reload_signature_algorithm,
4789       { "signature (SignatureAlgorithm)",  "reload.signature_algorithm", FT_UINT8,
4790         BASE_DEC, VALS(tls_signature_algorithm),  0x0,  NULL, HFILL
4791       }
4792     },
4793     { &hf_reload_signeridentity,
4794       { "identity (SignerIdentity)", "reload.signature.identity",  FT_NONE,
4795         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4796       }
4797     },
4798     { &hf_reload_signeridentity_identity,
4799       { "identity", "reload.signature.identity.identity",  FT_NONE,
4800         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4801       }
4802     },
4803     { &hf_reload_signeridentity_type,
4804       { "identity_type (SignerIdentityType)",  "reload.signature.identity.type", FT_UINT8,
4805         BASE_DEC, VALS(signeridentitytypes), 0x0,  NULL, HFILL
4806       }
4807     },
4808     { &hf_reload_signeridentity_value,
4809       { "SignatureIdentityValue", "reload.signature.identity.value",  FT_NONE,
4810         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4811       }
4812     },
4813     { &hf_reload_signeridentity_value_certificate_hash,
4814       { "certificate_hash",  "reload.signature.identity.value.certificate_hash", FT_NONE,
4815         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4816       }
4817     },
4818     { &hf_reload_signeridentity_value_certificate_node_id_hash,
4819       { "certificate_node_id_hash",  "reload.signature.identity.value.certificate_node_id_hash", FT_NONE,
4820         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4821       }
4822     },
4823     { &hf_reload_signature_value,
4824       { "signature_value",  "reload.signature.value.",  FT_NONE,
4825         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4826       }
4827     },
4828     { &hf_reload_length_uint8,
4829       { "length (uint8)", "reload.length.8", FT_UINT8,
4830         BASE_DEC, NULL, 0x0,  NULL, HFILL
4831       }
4832     },
4833     { &hf_reload_length_uint16,
4834       { "length (uint16)", "reload.length.16", FT_UINT16,
4835         BASE_DEC, NULL, 0x0,  NULL, HFILL
4836       }
4837     },
4838     { &hf_reload_length_uint24,
4839       { "length (uint24)", "reload.length.24", FT_UINT32,
4840         BASE_DEC, NULL, 0x0,  NULL, HFILL
4841       }
4842     },
4843     { &hf_reload_length_uint32,
4844       { "length (uint32)", "reload.length.32",  FT_UINT32,
4845         BASE_DEC, NULL, 0x0,  NULL, HFILL
4846       }
4847     },
4848     { &hf_reload_opaque,
4849       { "opaque",  "reload.opaque", FT_NONE,
4850         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4851       }
4852     },
4853     { &hf_reload_opaque_data,
4854       { "data (bytes)", "reload.opaque.data", FT_BYTES,
4855         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4856       }
4857     },
4858     { &hf_reload_opaque_string,
4859       { "data (string)", "reload.opaque.string", FT_STRING,
4860         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4861       }
4862     },
4863     { &hf_reload_routequeryreq,
4864       { "RouteQueryReq",  "reload.routequeryreq", FT_NONE,
4865         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4866       }
4867     },
4868     { &hf_reload_routequeryreq_destination,
4869       { "destination",  "reload.routequeryreq.destination", FT_NONE,
4870         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4871       }
4872     },
4873     { &hf_reload_overlay_specific,
4874       { "overlay_specific_data",  "reload.overlay_specific_data", FT_NONE,
4875         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4876       }
4877     },
4878     { &hf_reload_probereq,
4879       { "ProbeReq", "reload.probereq",  FT_NONE,
4880         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4881       }
4882     },
4883     { &hf_reload_probereq_requested_info,
4884       { "requested_info", "reload.probereq.requested_info",  FT_NONE,
4885         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4886       }
4887     },
4888     { &hf_reload_probe_information,
4889       { "ProbeInformation",  "reload.probe_information", FT_NONE,
4890         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4891       }
4892     },
4893     { &hf_reload_probe_information_data,
4894       { "value (ProbeInformationData)",  "reload.probe_information_data", FT_NONE,
4895         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4896       }
4897     },
4898     { &hf_reload_probe_information_type,
4899       { "type (ProbeInformationType)", "reload.probe_information.type", FT_UINT8,
4900         BASE_HEX, VALS(probeinformationtypes),  0x0,  NULL, HFILL
4901       }
4902     },
4903     { &hf_reload_responsible_set,
4904       { "responsible_ppb (uint32)",  "reload.responsible_set", FT_UINT32,
4905         BASE_HEX, NULL, 0x0,  NULL, HFILL
4906       }
4907     },
4908     { &hf_reload_num_resources,
4909       { "num_resources (uint32)",  "reload.num_resources", FT_UINT32,
4910         BASE_DEC, NULL, 0x0,  NULL, HFILL
4911       }
4912     },
4913     { &hf_reload_uptime,
4914       { "uptime (uint32)", "reload.uptime", FT_UINT32,
4915         BASE_DEC, NULL, 0x0,  NULL, HFILL
4916       }
4917     },
4918     { &hf_reload_probeans,
4919       { "ProbeAns",  "reload.probeans", FT_NONE,
4920         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4921       }
4922     },
4923     { &hf_reload_probeans_probe_info,
4924       { "probe_info",  "reload.probe_info", FT_NONE,
4925         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4926       }
4927     },
4928     { &hf_reload_appattachreq,
4929       { "AppAttachReq", "reload.appattachreq", FT_NONE,
4930         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4931       }
4932     },
4933     { &hf_reload_appattachans,
4934       { "AppAttachAns", "reload.appattachans", FT_NONE,
4935         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4936       }
4937     },
4938     { &hf_reload_application,
4939       { "application (uint16)", "reload.application", FT_UINT16,
4940         BASE_DEC, VALS(applicationids), 0x0,  NULL, HFILL
4941       }
4942     },
4943     { &hf_reload_ping_response_id,
4944       { "response_id (uint64)", "reload.ping.response_id",  FT_UINT64,
4945         BASE_DEC, NULL, 0x0,  NULL, HFILL
4946       }
4947     },
4948     { &hf_reload_ping_time,
4949       { "time (uint64)", "reload.ping.time", FT_ABSOLUTE_TIME,
4950         ABSOLUTE_TIME_UTC, NULL, 0x0,  NULL, HFILL
4951       }
4952     },
4953     { &hf_reload_storeddata,
4954       { "StoredData",  "reload.storeddata", FT_NONE,
4955         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4956       }
4957     },
4958     { &hf_reload_storedmetadata,
4959       { "StoredMetaData",  "reload.storedmetadata", FT_NONE,
4960         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4961       }
4962     },
4963     { &hf_reload_storeddata_storage_time,
4964       { "storage_time (uint64)", "reload.storeddata.storage_time", FT_ABSOLUTE_TIME,
4965         ABSOLUTE_TIME_UTC, NULL, 0x0,  NULL, HFILL
4966       }
4967     },
4968     { &hf_reload_storeddata_lifetime,
4969       { "lifetime (uint32)",  "reload.storeddata.lifetime", FT_UINT32,
4970         BASE_DEC, NULL, 0x0,  NULL, HFILL
4971       }
4972     },
4973     { &hf_reload_datavalue,
4974       { "DataValue",  "reload.datavalue", FT_NONE,
4975         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4976       }
4977     },
4978     { &hf_reload_value,
4979       { "value",  "reload.value", FT_NONE,
4980         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4981       }
4982     },
4983     { &hf_reload_metadata,
4984       { "MetaData",  "reload.metadata", FT_NONE,
4985         BASE_NONE,  NULL, 0x0,  NULL, HFILL
4986       }
4987     },
4988     { &hf_reload_datavalue_exists,
4989       { "exists (Boolean)", "reload.datavalue.exists",  FT_BOOLEAN,
4990         BASE_NONE, NULL, 0x0,  NULL, HFILL
4991       }
4992     },
4993     { &hf_reload_datavalue_value,
4994       { "value",    "reload.datavaluevalue", FT_NONE,
4995         BASE_NONE,  NULL,   0x0,  NULL, HFILL
4996       }
4997     },
4998     { &hf_reload_metadata_value_length,
4999       { "value_length (uint32)",  "reload.metadata.value_length", FT_UINT32,
5000         BASE_DEC, NULL, 0x0,  NULL, HFILL
5001       }
5002     },
5003     { & hf_reload_metadata_hash_value,
5004       { "hash_value",  "reload.metadata.hash_value", FT_NONE,
5005         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5006       }
5007     },
5008     { &hf_reload_arrayentry,
5009       { "ArrayEntry",  "reload.arrayentry", FT_NONE,
5010         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5011       }
5012     },
5013     { &hf_reload_arrayentry_index,
5014       { "index (uint32)",  "reload.arrayentry.index", FT_UINT32,
5015         BASE_DEC, NULL, 0x0,  NULL, HFILL
5016       }
5017     },
5018     { &hf_reload_arrayentry_value,
5019       { "value",  "reload.arrayentry.value", FT_NONE,
5020         BASE_NONE, NULL, 0x0,  NULL, HFILL
5021       }
5022     },
5023     { &hf_reload_dictionaryentry,
5024       { "DictionaryEntry",  "reload.dictionaryentry", FT_NONE,
5025         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5026       }
5027     },
5028     { &hf_reload_dictionarykey,
5029       { "key (DictionaryKey)",  "reload.dictionarykey", FT_NONE,
5030         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5031       }
5032     },
5033     { &hf_reload_dictionary_value,
5034       { "value (DataValue)",  "reload.dictionary.value", FT_NONE,
5035         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5036       }
5037     },
5038     { &hf_reload_kinddata,
5039       { "StoreKindData",  "reload.kinddata", FT_NONE,
5040         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5041       }
5042     },
5043     { &hf_reload_kinddata_kind,
5044       { "kind (KindId)",  "reload.kinddata.kind", FT_UINT32,
5045         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5046       }
5047     },
5048     { &hf_reload_statkindresponse,
5049       { "StatKindResponse",  "reload.statkindresponse", FT_NONE,
5050         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5051       }
5052     },
5053     { &hf_reload_kindid,
5054       { "KindId",  "reload.kindid",  FT_UINT32,
5055         BASE_DEC, NULL,  0x0,  NULL, HFILL
5056       }
5057     },
5058     { &hf_reload_kindid_list,
5059       { "kinds",  "reload.kindid_list", FT_NONE,
5060         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5061       }
5062     },
5063     { &hf_reload_generation_counter,
5064       { "generation_counter (uint64)", "reload.generation_counter", FT_UINT64,
5065         BASE_DEC, NULL, 0x0,  NULL, HFILL
5066       }
5067     },
5068     { &hf_reload_values,
5069       { "values",  "reload.kinddata.values_length",  FT_NONE,
5070         BASE_NONE, NULL, 0x0,  NULL, HFILL
5071       }
5072     },
5073     { &hf_reload_storereq,
5074       { "StoreReq", "reload.storereq", FT_NONE,
5075         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5076       }
5077     },
5078     { &hf_reload_resource,
5079       { "resource", "reload.resource", FT_NONE,
5080         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5081       }
5082     },
5083     { &hf_reload_store_replica_num,
5084       { "replica_number (uint8)",  "reload.store.replica_number", FT_UINT8,
5085         BASE_DEC, NULL, 0x0,  NULL, HFILL
5086       }
5087     },
5088     { &hf_reload_store_kind_data,
5089       { "kind_data",  "reload.store.kind_data",  FT_NONE,
5090         BASE_NONE, NULL, 0x0,  NULL, HFILL
5091       }
5092     },
5093     { &hf_reload_storeans,
5094       { "StoreAns", "reload.storeans", FT_NONE,
5095         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5096       }
5097     },
5098     { &hf_reload_storeans_kind_responses,
5099       { "kind_responses", "reload.storeans.kind_responses", FT_NONE,
5100         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5101       }
5102     },
5103     { &hf_reload_storekindresponse,
5104       { "StoreKindResponse", "reload.storekindresponse", FT_NONE,
5105         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5106       }
5107     },
5108     { &hf_reload_replicas,
5109       { "replicas", "reload.storekindresponse.replicas", FT_NONE,
5110         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5111       }
5112     },
5113     { &hf_reload_statreq,
5114       { "StatReq", "reload.statreq", FT_NONE,
5115         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5116       }
5117     },
5118     { &hf_reload_fetchans,
5119       { "FetchAns", "reload.fetchans", FT_NONE,
5120         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5121       }
5122     },
5123     { &hf_reload_fetchreq,
5124       { "FetchReq", "reload.fetchreq", FT_NONE,
5125         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5126       }
5127     },
5128     { &hf_reload_fetchreq_specifiers,
5129       { "specifiers", "reload.fetchreq.specifiers", FT_NONE,
5130         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5131       }
5132     },
5133     { &hf_reload_arrayrange,
5134       { "ArrayRange", "reload.arrayrange", FT_NONE,
5135         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5136       }
5137     },
5138     { &hf_reload_storeddataspecifier,
5139       { "StoredDataSpecifier", "reload.storeddataspecifier", FT_NONE,
5140         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5141       }
5142     },
5143     { &hf_reload_storeddataspecifier_indices,
5144       { "indices", "reload.storeddataspecifier.indices", FT_NONE,
5145         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5146       }
5147     },
5148     { &hf_reload_storeddataspecifier_keys,
5149       { "indices", "reload.storeddataspecifier.keys", FT_NONE,
5150         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5151       }
5152     },
5153     { &hf_reload_statans,
5154       { "StatAns",  "reload.statans", FT_NONE,
5155         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5156       }
5157     },
5158     { &hf_reload_findans,
5159       { "FindAns",  "reload.findans", FT_NONE,
5160         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5161       }
5162     },
5163     { &hf_reload_findkinddata_closest,
5164       { "closest",  "reload.findkindata.closest", FT_NONE,
5165         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5166       }
5167     },
5168     { &hf_reload_findkinddata,
5169       { "FindKindData", "reload.findkinddata", FT_NONE,
5170         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5171       }
5172     },
5173     { &hf_reload_fragment_overlap,
5174       { "Fragment overlap", "reload.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5175         "Fragment overlaps with other fragments", HFILL
5176       }
5177     },
5178
5179     { &hf_reload_fragment_overlap_conflict,
5180       { "Conflicting data in fragment overlap", "reload.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5181         "Overlapping fragments contained conflicting data", HFILL
5182       }
5183     },
5184
5185     { &hf_reload_fragment_multiple_tails,
5186       { "Multiple tail fragments found",  "reload.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5187         "Several tails were found when defragmenting the packet", HFILL
5188       }
5189     },
5190
5191     { &hf_reload_fragment_too_long_fragment,
5192       { "Fragment too long",  "reload.fragment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5193         "Fragment contained data past end of packet", HFILL
5194       }
5195     },
5196
5197     { &hf_reload_fragment_error,
5198       { "Defragmentation error", "reload.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
5199         "Defragmentation error due to illegal fragments", HFILL
5200       }
5201     },
5202
5203     { &hf_reload_fragment_count,
5204       { "Fragment count", "reload.fragment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
5205         NULL, HFILL
5206       }
5207     },
5208
5209     { &hf_reload_fragment,
5210       { "RELOAD fragment", "reload.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
5211         NULL, HFILL
5212       }
5213     },
5214
5215     { &hf_reload_fragments,
5216       { "RELOAD fragments", "reload.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
5217         NULL, HFILL
5218       }
5219     },
5220
5221     { &hf_reload_reassembled_in,
5222       { "Reassembled RELOAD in frame", "reload.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
5223         "This RELOAD packet is reassembled in this frame", HFILL
5224       }
5225     },
5226
5227     { &hf_reload_reassembled_length,
5228       { "Reassembled RELOAD length", "reload.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
5229         "The total length of the reassembled payload", HFILL
5230       }
5231     },
5232
5233     { &hf_reload_configupdatereq,
5234       { "ConfigUpdateReq",  "reload.configupdatereq.",  FT_NONE,
5235         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5236       }
5237     },
5238
5239     { &hf_reload_configupdatereq_type,
5240       { "type (ConfigUpdateType)", "reload.configupdatereq.type", FT_UINT8,
5241         BASE_DEC, VALS(configupdatetypes),  0x0,  NULL, HFILL
5242       }
5243     },
5244
5245     { &hf_reload_configupdatereq_configdata,
5246       { "config_data",  "reload.configupdatereq.config_data",  FT_NONE,
5247         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5248       }
5249     },
5250
5251     { &hf_reload_configupdatereq_kinds,
5252       { "kinds",  "reload.configupdatereq.kinds",  FT_NONE,
5253         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5254       }
5255     },
5256     { &hf_reload_kinddescription,
5257       { "KindDescription",  "reload.configupdatereq.kinddescription",  FT_NONE,
5258         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5259       }
5260     },
5261     { &hf_reload_pingreq,
5262       { "PingReq",  "reload.pingreq",  FT_NONE,
5263         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5264       }
5265     },
5266     { &hf_reload_pingans,
5267       { "PingAns",  "reload.pingans",  FT_NONE,
5268         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5269       }
5270     },
5271     { &hf_reload_padding,
5272       { "padding",  "reload.padding",  FT_NONE,
5273         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5274       }
5275     },
5276
5277     { &hf_reload_chordupdate,
5278       { "ChordUpdate",  "reload.chordupdate",  FT_NONE,
5279         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5280       }
5281     },
5282     { &hf_reload_chordupdate_type,
5283       { "type (ChordUpdateType)", "reload.chordupdate.type", FT_UINT8,
5284         BASE_DEC, VALS(chordupdatetypes),  0x0,  NULL, HFILL
5285       }
5286     },
5287     { &hf_reload_chordupdate_predecessors,
5288       { "predecessors",  "reload.chordupdate.predecessors",  FT_NONE,
5289         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5290       }
5291     },
5292     { &hf_reload_chordupdate_successors,
5293       { "successors",  "reload.chordupdate.successors",  FT_NONE,
5294         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5295       }
5296     },
5297     { &hf_reload_chordupdate_fingers,
5298       { "fingers",  "reload.chordupdate.fingers",  FT_NONE,
5299         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5300       }
5301     },
5302     { &hf_reload_chordroutequeryans,
5303       { "ChordRouteQueryAns",  "reload.chordroutequeryans",  FT_NONE,
5304         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5305       }
5306     },
5307     { &hf_reload_chordroutequeryans_next_peer,
5308       { "next_peer (NodeId)",  "reload.chordroutequeryans.nodeid",  FT_BYTES,
5309         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5310       }
5311     },
5312     { &hf_reload_chordleave,
5313       { "ChordLeaveData",  "reload.chordleavedata",  FT_NONE,
5314         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5315       }
5316     },
5317     { &hf_reload_chordleave_type,
5318       { "type (ChordLeaveType)", "reload.chordleavedata.type", FT_UINT8,
5319         BASE_DEC, VALS(chordleavetypes),  0x0,  NULL, HFILL
5320       }
5321     },
5322     { &hf_reload_chordleave_predecessors,
5323       { "predecessors",  "reload.chordleavedata.predecessors",  FT_NONE,
5324         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5325       }
5326     },
5327     { &hf_reload_chordleave_successors,
5328       { "successors",  "reload.chordleavedata.successors",  FT_NONE,
5329         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5330       }
5331     },
5332     { &hf_reload_turnserver,
5333       { "TurnServer",  "reload.turnserver",  FT_NONE,
5334         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5335       }
5336     },
5337     { &hf_reload_turnserver_iteration,
5338       { "iteration (uint8)",  "reload.turnserver.iteration",  FT_UINT8,
5339         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5340       }
5341     },
5342     { &hf_reload_turnserver_server_address,
5343       { "server_address",  "reload.turnserver.server_address",  FT_NONE,
5344         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5345       }
5346     },
5347     { &hf_reload_sipregistration,
5348       { "SipRegistration",  "reload.sipregistration",  FT_NONE,
5349         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5350       }
5351     },
5352     { &hf_reload_sipregistration_type,
5353       { "type (SipRegistrationType)",  "reload.sipregistration.type",  FT_UINT8,
5354         BASE_DEC,  VALS(sipregistrationtypes), 0x0,  NULL, HFILL
5355       }
5356     },
5357     { &hf_reload_sipregistration_data,
5358       { "data (SipRegistrationData)",  "reload.sipregistration.data",  FT_NONE,
5359         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5360       }
5361     },
5362     { &hf_reload_sipregistration_data_uri,
5363       { "uri",  "reload.sipregistration.data.uri",  FT_NONE,
5364         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5365       }
5366     },
5367     { &hf_reload_sipregistration_data_contact_prefs,
5368       { "contact_prefs",  "reload.sipregistration.data.contact_prefs",  FT_NONE,
5369         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5370       }
5371     },
5372     { &hf_reload_sipregistration_data_destination_list,
5373       { "destination_list",  "reload.sipregistration.data.destination_list",  FT_NONE,
5374         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5375       }
5376     },
5377     { &hf_reload_redirserviceprovider,
5378       { "RedirServiceProvider",  "reload.redirserviceprovider",  FT_NONE,
5379         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5380       }
5381     },
5382     { &hf_reload_redirserviceproviderdata,
5383       { "data (RedirServiceProviderData)",  "reload.redirserviceprovider.data",  FT_NONE,
5384         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5385       }
5386     },
5387     { &hf_reload_redirserviceproviderdata_serviceprovider,
5388       { "serviceProvider (NodeId)",  "reload.redirserviceprovider.data.serviceprovider",  FT_BYTES,
5389         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5390       }
5391     },
5392     { &hf_reload_redirserviceproviderdata_namespace,
5393       { "namespace",  "reload.redirserviceprovider.data.namespace",  FT_NONE,
5394         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5395       }
5396     },
5397     { &hf_reload_redirserviceproviderdata_level,
5398       { "level (uint16)",  "reload.redirserviceprovider.data.level",  FT_UINT16,
5399         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5400       }
5401     },
5402     { &hf_reload_redirserviceproviderdata_node,
5403       { "node (uint16)",  "reload.redirserviceprovider.data.node",  FT_UINT16,
5404         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5405       }
5406     },
5407     { &hf_reload_self_tuning_data,
5408       { "SelfTuningData",  "reload.selftuning_data",  FT_NONE,
5409         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5410       }
5411     },
5412     { &hf_reload_self_tuning_data_network_size,
5413       { "network_size (uint32)",  "reload.selftuning_data.network_size",  FT_UINT32,
5414         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5415       }
5416     },
5417     { &hf_reload_self_tuning_data_join_rate,
5418       { "join_rate (uint32)",  "reload.selftuning_data.join_rate",  FT_UINT32,
5419         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5420       }
5421     },
5422     { &hf_reload_self_tuning_data_leave_rate,
5423       { "leave_rate (uint32)",  "reload.selftuning_data.leave_rate",  FT_UINT32,
5424         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5425       }
5426     },
5427     { &hf_reload_findreq,
5428       { "FindReq",  "reload.findreq",  FT_NONE,
5429         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5430       }
5431     },
5432     { &hf_reload_dmflags,
5433       { "dMFlags (uint64)",  "reload.dmflags",  FT_UINT64,
5434         BASE_HEX,  NULL, 0x0,  NULL, HFILL
5435       }
5436     },
5437     { &hf_reload_dmflag_status_info,
5438       { "STATUS_INFO", "reload.dmflags.status_info", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5439         NULL, HFILL
5440       }
5441     },
5442     { &hf_reload_dmflag_routing_table_size,
5443       { "ROUTING_TABLE_SIZE", "reload.dmflags.routing_table_size", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5444         NULL, HFILL
5445       }
5446     },
5447     { &hf_reload_dmflag_process_power,
5448       { "PROCESS_POWER", "reload.dmflags.process_power", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5449         NULL, HFILL
5450       }
5451     },
5452     { &hf_reload_dmflag_bandwidth,
5453       { "BANDWIDTH", "reload.dmflags.bandwidth", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5454         NULL, HFILL
5455       }
5456     },
5457     { &hf_reload_dmflag_software_version,
5458       { "SOFTWARE_VERSION", "reload.dmflags.software_version", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5459         NULL, HFILL
5460       }
5461     },
5462     { &hf_reload_dmflag_machine_uptime,
5463       { "MACHINE_UPTIME", "reload.dmflags.machine_uptime", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5464         NULL, HFILL
5465       }
5466     },
5467     { &hf_reload_dmflag_app_uptime,
5468       { "APP_UPTIME", "reload.dmflags.app_uptime", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5469         NULL, HFILL
5470       }
5471     },
5472     { &hf_reload_dmflag_memory_footprint,
5473       { "MEMORY_FOOTPRINT", "reload.dmflags.memory_footprint", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5474         NULL, HFILL
5475       }
5476     },
5477     { &hf_reload_dmflag_datasize_stored,
5478       { "DATASIZE_STORED", "reload.dmflags.datasize_stored", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5479         NULL, HFILL
5480       }
5481     },
5482     { &hf_reload_dmflag_instances_stored,
5483       { "INSTANCES_STORED", "reload.dmflags.instances_stored", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5484         NULL, HFILL
5485       }
5486     },
5487     { &hf_reload_dmflag_messages_sent_rcvd,
5488       { "MESSAGES_SENT_RCVD", "reload.dmflags.messages_sent_rcvd", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5489         NULL, HFILL
5490       }
5491     },
5492     { &hf_reload_dmflag_ewma_bytes_sent,
5493       { "EWMA_BYTES_SENT", "reload.dmflags.ewma_bytes_sent", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5494         NULL, HFILL
5495       }
5496     },
5497     { &hf_reload_dmflag_ewma_bytes_rcvd,
5498       { "EWMA_BYTES_RCVD", "reload.dmflags.ewma_bytes_rcvd", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5499         NULL, HFILL
5500       }
5501     },
5502     { &hf_reload_dmflag_underlay_hop,
5503       { "UNDERLAY_HOP", "reload.dmflags.underlay_hop", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5504         NULL, HFILL
5505       }
5506     },
5507     { &hf_reload_dmflag_battery_status,
5508       { "BATTERY_STATUS", "reload.dmflags.battery_status", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
5509         NULL, HFILL
5510       }
5511     },
5512     { &hf_reload_diagnosticrequest,
5513       { "DiagnosticRequest",  "reload.diagnosticrequest",  FT_NONE,
5514         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5515       }
5516     },
5517     { &hf_reload_diagnosticresponse,
5518       { "DiagnosticResponse",  "reload.diagnosticresponse",  FT_NONE,
5519         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5520       }
5521     },
5522     { &hf_reload_diagnosticextension,
5523       { "DiagnosticExtension",  "reload.diagnosticextension",  FT_NONE,
5524         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5525       }
5526     },
5527     { &hf_reload_diagnosticextension_type,
5528       { "type (DiagnosticExtensionRequestType)",  "reload.diagnosticextension.type",  FT_UINT16,
5529         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5530       }
5531     },
5532     { &hf_reload_diagnosticextension_contents,
5533       { "diagnostic_extension_contents",  "reload.diagnosticextension.contents",  FT_NONE,
5534         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5535       }
5536     },
5537     { &hf_reload_diagnostic_expiration, {
5538         "expiration (uint64)", "reload.diagnostic.expiration", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
5539         NULL, 0x0, NULL, HFILL
5540       }
5541     },
5542     { &hf_reload_diagnosticrequest_timestampinitiated, {
5543         "timestampInitiated (uint64)", "reload.diagnosticrequest.timestampinitiated",FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
5544         NULL, 0x0, NULL, HFILL
5545       }
5546     },
5547     { &hf_reload_diagnosticrequest_extensions,
5548       { "diagnostic_extensions",  "reload.diagnosticrequest.extensions",  FT_NONE,
5549         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5550       }
5551     },
5552     { &hf_reload_pathtrackreq,
5553       { "PathTrackReq",  "reload.pathtrackreq",  FT_NONE,
5554         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5555       }
5556     },
5557     { &hf_reload_pathtrackreq_destination,
5558       { "destination (Destination)",  "reload.pathtrackreq.destination",  FT_NONE,
5559         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5560       }
5561     },
5562     { &hf_reload_pathtrackreq_request,
5563       { "request (DiagnosticRequest)",  "reload.pathtrackreq.request",  FT_NONE,
5564         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5565       }
5566     },
5567     { &hf_reload_diagnosticinfo,
5568       { "DiagnosticInfo",  "reload.diagnostic.info",  FT_NONE,
5569         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5570       }
5571     },
5572     { &hf_reload_diagnosticinfo_kind,
5573       { "kind (DiagnosticKindId)",  "reload.diagnostic.kindid",  FT_UINT16,
5574         BASE_DEC,  VALS(diagnostickindids), 0x0,  NULL, HFILL
5575       }
5576     },
5577     { &hf_reload_diagnosticinfo_congestion_status,
5578       { "congestion_status (uint8)",  "reload.diagnostic.info.congestion_status",  FT_UINT8,
5579         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5580       }
5581     },
5582     { &hf_reload_diagnosticinfo_number_peers,
5583       { "number_peers (uint32)",  "reload.diagnostic.info.number_peers",  FT_UINT32,
5584         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5585       }
5586     },
5587     { &hf_reload_diagnosticinfo_processing_power,
5588       { "processing_power (uint32)",  "reload.diagnostic.info.processing_power",  FT_UINT32,
5589         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5590       }
5591     },
5592     { &hf_reload_diagnosticinfo_bandwidth,
5593       { "bandwidth (uint32)",  "reload.diagnostic.info.bandwidth",  FT_UINT32,
5594         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5595       }
5596     },
5597     { &hf_reload_diagnosticinfo_software_version,
5598       { "software_version (opaque string)",  "reload.diagnostic.info.software_version",  FT_STRING,
5599         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5600       }
5601     },
5602     { &hf_reload_diagnosticinfo_machine_uptime,
5603       { "machine_uptime (uint64)",  "reload.diagnostic.info.machine_uptime",  FT_UINT64,
5604         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5605       }
5606     },
5607     { &hf_reload_diagnosticinfo_app_uptime,
5608       { "app_uptime (uint64)",  "reload.diagnostic.info.app_uptime",  FT_UINT64,
5609         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5610       }
5611     },
5612     { &hf_reload_diagnosticinfo_memory_footprint,
5613       { "memory_footprint(uint32)",  "reload.diagnostic.info.memory_footprint",  FT_UINT32,
5614         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5615       }
5616     },
5617     { &hf_reload_diagnosticinfo_datasize_stored,
5618       { "datasize_stored (uint64)",  "reload.diagnostic.info.datasize_stored",  FT_UINT64,
5619         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5620       }
5621     },
5622     { &hf_reload_diagnosticinfo_instances_stored,
5623       { "instances_stored",  "reload.diagnostic.info.instances_stored",  FT_NONE,
5624         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5625       }
5626     },
5627     { &hf_reload_diagnosticinfo_instancesstored_info,
5628       { "InstancesStoredInfo)",  "reload.diagnostic.info.instancesstored_info",  FT_NONE,
5629         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5630       }
5631     },
5632     { &hf_reload_diagnosticinfo_instancesstored_instances,
5633       { "instances (uint64)",  "reload.diagnostic.info.instancesstored_instances",  FT_UINT64,
5634         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5635       }
5636     },
5637     { &hf_reload_diagnosticinfo_messages_sent_rcvd,
5638       { "messages_sent_rcvd",  "reload.diagnostic.info.messages_sent_rcvd",  FT_NONE,
5639         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5640       }
5641     },
5642     { &hf_reload_diagnosticinfo_messages_sent_rcvd_info,
5643       { "MessagesSentRcvdInfo",  "reload.diagnostic.info.messages_sent_rcvd.info",  FT_NONE,
5644         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5645       }
5646     },
5647     { &hf_reload_diagnosticinfo_message_code,
5648       { "messages_code (uint16)",  "reload.diagnostic.info.message_code",  FT_UINT16,
5649         BASE_HEX,  NULL, 0x0,  NULL, HFILL
5650       }
5651     },
5652     { &hf_reload_diagnosticinfo_messages_sent,
5653       { "sent (uint64)",  "reload.diagnostic.info.messages_sent",  FT_UINT64,
5654         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5655       }
5656     },
5657     { &hf_reload_diagnosticinfo_messages_rcvd,
5658       { "rcvd (uint64)",  "reload.diagnostic.info.messages_rcvd",  FT_UINT64,
5659         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5660       }
5661     },
5662     { &hf_reload_diagnosticinfo_ewma_bytes_sent,
5663       { "ewma_bytes_sent (uint32)",  "reload.diagnostic.info.ewma_bytes_sent",  FT_UINT32,
5664         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5665       }
5666     },
5667     { &hf_reload_diagnosticinfo_ewma_bytes_rcvd,
5668       { "ewma_bytes_rcvd (uint32)",  "reload.diagnostic.info.ewma_bytes_rcvd",  FT_UINT32,
5669         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5670       }
5671     },
5672     { &hf_reload_diagnosticinfo_underlay_hops,
5673       { "underlay_hops (uint8)",  "reload.diagnostic.info.underlay_hops",  FT_UINT8,
5674         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5675       }
5676     },
5677     { &hf_reload_diagnosticinfo_battery_status,
5678       { "battery_status (uint8)",  "reload.diagnostic.info.battery_status",  FT_UINT8,
5679         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5680       }
5681     },
5682     { &hf_reload_diagnosticresponse_timestampreceived, {
5683         "timestampReceived (uint64)", "reload.diagnosticresponse.timestampreceived",FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
5684         NULL, 0x0, NULL, HFILL
5685       }
5686     },
5687     { &hf_reload_diagnosticresponse_hopcounter,
5688       { "hopCounter (uint8)",  "reload.diagnosticresponse.hopcounter",  FT_UINT8,
5689         BASE_DEC,  NULL, 0x0,  NULL, HFILL
5690       }
5691     },
5692     { &hf_reload_diagnosticresponse_diagnostic_info_list,
5693       { "diagnostic_info_list",  "reload.diagnosticresponse.diagnostic_info_list",  FT_NONE,
5694         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5695       }
5696     },
5697     { &hf_reload_pathtrackans,
5698       { "PathTrackAns",  "reload.pathtrackans",  FT_NONE,
5699         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5700       }
5701     },
5702     { &hf_reload_pathtrackans_next_hop,
5703       { "next_hop",  "reload.pathtrackans.next_hop",  FT_NONE,
5704         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5705       }
5706     },
5707     { &hf_reload_pathtrackans_response,
5708       { "response (DiagnosticResponse)",  "reload.pathtrackand.response",  FT_NONE,
5709         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5710       }
5711     },
5712     { &hf_reload_extensiveroutingmodeoption,
5713       { "ExtensiveRoutingModeOption",  "reload.extensiveroutingmodeoption",  FT_NONE,
5714         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5715       }
5716     },
5717     { &hf_reload_routemode,
5718       { "routemode (RouteMode)", "reload.routemode", FT_UINT8,
5719         BASE_DEC, VALS(routemodes),  0x0,  NULL, HFILL
5720       }
5721     },
5722     { &hf_reload_extensiveroutingmode_transport,
5723       { "transport (OverlayLinkType)",  "reload.extensiveroutingmode.transport",  FT_UINT8,
5724         BASE_DEC, VALS(overlaylinktypes), 0x0,  NULL, HFILL
5725       }
5726     },
5727     { &hf_reload_extensiveroutingmode_ipaddressport,
5728       { "ipaddressport (IpAddressPort)",  "reload.extensiveroutingmode.ipaddressport",  FT_NONE,
5729         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5730       }
5731     },
5732     { &hf_reload_extensiveroutingmode_destination,
5733       { "destination",  "reload.extensiveroutingmode.destination",  FT_NONE,
5734         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5735       }
5736     },
5737     { &hf_reload_joinreq,
5738       { "JoinReq",  "reload.joinreq",  FT_NONE,
5739         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5740       }
5741     },
5742     { &hf_reload_joinans,
5743       { "JoinAns",  "reload.joinans",  FT_NONE,
5744         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5745       }
5746     },
5747     { &hf_reload_joinreq_joining_peer_id,
5748       { "joining_peer_id (NodeId)",  "reload.joinreq.joining_peer_id",  FT_BYTES,
5749         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5750       }
5751     },
5752     { &hf_reload_leavereq,
5753       { "LeaveReq",  "reload.leavereq",  FT_NONE,
5754         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5755       }
5756     },
5757     { &hf_reload_leavereq_leaving_peer_id,
5758       { "leaving_peer_id (NodeId)",  "reload.leavereq.leaving_peer_id",  FT_BYTES,
5759         BASE_NONE,  NULL, 0x0,  NULL, HFILL
5760       }
5761     },
5762
5763   };
5764
5765   /* Setup protocol subtree array */
5766   static gint *ett[] = {
5767     &ett_reload,
5768     &ett_reload_forwarding,
5769     &ett_reload_message,
5770     &ett_reload_security,
5771     &ett_reload_fragment_flag,
5772     &ett_reload_destination,
5773     &ett_reload_via_list,
5774     &ett_reload_destination_list,
5775     &ett_reload_resourceid,
5776     &ett_reload_forwarding_options,
5777     &ett_reload_forwarding_option,
5778     &ett_reload_forwarding_option_flags,
5779     &ett_reload_forwarding_option_directresponseforwarding,
5780     &ett_reload_attachreqans,
5781     &ett_reload_icecandidates,
5782     &ett_reload_icecandidate,
5783     &ett_reload_icecandidate_computed_address,
5784     &ett_reload_iceextensions,
5785     &ett_reload_iceextension,
5786     &ett_reload_ipaddressport,
5787     &ett_reload_ipv4addrport,
5788     &ett_reload_ipv6addrport,
5789     &ett_reload_message_contents,
5790     &ett_reload_message_extensions,
5791     &ett_reload_message_extension,
5792     &ett_reload_error_response,
5793     &ett_reload_security_block,
5794     &ett_reload_certificates,
5795     &ett_reload_genericcertificate,
5796     &ett_reload_signature,
5797     &ett_reload_signatureandhashalgorithm,
5798     &ett_reload_signeridentity,
5799     &ett_reload_signeridentity_identity,
5800     &ett_reload_signeridentity_value,
5801     &ett_reload_opaque,
5802     &ett_reload_message_body,
5803     &ett_reload_routequeryreq,
5804     &ett_reload_probereq,
5805     &ett_reload_probereq_requested_info,
5806     &ett_reload_probe_information,
5807     &ett_reload_probe_information_data,
5808     &ett_reload_probeans,
5809     &ett_reload_probeans_probe_info,
5810     &ett_reload_appattach,
5811     &ett_reload_pingreq,
5812     &ett_reload_pingans,
5813     &ett_reload_storeddata,
5814     &ett_reload_kinddata,
5815     &ett_reload_values,
5816     &ett_reload_datavalue,
5817     &ett_reload_arrayentry,
5818     &ett_reload_dictionaryentry,
5819     &ett_reload_storereq,
5820     &ett_reload_store_kind_data,
5821     &ett_reload_storeans,
5822     &ett_reload_storeans_kind_responses,
5823     &ett_reload_storekindresponse,
5824     &ett_reload_fetchans,
5825     &ett_reload_fetchreq,
5826     &ett_reload_fetchreq_specifiers,
5827     &ett_reload_storeddataspecifier,
5828     &ett_reload_storeddataspecifier_indices,
5829     &ett_reload_storeddataspecifier_keys,
5830     &ett_reload_statans,
5831     &ett_reload_findans,
5832     &ett_reload_findkinddata,
5833     &ett_reload_fragments,
5834     &ett_reload_fragment,
5835     &ett_reload_configupdatereq,
5836     &ett_reload_configupdatereq_config_data,
5837     &ett_reload_kinddescription,
5838     &ett_reload_configupdatereq_kinds,
5839     &ett_reload_storekindresponse_replicas,
5840     &ett_reload_nodeid_list,
5841     &ett_reload_chordupdate,
5842     &ett_reload_chordroutequeryans,
5843     &ett_reload_chordleave,
5844     &ett_reload_turnserver,
5845     &ett_reload_sipregistration,
5846     &ett_reload_sipregistration_data,
5847     &ett_reload_sipregistration_destination_list,
5848     &ett_reload_dictionaryentry_key,
5849     &ett_reload_overlay_specific,
5850     &ett_reload_kindid_list,
5851     &ett_reload_redirserviceproviderdata,
5852     &ett_reload_redirserviceprovider,
5853     &ett_reload_self_tuning_data,
5854     &ett_reload_findreq,
5855     &ett_reload_dmflags,
5856     &ett_reload_diagnosticextension,
5857     &ett_reload_diagnosticrequest,
5858     &ett_reload_diagnosticrequest_extensions,
5859     &ett_reload_pathtrackreq,
5860     &ett_reload_diagnosticinfo,
5861     &ett_reload_diagnosticinfo_instances_stored,
5862     &ett_reload_diagnosticinfo_instancesstored_info,
5863     &ett_reload_diagnosticinfo_messages_sent_rcvd,
5864     &ett_reload_diagnosticinfo_messages_sent_rcvd_info,
5865     &ett_reload_diagnosticresponse,
5866     &ett_reload_diagnosticresponse_diagnostic_info_list,
5867     &ett_reload_pathtrackans,
5868     &ett_reload_extensiveroutingmodeoption,
5869     &ett_reload_extensiveroutingmode_destination,
5870     &ett_reload_joinreq,
5871     &ett_reload_joinans,
5872     &ett_reload_leavereq,
5873   };
5874
5875   static ei_register_info ei[] = {
5876      { &ei_reload_truncated_field, { "reload.truncated_field", PI_PROTOCOL, PI_ERROR, "Truncated field", EXPFILL }},
5877      { &ei_reload_truncated_packet, { "reload.truncated_packet", PI_PROTOCOL, PI_ERROR, "Truncated RELOAD packet", EXPFILL }},
5878      { &ei_reload_computed_len_too_big, { "reload.computed_len_too_big", PI_PROTOCOL, PI_ERROR, "Computed length > max_field length", EXPFILL }},
5879      { &ei_reload_identity_type_unknown, { "reload.signature.identity.type.unknown", PI_PROTOCOL, PI_ERROR, "Unknown identity type", EXPFILL }},
5880      { &ei_reload_unknown_data_model, { "reload.unknown_data_model", PI_PROTOCOL, PI_ERROR, "Unknown Data Model", EXPFILL }},
5881      { &ei_reload_no_xml_dissector, { "reload.no_xml_dissector", PI_PROTOCOL, PI_ERROR, "Can not find xml dissector", EXPFILL }},
5882   };
5883
5884   static uat_field_t reloadkindidlist_uats_flds[] = {
5885     UAT_FLD_DEC(kindidlist_uats,id,"Kind-ID Number","Custom Kind-ID Number"),
5886     UAT_FLD_CSTRING(kindidlist_uats,name,"Kind-ID Name","Custom Kind-ID Name"),
5887     UAT_FLD_VS(kindidlist_uats,data_model,"Kind-ID data model",datamodels,"Kind ID data model"),
5888     UAT_END_FIELDS
5889   };
5890
5891
5892   /* Register the protocol name and description */
5893   proto_reload = proto_register_protocol("REsource LOcation And Discovery", "RELOAD", "reload");
5894   register_dissector("reload", dissect_reload_message_no_return, proto_reload);
5895   /* Required function calls to register the header fields and subtrees used */
5896   proto_register_field_array(proto_reload, hf, array_length(hf));
5897   proto_register_subtree_array(ett, array_length(ett));
5898   expert_reload = expert_register_protocol(proto_reload);
5899   expert_register_field_array(expert_reload, ei, array_length(ei));
5900
5901   reload_module = prefs_register_protocol(proto_reload, NULL);
5902
5903   reloadkindids_uat =
5904     uat_new("Kind-ID Table",
5905             sizeof(kind_t),
5906             "reload_kindids",               /* filename */
5907             TRUE,                           /* from_profile */
5908             &kindidlist_uats,               /* data_ptr */
5909             &nreloadkinds,                  /* numitems_ptr */
5910             UAT_AFFECTS_DISSECTION,         /* affects dissection of packets, but not set of named fields */
5911             NULL,                           /* Help section (currently a wiki page) */
5912             uat_kindid_copy_cb,
5913             NULL,
5914             uat_kindid_record_free_cb,
5915             NULL,
5916             reloadkindidlist_uats_flds);
5917
5918
5919   prefs_register_uat_preference(reload_module, "kindid.table",
5920                                 "Kind ID list",
5921                                 "A table of Kind ID definitions",
5922                                 reloadkindids_uat);
5923
5924   prefs_register_bool_preference(reload_module, "defragment",
5925                                  "Reassemble fragmented reload datagrams",
5926                                  "Whether fragmented RELOAD datagrams should be reassembled",
5927                                  &reload_defragment);
5928   prefs_register_uint_preference(reload_module, "nodeid_length",
5929                                  "NodeId Length",
5930                                  "Length of the NodeId as defined in the overlay.",
5931                                  10,
5932                                  &reload_nodeid_length);
5933   prefs_register_string_preference(reload_module, "topology_plugin",
5934                                    "topology plugin", "topology plugin defined in the overlay", &reload_topology_plugin);
5935
5936   register_init_routine(reload_defragment_init);
5937 }
5938
5939 void
5940 proto_reg_handoff_reload(void)
5941 {
5942
5943   data_handle = find_dissector("data");
5944   xml_handle  = find_dissector("xml");
5945
5946   heur_dissector_add("udp", dissect_reload_heur, proto_reload);
5947   heur_dissector_add("tcp", dissect_reload_heur, proto_reload);
5948 }
5949
5950 /*
5951  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
5952  *
5953  * Local variables:
5954  * c-basic-offset: 2
5955  * tab-width: 8
5956  * indent-tabs-mode: nil
5957  * End:
5958  *
5959  * vi: set shiftwidth=2 tabstop=8 expandtab:
5960  * :indentSize=2:tabSize=8:noTabs=true:
5961  */