Coverage Report

Created: 2026-05-14 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-gdsdb.c
Line
Count
Source
1
/* packet-gdsdb.c
2
 * Routines for Firebird/Interbase dissection
3
 * Copyright 2007, Moshe van der Sterre <moshevds@gmail.com>
4
 *
5
 * Firebird home: http://www.firebirdsql.org
6
 * Source: http://sourceforge.net/projects/firebird/
7
 * https://firebirdsql.org/file/documentation/html/en/firebirddocs/wireprotocol/firebird-wire-protocol.html
8
 *
9
 * Wireshark - Network traffic analyzer
10
 * By Gerald Combs <gerald@wireshark.org>
11
 * Copyright 1998 Gerald Combs
12
 *
13
 * SPDX-License-Identifier: GPL-2.0-or-later
14
 */
15
16
#include "config.h"
17
18
#include <epan/packet.h>
19
#include <epan/expert.h>
20
21
#include <wsutil/ws_roundup.h>
22
23
void proto_register_gdsdb(void);
24
void proto_reg_handoff_gdsdb(void);
25
26
static dissector_handle_t gdsdb_handle;
27
/* IANA-registered port */
28
15
#define TCP_PORT  3050
29
30
static int proto_gdsdb;
31
static int ett_gdsdb;
32
static int hf_gdsdb_opcode;
33
/* static int ett_gdsdb_opcode; */
34
35
/* gdsdb_dummy */
36
/* gdsdb_connect */
37
static int hf_gdsdb_connect_operation;
38
static int hf_gdsdb_connect_version;
39
static int hf_gdsdb_connect_client;
40
static int hf_gdsdb_connect_filename;
41
static int hf_gdsdb_connect_count;
42
static int hf_gdsdb_connect_userid;
43
static int hf_gdsdb_connect_pref;
44
static int ett_gdsdb_connect_pref;
45
static int hf_gdsdb_connect_pref_version;
46
static int hf_gdsdb_connect_pref_architecture;
47
static int hf_gdsdb_connect_pref_mintype;
48
static int hf_gdsdb_connect_pref_maxtype;
49
static int hf_gdsdb_connect_pref_weight;
50
/* gdsdb_accept */
51
static int hf_gdsdb_accept_version;
52
static int hf_gdsdb_accept_architecture;
53
static int hf_gdsdb_accept_proto_min_type;
54
/* gdsdb_request */
55
static int hf_gdsdb_request_type;
56
static int hf_gdsdb_request_object;
57
static int hf_gdsdb_request_partner;
58
/* gdsdb_attach */
59
static int hf_gdsdb_attach_database_object_id;
60
static int hf_gdsdb_attach_database_path;
61
static int hf_gdsdb_attach_database_param_buf;
62
/* gdsdb_compile */
63
static int hf_gdsdb_compile_database;
64
static int hf_gdsdb_compile_blr;
65
/* gdsdb_receive */
66
static int hf_gdsdb_receive_request;
67
static int hf_gdsdb_receive_incarnation;
68
static int hf_gdsdb_receive_transaction;
69
static int hf_gdsdb_receive_msgnr;
70
static int hf_gdsdb_receive_messages;
71
static int hf_gdsdb_receive_direction;
72
static int hf_gdsdb_receive_offset;
73
/* gdsdb_send */
74
static int hf_gdsdb_send_request;
75
static int hf_gdsdb_send_incarnation;
76
static int hf_gdsdb_send_transaction;
77
static int hf_gdsdb_send_msgnr;
78
static int hf_gdsdb_send_messages;
79
/* gdsdb_response */
80
static int hf_gdsdb_response_object;
81
static int hf_gdsdb_response_blobid;
82
static int hf_gdsdb_response_datasize;
83
static int hf_gdsdb_response_data;
84
/* gdsdb_status_vector */
85
static int hf_gdsdb_status_vector_arg;
86
static int hf_gdsdb_status_vector_error_code;
87
static int hf_gdsdb_status_vector_number;
88
static int hf_gdsdb_status_vector_string;
89
static int hf_gdsdb_status_vector_sql_state;
90
/* gdsdb_transact */
91
static int hf_gdsdb_transact_database;
92
static int hf_gdsdb_transact_transaction;
93
#if 0
94
static int hf_gdsdb_transact_messages;
95
#endif
96
/* gdsdb_transact_response */
97
static int hf_gdsdb_transactresponse_messages;
98
/* gdsdb_open_blob2 */
99
static int hf_gdsdb_openblob2_bpb;
100
/* gdsdb_open_blob */
101
static int hf_gdsdb_openblob_transaction;
102
static int hf_gdsdb_openblob_id;
103
#if 0
104
/* gdsdb_segment */
105
static int hf_gdsdb_segment_blob;
106
static int hf_gdsdb_segment_length;
107
static int hf_gdsdb_segment_segment;
108
/* gdsdb_seek_blob */
109
static int hf_gdsdb_seekblob_blob;
110
static int hf_gdsdb_seekblob_mode;
111
#endif
112
/* gdsdb_reconnect */
113
static int hf_gdsdb_reconnect_handle;
114
static int hf_gdsdb_reconnect_database_size;
115
static int hf_gdsdb_reconnect_database;
116
/* gdsdb_info & gdsdb_service_start */
117
static int hf_gdsdb_info_object;
118
static int hf_gdsdb_info_incarnation;
119
static int hf_gdsdb_info_items;
120
static int hf_gdsdb_info_recv_items;
121
static int hf_gdsdb_info_buffer_length;
122
/* gdsdb_release */
123
static int hf_gdsdb_release_object;
124
#if 0
125
/* gdsdb_prepare2 */
126
static int hf_gdsdb_prepare2_transaction;
127
/* gdsdb_event & gdsdb_cancel_events */
128
static int hf_gdsdb_event_database;
129
static int hf_gdsdb_event_items;
130
static int hf_gdsdb_event_ast;
131
static int hf_gdsdb_event_arg;
132
static int hf_gdsdb_event_rid;
133
/* gdsdb_ddl */
134
static int hf_gdsdb_ddl_database;
135
static int hf_gdsdb_ddl_transaction;
136
static int hf_gdsdb_ddl_blr;
137
/* gdsdb_slice */
138
static int hf_gdsdb_slice_transaction;
139
static int hf_gdsdb_slice_id;
140
static int hf_gdsdb_slice_sdl;
141
static int hf_gdsdb_slice_parameters;
142
/* gdsdb_slice_response */
143
static int hf_gdsdb_sliceresponse_length;
144
#endif
145
/* gdsdb_execute */
146
static int hf_gdsdb_execute_statement;
147
static int hf_gdsdb_execute_transaction;
148
static int hf_gdsdb_execute_message_number;
149
static int hf_gdsdb_execute_messages;
150
#if 0
151
/* gdsdb_execute2 */
152
static int hf_gdsdb_execute_outblr;
153
static int hf_gdsdb_execute_outmsgnr;
154
/* gdsdb_exec_immediate2 */
155
static int hf_gdsdb_prepare2_blr;
156
static int hf_gdsdb_prepare2_number;
157
static int hf_gdsdb_prepare2_messages;
158
static int hf_gdsdb_prepare2_outblr;
159
static int hf_gdsdb_prepare2_outmsgnr;
160
#endif
161
/* gdsdb_prepare */
162
static int hf_gdsdb_prepare_transaction;
163
static int hf_gdsdb_prepare_statement;
164
static int hf_gdsdb_prepare_dialect;
165
static int hf_gdsdb_prepare_querystr;
166
static int hf_gdsdb_prepare_bufferlength;
167
#if 0
168
/* gdsdb_fetch */
169
static int hf_gdsdb_fetch_statement;
170
static int hf_gdsdb_fetch_message_number;
171
static int hf_gdsdb_fetch_messages;
172
#endif
173
/* gdsdb_fetch_response */
174
static int hf_gdsdb_fetchresponse_status;
175
static int hf_gdsdb_fetchresponse_messages;
176
/* gdsdb_free_statement */
177
static int hf_gdsdb_free_statement;
178
static int hf_gdsdb_free_option;
179
#if 0
180
/* gdsdb_insert */
181
static int hf_gdsdb_insert_statement;
182
static int hf_gdsdb_insert_message_number;
183
static int hf_gdsdb_insert_messages;
184
/* gdsdb_cursor */
185
static int hf_gdsdb_cursor_statement;
186
static int hf_gdsdb_cursor_type;
187
/* gdsdb_sql_response */
188
static int hf_gdsdb_sqlresponse_messages;
189
#endif
190
191
static expert_field ei_gdsdb_invalid_length;
192
193
enum
194
{
195
  op_void                   = 0,
196
  op_connect                = 1,
197
  op_exit                   = 2,
198
  op_accept                 = 3,
199
  op_reject                 = 4,
200
  op_protocol               = 5,
201
  op_disconnect             = 6,
202
  op_credit                 = 7,
203
  op_continuation           = 8,
204
  op_response               = 9,
205
  op_open_file              = 10,
206
  op_create_file            = 11,
207
  op_close_file             = 12,
208
  op_read_page              = 13,
209
  op_write_page             = 14,
210
  op_lock                   = 15,
211
  op_convert_lock           = 16,
212
  op_release_lock           = 17,
213
  op_blocking               = 18,
214
  op_attach                 = 19,
215
  op_create                 = 20,
216
  op_detach                 = 21,
217
  op_compile                = 22,
218
  op_start                  = 23,
219
  op_start_and_send         = 24,
220
  op_send                   = 25,
221
  op_receive                = 26,
222
  op_unwind                 = 27,
223
  op_release                = 28,
224
  op_transaction            = 29,
225
  op_commit                 = 30,
226
  op_rollback               = 31,
227
  op_prepare                = 32,
228
  op_reconnect              = 33,
229
  op_create_blob            = 34,
230
  op_open_blob              = 35,
231
  op_get_segment            = 36,
232
  op_put_segment            = 37,
233
  op_cancel_blob            = 38,
234
  op_close_blob             = 39,
235
  op_info_database          = 40,
236
  op_info_request           = 41,
237
  op_info_transaction       = 42,
238
  op_info_blob              = 43,
239
  op_batch_segments         = 44,
240
  op_mgr_set_affinity       = 45,
241
  op_mgr_clear_affinity     = 46,
242
  op_mgr_report             = 47,
243
  op_que_events             = 48,
244
  op_cancel_events          = 49,
245
  op_commit_retaining       = 50,
246
  op_prepare2               = 51,
247
  op_event                  = 52,
248
  op_connect_request        = 53,
249
  op_aux_connect            = 54,
250
  op_ddl                    = 55,
251
  op_open_blob2             = 56,
252
  op_create_blob2           = 57,
253
  op_get_slice              = 58,
254
  op_put_slice              = 59,
255
  op_slice                  = 60,
256
  op_seek_blob              = 61,
257
  op_allocate_statement     = 62,
258
  op_execute                = 63,
259
  op_exec_immediate         = 64,
260
  op_fetch                  = 65,
261
  op_fetch_response         = 66,
262
  op_free_statement         = 67,
263
  op_prepare_statement      = 68,
264
  op_set_cursor             = 69,
265
  op_info_sql               = 70,
266
  op_dummy                  = 71,
267
  op_response_piggyback     = 72,
268
  op_start_and_receive      = 73,
269
  op_start_send_and_receive = 74,
270
  op_exec_immediate2        = 75,
271
  op_execute2               = 76,
272
  op_insert                 = 77,
273
  op_sql_response           = 78,
274
  op_transact               = 79,
275
  op_transact_response      = 80,
276
  op_drop_database          = 81,
277
  op_service_attach         = 82,
278
  op_service_detach         = 83,
279
  op_service_info           = 84,
280
  op_service_start          = 85,
281
  op_rollback_retaining     = 86,
282
  op_update_account_info    = 87,
283
  op_authenticate_user      = 88,
284
  op_partial                = 89,
285
  op_trusted_auth           = 90,
286
  op_cancel                 = 91,
287
  op_max
288
};
289
290
static const value_string gdsdb_opcode[] = {
291
  { op_void,                   "Void" },
292
  { op_connect,                "Connect" },
293
  { op_exit,                   "Exit" },
294
  { op_accept,                 "Accept" },
295
  { op_reject,                 "Reject" },
296
  { op_protocol,               "Protocol" },
297
  { op_disconnect,             "Disconnect" },
298
  { op_credit,                 "Credit" },
299
  { op_continuation,           "Continuation" },
300
  { op_response,               "Response" },
301
  { op_open_file,              "Open file" },
302
  { op_create_file,            "Create file" },
303
  { op_close_file,             "Close file" },
304
  { op_read_page,              "Read page" },
305
  { op_write_page,             "Write page" },
306
  { op_lock,                   "Lock" },
307
  { op_convert_lock,           "Convert lock" },
308
  { op_release_lock,           "Release lock" },
309
  { op_blocking,               "Blocking" },
310
  { op_attach,                 "Attach" },
311
  { op_create,                 "Create" },
312
  { op_detach,                 "Detach" },
313
  { op_compile,                "Compile" },
314
  { op_start,                  "Start" },
315
  { op_start_and_send,         "Start and send" },
316
  { op_send,                   "Send" },
317
  { op_receive,                "Receive" },
318
  { op_unwind,                 "Unwind" },
319
  { op_release,                "Release" },
320
  { op_transaction,            "Transaction" },
321
  { op_commit,                 "Commit" },
322
  { op_rollback,               "Rollback" },
323
  { op_prepare,                "Prepare" },
324
  { op_reconnect,              "Reconnect" },
325
  { op_create_blob,            "Create blob" },
326
  { op_open_blob,              "Open blob" },
327
  { op_get_segment,            "Get segment" },
328
  { op_put_segment,            "Put segment" },
329
  { op_cancel_blob,            "Cancel blob" },
330
  { op_close_blob,             "Close blob" },
331
  { op_info_database,          "Info database" },
332
  { op_info_request,           "Info request" },
333
  { op_info_transaction,       "Info transaction" },
334
  { op_info_blob,              "Info blob" },
335
  { op_batch_segments,         "Batch segments" },
336
  { op_mgr_set_affinity,       "Mgr set affinity" },
337
  { op_mgr_clear_affinity,     "Mgr clear affinity" },
338
  { op_mgr_report,             "Mgr report" },
339
  { op_que_events,             "Que events" },
340
  { op_cancel_events,          "Cancel events" },
341
  { op_commit_retaining,       "Commit retaining" },
342
  { op_prepare2,               "Prepare 2" },
343
  { op_event,                  "Event" },
344
  { op_connect_request,        "Connect request" },
345
  { op_aux_connect,            "Aux connect" },
346
  { op_ddl,                    "DDl" },
347
  { op_open_blob2,             "Open blob 2" },
348
  { op_create_blob2,           "Create blob 2" },
349
  { op_get_slice,              "Get slice" },
350
  { op_put_slice,              "Put slice" },
351
  { op_slice,                  "Slice" },
352
  { op_seek_blob,              "Seek blob" },
353
  { op_allocate_statement,     "Allocate statement" },
354
  { op_execute,                "Execute" },
355
  { op_exec_immediate,         "Exec immediate" },
356
  { op_fetch,                  "Fetch" },
357
  { op_fetch_response,         "Fetch response" },
358
  { op_free_statement,         "Free statement" },
359
  { op_prepare_statement,      "Prepare statement" },
360
  { op_set_cursor,             "Set cursor" },
361
  { op_info_sql,               "Info sql" },
362
  { op_dummy,                  "Dummy" },
363
  { op_response_piggyback,     "Response piggyback" },
364
  { op_start_and_receive,      "Start and receive" },
365
  { op_start_send_and_receive, "Start send and receive" },
366
  { op_exec_immediate2,        "Exec immediate 2" },
367
  { op_execute2,               "Execute 2" },
368
  { op_insert,                 "Insert" },
369
  { op_sql_response,           "Sql response" },
370
  { op_transact,               "Transact" },
371
  { op_transact_response,      "Transact response" },
372
  { op_drop_database,          "Drop database" },
373
  { op_service_attach,         "Service attach" },
374
  { op_service_detach,         "Service detach" },
375
  { op_service_info,           "Service info" },
376
  { op_service_start,          "Service start" },
377
  { op_rollback_retaining,     "Rollback retaining" },
378
  { op_update_account_info,    "update_account_info" },
379
  { op_authenticate_user,      "authenticate_user" },
380
  { op_partial,                "partial" },
381
  { op_trusted_auth,           "trusted_auth" },
382
  { op_cancel,                 "cancel" },
383
  { 0, NULL }
384
};
385
static value_string_ext gdsdb_opcode_ext = VALUE_STRING_EXT_INIT(gdsdb_opcode);
386
387
388
static const value_string gdsdb_architectures[] = {
389
  {  1, "Generic" },
390
  {  2, "Apollo" },
391
  {  3, "Sun" },
392
  {  4, "Vms" },
393
  {  5, "Ultrix" },
394
  {  6, "Alliant" },
395
  {  7, "MS-Dos" },
396
  {  8, "Sun 4" },
397
  {  9, "Sun 386" },
398
  { 10, "HP-UX" },
399
  { 11, "HP MPE/xl" },
400
  { 12, "Mac" },
401
  { 13, "Mac aux" },
402
  { 14, "rt" },
403
  { 15, "mips Ultrix" },
404
  { 16, "HP-UX 68k" },
405
  { 17, "Xenix" },
406
  { 18, "Aviion" },
407
  { 19, "SGI" },
408
  { 20, "Apollo_dn10k" },
409
  { 21, "Cray" },
410
  { 22, "Imp" },
411
  { 23, "Delta" },
412
  { 24, "SCO" },
413
  { 25, "Next" },
414
  { 26, "Next 386" },
415
  { 27, "m88k" },
416
  { 28, "UnixWare" },
417
  { 29, "Intel 32" },
418
  { 30, "Epson" },
419
  { 31, "Decosf" },
420
  { 32, "Ncr3000" },
421
  { 33, "NT PPC" },
422
  { 34, "DG x86" },
423
  { 35, "SCO ev" },
424
  { 36, "Linux" },
425
  { 37, "FreeBSD"  },
426
  { 38, "NetBSD" },
427
  { 39, "Darwin PPC" },
428
  { 0, NULL }
429
};
430
431
enum
432
{
433
  arg_end = 0,
434
  arg_gds = 1,
435
  arg_string = 2,
436
  arg_cstring = 3,
437
  arg_number = 4,
438
  arg_interpreted = 5,
439
  arg_vms = 6,
440
  arg_unix = 7,
441
  arg_domain = 8,
442
  arg_dos = 9,
443
  arg_mpexl = 10,
444
  arg_mpexl_ipc = 11,
445
  arg_next_mach = 15,
446
  arg_netware = 16,
447
  arg_win32 = 17,
448
  arg_warning = 18,
449
  arg_sql_state = 19
450
};
451
452
static const value_string gdsdb_arg_types[] = {
453
  {  arg_end,  "end of argument list" },
454
  {  arg_gds,  "generic DSRI" },
455
  {  arg_string,  "string argument" },
456
  {  arg_cstring,  "count & string argument" },
457
  {  arg_number,  "numeric argument" },
458
  {  arg_interpreted,  "interpreted status code" },
459
  {  arg_vms,  "VAX/VMS status code" },
460
  {  arg_unix,  "UNIX error code" },
461
  {  arg_domain,  "Apollo/Domain error code" },
462
  {  arg_dos,  "MSDOS/OS2 error code" },
463
  {  arg_mpexl, "HP MPE/XL error code" },
464
  {  arg_mpexl_ipc, "HP MPE/XL IPC error code" },
465
  {  arg_next_mach, "NeXT/Mach error code" },
466
  {  arg_netware, "NetWare error code" },
467
  {  arg_win32, "Win32 error code" },
468
  {  arg_warning, "warning argument" },
469
  {  arg_sql_state, "SQLSTATE" },
470
  { 0, NULL }
471
};
472
473
static const value_string gdsdb_response_status_vals[] = {
474
  { 0, "success" },
475
  { 100, "end of cursor" },
476
  { 0, NULL }
477
};
478
479
static int dword_align(int length)
480
0
{
481
0
  return WS_ROUNDUP_4(length);
482
0
}
483
484
static int add_uint_string(proto_tree *tree, int hf_string, tvbuff_t *tvb, int offset)
485
0
{
486
0
  proto_item* ti;
487
0
  int length;
488
489
0
  ti = proto_tree_add_item(tree, hf_string, tvb,
490
0
            offset, 4, ENC_ASCII|ENC_BIG_ENDIAN);
491
0
  length = dword_align(tvb_get_ntohl(tvb, offset))+4;
492
0
  proto_item_set_len(ti, length);
493
0
  int ret_offset = offset + length;
494
0
  if (length < 4 || ret_offset < offset) {
495
0
    expert_add_info_format(NULL, ti, &ei_gdsdb_invalid_length, "Invalid length: %d", length);
496
0
    return tvb_reported_length(tvb);
497
0
  }
498
0
  return ret_offset;
499
0
}
500
501
static int add_byte_array(proto_tree *tree, int hf_len, int hf_byte, tvbuff_t *tvb, int offset)
502
0
{
503
0
  proto_item* ti;
504
0
  uint32_t length;
505
506
0
  proto_tree_add_item_ret_uint(tree, hf_len, tvb,
507
0
            offset, 4, ENC_BIG_ENDIAN, &length);
508
0
  offset += 4;
509
0
  if (length > 0)
510
0
  {
511
0
    ti = proto_tree_add_item(tree, hf_byte, tvb,
512
0
            offset, length, ENC_NA);
513
0
    length = dword_align(length);
514
0
    proto_item_set_len(ti, length);
515
0
  }
516
0
  return offset + length;
517
0
}
518
519
static int
520
gdsdb_dummy(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, int offset _U_)
521
1
{
522
  /* Ignore data */
523
1
  return tvb_reported_length(tvb);
524
1
}
525
526
static int
527
gdsdb_connect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
528
0
{
529
0
  int count, file_size, total_length = 16;
530
0
  int i, length = tvb_reported_length_remaining(tvb, offset);
531
0
  proto_item *ti;
532
0
  proto_tree *pref_tree;
533
534
  /* Calculate if we need more data */
535
0
  if (length < total_length)
536
0
    return -1;
537
538
0
  file_size = tvb_get_ntohl(tvb, offset+12);
539
0
  total_length += 4+dword_align(file_size);
540
0
  if (length < total_length+4)
541
0
    return -1;
542
543
0
  count = tvb_get_ntohl(tvb, offset+total_length-4);
544
0
  if (count < 0 || count > 255) {
545
    /* This is a 32-bit integer on the wire but as a count of
546
     * the number of supported protocol versions to follow, it
547
     * should never have the high bytes set. */
548
0
    expert_add_info(pinfo, NULL, &ei_gdsdb_invalid_length);
549
0
    return tvb_reported_length(tvb);
550
0
  }
551
0
  total_length += (4+(count*20));
552
0
  if (length < total_length)
553
0
    return -1;
554
555
0
  proto_tree_add_item(tree, hf_gdsdb_connect_operation, tvb,
556
0
              offset, 4, ENC_BIG_ENDIAN);
557
0
  offset += 4;
558
0
  proto_tree_add_item(tree, hf_gdsdb_connect_version, tvb,
559
0
              offset, 4, ENC_BIG_ENDIAN);
560
0
  offset += 4;
561
0
  proto_tree_add_item(tree, hf_gdsdb_connect_client, tvb,
562
0
              offset, 4, ENC_BIG_ENDIAN);
563
0
  offset += 4;
564
0
  offset = add_uint_string(tree, hf_gdsdb_connect_filename, tvb, offset);
565
566
0
  proto_tree_add_item(tree, hf_gdsdb_connect_count, tvb,
567
0
              offset, 4, ENC_BIG_ENDIAN);
568
0
  offset += 4;
569
0
  col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", tvb_format_text(pinfo->pool, tvb, offset+4, tvb_get_ntohl(tvb, offset)));
570
0
  offset = add_uint_string(tree, hf_gdsdb_connect_userid, tvb, offset);
571
572
0
  for(i=0;i<count;i++){
573
0
    ti = proto_tree_add_item(tree, hf_gdsdb_connect_pref, tvb, offset, 20, ENC_NA);
574
0
    pref_tree = proto_item_add_subtree(ti, ett_gdsdb_connect_pref);
575
576
0
    proto_tree_add_item(pref_tree, hf_gdsdb_connect_pref_version,
577
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
578
0
    offset += 4;
579
0
    proto_tree_add_item(pref_tree, hf_gdsdb_connect_pref_architecture,
580
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
581
0
    offset += 4;
582
0
    proto_tree_add_item(pref_tree, hf_gdsdb_connect_pref_mintype,
583
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
584
0
    offset += 4;
585
0
    proto_tree_add_item(pref_tree, hf_gdsdb_connect_pref_maxtype,
586
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
587
0
    offset += 4;
588
0
    proto_tree_add_item(pref_tree, hf_gdsdb_connect_pref_weight,
589
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
590
0
    offset += 4;
591
0
  }
592
593
0
  return offset;
594
0
}
595
596
static int
597
gdsdb_accept(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
598
0
{
599
  /* Calculate if we need more data */
600
0
  if (tvb_reported_length_remaining(tvb, offset) < 12) {
601
0
    return -1;
602
0
  }
603
604
0
  proto_tree_add_item(tree, hf_gdsdb_accept_version, tvb,
605
0
              offset, 4, ENC_BIG_ENDIAN);
606
0
  offset += 4;
607
0
  proto_tree_add_item(tree, hf_gdsdb_accept_architecture, tvb,
608
0
              offset, 4, ENC_BIG_ENDIAN);
609
0
  offset += 4;
610
0
  proto_tree_add_item(tree, hf_gdsdb_accept_proto_min_type, tvb,
611
0
              offset, 4, ENC_BIG_ENDIAN);
612
0
  offset += 4;
613
614
0
  return offset;
615
0
}
616
617
static int
618
gdsdb_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
619
0
{
620
  /* Calculate if we need more data */
621
0
  if (tvb_reported_length_remaining(tvb, offset) < 16) {
622
0
    return -1;
623
0
  }
624
625
0
  proto_tree_add_item(tree, hf_gdsdb_request_type, tvb, offset, 4, ENC_BIG_ENDIAN);
626
0
  offset += 4;
627
628
0
  proto_tree_add_item(tree, hf_gdsdb_request_object, tvb, offset, 4, ENC_BIG_ENDIAN);
629
0
  offset += 4;
630
631
0
  proto_tree_add_item(tree, hf_gdsdb_request_partner, tvb, offset, 8, ENC_BIG_ENDIAN);
632
0
  offset += 8;
633
634
0
  return offset;
635
0
}
636
637
static int
638
gdsdb_attach(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
639
0
{
640
0
  int total_length = 12;
641
0
  int size, length = tvb_reported_length_remaining(tvb, offset);
642
643
  /* Calculate if we need more data */
644
0
  if (length < total_length) {
645
0
    return -1;
646
0
  }
647
648
0
  size = tvb_get_ntohl(tvb, offset+4);
649
0
  total_length += dword_align(size);
650
0
  if (length < total_length)
651
0
    return -1;
652
653
0
  size = tvb_get_ntohl(tvb, offset+total_length-4);
654
0
  total_length += dword_align(size);
655
0
  if (length < total_length)
656
0
    return -1;
657
658
0
  proto_tree_add_item(tree, hf_gdsdb_attach_database_object_id, tvb, offset, 4, ENC_BIG_ENDIAN);
659
0
  offset += 4;
660
661
0
  col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", tvb_format_text(pinfo->pool, tvb, offset+4, tvb_get_ntohl(tvb, offset)));
662
0
  offset = add_uint_string(tree, hf_gdsdb_attach_database_path, tvb, offset);
663
0
  offset = add_uint_string(tree, hf_gdsdb_attach_database_param_buf, tvb, offset);
664
665
0
  return offset;
666
0
}
667
668
static int
669
gdsdb_compile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
670
0
{
671
0
  int total_length = 8;
672
0
  int size, length = tvb_reported_length_remaining(tvb, offset);
673
674
  /* Calculate if we need more data */
675
0
  if (length < total_length) {
676
0
    return -1;
677
0
  }
678
679
0
  size = tvb_get_ntohl(tvb, offset+4);
680
0
  total_length += dword_align(size);
681
0
  if (length < total_length)
682
0
    return -1;
683
684
0
  proto_tree_add_item(tree, hf_gdsdb_compile_database, tvb, offset, 4, ENC_BIG_ENDIAN);
685
0
  offset += 4;
686
687
0
  offset = add_uint_string(tree, hf_gdsdb_compile_blr, tvb, offset);
688
689
0
  return offset;
690
0
}
691
692
static int
693
gdsdb_receive(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
694
0
{
695
  /* Calculate if we need more data */
696
0
  if (tvb_reported_length_remaining(tvb, offset) < 20) {
697
0
    return -1;
698
0
  }
699
700
0
  proto_tree_add_item(tree, hf_gdsdb_receive_request, tvb,
701
0
              offset, 4, ENC_BIG_ENDIAN);
702
0
  offset += 4;
703
0
  proto_tree_add_item(tree, hf_gdsdb_receive_incarnation, tvb,
704
0
              offset, 4, ENC_BIG_ENDIAN);
705
0
  offset += 4;
706
0
  proto_tree_add_item(tree, hf_gdsdb_receive_transaction, tvb,
707
0
              offset, 4, ENC_BIG_ENDIAN);
708
0
  offset += 4;
709
0
  proto_tree_add_item(tree, hf_gdsdb_receive_msgnr, tvb,
710
0
              offset, 4, ENC_BIG_ENDIAN);
711
0
  offset += 4;
712
0
  proto_tree_add_item(tree, hf_gdsdb_receive_messages, tvb,
713
0
              offset, 4, ENC_BIG_ENDIAN);
714
0
  offset += 4;
715
0
  while (tvb_reported_length_remaining(tvb, offset) >= 12) {
716
0
    proto_tree_add_item(tree, hf_gdsdb_receive_direction,
717
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
718
0
    offset += 4;
719
0
    proto_tree_add_item(tree, hf_gdsdb_receive_offset,
720
0
             tvb, offset, 8, ENC_BIG_ENDIAN);
721
0
    offset += 8;
722
0
  }
723
724
0
  return offset;
725
0
}
726
727
static int
728
gdsdb_send(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
729
0
{
730
  /* Calculate if we need more data */
731
0
  if (tvb_reported_length_remaining(tvb, offset) < 20) {
732
0
    return -1;
733
0
  }
734
735
0
  proto_tree_add_item(tree, hf_gdsdb_send_request, tvb,
736
0
              offset, 4, ENC_BIG_ENDIAN);
737
0
  offset += 4;
738
0
  proto_tree_add_item(tree, hf_gdsdb_send_incarnation, tvb,
739
0
              offset, 4, ENC_BIG_ENDIAN);
740
0
  offset += 4;
741
0
  proto_tree_add_item(tree, hf_gdsdb_send_transaction, tvb,
742
0
              offset, 4, ENC_BIG_ENDIAN);
743
0
  offset += 4;
744
0
  proto_tree_add_item(tree, hf_gdsdb_send_msgnr, tvb,
745
0
              offset, 4, ENC_BIG_ENDIAN);
746
0
  offset += 4;
747
0
  proto_tree_add_item(tree, hf_gdsdb_send_messages, tvb,
748
0
              offset, 4, ENC_BIG_ENDIAN);
749
0
  offset += 4;
750
751
0
  return offset;
752
0
}
753
754
static int
755
gdsdb_status_vector(proto_tree *tree, tvbuff_t *tvb, int offset)
756
0
{
757
0
  uint32_t arg;
758
0
  while (tvb_reported_length_remaining(tvb, offset) >= 4)
759
0
  {
760
0
    proto_tree_add_item_ret_uint(tree, hf_gdsdb_status_vector_arg, tvb,
761
0
              offset, 4, ENC_BIG_ENDIAN, &arg);
762
0
    offset += 4;
763
0
    if (arg == 0)
764
0
      break;
765
766
0
    switch(arg)
767
0
    {
768
0
    case arg_gds:
769
0
    default:
770
0
      proto_tree_add_item(tree, hf_gdsdb_status_vector_error_code, tvb,
771
0
              offset, 4, ENC_BIG_ENDIAN);
772
0
      offset += 4;
773
0
      break;
774
0
    case arg_number:
775
0
      proto_tree_add_item(tree, hf_gdsdb_status_vector_number, tvb,
776
0
              offset, 4, ENC_BIG_ENDIAN);
777
0
      offset += 4;
778
0
      break;
779
0
    case arg_string:
780
0
    case arg_interpreted:
781
0
      offset = add_uint_string(tree, hf_gdsdb_status_vector_string, tvb, offset);
782
0
      break;
783
0
    case arg_sql_state:
784
0
      offset = add_uint_string(tree, hf_gdsdb_status_vector_sql_state, tvb, offset);
785
0
      break;
786
0
    }
787
0
  }
788
789
0
  return offset;
790
0
}
791
792
static int
793
gdsdb_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
794
0
{
795
0
  int total_length = 16;
796
0
  int length = tvb_reported_length_remaining(tvb, offset);
797
798
  /* Calculate if we need more data */
799
0
  if (length < total_length) {
800
0
    return -1;
801
0
  }
802
803
0
  total_length += dword_align(tvb_get_ntohl(tvb, offset+12));
804
0
  if (length < total_length) {
805
0
    return -1;
806
0
  }
807
808
0
  proto_tree_add_item(tree, hf_gdsdb_response_object, tvb,
809
0
              offset, 4, ENC_BIG_ENDIAN);
810
0
  offset += 4;
811
0
  proto_tree_add_item(tree, hf_gdsdb_response_blobid, tvb,
812
0
              offset, 8, ENC_BIG_ENDIAN);
813
0
  offset += 8;
814
0
  offset = add_byte_array(tree, hf_gdsdb_response_datasize, hf_gdsdb_response_data, tvb, offset);
815
816
0
  return gdsdb_status_vector(tree, tvb, offset);
817
0
}
818
819
static int
820
gdsdb_transact(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
821
0
{
822
  /* Calculate if we need more data */
823
0
  if (tvb_reported_length_remaining(tvb, offset) < 8) {
824
0
    return -1;
825
0
  }
826
827
0
  proto_tree_add_item(tree, hf_gdsdb_transact_database, tvb,
828
0
              offset, 4, ENC_BIG_ENDIAN);
829
0
  offset += 4;
830
0
  proto_tree_add_item(tree, hf_gdsdb_transact_transaction, tvb,
831
0
              offset, 4, ENC_BIG_ENDIAN);
832
0
  offset += 4;
833
834
0
  return offset;
835
0
}
836
837
static int
838
gdsdb_transact_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
839
0
{
840
  /* Calculate if we need more data */
841
0
  if (tvb_reported_length_remaining(tvb, offset) < 4) {
842
0
    return -1;
843
0
  }
844
845
0
  proto_tree_add_item(tree, hf_gdsdb_transactresponse_messages,
846
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
847
0
  offset += 4;
848
849
0
  return offset;
850
0
}
851
852
static int
853
gdsdb_open_blob2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
854
0
{
855
0
  int total_length = 12;
856
0
  int length = tvb_reported_length_remaining(tvb, offset);
857
858
  /* Calculate if we need more data */
859
0
  if (length < total_length) {
860
0
    return -1;
861
0
  }
862
863
0
  total_length += dword_align(tvb_get_ntohl(tvb, offset));
864
0
  if (length < total_length) {
865
0
    return -1;
866
0
  }
867
868
0
  offset = add_uint_string(tree, hf_gdsdb_openblob2_bpb, tvb, offset);
869
870
0
  proto_tree_add_item(tree, hf_gdsdb_openblob_transaction, tvb,
871
0
              offset, 4, ENC_BIG_ENDIAN);
872
0
  offset += 4;
873
0
  proto_tree_add_item(tree, hf_gdsdb_openblob_id, tvb, offset,
874
0
                8, ENC_BIG_ENDIAN);
875
0
  offset += 8;
876
877
0
  return offset;
878
0
}
879
880
static int
881
gdsdb_open_blob(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
882
0
{
883
  /* Calculate if we need more data */
884
0
  if (tvb_reported_length_remaining(tvb, offset) < 8) {
885
0
    return -1;
886
0
  }
887
888
0
  proto_tree_add_item(tree, hf_gdsdb_openblob_transaction, tvb,
889
0
              offset, 4, ENC_BIG_ENDIAN);
890
0
  offset += 4;
891
0
  proto_tree_add_item(tree, hf_gdsdb_openblob_id, tvb, offset,
892
0
                8, ENC_BIG_ENDIAN);
893
0
  offset += 8;
894
895
0
  return offset;
896
0
}
897
898
static int
899
gdsdb_segment(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
900
0
{
901
  /* Calculate if we need more data */
902
0
  if (tvb_reported_length_remaining(tvb, offset) < 12)
903
0
    return -1;
904
905
0
  if (tree) {
906
/* hf_gdsdb_segment_blob */
907
/* hf_gdsdb_segment_length */
908
/* add_uint_string(hf_gdsdb_segment_segment )*/
909
0
  }
910
911
0
  return tvb_reported_length(tvb);
912
0
}
913
914
static int
915
gdsdb_seek_blob(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
916
0
{
917
  /* Calculate if we need more data */
918
0
  if (tvb_reported_length_remaining(tvb, offset) < 12)
919
0
    return -1;
920
921
0
  if (tree) {
922
/* hf_gdsdb_seekblob_blob */
923
/* hf_gdsdb_seekblob_mode */
924
0
  }
925
926
0
  return tvb_reported_length(tvb);
927
0
}
928
929
static int
930
gdsdb_reconnect(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
931
0
{
932
0
  int total_length = 8;
933
0
  int length = tvb_reported_length_remaining(tvb, offset);
934
935
  /* Calculate if we need more data */
936
0
  if (length < total_length) {
937
0
    return -1;
938
0
  }
939
940
0
  total_length += dword_align(tvb_get_ntohl(tvb, offset+4));
941
0
  if (length < total_length) {
942
0
    return -1;
943
0
  }
944
945
0
  proto_tree_add_item(tree, hf_gdsdb_reconnect_handle, tvb, offset,
946
0
                4, ENC_BIG_ENDIAN);
947
0
  offset += 4;
948
0
  offset = add_byte_array(tree, hf_gdsdb_reconnect_database_size, hf_gdsdb_reconnect_database, tvb, offset);
949
950
0
  return offset;
951
0
}
952
953
static int
954
gdsdb_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
955
0
{
956
0
  unsigned opcode;
957
0
  int total_length = 16;
958
0
  int length = tvb_reported_length_remaining(tvb, offset);
959
960
  /* Calculate if we need more data */
961
0
  if (length < total_length) {
962
0
    return -1;
963
0
  }
964
965
0
  opcode = tvb_get_ntohl(tvb, offset-4);
966
967
0
  total_length += dword_align(tvb_get_ntohl(tvb, offset+8));
968
0
  if (length < total_length) {
969
0
    return -1;
970
0
  }
971
972
0
  if(opcode == op_service_info) {
973
0
    total_length += dword_align(tvb_get_ntohl(tvb, offset+total_length-8));
974
0
    if (length < total_length) {
975
0
      return -1;
976
0
    }
977
0
  }
978
979
0
  proto_tree_add_item(tree, hf_gdsdb_info_object, tvb, offset,
980
0
                4, ENC_BIG_ENDIAN);
981
0
  offset += 4;
982
0
  proto_tree_add_item(tree, hf_gdsdb_info_incarnation, tvb,
983
0
              offset, 4, ENC_BIG_ENDIAN);
984
0
  offset += 4;
985
986
0
  offset = add_uint_string(tree, hf_gdsdb_info_items, tvb, offset);
987
0
  if(opcode == op_service_info) {
988
0
    offset = add_uint_string(tree, hf_gdsdb_info_recv_items, tvb, offset);
989
0
  }
990
991
0
  proto_tree_add_item(tree, hf_gdsdb_info_buffer_length, tvb,
992
0
              offset, 4, ENC_BIG_ENDIAN);
993
0
  offset += 4;
994
995
0
  return offset;
996
0
}
997
998
static int
999
gdsdb_service_start(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1000
0
{
1001
  /* Calculate if we need more data */
1002
0
  if (tvb_reported_length_remaining(tvb, offset) < 16)
1003
0
    return -1;
1004
1005
0
  if (tree) {
1006
/* hf_gdsdb_info_object */
1007
/* hf_gdsdb_info_incarnation */
1008
/* hf_gdsdb_info_items */
1009
/* hf_gdsdb_info_buffer_length */
1010
0
  }
1011
1012
0
  return tvb_reported_length(tvb);
1013
0
}
1014
1015
static int
1016
gdsdb_release(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1017
1
{
1018
  /* Calculate if we need more data */
1019
1
  if (tvb_reported_length_remaining(tvb, offset) < 4)
1020
0
    return -1;
1021
1022
1
  proto_tree_add_item(tree, hf_gdsdb_release_object, tvb, offset,
1023
1
                4, ENC_BIG_ENDIAN);
1024
  /* offset += 4; */
1025
1026
  /* Unsure dissection is complete, so don't allow other commands to
1027
    follow by returning offset*/
1028
1
  return tvb_reported_length(tvb);
1029
1
}
1030
1031
#if 0
1032
static int
1033
gdsdb_prepare2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1034
{
1035
  /* Calculate if we need more data */
1036
  if (tvb_reported_length_remaining(tvb, offset) < 8)
1037
    return -1;
1038
1039
  if (tree) {
1040
/* hf_gdsdb_prepare2_transaction */
1041
  }
1042
1043
  return tvb_reported_length(tvb);
1044
}
1045
#endif
1046
1047
static int
1048
gdsdb_event(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1049
0
{
1050
  /* Calculate if we need more data */
1051
0
  if (tvb_reported_length_remaining(tvb, offset) < 20)
1052
0
    return -1;
1053
1054
0
  if (tree) {
1055
/* hf_gdsdb_event_database */
1056
/* add_uint_string(hf_gdsdb_event_items) */
1057
/* hf_gdsdb_event_ast */
1058
/* hf_gdsdb_event_arg */
1059
/* hf_gdsdb_event_rid */
1060
0
  }
1061
1062
0
  return tvb_reported_length(tvb);
1063
0
}
1064
1065
static int
1066
gdsdb_cancel_events(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1067
0
{
1068
  /* Calculate if we need more data */
1069
0
  if (tvb_reported_length_remaining(tvb, offset) < 8)
1070
0
    return -1;
1071
1072
0
  if (tree) {
1073
/* hf_gdsdb_event_database */
1074
0
  }
1075
1076
0
  return tvb_reported_length(tvb);
1077
0
}
1078
1079
static int
1080
gdsdb_ddl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1081
0
{
1082
  /* Calculate if we need more data */
1083
0
  if (tvb_reported_length_remaining(tvb, offset) < 12)
1084
0
    return -1;
1085
1086
0
  if (tree) {
1087
/* hf_gdsdb_ddl_database */
1088
/* hf_gdsdb_ddl_transaction */
1089
/* add_uint_string(hf_gdsdb_ddl_blr) */
1090
0
  }
1091
1092
0
  return tvb_reported_length(tvb);
1093
0
}
1094
1095
static int
1096
gdsdb_slice(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1097
0
{
1098
  /* Calculate if we need more data */
1099
0
  if (tvb_reported_length_remaining(tvb, offset) < 20)
1100
0
    return -1;
1101
1102
0
  if (tree) {
1103
/* hf_gdsdb_slice_transaction */
1104
/* hf_gdsdb_slice_id */
1105
/* add_uint_string(hf_gdsdb_slice_sdl) */
1106
/* hf_gdsdb_slice_parameters */
1107
0
  }
1108
1109
0
  return tvb_reported_length(tvb);
1110
0
}
1111
1112
static int
1113
gdsdb_slice_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1114
0
{
1115
  /* Calculate if we need more data */
1116
0
  if (tvb_reported_length_remaining(tvb, offset) < 4)
1117
0
    return -1;
1118
1119
0
  if (tree) {
1120
/* hf_gdsdb_sliceresponse_length */
1121
0
  }
1122
1123
0
  return tvb_reported_length(tvb);
1124
0
}
1125
1126
static int
1127
gdsdb_execute(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1128
0
{
1129
  /* Calculate if we need more data */
1130
0
  if (tvb_reported_length_remaining(tvb, offset) < 16)
1131
0
    return -1;
1132
1133
0
  proto_tree_add_item(tree, hf_gdsdb_execute_statement, tvb,
1134
0
              offset, 4, ENC_BIG_ENDIAN);
1135
0
  offset += 4;
1136
0
  proto_tree_add_item(tree, hf_gdsdb_execute_transaction, tvb,
1137
0
              offset, 4, ENC_BIG_ENDIAN);
1138
0
  offset += 4;
1139
0
  proto_tree_add_item(tree, hf_gdsdb_execute_message_number, tvb,
1140
0
              offset, 4, ENC_BIG_ENDIAN);
1141
0
  offset += 4;
1142
0
  proto_tree_add_item(tree, hf_gdsdb_execute_messages, tvb,
1143
0
              offset, 4, ENC_BIG_ENDIAN);
1144
  /* offset += 4; */
1145
1146
  /* Unsure dissection is complete, so don't allow other commands to
1147
    follow by returning offset*/
1148
0
  return tvb_reported_length(tvb);
1149
0
}
1150
1151
static int
1152
gdsdb_exec_immediate2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1153
0
{
1154
  /* Calculate if we need more data */
1155
0
  if (tvb_reported_length_remaining(tvb, offset) < 40)
1156
0
    return -1;
1157
1158
0
  if (tree) {
1159
/* hf_gdsdb_prepare2_blr */
1160
/* hf_gdsdb_prepare2_number */
1161
/* hf_gdsdb_prepare2_messages */
1162
/* hf_gdsdb_prepare2_outblr */
1163
/* hf_gdsdb_prepare2_outmsgnr */
1164
0
  }
1165
1166
0
  return tvb_reported_length(tvb);
1167
0
}
1168
1169
static int
1170
gdsdb_prepare(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
1171
0
{
1172
0
  int total_length = 20;
1173
0
  int length = tvb_reported_length_remaining(tvb, offset);
1174
1175
  /* Calculate if we need more data */
1176
0
  if (length < total_length) {
1177
0
    return -1;
1178
0
  }
1179
1180
0
  total_length += dword_align(tvb_get_ntohl(tvb, offset+12));
1181
0
  if (length < total_length) {
1182
0
    return -1;
1183
0
  }
1184
1185
0
  proto_tree_add_item(tree, hf_gdsdb_prepare_transaction, tvb,
1186
0
              offset, 4, ENC_BIG_ENDIAN);
1187
0
  offset += 4;
1188
0
  proto_tree_add_item(tree, hf_gdsdb_prepare_statement, tvb,
1189
0
              offset, 4, ENC_BIG_ENDIAN);
1190
0
  offset += 4;
1191
0
  proto_tree_add_item(tree, hf_gdsdb_prepare_dialect, tvb,
1192
0
              offset, 4, ENC_BIG_ENDIAN);
1193
0
  offset += 4;
1194
0
  col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", tvb_format_text(pinfo->pool, tvb, offset+4, tvb_get_ntohl(tvb, offset)));
1195
0
  offset = add_uint_string(tree, hf_gdsdb_prepare_querystr, tvb, offset);
1196
1197
0
  proto_tree_add_item(tree, hf_gdsdb_prepare_bufferlength, tvb,
1198
0
              offset, 4, ENC_BIG_ENDIAN);
1199
0
  offset += 4;
1200
1201
0
  return offset;
1202
0
}
1203
1204
static int
1205
gdsdb_fetch(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1206
0
{
1207
  /* Calculate if we need more data */
1208
0
  if (tvb_reported_length_remaining(tvb, offset) < 12) {
1209
0
    return -1;
1210
0
  }
1211
1212
0
  if (tree) {
1213
/* hf_gdsdb_fetch_statement */
1214
/* hf_gdsdb_fetch_message_number */
1215
/* hf_gdsdb_fetch_messages */
1216
0
  }
1217
1218
0
  return tvb_reported_length(tvb);
1219
0
}
1220
1221
static int
1222
gdsdb_fetch_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1223
0
{
1224
  /* Calculate if we need more data */
1225
0
  if (tvb_reported_length_remaining(tvb, offset) < 8) {
1226
0
    return -1;
1227
0
  }
1228
1229
0
  proto_tree_add_item(tree, hf_gdsdb_fetchresponse_status, tvb,
1230
0
              offset, 4, ENC_BIG_ENDIAN);
1231
0
  offset += 4;
1232
0
  proto_tree_add_item(tree, hf_gdsdb_fetchresponse_messages, tvb,
1233
0
              offset, 4, ENC_BIG_ENDIAN);
1234
  //offset += 4;
1235
1236
0
  return tvb_reported_length(tvb);
1237
0
}
1238
1239
static int
1240
gdsdb_free_statement(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1241
0
{
1242
  /* Calculate if we need more data */
1243
0
  if (tvb_reported_length_remaining(tvb, offset) < 8) {
1244
0
    return -1;
1245
0
  }
1246
1247
0
  proto_tree_add_item(tree, hf_gdsdb_free_statement, tvb,
1248
0
              offset, 4, ENC_BIG_ENDIAN);
1249
0
  offset += 4;
1250
0
  proto_tree_add_item(tree, hf_gdsdb_free_option, tvb,
1251
0
              offset, 4, ENC_BIG_ENDIAN);
1252
0
  offset += 4;
1253
1254
0
  return offset;
1255
0
}
1256
1257
static int
1258
gdsdb_insert(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1259
0
{
1260
  /* Calculate if we need more data */
1261
0
  if (tvb_reported_length_remaining(tvb, offset) < 12) {
1262
0
    return -1;
1263
0
  }
1264
1265
0
  if (tree) {
1266
/* hf_gdsdb_insert_statement */
1267
/* hf_gdsdb_insert_message_number */
1268
/* hf_gdsdb_insert_messages */
1269
0
  }
1270
1271
0
  return tvb_reported_length(tvb);
1272
0
}
1273
1274
static int
1275
gdsdb_cursor(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1276
0
{
1277
  /* Calculate if we need more data */
1278
0
  if (tvb_reported_length_remaining(tvb, offset) < 12) {
1279
0
    return -1;
1280
0
  }
1281
1282
0
  if (tree) {
1283
/* hf_gdsdb_cursor_statement */
1284
/* hf_gdsdb_cursor_type */
1285
0
  }
1286
1287
0
  return tvb_reported_length(tvb);
1288
0
}
1289
1290
static int
1291
gdsdb_sql_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
1292
0
{
1293
  /* Calculate if we need more data */
1294
0
  if (tvb_reported_length_remaining(tvb, offset) < 4) {
1295
0
    return -1;
1296
0
  }
1297
1298
0
  if (tree) {
1299
/* hf_gdsdb_sqlresponse_messages */
1300
0
  }
1301
1302
0
  return tvb_reported_length(tvb);
1303
0
}
1304
1305
static int (* const gdsdb_handle_opcode[])(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) = {
1306
  gdsdb_dummy,             /* op_void */
1307
  gdsdb_connect,           /* op_connect */
1308
  gdsdb_dummy,             /* op_exit */
1309
  gdsdb_accept,            /* op_accept */
1310
  gdsdb_dummy,             /* op_reject */
1311
  gdsdb_dummy,             /* op_protocol */
1312
  gdsdb_dummy,             /* op_disconnect */
1313
  gdsdb_dummy,             /* op_credit */
1314
  gdsdb_dummy,             /* op_continuation */
1315
  gdsdb_response,          /* op_response */
1316
  gdsdb_dummy,             /* op_open_file */
1317
  gdsdb_dummy,             /* op_create_file */
1318
  gdsdb_dummy,             /* op_close_file */
1319
  gdsdb_dummy,             /* op_read_page */
1320
  gdsdb_dummy,             /* op_write_page */
1321
  gdsdb_dummy,             /* op_lock */
1322
  gdsdb_dummy,             /* op_convert_lock */
1323
  gdsdb_dummy,             /* op_release_lock */
1324
  gdsdb_dummy,             /* op_blocking */
1325
  gdsdb_attach,            /* op_attach */
1326
  gdsdb_attach,            /* op_create */
1327
  gdsdb_release,           /* op_detach */
1328
  gdsdb_compile,           /* op_compile */
1329
  gdsdb_receive,           /* op_start */
1330
  gdsdb_send,              /* op_start_and_send */
1331
  gdsdb_send,              /* op_send */
1332
  gdsdb_receive,           /* op_receive */
1333
  gdsdb_release,           /* op_unwind */
1334
  gdsdb_release,           /* op_release */
1335
  gdsdb_reconnect,         /* op_transaction */
1336
  gdsdb_release,           /* op_commit */
1337
  gdsdb_release,           /* op_rollback */
1338
  gdsdb_release,           /* op_prepare */
1339
  gdsdb_reconnect,         /* op_reconnect */
1340
  gdsdb_open_blob2,        /* op_create_blob */
1341
  gdsdb_open_blob,         /* op_open_blob */
1342
  gdsdb_segment,           /* op_get_segment */
1343
  gdsdb_segment,           /* op_put_segment */
1344
  gdsdb_release,           /* op_cancel_blob */
1345
  gdsdb_release,           /* op_close_blob */
1346
  gdsdb_info,              /* op_info_database */
1347
  gdsdb_info,              /* op_info_request */
1348
  gdsdb_info,              /* op_info_transaction */
1349
  gdsdb_info,              /* op_info_blob */
1350
  gdsdb_segment,           /* op_batch_segments */
1351
  gdsdb_dummy,             /* op_mgr_set_affinity */
1352
  gdsdb_dummy,             /* op_mgr_clear_affinity */
1353
  gdsdb_dummy,             /* op_mgr_report */
1354
  gdsdb_event,             /* op_que_events */
1355
  gdsdb_cancel_events,     /* op_cancel_events */
1356
  gdsdb_release,           /* op_commit_retaining */
1357
  gdsdb_release,           /* op_prepare */
1358
  gdsdb_event,             /* op_event */
1359
  gdsdb_request,           /* op_connect_request */
1360
  gdsdb_request,           /* op_aux_connect */
1361
  gdsdb_ddl,               /* op_ddl */
1362
  gdsdb_open_blob2,        /* op_open_blob2 */
1363
  gdsdb_open_blob2,        /* op_create_blob2 */
1364
  gdsdb_slice,             /* op_get_slice */
1365
  gdsdb_slice,             /* op_put_slice */
1366
  gdsdb_slice_response,    /* op_slice */
1367
  gdsdb_seek_blob,         /* op_seek_blob */
1368
  gdsdb_release,           /* op_allocate_statement */
1369
  gdsdb_execute,           /* op_execute */
1370
  gdsdb_prepare,           /* op_exec_immediate */
1371
  gdsdb_fetch,             /* op_fetch */
1372
  gdsdb_fetch_response,    /* op_fetch_response */
1373
  gdsdb_free_statement,    /* op_free_statement */
1374
  gdsdb_prepare,           /* op_prepare_statement */
1375
  gdsdb_cursor,            /* op_set_cursor */
1376
  gdsdb_info,              /* op_info_sql */
1377
  gdsdb_dummy,             /* op_dummy */
1378
  gdsdb_response,          /* op_response_piggyback */
1379
  gdsdb_receive,           /* op_start_and_receive */
1380
  gdsdb_send,              /* op_start_send_and_receive */
1381
  gdsdb_exec_immediate2,   /* op_exec_immediate2 */
1382
  gdsdb_execute,           /* op_execute2 */
1383
  gdsdb_insert,            /* op_insert */
1384
  gdsdb_sql_response,      /* op_sql_response */
1385
  gdsdb_transact,          /* op_transact */
1386
  gdsdb_transact_response, /* op_transact_response */
1387
  gdsdb_release,           /* op_drop_database */
1388
  gdsdb_attach,            /* op_service_attach */
1389
  gdsdb_release,           /* op_service_detach */
1390
  gdsdb_info,              /* op_service_info */
1391
  gdsdb_service_start,     /* op_service_start */
1392
  gdsdb_release,           /* op_rollback_retaining */
1393
  gdsdb_dummy,             /* op_update_account_info */
1394
  gdsdb_dummy,             /* op_authenticate_user */
1395
  gdsdb_dummy,             /* op_partial */
1396
  gdsdb_dummy,             /* op_trusted_auth */
1397
  gdsdb_dummy              /* op_cancel */
1398
};
1399
1400
static int
1401
dissect_gdsdb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1402
5
{
1403
5
  proto_item  *ti;
1404
5
  proto_tree  *gdsdb_tree;
1405
5
  unsigned     opcode;
1406
5
  int          offset = 0;
1407
1408
5
  if (tvb_reported_length(tvb) < 4)
1409
0
    return 0;
1410
1411
  /* Ensure at least the first opcode is valid */
1412
5
  opcode = tvb_get_ntohl(tvb, offset);
1413
5
  if(opcode >= op_max)
1414
3
    return 0;
1415
1416
2
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "GDS DB");
1417
2
  col_clear(pinfo->cinfo, COL_INFO);
1418
1419
4
  while (tvb_reported_length_remaining(tvb, offset) >= 4)
1420
2
  {
1421
2
    opcode = tvb_get_ntohl(tvb, offset);
1422
2
    if(opcode >= op_max) {
1423
      /* At least one opcode has been added to the tree, so
1424
       * abort rather than rejecting the packet. */
1425
0
      return tvb_reported_length(tvb);
1426
0
    }
1427
1428
    /* There is no length field for PDUs, so each opcode must be
1429
     * scanned to determine the length.
1430
     *
1431
     * XXX - This should be done before adding anything to the tree
1432
     * or columns for the opcode. Either there should be separate
1433
     * functions that return the expected length, or the processing
1434
     * functions should set pinfo->desegment_len themselves.
1435
     */
1436
2
    col_append_sep_str(pinfo->cinfo, COL_INFO, ", ",
1437
2
        val_to_str_ext(pinfo->pool, opcode, &gdsdb_opcode_ext, "Unknown opcode %u"));
1438
1439
2
    ti = proto_tree_add_item(tree, proto_gdsdb, tvb, offset, -1, ENC_NA);
1440
2
    gdsdb_tree = proto_item_add_subtree(ti, ett_gdsdb);
1441
2
    proto_tree_add_item(gdsdb_tree, hf_gdsdb_opcode, tvb,
1442
2
                offset, 4, ENC_BIG_ENDIAN);
1443
1444
    /* opcode < op_max */
1445
2
    int old_offset = offset;
1446
2
    offset = gdsdb_handle_opcode[opcode](tvb, pinfo, gdsdb_tree, offset+4);
1447
2
    if (offset <= old_offset) {
1448
0
      expert_add_info(NULL, ti, &ei_gdsdb_invalid_length);
1449
0
      return tvb_reported_length_remaining(tvb, old_offset);
1450
0
    }
1451
2
    if (offset < 0)
1452
0
    {
1453
      /* But at this moment we don't know how much we will need */
1454
0
      pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
1455
0
      return -1; /* need more data */
1456
0
    }
1457
2
  }
1458
1459
2
  return offset;
1460
2
}
1461
1462
void
1463
proto_register_gdsdb(void)
1464
15
{
1465
15
  static hf_register_info hf[] = {
1466
15
    { &hf_gdsdb_opcode,
1467
15
      { "Opcode", "gdsdb.opcode",
1468
15
      FT_UINT32, BASE_DEC|BASE_EXT_STRING, &gdsdb_opcode_ext, 0x0,
1469
15
      NULL, HFILL }
1470
15
    },
1471
    /* gdsdb_dummy */
1472
    /* gdsdb_connect */
1473
15
    { &hf_gdsdb_connect_operation,
1474
15
      { "Operation", "gdsdb.connect.operation",
1475
15
      FT_UINT32, BASE_DEC|BASE_EXT_STRING, &gdsdb_opcode_ext, 0x0,
1476
15
      NULL, HFILL }
1477
15
    },
1478
15
    { &hf_gdsdb_connect_version,
1479
15
      { "Version", "gdsdb.connect.version",
1480
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1481
15
      NULL, HFILL }
1482
15
    },
1483
15
    { &hf_gdsdb_connect_client,
1484
15
      { "Client Architecture", "gdsdb.connect.client",
1485
15
      FT_UINT32, BASE_DEC, VALS(gdsdb_architectures), 0x0,
1486
15
      NULL, HFILL }
1487
15
    },
1488
15
    { &hf_gdsdb_connect_filename,
1489
15
      { "Filename", "gdsdb.connect.filename",
1490
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1491
15
      NULL, HFILL }
1492
15
    },
1493
15
    { &hf_gdsdb_connect_count,
1494
15
      { "Version option count", "gdsdb.connect.count",
1495
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1496
15
      NULL, HFILL }
1497
15
    },
1498
15
    { &hf_gdsdb_connect_userid,
1499
15
      { "User ID", "gdsdb.connect.userid",
1500
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1501
15
      NULL, HFILL }
1502
15
    },
1503
15
    { &hf_gdsdb_connect_pref,
1504
15
      { "Preferred version", "gdsdb.connect.pref",
1505
15
      FT_NONE, BASE_NONE, NULL, 0x0,
1506
15
      NULL, HFILL }
1507
15
    },
1508
15
    { &hf_gdsdb_connect_pref_version,
1509
15
      { "Version", "gdsdb.connect.pref.version",
1510
15
      FT_INT32, BASE_DEC, NULL, 0x0,
1511
15
      NULL, HFILL }
1512
15
    },
1513
15
    { &hf_gdsdb_connect_pref_architecture,
1514
15
      { "Architecture", "gdsdb.connect.pref.arch",
1515
15
      FT_UINT32, BASE_DEC, VALS(gdsdb_architectures), 0x0,
1516
15
      NULL, HFILL }
1517
15
    },
1518
15
    { &hf_gdsdb_connect_pref_mintype,
1519
15
      { "Minimum type", "gdsdb.connect.pref.mintype",
1520
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1521
15
      NULL, HFILL }
1522
15
    },
1523
15
    { &hf_gdsdb_connect_pref_maxtype,
1524
15
      { "Maximum type", "gdsdb.connect.pref.maxtype",
1525
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1526
15
      NULL, HFILL }
1527
15
    },
1528
15
    { &hf_gdsdb_connect_pref_weight,
1529
15
      { "Preference weight", "gdsdb.connect.pref.weight",
1530
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1531
15
      NULL, HFILL }
1532
15
    },
1533
    /* gdsdb_accept */
1534
15
    { &hf_gdsdb_accept_version,
1535
15
      { "Version", "gdsdb.accept.version",
1536
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1537
15
      NULL, HFILL }
1538
15
    },
1539
15
    { &hf_gdsdb_accept_architecture,
1540
15
      { "Architecture", "gdsdb.accept.arch",
1541
15
      FT_UINT32, BASE_DEC, VALS(gdsdb_architectures), 0x0,
1542
15
      NULL, HFILL }
1543
15
    },
1544
15
    { &hf_gdsdb_accept_proto_min_type,
1545
15
      { "Protocol Minimum Type", "gdsdb.accept.proto_min_type",
1546
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1547
15
      NULL, HFILL }
1548
15
    },
1549
    /* gdsdb_request */
1550
15
    { &hf_gdsdb_request_type,
1551
15
      { "Type", "gdsdb.connect.type",
1552
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1553
15
      NULL, HFILL }
1554
15
    },
1555
15
    { &hf_gdsdb_request_object,
1556
15
      { "Object", "gdsdb.connect.object",
1557
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1558
15
      NULL, HFILL }
1559
15
    },
1560
15
    { &hf_gdsdb_request_partner,
1561
15
      { "Partner", "gdsdb.connect.partner",
1562
15
      FT_UINT64, BASE_DEC, NULL, 0x0,
1563
15
      NULL, HFILL }
1564
15
    },
1565
    /* gdsdb_attach */
1566
15
    { &hf_gdsdb_attach_database_object_id,
1567
15
      { "Database ObjectID", "gdsdb.attach.database_object_id",
1568
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1569
15
      NULL, HFILL }
1570
15
    },
1571
15
    { &hf_gdsdb_attach_database_path,
1572
15
      { "Database Path", "gdsdb.attach.database_path",
1573
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1574
15
      NULL, HFILL }
1575
15
    },
1576
15
    { &hf_gdsdb_attach_database_param_buf,
1577
15
      { "Database Parameter Buffers", "gdsdb.attach.database_param_buf",
1578
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1579
15
      NULL, HFILL }
1580
15
    },
1581
    /* gdsdb_compile */
1582
15
    { &hf_gdsdb_compile_database,
1583
15
      { "Database", "gdsdb.compile.filename",
1584
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1585
15
      NULL, HFILL }
1586
15
    },
1587
15
    { &hf_gdsdb_compile_blr,
1588
15
      { "BLR", "gdsdb.compile.blr",
1589
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1590
15
      NULL, HFILL }
1591
15
    },
1592
    /* gdsdb_receive */
1593
15
    { &hf_gdsdb_receive_request,
1594
15
      { "Request", "gdsdb.receive.request",
1595
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1596
15
      NULL, HFILL }
1597
15
    },
1598
15
    { &hf_gdsdb_receive_incarnation,
1599
15
      { "Incarnation", "gdsdb.receive.incarnation",
1600
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1601
15
      NULL, HFILL }
1602
15
    },
1603
15
    { &hf_gdsdb_receive_transaction,
1604
15
      { "Transaction", "gdsdb.receive.transaction",
1605
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1606
15
      NULL, HFILL }
1607
15
    },
1608
15
    { &hf_gdsdb_receive_msgnr,
1609
15
      { "Message number", "gdsdb.receive.msgnr",
1610
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1611
15
      NULL, HFILL }
1612
15
    },
1613
15
    { &hf_gdsdb_receive_messages,
1614
15
      { "Message Count", "gdsdb.receive.msgcount",
1615
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1616
15
      NULL, HFILL }
1617
15
    },
1618
15
    { &hf_gdsdb_receive_direction,
1619
15
      { "Scroll direction", "gdsdb.receive.direction",
1620
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1621
15
      NULL, HFILL }
1622
15
    },
1623
15
    { &hf_gdsdb_receive_offset,
1624
15
      { "Scroll offset", "gdsdb.receive.offset",
1625
15
      FT_UINT64, BASE_DEC, NULL, 0x0,
1626
15
      NULL, HFILL }
1627
15
    },
1628
    /* gdsdb_send */
1629
15
    { &hf_gdsdb_send_request,
1630
15
      { "Send request", "gdsdb.send.request",
1631
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1632
15
      NULL, HFILL }
1633
15
    },
1634
15
    { &hf_gdsdb_send_incarnation,
1635
15
      { "Send request", "gdsdb.send.incarnation",
1636
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1637
15
      NULL, HFILL }
1638
15
    },
1639
15
    { &hf_gdsdb_send_transaction,
1640
15
      { "Send request", "gdsdb.send.transaction",
1641
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1642
15
      NULL, HFILL }
1643
15
    },
1644
15
    { &hf_gdsdb_send_msgnr,
1645
15
      { "Send request", "gdsdb.send.msgnr",
1646
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1647
15
      NULL, HFILL }
1648
15
    },
1649
15
    { &hf_gdsdb_send_messages,
1650
15
      { "Send request", "gdsdb.send.messages",
1651
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1652
15
      NULL, HFILL }
1653
15
    },
1654
    /* gdsdb_response */
1655
15
    { &hf_gdsdb_response_object,
1656
15
      { "Response object", "gdsdb.response.object",
1657
15
      FT_UINT32, BASE_HEX, NULL, 0x0,
1658
15
      NULL, HFILL }
1659
15
    },
1660
15
    { &hf_gdsdb_response_blobid,
1661
15
      { "Blob ID", "gdsdb.response.blobid",
1662
15
      FT_UINT64, BASE_HEX, NULL, 0x0,
1663
15
      NULL, HFILL }
1664
15
    },
1665
15
    { &hf_gdsdb_response_datasize,
1666
15
      { "Data size", "gdsdb.response.datasize",
1667
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1668
15
      NULL, HFILL }
1669
15
    },
1670
15
    { &hf_gdsdb_response_data,
1671
15
      { "Data", "gdsdb.response.data",
1672
15
      FT_BYTES, BASE_NONE, NULL, 0x0,
1673
15
      NULL, HFILL }
1674
15
    },
1675
    /* gdsdb_status_vector */
1676
15
    { &hf_gdsdb_status_vector_arg,
1677
15
      { "Argument", "gdsdb.status_vector.arg",
1678
15
      FT_UINT32, BASE_DEC, VALS(gdsdb_arg_types), 0x0,
1679
15
      NULL, HFILL }
1680
15
    },
1681
15
    { &hf_gdsdb_status_vector_error_code,
1682
15
      { "Error code", "gdsdb.status_vector.error_code",
1683
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1684
15
      NULL, HFILL }
1685
15
    },
1686
15
    { &hf_gdsdb_status_vector_number,
1687
15
      { "Number", "gdsdb.status_vector.number",
1688
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1689
15
      NULL, HFILL }
1690
15
    },
1691
15
    { &hf_gdsdb_status_vector_string,
1692
15
      { "String", "gdsdb.status_vector.string",
1693
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1694
15
      NULL, HFILL }
1695
15
    },
1696
15
    { &hf_gdsdb_status_vector_sql_state,
1697
15
      { "SQL State", "gdsdb.status_vector.sql_state",
1698
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1699
15
      NULL, HFILL }
1700
15
    },
1701
    /* gdsdb_transact */
1702
15
    { &hf_gdsdb_transact_database,
1703
15
      { "Database", "gdsdb.transact.database",
1704
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1705
15
      NULL, HFILL }
1706
15
    },
1707
15
    { &hf_gdsdb_transact_transaction,
1708
15
      { "Database", "gdsdb.transact.transaction",
1709
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1710
15
      NULL, HFILL }
1711
15
    },
1712
#if 0
1713
    { &hf_gdsdb_transact_messages,
1714
      { "Messages", "gdsdb.transact.messages",
1715
      FT_UINT32, BASE_DEC, NULL, 0x0,
1716
      NULL, HFILL }
1717
    },
1718
#endif
1719
    /* gdsdb_transact_response */
1720
15
    { &hf_gdsdb_transactresponse_messages,
1721
15
      { "Messages", "gdsdb.transactresponse.messages",
1722
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1723
15
      NULL, HFILL }
1724
15
    },
1725
    /* gdsdb_open_blob2 */
1726
15
    { &hf_gdsdb_openblob2_bpb,
1727
15
      { "Blob parameter block", "gdsdb.openblob2.bpb",
1728
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1729
15
      NULL, HFILL }
1730
15
    },
1731
    /* gdsdb_open_blob */
1732
15
    { &hf_gdsdb_openblob_transaction,
1733
15
      { "Transaction", "gdsdb.openblob2.transaction",
1734
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1735
15
      NULL, HFILL }
1736
15
    },
1737
15
    { &hf_gdsdb_openblob_id,
1738
15
      { "ID", "gdsdb.openblob.id",
1739
15
      FT_UINT64, BASE_HEX, NULL, 0x0,
1740
15
      NULL, HFILL }
1741
15
    },
1742
#if 0
1743
    /* gdsdb_segment */
1744
    { &hf_gdsdb_segment_blob,
1745
      { "Blob", "gdsdb.segment.blob",
1746
      FT_UINT32, BASE_DEC, NULL, 0x0,
1747
      NULL, HFILL }
1748
    },
1749
    { &hf_gdsdb_segment_length,
1750
      { "Length", "gdsdb.segment.length",
1751
      FT_UINT32, BASE_DEC, NULL, 0x0,
1752
      NULL, HFILL }
1753
    },
1754
    { &hf_gdsdb_segment_segment,
1755
      { "Segment", "gdsdb.segment.segment",
1756
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1757
      NULL, HFILL }
1758
    },
1759
    /* gdsdb_seek_blob */
1760
    { &hf_gdsdb_seekblob_blob,
1761
      { "Blob", "gdsdb.seekblob.blob",
1762
      FT_UINT32, BASE_DEC, NULL, 0x0,
1763
      NULL, HFILL }
1764
    },
1765
    { &hf_gdsdb_seekblob_mode,
1766
      { "Mode", "gdsdb.seekblob.mode",
1767
      FT_UINT32, BASE_DEC, NULL, 0x0,
1768
      NULL, HFILL }
1769
    },
1770
#endif
1771
    /* gdsdb_reconnect */
1772
15
    { &hf_gdsdb_reconnect_handle,
1773
15
      { "Handle", "gdsdb.reconnect.handle",
1774
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1775
15
      NULL, HFILL }
1776
15
    },
1777
15
    { &hf_gdsdb_reconnect_database_size,
1778
15
      { "Database size", "gdsdb.reconnect.database_size",
1779
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1780
15
      NULL, HFILL }
1781
15
    },
1782
15
    { &hf_gdsdb_reconnect_database,
1783
15
      { "Database", "gdsdb.reconnect.database",
1784
15
      FT_BYTES, BASE_NONE, NULL, 0x0,
1785
15
      NULL, HFILL }
1786
15
    },
1787
    /* gdsdb_info & gdsdb_service_start */
1788
15
    { &hf_gdsdb_info_object,
1789
15
      { "Object", "gdsdb.info.object",
1790
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1791
15
      NULL, HFILL }
1792
15
    },
1793
15
    { &hf_gdsdb_info_incarnation,
1794
15
      { "Incarnation", "gdsdb.info.incarnation",
1795
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1796
15
      NULL, HFILL }
1797
15
    },
1798
15
    { &hf_gdsdb_info_items,
1799
15
      { "Items", "gdsdb.info.items",
1800
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1801
15
      NULL, HFILL }
1802
15
    },
1803
15
    { &hf_gdsdb_info_recv_items,
1804
15
      { "Items", "gdsdb.info.recv_items",
1805
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1806
15
      NULL, HFILL }
1807
15
    },
1808
15
    { &hf_gdsdb_info_buffer_length,
1809
15
      { "Buffer length", "gdsdb.info.bufferlength",
1810
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1811
15
      NULL, HFILL }
1812
15
    },
1813
    /* gdsdb_release */
1814
15
    { &hf_gdsdb_release_object,
1815
15
      { "Object", "gdsdb.release.object",
1816
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1817
15
      NULL, HFILL }
1818
15
    },
1819
#if 0
1820
    /* gdsdb_prepare2 */
1821
    { &hf_gdsdb_prepare2_transaction,
1822
      { "Transaction", "gdsdb.prepare2.transaction",
1823
      FT_UINT32, BASE_DEC, NULL, 0x0,
1824
      NULL, HFILL }
1825
    },
1826
    /* gdsdb_event & gdsdb_cancel_events */
1827
    { &hf_gdsdb_event_database,
1828
      { "Database", "gdsdb.event.database",
1829
      FT_UINT32, BASE_DEC, NULL, 0x0,
1830
      NULL, HFILL }
1831
    },
1832
    { &hf_gdsdb_event_items,
1833
      { "Event description block", "gdsdb.event.items",
1834
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1835
      NULL, HFILL }
1836
    },
1837
    { &hf_gdsdb_event_ast,
1838
      { "ast routine", "gdsdb.event.ast",
1839
      FT_UINT32, BASE_DEC, NULL, 0x0,
1840
      NULL, HFILL }
1841
    },
1842
    { &hf_gdsdb_event_arg,
1843
      { "Argument to ast routine", "gdsdb.event.arg",
1844
      FT_UINT32, BASE_DEC, NULL, 0x0,
1845
      NULL, HFILL }
1846
    },
1847
    { &hf_gdsdb_event_rid,
1848
      { "ID", "gdsdb.event.id",
1849
      FT_UINT32, BASE_DEC, NULL, 0x0,
1850
      NULL, HFILL }
1851
    },
1852
    /* gdsdb_ddl */
1853
    { &hf_gdsdb_ddl_database,
1854
      { "Database", "gdsdb.ddl.database",
1855
      FT_UINT32, BASE_DEC, NULL, 0x0,
1856
      NULL, HFILL }
1857
    },
1858
    { &hf_gdsdb_ddl_transaction,
1859
      { "Transaction", "gdsdb.ddl.transaction",
1860
      FT_UINT32, BASE_DEC, NULL, 0x0,
1861
      NULL, HFILL }
1862
    },
1863
    { &hf_gdsdb_ddl_blr,
1864
      { "BLR", "gdsdb.ddl.blr",
1865
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1866
      NULL, HFILL }
1867
    },
1868
    /* gdsdb_slice */
1869
    { &hf_gdsdb_slice_transaction,
1870
      { "Transaction", "gdsdb.slice.transaction",
1871
      FT_UINT32, BASE_DEC, NULL, 0x0,
1872
      NULL, HFILL }
1873
    },
1874
    { &hf_gdsdb_slice_id,
1875
      { "ID", "gdsdb.slice.id",
1876
      FT_UINT64, BASE_HEX, NULL, 0x0,
1877
      NULL, HFILL }
1878
    },
1879
    { &hf_gdsdb_slice_sdl,
1880
      { "Slice description language", "gdsdb.slice.sdl",
1881
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1882
      NULL, HFILL }
1883
    },
1884
    { &hf_gdsdb_slice_parameters,
1885
      { "Parameters", "gdsdb.slice.parameters",
1886
      FT_UINT32, BASE_DEC, NULL, 0x0,
1887
      NULL, HFILL }
1888
    },
1889
    /* gdsdb_slice_response */
1890
    { &hf_gdsdb_sliceresponse_length,
1891
      { "Length", "gdsdb.sliceresponse.length",
1892
      FT_UINT32, BASE_DEC, NULL, 0x0,
1893
      NULL, HFILL }
1894
    },
1895
#endif
1896
    /* gdsdb_execute */
1897
15
    { &hf_gdsdb_execute_statement,
1898
15
      { "Statement", "gdsdb.execute.statement",
1899
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1900
15
      NULL, HFILL }
1901
15
    },
1902
15
    { &hf_gdsdb_execute_transaction,
1903
15
      { "Transaction", "gdsdb.execute.transaction",
1904
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1905
15
      NULL, HFILL }
1906
15
    },
1907
15
    { &hf_gdsdb_execute_message_number,
1908
15
      { "Message number", "gdsdb.execute.messagenumber",
1909
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1910
15
      NULL, HFILL }
1911
15
    },
1912
15
    { &hf_gdsdb_execute_messages,
1913
15
      { "Number of messages", "gdsdb.execute.messages",
1914
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1915
15
      NULL, HFILL }
1916
15
    },
1917
#if 0
1918
    /* gdsdb_execute2 */
1919
    { &hf_gdsdb_execute_outblr,
1920
      { "Output BLR", "gdsdb.execute.outblr",
1921
      FT_UINT32, BASE_DEC, NULL, 0x0,
1922
      NULL, HFILL }
1923
    },
1924
    { &hf_gdsdb_execute_outmsgnr,
1925
      { "Output Message number", "gdsdb.execute.outmsgnr",
1926
      FT_UINT32, BASE_DEC, NULL, 0x0,
1927
      NULL, HFILL }
1928
    },
1929
    /* gdsdb_exec_immediate2 */
1930
    { &hf_gdsdb_prepare2_blr,
1931
      { "BLR", "gdsdb.prepare.blr",
1932
      FT_UINT32, BASE_DEC, NULL, 0x0,
1933
      NULL, HFILL }
1934
    },
1935
    { &hf_gdsdb_prepare2_number,
1936
      { "Message number", "gdsdb.prepare2.messagenumber",
1937
      FT_UINT32, BASE_DEC, NULL, 0x0,
1938
      NULL, HFILL }
1939
    },
1940
    { &hf_gdsdb_prepare2_messages,
1941
      { "Number of messages", "gdsdb.prepare2.messages",
1942
      FT_UINT32, BASE_DEC, NULL, 0x0,
1943
      NULL, HFILL }
1944
    },
1945
    { &hf_gdsdb_prepare2_outblr,
1946
      { "Output BLR", "gdsdb.prepare2.outblr",
1947
      FT_UINT32, BASE_DEC, NULL, 0x0,
1948
      NULL, HFILL }
1949
    },
1950
    { &hf_gdsdb_prepare2_outmsgnr,
1951
      { "Output Message number", "gdsdb.prepare2.outmsgnr",
1952
      FT_UINT32, BASE_DEC, NULL, 0x0,
1953
      NULL, HFILL }
1954
    },
1955
#endif
1956
    /* gdsdb_prepare */
1957
15
    { &hf_gdsdb_prepare_transaction,
1958
15
      { "Prepare, Transaction", "gdsdb.prepare.transaction",
1959
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1960
15
      NULL, HFILL }
1961
15
    },
1962
15
    { &hf_gdsdb_prepare_statement,
1963
15
      { "Prepare, Statement", "gdsdb.prepare.statement",
1964
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1965
15
      NULL, HFILL }
1966
15
    },
1967
15
    { &hf_gdsdb_prepare_dialect,
1968
15
      { "Prepare, Dialect", "gdsdb.prepare.dialect",
1969
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1970
15
      NULL, HFILL }
1971
15
    },
1972
15
    { &hf_gdsdb_prepare_querystr,
1973
15
      { "Prepare, Query", "gdsdb.prepare.querystr",
1974
15
      FT_UINT_STRING, BASE_NONE, NULL, 0x0,
1975
15
      NULL, HFILL }
1976
15
    },
1977
15
    { &hf_gdsdb_prepare_bufferlength,
1978
15
      { "Prepare, Bufferlength", "gdsdb.prepare.bufferlen",
1979
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
1980
15
      NULL, HFILL }
1981
15
    },
1982
#if 0
1983
    /* gdsdb_fetch */
1984
    { &hf_gdsdb_fetch_statement,
1985
      { "Statement", "gdsdb.fetch.statement",
1986
      FT_UINT32, BASE_DEC, NULL, 0x0,
1987
      NULL, HFILL }
1988
    },
1989
    { &hf_gdsdb_fetch_message_number,
1990
      { "Message number", "gdsdb.fetch.messagenr",
1991
      FT_UINT32, BASE_DEC, NULL, 0x0,
1992
      NULL, HFILL }
1993
    },
1994
    { &hf_gdsdb_fetch_messages,
1995
      { "Number of messages", "gdsdb.fetch.messages",
1996
      FT_UINT32, BASE_DEC, NULL, 0x0,
1997
      NULL, HFILL }
1998
    },
1999
#endif
2000
    /* gdsdb_fetch_response */
2001
15
    { &hf_gdsdb_fetchresponse_status,
2002
15
      { "Status", "gdsdb.fetchresponse.status",
2003
15
      FT_UINT32, BASE_DEC, VALS(gdsdb_response_status_vals), 0x0,
2004
15
      NULL, HFILL }
2005
15
    },
2006
15
    { &hf_gdsdb_fetchresponse_messages,
2007
15
      { "Number of messages", "gdsdb.fetchresponse.messages",
2008
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
2009
15
      NULL, HFILL }
2010
15
    },
2011
    /* gdsdb_free_statement */
2012
15
    { &hf_gdsdb_free_statement,
2013
15
      { "Statement", "gdsdb.fetchresponse.statement",
2014
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
2015
15
      NULL, HFILL }
2016
15
    },
2017
15
    { &hf_gdsdb_free_option,
2018
15
      { "Option", "gdsdb.fetchresponse.option",
2019
15
      FT_UINT32, BASE_DEC, NULL, 0x0,
2020
15
      NULL, HFILL }
2021
15
    },
2022
#if 0
2023
    /* gdsdb_insert */
2024
    { &hf_gdsdb_insert_statement,
2025
      { "Statement", "gdsdb.insert.statement",
2026
      FT_UINT32, BASE_DEC, NULL, 0x0,
2027
      NULL, HFILL }
2028
    },
2029
    { &hf_gdsdb_insert_message_number,
2030
      { "Message number", "gdsdb.insert.messagenr",
2031
      FT_UINT32, BASE_DEC, NULL, 0x0,
2032
      NULL, HFILL }
2033
    },
2034
    { &hf_gdsdb_insert_messages,
2035
      { "Number of messages", "gdsdb.insert.messages",
2036
      FT_UINT32, BASE_DEC, NULL, 0x0,
2037
      NULL, HFILL }
2038
    },
2039
    /* gdsdb_cursor */
2040
    { &hf_gdsdb_cursor_statement,
2041
      { "Statement", "gdsdb.cursor.statement",
2042
      FT_UINT32, BASE_DEC, NULL, 0x0,
2043
      NULL, HFILL }
2044
    },
2045
    { &hf_gdsdb_cursor_type,
2046
      { "Type", "gdsdb.cursor.type",
2047
      FT_UINT32, BASE_DEC, NULL, 0x0,
2048
      NULL, HFILL }
2049
    },
2050
    /* gdsdb_sql_response */
2051
    { &hf_gdsdb_sqlresponse_messages,
2052
      { "SQL Response, Message Count", "gdsdb.sqlresponse.msgcount",
2053
      FT_UINT32, BASE_DEC, NULL, 0x0,
2054
      NULL, HFILL }
2055
    }
2056
#endif
2057
15
  };
2058
2059
15
  static int *ett[] = {
2060
15
    &ett_gdsdb,
2061
    /* &ett_gdsdb_opcode, */
2062
15
    &ett_gdsdb_connect_pref
2063
15
  };
2064
2065
/* Expert info */
2066
15
  static ei_register_info ei[] = {
2067
15
    { &ei_gdsdb_invalid_length, { "gdsdb.invalid_length", PI_MALFORMED, PI_ERROR,
2068
15
      "Invalid length", EXPFILL }},
2069
15
  };
2070
2071
15
  proto_gdsdb = proto_register_protocol("Firebird SQL Database Remote Protocol", "FB/IB GDS DB", "gdsdb");
2072
2073
15
  proto_register_field_array(proto_gdsdb, hf, array_length(hf));
2074
15
  proto_register_subtree_array(ett, array_length(ett));
2075
15
  expert_module_t *expert_gdsdb = expert_register_protocol(proto_gdsdb);
2076
15
  expert_register_field_array(expert_gdsdb, ei, array_length(ei));
2077
2078
15
  gdsdb_handle = register_dissector("gdsdb", dissect_gdsdb, proto_gdsdb);
2079
15
}
2080
2081
void
2082
proto_reg_handoff_gdsdb(void)
2083
15
{
2084
15
  dissector_add_uint_with_preference("tcp.port", TCP_PORT, gdsdb_handle);
2085
15
}
2086
2087
/*
2088
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
2089
 *
2090
 * Local variables:
2091
 * c-basic-offset: 8
2092
 * tab-width: 8
2093
 * indent-tabs-mode: t
2094
 * End:
2095
 *
2096
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
2097
 * :indentSize=8:tabSize=8:noTabs=false:
2098
 */