The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions
mod.h File Reference

Function prototypes and datatypes used in the module. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/pool.h>
#include <freeradius-devel/json/base.h>
+ Include dependency graph for mod.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rlm_couchbase_handle_t
 Couchbase instance specific information. More...
 
struct  rlm_couchbase_t
 The main module instance. More...
 

Macros

#define MAX_KEY_SIZE   250
 
#define MAX_VALUE_SIZE   20480
 

Functions

int mod_attribute_to_element (const char *name, json_object *map, void *buf)
 Map attributes to JSON element names. More...
 
int mod_build_api_opts (CONF_SECTION *conf, rlm_couchbase_t *inst)
 Build a couchbase_opts_t structure from the configuration "couchbase_api" list. More...
 
int mod_build_attribute_element_map (CONF_SECTION *conf, rlm_couchbase_t *inst)
 Build a JSON object map from the configuration "map" list. More...
 
int mod_client_map_section (CONF_SECTION *client, CONF_SECTION const *map, json_object *json, char const *docid)
 
int mod_conn_alive (void *opaque, void *connection)
 
void * mod_conn_create (TALLOC_CTX *ctx, UNUSED void *instance, fr_time_delta_t timeout)
 
int mod_ensure_start_timestamp (json_object *json, fr_pair_list_t *vps)
 Ensure accounting documents always contain a valid timestamp. More...
 
int mod_free_api_opts (rlm_couchbase_t *inst)
 Delete a object built by mod_build_api_opts() More...
 
int mod_json_object_to_map (TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *request, json_object *json, tmpl_pair_list_t list)
 
int mod_load_client_documents (rlm_couchbase_t *inst, CONF_SECTION *tmpl, CONF_SECTION *map)
 Load client entries from Couchbase client documents on startup. More...
 
json_object * mod_value_pair_to_json_object (request_t *request, fr_pair_t *vp)
 Convert value pairs to json objects. More...
 

Detailed Description

Function prototypes and datatypes used in the module.

Id
72fb139c558c9ec524ca09b7ff8f841379f9bf58
Author
Aaron Hurt (ahurt.nosp@m.@anb.nosp@m.cs.co.nosp@m.m)

Definition in file mod.h.


Data Structure Documentation

◆ rlm_couchbase_handle_t

struct rlm_couchbase_handle_t

Couchbase instance specific information.

This struct contains the Couchbase connection handle as well as a cookie pointer to store fetched document payloads.

Definition at line 71 of file mod.h.

Data Fields
void * cookie Couchbase cookie (cookie_u cookie_t).
void * handle Real couchbase instance.

◆ rlm_couchbase_t

struct rlm_couchbase_t

The main module instance.

This struct contains the core module configuration.

Definition at line 44 of file mod.h.

+ Collaboration diagram for rlm_couchbase_t:
Data Fields
tmpl_t * acct_key Accounting document key.
void * api_opts Couchbase API internal options.
char const * bucket Couchbase bucket.
const char * client_view Couchbase view that returns client documents.
char const * doctype Value of accounting 'docType' element name.
uint32_t expire Accounting document expire time in seconds.
json_object * map Json object to hold user defined attribute map.
char const * name Module instance name.
char const * password Couchbase bucket password.
fr_pool_t * pool Connection pool.
bool read_clients Toggle for loading client records.
char const * server Couchbase server list.
char const * server_raw Raw server string before parsing.
tmpl_t * user_key User document key.
char const * username Couchbase bucket username.

Macro Definition Documentation

◆ MAX_KEY_SIZE

#define MAX_KEY_SIZE   250

Definition at line 38 of file mod.h.

◆ MAX_VALUE_SIZE

#define MAX_VALUE_SIZE   20480

Definition at line 35 of file mod.h.

Function Documentation

◆ mod_attribute_to_element()

int mod_attribute_to_element ( const char *  name,
json_object *  map,
void *  buf 
)

Map attributes to JSON element names.

Attempt to map the passed attribute name to the configured JSON element name using the JSON object map mod_build_attribute_element_map().

Parameters
nameThe character name of the requested attribute.
mapThe JSON object map to use for the lookup.
bufThe buffer where the given element will be stored if found.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 311 of file mod.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_build_api_opts()

int mod_build_api_opts ( CONF_SECTION conf,
rlm_couchbase_t inst 
)

Build a couchbase_opts_t structure from the configuration "couchbase_api" list.

Parse the "couchbase_api" list from the module configuration file and store this as a couchbase_opts_t object (key/value list).

Parameters
confConfiguration list.
instThe module instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 93 of file mod.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_build_attribute_element_map()

int mod_build_attribute_element_map ( CONF_SECTION conf,
rlm_couchbase_t inst 
)

Build a JSON object map from the configuration "map" list.

Parse the "map" list from the module configuration file and store this as a JSON object (key/value list) in the module instance. This map will be used to lookup and map attributes for all incoming accounting requests.

Parameters
confConfiguration list.
instThe module instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 237 of file mod.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_client_map_section()

int mod_client_map_section ( CONF_SECTION client,
CONF_SECTION const *  map,
json_object *  json,
char const *  docid 
)

◆ mod_conn_alive()

int mod_conn_alive ( void *  opaque,
void *  connection 
)

◆ mod_conn_create()

void* mod_conn_create ( TALLOC_CTX *  ctx,
UNUSED void *  instance,
fr_time_delta_t  timeout 
)

◆ mod_ensure_start_timestamp()

int mod_ensure_start_timestamp ( json_object *  json,
fr_pair_list_t vps 
)

Ensure accounting documents always contain a valid timestamp.

Inspect the given JSON object representation of an accounting document fetched from Couchbase and ensuse it contains a valid (non NULL) timestamp value.

Parameters
jsonJSON object representation of an accounting document.
vpsThe value pairs associated with the current accounting request.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 604 of file mod.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_free_api_opts()

int mod_free_api_opts ( rlm_couchbase_t inst)

Delete a object built by mod_build_api_opts()

Release the underlying mod_build_api_opts() objects

Parameters
instThe module instance.
Returns
0.

Definition at line 63 of file mod.c.

+ Here is the caller graph for this function:

◆ mod_json_object_to_map()

int mod_json_object_to_map ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
request_t request,
json_object *  json,
tmpl_pair_list_t  list 
)

◆ mod_load_client_documents()

int mod_load_client_documents ( rlm_couchbase_t inst,
CONF_SECTION tmpl,
CONF_SECTION map 
)

Load client entries from Couchbase client documents on startup.

This function executes the view defined in the module configuration and loops through all returned rows. The view is called with "stale=false" to ensure the most accurate data available when the view is called. This will force an index rebuild on this design document in Couchbase. However, since this function is only run once at server startup this should not be a concern.

Parameters
instThe module instance.
tmplDefault values for new clients.
mapThe client attribute configuration list.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 706 of file mod.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_value_pair_to_json_object()

json_object* mod_value_pair_to_json_object ( request_t request,
fr_pair_t vp 
)

Convert value pairs to json objects.

Take the passed value pair and convert it to a json-c JSON object..

Parameters
requestThe request object.
vpThe value pair to convert.
Returns
A JSON object.

Definition at line 510 of file mod.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: