ddn.net.dtls.transport

DTLS transport abstraction layer.

Provides concrete implementations of the datagram transport and timer interfaces defined in ddn.api.net.dtls. Includes in-memory transport and manual timer for unit testing.

Types 2

In-memory DTLS transport for unit testing.

Datagrams written via sendTo() are buffered and can be retrieved via recvFrom() on a connected peer transport. Useful for testing DTLS logic without real network I/O.

Fields
bool open_
DatagramEndpoint localAddr_
QueuedDatagram[] inbox_
Methods
void connect(MemoryDtlsTransport a, MemoryDtlsTransport b)Connect two MemoryDtlsTransport instances for bidirectional communication.
ptrdiff_t recvFrom(ubyte[] buffer, out DatagramEndpoint sender)Receive a single datagram.
ptrdiff_t sendTo(const(ubyte)[] data, DatagramEndpoint dest)Send a single datagram to the given address.
PollHandle pollHandle() @property constReturns an invalid PollHandle (memory transport has no OS handle).
bool isOpen() @property constReturns whether the transport is still open.
void close()Close the transport.
size_t pendingCount() @property constReturns the number of queued incoming datagrams.
void injectDatagram(const(ubyte)[] data, DatagramEndpoint sender)Inject a datagram directly into the inbox for testing.
DatagramEndpoint localAddress() @property constReturns the local address of this transport.
void localAddress(DatagramEndpoint addr) @propertySets the local address of this transport.
Constructors
this(DatagramEndpoint localAddr = DatagramEndpoint.init)Constructs a MemoryDtlsTransport with an optional local address.

Manual timer sink for unit testing.

Allows explicit triggering of scheduled timeouts for deterministic testing of DTLS retransmission logic.

Fields
Duration scheduledDelay_
void delegate() callback_
bool hasTimeout_
Methods
void scheduleTimeout(Duration delay, void delegate() onTimeout)Schedule a timeout callback.
void cancelTimeout()Cancel any previously scheduled timeout.
bool hasPendingTimeout() @property constCheck if a timeout is currently scheduled.
Duration pendingDelay() @property constGet the scheduled delay duration.
bool trigger()Manually trigger the scheduled timeout.