mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-10 04:26:19 -04:00
Add UPD-Checksum code, fix problem in net.c (return instead of break)
Patch by Reinhard Arlt, 12 Aug 2005
This commit is contained in:
parent
5315dfa9d1
commit
8534bf9ac0
@ -2,6 +2,9 @@
|
|||||||
Changes for U-Boot 1.1.3:
|
Changes for U-Boot 1.1.3:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
* Add UPD-Checksum code, fix problem in net.c (return instead of break)
|
||||||
|
Patch by Reinhard Arlt, 12 Aug 2005
|
||||||
|
|
||||||
* esd PCI405 board updated
|
* esd PCI405 board updated
|
||||||
Patch by Matthias Fuchs, 28 Jul 2005
|
Patch by Matthias Fuchs, 28 Jul 2005
|
||||||
|
|
||||||
|
44
net/net.c
44
net/net.c
@ -1410,7 +1410,7 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
puts (" ICMP Host Redirect to ");
|
puts (" ICMP Host Redirect to ");
|
||||||
print_IPaddr(icmph->un.gateway);
|
print_IPaddr(icmph->un.gateway);
|
||||||
putc(' ');
|
putc(' ');
|
||||||
break;
|
return;
|
||||||
#if (CONFIG_COMMANDS & CFG_CMD_PING)
|
#if (CONFIG_COMMANDS & CFG_CMD_PING)
|
||||||
case ICMP_ECHO_REPLY:
|
case ICMP_ECHO_REPLY:
|
||||||
/*
|
/*
|
||||||
@ -1418,7 +1418,7 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
*/
|
*/
|
||||||
/* XXX point to ip packet */
|
/* XXX point to ip packet */
|
||||||
(*packetHandler)((uchar *)ip, 0, 0, 0);
|
(*packetHandler)((uchar *)ip, 0, 0, 0);
|
||||||
break;
|
return;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -1427,6 +1427,46 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_UDP_CHECKSUM
|
||||||
|
if (ip->udp_xsum != 0) {
|
||||||
|
ulong xsum;
|
||||||
|
ushort *sumptr;
|
||||||
|
ushort sumlen;
|
||||||
|
|
||||||
|
xsum = ip->ip_p;
|
||||||
|
xsum += (ntohs(ip->udp_len));
|
||||||
|
xsum += (ntohl(ip->ip_src) >> 16) & 0x0000ffff;
|
||||||
|
xsum += (ntohl(ip->ip_src) >> 0) & 0x0000ffff;
|
||||||
|
xsum += (ntohl(ip->ip_dst) >> 16) & 0x0000ffff;
|
||||||
|
xsum += (ntohl(ip->ip_dst) >> 0) & 0x0000ffff;
|
||||||
|
|
||||||
|
sumlen = ntohs(ip->udp_len);
|
||||||
|
sumptr = (ushort *) &(ip->udp_src);
|
||||||
|
|
||||||
|
while (sumlen > 1) {
|
||||||
|
ushort sumdata;
|
||||||
|
|
||||||
|
sumdata = *sumptr++;
|
||||||
|
xsum += ntohs(sumdata);
|
||||||
|
sumlen -= 2;
|
||||||
|
}
|
||||||
|
if (sumlen > 0) {
|
||||||
|
ushort sumdata;
|
||||||
|
|
||||||
|
sumdata = *(unsigned char *) sumptr;
|
||||||
|
sumdata = (sumdata << 8) & 0xff00;
|
||||||
|
xsum += sumdata;
|
||||||
|
}
|
||||||
|
while ((xsum >> 16) != 0) {
|
||||||
|
xsum = (xsum & 0x0000ffff) + ((xsum >> 16) & 0x0000ffff);
|
||||||
|
}
|
||||||
|
if ((xsum != 0x00000000) && (xsum != 0x0000ffff)) {
|
||||||
|
printf(" UDP wrong checksum %08x %08x\n", xsum, ntohs(ip->udp_xsum));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NETCONSOLE
|
#ifdef CONFIG_NETCONSOLE
|
||||||
nc_input_packet((uchar *)ip +IP_HDR_SIZE,
|
nc_input_packet((uchar *)ip +IP_HDR_SIZE,
|
||||||
ntohs(ip->udp_dst),
|
ntohs(ip->udp_dst),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user