Skip to content

Commit

Permalink
Merge caec707 into 7ef91f9
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost authored Apr 15, 2021
2 parents 7ef91f9 + caec707 commit 1518778
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ThreadStackManager
CHIP_ERROR AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, chip::Mdns::TextEntry * aTxtEntries,
size_t aTxtEntiresSize, uint32_t aLeaseInterval, uint32_t aKeyLeaseInterval);
CHIP_ERROR RemoveSrpService(const char * aInstanceName, const char * aName);
CHIP_ERROR RemoveAllSrpServices();
CHIP_ERROR SetupSrpHost(const char * aHostName);
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT

Expand Down Expand Up @@ -242,6 +243,11 @@ inline CHIP_ERROR ThreadStackManager::RemoveSrpService(const char * aInstanceNam
return static_cast<ImplClass *>(this)->_RemoveSrpService(aInstanceName, aName);
}

inline CHIP_ERROR ThreadStackManager::RemoveAllSrpServices()
{
return static_cast<ImplClass *>(this)->_RemoveAllSrpServices();
}

inline CHIP_ERROR ThreadStackManager::SetupSrpHost(const char * aHostName)
{
return static_cast<ImplClass *>(this)->_SetupSrpHost(aHostName);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/mdns/platform/Mdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ CHIP_ERROR ChipMdnsPublishService(const MdnsService * service);
*/
CHIP_ERROR ChipMdnsStopPublish();

CHIP_ERROR ChipMdnsRemoveService(const MdnsService * service);

/**
* This function browses the services published by mdns
*
Expand Down
5 changes: 5 additions & 0 deletions src/platform/Darwin/MdnsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,11 @@ CHIP_ERROR ChipMdnsStopPublish()
return MdnsContexts::GetInstance().Removes(ContextType::Register);
}

CHIP_ERROR ChipMdnsRemoveService(const MdnsService * service)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ChipMdnsBrowse(const char * type, MdnsServiceProtocol protocol, chip::Inet::IPAddressType addressType,
chip::Inet::InterfaceId interface, MdnsBrowseCallback callback, void * context)
{
Expand Down
5 changes: 5 additions & 0 deletions src/platform/ESP32/MdnsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ CHIP_ERROR ChipMdnsStopPublish()
return mdns_service_remove_all() == ESP_OK ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL;
}

CHIP_ERROR ChipMdnsRemoveService(const MdnsService * service)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ChipMdnsBrowse(const char * /*type*/, MdnsServiceProtocol /*protocol*/, chip::Inet::IPAddressType addressType,
chip::Inet::InterfaceId /*interface*/, MdnsBrowseCallback /*callback*/, void * /*context*/)
{
Expand Down
5 changes: 5 additions & 0 deletions src/platform/Linux/MdnsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,11 @@ CHIP_ERROR ChipMdnsStopPublish()
return MdnsAvahi::GetInstance().StopPublish();
}

CHIP_ERROR ChipMdnsRemoveService(const MdnsService * service)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ChipMdnsBrowse(const char * type, MdnsServiceProtocol protocol, chip::Inet::IPAddressType addressType,
chip::Inet::InterfaceId interface, MdnsBrowseCallback callback, void * context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetPrimary80215
const otExtAddress * extendedAddr = otLinkGetExtendedAddress(mOTInst);
memcpy(buf, extendedAddr, sizeof(otExtAddress));
return CHIP_NO_ERROR;
};
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetFactoryAssignedEUI64(uint8_t (&buf)[8])
Expand All @@ -836,7 +836,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetFactoryAssig
otLinkGetFactoryAssignedIeeeEui64(mOTInst, &extendedAddr);
memcpy(buf, extendedAddr.m8, sizeof(extendedAddr.m8));
return CHIP_NO_ERROR;
};
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetExternalIPv6Address(chip::Inet::IPAddress & addr)
Expand Down Expand Up @@ -873,7 +873,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetPollPeriod(u
buf = otLinkGetPollPeriod(mOTInst);
Impl()->UnlockThreadStack();
return CHIP_NO_ERROR;
};
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::DoInit(otInstance * otInst)
Expand Down Expand Up @@ -1253,6 +1253,19 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_RemoveSrpServic
return error;
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_RemoveAllSrpServices()
{
if (otSrpClientGetServices(mOTInst) != nullptr)
{
return MapOpenThreadError(otSrpClientRemoveHostAndServices(mOTInst, false));
}
else
{
return CHIP_NO_ERROR;
}
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetupSrpHost(const char * aHostName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class GenericThreadStackManagerImpl_OpenThread
CHIP_ERROR _AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, chip::Mdns::TextEntry * aTxtEntries,
size_t aTxtEntiresSize, uint32_t aLeaseInterval, uint32_t aKeyLeaseInterval);
CHIP_ERROR _RemoveSrpService(const char * aInstanceName, const char * aName);
CHIP_ERROR _RemoveAllSrpServices();
CHIP_ERROR _SetupSrpHost(const char * aHostName);
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT

Expand Down
10 changes: 9 additions & 1 deletion src/platform/OpenThread/MdnsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ CHIP_ERROR ChipMdnsPublishService(const MdnsService * service)

CHIP_ERROR ChipMdnsStopPublish()
{
return CHIP_ERROR_NOT_IMPLEMENTED;
return ThreadStackMgr().RemoveAllSrpServices();
}

CHIP_ERROR ChipMdnsRemoveService(const MdnsService * service)
{
char serviceType[kMdnsTypeMaxSize + kMdnsProtocolTextMaxSize + 1];
snprintf(serviceType, sizeof(serviceType), "%s.%s", service->mType, GetProtocolString(service->mProtocol));

return ThreadStackMgr().RemoveSrpService(service->mName, serviceType);
}

CHIP_ERROR ChipMdnsBrowse(const char * type, MdnsServiceProtocol protocol, Inet::IPAddressType addressType,
Expand Down

0 comments on commit 1518778

Please sign in to comment.