sitara_depot/components/free_rtos/ethernet_ip/eth_ip_checksum.c
algin ae3cac8a7d feat: First commit
Adds sitara_depot/free_rtos

Original one is on server_gorbunov/SmartForce4.0/sitara_depot
2023-05-03 14:01:32 +03:00

23 lines
391 B
C

/*
* eth_ip_checksum.c
*
* Created on: 14 ìàð. 2023 ã.
* Author: sychev
*/
#include "eth_ip_checksum.h"
#include "base/swap.h"
uint16_t eth_ip_calcChecksum(uint16_t * const data, uint32_t length)
{
uint32_t i, crc = 0;
for (i = 0 ; i < length; ++i ) {
crc += BASE_SWAP16(data[i]);
}
crc = (crc & 0xffff) + (crc >> 16);
return (uint16_t) (~crc);
}