Class DtlsSrtpTransport
Class for managing the transport logic for a DTLS SRTP client or a server.
Inherited Members
Namespace: SipLib.Dtls
Assembly: SipLib.dll
Syntax
public class DtlsSrtpTransport : DatagramTransport, TlsCloseable, IDisposable
Constructors
| Edit this page View SourceDtlsSrtpTransport(IDtlsSrtpPeer, int)
Constructor
Declaration
public DtlsSrtpTransport(IDtlsSrtpPeer connection, int mtu = 1500)
Parameters
Type | Name | Description |
---|---|---|
IDtlsSrtpPeer | connection | A DtlsSrtpClient object or a DtlsSrtpServer object that this transport object will manage |
int | mtu | Maximum transfer unit for the network. Defaults to 1500. |
Fields
| Edit this page View SourceOnDataReady
Event that is fired when there is data that needs to be sent via UDP
Declaration
public Action<byte[]>? OnDataReady
Field Value
Type | Description |
---|---|
Action<byte[]> |
RetransmissionMilliseconds
Sets the period in milliseconds that receive will wait before try retransmission
Declaration
public int RetransmissionMilliseconds
Field Value
Type | Description |
---|---|
int |
TimeoutMilliseconds
Sets the period in milliseconds that the handshake attempt will timeout after.
Declaration
public int TimeoutMilliseconds
Field Value
Type | Description |
---|---|
int |
Properties
| Edit this page View SourceIsClient
Returns true if this transport object is for a DTLS client or false if its for a DTLS server.
Declaration
public bool IsClient { get; }
Property Value
Type | Description |
---|---|
bool |
SrtcpDecoder
Gets the SRTCP decoder
Declaration
public IPacketTransformer SrtcpDecoder { get; }
Property Value
Type | Description |
---|---|
IPacketTransformer |
SrtcpEncoder
Gets the SRTCP decoder
Declaration
public IPacketTransformer SrtcpEncoder { get; }
Property Value
Type | Description |
---|---|
IPacketTransformer |
SrtpDecoder
Gets the SRTP decoder
Declaration
public IPacketTransformer SrtpDecoder { get; }
Property Value
Type | Description |
---|---|
IPacketTransformer |
SrtpEncoder
Gets the SRTP encoder
Declaration
public IPacketTransformer SrtpEncoder { get; }
Property Value
Type | Description |
---|---|
IPacketTransformer |
Transport
Gets or sets the DTLS transport object
Declaration
public DtlsTransport? Transport { get; }
Property Value
Type | Description |
---|---|
DtlsTransport |
Methods
| Edit this page View SourceBackOff(int)
Handle retransmission time based in DTLS 1.3
Declaration
protected virtual int BackOff(int currentWaitMillis)
Parameters
Type | Name | Description |
---|---|---|
int | currentWaitMillis |
Returns
Type | Description |
---|---|
int |
Close()
Closes this transport object.
Declaration
public virtual void Close()
Dispose()
Close the transport if the instance is out of scope.
Declaration
public void Dispose()
Dispose(bool)
Close the transport if the instance is out of scope.
Declaration
protected void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
DoHandshake(out string?)
Starts the DTLS handshake as a client or as a server. This method blocks until the handshake is complete.
Declaration
public bool DoHandshake(out string? handshakeError)
Parameters
Type | Name | Description |
---|---|---|
string | handshakeError | Set to a string that describes the handshake error. Set to null if no errors occurred. Will be non-null if this method returns false. |
Returns
Type | Description |
---|---|
bool | Returns true if successful or false if a handshake error occurred. |
GenerateRtcpDecoder()
Generates an IPacketTransformer interface to use to decode RTCP packets
Declaration
protected IPacketTransformer GenerateRtcpDecoder()
Returns
Type | Description |
---|---|
IPacketTransformer |
GenerateRtcpEncoder()
Generates an IPacketTransformer interface to use to encode RTCP packets
Declaration
protected IPacketTransformer GenerateRtcpEncoder()
Returns
Type | Description |
---|---|
IPacketTransformer |
GenerateRtpDecoder()
Generates an IPacketTransformer interface to use to decode RTP packets
Declaration
protected IPacketTransformer GenerateRtpDecoder()
Returns
Type | Description |
---|---|
IPacketTransformer |
GenerateRtpEncoder()
Generates an IPacketTransformer interface to use to encode RTP packets
Declaration
protected IPacketTransformer GenerateRtpEncoder()
Returns
Type | Description |
---|---|
IPacketTransformer |
GenerateTransformer(bool, bool)
Generates an IPacketTransformer for a DTLS client or server for RTP or RTCP packets
Declaration
protected IPacketTransformer GenerateTransformer(bool isClient, bool isRtp)
Parameters
Type | Name | Description |
---|---|---|
bool | isClient | Set to true to generate the transformer for the client or false to generate the transformer for the server. |
bool | isRtp | Set to true to generate the transformer for RTP packets or to false to generate the transformer for RTCP packets |
Returns
Type | Description |
---|---|
IPacketTransformer |
GetMasterClientKey()
Gets the client's master key
Declaration
protected byte[] GetMasterClientKey()
Returns
Type | Description |
---|---|
byte[] |
GetMasterClientSalt()
Gets the client's master salt
Declaration
protected byte[] GetMasterClientSalt()
Returns
Type | Description |
---|---|
byte[] |
GetMasterServerKey()
Gets the server's master key
Declaration
protected byte[] GetMasterServerKey()
Returns
Type | Description |
---|---|
byte[] |
GetMasterServerSalt()
Gets the server's master salt
Declaration
protected byte[] GetMasterServerSalt()
Returns
Type | Description |
---|---|
byte[] |
GetReceiveLimit()
Returns the maximum number of bytes that can be received
Declaration
public int GetReceiveLimit()
Returns
Type | Description |
---|---|
int |
GetRemoteCertificate()
Gets the X.509 certificate of the remote peer
Declaration
public Certificate GetRemoteCertificate()
Returns
Type | Description |
---|---|
Certificate |
GetSendLimit()
Returns the maximum number of bytes that can be sent
Declaration
public int GetSendLimit()
Returns
Type | Description |
---|---|
int |
GetSrtcpPolicy()
Gets the SRTCP encryption and authenticaion policy information for the DTLS-SRTP session
Declaration
protected SrtpPolicy GetSrtcpPolicy()
Returns
Type | Description |
---|---|
SrtpPolicy |
GetSrtpPolicy()
Gets the SRTCP encryption and authenticaion policy information for the DTLS-SRTP session
Declaration
protected SrtpPolicy GetSrtpPolicy()
Returns
Type | Description |
---|---|
SrtpPolicy |
IsHandshakeComplete()
Returns true if the DTLS handshake is complete or false if it is not
Declaration
public bool IsHandshakeComplete()
Returns
Type | Description |
---|---|
bool |
IsHandshakeFailed()
Returns true if the DTLS hanshake failed or false if it did not
Declaration
public bool IsHandshakeFailed()
Returns
Type | Description |
---|---|
bool |
IsHandshaking()
Returns true if the DTLS handshake is in progress
Declaration
public bool IsHandshaking()
Returns
Type | Description |
---|---|
bool |
ProtectRTCP(byte[], int, int)
Protects (encrypts) a compete RTCP packet
Declaration
public byte[] ProtectRTCP(byte[] packet, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | packet | The complete RTCP packet to protect |
int | offset | Offset to the RTCP packet |
int | length | Number of bytes in the RTCP packet |
Returns
Type | Description |
---|---|
byte[] | Returns the encrypted RTCP packet |
ProtectRTP(byte[], int, int)
Protects (encrypts) a complete RTP packet.
Declaration
public byte[] ProtectRTP(byte[] packet, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | packet | Complete RTP packet to encrypt |
int | offset | Offset to the RTP packet |
int | length | Number of bytes in the RTP packet |
Returns
Type | Description |
---|---|
byte[] | Returns the encrypted RTP packet |
Receive(byte[], int, int, int)
Implementation of the ReciveMethod of the BouncyCastle DatagramTransport interface. Users of the DtlsSrtpTransport class must not call this method.
Declaration
public int Receive(byte[] buf, int off, int len, int waitMillis)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buf | |
int | off | |
int | len | |
int | waitMillis |
Returns
Type | Description |
---|---|
int |
Send(byte[], int, int)
Implementation of the Send() method of the BouncyCastle DatagramTransport interface. Users of the DtlsSrtpTransport class must not call this method.
Declaration
public void Send(byte[] buf, int off, int len)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buf | |
int | off | |
int | len |
UnprotectRTCP(byte[], int, int)
Unprotects (decrypts) a complete RTCP packet
Declaration
public byte[] UnprotectRTCP(byte[] packet, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | packet | Complete RTCP packet to decrypt |
int | offset | Offset to the RTCP packet |
int | length | Number of bytes in the RTCP packet |
Returns
Type | Description |
---|---|
byte[] | Returns the decrypted RTCP packet |
UnprotectRTP(byte[], int, int)
Unprotects (decrypts) an RTP packet received from the remote endpoint. Only call this method if IsHandshake() complete returns true and IsHandshakeFailed() returns false
Declaration
public byte[] UnprotectRTP(byte[] packet, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | packet | Complete RTP packet that was receivedincluding the RTP header |
int | offset | Offset into the input of the RTP packet |
int | length | Number of bytes in the RTP packet |
Returns
Type | Description |
---|---|
byte[] |
WriteToRecvStream(byte[])
Call this method to send a UDP packet that has been received from the network to the receive stream of the DTLS handshake logic. Only call this method if the DTLS handshake has not been completed.
Declaration
public void WriteToRecvStream(byte[] buf)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buf | The UDP packet that was received from the network. |
Events
| Edit this page View SourceOnAlert
Event that is fired if a DTlS protocol Alert occurs
Declaration
public event Action<AlertLevelsEnum, AlertTypesEnum, string>? OnAlert
Event Type
Type | Description |
---|---|
Action<AlertLevelsEnum, AlertTypesEnum, string> |