2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * @brief Function prototypes and datatypes used in the module.
23 * @copyright 2013-2014 Aaron Hurt <ahurt@anbcs.com>
29 RCSIDH(mod_h, "$Id$");
31 #include <freeradius-devel/radiusd.h>
33 #include <libcouchbase/couchbase.h>
36 #include "jsonc_missing.h"
38 /* maximum size of a stored value */
39 #define MAX_VALUE_SIZE 20480
41 /* maximum length of a document key */
42 #define MAX_KEY_SIZE 250
44 /* configuration struct */
45 typedef struct rlm_couchbase_t {
46 char const *acct_key; //!< Accounting document key.
47 char const *doctype; //!< Value of 'docType' element name.
48 char const *server_raw; //!< Raw server string before parsing.
49 char const *server; //!< Couchbase server list.
50 char const *bucket; //!< Couchbase bucket.
51 char const *password; //!< Couchbase bucket password.
52 uint32_t expire; //!< Document expire time in seconds.
53 const char *user_key; //!< User document key.
54 json_object *map; //!< Json object to hold user defined attribute map.
55 fr_connection_pool_t *pool; //!< Connection pool.
58 /* connection pool handle struct */
59 typedef struct rlm_couchbase_handle_t {
60 void *handle; //!< Real couchbase instance.
61 void *cookie; //!< Couchbase cookie.
62 } rlm_couchbase_handle_t;
64 /* define functions */
65 void *mod_conn_create(void *instance);
67 int mod_conn_alive(UNUSED void *instance, void *handle);
69 int mod_conn_delete(UNUSED void *instance, void *handle);
71 int mod_build_attribute_element_map(CONF_SECTION *conf, void *instance);
73 int mod_attribute_to_element(const char *name, json_object *map, void *buf);
75 void *mod_json_object_to_value_pairs(json_object *json, const char *section, REQUEST *request);
77 json_object *mod_value_pair_to_json_object(REQUEST *request, VALUE_PAIR *vp);
79 int mod_ensure_start_timestamp(json_object *json, VALUE_PAIR *vps);