8 #include "Arp/System/Commons/Net/IpAddress.hpp" 9 #include "Arp/System/Commons/Net/Socket.hpp" 10 #include "Arp/System/Commons/Logging.h" 11 #include "Arp/System/Commons/Exceptions/Exceptions.h" 12 #include "Arp/System/Commons/Security/IdentityStore.hpp" 17 typedef struct ssl_st SSL;
18 typedef struct ssl_ctx_st SSL_CTX;
20 namespace Arp {
namespace System {
namespace Commons {
namespace Net
37 using Ptr = shared_ptr<TlsContext>;
41 TlsContext(
const TlsContext& arg) =
delete;
45 TlsContext& operator=(
const TlsContext& arg) =
delete;
48 SSL_CTX* pTlsCtx =
nullptr;
54 friend class TlsContext;
59 typedef std::shared_ptr<TlsSocket>
Ptr;
106 bool IsBlocking(
void);
116 bool IsTlsConnected(
void);
128 int GetRemotePort(
void);
207 int Send(
const void* pBuffer,
size_t length,
SocketError& error);
216 int Receive(
void* pBuffer,
size_t length,
SocketError& error);
343 SocketError SetOptionLinger(
bool enable,
size_t timeout);
351 SocketError GetOptionLinger(
bool& enable,
size_t& timeout);
398 void SetCipherList(
String cipherList);
409 SocketError HandleSslResult(
int result,
int* sslErrorOut =
nullptr);
410 int GetFileDescriptor(
void);
411 void ClearOpenSslErrors(
void);
415 SSL* sslConnection =
nullptr;
416 TlsContext::Ptr pContext;
418 Ptr currentAcceptSocket;
422 bool socketIsConnected;
425 bool tlsConnectIsPending;
426 bool pendingTlsConnectNeedsRead;
436 return this->pSocket->GetSocketType();
441 return this->pSocket->GetSocketDomain();
444 inline bool TlsSocket::IsBlocking(
void)
446 return this->pSocket->IsBlocking();
451 return this->pSocket->GetRemoteIpAddress();
454 inline int TlsSocket::GetRemotePort(
void)
456 return this->pSocket->GetRemotePort();
459 inline bool TlsSocket::IsConnected(
void)
461 return (!this->hasSslError) && (this->tlsIsConnected || this->socketIsConnected);
464 inline bool TlsSocket::IsTlsConnected(
void)
466 return (!this->hasSslError) && (this->tlsIsConnected);
471 return pSocket->Bind(ip4Address, port);
476 return pSocket->Listen(backlog);
481 return this->pSocket->SetSocketOption(optionName, optionValue, optionLength);
486 return this->pSocket->GetSocketOption(optionName, optionValue, optionLength);
491 return this->pSocket->SetOptionReuseAddress(enabled);
494 inline SocketError TlsSocket::GetOptionReuseAddress(
bool& enabled)
496 return this->pSocket->GetOptionReuseAddress(enabled);
501 return this->pSocket->SetOptionKeepAlive(enabled);
506 return this->pSocket->GetOptionKeepAlive(enabled);
511 return this->pSocket->SetOptionBroadcast(enabled);
516 return this->pSocket->GetOptionBroadcast(enabled);
521 return this->pSocket->SetOptionNoDelay(enabled);
526 return this->pSocket->GetOptionNoDelay(enabled);
529 inline SocketError TlsSocket::SetOptionLinger(
bool enable,
size_t timeout)
531 return this->pSocket->SetOptionLinger(enable, timeout);
534 inline SocketError TlsSocket::GetOptionLinger(
bool& enable,
size_t& timeout)
536 return this->pSocket->GetOptionLinger(enable, timeout);
541 return this->pSocket->SetOptionBlocking(enable);
SocketType
Enumeration of supported socket types.
Definition: SocketType.hpp:13
SocketError
Possible error codes for socket operation results.
Definition: SocketError.hpp:14
Check if a connect request can be performed.
SocketOptionName
Specifies socket options to be set by the application. Copied from Eclr Socket Adaption ...
Definition: SocketOptionName.hpp:16
Arp::System::Ve::ISocketService ISocketService
Injection of SocketService-Interface in class context.
Definition: TlsSocket.hpp:62
A connect request was made on an already connected socket.
std::shared_ptr< TlsSocket > Ptr
Contextual definition of pointer type.
Definition: TlsSocket.hpp:59
Namespace for classes dealing with certificates
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:34
std::shared_ptr< Socket > Ptr
Contextual definition of pointer type.
Definition: Socket.hpp:120
SocketDomain
Supported communication domains, selecting the protocol for communication.
Definition: SocketDomain.hpp:13
Definition: Loggable.hxx:18
Root namespace for the PLCnext API
SocketBlockingMode
Supported blocking modes.
Definition: Socket.hpp:25
Check if a connection request is pending.
A request to send or receive data was disallowed because the socket had already been shut down in tha...
SelectMode
Modes for Select call to check different data channels.
Definition: SelectMode.hpp:13
Unified representation for ip address schemes.
Definition: IpAddress.hpp:13
System components used by the System, Device, Plc or Io domains.
Interface to realize TLS Connection over TCP
Definition: TlsSocket.hpp:31