ReactOS  0.4.14-dev-50-g13bb5e2
checksum.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS TCP/IP protocol driver
4  * FILE: include/checksum.h
5  * PURPOSE: Checksum routine definitions
6  */
7 
8 #pragma once
9 
11  ULONG Sum);
12 
14  PVOID Data,
15  UINT Count,
16  ULONG Seed);
17 
18 unsigned int
20  const unsigned char * buff,
21  int len,
22  unsigned int sum);
23 
24 ULONG
26  PIPv4_HEADER IPHeader,
27  PUCHAR PacketBuffer,
29 
30 #define IPv4Checksum(Data, Count, Seed)(~ChecksumFold(ChecksumCompute(Data, Count, Seed)))
31 #define TCPv4Checksum(Data, Count, Seed)(~ChecksumFold(csum_partial(Data, Count, Seed)))
32 //#define TCPv4Checksum(Data, Count, Seed)(~ChecksumFold(ChecksumCompute(Data, Count, Seed)))
33 
34 /*
35  * Macro to check for a correct checksum
36  * BOOLEAN IPv4CorrectChecksum(PVOID Data, UINT Count)
37  */
38 #define IPv4CorrectChecksum(Data, Count) \
39  (BOOLEAN)(IPv4Checksum(Data, Count, 0) == DH2N(0x0000FFFF))
40 
41 /*
42  * Macro to check for a correct checksum
43  * BOOLEAN TCPv4CorrectChecksum(PTCPv4_PSEUDO_HEADER TcpPseudoHeader,
44  * PVOID Data, UINT Count)
45  */
46 #define TCPv4CorrectChecksum(TcpPseudoHeader, Data, Count) \
47  (BOOLEAN)(TCPv4Checksum(Data, Count, \
48  TCPv4Checksum(TcpPseudoHeader, sizeof(TCPv4_PSEUDO_HEADER), \
49  0)) == DH2N(0x0000FFFF))
unsigned char * PUCHAR
Definition: retypes.h:3
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
ULONG UDPv4ChecksumCalculate(PIPv4_HEADER IPHeader, PUCHAR PacketBuffer, ULONG DataLength)
Definition: checksum.c:60
ULONG ChecksumCompute(PVOID Data, UINT Count, ULONG Seed)
Definition: checksum.c:27
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum)
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
Definition: ip.h:37
ULONG ChecksumFold(ULONG Sum)
Definition: checksum.c:15
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
static unsigned char buff[32768]
Definition: fatten.c:17