2000-08-02 00:24:26 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS TCP/IP protocol driver
|
|
|
|
* FILE: include/checksum.h
|
|
|
|
* PURPOSE: Checksum routine definitions
|
|
|
|
*/
|
2010-02-26 11:43:19 +00:00
|
|
|
|
|
|
|
#pragma once
|
2000-08-02 00:24:26 +00:00
|
|
|
|
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
svn path=/trunk/; revision=8537
2004-03-04 20:45:39 +00:00
|
|
|
ULONG ChecksumFold(
|
|
|
|
ULONG Sum);
|
|
|
|
|
2000-08-02 00:24:26 +00:00
|
|
|
ULONG ChecksumCompute(
|
|
|
|
PVOID Data,
|
|
|
|
UINT Count,
|
|
|
|
ULONG Seed);
|
|
|
|
|
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
svn path=/trunk/; revision=8537
2004-03-04 20:45:39 +00:00
|
|
|
unsigned int
|
|
|
|
csum_partial(
|
|
|
|
const unsigned char * buff,
|
|
|
|
int len,
|
|
|
|
unsigned int sum);
|
|
|
|
|
2009-10-20 05:24:37 +00:00
|
|
|
ULONG
|
|
|
|
UDPv4ChecksumCalculate(
|
|
|
|
PIPv4_HEADER IPHeader,
|
|
|
|
PUCHAR PacketBuffer,
|
|
|
|
ULONG DataLength);
|
|
|
|
|
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
svn path=/trunk/; revision=8537
2004-03-04 20:45:39 +00:00
|
|
|
#define IPv4Checksum(Data, Count, Seed)(~ChecksumFold(ChecksumCompute(Data, Count, Seed)))
|
|
|
|
#define TCPv4Checksum(Data, Count, Seed)(~ChecksumFold(csum_partial(Data, Count, Seed)))
|
|
|
|
//#define TCPv4Checksum(Data, Count, Seed)(~ChecksumFold(ChecksumCompute(Data, Count, Seed)))
|
2000-08-02 00:24:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro to check for a correct checksum
|
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
svn path=/trunk/; revision=8537
2004-03-04 20:45:39 +00:00
|
|
|
* BOOLEAN IPv4CorrectChecksum(PVOID Data, UINT Count)
|
2000-08-02 00:24:26 +00:00
|
|
|
*/
|
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
svn path=/trunk/; revision=8537
2004-03-04 20:45:39 +00:00
|
|
|
#define IPv4CorrectChecksum(Data, Count) \
|
2000-08-02 00:24:26 +00:00
|
|
|
(BOOLEAN)(IPv4Checksum(Data, Count, 0) == DH2N(0x0000FFFF))
|
|
|
|
|
2004-03-04 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/net/tcpip/tcpip/i386: New directory.
* drivers/net/tcpip/tcpip/i386/checksum.S: New file.
* drivers/net/tcpip/notes.txt: New file.
* drivers/net/afd/afd/dispatch.c (AfdDispCompleteListen): Signal ACCEPT
network event.
(AfdDispEventSelect): Reference event handle.
* drivers/net/afd/afd/tdi.c (TdiListen): Remove unused event.
Move Iosb and RequestConnectionInfo to AFD_LISTEN_REQUEST structure.
* drivers/net/afd/include/afd.h (AFDFCB): Replace EventObjects with
EventObject of type PKEVENT.
* drivers/net/tcpip/makefile (ARCH_OBJECTS): New variable.
(TARGET_OBJECTS): Add ARCH_OBJECTS.
* drivers/net/tcpip/include/address.h (AddrCloneAddress): New prototype.
* drivers/net/tcpip/include/checksum.h (ChecksumFold, csum_partial): New
prototype.
(TCPv4Checksum): New macro.
(CorrectChecksum): Rename to IPv4CorrectChecksum.
(TCPv4CorrectChecksum): New macro.
* drivers/net/tcpip/include/ip.h (IPv4_DF_MASK): New constant.
* drivers/net/tcpip/include/tcp.h (TCP_XXX): Correct constants.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment): Prototype.
* drivers/net/tcpip/include/titypes.h (TCP_SEND_REQUEST): Add SequenceNumber
and AckNumber.
(TCP_SEGMENT): New structure.
(CONNECTION_ENDPOINT): Add ListenRequest and ReceivedSegments.
* drivers/net/tcpip/network/transmit.c (SendFragments): Release memory
for Data on failure.
* drivers/net/tcpip/tcpip/address.c (AddrCloneAddress): New function.
* drivers/net/tcpip/tcpip/checksum.c (ChecksumFold): Factor out folding
from ChecksumCompute.
* drivers/net/tcpip/tcpip/dispatch.c (DispTdiListen): Support asynchronous
operation.
* drivers/net/tcpip/tcpip/fileobjs.c (FileOpenAddress): Don't cast to
PTDI_ADDRESS_IP.
Initialize ReceivedSegments.
* drivers/net/tcpip/tcpip/routines.c (DisplayIPHeader): New function.
(DisplayIPPacket): Call DisplayIPHeader().
(DisplayTCPHeader): Change format strings.
* drivers/net/tcpip/transport/tcp/tcp.c (IPIdentification,
TCPSegmentList): Add.
(TCPCreateSegment, TCPFreeSegment, TCPAddSegment,
TCPBuildAndTransmitSendRequest2, TCPiSelectISS, TCPiReceiveListen,
TCPiReceiveSynSent, TCPiReceiveSynReceived, TCPiReceiveData): New
function.
(TCPiBuildPacket): Build segment.
(TCPStartup): Initialize TCPSegmentList.
(TCPShutdown): Cleanup TCPSegmentList.
svn path=/trunk/; revision=8537
2004-03-04 20:45:39 +00:00
|
|
|
/*
|
|
|
|
* Macro to check for a correct checksum
|
|
|
|
* BOOLEAN TCPv4CorrectChecksum(PTCPv4_PSEUDO_HEADER TcpPseudoHeader,
|
|
|
|
* PVOID Data, UINT Count)
|
|
|
|
*/
|
|
|
|
#define TCPv4CorrectChecksum(TcpPseudoHeader, Data, Count) \
|
|
|
|
(BOOLEAN)(TCPv4Checksum(Data, Count, \
|
|
|
|
TCPv4Checksum(TcpPseudoHeader, sizeof(TCPv4_PSEUDO_HEADER), \
|
|
|
|
0)) == DH2N(0x0000FFFF))
|