Initial commit

This commit is contained in:
2026-07-13 09:25:40 +07:00
parent c08ff54676
commit bccfb156d7
1938 changed files with 641646 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
namespace Sick.SafetyScanners.DataStructures;
/// <summary>
/// Represents a PacketBuffer with a parsed DatagramHeader
/// Used for merging fragmented UDP packets
/// </summary>
public sealed class ParsedPacketBuffer
{
/// <summary>
/// Gets the packet buffer
/// </summary>
public PacketBuffer PacketBuffer { get; init; }
/// <summary>
/// Gets the parsed datagram header
/// </summary>
public DatagramHeader DatagramHeader { get; init; }
public ParsedPacketBuffer(PacketBuffer packetBuffer, DatagramHeader datagramHeader)
{
PacketBuffer = packetBuffer ?? throw new ArgumentNullException(nameof(packetBuffer));
DatagramHeader = datagramHeader ?? throw new ArgumentNullException(nameof(datagramHeader));
}
/// <summary>
/// Compares two ParsedPacketBuffer instances by fragment offset for sorting
/// </summary>
public static int CompareByOffset(ParsedPacketBuffer x, ParsedPacketBuffer y)
{
if (x == null && y == null) return 0;
if (x == null) return -1;
if (y == null) return 1;
return x.DatagramHeader.FragmentOffset.CompareTo(y.DatagramHeader.FragmentOffset);
}
}