Add helper function for generating random MAC addresses with same OUI
random_mac_addr_keep_oui() is similar to random_mac_addr(), but it maintains the OUI part of the source address. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
c1d1b6998d
commit
1cbdb9d137
2 changed files with 11 additions and 0 deletions
|
@ -856,3 +856,13 @@ int random_mac_addr(u8 *addr)
|
||||||
addr[0] |= 0x02; /* locally administered */
|
addr[0] |= 0x02; /* locally administered */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int random_mac_addr_keep_oui(u8 *addr)
|
||||||
|
{
|
||||||
|
if (os_get_random(addr + 3, 3) < 0)
|
||||||
|
return -1;
|
||||||
|
addr[0] &= 0xfe; /* unicast */
|
||||||
|
addr[0] |= 0x02; /* locally administered */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -539,6 +539,7 @@ void str_clear_free(char *str);
|
||||||
void bin_clear_free(void *bin, size_t len);
|
void bin_clear_free(void *bin, size_t len);
|
||||||
|
|
||||||
int random_mac_addr(u8 *addr);
|
int random_mac_addr(u8 *addr);
|
||||||
|
int random_mac_addr_keep_oui(u8 *addr);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue