File: | builds/wireshark/wireshark/epan/dissectors/packet-pgsql.c |
Warning: | line 626, column 9 Value stored to 'n' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* packet-pgsql.c |
2 | * Routines for PostgreSQL v3 protocol dissection. |
3 | * <http://www.postgresql.org/docs/current/static/protocol.html> |
4 | * Copyright 2004 Abhijit Menon-Sen <ams@oryx.com> |
5 | * |
6 | * Wireshark - Network traffic analyzer |
7 | * By Gerald Combs <gerald@wireshark.org> |
8 | * Copyright 1998 Gerald Combs |
9 | * |
10 | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | */ |
12 | |
13 | #include "config.h" |
14 | |
15 | #include <epan/packet.h> |
16 | #include <epan/proto_data.h> |
17 | |
18 | #include "packet-gssapi.h" |
19 | #include "packet-tls-utils.h" |
20 | #include "packet-tcp.h" |
21 | |
22 | void proto_register_pgsql(void); |
23 | void proto_reg_handoff_pgsql(void); |
24 | |
25 | static dissector_handle_t pgsql_handle; |
26 | static dissector_handle_t pgsql_gssapi_handle; |
27 | static dissector_handle_t tls_handle; |
28 | static dissector_handle_t gssapi_handle; |
29 | static dissector_handle_t ntlmssp_handle; |
30 | |
31 | static int proto_pgsql; |
32 | static int hf_frontend; |
33 | static int hf_type; |
34 | static int hf_copydata; |
35 | static int hf_copydata_type; |
36 | static int hf_xlogdata; |
37 | static int hf_logical_msg_type; |
38 | static int hf_custom_type_name; |
39 | static int hf_namespace; |
40 | static int hf_relation_name; |
41 | static int hf_relation_oid; |
42 | static int hf_xid_subtransaction; |
43 | static int hf_xid; |
44 | static int hf_length; |
45 | static int hf_version_major; |
46 | static int hf_version_minor; |
47 | static int hf_request_code; |
48 | static int hf_supported_minor_version; |
49 | static int hf_number_nonsupported_options; |
50 | static int hf_nonsupported_option; |
51 | static int hf_parameter_name; |
52 | static int hf_parameter_value; |
53 | static int hf_query; |
54 | static int hf_authtype; |
55 | static int hf_passwd; |
56 | static int hf_salt; |
57 | static int hf_gssapi_sspi_data; |
58 | static int hf_sasl_auth_mech; |
59 | static int hf_sasl_auth_data; |
60 | static int hf_sasl_auth_data_length; |
61 | static int hf_statement; |
62 | static int hf_portal; |
63 | static int hf_return; |
64 | static int hf_tag; |
65 | static int hf_status; |
66 | static int hf_error; |
67 | static int hf_pid; |
68 | static int hf_key; |
69 | static int hf_condition; |
70 | static int hf_text; |
71 | static int hf_tableoid; |
72 | static int hf_typeoid; |
73 | static int hf_oid; |
74 | static int hf_format; |
75 | static int hf_field_count; |
76 | static int hf_val_name; |
77 | static int hf_val_idx; |
78 | static int hf_val_length; |
79 | static int hf_val_data; |
80 | static int hf_val_text_data; |
81 | static int hf_val_mod; |
82 | static int hf_severity; |
83 | static int hf_code; |
84 | static int hf_message; |
85 | static int hf_detail; |
86 | static int hf_hint; |
87 | static int hf_position; |
88 | static int hf_internal_position; |
89 | static int hf_internal_query; |
90 | static int hf_where; |
91 | static int hf_schema_name; |
92 | static int hf_table_name; |
93 | static int hf_column_name; |
94 | static int hf_type_name; |
95 | static int hf_tuple_type; |
96 | static int hf_tuple_data_type; |
97 | static int hf_constraint_name; |
98 | static int hf_file; |
99 | static int hf_line; |
100 | static int hf_routine; |
101 | static int hf_ssl_response; |
102 | static int hf_gssenc_response; |
103 | static int hf_gssapi_encrypted_payload; |
104 | static int hf_logical_column_flags; |
105 | static int hf_logical_column_length; |
106 | static int hf_logical_column_name; |
107 | static int hf_logical_number_columns; |
108 | static int hf_logical_column_oid; |
109 | static int hf_logical_column_type_modifier; |
110 | static int hf_logical_commit_flags; |
111 | static int hf_logical_commit_ts; |
112 | static int hf_logical_lsn_abort; |
113 | static int hf_logical_lsn_commit; |
114 | static int hf_logical_lsn_final; |
115 | static int hf_logical_lsn_origin; |
116 | static int hf_logical_lsn_transaction; |
117 | static int hf_logical_message_content; |
118 | static int hf_logical_message_flags; |
119 | static int hf_logical_message_length; |
120 | static int hf_logical_message_lsn; |
121 | static int hf_logical_message_prefix; |
122 | static int hf_logical_origin_name; |
123 | static int hf_logical_prepare_commit_ts; |
124 | static int hf_logical_prepare_flags; |
125 | static int hf_logical_prepare_gid; |
126 | static int hf_logical_prepare_lsn_end; |
127 | static int hf_logical_prepare_lsn_rollback; |
128 | static int hf_logical_prepare_lsn; |
129 | static int hf_logical_prepare_rollback_ts; |
130 | static int hf_logical_prepare_ts; |
131 | static int hf_logical_relation_number; |
132 | static int hf_logical_replica_identity; |
133 | static int hf_logical_stream_abort_ts; |
134 | static int hf_logical_stream_first_segment; |
135 | static int hf_logical_stream_flags; |
136 | static int hf_logical_truncate_flags; |
137 | static int hf_standby_catalog_xmin_epoch; |
138 | static int hf_standby_catalog_xmin; |
139 | static int hf_standby_clock_ts; |
140 | static int hf_standby_immediate_ack; |
141 | static int hf_standby_last_wal_applied; |
142 | static int hf_standby_last_wal_flushed; |
143 | static int hf_standby_last_wal_written; |
144 | static int hf_standby_xmin_epoch; |
145 | static int hf_standby_xmin; |
146 | static int hf_xlog_wal_end; |
147 | static int hf_xlog_wal_start; |
148 | |
149 | static int ett_pgsql; |
150 | static int ett_values; |
151 | |
152 | #define PGSQL_PORT5432 5432 |
153 | static bool_Bool pgsql_desegment = true1; |
154 | static bool_Bool first_message = true1; |
155 | |
156 | typedef enum { |
157 | /* Reserve 0 (== GPOINTER_TO_UINT(NULL)) for no PGSQL detected */ |
158 | PGSQL_AUTH_STATE_NONE = 1, /* No authentication seen or used */ |
159 | PGSQL_AUTH_SASL_REQUESTED, /* Server sends SASL auth request with supported SASL mechanisms*/ |
160 | PGSQL_AUTH_SASL_CONTINUE, /* Server and/or client send further SASL challenge-response messages */ |
161 | PGSQL_AUTH_GSSAPI_SSPI_DATA, /* GSSAPI/SSPI in use */ |
162 | PGSQL_AUTH_SSL_REQUESTED, /* Client sends SSL encryption request */ |
163 | PGSQL_AUTH_GSSENC_REQUESTED, /* Client sends GSSAPI encryption request */ |
164 | } pgsql_auth_state_t; |
165 | |
166 | typedef struct pgsql_conn_data { |
167 | wmem_tree_t *state_tree; /* Tree of encryption and auth state changes */ |
168 | uint32_t server_port; |
169 | bool_Bool streamed_txn; |
170 | } pgsql_conn_data_t; |
171 | |
172 | struct pgsql_per_packet_data_t { |
173 | bool_Bool streamed_txn; |
174 | }; |
175 | |
176 | static const value_string fe_messages[] = { |
177 | { 'p', "Authentication message" }, |
178 | { 'Q', "Simple query" }, |
179 | { 'P', "Parse" }, |
180 | { 'B', "Bind" }, |
181 | { 'E', "Execute" }, |
182 | { 'D', "Describe" }, |
183 | { 'C', "Close" }, |
184 | { 'H', "Flush" }, |
185 | { 'S', "Sync" }, |
186 | { 'F', "Function call" }, |
187 | { 'd', "Copy data" }, |
188 | { 'c', "Copy completion" }, |
189 | { 'f', "Copy failure" }, |
190 | { 'X', "Termination" }, |
191 | { 0, NULL((void*)0) } |
192 | }; |
193 | |
194 | static const value_string be_messages[] = { |
195 | { 'R', "Authentication request" }, |
196 | { 'K', "Backend key data" }, |
197 | { 'S', "Parameter status" }, |
198 | { '1', "Parse completion" }, |
199 | { '2', "Bind completion" }, |
200 | { '3', "Close completion" }, |
201 | { 'C', "Command completion" }, |
202 | { 't', "Parameter description" }, |
203 | { 'T', "Row description" }, |
204 | { 'D', "Data row" }, |
205 | { 'I', "Empty query" }, |
206 | { 'n', "No data" }, |
207 | { 'E', "Error" }, |
208 | { 'N', "Notice" }, |
209 | { 's', "Portal suspended" }, |
210 | { 'Z', "Ready for query" }, |
211 | { 'A', "Notification" }, |
212 | { 'V', "Function call response" }, |
213 | { 'G', "CopyIn response" }, |
214 | { 'H', "CopyOut response" }, |
215 | { 'd', "Copy data" }, |
216 | { 'c', "Copy completion" }, |
217 | { 'v', "Negotiate protocol version" }, |
218 | { 0, NULL((void*)0) } |
219 | }; |
220 | |
221 | static const value_string tuple_types[] = { |
222 | { 'n', "NULL" }, |
223 | { 'u', "Unchanged TOASTed" }, |
224 | { 't', "Text" }, |
225 | { 'b', "Binary" }, |
226 | { 0, NULL((void*)0) } |
227 | }; |
228 | |
229 | static const value_string tuple_data_types[] = { |
230 | { 'K', "Key" }, |
231 | { 'O', "Old tuple" }, |
232 | { 'N', "New tuple" }, |
233 | { 0, NULL((void*)0) } |
234 | }; |
235 | |
236 | static const value_string logical_message_types[] = { |
237 | { 'B', "Begin" }, |
238 | { 'b', "Begin Prepare" }, |
239 | { 'C', "Commit" }, |
240 | { 'K', "Commit Prepared" }, |
241 | { 'D', "Delete" }, |
242 | { 'I', "Insert" }, |
243 | { 'M', "Message" }, |
244 | { 'P', "Prepare" }, |
245 | { 'r', "Rollback Prepared" }, |
246 | { 'R', "Relation" }, |
247 | { 'T', "Truncate" }, |
248 | { 'U', "Update" }, |
249 | { 'O', "Origin" }, |
250 | { 'Y', "Type" }, |
251 | { 'S', "Stream Start" }, |
252 | { 'E', "Stream Stop" }, |
253 | { 'c', "Stream Commit" }, |
254 | { 'A', "Stream Abort" }, |
255 | { 'p', "Stream Prepare" }, |
256 | { 0, NULL((void*)0) } |
257 | }; |
258 | |
259 | #define PGSQL_AUTH_TYPE_SUCCESS0 0 |
260 | #define PGSQL_AUTH_TYPE_KERBEROS41 1 |
261 | #define PGSQL_AUTH_TYPE_KERBEROS52 2 |
262 | #define PGSQL_AUTH_TYPE_PLAINTEXT3 3 |
263 | #define PGSQL_AUTH_TYPE_CRYPT4 4 |
264 | #define PGSQL_AUTH_TYPE_MD55 5 |
265 | #define PGSQL_AUTH_TYPE_SCM6 6 |
266 | #define PGSQL_AUTH_TYPE_GSSAPI7 7 |
267 | #define PGSQL_AUTH_TYPE_GSSAPI_SSPI_CONTINUE8 8 |
268 | #define PGSQL_AUTH_TYPE_SSPI9 9 |
269 | #define PGSQL_AUTH_TYPE_SASL10 10 |
270 | #define PGSQL_AUTH_TYPE_SASL_CONTINUE11 11 |
271 | #define PGSQL_AUTH_TYPE_SASL_COMPLETE12 12 |
272 | |
273 | static const value_string auth_types[] = { |
274 | { PGSQL_AUTH_TYPE_SUCCESS0 , "Success" }, |
275 | { PGSQL_AUTH_TYPE_KERBEROS41 , "Kerberos V4" }, |
276 | { PGSQL_AUTH_TYPE_KERBEROS52 , "Kerberos V5" }, |
277 | { PGSQL_AUTH_TYPE_PLAINTEXT3 , "Plaintext password" }, |
278 | { PGSQL_AUTH_TYPE_CRYPT4 , "crypt()ed password" }, |
279 | { PGSQL_AUTH_TYPE_MD55 , "MD5 password" }, |
280 | { PGSQL_AUTH_TYPE_SCM6 , "SCM credentials" }, |
281 | { PGSQL_AUTH_TYPE_GSSAPI7 , "GSSAPI" }, |
282 | { PGSQL_AUTH_TYPE_GSSAPI_SSPI_CONTINUE8 , "GSSAPI/SSPI continue" }, |
283 | { PGSQL_AUTH_TYPE_SSPI9 , "SSPI" }, |
284 | { PGSQL_AUTH_TYPE_SASL10 , "SASL" }, |
285 | { PGSQL_AUTH_TYPE_SASL_CONTINUE11 , "SASL continue" }, |
286 | { PGSQL_AUTH_TYPE_SASL_COMPLETE12 , "SASL complete" }, |
287 | { 0, NULL((void*)0) } |
288 | }; |
289 | |
290 | static const value_string status_vals[] = { |
291 | { 'I', "Idle" }, |
292 | { 'T', "In a transaction" }, |
293 | { 'E', "In a failed transaction" }, |
294 | { 0, NULL((void*)0) } |
295 | }; |
296 | |
297 | static const value_string format_vals[] = { |
298 | { 0, "Text" }, |
299 | { 1, "Binary" }, |
300 | { 0, NULL((void*)0) } |
301 | }; |
302 | |
303 | #define PGSQL_CANCELREQUEST80877102 80877102 |
304 | #define PGSQL_SSLREQUEST80877103 80877103 |
305 | #define PGSQL_GSSENCREQUEST80877104 80877104 |
306 | |
307 | static const value_string request_code_vals[] = { |
308 | { PGSQL_CANCELREQUEST80877102, "CancelRequest" }, |
309 | { PGSQL_SSLREQUEST80877103, "SSLRequest" }, |
310 | { PGSQL_GSSENCREQUEST80877104, "GSSENCRequest" }, |
311 | { 0, NULL((void*)0) } |
312 | }; |
313 | |
314 | static const value_string ssl_response_vals[] = { |
315 | { 'N', "Unwilling to perform SSL" }, |
316 | { 'S', "Willing to perform SSL" }, |
317 | { 0, NULL((void*)0) } |
318 | }; |
319 | |
320 | static const value_string gssenc_response_vals[] = { |
321 | { 'G', "Willing to perform GSSAPI encryption" }, |
322 | { 'N', "Unwilling to perform GSSAPI encryption" }, |
323 | { 0, NULL((void*)0) } |
324 | }; |
325 | |
326 | static void |
327 | dissect_pg_epoch(tvbuff_t *tvb, int n, proto_tree *tree, int hfindex) |
328 | { |
329 | uint64_t system_clock = tvb_get_uint64(tvb, n, ENC_BIG_ENDIAN0x00000000); |
330 | /* PostgreSQL epoch starts at 2000-01-01, which translates to a timestamp of 946681200 */ |
331 | nstime_t system_time = NSTIME_INIT_SECS_USECS(system_clock / 1000000 + 946681200, system_clock % 1000000){system_clock / 1000000 + 946681200, system_clock % 1000000*1000 }; |
332 | proto_tree_add_time(tree, hfindex, tvb, n, 8, &system_time); |
333 | } |
334 | |
335 | static int |
336 | get_tuple_data_length(tvbuff_t *tvb, int start) |
337 | { |
338 | int number_columns; |
339 | int n = start; |
340 | number_columns = tvb_get_uint16(tvb, n, ENC_BIG_ENDIAN0x00000000); |
341 | n += 2; |
342 | for (int i = 0; i < number_columns; i++) { |
343 | unsigned char tuple_type; |
344 | tuple_type = tvb_get_uint8(tvb, n); |
345 | n += 1; |
346 | |
347 | if (tuple_type == 't' || tuple_type == 'b') { |
348 | int column_length; |
349 | column_length = tvb_get_ntohl(tvb, n); |
350 | n += 4 + column_length; |
351 | } |
352 | } |
353 | return n - start; |
354 | } |
355 | |
356 | static int |
357 | dissect_tuple_data(tvbuff_t *tvb, int n, proto_tree *tree) |
358 | { |
359 | int number_columns; |
360 | |
361 | number_columns = tvb_get_uint16(tvb, n, ENC_BIG_ENDIAN0x00000000); |
362 | proto_tree_add_item_ret_uint(tree, hf_logical_number_columns, tvb, n, 2, ENC_BIG_ENDIAN0x00000000, &number_columns); |
363 | n += 2; |
364 | |
365 | for (int i = 0; i < number_columns; i++) { |
366 | unsigned char tuple_type; |
367 | int shrub_start = 0; |
368 | const char *typestr; |
369 | proto_tree *shrub; |
370 | |
371 | /* tuple_type is included in the column's shrub, save the start position */ |
372 | shrub_start = n; |
373 | |
374 | tuple_type = tvb_get_uint8(tvb, n); |
375 | typestr = val_to_str_const(tuple_type, tuple_types, "Unknown"); |
376 | n += 1; |
377 | |
378 | if (tuple_type == 't' || tuple_type == 'b') { |
379 | int column_length; |
380 | |
381 | column_length = tvb_get_ntohl(tvb, n); |
382 | /* Shrub's size includes tuple_type (1 byte) + column_length (4 bytes) of column length */ |
383 | shrub = proto_tree_add_subtree_format(tree, tvb, shrub_start, 5 + column_length, ett_values, NULL((void*)0), "Column %d", i); |
384 | /* Now that the shrub is created, add the typestr. n was already incremented */ |
385 | proto_tree_add_string(shrub, hf_tuple_type, tvb, shrub_start, 1, typestr); |
386 | |
387 | proto_tree_add_item_ret_int(shrub, hf_logical_column_length, tvb, n, 4, ENC_BIG_ENDIAN0x00000000, &column_length); |
388 | n += 4; |
389 | |
390 | if (tuple_type == 't') { |
391 | proto_tree_add_item(shrub, hf_val_text_data, tvb, n, column_length, ENC_ASCII0x00000000); |
392 | } else { |
393 | proto_tree_add_item(shrub, hf_val_data, tvb, n, column_length, ENC_NA0x00000000); |
394 | } |
395 | n += column_length; |
396 | } else { |
397 | shrub = proto_tree_add_subtree_format(tree, tvb, shrub_start, 1, ett_values, NULL((void*)0), "Column %d", i); |
398 | proto_tree_add_string(shrub, hf_tuple_type, tvb, shrub_start, 1, typestr); |
399 | } |
400 | } |
401 | return n; |
402 | } |
403 | |
404 | static int |
405 | dissect_new_tuple_data(tvbuff_t *tvb, int n, proto_tree *tree) |
406 | { |
407 | proto_tree *shrub; |
408 | const char * tupledatastr; |
409 | unsigned char type; |
410 | int length, start_shrub = n; |
411 | |
412 | type = tvb_get_uint8(tvb, n); |
413 | tupledatastr = val_to_str_const(type, tuple_data_types, "Unknown"); |
414 | n += 1; |
415 | |
416 | length = get_tuple_data_length(tvb, n); |
417 | shrub = proto_tree_add_subtree_format(tree, tvb, start_shrub, length + 1, ett_values, NULL((void*)0), "%s", tupledatastr); |
418 | proto_tree_add_string(shrub, hf_tuple_data_type, tvb, start_shrub, 1, tupledatastr); |
419 | |
420 | n = dissect_tuple_data(tvb, n, shrub); |
421 | return n; |
422 | } |
423 | |
424 | static int |
425 | dissect_old_tuple_data(tvbuff_t *tvb, int n, proto_tree *tree) |
426 | { |
427 | proto_tree *shrub; |
428 | const char *tupledatastr; |
429 | int length, start_shrub = n; |
430 | unsigned char type; |
431 | |
432 | type = tvb_get_uint8(tvb, n); |
433 | if (type != 'K' && type != 'O') { |
434 | /* No optional old tuple detected */ |
435 | return n; |
436 | } |
437 | |
438 | n += 1; |
439 | tupledatastr = val_to_str_const(type, tuple_data_types, "Unknown"); |
440 | |
441 | /* Get the size of the tuple data so we can build our shrub */ |
442 | length = get_tuple_data_length(tvb, n); |
443 | shrub = proto_tree_add_subtree_format(tree, tvb, start_shrub, length - (start_shrub - 1), ett_values, NULL((void*)0), "%s", tupledatastr); |
444 | proto_tree_add_string(shrub, hf_tuple_data_type, tvb, start_shrub, 1, tupledatastr); |
445 | |
446 | /* Now we can dissect tuple data for real */ |
447 | return dissect_tuple_data(tvb, n, shrub); |
448 | } |
449 | |
450 | static bool_Bool is_streamed_txn(packet_info *pinfo, pgsql_conn_data_t *conv_data) |
451 | { |
452 | struct pgsql_per_packet_data_t *pgsql_ppd; |
453 | pgsql_ppd = (struct pgsql_per_packet_data_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_pgsql, pinfo->curr_layer_num); |
454 | if (!pgsql_ppd) { |
455 | /* First time, allocate the per packet and copy the current |
456 | * streamed_txn from the conversation |
457 | */ |
458 | pgsql_ppd = wmem_new0(wmem_file_scope(), struct pgsql_per_packet_data_t)((struct pgsql_per_packet_data_t*)wmem_alloc0((wmem_file_scope ()), sizeof(struct pgsql_per_packet_data_t))); |
459 | p_add_proto_data(wmem_file_scope(), pinfo, proto_pgsql, pinfo->curr_layer_num, pgsql_ppd); |
460 | pgsql_ppd->streamed_txn = conv_data->streamed_txn; |
461 | } |
462 | return pgsql_ppd->streamed_txn; |
463 | } |
464 | |
465 | static void set_streamed_txn(packet_info *pinfo, pgsql_conn_data_t *conv_data, bool_Bool streamed_txn) |
466 | { |
467 | struct pgsql_per_packet_data_t *pgsql_ppd; |
468 | /* Set both the conversation's and the ppd stream_txn state. |
469 | * Conversation is used to set the stream_txn's value when ppd is |
470 | * created. |
471 | */ |
472 | conv_data->streamed_txn = streamed_txn; |
473 | pgsql_ppd = (struct pgsql_per_packet_data_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_pgsql, pinfo->curr_layer_num); |
474 | if (!pgsql_ppd) { |
475 | pgsql_ppd = wmem_new0(wmem_file_scope(), struct pgsql_per_packet_data_t)((struct pgsql_per_packet_data_t*)wmem_alloc0((wmem_file_scope ()), sizeof(struct pgsql_per_packet_data_t))); |
476 | p_add_proto_data(wmem_file_scope(), pinfo, proto_pgsql, pinfo->curr_layer_num, pgsql_ppd); |
477 | } |
478 | pgsql_ppd->streamed_txn = streamed_txn;; |
479 | } |
480 | |
481 | static void dissect_pgsql_logical_be_msg(int32_t length, tvbuff_t *tvb, int n, proto_tree *tree, packet_info *pinfo, |
482 | pgsql_conn_data_t *conv_data) |
483 | { |
484 | proto_tree *shrub; |
485 | proto_item *ti; |
486 | int siz, i, content_length, leftover; |
487 | char *s; |
488 | |
489 | unsigned char message_type = tvb_get_uint8(tvb, n); |
490 | const char *logical_message_name = try_val_to_str(message_type, logical_message_types); |
491 | if (logical_message_name == NULL((void*)0)) |
492 | { |
493 | /* Doesn't look like a logical replication message. It's probably WAL |
494 | * data stream from physical replication. |
495 | */ |
496 | proto_tree_add_item(tree, hf_xlogdata, tvb, n, length - (n - 1), ENC_NA0x00000000); |
497 | return; |
498 | } |
499 | |
500 | proto_tree_add_string(tree, hf_logical_msg_type, tvb, n, 1, logical_message_name); |
501 | n += 1; |
502 | |
503 | /* Payload's length doesn't include the type */ |
504 | shrub = proto_tree_add_subtree_format(tree, tvb, n, length - (n - 1), ett_values, NULL((void*)0), "%s", logical_message_name); |
505 | |
506 | switch (message_type) { |
507 | /* Begin */ |
508 | case 'B': |
509 | proto_tree_add_item(shrub, hf_logical_lsn_final, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
510 | n += 8; |
511 | dissect_pg_epoch(tvb, n, shrub, hf_logical_commit_ts); |
512 | n += 8; |
513 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
514 | break; |
515 | |
516 | /* Message */ |
517 | case 'M': |
518 | if (is_streamed_txn(pinfo, conv_data)) { |
519 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
520 | n += 4; |
521 | } |
522 | proto_tree_add_item(shrub, hf_logical_message_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
523 | n += 1; |
524 | proto_tree_add_item(shrub, hf_logical_message_lsn, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
525 | n += 8; |
526 | siz = tvb_strsize(tvb, n); |
527 | proto_tree_add_item(shrub, hf_logical_message_prefix, tvb, n, siz, ENC_ASCII0x00000000); |
528 | n += siz; |
529 | content_length = tvb_strsize(tvb, n); |
530 | proto_tree_add_item_ret_int(shrub, hf_logical_message_length, tvb, n, 4, ENC_BIG_ENDIAN0x00000000, &content_length); |
531 | n += 4; |
532 | proto_tree_add_item(shrub, hf_logical_message_content, tvb, n, content_length, ENC_ASCII0x00000000); |
533 | break; |
534 | |
535 | /* Commit */ |
536 | case 'C': |
537 | proto_tree_add_item(shrub, hf_logical_commit_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
538 | n += 1; |
539 | proto_tree_add_item(shrub, hf_logical_lsn_commit, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
540 | n += 8; |
541 | proto_tree_add_item(shrub, hf_logical_lsn_transaction, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
542 | n += 8; |
543 | dissect_pg_epoch(tvb, n, shrub, hf_standby_clock_ts); |
544 | break; |
545 | |
546 | /* Origin */ |
547 | case 'O': |
548 | proto_tree_add_item(shrub, hf_logical_lsn_origin, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
549 | n += 8; |
550 | siz = tvb_strsize(tvb, n); |
551 | proto_tree_add_item(shrub, hf_logical_origin_name, tvb, n, siz, ENC_ASCII0x00000000); |
552 | break; |
553 | |
554 | /* Relation */ |
555 | case 'R': |
556 | if (is_streamed_txn(pinfo, conv_data)) { |
557 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
558 | n += 4; |
559 | } |
560 | proto_tree_add_item(shrub, hf_relation_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
561 | n += 4; |
562 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n, &siz, ENC_ASCII0x00000000); |
563 | proto_tree_add_string(shrub, hf_namespace, tvb, n, siz, s); |
564 | n += siz; |
565 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n, &siz, ENC_ASCII0x00000000); |
566 | proto_tree_add_string(shrub, hf_relation_name, tvb, n, siz, s); |
567 | n += siz; |
568 | proto_tree_add_item(shrub, hf_logical_replica_identity, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
569 | n += 1; |
570 | i = tvb_get_ntohs(tvb, n); |
571 | shrub = proto_tree_add_subtree_format(shrub, tvb, n, 2, ett_values, NULL((void*)0), "Columns: %d", i); |
572 | n += 2; |
573 | while (i-- > 0) { |
574 | proto_tree *twig; |
575 | siz = tvb_strsize(tvb, n+1); |
576 | ti = proto_tree_add_item(shrub, hf_val_name, tvb, n+1, siz, ENC_ASCII0x00000000); |
577 | twig = proto_item_add_subtree(ti, ett_values); |
578 | proto_tree_add_item(twig, hf_logical_column_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
579 | n +=1; |
580 | proto_tree_add_item(twig, hf_logical_column_name, tvb, n, siz, ENC_ASCII0x00000000); |
581 | n += siz; |
582 | proto_tree_add_item(twig, hf_logical_column_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
583 | n += 4; |
584 | proto_tree_add_item(twig, hf_logical_column_type_modifier, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
585 | n += 4; |
586 | } |
587 | break; |
588 | |
589 | /* Type */ |
590 | case 'Y': |
591 | if (is_streamed_txn(pinfo, conv_data)) { |
592 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
593 | n += 4; |
594 | } |
595 | proto_tree_add_item(shrub, hf_typeoid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
596 | n += 4; |
597 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n, &siz, ENC_ASCII0x00000000); |
598 | proto_tree_add_string(shrub, hf_namespace, tvb, n, siz, s); |
599 | n += siz; |
600 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n, &siz, ENC_ASCII0x00000000); |
601 | proto_tree_add_string(shrub, hf_custom_type_name, tvb, n, siz, s); |
602 | n += siz; |
603 | break; |
604 | |
605 | /* Insert */ |
606 | case 'I': |
607 | if (is_streamed_txn(pinfo, conv_data)) { |
608 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
609 | n += 4; |
610 | } |
611 | proto_tree_add_item(shrub, hf_relation_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
612 | n += 4; |
613 | dissect_new_tuple_data(tvb, n, shrub); |
614 | break; |
615 | |
616 | /* Update */ |
617 | case 'U': |
618 | if (is_streamed_txn(pinfo, conv_data)) { |
619 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
620 | n += 4; |
621 | } |
622 | i = tvb_get_ntohl(tvb, n); |
623 | proto_tree_add_item(shrub, hf_logical_column_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
624 | n += 4; |
625 | n = dissect_old_tuple_data(tvb, n, shrub); |
626 | n = dissect_new_tuple_data(tvb, n, shrub); |
Value stored to 'n' is never read | |
627 | break; |
628 | |
629 | /* Delete */ |
630 | case 'D': |
631 | if (is_streamed_txn(pinfo, conv_data)) { |
632 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
633 | n += 4; |
634 | } |
635 | i = tvb_get_ntohl(tvb, n); |
636 | proto_tree_add_item(shrub, hf_logical_column_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
637 | n += 4; |
638 | dissect_old_tuple_data(tvb, n, shrub); |
639 | break; |
640 | |
641 | /* Truncate */ |
642 | case 'T': |
643 | if (is_streamed_txn(pinfo, conv_data)) { |
644 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
645 | n += 4; |
646 | } |
647 | i = tvb_get_ntohl(tvb, n); |
648 | proto_tree_add_item_ret_uint(shrub, hf_logical_relation_number, tvb, n, 4, ENC_BIG_ENDIAN0x00000000, &i); |
649 | n += 4; |
650 | proto_tree_add_item(shrub, hf_logical_truncate_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
651 | n += 1; |
652 | shrub = proto_tree_add_subtree_format(shrub, tvb, n, length - n, ett_values, NULL((void*)0), "Relation Oids: %d", i); |
653 | while (i-- > 0) { |
654 | proto_tree_add_item(shrub, hf_relation_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
655 | n += 4; |
656 | } |
657 | break; |
658 | |
659 | /* Stream Start */ |
660 | case 'S': |
661 | set_streamed_txn(pinfo, conv_data, true1); |
662 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
663 | n += 4; |
664 | proto_tree_add_item(shrub, hf_logical_stream_first_segment, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
665 | break; |
666 | |
667 | /* Stream Stop */ |
668 | case 'E': |
669 | set_streamed_txn(pinfo, conv_data, false0); |
670 | break; |
671 | |
672 | /* Stream Commit */ |
673 | case 'c': |
674 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
675 | n += 4; |
676 | proto_tree_add_item(shrub, hf_logical_stream_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
677 | n += 1; |
678 | proto_tree_add_item(shrub, hf_logical_lsn_commit, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
679 | n += 8; |
680 | proto_tree_add_item(shrub, hf_logical_lsn_transaction, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
681 | n += 8; |
682 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_commit_ts); |
683 | n += 8; |
684 | break; |
685 | |
686 | /* Stream Abort */ |
687 | case 'A': |
688 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
689 | n += 4; |
690 | proto_tree_add_item(shrub, hf_xid_subtransaction, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
691 | n += 4; |
692 | leftover = length - (n - 1); |
693 | /* PostgreSQL's doc is currently a bit confusing here as the abort LSN |
694 | * and abort ts are marked as "available since protocol version 4". |
695 | * However, it will only be sent if streaming=parallel which is only |
696 | * supported with protocol version 4. |
697 | * So in any case, since this is the last message, we can assume that if |
698 | * we have enough data, they are the abort lsn and ts. |
699 | */ |
700 | if (leftover == 16) { |
701 | proto_tree_add_item(shrub, hf_logical_lsn_abort, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
702 | n += 8; |
703 | dissect_pg_epoch(tvb, n, shrub, hf_logical_stream_abort_ts); |
704 | } |
705 | break; |
706 | |
707 | /* Begin Prepare*/ |
708 | case 'b': |
709 | proto_tree_add_item(shrub, hf_logical_prepare_lsn, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
710 | n += 8; |
711 | proto_tree_add_item(shrub, hf_logical_prepare_lsn_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
712 | n += 8; |
713 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_ts); |
714 | n += 8; |
715 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
716 | n += 4; |
717 | siz = tvb_strsize(tvb, n); |
718 | proto_tree_add_item(shrub, hf_logical_prepare_gid, tvb, n, siz, ENC_ASCII0x00000000); |
719 | n += siz; |
720 | break; |
721 | |
722 | /* Prepare*/ |
723 | case 'P': |
724 | proto_tree_add_item(shrub, hf_logical_prepare_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
725 | n += 1; |
726 | proto_tree_add_item(shrub, hf_logical_prepare_lsn, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
727 | n += 8; |
728 | proto_tree_add_item(shrub, hf_logical_prepare_lsn_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
729 | n += 8; |
730 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_ts); |
731 | n += 8; |
732 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
733 | n += 4; |
734 | siz = tvb_strsize(tvb, n); |
735 | proto_tree_add_item(shrub, hf_logical_prepare_gid, tvb, n, siz, ENC_ASCII0x00000000); |
736 | n += siz; |
737 | break; |
738 | |
739 | /* Commit Prepared */ |
740 | case 'K': |
741 | proto_tree_add_item(shrub, hf_logical_prepare_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
742 | n += 1; |
743 | proto_tree_add_item(shrub, hf_logical_prepare_lsn, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
744 | n += 8; |
745 | proto_tree_add_item(shrub, hf_logical_prepare_lsn_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
746 | n += 8; |
747 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_commit_ts); |
748 | n += 8; |
749 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
750 | n += 4; |
751 | siz = tvb_strsize(tvb, n); |
752 | proto_tree_add_item(shrub, hf_logical_prepare_gid, tvb, n, siz, ENC_ASCII0x00000000); |
753 | n += siz; |
754 | break; |
755 | |
756 | /* Rollback Prepared */ |
757 | case 'r': |
758 | proto_tree_add_item(shrub, hf_logical_prepare_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
759 | n += 1; |
760 | proto_tree_add_item(shrub, hf_logical_prepare_lsn_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
761 | n += 8; |
762 | proto_tree_add_item(shrub, hf_logical_prepare_lsn_rollback, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
763 | n += 8; |
764 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_ts); |
765 | n += 8; |
766 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_rollback_ts); |
767 | n += 8; |
768 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
769 | n += 4; |
770 | siz = tvb_strsize(tvb, n); |
771 | proto_tree_add_item(shrub, hf_logical_prepare_gid, tvb, n, siz, ENC_ASCII0x00000000); |
772 | n += siz; |
773 | break; |
774 | |
775 | /* Stream Prepare */ |
776 | case 'p': |
777 | proto_tree_add_item(shrub, hf_logical_stream_flags, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
778 | n +=1; |
779 | proto_tree_add_item(shrub, hf_logical_prepare_lsn, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
780 | n += 8; |
781 | proto_tree_add_item(shrub, hf_logical_prepare_lsn_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
782 | n += 8; |
783 | dissect_pg_epoch(tvb, n, shrub, hf_logical_prepare_ts); |
784 | n += 8; |
785 | proto_tree_add_item(shrub, hf_xid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
786 | n += 4; |
787 | siz = tvb_strsize(tvb, n); |
788 | proto_tree_add_item(shrub, hf_logical_prepare_gid, tvb, n, siz, ENC_ASCII0x00000000); |
789 | n += siz; |
790 | break; |
791 | default: |
792 | return; |
793 | } |
794 | col_append_fstr(pinfo->cinfo, COL_INFO, "/%c", message_type); |
795 | } |
796 | |
797 | static void dissect_pgsql_copy_data_be_msg(int32_t length, tvbuff_t *tvb, |
798 | int n, proto_tree *tree, packet_info *pinfo, |
799 | pgsql_conn_data_t *conv_data) |
800 | { |
801 | proto_tree *shrub; |
802 | unsigned char type = tvb_get_uint8(tvb, n); |
803 | switch (type) { |
804 | /* XLogData */ |
805 | case 'w': |
806 | col_append_fstr(pinfo->cinfo, COL_INFO, "/%c", type); |
807 | shrub = proto_tree_add_subtree_format(tree, tvb, n, length - (n - 1), ett_values, NULL((void*)0), "XLogData"); |
808 | proto_tree_add_string(shrub, hf_copydata_type, tvb, n, 1, "XLogData"); |
809 | n += 1; |
810 | proto_tree_add_item(shrub, hf_xlog_wal_start, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
811 | n += 8; |
812 | proto_tree_add_item(shrub, hf_xlog_wal_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
813 | n += 8; |
814 | dissect_pg_epoch(tvb, n, shrub, hf_standby_clock_ts); |
815 | n += 8; |
816 | dissect_pgsql_logical_be_msg(length, tvb, n, shrub, pinfo, conv_data); |
817 | break; |
818 | |
819 | /* Primary keep alive */ |
820 | case 'k': |
821 | col_append_fstr(pinfo->cinfo, COL_INFO, "/%c", type); |
822 | shrub = proto_tree_add_subtree_format(tree, tvb, n, length - (n - 1), ett_values, NULL((void*)0), "Primary keepalive"); |
823 | proto_tree_add_string(shrub, hf_copydata_type, tvb, n, 1, "Primary Keepalive Message"); |
824 | n += 1; |
825 | proto_tree_add_item(shrub, hf_xlog_wal_end, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
826 | n += 8; |
827 | dissect_pg_epoch(tvb, n, shrub, hf_standby_clock_ts); |
828 | n += 8; |
829 | proto_tree_add_item(shrub, hf_standby_immediate_ack, tvb, n, 1, ENC_NULL0x3D); |
830 | break; |
831 | |
832 | default: |
833 | proto_tree_add_item(tree, hf_copydata, tvb, n, length-n+1, ENC_NA0x00000000); |
834 | return; |
835 | } |
836 | } |
837 | |
838 | static void dissect_pgsql_copy_data_fe_msg(tvbuff_t *tvb, int n, proto_tree *tree, int32_t length, packet_info *pinfo) |
839 | { |
840 | proto_tree *shrub; |
841 | unsigned char type = tvb_get_uint8(tvb, n); |
842 | switch (type) { |
843 | /* Standby status update */ |
844 | case 'r': |
845 | shrub = proto_tree_add_subtree_format(tree, tvb, n, length - (n - 1), ett_values, NULL((void*)0), "Standby status update"); |
846 | proto_tree_add_string(shrub, hf_copydata_type, tvb, n, 1, "Standby status update"); |
847 | n += 1; |
848 | proto_tree_add_item(shrub, hf_standby_last_wal_written, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
849 | n += 8; |
850 | proto_tree_add_item(shrub, hf_standby_last_wal_flushed, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
851 | n += 8; |
852 | proto_tree_add_item(shrub, hf_standby_last_wal_applied, tvb, n, 8, ENC_BIG_ENDIAN0x00000000); |
853 | n += 8; |
854 | dissect_pg_epoch(tvb, n, shrub, hf_standby_clock_ts); |
855 | n += 8; |
856 | proto_tree_add_item(shrub, hf_standby_immediate_ack, tvb, n, 1, ENC_NULL0x3D); |
857 | break; |
858 | |
859 | /* Hot standby feedback */ |
860 | case 'h': |
861 | proto_tree_add_string(tree, hf_copydata_type, tvb, n, 1, "Hot standby feedback"); |
862 | shrub = proto_tree_add_subtree_format(tree, tvb, n, length - (n - 1), ett_values, NULL((void*)0), "Hot standby feedback"); |
863 | n += 1; |
864 | dissect_pg_epoch(tvb, n, shrub, hf_standby_clock_ts); |
865 | n += 8; |
866 | proto_tree_add_item(shrub, hf_standby_xmin, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
867 | n += 4; |
868 | proto_tree_add_item(shrub, hf_standby_xmin_epoch, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
869 | n += 4; |
870 | proto_tree_add_item(shrub, hf_standby_catalog_xmin, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
871 | n += 4; |
872 | proto_tree_add_item(shrub, hf_standby_catalog_xmin_epoch, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
873 | break; |
874 | |
875 | default: |
876 | proto_tree_add_item(tree, hf_copydata, tvb, n, length-n+1, ENC_NA0x00000000); |
877 | return; |
878 | } |
879 | col_append_fstr(pinfo->cinfo, COL_INFO, "/%c", type); |
880 | } |
881 | |
882 | static void dissect_pgsql_fe_msg(unsigned char type, unsigned length, tvbuff_t *tvb, |
883 | int n, proto_tree *tree, packet_info *pinfo, |
884 | pgsql_conn_data_t *conv_data) |
885 | { |
886 | unsigned char c; |
887 | int i, siz; |
888 | char *s; |
889 | proto_tree *shrub; |
890 | int32_t data_length; |
891 | pgsql_auth_state_t state; |
892 | tvbuff_t *next_tvb; |
893 | dissector_handle_t payload_handle; |
894 | |
895 | switch (type) { |
896 | /* Password, SASL or GSSAPI Response, depending on context */ |
897 | case 'p': |
898 | state = GPOINTER_TO_UINT(wmem_tree_lookup32_le(conv_data->state_tree, pinfo->num))((guint) (gulong) (wmem_tree_lookup32_le(conv_data->state_tree , pinfo->num))); |
899 | switch(state) { |
900 | |
901 | case PGSQL_AUTH_SASL_REQUESTED: |
902 | /* SASLInitResponse */ |
903 | siz = tvb_strsize(tvb, n); |
904 | proto_tree_add_item(tree, hf_sasl_auth_mech, tvb, n, siz, ENC_ASCII0x00000000); |
905 | n += siz; |
906 | proto_tree_add_item_ret_int(tree, hf_sasl_auth_data_length, tvb, n, 4, ENC_BIG_ENDIAN0x00000000, &data_length); |
907 | n += 4; |
908 | if (data_length) { |
909 | proto_tree_add_item(tree, hf_sasl_auth_data, tvb, n, data_length, ENC_NA0x00000000); |
910 | } |
911 | break; |
912 | |
913 | case PGSQL_AUTH_SASL_CONTINUE: |
914 | proto_tree_add_item(tree, hf_sasl_auth_data, tvb, n, length-4, ENC_NA0x00000000); |
915 | break; |
916 | |
917 | case PGSQL_AUTH_GSSAPI_SSPI_DATA: |
918 | next_tvb = tvb_new_subset_length(tvb, n, length - 4); |
919 | /* https://www.postgresql.org/docs/current/sspi-auth.html |
920 | * "PostgreSQL will use SSPI in negotiate mode, which will use |
921 | * Kerberos when possible and automatically fall back to NTLM |
922 | * in other cases... When using Kerberos authentication, SSPI |
923 | * works the same way GSSAPI does." |
924 | * Assume this means the Kerberos mode for SSPI works like |
925 | * GSSAPI, and not, say, SPNEGO the way TDS does. (Need |
926 | * a sample.) |
927 | */ |
928 | if (tvb_strneql(next_tvb, 0, "NTLMSSP", 7) == 0) { |
929 | payload_handle = ntlmssp_handle; |
930 | } else { |
931 | payload_handle = gssapi_handle; |
932 | } |
933 | n = call_dissector_only(payload_handle, next_tvb, pinfo, tree, NULL((void*)0)); |
934 | if ((length = tvb_reported_length_remaining(next_tvb, n))) { |
935 | proto_tree_add_item(tree, hf_gssapi_sspi_data, next_tvb, n, length, ENC_NA0x00000000); |
936 | } |
937 | break; |
938 | |
939 | default: |
940 | siz = tvb_strsize(tvb, n); |
941 | proto_tree_add_item(tree, hf_passwd, tvb, n, siz, ENC_ASCII0x00000000); |
942 | break; |
943 | } |
944 | break; |
945 | |
946 | /* Simple query */ |
947 | case 'Q': |
948 | siz = tvb_strsize(tvb, n); |
949 | proto_tree_add_item(tree, hf_query, tvb, n, siz, ENC_ASCII0x00000000); |
950 | break; |
951 | |
952 | /* Parse */ |
953 | case 'P': |
954 | siz = tvb_strsize(tvb, n); |
955 | proto_tree_add_item(tree, hf_statement, tvb, n, siz, ENC_ASCII0x00000000); |
956 | n += siz; |
957 | |
958 | siz = tvb_strsize(tvb, n); |
959 | proto_tree_add_item(tree, hf_query, tvb, n, siz, ENC_ASCII0x00000000); |
960 | n += siz; |
961 | |
962 | i = tvb_get_ntohs(tvb, n); |
963 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Parameters: %d", i); |
964 | n += 2; |
965 | while (i-- > 0) { |
966 | proto_tree_add_item(shrub, hf_typeoid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
967 | n += 4; |
968 | } |
969 | break; |
970 | |
971 | /* Bind */ |
972 | case 'B': |
973 | siz = tvb_strsize(tvb, n); |
974 | proto_tree_add_item(tree, hf_portal, tvb, n, siz, ENC_ASCII0x00000000); |
975 | n += siz; |
976 | |
977 | siz = tvb_strsize(tvb, n); |
978 | proto_tree_add_item(tree, hf_statement, tvb, n, siz, ENC_ASCII0x00000000); |
979 | n += siz; |
980 | |
981 | i = tvb_get_ntohs(tvb, n); |
982 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Parameter formats: %d", i); |
983 | n += 2; |
984 | while (i-- > 0) { |
985 | proto_tree_add_item(shrub, hf_format, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
986 | n += 2; |
987 | } |
988 | |
989 | i = tvb_get_ntohs(tvb, n); |
990 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Parameter values: %d", i); |
991 | n += 2; |
992 | while (i-- > 0) { |
993 | siz = tvb_get_ntohl(tvb, n); |
994 | proto_tree_add_int(shrub, hf_val_length, tvb, n, 4, siz); |
995 | n += 4; |
996 | if (siz > 0) { |
997 | proto_tree_add_item(shrub, hf_val_data, tvb, n, siz, ENC_NA0x00000000); |
998 | n += siz; |
999 | } |
1000 | } |
1001 | |
1002 | i = tvb_get_ntohs(tvb, n); |
1003 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Result formats: %d", i); |
1004 | n += 2; |
1005 | while (i-- > 0) { |
1006 | proto_tree_add_item(shrub, hf_format, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1007 | n += 2; |
1008 | } |
1009 | break; |
1010 | |
1011 | /* Execute */ |
1012 | case 'E': |
1013 | siz = tvb_strsize(tvb, n); |
1014 | proto_tree_add_item(tree, hf_portal, tvb, n, siz, ENC_ASCII0x00000000); |
1015 | n += siz; |
1016 | |
1017 | i = tvb_get_ntohl(tvb, n); |
1018 | if (i == 0) |
1019 | proto_tree_add_uint_format_value(tree, hf_return, tvb, n, 4, i, "all rows"); |
1020 | else |
1021 | proto_tree_add_uint_format_value(tree, hf_return, tvb, n, 4, i, "%d rows", i); |
1022 | break; |
1023 | |
1024 | /* Describe, Close */ |
1025 | case 'D': |
1026 | case 'C': |
1027 | c = tvb_get_uint8(tvb, n); |
1028 | if (c == 'P') |
1029 | i = hf_portal; |
1030 | else |
1031 | i = hf_statement; |
1032 | |
1033 | n += 1; |
1034 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n, &siz, ENC_ASCII0x00000000); |
1035 | proto_tree_add_string(tree, i, tvb, n, siz, s); |
1036 | break; |
1037 | |
1038 | /* Messages without a type identifier */ |
1039 | case '\0': |
1040 | i = tvb_get_ntohl(tvb, n); |
1041 | n += 4; |
1042 | length -= n; |
1043 | switch (i) { |
1044 | /* Startup message */ |
1045 | case 196608: |
1046 | proto_tree_add_item(tree, hf_version_major, tvb, n-4, 2, ENC_BIG_ENDIAN0x00000000); |
1047 | proto_tree_add_item(tree, hf_version_minor, tvb, n-2, 2, ENC_BIG_ENDIAN0x00000000); |
1048 | while ((signed)length > 0) { |
1049 | siz = tvb_strsize(tvb, n); |
1050 | length -= siz; |
1051 | if ((signed)length <= 0) { |
1052 | break; |
1053 | } |
1054 | proto_tree_add_item(tree, hf_parameter_name, tvb, n, siz, ENC_ASCII0x00000000); |
1055 | i = tvb_strsize(tvb, n+siz); |
1056 | proto_tree_add_item(tree, hf_parameter_value, tvb, n + siz, i, ENC_ASCII0x00000000); |
1057 | length -= i; |
1058 | |
1059 | n += siz+i; |
1060 | if (length == 1 && tvb_get_uint8(tvb, n) == 0) |
1061 | break; |
1062 | } |
1063 | break; |
1064 | |
1065 | case PGSQL_SSLREQUEST80877103: |
1066 | proto_tree_add_item(tree, hf_request_code, tvb, n-4, 4, ENC_BIG_ENDIAN0x00000000); |
1067 | /* Next reply will be a single byte. */ |
1068 | wmem_tree_insert32(conv_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_SSL_REQUESTED)((gpointer) (gulong) (PGSQL_AUTH_SSL_REQUESTED))); |
1069 | break; |
1070 | |
1071 | case PGSQL_GSSENCREQUEST80877104: |
1072 | proto_tree_add_item(tree, hf_request_code, tvb, n-4, 4, ENC_BIG_ENDIAN0x00000000); |
1073 | /* Next reply will be a single byte. */ |
1074 | wmem_tree_insert32(conv_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_GSSENC_REQUESTED)((gpointer) (gulong) (PGSQL_AUTH_GSSENC_REQUESTED))); |
1075 | break; |
1076 | |
1077 | case PGSQL_CANCELREQUEST80877102: |
1078 | proto_tree_add_item(tree, hf_request_code, tvb, n-4, 4, ENC_BIG_ENDIAN0x00000000); |
1079 | proto_tree_add_item(tree, hf_pid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1080 | proto_tree_add_item(tree, hf_key, tvb, n+4, 4, ENC_BIG_ENDIAN0x00000000); |
1081 | break; |
1082 | } |
1083 | break; |
1084 | |
1085 | /* Copy data */ |
1086 | case 'd': |
1087 | dissect_pgsql_copy_data_fe_msg(tvb, n, tree, length, pinfo); |
1088 | break; |
1089 | |
1090 | /* Copy failure */ |
1091 | case 'f': |
1092 | siz = tvb_strsize(tvb, n); |
1093 | proto_tree_add_item(tree, hf_error, tvb, n, siz, ENC_ASCII0x00000000); |
1094 | break; |
1095 | |
1096 | /* Function call */ |
1097 | case 'F': |
1098 | proto_tree_add_item(tree, hf_oid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1099 | n += 4; |
1100 | |
1101 | i = tvb_get_ntohs(tvb, n); |
1102 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Parameter formats: %d", i); |
1103 | n += 2; |
1104 | while (i-- > 0) { |
1105 | proto_tree_add_item(shrub, hf_format, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1106 | n += 2; |
1107 | } |
1108 | |
1109 | i = tvb_get_ntohs(tvb, n); |
1110 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Parameter values: %d", i); |
1111 | n += 2; |
1112 | while (i-- > 0) { |
1113 | siz = tvb_get_ntohl(tvb, n); |
1114 | proto_tree_add_item(shrub, hf_val_length, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1115 | n += 4; |
1116 | if (siz > 0) { |
1117 | proto_tree_add_item(shrub, hf_val_data, tvb, n, siz, ENC_NA0x00000000); |
1118 | n += siz; |
1119 | } |
1120 | } |
1121 | |
1122 | proto_tree_add_item(tree, hf_format, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1123 | break; |
1124 | } |
1125 | } |
1126 | |
1127 | static void dissect_pgsql_be_msg(unsigned char type, unsigned length, tvbuff_t *tvb, |
1128 | int n, proto_tree *tree, packet_info *pinfo, |
1129 | pgsql_conn_data_t *conv_data) |
1130 | { |
1131 | unsigned char c; |
1132 | int i, siz; |
1133 | char *s, *t; |
1134 | int32_t num_nonsupported_options; |
1135 | proto_item *ti; |
1136 | proto_tree *shrub; |
1137 | uint32_t auth_type; |
1138 | |
1139 | switch (type) { |
1140 | /* Authentication request */ |
1141 | case 'R': |
1142 | proto_tree_add_item_ret_uint(tree, hf_authtype, tvb, n, 4, ENC_BIG_ENDIAN0x00000000, &auth_type); |
1143 | switch (auth_type) { |
1144 | case PGSQL_AUTH_TYPE_CRYPT4: |
1145 | case PGSQL_AUTH_TYPE_MD55: |
1146 | n += 4; |
1147 | siz = (auth_type == PGSQL_AUTH_TYPE_CRYPT4 ? 2 : 4); |
1148 | proto_tree_add_item(tree, hf_salt, tvb, n, siz, ENC_NA0x00000000); |
1149 | break; |
1150 | case PGSQL_AUTH_TYPE_GSSAPI_SSPI_CONTINUE8: |
1151 | proto_tree_add_item(tree, hf_gssapi_sspi_data, tvb, n, length-8, ENC_NA0x00000000); |
1152 | /* FALLTHROUGH */ |
1153 | case PGSQL_AUTH_TYPE_GSSAPI7: |
1154 | case PGSQL_AUTH_TYPE_SSPI9: |
1155 | wmem_tree_insert32(conv_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_GSSAPI_SSPI_DATA)((gpointer) (gulong) (PGSQL_AUTH_GSSAPI_SSPI_DATA))); |
1156 | break; |
1157 | case PGSQL_AUTH_TYPE_SASL10: |
1158 | wmem_tree_insert32(conv_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_SASL_REQUESTED)((gpointer) (gulong) (PGSQL_AUTH_SASL_REQUESTED))); |
1159 | n += 4; |
1160 | while ((unsigned)n < length) { |
1161 | siz = tvb_strsize(tvb, n); |
1162 | proto_tree_add_item(tree, hf_sasl_auth_mech, tvb, n, siz, ENC_ASCII0x00000000); |
1163 | n += siz; |
1164 | } |
1165 | break; |
1166 | case PGSQL_AUTH_TYPE_SASL_CONTINUE11: |
1167 | case PGSQL_AUTH_TYPE_SASL_COMPLETE12: |
1168 | wmem_tree_insert32(conv_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_SASL_CONTINUE)((gpointer) (gulong) (PGSQL_AUTH_SASL_CONTINUE))); |
1169 | n += 4; |
1170 | if ((unsigned)n < length) { |
1171 | proto_tree_add_item(tree, hf_sasl_auth_data, tvb, n, length-8, ENC_NA0x00000000); |
1172 | } |
1173 | break; |
1174 | } |
1175 | break; |
1176 | |
1177 | /* Key data */ |
1178 | case 'K': |
1179 | proto_tree_add_item(tree, hf_pid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1180 | proto_tree_add_item(tree, hf_key, tvb, n+4, 4, ENC_BIG_ENDIAN0x00000000); |
1181 | break; |
1182 | |
1183 | /* Parameter status */ |
1184 | case 'S': |
1185 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n, &siz, ENC_ASCII0x00000000); |
1186 | proto_tree_add_string(tree, hf_parameter_name, tvb, n, siz, s); |
1187 | n += siz; |
1188 | t = tvb_get_stringz_enc(pinfo->pool, tvb, n, &i, ENC_ASCII0x00000000); |
1189 | proto_tree_add_string(tree, hf_parameter_value, tvb, n, i, t); |
1190 | break; |
1191 | |
1192 | /* Parameter description */ |
1193 | case 't': |
1194 | i = tvb_get_ntohs(tvb, n); |
1195 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Parameters: %d", i); |
1196 | n += 2; |
1197 | while (i-- > 0) { |
1198 | proto_tree_add_item(shrub, hf_typeoid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1199 | n += 4; |
1200 | } |
1201 | break; |
1202 | |
1203 | /* Row description */ |
1204 | case 'T': |
1205 | i = tvb_get_ntohs(tvb, n); |
1206 | ti = proto_tree_add_item(tree, hf_field_count, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1207 | shrub = proto_item_add_subtree(ti, ett_values); |
1208 | n += 2; |
1209 | while (i-- > 0) { |
1210 | proto_tree *twig; |
1211 | siz = tvb_strsize(tvb, n); |
1212 | ti = proto_tree_add_item(shrub, hf_val_name, tvb, n, siz, ENC_ASCII0x00000000); |
1213 | twig = proto_item_add_subtree(ti, ett_values); |
1214 | n += siz; |
1215 | proto_tree_add_item(twig, hf_tableoid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1216 | n += 4; |
1217 | proto_tree_add_item(twig, hf_val_idx, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1218 | n += 2; |
1219 | proto_tree_add_item(twig, hf_typeoid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1220 | n += 4; |
1221 | proto_tree_add_item(twig, hf_val_length, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1222 | n += 2; |
1223 | proto_tree_add_item(twig, hf_val_mod, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1224 | n += 4; |
1225 | proto_tree_add_item(twig, hf_format, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1226 | n += 2; |
1227 | } |
1228 | break; |
1229 | |
1230 | /* Data row */ |
1231 | case 'D': |
1232 | i = tvb_get_ntohs(tvb, n); |
1233 | ti = proto_tree_add_item(tree, hf_field_count, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1234 | shrub = proto_item_add_subtree(ti, ett_values); |
1235 | n += 2; |
1236 | while (i-- > 0) { |
1237 | siz = tvb_get_ntohl(tvb, n); |
1238 | proto_tree_add_int(shrub, hf_val_length, tvb, n, 4, siz); |
1239 | n += 4; |
1240 | if (siz > 0) { |
1241 | proto_tree_add_item(shrub, hf_val_data, tvb, n, siz, ENC_NA0x00000000); |
1242 | n += siz; |
1243 | } |
1244 | } |
1245 | break; |
1246 | |
1247 | /* Command completion */ |
1248 | case 'C': |
1249 | siz = tvb_strsize(tvb, n); |
1250 | proto_tree_add_item(tree, hf_tag, tvb, n, siz, ENC_ASCII0x00000000); |
1251 | break; |
1252 | |
1253 | /* Ready */ |
1254 | case 'Z': |
1255 | proto_tree_add_item(tree, hf_status, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
1256 | break; |
1257 | |
1258 | /* Error, Notice */ |
1259 | case 'E': |
1260 | case 'N': |
1261 | length -= 4; |
1262 | while ((signed)length > 0) { |
1263 | c = tvb_get_uint8(tvb, n); |
1264 | if (c == '\0') |
1265 | break; |
1266 | --length; |
1267 | s = tvb_get_stringz_enc(pinfo->pool, tvb, n+1, &siz, ENC_ASCII0x00000000); |
1268 | i = hf_text; |
1269 | switch (c) { |
1270 | case 'S': i = hf_severity; break; |
1271 | case 'C': i = hf_code; break; |
1272 | case 'M': i = hf_message; break; |
1273 | case 'D': i = hf_detail; break; |
1274 | case 'H': i = hf_hint; break; |
1275 | case 'P': i = hf_position; break; |
1276 | case 'p': i = hf_internal_position; break; |
1277 | case 'q': i = hf_internal_query; break; |
1278 | case 'W': i = hf_where; break; |
1279 | case 's': i = hf_schema_name; break; |
1280 | case 't': i = hf_table_name; break; |
1281 | case 'c': i = hf_column_name; break; |
1282 | case 'd': i = hf_type_name; break; |
1283 | case 'n': i = hf_constraint_name; break; |
1284 | case 'F': i = hf_file; break; |
1285 | case 'L': i = hf_line; break; |
1286 | case 'R': i = hf_routine; break; |
1287 | } |
1288 | proto_tree_add_string(tree, i, tvb, n, siz+1, s); |
1289 | length -= siz+1; |
1290 | n += siz+1; |
1291 | } |
1292 | break; |
1293 | |
1294 | /* NOTICE response */ |
1295 | case 'A': |
1296 | proto_tree_add_item(tree, hf_pid, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1297 | n += 4; |
1298 | siz = tvb_strsize(tvb, n); |
1299 | proto_tree_add_item(tree, hf_condition, tvb, n, siz, ENC_ASCII0x00000000); |
1300 | n += siz; |
1301 | siz = tvb_strsize(tvb, n); |
1302 | if (siz > 1) |
1303 | proto_tree_add_item(tree, hf_text, tvb, n, siz, ENC_ASCII0x00000000); |
1304 | break; |
1305 | |
1306 | /* Copy in/out */ |
1307 | case 'G': |
1308 | case 'H': |
1309 | proto_tree_add_item(tree, hf_format, tvb, n, 1, ENC_BIG_ENDIAN0x00000000); |
1310 | n += 1; |
1311 | i = tvb_get_ntohs(tvb, n); |
1312 | shrub = proto_tree_add_subtree_format(tree, tvb, n, 2, ett_values, NULL((void*)0), "Columns: %d", i); |
1313 | n += 2; |
1314 | while (i-- > 2) { |
1315 | proto_tree_add_item(shrub, hf_format, tvb, n, 2, ENC_BIG_ENDIAN0x00000000); |
1316 | n += 2; |
1317 | } |
1318 | break; |
1319 | |
1320 | /* Copy data */ |
1321 | case 'd': |
1322 | dissect_pgsql_copy_data_be_msg(length, tvb, n, tree, pinfo, conv_data); |
1323 | break; |
1324 | |
1325 | /* Function call response */ |
1326 | case 'V': |
1327 | siz = tvb_get_ntohl(tvb, n); |
1328 | proto_tree_add_int(tree, hf_val_length, tvb, n, 4, siz); |
1329 | if (siz > 0) |
1330 | proto_tree_add_item(tree, hf_val_data, tvb, n+4, siz, ENC_NA0x00000000); |
1331 | break; |
1332 | |
1333 | /* Negotiate Protocol Version */ |
1334 | case 'v': |
1335 | proto_tree_add_item(tree, hf_supported_minor_version, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1336 | n += 4; |
1337 | proto_tree_add_item_ret_int(tree, hf_number_nonsupported_options, tvb, n, 4, ENC_BIG_ENDIAN0x00000000, &num_nonsupported_options); |
1338 | n += 4; |
1339 | while (num_nonsupported_options > 0) { |
1340 | siz = tvb_strsize(tvb, n); |
1341 | proto_tree_add_item(tree, hf_nonsupported_option, tvb, n, siz, ENC_ASCII0x00000000); |
1342 | n += siz; |
1343 | num_nonsupported_options--; |
1344 | } |
1345 | break; |
1346 | } |
1347 | } |
1348 | |
1349 | /* This function is called by tcp_dissect_pdus() to find the size of the |
1350 | message starting at tvb[offset]. */ |
1351 | static unsigned |
1352 | pgsql_length(packet_info *pinfo _U___attribute__((unused)), tvbuff_t *tvb, int offset, void *data _U___attribute__((unused))) |
1353 | { |
1354 | int n = 0; |
1355 | unsigned char type; |
1356 | unsigned length; |
1357 | |
1358 | /* The length is either the four bytes after the type, or, if the |
1359 | type is 0, the first four bytes. */ |
1360 | type = tvb_get_uint8(tvb, offset); |
1361 | if (type != '\0') |
1362 | n = 1; |
1363 | length = tvb_get_ntohl(tvb, offset+n); |
1364 | return length+n; |
1365 | } |
1366 | |
1367 | /* This function is called by tcp_dissect_pdus() to find the size of the |
1368 | wrapped GSS-API message starting at tvb[offset] whe. */ |
1369 | static unsigned |
1370 | pgsql_gssapi_length(packet_info *pinfo _U___attribute__((unused)), tvbuff_t *tvb, int offset, void *data _U___attribute__((unused))) |
1371 | { |
1372 | /* The length of the GSS-API message is the first four bytes, and does |
1373 | * not include the 4 byte length (the gss_wrap). */ |
1374 | return tvb_get_ntohl(tvb, offset) + 4; |
1375 | } |
1376 | |
1377 | |
1378 | /* This function is responsible for dissecting a single message. */ |
1379 | |
1380 | static int |
1381 | dissect_pgsql_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused))) |
1382 | { |
1383 | proto_item *ti, *hidden_item; |
1384 | proto_tree *ptree; |
1385 | conversation_t *conversation; |
1386 | pgsql_conn_data_t *conn_data; |
1387 | pgsql_auth_state_t state; |
1388 | |
1389 | int n; |
1390 | unsigned char type; |
1391 | const char *typestr; |
1392 | unsigned length; |
1393 | bool_Bool fe; |
1394 | |
1395 | conversation = find_or_create_conversation(pinfo); |
1396 | conn_data = (pgsql_conn_data_t *)conversation_get_proto_data(conversation, proto_pgsql); |
1397 | if (!conn_data) { |
1398 | conn_data = wmem_new(wmem_file_scope(), pgsql_conn_data_t)((pgsql_conn_data_t*)wmem_alloc((wmem_file_scope()), sizeof(pgsql_conn_data_t ))); |
1399 | conn_data->state_tree = wmem_tree_new(wmem_file_scope()); |
1400 | conn_data->server_port = pinfo->match_uint; |
1401 | conn_data->streamed_txn = false0; |
1402 | wmem_tree_insert32(conn_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_STATE_NONE)((gpointer) (gulong) (PGSQL_AUTH_STATE_NONE))); |
1403 | conversation_add_proto_data(conversation, proto_pgsql, conn_data); |
1404 | } |
1405 | |
1406 | fe = (conn_data->server_port == pinfo->destport); |
1407 | |
1408 | n = 0; |
1409 | type = tvb_get_uint8(tvb, 0); |
1410 | if (type != '\0') |
1411 | n += 1; |
1412 | length = tvb_get_ntohl(tvb, n); |
1413 | |
1414 | /* This is like specifying VALS(messages) for hf_type, which we can't do |
1415 | directly because of messages without type bytes, and because the type |
1416 | interpretation depends on fe. */ |
1417 | if (fe) { |
1418 | /* There are a few frontend messages that have no leading type byte. |
1419 | We identify them by the fact that the first byte of their length |
1420 | must be zero, and that the next four bytes are a unique tag. */ |
1421 | if (type == '\0') { |
1422 | unsigned tag = tvb_get_ntohl(tvb, 4); |
1423 | |
1424 | if (length == 16 && tag == PGSQL_CANCELREQUEST80877102) |
1425 | typestr = "Cancel request"; |
1426 | else if (length == 8 && tag == PGSQL_SSLREQUEST80877103) |
1427 | typestr = "SSL request"; |
1428 | else if (length == 8 && tag == PGSQL_GSSENCREQUEST80877104) |
1429 | typestr = "GSS encrypt request"; |
1430 | else if (tag == 196608) |
1431 | typestr = "Startup message"; |
1432 | else |
1433 | typestr = "Unknown"; |
1434 | } else if (type == 'p') { |
1435 | state = GPOINTER_TO_UINT(wmem_tree_lookup32_le(conn_data->state_tree, pinfo->num))((guint) (gulong) (wmem_tree_lookup32_le(conn_data->state_tree , pinfo->num))); |
1436 | switch (state) { |
1437 | case PGSQL_AUTH_SASL_REQUESTED: |
1438 | typestr = "SASLInitialResponse message"; |
1439 | break; |
1440 | case PGSQL_AUTH_SASL_CONTINUE: |
1441 | typestr = "SASLResponse message"; |
1442 | break; |
1443 | case PGSQL_AUTH_GSSAPI_SSPI_DATA: |
1444 | typestr = "GSSResponse message"; |
1445 | break; |
1446 | default: |
1447 | typestr = "Password message"; |
1448 | break; |
1449 | } |
1450 | } else |
1451 | typestr = val_to_str_const(type, fe_messages, "Unknown"); |
1452 | } |
1453 | else { |
1454 | typestr = val_to_str_const(type, be_messages, "Unknown"); |
1455 | } |
1456 | |
1457 | /* This is a terrible hack. It makes the "Info" column reflect |
1458 | the contents of every message in a TCP packet. Could it be |
1459 | done any better? */ |
1460 | col_append_fstr(pinfo->cinfo, COL_INFO, "%s%c", |
1461 | ( first_message ? "" : "/" ), g_ascii_isprint(type)((g_ascii_table[(guchar) (type)] & G_ASCII_PRINT) != 0) ? type : '?'); |
1462 | first_message = false0; |
1463 | |
1464 | { |
1465 | ti = proto_tree_add_item(tree, proto_pgsql, tvb, 0, -1, ENC_NA0x00000000); |
1466 | ptree = proto_item_add_subtree(ti, ett_pgsql); |
1467 | |
1468 | n = 1; |
1469 | if (type == '\0') |
1470 | n = 0; |
1471 | proto_tree_add_string(ptree, hf_type, tvb, 0, n, typestr); |
1472 | proto_tree_add_item(ptree, hf_length, tvb, n, 4, ENC_BIG_ENDIAN0x00000000); |
1473 | hidden_item = proto_tree_add_boolean(ptree, hf_frontend, tvb, 0, 0, fe); |
1474 | proto_item_set_hidden(hidden_item); |
1475 | n += 4; |
1476 | |
1477 | if (fe) |
1478 | dissect_pgsql_fe_msg(type, length, tvb, n, ptree, pinfo, conn_data); |
1479 | else |
1480 | dissect_pgsql_be_msg(type, length, tvb, n, ptree, pinfo, conn_data); |
1481 | } |
1482 | |
1483 | return tvb_captured_length(tvb); |
1484 | } |
1485 | |
1486 | static int |
1487 | dissect_pgsql_gssapi_wrap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
1488 | { |
1489 | proto_item *ti; |
1490 | proto_tree *ptree; |
1491 | |
1492 | conversation_t *conversation; |
1493 | pgsql_conn_data_t *conn_data; |
1494 | |
1495 | conversation = find_or_create_conversation(pinfo); |
1496 | conn_data = (pgsql_conn_data_t *)conversation_get_proto_data(conversation, proto_pgsql); |
1497 | |
1498 | if (!conn_data) { |
1499 | /* This shouldn't happen. */ |
1500 | conn_data = wmem_new0(wmem_file_scope(), pgsql_conn_data_t)((pgsql_conn_data_t*)wmem_alloc0((wmem_file_scope()), sizeof( pgsql_conn_data_t))); |
1501 | conn_data->state_tree = wmem_tree_new(wmem_file_scope()); |
1502 | conn_data->server_port = pinfo->match_uint; |
1503 | wmem_tree_insert32(conn_data->state_tree, pinfo->num, GUINT_TO_POINTER(PGSQL_AUTH_GSSAPI_SSPI_DATA)((gpointer) (gulong) (PGSQL_AUTH_GSSAPI_SSPI_DATA))); |
1504 | conversation_add_proto_data(conversation, proto_pgsql, conn_data); |
1505 | } |
1506 | |
1507 | bool_Bool fe = (pinfo->destport == conn_data->server_port); |
1508 | |
1509 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "PGSQL"); |
1510 | col_set_str(pinfo->cinfo, COL_INFO, |
1511 | fe ? ">" : "<"); |
1512 | |
1513 | ti = proto_tree_add_item(tree, proto_pgsql, tvb, 0, -1, ENC_NA0x00000000); |
1514 | ptree = proto_item_add_subtree(ti, ett_pgsql); |
1515 | |
1516 | proto_tree_add_string(ptree, hf_type, tvb, 0, 0, "GSS-API encrypted message"); |
1517 | proto_tree_add_item(ptree, hf_length, tvb, 0, 4, ENC_BIG_ENDIAN0x00000000); |
1518 | |
1519 | gssapi_encrypt_info_t encrypt; |
1520 | memset(&encrypt, 0, sizeof(encrypt)); |
1521 | encrypt.decrypt_gssapi_tvb = DECRYPT_GSSAPI_NORMAL1; |
1522 | |
1523 | int ver_len; |
1524 | tvbuff_t *gssapi_tvb = tvb_new_subset_remaining(tvb, 4); |
1525 | |
1526 | ver_len = call_dissector_with_data(gssapi_handle, gssapi_tvb, pinfo, ptree, &encrypt); |
1527 | if (ver_len == 0) { |
1528 | /* GSS-API couldn't do anything with it. */ |
1529 | return tvb_captured_length(tvb); |
1530 | } |
1531 | if (encrypt.gssapi_data_encrypted) { |
1532 | if (encrypt.gssapi_decrypted_tvb) { |
1533 | tvbuff_t *decr_tvb = encrypt.gssapi_decrypted_tvb; |
1534 | add_new_data_source(pinfo, encrypt.gssapi_decrypted_tvb, "Decrypted GSS-API"); |
1535 | dissect_pgsql_msg(decr_tvb, pinfo, ptree, data); |
1536 | } else { |
1537 | /* Encrypted but couldn't be decrypted. */ |
1538 | proto_tree_add_item(ptree, hf_gssapi_encrypted_payload, gssapi_tvb, ver_len, -1, ENC_NA0x00000000); |
1539 | } |
1540 | } else { |
1541 | /* No encrypted (sealed) payload. If any bytes are left, that is |
1542 | * signed-only payload. */ |
1543 | tvbuff_t *plain_tvb; |
1544 | if (encrypt.gssapi_decrypted_tvb) { |
1545 | plain_tvb = encrypt.gssapi_decrypted_tvb; |
1546 | } else { |
1547 | plain_tvb = tvb_new_subset_remaining(gssapi_tvb, ver_len); |
1548 | } |
1549 | if (tvb_reported_length(plain_tvb)) { |
1550 | dissect_pgsql_msg(plain_tvb, pinfo, ptree, data); |
1551 | } |
1552 | } |
1553 | return tvb_captured_length(tvb); |
1554 | } |
1555 | |
1556 | static int |
1557 | dissect_pgsql_gssapi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
1558 | { |
1559 | tcp_dissect_pdus(tvb, pinfo, tree, pgsql_desegment, 4, |
1560 | pgsql_gssapi_length, dissect_pgsql_gssapi_wrap, data); |
1561 | return tvb_captured_length(tvb); |
1562 | } |
1563 | |
1564 | /* This function is called once per TCP packet. It sets COL_PROTOCOL and |
1565 | * identifies FE/BE messages by adding a ">" or "<" to COL_INFO. Then it |
1566 | * arranges for each message to be dissected individually. */ |
1567 | |
1568 | static int |
1569 | dissect_pgsql(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) |
1570 | { |
1571 | proto_item *ti; |
1572 | proto_tree *ptree; |
1573 | conversation_t *conversation; |
1574 | pgsql_conn_data_t *conn_data; |
1575 | pgsql_auth_state_t state; |
1576 | |
1577 | first_message = true1; |
1578 | |
1579 | conversation = find_or_create_conversation(pinfo); |
1580 | conn_data = (pgsql_conn_data_t *)conversation_get_proto_data(conversation, proto_pgsql); |
1581 | |
1582 | bool_Bool fe = (pinfo->match_uint == pinfo->destport); |
1583 | |
1584 | if (fe && tvb_get_uint8(tvb, 0) == 0x16 && |
1585 | (!conn_data || wmem_tree_lookup32_le(conn_data->state_tree, pinfo->num) == NULL((void*)0))) |
1586 | { |
1587 | /* This is the first message in the conversation, and it looks |
1588 | * like a TLS handshake. Assume the client is performing |
1589 | * "direct SSL" negotiation. |
1590 | */ |
1591 | tls_set_appdata_dissector(tls_handle, pinfo, pgsql_handle); |
1592 | } |
1593 | |
1594 | if (!tvb_ascii_isprint(tvb, 0, 1) && tvb_get_uint8(tvb, 0) != '\0') { |
1595 | /* Doesn't look like the start of a PostgreSQL packet. Have we |
1596 | * seen Postgres yet? |
1597 | */ |
1598 | if (!conn_data || wmem_tree_lookup32_le(conn_data->state_tree, pinfo->num) == NULL((void*)0)) { |
1599 | /* No. Reject. This might be PostgreSQL over TLS and we missed |
1600 | * the start of the transaction. The TLS dissector should get |
1601 | * a chance. |
1602 | */ |
1603 | return 0; |
1604 | } |
1605 | /* Was there segmentation, and we lost a packet or were out of |
1606 | * order without out of order processing, or we couldn't do |
1607 | * desegmentation of a segment because of a bad checksum? |
1608 | * XXX: Should we call this Continuation Data if this happens, |
1609 | * so we don't send it to tcp_dissect_pdus()? |
1610 | */ |
1611 | } |
1612 | |
1613 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "PGSQL"); |
1614 | col_set_str(pinfo->cinfo, COL_INFO, |
1615 | fe ? ">" : "<"); |
1616 | |
1617 | if (conn_data && !fe) { |
1618 | state = GPOINTER_TO_UINT(wmem_tree_lookup32_le(conn_data->state_tree, pinfo->num))((guint) (gulong) (wmem_tree_lookup32_le(conn_data->state_tree , pinfo->num))); |
1619 | if (state == PGSQL_AUTH_SSL_REQUESTED) { |
1620 | /* Response to SSLRequest. */ |
1621 | wmem_tree_insert32(conn_data->state_tree, pinfo->num + 1, GUINT_TO_POINTER(PGSQL_AUTH_STATE_NONE)((gpointer) (gulong) (PGSQL_AUTH_STATE_NONE))); |
1622 | ti = proto_tree_add_item(tree, proto_pgsql, tvb, 0, -1, ENC_NA0x00000000); |
1623 | ptree = proto_item_add_subtree(ti, ett_pgsql); |
1624 | proto_tree_add_string(ptree, hf_type, tvb, 0, 0, "SSL response"); |
1625 | proto_tree_add_item(ptree, hf_ssl_response, tvb, 0, 1, ENC_ASCII0x00000000); |
1626 | switch (tvb_get_uint8(tvb, 0)) { |
1627 | case 'S': /* Willing to perform SSL */ |
1628 | /* Next packet will start using SSL. */ |
1629 | ssl_starttls_ack(tls_handle, pinfo, pgsql_handle); |
1630 | break; |
1631 | case 'E': /* ErrorResponse when server does not support SSL. */ |
1632 | /* Process normally. */ |
1633 | tcp_dissect_pdus(tvb, pinfo, tree, pgsql_desegment, 5, |
1634 | pgsql_length, dissect_pgsql_msg, data); |
1635 | break; |
1636 | case 'N': /* Unwilling to perform SSL */ |
1637 | default: /* Unexpected response. */ |
1638 | /* TODO: maybe add expert info here? */ |
1639 | break; |
1640 | } |
1641 | /* XXX: If it's anything other than 'E', a length of more |
1642 | * than one character is unexpected and should possibly have |
1643 | * an expert info (possible MitM: |
1644 | * https://www.postgresql.org/support/security/CVE-2021-23222/ ) |
1645 | */ |
1646 | return tvb_captured_length(tvb); |
1647 | } else if (state == PGSQL_AUTH_GSSENC_REQUESTED) { |
1648 | /* Response to GSSENCRequest. */ |
1649 | wmem_tree_insert32(conn_data->state_tree, pinfo->num + 1, GUINT_TO_POINTER(PGSQL_AUTH_STATE_NONE)((gpointer) (gulong) (PGSQL_AUTH_STATE_NONE))); |
1650 | ti = proto_tree_add_item(tree, proto_pgsql, tvb, 0, -1, ENC_NA0x00000000); |
1651 | ptree = proto_item_add_subtree(ti, ett_pgsql); |
1652 | proto_tree_add_string(ptree, hf_type, tvb, 0, 0, "GSS encrypt response"); |
1653 | proto_tree_add_item(ptree, hf_gssenc_response, tvb, 0, 1, ENC_ASCII0x00000000); |
1654 | switch (tvb_get_uint8(tvb, 0)) { |
1655 | case 'E': /* ErrorResponse; server does not support GSSAPI. */ |
1656 | /* Process normally. */ |
1657 | tcp_dissect_pdus(tvb, pinfo, tree, pgsql_desegment, 5, |
1658 | pgsql_length, dissect_pgsql_msg, data); |
1659 | break; |
1660 | case 'G': /* Willing to perform GSSAPI Enc */ |
1661 | wmem_tree_insert32(conn_data->state_tree, pinfo->num + 1, GUINT_TO_POINTER(PGSQL_AUTH_GSSAPI_SSPI_DATA)((gpointer) (gulong) (PGSQL_AUTH_GSSAPI_SSPI_DATA))); |
1662 | conversation_set_dissector_from_frame_number(conversation, pinfo->num + 1, pgsql_gssapi_handle); |
1663 | break; |
1664 | case 'N': /* Unwilling to perform GSSAPI Enc */ |
1665 | default: /* Unexpected response. */ |
1666 | /* TODO: maybe add expert info here? */ |
1667 | break; |
1668 | } |
1669 | return tvb_captured_length(tvb); |
1670 | } |
1671 | } |
1672 | |
1673 | tcp_dissect_pdus(tvb, pinfo, tree, pgsql_desegment, 5, |
1674 | pgsql_length, dissect_pgsql_msg, data); |
1675 | return tvb_captured_length(tvb); |
1676 | } |
1677 | |
1678 | void |
1679 | proto_register_pgsql(void) |
1680 | { |
1681 | static hf_register_info hf[] = { |
1682 | { &hf_frontend, |
1683 | { "Frontend", "pgsql.frontend", FT_BOOLEAN, BASE_NONE, NULL((void*)0), 0x0, |
1684 | "True for messages from the frontend, false otherwise.", |
1685 | HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1686 | }, |
1687 | { &hf_type, |
1688 | { "Type", "pgsql.type", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1689 | "A one-byte message type identifier.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1690 | }, |
1691 | { &hf_length, |
1692 | { "Length", "pgsql.length", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1693 | "The length of the message (not including the type).", |
1694 | HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1695 | }, |
1696 | { &hf_version_major, |
1697 | { "Protocol major version", "pgsql.version_major", FT_UINT16, BASE_DEC, NULL((void*)0), 0, |
1698 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1699 | }, |
1700 | { &hf_version_minor, |
1701 | { "Protocol minor version", "pgsql.version_minor", FT_UINT16, BASE_DEC, NULL((void*)0), 0, |
1702 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1703 | }, |
1704 | { &hf_request_code, |
1705 | { "Request code", "pgsql.request_code", FT_UINT32, BASE_DEC, |
1706 | VALS(request_code_vals)((0 ? (const struct _value_string*)0 : ((request_code_vals))) ), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1707 | }, |
1708 | { &hf_supported_minor_version, |
1709 | { "Supported minor version", "pgsql.version_supported_minor", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1710 | "Newest minor protocol version supported by the server for the major protocol version requested by the client.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1711 | }, |
1712 | { &hf_number_nonsupported_options, |
1713 | { "Number nonsupported options", "pgsql.number_nonsupported_options", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
1714 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1715 | }, |
1716 | { &hf_nonsupported_option, |
1717 | { "Nonsupported option", "pgsql.nonsupported_option", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1718 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1719 | }, |
1720 | { &hf_parameter_name, |
1721 | { "Parameter name", "pgsql.parameter_name", FT_STRINGZ, |
1722 | BASE_NONE, NULL((void*)0), 0, "The name of a database parameter.", |
1723 | HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1724 | }, |
1725 | { &hf_parameter_value, |
1726 | { "Parameter value", "pgsql.parameter_value", FT_STRINGZ, |
1727 | BASE_NONE, NULL((void*)0), 0, "The value of a database parameter.", |
1728 | HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1729 | }, |
1730 | { &hf_query, |
1731 | { "Query", "pgsql.query", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1732 | "A query string.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1733 | }, |
1734 | { &hf_passwd, |
1735 | { "Password", "pgsql.password", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1736 | "A password.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1737 | }, |
1738 | { &hf_authtype, |
1739 | { "Authentication type", "pgsql.authtype", FT_UINT32, BASE_DEC, |
1740 | VALS(auth_types)((0 ? (const struct _value_string*)0 : ((auth_types)))), 0, |
1741 | "The type of authentication requested by the backend.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1742 | }, |
1743 | { &hf_salt, |
1744 | { "Salt value", "pgsql.salt", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1745 | "The salt to use while encrypting a password.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1746 | }, |
1747 | { &hf_gssapi_sspi_data, |
1748 | { "GSSAPI or SSPI authentication data", "pgsql.auth.gssapi_sspi.data", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1749 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1750 | }, |
1751 | { &hf_sasl_auth_mech, |
1752 | { "SASL authentication mechanism", "pgsql.auth.sasl.mech", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1753 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1754 | }, |
1755 | { &hf_sasl_auth_data_length, |
1756 | { "SASL authentication data length", "pgsql.auth.sasl.data.length", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
1757 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1758 | }, |
1759 | { &hf_sasl_auth_data, |
1760 | { "SASL authentication data", "pgsql.auth.sasl.data", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1761 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1762 | }, |
1763 | { &hf_statement, |
1764 | { "Statement", "pgsql.statement", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1765 | "The name of a prepared statement.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1766 | }, |
1767 | { &hf_portal, |
1768 | { "Portal", "pgsql.portal", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1769 | "The name of a portal.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1770 | }, |
1771 | { &hf_return, |
1772 | { "Returns", "pgsql.returns", FT_UINT32, BASE_DEC, |
1773 | NULL((void*)0), 0, |
1774 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1775 | }, |
1776 | { &hf_tag, |
1777 | { "Tag", "pgsql.tag", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1778 | "A completion tag.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1779 | }, |
1780 | { &hf_status, |
1781 | { "Status", "pgsql.status", FT_UINT8, BASE_DEC, VALS(status_vals)((0 ? (const struct _value_string*)0 : ((status_vals)))), |
1782 | 0, "The transaction status of the backend.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1783 | }, |
1784 | { &hf_copydata, |
1785 | { "Copy data", "pgsql.copydata", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1786 | "Data sent following a Copy-in or Copy-out response.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1787 | }, |
1788 | { &hf_copydata_type, |
1789 | { "Copy data type", "pgsql.copydata_type", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1790 | "A one-byte message type identifier for Copy data.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1791 | }, |
1792 | { &hf_xlogdata, |
1793 | { "XLog data", "pgsql.xlogdata", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1794 | "XLog data.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1795 | }, |
1796 | { &hf_error, |
1797 | { "Error", "pgsql.error", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1798 | "An error message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1799 | }, |
1800 | { &hf_pid, |
1801 | { "PID", "pgsql.pid", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1802 | "The process ID of a backend.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1803 | }, |
1804 | { &hf_key, |
1805 | { "Key", "pgsql.key", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1806 | "The secret key used by a particular backend.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1807 | }, |
1808 | { &hf_condition, |
1809 | { "Condition", "pgsql.condition", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1810 | "The name of a NOTIFY condition.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1811 | }, |
1812 | { &hf_text, |
1813 | { "Text", "pgsql.text", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1814 | "Text from the backend.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1815 | }, |
1816 | { &hf_tableoid, |
1817 | { "Table OID", "pgsql.oid.table", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1818 | "The object identifier of a table.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1819 | }, |
1820 | { &hf_typeoid, |
1821 | { "Type OID", "pgsql.oid.type", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1822 | "The object identifier of a type.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1823 | }, |
1824 | { &hf_oid, |
1825 | { "OID", "pgsql.oid", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1826 | "An object identifier.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1827 | }, |
1828 | { &hf_format, |
1829 | { "Format", "pgsql.format", FT_UINT16, BASE_DEC, VALS(format_vals)((0 ? (const struct _value_string*)0 : ((format_vals)))), |
1830 | 0, "A format specifier.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1831 | }, |
1832 | { &hf_field_count, |
1833 | { "Field count", "pgsql.field.count", FT_UINT16, BASE_DEC, NULL((void*)0), 0, |
1834 | "The number of fields within a row.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1835 | }, |
1836 | { &hf_val_name, |
1837 | { "Column name", "pgsql.col.name", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1838 | "The name of a column.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1839 | }, |
1840 | { &hf_val_idx, |
1841 | { "Column index", "pgsql.col.index", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1842 | "The position of a column within a row.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1843 | }, |
1844 | { &hf_val_length, |
1845 | { "Column length", "pgsql.val.length", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
1846 | "The length of a parameter value, in bytes. -1 means NULL.", |
1847 | HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1848 | }, |
1849 | { &hf_val_data, |
1850 | { "Data", "pgsql.val.data", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1851 | "Parameter data.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1852 | }, |
1853 | { &hf_val_text_data, |
1854 | { "Text data", "pgsql.val.text_data", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1855 | "Text data.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1856 | }, |
1857 | { &hf_val_mod, |
1858 | { "Type modifier", "pgsql.col.typemod", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
1859 | "The type modifier for a column.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1860 | }, |
1861 | { &hf_severity, |
1862 | { "Severity", "pgsql.severity", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1863 | "Message severity.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1864 | }, |
1865 | { &hf_code, |
1866 | { "Code", "pgsql.code", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1867 | "SQLState code.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1868 | }, |
1869 | { &hf_message, |
1870 | { "Message", "pgsql.message", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1871 | "Error message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1872 | }, |
1873 | { &hf_detail, |
1874 | { "Detail", "pgsql.detail", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1875 | "Detailed error message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1876 | }, |
1877 | { &hf_hint, |
1878 | { "Hint", "pgsql.hint", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1879 | "A suggestion to resolve an error.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1880 | }, |
1881 | { &hf_position, |
1882 | { "Position", "pgsql.position", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1883 | "The index of the error within the query string.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1884 | }, |
1885 | { &hf_internal_position, |
1886 | { "Position (Internal)", "pgsql.internal_position", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1887 | "The index of the error within the internally-generated query string.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1888 | }, |
1889 | { &hf_internal_query, |
1890 | { "Query (Internal)", "pgsql.internal_query", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1891 | "The internally-generated query string", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1892 | }, |
1893 | { &hf_where, |
1894 | { "Context", "pgsql.where", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1895 | "The context in which an error occurred.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1896 | }, |
1897 | { &hf_schema_name, |
1898 | { "Schema", "pgsql.schema_name", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1899 | "The schema with which an error is associated.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1900 | }, |
1901 | { &hf_table_name, |
1902 | { "Table", "pgsql.table_name", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1903 | "The table with which an error is associated.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1904 | }, |
1905 | { &hf_column_name, |
1906 | { "Column", "pgsql.column_name", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1907 | "The column with which an error is associated.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1908 | }, |
1909 | { &hf_type_name, |
1910 | { "Type", "pgsql.type_name", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1911 | "The date type with which an error is associated.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1912 | }, |
1913 | { &hf_constraint_name, |
1914 | { "Constraint", "pgsql.constraint_name", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1915 | "The constraint with which an error is associated.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1916 | }, |
1917 | { &hf_file, |
1918 | { "File", "pgsql.file", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1919 | "The source-code file where an error was reported.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1920 | }, |
1921 | { &hf_line, |
1922 | { "Line", "pgsql.line", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1923 | "The line number on which an error was reported.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1924 | }, |
1925 | { &hf_routine, |
1926 | { "Routine", "pgsql.routine", FT_STRINGZ, BASE_NONE, NULL((void*)0), 0, |
1927 | "The routine that reported an error.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1928 | }, |
1929 | { &hf_ssl_response, |
1930 | { "SSL Response", "pgsql.ssl_response", FT_CHAR, BASE_HEX, |
1931 | VALS(ssl_response_vals)((0 ? (const struct _value_string*)0 : ((ssl_response_vals))) ), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1932 | }, |
1933 | { &hf_gssenc_response, |
1934 | { "GSSAPI Encrypt Response", "pgsql.gssenc_response", FT_CHAR, |
1935 | BASE_HEX, VALS(gssenc_response_vals)((0 ? (const struct _value_string*)0 : ((gssenc_response_vals )))), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1936 | }, |
1937 | { &hf_gssapi_encrypted_payload, |
1938 | { "GSS-API encrypted payload", "pgsql.gssapi.encrypted_payload", FT_BYTES, BASE_NONE, NULL((void*)0), 0, |
1939 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1940 | }, |
1941 | { &hf_standby_clock_ts, |
1942 | { "Server time", "pgsql.xlog_ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL((void*)0), 0, |
1943 | "The server's system clock at the time of transmission.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1944 | }, |
1945 | { &hf_xid, |
1946 | { "Transaction id", "pgsql.xid", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1947 | "Xid of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1948 | }, |
1949 | { &hf_xid_subtransaction, |
1950 | { "Subtransaction id", "pgsql.xid_subtransaction", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1951 | "Xid of the subtransaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1952 | }, |
1953 | { &hf_custom_type_name, |
1954 | { "Type name", "pgsql.custom_type_name", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1955 | "Name of the data type.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1956 | }, |
1957 | { &hf_namespace, |
1958 | { "Namespace", "pgsql.namespace", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1959 | "Namespace (empty string for pg_catalog).", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1960 | }, |
1961 | { &hf_relation_name, |
1962 | { "Relation name", "pgsql.relation", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1963 | "Relation name.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1964 | }, |
1965 | { &hf_tuple_type, |
1966 | { "Tuple type", "pgsql.tuple_type", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1967 | "Tuple type.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1968 | }, |
1969 | { &hf_tuple_data_type, |
1970 | { "Tuple data type", "pgsql.tuple_data_type", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
1971 | "Tuple data type.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1972 | }, |
1973 | { &hf_xlog_wal_start, |
1974 | { "WAL start", "pgsql.xlog_wal_start", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
1975 | "The starting point of the WAL data in this message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1976 | }, |
1977 | { &hf_xlog_wal_end, |
1978 | { "WAL end", "pgsql.xlog_wal_end", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
1979 | "The current end of WAL on the server.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1980 | }, |
1981 | { &hf_standby_last_wal_written, |
1982 | { "Last WAL written", "pgsql.standby.last_wal_written", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
1983 | "The location of the last WAL byte + 1 received and written to disk in the standby.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1984 | }, |
1985 | { &hf_standby_last_wal_flushed, |
1986 | { "Last WAL flushed", "pgsql.standby.last_wal_flushed", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
1987 | "The location of the last WAL byte + 1 flushed to disk in the standby.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1988 | }, |
1989 | { &hf_standby_last_wal_applied, |
1990 | { "Last WAL applied", "pgsql.standby.last_wal_applied", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
1991 | "The location of the last WAL byte + 1 applied in the standby.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1992 | }, |
1993 | { &hf_standby_immediate_ack, |
1994 | { "Immediate ack", "pgsql.standby.immediate_ack", FT_BOOLEAN, BASE_NONE, NULL((void*)0), 0, |
1995 | "If true, except a reply as soon as possible. 0 otherwise.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
1996 | }, |
1997 | { &hf_standby_xmin, |
1998 | { "xmin", "pgsql.standby.xmin", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
1999 | "The standby's current global xmin, excluding the catalog_xmin from any replication slots. If both this value and the following catalog_xmin are 0, this is treated as a notification that hot standby feedback will no longer be sent on this connection. Later non-zero messages may reinitiate the feedback mechanism.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2000 | }, |
2001 | { &hf_standby_xmin_epoch, |
2002 | { "xmin epoch", "pgsql.standby.xmin_epoch", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
2003 | "The epoch of the global xmin xid on the standby.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2004 | }, |
2005 | { &hf_standby_catalog_xmin, |
2006 | { "catalog xmin", "pgsql.standby.catalog_xmin", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
2007 | "The lowest catalog_xmin of any replication slots on the standby. Set to 0 if no catalog_xmin exists on the standby or if hot standby feedback is being disabled.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2008 | }, |
2009 | { &hf_standby_catalog_xmin_epoch, |
2010 | { "catalog xmin epoch", "pgsql.standby.catalog_xmin_epoch", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
2011 | "The epoch of the catalog_xmin xid on the standby.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2012 | }, |
2013 | { &hf_logical_msg_type, |
2014 | { "Logical message type", "pgsql.logical.msg_type", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
2015 | "A one-byte message type identifier for logical message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2016 | }, |
2017 | { &hf_logical_replica_identity, |
2018 | { "Replica identity", "pgsql.logical.replica_identity", FT_UINT8, BASE_DEC, NULL((void*)0), 0, |
2019 | "Replica identity setting for the relation (same as relreplident in pg_class).", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2020 | }, |
2021 | { &hf_logical_number_columns, |
2022 | { "Number columns", "pgsql.logical.number_columns", FT_UINT16, BASE_DEC, NULL((void*)0), 0, |
2023 | "Number of columns.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2024 | }, |
2025 | { &hf_logical_column_length, |
2026 | { "Length column", "pgsql.logical.column_length", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
2027 | "Length of the column value.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2028 | }, |
2029 | { &hf_logical_column_flags, |
2030 | { "Column flags", "pgsql.logical.column_flags", FT_UINT8, BASE_DEC, NULL((void*)0), 0, |
2031 | "Flags for the column. Currently can be either 0 for no flags or 1 which marks the column as part of the key.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2032 | }, |
2033 | { &hf_logical_column_name, |
2034 | { "Column name", "pgsql.logical.column_name", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
2035 | "Name of the column.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2036 | }, |
2037 | { &hf_logical_column_oid, |
2038 | { "Column OID", "pgsql.logical.column_oid", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
2039 | "OID of the column's data type.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2040 | }, |
2041 | { &hf_logical_column_type_modifier, |
2042 | { "Type modifier", "pgsql.logical.type_modifier", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
2043 | "Type modifier of the column (atttypmod).", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2044 | }, |
2045 | { &hf_relation_oid, |
2046 | { "Relation OID", "pgsql.relation_oid", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
2047 | "OID of the relation.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2048 | }, |
2049 | { &hf_logical_lsn_final, |
2050 | { "LSN transaction", "pgsql.logical.lsn", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2051 | "The final LSN of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2052 | }, |
2053 | { &hf_logical_prepare_flags, |
2054 | { "Prepare flags", "pgsql.logical.prepare.flags", FT_UINT8, BASE_DEC, NULL((void*)0), 0, |
2055 | "Prepare Flags. Currently unused.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2056 | }, |
2057 | { &hf_logical_prepare_gid, |
2058 | { "Prepare GID", "pgsql.logical.prepare.gid", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
2059 | "The user defined GID of the prepared transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2060 | }, |
2061 | { &hf_logical_prepare_lsn, |
2062 | { "LSN prepare", "pgsql.logical.prepare.lsn", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2063 | "The LSN of the prepare.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2064 | }, |
2065 | { &hf_logical_prepare_lsn_end, |
2066 | { "LSN prepare end", "pgsql.logical.prepare.lsn_end", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2067 | "The end LSN of the prepared transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2068 | }, |
2069 | { &hf_logical_prepare_lsn_rollback, |
2070 | { "LSN rollback prepare end", "pgsql.logical.prepare.rollback_lsn_end", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2071 | "The end LSN of the rollback of the prepared transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2072 | }, |
2073 | { &hf_logical_commit_ts, |
2074 | { "Commit timestamp", "pgsql.logical.commit_ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL((void*)0), 0, |
2075 | "Commit timestamp of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2076 | }, |
2077 | { &hf_logical_prepare_ts, |
2078 | { "Prepare timestamp", "pgsql.logical.prepare.ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL((void*)0), 0, |
2079 | "Prepare timestamp of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2080 | }, |
2081 | { &hf_logical_prepare_commit_ts, |
2082 | { "Commit timestamp", "pgsql.logical.prepare.commit_ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL((void*)0), 0, |
2083 | "Commit timestamp of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2084 | }, |
2085 | { &hf_logical_prepare_rollback_ts, |
2086 | { "Rollback timestamp", "pgsql.logical.prepare.rollback_ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL((void*)0), 0, |
2087 | "Rollback timestamp of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2088 | }, |
2089 | { &hf_logical_relation_number, |
2090 | { "Number relations", "pgsql.logical.relation_number", FT_UINT32, BASE_DEC, NULL((void*)0), 0, |
2091 | "Number of relations.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2092 | }, |
2093 | { &hf_logical_truncate_flags, |
2094 | { "Truncate flags", "pgsql.logical.truncate_flags", FT_INT8, BASE_DEC, NULL((void*)0), 0, |
2095 | "Truncate Flags. 1 for CASCADE, 2 for RESTART IDENTITY.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2096 | }, |
2097 | { &hf_logical_commit_flags, |
2098 | { "Commit flags", "pgsql.logical.commit_flags", FT_INT8, BASE_DEC, NULL((void*)0), 0, |
2099 | "Commit Flags. Currently unused.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2100 | }, |
2101 | { &hf_logical_lsn_commit, |
2102 | { "Commit LSN", "pgsql.logical.lsn_commit", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2103 | "The LSN of the commit.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2104 | }, |
2105 | { &hf_logical_lsn_transaction, |
2106 | { "Transaction LSN", "pgsql.logical.lsn_transaction", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2107 | "The end LSN of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2108 | }, |
2109 | { &hf_logical_lsn_origin, |
2110 | { "Origin LSN", "pgsql.logical.lsn_origin", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2111 | "The LSN of the commit on the origin server.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2112 | }, |
2113 | { &hf_logical_lsn_abort, |
2114 | { "Abort LSN", "pgsql.logical.lsn_abort", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2115 | "The LSN of the abort.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2116 | }, |
2117 | { &hf_logical_message_flags, |
2118 | { "Message flags", "pgsql.logical.message.flags", FT_UINT8, BASE_DEC, NULL((void*)0), 0, |
2119 | "Message Flags. Either 0 for no flags or 1 if the logical decoding message is transactional.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2120 | }, |
2121 | { &hf_logical_message_lsn, |
2122 | { "LSN message", "pgsql.logical.message.lsn", FT_UINT64, BASE_HEX, NULL((void*)0), 0, |
2123 | "The LSN of the logical decoding message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2124 | }, |
2125 | { &hf_logical_message_prefix, |
2126 | { "Message prefix", "pgsql.logical.message.prefix", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
2127 | "The prefix of the logical decoding message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2128 | }, |
2129 | { &hf_logical_message_content, |
2130 | { "Message content", "pgsql.logical.message.content", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
2131 | "The content of the logical decoding message.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2132 | }, |
2133 | { &hf_logical_message_length, |
2134 | { "Message length", "pgsql.logical.message.length", FT_INT32, BASE_DEC, NULL((void*)0), 0, |
2135 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2136 | }, |
2137 | { &hf_logical_stream_first_segment, |
2138 | { "First segment", "pgsql.logical.stream.first_segment", FT_INT8, BASE_DEC, NULL((void*)0), 0, |
2139 | "First segment.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2140 | }, |
2141 | { &hf_logical_stream_flags, |
2142 | { "Stream flags", "pgsql.logical.stream.flags", FT_INT8, BASE_DEC, NULL((void*)0), 0, |
2143 | "Stream flags. Currently Unused.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2144 | }, |
2145 | { &hf_logical_stream_abort_ts, |
2146 | { "Abort timestamp", "pgsql.logical.stream.abort_ts", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL((void*)0), 0, |
2147 | "Abort timestamp of the transaction.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2148 | }, |
2149 | { &hf_logical_origin_name, |
2150 | { "Origin name", "pgsql.logical.origin_name", FT_STRING, BASE_NONE, NULL((void*)0), 0, |
2151 | "Name of the origin.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } |
2152 | }, |
2153 | }; |
2154 | |
2155 | static int *ett[] = { |
2156 | &ett_pgsql, |
2157 | &ett_values |
2158 | }; |
2159 | |
2160 | proto_pgsql = proto_register_protocol("PostgreSQL", "PGSQL", "pgsql"); |
2161 | pgsql_handle = register_dissector("pgsql", dissect_pgsql, proto_pgsql); |
2162 | proto_register_field_array(proto_pgsql, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0])); |
2163 | proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0])); |
2164 | |
2165 | /* Unfortunately there's no way to set up a GSS-API conversation |
2166 | * instructing the GSS-API dissector to use our wrap handle; that |
2167 | * only works for protocols that have an OID and that begin the |
2168 | * GSS-API conversation by sending that OID. |
2169 | */ |
2170 | pgsql_gssapi_handle = register_dissector("pgsql.gssapi", dissect_pgsql_gssapi, proto_pgsql); |
2171 | } |
2172 | |
2173 | void |
2174 | proto_reg_handoff_pgsql(void) |
2175 | { |
2176 | dissector_add_uint_with_preference("tcp.port", PGSQL_PORT5432, pgsql_handle); |
2177 | |
2178 | tls_handle = find_dissector_add_dependency("tls", proto_pgsql); |
2179 | gssapi_handle = find_dissector_add_dependency("gssapi", proto_pgsql); |
2180 | ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_pgsql); |
2181 | } |
2182 | |
2183 | /* |
2184 | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
2185 | * |
2186 | * Local variables: |
2187 | * c-basic-offset: 4 |
2188 | * tab-width: 8 |
2189 | * indent-tabs-mode: nil |
2190 | * End: |
2191 | * |
2192 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
2193 | * :indentSize=4:tabSize=8:noTabs=true: |
2194 | */ |