The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
mod.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 72fb139c558c9ec524ca09b7ff8f841379f9bf58 $
20 *
21 * @brief Function prototypes and datatypes used in the module.
22 * @file mod.h
23 *
24 * @author Aaron Hurt (ahurt@anbcs.com)
25 * @copyright 2013-2014 The FreeRADIUS Server Project.
26 */
27RCSIDH(mod_h, "$Id: 72fb139c558c9ec524ca09b7ff8f841379f9bf58 $")
28
29#include <freeradius-devel/server/base.h>
30#include <freeradius-devel/server/pool.h>
31
32#include <freeradius-devel/json/base.h>
33
34/* maximum size of a stored value */
35#define MAX_VALUE_SIZE 20480
36
37/* maximum length of a document key */
38#define MAX_KEY_SIZE 250
39
40/** The main module instance
41 *
42 * This struct contains the core module configuration.
43 */
44typedef struct {
45 tmpl_t *acct_key; //!< Accounting document key.
46 char const *doctype; //!< Value of accounting 'docType' element name.
47 uint32_t expire; //!< Accounting document expire time in seconds.
48
49 char const *server_raw; //!< Raw server string before parsing.
50 char const *server; //!< Couchbase server list.
51 char const *bucket; //!< Couchbase bucket.
52 char const *username; //!< Couchbase bucket username.
53 char const *password; //!< Couchbase bucket password.
54
55 tmpl_t *user_key; //!< User document key.
56
57 bool read_clients; //!< Toggle for loading client records.
58 const char *client_view; //!< Couchbase view that returns client documents.
59
60 json_object *map; //!< Json object to hold user defined attribute map.
61 fr_pool_t *pool; //!< Connection pool.
62 char const *name; //!< Module instance name.
63 void *api_opts; //!< Couchbase API internal options.
65
66/** Couchbase instance specific information
67 *
68 * This struct contains the Couchbase connection handle as well as a
69 * cookie pointer to store fetched document payloads.
70 */
71typedef struct {
72 void *handle; //!< Real couchbase instance.
73 void *cookie; //!< Couchbase cookie (@p cookie_u @p cookie_t).
75
76/* define functions */
77void *mod_conn_create(TALLOC_CTX *ctx, UNUSED void *instance, fr_time_delta_t timeout);
78
79int mod_conn_alive(void *opaque, void *connection);
80
82
83int mod_attribute_to_element(const char *name, json_object *map, void *buf);
84
85int mod_json_object_to_map(TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *request, json_object *json, tmpl_pair_list_t list);
86
88
89int mod_ensure_start_timestamp(json_object *json, fr_pair_list_t *vps);
90
91int mod_client_map_section(CONF_SECTION *client, CONF_SECTION const *map, json_object *json, char const *docid);
92
94
96
98
#define RCSIDH(h, id)
Definition build.h:484
#define UNUSED
Definition build.h:315
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
unsigned int uint32_t
char const * bucket
Couchbase bucket.
Definition mod.h:51
int mod_attribute_to_element(const char *name, json_object *map, void *buf)
Map attributes to JSON element names.
Definition mod.c:311
int mod_free_api_opts(rlm_couchbase_t *inst)
Delete a object built by mod_build_api_opts()
Definition mod.c:63
void * mod_conn_create(TALLOC_CTX *ctx, UNUSED void *instance, fr_time_delta_t timeout)
int mod_build_api_opts(CONF_SECTION *conf, rlm_couchbase_t *inst)
Build a couchbase_opts_t structure from the configuration "couchbase_api" list.
Definition mod.c:93
void * cookie
Couchbase cookie (cookie_u cookie_t).
Definition mod.h:73
char const * server_raw
Raw server string before parsing.
Definition mod.h:49
const char * client_view
Couchbase view that returns client documents.
Definition mod.h:58
void * api_opts
Couchbase API internal options.
Definition mod.h:63
bool read_clients
Toggle for loading client records.
Definition mod.h:57
int mod_conn_alive(void *opaque, void *connection)
tmpl_t * user_key
User document key.
Definition mod.h:55
uint32_t expire
Accounting document expire time in seconds.
Definition mod.h:47
void * handle
Real couchbase instance.
Definition mod.h:72
int mod_load_client_documents(rlm_couchbase_t *inst, CONF_SECTION *tmpl, CONF_SECTION *map)
Load client entries from Couchbase client documents on startup.
Definition mod.c:706
int mod_build_attribute_element_map(CONF_SECTION *conf, rlm_couchbase_t *inst)
Build a JSON object map from the configuration "map" list.
Definition mod.c:237
char const * server
Couchbase server list.
Definition mod.h:50
int mod_ensure_start_timestamp(json_object *json, fr_pair_list_t *vps)
Ensure accounting documents always contain a valid timestamp.
Definition mod.c:604
char const * name
Module instance name.
Definition mod.h:62
json_object * map
Json object to hold user defined attribute map.
Definition mod.h:60
tmpl_t * acct_key
Accounting document key.
Definition mod.h:45
char const * username
Couchbase bucket username.
Definition mod.h:52
int mod_json_object_to_map(TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *request, json_object *json, tmpl_pair_list_t list)
json_object * mod_value_pair_to_json_object(request_t *request, fr_pair_t *vp)
Convert value pairs to json objects.
Definition mod.c:510
char const * doctype
Value of accounting 'docType' element name.
Definition mod.h:46
fr_pool_t * pool
Connection pool.
Definition mod.h:61
int mod_client_map_section(CONF_SECTION *client, CONF_SECTION const *map, json_object *json, char const *docid)
char const * password
Couchbase bucket password.
Definition mod.h:53
Couchbase instance specific information.
Definition mod.h:71
The main module instance.
Definition mod.h:44
A connection pool.
Definition pool.c:87
static rs_t * conf
Definition radsniff.c:53
static char const * name
eap_aka_sim_process_conf_t * inst
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
static size_t char ** out
Definition value.h:997