Skip to content

Commit

Permalink
[mdns] Add API to remove mdns host IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
marius-preda committed Apr 17, 2024
1 parent e02d243 commit 786d5a7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/openthread/mdns_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ const otIp6Address *otMdnsServerGetAddresses(otInstance *aInstance, uint8_t *num
*/
otError otMdnsServerAddAddress(otInstance *aInstance, const otIp6Address *aIp6Address);

/**
* This function clears the list of host IPv6 addresses.
*
* @param[in] aInstance A pointer to the OpenThread instance.
*/
void otMdnsServerClearAddresses(otInstance *aInstance);

/**
* This function returns the host name.
*
Expand Down
5 changes: 5 additions & 0 deletions src/core/api/mdns_server_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ otError otMdnsServerAddAddress(otInstance *aInstance, const otIp6Address *aIp6Ad
return AsCoreType(aInstance).Get<Dns::ServiceDiscovery::MdnsServer>().AddAddress(AsCoreType(aIp6Address));
}

void otMdnsServerClearAddresses(otInstance *aInstance)
{
return AsCoreType(aInstance).Get<Dns::ServiceDiscovery::MdnsServer>().ClearAddresses();
}

otError otMdnsServerSetHostName(otInstance *aInstance, const char *aHostName)
{
return AsCoreType(aInstance).Get<Dns::ServiceDiscovery::MdnsServer>().SetHostName(aHostName);
Expand Down
5 changes: 5 additions & 0 deletions src/core/net/mdns_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,11 @@ Error MdnsServer::AddAddress(const Ip6::Address &aIp6Address)
return error;
}

void MdnsServer::ClearAddresses()
{
mAddresses.Free();
}

Error MdnsServer::SetHostName(const char *aHostName)
{
Error error = kErrorNone;
Expand Down
5 changes: 5 additions & 0 deletions src/core/net/mdns_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ class MdnsServer : public InstanceLocator, private NonCopyable
*/
Error AddAddress(const Ip6::Address &aIp6Address);

/**
* This function clears the list of host IPv6 address.
*/
void ClearAddresses();

/**
* This function sets mDns host name label;
*
Expand Down

0 comments on commit 786d5a7

Please sign in to comment.