11#include <promeki/config.h>
12#if PROMEKI_ENABLE_MDNS
24PROMEKI_NAMESPACE_BEGIN
65 enum class Type : uint16_t {
75 static constexpr int64_t DefaultTtlSeconds = 75 * 60;
77 MdnsRecord() =
default;
90 static MdnsRecord ptr(
const String &owner,
const String &target,
91 const Duration &ttl = Duration::fromSeconds(DefaultTtlSeconds));
107 static MdnsRecord srv(
const String &owner,
const String &target, uint16_t port,
108 uint16_t priority = 0, uint16_t weight = 0,
109 const Duration &ttl = Duration::fromSeconds(DefaultTtlSeconds));
119 static MdnsRecord txt(
const String &owner,
const MdnsTxtRecord &txt,
120 const Duration &ttl = Duration::fromSeconds(DefaultTtlSeconds));
129 static MdnsRecord a(
const String &owner,
const Ipv4Address &address,
130 const Duration &ttl = Duration::fromSeconds(DefaultTtlSeconds));
139 static MdnsRecord aaaa(
const String &owner,
const Ipv6Address &address,
140 const Duration &ttl = Duration::fromSeconds(DefaultTtlSeconds));
143 Type type()
const {
return _type; }
146 const String &name()
const {
return _name; }
149 const Duration &ttl()
const {
return _ttl; }
155 bool cacheFlush()
const {
return _cacheFlush; }
163 void setCacheFlush(
bool enable) { _cacheFlush = enable; }
166 const String &ptrTarget()
const {
return _ptrTarget; }
169 uint16_t srvPriority()
const {
return _srvPriority; }
171 uint16_t srvWeight()
const {
return _srvWeight; }
173 uint16_t srvPort()
const {
return _srvPort; }
175 const String &srvTarget()
const {
return _srvTarget; }
178 const MdnsTxtRecord &txtRecord()
const {
return _txt; }
181 const Ipv4Address &aAddress()
const {
return _a; }
184 const Ipv6Address &aaaaAddress()
const {
return _aaaa; }
187 bool isGoodbye()
const {
return _ttl == Duration::zero(); }
190 bool operator==(
const MdnsRecord &other)
const;
191 bool operator!=(
const MdnsRecord &other)
const {
return !(*
this == other); }
194 Type _type = Type::Unknown;
197 bool _cacheFlush =
true;
200 uint16_t _srvPriority = 0;
201 uint16_t _srvWeight = 0;
202 uint16_t _srvPort = 0;
223Buffer mdnsBuildAnnounce(
const List<MdnsRecord> &records, uint16_t transactionId = 0);
233Buffer mdnsBuildGoodbye(
const List<MdnsRecord> &records, uint16_t transactionId = 0);
249Buffer mdnsBuildProbe(
const List<MdnsRecord> &records, uint16_t transactionId = 0);