Rename GW_AUTHENTICATOR and GW_BITMASK + cleanup

This commit is contained in:
Esa Korhonen 2017-01-20 14:31:16 +02:00
parent 126d9be749
commit 641896872e
21 changed files with 69 additions and 88 deletions

View File

@ -16,22 +16,11 @@
* @file authenticator.h
*
* The authenticator module interface definitions for MaxScale
*
* @verbatim
* Revision History
*
* Date Who Description
* 17/02/16 Martin Brampton Initial implementation
*
* @endverbatim
*/
#include <maxscale/cdefs.h>
#include <maxscale/buffer.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/dh.h>
MXS_BEGIN_DECLS
@ -77,7 +66,7 @@ struct servlistener;
*
* @see load_module
*/
typedef struct gw_authenticator
typedef struct mxs_authenticator
{
void* (*initialize)(char **options);
void* (*create)(void* instance);
@ -87,7 +76,7 @@ typedef struct gw_authenticator
void (*free)(struct dcb *);
void (*destroy)(void *);
int (*loadusers)(struct servlistener *);
} GWAUTHENTICATOR;
} MXS_AUTHENTICATOR;
/** Return values for extract and authenticate entry points */
#define MXS_AUTH_SUCCEEDED 0 /**< Authentication was successful */
@ -127,11 +116,11 @@ typedef enum
} mxs_auth_state_t;
/**
* The GWAUTHENTICATOR version data. The following should be updated whenever
* the GWAUTHENTICATOR structure is changed. See the rules defined in modinfo.h
* The MXS_AUTHENTICATOR version data. The following should be updated whenever
* the MXS_AUTHENTICATOR structure is changed. See the rules defined in modinfo.h
* that define how these numbers should change.
*/
#define GWAUTHENTICATOR_VERSION {1, 1, 0}
#define MXS_AUTHENTICATOR_VERSION {1, 1, 0}
bool authenticator_init(void **instance, const char *authenticator, const char *options);

View File

@ -14,20 +14,12 @@
/**
* @file bitmask.h An implementation of an arbitrarily long bitmask
*
* @verbatim
* Revision History
*
* Date Who Description
* 28/06/13 Mark Riddoch Initial implementation
* 17/10/15 Martin Brampton Add bitmask_render_readable
*
* @endverbatim
*/
#include <maxscale/cdefs.h>
#include <maxscale/spinlock.h>
#include <maxscale/limits.h>
#include <maxscale/spinlock.h>
MXS_BEGIN_DECLS
@ -43,18 +35,18 @@ typedef struct
{
SPINLOCK lock; /**< Lock to protect the bitmask */
unsigned char bits[MXS_BITMASK_SIZE]; /**< The bits themselves */
} GWBITMASK;
} MXS_BITMASK;
#define GWBITMASK_INIT {SPINLOCK_INIT}
#define MXS_BITMASK_INIT {SPINLOCK_INIT}
extern void bitmask_init(GWBITMASK *);
extern void bitmask_free(GWBITMASK *);
extern int bitmask_set(GWBITMASK *, int);
extern int bitmask_clear(GWBITMASK *, int);
extern int bitmask_clear_without_spinlock(GWBITMASK *, int);
extern int bitmask_isset(GWBITMASK *, int);
extern int bitmask_isallclear(GWBITMASK *);
extern void bitmask_copy(GWBITMASK *, GWBITMASK *);
extern char *bitmask_render_readable(GWBITMASK *);
void bitmask_init(MXS_BITMASK *);
void bitmask_free(MXS_BITMASK *);
int bitmask_set(MXS_BITMASK *, int);
int bitmask_clear(MXS_BITMASK *, int);
int bitmask_clear_without_spinlock(MXS_BITMASK *, int);
int bitmask_isset(MXS_BITMASK *, int);
int bitmask_isallclear(MXS_BITMASK *);
void bitmask_copy(MXS_BITMASK *, MXS_BITMASK *);
char *bitmask_render_readable(MXS_BITMASK *);
MXS_END_DECLS

View File

@ -130,11 +130,11 @@ typedef struct dcbstats
*/
typedef struct
{
GWBITMASK bitmask; /*< The bitmask of threads */
MXS_BITMASK bitmask; /*< The bitmask of threads */
struct dcb *next; /*< Next pointer for the zombie list */
} DCBMM;
#define DCBMM_INIT {GWBITMASK_INIT}
#define DCBMM_INIT {MXS_BITMASK_INIT}
/* DCB states */
typedef enum
@ -237,7 +237,7 @@ typedef struct dcb
struct session *session; /**< The owning session */
struct servlistener *listener; /**< For a client DCB, the listener data */
MXS_PROTOCOL func; /**< The protocol functions for this descriptor */
GWAUTHENTICATOR authfunc; /**< The authenticator functions for this descriptor */
MXS_AUTHENTICATOR authfunc; /**< The authenticator functions for this descriptor */
int writeqlen; /**< Current number of byes in the write queue */
SPINLOCK writeqlock; /**< Write Queue spinlock */

View File

@ -50,7 +50,7 @@ typedef struct servlistener
char *address; /**< Address to listen with */
char *authenticator; /**< Name of authenticator */
char *auth_options; /**< Authenticator options */
void *auth_instance; /**< Authenticator instance created in GWAUTHENTICATOR::initialize() */
void *auth_instance; /**< Authenticator instance created in MXS_AUTHENTICATOR::initialize() */
SSL_LISTENER *ssl; /**< Structure of SSL data or NULL */
struct dcb *listener; /**< The DCB for the listener */
struct users *users; /**< The user data for this listener */

View File

@ -38,7 +38,7 @@ bool authenticator_init(void** dest, const char *authenticator, const char *opti
{
bool rval = true;
void *instance = NULL;
GWAUTHENTICATOR *func = (GWAUTHENTICATOR*)load_module(authenticator, MODULE_AUTHENTICATOR);
MXS_AUTHENTICATOR *func = (MXS_AUTHENTICATOR*)load_module(authenticator, MODULE_AUTHENTICATOR);
if (func == NULL)
{

View File

@ -19,7 +19,7 @@
/**
* @file bitmask.c Implementation of bitmask operations for the gateway
*
* GWBITMASK is a fixed size bitmask with space for 256 bits.
* MXS_BITMASK is a fixed size bitmask with space for 256 bits.
*
* @verbatim
* Revision History
@ -34,8 +34,8 @@
* @endverbatim
*/
static int bitmask_isset_without_spinlock(GWBITMASK *bitmask, int bit);
static int bitmask_count_bits_set(GWBITMASK *bitmask);
static int bitmask_isset_without_spinlock(MXS_BITMASK *bitmask, int bit);
static int bitmask_count_bits_set(MXS_BITMASK *bitmask);
static const unsigned char bitmapclear[8] =
{
@ -52,7 +52,7 @@ static const unsigned char bitmapset[8] =
* @param bitmask Pointer the bitmask
*/
void
bitmask_init(GWBITMASK *bitmask)
bitmask_init(MXS_BITMASK *bitmask)
{
spinlock_init(&bitmask->lock);
memset(bitmask->bits, 0, MXS_BITMASK_SIZE);
@ -64,7 +64,7 @@ bitmask_init(GWBITMASK *bitmask)
* @param bitmask
*/
void
bitmask_free(GWBITMASK *bitmask)
bitmask_free(MXS_BITMASK *bitmask)
{
}
@ -78,7 +78,7 @@ bitmask_free(GWBITMASK *bitmask)
* the maximum length of the bitmask.
*/
int
bitmask_set(GWBITMASK *bitmask, int bit)
bitmask_set(MXS_BITMASK *bitmask, int bit)
{
ss_dassert(bit >= 0);
@ -116,7 +116,7 @@ bitmask_set(GWBITMASK *bitmask, int bit)
* @return int 1 if the bitmask is all clear after the operation, else 0.
*/
int
bitmask_clear_without_spinlock(GWBITMASK *bitmask, int bit)
bitmask_clear_without_spinlock(MXS_BITMASK *bitmask, int bit)
{
ss_dassert(bit >= 0);
@ -151,7 +151,7 @@ bitmask_clear_without_spinlock(GWBITMASK *bitmask, int bit)
* @return int 1 if the bitmask is all clear after the operation, else 0
*/
int
bitmask_clear(GWBITMASK *bitmask, int bit)
bitmask_clear(MXS_BITMASK *bitmask, int bit)
{
int result;
@ -171,7 +171,7 @@ bitmask_clear(GWBITMASK *bitmask, int bit)
* @param bit Bit to test
*/
int
bitmask_isset(GWBITMASK *bitmask, int bit)
bitmask_isset(MXS_BITMASK *bitmask, int bit)
{
int result;
@ -192,7 +192,7 @@ bitmask_isset(GWBITMASK *bitmask, int bit)
* @param bit Bit to test
*/
static int
bitmask_isset_without_spinlock(GWBITMASK *bitmask, int bit)
bitmask_isset_without_spinlock(MXS_BITMASK *bitmask, int bit)
{
ss_dassert(bit >= 0);
@ -221,7 +221,7 @@ bitmask_isset_without_spinlock(GWBITMASK *bitmask, int bit)
* @return Non-zero if the bitmask has no bits set
*/
int
bitmask_isallclear(GWBITMASK *bitmask)
bitmask_isallclear(MXS_BITMASK *bitmask)
{
unsigned char *ptr = bitmask->bits;
int result = 1;
@ -247,7 +247,7 @@ bitmask_isallclear(GWBITMASK *bitmask)
* @param src Bitmap to copy
*/
void
bitmask_copy(GWBITMASK *dest, GWBITMASK *src)
bitmask_copy(MXS_BITMASK *dest, MXS_BITMASK *src)
{
spinlock_acquire(&src->lock);
spinlock_acquire(&dest->lock);
@ -266,7 +266,7 @@ bitmask_copy(GWBITMASK *dest, GWBITMASK *src)
* @return pointer to the newly allocated string, or null if no memory
*/
char *
bitmask_render_readable(GWBITMASK *bitmask)
bitmask_render_readable(MXS_BITMASK *bitmask)
{
static const char empty[] = "No bits are set";
char *result;
@ -311,7 +311,7 @@ bitmask_render_readable(GWBITMASK *bitmask)
* @return int Number of set bits
*/
static int
bitmask_count_bits_set(GWBITMASK *bitmask)
bitmask_count_bits_set(MXS_BITMASK *bitmask)
{
static const unsigned char oneBits[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
unsigned char partresults;

View File

@ -699,7 +699,7 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol)
server->authenticator : dcb->func.auth_default ?
dcb->func.auth_default() : "NullAuthDeny";
GWAUTHENTICATOR *authfuncs = (GWAUTHENTICATOR*)load_module(authenticator,
MXS_AUTHENTICATOR *authfuncs = (MXS_AUTHENTICATOR*)load_module(authenticator,
MODULE_AUTHENTICATOR);
if (authfuncs == NULL)
{
@ -709,7 +709,7 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol)
return NULL;
}
memcpy(&dcb->authfunc, authfuncs, sizeof(GWAUTHENTICATOR));
memcpy(&dcb->authfunc, authfuncs, sizeof(MXS_AUTHENTICATOR));
/**
* Link dcb to session. Unlink is called in dcb_final_free
@ -2959,7 +2959,7 @@ dcb_accept(DCB *listener)
else
{
const char *authenticator_name = "NullAuthDeny";
GWAUTHENTICATOR *authfuncs;
MXS_AUTHENTICATOR *authfuncs;
client_dcb->service = listener->session->service;
client_dcb->session = session_set_dummy(client_dcb);
@ -2999,10 +2999,10 @@ dcb_accept(DCB *listener)
{
authenticator_name = client_dcb->func.auth_default();
}
if ((authfuncs = (GWAUTHENTICATOR *)load_module(authenticator_name,
if ((authfuncs = (MXS_AUTHENTICATOR *)load_module(authenticator_name,
MODULE_AUTHENTICATOR)) == NULL)
{
if ((authfuncs = (GWAUTHENTICATOR *)load_module("NullAuthDeny",
if ((authfuncs = (MXS_AUTHENTICATOR *)load_module("NullAuthDeny",
MODULE_AUTHENTICATOR)) == NULL)
{
MXS_ERROR("Failed to load authenticator module for %s, free dcb %p\n",
@ -3012,7 +3012,7 @@ dcb_accept(DCB *listener)
return NULL;
}
}
memcpy(&(client_dcb->authfunc), authfuncs, sizeof(GWAUTHENTICATOR));
memcpy(&(client_dcb->authfunc), authfuncs, sizeof(MXS_AUTHENTICATOR));
/** Allocate DCB specific authentication data */
if (client_dcb->authfunc.create &&

View File

@ -96,4 +96,4 @@ bool monitor_serialize(const MXS_MONITOR *monitor);
*/
MXS_MONITOR* monitor_server_in_use(const SERVER *server);
MXS_END_DECLS
MXS_END_DECLS

View File

@ -58,7 +58,7 @@ void dShowThreads(DCB *dcb);
void dShowEventQ(DCB *dcb);
void dShowEventStats(DCB *dcb);
GWBITMASK *poll_bitmask();
MXS_BITMASK *poll_bitmask();
int poll_get_stat(POLL_STAT stat);
RESULTSET *eventTimesGetList();

View File

@ -105,7 +105,7 @@ static int next_epoll_fd = 0; /*< Which thread handles the next DCB */
static fake_event_t **fake_events; /*< Thread-specific fake event queue */
static SPINLOCK *fake_event_lock;
static int do_shutdown = 0; /*< Flag the shutdown of the poll subsystem */
static GWBITMASK poll_mask;
static MXS_BITMASK poll_mask;
/** Poll cross-thread messaging variables */
static volatile int *poll_msg;
@ -1195,7 +1195,7 @@ poll_shutdown()
*
* @return The bitmask of the running polling threads
*/
GWBITMASK *
MXS_BITMASK *
poll_bitmask()
{
return &poll_mask;

View File

@ -287,7 +287,7 @@ serviceStartPort(SERVICE *service, SERV_LISTENER *port)
authenticator_name = port->listener->func.auth_default();
}
GWAUTHENTICATOR *authfuncs = (GWAUTHENTICATOR *)load_module(authenticator_name, MODULE_AUTHENTICATOR);
MXS_AUTHENTICATOR *authfuncs = (MXS_AUTHENTICATOR *)load_module(authenticator_name, MODULE_AUTHENTICATOR);
if (authfuncs == NULL)
{
@ -297,7 +297,7 @@ serviceStartPort(SERVICE *service, SERV_LISTENER *port)
return 0;
}
memcpy(&port->listener->authfunc, authfuncs, sizeof(GWAUTHENTICATOR));
memcpy(&port->listener->authfunc, authfuncs, sizeof(MXS_AUTHENTICATOR));
/**
* Normally, we'd allocate the DCB specific authentication data. As the

View File

@ -44,7 +44,7 @@
static int
test1()
{
static GWBITMASK bitmask, another;
static MXS_BITMASK bitmask, another;
int i;
/* Hint tests */

View File

@ -158,7 +158,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
modulecmd_register_command("cdc", "add_user", cdc_add_new_user, 3, args);
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
NULL, /* No create entry point */
@ -174,7 +174,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The CDC client to MaxScale authenticator implementation",
"V1.1.0",
&MyObject,

View File

@ -602,7 +602,7 @@ int gssapi_auth_load_users(SERV_LISTENER *listener)
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
gssapi_auth_init, /* Initialize authenticator */
gssapi_auth_alloc, /* Allocate authenticator data */
@ -618,7 +618,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"GSSAPI authenticator",
"V1.0.0",
&MyObject,

View File

@ -267,7 +267,7 @@ static int gssapi_backend_auth_authenticate(DCB *dcb)
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
gssapi_backend_auth_alloc, /* Allocate authenticator data */
@ -283,7 +283,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"GSSAPI backend authenticator",
"V1.0.0",
&MyObject,

View File

@ -57,7 +57,7 @@ typedef struct http_auth
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
NULL, /* No create entry point */
@ -73,7 +73,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The MaxScale HTTP BA authenticator",
"V1.1.0",
&MyObject,

View File

@ -51,7 +51,7 @@ static void max_admin_auth_free_client_data(DCB *dcb);
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
NULL, /* No create entry point */
@ -67,7 +67,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The MaxScale Admin client authenticator implementation",
"V2.1.0",
&MyObject,

View File

@ -75,7 +75,7 @@ static int mysql_auth_set_client_data(
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
mysql_auth_init, /* Initialize the authenticator */
NULL, /* No create entry point */
@ -91,7 +91,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The MySQL client to MaxScale authenticator implementation",
"V1.1.0",
&MyObject,

View File

@ -160,7 +160,7 @@ static bool auth_backend_ssl(DCB *dcb)
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
auth_backend_create, /* Create authenticator */
@ -176,7 +176,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The MySQL MaxScale to backend server authenticator",
"V1.0.0",
&MyObject,

View File

@ -53,7 +53,7 @@ static void null_auth_free_client_data(DCB *dcb);
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
NULL, /* No create entry point */
@ -69,7 +69,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The Null client authenticator implementation",
"V1.1.0",
&MyObject,

View File

@ -50,7 +50,7 @@ static void null_auth_free_client_data(DCB *dcb);
*/
MXS_MODULE* MXS_CREATE_MODULE()
{
static GWAUTHENTICATOR MyObject =
static MXS_AUTHENTICATOR MyObject =
{
NULL, /* No initialize entry point */
NULL, /* No create entry point */
@ -66,7 +66,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_MODULE_API_AUTHENTICATOR,
MXS_MODULE_GA,
GWAUTHENTICATOR_VERSION,
MXS_AUTHENTICATOR_VERSION,
"The Null client authenticator implementation",
"V1.1.0",
&MyObject,