29 #ifndef LIBFREERADIUS_REDIS_H
30 #define LIBFREERADIUS_REDIS_H
32 RCSIDH(redis_h,
"$Id: 4d2fb9c1cc2b625064923f60994cc2b2507a7af7 $")
34 #include <freeradius-devel/radiusd.h>
35 #include <hiredis/hiredis.h>
37 #define MAX_REDIS_COMMAND_LEN 4096
38 #define MAX_REDIS_ARGS 16
40 #define REDIS_ERROR_MOVED_STR "MOVED"
41 #define REDIS_ERROR_ASK_STR "ASK"
42 #define REDIS_ERROR_TRY_AGAIN_STR "TRYAGAIN"
43 #define REDIS_ERROR_NO_SCRIPT_STR "NOSCRIPT"
44 #define REDIS_DEFAULT_PORT 6379
56 #define fr_redis_reply_free(_p) if (_p) freeReplyObject(_p)
106 #define REDIS_COMMON_CONFIG \
107 { FR_CONF_OFFSET("server", PW_TYPE_STRING | PW_TYPE_REQUIRED | PW_TYPE_MULTI, fr_redis_conf_t, hostname) }, \
108 { FR_CONF_OFFSET("port", PW_TYPE_SHORT, fr_redis_conf_t, port), .dflt = "6379" }, \
109 { FR_CONF_OFFSET("database", PW_TYPE_INTEGER, fr_redis_conf_t, database), .dflt = "0" }, \
110 { FR_CONF_OFFSET("password", PW_TYPE_STRING | PW_TYPE_SECRET, fr_redis_conf_t, password) }, \
111 { FR_CONF_OFFSET("max_nodes", PW_TYPE_BYTE, fr_redis_conf_t, max_nodes), .dflt = "20" }, \
112 { FR_CONF_OFFSET("max_alt", PW_TYPE_INTEGER, fr_redis_conf_t, max_alt), .dflt = "3" }, \
113 { FR_CONF_OFFSET("max_redirects", PW_TYPE_INTEGER, fr_redis_conf_t, max_redirects), .dflt = "2" }
128 REQUEST *request, redisReply *key, redisReply *op, redisReply *value);
142 #define fr_redis_pipeline_free(_r, _n) \
145 for (_i = 0; _i < _n; _i++) {\
146 fr_redis_reply_free(_r[_i]); \
char const ** hostname
of Redis server.
fr_redis_rcode_t fr_redis_pipeline_result(fr_redis_rcode_t *rcode, redisReply *out[], size_t out_len, fr_redis_conn_t *conn, int pipelined)
Simplifies handling of pipelined commands with Redis cluster.
int fr_redis_reply_to_value_data(TALLOC_CTX *ctx, value_data_t *out, redisReply *reply, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv)
Convert a string or integer type to value_data_t of specified type.
Configuration parameters for a redis connection.
const FR_NAME_NUMBER redis_reply_types[]
uint32_t fr_redis_version_num(char const *version)
Convert version string into a 32bit unsigned integer for comparisons.
char const * prefix
Logging prefix for errors in fr_redis_cluster_conn_create.
uint32_t database
number on Redis server.
int fr_redis_tuple_from_map(TALLOC_CTX *pool, char const *out[], size_t out_len[], vp_map_t *map)
Add a single map pair to an existing command string as three elements.
fr_redis_rcode_t fr_redis_get_version(char *out, size_t out_len, fr_redis_conn_t *conn)
Get the version of Redis running on the remote server.
redisContext * handle
Hiredis context used when issuing commands.
Unrecoverable library/server error.
const FR_NAME_NUMBER redis_rcodes[]
Attempt operation on an alternative node.
uint16_t port
of Redis daemon.
void fr_redis_reply_print(log_lvl_t lvl, redisReply *reply, REQUEST *request, int idx)
Print the response data in a useful treelike form.
char const * password
to authenticate to Redis.
uint32_t max_alt
Maximum alternative nodes to try.
uint32_t max_retries
Maximum number of times we attempt a command when receiving successive -TRYAGAIN messages.
Attempt operation on an alternative node with remap.
uint8_t max_nodes
Maximum number of cluster nodes to connect to.
void fr_redis_version_print(void)
Print the version of libhiredis the server was built against.
Transitory error, caller should retry the operation with a new connection.
uint32_t max_redirects
Maximum number of times we can be redirected.
struct redis_conn fr_redis_conn_t
Connection handle, holding a redis context.
fr_redis_rcode_t
Codes are ordered inversely by priority.
struct redis_common_conf fr_redis_conf_t
Configuration parameters for a redis connection.
struct timeval retry_delay
How long to wait when we received a -TRYAGAIN message.
Operation was successfull.
fr_redis_rcode_t fr_redis_command_status(fr_redis_conn_t *conn, redisReply *reply)
Check the reply for errors.
int fr_redis_reply_to_map(TALLOC_CTX *ctx, vp_map_t **out, REQUEST *request, redisReply *key, redisReply *op, redisReply *value)
Convert a pair of redis reply objects to a map.
Connection handle, holding a redis context.
PW_TYPE
Internal data types used within libfreeradius.