--- embedaddon/php/ext/mysqlnd/mysqlnd_wireprotocol.h 2012/02/21 23:47:58 1.1 +++ embedaddon/php/ext/mysqlnd/mysqlnd_wireprotocol.h 2012/05/29 12:34:41 1.1.1.2 @@ -12,13 +12,13 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | + | Georg Richter | +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd_wireprotocol.h,v 1.1 2012/02/21 23:47:58 misho Exp $ */ +/* $Id: mysqlnd_wireprotocol.h,v 1.1.1.2 2012/05/29 12:34:41 misho Exp $ */ #ifndef MYSQLND_WIREPROTOCOL_H #define MYSQLND_WIREPROTOCOL_H @@ -51,8 +51,8 @@ PHPAPI extern const char * const mysqlnd_command_to_te /* Low-level extraction functionality */ typedef struct st_mysqlnd_packet_methods { size_t struct_size; - enum_func_status (*read_from_net)(void *packet, MYSQLND *conn TSRMLS_DC); - size_t (*write_to_net)(void *packet, MYSQLND *conn TSRMLS_DC); + enum_func_status (*read_from_net)(void * packet, MYSQLND_CONN_DATA * conn TSRMLS_DC); + size_t (*write_to_net)(void * packet, MYSQLND_CONN_DATA * conn TSRMLS_DC); void (*free_mem)(void *packet, zend_bool stack_allocation TSRMLS_DC); } mysqlnd_packet_methods; @@ -70,17 +70,20 @@ typedef struct st_mysqlnd_packet_greet { uint8_t protocol_version; char *server_version; uint32_t thread_id; - zend_uchar scramble_buf[SCRAMBLE_LENGTH]; + zend_uchar intern_auth_plugin_data[SCRAMBLE_LENGTH]; + zend_uchar * auth_plugin_data; + size_t auth_plugin_data_len; /* 1 byte pad */ - uint16_t server_capabilities; + uint32_t server_capabilities; uint8_t charset_no; uint16_t server_status; - /* 13 byte pad*/ + /* 13 byte pad, in 5.5 first 2 bytes are more capabilities followed by 1 byte scramble_length */ zend_bool pre41; /* If error packet, we use these */ char error[MYSQLND_ERRMSG_SIZE+1]; char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; - unsigned int error_no; + unsigned int error_no; + char *auth_protocol; } MYSQLND_PACKET_GREET; @@ -89,21 +92,50 @@ typedef struct st_mysqlnd_packet_auth { MYSQLND_PACKET_HEADER header; uint32_t client_flags; uint32_t max_packet_size; - uint8_t charset_no; - /* 23 byte pad */ + uint8_t charset_no; const char *user; - /* 8 byte scramble */ + const zend_uchar *auth_data; + size_t auth_data_len; const char *db; - /* 12 byte scramble */ - + const char *auth_plugin_name; /* Here the packet ends. This is user supplied data */ - const char *password; - /* +1 for \0 because of scramble() */ - unsigned char *server_scramble_buf; - size_t db_len; - zend_bool send_half_packet; + size_t db_len; + zend_bool send_auth_data; + zend_bool is_change_user_packet; + zend_bool silent; + } MYSQLND_PACKET_AUTH; +/* Auth response packet */ +typedef struct st_mysqlnd_packet_auth_response { + MYSQLND_PACKET_HEADER header; + uint8_t response_code; + uint64_t affected_rows; + uint64_t last_insert_id; + uint16_t server_status; + uint16_t warning_count; + char *message; + size_t message_len; + /* If error packet, we use these */ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; + + char *new_auth_protocol; + size_t new_auth_protocol_len; + zend_uchar *new_auth_protocol_data; + size_t new_auth_protocol_data_len; +} MYSQLND_PACKET_AUTH_RESPONSE; + + +/* Auth response packet */ +typedef struct st_mysqlnd_packet_change_auth_response { + MYSQLND_PACKET_HEADER header; + const zend_uchar *auth_data; + size_t auth_data_len; +} MYSQLND_PACKET_CHANGE_AUTH_RESPONSE; + + /* OK packet */ typedef struct st_mysqlnd_packet_ok { MYSQLND_PACKET_HEADER header; @@ -125,7 +157,7 @@ typedef struct st_mysqlnd_packet_ok { typedef struct st_mysqlnd_packet_command { MYSQLND_PACKET_HEADER header; enum php_mysqlnd_server_command command; - const char *argument; + const zend_uchar *argument; size_t arg_len; } MYSQLND_PACKET_COMMAND; @@ -239,17 +271,22 @@ typedef struct st_mysqlnd_packet_prepare_response { /* Statistics packet */ typedef struct st_mysqlnd_packet_chg_user_resp { MYSQLND_PACKET_HEADER header; - uint32_t field_count; + uint32_t response_code; /* message_len is not part of the packet*/ uint16_t server_capabilities; /* If error packet, we use these */ MYSQLND_ERROR_INFO error_info; zend_bool server_asked_323_auth; + + char *new_auth_protocol; + size_t new_auth_protocol_len; + zend_uchar *new_auth_protocol_data; + size_t new_auth_protocol_data_len; } MYSQLND_PACKET_CHG_USER_RESPONSE; -PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass); +PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass, size_t pass_len); unsigned long php_mysqlnd_net_field_length(zend_uchar **packet); zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length); @@ -259,21 +296,18 @@ PHPAPI const extern char * const mysqlnd_empty_string; enum_func_status php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool persistent, zend_bool as_unicode, zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC); enum_func_status php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool persistent, zend_bool as_unicode, zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC); PHPAPI MYSQLND_PROTOCOL * mysqlnd_protocol_init(zend_bool persistent TSRMLS_DC); PHPAPI void mysqlnd_protocol_free(MYSQLND_PROTOCOL * const protocol TSRMLS_DC); -PHPAPI struct st_mysqlnd_protocol_methods * mysqlnd_protocol_get_methods(); #endif /* MYSQLND_WIREPROTOCOL_H */