Add helper function for generating random MAC addresses
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
fee354c74d
commit
4d8fb63799
2 changed files with 12 additions and 0 deletions
|
@ -846,3 +846,13 @@ void bin_clear_free(void *bin, size_t len)
|
|||
os_free(bin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int random_mac_addr(u8 *addr)
|
||||
{
|
||||
if (os_get_random(addr, ETH_ALEN) < 0)
|
||||
return -1;
|
||||
addr[0] &= 0xfe; /* unicast */
|
||||
addr[0] |= 0x02; /* locally administered */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -538,6 +538,8 @@ void int_array_add_unique(int **res, int a);
|
|||
void str_clear_free(char *str);
|
||||
void bin_clear_free(void *bin, size_t len);
|
||||
|
||||
int random_mac_addr(u8 *addr);
|
||||
|
||||
|
||||
/*
|
||||
* gcc 4.4 ends up generating strict-aliasing warnings about some very common
|
||||
|
|
Loading…
Reference in a new issue