MXS-862: Move client information extraction to client protocol

The client protocol module now extracts the information that is relevant
for all modules. Currently this information consists of the client
capabilities, character set, username and default database.
This commit is contained in:
Markus Makela
2016-10-15 10:53:53 +03:00
parent c0ad2936a4
commit 891ce2d0e7
3 changed files with 57 additions and 73 deletions

View File

@ -155,31 +155,8 @@ bool store_client_token(DCB *dcb, GWBUF *buffer)
*/
static void copy_client_information(DCB *dcb, GWBUF *buffer)
{
size_t buflen = gwbuf_length(buffer);
MySQLProtocol *protocol = (MySQLProtocol*)dcb->protocol;
gssapi_auth_t *auth = (gssapi_auth_t*)dcb->authenticator_data;
/* Store the connection characteristics and sequence number of the current packet */
protocol->charset = 0;
gwbuf_copy_data(buffer, MYSQL_CHARSET_OFFSET, 1, (uint8_t*)&protocol->charset);
gwbuf_copy_data(buffer, MYSQL_CLIENT_CAP_OFFSET, MYSQL_CLIENT_CAP_SIZE,
(uint8_t*)&protocol->client_capabilities);
gwbuf_copy_data(buffer, MYSQL_SEQ_OFFSET, 1, &auth->sequence);
if (buflen > MYSQL_AUTH_PACKET_BASE_SIZE)
{
buflen -= MYSQL_AUTH_PACKET_BASE_SIZE;
/** TODO: Implement something that can safely iterate bytes of a GWBUF
* so that we know where the terminating null character is. For the time
* being, we'll just copy everything. */
uint8_t data[buflen];
gwbuf_copy_data(buffer, MYSQL_AUTH_PACKET_BASE_SIZE, buflen, data);
MYSQL_session *ses = (MYSQL_session*)dcb->data;
/** data is null-terminated so the strcpy is safe */
strcpy(ses->user, (char*)data);
}
}
/**