Table of Contents

Interface IPacketTransport

Namespace
VpnHood.Net.PacketTransports
Assembly
VpnHood.Net.PacketTransports.dll

Represents a two-way channel of IP packets: packets sent to it are queued and sent on, and packets it receives are raised through PacketReceived.

public interface IPacketTransport : IDisposable
Inherited Members

Remarks

A packet handed to the transport, or raised by it, has one owner at a time: whoever holds it disposes it, or hands it on.

Properties

IsSending

Gets a value indicating whether the transport has packets queued or a batch in flight.

bool IsSending { get; }

Property Value

bool

PacketStat

Gets the transport's counters: packets and bytes sent and received, drops, and the times of the last activity.

ReadOnlyPacketTransportStat PacketStat { get; }

Property Value

ReadOnlyPacketTransportStat

Methods

SendPacketQueued(IpPacket)

Queues a packet to send. The transport takes the packet whatever the outcome: it is never the caller's again.

bool SendPacketQueued(IpPacket ipPacket)

Parameters

ipPacket IpPacket

The packet.

Returns

bool

true if the packet was queued, or sent; false if it was refused or dropped, and disposed.

Exceptions

ObjectDisposedException

The transport is disposed; the packet is disposed too.

InvalidOperationException

A passthrough transport's send did not complete at once.

SendPacketQueuedAsync(IpPacket)

Queues a packet to send, waiting without a thread for room when the queue is full and the transport blocks. The transport takes the packet whatever the outcome.

ValueTask SendPacketQueuedAsync(IpPacket ipPacket)

Parameters

ipPacket IpPacket

The packet.

Returns

ValueTask

A task that represents the asynchronous operation. It completes when the packet is queued or dropped.

Exceptions

ObjectDisposedException

The transport is disposed; the packet is disposed too.

InvalidOperationException

A passthrough transport's send did not complete at once.

ChannelClosedException

The queue closed during the send, as the transport is being disposed; the packet is disposed too.

Events

PacketReceived

Occurs when the transport receives a packet. The handler takes the packet: it delivers or disposes it, or throws to give it back to the transport, which disposes it. Attach one handler only: a second could see a packet the first one disposed or handed on.

event EventHandler<IpPacket>? PacketReceived

Event Type

EventHandler<IpPacket>