11#include <promeki/config.h>
12#if PROMEKI_ENABLE_MDNS
27PROMEKI_NAMESPACE_BEGIN
70class MdnsServiceInstance {
72 PROMEKI_DATATYPE(MdnsServiceInstance, DataTypeMdnsServiceInstance, 1)
75 Error writeToStream(DataStream &s) const;
77 template <uint32_t V> static Result<MdnsServiceInstance> readFromStream(DataStream &s);
80 static constexpr
int InvalidInterfaceIndex = -1;
82 MdnsServiceInstance() = default;
85 const String &instanceName()
const {
return _instanceName; }
86 void setInstanceName(
const String &v) { _instanceName = v; }
89 const MdnsServiceType &type()
const {
return _type; }
90 void setType(
const MdnsServiceType &v) { _type = v; }
93 const String &hostname()
const {
return _hostname; }
94 void setHostname(
const String &v) { _hostname = v; }
97 uint16_t port()
const {
return _port; }
98 void setPort(uint16_t v) { _port = v; }
101 const List<Ipv4Address> &ipv4Addresses()
const {
return _v4; }
102 void setIpv4Addresses(
const List<Ipv4Address> &v) { _v4 = v; }
105 const List<Ipv6Address> &ipv6Addresses()
const {
return _v6; }
106 void setIpv6Addresses(
const List<Ipv6Address> &v) { _v6 = v; }
109 const MdnsTxtRecord &txt()
const {
return _txt; }
110 void setTxt(
const MdnsTxtRecord &v) { _txt = v; }
120 int interfaceIndex()
const {
return _interfaceIndex; }
121 void setInterfaceIndex(
int v) { _interfaceIndex = v; }
130 const TimeStamp &lastSeen()
const {
return _lastSeen; }
131 void setLastSeen(
const TimeStamp &v) { _lastSeen = v; }
141 const Duration &ttl()
const {
return _ttl; }
142 void setTtl(
const Duration &v) { _ttl = v; }
145 bool isValid()
const {
return !_instanceName.isEmpty() && _type.isValid(); }
168 bool operator==(
const MdnsServiceInstance &other)
const;
169 bool operator!=(
const MdnsServiceInstance &other)
const {
return !(*
this == other); }
182 bool hasSameContent(
const MdnsServiceInstance &other)
const;
192 bool hasSameSnapshot(
const MdnsServiceInstance &other)
const;
195 String toString()
const;
198 String _instanceName;
199 MdnsServiceType _type;
202 List<Ipv4Address> _v4;
203 List<Ipv6Address> _v6;
205 int _interfaceIndex = InvalidInterfaceIndex;
211TextStream &operator<<(TextStream &stream,
const MdnsServiceInstance &inst);