Skip to content

Commit f8f7925

Browse files
committed
Add native SCTP lab profile
1 parent afc7138 commit f8f7925

5 files changed

Lines changed: 94 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The first production milestone is M3UA over a transport abstraction. SCCP, TCAP,
4545
| Observability | Phase 7 profile added for commercial metrics, trace categories, and health signals |
4646
| Deployment profiles | Phase 7 profiles added for commercial Linux and local development use |
4747
| Phase 7 status | Commercialization foundation complete; commercial production remains blocked on native SCTP verification, external lab evidence, signing, and SBOM |
48-
| Native SCTP implementation | Phase 8 started: Linux SCTP socket probe, socket factory, endpoint connection planner, native socket adapter, client connector, and server listener added; full production readiness still requires native transport completion and lab verification |
48+
| Native SCTP implementation | Phase 8 started: Linux SCTP socket probe, socket factory, endpoint connection planner, native socket adapter, client connector, server listener, and opt-in lab profile added; full production readiness still requires native transport completion and lab verification |
4949

5050
## Requirements
5151

docs/PHASE8_NATIVE_SCTP.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,14 @@ NativeSctpSocketAdapter association = await listener.AcceptAsync(options);
7171
```
7272

7373
The listener shares the same socket factory and unsupported-platform behavior as the connector. Real accept/send/receive verification belongs in Linux SCTP lab runs.
74+
75+
## Lab Profile
76+
77+
Native SCTP lab tests are opt-in through `SIGTRAN_NATIVE_SCTP_LAB=1`.
78+
79+
```powershell
80+
$env:SIGTRAN_NATIVE_SCTP_LAB = "1"
81+
dotnet run --project src\sigtran.net.Tests\sigtran.net.Tests.csproj
82+
```
83+
84+
`NativeSctpLab.CreateFromEnvironment()` exposes the current lab profile. The default loopback endpoint is `127.0.0.1:2905`.

docs/SCTP_TRANSPORT.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,5 @@ The probe does not mark the transport production-ready by itself. It is the firs
134134
`NativeSctpConnector` performs the client-side bind/connect path and returns an established native adapter.
135135

136136
`NativeSctpListener` provides the server-side bind/listen/accept path for Linux native SCTP lab scenarios.
137+
138+
`NativeSctpLab.CreateFromEnvironment()` keeps native SCTP integration verification opt-in through `SIGTRAN_NATIVE_SCTP_LAB=1`.

src/sigtran.net.Tests/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Run("Native SCTP socket adapter reports lifecycle health", NativeSctpSocketAdapterReportsLifecycleHealth);
3737
Run("Native SCTP connector reports unsupported platform safely", NativeSctpConnectorReportsUnsupportedPlatformSafely);
3838
Run("Native SCTP listener validates options and unsupported platform", NativeSctpListenerValidatesOptionsAndUnsupportedPlatform);
39+
Run("Native SCTP lab profile is opt-in", NativeSctpLabProfileIsOptIn);
3940
Run("TCAP BER element encodes short and long lengths", TcapBerElementEncodesShortAndLongLengths);
4041
Run("TCAP transaction identifiers use BER context tags", TcapTransactionIdentifiersUseBerContextTags);
4142
Run("TCAP BER Invoke component round-trips", TcapBerInvokeComponentRoundTrips);
@@ -511,6 +512,27 @@ static void NativeSctpListenerValidatesOptionsAndUnsupportedPlatform()
511512
}
512513
}
513514

515+
static void NativeSctpLabProfileIsOptIn()
516+
{
517+
string? previous = Environment.GetEnvironmentVariable(NativeSctpLabProfile.EnableEnvironmentVariable);
518+
try
519+
{
520+
Environment.SetEnvironmentVariable(NativeSctpLabProfile.EnableEnvironmentVariable, null);
521+
NativeSctpLabProfile disabled = NativeSctpLab.CreateFromEnvironment();
522+
Assert(!disabled.Enabled, "native SCTP lab should be disabled by default");
523+
AssertEqual("127.0.0.1", disabled.LoopbackEndpoint.Host, "native SCTP lab loopback host");
524+
525+
Environment.SetEnvironmentVariable(NativeSctpLabProfile.EnableEnvironmentVariable, "1");
526+
NativeSctpLabProfile enabled = NativeSctpLab.CreateFromEnvironment();
527+
Assert(enabled.Enabled, "native SCTP lab should enable from environment");
528+
Assert(enabled.Describe().Contains("enabled=True", StringComparison.Ordinal), enabled.Describe());
529+
}
530+
finally
531+
{
532+
Environment.SetEnvironmentVariable(NativeSctpLabProfile.EnableEnvironmentVariable, previous);
533+
}
534+
}
535+
514536
static void TcapBerElementEncodesShortAndLongLengths()
515537
{
516538
Span<byte> shortBuffer = stackalloc byte[8];
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
namespace sigtran.net.Layers.SCTP;
2+
3+
/// <summary>
4+
/// Describes an opt-in native SCTP lab profile.
5+
/// </summary>
6+
public sealed class NativeSctpLabProfile
7+
{
8+
/// <summary>The environment variable that enables native SCTP lab tests.</summary>
9+
public const string EnableEnvironmentVariable = "SIGTRAN_NATIVE_SCTP_LAB";
10+
11+
/// <summary>Creates a native SCTP lab profile.</summary>
12+
/// <param name="enabled">Whether the profile is enabled.</param>
13+
/// <param name="loopbackEndpoint">The loopback SCTP endpoint.</param>
14+
/// <param name="requiresExternalPeer">Whether an external peer is required.</param>
15+
public NativeSctpLabProfile(bool enabled, SctpEndpoint loopbackEndpoint, bool requiresExternalPeer)
16+
{
17+
Enabled = enabled;
18+
LoopbackEndpoint = loopbackEndpoint ?? throw new ArgumentNullException(nameof(loopbackEndpoint));
19+
RequiresExternalPeer = requiresExternalPeer;
20+
}
21+
22+
/// <summary>Whether the profile is enabled.</summary>
23+
public bool Enabled { get; }
24+
25+
/// <summary>The loopback SCTP endpoint.</summary>
26+
public SctpEndpoint LoopbackEndpoint { get; }
27+
28+
/// <summary>Whether an external peer is required.</summary>
29+
public bool RequiresExternalPeer { get; }
30+
31+
/// <summary>Formats a compact lab profile summary.</summary>
32+
/// <returns>The lab profile summary.</returns>
33+
public string Describe()
34+
{
35+
return $"enabled={Enabled} loopback={LoopbackEndpoint} externalPeer={RequiresExternalPeer}";
36+
}
37+
}
38+
39+
/// <summary>
40+
/// Provides native SCTP lab profile helpers.
41+
/// </summary>
42+
public static class NativeSctpLab
43+
{
44+
/// <summary>Creates the current native SCTP lab profile from environment variables.</summary>
45+
/// <returns>The native SCTP lab profile.</returns>
46+
public static NativeSctpLabProfile CreateFromEnvironment()
47+
{
48+
bool enabled = string.Equals(
49+
Environment.GetEnvironmentVariable(NativeSctpLabProfile.EnableEnvironmentVariable),
50+
"1",
51+
StringComparison.Ordinal);
52+
53+
return new(
54+
enabled,
55+
new SctpEndpoint("127.0.0.1", 2905),
56+
requiresExternalPeer: false);
57+
}
58+
}

0 commit comments

Comments
 (0)