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);
225 int Send(
const void* pBuffer,
size_t length,
SocketError& error);
234 int Receive(
void* pBuffer,
size_t length,
SocketError& error);
361 SocketError SetOptionLinger(
bool enable,
size_t timeout);
369 SocketError GetOptionLinger(
bool& enable,
size_t& timeout);
416 void SetCipherList(
String cipherList);
427 SocketError HandleSslResult(
int result,
int* sslErrorOut =
nullptr);
428 int GetFileDescriptor(
void);
429 void ClearOpenSslErrors(
void);
433 SSL* sslConnection =
nullptr;
434 TlsContext::Ptr pContext;
436 Ptr currentAcceptSocket;
440 bool socketIsConnected;
443 bool tlsConnectIsPending;
444 bool pendingTlsConnectNeedsRead;
454 return this->pSocket->GetSocketType();
459 return this->pSocket->GetSocketDomain();
462 inline bool TlsSocket::IsBlocking(
void)
464 return this->pSocket->IsBlocking();
469 return this->pSocket->GetRemoteIpAddress();
472 inline int TlsSocket::GetRemotePort(
void)
474 return this->pSocket->GetRemotePort();
477 inline bool TlsSocket::IsConnected(
void)
479 return (!this->hasSslError) && (this->tlsIsConnected || this->socketIsConnected);
482 inline bool TlsSocket::IsTlsConnected(
void)
484 return (!this->hasSslError) && (this->tlsIsConnected);
489 return pSocket->Bind(ip4Address, port);
494 return pSocket->Bind2(ip4Address, port);
500 return pSocket->Listen(backlog);
505 return this->pSocket->SetSocketOption(optionName, optionValue, optionLength);
510 return this->pSocket->GetSocketOption(optionName, optionValue, optionLength);
515 return this->pSocket->SetOptionReuseAddress(enabled);
518 inline SocketError TlsSocket::GetOptionReuseAddress(
bool& enabled)
520 return this->pSocket->GetOptionReuseAddress(enabled);
525 return this->pSocket->SetOptionKeepAlive(enabled);
530 return this->pSocket->GetOptionKeepAlive(enabled);
535 return this->pSocket->SetOptionBroadcast(enabled);
540 return this->pSocket->GetOptionBroadcast(enabled);
545 return this->pSocket->SetOptionNoDelay(enabled);
550 return this->pSocket->GetOptionNoDelay(enabled);
553 inline SocketError TlsSocket::SetOptionLinger(
bool enable,
size_t timeout)
555 return this->pSocket->SetOptionLinger(enable, timeout);
558 inline SocketError TlsSocket::GetOptionLinger(
bool& enable,
size_t& timeout)
560 return this->pSocket->GetOptionLinger(enable, timeout);
565 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
Definition: ItemInfo.hpp:8
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