aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-mysql.c
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2015-02-02 09:46:36 +0100
committerAnders Broman <a.broman58@gmail.com>2015-02-04 06:53:25 +0000
commit18bc353b2d81e3535708a1ea3e86859ba51e2dfb (patch)
tree38d5489e0836b0d09effc15a7feab1c99890a47d /epan/dissectors/packet-mysql.c
parent66fc81b87a366830753d6a76a2cd25f9d0da5760 (diff)
MySQL: Add support of AuthSwitchRequest/AuthSwitchResponse
Bug: 10351 Ping-Bug: 10346 Change-Id: I730080a0aef293c3c8119f6c762ee246227bd07a Reviewed-on: https://code.wireshark.org/review/6915 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Daniƫl van Eeden <wireshark@myname.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-mysql.c')
-rw-r--r--epan/dissectors/packet-mysql.c83
1 files changed, 80 insertions, 3 deletions
diff --git a/epan/dissectors/packet-mysql.c b/epan/dissectors/packet-mysql.c
index 7bc3faa0e4..5ffd98d17d 100644
--- a/epan/dissectors/packet-mysql.c
+++ b/epan/dissectors/packet-mysql.c
@@ -608,7 +608,10 @@ static int hf_mysql_exec_field_float = -1;
static int hf_mysql_exec_field_time_length = -1;
static int hf_mysql_exec_field_time_sign = -1;
static int hf_mysql_exec_field_time_days = -1;
-
+static int hf_mysql_auth_switch_request_status = -1;
+static int hf_mysql_auth_switch_request_name = -1;
+static int hf_mysql_auth_switch_request_data = -1;
+static int hf_mysql_auth_switch_response_data = -1;
static dissector_handle_t ssl_handle;
@@ -663,7 +666,9 @@ typedef enum mysql_state {
ROW_PACKET,
RESPONSE_PREPARE,
PREPARED_PARAMETERS,
- PREPARED_FIELDS
+ PREPARED_FIELDS,
+ AUTH_SWITCH_REQUEST,
+ AUTH_SWITCH_RESPONSE
} mysql_state_t;
#ifdef CTDEBUG
@@ -725,6 +730,8 @@ static int mysql_dissect_result_header(tvbuff_t *tvb, packet_info *pinfo, int of
static int mysql_dissect_field_packet(tvbuff_t *tvb, int offset, proto_tree *tree, mysql_conn_data_t *conn_data);
static int mysql_dissect_row_packet(tvbuff_t *tvb, int offset, proto_tree *tree);
static int mysql_dissect_response_prepare(tvbuff_t *tvb, int offset, proto_tree *tree, mysql_conn_data_t *conn_data);
+static int mysql_dissect_auth_switch_request(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, mysql_conn_data_t *conn_data);
+static int mysql_dissect_auth_switch_response(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, mysql_conn_data_t *conn_data);
static void mysql_dissect_exec_string(tvbuff_t *tvb, int *param_offset, proto_item *field_tree);
static void mysql_dissect_exec_datetime(tvbuff_t *tvb, int *param_offset, proto_item *field_tree);
static void mysql_dissect_exec_tiny(tvbuff_t *tvb, int *param_offset, proto_item *field_tree);
@@ -963,6 +970,7 @@ mysql_dissect_login(tvbuff_t *tvb, packet_info *pinfo, int offset,
/* optional: authentication plugin */
if (conn_data->clnt_caps_ext & MYSQL_CAPS_PA)
{
+ conn_data->state = AUTH_SWITCH_REQUEST;
lenstr= my_tvb_strsize(tvb,offset);
proto_tree_add_item(login_tree, hf_mysql_client_auth_plugin, tvb, offset, lenstr, ENC_ASCII|ENC_NA);
offset += lenstr;
@@ -1185,6 +1193,10 @@ mysql_dissect_request(tvbuff_t *tvb,packet_info *pinfo, int offset,
my_stmt_data_t *stmt_data;
int stmt_pos, param_offset;
+ if(conn_data->state == AUTH_SWITCH_RESPONSE){
+ return mysql_dissect_auth_switch_response(tvb, pinfo, offset, tree, conn_data);
+ }
+
tf = proto_tree_add_item(tree, hf_mysql_request, tvb, offset, 1, ENC_NA);
req_tree = proto_item_add_subtree(tf, ett_request);
@@ -1287,10 +1299,12 @@ mysql_dissect_request(tvbuff_t *tvb,packet_info *pinfo, int offset,
proto_tree_add_item(req_tree, hf_mysql_charset, tvb, offset, 1, ENC_NA);
offset += 2; /* for charset */
}
+ conn_data->state = RESPONSE_OK;
/* optional: authentication plugin */
if (conn_data->clnt_caps_ext & MYSQL_CAPS_PA)
{
+ conn_data->state = AUTH_SWITCH_REQUEST;
lenstr= my_tvb_strsize(tvb,offset);
proto_tree_add_item(req_tree, hf_mysql_client_auth_plugin, tvb, offset, lenstr, ENC_ASCII|ENC_NA);
offset += lenstr;
@@ -1316,7 +1330,6 @@ mysql_dissect_request(tvbuff_t *tvb,packet_info *pinfo, int offset,
connattrs_length -= length;
}
}
- conn_data->state= RESPONSE_OK;
break;
case MYSQL_REFRESH:
@@ -1570,6 +1583,11 @@ mysql_dissect_response(tvbuff_t *tvb, packet_info *pinfo, int offset,
offset = mysql_dissect_field_packet(tvb, offset, tree, conn_data);
break;
+ case AUTH_SWITCH_REQUEST:
+ offset = mysql_dissect_auth_switch_request(tvb, pinfo, offset, tree, conn_data);
+ break;
+
+
default:
ti = proto_tree_add_item(tree, hf_mysql_payload, tvb, offset, -1, ENC_NA);
expert_add_info(pinfo, ti, &ei_mysql_unknown_response);
@@ -2023,7 +2041,46 @@ mysql_dissect_response_prepare(tvbuff_t *tvb, int offset, proto_tree *tree, mysq
}
+static int
+mysql_dissect_auth_switch_request(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, mysql_conn_data_t *conn_data _U_)
+{
+ gint lenstr;
+
+ col_set_str(pinfo->cinfo, COL_INFO, "Auth Switch Request" );
+ conn_data->state = AUTH_SWITCH_RESPONSE;
+
+ /* Status (Always 0xfe) */
+ proto_tree_add_item(tree, hf_mysql_auth_switch_request_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset += 1;
+
+ /* name */
+ lenstr = my_tvb_strsize(tvb, offset);
+ proto_tree_add_item(tree, hf_mysql_auth_switch_request_name, tvb, offset, lenstr, ENC_ASCII|ENC_NA);
+ offset += lenstr;
+
+ /* Data */
+ lenstr = my_tvb_strsize(tvb, offset);
+ proto_tree_add_item(tree, hf_mysql_auth_switch_request_data, tvb, offset, lenstr, ENC_NA);
+ offset += lenstr;
+
+ return offset + tvb_reported_length_remaining(tvb, offset);
+
+}
+static int
+mysql_dissect_auth_switch_response(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, mysql_conn_data_t *conn_data _U_)
+{
+ gint lenstr;
+
+ col_set_str(pinfo->cinfo, COL_INFO, "Auth Switch Response" );
+
+ /* Data */
+ lenstr = my_tvb_strsize(tvb, offset);
+ proto_tree_add_item(tree, hf_mysql_auth_switch_response_data, tvb, offset, lenstr, ENC_NA);
+ offset += lenstr;
+
+ return offset + tvb_reported_length_remaining(tvb, offset);
+}
/*
get length of string in packet buffer
@@ -3101,6 +3158,26 @@ void proto_register_mysql(void)
{ "Days", "mysql.exec.field.time.days",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
+
+ { &hf_mysql_auth_switch_request_status,
+ { "Status", "mysql.auth_switch_request.status",
+ FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_mysql_auth_switch_request_name,
+ { "Auth Method Name", "mysql.auth_switch_request.name",
+ FT_STRING, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_mysql_auth_switch_request_data,
+ { "Auth Method Data", "mysql.auth_switch_request.data",
+ FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_mysql_auth_switch_response_data,
+ { "Auth Method Data", "mysql.auth_switch_response.data",
+ FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
};
static gint *ett[]=