2 * Routines for edonkey dissection
3 * Copyright 2003, Xuan Zhang <xz@aemail4u.com>
4 * Copyright 2007, Stefano Picerno <stefano.picerno@gmail.com>
5 * Copyright 2008, Stefan Monhof <stefan.monhof@stud.uni-due.de>
7 * eDonkey dissector based on protocol descriptions from mldonkey:
8 * ftp://ftp.chatnfiles.com/gnu-mirror/savannah/files/mldonkey/docs/Edonkey-Overnet/edonkey-protocol.txt
9 * ftp://ftp.chatnfiles.com/gnu-mirror/savannah/files/mldonkey/docs/Edonkey-Overnet/overnet-protocol.txt
11 * Kademlia dissector based on source code inspection of aMule 2.1.3 and eMule 0.48a
12 * Modified and added on the basis of information and names from the eMule 0.50 source code
13 * found at http://www.emule-project.net
17 * Wireshark - Network traffic analyzer
18 * By Gerald Combs <gerald@wireshark.org>
19 * Copyright 1998 Gerald Combs
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
42 #include <epan/packet.h>
43 #include <epan/prefs.h>
44 #include <epan/wmem/wmem.h>
45 #include "packet-edonkey.h"
46 #include "packet-tcp.h"
48 void proto_reg_handoff_edonkey(void);
50 static int proto_edonkey
= -1;
52 static int hf_edonkey_message
= -1;
53 static int hf_edonkey_protocol
= -1;
54 static int hf_edonkey_message_length
= -1;
55 static int hf_edonkey_message_type
= -1;
56 static int hf_edonkey_client_hash
= -1;
57 static int hf_edonkey_server_hash
= -1;
58 static int hf_edonkey_file_hash
= -1;
59 static int hf_edonkey_client_id
= -1;
60 static int hf_edonkey_metatag_namesize
= -1;
61 static int hf_edonkey_metatag_type
= -1;
62 static int hf_edonkey_metatag
= -1;
63 static int hf_edonkey_metatag_name
= -1;
64 static int hf_edonkey_metatag_id
= -1;
65 static int hf_edonkey_search
= -1;
66 static int hf_edonkey_ip
= -1;
67 static int hf_edonkey_port
= -1;
68 static int hf_edonkey_hash
= -1;
69 static int hf_edonkey_part_count
= -1;
70 static int hf_edonkey_file_status
= -1;
71 static int hf_edonkey_directory
= -1;
72 static int hf_edonkey_string
= -1;
73 static int hf_edonkey_string_length
= -1;
74 static int hf_edonkey_fileinfo
= -1;
75 static int hf_edonkey_clientinfo
= -1;
76 static int hf_edonkey_serverinfo
= -1;
77 static int hf_emule_aich_partnum
= -1;
78 static int hf_emule_aich_root_hash
= -1;
79 static int hf_emule_aich_hash_entry
= -1;
80 static int hf_emule_aich_hash_id
= -1;
81 static int hf_emule_aich_hash
= -1;
82 static int hf_emule_multipacket_entry
= -1;
83 static int hf_emule_multipacket_opcode
= -1;
84 static int hf_emule_source_count
= -1;
85 static int hf_emule_zlib
= -1;
86 static int hf_emule_public_key
= -1;
87 static int hf_emule_signature
= -1;
88 static int hf_emule_sourceOBFU
= -1;
89 static int hf_overnet_peer
= -1;
91 static int hf_edonkey_unparsed_data_length
= -1;
92 static int hf_kademlia
= -1;
93 static int hf_kademlia_search_condition
= -1;
94 static int hf_kademlia_search_condition_argument_uint32
= -1;
95 static int hf_kademlia_search_condition_argument_uint64
= -1;
96 /* static int hf_kademlia_unparsed_data_length = -1; */
97 static int hf_kademlia_peer
= -1;
98 static int hf_kademlia_peer_id
= -1;
99 static int hf_kademlia_hash
= -1;
100 static int hf_kademlia_file_id
= -1;
101 static int hf_kademlia_keyword_hash
= -1;
102 static int hf_kademlia_recipients_id
= -1;
103 static int hf_kademlia_sender_id
= -1;
104 static int hf_kademlia_target_id
= -1;
105 static int hf_kademlia_distance
= -1;
106 static int hf_kademlia_version
= -1;
107 static int hf_kademlia_peertype
= -1;
108 static int hf_kademlia_tag_float
= -1;
109 static int hf_kademlia_tag_uint64
= -1;
110 static int hf_kademlia_tag_uint32
= -1;
111 static int hf_kademlia_tag_ipv4
= -1;
112 static int hf_kademlia_tag_uint16
= -1;
113 static int hf_kademlia_tag_uint8
= -1;
114 static int hf_kademlia_tag_hash
= -1;
115 static int hf_kademlia_tag_bsob
= -1;
116 static int hf_kademlia_tag_string
= -1;
117 static int hf_kademlia_udp_port
= -1;
118 static int hf_kademlia_tcp_port
= -1;
119 static int hf_kademlia_ip
= -1;
120 static int hf_kademlia_tag_name
= -1;
121 static int hf_kademlia_tag_name_length
= -1;
122 static int hf_kademlia_tag_type
= -1;
123 static int hf_kademlia_request_type
= -1;
125 static gint ett_kademlia_tag
= -1;
126 static gint ett_edonkey_listitem
= -1;
127 static gint ett_kademlia_search_expression
= -1;
128 static gint ett_edonkey
= -1;
129 static gint ett_edonkey_message
= -1;
130 static gint ett_edonkey_metatag
= -1;
131 static gint ett_edonkey_search
= -1;
132 static gint ett_edonkey_fileinfo
= -1;
133 static gint ett_edonkey_serverinfo
= -1;
134 static gint ett_edonkey_clientinfo
= -1;
135 static gint ett_emule_aichhash
= -1;
136 static gint ett_emule_multipacket
= -1;
137 static gint ett_emule_zlib
= -1;
138 static gint ett_overnet_peer
= -1;
139 static gint ett_emule_sourceOBFU
= -1;
141 /* desegmentation of eDonkey over TCP */
142 static gboolean edonkey_desegment
= TRUE
;
144 static const value_string kademlia_msgs
[] = {
145 { KADEMLIA2_BOOTSTRAP_REQ
,"KADEMLIA2_BOOTSTRAP_REQ" },
146 { KADEMLIA2_BOOTSTRAP_RES
,"KADEMLIA2_BOOTSTRAP_RES" },
147 { KADEMLIA2_HELLO_REQ
,"KADEMLIA2_HELLO_REQ" },
148 { KADEMLIA2_HELLO_RES
,"KADEMLIA2_HELLO_RES" },
149 { KADEMLIA2_PUBLISH_KEY_REQ
,"KADEMLIA2_PUBLISH_KEY_REQ" },
150 { KADEMLIA2_PUBLISH_NOTES_REQ
,"KADEMLIA2_PUBLISH_NOTES_REQ" },
151 { KADEMLIA2_PUBLISH_RES
,"KADEMLIA2_PUBLISH_RES" },
152 { KADEMLIA2_PUBLISH_SOURCE_REQ
,"KADEMLIA2_PUBLISH_SOURCE_REQ" },
153 { KADEMLIA2_REQ
,"KADEMLIA2_REQ" },
154 { KADEMLIA2_RES
,"KADEMLIA2_RES" },
155 { KADEMLIA2_SEARCH_KEY_REQ
,"KADEMLIA2_SEARCH_KEY_REQ" },
156 { KADEMLIA2_SEARCH_NOTES_REQ
,"KADEMLIA2_SEARCH_NOTES_REQ" },
157 { KADEMLIA2_SEARCH_RES
,"KADEMLIA2_SEARCH_RES" },
158 { KADEMLIA2_SEARCH_SOURCE_REQ
,"KADEMLIA2_SEARCH_SOURCE_REQ" },
159 { KADEMLIA_BOOTSTRAP_REQ
,"KADEMLIA_BOOTSTRAP_REQ" },
160 { KADEMLIA_BOOTSTRAP_RES
,"KADEMLIA_BOOTSTRAP_RES" },
161 { KADEMLIA_CALLBACK_REQ
,"KADEMLIA_CALLBACK_REQ" },
162 { KADEMLIA_FINDBUDDY_REQ
,"KADEMLIA_FINDBUDDY_REQ" },
163 { KADEMLIA_FINDBUDDY_RES
,"KADEMLIA_FINDBUDDY_RES" },
164 { KADEMLIA_FIREWALLED_ACK_RES
,"KADEMLIA_FIREWALLED_ACK_RES" },
165 { KADEMLIA_FIREWALLED_REQ
,"KADEMLIA_FIREWALLED_REQ" },
166 { KADEMLIA_FIREWALLED_RES
,"KADEMLIA_FIREWALLED_RES" },
167 { KADEMLIA_HELLO_REQ
,"KADEMLIA_HELLO_REQ" },
168 { KADEMLIA_HELLO_RES
,"KADEMLIA_HELLO_RES" },
169 { KADEMLIA_PUBLISH_NOTES_REQ
,"KADEMLIA_PUBLISH_NOTES_REQ" },
170 { KADEMLIA_PUBLISH_NOTES_RES
,"KADEMLIA_PUBLISH_NOTES_RES" },
171 { KADEMLIA_PUBLISH_REQ
,"KADEMLIA_PUBLISH_REQ" },
172 { KADEMLIA_PUBLISH_RES
,"KADEMLIA_PUBLISH_RES" },
173 { KADEMLIA_REQ
,"KADEMLIA_REQ" },
174 { KADEMLIA_RES
,"KADEMLIA_RES" },
175 { KADEMLIA_SEARCH_NOTES_REQ
,"KADEMLIA_SEARCH_NOTES_REQ" },
176 { KADEMLIA_SEARCH_NOTES_RES
,"KADEMLIA_SEARCH_NOTES_RES" },
177 { KADEMLIA_SEARCH_REQ
,"KADEMLIA_SEARCH_REQ" },
178 { KADEMLIA_SEARCH_RES
,"KADEMLIA_SEARCH_RES" },
182 static const value_string kademlia_tag_types
[] = {
183 { KADEMLIA_TAGTYPE_HASH
,"TAGTYPE_HASH" },
184 { KADEMLIA_TAGTYPE_STRING
,"TAGTYPE_STRING" },
185 { KADEMLIA_TAGTYPE_UINT32
,"TAGTYPE_UINT32" },
186 { KADEMLIA_TAGTYPE_FLOAT32
,"TAGTYPE_FLOAT32" },
187 { KADEMLIA_TAGTYPE_BOOL
,"TAGTYPE_BOOL" },
188 { KADEMLIA_TAGTYPE_BOOLARRAY
,"TAGTYPE_BOOLARRAY" },
189 { KADEMLIA_TAGTYPE_BLOB
,"TAGTYPE_BLOB" },
190 { KADEMLIA_TAGTYPE_UINT16
,"TAGTYPE_UINT16" },
191 { KADEMLIA_TAGTYPE_UINT8
,"TAGTYPE_UINT8" },
192 { KADEMLIA_TAGTYPE_BSOB
,"TAGTYPE_BSOB" },
193 { KADEMLIA_TAGTYPE_UINT64
,"TAGTYPE_UINT64" },
195 { KADEMLIA_TAGTYPE_STR1
,"TAGTYPE_STR1" },
196 { KADEMLIA_TAGTYPE_STR2
,"TAGTYPE_STR2" },
197 { KADEMLIA_TAGTYPE_STR3
,"TAGTYPE_STR3" },
198 { KADEMLIA_TAGTYPE_STR4
,"TAGTYPE_STR4" },
199 { KADEMLIA_TAGTYPE_STR5
,"TAGTYPE_STR5" },
200 { KADEMLIA_TAGTYPE_STR6
,"TAGTYPE_STR6" },
201 { KADEMLIA_TAGTYPE_STR7
,"TAGTYPE_STR7" },
202 { KADEMLIA_TAGTYPE_STR8
,"TAGTYPE_STR8" },
203 { KADEMLIA_TAGTYPE_STR9
,"TAGTYPE_STR9" },
204 { KADEMLIA_TAGTYPE_STR10
,"TAGTYPE_STR10" },
205 { KADEMLIA_TAGTYPE_STR11
,"TAGTYPE_STR11" },
206 { KADEMLIA_TAGTYPE_STR12
,"TAGTYPE_STR12" },
207 { KADEMLIA_TAGTYPE_STR13
,"TAGTYPE_STR13" },
208 { KADEMLIA_TAGTYPE_STR14
,"TAGTYPE_STR14" },
209 { KADEMLIA_TAGTYPE_STR15
,"TAGTYPE_STR15" },
210 { KADEMLIA_TAGTYPE_STR16
,"TAGTYPE_STR16" },
211 { KADEMLIA_TAGTYPE_STR17
,"TAGTYPE_STR17" },
212 { KADEMLIA_TAGTYPE_STR18
,"TAGTYPE_STR18" },
213 { KADEMLIA_TAGTYPE_STR19
,"TAGTYPE_STR19" },
214 { KADEMLIA_TAGTYPE_STR20
,"TAGTYPE_STR20" },
215 { KADEMLIA_TAGTYPE_STR21
,"TAGTYPE_STR21" },
216 { KADEMLIA_TAGTYPE_STR22
,"TAGTYPE_STR22" },
220 static const value_string kademlia_tags
[] = {
221 { KADEMLIA_TAG_BUDDYHASH
,"TAG_BUDDYHASH" },
222 { KADEMLIA_TAG_CLIENTLOWID
,"TAG_CLIENTLOWID" },
223 { KADEMLIA_TAG_COLLECTION
,"TAG_COLLECTION" },
224 { KADEMLIA_TAG_COPIED
,"TAG_COPIED" },
225 { KADEMLIA_TAG_DESCRIPTION
,"TAG_DESCRIPTION" },
226 { KADEMLIA_TAG_ENCRYPTION
,"TAG_ENCRYPTION" },
227 { KADEMLIA_TAG_FAIL
,"TAG_FAIL" },
228 { KADEMLIA_TAG_FILECOMMENT
,"TAG_FILECOMMENT" },
229 { KADEMLIA_TAG_FILE_COUNT
,"TAG_FILE_COUNT" },
230 { KADEMLIA_TAG_FILEFORMAT
,"TAG_FILEFORMAT" },
231 { KADEMLIA_TAG_FILENAME
,"TAG_FILENAME" },
232 { KADEMLIA_TAG_FILERATING
,"TAG_FILERATING" },
233 { KADEMLIA_TAG_FILESIZE_HI
,"TAG_FILESIZE_HI" },
234 { KADEMLIA_TAG_FILESIZE
,"TAG_FILESIZE" },
235 { KADEMLIA_TAG_FILETYPE
,"TAG_FILETYPE" },
236 { KADEMLIA_TAG_GAP_END
,"TAG_GAP_END" },
237 { KADEMLIA_TAG_GAP_START
,"TAG_GAP_START" },
238 { KADEMLIA_TAG_IP_ADDRESS
,"TAG_IP_ADDRESS" },
239 { KADEMLIA_TAG_MEDIA_ALBUM
,"TAG_MEDIA_ALBUM" },
240 { KADEMLIA_TAG_MEDIA_ARTIST
,"TAG_MEDIA_ARTIST" },
241 { KADEMLIA_TAG_MEDIA_BITRATE
,"TAG_MEDIA_BITRATE"},
242 { KADEMLIA_TAG_MEDIA_CODEC
,"TAG_MEDIA_CODEC" },
243 { KADEMLIA_TAG_MEDIA_LENGTH
,"TAG_MEDIA_LENGTH" },
244 { KADEMLIA_TAG_MEDIA_TITLE
,"TAG_MEDIA_TITLE" },
245 { KADEMLIA_TAG_PART_HASH
,"TAG_PART_HASH" },
246 { KADEMLIA_TAG_PART_PATH
,"TAG_PART_PATH" },
247 { KADEMLIA_TAG_PARTS
,"TAG_PARTS" },
248 { KADEMLIA_TAG_PERMISSIONS
,"TAG_PERMISSIONS" },
249 { KADEMLIA_TAG_PING
,"TAG_PING" },
250 { KADEMLIA_TAG_PORT
,"TAG_PORT" },
251 { KADEMLIA_TAG_PREFERENCE
,"TAG_PREFERENCE" },
252 { KADEMLIA_TAG_PRIORITY
,"TAG_PRIORITY" },
253 { KADEMLIA_TAG_QTIME
,"TAG_QTIME" },
254 { KADEMLIA_TAG_SERVERIP
,"TAG_SERVERIP" },
255 { KADEMLIA_TAG_SERVERPORT
,"TAG_SERVERPORT" },
256 { KADEMLIA_TAG_SOURCEIP
,"TAG_SOURCEIP" },
257 { KADEMLIA_TAG_SOURCEPORT
,"TAG_SOURCEPORT" },
258 { KADEMLIA_TAG_SOURCES
,"TAG_SOURCES" },
259 { KADEMLIA_TAG_SOURCETYPE
,"TAG_SOURCETYPE" },
260 { KADEMLIA_TAG_SOURCEUPORT
,"TAG_SOURCEUPORT" },
261 { KADEMLIA_TAG_STATUS
,"TAG_STATUS" },
262 { KADEMLIA_TAG_TEMPFILE
,"TAG_TEMPFILE" },
263 { KADEMLIA_TAG_USER_COUNT
,"TAG_USER_COUNT" },
264 { KADEMLIA_TAG_VERSION
,"TAG_VERSION" },
269 static const value_string edonkey_protocols
[] = {
270 { EDONKEY_PROTO_EDONKEY
, "eDonkey" },
271 { EDONKEY_PROTO_EMULE_EXT
, "eMule Extensions" },
272 { EDONKEY_PROTO_EMULE_COMP
, "eMule Compressed" },
273 { EDONKEY_PROTO_KADEMLIA
, "Kademlia" },
274 { EDONKEY_PROTO_KADEMLIA_COMP
, "Kademlia Compressed" },
275 { EDONKEY_PROTO_ADU_KADEMLIA
, "KAdu" },
276 { EDONKEY_PROTO_ADU_KADEMLIA_COMP
, "KAdu Compressed" },
280 static const value_string edonkey_tcp_msgs
[] = {
281 { EDONKEY_MSG_HELLO
, "Hello" },
282 { EDONKEY_MSG_BAD_PROTO
, "Bad Proto" },
283 { EDONKEY_MSG_GET_SERVER_LIST
, "Get Server List" },
284 { EDONKEY_MSG_OFFER_FILES
, "Offer Files" },
285 { EDONKEY_MSG_SEARCH_FILES
, "Search Files" },
286 { EDONKEY_MSG_DISCONNECT
, "Disconnect" },
287 { EDONKEY_MSG_GET_SOURCES
, "Get Sources" },
288 { EDONKEY_MSG_GET_SOURCES_OBFU
, "Get Sources Obfuscation" },
289 { EDONKEY_MSG_SEARCH_USER
, "Search User" },
290 { EDONKEY_MSG_CLIENT_CB_REQ
, "Client Callback Request" },
291 { EDONKEY_MSG_MORE_RESULTS
, "More Results" },
292 { EDONKEY_MSG_SERVER_LIST
, "Server List" },
293 { EDONKEY_MSG_SEARCH_FILE_RESULTS
, "Search File Results" },
294 { EDONKEY_MSG_SERVER_STATUS
, "Server Status" },
295 { EDONKEY_MSG_SERVER_CB_REQ
, "Server Callback Request" },
296 { EDONKEY_MSG_CALLBACK_FAIL
, "Callback Fail" },
297 { EDONKEY_MSG_SERVER_MESSAGE
, "Server Message" },
298 { EDONKEY_MSG_ID_CHANGE
, "ID Change" },
299 { EDONKEY_MSG_SERVER_INFO_DATA
, "Server Info Data" },
300 { EDONKEY_MSG_FOUND_SOURCES
, "Found Sources" },
301 { EDONKEY_MSG_FOUND_SOURCES_OBFU
, "Found Sources Obfuscation"},
302 { EDONKEY_MSG_SEARCH_USER_RESULTS
, "Search User Results" },
303 { EDONKEY_MSG_SENDING_PART
, "Sending Part" },
304 { EDONKEY_MSG_REQUEST_PARTS
, "Request Parts" },
305 { EDONKEY_MSG_NO_SUCH_FILE
, "No Such File" },
306 { EDONKEY_MSG_END_OF_DOWNLOAD
, "End of Download" },
307 { EDONKEY_MSG_VIEW_FILES
, "View Files" },
308 { EDONKEY_MSG_VIEW_FILES_ANSWER
, "View Files Answer" },
309 { EDONKEY_MSG_HELLO_ANSWER
, "Hello Answer" },
310 { EDONKEY_MSG_NEW_CLIENT_ID
, "New Client ID" },
311 { EDONKEY_MSG_CLIENT_MESSAGE
, "Client Message" },
312 { EDONKEY_MSG_FILE_STATUS_REQUEST
, "File Status Request" },
313 { EDONKEY_MSG_FILE_STATUS
, "File Status" },
314 { EDONKEY_MSG_HASHSET_REQUEST
, "Hashset Request" },
315 { EDONKEY_MSG_HASHSET_ANSWER
, "Hashset Answer" },
316 { EDONKEY_MSG_SLOT_REQUEST
, "Slot Request" },
317 { EDONKEY_MSG_SLOT_GIVEN
, "Slot Given" },
318 { EDONKEY_MSG_SLOT_RELEASE
, "Slot Release" },
319 { EDONKEY_MSG_SLOT_TAKEN
, "Slot Taken" },
320 { EDONKEY_MSG_FILE_REQUEST
, "File Request" },
321 { EDONKEY_MSG_FILE_REQUEST_ANSWER
, "File Request Answer" },
322 { EDONKEY_MSG_GET_SHARED_DIRS
, "Get Shared Directories" },
323 { EDONKEY_MSG_GET_SHARED_FILES
, "Get Shared Files" },
324 { EDONKEY_MSG_SHARED_DIRS
, "Shared Directories" },
325 { EDONKEY_MSG_SHARED_FILES
, "Shared Files" },
326 { EDONKEY_MSG_SHARED_DENIED
, "Shared Denied" },
330 static const value_string emule_tcp_msgs
[] = {
331 { EMULE_MSG_HELLO
, "Hello" },
332 { EMULE_MSG_HELLO_ANSWER
, "Hello Answer" },
333 { EMULE_MSG_DATA_COMPRESSED
, "Data Compressed" },
334 { EMULE_MSG_QUEUE_RANKING
, "Queue Ranking" },
335 { EMULE_MSG_FILE_DESC
, "File Description" },
336 { EMULE_MSG_SOURCES_REQUEST
, "Sources Request" },
337 { EMULE_MSG_SOURCES_ANSWER
, "Sources Answer" },
338 { EMULE_MSG_SIGNATURE
, "Signature" },
339 { EMULE_MSG_PUBLIC_KEY
, "Public Key" },
340 { EMULE_MSG_SEC_IDENT_STATE
, "Second Identification State" },
341 { EMULE_MSG_MULTIPACKET
, "MultiPacket" },
342 { EMULE_MSG_MULTIPACKET_EXT
, "MultiPacketExt" },
343 { EMULE_MSG_MULTIPACKET_ANSWER
, "MultiPacket Answer" },
344 { EMULE_MSG_CALLBACK
, "Callback" },
345 { EMULE_MSG_AICH_REQUEST
, "AICH Hashset Request" },
346 { EMULE_MSG_AICH_ANSWER
, "AICH Hashset Answer" },
347 { EMULE_MSG_AICHFILEHASH_ANSWER
, "AICH Master Hash Request" },
348 { EMULE_MSG_AICHFILEHASH_REQUEST
, "AICH Master Hash Answer" },
349 { EMULE_MSG_DATA_COMPRESSED_64
, "Data Compressed (64bit)" },
350 { EMULE_MSG_SENDING_PART_64
, "Sending Part (64bit)" },
351 { EMULE_MSG_REQUEST_PARTS_64
, "Request Parts (64bit)" },
355 static const value_string edonkey_udp_msgs
[] = {
356 { EDONKEY_MSG_UDP_SERVER_STATUS_REQUEST
, "Server Status Request" },
357 { EDONKEY_MSG_UDP_SERVER_STATUS
, "Server Status" },
358 { EDONKEY_MSG_UDP_SEARCH_FILE
, "Search File" },
359 { EDONKEY_MSG_UDP_SEARCH_FILE_RESULTS
, "Search File Results" },
360 { EDONKEY_MSG_UDP_GET_SOURCES
, "Get Sources" },
361 { EDONKEY_MSG_UDP_FOUND_SOURCES
, "Found Sources" },
362 { EDONKEY_MSG_UDP_CALLBACK_REQUEST
, "Callback Request" },
363 { EDONKEY_MSG_UDP_CALLBACK_FAIL
, "Callback Fail" },
364 { EDONKEY_MSG_UDP_SERVER_LIST
, "Server List" },
365 { EDONKEY_MSG_UDP_GET_SERVER_INFO
, "Get Server Info" },
366 { EDONKEY_MSG_UDP_SERVER_INFO
, "Server Info" },
367 { EDONKEY_MSG_UDP_GET_SERVER_LIST
, "Get Server List" },
369 /* eMule Extensions */
370 { EMULE_MSG_UDP_REASKFILEPING
, "Reask File Ping" },
371 { EMULE_MSG_UDP_REASKACK
, "Reask ACK" },
372 { EMULE_MSG_UDP_FILE_NOT_FOUND
, "File not found" },
373 { EMULE_MSG_UDP_QUEUE_FULL
, "Queue Full" },
375 /* Overnet Extensions */
376 { OVERNET_MSG_UDP_CONNECT
, "Connect" },
377 { OVERNET_MSG_UDP_CONNECT_REPLY
, "Connect Reply" },
378 { OVERNET_MSG_UDP_PUBLICIZE
, "Publicize" },
379 { OVERNET_MSG_UDP_PUBLICIZE_ACK
, "Publicize ACK" },
380 { OVERNET_MSG_UDP_SEARCH
, "Search" },
381 { OVERNET_MSG_UDP_SEARCH_NEXT
, "Search Next" },
382 { OVERNET_MSG_UDP_SEARCH_INFO
, "Search Info" },
383 { OVERNET_MSG_UDP_SEARCH_RESULT
, "Search Result" },
384 { OVERNET_MSG_UDP_SEARCH_END
, "Search End" },
385 { OVERNET_MSG_UDP_PUBLISH
, "Publish" },
386 { OVERNET_MSG_UDP_PUBLISH_ACK
, "Publish ACK" },
387 { OVERNET_MSG_UDP_IDENTIFY_REPLY
, "Identify Reply" },
388 { OVERNET_MSG_UDP_IDENTIFY_ACK
, "Identify ACK" },
389 { OVERNET_MSG_UDP_FIREWALL_CONNECTION
, "Firewall Connection" },
390 { OVERNET_MSG_UDP_FIREWALL_CONNECTION_ACK
, "Firewall Connection ACK" },
391 { OVERNET_MSG_UDP_FIREWALL_CONNECTION_NACK
, "Firewall Connection NACK" },
392 { OVERNET_MSG_UDP_IP_QUERY
, "IP Query" },
393 { OVERNET_MSG_UDP_IP_QUERY_ANSWER
, "IP Query Answer" },
394 { OVERNET_MSG_UDP_IP_QUERY_END
, "IP Query End" },
395 { OVERNET_MSG_UDP_IDENTIFY
, "Identify" },
399 static const value_string edonkey_special_tags
[] = {
400 { EDONKEY_STAG_NAME
, "Name" },
401 { EDONKEY_STAG_SIZE
, "Size" },
402 { EDONKEY_STAG_TYPE
, "Type" },
403 { EDONKEY_STAG_FORMAT
, "Format" },
404 { EDONKEY_STAG_COLLECTION
, "Collection" },
405 { EDONKEY_STAG_PART_PATH
, "Part Path" },
406 { EDONKEY_STAG_PART_HASH
, "Part Hash" },
407 { EDONKEY_STAG_COPIED
, "Copied" },
408 { EDONKEY_STAG_GAP_START
, "Gap Start" },
409 { EDONKEY_STAG_GAP_END
, "Gap End" },
410 { EDONKEY_STAG_DESCRIPTION
, "Description" },
411 { EDONKEY_STAG_PING
, "Ping" },
412 { EDONKEY_STAG_FAIL
, "Fail" },
413 { EDONKEY_STAG_PREFERENCE
, "Preference" },
414 { EDONKEY_STAG_PORT
, "Port" },
415 { EDONKEY_STAG_IP
, "IP" },
416 { EDONKEY_STAG_VERSION
, "Version" },
417 { EDONKEY_STAG_TEMPFILE
, "Temporary File" },
418 { EDONKEY_STAG_PRIORITY
, "Priority" },
419 { EDONKEY_STAG_STATUS
, "Status" },
420 { EDONKEY_STAG_AVAILABILITY
, "Availability" },
421 { EDONKEY_STAG_QTIME
, "Queue Time" },
422 { EDONKEY_STAG_PARTS
, "Parts" },
423 { EDONKEY_STAG_MOD_VERSION
, "Mod Version" },
424 { EMULE_STAG_COMPRESSION
, "Compression" },
425 { EMULE_STAG_UDP_CLIENT_PORT
, "UDP Client Port" },
426 { EMULE_STAG_UDP_VERSION
, "UDP Version" },
427 { EMULE_STAG_SOURCE_EXCHANGE
, "Source Exchange" },
428 { EMULE_STAG_COMMENTS
, "Comments" },
429 { EMULE_STAG_EXTENDED_REQUEST
, "Extended Request" },
430 { EMULE_STAG_COMPATIBLE_CLIENT
, "Compatible Client" },
431 { EMULE_STAG_COMPLETE_SOURCES
, "Complete Sources" },
432 { EMULE_STAG_SIZE_HI
, "Size (High Byte)" },
433 { EMULE_STAG_SERVER_VERSION
, "Server Version" },
434 { EMULE_STAG_COMPAT_OPTIONS1
, "Compatible Options" },
435 { EMULE_STAG_UDPPORTS
, "UDP Ports" },
436 { EMULE_STAG_MISCOPTIONS1
, "Misc Options 1" },
437 { EMULE_STAG_VERSION
, "eMule Version" },
438 { EMULE_STAG_BUDDYIP
, "Buddy IP" },
439 { EMULE_STAG_BUDDYUDP
, "Buddy UDP" },
440 { EMULE_STAG_MISCOPTIONS2
, "Misc Options 2" },
444 static const value_string edonkey_search_ops
[] = {
445 { EDONKEY_SEARCH_AND
, "AND" },
446 { EDONKEY_SEARCH_OR
, "OR" },
447 { EDONKEY_SEARCH_ANDNOT
, "AND NOT" },
451 static const value_string edonkey_search_conds
[] = {
452 { EDONKEY_SEARCH_MIN
, "MIN" },
453 { EDONKEY_SEARCH_MAX
, "MAX" },
457 static const value_string kademlia_search_conds
[] = {
467 static const value_string kademlia_versions
[] = {
468 { KADEMLIA_VERSION1_46c
, " (eMule <= 0.46c or compatibles)" },
469 { KADEMLIA_VERSION2_47a
, " (eMule 0.47a or compatibles)" },
470 { KADEMLIA_VERSION3_47b
, " (eMule 0.47b or compatibles)" },
471 { KADEMLIA_VERSION5_48a
, " (eMule 0.48a or compatibles)" },
472 { KADEMLIA_VERSION6_49aBETA
, " (eMule 0.49aBETA1 or compatibles)" },
473 { KADEMLIA_VERSION7_49a
, " (eMule 0.49a or compatibles)" },
477 static const value_string kademlia_parameter
[] = {
478 { KADEMLIA_FIND_VALUE
, " (Find Value)" },
479 { KADEMLIA_STORE
, " (Store)" },
480 { KADEMLIA_FIND_NODE
, " (Find Node)" },
484 static const value_string kademlia_tag_sourcetype
[] = {
485 { 1, "HighID Source" },
486 { 3, "Firewalled Kad Source" },
487 { 4, ">4GB file HighID Source" },
488 { 5, ">4GB file Firewalled Kad Source" },
489 { 6, "Firewalled Source with Direct Callback (supports >4GB)" },
493 static const value_string kademlia_tag_encryption
[] = {
494 { 1, "Supports Crypt Layer" },
495 { 2, "Requests Crypt Layer" },
496 { 3, "Supports & Requests Crypt Layer" },
497 { 4, "Requires Crypt Layer" },
498 { 5, "Supports & Requires Crypt Layer" },
499 { 6, "Requests & Requires Crypt Layer" },
500 { 7, "Supports, Requests & Requires Crypt Layer" },
501 { 8, "Direct UDP Callback" },
502 { 9, "Supports Crypt Layer; Direct UDP Callback" },
503 { 10, "Requests Crypt Layer; Direct UDP Callback" },
504 { 11, "Supports & Requests Crypt Layer; Direct UDP Callback" },
505 { 12, "Requires Crypt Layer; Direct UDP Callback" },
506 { 13, "Supports & Requires Crypt Layer; Direct UDP Callback" },
507 { 14, "Requests & Requires Crypt Layer; Direct UDP Callback" },
508 { 15, "Supports, Requests & Requires Crypt Layer; Direct UDP Callback" },
512 /* Dissects a generic eDonkey list */
513 static int dissect_edonkey_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
514 int offset
, proto_tree
*tree
,
515 int listnum_length
, const char* listdesc
,
516 int (*item_dissector
)(tvbuff_t
*, packet_info
*, int, proto_tree
*))
518 /* <List> ::= <List Size> <Item>* */
523 int list_start_offset
;
525 list_start_offset
= offset
;
527 switch (listnum_length
) {
530 listnum
= tvb_get_guint8(tvb
, offset
);
534 listnum
= tvb_get_ntohs(tvb
, offset
);
538 listnum
= tvb_get_letohs(tvb
, offset
);
542 listnum
= tvb_get_letohl(tvb
, offset
);
546 listnum
= tvb_get_ntohl(tvb
, offset
);
553 if (listnum_length
< 0)
554 listnum_length
= -listnum_length
;
556 /* keep the tree item object, its length will be set at the end of the function */
557 list_ti
= proto_tree_add_text(tree
, tvb
, offset
, listnum_length
, "%s List Size: %u", listdesc
, listnum
);
559 offset
+= listnum_length
;
561 for (i
=0; i
<listnum
; i
++)
563 int item_start_offset
;
565 item_start_offset
= offset
;
566 ti
= proto_tree_add_text( tree
, tvb
, item_start_offset
, 1, "%s[%u/%u]", listdesc
, i
+1, listnum
);
568 subtree
= proto_item_add_subtree(ti
, ett_edonkey_listitem
);
570 /* dissect one list element */
571 offset
= (*item_dissector
)(tvb
, pinfo
, offset
, subtree
);
572 /* Set the container node length */
573 proto_item_set_len( ti
, offset
- item_start_offset
);
576 /* Set the container node length */
577 proto_item_set_len(list_ti
, offset
- list_start_offset
);
581 static gint
lookup_str_index(gchar
* str
, gint length
, const value_string
*vs
)
585 if (str
== NULL
) return -1;
587 while (vs
[i
].strptr
) {
588 if (g_ascii_strncasecmp(str
, vs
[i
].strptr
, length
) == 0)
596 static guint8
edonkey_metatag_name_get_type(tvbuff_t
*tvb
, gint start
, gint length
, guint8 special_tagtype
)
600 if (try_val_to_str(special_tagtype
, edonkey_special_tags
) == NULL
) {
602 tag_name
= tvb_get_string(wmem_packet_scope(), tvb
, start
, length
);
603 idx
= lookup_str_index(tag_name
, length
, edonkey_special_tags
);
605 return EDONKEY_STAG_UNKNOWN
;
606 else return edonkey_special_tags
[idx
].value
;
608 else return special_tagtype
;
612 static proto_item
* edonkey_tree_add_metatag_name(proto_tree
*tree
, tvbuff_t
*tvb
,
613 gint start
, gint length
, guint8 special_tagtype
)
615 const gchar
*tag_name
;
616 tag_name
= try_val_to_str(special_tagtype
, edonkey_special_tags
);
617 if (tag_name
== NULL
) {
618 return proto_tree_add_item(tree
, hf_edonkey_metatag_name
, tvb
, start
, length
, ENC_ASCII
|ENC_NA
);
621 return proto_tree_add_uint_format(tree
, hf_edonkey_metatag_id
, tvb
, start
, length
,
622 special_tagtype
, "Meta Tag Name: %s (0x%02x)",
623 tag_name
, special_tagtype
);
627 static int dissect_kademlia_search_condition_argument_uint64(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
628 int offset
, proto_tree
*tree
)
630 proto_tree_add_item( tree
, hf_kademlia_search_condition_argument_uint64
, tvb
, offset
, 8, ENC_LITTLE_ENDIAN
);
634 static int dissect_kademlia_search_condition_argument_uint32(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
635 int offset
, proto_tree
*tree
)
637 proto_tree_add_item( tree
, hf_kademlia_search_condition_argument_uint32
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
641 static int dissect_kademlia_search_condition(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
642 int offset
, proto_tree
*tree
)
645 guint16 value
= tvb_get_guint8(tvb
, offset
);
646 ti
= proto_tree_add_item( tree
, hf_kademlia_search_condition
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
647 proto_item_append_text(ti
, " [%s]", val_to_str_const( value
, kademlia_search_conds
, "Unknown") );
652 /* Dissects the eDonkey meta tag */
653 static int dissect_edonkey_metatag(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
654 int offset
, proto_tree
*tree
)
656 /* <Meta Tag> ::= <Tag Type (guint8)> <Tag Name> <Tag> */
657 /* <Tag Name> ::= <Tag Name Size (guint16)> <Special Tag> || <String> */
658 /* <Tag Name> ::= <Special Tag> iff Tag Type had the top bit set */
660 proto_tree
*metatag_tree
;
661 guint8 real_tag_type
, tag_type
, special_tagtype
, trans_tagtype
, tag_value_guint8
;
662 guint16 tag_name_size
, string_length
, array_length
, tag_value_guint16
;
663 guint32 tag_length
, blob_length
, tag_value_guint32
;
666 real_tag_type
= tag_type
= tvb_get_guint8(tvb
, offset
);
667 if (tag_type
& EDONKEY_MTAG_SHORTNAME
) {
668 real_tag_type
&= ~EDONKEY_MTAG_SHORTNAME
;
670 special_tagtype
= tvb_get_guint8(tvb
, offset
+1);
673 tag_name_size
= tvb_get_letohs(tvb
, offset
+1);
674 special_tagtype
= tvb_get_guint8(tvb
, offset
+3);
675 tag_length
= 3 + tag_name_size
;
678 tag_offset
= offset
+ tag_length
;
680 switch (real_tag_type
)
682 case EDONKEY_MTAG_HASH
:
685 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
686 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
687 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
688 if (tag_type
==real_tag_type
)
689 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
690 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
691 proto_tree_add_item(metatag_tree
, hf_edonkey_hash
, tvb
, tag_offset
, 16, ENC_NA
);
694 case EDONKEY_MTAG_STRING
:
695 /* <Tag> ::= <Length (guint16)> <String> */
696 string_length
= tvb_get_letohs(tvb
, tag_offset
);
697 tag_length
+= 2+string_length
;
698 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
699 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
700 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
701 if (tag_type
==real_tag_type
)
702 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
703 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
704 proto_tree_add_uint(metatag_tree
, hf_edonkey_string_length
, tvb
, tag_offset
, 2, string_length
);
705 proto_tree_add_item(metatag_tree
, hf_edonkey_string
, tvb
, tag_offset
+2, string_length
, ENC_ASCII
|ENC_NA
);
708 case EDONKEY_MTAG_DWORD
:
709 /* <Tag> ::= guint32 */
711 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
712 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
713 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
714 if (tag_type
==real_tag_type
)
715 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
716 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
717 trans_tagtype
= edonkey_metatag_name_get_type(tvb
, offset
+3, tag_name_size
, special_tagtype
);
718 if (trans_tagtype
== EDONKEY_STAG_IP
) {
719 proto_tree_add_item(metatag_tree
, hf_edonkey_ip
, tvb
, tag_offset
, 4, ENC_BIG_ENDIAN
);
721 else if (trans_tagtype
== EMULE_STAG_SERVER_VERSION
) {
723 min
= tvb_get_letohs(tvb
, tag_offset
);
724 maj
= tvb_get_letohs(tvb
, tag_offset
+2);
725 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 4, "Meta Tag Value: %u.%u", maj
, min
);
728 tag_value_guint32
= tvb_get_letohl(tvb
, tag_offset
);
729 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 4, "Meta Tag Value: %u", tag_value_guint32
);
733 case EDONKEY_MTAG_FLOAT
:
734 /* <Tag> ::= 4 byte float */
736 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
737 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
738 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
739 if (tag_type
==real_tag_type
)
740 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
741 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
744 case EDONKEY_MTAG_WORD
:
745 /* <Tag> ::= guint16 */
747 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
748 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
749 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
750 if (tag_type
==real_tag_type
)
751 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
752 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
754 tag_value_guint16
= tvb_get_letohs(tvb
, tag_offset
);
755 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 2, "Meta Tag Value: %u", tag_value_guint16
);
759 case EDONKEY_MTAG_BYTE
:
760 /* <Tag> ::= guint8 */
762 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
763 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
764 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
765 if (tag_type
==real_tag_type
)
766 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
767 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
769 tag_value_guint8
= tvb_get_guint8(tvb
, tag_offset
);
770 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 1, "Meta Tag Value: %u", tag_value_guint8
);
774 case EDONKEY_MTAG_BOOL
:
775 /* <Tag> ::= <Bool (guint8)> */
777 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
778 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
779 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
780 if (tag_type
==real_tag_type
)
781 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
782 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
784 tag_value_guint8
= tvb_get_guint8(tvb
, tag_offset
);
785 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 1, "Meta Tag Value: %u", tag_value_guint8
);
789 case EDONKEY_MTAG_BOOL_ARRAY
:
790 /* <Tag> ::= <Length (guint16)> <BoolArray> */
791 array_length
= tvb_get_letohs(tvb
, tag_offset
);
793 * This is allegedly what the protocol uses, rather than the
794 * correct value of (array_length+7)/8
795 * Therefore an extra unused byte is transmitted if the array
796 * is a multiple of 8 longs.
798 tag_length
+= 2+(array_length
/8)+1;
799 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
800 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
801 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
802 if (tag_type
==real_tag_type
)
803 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
804 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
805 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 2, "Boolean Array Length: %u", array_length
);
808 case EDONKEY_MTAG_BLOB
:
809 /* <Tag> ::= <Length (guint32)> <BLOB> */
810 blob_length
= tvb_get_letohl(tvb
, tag_offset
);
811 tag_length
+= 4+blob_length
;
812 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
813 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
814 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
815 if (tag_type
==real_tag_type
)
816 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
817 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
818 proto_tree_add_text(metatag_tree
, tvb
, tag_offset
, 2, "BLOB Length: %u", blob_length
);
821 case EDONKEY_MTAG_BSOB
:
822 /* This is possibly a Binary Small OBject, like a BLOB but with an 8 or 16-bit length field */
823 /* That's a complete guess though, so don't handle it yet. */
824 case EDONKEY_MTAG_UNKNOWN
:
826 if (real_tag_type
>=EDONKEY_MTAG_STR1
&& real_tag_type
<=EDONKEY_MTAG_STR16
) {
827 /* <Tag> ::= <String> */
828 string_length
= real_tag_type
-EDONKEY_MTAG_STR1
+1;
829 tag_length
+= string_length
;
830 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
831 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
832 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_type
, tvb
, offset
, 1, tag_type
);
833 if (real_tag_type
==tag_type
)
834 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
835 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
836 proto_tree_add_item(metatag_tree
, hf_edonkey_string
, tvb
, tag_offset
, string_length
, ENC_ASCII
|ENC_NA
);
839 /* Unknown tag type - actual tag length is also unknown */
840 ti
= proto_tree_add_item(tree
, hf_edonkey_metatag
, tvb
, offset
, tag_length
, ENC_NA
);
841 metatag_tree
= proto_item_add_subtree(ti
, ett_edonkey_metatag
);
842 proto_tree_add_text(metatag_tree
, tvb
, offset
, 1, "Unknown Meta Tag Type (0x%02x)", tag_type
);
843 if (real_tag_type
==tag_type
)
844 proto_tree_add_uint(metatag_tree
, hf_edonkey_metatag_namesize
, tvb
, offset
+1, 2, tag_name_size
);
845 edonkey_tree_add_metatag_name(metatag_tree
, tvb
, tag_offset
-tag_name_size
, tag_name_size
, special_tagtype
);
851 return offset
+ tag_length
;
854 /* Dissects the eDonkey address */
855 static int dissect_edonkey_address(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
856 int offset
, proto_tree
*tree
)
858 /* <Address> ::= <IP> <Port> */
859 /* guint32 ip = tvb_get_letohl(tvb, offset);
860 proto_tree_add_ipv4(tree, hf_edonkey_ip, tvb, offset, 4, ip); */
861 proto_tree_add_item(tree
, hf_edonkey_ip
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
862 proto_tree_add_item(tree
, hf_edonkey_port
, tvb
, offset
+4, 2, ENC_LITTLE_ENDIAN
);
867 static int dissect_kademlia_udp_port(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
868 int offset
, proto_tree
*tree
)
870 proto_tree_add_item(tree
, hf_kademlia_udp_port
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
874 static int dissect_kademlia_tcp_port(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
875 int offset
, proto_tree
*tree
)
877 proto_tree_add_item(tree
, hf_kademlia_tcp_port
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
882 static int dissect_kademlia_ip_address(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
883 int offset
, proto_tree
*tree
)
885 proto_tree_add_item(tree
, hf_kademlia_ip
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
890 static int dissect_kademlia_address(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
891 int offset
, proto_tree
*tree
)
893 /* <Address> ::= <IP> <Port> <Tcp Port>*/
894 offset
= dissect_kademlia_ip_address( tvb
, pinfo
, offset
, tree
);
896 offset
= dissect_kademlia_udp_port( tvb
, pinfo
, offset
, tree
);
898 offset
= dissect_kademlia_tcp_port( tvb
, pinfo
, offset
, tree
);
903 static int dissect_kademlia_tagname(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
904 int offset
, proto_tree
*tree
, const gchar
** outputTagName
, const gchar
** outputExtendedTagName
)
906 /* <String> ::= <String length (guint16)> DATA */
907 const gchar
* tagname
;
908 const gchar
* tag_full_name
= NULL
;
909 guint8 tagname_value
;
910 proto_item
*ti
, *hidden_item
;
912 guint16 string_length
= tvb_get_letohs(tvb
, offset
);
914 proto_tree_add_uint(tree
, hf_kademlia_tag_name_length
, tvb
, offset
, 2, string_length
);
916 hidden_item
= proto_tree_add_uint(tree
, hf_edonkey_string_length
, tvb
, offset
, 2, string_length
);
917 PROTO_ITEM_SET_HIDDEN(hidden_item
);
919 tagname
= tvb_get_string(wmem_packet_scope(), tvb
, offset
+ 2, string_length
);
921 tag_full_name
= "UnknownTagName";
923 if ( tagname
&& string_length
== 1 ) {
924 tagname_value
= *(guint8
*)tagname
;
926 tag_full_name
= val_to_str_const( tagname_value
, kademlia_tags
, tag_full_name
);
929 ti
= proto_tree_add_item(tree
, hf_kademlia_tag_name
, tvb
, offset
+2, string_length
, ENC_BIG_ENDIAN
);
930 proto_item_append_text(ti
, " [%s]", tag_full_name
);
933 *outputTagName
= tagname
;
935 if (outputExtendedTagName
)
936 *outputExtendedTagName
= tag_full_name
;
938 return offset
+2+string_length
;
941 static int dissect_kademlia_string(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
942 int offset
, proto_tree
*tree
)
944 /* <String> ::= <String length (guint16)> DATA */
945 const gchar
* string_value
;
946 guint16 string_length
;
947 string_length
= tvb_get_letohs(tvb
, offset
);
949 proto_tree_add_uint(tree
, hf_edonkey_string_length
, tvb
, offset
, 2, string_length
);
951 string_value
= tvb_get_string(wmem_packet_scope(), tvb
, offset
+ 2, string_length
);
953 proto_tree_add_text(tree
, tvb
, offset
+2, string_length
, "String: %s", string_value
);
955 return offset
+2+string_length
;
958 /* Dissects the eDonkey address list */
959 static int dissect_edonkey_address_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
960 int offset
, proto_tree
*tree
)
962 /* <Address List> ::= <List Size (guint8)> <Address>* */
963 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 1, "Address", dissect_edonkey_address
);
966 /* Dissects the eDonkey hash */
967 static int dissect_edonkey_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
968 int offset
, proto_tree
*tree
)
970 /* <hash> ::= HASH (16 word MD4 digest) */
971 proto_tree_add_item(tree
, hf_edonkey_hash
, tvb
, offset
, 16, ENC_NA
);
975 /* Dissects the eDonkey file hash */
976 static int dissect_edonkey_file_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
977 int offset
, proto_tree
*tree
)
979 /* <File hash> ::= HASH (16 word MD4 digest) */
980 proto_tree_add_item(tree
, hf_edonkey_file_hash
, tvb
, offset
, 16, ENC_NA
);
984 /* Dissects the eMule public key */
985 static int dissect_edonkey_public_key(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
986 int offset
, proto_tree
*tree
)
988 guint8 length
= tvb_get_guint8(tvb
, offset
);
989 proto_tree_add_text(tree
, tvb
, offset
, 1, "Public key length: %u", length
);
991 proto_tree_add_item(tree
, hf_emule_public_key
, tvb
, offset
, length
, ENC_NA
);
992 return offset
+ length
;
995 /* Dissects the eMule signature */
996 static int dissect_edonkey_signature(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
997 int offset
, proto_tree
*tree
)
999 guint8 length
= tvb_get_guint8(tvb
, offset
);
1000 proto_tree_add_text(tree
, tvb
, offset
, 1, "Signature length: %u", length
);
1002 proto_tree_add_item(tree
, hf_emule_signature
, tvb
, offset
, length
, ENC_NA
);
1003 return offset
+ length
;
1006 static const char *kademlia_hash(tvbuff_t
*tvb
, int offset
) {
1010 for (i
= 0; i
< 4; i
++)
1011 hash
[i
] = tvb_get_letohl(tvb
, offset
+ i
*4);
1013 return wmem_strdup_printf(wmem_packet_scope(),
1014 "%08X%08X%08X%08X", hash
[0], hash
[1], hash
[2], hash
[3]);
1017 static int dissect_kademlia_hash_hidden(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1018 int offset
, proto_tree
*tree
) {
1019 proto_item
*hidden_item
;
1022 hash
= kademlia_hash(tvb
, offset
);
1024 /* <File hash> ::= HASH (16 word MD4 digest) */
1025 hidden_item
= proto_tree_add_string(tree
, hf_kademlia_hash
, tvb
, offset
, 16, hash
);
1026 PROTO_ITEM_SET_HIDDEN(hidden_item
);
1031 /* Dissects the Kademlia hash*/
1032 static int dissect_kademlia_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1033 int offset
, proto_tree
*tree
, int *value_ptr
) {
1036 hash
= kademlia_hash(tvb
, offset
);
1038 /* <File hash> ::= HASH (16 word MD4 digest) */
1039 proto_tree_add_string(tree
, *value_ptr
, tvb
, offset
, 16, hash
);
1041 return dissect_kademlia_hash_hidden(tvb
, pinfo
, offset
, tree
);
1044 static int dissect_kademlia_tag_hash_hidden(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1045 int offset
, proto_tree
*tree
) {
1046 proto_item
*hidden_item
;
1049 hash
= kademlia_hash(tvb
, offset
);
1051 /* <File hash> ::= HASH (16 word MD4 digest) */
1052 hidden_item
= proto_tree_add_string(tree
, hf_kademlia_tag_hash
, tvb
, offset
, 16, hash
);
1053 PROTO_ITEM_SET_HIDDEN(hidden_item
);
1058 static int dissect_kademlia_tag_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1059 int offset
, proto_tree
*tree
) {
1062 hash
= kademlia_hash(tvb
, offset
);
1064 /* <File hash> ::= HASH (16 word MD4 digest) */
1065 proto_tree_add_string(tree
, hf_kademlia_hash
, tvb
, offset
, 16, hash
);
1066 return dissect_kademlia_tag_hash_hidden( tvb
, pinfo
, offset
, tree
);
1069 static int dissect_kademlia_tag_bsob(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1070 int offset
, proto_tree
*tree
, const gchar
** string_value
)
1072 guint16 bsob_length
;
1074 bsob_length
= tvb_get_guint8(tvb
, offset
);
1075 *string_value
= tvb_bytes_to_str( tvb
, offset
+ 1, bsob_length
);
1077 proto_tree_add_item(tree
, hf_kademlia_tag_bsob
, tvb
, offset
+ 1, bsob_length
, ENC_NA
);
1078 return offset
+ 1 + bsob_length
;
1082 static int dissect_kademlia_tag_string(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1083 int offset
, proto_tree
*tree
, const gchar
** string_value
)
1085 proto_item
*hidden_item
;
1086 guint16 string_length
= tvb_get_letohs(tvb
, offset
);
1088 hidden_item
= proto_tree_add_uint(tree
, hf_edonkey_string_length
, tvb
, offset
, 2, string_length
);
1089 PROTO_ITEM_SET_HIDDEN(hidden_item
);
1090 hidden_item
= proto_tree_add_item(tree
, hf_edonkey_string
, tvb
, offset
+2, string_length
, ENC_ASCII
|ENC_NA
);
1091 PROTO_ITEM_SET_HIDDEN(hidden_item
);
1092 *string_value
= tvb_get_string(wmem_packet_scope(), tvb
, offset
+ 2, string_length
);
1094 proto_tree_add_item(tree
, hf_kademlia_tag_string
, tvb
, offset
+ 2, string_length
, ENC_ASCII
|ENC_NA
);
1095 return offset
+ 2 + string_length
;
1098 /* Dissects the eDonkey hash list */
1099 static int dissect_edonkey_hash_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1100 int offset
, proto_tree
*tree
)
1102 /* <Hash List> ::= <File Hash> <List Size (guint16)> <Hash>* */
1103 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1104 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Hash", dissect_edonkey_hash
);
1107 /* Dissects the eDonkey meta tag list */
1108 static int dissect_edonkey_metatag_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1109 int offset
, proto_tree
*tree
)
1111 /* <Meta Tag List> ::= <List Size (guint32)> <Meta tag>* */
1112 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 4, "Meta Tag", dissect_edonkey_metatag
);
1115 /* Dissects the eDonkey String */
1116 static int dissect_edonkey_string(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1117 int offset
, proto_tree
*tree
)
1119 /* <String> ::= <String length (guint16)> DATA */
1120 guint16 string_length
= tvb_get_letohs(tvb
, offset
);
1121 proto_tree_add_uint(tree
, hf_edonkey_string_length
, tvb
, offset
, 2, string_length
);
1122 proto_tree_add_item(tree
, hf_edonkey_string
, tvb
, offset
+2, string_length
, ENC_ASCII
|ENC_NA
);
1123 return offset
+2+string_length
;
1126 /* Dissects the eDonkey Directory */
1127 static int dissect_edonkey_directory(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1128 int offset
, proto_tree
*tree
)
1130 /* <Directory> ::= <String> */
1131 guint16 string_length
= tvb_get_letohs(tvb
, offset
);
1132 proto_tree_add_uint(tree
, hf_edonkey_string_length
, tvb
, offset
, 2, string_length
);
1133 proto_tree_add_item(tree
, hf_edonkey_directory
, tvb
, offset
+2, string_length
, ENC_ASCII
|ENC_NA
);
1134 return offset
+2+string_length
;
1137 /* Dissects the eDonkey Filename */
1138 static int dissect_edonkey_file_name(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1139 int offset
, proto_tree
*tree
)
1141 /* <Filename> ::= <String> */
1142 return dissect_edonkey_string(tvb
, pinfo
, offset
, tree
);
1145 /* Dissects the eDonkey File Status */
1146 static int dissect_edonkey_file_status(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1147 int offset
, proto_tree
*tree
)
1149 guint16 partcount
, arrlen
;
1151 /* <File Status> ::= <Part Count> <Part Status> */
1152 partcount
= tvb_get_letohs(tvb
, offset
);
1153 arrlen
= (partcount
+7)/8;
1155 proto_tree_add_uint(tree
, hf_edonkey_part_count
, tvb
, offset
, 2, partcount
);
1157 proto_tree_add_item(tree
, hf_edonkey_file_status
, tvb
, offset
+2, arrlen
, ENC_NA
);
1159 return offset
+2+arrlen
;
1163 /* Dissects the eDonkey directory list */
1164 static int dissect_edonkey_directory_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1165 int offset
, proto_tree
*tree
)
1167 /* <Directory List> ::= <List Size (guint32)> <Directory>* */
1168 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 4, "Directory", dissect_edonkey_directory
);
1171 /* Dissects the eDonkey server hash */
1172 static int dissect_edonkey_server_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1173 int offset
, proto_tree
*tree
)
1175 /* <Server hash> ::= HASH (16 word MD4 digest) */
1176 proto_tree_add_item(tree
, hf_edonkey_server_hash
, tvb
, offset
, 16, ENC_NA
);
1180 /* Dissects the eDonkey client hash */
1181 static int dissect_edonkey_client_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1182 int offset
, proto_tree
*tree
)
1184 /* <Client hash> ::= HASH (16 word MD4 digest) */
1185 proto_tree_add_item(tree
, hf_edonkey_client_hash
, tvb
, offset
, 16, ENC_NA
);
1189 /* Dissects the eMule sourceOBFU */
1190 static int dissect_emule_sourceOBFU(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1191 int offset
, proto_tree
*tree
)
1195 proto_tree
*sourceOBFU_tree
;
1196 guint8 settings
= tvb_get_guint8(tvb
, offset
+6);
1197 /* Add subtree for client info */
1198 ti
= proto_tree_add_item(tree
, hf_emule_sourceOBFU
, tvb
, offset
, 7 + ((settings
& 0x80) ? 16 : 0), ENC_NA
);
1199 sourceOBFU_tree
= proto_item_add_subtree(ti
, ett_emule_sourceOBFU
);
1201 proto_tree_add_item(sourceOBFU_tree
, hf_edonkey_ip
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1202 proto_tree_add_item(sourceOBFU_tree
, hf_edonkey_port
, tvb
, offset
+4, 2, ENC_LITTLE_ENDIAN
);
1203 proto_tree_add_text(sourceOBFU_tree
, tvb
, offset
+6, 1, "Obfuscation Settings: %u", settings
);
1205 if (settings
& 0x80)
1206 offset
= dissect_edonkey_client_hash(tvb
, pinfo
, offset
, sourceOBFU_tree
);
1211 /* Dissects the eMule sourceOBFU list */
1212 static int dissect_emule_sourceOBFU_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1213 int offset
, proto_tree
*tree
)
1215 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 1, "Sources Obfuscation", dissect_emule_sourceOBFU
);
1219 /* Dissects the eDonkey client ID */
1220 static int dissect_edonkey_client_id(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1221 int offset
, proto_tree
*tree
, gboolean fileinfo
)
1224 /* <Client ID> ::= guint32 */
1225 /* guint32 ip = tvb_get_letohl(tvb, offset);
1226 proto_tree_add_ipv4(tree, hf_edonkey_client_id, tvb, offset, 4, ip); */
1227 ti
= proto_tree_add_item(tree
, hf_edonkey_client_id
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1229 guint32 ip
= tvb_get_letohl(tvb
, offset
);
1230 guint16 port
= tvb_get_letohs(tvb
, offset
+4);
1231 if (ip
==0xfcfcfcfc && port
==0xfcfc) {
1232 proto_item_append_text(ti
, " (myself, incomplete file)");
1233 } else if (ip
==0xfbfbfbfb && port
==0xfbfb) {
1234 proto_item_append_text(ti
, " (myself, complete file)");
1240 /* Dissects the eDonkey port */
1241 static int dissect_edonkey_port(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1242 int offset
, proto_tree
*tree
)
1244 /* <Port> ::= guint16 */
1245 proto_tree_add_item(tree
, hf_edonkey_port
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1249 /* Dissects the eDonkey start offset */
1250 static int dissect_edonkey_start_offset(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1251 int offset
, proto_tree
*tree
)
1253 /* <Start Offset> ::= guint32 */
1254 guint32 start
= tvb_get_letohl(tvb
, offset
);
1255 proto_tree_add_text(tree
, tvb
, offset
, 4, "Start Offset: %u", start
);
1259 static int dissect_edonkey_start_offset_64(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1260 int offset
, proto_tree
*tree
)
1262 /* <Start Offset> ::= guint64 */
1263 guint64 start
= tvb_get_letoh64(tvb
, offset
);
1264 proto_tree_add_text(tree
, tvb
, offset
, 8, "Start Offset: %" G_GINT64_MODIFIER
"u", start
);
1268 /* Dissects the eDonkey end offset */
1269 static int dissect_edonkey_end_offset(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1270 int offset
, proto_tree
*tree
)
1272 /* <End Offset> ::= guint32 */
1273 guint32 end
= tvb_get_letohl(tvb
, offset
);
1274 proto_tree_add_text(tree
, tvb
, offset
, 4, "End Offset: %u", end
);
1278 static int dissect_edonkey_end_offset_64(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1279 int offset
, proto_tree
*tree
)
1281 /* <End Offset> ::= guint64 */
1282 guint64 end
= tvb_get_letoh64(tvb
, offset
);
1283 proto_tree_add_text(tree
, tvb
, offset
, 8, "End Offset: %" G_GINT64_MODIFIER
"u", end
);
1287 /* Dissects the eDonkey client info */
1288 static int dissect_edonkey_client_info(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1289 int offset
, proto_tree
*tree
)
1291 /* <Client info> ::= <Client hash> <Client ID> <Port> <Meta tag list> */
1293 proto_tree
*clientinfo_tree
;
1294 /* Add subtree for client info */
1295 ti
= proto_tree_add_item(tree
, hf_edonkey_clientinfo
, tvb
, offset
, 0, ENC_NA
);
1296 clientinfo_tree
= proto_item_add_subtree(ti
, ett_edonkey_clientinfo
);
1297 offset
= dissect_edonkey_client_hash(tvb
, pinfo
, offset
, clientinfo_tree
);
1298 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, clientinfo_tree
, FALSE
);
1299 offset
= dissect_edonkey_port(tvb
, pinfo
, offset
, clientinfo_tree
);
1300 offset
= dissect_edonkey_metatag_list(tvb
, pinfo
, offset
, clientinfo_tree
);
1304 /* Dissects the eDonkey client info list */
1305 static int dissect_edonkey_client_info_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1306 int offset
, proto_tree
*tree
)
1308 /* <Client Info List> ::= <List Size (guint32)> <Client Info>* */
1309 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 4, "Client Info", dissect_edonkey_client_info
);
1312 /* Dissects the eDonkey server info */
1313 static int dissect_edonkey_server_info(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1314 int offset
, proto_tree
*tree
)
1316 /* <Server info> ::= <Server hash> <Server Address> <Meta tag list> */
1318 proto_tree
*serverinfo_tree
;
1319 /* Add subtree for server info */
1320 ti
= proto_tree_add_item(tree
, hf_edonkey_serverinfo
, tvb
, offset
, 0, ENC_NA
);
1321 serverinfo_tree
= proto_item_add_subtree(ti
, ett_edonkey_serverinfo
);
1322 offset
= dissect_edonkey_server_hash(tvb
, pinfo
, offset
, serverinfo_tree
);
1323 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, serverinfo_tree
);
1324 offset
= dissect_edonkey_metatag_list(tvb
, pinfo
, offset
, serverinfo_tree
);
1328 /* Dissects the eDonkey file info */
1329 static int dissect_edonkey_file_info(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1330 int offset
, proto_tree
*tree
)
1332 /* <File info> ::= <File hash> <Client ID> <Port> <Meta tag list> */
1334 proto_tree
*fileinfo_tree
;
1336 /* Add subtree for file info */
1337 ti
= proto_tree_add_item(tree
, hf_edonkey_fileinfo
, tvb
, offset
, 0, ENC_NA
);
1339 fileinfo_tree
= proto_item_add_subtree(ti
, ett_edonkey_fileinfo
);
1340 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, fileinfo_tree
);
1341 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, fileinfo_tree
, TRUE
);
1342 offset
= dissect_edonkey_port(tvb
, pinfo
, offset
, fileinfo_tree
);
1343 offset
= dissect_edonkey_metatag_list(tvb
, pinfo
, offset
, fileinfo_tree
);
1344 proto_item_set_len(ti
, offset
-startoff
);
1348 /* Dissects the eDonkey file info list */
1349 static int dissect_edonkey_file_info_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1350 int offset
, proto_tree
*tree
)
1352 /* <File Info List> ::= <List Size (guint32)> <File Info>* */
1353 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 4, "File Info", dissect_edonkey_file_info
);
1357 /* Dissects the eMule address list */
1358 static int dissect_emule_address_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1359 int offset
, proto_tree
*tree
)
1361 /* <Address List> ::= <List Size (guint16)> <Address>* */
1362 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Address", dissect_edonkey_address
);
1365 static int dissect_emule_aich_root_hash(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1366 int offset
, proto_tree
*tree
)
1368 /* <AICH Root Hash> ::= HASH (20 byte SHA1 digest) */
1369 proto_tree_add_item(tree
, hf_emule_aich_root_hash
, tvb
, offset
, 20, ENC_NA
);
1373 static int dissect_emule_aich_hash_list_entry(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1374 int offset
, proto_tree
*tree
)
1378 proto_tree
*aichhash_tree
;
1379 /* <AICH Hash List Entry> ::= <AICH Hash ID> <AICH Hash> */
1380 ti
= proto_tree_add_item(tree
, hf_emule_aich_hash_entry
, tvb
, offset
, 22, ENC_NA
);
1381 aichhash_tree
= proto_item_add_subtree(ti
, ett_emule_aichhash
);
1383 hashid
= tvb_get_letohs(tvb
, offset
);
1384 proto_tree_add_uint(aichhash_tree
, hf_emule_aich_hash_id
, tvb
, offset
, 2, hashid
);
1385 proto_tree_add_item(aichhash_tree
, hf_emule_aich_hash
, tvb
, offset
+2, 20, ENC_NA
);
1389 static int dissect_emule_aich_hash_list(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1390 int offset
, proto_tree
*tree
)
1392 /* <AICH Hash List> ::= <List Size (guint16)> < <AICH Hash ID> <AICH Hash> >* */
1393 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "AICH Hash", dissect_emule_aich_hash_list_entry
);
1396 static int dissect_emule_multipacket(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1397 int offset
, int eoffset
, proto_tree
*tree
, int isext
)
1399 guint8 opcode
, nextop
;
1400 guint16 namelen
, partcount
, arrlen
, oplen
;
1401 guint32 sourcecount
;
1403 proto_tree
*mp_tree
;
1405 /* <MultiPacket> ::= <File Hash> <Opcodes>* */
1406 /* <MultiPacketExt> ::= <File Hash> <FileLength> <Opcodes>* */
1407 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1410 guint64 filelen
= tvb_get_letoh64(tvb
, offset
);
1411 proto_tree_add_text(tree
, tvb
, offset
, 8, "File Length: %" G_GINT64_MODIFIER
"u", filelen
);
1415 while (offset
<eoffset
) {
1416 opcode
= tvb_get_guint8(tvb
, offset
);
1419 case EDONKEY_MSG_FILE_STATUS_REQUEST
:
1420 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, 1, ENC_NA
);
1421 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1423 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1424 opcode
, "File Status Request (0x%02x)", opcode
);
1427 case EDONKEY_MSG_FILE_REQUEST
:
1428 partcount
= 443; /* Invalid */
1429 sourcecount
= 65536; /* Out of range */
1433 if (offset
+2<eoffset
) {
1434 nextop
= tvb_get_guint8(tvb
, offset
+1);
1435 if (nextop
!=EDONKEY_MSG_FILE_STATUS_REQUEST
&&
1436 nextop
!=EMULE_MSG_SOURCES_REQUEST
&&
1437 nextop
!=EMULE_MSG_AICHFILEHASH_REQUEST
) {
1439 partcount
= tvb_get_letohs(tvb
, offset
+1);
1440 if (partcount
<=442) {
1441 arrlen
= (partcount
+7)/8;
1444 if (offset
+2+arrlen
+2<eoffset
) {
1445 nextop
= tvb_get_guint8(tvb
, offset
+2+arrlen
+1);
1446 if (nextop
!=EDONKEY_MSG_FILE_STATUS_REQUEST
&&
1447 nextop
!=EMULE_MSG_SOURCES_REQUEST
&&
1448 nextop
!=EMULE_MSG_AICHFILEHASH_REQUEST
) {
1450 sourcecount
= tvb_get_letohs(tvb
, offset
+2+arrlen
+1);
1458 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, oplen
, ENC_NA
);
1459 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1461 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1462 opcode
, "File Name Request (0x%02x)", opcode
);
1463 if (partcount
<=442) {
1464 dissect_edonkey_file_status(tvb
, pinfo
, offset
+1, mp_tree
);
1465 if (sourcecount
<65536) {
1466 proto_tree_add_uint(mp_tree
, hf_emule_source_count
, tvb
, offset
+3+arrlen
, 2, sourcecount
);
1471 case EMULE_MSG_SOURCES_REQUEST
:
1472 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, 1, ENC_NA
);
1473 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1475 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1476 opcode
, "Sources Request (0x%02x)", opcode
);
1479 case EMULE_MSG_AICHFILEHASH_REQUEST
:
1480 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, 1, ENC_NA
);
1481 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1483 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1484 opcode
, "AICH Root Hash Request (0x%02x)", opcode
);
1488 case EDONKEY_MSG_FILE_STATUS
:
1489 partcount
= tvb_get_letohs(tvb
, offset
+1);
1490 arrlen
= (partcount
+7)/8;
1492 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, 3+arrlen
, ENC_NA
);
1493 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1495 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1496 opcode
, "File Status (0x%02x)", opcode
);
1497 offset
= dissect_edonkey_file_status(tvb
, pinfo
, offset
+1, mp_tree
);
1499 case EDONKEY_MSG_FILE_REQUEST_ANSWER
:
1500 namelen
= tvb_get_letohs(tvb
, offset
+1);
1502 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, 3+namelen
, ENC_NA
);
1503 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1505 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1506 opcode
, "File Name (0x%02x)", opcode
);
1507 offset
= dissect_edonkey_file_name(tvb
, pinfo
, offset
+1, mp_tree
);
1509 case EMULE_MSG_AICHFILEHASH_ANSWER
:
1510 ti
= proto_tree_add_item(tree
, hf_emule_multipacket_entry
, tvb
, offset
, 21, ENC_NA
);
1511 mp_tree
= proto_item_add_subtree(ti
, ett_emule_multipacket
);
1513 proto_tree_add_uint_format(mp_tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1514 opcode
, "AICH Root Hash (0x%02x)", opcode
);
1515 proto_tree_add_item(mp_tree
, hf_emule_aich_root_hash
, tvb
, offset
+1, 20, ENC_NA
);
1520 /* Unknown opcode means we can't continue parsing the stream */
1521 proto_tree_add_uint_format(tree
, hf_emule_multipacket_opcode
, tvb
, offset
, 1,
1522 opcode
, "Unknown MultiPacket opcode (0x%02x)", opcode
);
1530 /* Dissects the Overnet peer type */
1531 static int dissect_overnet_peertype(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1532 int offset
, proto_tree
*tree
)
1534 /* <Peer type> ::= guint8 */
1535 guint8 peertype
= tvb_get_guint8(tvb
, offset
);
1536 proto_tree_add_text(tree
, tvb
, offset
, 1, "Peer Type: %u", peertype
);
1540 /* Dissects the Overnet peer */
1541 static int dissect_overnet_peer(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1542 int offset
, proto_tree
*tree
)
1544 /* <Peer> ::= <Hash> <Address> <Peer type> */
1546 proto_tree
*peer_tree
;
1547 ti
= proto_tree_add_item(tree
, hf_overnet_peer
, tvb
, offset
, 16 + 6 + 1, ENC_NA
);
1548 peer_tree
= proto_item_add_subtree(ti
, ett_overnet_peer
);
1549 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, peer_tree
);
1550 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, peer_tree
);
1551 offset
= dissect_overnet_peertype(tvb
, pinfo
, offset
, peer_tree
);
1555 static int dissect_kademlia_peertype(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1556 int offset
, proto_tree
*tree
)
1558 /* <Peer type> ::= 1bytes */
1559 proto_tree_add_item( tree
, hf_kademlia_peertype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1563 /* Dissects the Kademlia peer */
1564 static int dissect_kademlia_peer(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1565 int offset
, proto_tree
*tree
)
1567 /* <Peer> ::= <Hash> <Address> <Peer type> */
1569 proto_tree
*peer_tree
;
1572 ti
= proto_tree_add_item(tree
, hf_kademlia_peer
, tvb
, offset
, 16 + 4 + 4 + 1, ENC_NA
);
1574 peer_tree
= proto_item_add_subtree(ti
, ett_overnet_peer
);
1577 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, peer_tree
, &hf_kademlia_peer_id
);
1579 /* 8 ( 4 ip + 2 tcp port + 2 udp port ) */
1580 offset
= dissect_kademlia_address(tvb
, pinfo
, offset
, peer_tree
);
1583 /* offset = dissect_kademlia_peertype(tvb, pinfo, offset, peer_tree); */
1584 kad_version
= tvb_get_guint8(tvb
, offset
);
1585 ti
= proto_tree_add_item(peer_tree
, hf_kademlia_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1586 proto_item_append_text(ti
, "%s", val_to_str_const(kad_version
, kademlia_versions
, " Unknown"));
1590 /* Dissects the Kademlia2 peer */
1591 static int dissect_kademlia2_peer(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1592 int offset
, proto_tree
*tree
)
1594 /* <Peer> ::= <Hash> <Address> <Peer type> */
1596 proto_tree
*peer_tree
;
1598 ti
= proto_tree_add_item(tree
, hf_kademlia_peer
, tvb
, offset
, 16 + 4 + 4 + 1, ENC_NA
);
1600 peer_tree
= proto_item_add_subtree(ti
, ett_overnet_peer
);
1603 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, peer_tree
, &hf_kademlia_peer_id
);
1605 /* 8 ( 4 ip + 2 tcp port + 2 udp port ) */
1606 offset
= dissect_kademlia_address(tvb
, pinfo
, offset
, peer_tree
);
1609 offset
= dissect_kademlia_peertype(tvb
, pinfo
, offset
, peer_tree
);
1614 /* Dissects the eDonkey search query */
1615 static int dissect_edonkey_search_query(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1616 int offset
, proto_tree
*tree
)
1618 /* <Search Query> ::= <Search Type> <Search> */
1620 proto_tree
*search_tree
;
1621 guint8 search_type
, e_operator
, special_tagtype
, limit_type
;
1622 guint16 tag_name_size
, string_length
;
1623 guint32 search_length
, limit
;
1624 int string_offset
, tag_name_offset
;
1626 search_type
= tvb_get_guint8(tvb
, offset
);
1629 switch (search_type
)
1631 case EDONKEY_SEARCH_BOOL
:
1632 /* <Search> ::= <Operator> <Search Query> <Search Query> */
1634 e_operator
= tvb_get_guint8(tvb
, offset
+1);
1636 /* Add subtree for search entry */
1637 ti
= proto_tree_add_item(tree
, hf_edonkey_search
, tvb
, offset
, search_length
, ENC_NA
);
1638 search_tree
= proto_item_add_subtree(ti
, ett_edonkey_search
);
1640 /* Add query info */
1641 proto_tree_add_text(search_tree
, tvb
, offset
, 2, "Boolean search (0x%02x): %s (0x%02x)",
1642 search_type
, val_to_str_const(e_operator
, edonkey_search_ops
, "Unknown"), e_operator
);
1645 offset
= dissect_edonkey_search_query(tvb
, pinfo
, offset
, search_tree
);
1646 offset
= dissect_edonkey_search_query(tvb
, pinfo
, offset
, search_tree
);
1649 case EDONKEY_SEARCH_NAME
:
1650 /* <Search> ::= <String> */
1651 string_offset
= offset
+ search_length
;
1652 string_length
= tvb_get_letohs(tvb
, string_offset
);
1653 search_length
+= 2+string_length
;
1655 /* Add subtree for search entry */
1656 ti
= proto_tree_add_item(tree
, hf_edonkey_search
, tvb
, offset
, search_length
, ENC_NA
);
1657 search_tree
= proto_item_add_subtree(ti
, ett_edonkey_search
);
1659 /* Add query info */
1660 proto_tree_add_text(search_tree
, tvb
, offset
, 1, "Search by name (0x%02x)", search_type
);
1661 proto_tree_add_uint(search_tree
, hf_edonkey_string_length
, tvb
, string_offset
, 2, string_length
);
1662 proto_tree_add_item(search_tree
, hf_edonkey_string
, tvb
, string_offset
+2, string_length
, ENC_ASCII
|ENC_NA
);
1663 offset
+= search_length
;
1666 case EDONKEY_SEARCH_META
:
1667 /* <Search> ::= <String> <Meta tag Name> */
1668 string_offset
= offset
+ search_length
;
1669 string_length
= tvb_get_letohs(tvb
, offset
+1);
1670 search_length
+= 2+string_length
;
1672 tag_name_offset
= offset
+ search_length
;
1673 tag_name_size
= tvb_get_letohs(tvb
, tag_name_offset
);
1674 special_tagtype
= tvb_get_guint8(tvb
, tag_name_offset
+2);
1675 search_length
+= 2 + tag_name_size
;
1677 /* Add subtree for search entry */
1678 ti
= proto_tree_add_item(tree
, hf_edonkey_search
, tvb
, offset
, search_length
, ENC_NA
);
1679 search_tree
= proto_item_add_subtree(ti
, ett_edonkey_search
);
1681 /* Add query info */
1682 proto_tree_add_text(search_tree
, tvb
, offset
, 1, "Search by metadata (0x%02x)", search_type
);
1683 proto_tree_add_uint(search_tree
, hf_edonkey_string_length
, tvb
, string_offset
, 2, string_length
);
1684 proto_tree_add_item(search_tree
, hf_edonkey_string
, tvb
, string_offset
+2, string_length
, ENC_ASCII
|ENC_NA
);
1685 proto_tree_add_uint(search_tree
, hf_edonkey_metatag_namesize
, tvb
, tag_name_offset
, 2, tag_name_size
);
1686 edonkey_tree_add_metatag_name(search_tree
, tvb
, tag_name_offset
+2, tag_name_size
, special_tagtype
);
1687 offset
+= search_length
;
1690 case EDONKEY_SEARCH_LIMIT
:
1691 /* <Search> ::= <Limit (guint32)> <Minmax> <Meta tag Name> */
1692 search_length
+= 5; /* 4 bytes for the limit, one for the minmax */
1693 limit
= tvb_get_letohl(tvb
, offset
+1);
1694 limit_type
= tvb_get_guint8(tvb
, offset
+5);
1696 tag_name_offset
= offset
+ search_length
;
1697 tag_name_size
= tvb_get_letohs(tvb
, tag_name_offset
);
1698 special_tagtype
= tvb_get_guint8(tvb
, tag_name_offset
+2);
1699 search_length
+= 2 + tag_name_size
;
1701 /* Add subtree for search entry */
1702 ti
= proto_tree_add_item(tree
, hf_edonkey_search
, tvb
, offset
, search_length
, ENC_NA
);
1703 search_tree
= proto_item_add_subtree(ti
, ett_edonkey_search
);
1705 /* Add query info */
1706 proto_tree_add_text(search_tree
, tvb
, offset
, 6, "Search by limit (0x%02x): %s %u",
1707 search_type
, val_to_str_const(limit_type
, edonkey_search_conds
, "Unknown"), limit
);
1708 proto_tree_add_uint(search_tree
, hf_edonkey_metatag_namesize
, tvb
, tag_name_offset
, 2, tag_name_size
);
1709 edonkey_tree_add_metatag_name(search_tree
, tvb
, tag_name_offset
+2, tag_name_size
, special_tagtype
);
1710 offset
+= search_length
;
1714 /* Unknown search type - actual search length is also unknown */
1715 ti
= proto_tree_add_item(tree
, hf_edonkey_search
, tvb
, offset
, search_length
, ENC_NA
);
1716 search_tree
= proto_item_add_subtree(ti
, ett_edonkey_search
);
1717 proto_tree_add_text(search_tree
, tvb
, offset
, search_length
, "Unknown Search (0x%02x)", search_type
);
1718 offset
+= search_length
;
1725 static void dissect_edonkey_tcp_message(guint8 msg_type
,
1726 tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1727 int offset
, int length
, proto_tree
*tree
)
1729 int msg_end
, bytes_remaining
;
1730 guint8 helloClient
, more
;
1731 guint32 nusers
, nfiles
;
1733 if (tree
== NULL
) return;
1735 bytes_remaining
= tvb_reported_length_remaining(tvb
, offset
);
1736 if ((length
< 0) || (length
> bytes_remaining
)) length
= bytes_remaining
;
1737 if (length
<= 0) return;
1739 msg_end
= offset
+ length
;
1742 case EDONKEY_MSG_HELLO
:
1743 /* Client to Server: <Client Info> */
1744 /* Client to Client: 0x10 <Client Info> <Server address> */
1745 /* If Hello is sent to server 0x10 before UserHash is skipped,
1746 but UserHash might starts with 0x10. To decrease posibility
1747 of mistake, we check also 6th and 15h byte of UserHash -
1748 they have constant value. The best way would be to process
1749 whole packet to check it. */
1750 helloClient
= (tvb_get_guint8(tvb
, offset
) == 0x10 && tvb_get_guint8(tvb
, offset
+ 6) == 0x0E && tvb_get_guint8(tvb
, offset
+ 15) == 0x6F);
1752 proto_tree_add_text(tree
, tvb
, offset
, 1, "User hash length: 16");
1755 offset
= dissect_edonkey_client_info(tvb
, pinfo
, offset
, tree
);
1756 if (helloClient
) /* User's server ip is sent only to clients. */
1757 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, tree
);
1760 case EDONKEY_MSG_HELLO_ANSWER
: /* Hello Answer: <Client Info> <Server address> */
1761 offset
= dissect_edonkey_client_info(tvb
, pinfo
, offset
, tree
);
1762 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, tree
);
1765 case EDONKEY_MSG_SERVER_CB_REQ
: /* Server Callback Request: <Client address> */
1766 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, tree
);
1769 case EDONKEY_MSG_SERVER_INFO_DATA
: /* Server Info Data: <Server Info> */
1770 offset
= dissect_edonkey_server_info(tvb
, pinfo
, offset
, tree
);
1773 case EDONKEY_MSG_SERVER_LIST
: /* Server List: <Address List> */
1774 offset
= dissect_edonkey_address_list(tvb
, pinfo
, offset
, tree
);
1777 case EDONKEY_MSG_OFFER_FILES
: /* Offer Files: <File info List> */
1778 case EDONKEY_MSG_VIEW_FILES_ANSWER
: /* View Files Answer: <File info list> */
1779 offset
= dissect_edonkey_file_info_list(tvb
, pinfo
, offset
, tree
);
1782 case EDONKEY_MSG_SEARCH_FILE_RESULTS
: /* Search File Results: <File Info list> <More> */
1783 offset
= dissect_edonkey_file_info_list(tvb
, pinfo
, offset
, tree
);
1784 more
= tvb_get_guint8(tvb
, offset
);
1785 proto_tree_add_text(tree
, tvb
, offset
, 1, "More: %s (0x%02x)", (more
) ? "TRUE" : "FALSE", more
);
1788 case EDONKEY_MSG_SEARCH_FILES
: /* Search File: <Search query> */
1789 case EDONKEY_MSG_SEARCH_USER
: /* Search User: <Search query> */
1790 offset
= dissect_edonkey_search_query(tvb
, pinfo
, offset
, tree
);
1793 case EDONKEY_MSG_GET_SOURCES
: /* Get Sources: <File Hash> <Size> <Size 64> */
1794 case EDONKEY_MSG_GET_SOURCES_OBFU
: /* Get Sources: <File Hash> <Size> <Size 64> */
1797 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1798 fileSize
= tvb_get_letohl(tvb
, offset
);
1799 proto_tree_add_text(tree
, tvb
, offset
, 4, "File size: %u %s", fileSize
, (fileSize
== 0) ? "(64bit file size used)" : "");
1801 /* if fileSize = 0 then 64bit file size comes next */
1802 if (fileSize
== 0) {
1803 guint64 fileSize64
= tvb_get_letoh64(tvb
, offset
);
1804 proto_tree_add_text(tree
, tvb
, offset
, 8, "Large file size : %" G_GINT64_MODIFIER
"u", fileSize64
);
1809 case EDONKEY_MSG_NO_SUCH_FILE
: /* No Such File: <File Hash> */
1810 case EDONKEY_MSG_END_OF_DOWNLOAD
: /* End of Download: <File Hash> */
1811 case EDONKEY_MSG_FILE_STATUS_REQUEST
: /* File Status Request: <File Hash> */
1812 case EDONKEY_MSG_HASHSET_REQUEST
: /* Hashset Request: <File Hash> */
1813 case EDONKEY_MSG_SLOT_REQUEST
: /* Slot Request: <File Hash> */
1814 case EDONKEY_MSG_FILE_REQUEST
: /* File Request: <File Hash> */
1815 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1818 case EDONKEY_MSG_FOUND_SOURCES_OBFU
: /* Found Sources: <File Hash> <SourceOBFU List> */
1819 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1820 offset
= dissect_emule_sourceOBFU_list(tvb
, pinfo
, offset
, tree
);
1823 case EDONKEY_MSG_FOUND_SOURCES
: /* Found Sources: <File Hash> <Address List> */
1824 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1825 offset
= dissect_edonkey_address_list(tvb
, pinfo
, offset
, tree
);
1828 case EDONKEY_MSG_CLIENT_CB_REQ
: /* Client Callback Request: <Client ID> */
1829 case EDONKEY_MSG_CALLBACK_FAIL
: /* Callback Fail: <Client ID> */
1830 case EDONKEY_MSG_ID_CHANGE
: /* ID Change: <Client ID> */
1831 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, tree
, FALSE
);
1834 case EDONKEY_MSG_NEW_CLIENT_ID
: /* New Client ID: <Client ID> <Client ID> */
1835 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, tree
, FALSE
);
1836 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, tree
, FALSE
);
1839 case EDONKEY_MSG_SERVER_MESSAGE
: /* Server Message: <String> */
1840 case EDONKEY_MSG_CLIENT_MESSAGE
: /* Client Message: <String> */
1841 offset
= dissect_edonkey_string(tvb
, pinfo
, offset
, tree
);
1844 case EDONKEY_MSG_SERVER_STATUS
: /* Server Status: <Nusers> <Nfiles> */
1845 nusers
= tvb_get_letohl(tvb
, offset
);
1846 nfiles
= tvb_get_letohl(tvb
, offset
+4);
1847 proto_tree_add_text(tree
, tvb
, offset
, 4, "Number of Users: %u", nusers
);
1848 proto_tree_add_text(tree
, tvb
, offset
+4, 4, "Number of Files: %u", nfiles
);
1851 case EDONKEY_MSG_FILE_STATUS
: /* File Status: <File hash> <Part Count> <Part Status>? */
1852 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1853 offset
= dissect_edonkey_file_status(tvb
, pinfo
, offset
, tree
);
1856 case EDONKEY_MSG_FILE_REQUEST_ANSWER
: /* File Request Answer: <File hash> <File name> */
1857 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1858 offset
= dissect_edonkey_file_name(tvb
, pinfo
, offset
, tree
);
1861 case EDONKEY_MSG_REQUEST_PARTS
: /* Request Parts: <File hash> <Start offset>(3) <End offset>(3) */
1864 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1865 pairs
= (msg_end
- offset
) / 8;
1867 for (count
=0; count
< pairs
; count
++)
1869 offset
= dissect_edonkey_start_offset(tvb
, pinfo
, offset
, tree
);
1871 for (count
=0; count
< pairs
; count
++)
1873 offset
= dissect_edonkey_end_offset(tvb
, pinfo
, offset
, tree
);
1878 case EDONKEY_MSG_SENDING_PART
: /* Sending Part: <File hash> <Start offset> <End offset> DATA */
1879 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1880 offset
= dissect_edonkey_start_offset(tvb
, pinfo
, offset
, tree
);
1881 offset
= dissect_edonkey_end_offset(tvb
, pinfo
, offset
, tree
);
1882 if (msg_end
> offset
) {
1883 bytes_remaining
= msg_end
- offset
;
1884 proto_tree_add_text(tree
, tvb
, offset
, bytes_remaining
, "Message Data (%d bytes)", bytes_remaining
);
1889 case EDONKEY_MSG_SEARCH_USER_RESULTS
: /* Search User Results: <Client info list> */
1890 offset
= dissect_edonkey_client_info_list(tvb
, pinfo
, offset
, tree
);
1893 case EDONKEY_MSG_GET_SHARED_FILES
: /* Get Shared Files: <Directory> */
1894 offset
= dissect_edonkey_directory(tvb
, pinfo
, offset
, tree
);
1897 case EDONKEY_MSG_SHARED_DIRS
: /* Shared Dirs: <Directory List> */
1898 offset
= dissect_edonkey_directory_list(tvb
, pinfo
, offset
, tree
);
1901 case EDONKEY_MSG_SHARED_FILES
: /* Shared Files: <Directory> <File info list> */
1902 offset
= dissect_edonkey_directory(tvb
, pinfo
, offset
, tree
);
1903 offset
= dissect_edonkey_file_info_list(tvb
, pinfo
, offset
, tree
);
1906 case EDONKEY_MSG_HASHSET_ANSWER
: /* Hashset Answer: <Hash List> */
1907 offset
= dissect_edonkey_hash_list(tvb
, pinfo
, offset
, tree
);
1911 proto_tree_add_text(tree
, tvb
, offset
, length
, "Message Data (%d bytes)", length
);
1915 if (offset
< msg_end
) {
1916 int extra_bytes
= msg_end
- offset
;
1917 /* trailing garbage or broken packet */
1918 proto_tree_add_uint_format(tree
, hf_edonkey_unparsed_data_length
, tvb
, offset
, extra_bytes
, extra_bytes
,
1919 "Trailing/Undecoded data: %d bytes", extra_bytes
);
1924 static void dissect_emule_tcp_message(guint8 msg_type
,
1925 tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
1926 int offset
, int length
, proto_tree
*tree
)
1928 int msg_end
, bytes_remaining
;
1929 guint32 packed_length
;
1930 guint16 version
, rank
, partnum
;
1932 if (tree
== NULL
) return;
1934 bytes_remaining
= tvb_reported_length_remaining(tvb
, offset
);
1935 if ((length
< 0) || (length
> bytes_remaining
)) length
= bytes_remaining
;
1936 if (length
<= 0) return;
1938 msg_end
= offset
+ length
;
1941 case EMULE_MSG_HELLO
: /* eMule Info: <eMule Version> <Meta tag list> */
1942 case EMULE_MSG_HELLO_ANSWER
: /* eMule Info Answer: <eMule Version> <Meta tag list> */
1943 version
= tvb_get_letohs(tvb
, offset
);
1944 proto_tree_add_text(tree
, tvb
, offset
, 2, "Version: %u", version
);
1945 dissect_edonkey_metatag_list(tvb
, pinfo
, offset
+2, tree
);
1948 case EMULE_MSG_QUEUE_RANKING
: /* eMule Queue Ranking: <eMule Rank (guint16)> */
1949 rank
= tvb_get_letohs(tvb
, offset
);
1950 proto_tree_add_text(tree
, tvb
, offset
, 2, "Queue Ranking: %u", rank
);
1953 case EMULE_MSG_SOURCES_REQUEST
: /* Sources Request: <File Hash> */
1954 dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1957 case EMULE_MSG_SOURCES_ANSWER
: /* Sources Answer: <File Hash> <Address List> */
1958 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1959 dissect_emule_address_list(tvb
, pinfo
, offset
, tree
);
1962 case EMULE_MSG_SEC_IDENT_STATE
: {
1963 guint32 rndchallenge
;
1964 guint8 state
= tvb_get_guint8(tvb
, offset
);
1965 proto_tree_add_text(tree
, tvb
, offset
, 1, "State: %u (%s needed)", state
, (state
== 0) ? "nothing is" : (state
== 1) ? "signature is" : "public key and signature are");
1967 rndchallenge
= tvb_get_letohl(tvb
, offset
);
1968 proto_tree_add_text(tree
, tvb
, offset
, 4, "Rndchallenge: %u", rndchallenge
);
1973 case EMULE_MSG_PUBLIC_KEY
: /* Public Key: <1byte : len> <len bytes: pubkey> */
1974 /* offset =*/ dissect_edonkey_public_key(tvb
, pinfo
, offset
, tree
);
1975 /* offset = dissect_emule_publickey(tvb, pinfo, offset, tree); */
1978 case EMULE_MSG_SIGNATURE
:
1979 offset
= dissect_edonkey_signature(tvb
, pinfo
, offset
, tree
);
1980 if (msg_end
!= offset
) {
1981 guint8 sigIPused
= tvb_get_guint8(tvb
, offset
);
1982 proto_tree_add_text(tree
, tvb
, offset
, 1, "Sig IP Used: %u", sigIPused
);
1987 /* case EMULE_MSG_SIGNATURE: Public Key: <1byte : len> <len bytes: pubkey> */
1988 /* offset = dissect_emule_publickey(tvb, pinfo, offset, tree); */
1991 /* case EMULE_MSG_SECIDENTSTATE: Public Key: <1byte : len> <len bytes: pubkey> */
1992 /* offset = dissect_emule_secstate(tvb, pinfo, offset, tree); */
1993 /* offset = dissect_emule_challenge(tvb, pinfo, offset, tree); */
1996 case EMULE_MSG_DATA_COMPRESSED
: /* Data Compressed: <File Hash> <Start Offset> <Length (guint32)> <DATA> */
1997 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
1998 offset
= dissect_edonkey_start_offset(tvb
, pinfo
, offset
, tree
);
1999 packed_length
= tvb_get_letohl(tvb
, offset
);
2000 proto_tree_add_text(tree
, tvb
, offset
, 4, "Packed Length: %u", packed_length
);
2002 if (msg_end
> offset
) {
2003 bytes_remaining
= msg_end
- offset
;
2004 proto_tree_add_text(tree
, tvb
, offset
, bytes_remaining
,
2005 "Compressed Message Data (%d bytes)", bytes_remaining
);
2009 case EMULE_MSG_DATA_COMPRESSED_64
: /* Data Compressed: <File Hash> <Start Offset (guint64)> <Length (guint32)> <DATA> */
2010 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2011 offset
= dissect_edonkey_start_offset_64(tvb
, pinfo
, offset
, tree
);
2012 packed_length
= tvb_get_letohl(tvb
, offset
);
2013 proto_tree_add_text(tree
, tvb
, offset
, 4, "Packed Length: %u", packed_length
);
2015 if (msg_end
> offset
) {
2016 bytes_remaining
= msg_end
- offset
;
2017 proto_tree_add_text(tree
, tvb
, offset
, bytes_remaining
,
2018 "Compressed Message Data (%d bytes)", bytes_remaining
);
2022 case EMULE_MSG_REQUEST_PARTS_64
: /* Request Parts: <File hash> <Start offset>(3) <End offset>(3) */
2023 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2024 offset
= dissect_edonkey_start_offset_64(tvb
, pinfo
, offset
, tree
);
2025 offset
= dissect_edonkey_start_offset_64(tvb
, pinfo
, offset
, tree
);
2026 offset
= dissect_edonkey_start_offset_64(tvb
, pinfo
, offset
, tree
);
2027 offset
= dissect_edonkey_end_offset_64(tvb
, pinfo
, offset
, tree
);
2028 offset
= dissect_edonkey_end_offset_64(tvb
, pinfo
, offset
, tree
);
2029 dissect_edonkey_end_offset_64(tvb
, pinfo
, offset
, tree
);
2032 case EMULE_MSG_SENDING_PART_64
: /* Sending Part: <File hash> <Start offset> <End offset> DATA */
2033 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2034 offset
= dissect_edonkey_start_offset_64(tvb
, pinfo
, offset
, tree
);
2035 offset
= dissect_edonkey_end_offset_64(tvb
, pinfo
, offset
, tree
);
2036 if (msg_end
> offset
) {
2037 bytes_remaining
= msg_end
- offset
;
2038 proto_tree_add_text(tree
, tvb
, offset
, bytes_remaining
, "Message Data (%d bytes)", bytes_remaining
);
2042 case EMULE_MSG_CALLBACK
: /* Callback: < hash ><hash> <uint16> */
2043 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2044 /*offset = */dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2045 /* offset = dissect_edonkey_generic_uint16(tvb, pinfo, offset, tree, "uint16" ); */
2048 case EMULE_MSG_AICH_REQUEST
: /* AICH Request: <File Hash> <PartNum> <AICH Hash> */
2049 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2050 partnum
= tvb_get_letohs(tvb
, offset
);
2051 proto_tree_add_uint(tree
, hf_emule_aich_partnum
, tvb
, offset
, 2, partnum
);
2053 dissect_emule_aich_root_hash(tvb
, pinfo
, offset
, tree
);
2056 case EMULE_MSG_AICH_ANSWER
: /* AICH Answer: <File Hash> <PartNum> <AICH Hash> <AICH Hash List> */
2057 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2058 partnum
= tvb_get_letohs(tvb
, offset
);
2059 proto_tree_add_uint(tree
, hf_emule_aich_partnum
, tvb
, offset
, 2, partnum
);
2061 offset
= dissect_emule_aich_root_hash(tvb
, pinfo
, offset
, tree
);
2062 dissect_emule_aich_hash_list(tvb
, pinfo
, offset
, tree
);
2065 case EMULE_MSG_MULTIPACKET
: /* MultiPacket: <Hash> <Opcodes> */
2066 case EMULE_MSG_MULTIPACKET_ANSWER
:
2067 case EMULE_MSG_MULTIPACKET_EXT
: /* MultiPacketExt: <Hash> <FileLength> <Opcodes> */
2068 dissect_emule_multipacket(tvb
, pinfo
, offset
, offset
+length
, tree
, msg_type
==EMULE_MSG_MULTIPACKET_EXT
);
2072 dissect_edonkey_tcp_message(msg_type
, tvb
, pinfo
, offset
, length
, tree
);
2078 static int dissect_edonkey_udp_message(guint8 msg_type
,
2079 tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2080 int offset
, int length
, proto_tree
*tree
)
2082 int msg_end
, bytes_remaining
;
2087 guint32 nusers
, nfiles
;
2089 if (tree
== NULL
) return offset
;
2091 bytes_remaining
= tvb_reported_length_remaining(tvb
, offset
);
2092 if ((length
< 0) || (length
> bytes_remaining
)) length
= bytes_remaining
;
2093 if (length
<= 0) return offset
;
2095 msg_end
= offset
+ length
;
2098 /* EDonkey UDP Messages */
2099 case EDONKEY_MSG_UDP_CALLBACK_REQUEST
: /* Callback Request: <Address> <Client ID> */
2100 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, tree
);
2101 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, tree
, FALSE
);
2104 case EDONKEY_MSG_UDP_CALLBACK_FAIL
: /* Callback Fail: <Client ID> */
2105 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, tree
, FALSE
);
2108 case EDONKEY_MSG_UDP_GET_SERVER_INFO
: /* Get Server Info: <Challenge> */
2110 ischal
= tvb_get_letohs(tvb
, offset
);
2111 if (ischal
==0xf0ff) {
2112 chal
= tvb_get_letohl(tvb
, offset
);
2113 proto_tree_add_text(tree
, tvb
, offset
, 4, "Challenge: 0x%08x", chal
);
2119 case EDONKEY_MSG_UDP_SERVER_INFO
: /* Server Info: <String> <String>*/
2120 ischal
= tvb_get_letohs(tvb
, offset
);
2121 if (ischal
==0xf0ff) {
2122 chal
= tvb_get_letohl(tvb
, offset
);
2123 proto_tree_add_text(tree
, tvb
, offset
, 4, "Challenge: 0x%08x", chal
);
2124 offset
= dissect_edonkey_metatag_list(tvb
, pinfo
, offset
+4, tree
);
2126 offset
= dissect_edonkey_string(tvb
, pinfo
, offset
, tree
);
2127 offset
= dissect_edonkey_string(tvb
, pinfo
, offset
, tree
);
2131 case EDONKEY_MSG_UDP_SERVER_LIST
: /* Server List: <Address List> */
2132 offset
= dissect_edonkey_address_list(tvb
, pinfo
, offset
, tree
);
2135 case EDONKEY_MSG_UDP_SEARCH_FILE_RESULTS
: /* Search File Result: <File Info> */
2136 offset
= dissect_edonkey_file_info(tvb
, pinfo
, offset
, tree
);
2139 case EDONKEY_MSG_UDP_SEARCH_FILE
: /* Search File: <Search query> */
2140 offset
= dissect_edonkey_search_query(tvb
, pinfo
, offset
, tree
);
2143 case EDONKEY_MSG_UDP_GET_SOURCES
: /* Get Sources: <File Hash> */
2144 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2147 case EDONKEY_MSG_UDP_FOUND_SOURCES
: /* Found Sources: <File Hash> <Address List> */
2148 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2149 offset
= dissect_edonkey_address_list(tvb
, pinfo
, offset
, tree
);
2152 case EDONKEY_MSG_UDP_SERVER_STATUS_REQUEST
: /* Server Status Request: <guint32> */
2153 chal
= tvb_get_letohl(tvb
, offset
);
2154 proto_tree_add_text(tree
, tvb
, offset
, 4, "Challenge: 0x%08x", chal
);
2158 case EDONKEY_MSG_UDP_SERVER_STATUS
: /* Server Status: <guint32> <Nusers> <Nfiles> <Nusersmax> */
2159 chal
= tvb_get_letohl(tvb
, offset
);
2160 proto_tree_add_text(tree
, tvb
, offset
, 4, "Challenge: 0x%08x", chal
);
2162 nusers
= tvb_get_letohl(tvb
, offset
);
2163 nfiles
= tvb_get_letohl(tvb
, offset
+4);
2164 proto_tree_add_text(tree
, tvb
, offset
, 4, "Number of Users: %u", nusers
);
2165 proto_tree_add_text(tree
, tvb
, offset
+4, 4, "Number of Files: %u", nfiles
);
2167 if (offset
< msg_end
) {
2168 nusers
= tvb_get_letohl(tvb
, offset
);
2169 proto_tree_add_text(tree
, tvb
, offset
, 4, "Max number of Users: %u", nusers
);
2174 /* Overnet UDP Messages */
2175 case OVERNET_MSG_UDP_CONNECT
: /* Connect: <Peer (sender) > */
2176 case OVERNET_MSG_UDP_PUBLICIZE
: /* Publicize: <Peer (sender) > */
2177 offset
= dissect_overnet_peer(tvb
, pinfo
, offset
, tree
);
2180 case OVERNET_MSG_UDP_CONNECT_REPLY
: /* Connect Reply: <guint16 Peer List> */
2181 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Overnet Peer", dissect_overnet_peer
);
2184 case OVERNET_MSG_UDP_SEARCH
: /* Search: <search type (guint8)> <Hash> */
2185 type
= tvb_get_guint8(tvb
, offset
);
2186 proto_tree_add_text(tree
, tvb
, offset
, 1, "Search Type: %u", type
);
2187 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
+1, tree
);
2190 case OVERNET_MSG_UDP_SEARCH_INFO
:
2191 /* Search Info: <Hash> <search type (guint8)> <min (guint16)> <max (guint16)>*/
2192 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, tree
);
2193 type
= tvb_get_guint8(tvb
, offset
);
2194 min
= tvb_get_letohs(tvb
, offset
+1);
2195 max
= tvb_get_letohs(tvb
, offset
+3);
2196 proto_tree_add_text(tree
, tvb
, offset
, 1, "Search Type: %u", type
);
2197 proto_tree_add_text(tree
, tvb
, offset
+1, 4, "Search Range: Min=%u Max=%u", min
, max
);
2200 case OVERNET_MSG_UDP_SEARCH_NEXT
: /* Search Next: <Hash> <guint8 Peer List> */
2201 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, tree
);
2202 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 1, "Overnet Peer", dissect_overnet_peer
);
2205 case OVERNET_MSG_UDP_SEARCH_RESULT
: /* Search Result: <Hash> <Hash> <Meta tag List> */
2206 case OVERNET_MSG_UDP_PUBLISH
: /* Publish: <Hash> <Hash> <Meta tag List> */
2207 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, tree
);
2208 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, tree
);
2209 offset
= dissect_edonkey_metatag_list(tvb
, pinfo
, offset
, tree
);
2212 case OVERNET_MSG_UDP_SEARCH_END
: /* Search End: <Hash> */
2213 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, tree
);
2216 case OVERNET_MSG_UDP_PUBLISH_ACK
: /* Publish ACK: <File Hash> */
2217 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2220 case OVERNET_MSG_UDP_IP_QUERY
: /* IP Query: <TCP Port> */
2221 proto_tree_add_item(tree
, hf_edonkey_port
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2224 case OVERNET_MSG_UDP_IP_QUERY_ANSWER
: /* IP Query Answer: <IP> */
2225 offset
= dissect_edonkey_client_id(tvb
, pinfo
, offset
, tree
, FALSE
);
2228 case OVERNET_MSG_UDP_IDENTIFY_REPLY
: /* Identify Reply: <Contact (sender)> */
2229 /* <Contact> ::= <Hash> <Address> */
2230 offset
= dissect_edonkey_hash(tvb
, pinfo
, offset
, tree
);
2231 offset
= dissect_edonkey_address(tvb
, pinfo
, offset
, tree
);
2234 case OVERNET_MSG_UDP_IDENTIFY_ACK
: /* Identify Reply: <TCP Port (sender)> */
2235 proto_tree_add_item(tree
, hf_edonkey_port
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2238 case OVERNET_MSG_UDP_FIREWALL_CONNECTION
: /* Firewall Connnection Ack: <Hash> <TCP Port> */
2239 offset
= dissect_edonkey_client_hash(tvb
, pinfo
, offset
, tree
);
2240 proto_tree_add_item(tree
, hf_edonkey_port
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2243 case OVERNET_MSG_UDP_FIREWALL_CONNECTION_ACK
: /* Firewall Connnection Ack: <Hash> */
2244 case OVERNET_MSG_UDP_FIREWALL_CONNECTION_NACK
: /* Firewall Connnection NAck: <Hash> */
2245 offset
= dissect_edonkey_client_hash(tvb
, pinfo
, offset
, tree
);
2249 proto_tree_add_text(tree
, tvb
, offset
, length
, "Message Data (%d bytes)", length
);
2257 static int dissect_emule_udp_message(guint8 msg_type
,
2258 tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2259 int offset
, int length
, proto_tree
*tree
)
2261 int msg_end
, bytes_remaining
;
2264 bytes_remaining
= tvb_reported_length_remaining(tvb
, offset
);
2265 if ((length
< 0) || (length
> bytes_remaining
)) length
= bytes_remaining
;
2266 if (length
<= 0) return offset
;
2268 msg_end
= offset
+ length
;
2271 case EMULE_MSG_UDP_REASKFILEPING
: /* Reask File Ping: <File Hash> */
2272 offset
= dissect_edonkey_file_hash(tvb
, pinfo
, offset
, tree
);
2273 if ( offset
+ 2 < msg_end
) {
2274 /* Udp version > 3 */
2275 offset
= dissect_edonkey_file_status( tvb
, pinfo
, offset
, tree
);
2278 if ( msg_end
== offset
+ 2 ) {
2279 /* Udp version > 2 */
2280 proto_tree_add_item( tree
, hf_emule_source_count
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2285 case EMULE_MSG_UDP_REASKACK
: /* Reask ACK: <eMule Rank> */
2286 if ( offset
+ 2 < msg_end
) {
2287 /* Udp version > 3 */
2288 offset
= dissect_edonkey_file_status( tvb
, pinfo
, offset
, tree
);
2291 rank
= tvb_get_letohs(tvb
, offset
);
2292 proto_tree_add_text(tree
, tvb
, offset
, 2, "Queue Ranking: %u", rank
);
2297 offset
= dissect_edonkey_udp_message(msg_type
, tvb
, pinfo
, offset
, length
,tree
);
2303 static int dissect_kademlia_peer_list_2byte(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2304 int offset
, proto_tree
*tree
)
2306 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Peer", dissect_kademlia_peer
);
2310 static int dissect_kademlia_peer_list_1byte(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2311 int offset
, proto_tree
*tree
)
2313 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 1, "Peer", dissect_kademlia_peer
);
2316 static int dissect_kademlia2_peer_list_2byte(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2317 int offset
, proto_tree
*tree
)
2319 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Peer", dissect_kademlia2_peer
);
2322 static int dissect_kademlia2_peer_list_1byte(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2323 int offset
, proto_tree
*tree
)
2325 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 1, "Peer", dissect_kademlia2_peer
);
2328 static int dissect_kademlia_tag(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2329 int offset
, proto_tree
*tree
)
2333 const gchar
*str_type
;
2335 proto_item
* tag_node
;
2336 proto_tree
*subtree
;
2337 int item_start_offset
;
2339 item_start_offset
= offset
;
2340 /* tag_node length is adjusted at the end of this function */
2341 tag_node
= proto_tree_add_text( tree
, tvb
, offset
, 1, "Tag " );
2342 subtree
= proto_item_add_subtree( tag_node
, ett_kademlia_tag
);
2344 type
= tvb_get_guint8( tvb
, offset
);
2345 str_type
= val_to_str_const(type
, kademlia_tag_types
, "Unknown" );
2348 proto_item
* ti_tagtype
;
2349 ti_tagtype
= proto_tree_add_item( subtree
, hf_kademlia_tag_type
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2350 proto_item_append_text( ti_tagtype
, " [%s]", str_type
);
2356 const gchar
*tagname_string
;
2357 const gchar
*tagname_extended_string
;
2360 tag_type
= tvb_get_guint8( tvb
, offset
+2 );
2361 offset
= dissect_kademlia_tagname( tvb
, pinfo
, offset
, subtree
, &tagname_string
, &tagname_extended_string
);
2362 if ( strlen( tagname_string
) == 1 ) {
2363 const guint8 tagname_guint
= *(guint8
*)tagname_string
;
2365 proto_item_append_text( tag_node
, " 0x%02X [%s] = ", tagname_guint
, tagname_extended_string
);
2368 proto_item_append_text( tag_node
, " \"%s\" [%s] = ", tagname_string
, tagname_extended_string
);
2371 /* Switch on type */
2374 case KADEMLIA_TAGTYPE_HASH
:
2375 proto_item_append_text( tag_node
, "%s", tvb_bytes_to_str( tvb
, offset
, 16 ));
2376 offset
= dissect_kademlia_tag_hash( tvb
, pinfo
, offset
, subtree
);
2378 case KADEMLIA_TAGTYPE_STRING
:
2381 offset
= dissect_kademlia_tag_string( tvb
, pinfo
, offset
, subtree
, &value
);
2383 proto_item_append_text( tag_node
, "\"%s\"", value
);
2386 case KADEMLIA_TAGTYPE_UINT8
:
2389 ti
= proto_tree_add_item( subtree
, hf_kademlia_tag_uint8
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2391 value
= tvb_get_guint8( tvb
, offset
);
2392 proto_item_append_text( tag_node
, "%u (0x%02X)", value
, value
);
2394 case KADEMLIA_TAG_SOURCETYPE
:
2396 proto_item_append_text(ti
," (%s)", val_to_str_const(value
, kademlia_tag_sourcetype
, "Unknown"));
2399 case KADEMLIA_TAG_ENCRYPTION
:
2400 proto_item_append_text(ti
, " (%s)", val_to_str_const(value
, kademlia_tag_encryption
, "Unknown"));
2406 case KADEMLIA_TAGTYPE_UINT16
:
2409 proto_tree_add_item( subtree
, hf_kademlia_tag_uint16
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2411 value
= tvb_get_letohs( tvb
, offset
);
2412 proto_item_append_text( tag_node
, "%u (0x%04X)", value
, value
);
2417 case KADEMLIA_TAGTYPE_UINT64
:
2420 proto_tree_add_item( subtree
, hf_kademlia_tag_uint64
, tvb
, offset
, 8, ENC_LITTLE_ENDIAN
);
2422 value
= tvb_get_letoh64( tvb
, offset
);
2423 proto_item_append_text( tag_node
, "%" G_GINT64_MODIFIER
"u (0x%08" G_GINT64_MODIFIER
"X)", value
, value
);
2428 case KADEMLIA_TAGTYPE_UINT32
:
2431 /* show ip as dotted decimal */
2433 case KADEMLIA_TAG_SERVERIP
:
2434 case KADEMLIA_TAG_SOURCEIP
:
2436 int ipa
= 0, ipb
= 0, ipc
= 0, ipd
= 0;
2437 proto_tree_add_item( subtree
, hf_kademlia_tag_ipv4
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
2438 value
= tvb_get_letohl( tvb
, offset
);
2439 ipa
= (value
/ (256*256*256)) % 256;
2440 ipb
= (value
/ (256*256)) % 256;
2441 ipc
= (value
/ 256) % 256;
2443 proto_item_append_text( tag_node
, "%u.%u.%u.%u (0x%02X) ", ipa
, ipb
, ipc
, ipd
, value
);
2447 proto_tree_add_item( subtree
, hf_kademlia_tag_uint32
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
2448 value
= tvb_get_letohl( tvb
, offset
);
2449 proto_item_append_text( tag_node
, "%u (0x%02X) ", value
, value
);
2455 case KADEMLIA_TAGTYPE_FLOAT32
:
2458 proto_tree_add_item( subtree
, hf_kademlia_tag_float
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
2460 value
= tvb_get_letohieee_float( tvb
, offset
);
2461 proto_item_append_text( tag_node
, "%f", value
);
2466 case KADEMLIA_TAGTYPE_BSOB
:
2469 offset
= dissect_kademlia_tag_bsob( tvb
, pinfo
, offset
, subtree
, &value
);
2470 proto_item_append_text( tag_node
, "%s", value
);
2474 proto_tree_add_text(tree
, tvb
, offset
, 1, "Tag value not decoded for type: 0x%02X", type
);
2477 proto_item_append_text( tag_node
, " (Type: %s)", str_type
);
2479 proto_item_set_len( tag_node
, offset
- item_start_offset
);
2484 static int dissect_kademlia_taglist(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2485 int offset
, proto_tree
*tree
)
2487 return dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 1, "Tag", dissect_kademlia_tag
);
2491 static int dissect_kademlia_publish_req_entry_file(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2492 int offset
, proto_tree
*tree
)
2495 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_file_id
);
2496 /* Read all the kad tags */
2497 return dissect_kademlia_taglist( tvb
, pinfo
, offset
, tree
);
2500 static int dissect_kademlia_publish_req_entry_peer(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2501 int offset
, proto_tree
*tree
)
2504 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_peer_id
);
2505 /* Read all the kad tags */
2506 return dissect_kademlia_taglist( tvb
, pinfo
, offset
, tree
);
2510 static int dissect_kademlia_search_result(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2511 int offset
, proto_tree
*tree
)
2514 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_hash
);
2515 /* Read all the kad tags */
2516 return dissect_kademlia_taglist( tvb
, pinfo
, offset
, tree
);
2519 static int dissect_kademlia_search_expression_tree(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2520 int offset
, proto_tree
*tree
)
2522 int op
, item_start_offset
;
2525 item_start_offset
= offset
;
2526 op
= tvb_get_guint8(tvb
, offset
);
2527 ti
= proto_tree_add_text(tree
, tvb
, offset
, 1, "SearchExp type: %x ", op
);
2529 tree
= proto_item_add_subtree( ti
, ett_kademlia_search_expression
);
2531 case 0: /* Bool op */
2534 const char* bool_op_label
;
2536 proto_item_append_text( ti
, "[BoolOp]" );
2538 boolop
= tvb_get_guint8(tvb
, offset
);
2542 bool_op_label
= "AND";
2545 bool_op_label
= "OR";
2548 bool_op_label
= "NAND";
2551 bool_op_label
= "Unknown";
2553 proto_tree_add_text(tree
, tvb
, offset
, 1, "Bool op: %x [%s]", boolop
, bool_op_label
);
2557 offset
= dissect_kademlia_search_expression_tree( tvb
, pinfo
, offset
, tree
);
2559 offset
= dissect_kademlia_search_expression_tree( tvb
, pinfo
, offset
, tree
);
2564 case 1: /* String */
2565 proto_item_append_text( ti
, "[String]" );
2566 offset
= dissect_kademlia_string( tvb
, pinfo
, offset
, tree
);
2568 case 2: /* Meta Tag */
2569 proto_item_append_text( ti
, "[MetaTag]" );
2571 offset
= dissect_edonkey_string( tvb
, pinfo
, offset
, tree
);
2573 offset
= dissect_kademlia_tagname( tvb
, pinfo
, offset
, tree
, NULL
, NULL
);
2575 case 3: /* Min/Max - 32bit! */
2576 proto_item_append_text( ti
, "[32bitOp]" );
2577 offset
= dissect_kademlia_search_condition_argument_uint32( tvb
, pinfo
, offset
, tree
);
2578 offset
= dissect_kademlia_search_condition( tvb
, pinfo
, offset
, tree
);
2580 offset
= dissect_kademlia_tagname( tvb
, pinfo
, offset
, tree
, NULL
, NULL
);
2582 case 8: /* Min/Max - 64bit! */
2583 proto_item_append_text( ti
, "[64bitOp]" );
2584 offset
= dissect_kademlia_search_condition_argument_uint64( tvb
, pinfo
, offset
, tree
);
2585 offset
= dissect_kademlia_search_condition( tvb
, pinfo
, offset
, tree
);
2587 offset
= dissect_kademlia_tagname( tvb
, pinfo
, offset
, tree
, NULL
, NULL
);
2590 proto_tree_add_text(tree
, tvb
, offset
, 1, "NOT DECODED op %x", op
);
2592 proto_item_set_len( ti
, offset
- item_start_offset
);
2596 static int dissect_kademlia2_prolog( tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2597 int offset
, proto_tree
*tree
)
2602 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_peer_id
);
2603 offset
= dissect_kademlia_tcp_port(tvb
, pinfo
, offset
, tree
);
2605 kad_version
= tvb_get_guint8(tvb
, offset
);
2606 /* ti = proto_tree_add_text(tree, tvb, offset, 1, "Kad Version: %d", kad_version ); */
2607 ti
= proto_tree_add_item(tree
, hf_kademlia_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2608 proto_item_append_text(ti
, "%s", val_to_str_const(kad_version
, kademlia_versions
, " Unknown"));
2614 static int dissect_kademlia_uload( tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2615 int offset
, proto_tree
*tree
)
2618 uLoad
= tvb_get_guint8(tvb
, offset
);
2619 proto_tree_add_text(tree
, tvb
, offset
, 1, "uLoad: %d", uLoad
);
2623 static int dissect_kademlia_udp_message(guint8 msg_type
,
2624 tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2625 int offset
, int length
, proto_tree
*tree
)
2627 int msg_end
, bytes_remaining
;
2628 proto_item
*hidden_item
;
2630 bytes_remaining
= tvb_reported_length_remaining(tvb
, offset
);
2631 if ((length
< 0) || (length
> bytes_remaining
)) length
= bytes_remaining
;
2632 if (length
<= 0) return offset
;
2634 hidden_item
= proto_tree_add_item(tree
, hf_kademlia
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2635 PROTO_ITEM_SET_HIDDEN(hidden_item
);
2637 msg_end
= offset
+ length
;
2640 case KADEMLIA_BOOTSTRAP_REQ
:/* <PEER [25]> */
2641 case KADEMLIA_HELLO_REQ
:
2642 case KADEMLIA_HELLO_RES
:
2643 offset
= dissect_kademlia_peer(tvb
, pinfo
, offset
, tree
);
2645 case KADEMLIA2_BOOTSTRAP_REQ
:
2646 offset
= dissect_kademlia2_prolog( tvb
, pinfo
, offset
, tree
);
2649 case KADEMLIA2_HELLO_REQ
:
2650 case KADEMLIA2_HELLO_RES
:
2651 offset
= dissect_kademlia2_prolog( tvb
, pinfo
, offset
, tree
);
2652 offset
= dissect_kademlia_taglist( tvb
, pinfo
, offset
, tree
);
2654 case KADEMLIA_BOOTSTRAP_RES
: /* <CNT [2]> <PEER [25]>*(CNT) */
2655 offset
= dissect_kademlia_peer_list_2byte( tvb
, pinfo
, offset
, tree
);
2657 case KADEMLIA2_BOOTSTRAP_RES
:
2658 offset
= dissect_kademlia2_prolog( tvb
, pinfo
, offset
, tree
);
2659 offset
= dissect_kademlia2_peer_list_2byte( tvb
, pinfo
, offset
, tree
);
2662 case KADEMLIA2_SEARCH_SOURCE_REQ
:
2666 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2668 startPos
= tvb_get_letohs( tvb
, offset
);
2669 proto_tree_add_text(tree
, tvb
, offset
, 2, "Start position: %d", startPos
);
2672 filesize
= tvb_get_letoh64( tvb
, offset
);
2673 proto_tree_add_text(tree
, tvb
, offset
, 8, "Filesize: %" G_GINT64_MODIFIER
"u", filesize
);
2678 case KADEMLIA_SEARCH_NOTES_REQ
: /* <HASH (key) [16]> */
2679 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_hash
);
2682 case KADEMLIA2_SEARCH_KEY_REQ
:
2685 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2687 startPos
= tvb_get_letohs( tvb
, offset
);
2688 proto_tree_add_text(tree
, tvb
, offset
, 2, "Start position: %d", startPos
);
2692 case KADEMLIA2_SEARCH_NOTES_REQ
:
2694 case KADEMLIA_PUBLISH_RES
:
2695 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2696 if (offset
<msg_end
) {
2697 offset
= dissect_kademlia_uload( tvb
, pinfo
, offset
, tree
);
2700 case KADEMLIA2_PUBLISH_RES
:
2701 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2702 offset
= dissect_kademlia_uload( tvb
, pinfo
, offset
, tree
);
2705 case KADEMLIA_REQ
: /* <TYPE [1]> <HASH (target) [16]> <HASH (receiver) 16> */
2709 guint8 target_id
[16];
2710 guint8 recipients_id
[16];
2715 type
= tvb_get_guint8(tvb
, offset
);
2716 ti
= proto_tree_add_uint_format_value(tree
, hf_kademlia_request_type
, tvb
, offset
, 1, type
, "0x%02x", type
);
2717 proto_item_append_text(ti
, "%s", val_to_str_const(type
, kademlia_parameter
, " Unknown"));
2721 for (i
=0; i
<4; i
++) {
2722 for (j
=3; j
>=0; j
--) {
2724 target_id
[l
] = tvb_get_guint8(tvb
, offset
+ abs(8*i
-(l
-3)));
2728 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2730 /* get recipient's id */
2731 for (i
=0; i
<4; i
++) {
2732 for (j
=3; j
>=0; j
--) {
2734 recipients_id
[l
] = tvb_get_guint8(tvb
, offset
+ abs(8*i
-(l
-3)));
2738 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_recipients_id
);
2740 /* target_id XOR recipients_id */
2741 for (i
=0; i
<16; i
++) {
2743 l
= target_id
[i
]^recipients_id
[i
];
2744 for(j
=8*i
; j
<8*i
+8; j
++) {
2754 binarray
[128] = '\0';
2755 proto_tree_add_string(tree
, hf_kademlia_distance
, tvb
, offset
, 0, binarray
);
2759 case KADEMLIA_RES
: /* <HASH (target) [16]> <CNT> <PEER [25]>*(CNT) */
2760 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2761 offset
= dissect_kademlia_peer_list_1byte( tvb
, pinfo
, offset
, tree
);
2764 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2765 offset
= dissect_kademlia2_peer_list_1byte( tvb
, pinfo
, offset
, tree
);
2768 case KADEMLIA_FIREWALLED_RES
: /* <IP (sender) [4]> */
2769 offset
= dissect_kademlia_ip_address( tvb
, pinfo
, offset
, tree
);
2772 case KADEMLIA_FIREWALLED_REQ
: /* <TCPPORT (sender) [2]> */
2773 offset
= dissect_kademlia_tcp_port( tvb
, pinfo
, offset
, tree
);
2775 case KADEMLIA_CALLBACK_REQ
:
2776 case KADEMLIA_FINDBUDDY_REQ
:
2777 case KADEMLIA_FINDBUDDY_RES
:
2779 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_hash
);
2781 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_hash
);
2782 offset
= dissect_kademlia_tcp_port( tvb
, pinfo
, offset
, tree
);
2784 case KADEMLIA2_PUBLISH_SOURCE_REQ
:
2785 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_file_id
);
2786 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_peer_id
);
2787 offset
= dissect_kademlia_taglist( tvb
, pinfo
, offset
, tree
);
2789 case KADEMLIA_SEARCH_REQ
:
2792 /* Target (16bytes) */
2793 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2794 /* Restrictive (1 byte) 0/1 */
2795 restrictive
= tvb_get_guint8(tvb
, offset
);
2796 proto_tree_add_text(tree
, tvb
, offset
, 1, "Restrictive: %x", restrictive
);
2799 if ( offset
< msg_end
&& restrictive
)
2800 offset
= dissect_kademlia_search_expression_tree( tvb
, pinfo
, offset
, tree
);
2803 case KADEMLIA_SEARCH_RES
:
2805 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2807 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Result", dissect_kademlia_search_result
);
2809 case KADEMLIA2_SEARCH_RES
:
2811 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_sender_id
);
2813 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_target_id
);
2815 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "Result", dissect_kademlia_search_result
);
2817 case KADEMLIA2_PUBLISH_KEY_REQ
:
2820 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_keyword_hash
);
2822 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "StuffToPublish", dissect_kademlia_publish_req_entry_file
);
2825 case KADEMLIA_PUBLISH_REQ
: /* 0x40 // <HASH (key) [16]> <CNT1 [2]> (<HASH (target) [16]> <CNT2 [2]> <META>*(CNT2))*(CNT1) */
2827 guint8 tagname_value
=0, taglist_size
, type
;
2830 /* check if TAG_SOURCETYPE is set */
2831 taglist_size
= tvb_get_guint8(tvb
, offset
+ j
);
2834 while(i
<= taglist_size
) {
2835 type
= tvb_get_guint8(tvb
, offset
+ j
);
2837 tagname_value
= tvb_get_guint8(tvb
, offset
+ j
);
2838 if (tagname_value
== 0xff)
2842 case KADEMLIA_TAGTYPE_HASH
:
2845 case KADEMLIA_TAGTYPE_STRING
:
2847 guint16 string_length
= tvb_get_letohs(tvb
, offset
+j
);
2848 j
+= 2 + string_length
;
2851 case KADEMLIA_TAGTYPE_UINT8
:
2854 case KADEMLIA_TAGTYPE_UINT16
:
2857 case KADEMLIA_TAGTYPE_UINT32
:
2858 case KADEMLIA_TAGTYPE_FLOAT32
:
2861 case KADEMLIA_TAGTYPE_UINT64
:
2864 case KADEMLIA_TAGTYPE_BSOB
:
2866 guint16 bsob_length
= tvb_get_guint8(tvb
, offset
);
2867 j
+= 1 + bsob_length
;
2874 switch (tagname_value
) {
2875 case KADEMLIA_TAG_SOURCETYPE
:
2878 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_file_id
);
2880 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "StuffToPublish", dissect_kademlia_publish_req_entry_peer
);
2886 offset
= dissect_kademlia_hash(tvb
, pinfo
, offset
, tree
, &hf_kademlia_keyword_hash
);
2888 offset
= dissect_edonkey_list(tvb
, pinfo
, offset
, tree
, 2, "StuffToPublish", dissect_kademlia_publish_req_entry_file
);
2897 static int dissect_kademlia_udp_compressed_message(guint8 msg_type
,
2898 tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
2899 int offset
, int length
, proto_tree
*tree
)
2901 tvbuff_t
*tvbraw
= NULL
;
2904 tvbraw
= tvb_child_uncompress(tvb
, tvb
, offset
, length
);
2909 raw_length
= tvb_length( tvbraw
);
2910 add_new_data_source(pinfo
, tvbraw
, "Decompressed Data");
2912 dissect_kademlia_udp_message( msg_type
, tvbraw
, pinfo
, 0, raw_length
, tree
);
2915 proto_tree_add_text( tree
, tvb
, offset
, length
, "Broken Compressed data (%d bytes)", length
);
2921 static guint
get_edonkey_tcp_pdu_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
)
2926 * Get the length of the eDonkey packet.
2928 msg_len
= tvb_get_letohl(tvb
, offset
+1);
2931 * That length doesn't include the header; add that in.
2932 * XXX - what if it overflows?
2934 return msg_len
+ EDONKEY_TCP_HEADER_LENGTH
;
2937 static int dissect_edonkey_tcp_pdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
2940 proto_tree
*edonkey_tree
= NULL
, *edonkey_msg_tree
= NULL
, *emule_zlib_tree
= NULL
;
2942 guint8 protocol
, msg_type
;
2944 const gchar
*protocol_name
, *message_name
;
2945 void (*dissector
)(guint8
, tvbuff_t
*, packet_info
*, int, int, proto_tree
*);
2946 tvbuff_t
*tvbraw
= NULL
;
2948 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "eDonkey");
2951 ti
= proto_tree_add_item(tree
, proto_edonkey
, tvb
, 0, -1, ENC_NA
);
2952 edonkey_tree
= proto_item_add_subtree(ti
, ett_edonkey
);
2956 protocol
= tvb_get_guint8(tvb
, offset
);
2957 msg_len
= tvb_get_letohl(tvb
, offset
+1);
2959 protocol_name
= try_val_to_str(protocol
, edonkey_protocols
);
2961 /* Add edonkey message tree */
2963 ti
= proto_tree_add_item(edonkey_tree
, hf_edonkey_message
, tvb
,
2964 offset
, EDONKEY_TCP_HEADER_LENGTH
+ msg_len
, ENC_NA
);
2965 edonkey_msg_tree
= proto_item_add_subtree(ti
, ett_edonkey_message
);
2967 proto_tree_add_uint_format_value(edonkey_msg_tree
, hf_edonkey_protocol
, tvb
, offset
, 1, protocol
,
2968 "%s (0x%02x)", protocol_name
, protocol
);
2969 proto_tree_add_uint(edonkey_msg_tree
, hf_edonkey_message_length
, tvb
, offset
+1, 4, msg_len
);
2973 /* Skip past the EDONKEY Header */
2974 offset
+= EDONKEY_TCP_HEADER_LENGTH
;
2976 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, ", ", "%s TCP", protocol_name
);
2978 msg_type
= tvb_get_guint8(tvb
, offset
);
2980 case EDONKEY_PROTO_EDONKEY
:
2981 message_name
= val_to_str_const(msg_type
, edonkey_tcp_msgs
, "Unknown");
2982 dissector
= dissect_edonkey_tcp_message
;
2985 case EDONKEY_PROTO_EMULE_EXT
:
2986 message_name
= val_to_str_const(msg_type
, emule_tcp_msgs
,
2987 val_to_str_const(msg_type
, edonkey_tcp_msgs
, "Unknown"));
2988 dissector
= dissect_emule_tcp_message
;
2991 case EDONKEY_PROTO_EMULE_COMP
:
2993 * These ought to be exactly the same as standard eDonkey (0xe5) messages,
2994 * except that the payload (after the type byte) is a zlib compressed
2997 message_name
= val_to_str_const(msg_type
, edonkey_tcp_msgs
, "Unknown");
2998 tvbraw
= tvb_child_uncompress(tvb
, tvb
, offset
+1, msg_len
-1);
3000 dissector
= dissect_edonkey_tcp_message
;
3005 message_name
= "Unknown";
3010 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ": %s", message_name
);
3012 if (edonkey_msg_tree
) {
3013 proto_tree_add_uint_format_value(edonkey_msg_tree
, hf_edonkey_message_type
, tvb
, offset
, 1, msg_type
,
3014 "%s (0x%02x)", message_name
, msg_type
);
3015 if (dissector
&& (msg_len
> 1)) {
3017 (*dissector
)(msg_type
, tvb
, pinfo
, offset
+1, msg_len
-1, edonkey_msg_tree
);
3019 ti
= proto_tree_add_item(edonkey_msg_tree
, hf_emule_zlib
, tvb
,
3020 offset
+1, msg_len
-1, ENC_NA
);
3021 emule_zlib_tree
= proto_item_add_subtree(ti
, ett_emule_zlib
);
3022 add_new_data_source(pinfo
, tvbraw
, "Decompressed Data");
3023 (*dissector
)(msg_type
, tvbraw
, pinfo
, 0, tvb_length(tvbraw
), emule_zlib_tree
);
3028 return tvb_length(tvb
);
3031 static int dissect_edonkey_tcp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
3035 /* An eDonkey TCP packet is at least 5 bytes long msg type + length */
3036 if (!tvb_bytes_exist(tvb
, 0, EDONKEY_TCP_HEADER_LENGTH
))
3039 protocol
= tvb_get_guint8(tvb
, 0);
3040 if (try_val_to_str(protocol
, edonkey_protocols
) == NULL
)
3041 return 0; /* Not a known protocol */
3043 col_clear(pinfo
->cinfo
, COL_INFO
);
3045 tcp_dissect_pdus(tvb
, pinfo
, tree
, edonkey_desegment
,
3046 EDONKEY_TCP_HEADER_LENGTH
, get_edonkey_tcp_pdu_len
,
3047 dissect_edonkey_tcp_pdu
, data
);
3048 return tvb_reported_length(tvb
);
3051 static int dissect_edonkey_udp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
3054 proto_tree
*edonkey_tree
= NULL
, *edonkey_msg_tree
= NULL
;
3056 guint8 protocol
, msg_type
;
3057 const gchar
*protocol_name
, *message_name
;
3059 /* An eDonkey UDP packet is at least 2 bytes long */
3060 if (!tvb_bytes_exist(tvb
, 0, EDONKEY_UDP_HEADER_LENGTH
))
3063 protocol
= tvb_get_guint8(tvb
, offset
);
3064 if (try_val_to_str(protocol
, edonkey_protocols
) == NULL
)
3065 return 0; /* Not a known protocol */
3067 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "eDonkey");
3070 ti
= proto_tree_add_item(tree
, proto_edonkey
, tvb
, 0, -1, ENC_NA
);
3071 edonkey_tree
= proto_item_add_subtree(ti
, ett_edonkey
);
3075 /* eDonkey UDP message - Assume that there is one message per packet */
3076 msg_type
= tvb_get_guint8(tvb
, offset
+1);
3077 protocol_name
= val_to_str_const(protocol
, edonkey_protocols
, "Unknown");
3079 if (protocol
== EDONKEY_PROTO_KADEMLIA
|| protocol
== EDONKEY_PROTO_KADEMLIA_COMP
3080 || protocol
== EDONKEY_PROTO_ADU_KADEMLIA
|| protocol
== EDONKEY_PROTO_ADU_KADEMLIA_COMP
)
3081 message_name
= val_to_str_const( msg_type
, kademlia_msgs
, "Unknown");
3083 message_name
= val_to_str_const(msg_type
, edonkey_udp_msgs
, "Unknown");
3085 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s UDP: %s", protocol_name
, message_name
);
3088 int remainingLength
, extraBytes
;
3090 ti
= proto_tree_add_item(edonkey_tree
, hf_edonkey_message
, tvb
, offset
, -1, ENC_NA
);
3091 edonkey_msg_tree
= proto_item_add_subtree(ti
, ett_edonkey_message
);
3093 proto_tree_add_uint_format_value(edonkey_msg_tree
, hf_edonkey_protocol
, tvb
, offset
, 1, protocol
,
3094 "%s (0x%02x)", protocol_name
, protocol
);
3095 proto_tree_add_uint_format_value(edonkey_msg_tree
, hf_edonkey_message_type
, tvb
, offset
+1, 1, msg_type
,
3096 "%s (0x%02x)", message_name
, msg_type
);
3098 offset
+= EDONKEY_UDP_HEADER_LENGTH
;
3099 remainingLength
= tvb_length_remaining( tvb
, offset
);
3101 if (remainingLength
> 0) {
3103 case EDONKEY_PROTO_EDONKEY
:
3104 offset
= dissect_edonkey_udp_message(msg_type
, tvb
, pinfo
, offset
, remainingLength
, edonkey_msg_tree
);
3107 case EDONKEY_PROTO_EMULE_EXT
:
3108 offset
= dissect_emule_udp_message(msg_type
, tvb
, pinfo
, offset
, remainingLength
, edonkey_msg_tree
);
3111 case EDONKEY_PROTO_ADU_KADEMLIA
:
3112 case EDONKEY_PROTO_KADEMLIA
:
3113 offset
= dissect_kademlia_udp_message(msg_type
, tvb
, pinfo
, offset
, remainingLength
, edonkey_msg_tree
);
3116 case EDONKEY_PROTO_ADU_KADEMLIA_COMP
:
3117 case EDONKEY_PROTO_KADEMLIA_COMP
:
3118 offset
= dissect_kademlia_udp_compressed_message(msg_type
, tvb
, pinfo
, offset
, remainingLength
, edonkey_msg_tree
);
3126 extraBytes
= tvb_reported_length_remaining( tvb
, offset
);
3128 if ( extraBytes
> 0 ) {
3129 /* trailing garbage or broken packet */
3130 proto_tree_add_uint_format(tree
, hf_edonkey_unparsed_data_length
, tvb
, offset
, extraBytes
, extraBytes
,
3131 "Trailing/Undecoded data: %d bytes", extraBytes
);
3135 return tvb_reported_length(tvb
);
3138 void proto_register_edonkey(void) {
3140 static hf_register_info hf
[] = {
3141 { &hf_edonkey_message
,
3142 { "eDonkey Message", "edonkey.message",
3143 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3144 { &hf_edonkey_protocol
,
3145 { "Protocol", "edonkey.protocol",
3146 FT_UINT8
, BASE_HEX
, VALS(edonkey_protocols
), 0, "eDonkey Protocol", HFILL
} },
3147 { &hf_edonkey_message_length
,
3148 { "Message Length", "edonkey.message.length",
3149 FT_UINT32
, BASE_DEC
, NULL
, 0, "eDonkey Message Length", HFILL
} },
3150 { &hf_edonkey_message_type
,
3151 { "Message Type", "edonkey.message.type",
3152 FT_UINT8
, BASE_HEX
, NULL
, 0, "eDonkey Message Type", HFILL
} },
3153 { &hf_edonkey_client_hash
,
3154 { "Client Hash", "edonkey.client_hash",
3155 FT_BYTES
, BASE_NONE
, NULL
, 0, "eDonkey Client Hash", HFILL
} },
3156 { &hf_edonkey_server_hash
,
3157 { "Server Hash", "edonkey.server_hash",
3158 FT_BYTES
, BASE_NONE
, NULL
, 0, "eDonkey Server Hash", HFILL
} },
3159 { &hf_edonkey_file_hash
,
3160 { "File Hash", "edonkey.file_hash",
3161 FT_BYTES
, BASE_NONE
, NULL
, 0, "eDonkey File Hash", HFILL
} },
3162 { &hf_edonkey_client_id
,
3163 { "Client ID", "edonkey.clientid",
3164 FT_IPv4
, BASE_NONE
, NULL
, 0, "eDonkey Client ID", HFILL
} },
3166 { "IP", "edonkey.ip",
3167 FT_IPv4
, BASE_NONE
, NULL
, 0, "eDonkey IP", HFILL
} },
3169 { "Port", "edonkey.port",
3170 FT_UINT16
, BASE_DEC
, NULL
, 0, "eDonkey Port", HFILL
} },
3171 { &hf_edonkey_metatag
,
3172 { "eDonkey Meta Tag", "edonkey.metatag",
3173 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3174 { &hf_edonkey_metatag_type
,
3175 { "Meta Tag Type", "edonkey.metatag.type",
3176 FT_UINT8
, BASE_HEX
, NULL
, 0, "eDonkey Meta Tag Type", HFILL
} },
3177 { &hf_edonkey_metatag_id
,
3178 { "Meta Tag ID", "edonkey.metatag.id",
3179 FT_UINT8
, BASE_HEX
, NULL
, 0, "eDonkey Meta Tag ID", HFILL
} },
3180 { &hf_edonkey_metatag_name
,
3181 { "Meta Tag Name", "edonkey.metatag.name",
3182 FT_STRING
, BASE_NONE
, NULL
, 0, "eDonkey Meta Tag Name", HFILL
} },
3183 { &hf_edonkey_metatag_namesize
,
3184 { "Meta Tag Name Size", "edonkey.metatag.namesize",
3185 FT_UINT16
, BASE_DEC
, NULL
, 0, "eDonkey Meta Tag Name Size", HFILL
} },
3186 { &hf_edonkey_search
,
3187 { "eDonkey Search", "edonkey.search",
3188 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3190 { "Hash", "edonkey.hash",
3191 FT_BYTES
, BASE_NONE
, NULL
, 0, "eDonkey Hash", HFILL
} },
3192 { &hf_edonkey_string
,
3193 { "String", "edonkey.string",
3194 FT_STRING
, BASE_NONE
, NULL
, 0, "eDonkey String", HFILL
} },
3195 { &hf_edonkey_string_length
,
3196 { "String Length", "edonkey.string_length",
3197 FT_UINT16
, BASE_DEC
, NULL
, 0, "eDonkey String Length", HFILL
} },
3198 { &hf_edonkey_part_count
,
3199 { "Part Count", "edonkey.part_count",
3200 FT_UINT16
, BASE_DEC
, NULL
, 0, "eDonkey Part Count", HFILL
} },
3201 { &hf_edonkey_file_status
,
3202 { "File Status", "edonkey.file_status",
3203 FT_BYTES
, BASE_NONE
, NULL
, 0, "eDonkey File Status", HFILL
} },
3204 { &hf_edonkey_directory
,
3205 { "Directory", "edonkey.directory",
3206 FT_STRING
, BASE_NONE
, NULL
, 0, "eDonkey Directory", HFILL
} },
3207 { &hf_edonkey_fileinfo
,
3208 { "eDonkey File Info", "edonkey.fileinfo",
3209 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3210 { &hf_edonkey_serverinfo
,
3211 { "eDonkey Server Info", "edonkey.serverinfo",
3212 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3213 { &hf_edonkey_clientinfo
,
3214 { "eDonkey Client Info", "edonkey.clientinfo",
3215 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3216 { &hf_emule_public_key
,
3217 { "Public Key", "edonkey.emule.public_key",
3218 FT_BYTES
, BASE_NONE
, NULL
, 0, "eMule Public Key", HFILL
} },
3219 { &hf_emule_signature
,
3220 { "Signature", "edonkey.emule.signature",
3221 FT_BYTES
, BASE_NONE
, NULL
, 0, "eMule Signature", HFILL
} },
3222 { &hf_emule_aich_partnum
,
3223 { "Part Number", "edonkey.emule.aich_partnum",
3224 FT_UINT16
, BASE_DEC
, NULL
, 0, "eMule AICH Part Number", HFILL
} },
3225 { &hf_emule_aich_root_hash
,
3226 { "AICH Root Hash", "edonkey.emule.aich_root_hash",
3227 FT_BYTES
, BASE_NONE
, NULL
, 0, "eMule AICH Root Hash", HFILL
} },
3228 { &hf_emule_aich_hash_entry
,
3229 { "AICH Hash Entry", "edonkey.emule.aich_hash_entry",
3230 FT_NONE
, BASE_NONE
, NULL
, 0, "eMule AICH Hash Entry", HFILL
} },
3231 { &hf_emule_aich_hash_id
,
3232 { "AICH Hash ID", "edonkey.emule.aich_hash_id",
3233 FT_UINT16
, BASE_HEX
, NULL
, 0, "eMule AICH Hash ID", HFILL
} },
3234 { &hf_emule_aich_hash
,
3235 { "AICH Hash", "edonkey.emule.aich_hash",
3236 FT_BYTES
, BASE_NONE
, NULL
, 0, "eMule AICH Hash", HFILL
} },
3237 { &hf_emule_multipacket_entry
,
3238 { "eMule MultiPacket Entry", "edonkey.emule.multipacket_entry",
3239 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3240 { &hf_emule_multipacket_opcode
,
3241 { "MultiPacket Opcode", "edonkey.emule.multipacket_opcode",
3242 FT_UINT8
, BASE_HEX
, NULL
, 0, "eMule MultiPacket Opcode", HFILL
} },
3243 { &hf_emule_sourceOBFU
,
3244 {"Source", "edonkey.source",
3245 FT_NONE
, BASE_NONE
, NULL
, 0, "eDonkey File Source", HFILL
} },
3246 { &hf_emule_source_count
,
3247 { "Completed Sources Count", "edonkey.emule.source_count",
3248 FT_UINT16
, BASE_DEC
, NULL
, 0, "eMule Completed Sources Count", HFILL
} },
3250 { "Compressed Data", "edonkey.emule.zlib",
3251 FT_NONE
, BASE_NONE
, NULL
, 0, "eMule Compressed Data", HFILL
} },
3253 { "Overnet Peer", "edonkey.overnet.peer",
3254 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3256 { "Kademlia Packet", "edonkey.kademlia",
3257 FT_UINT8
, BASE_HEX
, NULL
, 0, "Kademlia Packet Type", HFILL
} },
3258 { &hf_kademlia_peertype
,
3259 { "Peer Type", "edonkey.kademlia.peer.type",
3260 FT_UINT8
, BASE_DEC_HEX
, NULL
, 0, "Kademlia Peer Type", HFILL
} },
3261 { &hf_kademlia_peer
,
3262 { "Kademlia Peer", "edonkey.kademlia.peer",
3263 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3264 { &hf_kademlia_peer_id
,
3265 { "Peer ID", "edonkey.kademlia.peer.id",
3266 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia Peer ID", HFILL
} },
3267 { &hf_kademlia_hash
,
3268 { "Kademlia Hash", "edonkey.kademlia.hash",
3269 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
} },
3270 { &hf_kademlia_file_id
,
3271 { "File ID", "edonkey.kademlia.file.id",
3272 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia File ID", HFILL
} },
3273 { &hf_kademlia_keyword_hash
,
3274 { "Keyword Hash", "edonkey.kademlia.keyword.hash",
3275 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia Keyword Hash", HFILL
} },
3276 { &hf_kademlia_recipients_id
,
3277 { "Recipient's ID", "edonkey.kademlia.recipients.id",
3278 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia Recipient's ID", HFILL
} },
3279 { &hf_kademlia_sender_id
,
3280 { "Sender ID", "edonkey.kademlia.sender.id",
3281 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia Sender ID", HFILL
} },
3282 { &hf_kademlia_target_id
,
3283 { "Target ID", "edonkey.kademlia.target.id",
3284 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia Target ID", HFILL
} },
3285 { &hf_kademlia_distance
,
3286 { "XOR Distance", "edonkey.kademlia.distance",
3287 FT_STRING
, BASE_NONE
, NULL
, 0, "Kademlia XOR Distance", HFILL
} },
3288 { &hf_kademlia_version
,
3289 { "Kad Version", "edonkey.kademlia.version",
3290 FT_UINT8
, BASE_DEC_HEX
, NULL
, 0, NULL
, HFILL
} },
3291 { &hf_kademlia_tag_float
,
3292 { "Tag Value (Float)", "edonkey.kademlia.tag.value.float",
3293 FT_FLOAT
, BASE_NONE
, NULL
, 0, "Float Tag Value", HFILL
} },
3294 { &hf_kademlia_tag_uint64
,
3295 { "Tag Value (UINT64)", "edonkey.kademlia.tag.value.uint64",
3296 FT_UINT64
, BASE_DEC_HEX
, NULL
, 0, "UINT64 Tag Value", HFILL
} },
3297 { &hf_kademlia_tag_uint32
,
3298 { "Tag Value (UINT32)", "edonkey.kademlia.tag.value.uint32",
3299 FT_UINT32
, BASE_DEC_HEX
, NULL
, 0, "UINT32 Tag Value", HFILL
} },
3300 { &hf_kademlia_tag_ipv4
,
3301 { "Tag Value (IPv4)", "edonkey.kademlia.tag.value.ipv4",
3302 FT_IPv4
, BASE_NONE
, NULL
, 0, "UINT32 Tag Value (IPv4)", HFILL
} },
3303 { &hf_kademlia_tag_uint16
,
3304 { "Tag Value (UINT16)", "edonkey.kademlia.tag.value.uint16",
3305 FT_UINT16
, BASE_DEC_HEX
, NULL
, 0, "UINT16 Tag Value", HFILL
} },
3306 { &hf_kademlia_tag_uint8
,
3307 { "Tag Value (UINT8)", "edonkey.kademlia.tag.value.uint8",
3308 FT_UINT8
, BASE_DEC_HEX
, NULL
, 0, "UINT8 Tag Value", HFILL
} },
3309 { &hf_kademlia_tag_hash
,
3310 { "Tag Value (HASH)", "edonkey.kademlia.tag.value.hash",
3311 FT_BYTES
, BASE_NONE
, NULL
, 0, "HASH Tag Value", HFILL
} },
3312 { &hf_kademlia_tag_string
,
3313 { "Tag Value (String)", "edonkey.kademlia.tag.value.string",
3314 FT_STRING
, BASE_NONE
, NULL
, 0, "String Tag Value", HFILL
} },
3315 { &hf_kademlia_tag_bsob
,
3316 { "Tag Value (BSOB)", "edonkey.kademlia.tag.value.bsob",
3317 FT_BYTES
, BASE_NONE
, NULL
, 0, "BSOB Tag Value", HFILL
} },
3318 { &hf_kademlia_udp_port
,
3319 { "UDP Port", "edonkey.kademlia.udp_port",
3320 FT_UINT16
, BASE_DEC
, NULL
, 0, "Kademlia UDP Port", HFILL
} },
3322 { "IP", "edonkey.kademlia.ip",
3323 FT_IPv4
, BASE_NONE
, NULL
, 0, "eDonkey IP", HFILL
} },
3324 { &hf_kademlia_tcp_port
,
3325 { "TCP Port", "edonkey.kademlia.tcp_port",
3326 FT_UINT16
, BASE_DEC
, NULL
, 0, "Kademlia TCP Port", HFILL
} },
3328 { &hf_kademlia_unparsed_data_length
,
3329 { "Kademlia unparsed data length", "edonkey.kademlia.unparsed",
3330 FT_UINT16
, BASE_DEC
, NULL
, 0, "Kademlia trailing data length", HFILL
} },
3332 { &hf_kademlia_tag_name
,
3333 { "Tag Name", "edonkey.kademlia.tag.name",
3334 FT_UINT8
, BASE_HEX
, NULL
, 0, "Kademlia Tag Name String", HFILL
} },
3335 { &hf_kademlia_tag_name_length
,
3336 { "Tag Name Length", "edonkey.kademlia.tag.name.length",
3337 FT_UINT16
, BASE_DEC
, NULL
, 0, "Kademlia Tag Name String Length", HFILL
} },
3338 { &hf_kademlia_tag_type
,
3339 { "Tag Type", "edonkey.kademlia.tag.type",
3340 FT_UINT8
, BASE_HEX
, NULL
, 0, "Kademlia Tag Type", HFILL
} },
3341 { &hf_kademlia_request_type
,
3342 { "Request Type", "edonkey.kademlia.request.type",
3343 FT_UINT8
, BASE_HEX
, NULL
, 0, "Kademlia Request Type", HFILL
} },
3344 { &hf_kademlia_search_condition
,
3345 { "Search Condition", "edonkey.kademlia.search.condition",
3346 FT_UINT8
, BASE_HEX
, NULL
, 0, "Kademlia Search Condition", HFILL
} },
3347 { &hf_kademlia_search_condition_argument_uint32
,
3348 { "32bit Argument", "edonkey.kademlia.search.condition.argument.uint32",
3349 FT_UINT32
, BASE_DEC_HEX
, NULL
, 0, "Kademlia Search Condition Argument 32bit Value", HFILL
} },
3350 { &hf_kademlia_search_condition_argument_uint64
,
3351 { "64bit Argument", "edonkey.kademlia.search.condition.argument.uint64",
3352 FT_UINT64
, BASE_DEC_HEX
, NULL
, 0, "Kademlia Search Condition Argument 64bit Value", HFILL
} },
3353 { &hf_edonkey_unparsed_data_length
,
3354 { "eDonkey unparsed data length", "edonkey.unparsed",
3355 FT_UINT32
, BASE_DEC_HEX
, NULL
, 0, "eDonkey trailing or unparsed data length", HFILL
} },
3358 static gint
*ett
[] = {
3360 &ett_edonkey_message
,
3361 &ett_edonkey_metatag
,
3362 &ett_edonkey_search
,
3363 &ett_edonkey_fileinfo
,
3364 &ett_edonkey_serverinfo
,
3365 &ett_edonkey_clientinfo
,
3366 &ett_emule_aichhash
,
3367 &ett_emule_multipacket
,
3370 &ett_emule_sourceOBFU
,
3371 &ett_edonkey_listitem
,
3372 &ett_kademlia_search_expression
,
3375 module_t
*edonkey_module
;
3377 proto_edonkey
= proto_register_protocol("eDonkey Protocol", "EDONKEY", "edonkey");
3379 proto_register_field_array(proto_edonkey
, hf
, array_length(hf
));
3381 proto_register_subtree_array(ett
, array_length(ett
));
3383 edonkey_module
= prefs_register_protocol(proto_edonkey
, NULL
);
3384 prefs_register_bool_preference(edonkey_module
, "desegment",
3385 "Reassemble eDonkey messages spanning multiple TCP segments",
3386 "Whether the eDonkey dissector should reassemble messages spanning multiple TCP segments."
3387 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3388 &edonkey_desegment
);
3391 void proto_reg_handoff_edonkey(void) {
3393 dissector_handle_t edonkey_tcp_handle
;
3394 dissector_handle_t edonkey_udp_handle
;
3396 edonkey_tcp_handle
= new_create_dissector_handle(dissect_edonkey_tcp
, proto_edonkey
);
3397 edonkey_udp_handle
= new_create_dissector_handle(dissect_edonkey_udp
, proto_edonkey
);
3399 dissector_add_uint("tcp.port", 4661, edonkey_tcp_handle
);
3400 dissector_add_uint("tcp.port", 4662, edonkey_tcp_handle
);
3401 dissector_add_uint("tcp.port", 4663, edonkey_tcp_handle
);
3402 dissector_add_uint("udp.port", 4665, edonkey_udp_handle
);
3403 dissector_add_uint("udp.port", 4672, edonkey_udp_handle
);
3408 * Editor modelines - http://www.wireshark.org/tools/modelines.html
3413 * indent-tabs-mode: nil
3416 * vi: set shiftwidth=4 tabstop=8 expandtab:
3417 * :indentSize=4:tabSize=8:noTabs=true: