Skip to content

Commit

Permalink
[trel] updates for switching trel interface (#2579)
Browse files Browse the repository at this point in the history
As it's possible to switch network interface for TREL in
openthread/openthread#10872, updated
trel_dnssd.cpp in 2 places:
1) Initialize() can be called multiple times now, so it should clear the
mTrelNetifIndex at the beginning to refresh the index according to the
given interface name.
2) HandleMdnsState() may be invoked when TrelDnssd is not initialized,
we should still update the mMdnsPublisherReady status, so it's ready to
publish a service when TrelDnssd becomes initialized.
  • Loading branch information
sunytt authored Nov 5, 2024
1 parent a701edd commit 96c963b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/trel_dnssd/trel_dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ TrelDnssd::TrelDnssd(Ncp::RcpHost &aHost, Mdns::Publisher &aPublisher)
void TrelDnssd::Initialize(std::string aTrelNetif)
{
mTrelNetif = std::move(aTrelNetif);
// Reset mTrelNetifIndex to 0 so that when this function is called with a different aTrelNetif
// than the current mTrelNetif, CheckTrelNetifReady() will update mTrelNetifIndex accordingly.
mTrelNetifIndex = 0;

if (IsInitialized())
{
Expand Down Expand Up @@ -190,7 +193,6 @@ void TrelDnssd::UnregisterService(void)

void TrelDnssd::HandleMdnsState(Mdns::Publisher::State aState)
{
VerifyOrExit(IsInitialized());
VerifyOrExit(aState == Mdns::Publisher::State::kReady);

otbrLogDebug("mDNS Publisher is Ready");
Expand All @@ -202,6 +204,7 @@ void TrelDnssd::HandleMdnsState(Mdns::Publisher::State aState)
mRegisterInfo.mInstanceName = "";
}

VerifyOrExit(IsInitialized());
OnBecomeReady();

exit:
Expand Down

0 comments on commit 96c963b

Please sign in to comment.