[U-Boot] [PATCH 2/5] net: add helper to generate random mac address

Michael Walle michael at walle.cc
Sun Apr 1 22:00:42 CEST 2012


Hi Mike,

Am Sonntag 01 April 2012, 21:34:26 schrieb Mike Frysinger:
> 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"
thanks ;)

> > +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 ?
couldn't find anything about OUIs and locally administered mac addresses, 
therefore i set the OUI to 0. But as this mac generation only applies to 
emergency cases, i guess it is better to have a smaller chance of duplicate 
mac addresses. 

> and if you add a 2nd rand() call, you
> could seed all 48bits easily.
yes, i'll rework that.

-- 
Michael


More information about the U-Boot mailing list