mirror of
https://github.com/espressif/openthread.git
synced 2026-08-30 22:09:54 +00:00
Clean up MessageInfo class. (#888)
This commit is contained in:
@@ -230,9 +230,8 @@ void Client::SendEmptyMessage(const Ip6::Address &aAddress, uint16_t aPort, uint
|
||||
|
||||
VerifyOrExit((message = NewMessage(header)) != NULL, ;);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aAddress;
|
||||
messageInfo.mPeerPort = aPort;
|
||||
messageInfo.SetPeerAddr(aAddress);
|
||||
messageInfo.SetPeerPort(aPort);
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
@@ -289,9 +288,8 @@ void Client::HandleRetransmissionTimer(void)
|
||||
// Retransmit
|
||||
if (!requestMetadata.mAcknowledged)
|
||||
{
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = requestMetadata.mDestinationAddress;
|
||||
messageInfo.mPeerPort = requestMetadata.mDestinationPort;
|
||||
messageInfo.SetPeerAddr(requestMetadata.mDestinationAddress);
|
||||
messageInfo.SetPeerPort(requestMetadata.mDestinationPort);
|
||||
|
||||
SendCopy(*message, messageInfo);
|
||||
}
|
||||
@@ -321,7 +319,7 @@ Message *Client::FindRelatedRequest(const Header &aResponseHeader, const Ip6::Me
|
||||
aRequestMetadata.ReadFrom(*message);
|
||||
|
||||
if ((aRequestMetadata.mDestinationAddress == aMessageInfo.GetPeerAddr()) &&
|
||||
(aRequestMetadata.mDestinationPort == aMessageInfo.mPeerPort))
|
||||
(aRequestMetadata.mDestinationPort == aMessageInfo.GetPeerPort()))
|
||||
{
|
||||
assert(aRequestHeader.FromMessage(*message) == kThreadError_None);
|
||||
|
||||
@@ -432,7 +430,7 @@ void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag
|
||||
if (responseHeader.IsConfirmable())
|
||||
{
|
||||
// Send empty ACK if it is a CON message.
|
||||
SendEmptyAck(aMessageInfo.GetPeerAddr(), aMessageInfo.mPeerPort, responseHeader.GetMessageId());
|
||||
SendEmptyAck(aMessageInfo.GetPeerAddr(), aMessageInfo.GetPeerPort(), responseHeader.GetMessageId());
|
||||
}
|
||||
|
||||
FinalizeCoapTransaction(*message, requestMetadata, &responseHeader, &aMessage, kThreadError_None);
|
||||
@@ -447,7 +445,7 @@ exit:
|
||||
if (responseHeader.IsConfirmable() || responseHeader.IsNonConfirmable())
|
||||
{
|
||||
// Successfully parsed a header but no matching request was found - reject the message by sending reset.
|
||||
SendReset(aMessageInfo.GetPeerAddr(), aMessageInfo.mPeerPort, responseHeader.GetMessageId());
|
||||
SendReset(aMessageInfo.GetPeerAddr(), aMessageInfo.GetPeerPort(), responseHeader.GetMessageId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,7 +453,7 @@ exit:
|
||||
RequestMetadata::RequestMetadata(bool aConfirmable, const Ip6::MessageInfo &aMessageInfo,
|
||||
otCoapResponseHandler aHandler, void *aContext)
|
||||
{
|
||||
mDestinationPort = aMessageInfo.mPeerPort;
|
||||
mDestinationPort = aMessageInfo.GetPeerPort();
|
||||
mDestinationAddress = aMessageInfo.GetPeerAddr();
|
||||
mResponseHandler = aHandler;
|
||||
mResponseContext = aContext;
|
||||
|
||||
@@ -105,10 +105,9 @@ ThreadError AnnounceBeginClient::SendRequest(uint32_t aChannelMask, uint8_t aCou
|
||||
period.SetPeriod(aPeriod);
|
||||
SuccessOrExit(error = message->Append(&period, sizeof(period)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aAddress;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerAddr(aAddress);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
|
||||
@@ -327,9 +327,8 @@ ThreadError Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs,
|
||||
SuccessOrExit(error = message->Append(aTlvs, aLength));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mNetif.GetMle().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleMgmtCommissionerGetResponse, this));
|
||||
|
||||
@@ -421,9 +420,8 @@ ThreadError Commissioner::SendMgmtCommissionerSetRequest(const otCommissioningDa
|
||||
SuccessOrExit(error = message->Append(aTlvs, aLength));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mNetif.GetMle().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleMgmtCommissionerSetResponse, this));
|
||||
|
||||
@@ -483,9 +481,8 @@ ThreadError Commissioner::SendPetition(void)
|
||||
|
||||
SuccessOrExit(error = message->Append(&commissionerId, sizeof(Tlv) + commissionerId.GetLength()));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mNetif.GetMle().GetLeaderAloc(*static_cast<Ip6::Address *>(&messageInfo.mPeerAddr));
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleLeaderPetitionResponse, this));
|
||||
|
||||
@@ -580,9 +577,8 @@ ThreadError Commissioner::SendKeepAlive(void)
|
||||
sessionId.SetCommissionerSessionId(mSessionId);
|
||||
SuccessOrExit(error = message->Append(&sessionId, sizeof(sessionId)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mNetif.GetMle().GetLeaderAloc(*static_cast<Ip6::Address *>(&messageInfo.mPeerAddr));
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleLeaderKeepAliveResponse, this));
|
||||
|
||||
@@ -849,11 +845,10 @@ void Commissioner::HandleUdpTransmit(void)
|
||||
mTransmitMessage->Write(mTransmitMessage->GetOffset(), sizeof(tlv), &tlv);
|
||||
mTransmitMessage->SetOffset(0);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = *mNetif.GetMle().GetMeshLocal16();
|
||||
messageInfo.SetPeerAddr(mNetif.GetMle().GetMeshLocal16());
|
||||
messageInfo.GetPeerAddr().mFields.m16[7] = HostSwap16(mJoinerRloc);
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*mTransmitMessage, messageInfo));
|
||||
|
||||
|
||||
@@ -117,10 +117,9 @@ ThreadError EnergyScanClient::SendQuery(uint32_t aChannelMask, uint8_t aCount, u
|
||||
scanDuration.SetScanDuration(aScanDuration);
|
||||
SuccessOrExit(error = message->Append(&scanDuration, sizeof(scanDuration)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aAddress;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerAddr(aAddress);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent energy scan query");
|
||||
@@ -190,7 +189,7 @@ ThreadError EnergyScanClient::SendResponse(const Coap::Header &aRequestHeader, c
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit((message = mCoapServer.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
@@ -198,7 +197,6 @@ ThreadError EnergyScanClient::SendResponse(const Coap::Header &aRequestHeader, c
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
|
||||
@@ -248,11 +248,10 @@ void Joiner::HandleUdpTransmit(void)
|
||||
otLogInfoMeshCoP("transmit %d (to %llX)", mTransmitMessage->GetLength(),
|
||||
HostSwap64(*reinterpret_cast<uint64_t *>(&mJoinerRouter)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
messageInfo.GetPeerAddr().SetIid(mJoinerRouter);
|
||||
messageInfo.mPeerPort = mJoinerUdpPort;
|
||||
messageInfo.mInterfaceId = OT_NETIF_INTERFACE_ID_THREAD;
|
||||
messageInfo.SetPeerPort(mJoinerUdpPort);
|
||||
messageInfo.SetInterfaceId(OT_NETIF_INTERFACE_ID_THREAD);
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(*mTransmitMessage, messageInfo));
|
||||
|
||||
@@ -405,7 +404,7 @@ void Joiner::SendJoinerEntrustResponse(const Coap::Header &aRequestHeader,
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit((message = mCoapServer.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
@@ -413,7 +412,6 @@ void Joiner::SendJoinerEntrustResponse(const Coap::Header &aRequestHeader,
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
SuccessOrExit(error = message->Append(header.GetBytes(), header.GetLength()));
|
||||
|
||||
udpPort.Init();
|
||||
udpPort.SetUdpPort(aMessageInfo.mPeerPort);
|
||||
udpPort.SetUdpPort(aMessageInfo.GetPeerPort());
|
||||
SuccessOrExit(error = message->Append(&udpPort, sizeof(udpPort)));
|
||||
|
||||
iid.Init();
|
||||
@@ -234,12 +234,9 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
SuccessOrExit(error = message->Append(tmp, length));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
memcpy(messageInfo.GetPeerAddr().mFields.m8, mNetif.GetMle().GetMeshLocalPrefix(), 8);
|
||||
messageInfo.GetPeerAddr().mFields.m16[5] = HostSwap16(0x00ff);
|
||||
messageInfo.GetPeerAddr().mFields.m16[6] = HostSwap16(0xfe00);
|
||||
messageInfo.SetPeerAddr(mNetif.GetMle().GetMeshLocal16());
|
||||
messageInfo.GetPeerAddr().mFields.m16[7] = HostSwap16(borderAgentRloc);
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
@@ -308,11 +305,10 @@ void JoinerRouter::HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage,
|
||||
|
||||
aMessage.CopyTo(offset, 0, length, *message);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.mPeerAddr.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
memcpy(messageInfo.mPeerAddr.mFields.m8 + 8, joinerIid.GetIid(), 8);
|
||||
messageInfo.mPeerPort = joinerPort.GetUdpPort();
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerPort(joinerPort.GetUdpPort());
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
@@ -417,7 +413,7 @@ ThreadError JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo
|
||||
}
|
||||
|
||||
messageInfo = aMessageInfo;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("Sent joiner entrust length = %d", message->GetLength());
|
||||
|
||||
@@ -238,9 +238,8 @@ ThreadError Leader::SendDatasetChanged(const Ip6::Address &aAddress)
|
||||
|
||||
VerifyOrExit((message = mCoapClient.NewMessage(header)) != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aAddress;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerAddr(aAddress);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset changed");
|
||||
|
||||
@@ -100,10 +100,9 @@ ThreadError PanIdQueryClient::SendQuery(uint16_t aPanId, uint32_t aChannelMask,
|
||||
panId.SetPanId(aPanId);
|
||||
SuccessOrExit(error = message->Append(&panId, sizeof(panId)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aAddress;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerAddr(aAddress);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent panid query");
|
||||
@@ -175,7 +174,7 @@ ThreadError PanIdQueryClient::SendConflictResponse(const Coap::Header &aRequestH
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit((message = mCoapServer.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
@@ -183,7 +182,6 @@ ThreadError PanIdQueryClient::SendConflictResponse(const Coap::Header &aRequestH
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
|
||||
@@ -128,8 +128,7 @@ ThreadError Icmp::SendError(const Address &aDestination, IcmpHeader::Type aType,
|
||||
icmp6Header.SetCode(aCode);
|
||||
message->Write(0, sizeof(icmp6Header), &icmp6Header);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.mPeerAddr = aDestination;
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
|
||||
SuccessOrExit(error = mIp6.SendDatagram(*message, messageInfo, kProtoIcmp6));
|
||||
|
||||
@@ -221,15 +220,14 @@ ThreadError Icmp::HandleEchoRequest(Message &aRequestMessage, const MessageInfo
|
||||
aRequestMessage.CopyTo(aRequestMessage.GetOffset() + IcmpHeader::GetDataOffset(),
|
||||
IcmpHeader::GetDataOffset(), payloadLength, *replyMessage);
|
||||
|
||||
memset(&replyMessageInfo, 0, sizeof(replyMessageInfo));
|
||||
replyMessageInfo.GetPeerAddr() = aMessageInfo.GetPeerAddr();
|
||||
replyMessageInfo.SetPeerAddr(aMessageInfo.GetPeerAddr());
|
||||
|
||||
if (!aMessageInfo.GetSockAddr().IsMulticast())
|
||||
{
|
||||
replyMessageInfo.GetSockAddr() = aMessageInfo.GetSockAddr();
|
||||
replyMessageInfo.SetSockAddr(aMessageInfo.GetSockAddr());
|
||||
}
|
||||
|
||||
replyMessageInfo.mInterfaceId = aMessageInfo.mInterfaceId;
|
||||
replyMessageInfo.SetInterfaceId(aMessageInfo.mInterfaceId);
|
||||
|
||||
SuccessOrExit(error = mIp6.SendDatagram(*replyMessage, replyMessageInfo, kProtoIcmp6));
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ ThreadError Ip6::SendDatagram(Message &message, MessageInfo &messageInfo, IpProt
|
||||
|
||||
if (header.GetDestination().IsLinkLocal() || header.GetDestination().IsLinkLocalMulticast())
|
||||
{
|
||||
VerifyOrExit(messageInfo.mInterfaceId != 0, error = kThreadError_Drop);
|
||||
VerifyOrExit(messageInfo.GetInterfaceId() != 0, error = kThreadError_Drop);
|
||||
}
|
||||
|
||||
if (messageInfo.GetPeerAddr().IsRealmLocalMulticast())
|
||||
@@ -380,7 +380,7 @@ exit:
|
||||
|
||||
if (error == kThreadError_None)
|
||||
{
|
||||
message.SetInterfaceId(messageInfo.mInterfaceId);
|
||||
message.SetInterfaceId(messageInfo.GetInterfaceId());
|
||||
EnqueueDatagram(message);
|
||||
}
|
||||
|
||||
@@ -622,12 +622,11 @@ ThreadError Ip6::HandleDatagram(Message &message, Netif *netif, int8_t interface
|
||||
VerifyOrExit(sizeof(header) + payloadLength == message.GetLength() &&
|
||||
sizeof(header) + payloadLength <= Ip6::kMaxDatagramLength, error = kThreadError_Drop);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = header.GetSource();
|
||||
messageInfo.GetSockAddr() = header.GetDestination();
|
||||
messageInfo.mInterfaceId = interfaceId;
|
||||
messageInfo.mHopLimit = header.GetHopLimit();
|
||||
messageInfo.mLinkInfo = linkMessageInfo;
|
||||
messageInfo.SetPeerAddr(header.GetSource());
|
||||
messageInfo.SetSockAddr(header.GetDestination());
|
||||
messageInfo.SetInterfaceId(interfaceId);
|
||||
messageInfo.SetHopLimit(header.GetHopLimit());
|
||||
messageInfo.SetLinkInfo(linkMessageInfo);
|
||||
|
||||
// determine destination of packet
|
||||
if (header.GetDestination().IsMulticast())
|
||||
|
||||
+98
-4
@@ -55,12 +55,10 @@ class MessageInfo: public otMessageInfo
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method returns a reference to the local socket address.
|
||||
*
|
||||
* @returns A reference to the local socket address.
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
Address &GetSockAddr(void) { return *static_cast<Address *>(&mSockAddr);}
|
||||
MessageInfo(void) { memset(this, 0, sizeof(*this)); }
|
||||
|
||||
/**
|
||||
* This method returns a reference to the local socket address.
|
||||
@@ -70,6 +68,30 @@ public:
|
||||
*/
|
||||
const Address &GetSockAddr(void) const { return *static_cast<const Address *>(&mSockAddr);}
|
||||
|
||||
/**
|
||||
* This method sets the local socket address.
|
||||
*
|
||||
* @param[in] aAddress The IPv6 address.
|
||||
*
|
||||
*/
|
||||
void SetSockAddr(const Address &aAddress) { mSockAddr = aAddress; }
|
||||
|
||||
/**
|
||||
* This method gets the local socket port.
|
||||
*
|
||||
* @returns The local socket port.
|
||||
*
|
||||
*/
|
||||
uint16_t GetSockPort(void) const { return mSockPort; }
|
||||
|
||||
/**
|
||||
* This method gets the local socket port.
|
||||
*
|
||||
* @param[in] aPort The port value.
|
||||
*
|
||||
*/
|
||||
void SetSockPort(uint16_t aPort) { mSockPort = aPort; }
|
||||
|
||||
/**
|
||||
* This method returns a reference to the peer socket address.
|
||||
*
|
||||
@@ -85,6 +107,78 @@ public:
|
||||
*
|
||||
*/
|
||||
const Address &GetPeerAddr(void) const { return *static_cast<const Address *>(&mPeerAddr);}
|
||||
|
||||
/**
|
||||
* This method sets the peer's socket address.
|
||||
*
|
||||
* @param[in] aAddress The IPv6 address.
|
||||
*
|
||||
*/
|
||||
void SetPeerAddr(const Address &aAddress) { mPeerAddr = aAddress; }
|
||||
|
||||
/**
|
||||
* This method gets the peer socket port.
|
||||
*
|
||||
* @returns The peer socket port.
|
||||
*
|
||||
*/
|
||||
uint16_t GetPeerPort(void) const { return mPeerPort; }
|
||||
|
||||
/**
|
||||
* This method gets the peer socket port.
|
||||
*
|
||||
* @param[in] aPort The port value.
|
||||
*
|
||||
*/
|
||||
void SetPeerPort(uint16_t aPort) { mPeerPort = aPort; }
|
||||
|
||||
/**
|
||||
* This method gets the Interface ID.
|
||||
*
|
||||
* @returns The Interface ID.
|
||||
*
|
||||
*/
|
||||
int8_t GetInterfaceId(void) const { return mInterfaceId; }
|
||||
|
||||
/**
|
||||
* This method sets the Interface ID.
|
||||
*
|
||||
* @param[in] aInterfaceId The Interface ID.
|
||||
*
|
||||
*/
|
||||
void SetInterfaceId(int8_t aInterfaceId) { mInterfaceId = aInterfaceId; }
|
||||
|
||||
/**
|
||||
* This method gets the Hop Limit.
|
||||
*
|
||||
* @returns The Hop Limit.
|
||||
*
|
||||
*/
|
||||
uint8_t GetHopLimit(void) const { return mHopLimit; }
|
||||
|
||||
/**
|
||||
* This method sets the Hop Limit.
|
||||
*
|
||||
* @param[in] aHopLimit The Hop Limit.
|
||||
*
|
||||
*/
|
||||
void SetHopLimit(uint8_t aHopLimit) { mHopLimit = aHopLimit; }
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the Link Info.
|
||||
*
|
||||
* @returns A poitner to the Link Info.
|
||||
*
|
||||
*/
|
||||
const void *GetLinkInfo(void) const { return mLinkInfo; }
|
||||
|
||||
/**
|
||||
* This method sets the pointer to the Link Info.
|
||||
*
|
||||
* @param[in] aLinkInfo A pointer to the Link Info.
|
||||
*
|
||||
*/
|
||||
void SetLinkInfo(const void *aLinkInfo) { mLinkInfo = aLinkInfo; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,7 +91,7 @@ ThreadError UdpSocket::SendTo(Message &aMessage, const MessageInfo &aMessageInfo
|
||||
|
||||
if (messageInfoLocal.GetSockAddr().IsUnspecified())
|
||||
{
|
||||
messageInfoLocal.GetSockAddr() = GetSockName().GetAddress();
|
||||
messageInfoLocal.SetSockAddr(GetSockName().GetAddress());
|
||||
}
|
||||
|
||||
if (GetSockName().mPort == 0)
|
||||
|
||||
@@ -273,7 +273,7 @@ void otSetMaxTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
|
||||
const otIp6Address *otGetMeshLocalEid(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetMle().GetMeshLocal64();
|
||||
return &aInstance->mThreadNetif.GetMle().GetMeshLocal64();
|
||||
}
|
||||
|
||||
const uint8_t *otGetMeshLocalPrefix(otInstance *aInstance)
|
||||
|
||||
@@ -182,12 +182,11 @@ ThreadError AddressResolver::SendAddressQuery(const Ip6::Address &aEid)
|
||||
targetTlv.SetTarget(aEid);
|
||||
SuccessOrExit(error = message->Append(&targetTlv, sizeof(targetTlv)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xff03);
|
||||
messageInfo.GetPeerAddr().mFields.m16[7] = HostSwap16(0x0002);
|
||||
messageInfo.GetSockAddr() = *mMle.GetMeshLocal16();
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetSockAddr(mMle.GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
@@ -296,7 +295,7 @@ void AddressResolver::SendAddressNotificationResponse(const Coap::Header &aReque
|
||||
ThreadError error;
|
||||
Message *message;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit((message = mCoapServer.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
@@ -304,7 +303,6 @@ void AddressResolver::SendAddressNotificationResponse(const Coap::Header &aReque
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
@@ -336,8 +334,6 @@ ThreadError AddressResolver::SendAddressError(const ThreadTargetTlv &aTarget, co
|
||||
SuccessOrExit(error = message->Append(&aTarget, sizeof(aTarget)));
|
||||
SuccessOrExit(error = message->Append(&aEid, sizeof(aEid)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
|
||||
if (aDestination == NULL)
|
||||
{
|
||||
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xff03);
|
||||
@@ -348,8 +344,9 @@ ThreadError AddressResolver::SendAddressError(const ThreadTargetTlv &aTarget, co
|
||||
memcpy(&messageInfo.GetPeerAddr(), aDestination, sizeof(messageInfo.GetPeerAddr()));
|
||||
}
|
||||
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetSockAddr(mMle.GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
@@ -371,7 +368,7 @@ void AddressResolver::SendAddressErrorResponse(const Coap::Header &aRequestHeade
|
||||
ThreadError error;
|
||||
Message *message;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit((message = mCoapServer.NewMessage(0)) != NULL, error = kThreadError_NoBufs);
|
||||
|
||||
@@ -379,7 +376,6 @@ void AddressResolver::SendAddressErrorResponse(const Coap::Header &aRequestHeade
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
@@ -429,7 +425,7 @@ void AddressResolver::HandleAddressError(Coap::Header &aHeader, Message &aMessag
|
||||
for (const Ip6::NetifUnicastAddress *address = mNetif.GetUnicastAddresses(); address; address = address->GetNext())
|
||||
{
|
||||
if (memcmp(&address->mAddress, targetTlv.GetTarget(), sizeof(address->mAddress)) == 0 &&
|
||||
memcmp(mMle.GetMeshLocal64()->GetIid(), mlIidTlv.GetIid(), 8))
|
||||
memcmp(mMle.GetMeshLocal64().GetIid(), mlIidTlv.GetIid(), 8))
|
||||
{
|
||||
// Target EID matches address and Mesh Local EID differs
|
||||
mNetif.RemoveUnicastAddress(*address);
|
||||
@@ -500,7 +496,7 @@ void AddressResolver::HandleAddressQuery(Coap::Header &aHeader, Message &aMessag
|
||||
|
||||
if (mNetif.IsUnicastAddress(*targetTlv.GetTarget()))
|
||||
{
|
||||
mlIidTlv.SetIid(mMle.GetMeshLocal64()->GetIid());
|
||||
mlIidTlv.SetIid(mMle.GetMeshLocal64().GetIid());
|
||||
SendAddressQueryResponse(targetTlv, mlIidTlv, NULL, aMessageInfo.GetPeerAddr());
|
||||
ExitNow();
|
||||
}
|
||||
@@ -565,10 +561,9 @@ void AddressResolver::SendAddressQueryResponse(const ThreadTargetTlv &aTargetTlv
|
||||
SuccessOrExit(error = message->Append(aLastTransactionTimeTlv, sizeof(*aLastTransactionTimeTlv)));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
memcpy(&messageInfo.GetPeerAddr(), &aDestination, sizeof(messageInfo.GetPeerAddr()));
|
||||
messageInfo.GetSockAddr() = *mMle.GetMeshLocal16();
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
messageInfo.SetSockAddr(mMle.GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ ThreadError AnnounceBeginServer::SendResponse(const Coap::Header &aRequestHeader
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message = NULL;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit(aRequestHeader.GetType() == kCoapTypeConfirmable, ;);
|
||||
|
||||
@@ -143,7 +143,6 @@ ThreadError AnnounceBeginServer::SendResponse(const Coap::Header &aRequestHeader
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ ThreadError EnergyScanServer::SendResponse(const Coap::Header &aRequestHeader, c
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message = NULL;
|
||||
Coap::Header responseHeader;
|
||||
Ip6::MessageInfo responseInfo;
|
||||
Ip6::MessageInfo responseInfo(aRequestInfo);
|
||||
|
||||
VerifyOrExit(aRequestHeader.GetType() == kCoapTypeConfirmable, ;);
|
||||
|
||||
@@ -130,7 +130,6 @@ ThreadError EnergyScanServer::SendResponse(const Coap::Header &aRequestHeader, c
|
||||
|
||||
SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength()));
|
||||
|
||||
memcpy(&responseInfo, &aRequestInfo, sizeof(responseInfo));
|
||||
memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr));
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo));
|
||||
|
||||
@@ -244,9 +243,8 @@ ThreadError EnergyScanServer::SendReport(void)
|
||||
SuccessOrExit(error = message->Append(&energyList, sizeof(energyList)));
|
||||
SuccessOrExit(error = message->Append(mScanResults, mScanResultsLength));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = mCommissioner;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerAddr(mCommissioner);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent scan results");
|
||||
|
||||
@@ -193,9 +193,8 @@ ThreadError DatasetManager::Register(void)
|
||||
|
||||
mMle.GetLeaderAloc(leader);
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
memcpy(&messageInfo.mPeerAddr, &leader, sizeof(messageInfo.mPeerAddr));
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerAddr(leader);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset to leader");
|
||||
@@ -394,7 +393,7 @@ ThreadError DatasetManager::Set(Coap::Header &aHeader, Message &aMessage, const
|
||||
VerifyOrExit(locator != 0xffff, ;);
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
memcpy(&destination, mNetif.GetMle().GetMeshLocal16(), OT_MESH_LOCAL_PREFIX_SIZE);
|
||||
destination = mNetif.GetMle().GetMeshLocal16();
|
||||
destination.mFields.m16[4] = HostSwap16(0x0000);
|
||||
destination.mFields.m16[5] = HostSwap16(0x00ff);
|
||||
destination.mFields.m16[6] = HostSwap16(0xfe00);
|
||||
@@ -514,9 +513,8 @@ ThreadError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset,
|
||||
SuccessOrExit(error = message->Append(aTlvs, aLength));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mMle.GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset set request to leader");
|
||||
@@ -554,9 +552,8 @@ ThreadError DatasetManager::SendGetRequest(const uint8_t *aTlvTypes, const uint8
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aLength));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mMle.GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset get request to leader");
|
||||
|
||||
+13
-14
@@ -613,14 +613,14 @@ void Mle::SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLead
|
||||
mLeaderData.SetLeaderRouterId(aLeaderRouterId);
|
||||
}
|
||||
|
||||
const Ip6::Address *Mle::GetMeshLocal16(void) const
|
||||
const Ip6::Address &Mle::GetMeshLocal16(void) const
|
||||
{
|
||||
return &mMeshLocal16.GetAddress();
|
||||
return mMeshLocal16.GetAddress();
|
||||
}
|
||||
|
||||
const Ip6::Address *Mle::GetMeshLocal64(void) const
|
||||
const Ip6::Address &Mle::GetMeshLocal64(void) const
|
||||
{
|
||||
return &mMeshLocal64.GetAddress();
|
||||
return mMeshLocal64.GetAddress();
|
||||
}
|
||||
|
||||
ThreadError Mle::GetLeaderAddress(Ip6::Address &aAddress) const
|
||||
@@ -1579,12 +1579,11 @@ ThreadError Mle::SendMessage(Message &aMessage, const Ip6::Address &aDestination
|
||||
mKeyManager.IncrementMleFrameCounter();
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
memcpy(&messageInfo.GetPeerAddr(), &aDestination, sizeof(messageInfo.GetPeerAddr()));
|
||||
memcpy(&messageInfo.GetSockAddr(), &mLinkLocal64.GetAddress(), sizeof(messageInfo.GetSockAddr()));
|
||||
messageInfo.mPeerPort = kUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.mHopLimit = 255;
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
messageInfo.SetSockAddr(mLinkLocal64.GetAddress());
|
||||
messageInfo.SetPeerPort(kUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
messageInfo.SetHopLimit(255);
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(aMessage, messageInfo));
|
||||
|
||||
@@ -1620,7 +1619,7 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn
|
||||
aMessage.Read(aMessage.GetOffset(), sizeof(header), &header);
|
||||
VerifyOrExit(header.IsValid(),);
|
||||
|
||||
assert(aMessageInfo.mLinkInfo != NULL);
|
||||
assert(aMessageInfo.GetLinkInfo() != NULL);
|
||||
|
||||
if (header.GetSecuritySuite() == Header::kNoSecurity)
|
||||
{
|
||||
@@ -2095,7 +2094,7 @@ ThreadError Mle::HandleParentResponse(const Message &aMessage, const Ip6::Messag
|
||||
uint32_t aKeySequence)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
ResponseTlv response;
|
||||
SourceAddressTlv sourceAddress;
|
||||
LeaderDataTlv leaderData;
|
||||
@@ -2666,7 +2665,7 @@ exit:
|
||||
ThreadError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
Tlv tlv;
|
||||
MeshCoP::Tlv meshcopTlv;
|
||||
MeshCoP::DiscoveryResponseTlv discoveryResponse;
|
||||
@@ -2841,7 +2840,7 @@ ThreadError Mle::CheckReachability(uint16_t aMeshSource, uint16_t aMeshDest, Ip6
|
||||
ExitNow(error = kThreadError_None);
|
||||
}
|
||||
|
||||
memcpy(&dst, GetMeshLocal16(), kRlocPrefixLength);
|
||||
dst = GetMeshLocal16();
|
||||
dst.mFields.m16[7] = HostSwap16(aMeshSource);
|
||||
mNetif.GetIp6().mIcmp.SendError(dst, Ip6::IcmpHeader::kTypeDstUnreach, Ip6::IcmpHeader::kCodeDstUnreachNoRoute,
|
||||
aIp6Header);
|
||||
|
||||
@@ -587,20 +587,20 @@ public:
|
||||
uint16_t GetRloc16(void) const;
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the RLOC assigned to the Thread interface.
|
||||
* This method returns a reference to the RLOC assigned to the Thread interface.
|
||||
*
|
||||
* @returns A pointer to the RLOC assigned to the Thread interface.
|
||||
* @returns A reference to the RLOC assigned to the Thread interface.
|
||||
*
|
||||
*/
|
||||
const Ip6::Address *GetMeshLocal16(void) const;
|
||||
const Ip6::Address &GetMeshLocal16(void) const;
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the ML-EID assigned to the Thread interface.
|
||||
* This method returns a reference to the ML-EID assigned to the Thread interface.
|
||||
*
|
||||
* @returns A pointer to the ML-EID assigned to the Thread interface.
|
||||
* @returns A reference to the ML-EID assigned to the Thread interface.
|
||||
*
|
||||
*/
|
||||
const Ip6::Address *GetMeshLocal64(void) const;
|
||||
const Ip6::Address &GetMeshLocal64(void) const;
|
||||
|
||||
/**
|
||||
* This method returns the Router ID of the Leader.
|
||||
|
||||
@@ -639,7 +639,7 @@ ThreadError MleRouter::HandleLinkRequest(const Message &aMessage, const Ip6::Mes
|
||||
if (neighbor->mState != Neighbor::kStateValid)
|
||||
{
|
||||
const ThreadMessageInfo *threadMessageInfo =
|
||||
static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
|
||||
memcpy(&neighbor->mMacAddr, &macAddr, sizeof(neighbor->mMacAddr));
|
||||
neighbor->mLinkInfo.Clear();
|
||||
@@ -679,7 +679,7 @@ ThreadError MleRouter::SendLinkAccept(const Ip6::MessageInfo &aMessageInfo, Neig
|
||||
const TlvRequestTlv &aTlvRequest, const ChallengeTlv &aChallenge)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
static const uint8_t routerTlvs[] = {Tlv::kLinkMargin};
|
||||
Message *message;
|
||||
Header::Command command;
|
||||
@@ -790,7 +790,7 @@ ThreadError MleRouter::HandleLinkAccept(const Message &aMessage, const Ip6::Mess
|
||||
uint32_t aKeySequence, bool aRequest)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
Neighbor *neighbor = NULL;
|
||||
Mac::ExtAddress macAddr;
|
||||
VersionTlv version;
|
||||
@@ -1226,7 +1226,7 @@ uint8_t MleRouter::GetActiveRouterCount(void) const
|
||||
ThreadError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
Mac::ExtAddress macAddr;
|
||||
SourceAddressTlv sourceAddress;
|
||||
LeaderDataTlv leaderData;
|
||||
@@ -1592,7 +1592,7 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId)
|
||||
ThreadError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
Mac::ExtAddress macAddr;
|
||||
VersionTlv version;
|
||||
ScanMaskTlv scanMask;
|
||||
@@ -1973,7 +1973,7 @@ ThreadError MleRouter::HandleChildIdRequest(const Message &aMessage, const Ip6::
|
||||
uint32_t aKeySequence)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.mLinkInfo);
|
||||
const ThreadMessageInfo *threadMessageInfo = static_cast<const ThreadMessageInfo *>(aMessageInfo.GetLinkInfo());
|
||||
Mac::ExtAddress macAddr;
|
||||
ResponseTlv response;
|
||||
LinkFrameCounterTlv linkFrameCounter;
|
||||
@@ -3098,7 +3098,7 @@ ThreadError MleRouter::CheckReachability(uint16_t aMeshSource, uint16_t aMeshDes
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
memcpy(&destination, GetMeshLocal16(), 14);
|
||||
destination = GetMeshLocal16();
|
||||
destination.mFields.m16[7] = HostSwap16(aMeshSource);
|
||||
mNetif.GetIp6().mIcmp.SendError(destination, Ip6::IcmpHeader::kTypeDstUnreach,
|
||||
Ip6::IcmpHeader::kCodeDstUnreachNoRoute, aIp6Header);
|
||||
@@ -3138,9 +3138,9 @@ ThreadError MleRouter::SendAddressSolicit(ThreadStatusTlv::Status aStatus)
|
||||
statusTlv.SetStatus(aStatus);
|
||||
SuccessOrExit(error = message->Append(&statusTlv, sizeof(statusTlv)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
SuccessOrExit(error = GetLeaderAddress(messageInfo.GetPeerAddr()));
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetSockAddr(GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo,
|
||||
&MleRouter::HandleAddressSolicitResponse, this));
|
||||
@@ -3181,9 +3181,8 @@ ThreadError MleRouter::SendAddressRelease(void)
|
||||
macAddr64Tlv.SetMacAddr(*mMac.GetExtAddress());
|
||||
SuccessOrExit(error = message->Append(&macAddr64Tlv, sizeof(macAddr64Tlv)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
SuccessOrExit(error = GetLeaderAddress(messageInfo.GetPeerAddr()));
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMle("Sent address release");
|
||||
|
||||
@@ -623,10 +623,9 @@ ThreadError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
SuccessOrExit(error = message->Append(&rloc16Tlv, sizeof(rloc16Tlv)));
|
||||
}
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
mMle.GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.mSockAddr = *mMle.GetMeshLocal16();
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetSockAddr(mMle.GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
if (mLocal)
|
||||
|
||||
@@ -88,11 +88,10 @@ ThreadError NetworkDiagnostic::SendDiagnosticGet(const Ip6::Address &aDestinatio
|
||||
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aCount));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aDestination;
|
||||
messageInfo.GetSockAddr() = *mMle.GetMeshLocal16();
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
messageInfo.SetSockAddr(mMle.GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo,
|
||||
&NetworkDiagnostic::HandleDiagnosticGetResponse, this));
|
||||
@@ -147,11 +146,10 @@ ThreadError NetworkDiagnostic::SendDiagnosticReset(const Ip6::Address &aDestinat
|
||||
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aCount));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = aDestination;
|
||||
messageInfo.GetSockAddr() = *mMle.GetMeshLocal16();
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
messageInfo.SetSockAddr(mMle.GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetInterfaceId(mNetif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
@@ -259,7 +257,7 @@ void NetworkDiagnostic::HandleDiagnosticGet(Coap::Header &aHeader, Message &aMes
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message = NULL;
|
||||
Coap::Header header;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Ip6::MessageInfo messageInfo(aMessageInfo);
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestGet, error = kThreadError_Drop);
|
||||
@@ -418,7 +416,6 @@ void NetworkDiagnostic::HandleDiagnosticGet(Coap::Header &aHeader, Message &aMes
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&messageInfo, &aMessageInfo, sizeof(messageInfo));
|
||||
memset(&messageInfo.mSockAddr, 0, sizeof(messageInfo.mSockAddr));
|
||||
otLogInfoNetDiag("Sending diagnostic get acknowledgment");
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, messageInfo));
|
||||
@@ -448,7 +445,7 @@ void NetworkDiagnostic::HandleDiagnosticReset(Coap::Header &aHeader, Message &aM
|
||||
uint16_t numTlvTypes;
|
||||
Message *message = NULL;
|
||||
Coap::Header header;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Ip6::MessageInfo messageInfo(aMessageInfo);
|
||||
otLogInfoNetDiag("Received diagnostic reset request");
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
@@ -480,7 +477,6 @@ void NetworkDiagnostic::HandleDiagnosticReset(Coap::Header &aHeader, Message &aM
|
||||
|
||||
SuccessOrExit(error = message->Append(header.GetBytes(), header.GetLength()));
|
||||
|
||||
memcpy(&messageInfo, &aMessageInfo, sizeof(messageInfo));
|
||||
memset(&messageInfo.mSockAddr, 0, sizeof(messageInfo.mSockAddr));
|
||||
|
||||
SuccessOrExit(error = mCoapServer.SendMessage(*message, messageInfo));
|
||||
|
||||
@@ -193,9 +193,8 @@ ThreadError PanIdQueryServer::SendConflict(void)
|
||||
panId.SetPanId(mPanId);
|
||||
SuccessOrExit(error = message->Append(&panId, sizeof(panId)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr() = mCommissioner;
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.SetPeerAddr(mCommissioner);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent panid conflict");
|
||||
|
||||
Reference in New Issue
Block a user