mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
[dhcp6-client] use NetifUnicastAddress in IdentityAssociation struct (#4308)
This commit is contained in:
committed by
Jonathan Hui
parent
11d3d9bbf2
commit
8b4f3fff31
@@ -61,10 +61,11 @@ Dhcp6Client::Dhcp6Client(Instance &aInstance)
|
||||
memset(mIdentityAssociations, 0, sizeof(mIdentityAssociations));
|
||||
}
|
||||
|
||||
bool Dhcp6Client::MatchNetifAddressWithPrefix(const otNetifAddress &aNetifAddress, const otIp6Prefix &aIp6Prefix)
|
||||
bool Dhcp6Client::MatchNetifAddressWithPrefix(const Ip6::NetifUnicastAddress &aNetifAddress,
|
||||
const otIp6Prefix & aIp6Prefix)
|
||||
{
|
||||
return aIp6Prefix.mLength == aNetifAddress.mPrefixLength &&
|
||||
otIp6PrefixMatch(&aNetifAddress.mAddress, &aIp6Prefix.mPrefix) >= aIp6Prefix.mLength;
|
||||
return (aIp6Prefix.mLength == aNetifAddress.mPrefixLength) &&
|
||||
(aNetifAddress.GetAddress().PrefixMatch(aIp6Prefix.mPrefix) >= aIp6Prefix.mLength);
|
||||
}
|
||||
|
||||
void Dhcp6Client::UpdateAddresses(void)
|
||||
@@ -103,7 +104,7 @@ void Dhcp6Client::UpdateAddresses(void)
|
||||
|
||||
if (!found)
|
||||
{
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(*static_cast<Ip6::NetifUnicastAddress *>(&ia.mNetifAddress));
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(ia.mNetifAddress);
|
||||
mIdentityAssociations[i].mStatus = kIaStatusInvalid;
|
||||
}
|
||||
}
|
||||
@@ -584,7 +585,7 @@ otError Dhcp6Client::ProcessIaAddress(Message &aMessage, uint16_t aOffset)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (otIp6PrefixMatch(&ia.mNetifAddress.mAddress, &option.GetAddress()) >= ia.mNetifAddress.mPrefixLength)
|
||||
if (ia.mNetifAddress.GetAddress().PrefixMatch(option.GetAddress()) >= ia.mNetifAddress.mPrefixLength)
|
||||
{
|
||||
mIdentityAssociations[i].mNetifAddress.mAddress = option.GetAddress();
|
||||
mIdentityAssociations[i].mPreferredLifetime = option.GetPreferredLifetime();
|
||||
@@ -592,7 +593,7 @@ otError Dhcp6Client::ProcessIaAddress(Message &aMessage, uint16_t aOffset)
|
||||
mIdentityAssociations[i].mNetifAddress.mPreferred = option.GetPreferredLifetime() != 0;
|
||||
mIdentityAssociations[i].mNetifAddress.mValid = option.GetValidLifetime() != 0;
|
||||
mIdentityAssociations[i].mStatus = kIaStatusSolicitReplied;
|
||||
Get<ThreadNetif>().AddUnicastAddress(*static_cast<Ip6::NetifUnicastAddress *>(&ia.mNetifAddress));
|
||||
Get<ThreadNetif>().AddUnicastAddress(ia.mNetifAddress);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "mac/mac.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "net/dhcp6.hpp"
|
||||
#include "net/netif.hpp"
|
||||
#include "net/udp6.hpp"
|
||||
|
||||
namespace ot {
|
||||
@@ -87,11 +88,11 @@ enum IaStatus
|
||||
*/
|
||||
struct IdentityAssociation
|
||||
{
|
||||
otNetifAddress mNetifAddress; ///< the NetifAddress
|
||||
uint32_t mPreferredLifetime; ///< The preferred lifetime.
|
||||
uint32_t mValidLifetime; ///< The valid lifetime.
|
||||
uint16_t mPrefixAgentRloc; ///< Rloc of Prefix Agent
|
||||
uint8_t mStatus; ///< Status of IdentityAssociation
|
||||
Ip6::NetifUnicastAddress mNetifAddress; ///< the NetifAddress
|
||||
uint32_t mPreferredLifetime; ///< The preferred lifetime.
|
||||
uint32_t mValidLifetime; ///< The valid lifetime.
|
||||
uint16_t mPrefixAgentRloc; ///< Rloc of Prefix Agent
|
||||
uint8_t mStatus; ///< Status of IdentityAssociation
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,7 @@ private:
|
||||
void Start(void);
|
||||
void Stop(void);
|
||||
|
||||
static bool MatchNetifAddressWithPrefix(const otNetifAddress &aNetifAddress, const otIp6Prefix &aIp6Prefix);
|
||||
static bool MatchNetifAddressWithPrefix(const Ip6::NetifUnicastAddress &aAddress, const otIp6Prefix &aIp6Prefix);
|
||||
|
||||
otError Solicit(uint16_t aRloc16);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user