Table of Contents

Interface IChecksumPayloadPacket

Namespace
VpnHood.Net.Packets
Assembly
VpnHood.Net.Packets.dll

Represents a payload packet with an Internet checksum (RFC 1071): TCP, UDP, ICMPv4 or ICMPv6.

public interface IChecksumPayloadPacket : IPayloadPacket
Inherited Members

Remarks

The addresses are those of the IP packet that carries this one, as raw bytes: 4 for IPv4, 16 for IPv6. TCP, UDP and ICMPv6 sum them in a pseudo-header; ICMPv4 ignores them.

Properties

Checksum

Gets the checksum field as it is in the packet.

ushort Checksum { get; }

Property Value

ushort

Methods

ComputeChecksum(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Computes the checksum the packet's content calls for, without writing it.

ushort ComputeChecksum(ReadOnlySpan<byte> sourceAddress, ReadOnlySpan<byte> destinationAddress)

Parameters

sourceAddress ReadOnlySpan<byte>

The source address of the IP packet, 4 or 16 bytes.

destinationAddress ReadOnlySpan<byte>

The destination address of the IP packet, of the same length.

Returns

ushort

The checksum, as a number to write in network byte order.

Remarks

The checksum field may be zeroed while the sum runs and restored after, so no other thread may use the packet meanwhile.

IsChecksumValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Checks the packet's checksum field against its content.

bool IsChecksumValid(ReadOnlySpan<byte> sourceAddress, ReadOnlySpan<byte> destinationAddress)

Parameters

sourceAddress ReadOnlySpan<byte>

The source address of the IP packet, 4 or 16 bytes.

destinationAddress ReadOnlySpan<byte>

The destination address of the IP packet, of the same length.

Returns

bool

true if the checksum is valid; otherwise, false.

Remarks

An implementation may accept a checksum its protocol lets the sender omit, as UDP does over IPv4.

UpdateChecksum(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Computes the checksum and writes it to the packet's checksum field.

void UpdateChecksum(ReadOnlySpan<byte> sourceAddress, ReadOnlySpan<byte> destinationAddress)

Parameters

sourceAddress ReadOnlySpan<byte>

The source address of the IP packet, 4 or 16 bytes.

destinationAddress ReadOnlySpan<byte>

The destination address of the IP packet, of the same length.