CIP codec (#564): PatchU16 bounds guard; CipReply content equality; CipPath port/length/ASCII/odd/oversize validation with ArgumentException for malformed tag names and routes; CipPath.MessageRouter/ConnectionManager are now ReadOnlySpan<byte>; refused Forward Open surfaces ForwardOpenRefusedException with structured general/extended status; test CaptureFile uses BinaryPrimitives. EncapsulationClient (#565): frame write bounded by the exchange timeout, which faults (never cancels) the connection; finite positive timeouts enforced at every entry point; gate wait bounded by the timeout; deterministic reorder of the 300 ms test; new dispose-during-drain, gate-wait and RegisterSession zero-context tests. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -9,6 +9,24 @@ public sealed record ForwardOpenParams(
|
||||
|
||||
public sealed record ForwardOpenReply(uint OTConnectionId, uint TOConnectionId, uint OTApiMicros, uint TOApiMicros);
|
||||
|
||||
/// <summary>A target refused a Forward Open. The refusal is data, not just message text: callers (and
|
||||
/// diagnostics) read <see cref="GeneralStatus"/> / <see cref="ExtendedStatus"/> directly.</summary>
|
||||
public sealed class ForwardOpenRefusedException : AbTransportException
|
||||
{
|
||||
public ForwardOpenRefusedException(AbStatus status, byte generalStatus, IReadOnlyList<ushort> extendedStatus)
|
||||
: base(status, $"Forward Open refused: general 0x{generalStatus:X2}, extended {string.Join(",", extendedStatus.Select(e => $"0x{e:X4}"))}.")
|
||||
{
|
||||
GeneralStatus = generalStatus;
|
||||
ExtendedStatus = [.. extendedStatus]; // defensive copy: the exception is immutable
|
||||
}
|
||||
|
||||
/// <summary>The CIP general status of the refusal.</summary>
|
||||
public byte GeneralStatus { get; }
|
||||
|
||||
/// <summary>The CIP extended-status words of the refusal (may be empty).</summary>
|
||||
public IReadOnlyList<ushort> ExtendedStatus { get; }
|
||||
}
|
||||
|
||||
/// <summary>Connection Manager (class 6) request builders and reply parsers.</summary>
|
||||
public static class ConnectionManagerServices
|
||||
{
|
||||
@@ -52,8 +70,8 @@ public static class ConnectionManagerServices
|
||||
public static ForwardOpenReply ParseForwardOpenReply(CipReply reply)
|
||||
{
|
||||
if (reply.GeneralStatus != 0)
|
||||
throw new AbTransportException(reply.Status == AbStatus.BadReply ? AbStatus.BadConnection : reply.Status,
|
||||
$"Forward Open refused: general 0x{reply.GeneralStatus:X2}, extended {string.Join(",", reply.ExtendedStatus.Select(e => $"0x{e:X4}"))}.");
|
||||
throw new ForwardOpenRefusedException(reply.Status == AbStatus.BadReply ? AbStatus.BadConnection : reply.Status,
|
||||
reply.GeneralStatus, reply.ExtendedStatus);
|
||||
var r = new CipReader(reply.Data.Span);
|
||||
var ot = r.U32(); var to = r.U32(); r.U16(); r.U16(); r.U32();
|
||||
return new ForwardOpenReply(ot, to, r.U32(), r.U32());
|
||||
|
||||
Reference in New Issue
Block a user