join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
mdns_protocol.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_FABRIC_MDNS_PROTOCOL_HPP
26#define JOIN_FABRIC_MDNS_PROTOCOL_HPP
27
28// libjoin.
29#include <join/protocol.hpp>
30
31namespace join
32{
33 template <class Protocol>
34 class BasicDatagramPeer;
35
39 class Mdns
40 {
41 public:
45
50 constexpr explicit Mdns (int family = AF_INET) noexcept
51 : _family (family)
52 {
53 }
54
59 static inline Mdns& v4 () noexcept
60 {
61 static Mdns mdnsv4 (AF_INET);
62 return mdnsv4;
63 }
64
69 static inline Mdns& v6 () noexcept
70 {
71 static Mdns mdnsv6 (AF_INET6);
72 return mdnsv6;
73 }
74
79 constexpr int family () const noexcept
80 {
81 return _family;
82 }
83
88 constexpr int type () const noexcept
89 {
90 return SOCK_DGRAM;
91 }
92
97 constexpr int protocol () const noexcept
98 {
99 return IPPROTO_UDP;
100 }
101
107 static IpAddress multicastAddress (int family) noexcept
108 {
109 return (family == AF_INET6) ? "ff02::fb" : "224.0.0.251";
110 }
111
113 static constexpr uint16_t defaultPort = 5353;
114
116 static constexpr size_t maxMsgSize = 8192;
117
118 private:
120 int _family;
121 };
122
129 constexpr bool operator== (const Mdns& a, const Mdns& b) noexcept
130 {
131 return a.family () == b.family ();
132 }
133
140 constexpr bool operator!= (const Mdns& a, const Mdns& b) noexcept
141 {
142 return !(a == b);
143 }
144}
145
146#endif
mDNS peer.
Definition nameserver.hpp:229
basic datagram socket class.
Definition protocol.hpp:47
basic internet endpoint class.
Definition endpoint.hpp:632
IPv6, IPv4 address class.
Definition ip_address.hpp:51
Multicast DNS protocol class.
Definition mdns_protocol.hpp:40
static constexpr size_t maxMsgSize
maximum DNS message size.
Definition mdns_protocol.hpp:116
static Mdns & v6() noexcept
get protocol suitable for IPv6 address family.
Definition mdns_protocol.hpp:69
constexpr int protocol() const noexcept
get the protocol type.
Definition mdns_protocol.hpp:97
static constexpr uint16_t defaultPort
default DNS port.
Definition mdns_protocol.hpp:113
constexpr int family() const noexcept
get the protocol IP address family.
Definition mdns_protocol.hpp:79
static Mdns & v4() noexcept
get protocol suitable for IPv4 address family.
Definition mdns_protocol.hpp:59
constexpr Mdns(int family=AF_INET) noexcept
construct the mDNS protocol instance.
Definition mdns_protocol.hpp:50
static IpAddress multicastAddress(int family) noexcept
get multicast address for the given address family.
Definition mdns_protocol.hpp:107
constexpr int type() const noexcept
get the protocol communication semantic.
Definition mdns_protocol.hpp:88
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