/// <summary> /// (Re)calculates the checksum for any IPv4/ICMP/ICMPv6/TCP/UDP checksum present in the /// given packet. Individual checksum calculations may be disabled via the appropriate flag. /// Typically this function should be invoked on a modified packet before it is injected with <seealso cref="WinDivertSend(IntPtr, WinDivertBuffer, uint, ref WinDivertAddress, ref uint)" />. /// </summary> /// <param name="packet"> /// The packet to be modified. /// </param> /// <param name="packetLength"> /// The total length of the packet pPacket. /// </param> /// <param name="address"> /// A reference to a <seealso cref="WinDivertAddress" /> structure. /// </param> /// <param name="flags"> /// One or more <seealso cref="WinDivertChecksumHelperParam" /> flags. /// </param> /// <returns> /// The number of checksums calculated. /// </returns> public static uint WinDivertHelperCalcChecksums(WinDivertBuffer packet, uint packetLength, ref WinDivertAddress address, WinDivertChecksumHelperParam flags) { fixed (WinDivertAddress* pAddress = &address) { return WinDivertNative.WinDivertHelperCalcChecksums(packet.BufferPointer, packetLength, ref address, (ulong)flags); } }
/// <summary> /// (Re)calculates the checksum for any IPv4/ICMP/ICMPv6/TCP/UDP checksum present in the /// given packet. Individual checksum calculations may be disabled via the appropriate flag. /// Typically this function should be invoked on a modified packet before it is injected with <seealso cref="WinDivertSend(IntPtr, WinDivertBuffer, uint, ref WinDivertAddress, ref uint)" />. /// </summary> /// <param name="packet"> /// The packet to be modified. /// </param> /// <param name="packetLength"> /// The total length of the packet pPacket. /// </param> /// <param name="flags"> /// One or more <seealso cref="WinDivertChecksumHelperParam" /> flags. /// </param> /// <returns> /// The number of checksums calculated. /// </returns> public static uint WinDivertHelperCalcChecksums(WinDivertBuffer packet, uint packetLength, WinDivertChecksumHelperParam flags) { return WinDivertNative.WinDivertHelperCalcChecksums(packet.BufferPointer, packetLength, IntPtr.Zero, (ulong)flags); //fixed (byte* buff = packet._buffer) { //return WinDivertNative.WinDivertHelperCalcChecksums(buff, packetLength, IntPtr.Zero, (ulong)flags); } }