mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
util: Add address type utils
This commit is contained in:
parent
ac819aea67
commit
9ef5f68d4b
16
src/util.c
16
src/util.c
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user