summaryrefslogtreecommitdiff
path: root/net/net.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-01-19 22:16:08 -0700
committerSimon Glass <sjg@chromium.org>2015-02-12 10:35:33 -0700
commit0da0fcd51f6566d84eb24cbbd4c8ad784c702849 (patch)
treeca319b50fa22b7d0bbd636c83877dc52c17959fa /net/net.c
parent360334a1786c2ef8753239818ca295211b2d5aa8 (diff)
downloadu-boot-imx-0da0fcd51f6566d84eb24cbbd4c8ad784c702849.zip
u-boot-imx-0da0fcd51f6566d84eb24cbbd4c8ad784c702849.tar.gz
u-boot-imx-0da0fcd51f6566d84eb24cbbd4c8ad784c702849.tar.bz2
net: Use new checksum functions
Drop the old checksum functions in favour of the new ones. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'net/net.c')
-rw-r--r--net/net.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/net/net.c b/net/net.c
index 2bea07b..b60ce62 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1086,7 +1086,7 @@ NetReceive(uchar *inpkt, int len)
if ((ip->ip_hl_v & 0x0f) > 0x05)
return;
/* Check the Checksum of the header */
- if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE / 2)) {
+ if (!ip_checksum_ok((uchar *)ip, IP_HDR_SIZE)) {
debug("checksum bad\n");
return;
}
@@ -1291,27 +1291,6 @@ common:
/**********************************************************************/
int
-NetCksumOk(uchar *ptr, int len)
-{
- return !((NetCksum(ptr, len) + 1) & 0xfffe);
-}
-
-
-unsigned
-NetCksum(uchar *ptr, int len)
-{
- ulong xsum;
- ushort *p = (ushort *)ptr;
-
- xsum = 0;
- while (len-- > 0)
- xsum += *p++;
- xsum = (xsum & 0xffff) + (xsum >> 16);
- xsum = (xsum & 0xffff) + (xsum >> 16);
- return xsum & 0xffff;
-}
-
-int
NetEthHdrSize(void)
{
ushort myvlanid;
@@ -1410,7 +1389,7 @@ void net_set_udp_header(uchar *pkt, IPaddr_t dest, int dport, int sport,
net_set_ip_header(pkt, dest, NetOurIP);
ip->ip_len = htons(IP_UDP_HDR_SIZE + len);
ip->ip_p = IPPROTO_UDP;
- ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE >> 1);
+ ip->ip_sum = compute_ip_checksum(ip, IP_HDR_SIZE);
ip->udp_src = htons(sport);
ip->udp_dst = htons(dport);