All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
mod.h File Reference

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

#include <freeradius-devel/radiusd.h>
#include <libcouchbase/couchbase.h>
#include "../rlm_json/json.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
 

Typedefs

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

Functions

int mod_attribute_to_element (const char *name, json_object *map, void *buf)
 Map attributes to JSON element names. More...
 
int mod_build_attribute_element_map (CONF_SECTION *conf, void *instance)
 Build a JSON object map from the configuration "map" section. More...
 
int mod_client_map_section (CONF_SECTION *client, CONF_SECTION const *map, json_object *json, char const *docid)
 
int mod_conn_alive (UNUSED void *instance, void *handle)
 Check the health of a connection handle. More...
 
void * mod_conn_create (TALLOC_CTX *ctx, void *instance, struct timeval const *timeout)
 Create a new connection pool handle. More...
 
int mod_ensure_start_timestamp (json_object *json, VALUE_PAIR *vps)
 Ensure accounting documents always contain a valid timestamp. More...
 
void * mod_json_object_to_value_pairs (json_object *json, const char *section, REQUEST *request)
 Build value pairs from the passed JSON object and add to the request. More...
 
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 *request, VALUE_PAIR *vp)
 Convert value pairs to json objects. More...
 

Detailed Description

Function prototypes and datatypes used in the module.

Id:
0660f07c247659a1e315bb700eefc7737c87adf0
Author
Aaron Hurt ahurt.nosp@m.@anb.nosp@m.cs.co.nosp@m.m

Definition in file mod.h.


Data Structure Documentation

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 78 of file mod.h.

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

The main module instance.

This struct contains the core module configuration.

Definition at line 47 of file mod.h.

+ Collaboration diagram for rlm_couchbase_t:
Data Fields
vp_tmpl_t * acct_key Accounting document key.
char const * bucket Couchbase bucket.
bool check_simul Toggle to enable simultaneous use checking.
const char * client_view Couchbase view that returns client documents.
bool delete_stale_sessions Toggle to trigger zapping of stale sessions.
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 * password Couchbase bucket password.
fr_connection_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.
const char * simul_view Couchbase view that returns accounting documents.
vp_tmpl_t * simul_vkey The query key to be used with simul_view.
vp_tmpl_t * user_key User document key.
bool verify_simul Toggle to enable user login state verification.

Macro Definition Documentation

#define MAX_KEY_SIZE   250

Definition at line 41 of file mod.h.

#define MAX_VALUE_SIZE   20480

Definition at line 38 of file mod.h.

Typedef Documentation

Couchbase instance specific information.

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

The main module instance.

This struct contains the core module configuration.

Function Documentation

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 225 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mod_build_attribute_element_map ( CONF_SECTION conf,
void *  instance 
)

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

Parse the "map" section 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 section.
instanceThe module instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 150 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mod_client_map_section ( CONF_SECTION client,
CONF_SECTION const *  map,
json_object *  json,
char const *  docid 
)
int mod_conn_alive ( UNUSED void *  instance,
void *  handle 
)

Check the health of a connection handle.

Attempt to determing the state of the Couchbase connection by requesting a cluster statistics report. Mark the connection as failed if the request returns anything other than success.

Parameters
instanceThe module instance (currently unused).
handleThe connection handle.
Returns
  • 0 on success (alive).
  • -1 on failure (unavailable).

Definition at line 121 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* mod_conn_create ( TALLOC_CTX *  ctx,
void *  instance,
struct timeval const *  timeout 
)

Create a new connection pool handle.

Create a new connection to Couchbase within the pool and initialize information associated with the connection instance.

Parameters
ctxThe connection parent context.
instanceThe module instance.
timeoutMaximum time to establish the connection.
Returns
  • New connection handle.
  • NULL on error.

Create a new connection pool handle.

Create a new ldap connection and allocate memory for a new rlm_handle_t

Create a new connection pool handle.

Matches the fr_connection_create_t function prototype, is passed to fr_connection_pool_init, and called when a new connection is required by the connection pool API.

Creates an instances of rlm_rest_handle_t, and rlm_rest_curl_context_t which hold the context data required for generating requests and parsing responses.

If instance->connect_uri is not NULL libcurl will attempt to open a TCP socket to the server specified in the URI. This is done so that when the socket is first used, there will already be a cached TCP connection to the REST server associated with the curl handle.

See Also
fr_connection_pool_init
fr_connection_create_t
connection.c

Definition at line 68 of file mod.c.

int mod_ensure_start_timestamp ( json_object *  json,
VALUE_PAIR 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 476 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* mod_json_object_to_value_pairs ( json_object *  json,
const char *  section,
REQUEST request 
)

Build value pairs from the passed JSON object and add to the request.

Parse the passed JSON object and create value pairs that will be injected into the given request for authorization.

Example JSON document structure:

{
"docType": "raduser",
"userName": "test",
"config": {
"SHA-Password": {
"value": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
"op": ":="
}
},
"reply": {
"Reply-Message": {
"value": "Hidey Ho!",
"op": "="
}
}
}
Parameters
jsonThe JSON object representation of the user documnent.
sectionThe pair section ("config" or "reply").
requestThe request to which the generated pairs should be added.

Definition at line 281 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 sever startup this should not be a concern.

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

Definition at line 577 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

json_object* mod_value_pair_to_json_object ( REQUEST request,
VALUE_PAIR vp 
)

Convert value pairs to json objects.

Take the passed value pair and convert it to a json-c JSON object. This code is heavily based on the fr_json_from_pair() function from src/lib/print.c.

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

Definition at line 382 of file mod.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: