1 /* 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. 6 * 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. 11 * 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 15 */ 16 17 /** 18 * $Id: 3cf9a31c1115a183fbb9dfd83727b285610fd5de $ 19 * 20 * @brief Function prototypes and datatypes used in the module. 21 * @file mod.h 22 * 23 * @author Aaron Hurt <ahurt@anbcs.com> 24 * @copyright 2013-2014 The FreeRADIUS Server Project. 25 */ 26 27 #ifndef _mod_h_ 28 #define _mod_h_ 29 30 RCSIDH(mod_h, "$Id: 3cf9a31c1115a183fbb9dfd83727b285610fd5de $") 31 32 #include <freeradius-devel/radiusd.h> 33 34 #include "couchbase.h" 35 #include "jsonc_missing.h" 36 37 /* maximum size of a stored value */ 38 #define MAX_VALUE_SIZE 20480 39 40 /* maximum length of a document key */ 41 #define MAX_KEY_SIZE 250 42 43 /** The main module instance 44 * 45 * This struct contains the core module configuration. 46 */ 47 typedef struct rlm_couchbase_t { 48 char const *acct_key; //!< Accounting document key. 49 char const *doctype; //!< Value of accounting 'docType' element name. 50 uint32_t expire; //!< Accounting document expire time in seconds. 51 52 char const *server_raw; //!< Raw server string before parsing. 53 char const *server; //!< Couchbase server list. 54 char const *bucket; //!< Couchbase bucket. 55 char const *password; //!< Couchbase bucket password. 56 57 const char *user_key; //!< User document key. 58 59 bool read_clients; //!< Toggle for loading client records. 60 const char *client_view; //!< Couchbase view that returns client documents. 61 62 bool check_simul; //!< Toggle to enable simultaneous use checking. 63 const char *simul_view; //!< Couchbase view that returns accounting documents. 64 65 bool verify_simul; //!< Toggle to enable user login state verification. 66 const char *simul_vkey; //!< The query key to be used with simul_view. 67 bool delete_stale_sessions; //!< Toggle to trigger zapping of stale sessions. 68 bool raw_value; //!< Print raw values rather than resolving enums 69 70 json_object *map; //!< Json object to hold user defined attribute map. 71 fr_connection_pool_t *pool; //!< Connection pool. 72 } rlm_couchbase_t; 73 74 /** Couchbase instance specific information 75 * 76 * This struct contains the Couchbase connection handle as well as a 77 * cookie pointer to store fetched document payloads. 78 */ 79 typedef struct rlm_couchbase_handle_t { 80 void *handle; //!< Real couchbase instance. 81 void *cookie; //!< Couchbase cookie (@p cookie_u @p cookie_t). 82 } rlm_couchbase_handle_t; 83 84 /* define functions */ 85 void *mod_conn_create(TALLOC_CTX *ctx, void *instance); 86 87 int mod_build_attribute_element_map(CONF_SECTION *conf, void *instance); 88 89 int mod_attribute_to_element(const char *name, json_object *map, void *buf); 90 91 void *mod_json_object_to_value_pairs(json_object *json, const char *section, REQUEST *request); 92 93 json_object *mod_value_pair_to_json_object(REQUEST *request, VALUE_PAIR *vp, bool raw_value); 94 95 int mod_ensure_start_timestamp(json_object *json, VALUE_PAIR *vps); 96 97 int mod_client_map_section(CONF_SECTION *client, CONF_SECTION const *map, json_object *json, char const *docid); 98 99 int mod_load_client_documents(rlm_couchbase_t *inst, CONF_SECTION *tmpl, CONF_SECTION *map); 100 101 #endif /* _mod_h_ */ 102