Removed unused vars and fixed warnings, mysql_backend.c is still missing
This commit is contained in:
parent
0113088af6
commit
d5590c6d0e
@ -151,7 +151,7 @@ char *gw_bin2hex(char *out, const uint8_t *in, unsigned int len) {
|
||||
// note that XOR(str1, XOR(str1 CONCAT str2)) == str2
|
||||
// and that XOR(str1, str2) == XOR(str2, str1)
|
||||
///////////////////////////////////////////////////////
|
||||
void gw_str_xor(char *output, const uint8_t *input1, const uint8_t *input2, unsigned int len) {
|
||||
void gw_str_xor(uint8_t *output, const uint8_t *input1, const uint8_t *input2, unsigned int len) {
|
||||
const uint8_t *input1_end = NULL;
|
||||
input1_end = input1 + len;
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <service.h>
|
||||
#include <router.h>
|
||||
@ -81,13 +83,13 @@ struct dcb;
|
||||
* MySQL Protocol specific state data
|
||||
*/
|
||||
typedef struct {
|
||||
int fd; /* The socket descriptor */
|
||||
struct dcb *descriptor; /* The DCB of the socket we are running on */
|
||||
int state; /* Current descriptor state */
|
||||
char scramble[MYSQL_SCRAMBLE_LEN]; /* server scramble, created or received */
|
||||
uint32_t server_capabilities; /* server capabilities, created or received */
|
||||
uint32_t client_capabilities; /* client capabilities, created or received */
|
||||
unsigned long tid; /* MySQL Thread ID, in handshake */
|
||||
int fd; /* The socket descriptor */
|
||||
struct dcb *descriptor; /* The DCB of the socket we are running on */
|
||||
int state; /* Current descriptor state */
|
||||
uint8_t scramble[MYSQL_SCRAMBLE_LEN]; /* server scramble, created or received */
|
||||
uint32_t server_capabilities; /* server capabilities, created or received */
|
||||
uint32_t client_capabilities; /* client capabilities, created or received */
|
||||
unsigned long tid; /* MySQL Thread ID, in handshake */
|
||||
} MySQLProtocol;
|
||||
|
||||
/*
|
||||
@ -199,3 +201,15 @@ typedef enum
|
||||
),
|
||||
} gw_mysql_capabilities_t;
|
||||
#endif
|
||||
|
||||
extern void gw_sha1_str(const uint8_t *in, int in_len, uint8_t *out);
|
||||
extern void gw_sha1_2_str(const uint8_t *in, int in_len, const uint8_t *in2, int in2_len, uint8_t *out);
|
||||
extern void gw_str_xor(uint8_t *output, const uint8_t *input1, const uint8_t *input2, unsigned int len);
|
||||
extern char *gw_bin2hex(char *out, const uint8_t *in, unsigned int len);
|
||||
extern int gw_hex2bin(uint8_t *out, const char *in, unsigned int len);
|
||||
extern int gw_generate_random_str(char *output, int len);
|
||||
extern char *gw_strend(register const char *s);
|
||||
extern int setnonblocking(int fd);
|
||||
extern void setipaddress(struct in_addr *a, char *p);
|
||||
extern int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b);
|
||||
void gw_mysql_close(MySQLProtocol **ptr);
|
||||
|
@ -112,7 +112,6 @@ GetModuleObject()
|
||||
*/
|
||||
int
|
||||
mysql_send_ok(DCB *dcb, int packet_number, int in_affected_rows, const char* mysql_message) {
|
||||
int n = 0;
|
||||
uint8_t *outbuf = NULL;
|
||||
uint8_t mysql_payload_size = 0;
|
||||
uint8_t mysql_packet_header[4];
|
||||
@ -200,8 +199,6 @@ mysql_send_custom_error (DCB *dcb, int packet_number, int in_affected_rows, cons
|
||||
uint8_t mysql_packet_header[4];
|
||||
uint8_t *mysql_payload = NULL;
|
||||
uint8_t field_count = 0;
|
||||
uint8_t affected_rows = 0;
|
||||
uint8_t insert_id = 0;
|
||||
uint8_t mysql_err[2];
|
||||
uint8_t mysql_statemsg[6];
|
||||
unsigned int mysql_errno = 0;
|
||||
@ -281,8 +278,6 @@ mysql_send_auth_error (DCB *dcb, int packet_number, int in_affected_rows, const
|
||||
uint8_t mysql_packet_header[4];
|
||||
uint8_t *mysql_payload = NULL;
|
||||
uint8_t field_count = 0;
|
||||
uint8_t affected_rows = 0;
|
||||
uint8_t insert_id = 0;
|
||||
uint8_t mysql_err[2];
|
||||
uint8_t mysql_statemsg[6];
|
||||
unsigned int mysql_errno = 0;
|
||||
@ -352,7 +347,6 @@ mysql_send_auth_error (DCB *dcb, int packet_number, int in_affected_rows, const
|
||||
int
|
||||
MySQLSendHandshake(DCB* dcb)
|
||||
{
|
||||
int n = 0;
|
||||
uint8_t *outbuf = NULL;
|
||||
uint8_t mysql_payload_size = 0;
|
||||
uint8_t mysql_packet_header[4];
|
||||
@ -416,8 +410,9 @@ MySQLSendHandshake(DCB* dcb)
|
||||
mysql_handshake_payload = mysql_handshake_payload + sizeof(mysql_protocol_version);
|
||||
|
||||
// write server version plus 0 filler
|
||||
strcpy(mysql_handshake_payload, GW_MYSQL_VERSION);
|
||||
memcpy(mysql_handshake_payload, GW_MYSQL_VERSION, strlen(GW_MYSQL_VERSION));
|
||||
mysql_handshake_payload = mysql_handshake_payload + strlen(GW_MYSQL_VERSION);
|
||||
|
||||
*mysql_handshake_payload = 0x00;
|
||||
|
||||
mysql_handshake_payload++;
|
||||
@ -507,7 +502,6 @@ MySQLSendHandshake(DCB* dcb)
|
||||
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
MySQLProtocol *protocol = NULL;
|
||||
uint32_t client_capabilities;
|
||||
int compress = -1;
|
||||
int connect_with_db = -1;
|
||||
uint8_t *client_auth_packet = GWBUF_DATA(queue);
|
||||
@ -517,7 +511,6 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
uint8_t *auth_token = NULL;
|
||||
uint8_t *stage1_hash = NULL;
|
||||
int auth_ret = -1;
|
||||
SESSION *session = NULL;
|
||||
MYSQL_session *client_data = NULL;
|
||||
|
||||
if (dcb)
|
||||
@ -535,7 +528,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
compress = GW_MYSQL_CAPABILITIES_COMPRESS & gw_mysql_get_byte4(&protocol->client_capabilities);
|
||||
|
||||
// now get the user
|
||||
strncpy(username, client_auth_packet + 4 + 4 + 4 + 1 + 23, 128);
|
||||
strncpy(username, (char *)(client_auth_packet + 4 + 4 + 4 + 1 + 23), 128);
|
||||
fprintf(stderr, "<<< Client username is [%s]\n", username);
|
||||
|
||||
// get the auth token len
|
||||
@ -543,7 +536,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
|
||||
if (connect_with_db) {
|
||||
database = client_data->db;
|
||||
strncpy(database, client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1 + auth_token_len, 128);
|
||||
strncpy(database, (char *)(client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1 + auth_token_len), 128);
|
||||
fprintf(stderr, "<<< Client selected db is [%s]\n", database);
|
||||
} else {
|
||||
fprintf(stderr, "<<< Client is NOT connected with db\n");
|
||||
@ -777,11 +770,7 @@ int gw_read_client_event(DCB* dcb) {
|
||||
ROUTER *router_instance = NULL;
|
||||
void *rsession = NULL;
|
||||
MySQLProtocol *protocol = NULL;
|
||||
uint8_t buffer[MAX_BUFFER_SIZE] = "";
|
||||
int n = 0;
|
||||
int b = -1;
|
||||
GWBUF *head = NULL;
|
||||
GWBUF *gw_buffer = NULL;
|
||||
|
||||
if (dcb) {
|
||||
protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
@ -855,7 +844,7 @@ int gw_read_client_event(DCB* dcb) {
|
||||
router = session->service->router;
|
||||
router_instance = session->service->router_instance;
|
||||
rsession = session->router_session;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// read and handle errors & close, or return if busy
|
||||
@ -942,7 +931,6 @@ int gw_read_client_event(DCB* dcb) {
|
||||
//////////////////////////////////////////////
|
||||
int gw_write_client_event(DCB *dcb) {
|
||||
MySQLProtocol *protocol = NULL;
|
||||
int n;
|
||||
|
||||
if (dcb == NULL) {
|
||||
fprintf(stderr, "DCB is NULL, return\n");
|
||||
@ -962,7 +950,6 @@ int gw_write_client_event(DCB *dcb) {
|
||||
|
||||
if(protocol->state == MYSQL_AUTH_RECV) {
|
||||
SESSION *session = NULL;
|
||||
MYSQL_session *s_data = dcb->data;
|
||||
|
||||
//write to client mysql AUTH_OK packet, packet n. is 2
|
||||
mysql_send_ok(dcb, 2, 0, NULL);
|
||||
@ -1002,10 +989,7 @@ int gw_write_client_event(DCB *dcb) {
|
||||
///
|
||||
int gw_MySQLListener(DCB *listener, char *config_bind) {
|
||||
int l_so;
|
||||
int fl;
|
||||
struct sockaddr_in serv_addr;
|
||||
struct sockaddr_in local;
|
||||
socklen_t addrlen;
|
||||
char *bind_address_and_port = NULL;
|
||||
char *p;
|
||||
char address[1024]="";
|
||||
@ -1092,9 +1076,7 @@ int gw_MySQLAccept(DCB *listener) {
|
||||
socklen_t addrlen;
|
||||
addrlen = sizeof(local);
|
||||
DCB *client;
|
||||
SESSION *session;
|
||||
MySQLProtocol *protocol;
|
||||
MySQLProtocol *ptr_proto;
|
||||
int sendbuf = GW_BACKEND_SO_SNDBUF;
|
||||
socklen_t optlen = sizeof(sendbuf);
|
||||
|
||||
@ -1165,8 +1147,6 @@ int gw_MySQLAccept(DCB *listener) {
|
||||
static int gw_error_client_event(DCB *dcb) {
|
||||
|
||||
|
||||
MySQLProtocol *protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
|
||||
fprintf(stderr, "#### Handle error function gw_error_client_event, for [%i] is [%s]\n", dcb->state, gw_dcb_state2string(dcb->state));
|
||||
|
||||
fprintf(stderr, "#### Handle error function RETURN for [%i] is [%s]\n", dcb->state, gw_dcb_state2string(dcb->state));
|
||||
@ -1178,4 +1158,5 @@ static int
|
||||
gw_client_close(DCB *dcb)
|
||||
{
|
||||
dcb_close(dcb);
|
||||
return 1;
|
||||
}
|
||||
|
@ -26,13 +26,11 @@
|
||||
|
||||
#include "mysql_client_server_protocol.h"
|
||||
|
||||
static char *version_str = "V1.0.0";
|
||||
|
||||
MySQLProtocol *gw_mysql_init(MySQLProtocol *data);
|
||||
void gw_mysql_close(MySQLProtocol **ptr);
|
||||
|
||||
extern gw_read_backend_event(DCB* dcb);
|
||||
extern gw_write_backend_event(DCB *dcb);
|
||||
extern int gw_read_backend_event(DCB* dcb);
|
||||
extern int gw_write_backend_event(DCB *dcb);
|
||||
extern int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue);
|
||||
extern int gw_error_backend_event(DCB *dcb);
|
||||
|
||||
@ -40,8 +38,6 @@ extern int gw_error_backend_event(DCB *dcb);
|
||||
// Initialize mysql protocol struct
|
||||
///////////////////////////////////////
|
||||
MySQLProtocol *gw_mysql_init(MySQLProtocol *data) {
|
||||
int rv = -1;
|
||||
|
||||
MySQLProtocol *input = NULL;
|
||||
|
||||
if (input == NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user