From: Alan T. DeKok Date: Fri, 16 Apr 2021 19:56:55 +0000 (-0400) Subject: add "hint" function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6caffcb12629eea8e08eff74adc9aa370e06496;p=thirdparty%2Ffreeradius-server.git add "hint" function --- diff --git a/src/lib/util/htrie.h b/src/lib/util/htrie.h index c721f43f381..34c4a890830 100644 --- a/src/lib/util/htrie.h +++ b/src/lib/util/htrie.h @@ -30,6 +30,7 @@ extern "C" { #include #include #include +#include typedef struct fr_htrie_s fr_htrie_t; @@ -66,6 +67,7 @@ struct fr_htrie_s { }; typedef enum { + FR_HTRIE_INVALID = 0, FR_HTRIE_HASH = 0, //!< Data is stored in a hash. FR_HTRIE_RB, //!< Data is stored in a rb tree. FR_HTRIE_TRIE, //!< Data is stored in a prefix trie. @@ -126,6 +128,25 @@ static inline CC_HINT(nonnull) int fr_htrie_num_elements(fr_htrie_t *ht) return ht->funcs.num_elements(ht->store); } +static inline fr_htrie_type_t fr_htrie_hint(fr_type_t type) +{ + switch (type) { + case FR_TYPE_INTEGER: + case FR_TYPE_ETHERNET: + return FR_HTRIE_HASH; + + case FR_TYPE_IP: + return FR_HTRIE_TRIE; + + case FR_TYPE_STRING: + case FR_TYPE_OCTETS: + return FR_HTRIE_RB; + + default: + return FR_HTRIE_INVALID; + } +} + #ifdef __cplusplus } #endif