mbproxy: strip historical phase/wave/plan references from source comments
Comments described the *history* of how the code arrived (phase numbers, wave IDs, review IDs, dated TODOs) instead of what it does today. That scaffolding rotted as the codebase evolved. Cleaned 60 source files + .gitignore; behaviour unchanged (387/387 tests still pass). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Mbproxy.Proxy;
|
||||
|
||||
/// <summary>
|
||||
/// BCD-rewriting PDU pipeline. Registered as the singleton <see cref="IPduPipeline"/>
|
||||
/// in production (replaces <see cref="NoopPduPipeline"/> from Phase 03).
|
||||
/// in production.
|
||||
///
|
||||
/// FC scope (per design.md):
|
||||
/// FC03 / FC04 response — decode covered BCD slots from raw nibbles → binary integer.
|
||||
@@ -15,13 +15,13 @@ namespace Mbproxy.Proxy;
|
||||
/// MBAP transparency contract: the MBAP length field is NEVER modified. Re-encoded slots
|
||||
/// are the same byte width as the originals (ushort → ushort), so the PDU length is stable.
|
||||
///
|
||||
/// <para><b>Phase 9 — request correlation:</b> FC03/FC04 responses do not carry the
|
||||
/// original start address. The multiplexer builds an <see cref="Multiplexing.InFlightRequest"/>
|
||||
/// <para><b>Request correlation:</b> FC03/FC04 responses do not carry the original
|
||||
/// start address. The multiplexer builds an <see cref="Multiplexing.InFlightRequest"/>
|
||||
/// on the request path, stores it in its <see cref="Multiplexing.CorrelationMap"/>, and
|
||||
/// attaches it to the per-call <see cref="PerPlcContext.CurrentRequest"/> on the response
|
||||
/// path. The rewriter consumes <c>CurrentRequest</c> instead of a per-pair last-request
|
||||
/// slot, so concurrent responses from different upstream clients each decode against
|
||||
/// their own request range without cross-talk.</para>
|
||||
/// attaches it to the per-call <see cref="PerPlcContext.CurrentRequest"/> on the
|
||||
/// response path. The rewriter consumes <c>CurrentRequest</c>, so concurrent responses
|
||||
/// from different upstream clients each decode against their own request range without
|
||||
/// cross-talk.</para>
|
||||
///
|
||||
/// <para>This class is stateless. All per-call state arrives via <see cref="PduContext"/>
|
||||
/// (specifically <see cref="PerPlcContext.CurrentRequest"/> on response). It is safe to
|
||||
@@ -157,12 +157,12 @@ internal sealed class BcdPduPipeline : IPduPipeline
|
||||
ushort startAddress = (ushort)((pdu[1] << 8) | pdu[2]);
|
||||
ushort qty = (ushort)((pdu[3] << 8) | pdu[4]);
|
||||
|
||||
// Phase 12 (W2.14) — validate the request is fully sized for `qty` registers
|
||||
// (each 2 bytes after the byteCount byte). A client claiming qty=10 with only
|
||||
// 4 bytes of register data would otherwise have its BCD slots silently skipped
|
||||
// by the per-slot bounds check below — half the request rewritten, half not.
|
||||
// Returning here passes the malformed PDU through unchanged so the PLC's own
|
||||
// validator surfaces the protocol error.
|
||||
// Validate the request is fully sized for `qty` registers (each 2 bytes after
|
||||
// the byteCount byte). A client claiming qty=10 with only 4 bytes of register
|
||||
// data would otherwise have its BCD slots silently skipped by the per-slot
|
||||
// bounds check below — half the request rewritten, half not. Returning here
|
||||
// passes the malformed PDU through unchanged so the PLC's own validator
|
||||
// surfaces the protocol error.
|
||||
if (pdu.Length < 6 + qty * 2)
|
||||
return;
|
||||
|
||||
@@ -210,14 +210,14 @@ internal sealed class BcdPduPipeline : IPduPipeline
|
||||
ushort clientLow = (ushort)((pdu[lowByteOff] << 8) | pdu[lowByteOff + 1]);
|
||||
ushort clientHigh = (ushort)((pdu[highByteOff] << 8) | pdu[highByteOff + 1]);
|
||||
|
||||
// Phase 12 (W2.13) — validate that BOTH input words are within the
|
||||
// base-10000-digit range BEFORE reconstructing. Without this guard, a
|
||||
// client writing (high=9999, low=9999) silently mutates to (high=9998,
|
||||
// low=9999) because `9999 * 10_000 + 9999 = 99_989_999` is still <= the
|
||||
// 32-bit BCD ceiling, so Encode32 accepts it and rewrites — losing 1 from
|
||||
// the high word. The unconventional wire format ("two base-10000 CDAB
|
||||
// digits", per design.md:123) means each word independently must be
|
||||
// 0..9999 to round-trip cleanly.
|
||||
// Validate that BOTH input words are within the base-10000-digit range
|
||||
// BEFORE reconstructing. Without this guard, a client writing
|
||||
// (high=9999, low=9999) silently mutates to (high=9998, low=9999)
|
||||
// because `9999 * 10_000 + 9999 = 99_989_999` is still <= the 32-bit
|
||||
// BCD ceiling, so Encode32 accepts it and rewrites — losing 1 from the
|
||||
// high word. The unconventional wire format ("two base-10000 CDAB
|
||||
// digits", per design.md) means each word independently must be 0..9999
|
||||
// to round-trip cleanly.
|
||||
if (clientLow > 9999 || clientHigh > 9999)
|
||||
{
|
||||
RewriterLogEvents.InvalidBcd(ctx.Logger, ctx.PlcName, tag.Address,
|
||||
@@ -473,6 +473,4 @@ internal sealed class BcdPduPipeline : IPduPipeline
|
||||
// already counted this slot on the way out. Incrementing again would double-count.
|
||||
}
|
||||
|
||||
// Phase 12 (W3 cleanup) — HasBadNibble was previously duplicated here; the canonical
|
||||
// implementation now lives in BcdCodec.HasBadNibble (internal).
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user