3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

util: Add address type utils

This commit is contained in:
Andrew Zaborowski 2017-09-22 05:06:23 +02:00 committed by Denis Kenzior
parent ac819aea67
commit 9ef5f68d4b
2 changed files with 18 additions and 0 deletions

View File

@ -131,3 +131,19 @@ bool util_string_to_address(const char *str, uint8_t *addr)
return true;
}
bool util_is_group_address(const uint8_t *addr)
{
/* 802.11-2016 section 9.2.2 */
return util_is_bit_set(addr[0], 0);
}
bool util_is_broadcast_address(const uint8_t *addr)
{
/* 802.11-2016 section 9.2.4.3 */
static const uint8_t bcast_addr[6] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
return !memcmp(addr, bcast_addr, 6);
}

View File

@ -36,6 +36,8 @@ const char *util_ssid_to_utf8(size_t len, const uint8_t *ssid);
bool util_ssid_is_utf8(size_t len, const uint8_t *ssid);
const char *util_address_to_string(const uint8_t *addr);
bool util_string_to_address(const char *str, uint8_t *addr);
bool util_is_group_address(const uint8_t *addr);
bool util_is_broadcast_address(const uint8_t *addr);
static inline uint8_t util_bit_field(const uint8_t oct, int start, int num)
{