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);
223 int Send(
const void* pBuffer,
size_t length,
SocketError& error);
232 int Receive(
void* pBuffer,
size_t length,
SocketError& error);
359 SocketError SetOptionLinger(
bool enable,
size_t timeout);
367 SocketError GetOptionLinger(
bool& enable,
size_t& timeout);
414 void SetCipherList(
String cipherList);
425 SocketError HandleSslResult(
int result,
int* sslErrorOut =
nullptr);
426 int GetFileDescriptor(
void);
427 void ClearOpenSslErrors(
void);
431 SSL* sslConnection =
nullptr;
432 TlsContext::Ptr pContext;
434 Ptr currentAcceptSocket;
438 bool socketIsConnected;
441 bool tlsConnectIsPending;
442 bool pendingTlsConnectNeedsRead;
452 return this->pSocket->GetSocketType();
457 return this->pSocket->GetSocketDomain();
460 inline bool TlsSocket::IsBlocking(
void)
462 return this->pSocket->IsBlocking();
467 return this->pSocket->GetRemoteIpAddress();
470 inline int TlsSocket::GetRemotePort(
void)
472 return this->pSocket->GetRemotePort();
475 inline bool TlsSocket::IsConnected(
void)
477 return (!this->hasSslError) && (this->tlsIsConnected || this->socketIsConnected);
480 inline bool TlsSocket::IsTlsConnected(
void)
482 return (!this->hasSslError) && (this->tlsIsConnected);
487 return pSocket->Bind(ip4Address, port);
492 return pSocket->Bind2(ip4Address, port);
498 return pSocket->Listen(backlog);
503 return this->pSocket->SetSocketOption(optionName, optionValue, optionLength);
508 return this->pSocket->GetSocketOption(optionName, optionValue, optionLength);
513 return this->pSocket->SetOptionReuseAddress(enabled);
516 inline SocketError TlsSocket::GetOptionReuseAddress(
bool& enabled)
518 return this->pSocket->GetOptionReuseAddress(enabled);
523 return this->pSocket->SetOptionKeepAlive(enabled);
528 return this->pSocket->GetOptionKeepAlive(enabled);
533 return this->pSocket->SetOptionBroadcast(enabled);
538 return this->pSocket->GetOptionBroadcast(enabled);
543 return this->pSocket->SetOptionNoDelay(enabled);
548 return this->pSocket->GetOptionNoDelay(enabled);
551 inline SocketError TlsSocket::SetOptionLinger(
bool enable,
size_t timeout)
553 return this->pSocket->SetOptionLinger(enable, timeout);
556 inline SocketError TlsSocket::GetOptionLinger(
bool& enable,
size_t& timeout)
558 return this->pSocket->GetOptionLinger(enable, timeout);
563 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