X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=net%2Fnet.c;h=1d1c98f3c20204c74ef3173b50537e21af8c60cd;hb=197b049b8b8a488384f351b988dd15f78830ba4e;hp=11b770004b11c2cde847b2190307039ab49689e1;hpb=e1b7296126bc22825950c24343302205228bdb8d;p=u-boot diff --git a/net/net.c b/net/net.c index 11b770004b..1d1c98f3c2 100644 --- a/net/net.c +++ b/net/net.c @@ -92,6 +92,8 @@ #if (CONFIG_COMMANDS & CFG_CMD_NET) +DECLARE_GLOBAL_DATA_PTR; + #define ARP_TIMEOUT 5 /* Seconds before trying ARP again */ #ifndef CONFIG_NET_RETRY_COUNT # define ARP_TIMEOUT_COUNT 5 /* # of timeouts before giving up */ @@ -222,8 +224,10 @@ void ArpRequest (void) (NetOurIP & NetOurSubnetMask)) { if (NetOurGatewayIP == 0) { puts ("## Warning: gatewayip needed but not set\n"); + NetArpWaitReplyIP = NetArpWaitPacketIP; + } else { + NetArpWaitReplyIP = NetOurGatewayIP; } - NetArpWaitReplyIP = NetOurGatewayIP; } else { NetArpWaitReplyIP = NetArpWaitPacketIP; } @@ -264,8 +268,6 @@ void ArpTimeoutCheck(void) int NetLoop(proto_t protocol) { - DECLARE_GLOBAL_DATA_PTR; - bd_t *bd = gd->bd; #ifdef CONFIG_NET_MULTI @@ -461,7 +463,7 @@ restart: /* * Echo the inverted link state to the fault LED. */ - if(miiphy_link(CFG_FAULT_MII_ADDR)) { + if(miiphy_link(eth_get_dev()->name, CFG_FAULT_MII_ADDR)) { status_led_set (STATUS_LED_RED, STATUS_LED_OFF); } else { status_led_set (STATUS_LED_RED, STATUS_LED_ON); @@ -512,7 +514,7 @@ restart: /* * Echo the inverted link state to the fault LED. */ - if(miiphy_link(CFG_FAULT_MII_ADDR)) { + if(miiphy_link(eth_get_dev()->name, CFG_FAULT_MII_ADDR)) { status_led_set (STATUS_LED_RED, STATUS_LED_OFF); } else { status_led_set (STATUS_LED_RED, STATUS_LED_ON); @@ -570,9 +572,6 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len) void NetStartAgain (void) { -#ifdef CONFIG_NET_MULTI - DECLARE_GLOBAL_DATA_PTR; -#endif char *nretry; int noretry = 0, once = 0; @@ -810,6 +809,7 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len) int odd; ulong result = 0; ushort leftover; + ushort *p; if (len > 0) { odd = 1 & (ulong)buff; @@ -819,14 +819,19 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len) buff++; } while (len > 1) { - result += *((const ushort *)buff)++; + p = (ushort *)buff; + result += *p++; + buff = (uchar *)p; if (result & 0x80000000) result = (result & 0xFFFF) + (result >> 16); len -= 2; } if (len) { leftover = (signed short)(*(const signed char *)buff); - /* * XXX CISCO SUCKS big time! (and blows too) */ + /* CISCO SUCKS big time! (and blows too): + * CDP uses the IP checksum algorithm with a twist; + * for the last byte it *sign* extends and sums. + */ result = (result & 0xffff0000) | ((result + leftover) & 0x0000ffff); } while (result >> 16) @@ -1655,7 +1660,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len) ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2); } -void copy_filename (uchar *dst, uchar *src, int size) +void copy_filename (char *dst, char *src, int size) { if (*src && (*src == '"')) { ++src;