mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 19:27:46 +00:00
[srp] rename Advertising to ServiceUpdate (#6220)
This commit renames *Advertising* to *ServiceUpdate* to keep consistent with public APIs. For example, change HandleAdvertisingResult to HandleServiceUpdateResult.
This commit is contained in:
@@ -87,7 +87,7 @@ void otSrpServerHandleServiceUpdateResult(otInstance *aInstance, const otSrpServ
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
instance.Get<Srp::Server>().HandleAdvertisingResult(static_cast<const Srp::Server::Host *>(aHost), aError);
|
||||
instance.Get<Srp::Server>().HandleServiceUpdateResult(static_cast<const Srp::Server::Host *>(aHost), aError);
|
||||
}
|
||||
|
||||
const otSrpServerHost *otSrpServerGetNextHost(otInstance *aInstance, const otSrpServerHost *aHost)
|
||||
|
||||
+17
-17
@@ -77,8 +77,8 @@ static Dns::UpdateHeader::Response ErrorToDnsResponseCode(otError aError)
|
||||
Server::Server(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mSocket(aInstance)
|
||||
, mAdvertisingHandler(nullptr)
|
||||
, mAdvertisingHandlerContext(nullptr)
|
||||
, mServiceUpdateHandler(nullptr)
|
||||
, mServiceUpdateHandlerContext(nullptr)
|
||||
, mDomain(nullptr)
|
||||
, mMinLease(kDefaultMinLease)
|
||||
, mMaxLease(kDefaultMaxLease)
|
||||
@@ -98,8 +98,8 @@ Server::~Server(void)
|
||||
|
||||
void Server::SetServiceHandler(otSrpServerServiceUpdateHandler aServiceHandler, void *aServiceHandlerContext)
|
||||
{
|
||||
mAdvertisingHandler = aServiceHandler;
|
||||
mAdvertisingHandlerContext = aServiceHandlerContext;
|
||||
mServiceUpdateHandler = aServiceHandler;
|
||||
mServiceUpdateHandlerContext = aServiceHandlerContext;
|
||||
}
|
||||
|
||||
bool Server::IsRunning(void) const
|
||||
@@ -262,13 +262,13 @@ exit:
|
||||
return hasConflicts;
|
||||
}
|
||||
|
||||
void Server::HandleAdvertisingResult(const Host *aHost, otError aError)
|
||||
void Server::HandleServiceUpdateResult(const Host *aHost, otError aError)
|
||||
{
|
||||
UpdateMetadata *update = mOutstandingUpdates.FindMatching(aHost);
|
||||
|
||||
if (update != nullptr)
|
||||
{
|
||||
HandleAdvertisingResult(update, aError);
|
||||
HandleServiceUpdateResult(update, aError);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -276,9 +276,9 @@ void Server::HandleAdvertisingResult(const Host *aHost, otError aError)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::HandleAdvertisingResult(UpdateMetadata *aUpdate, otError aError)
|
||||
void Server::HandleServiceUpdateResult(UpdateMetadata *aUpdate, otError aError)
|
||||
{
|
||||
HandleSrpUpdateResult(aError, aUpdate->GetDnsHeader(), aUpdate->GetHost(), aUpdate->GetMessageInfo());
|
||||
CommitSrpUpdate(aError, aUpdate->GetDnsHeader(), aUpdate->GetHost(), aUpdate->GetMessageInfo());
|
||||
|
||||
IgnoreError(mOutstandingUpdates.Remove(*aUpdate));
|
||||
aUpdate->Free();
|
||||
@@ -293,10 +293,10 @@ void Server::HandleAdvertisingResult(UpdateMetadata *aUpdate, otError aError)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::HandleSrpUpdateResult(otError aError,
|
||||
const Dns::UpdateHeader &aDnsHeader,
|
||||
Host & aHost,
|
||||
const Ip6::MessageInfo & aMessageInfo)
|
||||
void Server::CommitSrpUpdate(otError aError,
|
||||
const Dns::UpdateHeader &aDnsHeader,
|
||||
Host & aHost,
|
||||
const Ip6::MessageInfo & aMessageInfo)
|
||||
{
|
||||
Host * existingHost;
|
||||
uint32_t hostLease;
|
||||
@@ -992,20 +992,20 @@ void Server::HandleUpdate(const Dns::UpdateHeader &aDnsHeader, Host *aHost, cons
|
||||
exit:
|
||||
if (error != OT_ERROR_NONE)
|
||||
{
|
||||
HandleSrpUpdateResult(error, aDnsHeader, *aHost, aMessageInfo);
|
||||
CommitSrpUpdate(error, aDnsHeader, *aHost, aMessageInfo);
|
||||
}
|
||||
else if (mAdvertisingHandler != nullptr)
|
||||
else if (mServiceUpdateHandler != nullptr)
|
||||
{
|
||||
UpdateMetadata *update = UpdateMetadata::New(GetInstance(), aDnsHeader, aHost, aMessageInfo);
|
||||
|
||||
IgnoreError(mOutstandingUpdates.Add(*update));
|
||||
mOutstandingUpdatesTimer.StartAt(mOutstandingUpdates.GetTail()->GetExpireTime(), 0);
|
||||
|
||||
mAdvertisingHandler(aHost, kDefaultEventsHandlerTimeout, mAdvertisingHandlerContext);
|
||||
mServiceUpdateHandler(aHost, kDefaultEventsHandlerTimeout, mServiceUpdateHandlerContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleSrpUpdateResult(OT_ERROR_NONE, aDnsHeader, *aHost, aMessageInfo);
|
||||
CommitSrpUpdate(OT_ERROR_NONE, aDnsHeader, *aHost, aMessageInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1257,7 +1257,7 @@ void Server::HandleOutstandingUpdatesTimer(void)
|
||||
otLogInfoSrp("[server] outstanding service update timeout");
|
||||
while (!mOutstandingUpdates.IsEmpty() && mOutstandingUpdates.GetTail()->GetExpireTime() <= TimerMilli::GetNow())
|
||||
{
|
||||
HandleAdvertisingResult(mOutstandingUpdates.GetTail(), OT_ERROR_RESPONSE_TIMEOUT);
|
||||
HandleServiceUpdateResult(mOutstandingUpdates.GetTail(), OT_ERROR_RESPONSE_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-12
@@ -402,10 +402,10 @@ public:
|
||||
* @param[in] aServiceHandler A service events handler.
|
||||
* @param[in] aServiceHandlerContext A pointer to arbitrary context information.
|
||||
*
|
||||
* @note The handler SHOULD call HandleAdvertisingResult to report the result of its processing.
|
||||
* @note The handler SHOULD call HandleServiceUpdateResult to report the result of its processing.
|
||||
* Otherwise, a SRP update will be considered failed.
|
||||
*
|
||||
* @sa HandleAdvertisingResult
|
||||
* @sa HandleServiceUpdateResult
|
||||
*
|
||||
*/
|
||||
void SetServiceHandler(otSrpServerServiceUpdateHandler aServiceHandler, void *aServiceHandlerContext);
|
||||
@@ -482,13 +482,14 @@ public:
|
||||
const Host *GetNextHost(const Host *aHost);
|
||||
|
||||
/**
|
||||
* This method receives the service advertising result.
|
||||
* This method receives the service update result from service handler set by
|
||||
* SetServiceHandler.
|
||||
*
|
||||
* @param[in] aHost A pointer to the Host object which contains the SRP service updates.
|
||||
* @param[in] aError The service advertising result.
|
||||
* @param[in] aError The service update result.
|
||||
*
|
||||
*/
|
||||
void HandleAdvertisingResult(const Host *aHost, otError aError);
|
||||
void HandleServiceUpdateResult(const Host *aHost, otError aError);
|
||||
|
||||
private:
|
||||
enum : uint16_t
|
||||
@@ -547,10 +548,10 @@ private:
|
||||
uint32_t GrantLease(uint32_t aLease) const;
|
||||
uint32_t GrantKeyLease(uint32_t aKeyLease) const;
|
||||
|
||||
void HandleSrpUpdateResult(otError aError,
|
||||
const Dns::UpdateHeader &aDnsHeader,
|
||||
Host & aHost,
|
||||
const Ip6::MessageInfo & aMessageInfo);
|
||||
void CommitSrpUpdate(otError aError,
|
||||
const Dns::UpdateHeader &aDnsHeader,
|
||||
Host & aHost,
|
||||
const Ip6::MessageInfo & aMessageInfo);
|
||||
void HandleDnsUpdate(Message & aMessage,
|
||||
const Ip6::MessageInfo & aMessageInfo,
|
||||
const Dns::UpdateHeader &aDnsHeader,
|
||||
@@ -612,12 +613,12 @@ private:
|
||||
static void HandleOutstandingUpdatesTimer(Timer &aTimer);
|
||||
void HandleOutstandingUpdatesTimer(void);
|
||||
|
||||
void HandleAdvertisingResult(UpdateMetadata *aUpdate, otError aError);
|
||||
void HandleServiceUpdateResult(UpdateMetadata *aUpdate, otError aError);
|
||||
const UpdateMetadata *FindOutstandingUpdate(const Ip6::MessageInfo &aMessageInfo, uint16_t aDnsMessageId);
|
||||
|
||||
Ip6::Udp::Socket mSocket;
|
||||
otSrpServerServiceUpdateHandler mAdvertisingHandler;
|
||||
void * mAdvertisingHandlerContext;
|
||||
otSrpServerServiceUpdateHandler mServiceUpdateHandler;
|
||||
void * mServiceUpdateHandlerContext;
|
||||
|
||||
char *mDomain;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user