From 6c957b9e845b82fb17c8ebc6d92b3114fd705453 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 24 Nov 2021 06:22:03 +0000 Subject: [PATCH] - remove compiler warning git-svn-id: http://moon:8086/svn/mips@208 a8ebac50-d88d-4704-bea3-6648445a41b3 --- src/common/network/icmp.c | 4 ++-- src/common/network/ipv4.c | 13 +++++++------ src/common/network/ipv4.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/common/network/icmp.c b/src/common/network/icmp.c index a59acd8..51922cd 100644 --- a/src/common/network/icmp.c +++ b/src/common/network/icmp.c @@ -29,8 +29,8 @@ void ICMPSendRequest(packet_t *pPacket, uint8_t *inet_addr_src, uint8_t *inet_ad pICMP->data_hdr[0]= 0x00; // Identifier pICMP->data_hdr[1]= 0x00; // Sequence number - sum = IPv4ChkSum((uint16_t*)pICMP, 0, sizeof(ICMP)); - sum = IPv4ChkSum((uint16_t*)icmp_payload, sum, len); + sum = IPv4ChkSum(pICMP, 0, sizeof(ICMP)); + sum = IPv4ChkSum(icmp_payload, sum, len); pICMP->hdr_chksum = ~sum; pData = (uint8_t*)Eth_pkt_append(pPacket, sizeof(ICMP)); diff --git a/src/common/network/ipv4.c b/src/common/network/ipv4.c index e33dd96..623e41e 100644 --- a/src/common/network/ipv4.c +++ b/src/common/network/ipv4.c @@ -41,23 +41,24 @@ uint8_t *IPV4_create(packet_t *pPacket, uint16_t proto, uint16_t len, uint8_t *i } // ------------------------------------------------------------------------- -uint16_t IPv4ChkSum(uint16_t *pBuf, uint16_t acc, uint16_t len) +uint16_t IPv4ChkSum(void *pBuf, uint16_t acc, uint16_t len) { + uint16_t *pBuf16 = (uint16_t*)pBuf; while(len > 1) { - acc += *pBuf; - if(acc < *pBuf) + acc += *pBuf16; + if(acc < *pBuf16) acc++; - ++pBuf; + ++pBuf16; len -= 2; } /* add up any odd byte */ if(len == 1) { - acc += htons(((uint16_t)(*(uint8_t *)pBuf)) << 8); - if(acc < htons(((uint16_t)(*(uint8_t *)pBuf)) << 8)) + acc += htons(((uint16_t)(*(uint8_t *)pBuf16)) << 8); + if(acc < htons(((uint16_t)(*(uint8_t *)pBuf16)) << 8)) acc++; } return acc; diff --git a/src/common/network/ipv4.h b/src/common/network/ipv4.h index 3b8c8e3..760edc6 100644 --- a/src/common/network/ipv4.h +++ b/src/common/network/ipv4.h @@ -51,7 +51,7 @@ typedef struct _sIPV4 #define IPV4_PRECENCE_ROUTINE 0x00 // 000 - Routine // ------------------------------------------------------------------------- -uint16_t IPv4ChkSum(uint16_t *pBuf, uint16_t acc, uint16_t len); +uint16_t IPv4ChkSum(void *pBuf, uint16_t acc, uint16_t len); uint8_t *IPV4_create(packet_t *pPacket, uint16_t proto, uint16_t len, uint8_t *inet_addr_src, uint8_t *inet_addr_dst); // -------------------------------------------------------------------------