Coverage Report

Created: 2026-08-14 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-vuze-dht.c
Line
Count
Source
1
/* packet-vuze-dht.c
2
 * Routines for Vuze-DHT dissection
3
 * Copyright 2011, Xiao Xiangquan <xiaoxiangquan@gmail.com>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1999 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
#include <epan/to_str.h>
16
17
16
#define DEFAULT_UDP_PORT 11273 /* Not IANA registered */
18
19
void proto_register_vuze_dht(void);
20
21
/* --- protocol specification:
22
 * http://wiki.vuze.com/w/Distributed_hash_table
23
 */
24
25
/* protocol versions */
26
enum {
27
  PV_DIV_AND_CONT           =  6,
28
  PV_ANTI_SPOOF             =  7,
29
  PV_ANTI_SPOOF2            =  8,
30
  PV_FIX_ORIGINATOR         =  9,
31
  PV_NETWORKS               =  9,
32
  PV_VIVALDI                = 10,
33
  PV_REMOVE_DIST_ADD_VER    = 11,
34
  PV_XFER_STATUS            = 12,
35
  PV_SIZE_ESTIMATE          = 13,
36
  PV_VENDOR_ID              = 14,
37
  PV_BLOCK_KEYS             = 14,
38
  PV_GENERIC_NETPOS         = 15,
39
  PV_VIVALDI_FINDVALUE      = 16,
40
  PV_ANON_VALUES            = 17,
41
  PV_CVS_FIX_OVERLOAD_V1    = 18,
42
  PV_CVS_FIX_OVERLOAD_V2    = 19,
43
  PV_MORE_STATS             = 20,
44
  PV_CVS_FIX_OVERLOAD_V3    = 21,
45
  PV_MORE_NODE_STATUS       = 22,
46
  PV_LONGER_LIFE            = 23,
47
  PV_REPLICATION_CONTROL    = 24,
48
  PV_RESTRICT_ID_PORTS      = 32,
49
  PV_RESTRICT_ID_PORTS2     = 33,
50
  PV_RESTRICT_ID_PORTS2X    = 34,
51
  PV_RESTRICT_ID_PORTS2Y    = 35,
52
  PV_RESTRICT_ID_PORTS2Z    = 36,
53
  PV_RESTRICT_ID3           = 50,
54
  PV_VIVALDI_OPTIONAL       = 51,
55
  PV_PACKET_FLAGS           = 51,
56
  PV_ALT_CONTACTS           = 52,
57
  PV_PACKET_FLAGS2          = 53
58
};
59
60
/* Type Length */
61
enum {
62
  TL_BYTE  =  1,
63
  TL_BOOL  =  1,
64
  TL_SHORT =  2,
65
  TL_INT   =  4,
66
  TL_IPv4  =  4,
67
  TL_FLOAT =  4,
68
  TL_LONG  =  8,
69
  TL_IPv6  = 16
70
};
71
72
/* Bool type */
73
enum {
74
  BT_FALSE = 0x0,
75
  BT_TRUE = 0x1
76
};
77
static const value_string vuze_dht_bool_type_vals[] = {
78
  { BT_FALSE, "False" },
79
  { BT_TRUE, "True" },
80
  { 0, NULL }
81
};
82
83
/* action type */
84
enum {
85
  AT_PING_REQUEST       = 1024,
86
  AT_PING_REPLY         = 1025,
87
  AT_STORE_REQUEST      = 1026,
88
  AT_STORE_REPLY        = 1027,
89
  AT_FIND_NODE_REQUEST  = 1028,
90
  AT_FIND_NODE_REPLY    = 1029,
91
  AT_FIND_VALUE_REQUEST = 1030,
92
  AT_FIND_VALUE_REPLY   = 1031,
93
  AT_ERROR_REPLY        = 1032,
94
  AT_KEY_BLOCK_REQUEST  = 1036,
95
  AT_KEY_BLOCK_REPLY    = 1037
96
};
97
static const value_string vuze_dht_action_type_vals[] = {
98
  { AT_PING_REQUEST,        "PING request" },
99
  { AT_PING_REPLY,          "PING reply" },
100
  { AT_STORE_REQUEST,       "STORE request" },
101
  { AT_STORE_REPLY,         "STORE reply" },
102
  { AT_FIND_NODE_REQUEST,   "FIND_NODE request" },
103
  { AT_FIND_NODE_REPLY,     "FIND_NODE reply" },
104
  { AT_FIND_VALUE_REQUEST,  "FIND_VALUE request" },
105
  { AT_FIND_VALUE_REPLY,    "FIND_VALUE reply" },
106
  { AT_ERROR_REPLY,         "ERROR reply" },
107
  { AT_KEY_BLOCK_REQUEST,   "kEY_BLOCK request" },
108
  { AT_KEY_BLOCK_REPLY,     "KEY_BLOCK reply" },
109
  { 0, NULL }
110
};
111
112
/* Contact type, must be 1(UDP) */
113
enum {
114
  CONTACT_UDP = 1
115
};
116
static const value_string vuze_dht_contact_type_vals[] = {
117
  { CONTACT_UDP, "UDP" },
118
  { 0, NULL }
119
};
120
121
/* Node type */
122
enum {
123
  NT_BOOTSTRAP_NODE = 0x0,
124
  NT_ORDINARY_NODE  = 0x1,
125
  NT_UNKNOWN_NODE   = -1
126
};
127
static const value_string vuze_dht_node_type_vals[] = {
128
  { NT_BOOTSTRAP_NODE, "Bootstrap node" },
129
  { NT_ORDINARY_NODE,  "Ordinary node" },
130
  { NT_UNKNOWN_NODE,   "Unknown node" },
131
  { 0, NULL }
132
};
133
134
/* flag type */
135
enum {
136
    FT_SINGLE_VALUE = 0x00,
137
    FT_DOWNLOADING  = 0x01,
138
    FT_SEEDING      = 0x02,
139
    FT_MULTI_VALUE  = 0x04,
140
    FT_STATS        = 0x08,
141
    FLAG_ANON       = 0x10,
142
    FLAG_PRECIOUS   = 0x20
143
};
144
static const value_string vuze_dht_flag_type_vals[] = {
145
  { FT_SINGLE_VALUE, "Single value" },
146
  { FT_DOWNLOADING,  "Downloading" },
147
  { FT_SEEDING,      "Seeding" },
148
  { FT_MULTI_VALUE,  "Multi value" },
149
  { FT_STATS,        "Stats" },
150
  { FLAG_ANON,       "Anon" },
151
  { FLAG_PRECIOUS,   "Precious" },
152
  { 0, NULL }
153
};
154
155
/* generic flag type */
156
enum {
157
  GF_NONE         = 0x00,
158
  GF_DHT_SLEEPING = 0x01
159
};
160
static const value_string vuze_dht_generic_flag_type_vals[] = {
161
  { GF_NONE, "None"},
162
  { GF_DHT_SLEEPING, "DHT sleeping" },
163
  {0, NULL}
164
};
165
166
/* error type */
167
enum {
168
  ET_WRONG_ADDRESS  = 1,
169
  ET_KEY_BLOCKED    = 2
170
};
171
static const value_string vuze_dht_error_type_vals[] = {
172
  { ET_WRONG_ADDRESS, "Originator's address stored in the request is incorrect" },
173
  { ET_KEY_BLOCKED,   "The requested key has been blocked" },
174
  { 0, NULL }
175
};
176
177
/* network coordinate type */
178
enum {
179
  NC_VIVALDI = 1
180
};
181
static const value_string vuze_dht_network_coordinate_type_vals[] = {
182
  { NC_VIVALDI, "Vivaldi" },
183
  { 0, NULL }
184
};
185
186
static int proto_vuze_dht;
187
188
/* --- fields ---*/
189
190
/* address appears in contacts, request header, reply error */
191
static int hf_vuze_dht_address;
192
static int hf_vuze_dht_address_len;
193
static int hf_vuze_dht_address_v4;
194
static int hf_vuze_dht_address_v6;
195
static int hf_vuze_dht_address_port;
196
197
/* contact appears in values, reply find_node, reply find_value */
198
static int hf_vuze_dht_contact;
199
static int hf_vuze_dht_contact_type;
200
static int hf_vuze_dht_proto_ver;
201
202
/* value appears in reply find_value */
203
static int hf_vuze_dht_value;
204
static int hf_vuze_dht_value_ver;
205
static int hf_vuze_dht_value_created;
206
static int hf_vuze_dht_value_bytes_count;
207
static int hf_vuze_dht_value_bytes;
208
static int hf_vuze_dht_value_flags;
209
static int hf_vuze_dht_value_life_hours;
210
static int hf_vuze_dht_value_replication_factor;
211
212
/* firstly appear in request header */
213
static int hf_vuze_dht_connection_id;
214
static int hf_vuze_dht_action;
215
static int hf_vuze_dht_transaction_id;
216
static int hf_vuze_dht_vendor_id;
217
static int hf_vuze_dht_network_id;
218
static int hf_vuze_dht_local_proto_ver;
219
static int hf_vuze_dht_instance_id;
220
static int hf_vuze_dht_time;
221
static int hf_vuze_dht_generic_flags;
222
static int hf_vuze_dht_generic_flags2;
223
224
/* firstly appear in reply ping */
225
static int hf_vuze_dht_network_coordinates_count;
226
static int hf_vuze_dht_network_coordinates;
227
static int hf_vuze_dht_network_coordinate;
228
static int hf_vuze_dht_network_coordinate_type;
229
static int hf_vuze_dht_network_coordinate_size;
230
static int hf_vuze_dht_network_coordinate_data;
231
static int hf_vuze_dht_network_coordinate_x;
232
static int hf_vuze_dht_network_coordinate_y;
233
static int hf_vuze_dht_network_coordinate_height;
234
static int hf_vuze_dht_network_coordinate_error;
235
236
/* firstly appear in request store */
237
static int hf_vuze_dht_spoof_id;
238
static int hf_vuze_dht_keys_count;
239
static int hf_vuze_dht_keys;
240
static int hf_vuze_dht_key;
241
static int hf_vuze_dht_key_len;
242
static int hf_vuze_dht_key_data;
243
static int hf_vuze_dht_value_group;
244
static int hf_vuze_dht_value_groups;
245
static int hf_vuze_dht_value_groups_count;
246
static int hf_vuze_dht_values_count;
247
248
/* firstly appear in reply store */
249
static int hf_vuze_dht_diversifications_len;
250
static int hf_vuze_dht_diversifications;
251
252
/* firstly appear in request find_node */
253
static int hf_vuze_dht_id_len;
254
static int hf_vuze_dht_id;
255
static int hf_vuze_dht_node_status;
256
static int hf_vuze_dht_size;
257
258
/* firstly appear in reply find_node */
259
static int hf_vuze_dht_node_type;
260
static int hf_vuze_dht_contacts_count;
261
static int hf_vuze_dht_contacts;
262
263
/* firstly appear in request find_value */
264
static int hf_vuze_dht_flags;
265
static int hf_vuze_dht_values_num;
266
static int hf_vuze_dht_values_total;
267
static int hf_vuze_dht_reads_per_min;
268
static int hf_vuze_dht_diversification_type;
269
static int hf_vuze_dht_max_values;
270
271
/* firstly appear in reply find_value */
272
static int hf_vuze_dht_has_continuation;
273
static int hf_vuze_dht_has_values;
274
275
/* firstly appear in reply error */
276
static int hf_vuze_dht_error_type;
277
static int hf_vuze_dht_key_block_request_len;
278
static int hf_vuze_dht_key_block_request;
279
static int hf_vuze_dht_signature_len;
280
static int hf_vuze_dht_signature;
281
282
/* trees */
283
static int ett_vuze_dht;
284
static int ett_vuze_dht_address;
285
static int ett_vuze_dht_contacts;
286
static int ett_vuze_dht_contact;
287
static int ett_vuze_dht_keys;
288
static int ett_vuze_dht_key;
289
static int ett_vuze_dht_value_groups;
290
static int ett_vuze_dht_value_group;
291
static int ett_vuze_dht_value;
292
static int ett_vuze_dht_network_coordinates;
293
static int ett_vuze_dht_network_coordinate;
294
295
static dissector_handle_t vuze_dht_handle;
296
297
void proto_reg_handoff_vuze_dht(void);
298
299
/* --- Address format --------------
300
301
byte:          indicates length of the IP address (4 for IPv4, 16 for IPv6)
302
4 or 16 bytes: the address in network byte order
303
short:         port number
304
305
*/
306
static int
307
dissect_vuze_dht_address(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset, const char* addr_name)
308
136
{
309
136
  uint8_t ip_length;
310
136
  proto_tree *sub_tree;
311
136
  proto_item *ti;
312
136
  address addr;
313
314
136
  ip_length = tvb_get_uint8(tvb,offset);
315
  /* the decoded length is ip length+3, see the format above */
316
136
  ti = proto_tree_add_none_format(tree, hf_vuze_dht_address, tvb, offset, ip_length+3, "%s: ", addr_name );
317
136
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_address);
318
319
136
  proto_tree_add_item(sub_tree, hf_vuze_dht_address_len, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
320
136
  offset += TL_BYTE;
321
322
136
  switch(ip_length)
323
136
  {
324
1
  case TL_IPv4:
325
1
    proto_tree_add_item(sub_tree, hf_vuze_dht_address_v4, tvb, offset, ip_length, ENC_BIG_ENDIAN);
326
1
    set_address_tvb( &addr, AT_IPv4, ip_length, tvb, offset);
327
1
    break;
328
1
  case TL_IPv6:
329
1
    proto_tree_add_item(sub_tree, hf_vuze_dht_address_v6, tvb, offset, ip_length, ENC_NA);
330
1
    set_address_tvb( &addr, AT_IPv6, ip_length, tvb, offset);
331
1
    break;
332
134
  default:
333
134
    clear_address(&addr);
334
134
    break;
335
136
  }
336
136
  offset += ip_length;
337
338
136
  proto_tree_add_item(sub_tree, hf_vuze_dht_address_port, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN);
339
136
  proto_item_append_text( ti, "%s:%d", address_to_str(pinfo->pool, &addr ), tvb_get_ntohs(tvb,offset) );
340
136
  offset += TL_SHORT;
341
342
136
  return offset;
343
136
}
344
345
/* --- Contact format --------------
346
347
byte:        indicates contact type, which must be UDP(1)
348
byte:        the contact's protocol version
349
7 or 19 bytes: Address
350
351
*/
352
static int
353
dissect_vuze_dht_contact(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
354
109
{
355
109
  proto_item *ti;
356
109
  proto_tree *sub_tree;
357
358
  /* the decoded length is ip length+5, see the format above */
359
109
  ti = proto_tree_add_none_format( tree, hf_vuze_dht_contact, tvb, offset, tvb_get_uint8(tvb,offset+2)+5,
360
109
      "%s contact, version %d",
361
109
      val_to_str_const( tvb_get_uint8(tvb, offset), vuze_dht_contact_type_vals, "Unknown"),
362
109
      tvb_get_uint8(tvb, offset+1) );
363
109
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_contact);
364
365
109
  proto_tree_add_item(sub_tree, hf_vuze_dht_contact_type, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
366
109
  offset += TL_BYTE;
367
109
  proto_tree_add_item(sub_tree, hf_vuze_dht_proto_ver, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
368
109
  offset += TL_BYTE;
369
109
  offset = dissect_vuze_dht_address( tvb, pinfo, sub_tree, offset, "Contact Address" );
370
371
109
  return offset;
372
109
}
373
374
/* --- Contact List --- */
375
static int
376
dissect_vuze_dht_contacts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int contacts_count)
377
21
{
378
21
  proto_item *ti;
379
21
  proto_tree *sub_tree;
380
21
  int i;
381
382
21
  ti = proto_tree_add_none_format( tree, hf_vuze_dht_contacts, tvb, offset, 0, "%d contacts", contacts_count );
383
21
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_contacts);
384
127
  for( i=0; i<contacts_count; i++ )
385
106
    offset = dissect_vuze_dht_contact( tvb, pinfo, sub_tree, offset );
386
387
21
  return offset;
388
21
}
389
390
/* --- Key format
391
 Name               | Type
392
 LENGTH               byte
393
 KEY                  byte[LENGTH]
394
 --- */
395
static int
396
dissect_vuze_dht_key(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset)
397
0
{
398
0
  proto_item *ti;
399
0
  proto_tree *sub_tree;
400
0
  unsigned key_len;
401
402
0
  key_len = tvb_get_uint8( tvb, offset );
403
0
  ti = proto_tree_add_item( tree, hf_vuze_dht_key, tvb, offset, key_len+1, ENC_NA );
404
0
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_key);
405
406
0
  proto_tree_add_item( sub_tree, hf_vuze_dht_key_len, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN );
407
0
  offset += TL_BYTE;
408
409
0
  proto_tree_add_item( sub_tree, hf_vuze_dht_key_data, tvb, offset, key_len, ENC_NA );
410
0
  proto_item_append_text( ti, ": %d bytes ( %s )", key_len, tvb_bytes_to_str(pinfo->pool, tvb, offset, key_len ) );
411
0
  offset += key_len;
412
413
0
  return offset;
414
0
}
415
416
/* --- Keys List --- */
417
static int
418
dissect_vuze_dht_keys(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int keys_count)
419
0
{
420
0
  proto_item *ti;
421
0
  proto_tree *sub_tree;
422
0
  int i;
423
424
0
  ti = proto_tree_add_none_format( tree, hf_vuze_dht_keys, tvb, offset, 0, "%d keys", keys_count );
425
0
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_keys);
426
0
  for( i=0; i<keys_count; i++ )
427
0
    offset = dissect_vuze_dht_key( tvb, pinfo, sub_tree, offset );
428
429
0
  return offset;
430
0
}
431
432
/* --- Value format --------------
433
434
Name             | Type  | Protocol version    | Note
435
VERSION            byte    >=REMOVE_DIST_ADD_VER  Version of the value. (details later)
436
CREATED            long    always                Creation time. Units unknown; probably milliseconds since the epoch.
437
VALUE_BYTES_COUNT  short   always                Number of bytes in the value.
438
VALUE_BYTES        bytes   always                The bytes of the value.
439
ORIGINATOR         contact always                presumably the node that created the value.
440
FLAGS              byte    always
441
LIFE_HOURS         byte    >=LONGER_LIFE          Hours for the value to live. (Details of how it's handled)
442
REPLICATION_FACTOR byte    >=REPLICATION_CONTROL  Per-value # of replicas to maintain.
443
444
If STATS are used in request, then some stats for the value are returned instead of value itself.
445
They are serialised as follows:
446
  0 (byte) - version,
447
  number of stored values for the key (int),
448
  total size of stored values (int),
449
  reads per minute (int),
450
  diversification type (byte).
451
*/
452
static int
453
dissect_vuze_dht_value(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset, int ver )
454
6
{
455
6
  proto_item *ti;
456
6
  proto_tree *sub_tree;
457
6
  unsigned value_ver = -1;
458
459
6
  ti = proto_tree_add_item( tree, hf_vuze_dht_value, tvb, offset, 0, ENC_NA );
460
6
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_value);
461
6
  if( ver >= PV_REMOVE_DIST_ADD_VER )
462
6
  {
463
6
    proto_tree_add_item_ret_uint(sub_tree, hf_vuze_dht_value_ver, tvb, offset, TL_INT, ENC_BIG_ENDIAN, &value_ver);
464
6
    offset += TL_INT;
465
6
  }
466
  /* It's a return for STATS */
467
6
  if( value_ver==0 )
468
0
  {
469
0
    proto_item_append_text( ti,
470
0
                            " (reply to STATS): %d values for the key, out of %d in total...",
471
0
                            tvb_get_ntohl(tvb, offset), tvb_get_ntohl(tvb, offset+TL_INT) );
472
473
0
    proto_tree_add_item(tree, hf_vuze_dht_values_num, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
474
0
    offset += TL_INT;
475
0
    proto_tree_add_item(tree, hf_vuze_dht_values_total, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
476
0
    offset += TL_INT;
477
0
    proto_tree_add_item(tree, hf_vuze_dht_reads_per_min, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
478
0
    offset += TL_INT;
479
0
    proto_tree_add_item(tree, hf_vuze_dht_diversification_type, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
480
0
    offset += TL_BYTE;
481
0
  }
482
  /* regular value */
483
6
  else
484
6
  {
485
6
    uint16_t value_bytes_count;
486
487
6
    proto_tree_add_item(sub_tree, hf_vuze_dht_value_created, tvb, offset, TL_LONG, ENC_BIG_ENDIAN);
488
6
    offset += TL_LONG;
489
490
6
    proto_tree_add_item_ret_uint16(sub_tree, hf_vuze_dht_value_bytes_count, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN, &value_bytes_count);
491
6
    offset += TL_SHORT;
492
493
6
    proto_tree_add_item(sub_tree, hf_vuze_dht_value_bytes, tvb, offset, value_bytes_count, ENC_NA);
494
6
    proto_item_append_text( ti, ": %d bytes ( %s )", value_bytes_count, tvb_bytes_to_str(pinfo->pool, tvb, offset, value_bytes_count ) );
495
6
    offset += value_bytes_count;
496
497
6
    offset = dissect_vuze_dht_contact( tvb, pinfo, sub_tree, offset );
498
499
6
    proto_tree_add_item(sub_tree, hf_vuze_dht_value_flags, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
500
6
    offset += TL_BYTE;
501
6
    proto_tree_add_item(sub_tree, hf_vuze_dht_value_life_hours, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
502
6
    offset += TL_BYTE;
503
6
    proto_tree_add_item(sub_tree, hf_vuze_dht_value_replication_factor, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
504
6
    offset += TL_BYTE;
505
6
  }
506
507
6
  return offset;
508
6
}
509
510
/* --- Values format
511
values_count        short
512
values              value[values_count]
513
 --- */
514
static int
515
dissect_vuze_dht_value_group(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver)
516
4
{
517
4
  proto_item *ti;
518
4
  proto_tree *sub_tree;
519
4
  int values_count;
520
4
  int i;
521
522
4
  values_count = tvb_get_ntohs( tvb, offset );
523
524
4
  ti = proto_tree_add_none_format( tree, hf_vuze_dht_value_group, tvb, offset, 0, "%d values", values_count );
525
4
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_value_group);
526
527
4
  proto_tree_add_item( sub_tree, hf_vuze_dht_values_count, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN );
528
4
  offset += TL_SHORT;
529
530
10
  for( i=0; i<values_count; i++ )
531
6
    offset = dissect_vuze_dht_value( tvb, pinfo, sub_tree, offset, ver );
532
533
4
  return offset;
534
4
}
535
536
/* --- Values Groups format
537
value_group[value_groups_count]
538
 --- */
539
static int
540
dissect_vuze_dht_value_groups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int value_groups_count, int ver)
541
0
{
542
0
  proto_item *ti;
543
0
  proto_tree *sub_tree;
544
0
  int i;
545
546
0
  ti = proto_tree_add_none_format( tree, hf_vuze_dht_value_groups, tvb, offset, 0, "%d value groups", value_groups_count );
547
0
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_value_groups);
548
0
  for( i=0; i<value_groups_count; i++ )
549
0
    offset = dissect_vuze_dht_value_group( tvb, pinfo, sub_tree, offset, ver );
550
551
0
  return offset;
552
0
}
553
554
/* --- Network Coordinates format ------
555
Name               | Type
556
TYPE                 byte
557
SIZE                 byte
558
Network Coordinates  byte[SIZE]
559
 */
560
static int
561
dissect_vuze_dht_network_coordinate(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset)
562
77
{
563
77
  proto_item *ti;
564
77
  proto_tree *sub_tree;
565
77
  unsigned coordinate_size;
566
77
  unsigned coordinate_type;
567
568
77
  coordinate_type = tvb_get_uint8( tvb, offset );
569
77
  coordinate_size = tvb_get_uint8( tvb, offset+1 );
570
571
77
  ti = proto_tree_add_item( tree, hf_vuze_dht_network_coordinate, tvb, offset, coordinate_size+2, ENC_NA );
572
77
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_network_coordinate);
573
574
77
  proto_item_append_text( ti, ": type %d, length %d", tvb_get_uint8(tvb,offset), tvb_get_uint8(tvb,offset+TL_BYTE) );
575
576
77
  if (coordinate_type == NC_VIVALDI) {
577
6
    proto_item_append_text( ti, " ( %.2f, %.2f, %.2f, %.2f )",
578
6
        tvb_get_ntohieee_float(tvb, offset+TL_BYTE+TL_BYTE),
579
6
        tvb_get_ntohieee_float(tvb, offset+TL_BYTE+TL_BYTE+TL_FLOAT),
580
6
        tvb_get_ntohieee_float(tvb, offset+TL_BYTE+TL_BYTE+TL_FLOAT+TL_FLOAT),
581
6
        tvb_get_ntohieee_float(tvb, offset+TL_BYTE+TL_BYTE+TL_FLOAT+TL_FLOAT+TL_FLOAT) );
582
71
  } else {
583
71
    proto_item_append_text( ti, " ( %s )",
584
71
        tvb_bytes_to_str(pinfo->pool, tvb, offset+TL_BYTE+TL_BYTE, coordinate_size ) );
585
71
  }
586
587
77
  proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_type, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN );
588
77
  offset += TL_BYTE;
589
77
  proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_size, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN );
590
77
  offset += TL_BYTE;
591
592
77
  if (coordinate_type == NC_VIVALDI) {
593
6
      proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_x, tvb, offset, TL_FLOAT, ENC_BIG_ENDIAN );
594
6
      offset += TL_FLOAT;
595
6
      proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_y, tvb, offset, TL_FLOAT, ENC_BIG_ENDIAN );
596
6
      offset += TL_FLOAT;
597
6
      proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_height, tvb, offset, TL_FLOAT, ENC_BIG_ENDIAN );
598
6
      offset += TL_FLOAT;
599
6
      proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_error, tvb, offset, TL_FLOAT, ENC_BIG_ENDIAN );
600
6
      offset += TL_FLOAT;
601
71
  } else {
602
71
    proto_tree_add_item( sub_tree, hf_vuze_dht_network_coordinate_data, tvb, offset, coordinate_size, ENC_NA );
603
71
    offset += coordinate_size;
604
71
  }
605
606
77
  return offset;
607
77
}
608
609
/* --- Network Coordinates List ---
610
Name                     | Type              | Protocol version
611
Network Coordinates Count  byte                >=PV_GENERIC_NETPOS
612
Network Coordinates        Network Coordinate  >=PV_GENERIC_NETPOS
613
 */
614
static int
615
dissect_vuze_dht_network_coordinates(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver)
616
11
{
617
11
  proto_item *ti;
618
11
  proto_tree *sub_tree;
619
11
  unsigned i;
620
11
  unsigned network_coordinates_count;
621
622
11
  if( ver >= PV_GENERIC_NETPOS )
623
11
  {
624
11
    proto_tree_add_item_ret_uint(tree, hf_vuze_dht_network_coordinates_count, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &network_coordinates_count);
625
11
    offset += TL_BYTE;
626
627
11
    ti = proto_tree_add_none_format( tree, hf_vuze_dht_network_coordinates, tvb, offset, 0, "%d network coordinates", network_coordinates_count );
628
11
    sub_tree = proto_item_add_subtree(ti, ett_vuze_dht_network_coordinates);
629
88
    for( i=0; i<network_coordinates_count; i++ )
630
77
      offset = dissect_vuze_dht_network_coordinate( tvb, pinfo, sub_tree, offset );
631
11
  }
632
11
  return offset;
633
11
}
634
635
/* ---  Request Header format --------------
636
637
Name                  | Type  | Protocol version | Note
638
CONNECTION_ID           long    always             random number with most significant bit set to 1
639
ACTION                  int     always             type of the packet
640
TRANSACTION_ID          int     always             unique number used through the communication; it is randomly generated
641
                                                   at the start of the application and increased by 1 with each sent packet
642
PROTOCOL_VERSION        byte    always             version of protocol used in this packet
643
VENDOR_ID               byte    >=VENDOR_ID         ID of the DHT implementor; 0 = Azureus, 1 = ShareNet, 255 = unknown
644
NETWORK_ID              int     >=NETWORKS          ID of the network; 0 = stable version; 1 = CVS version
645
LOCAL_PROTOCOL_VERSION  byte    >=FIX_ORIGINATOR    maximum protocol version this node supports; if this packet's protocol
646
                                                   version is <FIX_ORIGINATOR then the value is stored at the end of the packet
647
NODE_ADDRESS            address always             address of the local node
648
INSTANCE_ID             int     always             application's helper number; randomly generated at the start
649
TIME                    long    always             time of the local node; stored as number of milliseconds since Epoch
650
FLAG                    byte    >=PACKET_FLAGS
651
FLAG2                   byte    >=PACKET_FLAGS2
652
653
*/
654
static int
655
dissect_vuze_dht_request_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int *action, int *ver )
656
30
{
657
30
  proto_tree_add_item(tree, hf_vuze_dht_connection_id, tvb, offset, TL_LONG, ENC_BIG_ENDIAN);
658
30
  offset += TL_LONG;
659
660
30
  proto_tree_add_item(tree, hf_vuze_dht_action, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
661
30
  *action = tvb_get_ntohl(tvb, offset);
662
30
  col_append_fstr(pinfo->cinfo, COL_INFO, " Action: %s", val_to_str_const( *action, vuze_dht_action_type_vals, "Unknown") );
663
30
  offset += TL_INT;
664
665
30
  proto_tree_add_item(tree, hf_vuze_dht_transaction_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
666
30
  offset += TL_INT;
667
668
30
  proto_tree_add_item(tree, hf_vuze_dht_proto_ver, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
669
30
  *ver = tvb_get_uint8( tvb, offset );
670
30
  offset += TL_BYTE;
671
672
30
  if( *ver >= PV_VENDOR_ID )
673
17
  {
674
17
    proto_tree_add_item(tree, hf_vuze_dht_vendor_id, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
675
17
    offset += TL_BYTE;
676
17
  }
677
678
30
  if( *ver >= PV_NETWORKS )
679
23
  {
680
23
    proto_tree_add_item(tree, hf_vuze_dht_network_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
681
23
    offset += TL_INT;
682
23
  }
683
30
  if( *ver >= PV_FIX_ORIGINATOR )
684
22
  {
685
22
    proto_tree_add_item(tree, hf_vuze_dht_local_proto_ver, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
686
22
    offset += TL_BYTE;
687
22
  }
688
689
30
  offset = dissect_vuze_dht_address(tvb, pinfo, tree, offset, "Local Address");
690
30
  proto_tree_add_item(tree, hf_vuze_dht_instance_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
691
30
  offset += TL_INT;
692
30
  proto_tree_add_item(tree, hf_vuze_dht_time, tvb, offset, TL_LONG, ENC_BIG_ENDIAN);
693
30
  offset += TL_LONG;
694
695
30
  if( *ver >= PV_PACKET_FLAGS )
696
13
  {
697
13
    proto_tree_add_item(tree, hf_vuze_dht_generic_flags, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
698
13
    offset += TL_BYTE;
699
13
  }
700
30
  if( *ver >= PV_PACKET_FLAGS2 )
701
13
  {
702
13
    proto_tree_add_item(tree, hf_vuze_dht_generic_flags2, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
703
13
    offset += TL_BYTE;
704
13
  }
705
706
30
  return offset;
707
30
}
708
709
/* ---  Reply Header format --------------
710
711
Name           | Type | Protocol version | Note
712
ACTION           int    always             type of the packet
713
TRANSACTION_ID   int    always             must be equal to TRANSACTION_ID from the request
714
CONNECTION_ID    long   always             must be equal to CONNECTION_ID from the request
715
PROTOCOL_VERSION byte   always             version of protocol used in this packet
716
VENDOR_ID        byte   >=VENDOR_ID         same meaning as in the request
717
NETWORK_ID       int    >=NETWORKS          same meaning as in the request
718
INSTANCE_ID      int    always             instance id of the node that replies to the request
719
FLAG             byte   >=PACKET_FLAGS
720
FLAG2            byte   >=PACKET_FLAGS2
721
722
*/
723
static int
724
dissect_vuze_dht_reply_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int *action, int *ver )
725
6
{
726
6
  proto_tree_add_item(tree, hf_vuze_dht_action, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
727
6
  *action = tvb_get_ntohl(tvb, offset);
728
6
  col_append_fstr(pinfo->cinfo, COL_INFO, " Action: %s", val_to_str_const( *action, vuze_dht_action_type_vals, "Unknown") );
729
6
  offset += TL_INT;
730
731
6
  proto_tree_add_item(tree, hf_vuze_dht_transaction_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
732
6
  offset += TL_INT;
733
734
6
  proto_tree_add_item(tree, hf_vuze_dht_connection_id, tvb, offset, TL_LONG, ENC_BIG_ENDIAN);
735
6
  offset += TL_LONG;
736
737
6
  proto_tree_add_item(tree, hf_vuze_dht_proto_ver, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
738
6
  *ver = tvb_get_uint8( tvb, offset );
739
6
  offset += TL_BYTE;
740
741
6
  if( *ver >= PV_VENDOR_ID )
742
2
  {
743
2
    proto_tree_add_item(tree, hf_vuze_dht_vendor_id, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
744
2
    offset += TL_BYTE;
745
2
  }
746
747
6
  if( *ver >= PV_NETWORKS )
748
3
  {
749
3
    proto_tree_add_item(tree, hf_vuze_dht_network_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
750
3
    offset += TL_INT;
751
3
  }
752
753
6
  proto_tree_add_item(tree, hf_vuze_dht_instance_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
754
6
  offset += TL_INT;
755
756
6
  if( *ver >= PV_PACKET_FLAGS )
757
1
  {
758
1
    proto_tree_add_item(tree, hf_vuze_dht_generic_flags, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
759
1
    offset += TL_BYTE;
760
1
  }
761
6
  if( *ver >= PV_PACKET_FLAGS2 )
762
1
  {
763
1
    proto_tree_add_item(tree, hf_vuze_dht_generic_flags2, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
764
1
    offset += TL_BYTE;
765
1
  }
766
767
6
  return offset;
768
6
}
769
770
/* --- Reply Ping -----------------
771
772
ACTION equal to 1025
773
If protocol version is >=VIVALDI then packet's body carries network coordinates.
774
775
*/
776
static int
777
dissect_vuze_dht_reply_ping(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver )
778
1
{
779
1
  if( ver >= PV_VIVALDI )
780
1
  {
781
1
    offset = dissect_vuze_dht_network_coordinates( tvb, pinfo, tree, offset, ver );
782
1
  }
783
1
  return offset;
784
1
}
785
786
/* --- Request Store -----------------
787
788
Name             | Type       | Protocol version | Note
789
SPOOF_ID           int          >=ANTI_SPOOF       Spoof ID of the target node; it must be the same number as previously retrieved through FIND_NODE reply.
790
KEYS_COUNT         byte         always             Number of keys that follow.
791
KEYS               keys         always             Keys that the target node should store.
792
VALUE_GROUPS_COUNT byte         always             Number of groups of values this packet contains.
793
VALUES             value groups always             Groups of values, one for each key; values are stored in the same order as keys.
794
795
*/
796
static int
797
dissect_vuze_dht_request_store(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver )
798
0
{
799
0
  uint8_t keys_count, value_groups_count;
800
0
  if( ver >= PV_ANTI_SPOOF )
801
0
  {
802
0
    proto_tree_add_item(tree, hf_vuze_dht_spoof_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
803
0
    offset += TL_INT;
804
0
  }
805
0
  proto_tree_add_item_ret_uint8(tree, hf_vuze_dht_keys_count, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &keys_count);
806
0
  offset += TL_BYTE;
807
808
0
  offset = dissect_vuze_dht_keys( tvb, pinfo, tree, offset, keys_count );
809
810
0
  proto_tree_add_item_ret_uint8(tree, hf_vuze_dht_value_groups_count, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &value_groups_count);
811
0
  offset += TL_BYTE;
812
813
0
  offset = dissect_vuze_dht_value_groups( tvb, pinfo, tree, offset, value_groups_count, ver );
814
815
0
  return offset;
816
0
}
817
818
/* --- Reply Store -----------------
819
820
Name                  | Type | Protocol version | Note
821
DIVERSIFICATIONS_LENGTH byte   >=DIV_AND_CONT      Number of diversifications this packet contains.
822
DIVERSIFICATIONS        byte[] >=DIV_AND_CONT      Array with diversifications;
823
                                                  they are stored in the same order as keys and values from the request.
824
*/
825
static int
826
dissect_vuze_dht_reply_store(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset, int ver )
827
0
{
828
0
  if( ver >= PV_DIV_AND_CONT )
829
0
  {
830
0
    unsigned diversifications_len;
831
0
    proto_tree_add_item_ret_uint(tree, hf_vuze_dht_diversifications_len, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &diversifications_len);
832
0
    offset += TL_BYTE;
833
834
0
    proto_tree_add_item(tree, hf_vuze_dht_diversifications, tvb, offset, diversifications_len, ENC_NA);
835
0
    offset += diversifications_len;
836
0
  }
837
838
0
  return offset;
839
0
}
840
841
/* --- Request Find node -----------------
842
843
Name      | Type | Protocol version | Note
844
ID_LENGTH   byte   always             Length of the following ID.
845
ID          byte[] always             ID to search
846
NODE_STATUS int    >=MORE_NODE_STATUS  Node status
847
DHT_SIZE    int    >=MORE_NODE_STATUS  Estimated size of the DHT; Unknown value can be indicated as zero.
848
849
*/
850
static int
851
dissect_vuze_dht_request_find_node(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset, int ver )
852
0
{
853
0
  unsigned id_len;
854
855
0
  proto_tree_add_item_ret_uint(tree, hf_vuze_dht_id_len, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &id_len);
856
0
  offset += TL_BYTE;
857
858
0
  proto_tree_add_item(tree, hf_vuze_dht_id, tvb, offset, id_len, ENC_NA);
859
0
  offset += id_len;
860
861
0
  if( ver >= PV_MORE_NODE_STATUS )
862
0
  {
863
0
    proto_tree_add_item(tree, hf_vuze_dht_node_status, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
864
0
    offset += TL_INT;
865
0
    proto_tree_add_item(tree, hf_vuze_dht_size, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
866
0
    offset += TL_INT;
867
0
  }
868
869
0
  return offset;
870
0
}
871
872
/* --- Reply Find node -----------------
873
874
Name              | Type              | Protocol version | Note
875
SPOOF_ID            int                 >=ANTI_SPOOF        Spoof ID of the requesting node;
876
                                                           it should be constructed from information known about
877
                                                           requesting contact and not easily guessed by others.
878
NODE_TYPE           int                 >=XFER_STATUS       Type of the replying node;
879
                                                           Possible values are 0 for bootstrap node,
880
                                                           1 for ordinary node and ffffffffh for unknown type.
881
DHT_SIZE            int                 >=SIZE_ESTIMATE     Estimated size of the DHT; Unknown value can be indicated as zero.
882
NETWORK_COORDINATES network coordinates >=VIVALDI           Network coordinates of replying node.
883
CONTACTS_COUNT      short               always             Number of carried contacts.
884
CONTACTS            contacts            always             List with contacts.
885
886
*/
887
static int
888
dissect_vuze_dht_reply_find_node(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver )
889
0
{
890
0
  unsigned contacts_count;
891
892
0
  if( ver >= PV_ANTI_SPOOF )
893
0
  {
894
0
    proto_tree_add_item(tree, hf_vuze_dht_spoof_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
895
0
    offset += TL_INT;
896
0
  }
897
0
  if( ver >= PV_XFER_STATUS )
898
0
  {
899
0
    proto_tree_add_item(tree, hf_vuze_dht_node_type, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
900
0
    offset += TL_INT;
901
0
  }
902
0
  if( ver >= PV_SIZE_ESTIMATE )
903
0
  {
904
0
    proto_tree_add_item(tree, hf_vuze_dht_size, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
905
0
    offset += TL_INT;
906
0
  }
907
0
  if( ver >= PV_VIVALDI )
908
0
  {
909
0
    offset = dissect_vuze_dht_network_coordinates( tvb, pinfo, tree, offset, ver );
910
0
  }
911
912
0
  proto_tree_add_item_ret_uint(tree, hf_vuze_dht_contacts_count, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN, &contacts_count);
913
0
  offset += TL_SHORT;
914
915
0
  offset = dissect_vuze_dht_contacts( tvb, pinfo, tree, offset, contacts_count );
916
917
0
  return offset;
918
0
}
919
920
/* --- Request Find value -----------------
921
922
Name     | Type | Note
923
KEY        key    Key for which the values are requested.
924
FLAGS      byte   Flags for the operation, possible values are:
925
                      SINGLE_VALUE = 00h
926
                      DOWNLOADING = 01h
927
                      SEEDING = 02h
928
                      MULTI_VALUE = 04h
929
                      STATS = 08h
930
MAX_VALUES byte   Maximum number of returned values.
931
*/
932
static int
933
dissect_vuze_dht_request_find_value(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver _U_ )
934
0
{
935
0
  offset = dissect_vuze_dht_key( tvb, pinfo, tree, offset );
936
0
  proto_tree_add_item(tree, hf_vuze_dht_flags, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
937
0
  offset += TL_BYTE;
938
0
  proto_tree_add_item(tree, hf_vuze_dht_max_values, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
939
0
  offset += TL_BYTE;
940
941
0
  return offset;
942
0
}
943
944
/* --- Reply Find value -----------------
945
946
Name               | Type              | Condition                     | Note
947
HAS_CONTINUATION     boolean             protocol version >=DIV_AND_CONT  Indicates whether there is at least one other packet with values.
948
HAS_VALUES           boolean             always                          Indicates whether this packet carries values or contacts.
949
CONTACTS_COUNT       short               HAS_VALUES == false             Number of stored contacts.
950
CONTACTS             contacts            HAS_VALUES == false             Stored contacts that are close to the searched key.
951
NETWORK_COORDINATES  network coordinates HAS_VALUES == false             Network coordinates of the replying node.
952
                                         && protocol version >=VIVALDI_FINDVALUE
953
DIVERSIFICATION_TYPE byte                HAS_VALUES == true              Type of key's diversification.
954
                                         && protocol version >=DIV_AND_CONT
955
VALUES               value group         HAS_VALUES == true              Values that match searched key.
956
957
*/
958
static int
959
dissect_vuze_dht_reply_find_value(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver )
960
22
{
961
22
  uint8_t has_values;
962
22
  unsigned contacts_count;
963
22
  if( ver >= PV_DIV_AND_CONT )
964
18
  {
965
18
    proto_tree_add_item(tree, hf_vuze_dht_has_continuation, tvb, offset, TL_BOOL, ENC_BIG_ENDIAN);
966
18
    offset += TL_BOOL;
967
18
  }
968
22
  proto_tree_add_item_ret_uint8(tree, hf_vuze_dht_has_values, tvb, offset, TL_BOOL, ENC_BIG_ENDIAN, &has_values);
969
22
  offset += TL_BOOL;
970
971
22
  if( has_values )
972
21
  {
973
21
    proto_tree_add_item_ret_uint(tree, hf_vuze_dht_contacts_count, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN, &contacts_count);
974
21
    offset += TL_SHORT;
975
21
    offset = dissect_vuze_dht_contacts( tvb, pinfo, tree, offset, contacts_count  );
976
977
21
    if( ver >= PV_VIVALDI_FINDVALUE )
978
10
    {
979
10
      offset = dissect_vuze_dht_network_coordinates( tvb, pinfo, tree, offset, ver );
980
10
    }
981
21
    if( ver >= PV_DIV_AND_CONT )
982
4
    {
983
4
      proto_tree_add_item(tree, hf_vuze_dht_diversification_type, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN);
984
4
      offset += TL_BYTE;
985
4
    }
986
21
    offset = dissect_vuze_dht_value_group( tvb, pinfo, tree, offset, ver );
987
21
  }
988
989
22
  return offset;
990
22
}
991
992
/* --- Reply Error -----------------
993
994
Name                   | Type   | Condition                 | Note
995
ERROR_TYPE               int      always                      Type of the error. Possible values are:
996
                                                                WRONG_ADDRESS = 1 - originator's address stored in the request is incorrect
997
                                                                KEY_BLOCKED = 2 - the requested key has been blocked
998
SENDER_ADDRESS           address  ERROR_TYPE == WRONG_ADDRESS Real originator's address.
999
KEY_BLOCK_REQUEST_LENGTH byte     ERROR_TYPE == KEY_BLOCKED   Length of the following request.
1000
KEY_BLOCK_REQUEST        byte[]   ERROR_TYPE == KEY_BLOCKED   Request that blocks/unlocks the key.
1001
SIGNATURE_LENGTH         short    ERROR_TYPE == KEY_BLOCKED   Length of the following signature.
1002
SIGNATURE                byte[]   ERROR_TYPE == KEY_BLOCKED   Signature of the request.
1003
1004
*/
1005
static int
1006
dissect_vuze_dht_reply_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ver _U_ )
1007
0
{
1008
0
  unsigned error_type;
1009
0
  uint8_t key_block_request_len;
1010
0
  unsigned signature_len;
1011
1012
0
  proto_tree_add_item_ret_uint(tree, hf_vuze_dht_error_type, tvb, offset, TL_INT, ENC_BIG_ENDIAN, &error_type);
1013
0
  col_append_fstr(pinfo->cinfo, COL_INFO, " Error: %s", val_to_str_const( error_type, vuze_dht_error_type_vals, "Unknown") );
1014
0
  offset += TL_INT;
1015
1016
0
  switch(error_type)
1017
0
  {
1018
0
  case ET_WRONG_ADDRESS:
1019
0
    offset = dissect_vuze_dht_address( tvb, pinfo, tree, offset, "Sender Address" );
1020
0
    break;
1021
0
  case ET_KEY_BLOCKED:
1022
0
    proto_tree_add_item_ret_uint8(tree, hf_vuze_dht_key_block_request_len, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &key_block_request_len);
1023
0
    offset += TL_BYTE;
1024
1025
0
    proto_tree_add_item(tree, hf_vuze_dht_key_block_request, tvb, offset, key_block_request_len, ENC_NA);
1026
0
    offset += key_block_request_len;
1027
1028
0
    proto_tree_add_item_ret_uint(tree, hf_vuze_dht_signature_len, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN, &signature_len);
1029
0
    offset += TL_SHORT;
1030
1031
0
    proto_tree_add_item(tree, hf_vuze_dht_signature, tvb, offset, signature_len, ENC_NA);
1032
0
    offset += signature_len;
1033
0
    break;
1034
0
  default:
1035
0
    break;
1036
0
  }
1037
1038
0
  return offset;
1039
0
}
1040
1041
/* --- Request Key block -----------------
1042
1043
Name                    | Type  | Note
1044
SPOOF_ID                  int     Spoof ID obtained through FIND_NODE request.
1045
KEY_BLOCK_REQUEST_LENGTH  byte    Length of the following request.
1046
KEY_BLOCK_REQUEST         byte[]  Request that blocks/unlocks the key.
1047
SIGNATURE_LENGTH          short   Length of the following signature.
1048
SIGNATURE                 byte[]  Signature of the request.
1049
1050
*/
1051
static int
1052
dissect_vuze_dht_request_key_block(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree, int offset, int ver _U_ )
1053
0
{
1054
0
  uint8_t key_block_request_len;
1055
0
  unsigned signature_len;
1056
1057
0
  proto_tree_add_item(tree, hf_vuze_dht_spoof_id, tvb, offset, TL_INT, ENC_BIG_ENDIAN);
1058
0
  offset += TL_INT;
1059
1060
0
  proto_tree_add_item_ret_uint8(tree, hf_vuze_dht_key_block_request_len, tvb, offset, TL_BYTE, ENC_BIG_ENDIAN, &key_block_request_len);
1061
0
  offset += TL_BYTE;
1062
1063
0
  proto_tree_add_item(tree, hf_vuze_dht_key_block_request, tvb, offset, key_block_request_len, ENC_NA);
1064
0
  offset += key_block_request_len;
1065
1066
0
  proto_tree_add_item_ret_uint(tree, hf_vuze_dht_signature_len, tvb, offset, TL_SHORT, ENC_BIG_ENDIAN, &signature_len);
1067
0
  offset += TL_SHORT;
1068
1069
0
  proto_tree_add_item(tree, hf_vuze_dht_signature, tvb, offset, signature_len, ENC_NA);
1070
0
  offset += signature_len;
1071
1072
0
  return offset;
1073
0
}
1074
1075
static int
1076
dissect_vuze_dht(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1077
36
{
1078
36
  proto_item *ti;
1079
36
  proto_tree *sub_tree;
1080
36
  int action, proto_ver;
1081
36
  int decoded_length = 0;
1082
1083
  /* set the protocol column */
1084
36
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "Vuze-DHT");
1085
  /* clear the info column */
1086
36
  col_clear( pinfo->cinfo, COL_INFO);
1087
1088
36
  ti = proto_tree_add_item(tree, proto_vuze_dht, tvb, 0, -1, ENC_NA);
1089
36
  sub_tree = proto_item_add_subtree(ti, ett_vuze_dht);
1090
1091
  /*
1092
    Requests always start with Connection IDs, which guaranteed to have their MSB set to 1
1093
    Replies always start with the action, which always has the MSB clear
1094
    Therefore, the MSB of an incoming packet should be used to distinguish requests from replies.
1095
  */
1096
36
  if( tvb_get_uint8(tvb,0) & 0x80 )
1097
30
  {
1098
30
    decoded_length = dissect_vuze_dht_request_header(tvb, pinfo, sub_tree, decoded_length, &action, &proto_ver );
1099
30
  }
1100
6
  else
1101
6
  {
1102
6
    decoded_length = dissect_vuze_dht_reply_header(tvb, pinfo, sub_tree, decoded_length, &action, &proto_ver );
1103
6
  }
1104
1105
36
  switch( action )
1106
36
  {
1107
0
  case AT_PING_REQUEST:
1108
0
    break;
1109
1
  case AT_PING_REPLY:
1110
1
    decoded_length = dissect_vuze_dht_reply_ping(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1111
1
    break;
1112
0
  case AT_STORE_REQUEST:
1113
0
    decoded_length = dissect_vuze_dht_request_store(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1114
0
    break;
1115
0
  case AT_STORE_REPLY:
1116
0
    decoded_length = dissect_vuze_dht_reply_store(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1117
0
    break;
1118
0
  case AT_FIND_NODE_REQUEST:
1119
0
    decoded_length = dissect_vuze_dht_request_find_node(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1120
0
    break;
1121
0
  case AT_FIND_NODE_REPLY:
1122
0
    decoded_length = dissect_vuze_dht_reply_find_node(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1123
0
    break;
1124
0
  case AT_FIND_VALUE_REQUEST:
1125
0
    decoded_length = dissect_vuze_dht_request_find_value(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1126
0
    break;
1127
22
  case AT_FIND_VALUE_REPLY:
1128
22
    decoded_length = dissect_vuze_dht_reply_find_value(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1129
22
    break;
1130
0
  case AT_ERROR_REPLY:
1131
0
    decoded_length = dissect_vuze_dht_reply_error(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1132
0
    break;
1133
0
  case AT_KEY_BLOCK_REQUEST:
1134
0
    decoded_length = dissect_vuze_dht_request_key_block(tvb, pinfo, sub_tree, decoded_length, proto_ver );
1135
0
    break;
1136
7
  default:
1137
7
    break;
1138
36
  }
1139
1140
10
  return decoded_length;
1141
36
}
1142
1143
void
1144
proto_register_vuze_dht(void)
1145
16
{
1146
16
  static hf_register_info hf[] = {
1147
16
    { &hf_vuze_dht_address,
1148
16
      { "Address", "vuze-dht.address",
1149
16
      FT_NONE, BASE_NONE, NULL, 0x0,
1150
16
      NULL, HFILL }
1151
16
    },
1152
16
    { &hf_vuze_dht_address_len,
1153
16
      { "Address Length", "vuze-dht.address.length",
1154
16
      FT_UINT8, BASE_DEC, NULL, 0x0,
1155
16
      NULL, HFILL }
1156
16
    },
1157
16
    { &hf_vuze_dht_address_v4,
1158
16
      { "IPv4 Address", "vuze-dht.address.ipv4",
1159
16
      FT_IPv4, BASE_NONE, NULL, 0x0,
1160
16
      NULL, HFILL }
1161
16
    },
1162
16
    { &hf_vuze_dht_address_v6,
1163
16
      { "IPv6 Address", "vuze-dht.address.ipv6",
1164
16
      FT_IPv6, BASE_NONE, NULL, 0x0,
1165
16
      NULL, HFILL }
1166
16
    },
1167
16
    { &hf_vuze_dht_address_port,
1168
16
      { "Port", "vuze-dht.address.port",
1169
16
      FT_UINT16, BASE_DEC, NULL, 0x0,
1170
16
      NULL, HFILL }
1171
16
    },
1172
16
    { &hf_vuze_dht_contact,
1173
16
      { "Contact", "vuze-dht.contact",
1174
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1175
16
      NULL, HFILL }
1176
16
    },
1177
16
    { &hf_vuze_dht_contact_type,
1178
16
      { "Contact Type", "vuze-dht.contact.type",
1179
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_contact_type_vals), 0x0,
1180
16
      NULL, HFILL }
1181
16
    },
1182
16
    { &hf_vuze_dht_proto_ver,
1183
16
      { "Protocol Version", "vuze-dht.proto_ver",
1184
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1185
16
      NULL, HFILL }
1186
16
    },
1187
16
    { &hf_vuze_dht_value,
1188
16
      { "Value", "vuze-dht.value",
1189
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1190
16
      NULL, HFILL }
1191
16
    },
1192
16
    { &hf_vuze_dht_value_ver,
1193
16
      { "Value Version", "vuze-dht.value.ver",
1194
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1195
16
      NULL, HFILL }
1196
16
    },
1197
16
    { &hf_vuze_dht_value_created,
1198
16
      { "Value Creation Time", "vuze-dht.value.creation_time",
1199
16
      FT_UINT64, BASE_DEC,  NULL, 0x0,
1200
16
      NULL, HFILL }
1201
16
    },
1202
16
    { &hf_vuze_dht_value_bytes_count,
1203
16
      { "Value Bytes Count", "vuze-dht.value.bytes_count",
1204
16
      FT_UINT16, BASE_DEC,  NULL, 0x0,
1205
16
      NULL, HFILL }
1206
16
    },
1207
16
    { &hf_vuze_dht_value_bytes,
1208
16
      { "Value Bytes", "vuze-dht.value.bytes",
1209
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1210
16
      NULL, HFILL }
1211
16
    },
1212
16
    { &hf_vuze_dht_value_flags,
1213
16
      { "Value Flags", "vuze-dht.value.flags",
1214
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1215
16
      NULL, HFILL }
1216
16
    },
1217
16
    { &hf_vuze_dht_value_life_hours,
1218
16
      { "Value Life Hours", "vuze-dht.value.life_hours",
1219
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1220
16
      NULL, HFILL }
1221
16
    },
1222
16
    { &hf_vuze_dht_value_replication_factor,
1223
16
      { "Value Replication Factor", "vuze-dht.value.replication_factor",
1224
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1225
16
      NULL, HFILL }
1226
16
    },
1227
16
    { &hf_vuze_dht_connection_id,
1228
16
      { "Connection ID", "vuze-dht.connection_id",
1229
16
      FT_UINT64, BASE_DEC,  NULL, 0x0,
1230
16
      NULL, HFILL }
1231
16
    },
1232
16
    { &hf_vuze_dht_action,
1233
16
      { "Action", "vuze-dht.action",
1234
16
      FT_UINT32, BASE_DEC,  VALS(vuze_dht_action_type_vals), 0x0,
1235
16
      NULL, HFILL }
1236
16
    },
1237
16
    { &hf_vuze_dht_transaction_id,
1238
16
      { "Transaction ID", "vuze-dht.transaction_id",
1239
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1240
16
      NULL, HFILL }
1241
16
    },
1242
16
    { &hf_vuze_dht_vendor_id,
1243
16
      { "Vendor ID", "vuze-dht.vendor_id",
1244
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1245
16
      NULL, HFILL }
1246
16
    },
1247
16
    { &hf_vuze_dht_network_id,
1248
16
      { "Network ID", "vuze-dht.network_id",
1249
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1250
16
      NULL, HFILL }
1251
16
    },
1252
16
    { &hf_vuze_dht_local_proto_ver,
1253
16
      { "Local Protocol Version", "vuze-dht.local_proto_ver",
1254
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1255
16
      NULL, HFILL }
1256
16
    },
1257
16
    { &hf_vuze_dht_instance_id,
1258
16
      { "Instance ID", "vuze-dht.instance_id",
1259
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1260
16
      NULL, HFILL }
1261
16
    },
1262
16
    { &hf_vuze_dht_time,
1263
16
      { "Time", "vuze-dht.time",
1264
16
      FT_UINT64, BASE_DEC,  NULL, 0x0,
1265
16
      NULL, HFILL }
1266
16
    },
1267
16
    { &hf_vuze_dht_network_coordinates_count,
1268
16
      { "Network Coordinates Count", "vuze-dht.network_coordinates_count",
1269
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1270
16
      NULL, HFILL }
1271
16
    },
1272
16
    { &hf_vuze_dht_network_coordinates,
1273
16
      { "Network Coordinates", "vuze-dht.network_coordinates",
1274
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1275
16
      NULL, HFILL }
1276
16
    },
1277
16
    { &hf_vuze_dht_network_coordinate,
1278
16
      { "Network Coordinate", "vuze-dht.network_coordinate",
1279
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1280
16
      NULL, HFILL }
1281
16
    },
1282
16
    { &hf_vuze_dht_network_coordinate_type,
1283
16
      { "Network Coordinate Type", "vuze-dht.network_coordinate.type",
1284
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_network_coordinate_type_vals), 0x0,
1285
16
      NULL, HFILL }
1286
16
    },
1287
16
    { &hf_vuze_dht_network_coordinate_size,
1288
16
      { "Network Coordinate Size", "vuze-dht.network_coordinate.size",
1289
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1290
16
      NULL, HFILL }
1291
16
    },
1292
16
    { &hf_vuze_dht_network_coordinate_data,
1293
16
      { "Network Coordinate Data", "vuze-dht.network_coordinate.data",
1294
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1295
16
      NULL, HFILL }
1296
16
    },
1297
16
    { &hf_vuze_dht_network_coordinate_x,
1298
16
      { "Network Coordinate X", "vuze-dht.network_coordinate.x",
1299
16
      FT_FLOAT, BASE_NONE,  NULL, 0x0,
1300
16
      NULL, HFILL }
1301
16
    },
1302
16
    { &hf_vuze_dht_network_coordinate_y,
1303
16
      { "Network Coordinate Y", "vuze-dht.network_coordinate.y",
1304
16
      FT_FLOAT, BASE_NONE,  NULL, 0x0,
1305
16
      NULL, HFILL }
1306
16
    },
1307
16
    { &hf_vuze_dht_network_coordinate_height,
1308
16
      { "Network Coordinate Height", "vuze-dht.network_coordinate.height",
1309
16
      FT_FLOAT, BASE_NONE,  NULL, 0x0,
1310
16
      NULL, HFILL }
1311
16
    },
1312
16
    { &hf_vuze_dht_network_coordinate_error,
1313
16
      { "Network Coordinate Error", "vuze-dht.network_coordinate.error",
1314
16
      FT_FLOAT, BASE_NONE,  NULL, 0x0,
1315
16
      NULL, HFILL }
1316
16
    },
1317
16
    { &hf_vuze_dht_spoof_id,
1318
16
      { "Spoof ID", "vuze-dht.spoof_id",
1319
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1320
16
      NULL, HFILL }
1321
16
    },
1322
16
    { &hf_vuze_dht_keys_count,
1323
16
      { "Keys Count", "vuze-dht.keys_count",
1324
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1325
16
      NULL, HFILL }
1326
16
    },
1327
16
    { &hf_vuze_dht_keys,
1328
16
      { "Keys", "vuze-dht.keys",
1329
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1330
16
      NULL, HFILL }
1331
16
    },
1332
16
    { &hf_vuze_dht_key,
1333
16
      { "Key", "vuze-dht.key",
1334
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1335
16
      NULL, HFILL }
1336
16
    },
1337
16
    { &hf_vuze_dht_key_len,
1338
16
      { "Key Length", "vuze-dht.key.len",
1339
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1340
16
      NULL, HFILL }
1341
16
    },
1342
16
    { &hf_vuze_dht_key_data,
1343
16
      { "Key Data", "vuze-dht.key.data",
1344
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1345
16
      NULL, HFILL }
1346
16
    },
1347
16
    { &hf_vuze_dht_values_count,
1348
16
      { "Values Count", "vuze-dht.values_count",
1349
16
      FT_UINT16, BASE_DEC,  NULL, 0x0,
1350
16
      NULL, HFILL }
1351
16
    },
1352
16
    { &hf_vuze_dht_value_groups_count,
1353
16
      { "Value Groups Count", "vuze-dht.value_groups_count",
1354
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1355
16
      NULL, HFILL }
1356
16
    },
1357
16
    { &hf_vuze_dht_value_group,
1358
16
      { "Values", "vuze-dht.values",
1359
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1360
16
      NULL, HFILL }
1361
16
    },
1362
16
    { &hf_vuze_dht_value_groups,
1363
16
      { "Value Groups", "vuze-dht.value_groups",
1364
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1365
16
      NULL, HFILL }
1366
16
    },
1367
16
    { &hf_vuze_dht_diversifications_len,
1368
16
      { "Diversifications Length", "vuze-dht.diversifications_len",
1369
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1370
16
      NULL, HFILL }
1371
16
    },
1372
16
    { &hf_vuze_dht_diversifications,
1373
16
      { "Diversifications", "vuze-dht.diversifications",
1374
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1375
16
      NULL, HFILL }
1376
16
    },
1377
16
    { &hf_vuze_dht_id_len,
1378
16
      { "ID Length", "vuze-dht.id_len",
1379
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1380
16
      NULL, HFILL }
1381
16
    },
1382
16
    { &hf_vuze_dht_id,
1383
16
      { "ID", "vuze-dht.id",
1384
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1385
16
      NULL, HFILL }
1386
16
    },
1387
16
    { &hf_vuze_dht_node_status,
1388
16
      { "Node Status", "vuze-dht.node_status",
1389
16
      FT_UINT32, BASE_HEX,  NULL, 0x0,
1390
16
      NULL, HFILL }
1391
16
    },
1392
16
    { &hf_vuze_dht_size,
1393
16
      { "DHT Size", "vuze-dht.dht_size",
1394
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1395
16
      NULL, HFILL }
1396
16
    },
1397
16
    { &hf_vuze_dht_node_type,
1398
16
      { "Node Type", "vuze-dht.node_type",
1399
16
      FT_UINT32, BASE_DEC,  VALS(vuze_dht_node_type_vals), 0x0,
1400
16
      NULL, HFILL }
1401
16
    },
1402
16
    { &hf_vuze_dht_contacts_count,
1403
16
      { "Contacts Count", "vuze-dht.contacts_count",
1404
16
      FT_UINT16, BASE_DEC,  NULL, 0x0,
1405
16
      NULL, HFILL }
1406
16
    },
1407
16
    { &hf_vuze_dht_contacts,
1408
16
      { "Contacts", "vuze-dht.contacts",
1409
16
      FT_NONE, BASE_NONE,  NULL, 0x0,
1410
16
      NULL, HFILL }
1411
16
    },
1412
16
    { &hf_vuze_dht_flags,
1413
16
      { "Flags", "vuze-dht.flags",
1414
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_flag_type_vals), 0x0,
1415
16
      NULL, HFILL }
1416
16
    },
1417
16
    { &hf_vuze_dht_values_num,
1418
16
      { "Values Num", "vuze-dht.stats.values_num",
1419
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1420
16
      NULL, HFILL }
1421
16
    },
1422
16
    { &hf_vuze_dht_values_total,
1423
16
      { "Values Total", "vuze-dht.stats.values_total",
1424
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1425
16
      NULL, HFILL }
1426
16
    },
1427
16
    { &hf_vuze_dht_reads_per_min,
1428
16
      { "Reads Per Minute", "vuze-dht.stats.reads_per_min",
1429
16
      FT_UINT32, BASE_DEC,  NULL, 0x0,
1430
16
      NULL, HFILL }
1431
16
    },
1432
16
    { &hf_vuze_dht_diversification_type,
1433
16
      { "Diversification Type", "vuze-dht.stats.diversification_type",
1434
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1435
16
      NULL, HFILL }
1436
16
    },
1437
16
    { &hf_vuze_dht_max_values,
1438
16
      { "Max values", "vuze-dht.max_values",
1439
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1440
16
      NULL, HFILL }
1441
16
    },
1442
16
    { &hf_vuze_dht_has_continuation,
1443
16
      { "Has Continuation", "vuze-dht.has_continuation",
1444
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_bool_type_vals), 0x0,
1445
16
      NULL, HFILL }
1446
16
    },
1447
16
    { &hf_vuze_dht_has_values,
1448
16
      { "Has Values", "vuze-dht.has_values",
1449
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_bool_type_vals), 0x0,
1450
16
      NULL, HFILL }
1451
16
    },
1452
16
    { &hf_vuze_dht_error_type,
1453
16
      { "Error Type", "vuze-dht.error_type",
1454
16
      FT_UINT32, BASE_DEC,  VALS(vuze_dht_error_type_vals), 0x0,
1455
16
      NULL, HFILL }
1456
16
    },
1457
16
    { &hf_vuze_dht_key_block_request_len,
1458
16
      { "Key Block Request Length", "vuze-dht.key_block_request_len",
1459
16
      FT_UINT8, BASE_DEC,  NULL, 0x0,
1460
16
      NULL, HFILL }
1461
16
    },
1462
16
    { &hf_vuze_dht_key_block_request,
1463
16
      { "Key Block Request", "vuze-dht.key_block_request",
1464
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1465
16
      NULL, HFILL }
1466
16
    },
1467
16
    { &hf_vuze_dht_signature_len,
1468
16
      { "Signature Length", "vuze-dht.signature_len",
1469
16
      FT_UINT16, BASE_DEC,  NULL, 0x0,
1470
16
      NULL, HFILL }
1471
16
    },
1472
16
    { &hf_vuze_dht_signature,
1473
16
      { "Signature", "vuze-dht.signature",
1474
16
      FT_BYTES, BASE_NONE,  NULL, 0x0,
1475
16
      NULL, HFILL }
1476
16
    },
1477
16
    { &hf_vuze_dht_generic_flags,
1478
16
      { "Generic Flags", "vuze-dht.generic_flags",
1479
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_generic_flag_type_vals), 0x0,
1480
16
      NULL, HFILL }
1481
16
    },
1482
16
    { &hf_vuze_dht_generic_flags2,
1483
16
      { "Generic Flags 2", "vuze-dht.generic_flags2",
1484
16
      FT_UINT8, BASE_DEC,  VALS(vuze_dht_flag_type_vals), 0x0,
1485
16
      NULL, HFILL }
1486
16
    }
1487
16
  };
1488
1489
  /* Setup protocol subtree array */
1490
16
  static int *ett[] = {
1491
16
      &ett_vuze_dht,
1492
16
      &ett_vuze_dht_address,
1493
16
      &ett_vuze_dht_contacts,
1494
16
      &ett_vuze_dht_contact,
1495
16
      &ett_vuze_dht_keys,
1496
16
      &ett_vuze_dht_key,
1497
16
      &ett_vuze_dht_value_groups,
1498
16
      &ett_vuze_dht_value_group,
1499
16
      &ett_vuze_dht_value,
1500
16
      &ett_vuze_dht_network_coordinates,
1501
16
      &ett_vuze_dht_network_coordinate
1502
16
  };
1503
1504
  /* Register protocol */
1505
16
  proto_vuze_dht = proto_register_protocol ( "Vuze DHT Protocol", "Vuze-DHT", "vuze-dht" );
1506
1507
16
  proto_register_field_array(proto_vuze_dht, hf, array_length(hf));
1508
16
  proto_register_subtree_array(ett, array_length(ett));
1509
1510
16
  vuze_dht_handle = register_dissector("vuze-dht", dissect_vuze_dht, proto_vuze_dht);
1511
16
}
1512
1513
void
1514
proto_reg_handoff_vuze_dht(void)
1515
16
{
1516
16
  dissector_add_uint("udp.port", DEFAULT_UDP_PORT, vuze_dht_handle);
1517
16
}
1518
/*
1519
 * Editor modelines
1520
 *
1521
 * Local Variables:
1522
 * c-basic-offset: 2
1523
 * tab-width: 8
1524
 * indent-tabs-mode: nil
1525
 * End:
1526
 *
1527
 * ex: set shiftwidth=2 tabstop=8 expandtab:
1528
 * :indentSize=2:tabSize=8:noTabs=true:
1529
 */