|
| 1 | +namespace Sigtran.NET.Layers.SCTP; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Reports native SCTP production hardening readiness. |
| 5 | +/// </summary> |
| 6 | +public sealed class SctpProductionHardeningReadinessReport |
| 7 | +{ |
| 8 | + /// <summary>Creates an SCTP production hardening readiness report.</summary> |
| 9 | + /// <param name="hasStreamAndPpidFraming">Whether outbound stream and PPID framing is available.</param> |
| 10 | + /// <param name="hasAssociationLifecycleJournal">Whether association lifecycle journaling is available.</param> |
| 11 | + /// <param name="hasReconnectSchedule">Whether reconnect scheduling is available.</param> |
| 12 | + /// <param name="hasSendBackpressurePolicy">Whether send backpressure policy is available.</param> |
| 13 | + /// <param name="hasOperationTimeoutPolicy">Whether operation timeout policy is available.</param> |
| 14 | + /// <param name="hasMultiHomingReadiness">Whether multi-homing readiness checks are available.</param> |
| 15 | + /// <param name="hasFaultRecovery">Whether fault recovery decisions are available.</param> |
| 16 | + /// <param name="hasTransportDiagnostics">Whether transport diagnostics snapshots are available.</param> |
| 17 | + /// <param name="hasRetainedLinuxSctpEvidence">Whether retained Linux SCTP evidence is available.</param> |
| 18 | + /// <param name="hasRetainedExternalPeerEvidence">Whether retained external peer evidence is available.</param> |
| 19 | + public SctpProductionHardeningReadinessReport( |
| 20 | + bool hasStreamAndPpidFraming, |
| 21 | + bool hasAssociationLifecycleJournal, |
| 22 | + bool hasReconnectSchedule, |
| 23 | + bool hasSendBackpressurePolicy, |
| 24 | + bool hasOperationTimeoutPolicy, |
| 25 | + bool hasMultiHomingReadiness, |
| 26 | + bool hasFaultRecovery, |
| 27 | + bool hasTransportDiagnostics, |
| 28 | + bool hasRetainedLinuxSctpEvidence, |
| 29 | + bool hasRetainedExternalPeerEvidence) |
| 30 | + { |
| 31 | + HasStreamAndPpidFraming = hasStreamAndPpidFraming; |
| 32 | + HasAssociationLifecycleJournal = hasAssociationLifecycleJournal; |
| 33 | + HasReconnectSchedule = hasReconnectSchedule; |
| 34 | + HasSendBackpressurePolicy = hasSendBackpressurePolicy; |
| 35 | + HasOperationTimeoutPolicy = hasOperationTimeoutPolicy; |
| 36 | + HasMultiHomingReadiness = hasMultiHomingReadiness; |
| 37 | + HasFaultRecovery = hasFaultRecovery; |
| 38 | + HasTransportDiagnostics = hasTransportDiagnostics; |
| 39 | + HasRetainedLinuxSctpEvidence = hasRetainedLinuxSctpEvidence; |
| 40 | + HasRetainedExternalPeerEvidence = hasRetainedExternalPeerEvidence; |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary>Whether outbound stream and PPID framing is available.</summary> |
| 44 | + public bool HasStreamAndPpidFraming { get; } |
| 45 | + |
| 46 | + /// <summary>Whether association lifecycle journaling is available.</summary> |
| 47 | + public bool HasAssociationLifecycleJournal { get; } |
| 48 | + |
| 49 | + /// <summary>Whether reconnect scheduling is available.</summary> |
| 50 | + public bool HasReconnectSchedule { get; } |
| 51 | + |
| 52 | + /// <summary>Whether send backpressure policy is available.</summary> |
| 53 | + public bool HasSendBackpressurePolicy { get; } |
| 54 | + |
| 55 | + /// <summary>Whether operation timeout policy is available.</summary> |
| 56 | + public bool HasOperationTimeoutPolicy { get; } |
| 57 | + |
| 58 | + /// <summary>Whether multi-homing readiness checks are available.</summary> |
| 59 | + public bool HasMultiHomingReadiness { get; } |
| 60 | + |
| 61 | + /// <summary>Whether fault recovery decisions are available.</summary> |
| 62 | + public bool HasFaultRecovery { get; } |
| 63 | + |
| 64 | + /// <summary>Whether transport diagnostics snapshots are available.</summary> |
| 65 | + public bool HasTransportDiagnostics { get; } |
| 66 | + |
| 67 | + /// <summary>Whether retained Linux SCTP evidence is available.</summary> |
| 68 | + public bool HasRetainedLinuxSctpEvidence { get; } |
| 69 | + |
| 70 | + /// <summary>Whether retained external peer evidence is available.</summary> |
| 71 | + public bool HasRetainedExternalPeerEvidence { get; } |
| 72 | + |
| 73 | + /// <summary>The implemented foundation capability count.</summary> |
| 74 | + public int FoundationCapabilityCount => |
| 75 | + Count(HasStreamAndPpidFraming) |
| 76 | + + Count(HasAssociationLifecycleJournal) |
| 77 | + + Count(HasReconnectSchedule) |
| 78 | + + Count(HasSendBackpressurePolicy) |
| 79 | + + Count(HasOperationTimeoutPolicy) |
| 80 | + + Count(HasMultiHomingReadiness) |
| 81 | + + Count(HasFaultRecovery) |
| 82 | + + Count(HasTransportDiagnostics); |
| 83 | + |
| 84 | + /// <summary>Whether all SDK hardening foundation capabilities are available.</summary> |
| 85 | + public bool FoundationReady => FoundationCapabilityCount == SctpProductionHardeningReadiness.RequiredFoundationCapabilityCount; |
| 86 | + |
| 87 | + /// <summary>Whether retained production evidence is available.</summary> |
| 88 | + public bool EvidenceReady => HasRetainedLinuxSctpEvidence && HasRetainedExternalPeerEvidence; |
| 89 | + |
| 90 | + /// <summary>Whether native SCTP hardening can be claimed production-ready.</summary> |
| 91 | + public bool ProductionReady => FoundationReady && EvidenceReady; |
| 92 | + |
| 93 | + /// <summary>Formats a compact readiness summary.</summary> |
| 94 | + /// <returns>The readiness summary.</returns> |
| 95 | + public string Describe() |
| 96 | + { |
| 97 | + return $"sctpHardeningFoundationReady={FoundationReady} sctpHardeningProductionReady={ProductionReady} foundationCapabilities={FoundationCapabilityCount}/{SctpProductionHardeningReadiness.RequiredFoundationCapabilityCount} linuxEvidence={HasRetainedLinuxSctpEvidence} externalPeerEvidence={HasRetainedExternalPeerEvidence}"; |
| 98 | + } |
| 99 | + |
| 100 | + private static int Count(bool value) |
| 101 | + { |
| 102 | + return value ? 1 : 0; |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +/// <summary> |
| 107 | +/// Provides native SCTP production hardening readiness information. |
| 108 | +/// </summary> |
| 109 | +public static class SctpProductionHardeningReadiness |
| 110 | +{ |
| 111 | + /// <summary>The required native SCTP hardening foundation capability count.</summary> |
| 112 | + public const int RequiredFoundationCapabilityCount = 8; |
| 113 | + |
| 114 | + /// <summary>Explains the production evidence gate.</summary> |
| 115 | + public const string ProductionGateDescription = "Retained Linux SCTP and external peer traffic evidence are required before production SCTP hardening can be claimed."; |
| 116 | + |
| 117 | + /// <summary>Returns the current SCTP production hardening readiness report.</summary> |
| 118 | + /// <param name="hasRetainedLinuxSctpEvidence">Whether retained Linux SCTP evidence is available.</param> |
| 119 | + /// <param name="hasRetainedExternalPeerEvidence">Whether retained external peer evidence is available.</param> |
| 120 | + /// <returns>The current SCTP production hardening readiness report.</returns> |
| 121 | + public static SctpProductionHardeningReadinessReport GetReport( |
| 122 | + bool hasRetainedLinuxSctpEvidence = false, |
| 123 | + bool hasRetainedExternalPeerEvidence = false) |
| 124 | + { |
| 125 | + return new( |
| 126 | + hasStreamAndPpidFraming: true, |
| 127 | + hasAssociationLifecycleJournal: true, |
| 128 | + hasReconnectSchedule: true, |
| 129 | + hasSendBackpressurePolicy: true, |
| 130 | + hasOperationTimeoutPolicy: true, |
| 131 | + hasMultiHomingReadiness: true, |
| 132 | + hasFaultRecovery: true, |
| 133 | + hasTransportDiagnostics: true, |
| 134 | + hasRetainedLinuxSctpEvidence, |
| 135 | + hasRetainedExternalPeerEvidence); |
| 136 | + } |
| 137 | +} |
0 commit comments