diff --git a/src/core/net/dhcp6_client.cpp b/src/core/net/dhcp6_client.cpp index c4bf40885..86beebc91 100644 --- a/src/core/net/dhcp6_client.cpp +++ b/src/core/net/dhcp6_client.cpp @@ -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().RemoveUnicastAddress(*static_cast(&ia.mNetifAddress)); + Get().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().AddUnicastAddress(*static_cast(&ia.mNetifAddress)); + Get().AddUnicastAddress(ia.mNetifAddress); break; } } diff --git a/src/core/net/dhcp6_client.hpp b/src/core/net/dhcp6_client.hpp index 05ca1a955..e38ca0dbd 100644 --- a/src/core/net/dhcp6_client.hpp +++ b/src/core/net/dhcp6_client.hpp @@ -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);