8#include "Arp/System/Core/PimplPtr.hxx"
9#include "Arp/System/Commons/Net/Socket.hpp"
10#include "Arp/System/Commons/Net/TlsOptions.hpp"
11#include "Arp/System/Commons/Security/Certificate.hpp"
12#include "Arp/System/Commons/Net/TlsVerificationError.hpp"
13#include "Arp/System/Commons/Net/TlsAlertType.hpp"
14#include "Arp/System/Commons/Net/TlsAlertLevel.hpp"
17namespace Arp {
namespace System {
namespace Commons {
namespace Net
24using TlsContextPtr = std::shared_ptr<TlsContext>;
39 using Ptr = std::shared_ptr<TlsSocket2>;
513 const Impl& GetImpl(
void)
const;
Definition: Loggable.hxx:20
Unified representation for ip address schemes.
Definition: IpAddress.hpp:14
std::shared_ptr< Socket > Ptr
Contextual definition of pointer type.
Definition: Socket.hpp:122
Interface to realize TLS Connection over TCP
Definition: TlsSocket2.hpp:34
void RemoveAlertSendHandler(const AlertHandler &handler)
Removes a AlertSend handler again
SocketError GetSocketOption(SocketOptionName optionName, void *optionValue, size_t *optionLength)
Returns current value of queried socket option.
SocketError SetOptionBlocking(bool enable)
Enables/disables the blocking mode of this socket..
SocketError InitClient(const String &trustStoreName, const String &identityStoreName, const String &hostName)
SocketError SetOptionNoDelay(bool enabled)
Enables/Disables no-delay for this socket.
int Poll(PollMode mode, Milliseconds timeout, SocketError &error)
Checks if an i/o operation can be processed without blocking.
Ptr Accept(IpAddress &ip4address, int &port, SocketError &error)
Accepts a pending connection request.
bool Select(SelectMode mode, Microseconds timeout, SocketError &error)
Checks if an i/o operation can be performed without blocking the calling thread.
SocketError GetOptionBroadcast(bool &enabled)
Checks if broadcast is enabled.
SocketError RenegotiateSession()
SocketError Connect(const IpAddress &ip4Address, int port)
Tries to connect with a remote socket.
SocketError SetOptionBroadcast(bool enabled)
Enables/Disables broadcast for this socket.
int GetRemotePort(void)
If this socket is connected this method returns the port of the connection.
SocketError SetOptionReuseAddress(bool enabled)
Enables/Disables the reuse-address option for this socket.
delegate< void(bool &, TlsVerificationError &, int, const Certificate *)> VerifyHandler
Used a for AddVerifyHandler Note: certificate is optional and can be nullptr, must be checked before ...
Definition: TlsSocket2.hpp:45
SocketError UpdateSessionKeys(bool requestUpdate=true)
IpAddress GetRemoteIpAddress(void)
Checks if this socket is connected with a remote peer.
SocketError SetOptionKeepAlive(bool enabled)
Enables/Disables the keep-alive option for this socket.
void AddAlertReceivedHandler(const AlertHandler &handler)
Adds a handler which is called when a TLS alert is received from the peer
SocketError Shutdown(ShutdownMode mode)
Shuts down a full-duplex connection.
void RemoveVerifyHandler(const VerifyHandler &handler)
Removes a VerifyHandler again
SocketError Bind2(const IpAddress &ip4Address, int &port)
Binds the socket to a specific address and port combination.
bool IsTlsConnected(void)
Checks if a TLS connection is established with a remote peer.
SocketError GetOptionKeepAlive(bool &enabled)
Checks if keep-alive is enabled.
SocketError GetOptionLinger(bool &enable, size_t &timeout)
Returns the current linger options. For more information see Arp::System::Commons::Net::Socket::SetOp...
SocketError Close(void)
Closes the socket. This ends all communication on the socket.
bool IsBlocking(void)
Checks if the socket is in blocking mode.
void AddVerifyHandler(const VerifyHandler &handler)
Adds a handler which is called during certificate validation ot the peer certificate
SocketError Bind(const IpAddress &ip4Address, int port)
Binds the socket to a specific address and port combination.
SocketError SetOptionLinger(bool enable, size_t timeout)
Sets the amount of time a socket resides in TIME_WAIT state after active close.
SocketError SetSocketOption(SocketOptionName optionName, const void *optionValue, size_t optionLength)
Sets a single option on the socket.
void SetCipherList(const String &cipherList)
SocketDomain GetSocketDomain(void)
Returns the type of the socket.
SocketError Listen(size_t backlog)
Marks this socket as a passive socket that accepts incoming connection requests.
SteadyTimePoint GetLastKeyUpdateTime(void)
Queries the last timepoint when a TLS session resumption (TLS 1.2) or key update (TLS 1....
SocketError InitServer(const String &identityStoreName, const String &trustStoreName="")
SocketType GetSocketType(void)
Returns the type of the socket.
SocketError Shutdown(void)
Shuts down a full-duplex connection.
SocketError GetOptionNoDelay(bool &enabled)
Checks if no-delay is enabled.
SocketError GetOptionReuseAddress(bool &enabled)
Checks if reuse-address is enabled.
void AddAlertSendHandler(const AlertHandler &handler)
Adds a handler which is called when a TLS alert is send to the peer
int Receive(void *pBuffer, size_t length, SocketError &error)
Reads data from connected socket.
bool IsConnected(void)
Checks if the socket is in blocking mode.
int Send(const void *pBuffer, size_t length, SocketError &error)
Transmit data over the socket that is in a connected state.
SteadyTimePoint GetLastRenegotionTime(void)
Queries the last timepoint when a TLS renegotiation was performed
void RemoveAlertReceivedHandler(const AlertHandler &handler)
Removes a AlertReceived handler again
Class to handle x.509 certificates
Definition: Certificate.hpp:25
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: TypeSystem.h:52
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:49
SteadyClock::time_point SteadyTimePoint
Represents the type of a monotonic clock timepoint.
Definition: TypeSystem.h:40
@ System
System components used by the System, Device, Plc or Io domains.
TlsVerificationError
This enum list possible error codes which further specifies an certificate verification error....
Definition: TlsVerificationError.hpp:18
PollMode
This enum is used to specifiy the poll mode of the <cref name="Socket::Poll" > operation.
Definition: PollMode.hpp:15
SelectMode
Modes for Select call to check different data channels.
Definition: SelectMode.hpp:14
TlsAlertType
This enum defines the TLS alert types
Definition: TlsAlertType.hpp:16
SocketDomain
Supported communication domains, selecting the protocol for communication.
Definition: SocketDomain.hpp:14
SocketType
Enumeration of supported socket types.
Definition: SocketType.hpp:14
ShutdownMode
This enum is used to specifiy the shutdown mode of the <cref name="Socket::Shutdown(ShutdownMode)" > ...
Definition: ShutdownMode.hpp:15
SocketError
Possible error codes for socket operation results.
Definition: SocketError.hpp:15
TlsAlertLevel
This enum represents avaliable TLS alert Levels
Definition: TlsAlertLevel.hpp:16
TlsOptions
This enum is used to select different options for the TlsSocket class
Definition: TlsOptions.hpp:25
SocketOptionName
Specifies socket options to be set by the application. Copied from Eclr Socket Adaption
Definition: SocketOptionName.hpp:17
SocketBlockingMode
Supported blocking modes.
Definition: Socket.hpp:28
Root namespace for the PLCnext API