forked from osmocom/wireshark
MySQL: fix server status bit-mask
MySQL-Server 5.7 has introduced SERVER_SESSION_STATE_CHANGED with a 0x4000 bitmask. This commit updates the server status bitmask field to the current implementation as documented at https://github.com/mysql/mysql-server/blob/8.0/include/mysql_com.h https://dev.mysql.com/doc/dev/mysql-server/latest/mysql__com_8h.html Furthermore response code field is now exposed. Bug: 15074 Change-Id: If87a3c2efb82488e8f2e771f077fb7b88c702393 Reviewed-on: https://code.wireshark.org/review/29292 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
6f0e29054c
commit
6242d1cfa1
|
@ -95,17 +95,19 @@ void proto_reg_handoff_mysql(void);
|
|||
/* status bitfield */
|
||||
#define MYSQL_STAT_IT 0x0001
|
||||
#define MYSQL_STAT_AC 0x0002
|
||||
#define MYSQL_STAT_MR 0x0004
|
||||
#define MYSQL_STAT_MU 0x0008
|
||||
#define MYSQL_STAT_MU 0x0004
|
||||
#define MYSQL_STAT_MR 0x0008
|
||||
#define MYSQL_STAT_BI 0x0010
|
||||
#define MYSQL_STAT_NI 0x0020
|
||||
#define MYSQL_STAT_CR 0x0040
|
||||
#define MYSQL_STAT_LR 0x0080
|
||||
#define MYSQL_STAT_DR 0x0100
|
||||
#define MYSQL_STAT_BS 0x0200
|
||||
#define MYSQL_STAT_SESSION_STATE_CHANGED 0x0400
|
||||
#define MYSQL_STAT_MC 0x0400
|
||||
#define MYSQL_STAT_QUERY_WAS_SLOW 0x0800
|
||||
#define MYSQL_STAT_PS_OUT_PARAMS 0x1000
|
||||
#define MYSQL_STAT_TRANS_READONLY 0x2000
|
||||
#define MYSQL_STAT_SESSION_STATE_CHANGED 0x4000
|
||||
|
||||
/* bitfield for MYSQL_REFRESH */
|
||||
#define MYSQL_RFSH_GRANT 1 /* Refresh grant tables */
|
||||
|
@ -168,6 +170,11 @@ void proto_reg_handoff_mysql(void);
|
|||
#define MYSQL_COMPRESS_INIT 1
|
||||
#define MYSQL_COMPRESS_ACTIVE 2
|
||||
|
||||
/* Generic Response Codes */
|
||||
#define MYSQL_RESPONSE_OK 0x00
|
||||
#define MYSQL_RESPONSE_ERR 0xFF
|
||||
#define MYSQL_RESPONSE_EOF 0xFE
|
||||
|
||||
/* decoding table: command */
|
||||
static const value_string mysql_command_vals[] = {
|
||||
{MYSQL_SLEEP, "SLEEP"},
|
||||
|
@ -425,6 +432,13 @@ static const value_string mysql_session_track_type_vals[] = {
|
|||
{0, NULL}
|
||||
};
|
||||
|
||||
static const value_string mysql_response_code_vals[] = {
|
||||
{ MYSQL_RESPONSE_OK, "OK Packet" },
|
||||
{ MYSQL_RESPONSE_ERR, "ERR Packet" },
|
||||
{ MYSQL_RESPONSE_EOF, "EOF Packet" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* protocol id */
|
||||
static int proto_mysql = -1;
|
||||
|
||||
|
@ -491,9 +505,11 @@ static int hf_mysql_stat_cr = -1;
|
|||
static int hf_mysql_stat_lr = -1;
|
||||
static int hf_mysql_stat_dr = -1;
|
||||
static int hf_mysql_stat_bs = -1;
|
||||
static int hf_mysql_stat_mc = -1;
|
||||
static int hf_mysql_stat_session_state_changed = -1;
|
||||
static int hf_mysql_stat_query_was_slow = -1;
|
||||
static int hf_mysql_stat_ps_out_params = -1;
|
||||
static int hf_mysql_stat_trans_readonly = -1;
|
||||
static int hf_mysql_refresh = -1;
|
||||
static int hf_mysql_rfsh_grants = -1;
|
||||
static int hf_mysql_rfsh_log = -1;
|
||||
|
@ -507,6 +523,7 @@ static int hf_mysql_packet_length = -1;
|
|||
static int hf_mysql_packet_number = -1;
|
||||
static int hf_mysql_request = -1;
|
||||
static int hf_mysql_command = -1;
|
||||
static int hf_mysql_response_code = -1;
|
||||
static int hf_mysql_error_code = -1;
|
||||
static int hf_mysql_error_string = -1;
|
||||
static int hf_mysql_sqlstate = -1;
|
||||
|
@ -798,17 +815,19 @@ static const int *mysql_rfsh_flags[] = {
|
|||
static const int *mysql_stat_flags[] = {
|
||||
&hf_mysql_stat_it,
|
||||
&hf_mysql_stat_ac,
|
||||
&hf_mysql_stat_mr,
|
||||
&hf_mysql_stat_mu,
|
||||
&hf_mysql_stat_mr,
|
||||
&hf_mysql_stat_bi,
|
||||
&hf_mysql_stat_ni,
|
||||
&hf_mysql_stat_cr,
|
||||
&hf_mysql_stat_lr,
|
||||
&hf_mysql_stat_dr,
|
||||
&hf_mysql_stat_bs,
|
||||
&hf_mysql_stat_session_state_changed,
|
||||
&hf_mysql_stat_mc,
|
||||
&hf_mysql_stat_query_was_slow,
|
||||
&hf_mysql_stat_ps_out_params,
|
||||
&hf_mysql_stat_trans_readonly,
|
||||
&hf_mysql_stat_session_state_changed,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -1625,12 +1644,14 @@ mysql_dissect_response(tvbuff_t *tvb, packet_info *pinfo, int offset,
|
|||
response_code = tvb_get_guint8(tvb, offset);
|
||||
|
||||
if (response_code == 0xff ) {
|
||||
proto_tree_add_item(tree, hf_mysql_response_code, tvb, offset, 1, ENC_NA);
|
||||
offset = mysql_dissect_error_packet(tvb, pinfo, offset+1, tree);
|
||||
mysql_set_conn_state(pinfo, conn_data, REQUEST);
|
||||
}
|
||||
|
||||
else if (response_code == 0xfe && tvb_reported_length_remaining(tvb, offset) < 9) {
|
||||
|
||||
proto_tree_add_item(tree, hf_mysql_response_code, tvb, offset, 1, ENC_NA);
|
||||
ti = proto_tree_add_item(tree, hf_mysql_eof, tvb, offset, 1, ENC_NA);
|
||||
|
||||
offset += 1;
|
||||
|
@ -1670,6 +1691,7 @@ mysql_dissect_response(tvbuff_t *tvb, packet_info *pinfo, int offset,
|
|||
}
|
||||
|
||||
else if (response_code == 0) {
|
||||
proto_tree_add_item(tree, hf_mysql_response_code, tvb, offset, 1, ENC_NA);
|
||||
if (current_state == RESPONSE_PREPARE) {
|
||||
offset = mysql_dissect_response_prepare(tvb, pinfo, offset, tree, conn_data);
|
||||
} else if (tvb_reported_length_remaining(tvb, offset+1) > tvb_get_fle(tvb, offset+1, NULL, NULL)) {
|
||||
|
@ -2378,7 +2400,7 @@ void proto_register_mysql(void)
|
|||
{ &hf_mysql_packet_number,
|
||||
{ "Packet Number", "mysql.packet_number",
|
||||
FT_UINT8, BASE_DEC, NULL, 0x0,
|
||||
NULL, HFILL }},
|
||||
"Packet Number (now called: Sequence ID)", HFILL }},
|
||||
|
||||
{ &hf_mysql_request,
|
||||
{ "Request Command", "mysql.request",
|
||||
|
@ -2390,6 +2412,11 @@ void proto_register_mysql(void)
|
|||
FT_UINT8, BASE_DEC|BASE_EXT_STRING, &mysql_command_vals_ext, 0x0,
|
||||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_response_code,
|
||||
{ "Response Code", "mysql.response_code",
|
||||
FT_UINT8, BASE_HEX, VALS(mysql_response_code_vals), 0x0,
|
||||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_error_code,
|
||||
{ "Error Code", "mysql.error_code",
|
||||
FT_UINT16, BASE_DEC, NULL, 0x0,
|
||||
|
@ -2751,9 +2778,9 @@ void proto_register_mysql(void)
|
|||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_stat_mu,
|
||||
{ "Multi query - more resultsets", "mysql.stat.mu",
|
||||
{ "Multi query / Unused", "mysql.stat.mu",
|
||||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_MU,
|
||||
NULL, HFILL }},
|
||||
"Multi query / Unused with MySQL >= 5.6", HFILL }},
|
||||
|
||||
{ &hf_mysql_stat_bi,
|
||||
{ "Bad index used", "mysql.stat.bi",
|
||||
|
@ -2776,7 +2803,7 @@ void proto_register_mysql(void)
|
|||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_stat_dr,
|
||||
{ "database dropped", "mysql.stat.dr",
|
||||
{ "Database dropped", "mysql.stat.dr",
|
||||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_DR,
|
||||
NULL, HFILL }},
|
||||
|
||||
|
@ -2785,6 +2812,11 @@ void proto_register_mysql(void)
|
|||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_BS,
|
||||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_stat_mc,
|
||||
{ "Metadata changed", "mysql.stat.mc",
|
||||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_MC,
|
||||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_stat_session_state_changed,
|
||||
{ "Session state changed", "mysql.stat.session_state_changed",
|
||||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_SESSION_STATE_CHANGED,
|
||||
|
@ -2800,6 +2832,11 @@ void proto_register_mysql(void)
|
|||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_PS_OUT_PARAMS,
|
||||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_stat_trans_readonly,
|
||||
{ "In Trans Readonly", "mysql.stat.trans_readonly",
|
||||
FT_BOOLEAN, 16, TFS(&tfs_set_notset), MYSQL_STAT_TRANS_READONLY,
|
||||
NULL, HFILL }},
|
||||
|
||||
{ &hf_mysql_refresh,
|
||||
{ "Refresh Option", "mysql.refresh",
|
||||
FT_UINT8, BASE_HEX, NULL, 0x0,
|
||||
|
|
Loading…
Reference in New Issue