/src/wireshark/epan/dissectors/packet-hazelcast.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * packet-hazelcast.c |
3 | | * dissector for hazelcast wire protocol |
4 | | * Paul Erkkila <paul.erkkila@level3.com> |
5 | | * |
6 | | * Website: http://www.hazelcast.com/ |
7 | | * |
8 | | * reversed from this code: |
9 | | * http://code.google.com/p/hazelcast/source/browse/branches/1.9.4/hazelcast/src/main/java/com/hazelcast/nio/Packet.java |
10 | | * |
11 | | * Wireshark - Network traffic analyzer |
12 | | * By Gerald Combs <gerald@wireshark.org> |
13 | | * Copyright 1998 Gerald Combs |
14 | | * |
15 | | * SPDX-License-Identifier: GPL-2.0-or-later |
16 | | * |
17 | | */ |
18 | | |
19 | | |
20 | | #include "config.h" |
21 | | |
22 | | #include <epan/packet.h> |
23 | | #include <epan/prefs.h> |
24 | | #include <epan/tap.h> |
25 | | #include "packet-tcp.h" |
26 | | |
27 | | void proto_register_hazelcast(void); |
28 | | void proto_reg_handoff_hazelcast(void); |
29 | | |
30 | | static dissector_handle_t hazelcast_handle; |
31 | | |
32 | | static int proto_hazelcast; |
33 | | static int hazelcast_tap; |
34 | | |
35 | | static int hf_hazelcast_headerLength; |
36 | | static int hf_hazelcast_headerKeyLength; |
37 | | static int hf_hazelcast_headerValueLength; |
38 | | static int hf_hazelcast_headerVersion; |
39 | | |
40 | | static int hf_hazelcast_operation; |
41 | | static int hf_hazelcast_blockID; |
42 | | static int hf_hazelcast_threadID; |
43 | | static int hf_hazelcast_timeout; |
44 | | static int hf_hazelcast_ttl; |
45 | | static int hf_hazelcast_txnID; |
46 | | static int hf_hazelcast_longValue; |
47 | | static int hf_hazelcast_version; |
48 | | static int hf_hazelcast_lockCount; |
49 | | static int hf_hazelcast_lockAddrIP; |
50 | | static int hf_hazelcast_lockAddrPort; |
51 | | static int hf_hazelcast_callID; |
52 | | static int hf_hazelcast_responseType; |
53 | | static int hf_hazelcast_nameLength; |
54 | | static int hf_hazelcast_name; |
55 | | static int hf_hazelcast_indexCount; |
56 | | static int hf_hazelcast_keyPartitionHash; |
57 | | static int hf_hazelcast_valuePartitionHash; |
58 | | static int hf_hazelcast_keys; |
59 | | static int hf_hazelcast_values; |
60 | | |
61 | | /* flags */ |
62 | | static int hf_hazelcast_flags; |
63 | | |
64 | 14 | #define HAZELCAST_LOCKCOUNT_FLAG (1 << 0) |
65 | 14 | #define HAZELCAST_TIMEOUT_FLAG (1 << 1) |
66 | 14 | #define HAZELCAST_TTL_FLAG (1 << 2) |
67 | 14 | #define HAZELCAST_TXN_FLAG (1 << 3) |
68 | 14 | #define HAZELCAST_LONGVALUE_FLAG (1 << 4) |
69 | 14 | #define HAZELCAST_VERSION_FLAG (1 << 5) |
70 | 14 | #define HAZELCAST_CLIENT_FLAG (1 << 6) |
71 | 14 | #define HAZELCAST_LOCKADDRNULL_FLAG (1 << 7) |
72 | | |
73 | | static int hf_hazelcast_flags_lockCount; |
74 | | static int hf_hazelcast_flags_timeout; |
75 | | static int hf_hazelcast_flags_ttl; |
76 | | static int hf_hazelcast_flags_txn; |
77 | | static int hf_hazelcast_flags_longValue; |
78 | | static int hf_hazelcast_flags_version; |
79 | | static int hf_hazelcast_flags_client; |
80 | | static int hf_hazelcast_flags_lockAddrNull; |
81 | | |
82 | | |
83 | | static int ett_hazelcast; |
84 | | static int ett_hazelcast_flags; |
85 | | |
86 | | /* prefs */ |
87 | | static bool hazelcast_desegment = true; |
88 | 14 | #define HAZELCAST_PORT 5701 /* Not IANA registered */ |
89 | | |
90 | | static const value_string operationTypes[] = { |
91 | | {0, "NONE"}, |
92 | | {1, "RESPONSE"}, |
93 | | {2, "LOG"}, |
94 | | {3, "HEARTBEAT"}, |
95 | | {4, "JOIN_CHECK"}, |
96 | | {5, "REMOTELY_PROCESS"}, |
97 | | {6, "REMOTELY_PROCESS_AND_RESPOND"}, |
98 | | {7, "REMOTELY_CALLABLE_BOOLEAN"}, |
99 | | {8, "REMOTELY_CALLABLE_OBJECT"}, |
100 | | {9, "EVENT"}, |
101 | | {10, "EXECUTE"}, |
102 | | {11, "CANCEL_EXECUTION"}, |
103 | | {12, "ADD_LISTENER"}, |
104 | | {13, "ADD_LISTENER_NO_RESPONSE"}, |
105 | | {14, "REMOVE_LISTENER"}, |
106 | | {15, "BLOCKING_ADD_KEY"}, |
107 | | {16, "BLOCKING_REMOVE_KEY"}, |
108 | | {17, "BLOCKING_OFFER_KEY"}, |
109 | | {18, "BLOCKING_GENERATE_KEY"}, |
110 | | {19, "BLOCKING_ITERATE"}, |
111 | | {20, "BLOCKING_SIZE"}, |
112 | | {21, "BLOCKING_TAKE_KEY"}, |
113 | | {22, "BLOCKING_CANCEL_TAKE_KEY"}, |
114 | | {23, "BLOCKING_SET"}, |
115 | | {24, "BLOCKING_PEEK_KEY"}, |
116 | | {25, "BLOCKING_GET_KEY_BY_INDEX"}, |
117 | | {26, "BLOCKING_GET_INDEX_BY_KEY"}, |
118 | | {27, "BLOCKING_QUEUE_POLL"}, |
119 | | {28, "BLOCKING_QUEUE_OFFER"}, |
120 | | {29, "BLOCKING_QUEUE_SIZE"}, |
121 | | {30, "BLOCKING_QUEUE_PEEK"}, |
122 | | {31, "BLOCKING_QUEUE_REMOVE"}, |
123 | | {32, "TOPIC_PUBLISH"}, |
124 | | {33, "ATOMIC_NUMBER_ADD_AND_GET"}, |
125 | | {34, "ATOMIC_NUMBER_GET_AND_ADD"}, |
126 | | {35, "ATOMIC_NUMBER_GET_AND_SET"}, |
127 | | {36, "ATOMIC_NUMBER_COMPARE_AND_SET"}, |
128 | | {37, "CONCURRENT_MAP_PUT"}, |
129 | | {38, "CONCURRENT_MAP_PUT_ALL"}, |
130 | | {39, "CONCURRENT_MAP_PUT_TRANSIENT"}, |
131 | | {40, "CONCURRENT_MAP_SET"}, |
132 | | {41, "CONCURRENT_MAP_MERGE"}, |
133 | | {42, "CONCURRENT_MAP_ASYNC_MERGE"}, |
134 | | {43, "CONCURRENT_MAP_WAN_MERGE"}, |
135 | | {44, "CONCURRENT_MAP_TRY_PUT"}, |
136 | | {45, "CONCURRENT_MAP_PUT_AND_UNLOCK"}, |
137 | | {46, "CONCURRENT_MAP_GET"}, |
138 | | {47, "CONCURRENT_MAP_GET_ALL"}, |
139 | | {48, "CONCURRENT_MAP_REMOVE"}, |
140 | | {49, "CONCURRENT_MAP_TRY_REMOVE"}, |
141 | | {50, "CONCURRENT_MAP_REMOVE_ITEM"}, |
142 | | {51, "CONCURRENT_MAP_GET_MAP_ENTRY"}, |
143 | | {52, "CONCURRENT_MAP_GET_DATA_RECORD_ENTRY"}, |
144 | | {53, "CONCURRENT_MAP_BLOCK_INFO"}, |
145 | | {54, "CONCURRENT_MAP_BLOCK_MIGRATION_CHECK"}, |
146 | | {55, "CONCURRENT_MAP_SIZE"}, |
147 | | {56, "CONCURRENT_MAP_CONTAINS_KEY"}, |
148 | | {57, "CONCURRENT_MAP_CONTAINS_ENTRY"}, |
149 | | {58, "CONCURRENT_MAP_ITERATE_ENTRIES"}, |
150 | | {59, "CONCURRENT_MAP_ITERATE_KEYS"}, |
151 | | {60, "CONCURRENT_MAP_ITERATE_KEYS_ALL"}, |
152 | | {61, "CONCURRENT_MAP_ITERATE_VALUES"}, |
153 | | {62, "CONCURRENT_MAP_LOCK"}, |
154 | | {63, "CONCURRENT_MAP_LOCK_MAP"}, |
155 | | {64, "CONCURRENT_MAP_UNLOCK"}, |
156 | | {65, "CONCURRENT_MAP_FORCE_UNLOCK"}, |
157 | | {66, "CONCURRENT_MAP_UNLOCK_MAP"}, |
158 | | {67, "CONCURRENT_MAP_BLOCKS"}, |
159 | | {68, "CONCURRENT_MAP_CONTAINS_VALUE"}, |
160 | | {69, "CONCURRENT_MAP_PUT_IF_ABSENT"}, |
161 | | {70, "CONCURRENT_MAP_REMOVE_IF_SAME"}, |
162 | | {71, "CONCURRENT_MAP_REPLACE_IF_NOT_NULL"}, |
163 | | {72, "CONCURRENT_MAP_REPLACE_IF_SAME"}, |
164 | | {73, "CONCURRENT_MAP_TRY_LOCK_AND_GET"}, |
165 | | {74, "CONCURRENT_MAP_ADD_TO_LIST"}, |
166 | | {75, "CONCURRENT_MAP_ADD_TO_SET"}, |
167 | | {76, "CONCURRENT_MAP_MIGRATE_RECORD"}, |
168 | | {77, "CONCURRENT_MAP_PUT_MULTI"}, |
169 | | {78, "CONCURRENT_MAP_REMOVE_MULTI"}, |
170 | | {79, "CONCURRENT_MAP_VALUE_COUNT"}, |
171 | | {80, "CONCURRENT_MAP_BACKUP_PUT"}, |
172 | | {81, "CONCURRENT_MAP_BACKUP_REMOVE"}, |
173 | | {82, "CONCURRENT_MAP_BACKUP_REMOVE_MULTI"}, |
174 | | {83, "CONCURRENT_MAP_BACKUP_LOCK"}, |
175 | | {84, "CONCURRENT_MAP_BACKUP_ADD"}, |
176 | | {85, "CONCURRENT_MAP_INVALIDATE"}, |
177 | | {86, "CONCURRENT_MAP_EVICT"}, |
178 | | {87, "CONCURRENT_MAP_FLUSH"}, |
179 | | {88, "TRANSACTION_BEGIN"}, |
180 | | {89, "TRANSACTION_COMMIT"}, |
181 | | {90, "TRANSACTION_ROLLBACK"}, |
182 | | {91, "DESTROY"}, |
183 | | {92, "GET_ID"}, |
184 | | {93, "NEW_ID"}, |
185 | | {94, "ADD_INDEX"}, |
186 | | {95, "GET_INSTANCES"}, |
187 | | {96, "GET_MEMBERS"}, |
188 | | {97, "GET_CLUSTER_TIME"}, |
189 | | {98, "CLIENT_AUTHENTICATE"}, |
190 | | {99, "CLIENT_ADD_INSTANCE_LISTENER"}, |
191 | | {100, "CLIENT_GET_PARTITIONS"}, |
192 | | {101, "BLOCKING_QUEUE_REMAINING_CAPACITY"}, |
193 | | {102, "BLOCKING_QUEUE_ENTRIES"}, |
194 | | {103, "COUNT_DOWN_LATCH_AWAIT"}, |
195 | | {104, "COUNT_DOWN_LATCH_COUNT_DOWN"}, |
196 | | {105, "COUNT_DOWN_LATCH_DESTROY"}, |
197 | | {106, "COUNT_DOWN_LATCH_GET_COUNT"}, |
198 | | {107, "COUNT_DOWN_LATCH_GET_OWNER"}, |
199 | | {108, "COUNT_DOWN_LATCH_SET_COUNT"}, |
200 | | {109, "SEMAPHORE_ATTACH_DETACH_PERMITS"}, |
201 | | {110, "SEMAPHORE_CANCEL_ACQUIRE"}, |
202 | | {111, "SEMAPHORE_DESTROY"}, |
203 | | {112, "SEMAPHORE_DRAIN_PERMITS"}, |
204 | | {113, "SEMAPHORE_GET_ATTACHED_PERMITS"}, |
205 | | {114, "SEMAPHORE_GET_AVAILABLE_PERMITS"}, |
206 | | {115, "SEMAPHORE_REDUCE_PERMITS"}, |
207 | | {116, "SEMAPHORE_RELEASE"}, |
208 | | {117, "SEMAPHORE_TRY_ACQUIRE"}, |
209 | | {118, "LOCK_LOCK"}, |
210 | | {119, "LOCK_UNLOCK"}, |
211 | | {120, "LOCK_FORCE_UNLOCK"}, |
212 | | {0 , NULL} |
213 | | }; |
214 | | static value_string_ext operationTypes_ext = VALUE_STRING_EXT_INIT(operationTypes); |
215 | | |
216 | | static const value_string responseTypes[] = { |
217 | | {2, "RESPONSE_NONE"}, |
218 | | {3, "RESPONSE_SUCCESS"}, |
219 | | {4, "RESPONSE_FAILURE"}, |
220 | | {5, "RESPONSE_REDO"}, |
221 | | {0, NULL} |
222 | | }; |
223 | | static value_string_ext responseTypes_ext = VALUE_STRING_EXT_INIT(responseTypes); |
224 | | |
225 | | |
226 | | |
227 | | |
228 | | /* Get the length of a single HAZELCAST message */ |
229 | | static unsigned get_hazelcast_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, |
230 | | int offset, void *data _U_) |
231 | 0 | { |
232 | |
|
233 | 0 | unsigned messageLength; |
234 | 0 | unsigned headerKeyLength; |
235 | 0 | unsigned headerValueLength; |
236 | |
|
237 | 0 | messageLength = tvb_get_ntohl(tvb, offset); |
238 | |
|
239 | 0 | headerKeyLength = tvb_get_ntohl(tvb, offset+4); |
240 | |
|
241 | 0 | headerValueLength = tvb_get_ntohl(tvb, offset+8); |
242 | | |
243 | | /* |
244 | | * * That length doesn't include the length of the header itself add that in. |
245 | | */ |
246 | 0 | return messageLength + headerKeyLength + headerValueLength + 13; |
247 | |
|
248 | 0 | } |
249 | | |
250 | 0 | static int dissect_hazelcast_message(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) { |
251 | |
|
252 | 0 | uint8_t version; |
253 | |
|
254 | 0 | uint8_t flags; |
255 | 0 | uint8_t operation; |
256 | |
|
257 | 0 | uint8_t lockCountFlag; |
258 | 0 | uint8_t timeoutFlag; |
259 | 0 | uint8_t ttlFlag; |
260 | 0 | uint8_t txnFlag; |
261 | 0 | uint8_t longValueFlag; |
262 | 0 | uint8_t versionFlag; |
263 | 0 | uint8_t lockAddrNullFlag; |
264 | |
|
265 | 0 | uint32_t nameLength; |
266 | 0 | uint32_t keyLength; |
267 | 0 | uint32_t valueLength; |
268 | 0 | int offset = 0; |
269 | |
|
270 | 0 | proto_tree *hcast_tree = NULL; |
271 | 0 | proto_tree *flag_tree = NULL; |
272 | |
|
273 | 0 | proto_item *tf = NULL; |
274 | | |
275 | | /* Make entries in Protocol column and Info column on summary display */ |
276 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "HAZELCAST"); |
277 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Hazelcast distributed object goodness"); |
278 | |
|
279 | 0 | if (tree) { |
280 | |
|
281 | 0 | proto_item *ti; |
282 | 0 | ti = proto_tree_add_item(tree, proto_hazelcast, tvb, 0, -1, ENC_NA); |
283 | |
|
284 | 0 | hcast_tree = proto_item_add_subtree(ti, ett_hazelcast); |
285 | 0 | } |
286 | 0 | if (tvb_captured_length_remaining(tvb, 0) < 13) { |
287 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Hazelcast too short"); |
288 | 0 | return 0; |
289 | 0 | } |
290 | | |
291 | 0 | version = tvb_get_uint8(tvb, 12); |
292 | 0 | if ( version != 6 ) { |
293 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Hazelcast unsupported version"); |
294 | 0 | return 12; |
295 | 0 | } |
296 | | |
297 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_headerLength, tvb, offset, 4, ENC_BIG_ENDIAN); |
298 | 0 | offset += 4; |
299 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_headerKeyLength, tvb, offset, 4, ENC_BIG_ENDIAN); |
300 | 0 | keyLength = tvb_get_ntohl(tvb, offset); |
301 | 0 | offset += 4; |
302 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_headerValueLength, tvb, offset, 4, ENC_BIG_ENDIAN); |
303 | 0 | valueLength = tvb_get_ntohl(tvb, offset); |
304 | 0 | offset += 4; |
305 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_headerVersion, tvb, offset, 1, ENC_BIG_ENDIAN); |
306 | 0 | offset += 1; |
307 | | |
308 | |
|
309 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_operation, tvb, offset, 1, ENC_BIG_ENDIAN); |
310 | 0 | operation = tvb_get_uint8(tvb, offset); |
311 | 0 | col_add_str(pinfo->cinfo, COL_INFO, val_to_str(operation, operationTypes, "Unknown (0x%02x)")); |
312 | 0 | offset += 1; |
313 | |
|
314 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_blockID, tvb, offset, 4, ENC_BIG_ENDIAN); |
315 | 0 | offset += 4; |
316 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_threadID, tvb, offset, 4, ENC_BIG_ENDIAN); |
317 | 0 | offset += 4; |
318 | |
|
319 | 0 | flags = tvb_get_uint8(tvb, offset); |
320 | |
|
321 | 0 | tf = proto_tree_add_item(hcast_tree, hf_hazelcast_flags, tvb, offset, 1, ENC_BIG_ENDIAN); |
322 | |
|
323 | 0 | flag_tree = proto_item_add_subtree(tf, ett_hazelcast_flags); |
324 | |
|
325 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_lockCount, tvb, offset, 1, ENC_BIG_ENDIAN); |
326 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_timeout, tvb, offset, 1, ENC_BIG_ENDIAN); |
327 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_ttl, tvb, offset, 1, ENC_BIG_ENDIAN); |
328 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_txn, tvb, offset, 1, ENC_BIG_ENDIAN); |
329 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_longValue, tvb, offset, 1, ENC_BIG_ENDIAN); |
330 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_version, tvb, offset, 1, ENC_BIG_ENDIAN); |
331 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_client, tvb, offset, 1, ENC_BIG_ENDIAN); |
332 | 0 | proto_tree_add_item(flag_tree, hf_hazelcast_flags_lockAddrNull, tvb, offset, 1, ENC_BIG_ENDIAN); |
333 | | |
334 | |
|
335 | 0 | lockCountFlag = flags & HAZELCAST_LOCKCOUNT_FLAG; |
336 | 0 | timeoutFlag = flags & HAZELCAST_TIMEOUT_FLAG; |
337 | 0 | ttlFlag = flags & HAZELCAST_TTL_FLAG; |
338 | 0 | txnFlag = flags & HAZELCAST_TXN_FLAG; |
339 | 0 | longValueFlag = flags & HAZELCAST_LONGVALUE_FLAG; |
340 | 0 | versionFlag = flags & HAZELCAST_VERSION_FLAG; |
341 | 0 | lockAddrNullFlag = flags & HAZELCAST_LOCKADDRNULL_FLAG; |
342 | |
|
343 | 0 | offset += 1; |
344 | | |
345 | |
|
346 | 0 | if ( lockCountFlag ) { |
347 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_lockCount, tvb, offset, 4, ENC_BIG_ENDIAN); |
348 | 0 | offset += 4; |
349 | 0 | } |
350 | |
|
351 | 0 | if ( timeoutFlag ) { |
352 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_timeout, tvb, offset, 8, ENC_BIG_ENDIAN); |
353 | 0 | offset += 8; |
354 | 0 | } |
355 | |
|
356 | 0 | if ( ttlFlag ) { |
357 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_ttl, tvb, offset, 8, ENC_BIG_ENDIAN); |
358 | 0 | offset += 8; |
359 | 0 | } |
360 | |
|
361 | 0 | if ( txnFlag ) { |
362 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_txnID, tvb, offset, 8, ENC_BIG_ENDIAN); |
363 | 0 | offset += 8; |
364 | 0 | } |
365 | |
|
366 | 0 | if ( longValueFlag ) { |
367 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_longValue, tvb, offset, 8, ENC_BIG_ENDIAN); |
368 | 0 | offset += 8; |
369 | 0 | } |
370 | |
|
371 | 0 | if ( versionFlag ) { |
372 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_version, tvb, offset, 8, ENC_BIG_ENDIAN); |
373 | 0 | offset += 8; |
374 | 0 | } |
375 | |
|
376 | 0 | if ( lockAddrNullFlag == 0 ) { |
377 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_lockAddrIP, tvb, offset, 4, ENC_BIG_ENDIAN); |
378 | 0 | offset += 4; |
379 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_lockAddrPort, tvb, offset, 4, ENC_BIG_ENDIAN); |
380 | 0 | offset += 4; |
381 | 0 | } |
382 | |
|
383 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_callID, tvb, offset, 8, ENC_BIG_ENDIAN); |
384 | 0 | offset += 8; |
385 | |
|
386 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_responseType, tvb, offset, 1, ENC_BIG_ENDIAN); |
387 | 0 | offset += 1; |
388 | |
|
389 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_nameLength, tvb, offset, 4, ENC_BIG_ENDIAN); |
390 | 0 | nameLength = tvb_get_ntohl(tvb, offset); |
391 | 0 | offset += 4; |
392 | |
|
393 | 0 | if ( nameLength > 0 ) { |
394 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_name, tvb, offset, nameLength, ENC_ASCII); |
395 | 0 | offset += nameLength; |
396 | 0 | } |
397 | |
|
398 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_indexCount, tvb, offset, 1, ENC_BIG_ENDIAN); |
399 | 0 | offset += 1; |
400 | |
|
401 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_keyPartitionHash, tvb, offset, 4, ENC_BIG_ENDIAN); |
402 | 0 | offset += 4; |
403 | |
|
404 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_valuePartitionHash, tvb, offset, 4, ENC_BIG_ENDIAN); |
405 | 0 | offset += 4; |
406 | |
|
407 | 0 | if ( keyLength > 0 ) { |
408 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_keys, tvb, offset, keyLength, ENC_NA); |
409 | 0 | offset += keyLength; |
410 | 0 | } |
411 | |
|
412 | 0 | if ( valueLength > 0 ) { |
413 | 0 | proto_tree_add_item(hcast_tree, hf_hazelcast_values, tvb, offset, valueLength, ENC_NA); |
414 | | /*offset += valueLength;*/ |
415 | 0 | } |
416 | |
|
417 | 0 | return tvb_captured_length(tvb); |
418 | 0 | } |
419 | | |
420 | | /* |
421 | | * Code to actually dissect the packets |
422 | | * |
423 | | * this really just works in TCP reassembly and calls the real dissector |
424 | | * |
425 | | */ |
426 | 0 | static int dissect_hazelcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) { |
427 | |
|
428 | 0 | tcp_dissect_pdus(tvb, pinfo, tree, hazelcast_desegment, 13, get_hazelcast_message_len, dissect_hazelcast_message, data); |
429 | 0 | return tvb_captured_length(tvb); |
430 | 0 | } |
431 | | |
432 | 14 | void proto_register_hazelcast(void) { |
433 | | |
434 | 14 | static hf_register_info hf[] = { |
435 | | |
436 | 14 | { &hf_hazelcast_headerLength, |
437 | 14 | { "Hazelcast hdr length", "hazelcast.hdr.length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } |
438 | 14 | }, |
439 | 14 | { &hf_hazelcast_headerKeyLength, |
440 | 14 | { "Hazelcast hdr key length", "hazelcast.hdr.keylength", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } |
441 | 14 | }, |
442 | 14 | { &hf_hazelcast_headerValueLength, |
443 | 14 | { "Hazelcast hdr value length", "hazelcast.hdr.valuelength", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } |
444 | 14 | }, |
445 | 14 | { &hf_hazelcast_headerVersion, |
446 | 14 | { "Hazelcast hdr version", "hazelcast.hdr.version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } |
447 | 14 | }, |
448 | 14 | { &hf_hazelcast_operation, |
449 | 14 | { "Hazelcast operation", "hazelcast.operation", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &operationTypes_ext, 0x0, NULL, HFILL } |
450 | 14 | }, |
451 | 14 | { &hf_hazelcast_blockID, |
452 | 14 | { "Hazelcast blockID", "hazelcast.blockID", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } |
453 | 14 | }, |
454 | 14 | { &hf_hazelcast_threadID, |
455 | 14 | { "Hazelcast threadID", "hazelcast.threadID", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } |
456 | 14 | }, |
457 | 14 | { &hf_hazelcast_flags, |
458 | 14 | { "hazelcast flags", "hazelcast.flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } |
459 | 14 | }, |
460 | 14 | { &hf_hazelcast_flags_lockCount, |
461 | 14 | { "hazelcast lockCount flag", "hazelcast.flags.lockCount", FT_BOOLEAN, 8, NULL, HAZELCAST_LOCKCOUNT_FLAG, NULL, HFILL } |
462 | 14 | }, |
463 | 14 | { &hf_hazelcast_flags_timeout, |
464 | 14 | { "hazelcast timeout flag", "hazelcast.flags.timeout", FT_BOOLEAN, 8, NULL, HAZELCAST_TIMEOUT_FLAG, NULL, HFILL } |
465 | 14 | }, |
466 | 14 | { &hf_hazelcast_flags_ttl, |
467 | 14 | { "hazelcast ttl flag", "hazelcast.flags.ttl", FT_BOOLEAN, 8, NULL, HAZELCAST_TTL_FLAG, NULL, HFILL } |
468 | 14 | }, |
469 | 14 | { &hf_hazelcast_flags_txn, |
470 | 14 | { "hazelcast txn flag", "hazelcast.flags.txn", FT_BOOLEAN, 8, NULL, HAZELCAST_TXN_FLAG, NULL, HFILL } |
471 | 14 | }, |
472 | 14 | { &hf_hazelcast_flags_longValue, |
473 | 14 | { "hazelcast longValue flag", "hazelcast.flags.longValue", FT_BOOLEAN, 8, NULL, HAZELCAST_LONGVALUE_FLAG, NULL, HFILL } |
474 | 14 | }, |
475 | 14 | { &hf_hazelcast_flags_version, |
476 | 14 | { "hazelcast version flag", "hazelcast.flags.version", FT_BOOLEAN, 8, NULL, HAZELCAST_VERSION_FLAG, NULL, HFILL } |
477 | 14 | }, |
478 | 14 | { &hf_hazelcast_flags_client, |
479 | 14 | { "hazelcast client flag", "hazelcast.flags.client", FT_BOOLEAN, 8, NULL, HAZELCAST_CLIENT_FLAG, NULL, HFILL } |
480 | 14 | }, |
481 | 14 | { &hf_hazelcast_flags_lockAddrNull, |
482 | 14 | { "hazelcast lockAddrNull flag", "hazelcast.flags.lockAddrNull", FT_BOOLEAN, 8, NULL, HAZELCAST_LOCKADDRNULL_FLAG, NULL, HFILL } |
483 | 14 | }, |
484 | 14 | { &hf_hazelcast_timeout, |
485 | 14 | { "hazelcast timeout", "hazelcast.timeout", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } |
486 | 14 | }, |
487 | 14 | { &hf_hazelcast_ttl, |
488 | 14 | { "hazelcast ttl", "hazelcast.ttl", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } |
489 | 14 | }, |
490 | 14 | { &hf_hazelcast_longValue, |
491 | 14 | { "hazelcast longValue", "hazelcast.longValue", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } |
492 | 14 | }, |
493 | 14 | { &hf_hazelcast_txnID, |
494 | 14 | { "hazelcast txnID", "hazelcast.txnID", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } |
495 | 14 | }, |
496 | 14 | { &hf_hazelcast_version, |
497 | 14 | { "hazelcast version", "hazelcast.version", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } |
498 | 14 | }, |
499 | 14 | { &hf_hazelcast_lockCount, |
500 | 14 | { "hazelcast lockCount", "hazelcast.lockCount", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } |
501 | 14 | }, |
502 | 14 | { &hf_hazelcast_lockAddrIP, |
503 | 14 | { "hazelcast lock address IP", "hazelcast.lockaddr.ip", FT_IPv4, BASE_NONE, NULL, 0x0, "lockAddrIP", HFILL } |
504 | 14 | }, |
505 | 14 | { &hf_hazelcast_lockAddrPort, |
506 | 14 | { "hazelcast lock address Port", "hazelcast.lockaddr.port", FT_UINT32, BASE_DEC, NULL, 0x0, "lockAddrPort", HFILL } |
507 | 14 | }, |
508 | 14 | { &hf_hazelcast_callID, |
509 | 14 | { "hazelcast callID", "hazelcast.callID", FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL } |
510 | 14 | }, |
511 | 14 | { &hf_hazelcast_responseType, |
512 | 14 | { "hazelcast response type", "hazelcast.responseType", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &responseTypes_ext, 0x0, NULL, HFILL } |
513 | 14 | }, |
514 | 14 | { &hf_hazelcast_nameLength, |
515 | 14 | { "hazelcast name length", "hazelcast.nameLength", FT_UINT32, BASE_DEC, NULL, 0x0, "nameLength", HFILL } |
516 | 14 | }, |
517 | 14 | { &hf_hazelcast_name, |
518 | 14 | { "hazelcast name", "hazelcast.name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } |
519 | 14 | }, |
520 | 14 | { &hf_hazelcast_indexCount, |
521 | 14 | { "hazelcast indexCount", "hazelcast.indexCount", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } |
522 | 14 | }, |
523 | 14 | { &hf_hazelcast_keyPartitionHash, |
524 | 14 | { "hazelcast keyPartitionHash", "hazelcast.keyPartitionHash", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } |
525 | 14 | }, |
526 | 14 | { &hf_hazelcast_valuePartitionHash, |
527 | 14 | { "hazelcast valuePartitionHash", "hazelcast.valuePartitionHash", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } |
528 | 14 | }, |
529 | 14 | { &hf_hazelcast_keys, |
530 | 14 | { "hazelcast keys", "hazelcast.keys", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } |
531 | 14 | }, |
532 | 14 | { &hf_hazelcast_values, |
533 | 14 | { "hazelcast values", "hazelcast.values", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } |
534 | 14 | } |
535 | | |
536 | 14 | }; |
537 | | |
538 | | /* Setup protocol subtree array */ |
539 | 14 | static int *ett[] = { |
540 | 14 | &ett_hazelcast, |
541 | 14 | &ett_hazelcast_flags |
542 | 14 | }; |
543 | | |
544 | 14 | module_t *hazelcast_module; |
545 | | |
546 | | |
547 | 14 | proto_hazelcast = proto_register_protocol ( |
548 | 14 | "Hazelcast Wire Protocol", /* name */ |
549 | 14 | "HAZELCAST", /* short name */ |
550 | 14 | "hzlcst" /* abbrev */ |
551 | 14 | ); |
552 | | |
553 | 14 | proto_register_field_array(proto_hazelcast, hf, array_length(hf)); |
554 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
555 | | |
556 | 14 | hazelcast_module = prefs_register_protocol(proto_hazelcast, NULL); |
557 | | |
558 | 14 | prefs_register_bool_preference(hazelcast_module, "desegment", |
559 | 14 | "Reassemble hazelcast messages spanning multiple TCP segments", |
560 | 14 | "Whether the hazel dissector should reassemble messages spanning multiple TCP segments." |
561 | 14 | " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", |
562 | 14 | &hazelcast_desegment); |
563 | | |
564 | 14 | hazelcast_tap = register_tap("hzlcst"); |
565 | | |
566 | 14 | hazelcast_handle = register_dissector("hzlcst", dissect_hazelcast, proto_hazelcast); |
567 | 14 | } |
568 | | |
569 | | |
570 | | void |
571 | 14 | proto_reg_handoff_hazelcast(void) { |
572 | 14 | dissector_add_uint_with_preference("tcp.port", HAZELCAST_PORT, hazelcast_handle); |
573 | 14 | } |
574 | | |
575 | | /* |
576 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
577 | | * |
578 | | * Local variables: |
579 | | * c-basic-offset: 4 |
580 | | * tab-width: 8 |
581 | | * indent-tabs-mode: nil |
582 | | * End: |
583 | | * |
584 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
585 | | * :indentSize=4:tabSize=8:noTabs=true: |
586 | | */ |
587 | | |