ether-addr-util: split out logic to mark MAC addresses as random
This commit is contained in:
committed by
Yu Watanabe
parent
32c376a46c
commit
e22ca70008
@@ -270,3 +270,11 @@ int parse_ether_addr(const char *s, struct ether_addr *ret) {
|
||||
*ret = a.ether;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ether_addr_mark_random(struct ether_addr *addr) {
|
||||
assert(addr);
|
||||
|
||||
/* see eth_random_addr in the kernel */
|
||||
addr->ether_addr_octet[0] &= 0xfe; /* clear multicast bit */
|
||||
addr->ether_addr_octet[0] |= 0x02; /* set local assignment bit (IEEE802) */
|
||||
}
|
||||
|
||||
@@ -113,3 +113,5 @@ static inline bool ether_addr_is_global(const struct ether_addr *addr) {
|
||||
|
||||
extern const struct hash_ops ether_addr_hash_ops;
|
||||
extern const struct hash_ops ether_addr_hash_ops_free;
|
||||
|
||||
void ether_addr_mark_random(struct ether_addr *addr);
|
||||
|
||||
Reference in New Issue
Block a user