X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=net%2Fping.c;h=366f51825f9ecbff62354eeae1aeb2c49b4aa25b;hb=b9cb64825b5e6efeb715abd8b48d9b12f98973e9;hp=2ba9f76e5a5b032ee7d194c4c941843d84c1b40d;hpb=e94070c443bdc9c0231abeca920d9f9362701aec;p=platform%2Fkernel%2Fu-boot.git diff --git a/net/ping.c b/net/ping.c index 2ba9f76..366f518 100644 --- a/net/ping.c +++ b/net/ping.c @@ -6,6 +6,7 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de + * SPDX-License-Identifier: GPL-2.0 */ #include "ping.h" @@ -28,14 +29,14 @@ static void set_icmp_header(uchar *pkt, IPaddr_t dest) ip->ip_len = htons(IP_ICMP_HDR_SIZE); ip->ip_p = IPPROTO_ICMP; - ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE >> 1); + ip->ip_sum = compute_ip_checksum(ip, IP_HDR_SIZE); icmp->type = ICMP_ECHO_REQUEST; icmp->code = 0; icmp->checksum = 0; icmp->un.echo.id = 0; icmp->un.echo.sequence = htons(PingSeqNo++); - icmp->checksum = ~NetCksum((uchar *)icmp, ICMP_HDR_SIZE >> 1); + icmp->checksum = compute_ip_checksum(icmp, ICMP_HDR_SIZE); } static int ping_send(void) @@ -45,7 +46,7 @@ static int ping_send(void) /* XXX always send arp request */ - debug("sending ARP for %pI4\n", &NetPingIP); + debug_cond(DEBUG_DEV_PKT, "sending ARP for %pI4\n", &NetPingIP); NetArpWaitPacketIP = NetPingIP; @@ -93,20 +94,18 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) case ICMP_ECHO_REQUEST: eth_hdr_size = net_update_ether(et, et->et_src, PROT_IP); - debug("Got ICMP ECHO REQUEST, return " + debug_cond(DEBUG_DEV_PKT, "Got ICMP ECHO REQUEST, return " "%d bytes\n", eth_hdr_size + len); ip->ip_sum = 0; ip->ip_off = 0; NetCopyIP((void *)&ip->ip_dst, &ip->ip_src); NetCopyIP((void *)&ip->ip_src, &NetOurIP); - ip->ip_sum = ~NetCksum((uchar *)ip, - IP_HDR_SIZE >> 1); + ip->ip_sum = compute_ip_checksum(ip, IP_HDR_SIZE); icmph->type = ICMP_ECHO_REPLY; icmph->checksum = 0; - icmph->checksum = ~NetCksum((uchar *)icmph, - (len - IP_HDR_SIZE) >> 1); + icmph->checksum = compute_ip_checksum(icmph, len - IP_HDR_SIZE); NetSendPacket((uchar *)et, eth_hdr_size + len); return; /* default: