join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
tls_protocol.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_CRYPTO_TLS_PROTOCOL_HPP
26#define JOIN_CRYPTO_TLS_PROTOCOL_HPP
27
28// libjoin.
29#include <join/protocol.hpp>
30
31namespace join
32{
33 template <class Protocol>
34 class BasicTlsWrapper;
35
36 template <class Protocol>
38
39 template <class Protocol>
40 class BasicTlsStream;
41
45 class Tls
46 {
47 public:
48 using Transport = Tcp;
49 using Endpoint = typename Transport::Endpoint;
52
57 constexpr explicit Tls (int family = AF_INET) noexcept
58 : _transport (family)
59 {
60 }
61
66 static inline Tls& v4 () noexcept
67 {
68 static Tls tlsv4 (AF_INET);
69 return tlsv4;
70 }
71
76 static inline Tls& v6 () noexcept
77 {
78 static Tls tlsv6 (AF_INET6);
79 return tlsv6;
80 }
81
86 constexpr int family () const noexcept
87 {
88 return _transport.family ();
89 }
90
91 private:
93 Transport _transport;
94 };
95
102 constexpr bool operator== (const Tls& a, const Tls& b) noexcept
103 {
104 return a.family () == b.family ();
105 }
106
110 class Dtls
111 {
112 public:
113 using Transport = Udp;
116
121 constexpr explicit Dtls (int family = AF_INET) noexcept
122 : _transport (family)
123 {
124 }
125
130 static inline Dtls& v4 () noexcept
131 {
132 static Dtls dtlsv4 (AF_INET);
133 return dtlsv4;
134 }
135
140 static inline Dtls& v6 () noexcept
141 {
142 static Dtls dtlsv6 (AF_INET6);
143 return dtlsv6;
144 }
145
150 constexpr int family () const noexcept
151 {
152 return _transport.family ();
153 }
154
155 private:
157 Transport _transport;
158 };
159
166 constexpr bool operator== (const Dtls& a, const Dtls& b) noexcept
167 {
168 return a.family () == b.family ();
169 }
170}
171
172#endif
DTLS decorator for datagram sockets.
Definition tls_protocol.hpp:37
TLS stream class.
Definition tls_stream.hpp:43
TLS decorator for stream sockets.
Definition tls_wrapper.hpp:38
DTLS protocol class (DTLS over UDP).
Definition tls_protocol.hpp:111
constexpr Dtls(int family=AF_INET) noexcept
create the dtls protocol instance.
Definition tls_protocol.hpp:121
static Dtls & v4() noexcept
get protocol suitable for IPv4 address family.
Definition tls_protocol.hpp:130
typename Transport::Endpoint Endpoint
Definition tls_protocol.hpp:114
static Dtls & v6() noexcept
get protocol suitable for IPv6 address family.
Definition tls_protocol.hpp:140
constexpr int family() const noexcept
get the protocol IP address family.
Definition tls_protocol.hpp:150
Udp Transport
Definition tls_protocol.hpp:113
TCP protocol class.
Definition protocol.hpp:452
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:494
BasicInternetEndpoint< Tcp > Endpoint
Definition protocol.hpp:454
TLS protocol class (TLS over TCP).
Definition tls_protocol.hpp:46
typename Transport::Endpoint Endpoint
Definition tls_protocol.hpp:49
static Tls & v6() noexcept
get protocol suitable for IPv6 address family.
Definition tls_protocol.hpp:76
static Tls & v4() noexcept
get protocol suitable for IPv4 address family.
Definition tls_protocol.hpp:66
constexpr int family() const noexcept
get the protocol IP address family.
Definition tls_protocol.hpp:86
constexpr Tls(int family=AF_INET) noexcept
create the tls protocol instance.
Definition tls_protocol.hpp:57
Tcp Transport
Definition tls_protocol.hpp:48
UDP protocol class.
Definition protocol.hpp:283
BasicInternetEndpoint< Udp > Endpoint
Definition protocol.hpp:285
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:322
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:196