Add support for pseudo IP/TCP/UDP checksums.

Most NIC cards support checksum offloading,
meaning that it is not necessary to calculate the
full IP/TCP/UDP checksums for injected packets.
WINDIVERT_ADDRESS has been extended to include 3
extra flags that indicate if the packet has full
or pseudo checksums.  This is a WIP.
This commit is contained in:
basil00
2017-11-09 22:11:13 +08:00
parent bbf6a34aa6
commit aea3a3a858
8 changed files with 194 additions and 252 deletions
+5 -11
View File
@@ -62,7 +62,10 @@ typedef struct
UINT32 SubIfIdx; /* Packet's sub-interface index. */
UINT8 Direction:1; /* Packet's direction. */
UINT8 Loopback:1; /* Packet is loopback? */
UINT8 Reserved:6;
UINT8 IPv4Checksum:1; /* Packet has full IPv4 checksum? */
UINT8 TCPChecksum:1; /* Packet has full TCP checksum? */
UINT8 UDPChecksum:1; /* Packet has full UDP checksum? */
UINT8 Reserved:2;
} WINDIVERT_ADDRESS, *PWINDIVERT_ADDRESS;
#define WINDIVERT_DIRECTION_OUTBOUND 0
@@ -318,7 +321,6 @@ typedef struct
#define WINDIVERT_HELPER_NO_ICMPV6_CHECKSUM 4
#define WINDIVERT_HELPER_NO_TCP_CHECKSUM 8
#define WINDIVERT_HELPER_NO_UDP_CHECKSUM 16
#define WINDIVERT_HELPER_NO_REPLACE 2048
/*
* Parse IPv4/IPv6/ICMP/ICMPv6/TCP/UDP headers from a raw packet.
@@ -355,6 +357,7 @@ extern WINDIVERTEXPORT BOOL WinDivertHelperParseIPv6Address(
extern WINDIVERTEXPORT UINT WinDivertHelperCalcChecksums(
__inout PVOID pPacket,
__in UINT packetLen,
__in_opt PWINDIVERT_ADDRESS pAddr,
__in UINT64 flags);
/*
@@ -376,15 +379,6 @@ extern WINDIVERTEXPORT BOOL WinDivertHelperEvalFilter(
__in UINT packetLen,
__in PWINDIVERT_ADDRESS pAddr);
/****************************************************************************/
/* WINDIVERT LEGACY API */
/****************************************************************************/
/*
* Deprecated API:
*/
#define WINDIVERT_FLAG_NO_CHECKSUM 0
#endif /* WINDIVERT_KERNEL */
#ifdef __cplusplus