openthread-br  0.3.0-72c0388
Classes | Public Member Functions | Protected Member Functions | List of all members
otbr::Mdns::PublisherMDnsSd Class Reference

#include <src/mdns/mdns_mdnssd.hpp>

Inheritance diagram for otbr::Mdns::PublisherMDnsSd:
otbr::MainloopProcessor otbr::Mdns::Publisher NonCopyable

Public Member Functions

 PublisherMDnsSd (StateCallback aCallback)
 
void UnpublishService (const std::string &aName, const std::string &aType, ResultCallback &&aCallback) override
 
void UnpublishHost (const std::string &aName, ResultCallback &&aCallback) override
 
void SubscribeService (const std::string &aType, const std::string &aInstanceName) override
 
void UnsubscribeService (const std::string &aType, const std::string &aInstanceName) override
 
void SubscribeHost (const std::string &aHostName) override
 
void UnsubscribeHost (const std::string &aHostName) override
 
otbrError Start (void) override
 
bool IsStarted (void) const override
 
void Stop (void) override
 
void Update (MainloopContext &aMainloop) override
 
void Process (const MainloopContext &aMainloop) override
 
- Public Member Functions inherited from otbr::Mdns::Publisher
void PublishService (const std::string &aHostName, const std::string &aName, const std::string &aType, const SubTypeList &aSubTypeList, uint16_t aPort, const TxtList &aTxtList, ResultCallback &&aCallback)
 
void PublishHost (const std::string &aName, const std::vector< Ip6Address > &aAddresses, ResultCallback &&aCallback)
 
uint64_t AddSubscriptionCallbacks (DiscoveredServiceInstanceCallback aInstanceCallback, DiscoveredHostCallback aHostCallback)
 
void RemoveSubscriptionCallbacks (uint64_t aSubscriberId)
 
const MdnsTelemetryInfoGetMdnsTelemetryInfo () const
 

Protected Member Functions

otbrError PublishServiceImpl (const std::string &aHostName, const std::string &aName, const std::string &aType, const SubTypeList &aSubTypeList, uint16_t aPort, const TxtList &aTxtList, ResultCallback &&aCallback) override
 
otbrError PublishHostImpl (const std::string &aName, const std::vector< Ip6Address > &aAddress, ResultCallback &&aCallback) override
 
void OnServiceResolveFailedImpl (const std::string &aType, const std::string &aInstanceName, int32_t aErrorCode) override
 
void OnHostResolveFailedImpl (const std::string &aHostName, int32_t aErrorCode) override
 
otbrError DnsErrorToOtbrError (int32_t aErrorCode) override
 
- Protected Member Functions inherited from otbr::Mdns::Publisher
void AddServiceRegistration (ServiceRegistrationPtr &&aServiceReg)
 
void RemoveServiceRegistration (const std::string &aName, const std::string &aType, otbrError aError)
 
ServiceRegistrationFindServiceRegistration (const std::string &aName, const std::string &aType)
 
void OnServiceResolved (const std::string &aType, const DiscoveredInstanceInfo &aInstanceInfo)
 
void OnServiceResolveFailed (const std::string &aType, const std::string &aInstanceName, int32_t aErrorCode)
 
void OnServiceRemoved (uint32_t aNetifIndex, const std::string &aType, const std::string &aInstanceName)
 
void OnHostResolved (const std::string &aHostName, const DiscoveredHostInfo &aHostInfo)
 
void OnHostResolveFailed (const std::string &aHostName, int32_t aErrorCode)
 
ResultCallback HandleDuplicateServiceRegistration (const std::string &aHostName, const std::string &aName, const std::string &aType, const SubTypeList &aSubTypeList, uint16_t aPort, const TxtList &aTxtList, ResultCallback &&aCallback)
 
ResultCallback HandleDuplicateHostRegistration (const std::string &aName, const std::vector< Ip6Address > &aAddresses, ResultCallback &&aCallback)
 
void AddHostRegistration (HostRegistrationPtr &&aHostReg)
 
void RemoveHostRegistration (const std::string &aName, otbrError aError)
 
HostRegistrationFindHostRegistration (const std::string &aName)
 
void UpdateServiceRegistrationEmaLatency (const std::string &aInstanceName, const std::string &aType, otbrError aError)
 
void UpdateHostRegistrationEmaLatency (const std::string &aHostName, otbrError aError)
 
void UpdateServiceInstanceResolutionEmaLatency (const std::string &aInstanceName, const std::string &aType, otbrError aError)
 
void UpdateHostResolutionEmaLatency (const std::string &aHostName, otbrError aError)
 

Additional Inherited Members

- Public Types inherited from otbr::Mdns::Publisher
enum  State { State::kIdle, State::kReady }
 
typedef std::vector< TxtEntryTxtList
 
typedef std::vector< std::string > SubTypeList
 
typedef std::vector< Ip6AddressAddressList
 
using DiscoveredServiceInstanceCallback = std::function< void(const std::string &aType, const DiscoveredInstanceInfo &aInstanceInfo)>
 
using DiscoveredHostCallback = std::function< void(const std::string &aHostName, const DiscoveredHostInfo &aHostInfo)>
 
using StateCallback = std::function< void(State aNewState)>
 
using ResultCallback = OnceCallback< void(otbrError aError)>
 
- Static Public Member Functions inherited from otbr::Mdns::Publisher
static PublisherCreate (StateCallback aCallback)
 
static void Destroy (Publisher *aPublisher)
 
static otbrError EncodeTxtData (const TxtList &aTxtList, std::vector< uint8_t > &aTxtData)
 
static otbrError DecodeTxtData (TxtList &aTxtList, const uint8_t *aTxtData, uint16_t aTxtLength)
 
- Protected Types inherited from otbr::Mdns::Publisher
using ServiceRegistrationPtr = std::unique_ptr< ServiceRegistration >
 
using ServiceRegistrationMap = std::map< std::string, ServiceRegistrationPtr >
 
using HostRegistrationPtr = std::unique_ptr< HostRegistration >
 
using HostRegistrationMap = std::map< std::string, HostRegistrationPtr >
 
- Static Protected Member Functions inherited from otbr::Mdns::Publisher
static SubTypeList SortSubTypeList (SubTypeList aSubTypeList)
 
static TxtList SortTxtList (TxtList aTxtList)
 
static AddressList SortAddressList (AddressList aAddressList)
 
static std::string MakeFullServiceName (const std::string &aName, const std::string &aType)
 
static std::string MakeFullHostName (const std::string &aName)
 
static void UpdateMdnsResponseCounters (otbr::MdnsResponseCounters &aCounters, otbrError aError)
 
static void UpdateEmaLatency (uint32_t &aEmaLatency, uint32_t aLatency, otbrError aError)
 
- Protected Attributes inherited from otbr::Mdns::Publisher
ServiceRegistrationMap mServiceRegistrations
 
HostRegistrationMap mHostRegistrations
 
uint64_t mNextSubscriberId = 1
 
std::map< uint64_t, std::pair< DiscoveredServiceInstanceCallback, DiscoveredHostCallback > > mDiscoveredCallbacks
 
std::map< std::pair< std::string, std::string >, Timepoint > mServiceRegistrationBeginTime
 
std::map< std::string, Timepoint > mHostRegistrationBeginTime
 
std::map< std::pair< std::string, std::string >, Timepoint > mServiceInstanceResolutionBeginTime
 
std::map< std::string, Timepoint > mHostResolutionBeginTime
 
otbr::MdnsTelemetryInfo mTelemetryInfo {}
 
- Static Protected Attributes inherited from otbr::Mdns::Publisher
static constexpr uint8_t kMaxTextEntrySize = 255
 

Detailed Description

This class implements mDNS publisher with mDNSResponder.

Member Function Documentation

◆ IsStarted()

bool otbr::Mdns::PublisherMDnsSd::IsStarted ( void  ) const
overridevirtual

This method checks if publisher has been started.

Return values
trueAlready started.
falseNot started.

Implements otbr::Mdns::Publisher.

◆ Process()

void otbr::Mdns::PublisherMDnsSd::Process ( const MainloopContext aMainloop)
overridevirtual

This method processes mainloop events.

Parameters
[in]aMainloopA reference to the mainloop context.

Implements otbr::MainloopProcessor.

◆ Start()

otbrError otbr::Mdns::PublisherMDnsSd::Start ( void  )
overridevirtual

This method starts the mDNS publisher.

Return values
OTBR_ERROR_NONESuccessfully started mDNS publisher;
OTBR_ERROR_MDNSFailed to start mDNS publisher.

Implements otbr::Mdns::Publisher.

◆ Stop()

void otbr::Mdns::PublisherMDnsSd::Stop ( void  )
overridevirtual

This method stops the mDNS publisher.

Implements otbr::Mdns::Publisher.

◆ SubscribeHost()

void otbr::Mdns::PublisherMDnsSd::SubscribeHost ( const std::string &  aHostName)
overridevirtual

This method subscribes a given host.

mDNS implementations should use the DiscoveredHostCallback function to notify discovered hosts.

Note
Discovery Proxy implementation guarantees no duplicate subscriptions for the same host.
Parameters
[in]aHostNameThe host name (without domain).

Implements otbr::Mdns::Publisher.

◆ SubscribeService()

void otbr::Mdns::PublisherMDnsSd::SubscribeService ( const std::string &  aType,
const std::string &  aInstanceName 
)
overridevirtual

This method subscribes a given service or service instance.

If aInstanceName is not empty, this method subscribes the service instance. Otherwise, this method subscribes the service. mDNS implementations should use the DiscoveredServiceInstanceCallback function to notify discovered service instances.

Note
Discovery Proxy implementation guarantees no duplicate subscriptions for the same service or service instance.
Parameters
[in]aTypeThe service type.
[in]aInstanceNameThe service instance to subscribe, or empty to subscribe the service.

Implements otbr::Mdns::Publisher.

◆ UnpublishHost()

void otbr::Mdns::PublisherMDnsSd::UnpublishHost ( const std::string &  aName,
ResultCallback &&  aCallback 
)
overridevirtual

This method un-publishes a host.

Parameters
[in]aNameA host name.
[in]aCallbackThe callback for receiving the publishing result.

Implements otbr::Mdns::Publisher.

◆ UnpublishService()

void otbr::Mdns::PublisherMDnsSd::UnpublishService ( const std::string &  aName,
const std::string &  aType,
ResultCallback &&  aCallback 
)
overridevirtual

This method un-publishes a service.

Parameters
[in]aNameThe name of this service.
[in]aTypeThe type of this service.
[in]aCallbackThe callback for receiving the publishing result.

Implements otbr::Mdns::Publisher.

◆ UnsubscribeHost()

void otbr::Mdns::PublisherMDnsSd::UnsubscribeHost ( const std::string &  aHostName)
overridevirtual

This method unsubscribes a given host.

Note
Discovery Proxy implementation guarantees no redundant unsubscription for a host.
Parameters
[in]aHostNameThe host name (without domain).

Implements otbr::Mdns::Publisher.

◆ UnsubscribeService()

void otbr::Mdns::PublisherMDnsSd::UnsubscribeService ( const std::string &  aType,
const std::string &  aInstanceName 
)
overridevirtual

This method unsubscribes a given service or service instance.

If aInstanceName is not empty, this method unsubscribes the service instance. Otherwise, this method unsubscribes the service.

Note
Discovery Proxy implementation guarantees no redundant unsubscription for a service or service instance.
Parameters
[in]aTypeThe service type.
[in]aInstanceNameThe service instance to unsubscribe, or empty to unsubscribe the service.

Implements otbr::Mdns::Publisher.

◆ Update()

void otbr::Mdns::PublisherMDnsSd::Update ( MainloopContext aMainloop)
overridevirtual

This method updates the mainloop context.

Parameters
[in,out]aMainloopA reference to the mainloop to be updated.

Implements otbr::MainloopProcessor.


The documentation for this class was generated from the following files: