From: Michael Walle <michael@walle.cc>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/5] net: add helper to generate random mac address
Date: Sun, 1 Apr 2012 22:00:42 +0200 [thread overview]
Message-ID: <201204012200.42962.michael@walle.cc> (raw)
In-Reply-To: <201204011534.27331.vapier@gentoo.org>
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
next prev parent reply other threads:[~2012-04-01 20:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-31 12:38 [U-Boot] [PATCH 0/5 v3] Kirkwood: add lschlv2 and lsxhl board support Michael Walle
2012-03-31 12:38 ` [U-Boot] [PATCH 1/5] lib: add rand() function Michael Walle
2012-03-31 12:38 ` [U-Boot] [PATCH 2/5] net: add helper to generate random mac address Michael Walle
2012-04-01 19:34 ` Mike Frysinger
2012-04-01 20:00 ` Michael Walle [this message]
2012-04-02 5:39 ` Prafulla Wadaskar
2012-03-31 12:38 ` [U-Boot] [PATCH 3/5] net: add eth_setenv_enetaddr_by_index() Michael Walle
2012-04-02 5:42 ` Prafulla Wadaskar
2012-03-31 12:38 ` [U-Boot] [PATCH 4/5] Kirkwood: add lschlv2 and lsxhl board support Michael Walle
2012-03-31 12:38 ` [U-Boot] [PATCH 5/5] Kirkwood: automatically build kwb image for lsxl Michael Walle
2012-04-02 5:24 ` [U-Boot] [PATCH 0/5 v3] Kirkwood: add lschlv2 and lsxhl board support Prafulla Wadaskar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201204012200.42962.michael@walle.cc \
--to=michael@walle.cc \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox