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);
111 bool IsConnected(
void);
116 bool IsTlsConnected(
void);
128 int GetRemotePort(
void);
229 int Send(
const void* pBuffer,
size_t length,
SocketError& error);
238 int Receive(
void* pBuffer,
size_t length,
SocketError& error);
380 SocketError SetOptionLinger(
bool enable,
size_t timeout);
388 SocketError GetOptionLinger(
bool& enable,
size_t& timeout);
435 void SetCipherList(
String cipherList);
450 SocketError HandleSslResult(
int result,
int* sslErrorOut =
nullptr);
451 int GetFileDescriptor(
void);
452 void ClearOpenSslErrors(
void);
456 SSL* sslConnection =
nullptr;
457 TlsContext::Ptr pContext;
459 Ptr currentAcceptSocket;
463 bool socketIsConnected;
466 bool tlsConnectIsPending;
467 bool pendingTlsConnectNeedsRead;
477 return this->pSocket->GetSocketType();
482 return this->pSocket->GetSocketDomain();
485 inline bool TlsSocket::IsBlocking(
void)
487 return this->pSocket->IsBlocking();
492 return this->pSocket->GetRemoteIpAddress();
495 inline int TlsSocket::GetRemotePort(
void)
497 return this->pSocket->GetRemotePort();
500 inline bool TlsSocket::IsConnected(
void)
502 return (!this->hasSslError) && (this->tlsIsConnected || this->socketIsConnected);
505 inline bool TlsSocket::IsTlsConnected(
void)
507 return (!this->hasSslError) && (this->tlsIsConnected);
512 return pSocket->Bind(ip4Address, port);
517 return pSocket->Bind2(ip4Address, port);
523 return pSocket->Listen(backlog);
528 return this->pSocket->SetSocketOption(optionName, optionValue, optionLength);
533 return this->pSocket->GetSocketOption(optionName, optionValue, optionLength);
538 return this->pSocket->SetOptionReuseAddress(enabled);
541 inline SocketError TlsSocket::GetOptionReuseAddress(
bool& enabled)
543 return this->pSocket->GetOptionReuseAddress(enabled);
548 return this->pSocket->SetOptionKeepAlive(enabled);
553 return this->pSocket->GetOptionKeepAlive(enabled);
558 return this->pSocket->SetOptionBroadcast(enabled);
563 return this->pSocket->GetOptionBroadcast(enabled);
568 return this->pSocket->SetOptionNoDelay(enabled);
573 return this->pSocket->GetOptionNoDelay(enabled);
576 inline SocketError TlsSocket::SetOptionLinger(
bool enable,
size_t timeout)
578 return this->pSocket->SetOptionLinger(enable, timeout);
581 inline SocketError TlsSocket::GetOptionLinger(
bool& enable,
size_t& timeout)
583 return this->pSocket->GetOptionLinger(enable, timeout);
588 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
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: TypeSystem.h:36
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
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:122
SocketDomain
Supported communication domains, selecting the protocol for communication.
Definition: SocketDomain.hpp:13
Definition: Loggable.hxx:18
PollMode
This enum is used to specifiy the poll mode of the <cref name="Socket::Poll"> operation.
Definition: PollMode.hpp:14
Root namespace for the PLCnext API
SocketBlockingMode
Supported blocking modes.
Definition: Socket.hpp:27
ShutdownMode
This enum is used to specifiy the shutdown mode of the <cref name="Socket::Shutdown(ShutdownMode)"> o...
Definition: ShutdownMode.hpp:14
SelectMode
Modes for Select call to check different data channels.
Definition: SelectMode.hpp:13
Connect operation should be polled.
Unified representation for ip address schemes.
Definition: IpAddress.hpp:13
System components used by the System, Device, Plc or Io domains.
Accept operation should be polled.
Interface to realize TLS Connection over TCP
Definition: TlsSocket.hpp:31