[U-Boot] [PATCH 06/30] net: get mac address from environment and use eth util funcs

Peter Tyser ptyser at xes-inc.com
Tue Feb 17 17:21:42 CET 2009


On Tue, 2009-02-17 at 00:10 -0500, Mike Frysinger wrote:
> Signed-off-by: Mike Frysinger <vapier at gentoo.org>
> CC: Ben Warren <biggerbadderben at gmail.com>
> ---
>  net/bootp.c |   13 ++-----------
>  net/net.c   |   17 +++++------------
>  2 files changed, 7 insertions(+), 23 deletions(-)
> 
> diff --git a/net/bootp.c b/net/bootp.c
> index d1cbd39..3dea70a 100644
> --- a/net/bootp.c
> +++ b/net/bootp.c
> @@ -573,21 +573,12 @@ BootpRequest (void)
>  #ifdef CONFIG_BOOTP_RANDOM_DELAY		/* Random BOOTP delay */
>  	unsigned char bi_enetaddr[6];
>  	int   reg;
> -	char  *e,*s;
> -	char tmp[64];
>  	ulong tst1, tst2, sum, m_mask, m_value = 0;
>  
>  	if (BootpTry ==0) {
>  		/* get our mac */
> -		reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
> -		s = (reg > 0) ? tmp : NULL;
> +		eth_getenv_enetaddr("ethaddr", bi_enetaddr);
>  
> -		for (reg=0; reg<6; ++reg) {
> -			bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
> -			if (s) {
> -				s = (*e) ? e+1 : e;
> -			}
> -		}
>  #ifdef DEBUG
>  		puts ("BootpRequest => Our Mac: ");
>  		for (reg=0; reg<6; reg++) {
> diff --git a/net/net.c b/net/net.c
> index 9740f38..3fe5cb8 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -330,7 +330,7 @@ restart:
>  #ifdef CONFIG_NET_MULTI
>  	memcpy (NetOurEther, eth_get_dev()->enetaddr, 6);
>  #else
> -	memcpy (NetOurEther, bd->bi_enetaddr, 6);
> +	eth_getenv_enetaddr("ethaddr", NetOurEther);
>  #endif
>  
>  	NetState = NETLOOP_CONTINUE;
> @@ -693,8 +693,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
>  	}
>  
>  #ifdef ET_DEBUG
> -	printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
> -		dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]);
> +	printf("sending UDP to %08lx/%pM\n", dest, ether);
>  #endif
>  
>  	pkt = (uchar *)NetTxPacket;
> @@ -915,11 +914,7 @@ int CDPSendTrigger(void)
>  #ifdef CONFIG_CDP_DEVICE_ID
>  	*s++ = htons(CDP_DEVICE_ID_TLV);
>  	*s++ = htons(CONFIG_CDP_DEVICE_ID);
> -	memset(buf, 0, sizeof(buf));
> -	sprintf(buf, CONFIG_CDP_DEVICE_ID_PREFIX "%02X%02X%02X%02X%02X%02X",
> -		NetOurEther[0] & 0xff, NetOurEther[1] & 0xff,
> -		NetOurEther[2] & 0xff, NetOurEther[3] & 0xff,
> -		NetOurEther[4] & 0xff, NetOurEther[5] & 0xff);
> +	sprintf(buf, "%pM", NetOurEther);
>  	memcpy((uchar *)s, buf, 16);
>  	s += 16 / 2;

It looks like CONFIG_CDP_DEVICE_ID_PREFIX was accidentally removed.  The
formatting of "%pM" will also have ':'s where the original field did
not.

Awesome changes!

Best,
Peter



More information about the U-Boot mailing list