/src/wireshark/epan/dissectors/packet-bitcoin.c
Line | Count | Source |
1 | | /* packet-bitcoin.c |
2 | | * Routines for bitcoin dissection |
3 | | * Copyright 2011, Christian Svensson <blue@cmd.nu> |
4 | | * Bitcoin address: 15Y2EN5mLnsTt3CZBfgpnZR5SeLwu7WEHz |
5 | | * |
6 | | * See https://en.bitcoin.it/wiki/Protocol_specification |
7 | | * |
8 | | * Updated 2015, Laurenz Kamp <laurenz.kamp@gmx.de> |
9 | | * Changes made: |
10 | | * Updated dissectors: |
11 | | * -> ping: ping packets now have a nonce. |
12 | | * -> version: If version >= 70002, version messages have a relay flag. |
13 | | * -> Messages with no payload: Added mempool and filterclear messages. |
14 | | * Added dissectors: |
15 | | * -> pong message |
16 | | * -> notfound message |
17 | | * -> reject message |
18 | | * -> filterload |
19 | | * -> filteradd |
20 | | * -> merkleblock |
21 | | * -> headers |
22 | | * |
23 | | * Wireshark - Network traffic analyzer |
24 | | * By Gerald Combs <gerald@wireshark.org> |
25 | | * Copyright 1998 Gerald Combs |
26 | | * |
27 | | * SPDX-License-Identifier: GPL-2.0-or-later |
28 | | */ |
29 | | #include "config.h" |
30 | | |
31 | | #include <epan/packet.h> |
32 | | #include <epan/prefs.h> |
33 | | #include <epan/expert.h> |
34 | | #include <epan/tfs.h> |
35 | | #include <wsutil/array.h> |
36 | | |
37 | | #include "packet-tcp.h" |
38 | | |
39 | 3.05k | #define BITCOIN_MAIN_MAGIC_NUMBER 0xD9B4BEF9 |
40 | 3.05k | #define BITCOIN_TESTNET_MAGIC_NUMBER 0xDAB5BFFA |
41 | 3.04k | #define BITCOIN_TESTNET3_MAGIC_NUMBER 0x0709110B |
42 | 3.04k | #define BITCOIN_TESTNET4_MAGIC_NUMBER 0x283F161C |
43 | | |
44 | | static const value_string inv_types[] = |
45 | | { |
46 | | { 0, "ERROR" }, |
47 | | { 1, "MSG_TX" }, |
48 | | { 2, "MSG_BLOCK" }, |
49 | | { 3, "MSG_FILTERED_BLOCK" }, |
50 | | { 4, "MSG_CMPCT_BLOCK" }, |
51 | | { 5, "MSG_WTX" }, |
52 | | { 0x40000001, "MSG_WITNESS_TX" }, |
53 | | { 0x40000002, "MSG_WITNESS_BLOCK" }, |
54 | | { 0, NULL } |
55 | | }; |
56 | | |
57 | | static const value_string network_ids[] = |
58 | | { |
59 | | { 0x01, "IPv4" }, |
60 | | { 0x02, "IPv6" }, |
61 | | { 0x03, "Tor v2" }, |
62 | | { 0x04, "Tor v3" }, |
63 | | { 0x05, "I2P" }, |
64 | | { 0x06, "Cjdns" }, |
65 | | { 0, NULL } |
66 | | }; |
67 | | |
68 | | static const value_string reject_ccode[] = |
69 | | { |
70 | | { 0x01, "REJECT_MALFORMED" }, |
71 | | { 0x10, "REJECT_INVALID" }, |
72 | | { 0x11, "REJECT_OBSOLETE" }, |
73 | | { 0x12, "REJECT_DUPLICATE" }, |
74 | | { 0x40, "REJECT_NONSTANDARD" }, |
75 | | { 0x41, "REJECT_DUST" }, |
76 | | { 0x42, "REJECT_INSUFFICIENTFEE" }, |
77 | | { 0x43, "REJECT_CHECKPOINT" }, |
78 | | { 0, NULL } |
79 | | }; |
80 | | |
81 | | static const value_string filterload_nflags[] = |
82 | | { |
83 | | { 0, "BLOOM_UPDATE_NONE" }, |
84 | | { 1, "BLOOM_UPDATE_ALL" }, |
85 | | { 2, "BLOOM_UPDATE_P2PUBKEY_ONLY" }, |
86 | | { 0, NULL } |
87 | | }; |
88 | | |
89 | | /* |
90 | | * Minimum bitcoin identification header. |
91 | | * - Magic - 4 bytes |
92 | | * - Command - 12 bytes |
93 | | * - Payload length - 4 bytes |
94 | | * - Checksum - 4 bytes |
95 | | */ |
96 | 27 | #define BITCOIN_HEADER_LENGTH 4+12+4+4 |
97 | | |
98 | | void proto_register_bitcoin(void); |
99 | | void proto_reg_handoff_bitcoin(void); |
100 | | |
101 | | static dissector_handle_t bitcoin_handle; |
102 | | |
103 | | static dissector_table_t bitcoin_command_table; |
104 | | |
105 | | static int proto_bitcoin; |
106 | | |
107 | | static int hf_address_address; |
108 | | static int hf_address_port; |
109 | | static int hf_address_services; |
110 | | static int hf_bitcoin_checksum; |
111 | | static int hf_bitcoin_command; |
112 | | static int hf_bitcoin_length; |
113 | | static int hf_bitcoin_magic; |
114 | | static int hf_bitcoin_msg_addr; |
115 | | static int hf_bitcoin_msg_addrv2; |
116 | | static int hf_bitcoin_msg_block; |
117 | | static int hf_bitcoin_msg_feefilter; |
118 | | static int hf_bitcoin_msg_filteradd; |
119 | | static int hf_bitcoin_msg_filterload; |
120 | | static int hf_bitcoin_msg_getblocks; |
121 | | static int hf_bitcoin_msg_getdata; |
122 | | static int hf_bitcoin_msg_getheaders; |
123 | | static int hf_bitcoin_msg_headers; |
124 | | static int hf_bitcoin_msg_inv; |
125 | | static int hf_bitcoin_msg_merkleblock; |
126 | | static int hf_bitcoin_msg_notfound; |
127 | | static int hf_bitcoin_msg_ping; |
128 | | static int hf_bitcoin_msg_pong; |
129 | | static int hf_bitcoin_msg_reject; |
130 | | static int hf_bitcoin_msg_sendcmpct; |
131 | | static int hf_bitcoin_msg_tx; |
132 | | static int hf_bitcoin_msg_version; |
133 | | static int hf_data_value; |
134 | | static int hf_data_varint_count16; |
135 | | static int hf_data_varint_count32; |
136 | | static int hf_data_varint_count64; |
137 | | static int hf_data_varint_count8; |
138 | | static int hf_msg_addr_address; |
139 | | static int hf_msg_addr_count16; |
140 | | static int hf_msg_addr_count32; |
141 | | static int hf_msg_addr_count64; |
142 | | static int hf_msg_addr_count8; |
143 | | static int hf_msg_addr_timestamp; |
144 | | static int hf_msg_addrv2_count16; |
145 | | static int hf_msg_addrv2_count32; |
146 | | static int hf_msg_addrv2_count64; |
147 | | static int hf_msg_addrv2_count8; |
148 | | static int hf_msg_addrv2_item; |
149 | | static int hf_msg_addrv2_timestamp; |
150 | | static int hf_msg_addrv2_services; |
151 | | static int hf_msg_addrv2_network; |
152 | | static int hf_msg_addrv2_address_ipv4; |
153 | | static int hf_msg_addrv2_address_ipv6; |
154 | | static int hf_msg_addrv2_address_other; |
155 | | static int hf_msg_addrv2_port; |
156 | | static int hf_msg_block_bits; |
157 | | static int hf_msg_block_merkle_root; |
158 | | static int hf_msg_block_nonce; |
159 | | static int hf_msg_block_prev_block; |
160 | | static int hf_msg_block_time; |
161 | | static int hf_msg_block_transactions16; |
162 | | static int hf_msg_block_transactions32; |
163 | | static int hf_msg_block_transactions64; |
164 | | static int hf_msg_block_transactions8; |
165 | | static int hf_msg_block_version; |
166 | | static int hf_msg_feefilter_value; |
167 | | static int hf_msg_filteradd_data; |
168 | | static int hf_msg_filterload_filter; |
169 | | static int hf_msg_filterload_nflags; |
170 | | static int hf_msg_filterload_nhashfunc; |
171 | | static int hf_msg_filterload_ntweak; |
172 | | static int hf_msg_getblocks_count16; |
173 | | static int hf_msg_getblocks_count32; |
174 | | static int hf_msg_getblocks_count64; |
175 | | static int hf_msg_getblocks_count8; |
176 | | static int hf_msg_getblocks_start; |
177 | | static int hf_msg_getblocks_stop; |
178 | | static int hf_msg_getdata_count16; |
179 | | static int hf_msg_getdata_count32; |
180 | | static int hf_msg_getdata_count64; |
181 | | static int hf_msg_getdata_count8; |
182 | | static int hf_msg_getdata_hash; |
183 | | static int hf_msg_getdata_type; |
184 | | static int hf_msg_getheaders_count16; |
185 | | static int hf_msg_getheaders_count32; |
186 | | static int hf_msg_getheaders_count64; |
187 | | static int hf_msg_getheaders_count8; |
188 | | static int hf_msg_getheaders_start; |
189 | | static int hf_msg_getheaders_stop; |
190 | | static int hf_msg_getheaders_version; |
191 | | static int hf_msg_headers_bits; |
192 | | static int hf_msg_headers_count16; |
193 | | static int hf_msg_headers_count32; |
194 | | static int hf_msg_headers_count64; |
195 | | static int hf_msg_headers_count8; |
196 | | static int hf_msg_headers_merkle_root; |
197 | | static int hf_msg_headers_nonce; |
198 | | static int hf_msg_headers_prev_block; |
199 | | static int hf_msg_headers_time; |
200 | | static int hf_msg_headers_version; |
201 | | static int hf_msg_inv_count16; |
202 | | static int hf_msg_inv_count32; |
203 | | static int hf_msg_inv_count64; |
204 | | static int hf_msg_inv_count8; |
205 | | static int hf_msg_inv_hash; |
206 | | static int hf_msg_inv_type; |
207 | | static int hf_msg_merkleblock_bits; |
208 | | static int hf_msg_merkleblock_flags_data; |
209 | | static int hf_msg_merkleblock_flags_size16; |
210 | | static int hf_msg_merkleblock_flags_size32; |
211 | | static int hf_msg_merkleblock_flags_size64; |
212 | | static int hf_msg_merkleblock_flags_size8; |
213 | | static int hf_msg_merkleblock_hashes_count16; |
214 | | static int hf_msg_merkleblock_hashes_count32; |
215 | | static int hf_msg_merkleblock_hashes_count64; |
216 | | static int hf_msg_merkleblock_hashes_count8; |
217 | | static int hf_msg_merkleblock_hashes_hash; |
218 | | static int hf_msg_merkleblock_merkle_root; |
219 | | static int hf_msg_merkleblock_nonce; |
220 | | static int hf_msg_merkleblock_prev_block; |
221 | | static int hf_msg_merkleblock_time; |
222 | | static int hf_msg_merkleblock_transactions; |
223 | | static int hf_msg_merkleblock_version; |
224 | | static int hf_msg_notfound_count16; |
225 | | static int hf_msg_notfound_count32; |
226 | | static int hf_msg_notfound_count64; |
227 | | static int hf_msg_notfound_count8; |
228 | | static int hf_msg_notfound_hash; |
229 | | static int hf_msg_notfound_type; |
230 | | static int hf_msg_ping_nonce; |
231 | | static int hf_msg_pong_nonce; |
232 | | static int hf_msg_reject_ccode; |
233 | | static int hf_msg_reject_data; |
234 | | static int hf_msg_reject_message; |
235 | | static int hf_msg_reject_reason; |
236 | | static int hf_msg_sendcmpct_announce; |
237 | | static int hf_msg_sendcmpct_version; |
238 | | static int hf_msg_tx_in; |
239 | | static int hf_msg_tx_in_count16; |
240 | | static int hf_msg_tx_in_count32; |
241 | | static int hf_msg_tx_in_count64; |
242 | | static int hf_msg_tx_in_count8; |
243 | | static int hf_msg_tx_in_prev_outp_hash; |
244 | | static int hf_msg_tx_in_prev_outp_index; |
245 | | static int hf_msg_tx_in_prev_output; |
246 | | static int hf_msg_tx_in_script16; |
247 | | static int hf_msg_tx_in_script32; |
248 | | static int hf_msg_tx_in_script64; |
249 | | static int hf_msg_tx_in_script8; |
250 | | static int hf_msg_tx_in_seq; |
251 | | static int hf_msg_tx_in_sig_script; |
252 | | static int hf_msg_tx_lock_time; |
253 | | static int hf_msg_tx_out; |
254 | | static int hf_msg_tx_out_count16; |
255 | | static int hf_msg_tx_out_count32; |
256 | | static int hf_msg_tx_out_count64; |
257 | | static int hf_msg_tx_out_count8; |
258 | | static int hf_msg_tx_out_script; |
259 | | static int hf_msg_tx_out_script16; |
260 | | static int hf_msg_tx_out_script32; |
261 | | static int hf_msg_tx_out_script64; |
262 | | static int hf_msg_tx_out_script8; |
263 | | static int hf_msg_tx_out_value; |
264 | | static int hf_msg_tx_witness; |
265 | | static int hf_msg_tx_witness_components16; |
266 | | static int hf_msg_tx_witness_components32; |
267 | | static int hf_msg_tx_witness_components64; |
268 | | static int hf_msg_tx_witness_components8; |
269 | | static int hf_msg_tx_witness_component; |
270 | | static int hf_msg_tx_witness_component_length16; |
271 | | static int hf_msg_tx_witness_component_length32; |
272 | | static int hf_msg_tx_witness_component_length64; |
273 | | static int hf_msg_tx_witness_component_length8; |
274 | | static int hf_msg_tx_witness_component_data; |
275 | | static int hf_msg_tx_version; |
276 | | static int hf_msg_tx_flag; |
277 | | static int hf_msg_version_addr_me; |
278 | | static int hf_msg_version_addr_you; |
279 | | static int hf_msg_version_nonce; |
280 | | static int hf_msg_version_relay; |
281 | | static int hf_msg_version_services; |
282 | | static int hf_msg_version_start_height; |
283 | | static int hf_msg_version_timestamp; |
284 | | static int hf_msg_version_user_agent; |
285 | | static int hf_msg_version_version; |
286 | | static int hf_services_network; |
287 | | static int hf_services_getutxo; |
288 | | static int hf_services_bloom; |
289 | | static int hf_services_witness; |
290 | | static int hf_services_xthin; |
291 | | static int hf_services_compactfilters; |
292 | | static int hf_services_networklimited; |
293 | | static int hf_services_p2pv2; |
294 | | static int hf_string_value; |
295 | | static int hf_string_varint_count16; |
296 | | static int hf_string_varint_count32; |
297 | | static int hf_string_varint_count64; |
298 | | static int hf_string_varint_count8; |
299 | | |
300 | | static int * const services_hf_flags[] = { |
301 | | &hf_services_network, |
302 | | &hf_services_getutxo, |
303 | | &hf_services_bloom, |
304 | | &hf_services_witness, |
305 | | &hf_services_xthin, |
306 | | &hf_services_compactfilters, |
307 | | &hf_services_networklimited, |
308 | | &hf_services_p2pv2, |
309 | | NULL |
310 | | }; |
311 | | |
312 | | static int ett_bitcoin; |
313 | | static int ett_bitcoin_msg; |
314 | | static int ett_services; |
315 | | static int ett_address; |
316 | | static int ett_string; |
317 | | static int ett_addr_list; |
318 | | static int ett_inv_list; |
319 | | static int ett_getdata_list; |
320 | | static int ett_notfound_list; |
321 | | static int ett_getblocks_list; |
322 | | static int ett_getheaders_list; |
323 | | static int ett_tx_in_list; |
324 | | static int ett_tx_in_outp; |
325 | | static int ett_tx_out_list; |
326 | | static int ett_tx_witness_list; |
327 | | static int ett_tx_witness_component_list; |
328 | | |
329 | | static expert_field ei_bitcoin_command_unknown; |
330 | | static expert_field ei_bitcoin_address_length; |
331 | | static expert_field ei_bitcoin_script_len; |
332 | | |
333 | | |
334 | | static bool bitcoin_desegment = true; |
335 | | |
336 | | static unsigned |
337 | | get_bitcoin_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, |
338 | | int offset, void *data _U_) |
339 | 18 | { |
340 | 18 | uint32_t length; |
341 | 18 | length = BITCOIN_HEADER_LENGTH; |
342 | | |
343 | | /* add payload length */ |
344 | 18 | length += tvb_get_letohl(tvb, offset+16); |
345 | | |
346 | 18 | return length; |
347 | 18 | } |
348 | | |
349 | | static void |
350 | 0 | format_feefilter_value(char *buf, int64_t value) { |
351 | 0 | snprintf(buf, ITEM_LABEL_LENGTH, "%.3f sat/B", ((double) value) / 1000); |
352 | 0 | } |
353 | | |
354 | | /** |
355 | | * Create a sub-tree and fill it with a net_addr structure |
356 | | */ |
357 | | static proto_tree * |
358 | | create_address_tree(tvbuff_t *tvb, proto_item *ti, uint32_t offset) |
359 | 0 | { |
360 | 0 | proto_tree *tree; |
361 | |
|
362 | 0 | tree = proto_item_add_subtree(ti, ett_address); |
363 | | |
364 | | /* services */ |
365 | 0 | proto_tree_add_bitmask(tree, tvb, offset, hf_address_services, |
366 | 0 | ett_services, services_hf_flags, ENC_LITTLE_ENDIAN); |
367 | 0 | offset += 8; |
368 | | |
369 | | /* IPv6 address */ |
370 | 0 | proto_tree_add_item(tree, hf_address_address, tvb, offset, 16, ENC_NA); |
371 | 0 | offset += 16; |
372 | | |
373 | | /* port */ |
374 | 0 | proto_tree_add_item(tree, hf_address_port, tvb, offset, 2, ENC_BIG_ENDIAN); |
375 | |
|
376 | 0 | return tree; |
377 | 0 | } |
378 | | |
379 | | /** |
380 | | * Extract a variable length integer from a tvbuff |
381 | | */ |
382 | | static void |
383 | | get_varint(tvbuff_t *tvb, const int offset, int *length, uint64_t *ret) |
384 | 0 | { |
385 | 0 | unsigned value; |
386 | | |
387 | | /* Note: just throw an exception if not enough bytes are available in the tvbuff */ |
388 | | |
389 | | /* calculate variable length */ |
390 | 0 | value = tvb_get_uint8(tvb, offset); |
391 | 0 | if (value < 0xfd) |
392 | 0 | { |
393 | 0 | *length = 1; |
394 | 0 | *ret = value; |
395 | 0 | return; |
396 | 0 | } |
397 | | |
398 | 0 | if (value == 0xfd) |
399 | 0 | { |
400 | 0 | *length = 3; |
401 | 0 | *ret = tvb_get_letohs(tvb, offset+1); |
402 | 0 | return; |
403 | 0 | } |
404 | 0 | if (value == 0xfe) |
405 | 0 | { |
406 | 0 | *length = 5; |
407 | 0 | *ret = tvb_get_letohl(tvb, offset+1); |
408 | 0 | return; |
409 | 0 | } |
410 | | |
411 | 0 | *length = 9; |
412 | 0 | *ret = tvb_get_letoh64(tvb, offset+1); |
413 | 0 | return; |
414 | |
|
415 | 0 | } |
416 | | |
417 | | static void add_varint_item(proto_tree *tree, tvbuff_t *tvb, const int offset, int length, |
418 | | int hfi8, int hfi16, int hfi32, int hfi64) |
419 | 0 | { |
420 | 0 | switch (length) |
421 | 0 | { |
422 | 0 | case 1: |
423 | 0 | proto_tree_add_item(tree, hfi8, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
424 | 0 | break; |
425 | 0 | case 3: |
426 | 0 | proto_tree_add_item(tree, hfi16, tvb, offset+1, 2, ENC_LITTLE_ENDIAN); |
427 | 0 | break; |
428 | 0 | case 5: |
429 | 0 | proto_tree_add_item(tree, hfi32, tvb, offset+1, 4, ENC_LITTLE_ENDIAN); |
430 | 0 | break; |
431 | 0 | case 9: |
432 | 0 | proto_tree_add_item(tree, hfi64, tvb, offset+1, 8, ENC_LITTLE_ENDIAN); |
433 | 0 | break; |
434 | 0 | } |
435 | 0 | } |
436 | | |
437 | | static proto_tree * |
438 | | create_string_tree(proto_tree *tree, int hfindex, tvbuff_t *tvb, uint32_t* offset) |
439 | 0 | { |
440 | 0 | proto_tree *subtree; |
441 | 0 | proto_item *ti; |
442 | 0 | int varint_length; |
443 | 0 | uint64_t varint; |
444 | 0 | int string_length; |
445 | | |
446 | | /* First is the length of the following string as a varint */ |
447 | 0 | get_varint(tvb, *offset, &varint_length, &varint); |
448 | 0 | string_length = (int) varint; |
449 | |
|
450 | 0 | ti = proto_tree_add_item(tree, hfindex, tvb, *offset, varint_length + string_length, ENC_NA); |
451 | 0 | subtree = proto_item_add_subtree(ti, ett_string); |
452 | | |
453 | | /* length */ |
454 | 0 | add_varint_item(subtree, tvb, *offset, varint_length, hf_string_varint_count8, |
455 | 0 | hf_string_varint_count16, hf_string_varint_count32, |
456 | 0 | hf_string_varint_count64); |
457 | 0 | *offset += varint_length; |
458 | | |
459 | | /* string */ |
460 | 0 | proto_tree_add_item(subtree, hf_string_value, tvb, *offset, string_length, |
461 | 0 | ENC_ASCII); |
462 | 0 | *offset += string_length; |
463 | |
|
464 | 0 | return subtree; |
465 | 0 | } |
466 | | |
467 | | static proto_tree * |
468 | | create_data_tree(proto_tree *tree, int hfindex, tvbuff_t *tvb, uint32_t* offset) |
469 | 0 | { |
470 | 0 | proto_tree *subtree; |
471 | 0 | proto_item *ti; |
472 | 0 | int varint_length; |
473 | 0 | uint64_t varint; |
474 | 0 | int data_length; |
475 | | |
476 | | /* First is the length of the following string as a varint */ |
477 | 0 | get_varint(tvb, *offset, &varint_length, &varint); |
478 | 0 | data_length = (int) varint; |
479 | |
|
480 | 0 | ti = proto_tree_add_item(tree, hfindex, tvb, *offset, varint_length + data_length, ENC_NA); |
481 | 0 | subtree = proto_item_add_subtree(ti, ett_string); |
482 | | |
483 | | /* length */ |
484 | 0 | add_varint_item(subtree, tvb, *offset, varint_length, hf_data_varint_count8, |
485 | 0 | hf_data_varint_count16, hf_data_varint_count32, |
486 | 0 | hf_data_varint_count64); |
487 | 0 | *offset += varint_length; |
488 | | |
489 | | /* data */ |
490 | 0 | proto_tree_add_item(subtree, hf_data_value, tvb, *offset, data_length, |
491 | 0 | BASE_SHOW_UTF_8_PRINTABLE); |
492 | 0 | *offset += data_length; |
493 | |
|
494 | 0 | return subtree; |
495 | 0 | } |
496 | | |
497 | | /* Note: A number of the following message handlers include code of the form: |
498 | | * ... |
499 | | * uint64_t count; |
500 | | * ... |
501 | | * for (; count > 0; count--) |
502 | | * { |
503 | | * proto_tree_add_item9...); |
504 | | * offset += ...; |
505 | | * proto_tree_add_item9...); |
506 | | * offset += ...; |
507 | | * ... |
508 | | * } |
509 | | * ... |
510 | | * |
511 | | * Issue if 'count' is a very large number: |
512 | | * If 'tree' is NULL, then the result will be effectively (but not really) |
513 | | * an infinite loop. This is true because if 'tree' is NULL then |
514 | | * proto_tree_add_item(tree, ...) is effectively a no-op and will not throw |
515 | | * an exception. |
516 | | * So: the loop should be executed only when 'tree' is defined so that the |
517 | | * proto_ calls will throw an exception when the tvb is used up; |
518 | | * This should only take a few-hundred loops at most. |
519 | | * https://gitlab.com/wireshark/wireshark/-/issues/8312 |
520 | | */ |
521 | | |
522 | | /** |
523 | | * Handler for version messages |
524 | | */ |
525 | | static int |
526 | | dissect_bitcoin_msg_version(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
527 | 0 | { |
528 | 0 | proto_item *ti; |
529 | 0 | uint32_t version; |
530 | 0 | uint32_t offset = 0; |
531 | |
|
532 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_version, tvb, offset, -1, ENC_NA); |
533 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
534 | |
|
535 | 0 | version = tvb_get_letohl(tvb, offset); |
536 | |
|
537 | 0 | proto_tree_add_item(tree, hf_msg_version_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
538 | 0 | offset += 4; |
539 | |
|
540 | 0 | proto_tree_add_bitmask(tree, tvb, offset, hf_msg_version_services, |
541 | 0 | ett_services, services_hf_flags, ENC_LITTLE_ENDIAN); |
542 | 0 | offset += 8; |
543 | |
|
544 | 0 | proto_tree_add_item(tree, hf_msg_version_timestamp, tvb, offset, 8, ENC_TIME_SECS_NSECS|ENC_LITTLE_ENDIAN); |
545 | 0 | offset += 8; |
546 | |
|
547 | 0 | ti = proto_tree_add_item(tree, hf_msg_version_addr_you, tvb, offset, 26, ENC_NA); |
548 | 0 | create_address_tree(tvb, ti, offset); |
549 | 0 | offset += 26; |
550 | |
|
551 | 0 | if (version >= 106) |
552 | 0 | { |
553 | 0 | ti = proto_tree_add_item(tree, hf_msg_version_addr_me, tvb, offset, 26, ENC_NA); |
554 | 0 | create_address_tree(tvb, ti, offset); |
555 | 0 | offset += 26; |
556 | |
|
557 | 0 | proto_tree_add_item(tree, hf_msg_version_nonce, tvb, offset, 8, ENC_LITTLE_ENDIAN); |
558 | 0 | offset += 8; |
559 | |
|
560 | 0 | create_string_tree(tree, hf_msg_version_user_agent, tvb, &offset); |
561 | 0 | } |
562 | |
|
563 | 0 | if (version >= 209) |
564 | 0 | { |
565 | 0 | proto_tree_add_item(tree, hf_msg_version_start_height, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
566 | 0 | offset += 4; |
567 | 0 | } |
568 | |
|
569 | 0 | if (version >= 70002) |
570 | 0 | { |
571 | 0 | proto_tree_add_item(tree, hf_msg_version_relay, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
572 | 0 | offset += 1; |
573 | 0 | } |
574 | |
|
575 | 0 | return offset; |
576 | 0 | } |
577 | | |
578 | | /** |
579 | | * Handler for address messages |
580 | | */ |
581 | | static int |
582 | | dissect_bitcoin_msg_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
583 | 0 | { |
584 | 0 | proto_item *ti; |
585 | 0 | int length; |
586 | 0 | uint64_t count; |
587 | 0 | uint32_t offset = 0; |
588 | |
|
589 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_addr, tvb, offset, -1, ENC_NA); |
590 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
591 | |
|
592 | 0 | get_varint(tvb, offset, &length, &count); |
593 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_addr_count8, hf_msg_addr_count16, |
594 | 0 | hf_msg_addr_count32, hf_msg_addr_count64); |
595 | 0 | offset += length; |
596 | |
|
597 | 0 | for (; count > 0; count--) |
598 | 0 | { |
599 | 0 | proto_tree *subtree; |
600 | |
|
601 | 0 | ti = proto_tree_add_item(tree, hf_msg_addr_address, tvb, offset, 30, ENC_NA); |
602 | 0 | subtree = create_address_tree(tvb, ti, offset+4); |
603 | |
|
604 | 0 | proto_tree_add_item(subtree, hf_msg_addr_timestamp, tvb, offset, 4, ENC_TIME_SECS|ENC_LITTLE_ENDIAN); |
605 | 0 | offset += 26; |
606 | 0 | offset += 4; |
607 | 0 | } |
608 | |
|
609 | 0 | return offset; |
610 | 0 | } |
611 | | |
612 | | /** |
613 | | * Handler for addrv2 messages |
614 | | */ |
615 | | static int |
616 | | dissect_bitcoin_msg_addrv2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
617 | 0 | { |
618 | 0 | proto_item *ti; |
619 | 0 | int length; |
620 | 0 | uint64_t count; |
621 | 0 | int offset = 0; |
622 | |
|
623 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_addrv2, tvb, offset, -1, ENC_NA); |
624 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
625 | |
|
626 | 0 | get_varint(tvb, offset, &length, &count); |
627 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_addrv2_count8, hf_msg_addrv2_count16, |
628 | 0 | hf_msg_addrv2_count32, hf_msg_addrv2_count64); |
629 | 0 | offset += length; |
630 | |
|
631 | 0 | for (; count > 0; count--) |
632 | 0 | { |
633 | 0 | proto_item *sti; |
634 | 0 | proto_item *sti_services; |
635 | 0 | proto_tree *subtree; |
636 | 0 | uint64_t services; |
637 | 0 | uint8_t network; |
638 | 0 | uint64_t address_length; |
639 | |
|
640 | 0 | sti = proto_tree_add_item(tree, hf_msg_addrv2_item, tvb, offset, -1, ENC_NA); |
641 | 0 | subtree = proto_item_add_subtree(sti, ett_addr_list); |
642 | |
|
643 | 0 | proto_tree_add_item(subtree, hf_msg_addrv2_timestamp, tvb, offset, 4, ENC_TIME_SECS|ENC_LITTLE_ENDIAN); |
644 | 0 | offset += 4; |
645 | |
|
646 | 0 | get_varint(tvb, offset, &length, &services); |
647 | 0 | sti_services = proto_tree_add_bitmask_value(subtree, tvb, offset, hf_msg_addrv2_services, |
648 | 0 | ett_services, services_hf_flags, services); |
649 | 0 | proto_item_set_len(sti_services, length); |
650 | 0 | offset += length; |
651 | |
|
652 | 0 | network = tvb_get_uint8(tvb, offset); |
653 | 0 | proto_tree_add_item(subtree, hf_msg_addrv2_network, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
654 | 0 | offset += 1; |
655 | |
|
656 | 0 | get_varint(tvb, offset, &length, &address_length); |
657 | 0 | offset += length; |
658 | |
|
659 | 0 | switch (network) |
660 | 0 | { |
661 | 0 | case 1: |
662 | 0 | proto_tree_add_item(subtree, hf_msg_addrv2_address_ipv4, tvb, offset, (unsigned) address_length, ENC_BIG_ENDIAN); |
663 | 0 | if (address_length != 4) { |
664 | 0 | proto_tree_add_expert(subtree, pinfo, &ei_bitcoin_address_length, |
665 | 0 | tvb, offset, (unsigned) address_length); |
666 | 0 | } |
667 | 0 | break; |
668 | | |
669 | 0 | case 2: |
670 | 0 | proto_tree_add_item(subtree, hf_msg_addrv2_address_ipv6, tvb, offset, (unsigned) address_length, ENC_NA); |
671 | 0 | if (address_length != 16) { |
672 | 0 | proto_tree_add_expert(subtree, pinfo, &ei_bitcoin_address_length, |
673 | 0 | tvb, offset, (unsigned) address_length); |
674 | 0 | } |
675 | 0 | break; |
676 | | |
677 | 0 | default: |
678 | 0 | proto_tree_add_item(subtree, hf_msg_addrv2_address_other, tvb, offset, (unsigned) address_length, ENC_NA); |
679 | 0 | break; |
680 | 0 | } |
681 | | |
682 | | /* |
683 | | * The above should make sure that the addition won't overflow. |
684 | | * XXX - but what if address length fits in an unsigned int but |
685 | | * not a signed int? |
686 | | */ |
687 | 0 | offset += (int)address_length; |
688 | |
|
689 | 0 | proto_tree_add_item(subtree, hf_msg_addrv2_port, tvb, offset, 2, ENC_BIG_ENDIAN); |
690 | 0 | offset += 2; |
691 | |
|
692 | 0 | proto_item_set_end(sti, tvb, offset); |
693 | 0 | } |
694 | | |
695 | 0 | return offset; |
696 | 0 | } |
697 | | |
698 | | /** |
699 | | * Handler for inventory messages |
700 | | */ |
701 | | static int |
702 | | dissect_bitcoin_msg_inv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
703 | 0 | { |
704 | 0 | proto_item *ti; |
705 | 0 | int length; |
706 | 0 | uint64_t count; |
707 | 0 | uint32_t offset = 0; |
708 | |
|
709 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_inv, tvb, offset, -1, ENC_NA); |
710 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
711 | |
|
712 | 0 | get_varint(tvb, offset, &length, &count); |
713 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_inv_count8, hf_msg_inv_count16, |
714 | 0 | hf_msg_inv_count32, hf_msg_inv_count64); |
715 | |
|
716 | 0 | offset += length; |
717 | |
|
718 | 0 | for (; count > 0; count--) |
719 | 0 | { |
720 | 0 | proto_tree *subtree; |
721 | |
|
722 | 0 | subtree = proto_tree_add_subtree(tree, tvb, offset, 36, ett_inv_list, NULL, "Inventory vector"); |
723 | |
|
724 | 0 | proto_tree_add_item(subtree, hf_msg_inv_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
725 | 0 | offset += 4; |
726 | |
|
727 | 0 | proto_tree_add_item(subtree, hf_msg_inv_hash, tvb, offset, 32, ENC_NA); |
728 | 0 | offset += 32; |
729 | 0 | } |
730 | |
|
731 | 0 | return offset; |
732 | 0 | } |
733 | | |
734 | | /** |
735 | | * Handler for getdata messages |
736 | | */ |
737 | | static int |
738 | | dissect_bitcoin_msg_getdata(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
739 | 0 | { |
740 | 0 | proto_item *ti; |
741 | 0 | int length; |
742 | 0 | uint64_t count; |
743 | 0 | uint32_t offset = 0; |
744 | |
|
745 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_getdata, tvb, offset, -1, ENC_NA); |
746 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
747 | |
|
748 | 0 | get_varint(tvb, offset, &length, &count); |
749 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_getdata_count8, hf_msg_getdata_count16, |
750 | 0 | hf_msg_getdata_count32, hf_msg_getdata_count64); |
751 | |
|
752 | 0 | offset += length; |
753 | |
|
754 | 0 | for (; count > 0; count--) |
755 | 0 | { |
756 | 0 | proto_tree *subtree; |
757 | |
|
758 | 0 | subtree = proto_tree_add_subtree(tree, tvb, offset, 36, ett_getdata_list, NULL, "Inventory vector"); |
759 | |
|
760 | 0 | proto_tree_add_item(subtree, hf_msg_getdata_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
761 | 0 | offset += 4; |
762 | |
|
763 | 0 | proto_tree_add_item(subtree, hf_msg_getdata_hash, tvb, offset, 32, ENC_NA); |
764 | 0 | offset += 32; |
765 | 0 | } |
766 | |
|
767 | 0 | return offset; |
768 | 0 | } |
769 | | |
770 | | /** |
771 | | * Handler for notfound messages |
772 | | */ |
773 | | static int |
774 | | dissect_bitcoin_msg_notfound(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
775 | 0 | { |
776 | 0 | proto_item *ti; |
777 | 0 | int length; |
778 | 0 | uint64_t count; |
779 | 0 | uint32_t offset = 0; |
780 | |
|
781 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_notfound, tvb, offset, -1, ENC_NA); |
782 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
783 | |
|
784 | 0 | get_varint(tvb, offset, &length, &count); |
785 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_notfound_count8, hf_msg_notfound_count16, |
786 | 0 | hf_msg_notfound_count32, hf_msg_notfound_count64); |
787 | |
|
788 | 0 | offset += length; |
789 | |
|
790 | 0 | for (; count > 0; count--) |
791 | 0 | { |
792 | 0 | proto_tree *subtree; |
793 | |
|
794 | 0 | subtree = proto_tree_add_subtree(tree, tvb, offset, 36, ett_notfound_list, NULL, "Inventory vector"); |
795 | |
|
796 | 0 | proto_tree_add_item(subtree, hf_msg_notfound_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
797 | 0 | offset += 4; |
798 | |
|
799 | 0 | proto_tree_add_item(subtree, hf_msg_notfound_hash, tvb, offset, 32, ENC_NA); |
800 | 0 | offset += 32; |
801 | 0 | } |
802 | |
|
803 | 0 | return offset; |
804 | 0 | } |
805 | | |
806 | | /** |
807 | | * Handler for getblocks messages |
808 | | */ |
809 | | static int |
810 | | dissect_bitcoin_msg_getblocks(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
811 | 0 | { |
812 | 0 | proto_item *ti; |
813 | 0 | int length; |
814 | 0 | uint64_t count; |
815 | 0 | uint32_t offset = 0; |
816 | |
|
817 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_getblocks, tvb, offset, -1, ENC_NA); |
818 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
819 | | |
820 | | /* why the protocol version is sent here nobody knows */ |
821 | 0 | proto_tree_add_item(tree, hf_msg_version_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
822 | 0 | offset += 4; |
823 | |
|
824 | 0 | get_varint(tvb, offset, &length, &count); |
825 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_getblocks_count8, hf_msg_getblocks_count16, |
826 | 0 | hf_msg_getblocks_count32, hf_msg_getblocks_count64); |
827 | |
|
828 | 0 | offset += length; |
829 | |
|
830 | 0 | for (; count > 0; count--) |
831 | 0 | { |
832 | 0 | proto_tree_add_item(tree, hf_msg_getblocks_start, tvb, offset, 32, ENC_NA); |
833 | 0 | offset += 32; |
834 | 0 | } |
835 | |
|
836 | 0 | proto_tree_add_item(tree, hf_msg_getblocks_stop, tvb, offset, 32, ENC_NA); |
837 | 0 | offset += 32; |
838 | |
|
839 | 0 | return offset; |
840 | 0 | } |
841 | | |
842 | | /** |
843 | | * Handler for getheaders messages |
844 | | * UNTESTED |
845 | | */ |
846 | | static int |
847 | | dissect_bitcoin_msg_getheaders(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
848 | 0 | { |
849 | 0 | proto_item *ti; |
850 | 0 | int length; |
851 | 0 | uint64_t count; |
852 | 0 | uint32_t offset = 0; |
853 | |
|
854 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_getheaders, tvb, offset, -1, ENC_NA); |
855 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
856 | |
|
857 | 0 | proto_tree_add_item(tree, hf_msg_headers_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
858 | 0 | offset += 4; |
859 | |
|
860 | 0 | get_varint(tvb, offset, &length, &count); |
861 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_getheaders_count8, hf_msg_getheaders_count16, |
862 | 0 | hf_msg_getheaders_count32, hf_msg_getheaders_count64); |
863 | |
|
864 | 0 | offset += length; |
865 | |
|
866 | 0 | for (; count > 0; count--) |
867 | 0 | { |
868 | 0 | proto_tree_add_item(tree, hf_msg_getheaders_start, tvb, offset, 32, ENC_NA); |
869 | 0 | offset += 32; |
870 | 0 | } |
871 | |
|
872 | 0 | proto_tree_add_item(tree, hf_msg_getheaders_stop, tvb, offset, 32, ENC_NA); |
873 | 0 | offset += 32; |
874 | |
|
875 | 0 | return offset; |
876 | 0 | } |
877 | | |
878 | | /** |
879 | | * Handler for tx message body |
880 | | */ |
881 | | static uint32_t |
882 | | dissect_bitcoin_msg_tx_common(tvbuff_t *tvb, uint32_t offset, packet_info *pinfo, proto_tree *tree, unsigned msgnum) |
883 | 0 | { |
884 | 0 | proto_item *rti; |
885 | 0 | int count_length; |
886 | 0 | uint64_t in_count; |
887 | 0 | uint64_t out_count; |
888 | |
|
889 | 0 | if (msgnum == 0) { |
890 | 0 | rti = proto_tree_add_item(tree, hf_bitcoin_msg_tx, tvb, offset, -1, ENC_NA); |
891 | 0 | } else { |
892 | 0 | rti = proto_tree_add_none_format(tree, hf_bitcoin_msg_tx, tvb, offset, -1, "Tx message [ %4d ]", msgnum); |
893 | 0 | } |
894 | 0 | tree = proto_item_add_subtree(rti, ett_bitcoin_msg); |
895 | |
|
896 | 0 | proto_tree_add_item(tree, hf_msg_tx_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
897 | 0 | offset += 4; |
898 | | |
899 | | /* If present, "flag" always starts with 0x00. */ |
900 | | /* Otherwise we proceed straight to "in_count". */ |
901 | 0 | uint8_t flag = tvb_get_uint8(tvb, offset); |
902 | 0 | if (flag == 0) { |
903 | 0 | proto_tree_add_item(tree, hf_msg_tx_flag, tvb, offset, 2, ENC_NA); |
904 | 0 | offset += 2; |
905 | 0 | } |
906 | | |
907 | | /* TxIn[] */ |
908 | 0 | get_varint(tvb, offset, &count_length, &in_count); |
909 | 0 | add_varint_item(tree, tvb, offset, count_length, hf_msg_tx_in_count8, hf_msg_tx_in_count16, |
910 | 0 | hf_msg_tx_in_count32, hf_msg_tx_in_count64); |
911 | |
|
912 | 0 | offset += count_length; |
913 | | |
914 | | /* TxIn |
915 | | * [36] previous_output outpoint |
916 | | * [1+] script length var_int |
917 | | * [ ?] signature script uchar[] |
918 | | * [ 4] sequence uint32_t |
919 | | * |
920 | | * outpoint (aka previous output) |
921 | | * [32] hash char[32 |
922 | | * [ 4] index uint32_t |
923 | | * |
924 | | */ |
925 | 0 | for (uint64_t idx = 0; idx < in_count; idx++) |
926 | 0 | { |
927 | 0 | proto_tree *subtree; |
928 | 0 | proto_tree *prevtree; |
929 | 0 | proto_item *ti; |
930 | 0 | proto_item *pti; |
931 | 0 | uint64_t script_length; |
932 | 0 | uint32_t scr_len_offset; |
933 | |
|
934 | 0 | scr_len_offset = offset+36; |
935 | 0 | get_varint(tvb, scr_len_offset, &count_length, &script_length); |
936 | | |
937 | | /* A funny script_length won't cause an exception since the field type is FT_NONE */ |
938 | 0 | ti = proto_tree_add_item(tree, hf_msg_tx_in, tvb, offset, |
939 | 0 | 36 + count_length + (unsigned)script_length + 4, ENC_NA); |
940 | 0 | subtree = proto_item_add_subtree(ti, ett_tx_in_list); |
941 | | |
942 | | /* previous output */ |
943 | 0 | pti = proto_tree_add_item(subtree, hf_msg_tx_in_prev_output, tvb, offset, 36, ENC_NA); |
944 | 0 | prevtree = proto_item_add_subtree(pti, ett_tx_in_outp); |
945 | |
|
946 | 0 | proto_tree_add_item(prevtree, hf_msg_tx_in_prev_outp_hash, tvb, offset, 32, ENC_NA); |
947 | 0 | offset += 32; |
948 | |
|
949 | 0 | proto_tree_add_item(prevtree, hf_msg_tx_in_prev_outp_index, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
950 | 0 | offset += 4; |
951 | | /* end previous output */ |
952 | |
|
953 | 0 | add_varint_item(subtree, tvb, offset, count_length, hf_msg_tx_in_script8, hf_msg_tx_in_script16, |
954 | 0 | hf_msg_tx_in_script32, hf_msg_tx_in_script64); |
955 | |
|
956 | 0 | offset += count_length; |
957 | |
|
958 | 0 | if ((offset + script_length) > INT_MAX) { |
959 | 0 | proto_tree_add_expert(tree, pinfo, &ei_bitcoin_script_len, |
960 | 0 | tvb, scr_len_offset, count_length); |
961 | 0 | return INT_MAX; |
962 | 0 | } |
963 | | |
964 | 0 | proto_tree_add_item(subtree, hf_msg_tx_in_sig_script, tvb, offset, (unsigned)script_length, ENC_NA); |
965 | 0 | offset += (unsigned)script_length; |
966 | |
|
967 | 0 | proto_tree_add_item(subtree, hf_msg_tx_in_seq, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
968 | 0 | offset += 4; |
969 | 0 | } |
970 | | |
971 | | /* TxOut[] */ |
972 | 0 | get_varint(tvb, offset, &count_length, &out_count); |
973 | 0 | add_varint_item(tree, tvb, offset, count_length, hf_msg_tx_out_count8, hf_msg_tx_out_count16, |
974 | 0 | hf_msg_tx_out_count32, hf_msg_tx_out_count64); |
975 | |
|
976 | 0 | offset += count_length; |
977 | | |
978 | | /* TxOut |
979 | | * [ 8] value |
980 | | * [1+] script length [var_int] |
981 | | * [ ?] script |
982 | | */ |
983 | 0 | for (; out_count > 0; out_count--) |
984 | 0 | { |
985 | 0 | proto_item *ti; |
986 | 0 | proto_tree *subtree; |
987 | 0 | uint64_t script_length; |
988 | 0 | uint32_t scr_len_offset; |
989 | |
|
990 | 0 | scr_len_offset = offset+8; |
991 | 0 | get_varint(tvb, scr_len_offset, &count_length, &script_length); |
992 | | |
993 | | /* A funny script_length won't cause an exception since the field type is FT_NONE */ |
994 | 0 | ti = proto_tree_add_item(tree, hf_msg_tx_out, tvb, offset, |
995 | 0 | 8 + count_length + (unsigned)script_length , ENC_NA); |
996 | 0 | subtree = proto_item_add_subtree(ti, ett_tx_out_list); |
997 | |
|
998 | 0 | proto_tree_add_item(subtree, hf_msg_tx_out_value, tvb, offset, 8, ENC_LITTLE_ENDIAN); |
999 | 0 | offset += 8; |
1000 | |
|
1001 | 0 | add_varint_item(subtree, tvb, offset, count_length, hf_msg_tx_out_script8, hf_msg_tx_out_script16, |
1002 | 0 | hf_msg_tx_out_script32, hf_msg_tx_out_script64); |
1003 | |
|
1004 | 0 | offset += count_length; |
1005 | |
|
1006 | 0 | if ((offset + script_length) > INT_MAX) { |
1007 | 0 | proto_tree_add_expert(tree, pinfo, &ei_bitcoin_script_len, |
1008 | 0 | tvb, scr_len_offset, count_length); |
1009 | 0 | return INT_MAX; |
1010 | 0 | } |
1011 | | |
1012 | 0 | proto_tree_add_item(subtree, hf_msg_tx_out_script, tvb, offset, (unsigned)script_length, ENC_NA); |
1013 | 0 | offset += (unsigned)script_length; |
1014 | 0 | } |
1015 | | |
1016 | 0 | if (flag == 0) { |
1017 | | /* TxWitness |
1018 | | */ |
1019 | 0 | for (; in_count > 0; in_count--) |
1020 | 0 | { |
1021 | 0 | proto_item *ti; |
1022 | 0 | proto_tree *subtree; |
1023 | |
|
1024 | 0 | ti = proto_tree_add_item(tree, hf_msg_tx_witness, tvb, offset, -1, ENC_NA); |
1025 | 0 | subtree = proto_item_add_subtree(ti, ett_tx_witness_list); |
1026 | | |
1027 | | // count of witness data components |
1028 | 0 | int component_count_length; |
1029 | 0 | uint64_t component_count; |
1030 | |
|
1031 | 0 | get_varint(tvb, offset, &component_count_length, &component_count); |
1032 | 0 | add_varint_item(subtree, tvb, offset, component_count_length, hf_msg_tx_witness_components8, |
1033 | 0 | hf_msg_tx_witness_components16, hf_msg_tx_witness_components32, |
1034 | 0 | hf_msg_tx_witness_components64); |
1035 | 0 | offset += component_count_length; |
1036 | |
|
1037 | 0 | for (; component_count > 0; component_count--) |
1038 | 0 | { |
1039 | 0 | proto_item *subti; |
1040 | 0 | proto_tree *subsubtree; |
1041 | |
|
1042 | 0 | int component_size_length; |
1043 | 0 | uint64_t component_size; |
1044 | |
|
1045 | 0 | get_varint(tvb, offset, &component_size_length, &component_size); |
1046 | |
|
1047 | 0 | subti = proto_tree_add_item(subtree, hf_msg_tx_witness_component, tvb, offset, |
1048 | 0 | component_size_length + (int) component_size, ENC_NA); |
1049 | 0 | subsubtree = proto_item_add_subtree(subti, ett_tx_witness_component_list); |
1050 | |
|
1051 | 0 | add_varint_item(subsubtree, tvb, offset, component_size_length, hf_msg_tx_witness_component_length8, |
1052 | 0 | hf_msg_tx_witness_component_length16, hf_msg_tx_witness_component_length32, |
1053 | 0 | hf_msg_tx_witness_component_length64); |
1054 | 0 | offset += component_size_length; |
1055 | |
|
1056 | 0 | proto_tree_add_item(subsubtree, hf_msg_tx_witness_component_data, tvb, offset, (int) component_size, ENC_NA); |
1057 | 0 | offset += (uint32_t)component_size; |
1058 | 0 | } |
1059 | |
|
1060 | 0 | proto_item_set_end(ti, tvb, offset); |
1061 | 0 | } |
1062 | 0 | } |
1063 | |
|
1064 | 0 | proto_tree_add_item(tree, hf_msg_tx_lock_time, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1065 | 0 | offset += 4; |
1066 | | |
1067 | | /* needed for block nesting */ |
1068 | 0 | proto_item_set_len(rti, offset); |
1069 | |
|
1070 | 0 | return offset; |
1071 | 0 | } |
1072 | | |
1073 | | /** |
1074 | | * Handler for tx message |
1075 | | */ |
1076 | | static int |
1077 | | dissect_bitcoin_msg_tx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) |
1078 | 0 | { |
1079 | 0 | return dissect_bitcoin_msg_tx_common(tvb, 0, pinfo, tree, 0); |
1080 | 0 | } |
1081 | | |
1082 | | |
1083 | | /** |
1084 | | * Handler for block messages |
1085 | | */ |
1086 | | static int |
1087 | | dissect_bitcoin_msg_block(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) |
1088 | 0 | { |
1089 | 0 | proto_item *ti; |
1090 | 0 | int length; |
1091 | 0 | uint64_t count; |
1092 | 0 | unsigned msgnum; |
1093 | 0 | uint32_t offset = 0; |
1094 | | |
1095 | | /* Block |
1096 | | * [ 4] version uint32_t |
1097 | | * [32] prev_block char[32] |
1098 | | * [32] merkle_root char[32] |
1099 | | * [ 4] timestamp uint32_t A unix timestamp ... (Currently limited to dates before the year 2106!) |
1100 | | * [ 4] bits uint32_t |
1101 | | * [ 4] nonce uint32_t |
1102 | | * [ ?] txn_count var_int |
1103 | | * [ ?] txns tx[] Block transactions, in format of "tx" command |
1104 | | */ |
1105 | |
|
1106 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_block, tvb, offset, -1, ENC_NA); |
1107 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1108 | |
|
1109 | 0 | proto_tree_add_item(tree, hf_msg_block_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1110 | 0 | offset += 4; |
1111 | |
|
1112 | 0 | proto_tree_add_item(tree, hf_msg_block_prev_block, tvb, offset, 32, ENC_NA); |
1113 | 0 | offset += 32; |
1114 | |
|
1115 | 0 | proto_tree_add_item(tree, hf_msg_block_merkle_root, tvb, offset, 32, ENC_NA); |
1116 | 0 | offset += 32; |
1117 | |
|
1118 | 0 | proto_tree_add_item(tree, hf_msg_block_time, tvb, offset, 4, ENC_TIME_SECS|ENC_LITTLE_ENDIAN); |
1119 | 0 | offset += 4; |
1120 | |
|
1121 | 0 | proto_tree_add_item(tree, hf_msg_block_bits, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1122 | 0 | offset += 4; |
1123 | |
|
1124 | 0 | proto_tree_add_item(tree, hf_msg_block_nonce, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1125 | 0 | offset += 4; |
1126 | |
|
1127 | 0 | get_varint(tvb, offset, &length, &count); |
1128 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_block_transactions8, hf_msg_block_transactions16, |
1129 | 0 | hf_msg_block_transactions32, hf_msg_block_transactions64); |
1130 | |
|
1131 | 0 | offset += length; |
1132 | |
|
1133 | 0 | msgnum = 0; |
1134 | 0 | for (; count>0 && offset<INT_MAX; count--) |
1135 | 0 | { |
1136 | 0 | msgnum += 1; |
1137 | 0 | offset = dissect_bitcoin_msg_tx_common(tvb, offset, pinfo, tree, msgnum); |
1138 | 0 | } |
1139 | |
|
1140 | 0 | return offset; |
1141 | 0 | } |
1142 | | |
1143 | | /** |
1144 | | * Handler for headers messages |
1145 | | */ |
1146 | | static int |
1147 | | dissect_bitcoin_msg_headers(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1148 | 0 | { |
1149 | 0 | proto_item *ti; |
1150 | 0 | int length; |
1151 | 0 | uint64_t count; |
1152 | 0 | uint32_t offset = 0; |
1153 | |
|
1154 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_headers, tvb, offset, -1, ENC_NA); |
1155 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1156 | |
|
1157 | 0 | get_varint(tvb, offset, &length, &count); |
1158 | 0 | add_varint_item(tree, tvb, offset, length, hf_msg_headers_count8, hf_msg_headers_count16, |
1159 | 0 | hf_msg_headers_count32, hf_msg_headers_count64); |
1160 | |
|
1161 | 0 | offset += length; |
1162 | |
|
1163 | 0 | for (; count > 0; count--) |
1164 | 0 | { |
1165 | 0 | proto_tree *subtree; |
1166 | 0 | uint64_t txcount; |
1167 | |
|
1168 | 0 | subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_bitcoin_msg, NULL, "Header"); |
1169 | |
|
1170 | 0 | proto_tree_add_item(subtree, hf_msg_headers_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1171 | 0 | offset += 4; |
1172 | |
|
1173 | 0 | proto_tree_add_item(subtree, hf_msg_headers_prev_block, tvb, offset, 32, ENC_NA); |
1174 | 0 | offset += 32; |
1175 | |
|
1176 | 0 | proto_tree_add_item(subtree, hf_msg_headers_merkle_root, tvb, offset, 32, ENC_NA); |
1177 | 0 | offset += 32; |
1178 | |
|
1179 | 0 | proto_tree_add_item(subtree, hf_msg_headers_time, tvb, offset, 4, ENC_TIME_SECS|ENC_LITTLE_ENDIAN); |
1180 | 0 | offset += 4; |
1181 | |
|
1182 | 0 | proto_tree_add_item(subtree, hf_msg_headers_bits, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1183 | 0 | offset += 4; |
1184 | |
|
1185 | 0 | proto_tree_add_item(subtree, hf_msg_headers_nonce, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1186 | 0 | offset += 4; |
1187 | |
|
1188 | 0 | get_varint(tvb, offset, &length, &txcount); |
1189 | |
|
1190 | 0 | add_varint_item(subtree, tvb, offset, length, hf_msg_headers_count8, hf_msg_headers_count16, |
1191 | 0 | hf_msg_headers_count32, hf_msg_headers_count64); |
1192 | |
|
1193 | 0 | offset += length; |
1194 | |
|
1195 | 0 | proto_item_set_len(subtree, 80 + length); |
1196 | 0 | } |
1197 | |
|
1198 | 0 | return offset; |
1199 | 0 | } |
1200 | | |
1201 | | /** |
1202 | | * Handler for ping messages |
1203 | | */ |
1204 | | static int |
1205 | | dissect_bitcoin_msg_ping(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1206 | 0 | { |
1207 | 0 | proto_item *ti; |
1208 | 0 | uint32_t offset = 0; |
1209 | |
|
1210 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_ping, tvb, offset, -1, ENC_NA); |
1211 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1212 | |
|
1213 | 0 | proto_tree_add_item(tree, hf_msg_ping_nonce, tvb, offset, 8, ENC_LITTLE_ENDIAN); |
1214 | 0 | offset += 8; |
1215 | |
|
1216 | 0 | return offset; |
1217 | 0 | } |
1218 | | |
1219 | | /** |
1220 | | * Handler for pong messages |
1221 | | */ |
1222 | | static int |
1223 | | dissect_bitcoin_msg_pong(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1224 | 0 | { |
1225 | 0 | proto_item *ti; |
1226 | 0 | uint32_t offset = 0; |
1227 | |
|
1228 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_pong, tvb, offset, -1, ENC_NA); |
1229 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1230 | |
|
1231 | 0 | proto_tree_add_item(tree, hf_msg_pong_nonce, tvb, offset, 8, ENC_LITTLE_ENDIAN); |
1232 | 0 | offset += 8; |
1233 | |
|
1234 | 0 | return offset; |
1235 | 0 | } |
1236 | | |
1237 | | /** |
1238 | | * Handler for reject messages |
1239 | | */ |
1240 | | static int |
1241 | | dissect_bitcoin_msg_reject(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1242 | 0 | { |
1243 | 0 | proto_item *ti; |
1244 | 0 | uint32_t offset = 0; |
1245 | |
|
1246 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_reject, tvb, offset, -1, ENC_NA); |
1247 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1248 | |
|
1249 | 0 | create_string_tree(tree, hf_msg_reject_message, tvb, &offset); |
1250 | |
|
1251 | 0 | proto_tree_add_item(tree, hf_msg_reject_ccode, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
1252 | 0 | offset += 1; |
1253 | |
|
1254 | 0 | create_string_tree(tree, hf_msg_reject_reason, tvb, &offset); |
1255 | |
|
1256 | 0 | if (tvb_reported_length_remaining(tvb, offset) > 0) |
1257 | 0 | { |
1258 | 0 | proto_tree_add_item(tree, hf_msg_reject_data, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA); |
1259 | 0 | } |
1260 | |
|
1261 | 0 | return offset; |
1262 | 0 | } |
1263 | | |
1264 | | /** |
1265 | | * Handler for feefilter messages |
1266 | | */ |
1267 | | static int |
1268 | | dissect_bitcoin_msg_feefilter(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1269 | 0 | { |
1270 | 0 | proto_item *ti; |
1271 | 0 | uint32_t offset = 0; |
1272 | |
|
1273 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_feefilter, tvb, offset, -1, ENC_NA); |
1274 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1275 | |
|
1276 | 0 | proto_tree_add_item(tree, hf_msg_feefilter_value, tvb, offset, 8, ENC_LITTLE_ENDIAN); |
1277 | 0 | offset += 8; |
1278 | |
|
1279 | 0 | return offset; |
1280 | 0 | } |
1281 | | |
1282 | | /** |
1283 | | * Handler for filterload messages |
1284 | | */ |
1285 | | static int |
1286 | | dissect_bitcoin_msg_filterload(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1287 | 0 | { |
1288 | 0 | proto_item *ti; |
1289 | 0 | uint32_t offset = 0; |
1290 | |
|
1291 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_filterload, tvb, offset, -1, ENC_NA); |
1292 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1293 | |
|
1294 | 0 | create_data_tree(tree, hf_msg_filterload_filter, tvb, &offset); |
1295 | |
|
1296 | 0 | proto_tree_add_item(tree, hf_msg_filterload_nhashfunc, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1297 | 0 | offset += 4; |
1298 | |
|
1299 | 0 | proto_tree_add_item(tree, hf_msg_filterload_ntweak, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1300 | 0 | offset += 4; |
1301 | |
|
1302 | 0 | proto_tree_add_item(tree, hf_msg_filterload_nflags, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
1303 | 0 | offset += 1; |
1304 | |
|
1305 | 0 | return offset; |
1306 | 0 | } |
1307 | | |
1308 | | /** |
1309 | | * Handler for filteradd messages |
1310 | | */ |
1311 | | static int |
1312 | | dissect_bitcoin_msg_filteradd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1313 | 0 | { |
1314 | 0 | proto_item *ti; |
1315 | 0 | uint32_t offset = 0; |
1316 | |
|
1317 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_filteradd, tvb, offset, -1, ENC_NA); |
1318 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1319 | |
|
1320 | 0 | create_data_tree(tree, hf_msg_filteradd_data, tvb, &offset); |
1321 | |
|
1322 | 0 | return offset; |
1323 | 0 | } |
1324 | | |
1325 | | /** |
1326 | | * Handler for merkleblock messages |
1327 | | */ |
1328 | | |
1329 | | static int |
1330 | | dissect_bitcoin_msg_merkleblock(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1331 | 0 | { |
1332 | 0 | proto_item *ti; |
1333 | 0 | proto_item *subtree; |
1334 | 0 | int length; |
1335 | 0 | uint64_t count; |
1336 | 0 | uint32_t offset = 0; |
1337 | |
|
1338 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_merkleblock, tvb, offset, -1, ENC_NA); |
1339 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1340 | |
|
1341 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_version, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1342 | 0 | offset += 4; |
1343 | |
|
1344 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_prev_block, tvb, offset, 32, ENC_NA); |
1345 | 0 | offset += 32; |
1346 | |
|
1347 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_merkle_root, tvb, offset, 32, ENC_NA); |
1348 | 0 | offset += 32; |
1349 | |
|
1350 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_time, tvb, offset, 4, ENC_TIME_SECS|ENC_LITTLE_ENDIAN); |
1351 | 0 | offset += 4; |
1352 | |
|
1353 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_bits, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1354 | 0 | offset += 4; |
1355 | |
|
1356 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_nonce, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1357 | 0 | offset += 4; |
1358 | |
|
1359 | 0 | proto_tree_add_item(tree, hf_msg_merkleblock_transactions, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
1360 | 0 | offset += 4; |
1361 | |
|
1362 | 0 | get_varint(tvb, offset, &length, &count); |
1363 | |
|
1364 | 0 | subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_bitcoin_msg, NULL, "Hashes"); |
1365 | |
|
1366 | 0 | add_varint_item(subtree, tvb, offset, length, hf_msg_merkleblock_hashes_count8, hf_msg_merkleblock_hashes_count16, |
1367 | 0 | hf_msg_merkleblock_hashes_count32, hf_msg_merkleblock_hashes_count64); |
1368 | 0 | offset += length; |
1369 | |
|
1370 | 0 | for (; count > 0; count--) |
1371 | 0 | { |
1372 | 0 | proto_tree_add_item(subtree, hf_msg_merkleblock_hashes_hash, tvb, offset, 32, ENC_NA); |
1373 | 0 | offset += 32; |
1374 | 0 | } |
1375 | |
|
1376 | 0 | get_varint(tvb, offset, &length, &count); |
1377 | |
|
1378 | 0 | subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_bitcoin_msg, NULL, "Flags"); |
1379 | |
|
1380 | 0 | add_varint_item(subtree, tvb, offset, length, hf_msg_merkleblock_flags_size8, hf_msg_merkleblock_flags_size16, |
1381 | 0 | hf_msg_merkleblock_flags_size32, hf_msg_merkleblock_flags_size64); |
1382 | 0 | offset += length; |
1383 | | |
1384 | | /* The cast to unsigned is save because bitcoin messages are always smaller than 0x02000000 bytes. */ |
1385 | 0 | proto_tree_add_item(subtree, hf_msg_merkleblock_flags_data, tvb, offset, (unsigned)count, BASE_SHOW_UTF_8_PRINTABLE); |
1386 | 0 | offset += (uint32_t)count; |
1387 | |
|
1388 | 0 | return offset; |
1389 | 0 | } |
1390 | | |
1391 | | /** |
1392 | | * Handler for sendcmpct messages |
1393 | | */ |
1394 | | |
1395 | | static int |
1396 | | dissect_bitcoin_msg_sendcmpct(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) |
1397 | 0 | { |
1398 | 0 | proto_item *ti; |
1399 | 0 | uint32_t offset = 0; |
1400 | |
|
1401 | 0 | ti = proto_tree_add_item(tree, hf_bitcoin_msg_sendcmpct, tvb, offset, -1, ENC_NA); |
1402 | 0 | tree = proto_item_add_subtree(ti, ett_bitcoin_msg); |
1403 | |
|
1404 | 0 | proto_tree_add_item(tree, hf_msg_sendcmpct_announce, tvb, offset, 1, ENC_NA); |
1405 | 0 | offset += 1; |
1406 | |
|
1407 | 0 | proto_tree_add_item(tree, hf_msg_sendcmpct_version, tvb, offset, 8, ENC_LITTLE_ENDIAN); |
1408 | 0 | offset += 8; |
1409 | |
|
1410 | 0 | return offset; |
1411 | 0 | } |
1412 | | |
1413 | | /** |
1414 | | * Handler for unimplemented or payload-less messages |
1415 | | */ |
1416 | | static int |
1417 | | dissect_bitcoin_msg_empty(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) |
1418 | 0 | { |
1419 | 0 | return tvb_captured_length(tvb); |
1420 | 0 | } |
1421 | | |
1422 | | static int dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) |
1423 | 16 | { |
1424 | 16 | proto_item *ti; |
1425 | 16 | uint32_t offset = 0; |
1426 | 16 | const char* command; |
1427 | 16 | dissector_handle_t command_handle; |
1428 | | |
1429 | 16 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bitcoin"); |
1430 | | |
1431 | 16 | ti = proto_tree_add_item(tree, proto_bitcoin, tvb, 0, -1, ENC_NA); |
1432 | 16 | tree = proto_item_add_subtree(ti, ett_bitcoin); |
1433 | | |
1434 | | /* add basic protocol data */ |
1435 | 16 | proto_tree_add_item(tree, hf_bitcoin_magic, tvb, 0, 4, ENC_BIG_ENDIAN); |
1436 | 16 | proto_tree_add_item_ret_string(tree, hf_bitcoin_command, tvb, 4, 12, ENC_ASCII|ENC_NA, pinfo->pool, (const uint8_t**)&command); |
1437 | 16 | proto_tree_add_item(tree, hf_bitcoin_length, tvb, 16, 4, ENC_LITTLE_ENDIAN); |
1438 | 16 | proto_tree_add_checksum(tree, tvb, 20, hf_bitcoin_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS); |
1439 | | |
1440 | 16 | offset = 24; |
1441 | | |
1442 | 16 | command_handle = dissector_get_string_handle(bitcoin_command_table, command); |
1443 | 16 | if (command_handle != NULL) |
1444 | 0 | { |
1445 | | /* handle command specific message part */ |
1446 | 0 | tvbuff_t *tvb_sub; |
1447 | |
|
1448 | 0 | col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", command); |
1449 | 0 | tvb_sub = tvb_new_subset_remaining(tvb, offset); |
1450 | 0 | call_dissector(command_handle, tvb_sub, pinfo, tree); |
1451 | 0 | } |
1452 | 16 | else |
1453 | 16 | { |
1454 | | /* no handler found */ |
1455 | 16 | col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "[unknown command]"); |
1456 | | |
1457 | 16 | expert_add_info(pinfo, ti, &ei_bitcoin_command_unknown); |
1458 | 16 | } |
1459 | | |
1460 | 16 | return tvb_reported_length(tvb); |
1461 | 16 | } |
1462 | | |
1463 | | static int |
1464 | | dissect_bitcoin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
1465 | 9 | { |
1466 | 9 | col_clear(pinfo->cinfo, COL_INFO); |
1467 | 9 | tcp_dissect_pdus(tvb, pinfo, tree, bitcoin_desegment, BITCOIN_HEADER_LENGTH, |
1468 | 9 | get_bitcoin_pdu_length, dissect_bitcoin_tcp_pdu, data); |
1469 | | |
1470 | 9 | return tvb_reported_length(tvb); |
1471 | 9 | } |
1472 | | |
1473 | | static bool |
1474 | | dissect_bitcoin_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
1475 | 3.19k | { |
1476 | 3.19k | uint32_t magic_number; |
1477 | 3.19k | conversation_t *conversation; |
1478 | | |
1479 | 3.19k | if (tvb_captured_length(tvb) < 4) |
1480 | 141 | return false; |
1481 | | |
1482 | 3.05k | magic_number = tvb_get_letohl(tvb, 0); |
1483 | 3.05k | if ((magic_number != BITCOIN_MAIN_MAGIC_NUMBER) && |
1484 | 3.05k | (magic_number != BITCOIN_TESTNET_MAGIC_NUMBER) && |
1485 | 3.04k | (magic_number != BITCOIN_TESTNET3_MAGIC_NUMBER) && |
1486 | 3.04k | (magic_number != BITCOIN_TESTNET4_MAGIC_NUMBER)) |
1487 | 3.04k | return false; |
1488 | | |
1489 | | /* Ok: This connection should always use the bitcoin dissector */ |
1490 | 8 | conversation = find_or_create_conversation(pinfo); |
1491 | 8 | conversation_set_dissector(conversation, bitcoin_handle); |
1492 | | |
1493 | 8 | dissect_bitcoin(tvb, pinfo, tree, data); |
1494 | 8 | return true; |
1495 | 3.05k | } |
1496 | | |
1497 | | void |
1498 | | proto_register_bitcoin(void) |
1499 | 14 | { |
1500 | 14 | static hf_register_info hf[] = { |
1501 | 14 | { &hf_bitcoin_magic, |
1502 | 14 | { "Packet magic", "bitcoin.magic", |
1503 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
1504 | 14 | NULL, HFILL } |
1505 | 14 | }, |
1506 | 14 | { &hf_bitcoin_command, |
1507 | 14 | { "Command name", "bitcoin.command", |
1508 | 14 | FT_STRING, BASE_NONE, NULL, 0x0, |
1509 | 14 | NULL, HFILL } |
1510 | 14 | }, |
1511 | 14 | { &hf_bitcoin_length, |
1512 | 14 | { "Payload Length", "bitcoin.length", |
1513 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1514 | 14 | NULL, HFILL } |
1515 | 14 | }, |
1516 | 14 | { &hf_bitcoin_checksum, |
1517 | 14 | { "Payload checksum", "bitcoin.checksum", |
1518 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
1519 | 14 | NULL, HFILL } |
1520 | 14 | }, |
1521 | 14 | { &hf_bitcoin_msg_version, |
1522 | 14 | { "Version message", "bitcoin.version", |
1523 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1524 | 14 | NULL, HFILL } |
1525 | 14 | }, |
1526 | 14 | { &hf_msg_version_version, |
1527 | 14 | { "Protocol version", "bitcoin.version.version", |
1528 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1529 | 14 | NULL, HFILL } |
1530 | 14 | }, |
1531 | 14 | { &hf_msg_version_services, |
1532 | 14 | { "Node services", "bitcoin.version.services", |
1533 | 14 | FT_UINT64, BASE_HEX, NULL, 0x0, |
1534 | 14 | NULL, HFILL } |
1535 | 14 | }, |
1536 | 14 | { &hf_msg_version_timestamp, |
1537 | 14 | { "Node timestamp", "bitcoin.version.timestamp", |
1538 | 14 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, |
1539 | 14 | NULL, HFILL } |
1540 | 14 | }, |
1541 | 14 | { &hf_msg_version_addr_me, |
1542 | 14 | { "Address of emitting node", "bitcoin.version.addr_me", |
1543 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1544 | 14 | NULL, HFILL } |
1545 | 14 | }, |
1546 | 14 | { &hf_msg_version_addr_you, |
1547 | 14 | { "Address as receiving node", "bitcoin.version.addr_you", |
1548 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1549 | 14 | NULL, HFILL } |
1550 | 14 | }, |
1551 | 14 | { &hf_msg_version_nonce, |
1552 | 14 | { "Random nonce", "bitcoin.version.nonce", |
1553 | 14 | FT_UINT64, BASE_HEX, NULL, 0x0, |
1554 | 14 | NULL, HFILL } |
1555 | 14 | }, |
1556 | 14 | { &hf_msg_version_user_agent, |
1557 | 14 | { "User agent", "bitcoin.version.user_agent", |
1558 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1559 | 14 | NULL, HFILL } |
1560 | 14 | }, |
1561 | 14 | { &hf_msg_version_start_height, |
1562 | 14 | { "Block start height", "bitcoin.version.start_height", |
1563 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1564 | 14 | NULL, HFILL } |
1565 | 14 | }, |
1566 | 14 | { &hf_msg_version_relay, |
1567 | 14 | { "Relay flag", "bitcoin.version.relay", |
1568 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1569 | 14 | NULL, HFILL } |
1570 | 14 | }, |
1571 | 14 | { &hf_msg_addr_count8, |
1572 | 14 | { "Count", "bitcoin.addr.count", |
1573 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1574 | 14 | NULL, HFILL } |
1575 | 14 | }, |
1576 | 14 | { &hf_msg_addr_count16, |
1577 | 14 | { "Count", "bitcoin.addr.count", |
1578 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1579 | 14 | NULL, HFILL } |
1580 | 14 | }, |
1581 | 14 | { &hf_msg_addr_count32, |
1582 | 14 | { "Count", "bitcoin.addr.count", |
1583 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1584 | 14 | NULL, HFILL } |
1585 | 14 | }, |
1586 | 14 | { &hf_msg_addr_count64, |
1587 | 14 | { "Count", "bitcoin.addr.count64", |
1588 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1589 | 14 | NULL, HFILL } |
1590 | 14 | }, |
1591 | 14 | { &hf_bitcoin_msg_addr, |
1592 | 14 | { "Address message", "bitcoin.addr", |
1593 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1594 | 14 | NULL, HFILL } |
1595 | 14 | }, |
1596 | 14 | { &hf_msg_addr_address, |
1597 | 14 | { "Address", "bitcoin.addr.address", |
1598 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1599 | 14 | NULL, HFILL } |
1600 | 14 | }, |
1601 | 14 | { &hf_msg_addr_timestamp, |
1602 | 14 | { "Address timestamp", "bitcoin.addr.timestamp", |
1603 | 14 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, |
1604 | 14 | NULL, HFILL } |
1605 | 14 | }, |
1606 | 14 | { &hf_msg_addrv2_count8, |
1607 | 14 | { "Count", "bitcoin.addrv2.count", |
1608 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1609 | 14 | NULL, HFILL } |
1610 | 14 | }, |
1611 | 14 | { &hf_msg_addrv2_count16, |
1612 | 14 | { "Count", "bitcoin.addrv2.count", |
1613 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1614 | 14 | NULL, HFILL } |
1615 | 14 | }, |
1616 | 14 | { &hf_msg_addrv2_count32, |
1617 | 14 | { "Count", "bitcoin.addrv2.count", |
1618 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1619 | 14 | NULL, HFILL } |
1620 | 14 | }, |
1621 | 14 | { &hf_msg_addrv2_count64, |
1622 | 14 | { "Count", "bitcoin.addrv2.count64", |
1623 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1624 | 14 | NULL, HFILL } |
1625 | 14 | }, |
1626 | 14 | { &hf_msg_addrv2_item, |
1627 | 14 | { "Address", "bitcoin.addrv2.item", |
1628 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1629 | 14 | NULL, HFILL } |
1630 | 14 | }, |
1631 | 14 | { &hf_msg_addrv2_timestamp, |
1632 | 14 | { "Timestamp", "bitcoin.addrv2.timestamp", |
1633 | 14 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, |
1634 | 14 | NULL, HFILL } |
1635 | 14 | }, |
1636 | 14 | { &hf_msg_addrv2_services, |
1637 | 14 | { "Node services", "bitcoin.addrv2.services", |
1638 | 14 | FT_UINT64, BASE_HEX, NULL, 0x0, |
1639 | 14 | NULL, HFILL } |
1640 | 14 | }, |
1641 | 14 | { &hf_msg_addrv2_network, |
1642 | 14 | { "Node network", "bitcoin.addrv2.network", |
1643 | 14 | FT_UINT8, BASE_DEC, VALS(network_ids), 0x0, |
1644 | 14 | NULL, HFILL } |
1645 | 14 | }, |
1646 | 14 | { &hf_msg_addrv2_address_ipv4, |
1647 | 14 | { "Node address", "bitcoin.addrv2.address.ipv4", |
1648 | 14 | FT_IPv4, BASE_NONE, NULL, 0x0, |
1649 | 14 | NULL, HFILL } |
1650 | 14 | }, |
1651 | 14 | { &hf_msg_addrv2_address_ipv6, |
1652 | 14 | { "Node address", "bitcoin.addrv2.address.ipv6", |
1653 | 14 | FT_IPv6, BASE_NONE, NULL, 0x0, |
1654 | 14 | NULL, HFILL } |
1655 | 14 | }, |
1656 | 14 | { &hf_msg_addrv2_address_other, |
1657 | 14 | { "Node address", "bitcoin.addrv2.address.other", |
1658 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1659 | 14 | NULL, HFILL } |
1660 | 14 | }, |
1661 | 14 | { &hf_msg_addrv2_port, |
1662 | 14 | { "Node port", "bitcoin.addrv2.port", |
1663 | 14 | FT_UINT16, BASE_PT_TCP, NULL, 0x0, |
1664 | 14 | NULL, HFILL } |
1665 | 14 | }, |
1666 | 14 | { &hf_bitcoin_msg_addrv2, |
1667 | 14 | { "Addrv2 message", "bitcoin.addrv2", |
1668 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1669 | 14 | NULL, HFILL } |
1670 | 14 | }, |
1671 | 14 | { &hf_msg_inv_count8, |
1672 | 14 | { "Count", "bitcoin.inv.count", |
1673 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1674 | 14 | NULL, HFILL } |
1675 | 14 | }, |
1676 | 14 | { &hf_msg_inv_count16, |
1677 | 14 | { "Count", "bitcoin.inv.count", |
1678 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1679 | 14 | NULL, HFILL } |
1680 | 14 | }, |
1681 | 14 | { &hf_msg_inv_count32, |
1682 | 14 | { "Count", "bitcoin.inv.count", |
1683 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1684 | 14 | NULL, HFILL } |
1685 | 14 | }, |
1686 | 14 | { &hf_msg_inv_count64, |
1687 | 14 | { "Count", "bitcoin.inv.count64", |
1688 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1689 | 14 | NULL, HFILL } |
1690 | 14 | }, |
1691 | 14 | { &hf_bitcoin_msg_inv, |
1692 | 14 | { "Inventory message", "bitcoin.inv", |
1693 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1694 | 14 | NULL, HFILL } |
1695 | 14 | }, |
1696 | 14 | { &hf_msg_inv_type, |
1697 | 14 | { "Type", "bitcoin.inv.type", |
1698 | 14 | FT_UINT32, BASE_DEC, VALS(inv_types), 0x0, |
1699 | 14 | NULL, HFILL } |
1700 | 14 | }, |
1701 | 14 | { &hf_msg_inv_hash, |
1702 | 14 | { "Data hash", "bitcoin.inv.hash", |
1703 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1704 | 14 | NULL, HFILL } |
1705 | 14 | }, |
1706 | 14 | { &hf_bitcoin_msg_getdata, |
1707 | 14 | { "Getdata message", "bitcoin.getdata", |
1708 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1709 | 14 | NULL, HFILL } |
1710 | 14 | }, |
1711 | 14 | { &hf_msg_getdata_count8, |
1712 | 14 | { "Count", "bitcoin.getdata.count", |
1713 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1714 | 14 | NULL, HFILL } |
1715 | 14 | }, |
1716 | 14 | { &hf_msg_getdata_count16, |
1717 | 14 | { "Count", "bitcoin.getdata.count", |
1718 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1719 | 14 | NULL, HFILL } |
1720 | 14 | }, |
1721 | 14 | { &hf_msg_getdata_count32, |
1722 | 14 | { "Count", "bitcoin.getdata.count", |
1723 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1724 | 14 | NULL, HFILL } |
1725 | 14 | }, |
1726 | 14 | { &hf_msg_getdata_count64, |
1727 | 14 | { "Count", "bitcoin.getdata.count64", |
1728 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1729 | 14 | NULL, HFILL } |
1730 | 14 | }, |
1731 | 14 | { &hf_msg_getdata_type, |
1732 | 14 | { "Type", "bitcoin.getdata.type", |
1733 | 14 | FT_UINT32, BASE_DEC, VALS(inv_types), 0x0, |
1734 | 14 | NULL, HFILL } |
1735 | 14 | }, |
1736 | 14 | { &hf_msg_getdata_hash, |
1737 | 14 | { "Data hash", "bitcoin.getdata.hash", |
1738 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1739 | 14 | NULL, HFILL } |
1740 | 14 | }, |
1741 | 14 | { &hf_msg_notfound_count8, |
1742 | 14 | { "Count", "bitcoin.notfound.count", |
1743 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1744 | 14 | NULL, HFILL } |
1745 | 14 | }, |
1746 | 14 | { &hf_msg_notfound_count16, |
1747 | 14 | { "Count", "bitcoin.notfound.count", |
1748 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1749 | 14 | NULL, HFILL } |
1750 | 14 | }, |
1751 | 14 | { &hf_msg_notfound_count32, |
1752 | 14 | { "Count", "bitcoin.notfound.count", |
1753 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1754 | 14 | NULL, HFILL } |
1755 | 14 | }, |
1756 | 14 | { &hf_msg_notfound_count64, |
1757 | 14 | { "Count", "bitcoin.notfound.count64", |
1758 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1759 | 14 | NULL, HFILL } |
1760 | 14 | }, |
1761 | 14 | { &hf_bitcoin_msg_notfound, |
1762 | 14 | { "Getdata message", "bitcoin.notfound", |
1763 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1764 | 14 | NULL, HFILL } |
1765 | 14 | }, |
1766 | 14 | { &hf_msg_notfound_type, |
1767 | 14 | { "Type", "bitcoin.notfound.type", |
1768 | 14 | FT_UINT32, BASE_DEC, VALS(inv_types), 0x0, |
1769 | 14 | NULL, HFILL } |
1770 | 14 | }, |
1771 | 14 | { &hf_msg_notfound_hash, |
1772 | 14 | { "Data hash", "bitcoin.notfound.hash", |
1773 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1774 | 14 | NULL, HFILL } |
1775 | 14 | }, |
1776 | 14 | { &hf_msg_getblocks_count8, |
1777 | 14 | { "Count", "bitcoin.getblocks.count", |
1778 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1779 | 14 | NULL, HFILL } |
1780 | 14 | }, |
1781 | 14 | { &hf_msg_getblocks_count16, |
1782 | 14 | { "Count", "bitcoin.getblocks.count", |
1783 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1784 | 14 | NULL, HFILL } |
1785 | 14 | }, |
1786 | 14 | { &hf_msg_getblocks_count32, |
1787 | 14 | { "Count", "bitcoin.getblocks.count", |
1788 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1789 | 14 | NULL, HFILL } |
1790 | 14 | }, |
1791 | 14 | { &hf_msg_getblocks_count64, |
1792 | 14 | { "Count", "bitcoin.getblocks.count64", |
1793 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1794 | 14 | NULL, HFILL } |
1795 | 14 | }, |
1796 | 14 | { &hf_bitcoin_msg_getblocks, |
1797 | 14 | { "Getdata message", "bitcoin.getblocks", |
1798 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1799 | 14 | NULL, HFILL } |
1800 | 14 | }, |
1801 | 14 | { &hf_msg_getblocks_start, |
1802 | 14 | { "Starting hash", "bitcoin.getblocks.hash_start", |
1803 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1804 | 14 | NULL, HFILL } |
1805 | 14 | }, |
1806 | 14 | { &hf_msg_getblocks_stop, |
1807 | 14 | { "Stopping hash", "bitcoin.getblocks.hash_stop", |
1808 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1809 | 14 | NULL, HFILL } |
1810 | 14 | }, |
1811 | 14 | { &hf_msg_getheaders_count8, |
1812 | 14 | { "Count", "bitcoin.getheaders.count", |
1813 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1814 | 14 | NULL, HFILL } |
1815 | 14 | }, |
1816 | 14 | { &hf_msg_getheaders_count16, |
1817 | 14 | { "Count", "bitcoin.getheaders.count", |
1818 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1819 | 14 | NULL, HFILL } |
1820 | 14 | }, |
1821 | 14 | { &hf_msg_getheaders_count32, |
1822 | 14 | { "Count", "bitcoin.getheaders.count", |
1823 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1824 | 14 | NULL, HFILL } |
1825 | 14 | }, |
1826 | 14 | { &hf_msg_getheaders_count64, |
1827 | 14 | { "Count", "bitcoin.getheaders.count64", |
1828 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1829 | 14 | NULL, HFILL } |
1830 | 14 | }, |
1831 | 14 | { &hf_msg_getheaders_version, |
1832 | 14 | { "Protocol version", "bitcoin.headers.version", |
1833 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1834 | 14 | NULL, HFILL } |
1835 | 14 | }, |
1836 | 14 | { &hf_bitcoin_msg_getheaders, |
1837 | 14 | { "Getheaders message", "bitcoin.getheaders", |
1838 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1839 | 14 | NULL, HFILL } |
1840 | 14 | }, |
1841 | 14 | { &hf_msg_getheaders_start, |
1842 | 14 | { "Starting hash", "bitcoin.getheaders.hash_start", |
1843 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1844 | 14 | NULL, HFILL } |
1845 | 14 | }, |
1846 | 14 | { &hf_msg_getheaders_stop, |
1847 | 14 | { "Stopping hash", "bitcoin.getheaders.hash_stop", |
1848 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1849 | 14 | NULL, HFILL } |
1850 | 14 | }, |
1851 | 14 | { &hf_msg_tx_in_count8, |
1852 | 14 | { "Input Count", "bitcoin.tx.input_count", |
1853 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1854 | 14 | NULL, HFILL } |
1855 | 14 | }, |
1856 | 14 | { &hf_msg_tx_in_count16, |
1857 | 14 | { "Input Count", "bitcoin.tx.input_count", |
1858 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1859 | 14 | NULL, HFILL } |
1860 | 14 | }, |
1861 | 14 | { &hf_msg_tx_in_count32, |
1862 | 14 | { "Input Count", "bitcoin.tx.input_count", |
1863 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1864 | 14 | NULL, HFILL } |
1865 | 14 | }, |
1866 | 14 | { &hf_msg_tx_in_count64, |
1867 | 14 | { "Input Count", "bitcoin.tx.input_count64", |
1868 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1869 | 14 | NULL, HFILL } |
1870 | 14 | }, |
1871 | 14 | { &hf_bitcoin_msg_tx, |
1872 | 14 | { "Tx message", "bitcoin.tx", |
1873 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1874 | 14 | NULL, HFILL } |
1875 | 14 | }, |
1876 | 14 | { &hf_msg_tx_version, |
1877 | 14 | { "Transaction version", "bitcoin.tx.version", |
1878 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1879 | 14 | NULL, HFILL } |
1880 | 14 | }, |
1881 | 14 | { &hf_msg_tx_flag, |
1882 | 14 | { "Flag", "bitcoin.tx.flag", |
1883 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1884 | 14 | NULL, HFILL } |
1885 | 14 | }, |
1886 | 14 | { &hf_msg_tx_in_script8, |
1887 | 14 | { "Script Length", "bitcoin.tx.in.script_length", |
1888 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1889 | 14 | NULL, HFILL } |
1890 | 14 | }, |
1891 | 14 | { &hf_msg_tx_in_script16, |
1892 | 14 | { "Script Length", "bitcoin.tx.in.script_length", |
1893 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1894 | 14 | NULL, HFILL } |
1895 | 14 | }, |
1896 | 14 | { &hf_msg_tx_in_script32, |
1897 | 14 | { "Script Length", "bitcoin.tx.in.script_length", |
1898 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1899 | 14 | NULL, HFILL } |
1900 | 14 | }, |
1901 | 14 | { &hf_msg_tx_in_script64, |
1902 | 14 | { "Script Length", "bitcoin.tx.in.script_length64", |
1903 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1904 | 14 | NULL, HFILL } |
1905 | 14 | }, |
1906 | 14 | { &hf_msg_tx_in, |
1907 | 14 | { "Transaction input", "bitcoin.tx.in", |
1908 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1909 | 14 | NULL, HFILL } |
1910 | 14 | }, |
1911 | 14 | { &hf_msg_tx_in_prev_output, |
1912 | 14 | { "Previous output", "bitcoin.tx.in.prev_output", |
1913 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1914 | 14 | NULL, HFILL } |
1915 | 14 | }, |
1916 | 14 | { &hf_msg_tx_in_prev_outp_hash, |
1917 | 14 | { "Hash", "bitcoin.tx.in.prev_output.hash", |
1918 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1919 | 14 | NULL, HFILL } |
1920 | 14 | }, |
1921 | 14 | { &hf_msg_tx_in_prev_outp_index, |
1922 | 14 | { "Index", "bitcoin.tx.in.prev_output.index", |
1923 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1924 | 14 | NULL, HFILL } |
1925 | 14 | }, |
1926 | 14 | { &hf_msg_tx_in_sig_script, |
1927 | 14 | { "Signature script", "bitcoin.tx.in.sig_script", |
1928 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1929 | 14 | NULL, HFILL } |
1930 | 14 | }, |
1931 | 14 | { &hf_msg_tx_in_seq, |
1932 | 14 | { "Sequence", "bitcoin.tx.in.seq", |
1933 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1934 | 14 | NULL, HFILL } |
1935 | 14 | }, |
1936 | 14 | { &hf_msg_tx_out_count8, |
1937 | 14 | { "Output Count", "bitcoin.tx.output_count", |
1938 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1939 | 14 | NULL, HFILL } |
1940 | 14 | }, |
1941 | 14 | { &hf_msg_tx_out_count16, |
1942 | 14 | { "Output Count", "bitcoin.tx.output_count", |
1943 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1944 | 14 | NULL, HFILL } |
1945 | 14 | }, |
1946 | 14 | { &hf_msg_tx_out_count32, |
1947 | 14 | { "Output Count", "bitcoin.tx.output_count", |
1948 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1949 | 14 | NULL, HFILL } |
1950 | 14 | }, |
1951 | 14 | { &hf_msg_tx_out_count64, |
1952 | 14 | { "Output Count", "bitcoin.tx.output_count64", |
1953 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1954 | 14 | NULL, HFILL } |
1955 | 14 | }, |
1956 | 14 | { &hf_msg_tx_out, |
1957 | 14 | { "Transaction output", "bitcoin.tx.out", |
1958 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1959 | 14 | NULL, HFILL } |
1960 | 14 | }, |
1961 | 14 | { &hf_msg_tx_out_value, |
1962 | 14 | { "Value", "bitcoin.tx.out.value", |
1963 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1964 | 14 | NULL, HFILL } |
1965 | 14 | }, |
1966 | 14 | { &hf_msg_tx_out_script8, |
1967 | 14 | { "Script Length", "bitcoin.tx.out.script_length", |
1968 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1969 | 14 | NULL, HFILL } |
1970 | 14 | }, |
1971 | 14 | { &hf_msg_tx_out_script16, |
1972 | 14 | { "Script Length", "bitcoin.tx.out.script_length", |
1973 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
1974 | 14 | NULL, HFILL } |
1975 | 14 | }, |
1976 | 14 | { &hf_msg_tx_out_script32, |
1977 | 14 | { "Script Length", "bitcoin.tx.out.script_length", |
1978 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1979 | 14 | NULL, HFILL } |
1980 | 14 | }, |
1981 | 14 | { &hf_msg_tx_out_script64, |
1982 | 14 | { "Script Length", "bitcoin.tx.out.script_length64", |
1983 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1984 | 14 | NULL, HFILL } |
1985 | 14 | }, |
1986 | 14 | { &hf_msg_tx_out_script, |
1987 | 14 | { "Script", "bitcoin.tx.out.script", |
1988 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1989 | 14 | NULL, HFILL } |
1990 | 14 | }, |
1991 | 14 | { &hf_msg_tx_witness, |
1992 | 14 | { "Transaction witness", "bitcoin.tx.witness", |
1993 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
1994 | 14 | NULL, HFILL } |
1995 | 14 | }, |
1996 | 14 | { &hf_msg_tx_witness_components8, |
1997 | 14 | { "Number of components", "bitcoin.tx.witness.component_count", |
1998 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1999 | 14 | NULL, HFILL } |
2000 | 14 | }, |
2001 | 14 | { &hf_msg_tx_witness_components16, |
2002 | 14 | { "Number of components", "bitcoin.tx.witness.component_count", |
2003 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2004 | 14 | NULL, HFILL } |
2005 | 14 | }, |
2006 | 14 | { &hf_msg_tx_witness_components32, |
2007 | 14 | { "Number of components", "bitcoin.tx.witness.component_count", |
2008 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2009 | 14 | NULL, HFILL } |
2010 | 14 | }, |
2011 | 14 | { &hf_msg_tx_witness_components64, |
2012 | 14 | { "Number of components", "bitcoin.tx.witness.component_count64", |
2013 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2014 | 14 | NULL, HFILL } |
2015 | 14 | }, |
2016 | 14 | { &hf_msg_tx_witness_component, |
2017 | 14 | { "Witness component", "bitcoin.tx.witness.component", |
2018 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2019 | 14 | NULL, HFILL } |
2020 | 14 | }, |
2021 | 14 | { &hf_msg_tx_witness_component_length8, |
2022 | 14 | { "Length", "bitcoin.tx.witness.component.length", |
2023 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2024 | 14 | NULL, HFILL } |
2025 | 14 | }, |
2026 | 14 | { &hf_msg_tx_witness_component_length16, |
2027 | 14 | { "Length", "bitcoin.tx.witness.component.length", |
2028 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2029 | 14 | NULL, HFILL } |
2030 | 14 | }, |
2031 | 14 | { &hf_msg_tx_witness_component_length32, |
2032 | 14 | { "Length", "bitcoin.tx.witness.component.length", |
2033 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2034 | 14 | NULL, HFILL } |
2035 | 14 | }, |
2036 | 14 | { &hf_msg_tx_witness_component_length64, |
2037 | 14 | { "Length", "bitcoin.tx.witness.component.length64", |
2038 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2039 | 14 | NULL, HFILL } |
2040 | 14 | }, |
2041 | 14 | { &hf_msg_tx_witness_component_data, |
2042 | 14 | { "Data", "bitcoin.tx.witness.component.data", |
2043 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2044 | 14 | NULL, HFILL } |
2045 | 14 | }, |
2046 | 14 | { &hf_msg_tx_lock_time, |
2047 | 14 | { "Block lock time or block ID", "bitcoin.tx.lock_time", |
2048 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2049 | 14 | NULL, HFILL } |
2050 | 14 | }, |
2051 | 14 | { &hf_msg_block_transactions8, |
2052 | 14 | { "Number of transactions", "bitcoin.block.num_transactions", |
2053 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2054 | 14 | NULL, HFILL } |
2055 | 14 | }, |
2056 | 14 | { &hf_msg_block_transactions16, |
2057 | 14 | { "Number of transactions", "bitcoin.block.num_transactions", |
2058 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2059 | 14 | NULL, HFILL } |
2060 | 14 | }, |
2061 | 14 | { &hf_msg_block_transactions32, |
2062 | 14 | { "Number of transactions", "bitcoin.block.num_transactions", |
2063 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2064 | 14 | NULL, HFILL } |
2065 | 14 | }, |
2066 | 14 | { &hf_msg_block_transactions64, |
2067 | 14 | { "Number of transactions", "bitcoin.block.num_transactions64", |
2068 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2069 | 14 | NULL, HFILL } |
2070 | 14 | }, |
2071 | 14 | { &hf_bitcoin_msg_block, |
2072 | 14 | { "Block message", "bitcoin.block", |
2073 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2074 | 14 | NULL, HFILL } |
2075 | 14 | }, |
2076 | 14 | { &hf_msg_block_version, |
2077 | 14 | { "Block version", "bitcoin.block.version", |
2078 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2079 | 14 | NULL, HFILL } |
2080 | 14 | }, |
2081 | 14 | { &hf_msg_block_prev_block, |
2082 | 14 | { "Previous block", "bitcoin.block.prev_block", |
2083 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2084 | 14 | NULL, HFILL } |
2085 | 14 | }, |
2086 | 14 | { &hf_msg_block_merkle_root, |
2087 | 14 | { "Merkle root", "bitcoin.block.merkle_root", |
2088 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2089 | 14 | NULL, HFILL } |
2090 | 14 | }, |
2091 | 14 | { &hf_msg_block_time, |
2092 | 14 | { "Block timestamp", "bitcoin.block.timestamp", |
2093 | 14 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, |
2094 | 14 | NULL, HFILL } |
2095 | 14 | }, |
2096 | 14 | { &hf_msg_block_bits, |
2097 | 14 | { "Bits", "bitcoin.block.bits", |
2098 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2099 | 14 | NULL, HFILL } |
2100 | 14 | }, |
2101 | 14 | { &hf_msg_block_nonce, |
2102 | 14 | { "Nonce", "bitcoin.block.nonce", |
2103 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2104 | 14 | NULL, HFILL } |
2105 | 14 | }, |
2106 | 14 | { &hf_bitcoin_msg_headers, |
2107 | 14 | { "Headers message", "bitcoin.headers", |
2108 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2109 | 14 | NULL, HFILL } |
2110 | 14 | }, |
2111 | 14 | { &hf_msg_headers_version, |
2112 | 14 | { "Block version", "bitcoin.headers.version", |
2113 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2114 | 14 | NULL, HFILL } |
2115 | 14 | }, |
2116 | 14 | { &hf_msg_headers_prev_block, |
2117 | 14 | { "Previous block", "bitcoin.headers.prev_block", |
2118 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2119 | 14 | NULL, HFILL } |
2120 | 14 | }, |
2121 | 14 | { &hf_msg_headers_merkle_root, |
2122 | 14 | { "Merkle root", "bitcoin.headers.merkle_root", |
2123 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2124 | 14 | NULL, HFILL } |
2125 | 14 | }, |
2126 | 14 | { &hf_msg_headers_time, |
2127 | 14 | { "Block timestamp", "bitcoin.headers.timestamp", |
2128 | 14 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, |
2129 | 14 | NULL, HFILL } |
2130 | 14 | }, |
2131 | 14 | { &hf_msg_headers_bits, |
2132 | 14 | { "Bits", "bitcoin.headers.bits", |
2133 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2134 | 14 | NULL, HFILL } |
2135 | 14 | }, |
2136 | 14 | { &hf_msg_headers_nonce, |
2137 | 14 | { "Nonce", "bitcoin.headers.nonce", |
2138 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2139 | 14 | NULL, HFILL } |
2140 | 14 | }, |
2141 | 14 | { &hf_msg_headers_count8, |
2142 | 14 | { "Count", "bitcoin.headers.count", |
2143 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2144 | 14 | NULL, HFILL } |
2145 | 14 | }, |
2146 | 14 | { &hf_msg_headers_count16, |
2147 | 14 | { "Count", "bitcoin.headers.count", |
2148 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2149 | 14 | NULL, HFILL } |
2150 | 14 | }, |
2151 | 14 | { &hf_msg_headers_count32, |
2152 | 14 | { "Count", "bitcoin.headers.count", |
2153 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2154 | 14 | NULL, HFILL } |
2155 | 14 | }, |
2156 | 14 | { &hf_msg_headers_count64, |
2157 | 14 | { "Count", "bitcoin.headers.count64", |
2158 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2159 | 14 | NULL, HFILL } |
2160 | 14 | }, |
2161 | 14 | { &hf_bitcoin_msg_ping, |
2162 | 14 | { "Ping message", "bitcoin.ping", |
2163 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2164 | 14 | NULL, HFILL } |
2165 | 14 | }, |
2166 | 14 | { &hf_msg_ping_nonce, |
2167 | 14 | { "Random nonce", "bitcoin.ping.nonce", |
2168 | 14 | FT_UINT64, BASE_HEX, NULL, 0x0, |
2169 | 14 | NULL, HFILL } |
2170 | 14 | }, |
2171 | 14 | { &hf_bitcoin_msg_pong, |
2172 | 14 | { "Pong message", "bitcoin.pong", |
2173 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2174 | 14 | NULL, HFILL } |
2175 | 14 | }, |
2176 | 14 | { &hf_msg_pong_nonce, |
2177 | 14 | { "Random nonce", "bitcoin.pong.nonce", |
2178 | 14 | FT_UINT64, BASE_HEX, NULL, 0x0, |
2179 | 14 | NULL, HFILL } |
2180 | 14 | }, |
2181 | 14 | { &hf_bitcoin_msg_reject, |
2182 | 14 | { "Reject message", "bitcoin.reject", |
2183 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2184 | 14 | NULL, HFILL } |
2185 | 14 | }, |
2186 | 14 | { &hf_msg_reject_message, |
2187 | 14 | { "Message rejected", "bitcoin.reject.message", |
2188 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2189 | 14 | NULL, HFILL } |
2190 | 14 | }, |
2191 | 14 | { &hf_msg_reject_reason, |
2192 | 14 | { "Reason", "bitcoin.reject.reason", |
2193 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2194 | 14 | NULL, HFILL } |
2195 | 14 | }, |
2196 | 14 | { &hf_msg_reject_ccode, |
2197 | 14 | { "CCode", "bitcoin.reject.ccode", |
2198 | 14 | FT_UINT8, BASE_HEX, VALS(reject_ccode), 0x0, |
2199 | 14 | NULL, HFILL } |
2200 | 14 | }, |
2201 | 14 | { &hf_msg_reject_data, |
2202 | 14 | { "Data", "bitcoin.reject.data", |
2203 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2204 | 14 | NULL, HFILL } |
2205 | 14 | }, |
2206 | 14 | { &hf_bitcoin_msg_sendcmpct, |
2207 | 14 | { "Sendcmpct message", "bitcoin.sendcmpct", |
2208 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2209 | 14 | NULL, HFILL } |
2210 | 14 | }, |
2211 | 14 | { &hf_msg_sendcmpct_announce, |
2212 | 14 | { "Announce", "bitcoin.sendcmpct.announce", |
2213 | 14 | FT_BOOLEAN, BASE_NONE, NULL, 0x0, |
2214 | 14 | NULL, HFILL } |
2215 | 14 | }, |
2216 | 14 | { &hf_msg_sendcmpct_version, |
2217 | 14 | { "Version", "bitcoin.sendcmpct.version", |
2218 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2219 | 14 | NULL, HFILL } |
2220 | 14 | }, |
2221 | 14 | { &hf_bitcoin_msg_feefilter, |
2222 | 14 | { "Feefilter message", "bitcoin.feefilter", |
2223 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2224 | 14 | NULL, HFILL } |
2225 | 14 | }, |
2226 | 14 | { &hf_msg_feefilter_value, |
2227 | 14 | { "Minimal fee", "bitcoin.feefilter.value", |
2228 | 14 | FT_UINT64, BASE_CUSTOM, CF_FUNC(format_feefilter_value), 0x0, |
2229 | 14 | NULL, HFILL } |
2230 | 14 | }, |
2231 | 14 | { &hf_bitcoin_msg_filterload, |
2232 | 14 | { "Filterload message", "bitcoin.filterload", |
2233 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2234 | 14 | NULL, HFILL } |
2235 | 14 | }, |
2236 | 14 | { &hf_msg_filterload_filter, |
2237 | 14 | { "Filter", "bitcoin.filterload.filter", |
2238 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2239 | 14 | NULL, HFILL } |
2240 | 14 | }, |
2241 | 14 | { &hf_msg_filterload_nhashfunc, |
2242 | 14 | { "nHashFunc", "bitcoin.filterload.nhashfunc", |
2243 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2244 | 14 | NULL, HFILL } |
2245 | 14 | }, |
2246 | 14 | { &hf_msg_filterload_ntweak, |
2247 | 14 | { "nTweak", "bitcoin.filterload.ntweak", |
2248 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2249 | 14 | NULL, HFILL } |
2250 | 14 | }, |
2251 | 14 | { &hf_msg_filterload_nflags, |
2252 | 14 | { "nFlags", "bitcoin.filterload.nflags", |
2253 | 14 | FT_UINT8, BASE_HEX, VALS(filterload_nflags), 0x0, |
2254 | 14 | NULL, HFILL } |
2255 | 14 | }, |
2256 | 14 | { &hf_bitcoin_msg_filteradd, |
2257 | 14 | { "Filteradd message", "bitcoin.filteradd", |
2258 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2259 | 14 | NULL, HFILL } |
2260 | 14 | }, |
2261 | 14 | { &hf_msg_filteradd_data, |
2262 | 14 | { "Data", "bitcoin.filteradd.data", |
2263 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2264 | 14 | NULL, HFILL } |
2265 | 14 | }, |
2266 | 14 | { &hf_bitcoin_msg_merkleblock, |
2267 | 14 | { "Merkleblock message", "bitcoin.merkleblock", |
2268 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
2269 | 14 | NULL, HFILL } |
2270 | 14 | }, |
2271 | 14 | { &hf_msg_merkleblock_transactions, |
2272 | 14 | { "Number of transactions", "bitcoin.merkleblock.num_transactions", |
2273 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2274 | 14 | NULL, HFILL } |
2275 | 14 | }, |
2276 | 14 | { &hf_msg_merkleblock_version, |
2277 | 14 | { "Block version", "bitcoin.merkleblock.version", |
2278 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2279 | 14 | NULL, HFILL } |
2280 | 14 | }, |
2281 | 14 | { &hf_msg_merkleblock_prev_block, |
2282 | 14 | { "Previous block", "bitcoin.merkleblock.prev_block", |
2283 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2284 | 14 | NULL, HFILL } |
2285 | 14 | }, |
2286 | 14 | { &hf_msg_merkleblock_merkle_root, |
2287 | 14 | { "Merkle root", "bitcoin.merkleblock.merkle_root", |
2288 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2289 | 14 | NULL, HFILL } |
2290 | 14 | }, |
2291 | 14 | { &hf_msg_merkleblock_time, |
2292 | 14 | { "Block timestamp", "bitcoin.merkleblock.timestamp", |
2293 | 14 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, |
2294 | 14 | NULL, HFILL } |
2295 | 14 | }, |
2296 | 14 | { &hf_msg_merkleblock_bits, |
2297 | 14 | { "Bits", "bitcoin.merkleblock.bits", |
2298 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2299 | 14 | NULL, HFILL } |
2300 | 14 | }, |
2301 | 14 | { &hf_msg_merkleblock_nonce, |
2302 | 14 | { "Nonce", "bitcoin.merkleblock.nonce", |
2303 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
2304 | 14 | NULL, HFILL } |
2305 | 14 | }, |
2306 | 14 | { &hf_msg_merkleblock_hashes_count8, |
2307 | 14 | { "Count", "bitcoin.merkleblock.hashes.count", |
2308 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2309 | 14 | NULL, HFILL } |
2310 | 14 | }, |
2311 | 14 | { &hf_msg_merkleblock_hashes_count16, |
2312 | 14 | { "Count", "bitcoin.merkleblock.hashes.count", |
2313 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2314 | 14 | NULL, HFILL } |
2315 | 14 | }, |
2316 | 14 | { &hf_msg_merkleblock_hashes_count32, |
2317 | 14 | { "Count", "bitcoin.merkleblock.hashes.count", |
2318 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2319 | 14 | NULL, HFILL } |
2320 | 14 | }, |
2321 | 14 | { &hf_msg_merkleblock_hashes_count64, |
2322 | 14 | { "Count", "bitcoin.merkleblock.hashes.count64", |
2323 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2324 | 14 | NULL, HFILL } |
2325 | 14 | }, |
2326 | 14 | { &hf_msg_merkleblock_hashes_hash, |
2327 | 14 | { "Hash", "bitcoin.merkleblock.hashes.hash", |
2328 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2329 | 14 | NULL, HFILL } |
2330 | 14 | }, |
2331 | 14 | { &hf_msg_merkleblock_flags_size8, |
2332 | 14 | { "Size", "bitcoin.merkleblock.flags.count", |
2333 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2334 | 14 | NULL, HFILL } |
2335 | 14 | }, |
2336 | 14 | { &hf_msg_merkleblock_flags_size16, |
2337 | 14 | { "Size", "bitcoin.merkleblock.flags.count", |
2338 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2339 | 14 | NULL, HFILL } |
2340 | 14 | }, |
2341 | 14 | { &hf_msg_merkleblock_flags_size32, |
2342 | 14 | { "Size", "bitcoin.merkleblock.flags.count", |
2343 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2344 | 14 | NULL, HFILL } |
2345 | 14 | }, |
2346 | 14 | { &hf_msg_merkleblock_flags_size64, |
2347 | 14 | { "Size", "bitcoin.merkleblock.flags.count64", |
2348 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2349 | 14 | NULL, HFILL } |
2350 | 14 | }, |
2351 | 14 | { &hf_msg_merkleblock_flags_data, |
2352 | 14 | { "Data", "bitcoin.merkleblock.flags.data", |
2353 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2354 | 14 | NULL, HFILL } |
2355 | 14 | }, |
2356 | 14 | { &hf_services_network, |
2357 | 14 | { "Network node", "bitcoin.services.network", |
2358 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000001, |
2359 | 14 | NULL, HFILL } |
2360 | 14 | }, |
2361 | 14 | { &hf_services_getutxo, |
2362 | 14 | { "Getutxo node", "bitcoin.services.getutxo", |
2363 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000002, |
2364 | 14 | NULL, HFILL } |
2365 | 14 | }, |
2366 | 14 | { &hf_services_bloom, |
2367 | 14 | { "Bloom filter node", "bitcoin.services.bloom", |
2368 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000004, |
2369 | 14 | NULL, HFILL } |
2370 | 14 | }, |
2371 | 14 | { &hf_services_witness, |
2372 | 14 | { "Witness node", "bitcoin.services.witness", |
2373 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000008, |
2374 | 14 | NULL, HFILL } |
2375 | 14 | }, |
2376 | 14 | { &hf_services_xthin, |
2377 | 14 | { "Xtreme Thinblocks node", "bitcoin.services.xthin", |
2378 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000010, |
2379 | 14 | NULL, HFILL } |
2380 | 14 | }, |
2381 | 14 | { &hf_services_compactfilters, |
2382 | 14 | { "Compact filters node", "bitcoin.services.compactfilters", |
2383 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000040, |
2384 | 14 | NULL, HFILL } |
2385 | 14 | }, |
2386 | 14 | { &hf_services_networklimited, |
2387 | 14 | { "Limited network node", "bitcoin.services.networklimited", |
2388 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000400, |
2389 | 14 | NULL, HFILL } |
2390 | 14 | }, |
2391 | 14 | { &hf_services_p2pv2, |
2392 | 14 | { "Version 2 P2P node", "bitcoin.services.p2pv2", |
2393 | 14 | FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x00000800, |
2394 | 14 | NULL, HFILL } |
2395 | 14 | }, |
2396 | 14 | { &hf_address_services, |
2397 | 14 | { "Node services", "bitcoin.address.services", |
2398 | 14 | FT_UINT64, BASE_HEX, NULL, 0x0, |
2399 | 14 | NULL, HFILL } |
2400 | 14 | }, |
2401 | 14 | { &hf_address_address, |
2402 | 14 | { "Node address", "bitcoin.address.address", |
2403 | 14 | FT_IPv6, BASE_NONE, NULL, 0x0, |
2404 | 14 | NULL, HFILL } |
2405 | 14 | }, |
2406 | 14 | { &hf_address_port, |
2407 | 14 | { "Node port", "bitcoin.address.port", |
2408 | 14 | FT_UINT16, BASE_PT_TCP, NULL, 0x0, |
2409 | 14 | NULL, HFILL } |
2410 | 14 | }, |
2411 | 14 | { &hf_string_value, |
2412 | 14 | { "String value", "bitcoin.string.value", |
2413 | 14 | FT_STRING, BASE_NONE, NULL, 0x0, |
2414 | 14 | NULL, HFILL } |
2415 | 14 | }, |
2416 | 14 | { &hf_string_varint_count8, |
2417 | 14 | { "Count", "bitcoin.string.count", |
2418 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2419 | 14 | NULL, HFILL } |
2420 | 14 | }, |
2421 | 14 | { &hf_string_varint_count16, |
2422 | 14 | { "Count", "bitcoin.string.count", |
2423 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2424 | 14 | NULL, HFILL } |
2425 | 14 | }, |
2426 | 14 | { &hf_string_varint_count32, |
2427 | 14 | { "Count", "bitcoin.string.count", |
2428 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2429 | 14 | NULL, HFILL } |
2430 | 14 | }, |
2431 | 14 | { &hf_string_varint_count64, |
2432 | 14 | { "Count", "bitcoin.string.count64", |
2433 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2434 | 14 | NULL, HFILL } |
2435 | 14 | }, |
2436 | 14 | { &hf_data_value, |
2437 | 14 | { "Data", "bitcoin.data.value", |
2438 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
2439 | 14 | NULL, HFILL } |
2440 | 14 | }, |
2441 | 14 | { &hf_data_varint_count8, |
2442 | 14 | { "Count", "bitcoin.data.count", |
2443 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
2444 | 14 | NULL, HFILL } |
2445 | 14 | }, |
2446 | 14 | { &hf_data_varint_count16, |
2447 | 14 | { "Count", "bitcoin.data.count", |
2448 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
2449 | 14 | NULL, HFILL } |
2450 | 14 | }, |
2451 | 14 | { &hf_data_varint_count32, |
2452 | 14 | { "Count", "bitcoin.data.count", |
2453 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
2454 | 14 | NULL, HFILL } |
2455 | 14 | }, |
2456 | 14 | { &hf_data_varint_count64, |
2457 | 14 | { "Count", "bitcoin.data.count64", |
2458 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, |
2459 | 14 | NULL, HFILL } |
2460 | 14 | }, |
2461 | 14 | }; |
2462 | | |
2463 | 14 | static int *ett[] = { |
2464 | 14 | &ett_bitcoin, |
2465 | 14 | &ett_bitcoin_msg, |
2466 | 14 | &ett_services, |
2467 | 14 | &ett_address, |
2468 | 14 | &ett_string, |
2469 | 14 | &ett_addr_list, |
2470 | 14 | &ett_inv_list, |
2471 | 14 | &ett_getdata_list, |
2472 | 14 | &ett_notfound_list, |
2473 | 14 | &ett_getblocks_list, |
2474 | 14 | &ett_getheaders_list, |
2475 | 14 | &ett_tx_in_list, |
2476 | 14 | &ett_tx_in_outp, |
2477 | 14 | &ett_tx_out_list, |
2478 | 14 | &ett_tx_witness_list, |
2479 | 14 | &ett_tx_witness_component_list, |
2480 | 14 | }; |
2481 | | |
2482 | 14 | static ei_register_info ei[] = { |
2483 | 14 | { &ei_bitcoin_command_unknown, { "bitcoin.command.unknown", PI_PROTOCOL, PI_WARN, "Unknown command", EXPFILL }}, |
2484 | 14 | { &ei_bitcoin_address_length, { "bitcoin.address_length.invalid", PI_MALFORMED, PI_WARN, "Address length does not match network type", EXPFILL }}, |
2485 | 14 | { &ei_bitcoin_script_len, { "bitcoin.script_length.invalid", PI_MALFORMED, PI_ERROR, "script_len too large", EXPFILL }} |
2486 | 14 | }; |
2487 | | |
2488 | 14 | module_t *bitcoin_module; |
2489 | 14 | expert_module_t* expert_bitcoin; |
2490 | | |
2491 | 14 | proto_bitcoin = proto_register_protocol("Bitcoin protocol", "Bitcoin", "bitcoin"); |
2492 | | |
2493 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
2494 | 14 | proto_register_field_array(proto_bitcoin, hf, array_length(hf)); |
2495 | | |
2496 | 14 | expert_bitcoin = expert_register_protocol(proto_bitcoin); |
2497 | 14 | expert_register_field_array(expert_bitcoin, ei, array_length(ei)); |
2498 | | |
2499 | 14 | bitcoin_command_table = register_dissector_table("bitcoin.command", "Bitcoin Command", proto_bitcoin, FT_STRING, STRING_CASE_SENSITIVE); |
2500 | | |
2501 | 14 | bitcoin_handle = register_dissector("bitcoin", dissect_bitcoin, proto_bitcoin); |
2502 | | |
2503 | 14 | bitcoin_module = prefs_register_protocol(proto_bitcoin, NULL); |
2504 | 14 | prefs_register_bool_preference(bitcoin_module, "desegment", |
2505 | 14 | "Desegment all Bitcoin messages spanning multiple TCP segments", |
2506 | 14 | "Whether the Bitcoin dissector should desegment all messages" |
2507 | 14 | " spanning multiple TCP segments", |
2508 | 14 | &bitcoin_desegment); |
2509 | | |
2510 | 14 | } |
2511 | | |
2512 | | void |
2513 | | proto_reg_handoff_bitcoin(void) |
2514 | 14 | { |
2515 | 14 | dissector_handle_t command_handle; |
2516 | | |
2517 | 14 | dissector_add_for_decode_as_with_preference("tcp.port", bitcoin_handle); |
2518 | | |
2519 | 14 | heur_dissector_add( "tcp", dissect_bitcoin_heur, "Bitcoin over TCP", "bitcoin_tcp", proto_bitcoin, HEURISTIC_ENABLE); |
2520 | | |
2521 | | /* Register all of the commands */ |
2522 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_version, proto_bitcoin ); |
2523 | 14 | dissector_add_string("bitcoin.command", "version", command_handle); |
2524 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_addr, proto_bitcoin ); |
2525 | 14 | dissector_add_string("bitcoin.command", "addr", command_handle); |
2526 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_addrv2, proto_bitcoin ); |
2527 | 14 | dissector_add_string("bitcoin.command", "addrv2", command_handle); |
2528 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_inv, proto_bitcoin ); |
2529 | 14 | dissector_add_string("bitcoin.command", "inv", command_handle); |
2530 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_getdata, proto_bitcoin ); |
2531 | 14 | dissector_add_string("bitcoin.command", "getdata", command_handle); |
2532 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_getblocks, proto_bitcoin ); |
2533 | 14 | dissector_add_string("bitcoin.command", "getblocks", command_handle); |
2534 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_getheaders, proto_bitcoin ); |
2535 | 14 | dissector_add_string("bitcoin.command", "getheaders", command_handle); |
2536 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_tx, proto_bitcoin ); |
2537 | 14 | dissector_add_string("bitcoin.command", "tx", command_handle); |
2538 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_block, proto_bitcoin ); |
2539 | 14 | dissector_add_string("bitcoin.command", "block", command_handle); |
2540 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_ping, proto_bitcoin ); |
2541 | 14 | dissector_add_string("bitcoin.command", "ping", command_handle); |
2542 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_pong, proto_bitcoin ); |
2543 | 14 | dissector_add_string("bitcoin.command", "pong", command_handle); |
2544 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_notfound, proto_bitcoin ); |
2545 | 14 | dissector_add_string("bitcoin.command", "notfound", command_handle); |
2546 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_reject, proto_bitcoin ); |
2547 | 14 | dissector_add_string("bitcoin.command", "reject", command_handle); |
2548 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_headers, proto_bitcoin ); |
2549 | 14 | dissector_add_string("bitcoin.command", "headers", command_handle); |
2550 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_feefilter, proto_bitcoin ); |
2551 | 14 | dissector_add_string("bitcoin.command", "feefilter", command_handle); |
2552 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_filterload, proto_bitcoin ); |
2553 | 14 | dissector_add_string("bitcoin.command", "filterload", command_handle); |
2554 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_filteradd, proto_bitcoin ); |
2555 | 14 | dissector_add_string("bitcoin.command", "filteradd", command_handle); |
2556 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_merkleblock, proto_bitcoin ); |
2557 | 14 | dissector_add_string("bitcoin.command", "merkleblock", command_handle); |
2558 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_sendcmpct, proto_bitcoin ); |
2559 | 14 | dissector_add_string("bitcoin.command", "sendcmpct", command_handle); |
2560 | | |
2561 | | /* messages with no payload */ |
2562 | 14 | command_handle = create_dissector_handle( dissect_bitcoin_msg_empty, proto_bitcoin ); |
2563 | 14 | dissector_add_string("bitcoin.command", "verack", command_handle); |
2564 | 14 | dissector_add_string("bitcoin.command", "getaddr", command_handle); |
2565 | 14 | dissector_add_string("bitcoin.command", "mempool", command_handle); |
2566 | 14 | dissector_add_string("bitcoin.command", "filterclear", command_handle); |
2567 | 14 | dissector_add_string("bitcoin.command", "sendaddrv2", command_handle); |
2568 | 14 | dissector_add_string("bitcoin.command", "sendheaders", command_handle); |
2569 | 14 | dissector_add_string("bitcoin.command", "wtxidrelay", command_handle); |
2570 | | |
2571 | | /* messages not implemented */ |
2572 | | /* command_handle = create_dissector_handle( dissect_bitcoin_msg_empty, proto_bitcoin ); */ |
2573 | 14 | dissector_add_string("bitcoin.command", "checkorder", command_handle); |
2574 | 14 | dissector_add_string("bitcoin.command", "submitorder", command_handle); |
2575 | 14 | dissector_add_string("bitcoin.command", "reply", command_handle); |
2576 | 14 | dissector_add_string("bitcoin.command", "alert", command_handle); |
2577 | 14 | } |
2578 | | |
2579 | | /* |
2580 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
2581 | | * |
2582 | | * Local variables: |
2583 | | * c-basic-offset: 2 |
2584 | | * tab-width: 8 |
2585 | | * indent-tabs-mode: nil |
2586 | | * End: |
2587 | | * |
2588 | | * vi: set shiftwidth=2 tabstop=8 expandtab: |
2589 | | * :indentSize=2:tabSize=8:noTabs=true: |
2590 | | */ |