join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
dns_protocol.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_FABRIC_DNS_PROTOCOL_HPP
26#define JOIN_FABRIC_DNS_PROTOCOL_HPP
27
28// libjoin.
29#include <join/protocol.hpp>
30
31namespace join
32{
33 template <class Protocol>
34 class BasicDatagramResolver;
35
36 template <class Protocol>
37 class BasicDatagramNameServer;
38
42 class Dns
43 {
44 public:
49
54 constexpr explicit Dns (int family = AF_INET) noexcept
55 : _family (family)
56 {
57 }
58
63 static inline Dns& v4 () noexcept
64 {
65 static Dns dnsv4 (AF_INET);
66 return dnsv4;
67 }
68
73 static inline Dns& v6 () noexcept
74 {
75 static Dns dnsv6 (AF_INET6);
76 return dnsv6;
77 }
78
83 constexpr int family () const noexcept
84 {
85 return _family;
86 }
87
92 constexpr int type () const noexcept
93 {
94 return SOCK_DGRAM;
95 }
96
101 constexpr int protocol () const noexcept
102 {
103 return IPPROTO_UDP;
104 }
105
107 static constexpr uint16_t defaultPort = 53;
108
110 static constexpr size_t maxMsgSize = 8192;
111
112 private:
114 int _family;
115 };
116
123 constexpr bool operator== (const Dns& a, const Dns& b) noexcept
124 {
125 return a.family () == b.family ();
126 }
127
134 constexpr bool operator!= (const Dns& a, const Dns& b) noexcept
135 {
136 return !(a == b);
137 }
138}
139
140#endif
basic DNS name server over datagram socket.
Definition nameserver.hpp:43
basic DNS resolver over datagram socket.
Definition resolver.hpp:55
basic datagram socket class.
Definition protocol.hpp:47
basic internet endpoint class.
Definition endpoint.hpp:632
DNS over UDP protocol class.
Definition dns_protocol.hpp:43
static constexpr size_t maxMsgSize
maximum DNS message size.
Definition dns_protocol.hpp:110
constexpr int family() const noexcept
get the protocol IP address family.
Definition dns_protocol.hpp:83
constexpr int type() const noexcept
get the protocol communication semantic.
Definition dns_protocol.hpp:92
constexpr int protocol() const noexcept
get the protocol type.
Definition dns_protocol.hpp:101
static Dns & v6() noexcept
get protocol suitable for IPv6 address family.
Definition dns_protocol.hpp:73
constexpr Dns(int family=AF_INET) noexcept
construct the DNS protocol instance.
Definition dns_protocol.hpp:54
static Dns & v4() noexcept
get protocol suitable for IPv4 address family.
Definition dns_protocol.hpp:63
static constexpr uint16_t defaultPort
default DNS port.
Definition dns_protocol.hpp:107
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