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 <libcouchbase/couchbase.h>
32 #include <json/json.h>
34 #include "jsonc_missing.h"
36 /* maximum size of a stored value */
37 #define MAX_VALUE_SIZE 20480
39 /* maximum length of a document key */
40 #define MAX_KEY_SIZE 250
42 /* configuration struct */
43 typedef struct rlm_couchbase_t {
44 char const *acct_key; //!< Accounting document key.
45 char const *doctype; //!< Value of 'docType' element name.
46 char const *server_raw; //!< Raw server string before parsing.
47 char const *server; //!< Couchbase server list.
48 char const *bucket; //!< Couchbase bucket.
49 char const *password; //!< Couchbase bucket password.
50 uint32_t expire; //!< Document expire time in seconds.
51 const char *user_key; //!< User document key.
52 json_object *map; //!< Json object to hold user defined attribute map.
53 fr_connection_pool_t *pool; //!< Connection pool.
56 /* connection pool handle struct */
57 typedef struct rlm_couchbase_handle_t {
58 void *handle; //!< Real couchbase instance.
59 void *cookie; //!< Couchbase cookie.
60 } rlm_couchbase_handle_t;
62 /* define functions */
63 void *mod_conn_create(void *instance);
65 int mod_conn_alive(UNUSED void *instance, void *handle);
67 int mod_conn_delete(UNUSED void *instance, void *handle);
69 int mod_build_attribute_element_map(CONF_SECTION *conf, void *instance);
71 int mod_attribute_to_element(const char *name, json_object *map, void *buf);
73 void *mod_json_object_to_value_pairs(json_object *json, const char *section, REQUEST *request);
75 json_object *mod_value_pair_to_json_object(REQUEST *request, VALUE_PAIR *vp);
77 int mod_ensure_start_timestamp(json_object *json, VALUE_PAIR *vps);