public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
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 15:34:26 -0400	[thread overview]
Message-ID: <201204011534.27331.vapier@gentoo.org> (raw)
In-Reply-To: <1333197516-5138-3-git-send-email-michael@walle.cc>

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120401/e60aff6d/attachment.pgp>

  reply	other threads:[~2012-04-01 19:34 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 [this message]
2012-04-01 20:00     ` Michael Walle
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=201204011534.27331.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --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