projects
/
mech_eap.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fee354c
)
Add helper function for generating random MAC addresses
author
Jouni Malinen
<j@w1.fi>
Sat, 27 Sep 2014 16:12:02 +0000
(19:12 +0300)
committer
Jouni Malinen
<j@w1.fi>
Sat, 27 Sep 2014 16:12:02 +0000
(19:12 +0300)
Signed-off-by: Jouni Malinen <j@w1.fi>
src/utils/common.c
patch
|
blob
|
history
src/utils/common.h
patch
|
blob
|
history
diff --git
a/src/utils/common.c
b/src/utils/common.c
index
5b017e5
..
c740830
100644
(file)
--- a/
src/utils/common.c
+++ b/
src/utils/common.c
@@
-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;
+}
diff --git
a/src/utils/common.h
b/src/utils/common.h
index
2bc8fe1
..
1a191d2
100644
(file)
--- a/
src/utils/common.h
+++ b/
src/utils/common.h
@@
-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