Commit 95823ca0773356860e622ee3304a4b7cafcbf19a
Committed by
Wolfgang Denk
1 parent
500b6c51e4
net: get mac address from environment and use eth util funcs
Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com>
Showing 2 changed files with 6 additions and 22 deletions Side-by-side Diff
net/bootp.c
... | ... | @@ -573,21 +573,12 @@ |
573 | 573 | #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */ |
574 | 574 | unsigned char bi_enetaddr[6]; |
575 | 575 | int reg; |
576 | - char *e,*s; | |
577 | - char tmp[64]; | |
578 | 576 | ulong tst1, tst2, sum, m_mask, m_value = 0; |
579 | 577 | |
580 | 578 | if (BootpTry ==0) { |
581 | 579 | /* get our mac */ |
582 | - reg = getenv_r ("ethaddr", tmp, sizeof(tmp)); | |
583 | - s = (reg > 0) ? tmp : NULL; | |
580 | + eth_getenv_enetaddr("ethaddr", bi_enetaddr); | |
584 | 581 | |
585 | - for (reg=0; reg<6; ++reg) { | |
586 | - bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0; | |
587 | - if (s) { | |
588 | - s = (*e) ? e+1 : e; | |
589 | - } | |
590 | - } | |
591 | 582 | #ifdef DEBUG |
592 | 583 | puts ("BootpRequest => Our Mac: "); |
593 | 584 | for (reg=0; reg<6; reg++) { |
net/net.c
... | ... | @@ -404,7 +404,7 @@ |
404 | 404 | #ifdef CONFIG_NET_MULTI |
405 | 405 | memcpy (NetOurEther, eth_get_dev()->enetaddr, 6); |
406 | 406 | #else |
407 | - memcpy (NetOurEther, bd->bi_enetaddr, 6); | |
407 | + eth_getenv_enetaddr("ethaddr", NetOurEther); | |
408 | 408 | #endif |
409 | 409 | |
410 | 410 | NetState = NETLOOP_CONTINUE; |
... | ... | @@ -709,8 +709,7 @@ |
709 | 709 | } |
710 | 710 | |
711 | 711 | #ifdef ET_DEBUG |
712 | - printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n", | |
713 | - dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]); | |
712 | + printf("sending UDP to %08lx/%pM\n", dest, ether); | |
714 | 713 | #endif |
715 | 714 | |
716 | 715 | pkt = (uchar *)NetTxPacket; |
... | ... | @@ -931,11 +930,7 @@ |
931 | 930 | #ifdef CONFIG_CDP_DEVICE_ID |
932 | 931 | *s++ = htons(CDP_DEVICE_ID_TLV); |
933 | 932 | *s++ = htons(CONFIG_CDP_DEVICE_ID); |
934 | - memset(buf, 0, sizeof(buf)); | |
935 | - sprintf(buf, CONFIG_CDP_DEVICE_ID_PREFIX "%02X%02X%02X%02X%02X%02X", | |
936 | - NetOurEther[0] & 0xff, NetOurEther[1] & 0xff, | |
937 | - NetOurEther[2] & 0xff, NetOurEther[3] & 0xff, | |
938 | - NetOurEther[4] & 0xff, NetOurEther[5] & 0xff); | |
933 | + sprintf(buf, CONFIG_CDP_DEVICE_ID_PREFIX "%pm", NetOurEther); | |
939 | 934 | memcpy((uchar *)s, buf, 16); |
940 | 935 | s += 16 / 2; |
941 | 936 | #endif |
... | ... | @@ -1335,10 +1330,8 @@ |
1335 | 1330 | if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC) |
1336 | 1331 | break; |
1337 | 1332 | #ifdef ET_DEBUG |
1338 | - printf("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n", | |
1339 | - arp->ar_data[0], arp->ar_data[1], | |
1340 | - arp->ar_data[2], arp->ar_data[3], | |
1341 | - arp->ar_data[4], arp->ar_data[5]); | |
1333 | + printf("Got ARP REPLY, set server/gtwy eth addr (%pM)\n", | |
1334 | + arp->ar_data); | |
1342 | 1335 | #endif |
1343 | 1336 | |
1344 | 1337 | tmp = NetReadIP(&arp->ar_data[6]); |