*
* Release the underlying mod_build_api_opts() objects
*
- * @param instance The module instance.
+ * @param inst The module instance.
* @return 0.
*/
-int mod_free_api_opts(void *instance)
+int mod_free_api_opts(rlm_couchbase_t *inst)
{
- rlm_couchbase_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_couchbase_t); /* our module instance */
couchbase_opts_t *opts = inst->api_opts;
if (!opts) return 0;
DEBUG("Releasing the couchbase api options");
for (; opts != NULL; opts = opts->next) {
- if (opts->key) talloc_free(opts->key);
- if (opts->val) talloc_free(opts->val);
+ TALLOC_FREE(opts->key);
+ TALLOC_FREE(opts->val);
}
- talloc_free(opts);
+ TALLOC_FREE(opts);
/* return */
return 0;
* as a couchbase_opts_t object (key/value list).
*
* @param conf Configuration list.
- * @param instance The module instance.
+ * @param inst The module instance.
* @return
* - 0 on success.
* - -1 on failure.
*/
-int mod_build_api_opts(CONF_SECTION *conf, void *instance)
+int mod_build_api_opts(CONF_SECTION *conf, rlm_couchbase_t *inst)
{
- rlm_couchbase_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_couchbase_t); /* our module instance */
CONF_SECTION *cs; /* module config list */
CONF_ITEM *ci; /* config item */
CONF_PAIR *cp; /* config pair */
*/
void *mod_conn_create(TALLOC_CTX *ctx, void *instance, fr_time_delta_t timeout)
{
- rlm_couchbase_t const *inst = talloc_get_type_abort_const(instance, rlm_couchbase_t); /* module instance pointer */
+ rlm_couchbase_t *inst = talloc_get_type_abort(instance, rlm_couchbase_t); /* module instance pointer */
rlm_couchbase_handle_t *chandle = NULL; /* connection handle pointer */
cookie_t *cookie = NULL; /* couchbase cookie */
lcb_t cb_inst; /* couchbase connection instance */
* a cluster statistics report. Mark the connection as failed if the request
* returns anything other than success.
*
- * @param instance The module instance (currently unused).
- * @param handle The connection handle.
+ * @param opaque The module instance (currently unused).
+ * @param connection The connection handle.
* @return
* - 0 on success (alive).
* - -1 on failure (unavailable).
*/
-int mod_conn_alive(UNUSED void *instance, void *handle)
+int mod_conn_alive(UNUSED void *opaque, void *connection)
{
- rlm_couchbase_handle_t *chandle = handle; /* connection handle pointer */
+ rlm_couchbase_handle_t *chandle = connection; /* connection handle pointer */
lcb_t cb_inst = chandle->handle; /* couchbase instance */
lcb_error_t cb_error = LCB_SUCCESS; /* couchbase error status */
* used to lookup and map attributes for all incoming accounting requests.
*
* @param conf Configuration list.
- * @param instance The module instance.
+ * @param inst The module instance.
* @return
* - 0 on success.
* - -1 on failure.
*/
-int mod_build_attribute_element_map(CONF_SECTION *conf, void *instance)
+int mod_build_attribute_element_map(CONF_SECTION *conf, rlm_couchbase_t *inst)
{
- rlm_couchbase_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_couchbase_t); /* our module instance */
CONF_SECTION *cs; /* module config list */
CONF_ITEM *ci; /* config item */
CONF_PAIR *cp; /* conig pair */
if (map_afrom_value_box(ctx, &map,
attr_name, T_BARE_WORD,
&(tmpl_rules_t){
- .dict_def = request->dict,
- .list_def = list,
+ .attr = {
+ .dict_def = request->dict,
+ .list_def = list
+ }
},
op,
&tmp, true) < 0) {
/* get current event timestamp */
if ((vp = fr_pair_find_by_da_idx(vps, attr_event_timestamp, 0)) != NULL) {
/* get seconds value from attribute */
- ts = fr_time_to_sec(vp->vp_date);
+ ts = fr_unix_time_to_sec(vp->vp_date);
} else {
/* debugging */
DEBUG("failed to find event timestamp in current request");
} rlm_couchbase_handle_t;
/* define functions */
-void *mod_conn_create(TALLOC_CTX *ctx, void *instance, fr_time_delta_t timeout);
+void *mod_conn_create(TALLOC_CTX *ctx, UNUSED void *instance, fr_time_delta_t timeout);
-int mod_conn_alive(UNUSED void *instance, void *handle);
+int mod_conn_alive(void *opaque, void *connection);
-int mod_build_attribute_element_map(CONF_SECTION *conf, void *instance);
+int mod_build_attribute_element_map(CONF_SECTION *conf, rlm_couchbase_t *inst);
int mod_attribute_to_element(const char *name, json_object *map, void *buf);
int mod_load_client_documents(rlm_couchbase_t *inst, CONF_SECTION *tmpl, CONF_SECTION *map);
-int mod_build_api_opts(CONF_SECTION *conf, void *instance);
+int mod_build_api_opts(CONF_SECTION *conf, rlm_couchbase_t *inst);
-int mod_free_api_opts(void *instance);
+int mod_free_api_opts(rlm_couchbase_t *inst);
RCSID("$Id$")
-#define LOG_PREFIX inst->name
+#define LOG_PREFIX "couchbase - "
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/map.h>
TALLOC_CTX *pool = talloc_pool(request, 1024); /* We need to do lots of allocs */
fr_dcursor_t maps;
map_t *map = NULL;
- map_list_t map_head;
+ fr_dlist_head_t map_head;
vp_list_mod_t *vlm;
fr_dlist_head_t vlm_head;
- map_list_init(&map_head);
fr_dcursor_init(&maps, &map_head);
/*
*
* Detach the module instance and free any allocated resources.
*
- * @param instance The module instance.
+ * @param mctx The module instance.
* @return Returns 0 (success) in all conditions.
*/
-static int mod_detach(void *instance)
+static int mod_detach(module_detach_ctx_t const *mctx)
{
rlm_couchbase_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_couchbase_t);
*
* Intialize the module and create the initial Couchbase connection pool.
*
- * @param conf The module configuration.
- * @param instance The module instance.
+ * @param mctx The module instance.
* @return
* - 0 on success.
* - -1 on failure.
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
rlm_couchbase_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_couchbase_t); /* our module instance */
+ CONF_SECTION *conf = mctx->inst->conf;
{
char *server, *p;
.onload = mod_load,
.instantiate = mod_instantiate,
.detach = mod_detach
- }
+ },
.methods = {
[MOD_AUTHORIZE] = mod_authorize,
[MOD_ACCOUNTING] = mod_accounting,