|
@@ -20,6 +20,7 @@
|
20
|
20
|
FILE_LICENCE ( GPL2_OR_LATER );
|
21
|
21
|
|
22
|
22
|
#include <stdint.h>
|
|
23
|
+#include <stdlib.h>
|
23
|
24
|
#include <stdio.h>
|
24
|
25
|
#include <string.h>
|
25
|
26
|
#include <byteswap.h>
|
|
@@ -112,6 +113,21 @@ void eth_init_addr ( const void *hw_addr, void *ll_addr ) {
|
112
|
113
|
memcpy ( ll_addr, hw_addr, ETH_ALEN );
|
113
|
114
|
}
|
114
|
115
|
|
|
116
|
+/**
|
|
117
|
+ * Generate random Ethernet address
|
|
118
|
+ *
|
|
119
|
+ * @v hw_addr Generated hardware address
|
|
120
|
+ */
|
|
121
|
+void eth_random_addr ( void *hw_addr ) {
|
|
122
|
+ uint8_t *addr = hw_addr;
|
|
123
|
+ unsigned int i;
|
|
124
|
+
|
|
125
|
+ for ( i = 0 ; i < ETH_ALEN ; i++ )
|
|
126
|
+ addr[i] = random();
|
|
127
|
+ addr[0] &= ~0x01; /* Clear multicast bit */
|
|
128
|
+ addr[0] |= 0x02; /* Set locally-assigned bit */
|
|
129
|
+}
|
|
130
|
+
|
115
|
131
|
/**
|
116
|
132
|
* Transcribe Ethernet address
|
117
|
133
|
*
|