### Bug Summary

File: | epan/dissectors/packet-cql.c
Warning: | line 1774, column 7 Value stored to 'offset' is never read

### Annotated Source Code

Press '?' to see keyboard shortcuts

Show analyzer invocation
clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name packet-cql.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-21/lib/clang/21 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/epan -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-truncation -Wno-format-nonliteral -Wno-pointer-sign -std=gnu11 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2025-10-13-100350-3623-1 -x c /builds/wireshark/wireshark/epan/dissectors/packet-cql.c

Keyboard shortcuts:

- Use 'j/k' keys for keyboard navigation
- Use 'Shift+S' to show/hide relevant lines
- Use '?' to toggle this window

Close
Show only relevant lines Show control flow arrows

1 | /* packet-cql.c
2 | * Routines for Apache Cassandra CQL dissection
3 | * Copyright 2015, Aaron Ten Clay <aarontc@aarontc.com>
4 | *
5 | * Wireshark - Network traffic analyzer
6 | * By Gerald Combs <gerald@wireshark.org>
7 | * Copyright 1998 Gerald Combs
8 | *
9 | * SPDX-License-Identifier: GPL-2.0-or-later
10 | */
11 |
12 | /*
13 | * CQL V3 reference: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v3.spec
14 | * CQL V4 reference: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec
15 | * CQL V5 reference: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v5.spec
16 | */
17 | #include "config.h"
18 | #include <epan/conversation.h>
19 | #include <epan/packet.h>
20 | #include "packet-tcp.h"
21 | #include <epan/wmem_scopes.h>
22 | #include <epan/expert.h>
23 | #include <epan/to_str.h>
24 | #include <epan/addr_resolv.h>
25 | #ifdef HAVE_LZ41
26 | #include <lz4.h>
27 | #endif
28 | #ifdef HAVE_SNAPPY1
29 | #include <snappy-c.h>
30 | #endif
31 |
32 | #define CQL_DEFAULT_PORT9042 9042 /* Not IANA registered */
33 |
34 | /* the code can reasonably attempt to decompress buffer up to 10MB */
35 | #define MAX_UNCOMPRESSED_SIZE(10 * 1024 * 1024) (10 * 1024 * 1024)
36 |
37 | void proto_reg_handoff_cql(void);
38 | void proto_register_cql(void);
39 |
40 | static int proto_cql;
41 | /* CQL header frame fields */
42 | static int hf_cql_version;
43 | static int hf_cql_protocol_version;
44 | static int hf_cql_direction;
45 | /* CQL header frame fields */
46 | static int hf_cql_flags_bitmap;
47 | static int hf_cql_flag_compression;
48 | static int hf_cql_flag_tracing;
49 | static int hf_cql_flag_reserved3;
50 | static int hf_cql_flag_custom_payload;
51 | static int hf_cql_flag_warning;
52 | static int hf_cql_flag_reserved4;
53 | static int hf_cql_flag_beta;
54 | static int hf_cql_stream;
55 | static int hf_cql_opcode;
56 | static int hf_cql_length;
57 | static int hf_cql5_header;
58 | static int hf_cql5_compressed_length;
59 | static int hf_cql5_uncompressed_length;
60 | static int hf_cql5_self_contained;
61 | static int hf_cql5_crc24;
62 | static int hf_cql5_crc32;
63 |
64 | /* CQL data types */
65 | static int hf_cql_int;
66 | static int hf_cql_uuid;
67 | static int hf_cql_bytes;
68 |
69 | /* Batch flags */
70 | static int hf_cql_batch_flag_serial_consistency;
71 | static int hf_cql_batch_flag_default_timestamp;
72 | static int hf_cql_batch_flag_with_name_for_values;
73 | static int hf_cql_batch_flags_bitmap;
74 | static int ett_cql_batch_flags_bitmap;
75 |
76 | static int hf_cql_consistency;
77 | static int hf_cql_string_length;
78 | static int hf_cql_string_map_size;
79 | static int hf_cql_string;
80 | static int hf_cql_auth_token;
81 | static int hf_cql_value_count;
82 | static int hf_cql_short_bytes_length;
83 | static int hf_cql_bytes_length;
84 | static int hf_cql_bigint;
85 | static int hf_cql_scale;
86 | static int hf_cql_boolean;
87 | static int hf_cql_ascii;
88 | static int hf_cql_double;
89 | static int hf_cql_float;
90 | static int hf_cql_custom;
91 | static int hf_cql_null_value;
92 | static int hf_cql_tracing_uuid;
93 | static int hf_cql_port;
94 | static int hf_cql_timeuuid;
95 | static int hf_cql_varchar;
96 | static int hf_cql_varint_count8;
97 | static int hf_cql_varint_count16;
98 | static int hf_cql_varint_count32;
99 | static int hf_cql_varint_count64;
100 | static int hf_cql_raw_compressed_bytes;
101 | static int hf_cql_paging_state;
102 | static int hf_cql_page_size;
103 | static int hf_cql_timestamp;
104 | static int hf_cql_query_id;
105 | static int hf_cql_query_metadata_id;
106 | static int hf_cql_event_type;
107 | static int hf_cql_event_schema_change_type;
108 | static int hf_cql_event_schema_change_type_target;
109 | static int hf_cql_event_schema_change_keyspace;
110 | static int hf_cql_event_schema_change_object;
111 | static int hf_cql_result_timestamp;
112 | static int hf_cql_string_list_size;
113 | static int hf_cql_batch_type;
114 | static int hf_cql_batch_query_type;
115 | static int hf_cql_batch_query_size;
116 | static int hf_cql_error_code;
117 | static int hf_cql_result_kind;
118 | static int hf_cql_result_rows_data_type;
119 | static int hf_cql_error_failure_received;
120 | static int hf_cql_error_block_for;
121 | static int hf_cql_error_num_failures;
122 | static int hf_cql_error_data_present;
123 | static int hf_cql_error_write_type;
124 |
125 | static int hf_cql_query_flags_values;
126 | static int hf_cql_query_flags_skip_metadata;
127 | static int hf_cql_query_flags_page_size;
128 | static int hf_cql_query_flags_paging_state;
129 | static int hf_cql_query_flags_serial_consistency;
130 | static int hf_cql_query_flags_default_timestamp;
131 | static int hf_cql_query_flags_names_for_values;
132 |
133 | static int hf_cql_query_v5_flags_values;
134 | static int hf_cql_query_v5_flags_skip_metadata;
135 | static int hf_cql_query_v5_flags_page_size;
136 | static int hf_cql_query_v5_flags_paging_state;
137 | static int hf_cql_query_v5_flags_serial_consistency;
138 | static int hf_cql_query_v5_flags_default_timestamp;
139 | static int hf_cql_query_v5_flags_names_for_values;
140 | static int hf_cql_query_v5_flags_with_keyspace;
141 | static int hf_cql_query_v5_flags_now_in_seconds;
142 |
143 | static int hf_cql_result_rows_flags_values;
144 | static int hf_cql_result_prepared_flags_values;
145 | static int hf_cql_result_rows_flag_global_tables_spec;
146 | static int hf_cql_result_rows_flag_has_more_pages;
147 | static int hf_cql_result_rows_flag_no_metadata;
148 | static int hf_cql_result_rows_column_count;
149 | static int hf_cql_result_rows_tuple_size;
150 |
151 | static int hf_cql_result_prepared_pk_count;
152 |
153 | static int hf_cql_string_result_rows_global_table_spec_ksname;
154 | static int hf_cql_string_result_rows_global_table_spec_table_name;
155 | static int hf_cql_string_result_rows_table_name;
156 | static int hf_cql_string_result_rows_keyspace_name;
157 | static int hf_cql_string_result_rows_column_name;
158 | static int hf_cql_result_rows_row_count;
159 | static int hf_cql_string_result_rows_udt_name;
160 | static int hf_cql_string_result_rows_udt_size;
161 | static int hf_cql_string_result_rows_udt_field_name;
162 | static int hf_cql_string_result_rows_list_size;
163 | static int hf_cql_string_result_rows_map_size;
164 | static int hf_cql_string_result_rows_set_size;
165 | static int hf_cql_bytesmap_string;
166 |
167 | static int ett_cql_protocol;
168 | static int ett_cql_version;
169 | static int ett_cql_message;
170 | static int ett_cql_result_columns;
171 | static int ett_cql_results_no_metadata;
172 | static int ett_cql_result_map;
173 | static int ett_cql_result_set;
174 | static int ett_cql_result_metadata;
175 | static int ett_cql_result_rows;
176 | static int ett_cql_result_metadata_colspec;
177 | static int ett_cql_header_flags_bitmap;
178 | static int ett_cql_custom_payload;
179 |
180 | static int hf_cql_response_in;
181 | static int hf_cql_response_to;
182 | static int hf_cql_response_time;
183 |
184 | static int hf_cql_ipv4;
185 | static int hf_cql_ipv6;
186 |
187 | static int ett_cql5_header;
188 |
189 | /* desegmentation of CQL */
190 | static bool_Bool cql_desegment = true1;
191 |
192 | static expert_field ei_cql_data_not_dissected_yet;
193 | static expert_field ei_cql_unexpected_negative_value;
194 |
195 |
196 | typedef struct _cql_transaction_type {
197 | uint32_t req_frame;
198 | uint32_t rep_frame;
199 | nstime_t req_time;
200 | } cql_transaction_type;
201 |
202 | typedef enum {
203 | CQL_COMPRESSION_NONE = 0,
204 | CQL_COMPRESSION_LZ4 = 1,
205 | CQL_COMPRESSION_SNAPPY = 2,
206 | CQL_DECOMPRESSION_ATTEMPTED = 3,
207 | } cql_compression_level;
208 |
209 | typedef struct _cql_conversation_info_type {
210 | wmem_map_t* streams;
211 | uint32_t frame_start_v5_proto;
212 | cql_compression_level compression_level;
213 | uint16_t server_port;
214 | uint8_t protocol_version;
215 | } cql_conversation_type;
216 |
217 | static const value_string cql_direction_names[] = {
218 | { 0x0, "Request" },
219 | { 0x8, "Response" },
220 | { 0x0, NULL((void*)0) }
221 | };
222 |
223 | typedef enum {
224 | CQL_BATCH_FLAG_SERIAL_CONSISTENCY = 0x10,
225 | CQL_BATCH_FLAG_DEFAULT_TIMESTAMP = 0x20,
226 | CQL_BATCH_FLAG_WITH_NAME_FOR_VALUES = 0x40
227 | } cql_batch_flags;
228 |
229 | typedef enum {
230 | CQL_OPCODE_ERROR = 0x00,
231 | CQL_OPCODE_STARTUP = 0x01,
232 | CQL_OPCODE_READY = 0x02,
233 | CQL_OPCODE_AUTHENTICATE = 0x03,
234 | /* Opcode 0x04 not used in CQL */
235 | CQL_OPCODE_OPTIONS = 0x05,
236 | CQL_OPCODE_SUPPORTED = 0x06,
237 | CQL_OPCODE_QUERY = 0x07,
238 | CQL_OPCODE_RESULT = 0x08,
239 | CQL_OPCODE_PREPARE = 0x09,
240 | CQL_OPCODE_EXECUTE = 0x0A,
241 | CQL_OPCODE_REGISTER = 0x0B,
242 | CQL_OPCODE_EVENT = 0x0C,
243 | CQL_OPCODE_BATCH = 0x0D,
244 | CQL_OPCODE_AUTH_CHALLENGE = 0x0E,
245 | CQL_OPCODE_AUTH_RESPONSE = 0x0F,
246 | CQL_OPCODE_AUTH_SUCCESS = 0x10
247 | } cql_opcode_type;
248 |
249 | static const value_string cql_opcode_names[] = {
250 | { CQL_OPCODE_ERROR, "ERROR" },
251 | { CQL_OPCODE_STARTUP, "STARTUP" },
252 | { CQL_OPCODE_READY, "READY" },
253 | { CQL_OPCODE_AUTHENTICATE, "AUTHENTICATE" },
254 | { CQL_OPCODE_OPTIONS, "OPTIONS" },
255 | { CQL_OPCODE_SUPPORTED, "SUPPORTED" },
256 | { CQL_OPCODE_QUERY, "QUERY" },
257 | { CQL_OPCODE_RESULT, "RESULT" },
258 | { CQL_OPCODE_PREPARE, "PREPARE" },
259 | { CQL_OPCODE_EXECUTE, "EXECUTE" },
260 | { CQL_OPCODE_REGISTER, "REGISTER" },
261 | { CQL_OPCODE_EVENT, "EVENT" },
262 | { CQL_OPCODE_BATCH, "BATCH" },
263 | { CQL_OPCODE_AUTH_CHALLENGE, "AUTH_CHALLENGE" },
264 | { CQL_OPCODE_AUTH_RESPONSE, "AUTH_RESPONSE" },
265 | { CQL_OPCODE_AUTH_SUCCESS, "AUTH_SUCCESS" },
266 | { 0x00, NULL((void*)0) }
267 | };
268 |
269 |
270 | typedef enum {
271 | CQL_HEADER_FLAG_COMPRESSION = 0x01,
272 | CQL_HEADER_FLAG_TRACING = 0x02,
273 | CQL_HEADER_FLAG_V3_RESERVED = 0xFC,
274 | CQL_HEADER_FLAG_CUSTOM_PAYLOAD = 0x04,
275 | CQL_HEADER_FLAG_WARNING = 0x08,
276 | CQL_HEADER_FLAG_BETA = 0x10,
277 | CQL_HEADER_FLAG_V4_RESERVED = 0xF0
278 | } cql_flags;
279 |
280 | typedef enum {
281 | CQL_QUERY_FLAG_VALUES = 0x01,
282 | CQL_QUERY_FLAG_SKIP_METADATA = 0x02,
283 | CQL_QUERY_FLAG_PAGE_SIZE = 0x04,
284 | CQL_QUERY_FLAG_PAGING_STATE = 0x08,
285 | CQL_QUERY_FLAG_SERIAL_CONSISTENCY = 0x10,
286 | CQL_QUERY_FLAG_DEFAULT_TIMESTAMP = 0x20,
287 | CQL_QUERY_FLAG_VALUE_NAMES = 0x40,
288 | CQL_QUERY_FLAG_WITH_KEYSPACE = 0x80,
289 | CQL_QUERY_FLAG_NOW_IN_SECONDS = 0x100
290 | } cql_query_flags;
291 |
292 |
293 | typedef enum {
294 | CQL_RESULT_ROWS_FLAG_GLOBAL_TABLES_SPEC = 0x00000001,
295 | CQL_RESULT_ROWS_FLAG_HAS_MORE_PAGES = 0x00000002,
296 | CQL_RESULT_ROWS_FLAG_NO_METADATA = 0x00000004
297 | } cql_result_rows_flags;
298 |
299 | typedef enum {
300 | CQL_CONSISTENCY_ANY = 0x0000,
301 | CQL_CONSISTENCY_ONE = 0x0001,
302 | CQL_CONSISTENCY_TWO = 0x0002,
303 | CQL_CONSISTENCY_THREE = 0x003,
304 | CQL_CONSISTENCY_QUORUM = 0x0004,
305 | CQL_CONSISTENCY_ALL = 0x0005,
306 | CQL_CONSISTENCY_LOCAL_QUORUM = 0x0006,
307 | CQL_CONSISTENCY_EACH_QUORUM = 0x0007,
308 | CQL_CONSISTENCY_SERIAL = 0x0008,
309 | CQL_CONSISTENCY_LOCAL_SERIAL = 0x0009,
310 | CQL_CONSISTENCY_LOCAL_ONE = 0x000A
311 | } cql_consistencies;
312 |
313 | static const value_string cql_consistency_names[] = {
314 | { CQL_CONSISTENCY_ANY, "ANY" },
315 | { CQL_CONSISTENCY_ONE, "ONE" },
316 | { CQL_CONSISTENCY_TWO, "TWO" },
317 | { CQL_CONSISTENCY_THREE, "THREE" },
318 | { CQL_CONSISTENCY_QUORUM, "QUORUM" },
319 | { CQL_CONSISTENCY_ALL, "ALL" },
320 | { CQL_CONSISTENCY_LOCAL_QUORUM, "LOCAL_QUORUM" },
321 | { CQL_CONSISTENCY_EACH_QUORUM, "EACH_QUORUM" },
322 | { CQL_CONSISTENCY_SERIAL, "SERIAL" },
323 | { CQL_CONSISTENCY_LOCAL_SERIAL, "LOCAL_SERIAL" },
324 | { CQL_CONSISTENCY_LOCAL_ONE, "LOCAL_ONE" },
325 | { 0x00, NULL((void*)0) }
326 | };
327 |
328 |
329 | typedef enum {
330 | CQL_BATCH_TYPE_LOGGED = 0,
331 | CQL_BATCH_TYPE_UNLOGGED = 1,
332 | CQL_BATCH_TYPE_COUNTER = 2
333 | } cql_batch_types;
334 |
335 | static const value_string cql_batch_type_names[] = {
336 | { CQL_BATCH_TYPE_LOGGED, "LOGGED" },
337 | { CQL_BATCH_TYPE_UNLOGGED, "UNLOGGED" },
338 | { CQL_BATCH_TYPE_COUNTER, "COUNTER" },
339 | { 0x00, NULL((void*)0) }
340 | };
341 |
342 | typedef enum {
343 | CQL_BATCH_QUERY_TYPE_QUERY = 0,
344 | CQL_BATCH_QUERY_TYPE_PREPARED = 1
345 | } cql_batch_query_types;
346 |
347 | static const value_string cql_batch_query_type_names[] = {
348 | { CQL_BATCH_QUERY_TYPE_QUERY, "QUERY" },
349 | { CQL_BATCH_QUERY_TYPE_PREPARED, "PREPARED" },
350 | { 0x00, NULL((void*)0) }
351 | };
352 |
353 | typedef enum {
354 | CQL_RESULT_KIND_VOID = 0x0001,
355 | CQL_RESULT_KIND_ROWS = 0x0002,
356 | CQL_RESULT_KIND_SET_KEYSPACE = 0x0003,
357 | CQL_RESULT_KIND_PREPARED = 0x0004,
358 | CQL_RESULT_KIND_SCHEMA_CHANGE = 0x0005
359 | } cql_result_kinds;
360 |
361 | static const value_string cql_result_kind_names[] = {
362 | { CQL_RESULT_KIND_VOID, "VOID" },
363 | { CQL_RESULT_KIND_ROWS, "Rows" },
364 | { CQL_RESULT_KIND_SET_KEYSPACE, "Set Keyspace" },
365 | { CQL_RESULT_KIND_PREPARED, "Prepared" },
366 | { CQL_RESULT_KIND_SCHEMA_CHANGE, "Schema Change" },
367 | { 0x00, NULL((void*)0) }
368 | };
369 |
370 |
371 |
372 | typedef enum {
373 | CQL_RESULT_ROW_TYPE_CUSTOM = 0x0000,
374 | CQL_RESULT_ROW_TYPE_ASCII = 0x0001,
375 | CQL_RESULT_ROW_TYPE_BIGINT = 0x0002,
376 | CQL_RESULT_ROW_TYPE_BLOB = 0x0003,
377 | CQL_RESULT_ROW_TYPE_BOOLEAN = 0x0004,
378 | CQL_RESULT_ROW_TYPE_COUNTER = 0x0005,
379 | CQL_RESULT_ROW_TYPE_DECIMAL = 0x0006,
380 | CQL_RESULT_ROW_TYPE_DOUBLE = 0x0007,
381 | CQL_RESULT_ROW_TYPE_FLOAT = 0x0008,
382 | CQL_RESULT_ROW_TYPE_INT = 0x0009,
383 | CQL_RESULT_ROW_TYPE_TIMESTAMP = 0x000B,
384 | CQL_RESULT_ROW_TYPE_UUID = 0x000C,
385 | CQL_RESULT_ROW_TYPE_VARCHAR = 0x000D,
386 | CQL_RESULT_ROW_TYPE_VARINT = 0x000E,
387 | CQL_RESULT_ROW_TYPE_TIMEUUID = 0x000F,
388 | CQL_RESULT_ROW_TYPE_INET = 0x0010,
389 | CQL_RESULT_ROW_TYPE_DATE = 0x0011,
390 | CQL_RESULT_ROW_TYPE_TIME = 0x0012,
391 | CQL_RESULT_ROW_TYPE_SMALLINT = 0x0013,
392 | CQL_RESULT_ROW_TYPE_TINYINT = 0x0014,
393 | CQL_RESULT_ROW_TYPE_LIST = 0x0020,
394 | CQL_RESULT_ROW_TYPE_MAP = 0x0021,
395 | CQL_RESULT_ROW_TYPE_SET = 0x0022,
396 | CQL_RESULT_ROW_TYPE_UDT = 0x0030,
397 | CQL_RESULT_ROW_TYPE_TUPLE = 0x0031
398 | } cql_result_row_data_types;
399 |
400 | static const value_string cql_result_row_type_names[] = {
401 | { CQL_RESULT_ROW_TYPE_CUSTOM, "CUSTOM" },
402 | { CQL_RESULT_ROW_TYPE_ASCII, "ASCII" },
403 | { CQL_RESULT_ROW_TYPE_BIGINT, "BIGINT" },
404 | { CQL_RESULT_ROW_TYPE_BLOB, "BLOB" },
405 | { CQL_RESULT_ROW_TYPE_BOOLEAN, "BOOLEAN" },
406 | { CQL_RESULT_ROW_TYPE_COUNTER, "COUNTER" },
407 | { CQL_RESULT_ROW_TYPE_DECIMAL, "DECIMAL" },
408 | { CQL_RESULT_ROW_TYPE_DOUBLE, "DOUBLE" },
409 | { CQL_RESULT_ROW_TYPE_FLOAT, "FLOAT" },
410 | { CQL_RESULT_ROW_TYPE_INT, "INT" },
411 | { CQL_RESULT_ROW_TYPE_TIMESTAMP, "TIMESTAMP" },
412 | { CQL_RESULT_ROW_TYPE_UUID, "UUID" },
413 | { CQL_RESULT_ROW_TYPE_VARCHAR, "VARCHAR" },
414 | { CQL_RESULT_ROW_TYPE_VARINT, "VARINT" },
415 | { CQL_RESULT_ROW_TYPE_TIMEUUID, "TIMEUUID" },
416 | { CQL_RESULT_ROW_TYPE_INET, "INET" },
417 | { CQL_RESULT_ROW_TYPE_DATE, "DATE" },
418 | { CQL_RESULT_ROW_TYPE_TIME, "TIME" },
419 | { CQL_RESULT_ROW_TYPE_SMALLINT, "SMALLINT" },
420 | { CQL_RESULT_ROW_TYPE_TINYINT, "TINYINT" },
421 | { CQL_RESULT_ROW_TYPE_LIST, "LIST" },
422 | { CQL_RESULT_ROW_TYPE_MAP, "MAP" },
423 | { CQL_RESULT_ROW_TYPE_SET, "SET" },
424 | { CQL_RESULT_ROW_TYPE_UDT, "UDT" },
425 | { CQL_RESULT_ROW_TYPE_TUPLE, "TUPLE" },
426 | { 0x0, NULL((void*)0) }
427 | };
428 |
429 | /* From https://github.com/apache/cassandra/blob/cbf4dcb3345c7e2f42f6a897c66b6460b7acc2ca/doc/native_protocol_v4.spec#L1046 */
430 | typedef enum {
431 | CQL_ERROR_SERVER = 0x0000,
432 | CQL_ERROR_PROTOCOL = 0x000A,
433 | CQL_ERROR_AUTH = 0x0100,
434 | CQL_ERROR_UNAVAILABLE = 0x1000,
435 | CQL_ERROR_OVERLOADED = 0x1001,
436 | CQL_ERROR_BOOTSTRAPPING = 0x1002,
437 | CQL_ERROR_TRUNCATE = 0x1003,
438 | CQL_ERROR_WRITE_TIMEOUT = 0x1100,
439 | CQL_ERROR_READ_TIMEOUT = 0x1200,
440 | CQL_ERROR_READ_FAILURE = 0x1300,
441 | CQL_ERROR_FUNCTION_FAILURE = 0x1400,
442 | CQL_ERROR_WRITE_FAILURE = 0x1500,
443 | CQL_ERROR_SYNTAX = 0x2000,
444 | CQL_ERROR_UNAUTHORIEZED = 0x2100,
445 | CQL_ERROR_INVALID = 0x2200,
446 | CQL_ERROR_CONFIG = 0x2300,
447 | CQL_ERROR_ALREADY_EXISTS = 0x2400,
448 | CQL_ERROR_UNPREPARED = 0x2500
449 | } cql_error_types;
450 |
451 | static const value_string cql_error_names[] = {
452 | { CQL_ERROR_SERVER, "Server error" },
453 | { CQL_ERROR_PROTOCOL, "Protocol error" },
454 | { CQL_ERROR_AUTH, "Authentication error" },
455 | { CQL_ERROR_UNAVAILABLE, "Unavailable exception" },
456 | { CQL_ERROR_OVERLOADED, "Overloaded" },
457 | { CQL_ERROR_BOOTSTRAPPING, "Is_bootstrapping" },
458 | { CQL_ERROR_TRUNCATE, "Truncate_error" },
459 | { CQL_ERROR_WRITE_TIMEOUT, "Write_timeout" },
460 | { CQL_ERROR_READ_TIMEOUT, "Read_timeout" },
461 | { CQL_ERROR_READ_FAILURE, "Read_failure" },
462 | { CQL_ERROR_FUNCTION_FAILURE, "Function_failure" },
463 | { CQL_ERROR_WRITE_FAILURE, "Write_failure" },
464 | { CQL_ERROR_SYNTAX, "Syntax_error" },
465 | { CQL_ERROR_UNAUTHORIEZED, "Unauthorized" },
466 | { CQL_ERROR_INVALID, "Invalid" },
467 | {CQL_ERROR_CONFIG, "Config_error" },
468 | { CQL_ERROR_ALREADY_EXISTS, "Already_exists" },
469 | { CQL_ERROR_UNPREPARED, "Unprepared" },
470 | { 0x0, NULL((void*)0)}
471 | };
472 |
473 | static int
474 | dissect_cql_query_parameters(proto_tree* cql_subtree, tvbuff_t* tvb, int offset, const int execute, const uint8_t protocol_version)
475 | {
476 | int32_t bytes_length = 0;
477 | uint64_t flags = 0;
478 | uint64_t i = 0;
479 | uint32_t string_length = 0;
480 | uint32_t value_count = 0;
481 |
482 | static int * const cql_query_bitmaps[] = {
483 | &hf_cql_query_flags_values,
484 | &hf_cql_query_flags_skip_metadata,
485 | &hf_cql_query_flags_page_size,
486 | &hf_cql_query_flags_paging_state,
487 | &hf_cql_query_flags_serial_consistency,
488 | &hf_cql_query_flags_default_timestamp,
489 | &hf_cql_query_flags_names_for_values,
490 | NULL((void*)0)
491 | };
492 |
493 | static int * const cql5_query_bitmaps[] = {
494 | &hf_cql_query_v5_flags_values,
495 | &hf_cql_query_v5_flags_skip_metadata,
496 | &hf_cql_query_v5_flags_page_size,
497 | &hf_cql_query_v5_flags_paging_state,
498 | &hf_cql_query_v5_flags_serial_consistency,
499 | &hf_cql_query_v5_flags_default_timestamp,
500 | &hf_cql_query_v5_flags_names_for_values,
501 | &hf_cql_query_v5_flags_with_keyspace,
502 | &hf_cql_query_v5_flags_now_in_seconds,
503 | NULL((void*)0)
504 | };
505 |
506 | /* consistency */
507 | proto_tree_add_item(cql_subtree, hf_cql_consistency, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
508 | offset += 2;
509 |
510 | /* flags */
511 | if (protocol_version >= 5) {
512 | proto_tree_add_bitmask_list_ret_uint64(cql_subtree, tvb, offset, 4, cql5_query_bitmaps, ENC_BIG_ENDIAN0x00000000, &flags);
513 | offset += 4;
514 | } else {
515 | proto_tree_add_bitmask_list_ret_uint64(cql_subtree, tvb, offset, 1, cql_query_bitmaps, ENC_BIG_ENDIAN0x00000000, &flags);
516 | offset += 1;
517 | }
518 |
519 | if(flags & CQL_QUERY_FLAG_VALUES) {
520 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_value_count, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &value_count);
521 | offset += 2;
522 | for (i = 0; i < value_count; ++i) {
523 | if (!execute && flags & CQL_QUERY_FLAG_VALUE_NAMES) {
524 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
525 | offset += 2;
526 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
527 | offset += string_length;
528 | }
529 | proto_tree_add_item_ret_int(cql_subtree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &bytes_length);
530 | offset += 4;
531 | if (bytes_length > 0) {
532 | proto_tree_add_item(cql_subtree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA0x00000000);
533 | offset += bytes_length;
534 | }
535 | }
536 | }
537 |
538 | if (flags & CQL_QUERY_FLAG_PAGE_SIZE) {
539 | proto_tree_add_item(cql_subtree, hf_cql_page_size, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
540 | offset += 4;
541 | }
542 |
543 | if (flags & CQL_QUERY_FLAG_PAGING_STATE) {
544 | proto_tree_add_item_ret_int(cql_subtree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &bytes_length);
545 | offset += 4;
546 | if (bytes_length > 0) {
547 | proto_tree_add_item(cql_subtree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA0x00000000);
548 | offset += bytes_length;
549 | }
550 | }
551 |
552 | if (flags & CQL_QUERY_FLAG_SERIAL_CONSISTENCY) {
553 | proto_tree_add_item(cql_subtree, hf_cql_consistency, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
554 | offset += 2;
555 | }
556 |
557 | if (flags & CQL_QUERY_FLAG_DEFAULT_TIMESTAMP) {
558 | proto_tree_add_item(cql_subtree, hf_cql_timestamp, tvb, offset, 8, ENC_TIME_USECS0x00000030|ENC_BIG_ENDIAN0x00000000);
559 | offset += 8;
560 | }
561 |
562 | if (protocol_version >= 5) {
563 | if (flags & CQL_QUERY_FLAG_WITH_KEYSPACE) {
564 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
565 | offset += 2;
566 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
567 | offset += string_length;
568 | }
569 | if (flags & CQL_QUERY_FLAG_NOW_IN_SECONDS) {
570 | proto_tree_add_item(cql_subtree, hf_cql_int, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
571 | offset += 4;
572 | }
573 | }
574 | return offset;
575 | }
576 |
577 | static unsigned
578 | get_cql_pdu_len(packet_info* pinfo _U___attribute__((unused)), tvbuff_t* tvb, const int offset, void* data _U___attribute__((unused)))
579 | {
580 | /* CQL has 32-bit length at 5th byte in frame. */
581 | uint32_t length = tvb_get_ntohl(tvb, offset + 5);
582 |
583 | /* Include length of frame header. */
584 | return length + 9;
585 | }
586 |
587 | static unsigned
588 | get_cql5_comp_pdu_len(packet_info* pinfo _U___attribute__((unused)), tvbuff_t* tvb, const int offset, void* data _U___attribute__((unused)))
589 | {
590 | /* CQL v5 has 17-bit length if the frame is LZ4 compressed - at bytes 0-3, inclusive */
591 | uint32_t length = tvb_get_letoh24(tvb, offset) & 0x1FFFF;
592 |
593 | /* Include length of frame header. Non-compressed frame has a 6 bytes header, compressed - 8 bytes, + 4 for CRC32 at the end */
594 | return length + 8 + 4;
595 | }
596 |
597 | static unsigned
598 | get_cql5_non_comp_pdu_len(packet_info* pinfo _U___attribute__((unused)), tvbuff_t* tvb, const int offset, void* data _U___attribute__((unused)))
599 | {
600 | /* CQL v5 has 17-bit length at bytes 0-2 in an uncompressed frame */
601 | uint32_t length = tvb_get_letoh24(tvb, offset) & 0x1FFFF;
602 |
603 | /* Include length of frame header. Non-compressed frame has a 6 bytes header, compressed - 8 bytes, + 4 for CRC32 at the end */
604 | return length + 6 + 4;
605 | }
606 |
607 | static cql_transaction_type*
608 | cql_transaction_add_request(cql_conversation_type* conv,
609 | packet_info* pinfo,
610 | int32_t stream,
611 | int fake)
612 | {
613 | cql_transaction_type* trans;
614 | wmem_list_t* list;
615 |
616 | list = (wmem_list_t*)wmem_map_lookup(conv->streams, GINT_TO_POINTER(stream)((gpointer) (glong) (stream)));
617 | if(!list) {
618 | list = wmem_list_new(wmem_file_scope());
619 | } else {
620 | wmem_map_remove(conv->streams, GINT_TO_POINTER(stream)((gpointer) (glong) (stream)));
621 | }
622 |
623 | trans = wmem_new(wmem_file_scope(), cql_transaction_type)((cql_transaction_type*)wmem_alloc((wmem_file_scope()), sizeof (cql_transaction_type)));
624 | if (fake) {
625 | trans->req_frame = 0;
626 | } else {
627 | trans->req_frame = pinfo->fd->num;
628 | }
629 | trans->rep_frame = 0;
630 | trans->req_time = pinfo->abs_ts;
631 |
632 | wmem_list_append(list, (void *)trans);
633 | wmem_map_insert(conv->streams, GINT_TO_POINTER(stream)((gpointer) (glong) (stream)), (void*)list);
634 |
635 | return trans;
636 | }
637 |
638 | static cql_transaction_type*
639 | cql_enrich_transaction_with_response(cql_conversation_type* conv,
640 | packet_info* pinfo,
641 | int32_t stream)
642 | {
643 | cql_transaction_type* trans;
644 | wmem_list_frame_t* frame;
645 | wmem_list_t* list;
646 |
647 | list = (wmem_list_t*)wmem_map_lookup(conv->streams, GINT_TO_POINTER(stream)((gpointer) (glong) (stream)));
648 | if (!list) {
649 | return NULL((void*)0);
650 | }
651 |
652 | frame = wmem_list_tail(list);
653 | if (!frame) {
654 | return NULL((void*)0);
655 | }
656 |
657 | trans = (cql_transaction_type *)wmem_list_frame_data(frame);
658 | if (!trans) {
659 | return NULL((void*)0);
660 | }
661 |
662 | trans->rep_frame = pinfo->fd->num;
663 |
664 | return trans;
665 | }
666 |
667 | static cql_transaction_type*
668 | cql_transaction_lookup(cql_conversation_type* conv,
669 | packet_info* pinfo,
670 | int32_t stream)
671 | {
672 | wmem_list_frame_t* frame;
673 | wmem_list_t* list;
674 |
675 | list = (wmem_list_t*)wmem_map_lookup(conv->streams, GINT_TO_POINTER(stream)((gpointer) (glong) (stream)));
676 | if (!list) {
677 | return NULL((void*)0);
678 | }
679 |
680 | frame = wmem_list_head(list);
681 | if (!frame) {
682 | return NULL((void*)0);
683 | }
684 |
685 | do {
686 | cql_transaction_type* trans = NULL((void*)0);
687 | trans = (cql_transaction_type *)wmem_list_frame_data(frame);
688 | if (trans->req_frame == pinfo->fd->num || trans->rep_frame == pinfo->fd->num) {
689 | return trans;
690 | }
691 | } while ((frame = wmem_list_frame_next(frame)));
692 |
693 | return NULL((void*)0);
694 | }
695 |
696 |
697 | // NOLINTNEXTLINE(misc-no-recursion)
698 | static int parse_option(proto_tree* metadata_subtree, packet_info *pinfo, tvbuff_t* tvb, int offset)
699 | {
700 | uint32_t data_type = 0;
701 | uint32_t string_length = 0;
702 | uint32_t tuple_size = 0;
703 | uint32_t udt_size = 0;
704 | uint32_t i = 0;
705 |
706 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_result_rows_data_type, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &data_type);
707 | offset += 2;
708 | increment_dissection_depth(pinfo);
709 | switch (data_type) {
710 | case CQL_RESULT_ROW_TYPE_LIST:
711 | offset = parse_option(metadata_subtree, pinfo, tvb, offset);
712 | break;
713 | case CQL_RESULT_ROW_TYPE_MAP:
714 | offset = parse_option(metadata_subtree, pinfo, tvb, offset);
715 | offset = parse_option(metadata_subtree, pinfo, tvb, offset);
716 | break;
717 | case CQL_RESULT_ROW_TYPE_SET:
718 | offset = parse_option(metadata_subtree, pinfo, tvb, offset);
719 | break;
720 | case CQL_RESULT_ROW_TYPE_UDT:
721 | /* keyspace */
722 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
723 | offset += 2;
724 | proto_tree_add_item(metadata_subtree, hf_cql_string_result_rows_keyspace_name, tvb, offset, string_length, ENC_UTF_80x00000002);
725 | offset += string_length;
726 |
727 | /* UDT name */
728 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
729 | offset += 2;
730 | proto_tree_add_item(metadata_subtree, hf_cql_string_result_rows_udt_name, tvb, offset, string_length, ENC_UTF_80x00000002);
731 | offset += string_length;
732 |
733 | /* UDT size */
734 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_string_result_rows_udt_size, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &udt_size);
735 | offset += 2;
736 |
737 | for (i = 0; i < udt_size; i++) {
738 | /* UDT field name */
739 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
740 | offset += 2;
741 | proto_tree_add_item(metadata_subtree, hf_cql_string_result_rows_udt_field_name, tvb, offset, string_length, ENC_UTF_80x00000002);
742 | offset += string_length;
743 |
744 | /* UDT field option */
745 | offset = parse_option(metadata_subtree, pinfo, tvb, offset);
746 | }
747 | break;
748 | case CQL_RESULT_ROW_TYPE_TUPLE:
749 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_result_rows_tuple_size, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &tuple_size);
750 | offset += 2;
751 | for (i = 0; i < tuple_size; i++) {
752 | offset = parse_option(metadata_subtree, pinfo, tvb, offset);
753 | }
754 | break;
755 | default:
756 | break;
757 | }
758 | decrement_dissection_depth(pinfo);
759 |
760 | return offset;
761 | }
762 |
763 | static void add_varint_item(proto_tree *tree, tvbuff_t *tvb, const int offset, const int length)
764 | {
765 | switch (length)
766 | {
767 | case 1:
768 | proto_tree_add_item(tree, hf_cql_varint_count8, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
769 | break;
770 | case 2:
771 | proto_tree_add_item(tree, hf_cql_varint_count16, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
772 | break;
773 | case 3:
774 | proto_tree_add_item(tree, hf_cql_varint_count32, tvb, offset, 3, ENC_BIG_ENDIAN0x00000000);
775 | break;
776 | case 4:
777 | proto_tree_add_item(tree, hf_cql_varint_count32, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
778 | break;
779 | case 5:
780 | proto_tree_add_item(tree, hf_cql_varint_count64, tvb, offset, 5, ENC_BIG_ENDIAN0x00000000);
781 | break;
782 | case 6:
783 | proto_tree_add_item(tree, hf_cql_varint_count64, tvb, offset, 6, ENC_BIG_ENDIAN0x00000000);
784 | break;
785 | case 7:
786 | proto_tree_add_item(tree, hf_cql_varint_count64, tvb, offset, 7, ENC_BIG_ENDIAN0x00000000);
787 | break;
788 | case 8:
789 | proto_tree_add_item(tree, hf_cql_varint_count64, tvb, offset, 8, ENC_BIG_ENDIAN0x00000000);
790 | break;
791 | }
792 | }
793 |
794 | static void add_cql_uuid(proto_tree* tree, const int hf_uuid, tvbuff_t* tvb, const int offset)
795 | {
796 | e_guid_t guid;
797 | int i;
798 |
799 | guid.data1 = tvb_get_letohl(tvb, offset+12);
800 | guid.data2 = tvb_get_letohl(tvb, offset+10);
801 | guid.data3 = tvb_get_letohl(tvb, offset+8);
802 |
803 | for (i = 0; i < 8; i++)
804 | {
805 | guid.data4[i] = tvb_get_uint8(tvb, offset+(7-i));
806 | }
807 |
808 | proto_tree_add_guid(tree, hf_uuid, tvb, offset, 16, &guid);
809 | }
810 |
811 |
812 | // NOLINTNEXTLINE(misc-no-recursion)
813 | static int parse_value(proto_tree* columns_subtree, packet_info *pinfo, tvbuff_t* tvb, int* offset_metadata, int offset)
814 | {
815 | uint32_t data_type = 0;
816 | uint32_t string_length = 0;
817 | int32_t bytes_length = 0;
818 | uint32_t tuple_size = 0;
819 | int32_t list_size = 0;
820 | int32_t map_size = 0;
821 | int32_t set_size = 0;
822 | uint32_t udt_size = 0;
823 | proto_item *item;
824 | proto_item *sub_item;
825 | uint32_t i = 0;
826 | int32_t j = 0;
827 | int offset_metadata_backup = 0;
828 | uint32_t addr4;
829 | ws_in6_addr addr6;
830 | uint32_t port_number;
831 | proto_tree* map_subtree;
832 | proto_tree* set_subtree;
833 |
834 | proto_tree_add_item_ret_int(columns_subtree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &bytes_length);
835 | offset += 4;
836 |
837 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_result_rows_data_type, tvb, *offset_metadata, 2, ENC_BIG_ENDIAN0x00000000, &data_type);
838 | proto_item_set_hidden(item);
839 | *offset_metadata += 2;
840 |
841 | if (bytes_length == -1) { // value is NULL, but need to skip metadata offsets
842 | proto_tree_add_item(columns_subtree, hf_cql_null_value, tvb, offset, 0, ENC_NA0x00000000);
843 | if (data_type == CQL_RESULT_ROW_TYPE_MAP) {
844 | *offset_metadata += 4; /* skip the type fields of *both* key and value in the map in the metadata */
845 | } else if (data_type == CQL_RESULT_ROW_TYPE_SET) {
846 | *offset_metadata += 2; /* skip the type field of the elements in the set in the metadata */
847 | }
848 | return offset;
849 | }
850 |
851 | increment_dissection_depth(pinfo);
852 | switch (data_type) {
853 | case CQL_RESULT_ROW_TYPE_CUSTOM:
854 | proto_tree_add_item(columns_subtree, hf_cql_custom, tvb, offset, bytes_length, ENC_UTF_80x00000002);
855 | offset += bytes_length;
856 | break;
857 | case CQL_RESULT_ROW_TYPE_ASCII:
858 | proto_tree_add_item(columns_subtree, hf_cql_ascii, tvb, offset, bytes_length, ENC_ASCII0x00000000);
859 | offset += bytes_length;
860 | break;
861 | case CQL_RESULT_ROW_TYPE_BIGINT:
862 | proto_tree_add_item(columns_subtree, hf_cql_bigint, tvb, offset, 8, ENC_BIG_ENDIAN0x00000000);
863 | offset += 8;
864 | break;
865 | case CQL_RESULT_ROW_TYPE_BLOB:
866 | proto_tree_add_item(columns_subtree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA0x00000000);
867 | offset += bytes_length;
868 | break;
869 | case CQL_RESULT_ROW_TYPE_BOOLEAN:
870 | proto_tree_add_boolean(columns_subtree, hf_cql_boolean, tvb, offset, 1, true1);
871 | offset += 1;
872 | break;
873 | case CQL_RESULT_ROW_TYPE_COUNTER:
874 | break;
875 | case CQL_RESULT_ROW_TYPE_DECIMAL:
876 | proto_tree_add_item(columns_subtree, hf_cql_scale, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
877 | offset += 4;
878 | add_varint_item(columns_subtree, tvb, offset, bytes_length - 4);
879 | offset += bytes_length - 4;
880 | break;
881 | case CQL_RESULT_ROW_TYPE_DOUBLE:
882 | proto_tree_add_item(columns_subtree, hf_cql_double, tvb, offset, 8, ENC_BIG_ENDIAN0x00000000);
883 | offset += 8;
884 | break;
885 | case CQL_RESULT_ROW_TYPE_FLOAT:
886 | proto_tree_add_item(columns_subtree, hf_cql_float, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
887 | offset += 4;
888 | break;
889 | case CQL_RESULT_ROW_TYPE_INT:
890 | proto_tree_add_item(columns_subtree, hf_cql_int, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
891 | offset += 4;
892 | break;
893 | case CQL_RESULT_ROW_TYPE_TIMESTAMP:
894 | proto_tree_add_item(columns_subtree, hf_cql_result_timestamp, tvb, offset, 8, ENC_BIG_ENDIAN0x00000000);
895 | offset += 8;
896 | break;
897 | case CQL_RESULT_ROW_TYPE_UUID:
898 | add_cql_uuid(columns_subtree, hf_cql_uuid, tvb, offset);
899 | offset += 16;
900 | break;
901 | case CQL_RESULT_ROW_TYPE_VARCHAR:
902 | proto_tree_add_item(columns_subtree, hf_cql_varchar, tvb, offset, bytes_length, ENC_ASCII0x00000000);
903 | offset += bytes_length;
904 | break;
905 | case CQL_RESULT_ROW_TYPE_VARINT:
906 | add_varint_item(columns_subtree, tvb, offset, bytes_length);
907 | offset += bytes_length;
908 | break;
909 | case CQL_RESULT_ROW_TYPE_TIMEUUID:
910 | add_cql_uuid(columns_subtree, hf_cql_timeuuid, tvb, offset);
911 | offset += 16;
912 | break;
913 | case CQL_RESULT_ROW_TYPE_INET:
914 | switch (bytes_length) {
915 | case 4:
916 | case 8:
917 | addr4 = tvb_get_ipv4(tvb, offset);
918 | proto_tree_add_ipv4_format_value(columns_subtree, hf_cql_ipv4, tvb, offset, 4, addr4, "%s", get_hostname(addr4));
919 | offset += 4;
920 | break;
921 | case 16:
922 | case 20:
923 | tvb_get_ipv6(tvb, offset, &addr6);
924 | proto_tree_add_ipv6_format_value(columns_subtree, hf_cql_ipv6, tvb, offset, 16, &addr6, "%s", get_hostname6(&addr6));
925 | offset += 16;
926 | break;
927 | default:
928 | break;
929 | }
930 | /* port number is optional */
931 | if (bytes_length == 16 || bytes_length == 20) {
932 | sub_item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_port, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &port_number);
933 | proto_item_append_text(sub_item, " (%u)", port_number);
934 | offset += 4;
935 | }
936 | break;
937 | case CQL_RESULT_ROW_TYPE_DATE:
938 | break;
939 | case CQL_RESULT_ROW_TYPE_TIME:
940 | break;
941 | case CQL_RESULT_ROW_TYPE_SMALLINT:
942 | break;
943 | case CQL_RESULT_ROW_TYPE_TINYINT:
944 | break;
945 | case CQL_RESULT_ROW_TYPE_LIST:
946 | item = proto_tree_add_item_ret_int(columns_subtree, hf_cql_string_result_rows_list_size, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &list_size);
947 | if (list_size < 0) {
948 | expert_add_info(pinfo, item, &ei_cql_unexpected_negative_value);
949 | decrement_dissection_depth(pinfo);
950 | return tvb_reported_length(tvb);
951 | }
952 | offset += 4;
953 | offset_metadata_backup = *offset_metadata;
954 | for (j = 0; j < list_size; j++) {
955 | *offset_metadata = offset_metadata_backup;
956 | offset = parse_value(columns_subtree, pinfo, tvb, offset_metadata, offset);
957 | }
958 | break;
959 | case CQL_RESULT_ROW_TYPE_MAP:
960 | map_subtree = proto_tree_add_subtree(columns_subtree, tvb, offset, 0, ett_cql_result_map, NULL((void*)0), "Map");
961 | item = proto_tree_add_item_ret_int(map_subtree, hf_cql_string_result_rows_map_size, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &map_size);
962 | offset += 4;
963 | proto_item_append_text(map_subtree, " with %" PRId32"d" " element(s)", map_size);
964 | if (map_size < 0) {
965 | expert_add_info(pinfo, item, &ei_cql_unexpected_negative_value);
966 | decrement_dissection_depth(pinfo);
967 | return tvb_reported_length(tvb);
968 | } else if (map_size == 0) {
969 | *offset_metadata += 4; /* skip the type fields of *both* key and value in the map in the metadata */
970 | } else {
971 | offset_metadata_backup = *offset_metadata;
972 | for (j = 0; j < map_size; j++) {
973 | *offset_metadata = offset_metadata_backup;
974 | offset = parse_value(map_subtree, pinfo, tvb, offset_metadata, offset);
975 | offset = parse_value(map_subtree, pinfo, tvb, offset_metadata, offset);
976 | }
977 | }
978 | break;
979 | case CQL_RESULT_ROW_TYPE_SET:
980 | set_subtree = proto_tree_add_subtree(columns_subtree, tvb, offset, 0, ett_cql_result_set, NULL((void*)0), "Set");
981 | item = proto_tree_add_item_ret_int(set_subtree, hf_cql_string_result_rows_set_size, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &set_size);
982 | offset += 4;
983 | if (set_size < 0) {
984 | expert_add_info(pinfo, item, &ei_cql_unexpected_negative_value);
985 | decrement_dissection_depth(pinfo);
986 | return tvb_reported_length(tvb);
987 | } else if (set_size == 0) {
988 | *offset_metadata += 2; /* skip the type field of the elements in the set in the metadata */
989 | } else {
990 | offset_metadata_backup = *offset_metadata;
991 | for (j = 0; j < set_size; j++) {
992 | *offset_metadata = offset_metadata_backup;
993 | offset = parse_value(set_subtree, pinfo, tvb, offset_metadata, offset);
994 | }
995 | }
996 | break;
997 | case CQL_RESULT_ROW_TYPE_UDT:
998 | /* keyspace */
999 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, *offset_metadata, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1000 | proto_item_set_hidden(item);
1001 | *offset_metadata += 2;
1002 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_keyspace_name, tvb, *offset_metadata, string_length, ENC_UTF_80x00000002);
1003 | proto_item_set_hidden(item);
1004 | *offset_metadata += string_length;
1005 |
1006 | /* UDT name */
1007 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, *offset_metadata, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1008 | proto_item_set_hidden(item);
1009 | *offset_metadata += 2;
1010 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_udt_name, tvb, *offset_metadata, string_length, ENC_UTF_80x00000002);
1011 | proto_item_set_hidden(item);
1012 | *offset_metadata += string_length;
1013 |
1014 | /* UDT size */
1015 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_result_rows_udt_size, tvb, *offset_metadata, 2, ENC_BIG_ENDIAN0x00000000, &udt_size);
1016 | proto_item_set_hidden(item);
1017 | *offset_metadata += 2;
1018 |
1019 | for (i = 0; i < udt_size; i++) {
1020 | /* UDT field name */
1021 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, *offset_metadata, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1022 | proto_item_set_hidden(item);
1023 | *offset_metadata += 2;
1024 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_udt_field_name, tvb, *offset_metadata, string_length, ENC_UTF_80x00000002);
1025 | proto_item_set_hidden(item);
1026 | *offset_metadata += string_length;
1027 |
1028 | /* UDT field option */
1029 | offset = parse_value(columns_subtree, pinfo, tvb, offset_metadata, offset);
1030 | }
1031 | break;
1032 | case CQL_RESULT_ROW_TYPE_TUPLE:
1033 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_result_rows_tuple_size, tvb, *offset_metadata, 2, ENC_BIG_ENDIAN0x00000000, &tuple_size);
1034 | proto_item_set_hidden(item);
1035 | *offset_metadata += 2;
1036 | for (i = 0; i < tuple_size; i++) {
1037 | offset = parse_value(columns_subtree, pinfo, tvb, offset_metadata, offset);
1038 | }
1039 | break;
1040 | default:
1041 | break;
1042 | }
1043 | decrement_dissection_depth(pinfo);
1044 |
1045 | return offset;
1046 | }
1047 |
1048 | static int parse_result_metadata_more_pages(proto_tree* tree, tvbuff_t* tvb, int offset, const uint32_t flags)
1049 | {
1050 | int32_t bytes_length = 0;
1051 |
1052 | if (flags & CQL_RESULT_ROWS_FLAG_HAS_MORE_PAGES) {
1053 | /* show paging state */
1054 | proto_tree_add_item_ret_int(tree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &bytes_length);
1055 | offset += 4;
1056 | if (bytes_length > 0) {
1057 | proto_tree_add_item(tree, hf_cql_paging_state, tvb, offset, bytes_length, ENC_NA0x00000000);
1058 | offset += bytes_length;
1059 | }
1060 | }
1061 |
1062 | return offset;
1063 | }
1064 |
1065 | static int parse_result_metadata(proto_tree* tree, packet_info *pinfo, tvbuff_t* tvb,
1066 | int offset, const uint32_t flags, const int result_rows_columns_count)
1067 | {
1068 | proto_tree* col_spec_subtree = NULL((void*)0);
1069 | uint32_t string_length = 0;
1070 | int j;
1071 |
1072 | if (flags & CQL_RESULT_ROWS_FLAG_NO_METADATA) {
1073 | /* There will be no col_spec elements. */
1074 | return offset;
1075 | }
1076 |
1077 | if ((flags & (CQL_RESULT_ROWS_FLAG_GLOBAL_TABLES_SPEC | CQL_RESULT_ROWS_FLAG_NO_METADATA)) == CQL_RESULT_ROWS_FLAG_GLOBAL_TABLES_SPEC) {
1078 | proto_tree_add_item_ret_uint(tree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1079 | offset += 2;
1080 | proto_tree_add_item(tree, hf_cql_string_result_rows_global_table_spec_ksname, tvb, offset, string_length, ENC_UTF_80x00000002);
1081 | offset += string_length;
1082 |
1083 | proto_tree_add_item_ret_uint(tree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1084 | offset += 2;
1085 | proto_tree_add_item(tree, hf_cql_string_result_rows_global_table_spec_table_name, tvb, offset, string_length, ENC_UTF_80x00000002);
1086 | offset += string_length;
1087 | }
1088 |
1089 | for (j = 0; j < result_rows_columns_count; ++j) {
1090 | col_spec_subtree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_cql_result_metadata_colspec, NULL((void*)0), "Column");
1091 | proto_item_append_text(col_spec_subtree, " # %" PRId32"d" " specification", j + 1);
1092 | if (!(flags & CQL_RESULT_ROWS_FLAG_GLOBAL_TABLES_SPEC)) {
1093 | /* ksname and tablename */
1094 | proto_tree_add_item_ret_uint(col_spec_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1095 | offset += 2;
1096 | proto_tree_add_item(col_spec_subtree, hf_cql_string_result_rows_keyspace_name, tvb, offset, string_length, ENC_UTF_80x00000002);
1097 | offset += string_length;
1098 | proto_tree_add_item_ret_uint(col_spec_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1099 | offset += 2;
1100 | proto_tree_add_item(col_spec_subtree, hf_cql_string_result_rows_table_name, tvb, offset, string_length, ENC_UTF_80x00000002);
1101 | offset += string_length;
1102 | }
1103 |
1104 | /* column name */
1105 | proto_tree_add_item_ret_uint(col_spec_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1106 | offset += 2;
1107 | proto_tree_add_item(col_spec_subtree, hf_cql_string_result_rows_column_name, tvb, offset, string_length, ENC_UTF_80x00000002);
1108 | offset += string_length;
1109 |
1110 | /* type "option" */
1111 | offset = parse_option(col_spec_subtree, pinfo, tvb, offset);
1112 | }
1113 |
1114 | return offset;
1115 | }
1116 |
1117 |
1118 | static int parse_result_schema_change(proto_tree* subtree, packet_info *pinfo, tvbuff_t* tvb,
1119 | int offset)
1120 | {
1121 | uint32_t short_bytes_length = 0;
1122 | const uint8_t* string_event_type_target = NULL((void*)0);
1123 |
1124 | proto_tree_add_item_ret_uint(subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1125 | offset += 2;
1126 | proto_tree_add_item(subtree, hf_cql_event_schema_change_type, tvb, offset, short_bytes_length, ENC_UTF_80x00000002);
1127 | offset += short_bytes_length;
1128 | proto_tree_add_item_ret_uint(subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1129 | offset += 2;
1130 | proto_tree_add_item_ret_string(subtree, hf_cql_event_schema_change_type_target, tvb, offset, short_bytes_length, ENC_UTF_80x00000002, pinfo->pool, &string_event_type_target);
1131 | offset += short_bytes_length;
1132 | /* all targets have the keyspace as the first parameter*/
1133 | proto_tree_add_item_ret_uint(subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1134 | offset += 2;
1135 | proto_tree_add_item(subtree, hf_cql_event_schema_change_keyspace, tvb, offset, short_bytes_length, ENC_UTF_80x00000002);
1136 | offset += short_bytes_length;
1137 | if ((strcmp(string_event_type_target, "TABLE") == 0) || (strcmp(string_event_type_target, "TYPE") == 0)) {
1138 | proto_tree_add_item_ret_uint(subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1139 | offset += 2;
1140 | proto_tree_add_item(subtree, hf_cql_event_schema_change_object, tvb, offset, short_bytes_length, ENC_UTF_80x00000002);
1141 | } else {
1142 | /* TODO: handle "FUNCTION" or "AGGREGATE" targets:
1143 | - [string] the function/aggregate name
1144 | - [string list] one string for each argument type (as CQL type)
1145 | */
1146 | }
1147 |
1148 | return offset;
1149 | }
1150 |
1151 |
1152 | static int parse_row(proto_tree* columns_subtree, packet_info *pinfo, tvbuff_t* tvb,
1153 | int offset_metadata, int offset, const int result_rows_columns_count, const uint32_t flags)
1154 | {
1155 | int string_length;
1156 | int shadow_offset;
1157 | proto_item *item;
1158 | int j;
1159 |
1160 | shadow_offset = offset_metadata;
1161 | for (j = 0; j < result_rows_columns_count; ++j) {
1162 | if (!(flags & CQL_RESULT_ROWS_FLAG_GLOBAL_TABLES_SPEC)) {
1163 | /* ksname and tablename */
1164 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, shadow_offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1165 | proto_item_set_hidden(item);
1166 | shadow_offset += 2;
1167 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_keyspace_name, tvb, shadow_offset, string_length, ENC_UTF_80x00000002);
1168 | proto_item_set_hidden(item);
1169 | shadow_offset += string_length;
1170 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, shadow_offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1171 | proto_item_set_hidden(item);
1172 | shadow_offset += 2;
1173 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_table_name, tvb, shadow_offset, string_length, ENC_UTF_80x00000002);
1174 | proto_item_set_hidden(item);
1175 | shadow_offset += string_length;
1176 | } else { /* global table spec flag is on: ksname and tablename are NOT repeated for each column */
1177 | if (j == 0) { /* only for the 1st column, dissect the global ksname and tablename */
1178 | int ks_offset = offset_metadata;
1179 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, ks_offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1180 | proto_item_set_hidden(item);
1181 | ks_offset += 2;
1182 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_keyspace_name, tvb, ks_offset, string_length, ENC_UTF_80x00000002);
1183 | proto_item_set_hidden(item);
1184 | ks_offset += string_length;
1185 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, ks_offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1186 | proto_item_set_hidden(item);
1187 | ks_offset += 2;
1188 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_table_name, tvb, ks_offset, string_length, ENC_UTF_80x00000002);
1189 | proto_item_set_hidden(item);
1190 | ks_offset += string_length;
1191 | if (shadow_offset == offset_metadata) { /* if it's the 1st time we parsed the global ksname and tablename, now shadow_offset should skip them */
1192 | shadow_offset = ks_offset;
1193 | }
1194 | }
1195 | }
1196 |
1197 | /* column name */
1198 | item = proto_tree_add_item_ret_uint(columns_subtree, hf_cql_string_length, tvb, shadow_offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1199 | proto_item_set_hidden(item);
1200 | shadow_offset += 2;
1201 | item = proto_tree_add_item(columns_subtree, hf_cql_string_result_rows_column_name, tvb, shadow_offset, string_length, ENC_UTF_80x00000002);
1202 | proto_item_set_hidden(item);
1203 | shadow_offset += string_length;
1204 |
1205 | offset = parse_value(columns_subtree, pinfo, tvb, &shadow_offset, offset);
1206 | }
1207 |
1208 | return offset;
1209 | }
1210 |
1211 | #define MAX_PAYLOAD_LENGTH(128 * 1024 - 1) (128 * 1024 - 1) // 128K -1
1212 |
1213 | static int
1214 | dissect_cql_tcp_pdu(tvbuff_t* raw_tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused)));
1215 |
1216 | static int
1217 | dissect_cql5_uncomp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused)))
1218 | {
1219 | proto_item* ti;
1220 | proto_tree* cql_tree;
1221 | proto_tree* header_tree;
1222 | uint32_t offset = 0;
1223 | uint32_t length;
1224 | bool_Bool isSelfContained;
1225 | uint64_t header_data = tvb_get_letoh64(tvb, offset);
1226 | tvbuff_t *payload_tvb = NULL((void*)0);
1227 |
1228 | header_data &= 0xFFFFFFFFFF; // mask to 40 bits
1229 | length = header_data & MAX_PAYLOAD_LENGTH(128 * 1024 - 1);
1230 | isSelfContained = (header_data >> 17) & 1; // Self-contained flag at bit 17
1231 |
1232 | uint32_t payload_offset = offset + 6; // Skip the 6-byte header + CRC24 to get to payload
1233 |
1234 | ti = proto_tree_add_item(tree, proto_cql, tvb, offset, length + 6 + 4, ENC_NA0x00000000);
1235 | cql_tree = proto_item_add_subtree(ti, ett_cql_protocol);
1236 |
1237 | ti = proto_tree_add_item(cql_tree, hf_cql5_header, tvb, offset, 6, ENC_NA0x00000000);
1238 | header_tree = proto_item_add_subtree(ti, ett_cql5_header);
1239 |
1240 | proto_tree_add_uint(header_tree, hf_cql5_compressed_length, tvb, offset, 3, length);
1241 | proto_tree_add_boolean(header_tree, hf_cql5_self_contained, tvb, offset + 2, 1, isSelfContained);
1242 | proto_tree_add_item(header_tree, hf_cql5_crc24, tvb, offset + 3, 3, ENC_LITTLE_ENDIAN0x80000000);
1243 |
1244 | payload_tvb = tvb_new_subset_length(tvb, payload_offset, length);
1245 | tcp_dissect_pdus(payload_tvb, pinfo, cql_tree, cql_desegment, 9 /* bytes to determine length of PDU */, get_cql_pdu_len, dissect_cql_tcp_pdu, data);
1246 | proto_tree_add_item(tree, hf_cql5_crc32, tvb, length + 6, 4, ENC_LITTLE_ENDIAN0x80000000);
1247 | return length + 6 + 4; // length + header + crc32
1248 | }
1249 |
1250 | static int
1251 | dissect_cql5_comp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused)))
1252 | {
1253 | proto_item* ti;
1254 | proto_tree* cql_tree;
1255 | proto_tree* header_tree;
1256 | uint32_t offset = 0;
1257 | uint32_t length, uncomp_length;
1258 | bool_Bool isSelfContained;
1259 | uint64_t header_data = tvb_get_letoh64(tvb, offset);
1260 |
1261 | header_data &= 0xFFFFFFFFFF; // mask to 40 bits
1262 | length = header_data & MAX_PAYLOAD_LENGTH(128 * 1024 - 1);
1263 | uncomp_length = (header_data >> 17) & MAX_PAYLOAD_LENGTH(128 * 1024 - 1);
1264 | isSelfContained = (header_data >> 34) & 1; // Self-contained flag at bit 34
1265 |
1266 | // Try to determine if this is actually compressed by attempting LZ4 decompression
1267 | uint32_t payload_offset = offset + 8; // Skip the 8-byte header + CRC24 to get to payload
1268 | tvbuff_t *decompressed_tvb = NULL((void*)0);
1269 |
1270 | if (uncomp_length == 0) {
1271 | // Per CQL v5 spec: uncomp_length=0 means payload is uncompressed (optimization when compression doesn't help)
1272 | // actual_uncomp_length is already initialized to length
1273 | } else {
1274 | #ifdef HAVE_LZ41
1275 | if (uncomp_length <= MAX_UNCOMPRESSED_SIZE(10 * 1024 * 1024) && length > 0) {
1276 | if (tvb_captured_length_remaining(tvb, payload_offset) >= (int)length) {
1277 | unsigned char *decompressed_buffer = (unsigned char*)wmem_alloc(pinfo->pool, uncomp_length);
1278 | int ret = LZ4_decompress_safe(
1279 | (const char*)tvb_get_ptr(tvb, payload_offset, length),
1280 | (char*)decompressed_buffer,
1281 | length,
1282 | uncomp_length
1283 | );
1284 |
1285 | if (ret == (int)uncomp_length) {
1286 | // Create a new TVB with the decompressed data
1287 | decompressed_tvb = tvb_new_child_real_data(tvb, decompressed_buffer, uncomp_length, uncomp_length);
1288 | add_new_data_source(pinfo, decompressed_tvb, "LZ4 Decompressed Data");
1289 | } else {
1290 | // Decompression failed, free the buffer
1291 | wmem_free(pinfo->pool, decompressed_buffer);
1292 | }
1293 | }
1294 | }
1295 | #endif
1296 | }
1297 |
1298 | // Use the appropriate TVB for further processing
1299 | tvbuff_t *payload_tvb = NULL((void*)0);
1300 |
1301 | if (decompressed_tvb) {
1302 | payload_tvb = decompressed_tvb;
1303 | } else {
1304 | payload_tvb = tvb_new_subset_length(tvb, payload_offset, length);
1305 | }
1306 |
1307 | ti = proto_tree_add_item(tree, proto_cql, tvb, offset, length + 8 + 4, ENC_NA0x00000000);
1308 | cql_tree = proto_item_add_subtree(ti, ett_cql_protocol);
1309 |
1310 | ti = proto_tree_add_item(cql_tree, hf_cql5_header, tvb, offset, 5, ENC_NA0x00000000);
1311 | header_tree = proto_item_add_subtree(ti, ett_cql5_header);
1312 |
1313 | proto_tree_add_uint(header_tree, hf_cql5_compressed_length, tvb, offset, 3, length);
1314 | proto_tree_add_uint(header_tree, hf_cql5_uncompressed_length, tvb, offset + 2, 3, uncomp_length);
1315 | proto_tree_add_boolean(header_tree, hf_cql5_self_contained, tvb, offset + 3, 1, isSelfContained);
1316 | proto_tree_add_item(header_tree, hf_cql5_crc24, tvb, offset + 5, 3, ENC_LITTLE_ENDIAN0x80000000);
1317 |
1318 | tcp_dissect_pdus(payload_tvb, pinfo, cql_tree, cql_desegment, 9 /* bytes to determine length of PDU */, get_cql_pdu_len, dissect_cql_tcp_pdu, data);
1319 | proto_tree_add_item(tree, hf_cql5_crc32, tvb, length + 8, 4, ENC_LITTLE_ENDIAN0x80000000);
1320 | return length + 8 + 4; // compressed length + header + crc32
1321 |
1322 | }
1323 |
1324 | static int
1325 | dissect_cql_tcp_pdu(tvbuff_t* raw_tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused)))
1326 | {
1327 | proto_item* ti;
1328 | tvbuff_t* tvb = NULL((void*)0);
1329 | proto_tree* cql_tree;
1330 | proto_tree* version_tree;
1331 | proto_tree* cql_subtree = NULL((void*)0);
1332 | proto_tree* cust_payload_tree = NULL((void*)0);
1333 | proto_tree* rows_subtree = NULL((void*)0);
1334 | proto_tree* columns_subtree = NULL((void*)0);
1335 | proto_tree* single_column_subtree = NULL((void*)0);
1336 | proto_tree* metadata_subtree = NULL((void*)0);
1337 | proto_tree* prepared_metadata_subtree = NULL((void*)0);
1338 |
1339 | int offset = 0;
1340 | int offset_row_metadata = 0;
1341 | uint8_t flags = 0;
1342 | uint8_t first_byte = 0;
1343 | uint8_t server_to_client = 0;
1344 | uint8_t opcode = 0;
1345 | uint32_t message_length = 0;
1346 | uint32_t map_size = 0;
1347 | uint64_t i = 0;
1348 | uint32_t string_length = 0;
1349 | int32_t stream = 0;
1350 | uint32_t batch_size = 0;
1351 | uint32_t batch_query_type = 0;
1352 | uint32_t result_kind = 0;
1353 | uint32_t result_rows_flags = 0;
1354 | int32_t result_rows_columns_count = 0;
1355 | int32_t result_prepared_flags = 0;
1356 | int32_t result_prepared_pk_count = 0;
1357 | int64_t j = 0;
1358 | int64_t k = 0;
1359 | uint32_t short_bytes_length = 0;
1360 | int32_t bytes_length = 0;
1361 | int32_t result_rows_row_count = 0;
1362 |
1363 | conversation_t* conversation;
1364 | cql_conversation_type* cql_conv;
1365 | cql_transaction_type* cql_trans = NULL((void*)0);
1366 | cql_compression_level compression_level = CQL_COMPRESSION_NONE;
1367 |
1368 | static int * const cql_batch_flags_bitmaps[] = {
1369 | &hf_cql_batch_flag_serial_consistency,
1370 | &hf_cql_batch_flag_default_timestamp,
1371 | &hf_cql_batch_flag_with_name_for_values,
1372 | NULL((void*)0)
1373 | };
1374 |
1375 | static int * const cql_header_bitmaps_v3[] = {
1376 | &hf_cql_flag_compression,
1377 | &hf_cql_flag_tracing,
1378 | &hf_cql_flag_reserved3,
1379 | NULL((void*)0)
1380 | };
1381 |
1382 | static int * const cql_header_bitmaps_v4[] = {
1383 | &hf_cql_flag_compression,
1384 | &hf_cql_flag_tracing,
1385 | &hf_cql_flag_custom_payload,
1386 | &hf_cql_flag_warning,
1387 | &hf_cql_flag_reserved4,
1388 | NULL((void*)0)
1389 | };
1390 |
1391 | static int * const cql_header_bitmaps_v5[] = {
1392 | &hf_cql_flag_compression, /* deprecated in v5*/
1393 | &hf_cql_flag_tracing,
1394 | &hf_cql_flag_custom_payload,
1395 | &hf_cql_flag_warning,
1396 | &hf_cql_flag_beta,
1397 | NULL((void*)0)
1398 | };
1399 |
1400 | const uint8_t* string_event_type = NULL((void*)0);
1401 |
1402 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "CQL");
1403 | col_clear(pinfo->cinfo, COL_INFO);
1404 |
1405 | first_byte = tvb_get_uint8(raw_tvb, 0);
1406 | server_to_client = first_byte & (uint8_t)0x80;
1407 | opcode = tvb_get_uint8(raw_tvb, 4);
1408 |
1409 | conversation = find_or_create_conversation(pinfo);
1410 | cql_conv = (cql_conversation_type*) conversation_get_proto_data(conversation, proto_cql);
1411 | if(!cql_conv) {
1412 | cql_conv = wmem_new(wmem_file_scope(), cql_conversation_type)((cql_conversation_type*)wmem_alloc((wmem_file_scope()), sizeof (cql_conversation_type)));
1413 | cql_conv->streams = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
1414 | cql_conv->frame_start_v5_proto = 0;
1415 | cql_conv->server_port = pinfo->destport;
1416 | cql_conv->protocol_version = (first_byte & 0x7F);
1417 | cql_conv->compression_level = CQL_COMPRESSION_NONE;
1418 | conversation_add_proto_data(conversation, proto_cql, cql_conv);
1419 | }
1420 |
1421 | col_add_fstr(pinfo->cinfo, COL_INFO, "v%d %s Type %s",
1422 | cql_conv->protocol_version,
1423 | server_to_client == 0 ? "C->S" : "S->C",
1424 | val_to_str(pinfo->pool, opcode, cql_opcode_names, "Unknown (0x%02x)")
1425 | );
1426 |
1427 | ti = proto_tree_add_item(tree, proto_cql, raw_tvb, 0, -1, ENC_NA0x00000000);
1428 | cql_tree = proto_item_add_subtree(ti, ett_cql_protocol);
1429 |
1430 | ti = proto_tree_add_item(cql_tree, hf_cql_version, raw_tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1431 | version_tree = proto_item_add_subtree(ti, ett_cql_version);
1432 | proto_tree_add_item(version_tree, hf_cql_protocol_version, raw_tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1433 | proto_tree_add_item(version_tree, hf_cql_direction, raw_tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1434 | offset += 1;
1435 | switch(cql_conv->protocol_version){
1436 | case 3:
1437 | proto_tree_add_bitmask(cql_tree, raw_tvb, offset, hf_cql_flags_bitmap, ett_cql_header_flags_bitmap, cql_header_bitmaps_v3, ENC_BIG_ENDIAN0x00000000);
1438 | break;
1439 | case 4:
1440 | proto_tree_add_bitmask(cql_tree, raw_tvb, offset, hf_cql_flags_bitmap, ett_cql_header_flags_bitmap, cql_header_bitmaps_v4, ENC_BIG_ENDIAN0x00000000);
1441 | break;
1442 | case 5:
1443 | proto_tree_add_bitmask(cql_tree, raw_tvb, offset, hf_cql_flags_bitmap, ett_cql_header_flags_bitmap, cql_header_bitmaps_v5, ENC_BIG_ENDIAN0x00000000);
1444 | break;
1445 | default:
1446 | proto_tree_add_item(cql_tree, hf_cql_flags_bitmap, raw_tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1447 | break;
1448 | }
1449 | flags = tvb_get_uint8(raw_tvb, offset);
1450 | offset += 1;
1451 | proto_tree_add_item_ret_int(cql_tree, hf_cql_stream, raw_tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &stream);
1452 | offset += 2;
1453 | proto_tree_add_item(cql_tree, hf_cql_opcode, raw_tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1454 | offset += 1;
1455 | proto_tree_add_item_ret_uint(cql_tree, hf_cql_length, raw_tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &message_length);
1456 | offset += 4;
1457 |
1458 | /* Track the request/response. */
1459 | if (!pinfo->fd->visited) {
1460 | if (server_to_client == 0) {
1461 | /* This is a request, add it to this stream tracking */
1462 | cql_trans = cql_transaction_add_request(cql_conv, pinfo, stream, 0);
1463 | } else {
1464 | /* This is a response, bind the response with the latest request */
1465 | cql_trans = cql_enrich_transaction_with_response(cql_conv, pinfo, stream);
1466 | }
1467 | } else {
1468 | /* Search for any packet having this packed id as request or response */
1469 | cql_trans = cql_transaction_lookup(cql_conv, pinfo, stream);
1470 | }
1471 |
1472 | if (!cql_trans) {
1473 | /* Add a fake request to this stream tracking */
1474 | cql_trans = cql_transaction_add_request(cql_conv, pinfo, stream, 1);
1475 | }
1476 |
1477 | /* Add state tracking to tree */
1478 | if (server_to_client == 0 && cql_trans->rep_frame) {
1479 | /* request */
1480 | ti = proto_tree_add_uint(cql_tree, hf_cql_response_in, raw_tvb, 0, 0, cql_trans->rep_frame);
1481 | proto_item_set_generated(ti);
1482 | }
1483 | if (server_to_client && cql_trans->req_frame) {
1484 | /* reply */
1485 | nstime_t ns;
1486 |
1487 | ti = proto_tree_add_uint(cql_tree, hf_cql_response_to, raw_tvb, 0, 0, cql_trans->req_frame);
1488 | proto_item_set_generated(ti);
1489 | nstime_delta(&ns, &pinfo->abs_ts, &cql_trans->req_time);
1490 | ti = proto_tree_add_time(cql_tree, hf_cql_response_time, raw_tvb, 0, 0, &ns);
1491 | proto_item_set_generated(ti);
1492 | }
1493 |
1494 | /* We cannot rely on compression negotiation in the STARTUP message because the
1495 | * capture can be done at a random time hence missing the negotiation.
1496 | * So we will first try to decompress LZ4 then snappy
1497 | */
1498 | if (flags & CQL_HEADER_FLAG_COMPRESSION && cql_conv->protocol_version < 5) {
1499 | compression_level = CQL_DECOMPRESSION_ATTEMPTED;
1500 | #ifdef HAVE_LZ41
1501 | if (tvb_captured_length_remaining(raw_tvb, offset) > 4) {
1502 | /* Set ret == 0 to make it fail in case decompression is skipped
1503 | * due to orig_size being too big
1504 | */
1505 | uint32_t ret = 0, orig_size = tvb_get_ntohl(raw_tvb, offset);
1506 | unsigned char *decompressed_buffer = NULL((void*)0);
1507 | offset += 4;
1508 |
1509 | /* if the decompressed size is reasonably small try to decompress data */
1510 | if (orig_size <= MAX_UNCOMPRESSED_SIZE(10 * 1024 * 1024)) {
1511 | decompressed_buffer = (unsigned char*)wmem_alloc(pinfo->pool, orig_size);
1512 | ret = LZ4_decompress_safe(tvb_get_ptr(raw_tvb, offset, -1),
1513 | decompressed_buffer,
1514 | tvb_captured_length_remaining(raw_tvb, offset),
1515 | orig_size);
1516 | }
1517 | /* Decompression attempt failed: rewind offset */
1518 | if (ret != orig_size) {
1519 | wmem_free(pinfo->pool, decompressed_buffer);
1520 | offset -= 4;
1521 | } else {
1522 | /* Now re-setup the tvb buffer to have the new data */
1523 | tvb = tvb_new_child_real_data(raw_tvb, decompressed_buffer, orig_size, orig_size);
1524 | add_new_data_source(pinfo, tvb, "LZ4 Decompressed Data");
1525 | /* mark the decompression as successful */
1526 | compression_level = CQL_COMPRESSION_LZ4;
1527 | message_length= orig_size;
1528 | }
1529 | }
1530 | #endif
1531 | #ifdef HAVE_SNAPPY1
1532 | if (compression_level == CQL_DECOMPRESSION_ATTEMPTED) {
1533 | unsigned char *decompressed_buffer = NULL((void*)0);
1534 | size_t orig_size = 0;
1535 | snappy_status ret;
1536 |
1537 | /* get the raw data length */
1538 | ret = snappy_uncompressed_length(tvb_get_ptr(raw_tvb, offset, -1),
1539 | tvb_captured_length_remaining(raw_tvb, offset),
1540 | &orig_size);
1541 | /* if we get the length and it's reasonably short to allocate a buffer for it
1542 | * proceed to try decompressing the data
1543 | */
1544 | if (ret == SNAPPY_OK && orig_size <= MAX_UNCOMPRESSED_SIZE(10 * 1024 * 1024)) {
1545 | decompressed_buffer = (unsigned char*)wmem_alloc(pinfo->pool, orig_size);
1546 |
1547 | ret = snappy_uncompress(tvb_get_ptr(raw_tvb, offset, -1),
1548 | tvb_captured_length_remaining(raw_tvb, offset),
1549 | decompressed_buffer,
1550 | &orig_size);
1551 | } else {
1552 | /* else mark the input as invalid in order to skip the rest of the
1553 | * procedure
1554 | */
1555 | ret = SNAPPY_INVALID_INPUT;
1556 | }
1557 | /* if the decompression succeeded build the new tvb */
1558 | if (ret == SNAPPY_OK) {
1559 | tvb = tvb_new_child_real_data(raw_tvb, decompressed_buffer, (uint32_t)orig_size, (uint32_t)orig_size);
1560 | add_new_data_source(pinfo, tvb, "Snappy Decompressed Data");
1561 | compression_level = CQL_COMPRESSION_SNAPPY;
1562 | message_length = (uint32_t)orig_size;
1563 | } else {
1564 | wmem_free(pinfo->pool, decompressed_buffer);
1565 | }
1566 | }
1567 | #endif
1568 | }
1569 | if (compression_level == CQL_COMPRESSION_NONE) {
1570 | /* In case of decompression failure or uncompressed packet */
1571 | tvb = tvb_new_subset_remaining(raw_tvb, offset);
1572 | } else if (compression_level == CQL_DECOMPRESSION_ATTEMPTED) {
1573 | proto_tree_add_item(cql_tree, hf_cql_raw_compressed_bytes, raw_tvb, offset,
1574 | tvb_captured_length_remaining(raw_tvb, offset), ENC_NA0x00000000);
1575 | return tvb_captured_length(raw_tvb);
1576 | }
1577 | offset = 0;
1578 |
1579 |
1580 | /* Dissect the operation. */
1581 | if (server_to_client == 0) {
1582 | switch (opcode) {
1583 | case CQL_OPCODE_STARTUP:
1584 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message STARTUP");
1585 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_map_size, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &map_size);
1586 | offset += 2;
1587 | const uint8_t *key_string = NULL((void*)0);
1588 | const uint8_t*val_string = NULL((void*)0);
1589 | for(i = 0; i < map_size; ++i) {
1590 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1591 | offset += 2;
1592 | if (string_length == (sizeof("COMPRESSION") - 1)) { /* 'COMPRESSION' = 11 bytes, but there could be other keys with the same length! */
1593 | proto_tree_add_item_ret_string(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002, pinfo->pool, &key_string);
1594 | } else
1595 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1596 | offset += string_length;
1597 |
1598 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1599 | offset += 2;
1600 |
1601 | if (string_length == (sizeof("lz4") - 1) && key_string && strncmp((const char*)key_string, "COMPRESSION", sizeof("COMPRESSION") - 1) == 0) {
1602 | proto_tree_add_item_ret_string(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002, pinfo->pool, &val_string);
1603 | /* remember the compression for future packets, needed for v5 follow-up conversation */
1604 | if (val_string && strncmp((const char*)val_string, "lz4", sizeof("lz4") - 1) == 0) {
1605 | cql_conv->compression_level = CQL_COMPRESSION_LZ4;
1606 | }
1607 | } else
1608 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1609 | offset += string_length;
1610 | }
1611 | break;
1612 |
1613 | case CQL_OPCODE_AUTH_RESPONSE:
1614 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message AUTH_RESPONSE");
1615 |
1616 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &string_length);
1617 | offset += 4;
1618 | if (string_length > 0) {
1619 | proto_tree_add_item(cql_subtree, hf_cql_auth_token, tvb, offset, string_length, ENC_NA0x00000000);
1620 | }
1621 | break;
1622 |
1623 | case CQL_OPCODE_OPTIONS:
1624 | /* body should be empty */
1625 | break;
1626 |
1627 | case CQL_OPCODE_QUERY:
1628 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Query");
1629 |
1630 | /* Query */
1631 | const uint8_t *query_string;
1632 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &string_length);
1633 | offset += 4;
1634 | proto_tree_add_item_ret_string(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002, pinfo->pool, &query_string);
1635 | col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", query_string);
1636 | offset += string_length;
1637 |
1638 | /* Query parameters */
1639 | dissect_cql_query_parameters(cql_subtree, tvb, offset, 0, cql_conv->protocol_version);
1640 |
1641 | break;
1642 |
1643 |
1644 | case CQL_OPCODE_PREPARE:
1645 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message PREPARE");
1646 |
1647 | /* TODO: Link for later use by EXECUTE? */
1648 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &string_length);
1649 | offset += 4;
1650 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1651 | break;
1652 |
1653 |
1654 | case CQL_OPCODE_EXECUTE:
1655 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message EXECUTE");
1656 |
1657 | /* TODO: link to original PREPARE? */
1658 |
1659 | /* Query ID */
1660 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1661 | offset += 2;
1662 | proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, short_bytes_length, ENC_NA0x00000000);
1663 | offset += short_bytes_length;
1664 |
1665 | /* Query parameters */
1666 | dissect_cql_query_parameters(cql_subtree, tvb, offset, 1, cql_conv->protocol_version);
1667 | break;
1668 |
1669 |
1670 | case CQL_OPCODE_BATCH:
1671 | /* TODO NOT DONE */
1672 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message BATCH");
1673 |
1674 | proto_tree_add_item(cql_subtree, hf_cql_batch_type, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1675 | offset += 1;
1676 |
1677 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_batch_query_size, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &batch_size);
1678 | offset += 2;
1679 |
1680 | for (i = 0; i < batch_size; ++i) {
1681 | uint32_t value_count = 0;
1682 |
1683 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_batch_query_type, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000, &batch_query_type);
1684 | batch_query_type = tvb_get_uint8(tvb, offset);
1685 | offset += 1;
1686 | if (batch_query_type == 0) {
1687 | /* Query */
1688 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &string_length);
1689 | offset += 4;
1690 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1691 | offset += string_length;
1692 | } else if (batch_query_type == 1) {
1693 | uint32_t query_id_bytes_length;
1694 |
1695 | /* Query ID */
1696 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &query_id_bytes_length);
1697 | offset += 2;
1698 | proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, query_id_bytes_length, ENC_NA0x00000000);
1699 | offset += query_id_bytes_length;
1700 | }
1701 |
1702 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_value_count, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &value_count);
1703 | offset += 2;
1704 | for (k = 0; k < value_count; ++k) {
1705 | int32_t batch_bytes_length = 0;
1706 | proto_tree_add_item_ret_int(cql_subtree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &batch_bytes_length);
1707 | offset += 4;
1708 | if (batch_bytes_length > 0) {
1709 | proto_tree_add_item(cql_subtree, hf_cql_bytes, tvb, offset, batch_bytes_length, ENC_NA0x00000000);
1710 | offset += batch_bytes_length;
1711 | }
1712 | /* TODO - handle both -1 and -2 batch_bytes_length values:
1713 | -1 no byte should follow and the value represented is `null`.
1714 | -2 no byte should follow and the value represented is `not set` not resulting in any change to the existing value.
1715 | < -2 is an invalid value and results in an error. */
1716 | }
1717 | }
1718 | /* consistency */
1719 | proto_tree_add_item(cql_subtree, hf_cql_consistency, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
1720 | offset += 2;
1721 | proto_tree_add_bitmask(cql_subtree, tvb, offset, hf_cql_batch_flags_bitmap, ett_cql_batch_flags_bitmap, cql_batch_flags_bitmaps, ENC_BIG_ENDIAN0x00000000);
1722 | break;
1723 |
1724 | case CQL_OPCODE_REGISTER:
1725 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message REGISTER");
1726 |
1727 | /* string list */
1728 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_list_size, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &map_size);
1729 | offset += 2;
1730 | for(i = 0; i < map_size; ++i) {
1731 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1732 | offset += 2;
1733 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1734 | offset += string_length;
1735 | }
1736 |
1737 | break;
1738 |
1739 | default:
1740 | proto_tree_add_expert(cql_tree, pinfo, &ei_cql_data_not_dissected_yet, tvb, 0, message_length);
1741 | break;
1742 | }
1743 | } else {
1744 | if (flags & CQL_HEADER_FLAG_TRACING) {
1745 | add_cql_uuid(cql_tree, hf_cql_tracing_uuid, tvb, offset);
1746 | offset += 16;
1747 | }
1748 | switch (opcode) {
1749 | case CQL_OPCODE_ERROR:
1750 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message ERROR");
1751 | uint32_t error_code;
1752 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_error_code, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &error_code);
1753 | col_append_fstr(pinfo->cinfo, COL_INFO, ": %s (0x%x)", val_to_str_const(error_code, cql_error_names, "Unknown error code"), error_code);
1754 | offset += 4;
1755 |
1756 | /* string */
1757 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1758 | offset += 2;
1759 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1760 | offset += string_length;
1761 |
1762 | if (error_code == CQL_ERROR_WRITE_TIMEOUT || error_code == CQL_ERROR_READ_TIMEOUT || error_code == CQL_ERROR_READ_FAILURE || error_code == CQL_ERROR_WRITE_FAILURE) {
1763 | proto_tree_add_item(cql_subtree, hf_cql_consistency, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
1764 | offset += 2;
1765 | proto_tree_add_item(cql_subtree, hf_cql_error_failure_received, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1766 | offset += 4;
1767 | proto_tree_add_item(cql_subtree, hf_cql_error_block_for, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1768 | offset += 4;
1769 |
1770 | if (error_code == CQL_ERROR_WRITE_TIMEOUT) {
1771 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1772 | offset += 2;
1773 | proto_tree_add_item(cql_subtree, hf_cql_error_write_type, tvb, offset, string_length, ENC_UTF_80x00000002);
1774 | offset += string_length;
| Value stored to 'offset' is never read
1775 | } else if (error_code == CQL_ERROR_READ_TIMEOUT) {
1776 | proto_tree_add_item(cql_subtree, hf_cql_error_data_present, tvb, offset, 1, ENC_NA0x00000000);
1777 | offset += 1;
1778 | } else if (error_code == CQL_ERROR_READ_FAILURE) {
1779 | /* FIXME - in protocol v5, there's a reason_map here instead of num failures as in previous protocols*/
1780 | proto_tree_add_item(cql_subtree, hf_cql_error_num_failures, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1781 | offset += 4;
1782 | proto_tree_add_item(cql_subtree, hf_cql_error_data_present, tvb, offset, 1, ENC_NA0x00000000);
1783 | offset += 1;
1784 | } else if (error_code == CQL_ERROR_WRITE_FAILURE) {
1785 | /* FIXME - in protocol v5, there's a reason_map here instead of num failures as in previous protocols*/
1786 | proto_tree_add_item(cql_subtree, hf_cql_error_num_failures, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1787 | offset += 4;
1788 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1789 | offset += 2;
1790 | proto_tree_add_item(cql_subtree, hf_cql_error_write_type, tvb, offset, string_length, ENC_UTF_80x00000002);
1791 | offset += string_length;
1792 | }
1793 | }
1794 | break;
1795 |
1796 |
1797 | case CQL_OPCODE_AUTHENTICATE:
1798 | cql_conv->frame_start_v5_proto = pinfo->num; /* remember the frame number where we got past initial negotiation */
1799 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message AUTHENTICATE");
1800 |
1801 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1802 | offset += 2;
1803 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1804 | break;
1805 |
1806 |
1807 | case CQL_OPCODE_SUPPORTED:
1808 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message SUPPORTED");
1809 | uint32_t multimap_count, value_count;
1810 |
1811 | /* string multimap */
1812 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_value_count, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &multimap_count);
1813 | offset += 2;
1814 | for (k = 0; k < multimap_count; ++k) {
1815 | /* key - string */
1816 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1817 | offset += 2;
1818 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1819 | offset += string_length;
1820 |
1821 | /* value - string list */
1822 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_list_size, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &value_count);
1823 | offset += 2;
1824 | for(i = 0; i < value_count; ++i) {
1825 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1826 | offset += 2;
1827 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1828 | offset += string_length;
1829 | }
1830 | }
1831 | break;
1832 |
1833 |
1834 | case CQL_OPCODE_RESULT:
1835 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message RESULT");
1836 |
1837 | if (flags & CQL_HEADER_FLAG_CUSTOM_PAYLOAD) {
1838 | uint32_t bytesmap_count;
1839 | cust_payload_tree = proto_tree_add_subtree(cql_subtree, tvb, offset, 0, ett_cql_custom_payload, NULL((void*)0), "Custom Payload");
1840 | proto_tree_add_item_ret_uint(cust_payload_tree, hf_cql_value_count, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &bytesmap_count);
1841 | offset += 2;
1842 | for(k = 0; k < bytesmap_count; ++k) {
1843 | proto_tree_add_item_ret_uint(cust_payload_tree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1844 | offset += 2;
1845 | proto_tree_add_item(cust_payload_tree, hf_cql_bytesmap_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1846 | offset += string_length;
1847 | if (bytes_length > 0) {
1848 | proto_tree_add_item(cust_payload_tree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA0x00000000);
1849 | offset += bytes_length;
1850 | }
1851 | }
1852 | return offset;
1853 | }
1854 |
1855 | proto_tree_add_item_ret_int(cql_subtree, hf_cql_result_kind, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_kind);
1856 | col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", val_to_str_const(result_kind, cql_result_kind_names, "Unknown kind"));
1857 | offset += 4;
1858 |
1859 | switch (result_kind) {
1860 | case CQL_RESULT_KIND_VOID:
1861 | /* Nothing */
1862 | break;
1863 |
1864 | case CQL_RESULT_KIND_ROWS:
1865 | metadata_subtree = proto_tree_add_subtree(cql_subtree, tvb, offset, 0, ett_cql_result_metadata, &ti, "Rows Result Metadata");
1866 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_result_rows_flags_values, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_rows_flags);
1867 | proto_tree_add_item(metadata_subtree, hf_cql_result_rows_flag_global_tables_spec, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1868 | proto_tree_add_item(metadata_subtree, hf_cql_result_rows_flag_has_more_pages, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1869 | proto_tree_add_item(metadata_subtree, hf_cql_result_rows_flag_no_metadata, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1870 | offset += 4;
1871 |
1872 | ti = proto_tree_add_item_ret_int(metadata_subtree, hf_cql_result_rows_column_count, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_rows_columns_count);
1873 | if (result_rows_columns_count < 0) {
1874 | expert_add_info(pinfo, ti, &ei_cql_unexpected_negative_value);
1875 | return tvb_reported_length(tvb);
1876 | }
1877 | offset += 4;
1878 |
1879 | offset = parse_result_metadata_more_pages(metadata_subtree, tvb, offset, result_rows_flags);
1880 |
1881 | offset_row_metadata = offset;
1882 | offset = parse_result_metadata(metadata_subtree, pinfo, tvb, offset, result_rows_flags, result_rows_columns_count);
1883 | if (offset == offset_row_metadata) {
1884 | /* there was no col spec, no row metadata available */
1885 | offset_row_metadata = 0;
1886 | }
1887 |
1888 | rows_subtree = proto_tree_add_subtree(cql_subtree, tvb, offset, 0, ett_cql_result_rows, &ti, "Rows");
1889 | ti = proto_tree_add_item_ret_int(rows_subtree, hf_cql_result_rows_row_count, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_rows_row_count);
1890 | if (result_rows_row_count < 0) {
1891 | expert_add_info(pinfo, ti, &ei_cql_unexpected_negative_value);
1892 | return tvb_reported_length(tvb);
1893 | }
1894 | col_append_fstr(pinfo->cinfo, COL_INFO, " (%d rows)", result_rows_row_count);
1895 | offset += 4;
1896 |
1897 | if (result_rows_columns_count) {
1898 | for (j = 0; j < result_rows_row_count; ++j) {
1899 | columns_subtree = proto_tree_add_subtree(rows_subtree, tvb, offset, 0, ett_cql_result_columns, &ti, "Data (columns)");
1900 | proto_item_append_text(columns_subtree, " for row # %" PRId64"l" "d", j + 1);
1901 |
1902 | if (offset_row_metadata) {
1903 | offset = parse_row(columns_subtree, pinfo, tvb, offset_row_metadata, offset, result_rows_columns_count, result_rows_flags);
1904 | } else {
1905 | for (k = 0; k < result_rows_columns_count; ++k) {
1906 | proto_tree_add_item_ret_int(columns_subtree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &bytes_length);
1907 | offset += 4;
1908 | if (bytes_length >= 0) { /* do not display if there's no column data. If there is NULL or not set - do display it */
1909 | single_column_subtree = proto_tree_add_subtree(columns_subtree, tvb, offset, bytes_length > 0 ? bytes_length : 0, ett_cql_results_no_metadata, &ti, "Column data");
1910 | }
1911 | if (bytes_length > 0) {
1912 | proto_item_append_text(single_column_subtree, " for column # %" PRId64"l" "d", k + 1);
1913 | proto_tree_add_item(single_column_subtree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA0x00000000);
1914 | offset += bytes_length;
1915 | } else if (bytes_length == -1) {
1916 | proto_item_append_text(single_column_subtree, " is NULL for column # %" PRId64"l" "d", k + 1);
1917 | } else if (bytes_length == -2) {
1918 | proto_item_append_text(single_column_subtree, " is not set for column # %" PRId64"l" "d", k + 1);
1919 | } else if (bytes_length == 0) {
1920 | proto_item_append_text(single_column_subtree, " is empty for column # %" PRId64"l" "d", k + 1);
1921 | } else {
1922 | expert_add_info(pinfo, ti, &ei_cql_unexpected_negative_value);
1923 | return tvb_reported_length(tvb);
1924 | }
1925 | }
1926 | }
1927 | }
1928 | }
1929 |
1930 | break;
1931 |
1932 | case CQL_RESULT_KIND_SET_KEYSPACE:
1933 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &string_length);
1934 | offset += 2;
1935 | proto_tree_add_item(cql_subtree, hf_cql_string, tvb, offset, string_length, ENC_UTF_80x00000002);
1936 | break;
1937 |
1938 |
1939 | case CQL_RESULT_KIND_PREPARED:
1940 | /* <id><metadata><result_metadata> or <id><metadata_id><result_metadata> for protocol version 5*/
1941 |
1942 | /* Query ID */
1943 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1944 | offset += 2;
1945 | proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, short_bytes_length, ENC_NA0x00000000);
1946 | offset += short_bytes_length;
1947 |
1948 | if (cql_conv->protocol_version >= 5) {
1949 | /* Metadata ID */
1950 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
1951 | offset += 2;
1952 | proto_tree_add_item(cql_subtree, hf_cql_query_metadata_id, tvb, offset, short_bytes_length, ENC_NA0x00000000);
1953 | offset += short_bytes_length;
1954 | }
1955 |
1956 | /* metadata: <flags><columns_count><pk_count>[<pk_index_1>...<pk_index_n>][<global_table_spec>?<col_spec_1>...<col_spec_n>] */
1957 | prepared_metadata_subtree = proto_tree_add_subtree(cql_subtree, tvb, offset, 0, ett_cql_result_metadata, &ti, "Prepared Metadata");
1958 | proto_tree_add_item_ret_uint(prepared_metadata_subtree, hf_cql_result_prepared_flags_values, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_prepared_flags);
1959 | proto_tree_add_item(prepared_metadata_subtree, hf_cql_result_rows_flag_global_tables_spec, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1960 | offset += 4;
1961 | proto_tree_add_item_ret_int(prepared_metadata_subtree, hf_cql_result_rows_column_count, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_rows_columns_count);
1962 | if (result_rows_columns_count < 0) {
1963 | expert_add_info(pinfo, ti, &ei_cql_unexpected_negative_value);
1964 | return tvb_reported_length(tvb);
1965 | }
1966 | offset += 4;
1967 |
1968 | proto_tree_add_item_ret_int(prepared_metadata_subtree, hf_cql_result_prepared_pk_count, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_prepared_pk_count);
1969 | if (result_prepared_pk_count < 0) {
1970 | expert_add_info(pinfo, ti, &ei_cql_unexpected_negative_value);
1971 | return tvb_reported_length(tvb);
1972 | }
1973 | offset += 4;
1974 |
1975 | /* TODO: skipping all pk_index elements for now*/
1976 | offset += (2 * result_prepared_pk_count);
1977 |
1978 | offset = parse_result_metadata(prepared_metadata_subtree, pinfo, tvb, offset, result_prepared_flags, result_rows_columns_count);
1979 |
1980 | /* <result_metadata> is identical to rows result metadata */
1981 | metadata_subtree = proto_tree_add_subtree(cql_subtree, tvb, offset, 0, ett_cql_result_metadata, &ti, "Prepared Result Metadata");
1982 | proto_tree_add_item_ret_uint(metadata_subtree, hf_cql_result_rows_flags_values, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_rows_flags);
1983 | proto_tree_add_item(metadata_subtree, hf_cql_result_rows_flag_global_tables_spec, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1984 | proto_tree_add_item(metadata_subtree, hf_cql_result_rows_flag_has_more_pages, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1985 | proto_tree_add_item(metadata_subtree, hf_cql_result_rows_flag_no_metadata, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1986 | offset += 4;
1987 |
1988 | ti = proto_tree_add_item_ret_int(metadata_subtree, hf_cql_result_rows_column_count, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &result_rows_columns_count);
1989 | if (result_rows_columns_count < 0) {
1990 | expert_add_info(pinfo, ti, &ei_cql_unexpected_negative_value);
1991 | return tvb_reported_length(tvb);
1992 | }
1993 | offset += 4;
1994 |
1995 | offset = parse_result_metadata_more_pages(metadata_subtree, tvb, offset, result_rows_flags);
1996 |
1997 | parse_result_metadata(metadata_subtree, pinfo, tvb, offset, result_rows_flags, result_rows_columns_count);
1998 |
1999 | break;
2000 | case CQL_RESULT_KIND_SCHEMA_CHANGE:
2001 | /*offset = */parse_result_schema_change(cql_subtree, pinfo, tvb, offset);
2002 | break;
2003 |
2004 | default:
2005 | proto_tree_add_expert(cql_subtree, pinfo, &ei_cql_data_not_dissected_yet, tvb, 0, message_length);
2006 | break;
2007 | }
2008 |
2009 | break;
2010 |
2011 |
2012 | case CQL_OPCODE_EVENT:
2013 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message EVENT");
2014 |
2015 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000, &short_bytes_length);
2016 | offset += 2;
2017 |
2018 | proto_tree_add_item_ret_string(cql_subtree, hf_cql_event_type, tvb, offset, short_bytes_length, ENC_UTF_80x00000002, pinfo->pool, &string_event_type);
2019 | offset += short_bytes_length;
2020 | proto_item_append_text(cql_subtree, " (type: %s)", string_event_type);
2021 |
2022 | if (strcmp(string_event_type, "SCHEMA_CHANGE") == 0) {
2023 | /*offset = */parse_result_schema_change(cql_subtree, pinfo, tvb, offset);
2024 | } else {
2025 | /* TODO: handle "TOPOLOGY_CHANGE" and "STATUS_CHANGE" event types as well*/
2026 | }
2027 | break;
2028 |
2029 |
2030 | case CQL_OPCODE_AUTH_CHALLENGE:
2031 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message AUTH_CHALLENGE");
2032 |
2033 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &string_length);
2034 | offset += 4;
2035 | proto_tree_add_item(cql_subtree, hf_cql_auth_token, tvb, offset, string_length, ENC_NA0x00000000);
2036 | break;
2037 |
2038 |
2039 | case CQL_OPCODE_AUTH_SUCCESS:
2040 | cql_subtree = proto_tree_add_subtree(cql_tree, tvb, offset, message_length, ett_cql_message, &ti, "Message AUTH_SUCCESS");
2041 |
2042 | proto_tree_add_item_ret_uint(cql_subtree, hf_cql_string_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000, &string_length);
2043 | offset += 4;
2044 | if (string_length > 0) {
2045 | proto_tree_add_item(cql_subtree, hf_cql_auth_token, tvb, offset, string_length, ENC_NA0x00000000);
2046 | }
2047 | break;
2048 |
2049 | case CQL_OPCODE_READY:
2050 | cql_conv->frame_start_v5_proto = pinfo->num; /* remember the frame number where we got past initial negotiation */
2051 | /* body should be empty */
2052 | break;
2053 |
2054 | default:
2055 | proto_tree_add_expert(cql_subtree, pinfo, &ei_cql_data_not_dissected_yet, tvb, 0, message_length);
2056 | break;
2057 | }
2058 | }
2059 |
2060 | return tvb_reported_length(tvb);
2061 | }
2062 |
2063 | static int
2064 | dissect_cql_tcp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data)
2065 | {
2066 | uint8_t version;
2067 | conversation_t* conversation;
2068 | cql_conversation_type* cql_conv;
2069 |
2070 | /* This dissector version only understands CQL protocol v3, v4, v5. */
2071 | if (tvb_reported_length(tvb) < 1)
2072 | return 0;
2073 |
2074 | conversation = find_conversation_pinfo(pinfo, 0);
2075 | if (conversation) {
2076 | cql_conv = (cql_conversation_type*) conversation_get_proto_data(conversation, proto_cql);
2077 | if (cql_conv && cql_conv->protocol_version == 5) {
2078 | if (cql_conv->frame_start_v5_proto != 0 && pinfo->num > cql_conv->frame_start_v5_proto) {
2079 | /* if we are already in v5 and negotiation is done, use the stored compression level */
2080 | if (cql_conv->compression_level == CQL_COMPRESSION_NONE) {
2081 | tcp_dissect_pdus(tvb, pinfo, tree, cql_desegment, 3 /* bytes to determine length of PDU */, get_cql5_non_comp_pdu_len, dissect_cql5_uncomp, data);
2082 | } else if (cql_conv->compression_level == CQL_COMPRESSION_LZ4) {
2083 | tcp_dissect_pdus(tvb, pinfo, tree, cql_desegment, 3 /* bytes to determine length of PDU */, get_cql5_comp_pdu_len, dissect_cql5_comp, data);
2084 | } else {
2085 | /* unknown compression level, should not happen */
2086 | return 0;
2087 | }
2088 | } else {
2089 | /* negotiation not done yet, we treat it as pre-v5 frames */
2090 | tcp_dissect_pdus(tvb, pinfo, tree, cql_desegment, 9 /* bytes to determine length of PDU */, get_cql_pdu_len, dissect_cql_tcp_pdu, data);
2091 | }
2092 | } else { /* pre CQLv5 protocol versions */
2093 | tcp_dissect_pdus(tvb, pinfo, tree, cql_desegment, 9 /* bytes to determine length of PDU */, get_cql_pdu_len, dissect_cql_tcp_pdu, data);
2094 | }
2095 | } else {
2096 | version = tvb_get_uint8(tvb, 0) & 0x7F;
2097 | if ((version != 3 && version != 4 && version != 5)) /* this might fail if we are catching CQLv5 mid-stream, so be it */
2098 | return 0;
2099 |
2100 | tcp_dissect_pdus(tvb, pinfo, tree, cql_desegment, 9 /* bytes to determine length of PDU */, get_cql_pdu_len, dissect_cql_tcp_pdu, data);
2101 | }
2102 |
2103 | return tvb_reported_length(tvb);
2104 | }
2105 |
2106 | void
2107 | proto_reg_handoff_cql(void)
2108 | {
2109 | dissector_add_uint_with_preference("tcp.port", CQL_DEFAULT_PORT9042, find_dissector("cql"));
2110 | }
2111 |
2112 |
2113 | void
2114 | proto_register_cql(void)
2115 | {
2116 | expert_module_t* expert_cql;
2117 | static hf_register_info hf[] = {
2118 | {
2119 | &hf_cql_batch_flag_serial_consistency,
2120 | {
2121 | "Serial Consistency", "cql.batch.flags.serial_consistency",
2122 | FT_BOOLEAN, 8,
2123 | NULL((void*)0), CQL_BATCH_FLAG_SERIAL_CONSISTENCY,
2124 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2125 | }
2126 | },
2127 | {
2128 | &hf_cql_batch_flag_default_timestamp,
2129 | {
2130 | "Default Timestamp", "cql.batch.flags.default_timestamp",
2131 | FT_BOOLEAN, 8,
2132 | NULL((void*)0), CQL_BATCH_FLAG_DEFAULT_TIMESTAMP,
2133 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2134 | }
2135 | },
2136 | {
2137 | &hf_cql_batch_flag_with_name_for_values,
2138 | {
2139 | "With Name For Value", "cql.batch.flags.with_name_for_values",
2140 | FT_BOOLEAN, 8,
2141 | NULL((void*)0), CQL_BATCH_FLAG_WITH_NAME_FOR_VALUES,
2142 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2143 | }
2144 | },
2145 | {
2146 | &hf_cql_batch_flags_bitmap,
2147 | {
2148 | "Flags", "cql.batch.flags",
2149 | FT_UINT8, BASE_HEX,
2150 | NULL((void*)0), 0x0,
2151 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2152 | }
2153 | },
2154 | {
2155 | &hf_cql_version,
2156 | {
2157 | "Version", "cql.version",
2158 | FT_UINT8, BASE_HEX,
2159 | NULL((void*)0), 0x0,
2160 | "CQL protocol version (not language version)", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2161 | }
2162 | },
2163 | {
2164 | &hf_cql_protocol_version,
2165 | {
2166 | "Protocol version", "cql.protocol_version",
2167 | FT_UINT8, BASE_DEC,
2168 | NULL((void*)0), 0x0F,
2169 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2170 | }
2171 | },
2172 | {
2173 | &hf_cql_direction,
2174 | {
2175 | "Direction", "cql.direction",
2176 | FT_UINT8, BASE_HEX,
2177 | VALS(cql_direction_names)((0 ? (const struct _value_string*)0 : ((cql_direction_names) ))), 0xF0,
2178 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2179 | }
2180 | },
2181 | {
2182 | &hf_cql_flags_bitmap,
2183 | {
2184 | "Flags", "cql.flags",
2185 | FT_UINT8, BASE_HEX,
2186 | NULL((void*)0), 0x0,
2187 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2188 | }
2189 | },
2190 | {
2191 | &hf_cql_result_rows_flags_values,
2192 | {
2193 | "Rows Result Flags", "cql.result.rows.flags",
2194 | FT_UINT32, BASE_DEC,
2195 | NULL((void*)0), 0x0,
2196 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2197 | }
2198 | },
2199 | {
2200 | &hf_cql_result_prepared_flags_values,
2201 | {
2202 | "Prepared Result Flags", "cql.result.prepared.flags",
2203 | FT_UINT32, BASE_DEC,
2204 | NULL((void*)0), 0x0,
2205 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2206 | }
2207 | },
2208 | {
2209 | &hf_cql_result_rows_flag_global_tables_spec,
2210 | {
2211 | "Global tables spec.", "cql.result.rows.flags.global_tables",
2212 | FT_BOOLEAN, 32,
2213 | NULL((void*)0), CQL_RESULT_ROWS_FLAG_GLOBAL_TABLES_SPEC,
2214 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2215 | }
2216 | },
2217 | {
2218 | &hf_cql_result_rows_flag_has_more_pages,
2219 | {
2220 | "Has More Pages", "cql.result.rows.flags.has_more_pages",
2221 | FT_BOOLEAN, 32,
2222 | NULL((void*)0), CQL_RESULT_ROWS_FLAG_HAS_MORE_PAGES,
2223 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2224 | }
2225 | },
2226 | {
2227 | &hf_cql_result_rows_flag_no_metadata,
2228 | {
2229 | "No Metadata", "cql.result.rows.flags.no_metadata",
2230 | FT_BOOLEAN, 32,
2231 | NULL((void*)0), CQL_RESULT_ROWS_FLAG_NO_METADATA,
2232 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2233 | }
2234 | },
2235 | {
2236 | &hf_cql_flag_compression,
2237 | {
2238 | "Compression", "cql.flags.compression",
2239 | FT_BOOLEAN, 8,
2240 | NULL((void*)0), CQL_HEADER_FLAG_COMPRESSION,
2241 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2242 | }
2243 | },
2244 | {
2245 | &hf_cql_flag_tracing,
2246 | {
2247 | "Tracing", "cql.flags.tracing",
2248 | FT_BOOLEAN, 8,
2249 | NULL((void*)0), CQL_HEADER_FLAG_TRACING,
2250 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2251 | }
2252 | },
2253 | {
2254 | &hf_cql_flag_custom_payload,
2255 | {
2256 | "Custom Payload", "cql.flags.custom_payload",
2257 | FT_BOOLEAN, 8,
2258 | NULL((void*)0), CQL_HEADER_FLAG_CUSTOM_PAYLOAD,
2259 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2260 | }
2261 | },
2262 | {
2263 | &hf_cql_flag_warning,
2264 | {
2265 | "Warning", "cql.flags.warning",
2266 | FT_BOOLEAN, 8,
2267 | NULL((void*)0), CQL_HEADER_FLAG_WARNING,
2268 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2269 | }
2270 | },
2271 | {
2272 | &hf_cql_flag_reserved3,
2273 | {
2274 | "Reserved", "cql.flags.reserved",
2275 | FT_UINT8, BASE_HEX,
2276 | NULL((void*)0), CQL_HEADER_FLAG_V3_RESERVED,
2277 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2278 | }
2279 | },
2280 | {
2281 | &hf_cql_flag_reserved4,
2282 | {
2283 | "Reserved", "cql.flags.reserved",
2284 | FT_UINT8, BASE_HEX,
2285 | NULL((void*)0), CQL_HEADER_FLAG_V4_RESERVED,
2286 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2287 | }
2288 | },
2289 | {
2290 | &hf_cql_flag_beta,
2291 | {
2292 | "Beta", "cql.flags.beta",
2293 | FT_UINT8, BASE_HEX,
2294 | NULL((void*)0), CQL_HEADER_FLAG_BETA,
2295 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2296 | }
2297 | },
2298 | {
2299 | &hf_cql_query_flags_page_size,
2300 | {
2301 | "Page Size", "cql.query.flags.page_size",
2302 | FT_BOOLEAN, 8,
2303 | NULL((void*)0), CQL_QUERY_FLAG_PAGE_SIZE,
2304 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2305 | }
2306 | },
2307 | {
2308 | &hf_cql_query_v5_flags_page_size,
2309 | {
2310 | "Page Size", "cql.queryv5.flags.page_size",
2311 | FT_BOOLEAN, 32,
2312 | NULL((void*)0), CQL_QUERY_FLAG_PAGE_SIZE,
2313 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2314 | }
2315 | },
2316 | {
2317 | &hf_cql_query_flags_skip_metadata,
2318 | {
2319 | "Skip Metadata", "cql.query.flags.skip_metadata",
2320 | FT_BOOLEAN, 8,
2321 | NULL((void*)0), CQL_QUERY_FLAG_SKIP_METADATA,
2322 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2323 | }
2324 | },
2325 | {
2326 | &hf_cql_query_v5_flags_skip_metadata,
2327 | {
2328 | "Skip Metadata", "cql.queryv5.flags.skip_metadata",
2329 | FT_BOOLEAN, 32,
2330 | NULL((void*)0), CQL_QUERY_FLAG_SKIP_METADATA,
2331 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2332 | }
2333 | },
2334 | {
2335 | &hf_cql_query_flags_values,
2336 | {
2337 | "Values", "cql.query.flags.values",
2338 | FT_BOOLEAN, 8,
2339 | NULL((void*)0), CQL_QUERY_FLAG_VALUES,
2340 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2341 | }
2342 | },
2343 | {
2344 | &hf_cql_query_v5_flags_values,
2345 | {
2346 | "Values", "cql.queryv5.flags.values",
2347 | FT_BOOLEAN, 32,
2348 | NULL((void*)0), CQL_QUERY_FLAG_VALUES,
2349 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2350 | }
2351 | },
2352 | {
2353 | &hf_cql_query_flags_default_timestamp,
2354 | {
2355 | "Default Timestamp", "cql.query.flags.default_timestamp",
2356 | FT_BOOLEAN, 8,
2357 | NULL((void*)0), CQL_QUERY_FLAG_DEFAULT_TIMESTAMP,
2358 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2359 | }
2360 | },
2361 | {
2362 | &hf_cql_query_v5_flags_default_timestamp,
2363 | {
2364 | "Default Timestamp", "cql.queryv5.flags.default_timestamp",
2365 | FT_BOOLEAN, 32,
2366 | NULL((void*)0), CQL_QUERY_FLAG_DEFAULT_TIMESTAMP,
2367 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2368 | }
2369 | },
2370 | {
2371 | &hf_cql_query_flags_names_for_values,
2372 | {
2373 | "Names for Values", "cql.query.flags.value_names",
2374 | FT_BOOLEAN, 8,
2375 | NULL((void*)0), CQL_QUERY_FLAG_VALUE_NAMES,
2376 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2377 | }
2378 | },
2379 | {
2380 | &hf_cql_query_v5_flags_names_for_values,
2381 | {
2382 | "Names for Values", "cql.queryv5.flags.value_names",
2383 | FT_BOOLEAN, 32,
2384 | NULL((void*)0), CQL_QUERY_FLAG_VALUE_NAMES,
2385 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2386 | }
2387 | },
2388 | {
2389 | &hf_cql_query_flags_paging_state,
2390 | {
2391 | "Paging State", "cql.query.flags.paging_state",
2392 | FT_BOOLEAN, 8,
2393 | NULL((void*)0), CQL_QUERY_FLAG_PAGING_STATE,
2394 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2395 | }
2396 | },
2397 | {
2398 | &hf_cql_query_v5_flags_paging_state,
2399 | {
2400 | "Paging State", "cql.query.flags.paging_state",
2401 | FT_BOOLEAN, 32,
2402 | NULL((void*)0), CQL_QUERY_FLAG_PAGING_STATE,
2403 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2404 | }
2405 | },
2406 | {
2407 | &hf_cql_query_flags_serial_consistency,
2408 | {
2409 | "Serial Consistency", "cql.query.flags.serial_consistency",
2410 | FT_BOOLEAN, 8,
2411 | NULL((void*)0), CQL_QUERY_FLAG_SERIAL_CONSISTENCY,
2412 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2413 | }
2414 | },
2415 | {
2416 | &hf_cql_query_v5_flags_serial_consistency,
2417 | {
2418 | "Serial Consistency", "cql.queryv5.flags.serial_consistency",
2419 | FT_BOOLEAN, 32,
2420 | NULL((void*)0), CQL_QUERY_FLAG_SERIAL_CONSISTENCY,
2421 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2422 | }
2423 | },
2424 | {
2425 | &hf_cql_query_v5_flags_with_keyspace,
2426 | {
2427 | "With Keyspace", "cql.queryv5.flags.with_keyspace",
2428 | FT_BOOLEAN, 32,
2429 | NULL((void*)0), CQL_QUERY_FLAG_WITH_KEYSPACE,
2430 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2431 | }
2432 | },
2433 | {
2434 | &hf_cql_query_v5_flags_now_in_seconds,
2435 | {
2436 | "Now in Seconds", "cql.queryv5.flags.now_in_seconds",
2437 | FT_BOOLEAN, 32,
2438 | NULL((void*)0), CQL_QUERY_FLAG_NOW_IN_SECONDS,
2439 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2440 | }
2441 | },
2442 | {
2443 | &hf_cql_stream,
2444 | {
2445 | "Stream Identifier", "cql.stream",
2446 | FT_INT16, BASE_DEC,
2447 | NULL((void*)0), 0x0,
2448 | "Stream identifier this packet belongs to", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2449 | }
2450 | },
2451 | {
2452 | &hf_cql_opcode,
2453 | {
2454 | "Opcode", "cql.opcode",
2455 | FT_UINT8, BASE_DEC,
2456 | VALS(cql_opcode_names)((0 ? (const struct _value_string*)0 : ((cql_opcode_names)))), 0x7F, /* Mask the highest-order bit because it indicates message direction, not opcode. */
2457 | "CQL operation this packet describes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2458 | }
2459 | },
2460 | {
2461 | &hf_cql_batch_type,
2462 | {
2463 | "Batch type", "cql.batch_type",
2464 | FT_UINT8, BASE_DEC,
2465 | VALS(cql_batch_type_names)((0 ? (const struct _value_string*)0 : ((cql_batch_type_names )))), 0x0,
2466 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2467 | }
2468 | },
2469 | {
2470 | &hf_cql_batch_query_type,
2471 | {
2472 | "Batch query type", "cql.batch_query_type",
2473 | FT_UINT8, BASE_DEC,
2474 | VALS(cql_batch_query_type_names)((0 ? (const struct _value_string*)0 : ((cql_batch_query_type_names )))), 0x00,
2475 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2476 | }
2477 | },
2478 | {
2479 | &hf_cql_length,
2480 | {
2481 | "Message Length", "cql.message_length",
2482 | FT_UINT32, BASE_DEC,
2483 | NULL((void*)0), 0x0,
2484 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2485 | }
2486 | },
2487 | {
2488 | &hf_cql5_compressed_length,
2489 | {
2490 | "Compressed Message Length", "cql.v5_message_length.compressed",
2491 | FT_UINT32, BASE_DEC,
2492 | NULL((void*)0), 0x0,
2493 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2494 | }
2495 | },
2496 | {
2497 | &hf_cql5_uncompressed_length,
2498 | {
2499 | "Uncompressed Message Length", "cql.v5_message_length.uncompressed",
2500 | FT_UINT32, BASE_DEC,
2501 | NULL((void*)0), 0x0,
2502 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2503 | }
2504 | },
2505 | {
2506 | &hf_cql5_header,
2507 | {
2508 | "CQLv5 Header", "cql.v5_header",
2509 | FT_NONE, BASE_NONE,
2510 | NULL((void*)0), 0x0,
2511 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2512 | }
2513 | },
2514 | {
2515 | &hf_cql5_self_contained,
2516 | {
2517 | "Self-Contained Flag", "cql.v5_is_self_contained",
2518 | FT_BOOLEAN, BASE_NONE,
2519 | NULL((void*)0), 0x0,
2520 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2521 | }
2522 | },
2523 | {
2524 | &hf_cql5_crc24,
2525 | {
2526 | "Header CRC24", "cql.v5_crc24",
2527 | FT_UINT24, BASE_HEX,
2528 | NULL((void*)0), 0x0,
2529 | "CRC24 checksum of the header", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2530 | }
2531 | },
2532 | {
2533 | &hf_cql5_crc32,
2534 | {
2535 | "Payload CRC32", "cql.v5_crc32",
2536 | FT_UINT32, BASE_HEX,
2537 | NULL((void*)0), 0x0,
2538 | "CRC32 checksum of the frame payload", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2539 | }
2540 | },
2541 | {
2542 | &hf_cql_string_map_size,
2543 | {
2544 | "String Map Size", "cql.string_map_size",
2545 | FT_UINT16, BASE_DEC,
2546 | NULL((void*)0), 0x0,
2547 | "Number of strings in the map", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2548 | }
2549 | },
2550 | {
2551 | &hf_cql_string_list_size,
2552 | {
2553 | "String List Size", "cql.string_list_size",
2554 | FT_UINT16, BASE_DEC,
2555 | NULL((void*)0), 0x0,
2556 | "Number of strings in the list", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2557 | }
2558 | },
2559 | {
2560 | &hf_cql_string,
2561 | {
2562 | "String", "cql.string",
2563 | FT_STRING, BASE_NONE,
2564 | NULL((void*)0), 0x0,
2565 | "UTF-8 string value", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2566 | }
2567 | },
2568 | {
2569 | /* TODO: should this be an FT_STRING field? */
2570 | &hf_cql_auth_token,
2571 | {
2572 | "Auth Token", "cql.auth_token",
2573 | FT_BYTES, BASE_NONE,
2574 | NULL((void*)0), 0x0,
2575 | "[bytes] auth token", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2576 | }
2577 | },
2578 | {
2579 | &hf_cql_string_result_rows_global_table_spec_ksname,
2580 | {
2581 | "Global Spec Keyspace Name", "cql.result.rows.keyspace_name",
2582 | FT_STRING, BASE_NONE,
2583 | NULL((void*)0), 0x0,
2584 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2585 | }
2586 | },
2587 | {
2588 | &hf_cql_string_result_rows_global_table_spec_table_name,
2589 | {
2590 | "Global Spec Table Name", "cql.result.rows.table_name",
2591 | FT_STRING, BASE_NONE,
2592 | NULL((void*)0), 0x0,
2593 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2594 | }
2595 | },
2596 | {
2597 | &hf_cql_string_result_rows_table_name,
2598 | {
2599 | "Table Name", "cql.result.rows.table_name",
2600 | FT_STRING, BASE_NONE,
2601 | NULL((void*)0), 0x0,
2602 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2603 | }
2604 | },
2605 | {
2606 | &hf_cql_string_result_rows_udt_name,
2607 | {
2608 | "User Defined Type Name", "cql.result.rows.udt_name",
2609 | FT_STRING, BASE_NONE,
2610 | NULL((void*)0), 0x0,
2611 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2612 | }
2613 | },
2614 | {
2615 | &hf_cql_string_result_rows_udt_field_name,
2616 | {
2617 | "User Defined Type field Name", "cql.result.rows.udt_field_name",
2618 | FT_STRING, BASE_NONE,
2619 | NULL((void*)0), 0x0,
2620 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2621 | }
2622 | },
2623 | {
2624 | &hf_cql_string_result_rows_udt_size,
2625 | {
2626 | "User Defined Type Size", "cql.result.rows.udt_size",
2627 | FT_UINT16, BASE_DEC,
2628 | NULL((void*)0), 0x0,
2629 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2630 | }
2631 | },
2632 | {
2633 | &hf_cql_string_result_rows_list_size,
2634 | {
2635 | "List Size", "cql.result.rows.list_size",
2636 | FT_INT32, BASE_DEC,
2637 | NULL((void*)0), 0x0,
2638 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2639 | }
2640 | },
2641 | {
2642 | &hf_cql_string_result_rows_map_size,
2643 | {
2644 | "No. of key/value pairs in map", "cql.result.rows.map_size",
2645 | FT_INT32, BASE_DEC,
2646 | NULL((void*)0), 0x0,
2647 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2648 | }
2649 | },
2650 | {
2651 | &hf_cql_string_result_rows_set_size,
2652 | {
2653 | "Set Size", "cql.result.rows.set_size",
2654 | FT_INT32, BASE_DEC,
2655 | NULL((void*)0), 0x0,
2656 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2657 | }
2658 | },
2659 | {
2660 | &hf_cql_string_result_rows_keyspace_name,
2661 | {
2662 | "Keyspace Name", "cql.result.rows.keyspace_name",
2663 | FT_STRING, BASE_NONE,
2664 | NULL((void*)0), 0x0,
2665 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2666 | }
2667 | },
2668 | {
2669 | &hf_cql_bytesmap_string,
2670 | {
2671 | "Key", "cql.bytesmap.key",
2672 | FT_STRING, BASE_NONE,
2673 | NULL((void*)0), 0x0,
2674 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2675 | }
2676 | },
2677 | {
2678 | &hf_cql_string_result_rows_column_name,
2679 | {
2680 | "Column Name", "cql.result.rows.column_name",
2681 | FT_STRING, BASE_NONE,
2682 | NULL((void*)0), 0x0,
2683 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2684 | }
2685 | },
2686 | {
2687 | &hf_cql_string_length,
2688 | {
2689 | "String Length", "cql.string_length",
2690 | FT_UINT32, BASE_DEC,
2691 | NULL((void*)0), 0x0,
2692 | "Length of the subsequent string value", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2693 | }
2694 | },
2695 | {
2696 | &hf_cql_consistency,
2697 | {
2698 | "Consistency", "cql.consistency",
2699 | FT_UINT16, BASE_HEX,
2700 | VALS(cql_consistency_names)((0 ? (const struct _value_string*)0 : ((cql_consistency_names )))), 0x0,
2701 | "CQL consistency level specification", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2702 | }
2703 | },
2704 | { &hf_cql_error_failure_received,
2705 | {
2706 | "Error Failure Received", "cql.error_failure_received",
2707 | FT_UINT32, BASE_DEC,
2708 | NULL((void*)0), 0x0,
2709 | "Number of nodes answered (read) / failed (write)", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2710 | }
2711 | },
2712 | { &hf_cql_error_block_for,
2713 | {
2714 | "Error Block For", "cql.error_block_for",
2715 | FT_UINT32, BASE_DEC,
2716 | NULL((void*)0), 0x0,
2717 | "Number of replica responss required to achieve CL", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2718 | }
2719 | },
2720 | { &hf_cql_error_num_failures,
2721 | {
2722 | "Error Num Failures", "cql.error_num_failures",
2723 | FT_UINT32, BASE_DEC,
2724 | NULL((void*)0), 0x0,
2725 | "Number of nodes experienced failure", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2726 | }
2727 | },
2728 | { &hf_cql_error_data_present,
2729 | {
2730 | "Error data present flag", "cql.error_data_present",
2731 | FT_UINT8, BASE_DEC,
2732 | NULL((void*)0), 0x0,
2733 | "Replica responded or not", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2734 | }
2735 | },
2736 | { &hf_cql_error_write_type,
2737 | {
2738 | "Error Write Type", "cql.error_write_type",
2739 | FT_STRING, BASE_NONE,
2740 | NULL((void*)0), 0x0,
2741 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2742 | }
2743 | },
2744 | {
2745 | &hf_cql_value_count,
2746 | {
2747 | "Value count", "cql.value_count",
2748 | FT_UINT16, BASE_DEC,
2749 | NULL((void*)0), 0x0,
2750 | "Number of subsequent values", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2751 | }
2752 | },
2753 | {
2754 | &hf_cql_bytes_length,
2755 | {
2756 | "Bytes length", "cql.bytes_length.int",
2757 | FT_INT32, BASE_DEC,
2758 | NULL((void*)0), 0x0,
2759 | "Number of subsequent bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2760 | }
2761 | },
2762 | {
2763 | &hf_cql_short_bytes_length,
2764 | {
2765 | "Bytes length", "cql.bytes_length.short",
2766 | FT_UINT16, BASE_DEC,
2767 | NULL((void*)0), 0x0,
2768 | "Number of subsequent bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2769 | }
2770 | }, {
2771 | &hf_cql_bytes,
2772 | {
2773 | "Bytes", "cql.bytes",
2774 | FT_BYTES, BASE_NONE,
2775 | NULL((void*)0), 0x0,
2776 | "Raw byte array", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2777 | }
2778 | },
2779 | {
2780 | &hf_cql_bigint,
2781 | {
2782 | "Bigint", "cql.bigint",
2783 | FT_INT64, BASE_DEC,
2784 | NULL((void*)0), 0x0,
2785 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2786 | }
2787 | },
2788 | {
2789 | &hf_cql_scale,
2790 | {
2791 | "Scale", "cql.scale",
2792 | FT_INT32, BASE_DEC,
2793 | NULL((void*)0), 0x0,
2794 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2795 | }
2796 | },
2797 | {
2798 | &hf_cql_ascii,
2799 | {
2800 | "Ascii", "cql.ascii",
2801 | FT_STRING, BASE_NONE,
2802 | NULL((void*)0), 0x0,
2803 | "An Ascii string", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2804 | }
2805 | },
2806 | {
2807 | &hf_cql_double,
2808 | {
2809 | "Double float", "cql.double",
2810 | FT_DOUBLE, BASE_NONE,
2811 | NULL((void*)0), 0x0,
2812 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2813 | }
2814 | },
2815 | {
2816 | &hf_cql_float,
2817 | {
2818 | "Float", "cql.float",
2819 | FT_FLOAT, BASE_NONE,
2820 | NULL((void*)0), 0x0,
2821 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2822 | }
2823 | },
2824 | {
2825 | &hf_cql_int,
2826 | {
2827 | "Int", "cql.int",
2828 | FT_INT32, BASE_DEC,
2829 | NULL((void*)0), 0x0,
2830 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2831 | }
2832 | },
2833 | {
2834 | &hf_cql_varint_count8,
2835 | {
2836 | "Varint", "cql.varint",
2837 | FT_UINT8, BASE_DEC,
2838 | NULL((void*)0), 0x0,
2839 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2840 | },
2841 | },
2842 | {
2843 | &hf_cql_varint_count16,
2844 | {
2845 | "Varint", "cql.varint",
2846 | FT_UINT16, BASE_DEC,
2847 | NULL((void*)0), 0x0,
2848 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2849 | },
2850 | },
2851 | {
2852 | &hf_cql_varint_count32,
2853 | {
2854 | "Varint", "cql.varint",
2855 | FT_UINT32, BASE_DEC,
2856 | NULL((void*)0), 0x0,
2857 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2858 | },
2859 | },
2860 | {
2861 | &hf_cql_varint_count64,
2862 | {
2863 | "Varint", "cql.varint64",
2864 | FT_UINT64, BASE_DEC,
2865 | NULL((void*)0), 0x0,
2866 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2867 | },
2868 | },
2869 | {
2870 | &hf_cql_varchar,
2871 | {
2872 | "Varchar", "cql.varchar",
2873 | FT_STRING, BASE_NONE,
2874 | NULL((void*)0), 0x0,
2875 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2876 | }
2877 | },
2878 | {
2879 | &hf_cql_timeuuid,
2880 | {
2881 | "Time Uuid", "cql.timeuuid",
2882 | FT_GUID, BASE_NONE,
2883 | NULL((void*)0), 0x0,
2884 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2885 | }
2886 | },
2887 | {
2888 | &hf_cql_custom,
2889 | {
2890 | "Custom", "cql.custom",
2891 | FT_STRING, BASE_NONE,
2892 | NULL((void*)0), 0x0,
2893 | "A custom field", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2894 | }
2895 | },
2896 | {
2897 | &hf_cql_null_value,
2898 | {
2899 | "NULL value", "cql.null_value",
2900 | FT_NONE, BASE_NONE,
2901 | NULL((void*)0), 0x0,
2902 | "A NULL value", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2903 | }
2904 | },
2905 | {
2906 | &hf_cql_raw_compressed_bytes,
2907 | {
2908 | "Raw compressed bytes", "cql.raw_compressed_bytes",
2909 | FT_BYTES, BASE_NONE,
2910 | NULL((void*)0), 0x0,
2911 | "Raw byte that failed to be decompressed", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2912 | }
2913 | },
2914 |
2915 | {
2916 | &hf_cql_paging_state,
2917 | {
2918 | "Paging State", "cql.paging_state",
2919 | FT_BYTES, BASE_NONE,
2920 | NULL((void*)0), 0x0,
2921 | "Paging state byte array", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2922 | }
2923 | },
2924 | {
2925 | &hf_cql_page_size,
2926 | {
2927 | "Page size", "cql.page_size",
2928 | FT_INT32, BASE_DEC,
2929 | NULL((void*)0), 0x0,
2930 | "Desired page size of result (in CQL3 rows)", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2931 | }
2932 | },
2933 | {
2934 | &hf_cql_response_in,
2935 | {
2936 | "Response in", "cql.response_in",
2937 | FT_FRAMENUM, BASE_NONE,
2938 | FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE)((gpointer) (glong) (FT_FRAMENUM_RESPONSE)), 0x0,
2939 | "The response to this CQL request is in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2940 | }
2941 | },
2942 | {
2943 | &hf_cql_response_to,
2944 | {
2945 | "Request in", "cql.response_to",
2946 | FT_FRAMENUM, BASE_NONE,
2947 | FRAMENUM_TYPE(FT_FRAMENUM_REQUEST)((gpointer) (glong) (FT_FRAMENUM_REQUEST)), 0x0,
2948 | "This is a response to the CQL request in this fame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2949 | }
2950 | },
2951 | {
2952 | &hf_cql_response_time,
2953 | {
2954 | "Response time", "cql.response_time",
2955 | FT_RELATIVE_TIME, BASE_NONE,
2956 | NULL((void*)0), 0x0,
2957 | "The time between the request and the response", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2958 | }
2959 | },
2960 | {
2961 | &hf_cql_timestamp,
2962 | {
2963 | "Timestamp", "cql.timestamp",
2964 | FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
2965 | NULL((void*)0), 0x0,
2966 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2967 | }
2968 | },
2969 | {
2970 | &hf_cql_query_id,
2971 | {
2972 | "Query ID", "cql.query_id",
2973 | FT_BYTES, BASE_NONE,
2974 | NULL((void*)0), 0x0,
2975 | "CQL query id resulting from a PREPARE statement", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2976 | }
2977 | },
2978 | {
2979 | &hf_cql_query_metadata_id,
2980 | {
2981 | "Query Metadata ID", "cql.query_metadata_id",
2982 | FT_BYTES, BASE_NONE,
2983 | NULL((void*)0), 0x0,
2984 | "CQL v5 query metadata ID resulting from a PREPARE statement", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2985 | }
2986 | },
2987 | {
2988 | &hf_cql_event_type,
2989 | {
2990 | "Event Type", "cql.event_type",
2991 | FT_STRING, BASE_NONE,
2992 | NULL((void*)0), 0x0,
2993 | "CQL Event Type", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
2994 | }
2995 | },
2996 | {
2997 | &hf_cql_event_schema_change_type,
2998 | {
2999 | "Schema change type", "cql.schema_change_type",
3000 | FT_STRING, BASE_NONE,
3001 | NULL((void*)0), 0x0,
3002 | "CQL Schema Change Type", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3003 | }
3004 | },
3005 | {
3006 | &hf_cql_event_schema_change_type_target,
3007 | {
3008 | "Schema change target", "cql.schema_change_target",
3009 | FT_STRING, BASE_NONE,
3010 | NULL((void*)0), 0x0,
3011 | "CQL Schema Change target object", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3012 | }
3013 | },
3014 | {
3015 | &hf_cql_event_schema_change_object,
3016 | {
3017 | "Schema change event object name", "cql.schema_change_object_name",
3018 | FT_STRING, BASE_NONE,
3019 | NULL((void*)0), 0x0,
3020 | "CQL Schema Change object name", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3021 | }
3022 | },
3023 | {
3024 | &hf_cql_event_schema_change_keyspace,
3025 | {
3026 | "Schema change event keyspace name", "cql.schema_change_keyspace",
3027 | FT_STRING, BASE_NONE,
3028 | NULL((void*)0), 0x0,
3029 | "CQL Schema Change keyspace name", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3030 | }
3031 | },
3032 | {
3033 | &hf_cql_batch_query_size,
3034 | {
3035 | "Batch Query Size", "cql.batch_query_size",
3036 | FT_UINT16, BASE_DEC,
3037 | NULL((void*)0), 0x0,
3038 | "Number of statements in CQL batch", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3039 | }
3040 | },
3041 | {
3042 | &hf_cql_error_code,
3043 | {
3044 | "Error Code", "cql.error_code",
3045 | FT_UINT32, BASE_HEX,
3046 | VALS(cql_error_names)((0 ? (const struct _value_string*)0 : ((cql_error_names)))), 0x0,
3047 | "Error code from CQL server", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3048 | }
3049 | },
3050 | {
3051 | &hf_cql_result_kind,
3052 | {
3053 | "Result Kind", "cql.result.kind",
3054 | FT_INT32, BASE_DEC,
3055 | VALS(cql_result_kind_names)((0 ? (const struct _value_string*)0 : ((cql_result_kind_names )))), 0x0,
3056 | "Kind of result from CQL server", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3057 | }
3058 | },
3059 | {
3060 | &hf_cql_result_rows_column_count,
3061 | {
3062 | "Column Count", "cql.result.rows.column_count",
3063 | FT_INT32, BASE_DEC,
3064 | NULL((void*)0), 0x0,
3065 | "Count of columns in a rows result from CQL server", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3066 | }
3067 | },
3068 | {
3069 | &hf_cql_result_prepared_pk_count,
3070 | {
3071 | "PK Count", "cql.result.prepared.pk_count",
3072 | FT_INT32, BASE_DEC,
3073 | NULL((void*)0), 0x0,
3074 | "Count of Partition Key columns in a Prepared result from CQL server", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3075 | }
3076 | },
3077 | {
3078 | &hf_cql_result_rows_tuple_size,
3079 | {
3080 | "Tuple Size", "cql.result.rows.tuple_size",
3081 | FT_UINT16, BASE_DEC,
3082 | NULL((void*)0), 0x0,
3083 | "Size of a tuple rows result from CQL server", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3084 | }
3085 | },
3086 | {
3087 | &hf_cql_result_timestamp,
3088 | {
3089 | "Timestamp (Epoch Time)", "cql.result.timestamp",
3090 | FT_INT64, BASE_DEC,
3091 | NULL((void*)0), 0x0,
3092 | "Timestamp result", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3093 | }
3094 | },
3095 | {
3096 | &hf_cql_result_rows_data_type,
3097 | {
3098 | "CQL Data Type", "cql.data_type",
3099 | FT_UINT16, BASE_DEC,
3100 | VALS(cql_result_row_type_names)((0 ? (const struct _value_string*)0 : ((cql_result_row_type_names )))), 0x0,
3101 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3102 | }
3103 | },
3104 | {
3105 | &hf_cql_result_rows_row_count,
3106 | {
3107 | "CQL Result Rows Count", "cql.result.rows.row_count",
3108 | FT_INT32, BASE_DEC,
3109 | NULL((void*)0), 0x0,
3110 | "Number of rows returned in CQL result", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3111 | }
3112 | },
3113 | {
3114 | &hf_cql_uuid,
3115 | {
3116 | "UUID", "cql.uuid",
3117 | FT_GUID, BASE_NONE,
3118 | NULL((void*)0), 0x0,
3119 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3120 | }
3121 | },
3122 | {
3123 | &hf_cql_tracing_uuid,
3124 | {
3125 | "Tracing UUID", "cql.tracing_uuid",
3126 | FT_GUID, BASE_NONE,
3127 | NULL((void*)0), 0x0,
3128 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3129 | }
3130 | },
3131 | {
3132 | &hf_cql_port,
3133 | {
3134 | "Port", "cql.port",
3135 | FT_UINT32, BASE_DEC,
3136 | NULL((void*)0), 0x0,
3137 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3138 | }
3139 | },
3140 | {
3141 | &hf_cql_boolean,
3142 | {
3143 | "Boolean", "cql.boolean",
3144 | FT_BOOLEAN, BASE_NONE,
3145 | NULL((void*)0), 0x0,
3146 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3147 | }
3148 | },
3149 | {
3150 | &hf_cql_ipv4,
3151 | {
3152 | "IPV4", "cql.ipv4",
3153 | FT_IPv4, BASE_NONE,
3154 | NULL((void*)0), 0x0,
3155 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3156 | }
3157 | },
3158 | {
3159 | &hf_cql_ipv6,
3160 | {
3161 | "IPV6", "cql.ipv6",
3162 | FT_IPv6, BASE_NONE,
3163 | NULL((void*)0), 0x0,
3164 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0)
3165 | }
3166 | },
3167 | };
3168 |
3169 | static ei_register_info ei[] = {
3170 | { &ei_cql_data_not_dissected_yet,
3171 | { "cql.ie_data_not_dissected_yet",
3172 | PI_UNDECODED0x05000000, PI_WARN0x00600000, "IE data not dissected yet", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE , ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void *)0)}} }},
3173 | { &ei_cql_unexpected_negative_value,
3174 | { "cql.unexpected_negative_value",
3175 | PI_UNDECODED0x05000000, PI_ERROR0x00800000, "Unexpected negative value", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE , ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void *)0)}} }},
3176 | };
3177 |
3178 | static int* ett[] = {
3179 | &ett_cql_protocol,
3180 | &ett_cql_version,
3181 | &ett_cql_message,
3182 | &ett_cql_result_columns,
3183 | &ett_cql_results_no_metadata,
3184 | &ett_cql_result_map,
3185 | &ett_cql_result_set,
3186 | &ett_cql_result_metadata,
3187 | &ett_cql_result_metadata_colspec,
3188 | &ett_cql_result_rows,
3189 | &ett_cql_header_flags_bitmap,
3190 | &ett_cql_batch_flags_bitmap,
3191 | &ett_cql_custom_payload,
3192 | &ett_cql5_header
3193 | };
3194 |
3195 | proto_cql = proto_register_protocol("Cassandra CQL Protocol", "CQL", "cql" );
3196 | register_dissector("cql", dissect_cql_tcp, proto_cql);
3197 |
3198 | proto_register_field_array(proto_cql, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));
3199 | proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));
3200 |
3201 | expert_cql = expert_register_protocol(proto_cql);
3202 | expert_register_field_array(expert_cql, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0]));
3203 | }
3204 |
3205 | /*
3206 | * Editor modelines - https://www.wireshark.org/tools/modelines.html
3207 | *
3208 | * Local variables:
3209 | * c-basic-offset: 8
3210 | * tab-width: 8
3211 | * indent-tabs-mode: t
3212 | * End:
3213 | *
3214 | * vi: set shiftwidth=8 tabstop=8 noexpandtab:
3215 | * :indentSize=8:tabSize=8:noTabs=false:
3216 | */