All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations
redis_ippool.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _IPPOOL_RCODE_DEVICE_MISMATCH   -3
 
#define _IPPOOL_RCODE_EXPIRED   -2
 
#define _IPPOOL_RCODE_FAIL   -5
 
#define _IPPOOL_RCODE_NOT_FOUND   -1
 
#define _IPPOOL_RCODE_POOL_EMPTY   -4
 
#define _IPPOOL_RCODE_SUCCESS   0
 
#define IPADDR_LEN(_af)   ((_af == AF_UNSPEC) ? 0 : ((_af == AF_INET6) ? 128 : 32))
 
#define IPPOOL_ADDRESS_KEY   "ip"
 
#define IPPOOL_BUILD_IP_KEY(_buff, _p, _key, _key_len, _ip)
 Build the IP key {prefix}:ip. More...
 
#define IPPOOL_BUILD_KEY(_buff, _p, _key, _key_len)
 Wrap the prefix in {} and add the pool suffix. More...
 
#define IPPOOL_DEVICE_KEY   "device"
 
#define IPPOOL_MAX_IP_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_ADDRESS_KEY ":") - 1) + INET6_ADDRSTRLEN + 4
 {prefix}:ipaddr/prefix More...
 
#define IPPOOL_MAX_KEY_PREFIX_SIZE   128
 
#define IPPOOL_MAX_POOL_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_POOL_KEY) - 1) + 2
 {prefix}:pool More...
 
#define IPPOOL_POOL_KEY   "pool"
 
#define IPPOOL_SPRINT_IP(_buff, _ip, _prefix)
 If the prefix is as wide as the AF data size then print it without CIDR notation. More...
 

Enumerations

enum  ippool_action_t {
  POOL_ACTION_ALLOCATE = 1,
  POOL_ACTION_UPDATE = 2,
  POOL_ACTION_RELEASE = 3,
  POOL_ACTION_BULK_RELEASE = 4
}
 
enum  ippool_rcode_t {
  IPPOOL_RCODE_SUCCESS = _IPPOOL_RCODE_SUCCESS,
  IPPOOL_RCODE_NOT_FOUND = _IPPOOL_RCODE_NOT_FOUND,
  IPPOOL_RCODE_EXPIRED = _IPPOOL_RCODE_EXPIRED,
  IPPOOL_RCODE_DEVICE_MISMATCH = _IPPOOL_RCODE_DEVICE_MISMATCH,
  IPPOOL_RCODE_POOL_EMPTY = _IPPOOL_RCODE_POOL_EMPTY,
  IPPOOL_RCODE_FAIL = _IPPOOL_RCODE_FAIL
}
 

Macro Definition Documentation

#define _IPPOOL_RCODE_DEVICE_MISMATCH   -3

Definition at line 39 of file redis_ippool.h.

#define _IPPOOL_RCODE_EXPIRED   -2

Definition at line 38 of file redis_ippool.h.

#define _IPPOOL_RCODE_FAIL   -5

Definition at line 41 of file redis_ippool.h.

#define _IPPOOL_RCODE_NOT_FOUND   -1

Definition at line 37 of file redis_ippool.h.

#define _IPPOOL_RCODE_POOL_EMPTY   -4

Definition at line 40 of file redis_ippool.h.

#define _IPPOOL_RCODE_SUCCESS   0

Definition at line 36 of file redis_ippool.h.

#define IPADDR_LEN (   _af)    ((_af == AF_UNSPEC) ? 0 : ((_af == AF_INET6) ? 128 : 32))

Definition at line 73 of file redis_ippool.h.

#define IPPOOL_ADDRESS_KEY   "ip"

Definition at line 61 of file redis_ippool.h.

#define IPPOOL_BUILD_IP_KEY (   _buff,
  _p,
  _key,
  _key_len,
  _ip 
)
Value:
do { \
ssize_t _slen; \
*_p++ = '{'; \
memcpy(_p, _key, _key_len); \
_p += _key_len; \
_slen = strlcpy((char *)_p, "}:"IPPOOL_ADDRESS_KEY":", sizeof(_buff) - (_p - _buff)); \
if (is_truncated((size_t)_slen, sizeof(_buff) - (_p - _buff))) { \
REDEBUG("IP key too long"); \
goto finish; \
} \
_p += (size_t)_slen;\
_slen = fr_pair_value_snprint((char *)_p, sizeof(_buff) - (_p - _buff), _ip, '\0'); \
if (is_truncated((size_t)_slen, sizeof(_buff) - (_p - _buff))) { \
REDEBUG("IP key too long"); \
goto finish; \
} \
_p += (size_t)_slen;\
} while (0)
void size_t fr_pair_value_snprint(char *out, size_t outlen, VALUE_PAIR const *vp, char quote)
Print the value of an attribute to a string.
Definition: pair.c:2107
#define is_truncated(_ret, _max)
Definition: libradius.h:204
#define REDEBUG(fmt,...)
Definition: log.h:254
size_t strlcpy(char *dst, char const *src, size_t siz)
Definition: strlcpy.c:38
#define IPPOOL_ADDRESS_KEY
Definition: redis_ippool.h:61

Build the IP key {prefix}:ip.

Definition at line 92 of file redis_ippool.h.

#define IPPOOL_BUILD_KEY (   _buff,
  _p,
  _key,
  _key_len 
)
Value:
do { \
*_p++ = '{'; \
memcpy(_p, _key, _key_len); \
_p += _key_len; \
*_p++ = '}'; \
*_p++ = ':'; \
memcpy(_p, IPPOOL_POOL_KEY, sizeof(IPPOOL_POOL_KEY) - 1); \
_p += sizeof(IPPOOL_POOL_KEY) - 1; \
} while (0)
#define IPPOOL_POOL_KEY
Definition: redis_ippool.h:60

Wrap the prefix in {} and add the pool suffix.

Definition at line 78 of file redis_ippool.h.

#define IPPOOL_DEVICE_KEY   "device"

Definition at line 62 of file redis_ippool.h.

#define IPPOOL_MAX_IP_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_ADDRESS_KEY ":") - 1) + INET6_ADDRSTRLEN + 4

{prefix}:ipaddr/prefix

Definition at line 70 of file redis_ippool.h.

#define IPPOOL_MAX_KEY_PREFIX_SIZE   128

Definition at line 59 of file redis_ippool.h.

#define IPPOOL_MAX_POOL_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_POOL_KEY) - 1) + 2

{prefix}:pool

Definition at line 66 of file redis_ippool.h.

#define IPPOOL_POOL_KEY   "pool"

Definition at line 60 of file redis_ippool.h.

#define IPPOOL_SPRINT_IP (   _buff,
  _ip,
  _prefix 
)
Value:
do { \
if (_prefix == IPADDR_LEN((_ip)->af)) { \
inet_ntop((_ip)->af, &((_ip)->ipaddr), _buff, sizeof(_buff)); \
} else { \
uint8_t _net = (_ip)->prefix; \
(_ip)->prefix = _prefix; \
fr_inet_ntop_prefix(_buff, sizeof(_buff), _ip); \
(_ip)->prefix = _net; \
} \
} while (0)
char const * inet_ntop(int af, void const *src, char *dst, size_t cnt)
Definition: missing.c:538
char * fr_inet_ntop_prefix(char out[FR_IPADDR_PREFIX_STRLEN], size_t outlen, fr_ipaddr_t *addr)
Print a fr_ipaddr_t as a CIDR style network prefix.
Definition: inet.c:762
static char const * prefix
Definition: mainconfig.c:81
#define IPADDR_LEN(_af)
Definition: redis_ippool.h:73

If the prefix is as wide as the AF data size then print it without CIDR notation.

Definition at line 117 of file redis_ippool.h.

Enumeration Type Documentation

Enumerator
POOL_ACTION_ALLOCATE 
POOL_ACTION_UPDATE 
POOL_ACTION_RELEASE 
POOL_ACTION_BULK_RELEASE 

Definition at line 52 of file redis_ippool.h.

Enumerator
IPPOOL_RCODE_SUCCESS 
IPPOOL_RCODE_NOT_FOUND 
IPPOOL_RCODE_EXPIRED 
IPPOOL_RCODE_DEVICE_MISMATCH 
IPPOOL_RCODE_POOL_EMPTY 
IPPOOL_RCODE_FAIL 

Definition at line 43 of file redis_ippool.h.