Coverage Report

Created: 2025-02-15 06:25

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