Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: ip6/icmp/icmp6.c
- Revision:
- 136:8a65abb0dc63
- Parent:
- 61:aad055f1b0d1
- Child:
- 138:5ff0c7069300
--- a/ip6/icmp/icmp6.c Sat Mar 23 12:25:48 2019 +0000
+++ b/ip6/icmp/icmp6.c Sat Apr 06 11:20:20 2019 +0000
@@ -11,6 +11,7 @@
#include "slaac.h"
#include "echo6.h"
#include "dest6.h"
+#include "checksum.h"
__packed struct header
{
@@ -39,25 +40,14 @@
}
}
static uint16_t calculateChecksum(char* pSrcIp, char* pDstIp, int size, void* pPacket)
-{
- __packed struct pseudo
- {
- char src[16];
- char dst[16];
- uint32_t len;
- uint8_t zer[3];
- uint8_t pro;
- } pseudo;
-
- Ip6AddressCopy(pseudo.src, pSrcIp);
- Ip6AddressCopy(pseudo.dst, pDstIp);
- pseudo.len = NetToHost32(size);
- pseudo.zer[0] = 0;
- pseudo.zer[1] = 0;
- pseudo.zer[2] = 0;
- pseudo.pro = ICMP6;
-
- return NetCheckSumTwo(sizeof(pseudo), &pseudo, size, pPacket);
+{
+ uint32_t sum = 0;
+ uint32_t pro32 = ICMP6;
+ sum = CheckSumAddDirect(sum, 16, pSrcIp );
+ sum = CheckSumAddDirect(sum, 16, pDstIp );
+ sum = CheckSumAddInvert(sum, 4, &size );
+ sum = CheckSumAddInvert(sum, 4, &pro32 );
+ return CheckSumFinDirect(sum, size, pPacket);
}
static void logHeader()
{