
1 Apr
2012
1 Apr
'12
9:34 p.m.
On Saturday 31 March 2012 08:38:33 Michael Walle wrote:
--- a/include/net.h +++ b/include/net.h
in emergency cases, where you need a working network connection to seti
"seti" -> "set"
- Eg. you wan't a rescue boot and don't have a serial port to access
"wan't" -> "want"
+void eth_random_enetaddr(uchar *enetaddr) +{
- uint32_t rval;
- srand(get_timer(0));
- rval = rand();
- enetaddr[0] = 0x02; /* locally administered */
- enetaddr[1] = 0x00;
- enetaddr[2] = 0x00;
- enetaddr[3] = rval & 0xff;
- enetaddr[4] = (rval >> 8) & 0xff;
- enetaddr[5] = (rval >> 16) & 0xff;
why only extract 24 of the 32bits ? and if you add a 2nd rand() call, you could seed all 48bits easily.
then to make sure the first byte is correct, you finish off with: /* make sure it's local and unicast */ enetaddr[0] = (enetaddr[0] | 0x02) & ~0x01; -mike