This commit is contained in:
Massimiliano Pinto 2013-06-14 18:32:51 +02:00
commit eef179e6d4
5 changed files with 217 additions and 4 deletions

View File

@ -21,7 +21,9 @@
all:
(cd core; make)
(cd modules/routing; make)
(cd modules/protocol; make)
clean:
(cd core; make clean)
(cd modules/routing; make clean)
(cd modules/protocol; make clean)

47
modules/protocol/Makefile Normal file
View File

@ -0,0 +1,47 @@
# This file is distributed as part of the SkySQL Gateway. It is free
# software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation,
# version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright SkySQL Ab 2013
#
# Revision History
# Date Who Description
# 13/06/13 Mark Riddoch Initial protocol module development
CC=cc
CFLAGS=-c -fPIC -I/usr/include -I../include -I../../include
LDFLAGS=-shared
MYSQLCLIENTSRCS=mysql_client.c
MYSQLCLIENTOBJ=$(MYSQLCLIENTSRCS:.c=.o)
MYSQLBACKENDSRCS=mysql_backend.c
MYSQLBACKENDOBJ=$(MYSQLBACKENDSRCS:.c=.o)
SRCS=$(MYSQLCLIENTSRCS) $(MYSQLBACKENDSRCS)
OBJ=$(SRCS:.c=.o)
LIBS=
all: libMySQLClient.so libMySQLBackend.so
libMySQLClient.so: $(MYSQLCLIENTOBJ)
$(CC) $(LDFLAGS) $(MYSQLCLIENTOBJ) $(LIBS) -o $@
libMySQLBackend.so: $(MYSQLBACKENDOBJ)
$(CC) $(LDFLAGS) $(MYSQLBACKENDOBJ) $(LIBS) -o $@
.c.o:
$(CC) $(CFLAGS) $< -o $@
clean:
rm -f $(OBJ) libMySQLClient.so libMySQLBackend.so
tags:
ctags $(SRCS) $(HDRS)

View File

@ -0,0 +1,82 @@
/*
* This file is distributed as part of the SkySQL Gateway. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2013
*/
#include <stdio.h>
#include <dcb.h>
#include <buffer.h>
/*
* MySQL Protocol module for handling the protocol between the gateway
* and the backend MySQL database.
*
* Revision History
* Date Who Description
* 14/06/2013 Mark Riddoch Initial version
*/
static char *version_str = "V1.0.0";
extern int gw_read_backend_event(DCB* dcb, int epfd);
extern int gw_write_backend_event(DCB *dcb, int epfd);
extern int MySQLWrite(DCB *dcb, GWBUF *queue);
extern int handle_event_errors_backend(DCB *dcb, int event);
static GWPROTOCOL MyObject = {
gw_read_backend_event, /* Read - EPOLLIN handler */
MySQLWrite, /* Write - data from gateway */
gw_write_backend_event, /* WriteReady - EPOLLOUT handler */
handle_event_errors_backend, /* Error - EPOLLERR handler */
NULL, /* HangUp - EPOLLHUP handler */
NULL, /* Accept */
NULL, /* Connect */
NULL /* Close */
};
/*
* Implementation of the mandatory version entry point
*
* @return version string of the module
*/
char *
version()
{
return version_str;
}
/*
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
fprintf(stderr, "Initial MySQL Client Protcol module.\n");
}
/*
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
* "module object", this is a structure with the set of
* external entry points for this module.
*
* @return The module object
*/
GWPROTOCOL *
GetModuleObject()
{
return &MyObject;
}

View File

@ -0,0 +1,82 @@
/*
* This file is distributed as part of the SkySQL Gateway. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2013
*/
#include <stdio.h>
#include <dcb.h>
#include <buffer.h>
/*
* MySQL Protocol module for handling the protocol between the gateway
* and the client.
*
* Revision History
* Date Who Description
* 14/06/2013 Mark Riddoch Initial version
*/
static char *version_str = "V1.0.0";
extern int gw_route_read_event(DCB* dcb, int epfd);
extern int gw_handle_write_event(DCB *dcb, int epfd);
extern int MySQLWrite(DCB *dcb, GWBUF *queue);
extern int handle_event_errors(DCB *dcb, int event);
static GWPROTOCOL MyObject = {
gw_route_read_event, /* Read - EPOLLIN handler */
MySQLWrite, /* Write - data from gateway */
gw_handle_write_event, /* WriteReady - EPOLLOUT handler */
handle_event_errors, /* Error - EPOLLERR handler */
NULL, /* HangUp - EPOLLHUP handler */
NULL, /* Accept */
NULL, /* Connect */
NULL /* Close */
};
/*
* Implementation of the mandatory version entry point
*
* @return version string of the module
*/
char *
version()
{
return version_str;
}
/*
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
fprintf(stderr, "Initial MySQL Client Protcol module.\n");
}
/*
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
* "module object", this is a structure with the set of
* external entry points for this module.
*
* @return The module object
*/
GWPROTOCOL *
GetModuleObject()
{
return &MyObject;
}

View File

@ -22,8 +22,8 @@ static char *version_str = "V1.0.0";
static ROUTER *createInstance(SERVICE *service);
static void *newSession(ROUTER *instance, SESSION *session);
static void closeSession(ROUTER *instance, SESSION *session);
static int routeQuery(ROUTER *instance, SESSION *session, GWBUF *queue);
static void closeSession(ROUTER *instance, void *session);
static int routeQuery(ROUTER *instance, void *session, GWBUF *queue);
static ROUTER_OBJECT MyObject = { createInstance, newSession, closeSession, routeQuery };
@ -96,12 +96,12 @@ newSession(ROUTER *instance, SESSION *session)
* @param session The session being closed
*/
static void
closeSession(ROUTER *instance, SESSION *session)
closeSession(ROUTER *instance, void *session)
{
}
static int
routeQuery(ROUTER *instance, SESSION *session, GWBUF *queue)
routeQuery(ROUTER *instance, void *session, GWBUF *queue)
{
}