From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Walle Date: Sun, 1 Apr 2012 22:00:42 +0200 Subject: [U-Boot] [PATCH 2/5] net: add helper to generate random mac address In-Reply-To: <201204011534.27331.vapier@gentoo.org> References: <1333197516-5138-1-git-send-email-michael@walle.cc> <1333197516-5138-3-git-send-email-michael@walle.cc> <201204011534.27331.vapier@gentoo.org> Message-ID: <201204012200.42962.michael@walle.cc> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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