[dhcp6] use Ip6::Address::SetPrefix() (#4685)

This commit is contained in:
Jonathan Hui
2020-03-16 08:56:17 -07:00
committed by GitHub
parent 2bb72299d3
commit 6a277399e1
4 changed files with 13 additions and 14 deletions
+8 -8
View File
@@ -79,13 +79,13 @@ otError DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInf
StateTlv::State state = StateTlv::kReject;
Dataset dataset(mLocal.GetType());
ActiveTimestampTlv activeTimestamp;
PendingTimestampTlv pendingTimestamp;
ChannelTlv channel;
uint16_t sessionId;
otMeshLocalPrefix meshLocalPrefix;
MasterKey masterKey;
uint16_t panId;
ActiveTimestampTlv activeTimestamp;
PendingTimestampTlv pendingTimestamp;
ChannelTlv channel;
uint16_t sessionId;
Mle::MeshLocalPrefix meshLocalPrefix;
MasterKey masterKey;
uint16_t panId;
activeTimestamp.SetLength(0);
pendingTimestamp.SetLength(0);
@@ -144,7 +144,7 @@ otError DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInf
// check mesh local prefix
if (Tlv::ReadTlv(aMessage, Tlv::kMeshLocalPrefix, &meshLocalPrefix, sizeof(meshLocalPrefix)) == OT_ERROR_NONE &&
memcmp(&meshLocalPrefix, &Get<Mle::MleRouter>().GetMeshLocalPrefix(), sizeof(meshLocalPrefix)))
meshLocalPrefix != Get<Mle::MleRouter>().GetMeshLocalPrefix())
{
doesAffectConnectivity = true;
}
+1 -2
View File
@@ -280,8 +280,7 @@ otError Dhcp6Client::Solicit(uint16_t aRloc16)
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xff03);
messageInfo.GetPeerAddr().mFields.m16[7] = HostSwap16(0x0002);
#else
memcpy(messageInfo.GetPeerAddr().mFields.m8, Get<Mle::MleRouter>().GetMeshLocalPrefix().m8,
sizeof(otMeshLocalPrefix));
messageInfo.GetPeerAddr().SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
messageInfo.GetPeerAddr().mFields.m16[4] = HostSwap16(0x0000);
messageInfo.GetPeerAddr().mFields.m16[5] = HostSwap16(0x00ff);
messageInfo.GetPeerAddr().mFields.m16[6] = HostSwap16(0xfe00);
+1 -1
View File
@@ -464,7 +464,7 @@ otError Dhcp6Server::AddIaAddress(Message &aMessage, const Ip6::Address &aPrefix
IaAddress option;
option.Init();
memcpy(option.GetAddress().mFields.m8, &aPrefix, OT_IP6_PREFIX_SIZE);
option.GetAddress().SetPrefix(aPrefix.mFields.m8, OT_IP6_PREFIX_BITSIZE);
option.GetAddress().SetIid(*reinterpret_cast<Mac::ExtAddress *>(aClientId.GetDuidLinkLayerAddress()));
option.SetPreferredLifetime(OT_DHCP6_DEFAULT_PREFERRED_LIFETIME);
option.SetValidLifetime(OT_DHCP6_DEFAULT_VALID_LIFETIME);
+3 -3
View File
@@ -163,17 +163,17 @@ private:
* @param[in] aContextId The 6LoWPAN Context ID.
*
*/
void Set(const otIp6Prefix &aPrefix, const otMeshLocalPrefix &aMeshLocalPrefix, uint8_t aContextId)
void Set(const otIp6Prefix &aPrefix, const Mle::MeshLocalPrefix &aMeshLocalPrefix, uint8_t aContextId)
{
mPrefix = aPrefix;
memcpy(&mAloc.mAddress, &aMeshLocalPrefix, OT_IP6_PREFIX_SIZE);
mAloc.GetAddress().SetPrefix(aMeshLocalPrefix);
mAloc.mAddress.mFields.m16[4] = HostSwap16(0x0000);
mAloc.mAddress.mFields.m16[5] = HostSwap16(0x00ff);
mAloc.mAddress.mFields.m16[6] = HostSwap16(0xfe00);
mAloc.mAddress.mFields.m8[14] = Ip6::Address::kAloc16Mask;
mAloc.mAddress.mFields.m8[15] = aContextId;
mAloc.mPrefixLength = 64;
mAloc.mPrefixLength = OT_IP6_PREFIX_BITSIZE;
mAloc.mPreferred = true;
mAloc.mValid = true;
}