28RCSIDH(redis_ippool_h,
"$Id: 31f45df57f6ae956d692be5048c904442b170ace $")
33#define _IPPOOL_RCODE_SUCCESS 0
34#define _IPPOOL_RCODE_NOT_FOUND -1
35#define _IPPOOL_RCODE_EXPIRED -2
36#define _IPPOOL_RCODE_DEVICE_MISMATCH -3
37#define _IPPOOL_RCODE_POOL_EMPTY -4
38#define _IPPOOL_RCODE_FAIL -5
56#define IPPOOL_MAX_KEY_PREFIX_SIZE 128
57#define IPPOOL_POOL_KEY "pool"
58#define IPPOOL_ADDRESS_KEY "ip"
59#define IPPOOL_OWNER_KEY "device"
60#define IPPOOL_STATIC_BIT 0x10000000000000
64#define IPPOOL_MAX_POOL_KEY_SIZE IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_POOL_KEY) - 1) + 2
68#define IPPOOL_MAX_IP_KEY_SIZE IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_ADDRESS_KEY ":") - 1) + INET6_ADDRSTRLEN + 4
72#define IPPOOL_MAX_OWNER_KEY_SIZE IPPOOL_MAX_KEY_PREFIX_SIZE + (sizeof("{}:" IPPOOL_OWNER_KEY ":") - 1) + 128
75#define IPADDR_LEN(_af) ((_af == AF_UNSPEC) ? 0 : ((_af == AF_INET6) ? 128 : 32))
80#define IPPOOL_BUILD_KEY(_buff, _p, _key, _key_len) \
83 memcpy(_p, _key, _key_len); \
87 memcpy(_p, IPPOOL_POOL_KEY, sizeof(IPPOOL_POOL_KEY) - 1); \
88 _p += sizeof(IPPOOL_POOL_KEY) - 1; \
94#define IPPOOL_BUILD_IP_KEY(_buff, _p, _key, _key_len, _ip) \
98 memcpy(_p, _key, _key_len); \
100 _slen = strlcpy((char *)_p, "}:"IPPOOL_ADDRESS_KEY":", sizeof(_buff) - (_p - _buff)); \
101 if (is_truncated((size_t)_slen, sizeof(_buff) - (_p - _buff))) { \
102 REDEBUG("IP key too long"); \
103 ret = IPPOOL_RCODE_FAIL; \
106 _p += (size_t)_slen;\
107 _slen = fr_pair_print_value_quoted(&FR_SBUFF_OUT((char *)_p, sizeof(_buff) - (_p - _buff)), _ip, T_BARE_WORD); \
109 REDEBUG("IP key too long"); \
110 ret = IPPOOL_RCODE_FAIL; \
113 _p += (size_t)_slen;\
119#define IPPOOL_SPRINT_IP(_buff, _ip, _prefix) \
121 if (_prefix == IPADDR_LEN((_ip)->af)) { \
122 inet_ntop((_ip)->af, &((_ip)->addr), _buff, sizeof(_buff)); \
124 uint8_t _net = (_ip)->prefix; \
125 (_ip)->prefix = _prefix; \
126 fr_inet_ntop_prefix(_buff, sizeof(_buff), _ip); \
127 (_ip)->prefix = _net; \
#define _IPPOOL_RCODE_NOT_FOUND
@ POOL_ACTION_BULK_RELEASE
#define _IPPOOL_RCODE_FAIL
#define _IPPOOL_RCODE_POOL_EMPTY
#define _IPPOOL_RCODE_EXPIRED
@ IPPOOL_RCODE_DEVICE_MISMATCH
@ IPPOOL_RCODE_POOL_EMPTY
#define _IPPOOL_RCODE_DEVICE_MISMATCH
#define _IPPOOL_RCODE_SUCCESS