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
113 constexpr bool operator!= (const Tls& a, const Tls& b) noexcept
114 {
115 return !(a == b);
116 }
117
121 class Dtls
122 {
123 public:
124 using Transport = Udp;
127
132 constexpr explicit Dtls (int family = AF_INET) noexcept
133 : _transport (family)
134 {
135 }
136
141 static inline Dtls& v4 () noexcept
142 {
143 static Dtls dtlsv4 (AF_INET);
144 return dtlsv4;
145 }
146
151 static inline Dtls& v6 () noexcept
152 {
153 static Dtls dtlsv6 (AF_INET6);
154 return dtlsv6;
155 }
156
161 constexpr int family () const noexcept
162 {
163 return _transport.family ();
164 }
165
166 private:
168 Transport _transport;
169 };
170
177 constexpr bool operator== (const Dtls& a, const Dtls& b) noexcept
178 {
179 return a.family () == b.family ();
180 }
181
188 constexpr bool operator!= (const Dtls& a, const Dtls& b) noexcept
189 {
190 return !(a == b);
191 }
192}
193
194#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:122
constexpr Dtls(int family=AF_INET) noexcept
create the dtls protocol instance.
Definition tls_protocol.hpp:132
static Dtls & v4() noexcept
get protocol suitable for IPv4 address family.
Definition tls_protocol.hpp:141
typename Transport::Endpoint Endpoint
Definition tls_protocol.hpp:125
static Dtls & v6() noexcept
get protocol suitable for IPv6 address family.
Definition tls_protocol.hpp:151
constexpr int family() const noexcept
get the protocol IP address family.
Definition tls_protocol.hpp:161
Udp Transport
Definition tls_protocol.hpp:124
TCP protocol class.
Definition protocol.hpp:471
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:513
BasicInternetEndpoint< Tcp > Endpoint
Definition protocol.hpp:473
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:280
BasicInternetEndpoint< Udp > Endpoint
Definition protocol.hpp:282
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:319
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:186
bool operator!=(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are not equal.
Definition endpoint.hpp:198