Mark Riddoch c3f70c863e Addition of routing module diagnostics and options
readconnroute now support the options slave and master to restrict the set of
servers it will connect to
2013-06-26 14:04:56 +02:00

68 lines
1.9 KiB
C

#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/epoll.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdbool.h>
#define EXIT_FAILURE 1
// network buffer is 32K
#define MAX_BUFFER_SIZE 32768
// socket send buffer for backend
#define GW_BACKEND_SO_SNDBUF 1024
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
#define GW_VERSION "0.1.0"
#define GW_MYSQL_VERSION "5.5.22-SKYSQL-" GW_VERSION
#define GW_MYSQL_LOOP_TIMEOUT 300000000
#define GW_MYSQL_READ 0
#define GW_MYSQL_WRITE 1
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
#define GW_MYSQL_HANDSHAKE_FILLER 0x00
#define GW_MYSQL_SERVER_CAPABILITIES_BYTE1 0xff
#define GW_MYSQL_SERVER_CAPABILITIES_BYTE2 0xf7
#define GW_MYSQL_SERVER_LANGUAGE 0x08
#define GW_MYSQL_MAX_PACKET_LEN 0xffffffL;
#define GW_MYSQL_SCRAMBLE_SIZE 20
// debug for mysql_* functions
#define MYSQL_CONN_DEBUG
#undef MYSQL_CONN_DEBUG
#include "gateway_mysql.h"
#include "mysql_protocol.h"
#include "dcb.h"
extern void gw_daemonize(void);
extern int do_read_dcb(DCB *dcb);
extern int handle_event_errors(DCB *dcb);
extern int handle_event_errors_backend(DCB *dcb);
extern void MySQLListener(int epfd, char *config_bind);
extern int MySQLAccept(DCB *listener);
extern int gw_mysql_do_authentication(DCB *dcb, GWBUF *);
extern void gw_mysql_close(MySQLProtocol **ptr);
extern char *gw_strend(register const char *s);
extern int do_read_dcb(DCB *dcb);
extern int do_read_10(DCB *dcb, uint8_t *buffer);
extern MySQLProtocol * gw_mysql_init(MySQLProtocol *ptr);
extern int MySQLWrite(DCB *dcb, GWBUF *queue);
extern int gw_write_backend_event(DCB *dcb);
extern int gw_read_backend_event(DCB *dcb);
extern int setnonblocking(int fd);