join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicDtlsWrapper< Protocol > Class Template Reference

DTLS decorator for datagram sockets. More...

#include <dtls_wrapper.hpp>

Inheritance diagram for join::BasicDtlsWrapper< Protocol >:
Collaboration diagram for join::BasicDtlsWrapper< Protocol >:

Public Types

using Endpoint = typename BasicTls<Protocol>::Endpoint
 
- Public Types inherited from join::BasicTls< Protocol >
using UnderlyingSocket = typename Protocol::Transport::Socket
 
using Mode = typename UnderlyingSocket::Mode
 
using Option = typename UnderlyingSocket::Option
 
using State = typename UnderlyingSocket::State
 
using Endpoint = typename Protocol::Endpoint
 
using TimePoint = typename UnderlyingSocket::TimePoint
 

Public Member Functions

ssize_t readFrom (char *buf, size_t len, Endpoint *endpoint=nullptr) noexcept
 read data on the socket.
 
ssize_t writeTo (const char *buf, size_t len, const Endpoint &endpoint) noexcept
 write data on the socket.
 
int ttl () const noexcept
 returns the Time-To-Live value.
 
- Public Member Functions inherited from join::BasicTls< Protocol >
 BasicTls (TlsContext ctx, Mode mode=Mode::NonBlocking) noexcept
 create a TLS decorator with an internally created socket.
 
 BasicTls (UnderlyingSocket &&socket) noexcept
 create a TLS decorator taking ownership of the given socket, without context.
 
 BasicTls (UnderlyingSocket &&socket, TlsContext ctx) noexcept
 create a TLS decorator taking ownership of the given socket.
 
 BasicTls (const BasicTls &other)=delete
 copy constructor.
 
BasicTlsoperator= (const BasicTls &other)=delete
 copy assignment operator.
 
 BasicTls (BasicTls &&other) noexcept
 move constructor.
 
BasicTlsoperator= (BasicTls &&other) noexcept
 move assignment operator.
 
virtual ~BasicTls ()=default
 destroy the instance.
 
int open (const Protocol &protocol=Protocol()) noexcept
 open the underlying socket using the given protocol.
 
bool opened () const noexcept
 check if the underlying socket is opened.
 
int bind (const Endpoint &ep) noexcept
 assigns the specified endpoint to the underlying socket.
 
int bindToDevice (const std::string &dev) noexcept
 assigns the specified device to the underlying socket.
 
int connect (const Endpoint &ep) noexcept
 connect the underlying socket to the remote endpoint.
 
bool connected () noexcept
 check if the underlying socket is connected.
 
int deferHandshake ()
 set the TLS layer up without negotiating immediately.
 
int handshake ()
 perform the TLS handshake.
 
bool waitHandshake ()
 block until TLS handshake is finished.
 
bool waitHandshake (std::chrono::nanoseconds timeout)
 block until TLS handshake is finished, giving up after the given duration.
 
virtual bool waitHandshake (TimePoint deadline)
 block until TLS handshake is finished, giving up at the given time point.
 
bool encrypted () const noexcept
 check if the stream is encrypted.
 
int shutdown () noexcept
 Perform the TLS shutdown.
 
bool waitShutdown () noexcept
 block until TLS shutdown is finished.
 
bool waitShutdown (std::chrono::nanoseconds timeout) noexcept
 block until TLS shutdown is finished, giving up after the given duration.
 
bool waitShutdown (TimePoint deadline) noexcept
 block until TLS shutdown is finished, giving up at the given time point.
 
int disconnect () noexcept
 disconnect the underlying socket from the remote endpoint.
 
void close () noexcept
 close the socket handle.
 
bool waitReadyRead () const noexcept
 block until new data is available for reading.
 
bool waitReadyRead (std::chrono::nanoseconds timeout) const noexcept
 block until new data is available for reading, giving up after the given duration.
 
bool waitReadyRead (TimePoint deadline) const noexcept
 block until new data is available for reading, giving up at the given time point.
 
ssize_t read (char *buf, size_t len) noexcept
 read data from the TLS stream.
 
int readExactly (char *data, size_t size)
 read data until size is reached or an error occurred.
 
int readExactly (char *data, size_t size, std::chrono::nanoseconds timeout)
 read data until size is reached, an error occurred or the given duration elapsed.
 
int readExactly (char *data, size_t size, TimePoint deadline)
 read data until size is reached, an error occurred or the deadline expired.
 
bool waitReadyWrite () const noexcept
 block until at least one byte can be written on the socket.
 
bool waitReadyWrite (std::chrono::nanoseconds timeout) const noexcept
 block until at least one byte can be written on the socket, giving up after the given duration.
 
bool waitReadyWrite (TimePoint deadline) const noexcept
 block until at least one byte can be written, giving up at the given time point.
 
ssize_t write (const char *buf, size_t len) noexcept
 write data to the TLS stream.
 
int writeExactly (const char *data, size_t size)
 write data until size is reached or an error occurred.
 
int writeExactly (const char *data, size_t size, std::chrono::nanoseconds timeout)
 write data until size is reached, an error occurred or the given duration elapsed.
 
int writeExactly (const char *data, size_t size, TimePoint deadline)
 write data until size is reached, an error occurred or the deadline expired.
 
void setMode (Mode mode) noexcept
 set the mode of the underlying socket.
 
int setOption (Option opt, int val) noexcept
 set an option for the underlying socket.
 
int handle () const noexcept
 get the underlying socket handle.
 
int family () const noexcept
 get the underlying socket address family.
 
int type () const noexcept
 get the underlying socket type.
 
int protocol () const noexcept
 get the underlying protocol.
 
int mtu () const noexcept
 get the maximum transmission unit.
 
Endpoint localEndpoint () const noexcept
 get the local endpoint.
 
Endpoint remoteEndpoint () const
 get the remote endpoint.
 

Additional Inherited Members

- Protected Member Functions inherited from join::BasicTls< Protocol >
int handleTlsError (int result) noexcept
 handle TLS error.
 
void infoCallback (int where, int ret) const noexcept
 SSL state info callback.
 
int verifyCallback (int preverified, X509_STORE_CTX *context) noexcept
 verify peer certificate.
 
int verifyCert (X509_STORE_CTX *context) const
 verify certificate validity.
 
bool checkHostname (X509 *certificate) const noexcept
 check certificate hostname against remote endpoint.
 
- Static Protected Member Functions inherited from join::BasicTls< Protocol >
static void infoWrapper (const SSL *ssl, int where, int ret) noexcept
 c style info callback wrapper.
 
static int verifyWrapper (int preverified, X509_STORE_CTX *x509Ctx) noexcept
 c style verify callback wrapper.
 
- Protected Attributes inherited from join::BasicTls< Protocol >
UnderlyingSocket _socket
 verify certificate revocation using CRL.
 
TlsContext _ctx
 TLS context.
 
SslPtr _ssl
 TLS handle.
 

Detailed Description

template<class Protocol>
class join::BasicDtlsWrapper< Protocol >

DTLS decorator for datagram sockets.

Member Typedef Documentation

◆ Endpoint

template<class Protocol >
using join::BasicDtlsWrapper< Protocol >::Endpoint = typename BasicTls<Protocol>::Endpoint

Member Function Documentation

◆ readFrom()

template<class Protocol >
ssize_t join::BasicDtlsWrapper< Protocol >::readFrom ( char * buf,
size_t len,
Endpoint * endpoint = nullptr )
inlinenoexcept

read data on the socket.

Parameters
bufbuffer used to store the data received.
lenmaximum number of bytes to read.
endpointendpoint from where data are coming (optional).
Returns
The number of bytes received, -1 on failure.

◆ ttl()

template<class Protocol >
int join::BasicDtlsWrapper< Protocol >::ttl ( ) const
inlinenoexcept

returns the Time-To-Live value.

Returns
The Time-To-Live value.

◆ writeTo()

template<class Protocol >
ssize_t join::BasicDtlsWrapper< Protocol >::writeTo ( const char * buf,
size_t len,
const Endpoint & endpoint )
inlinenoexcept

write data on the socket.

Parameters
bufbuffer to write from.
lennumber of bytes to write.
endpointendpoint where to write the data.
Returns
the number of bytes written, -1 on failure.

The documentation for this class was generated from the following files: