The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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_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_OWNER_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_OWNER_KEY ":") - 1) + 128
 {prefix}:device More...
 
#define IPPOOL_MAX_POOL_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_POOL_KEY) - 1) + 2
 {prefix}:pool More...
 
#define IPPOOL_OWNER_KEY   "device"
 
#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...
 
#define IPPOOL_STATIC_BIT   0x10000000000000 /* A high bit which Redis ZSCORE will represent accurately*/
 

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

◆ _IPPOOL_RCODE_DEVICE_MISMATCH

#define _IPPOOL_RCODE_DEVICE_MISMATCH   -3

Definition at line 36 of file redis_ippool.h.

◆ _IPPOOL_RCODE_EXPIRED

#define _IPPOOL_RCODE_EXPIRED   -2

Definition at line 35 of file redis_ippool.h.

◆ _IPPOOL_RCODE_FAIL

#define _IPPOOL_RCODE_FAIL   -5

Definition at line 38 of file redis_ippool.h.

◆ _IPPOOL_RCODE_NOT_FOUND

#define _IPPOOL_RCODE_NOT_FOUND   -1

Definition at line 34 of file redis_ippool.h.

◆ _IPPOOL_RCODE_POOL_EMPTY

#define _IPPOOL_RCODE_POOL_EMPTY   -4

Definition at line 37 of file redis_ippool.h.

◆ _IPPOOL_RCODE_SUCCESS

#define _IPPOOL_RCODE_SUCCESS   0

Definition at line 33 of file redis_ippool.h.

◆ IPADDR_LEN

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

Definition at line 75 of file redis_ippool.h.

◆ IPPOOL_ADDRESS_KEY

#define IPPOOL_ADDRESS_KEY   "ip"

Definition at line 58 of file redis_ippool.h.

◆ IPPOOL_BUILD_IP_KEY

#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_print_value_quoted(&FR_SBUFF_OUT((char *)_p, sizeof(_buff) - (_p - _buff)), _ip, T_BARE_WORD); \
if (_slen < 0) { \
REDEBUG("IP key too long"); \
goto finish; \
} \
_p += (size_t)_slen;\
} while (0)
unsigned long int size_t
Definition: merged_model.c:25
#define is_truncated(_ret, _max)
Definition: print.h:48
@ IPPOOL_RCODE_FAIL
Definition: redis_ippool.h:46
#define IPPOOL_ADDRESS_KEY
Definition: redis_ippool.h:58
#define FR_SBUFF_OUT(_start, _len_or_end)
size_t strlcpy(char *dst, char const *src, size_t siz)
Definition: strlcpy.c:34
@ T_BARE_WORD
Definition: token.h:120
ssize_t fr_pair_print_value_quoted(fr_sbuff_t *out, fr_pair_t const *vp, fr_token_t quote)
Print the value of an attribute to a string.
Definition: pair_print.c:40

Build the IP key {prefix}:ip.

Definition at line 94 of file redis_ippool.h.

◆ IPPOOL_BUILD_KEY

#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:57

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

Definition at line 80 of file redis_ippool.h.

◆ IPPOOL_MAX_IP_KEY_SIZE

#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 68 of file redis_ippool.h.

◆ IPPOOL_MAX_KEY_PREFIX_SIZE

#define IPPOOL_MAX_KEY_PREFIX_SIZE   128

Definition at line 56 of file redis_ippool.h.

◆ IPPOOL_MAX_OWNER_KEY_SIZE

#define IPPOOL_MAX_OWNER_KEY_SIZE   IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_OWNER_KEY ":") - 1) + 128

{prefix}:device

Definition at line 72 of file redis_ippool.h.

◆ IPPOOL_MAX_POOL_KEY_SIZE

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

{prefix}:pool

Definition at line 64 of file redis_ippool.h.

◆ IPPOOL_OWNER_KEY

#define IPPOOL_OWNER_KEY   "device"

Definition at line 59 of file redis_ippool.h.

◆ IPPOOL_POOL_KEY

#define IPPOOL_POOL_KEY   "pool"

Definition at line 57 of file redis_ippool.h.

◆ IPPOOL_SPRINT_IP

#define IPPOOL_SPRINT_IP (   _buff,
  _ip,
  _prefix 
)
Value:
do { \
if (_prefix == IPADDR_LEN((_ip)->af)) { \
inet_ntop((_ip)->af, &((_ip)->addr), _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)
#define IPADDR_LEN(_af)
Definition: redis_ippool.h:75

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

Definition at line 119 of file redis_ippool.h.

◆ IPPOOL_STATIC_BIT

#define IPPOOL_STATIC_BIT   0x10000000000000 /* A high bit which Redis ZSCORE will represent accurately*/

Definition at line 60 of file redis_ippool.h.

Enumeration Type Documentation

◆ ippool_action_t

Enumerator
POOL_ACTION_ALLOCATE 
POOL_ACTION_UPDATE 
POOL_ACTION_RELEASE 
POOL_ACTION_BULK_RELEASE 

Definition at line 49 of file redis_ippool.h.

◆ ippool_rcode_t

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 40 of file redis_ippool.h.