EtherLib/prefab/packet_parsers/tcp_udp_common.c
Wiesner András 51696f7341 - MemoryPool allocation-deallocation bug fixed
- generic Queue implemented
- PacketRegistry allocation bug fixed
- TCP implementation initials
- ALIGN to type macros added
2023-01-17 08:19:29 +01:00

12 lines
393 B
C

#include <stdbool.h>
#include "tcp_udp_common.h"
#include "../../utils.h"
uint16_t tcp_udp_checksum(const IPv4PseudoHeader *pseudoHeader, const uint8_t * hdr, uint32_t size) {
uint32_t sum = chksum((const uint8_t *) pseudoHeader, sizeof(IPv4PseudoHeader), true) + chksum(hdr, size, true);
while (sum >> 16) {
sum = (sum & 0xFFFF) + (sum >> 16);
}
return htonl(sum);
}