utils: Add util_netmask_from_prefix

This commit is contained in:
Andrew Zaborowski 2021-02-26 17:17:25 +01:00 committed by Denis Kenzior
parent b689100c1c
commit e714e72e05
1 changed files with 5 additions and 0 deletions

View File

@ -110,4 +110,9 @@ static inline uint32_t util_secure_fill_with_msb(uint32_t val)
bool util_ip_prefix_tohl(const char *ip, uint8_t *prefix, uint32_t *start_out,
uint32_t *end_out, uint32_t *mask_out);
static inline uint32_t util_netmask_from_prefix(uint8_t prefix_len)
{
return ~((1ull << (32 - prefix_len)) - 1);
}
#endif /* __UTIL_H */