Give parameters as CONFIG_PARAMETER for FILTER::createInstance

The filters should use the same configuration parameters as other modules
use. This allows them to use the common configuration management functions
to get values from it.
This commit is contained in:
Markus Mäkelä 2017-01-05 16:22:34 +02:00
parent e75cdb2ceb
commit 2611f9a701
20 changed files with 206 additions and 257 deletions

View File

@ -23,6 +23,7 @@
*/
#include <maxscale/cdefs.h>
#include <maxscale/config.h>
#include <maxscale/routing.h>
#include <maxscale/dcb.h>
#include <maxscale/session.h>
@ -37,15 +38,6 @@ MXS_BEGIN_DECLS
*/
typedef void *FILTER;
/**
* The structure used to pass name, value pairs to the filter instances
*/
typedef struct
{
char *name; /**< Name of the parameter */
char *value; /**< Value of the parameter */
} FILTER_PARAMETER;
/**
* @verbatim
* The "module object" structure for a query router module
@ -73,7 +65,7 @@ typedef struct filter_object
{
FILTER *(*createInstance)(const char *name,
char **options,
FILTER_PARAMETER **params);
CONFIG_PARAMETER *params);
void *(*newSession)(FILTER *instance, SESSION *session);
void (*closeSession)(FILTER *instance, void *fsession);
void (*freeSession)(FILTER *instance, void *fsession);
@ -102,7 +94,7 @@ typedef struct filter_def
char *name; /**< The Filter name */
char *module; /**< The module to load */
char **options; /**< The options set for this filter */
FILTER_PARAMETER **parameters; /**< The filter parameters */
CONFIG_PARAMETER *parameters; /**< The filter parameters */
FILTER filter; /**< The runtime filter */
FILTER_OBJECT *obj; /**< The "MODULE_OBJECT" for the filter */
SPINLOCK spin; /**< Spinlock to protect the filter definition */

View File

@ -203,7 +203,7 @@ template<class FilterType, class FilterSessionType>
class Filter
{
public:
static FILTER* createInstance(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams)
static FILTER* createInstance(const char* zName, char** pzOptions, CONFIG_PARAMETER* ppParams)
{
FilterType* pFilter = NULL;

View File

@ -325,36 +325,11 @@ filter_add_option(FILTER_DEF *filter, const char *option)
void
filter_add_parameter(FILTER_DEF *filter, const char *name, const char *value)
{
int i;
CONFIG_CONTEXT ctx = {.object = ""};
spinlock_acquire(&filter->spin);
FILTER_PARAMETER **parameters;
if (filter->parameters == NULL)
{
parameters = (FILTER_PARAMETER **)MXS_CALLOC(2, sizeof(FILTER_PARAMETER *));
i = 0;
}
else
{
for (i = 0; filter->parameters[i]; i++)
{
;
}
parameters = (FILTER_PARAMETER **)MXS_REALLOC(filter->parameters,
(i + 2) * sizeof(FILTER_PARAMETER *));
}
FILTER_PARAMETER *parameter = MXS_CALLOC(1, sizeof(FILTER_PARAMETER));
char* my_name = MXS_STRDUP(name);
char* my_value = MXS_STRDUP(value);
MXS_ABORT_IF_TRUE(!parameters || !parameter || !my_name || !my_value);
parameter->name = my_name;
parameter->value = my_value;
parameters[i] = parameter;
parameters[i + 1] = NULL;
filter->parameters = parameters;
spinlock_release(&filter->spin);
config_add_param(&ctx, name, value);
ctx.parameters->next = filter->parameters;
filter->parameters = ctx.parameters;
}
/**
@ -363,15 +338,7 @@ filter_add_parameter(FILTER_DEF *filter, const char *name, const char *value)
*/
static void filter_free_parameters(FILTER_DEF *filter)
{
if (filter->parameters)
{
for (int i = 0; filter->parameters[i]; i++)
{
MXS_FREE(filter->parameters[i]->name);
MXS_FREE(filter->parameters[i]->value);
}
MXS_FREE(filter->parameters);
}
config_parameter_free(filter->parameters);
}
/**

View File

@ -136,7 +136,7 @@ bool cache_command_show(const MODULECMD_ARG* pArgs)
*
* @return True if the parameter was an unsigned integer.
*/
bool config_get_uint32(const FILTER_PARAMETER& param, uint32_t* pValue)
bool config_get_uint32(const CONFIG_PARAMETER& param, uint32_t* pValue)
{
bool rv = false;
char* end;
@ -167,7 +167,7 @@ bool config_get_uint32(const FILTER_PARAMETER& param, uint32_t* pValue)
*
* @return True if the parameter was an unsigned integer.
*/
bool config_get_uint64(const FILTER_PARAMETER& param, uint64_t* pValue)
bool config_get_uint64(const CONFIG_PARAMETER& param, uint64_t* pValue)
{
bool rv = false;
char* end;
@ -241,7 +241,7 @@ CacheFilter::~CacheFilter()
}
// static
CacheFilter* CacheFilter::create(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams)
CacheFilter* CacheFilter::create(const char* zName, char** pzOptions, CONFIG_PARAMETER* ppParams)
{
CacheFilter* pFilter = new CacheFilter;
@ -301,14 +301,12 @@ uint64_t CacheFilter::getCapabilities()
}
// static
bool CacheFilter::process_params(char **pzOptions, FILTER_PARAMETER **ppParams, CACHE_CONFIG& config)
bool CacheFilter::process_params(char **pzOptions, CONFIG_PARAMETER *ppParams, CACHE_CONFIG& config)
{
bool error = false;
for (int i = 0; ppParams[i]; ++i)
for (const CONFIG_PARAMETER *pParam = ppParams; pParam; pParam = pParam->next)
{
const FILTER_PARAMETER *pParam = ppParams[i];
if (strcmp(pParam->name, "max_resultset_rows") == 0)
{
if (!config_get_uint64(*pParam, &config.max_resultset_rows))

View File

@ -22,7 +22,7 @@ class CacheFilter : public maxscale::Filter<CacheFilter, CacheFilterSession>
public:
~CacheFilter();
static CacheFilter* create(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams);
static CacheFilter* create(const char* zName, char** pzOptions, CONFIG_PARAMETER* ppParams);
Cache& cache() { ss_dassert(m_sCache.get()); return *m_sCache.get(); }
const Cache& cache() const { ss_dassert(m_sCache.get()); return *m_sCache.get(); }
@ -39,7 +39,7 @@ private:
CacheFilter(const CacheFilter&);
CacheFilter& operator = (const CacheFilter&);
static bool process_params(char **pzOptions, FILTER_PARAMETER **ppParams, CACHE_CONFIG& config);
static bool process_params(char **pzOptions, CONFIG_PARAMETER *ppParams, CACHE_CONFIG& config);
private:
CACHE_CONFIG m_config;

View File

@ -46,7 +46,7 @@
* @endverbatim
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *params);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -147,7 +147,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
CCR_INSTANCE *my_instance;
int i;
@ -163,27 +163,27 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->match = NULL;
my_instance->nomatch = NULL;
for (i = 0; params && params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "count"))
if (!strcmp(p->name, "count"))
{
my_instance->count = atoi(params[i]->value);
my_instance->count = atoi(p->value);
}
else if (!strcmp(params[i]->name, "time"))
else if (!strcmp(p->name, "time"))
{
my_instance->time = atoi(params[i]->value);
my_instance->time = atoi(p->value);
}
else if (!strcmp(params[i]->name, "match"))
else if (!strcmp(p->name, "match"))
{
my_instance->match = MXS_STRDUP_A(params[i]->value);
my_instance->match = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "ignore"))
else if (!strcmp(p->name, "ignore"))
{
my_instance->nomatch = MXS_STRDUP_A(params[i]->value);
my_instance->nomatch = MXS_STRDUP_A(p->value);
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("ccrfilter: Unexpected parameter '%s'.\n", params[i]->name);
MXS_ERROR("ccrfilter: Unexpected parameter '%s'.\n", p->name);
}
}

View File

@ -94,7 +94,7 @@ int dbfw_yyparse(void*);
/*
* The filter entry points
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -1484,7 +1484,7 @@ bool replace_rules(FW_INSTANCE* instance)
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
FW_INSTANCE *my_instance;
int i;
@ -1501,46 +1501,46 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->action = FW_ACTION_BLOCK;
my_instance->log_match = FW_LOG_NONE;
for (i = 0; params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (strcmp(params[i]->name, "rules") == 0)
if (strcmp(p->name, "rules") == 0)
{
filename = params[i]->value;
filename = p->value;
}
else if (strcmp(params[i]->name, "log_match") == 0 &&
config_truth_value(params[i]->value))
else if (strcmp(p->name, "log_match") == 0 &&
config_truth_value(p->value))
{
my_instance->log_match |= FW_LOG_MATCH;
}
else if (strcmp(params[i]->name, "log_no_match") == 0 &&
config_truth_value(params[i]->value))
else if (strcmp(p->name, "log_no_match") == 0 &&
config_truth_value(p->value))
{
my_instance->log_match |= FW_LOG_NO_MATCH;
}
else if (strcmp(params[i]->name, "action") == 0)
else if (strcmp(p->name, "action") == 0)
{
if (strcmp(params[i]->value, "allow") == 0)
if (strcmp(p->value, "allow") == 0)
{
my_instance->action = FW_ACTION_ALLOW;
}
else if (strcmp(params[i]->value, "block") == 0)
else if (strcmp(p->value, "block") == 0)
{
my_instance->action = FW_ACTION_BLOCK;
}
else if (strcmp(params[i]->value, "ignore") == 0)
else if (strcmp(p->value, "ignore") == 0)
{
my_instance->action = FW_ACTION_IGNORE;
}
else
{
MXS_ERROR("Unknown value for %s: %s. Expected one of 'allow', "
"'block' or 'ignore'.", params[i]->name, params[i]->value);
"'block' or 'ignore'.", p->name, p->value);
err = true;
}
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("Unknown parameter '%s' for dbfwfilter.", params[i]->name);
MXS_ERROR("Unknown parameter '%s' for dbfwfilter.", p->name);
err = true;
}
}

View File

@ -23,7 +23,7 @@
*
*/
static FILTER *createInstance(const char* name, char **options, FILTER_PARAMETER **params);
static FILTER *createInstance(const char* name, char **options, CONFIG_PARAMETER *params);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -88,7 +88,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
HINT_INSTANCE *my_instance;

View File

@ -53,7 +53,7 @@
/*
* The filter entry points
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -97,7 +97,6 @@ MXS_MODULE* MXS_CREATE_MODULE()
"Lua Filter",
"V1.0.0",
&MyObject,
NULL, /* Parameters */
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
@ -197,7 +196,7 @@ typedef struct
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
LUA_INSTANCE *my_instance;
bool error = false;
@ -209,19 +208,19 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
spinlock_init(&my_instance->lock);
for (int i = 0; params[i] && !error; i++)
for (CONFIG_PARAMETER *p = p; p && !error; p = p->next)
{
if (strcmp(params[i]->name, "global_script") == 0)
if (strcmp(p->name, "global_script") == 0)
{
error = (my_instance->global_script = MXS_STRDUP(params[i]->value)) == NULL;
error = (my_instance->global_script = MXS_STRDUP(p->value)) == NULL;
}
else if (strcmp(params[i]->name, "session_script") == 0)
else if (strcmp(p->name, "session_script") == 0)
{
error = (my_instance->session_script = MXS_STRDUP(params[i]->value)) == NULL;
error = (my_instance->session_script = MXS_STRDUP(p->value)) == NULL;
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("Unexpected parameter '%s'", params[i]->name);
MXS_ERROR("Unexpected parameter '%s'", p->name);
error = true;
}
}

View File

@ -55,7 +55,7 @@ MaskingFilter::~MaskingFilter()
}
// static
MaskingFilter* MaskingFilter::create(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams)
MaskingFilter* MaskingFilter::create(const char* zName, char** pzOptions, CONFIG_PARAMETER* ppParams)
{
MaskingFilter* pFilter = new MaskingFilter;
@ -87,7 +87,7 @@ uint64_t MaskingFilter::getCapabilities()
}
// static
bool MaskingFilter::process_params(char **pzOptions, FILTER_PARAMETER **ppParams, Config& config)
bool MaskingFilter::process_params(char **pzOptions, CONFIG_PARAMETER *ppParams, Config& config)
{
return true;
}

View File

@ -24,7 +24,7 @@ public:
typedef MaskingFilterConfig Config;
~MaskingFilter();
static MaskingFilter* create(const char* zName, char** pzOptions, FILTER_PARAMETER** ppParams);
static MaskingFilter* create(const char* zName, char** pzOptions, CONFIG_PARAMETER* ppParams);
MaskingFilterSession* newSession(SESSION* pSession);
@ -38,7 +38,7 @@ private:
MaskingFilter(const MaskingFilter&);
MaskingFilter& operator = (const MaskingFilter&);
static bool process_params(char **pzOptions, FILTER_PARAMETER **ppParams, Config& config);
static bool process_params(char **pzOptions, CONFIG_PARAMETER *ppParams, Config& config);
private:
Config m_config;

View File

@ -46,7 +46,7 @@
#include <maxscale/debug.h>
#include "maxrows.h"
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *sdata);
static void freeSession(FILTER *instance, void *sdata);
@ -163,7 +163,7 @@ static int handle_expecting_nothing(MAXROWS_SESSION_DATA *csdata);
static int handle_expecting_response(MAXROWS_SESSION_DATA *csdata);
static int handle_rows(MAXROWS_SESSION_DATA *csdata);
static int handle_ignoring_response(MAXROWS_SESSION_DATA *csdata);
static bool process_params(char **options, FILTER_PARAMETER **params, MAXROWS_CONFIG* config);
static bool process_params(char **options, CONFIG_PARAMETER *params, MAXROWS_CONFIG* config);
static int send_upstream(MAXROWS_SESSION_DATA *csdata);
static int send_ok_upstream(MAXROWS_SESSION_DATA *csdata);
@ -180,7 +180,7 @@ static int send_ok_upstream(MAXROWS_SESSION_DATA *csdata);
*
* @return The instance data for this new instance
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params)
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
MAXROWS_INSTANCE *cinstance = NULL;
MAXROWS_CONFIG config = DEFAULT_CONFIG;
@ -882,22 +882,20 @@ static int handle_ignoring_response(MAXROWS_SESSION_DATA *csdata)
*
* @return True if all parameters could be processed, false otherwise.
*/
static bool process_params(char **options, FILTER_PARAMETER **params, MAXROWS_CONFIG* config)
static bool process_params(char **options, CONFIG_PARAMETER *params, MAXROWS_CONFIG* config)
{
bool error = false;
for (int i = 0; params[i]; ++i)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
const FILTER_PARAMETER *param = params[i];
/* We could add a new parameter, max_resultset_columns:
* This way if result has more than max_resultset_columns
* we return 0 result
*/
if (strcmp(param->name, "max_resultset_rows") == 0)
if (strcmp(p->name, "max_resultset_rows") == 0)
{
int v = atoi(param->value);
int v = atoi(p->value);
if (v > 0)
{
@ -908,9 +906,9 @@ static bool process_params(char **options, FILTER_PARAMETER **params, MAXROWS_CO
config->max_resultset_rows = MAXROWS_DEFAULT_MAX_RESULTSET_ROWS;
}
}
else if (strcmp(param->name, "max_resultset_size") == 0)
else if (strcmp(p->name, "max_resultset_size") == 0)
{
int v = atoi(param->value);
int v = atoi(p->value);
if (v > 0)
{
@ -919,13 +917,13 @@ static bool process_params(char **options, FILTER_PARAMETER **params, MAXROWS_CO
else
{
MXS_ERROR("The value of the configuration entry '%s' must "
"be an integer larger than 0.", param->name);
"be an integer larger than 0.", p->name);
error = true;
}
}
else if (strcmp(param->name, "debug") == 0)
else if (strcmp(p->name, "debug") == 0)
{
int v = atoi(param->value);
int v = atoi(p->value);
if ((v >= MAXROWS_DEBUG_MIN) && (v <= MAXROWS_DEBUG_MAX))
{
@ -935,13 +933,13 @@ static bool process_params(char **options, FILTER_PARAMETER **params, MAXROWS_CO
{
MXS_ERROR("The value of the configuration entry '%s' must "
"be between %d and %d, inclusive.",
param->name, MAXROWS_DEBUG_MIN, MAXROWS_DEBUG_MAX);
p->name, MAXROWS_DEBUG_MIN, MAXROWS_DEBUG_MAX);
error = true;
}
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("Unknown configuration entry '%s'.", param->name);
MXS_ERROR("Unknown configuration entry '%s'.", p->name);
error = true;
}
}

View File

@ -83,7 +83,7 @@ static int hktask_id = 0;
/*
* The filter entry points
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -490,11 +490,11 @@ char** parse_optstr(char* str, char* tok, int* szstore)
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
MQ_INSTANCE *my_instance;
int paramcount = 0, parammax = 64, i = 0, x = 0, arrsize = 0;
FILTER_PARAMETER** paramlist;
CONFIG_PARAMETER** paramlist;
char** arr = NULL;
char taskname[512];
@ -503,7 +503,7 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
spinlock_init(&my_instance->rconn_lock);
spinlock_init(&my_instance->msg_lock);
uid_gen = 0;
paramlist = MXS_MALLOC(sizeof(FILTER_PARAMETER*) * 64);
paramlist = MXS_MALLOC(sizeof(CONFIG_PARAMETER*) * 64);
MXS_ABORT_IF_NULL(paramlist);
if ((my_instance->conn = amqp_new_connection()) == NULL)
@ -521,63 +521,63 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->log_all = false;
my_instance->strict_logging = true;
for (i = 0; params[i]; i++)
for (const CONFIG_PARAMETER *p = p; p; p = p->next)
{
if (!strcmp(params[i]->name, "hostname"))
if (!strcmp(p->name, "hostname"))
{
my_instance->hostname = MXS_STRDUP_A(params[i]->value);
my_instance->hostname = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "username"))
else if (!strcmp(p->name, "username"))
{
my_instance->username = MXS_STRDUP_A(params[i]->value);
my_instance->username = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "password"))
else if (!strcmp(p->name, "password"))
{
my_instance->password = MXS_STRDUP_A(params[i]->value);
my_instance->password = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "vhost"))
else if (!strcmp(p->name, "vhost"))
{
my_instance->vhost = MXS_STRDUP_A(params[i]->value);
my_instance->vhost = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "port"))
else if (!strcmp(p->name, "port"))
{
my_instance->port = atoi(params[i]->value);
my_instance->port = atoi(p->value);
}
else if (!strcmp(params[i]->name, "exchange"))
else if (!strcmp(p->name, "exchange"))
{
my_instance->exchange = MXS_STRDUP_A(params[i]->value);
my_instance->exchange = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "key"))
else if (!strcmp(p->name, "key"))
{
my_instance->key = MXS_STRDUP_A(params[i]->value);
my_instance->key = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "queue"))
else if (!strcmp(p->name, "queue"))
{
my_instance->queue = MXS_STRDUP_A(params[i]->value);
my_instance->queue = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "ssl_client_certificate"))
else if (!strcmp(p->name, "ssl_client_certificate"))
{
my_instance->ssl_client_cert = MXS_STRDUP_A(params[i]->value);
my_instance->ssl_client_cert = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "ssl_client_key"))
else if (!strcmp(p->name, "ssl_client_key"))
{
my_instance->ssl_client_key = MXS_STRDUP_A(params[i]->value);
my_instance->ssl_client_key = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "ssl_CA_cert"))
else if (!strcmp(p->name, "ssl_CA_cert"))
{
my_instance->ssl_CA_cert = MXS_STRDUP_A(params[i]->value);
my_instance->ssl_CA_cert = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "exchange_type"))
else if (!strcmp(p->name, "exchange_type"))
{
my_instance->exchange_type = MXS_STRDUP_A(params[i]->value);
my_instance->exchange_type = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "logging_trigger"))
else if (!strcmp(p->name, "logging_trigger"))
{
arr = parse_optstr(params[i]->value, ",", &arrsize);
arr = parse_optstr(p->value, ",", &arrsize);
for (x = 0; x < arrsize; x++)
{
@ -617,15 +617,15 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
}
else if (strstr(params[i]->name, "logging_"))
else if (strstr(p->name, "logging_"))
{
if (paramcount < parammax)
{
paramlist[paramcount] = MXS_MALLOC(sizeof(FILTER_PARAMETER));
paramlist[paramcount] = MXS_MALLOC(sizeof(CONFIG_PARAMETER));
MXS_ABORT_IF_NULL(paramlist[paramcount]);
paramlist[paramcount]->name = MXS_STRDUP_A(params[i]->name);
paramlist[paramcount]->value = MXS_STRDUP_A(params[i]->value);
paramlist[paramcount]->name = MXS_STRDUP_A(p->name);
paramlist[paramcount]->value = MXS_STRDUP_A(p->value);
paramcount++;
}
}

View File

@ -40,7 +40,7 @@
* @endverbatim
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *params);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -128,7 +128,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
REGEXHINT_INSTANCE *my_instance = (REGEXHINT_INSTANCE*)MXS_MALLOC(sizeof(REGEXHINT_INSTANCE));
@ -140,28 +140,27 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->user = NULL;
bool error = false;
for (int i = 0; params && params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "match"))
if (!strcmp(p->name, "match"))
{
my_instance->match = MXS_STRDUP_A(params[i]->value);
my_instance->match = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "server"))
else if (!strcmp(p->name, "server"))
{
my_instance->server = MXS_STRDUP_A(params[i]->value);
my_instance->server = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "source"))
else if (!strcmp(p->name, "source"))
{
my_instance->source = MXS_STRDUP_A(params[i]->value);
my_instance->source = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "user"))
else if (!strcmp(p->name, "user"))
{
my_instance->user = MXS_STRDUP_A(params[i]->value);
my_instance->user = MXS_STRDUP_A(p->value);
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("namedserverfilter: Unexpected parameter '%s'.",
params[i]->name);
MXS_ERROR("namedserverfilter: Unexpected parameter '%s'.", p->name);
error = true;
}
}

View File

@ -70,7 +70,7 @@
/*
* The filter entry points
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -187,7 +187,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
QLA_INSTANCE *my_instance = (QLA_INSTANCE*) MXS_MALLOC(sizeof(QLA_INSTANCE));
@ -209,32 +209,31 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
if (params)
{
for (int i = 0; params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "match"))
if (!strcmp(p->name, "match"))
{
my_instance->match = MXS_STRDUP_A(params[i]->value);
my_instance->match = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "exclude"))
else if (!strcmp(p->name, "exclude"))
{
my_instance->nomatch = MXS_STRDUP_A(params[i]->value);
my_instance->nomatch = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "source"))
else if (!strcmp(p->name, "source"))
{
my_instance->source = MXS_STRDUP_A(params[i]->value);
my_instance->source = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "user"))
else if (!strcmp(p->name, "user"))
{
my_instance->user_name = MXS_STRDUP_A(params[i]->value);
my_instance->user_name = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "filebase"))
else if (!strcmp(p->name, "filebase"))
{
my_instance->filebase = MXS_STRDUP_A(params[i]->value);
my_instance->filebase = MXS_STRDUP_A(p->value);
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("qlafilter: Unexpected parameter '%s'.",
params[i]->name);
MXS_ERROR("qlafilter: Unexpected parameter '%s'.", p->name);
error = true;
}
}

View File

@ -40,7 +40,7 @@
* @endverbatim
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *params);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -164,7 +164,7 @@ void free_instance(REGEX_INSTANCE *instance)
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
REGEX_INSTANCE *my_instance;
int i, errnumber, cflags = PCRE2_CASELESS;
@ -177,40 +177,39 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->match = NULL;
my_instance->replace = NULL;
for (i = 0; params && params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "match"))
if (!strcmp(p->name, "match"))
{
my_instance->match = MXS_STRDUP_A(params[i]->value);
my_instance->match = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "replace"))
else if (!strcmp(p->name, "replace"))
{
my_instance->replace = MXS_STRDUP_A(params[i]->value);
my_instance->replace = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "source"))
else if (!strcmp(p->name, "source"))
{
my_instance->source = MXS_STRDUP_A(params[i]->value);
my_instance->source = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "user"))
else if (!strcmp(p->name, "user"))
{
my_instance->user = MXS_STRDUP_A(params[i]->value);
my_instance->user = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "log_trace"))
else if (!strcmp(p->name, "log_trace"))
{
my_instance->log_trace = config_truth_value(params[i]->value);
my_instance->log_trace = config_truth_value(p->value);
}
else if (!strcmp(params[i]->name, "log_file"))
else if (!strcmp(p->name, "log_file"))
{
if (logfile)
{
MXS_FREE(logfile);
}
logfile = MXS_STRDUP_A(params[i]->value);
logfile = MXS_STRDUP_A(p->value);
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("regexfilter: Unexpected parameter '%s'.",
params[i]->name);
MXS_ERROR("regexfilter: Unexpected parameter '%s'.", p->name);
}
}

View File

@ -97,7 +97,7 @@ static unsigned char required_packets[] =
/*
* The filter entry points
*/
static FILTER *createInstance(const char* name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char* name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -342,7 +342,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
TEE_INSTANCE *my_instance;
int i;
@ -361,36 +361,35 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->nomatch = NULL;
if (params)
{
for (i = 0; params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "service"))
if (!strcmp(p->name, "service"))
{
if ((my_instance->service = service_find(params[i]->value)) == NULL)
if ((my_instance->service = service_find(p->value)) == NULL)
{
MXS_ERROR("tee: service '%s' not found.\n",
params[i]->value);
p->value);
}
}
else if (!strcmp(params[i]->name, "match"))
else if (!strcmp(p->name, "match"))
{
my_instance->match = MXS_STRDUP_A(params[i]->value);
my_instance->match = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "exclude"))
else if (!strcmp(p->name, "exclude"))
{
my_instance->nomatch = MXS_STRDUP_A(params[i]->value);
my_instance->nomatch = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "source"))
else if (!strcmp(p->name, "source"))
{
my_instance->source = MXS_STRDUP_A(params[i]->value);
my_instance->source = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "user"))
else if (!strcmp(p->name, "user"))
{
my_instance->userName = MXS_STRDUP_A(params[i]->value);
my_instance->userName = MXS_STRDUP_A(p->value);
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("tee: Unexpected parameter '%s'.",
params[i]->name);
MXS_ERROR("tee: Unexpected parameter '%s'.", p->name);
}
}
}

View File

@ -30,7 +30,7 @@
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *params);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -117,7 +117,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
TEST_INSTANCE *my_instance;

View File

@ -48,7 +48,7 @@
/*
* The filter entry points
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -170,7 +170,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
TOPN_INSTANCE *my_instance = (TOPN_INSTANCE*)MXS_MALLOC(sizeof(TOPN_INSTANCE));
@ -184,36 +184,35 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
my_instance->filebase = NULL;
bool error = false;
for (int i = 0; params && params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "count"))
if (!strcmp(p->name, "count"))
{
my_instance->topN = atoi(params[i]->value);
my_instance->topN = atoi(p->value);
}
else if (!strcmp(params[i]->name, "filebase"))
else if (!strcmp(p->name, "filebase"))
{
my_instance->filebase = MXS_STRDUP_A(params[i]->value);
my_instance->filebase = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "match"))
else if (!strcmp(p->name, "match"))
{
my_instance->match = MXS_STRDUP_A(params[i]->value);
my_instance->match = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "exclude"))
else if (!strcmp(p->name, "exclude"))
{
my_instance->exclude = MXS_STRDUP_A(params[i]->value);
my_instance->exclude = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "source"))
else if (!strcmp(p->name, "source"))
{
my_instance->source = MXS_STRDUP_A(params[i]->value);
my_instance->source = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "user"))
else if (!strcmp(p->name, "user"))
{
my_instance->user = MXS_STRDUP_A(params[i]->value);
my_instance->user = MXS_STRDUP_A(p->value);
}
else if (!filter_standard_parameter(params[i]->name))
else if (!filter_standard_parameter(p->name))
{
MXS_ERROR("topfilter: Unexpected parameter '%s'.",
params[i]->name);
MXS_ERROR("topfilter: Unexpected parameter '%s'.", p->name);
error = true;
}
}

View File

@ -76,7 +76,7 @@ static const char* default_named_pipe = "/tmp/tpmfilter";
/*
* The filter entry points
*/
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **);
static FILTER *createInstance(const char *name, char **options, CONFIG_PARAMETER *);
static void *newSession(FILTER *instance, SESSION *session);
static void closeSession(FILTER *instance, void *session);
static void freeSession(FILTER *instance, void *session);
@ -189,7 +189,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @return The instance data for this new instance
*/
static FILTER *
createInstance(const char *name, char **options, FILTER_PARAMETER **params)
createInstance(const char *name, char **options, CONFIG_PARAMETER *params)
{
int i, ret;
TPM_INSTANCE *my_instance;
@ -210,35 +210,35 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
/* set default named pipe */
my_instance->named_pipe = MXS_STRDUP_A(default_named_pipe);
for (i = 0; params && params[i]; i++)
for (const CONFIG_PARAMETER *p = params; p; p = p->next)
{
if (!strcmp(params[i]->name, "filename"))
if (!strcmp(p->name, "filename"))
{
MXS_FREE(my_instance->filename);
my_instance->filename = MXS_STRDUP_A(params[i]->value);
my_instance->filename = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "source"))
else if (!strcmp(p->name, "source"))
{
my_instance->source = MXS_STRDUP_A(params[i]->value);
my_instance->source = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "user"))
else if (!strcmp(p->name, "user"))
{
my_instance->user = MXS_STRDUP_A(params[i]->value);
my_instance->user = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "delimiter"))
else if (!strcmp(p->name, "delimiter"))
{
MXS_FREE(my_instance->delimiter);
my_instance->delimiter = MXS_STRDUP_A(params[i]->value);
my_instance->delimiter = MXS_STRDUP_A(p->value);
}
else if (!strcmp(params[i]->name, "query_delimiter"))
else if (!strcmp(p->name, "query_delimiter"))
{
MXS_FREE(my_instance->query_delimiter);
my_instance->query_delimiter = MXS_STRDUP_A(params[i]->value);
my_instance->query_delimiter = MXS_STRDUP_A(p->value);
my_instance->query_delimiter_size = strlen(my_instance->query_delimiter);
}
else if (!strcmp(params[i]->name, "named_pipe"))
else if (!strcmp(p->name, "named_pipe"))
{
if (params[i]->value == NULL)
if (p->value == NULL)
{
MXS_ERROR("You need to specify 'named_pipe' for tpmfilter.");
MXS_FREE(my_instance);
@ -246,7 +246,7 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
}
else
{
my_instance->named_pipe = MXS_STRDUP_A(params[i]->value);
my_instance->named_pipe = MXS_STRDUP_A(p->value);
// check if the file exists first.
if (access(my_instance->named_pipe, F_OK) == 0)
{