mirror of
https://github.com/espressif/openthread.git
synced 2026-10-09 17:27:41 +00:00
Make public headers C99 compliant. (#186)
* Add -std=c99 and -pedantic-errors to CFLAGS.
This commit is contained in:
+3
-3
@@ -223,11 +223,11 @@ AC_PROG_LN_S
|
||||
# -Wall CC, CXX
|
||||
#
|
||||
|
||||
PROSPECTIVE_CFLAGS="-Wall"
|
||||
PROSPECTIVE_CXXFLAGS=""
|
||||
PROSPECTIVE_CFLAGS="-Wall -std=c99 -pedantic-errors"
|
||||
PROSPECTIVE_CXXFLAGS="-Wall"
|
||||
|
||||
AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS})
|
||||
AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CFLAGS} ${PROSPECTIVE_CXXFLAGS})
|
||||
AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS})
|
||||
|
||||
# Check for and initialize libtool
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ extern uint8_t _einit_array;
|
||||
__extension__ typedef int __guard __attribute__((mode(__DI__)));
|
||||
int __cxa_guard_acquire(__guard *g) { return !*(char *)(g); }
|
||||
void __cxa_guard_release(__guard *g) { *(char *)g = 1; }
|
||||
void __cxa_guard_abort(__guard *g) {};
|
||||
void __cxa_guard_abort(__guard *g) {}
|
||||
void __cxa_pure_virtual(void) { while (1); }
|
||||
|
||||
void IntDefaultHandler(void);
|
||||
|
||||
@@ -35,9 +35,9 @@ libopenthread_posix_a_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/examples/posix/platform \
|
||||
-D_GNU_SOURCE \
|
||||
$(NULL)
|
||||
|
||||
|
||||
libopenthread_posix_a_SOURCES = \
|
||||
alarm.c \
|
||||
logging.c \
|
||||
|
||||
@@ -482,7 +482,7 @@ int radioTransmit(void)
|
||||
{
|
||||
struct sockaddr_in sockaddr;
|
||||
int rval = 0;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
sockaddr.sin_family = AF_INET;
|
||||
@@ -564,7 +564,7 @@ void posixPlatformRadioProcess(void)
|
||||
void radioSendAck(void)
|
||||
{
|
||||
struct sockaddr_in sockaddr;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
s_ack_frame.mLength = IEEE802154_ACK_LENGTH;
|
||||
s_ack_message.mPsdu[0] = IEEE802154_FRAME_TYPE_ACK;
|
||||
|
||||
+18
-18
@@ -153,7 +153,7 @@ typedef struct otActiveScanResult
|
||||
uint8_t mChannel; ///< IEEE 802.15.4 Channel
|
||||
int8_t mRssi; ///< RSSI (dBm)
|
||||
uint8_t mLqi; ///< LQI
|
||||
uint8_t mVersion : 4; ///< Version
|
||||
unsigned int mVersion : 4; ///< Version
|
||||
bool mIsNative : 1; ///< Native Commissioner flag
|
||||
bool mIsJoinable : 1; ///< Joining Permitted flag
|
||||
} otActiveScanResult;
|
||||
@@ -188,22 +188,22 @@ typedef struct otLinkModeConfig
|
||||
/**
|
||||
* 1, if the sender has its receiver on when not transmitting. 0, otherwise.
|
||||
*/
|
||||
uint8_t mRxOnWhenIdle : 1;
|
||||
bool mRxOnWhenIdle : 1;
|
||||
|
||||
/**
|
||||
* 1, if the sender will use IEEE 802.15.4 to secure all data requests. 0, otherwise.
|
||||
*/
|
||||
uint8_t mSecureDataRequests : 1;
|
||||
bool mSecureDataRequests : 1;
|
||||
|
||||
/**
|
||||
* 1, if the sender is an FFD. 0, otherwise.
|
||||
*/
|
||||
uint8_t mDeviceType : 1;
|
||||
bool mDeviceType : 1;
|
||||
|
||||
/**
|
||||
* 1, if the sender requires the full Network Data. 0, otherwise.
|
||||
*/
|
||||
uint8_t mNetworkData : 1;
|
||||
bool mNetworkData : 1;
|
||||
} otLinkModeConfig;
|
||||
|
||||
/**
|
||||
@@ -252,10 +252,10 @@ typedef OT_TOOL_PACKED_BEGIN struct otIp6Address
|
||||
{
|
||||
union
|
||||
{
|
||||
uint8_t m8[kIp6AddressSize];
|
||||
uint16_t m16[kIp6AddressSize / sizeof(uint16_t)];
|
||||
uint32_t m32[kIp6AddressSize / sizeof(uint32_t)];
|
||||
};
|
||||
uint8_t m8[kIp6AddressSize]; ///< 8-bit fields
|
||||
uint16_t m16[kIp6AddressSize / sizeof(uint16_t)]; ///< 16-bit fields
|
||||
uint32_t m32[kIp6AddressSize / sizeof(uint32_t)]; ///< 32-bit fields
|
||||
} mFields; ///< IPv6 accessor fields
|
||||
} OT_TOOL_PACKED_END otIp6Address;
|
||||
|
||||
/**
|
||||
@@ -280,37 +280,37 @@ typedef struct otBorderRouterConfig
|
||||
/**
|
||||
* A 2-bit signed integer indicating router preference as defined in RFC 4291.
|
||||
*/
|
||||
int8_t mPreference : 2;
|
||||
int mPreference : 2;
|
||||
|
||||
/**
|
||||
* TRUE, if @p mPrefix is preferred and should e used for address autoconfiguration. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mSlaacPreferred : 1;
|
||||
bool mSlaacPreferred : 1;
|
||||
|
||||
/**
|
||||
* TRUE, if @p mPrefix is valid and should be used for address autoconfiguration. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mSlaacValid : 1;
|
||||
bool mSlaacValid : 1;
|
||||
|
||||
/**
|
||||
* TRUE, if this border router is a DHCPv6 Agent that supplies IPv6 address configuration. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mDhcp : 1;
|
||||
bool mDhcp : 1;
|
||||
|
||||
/**
|
||||
* TRUE, if this border router is a DHCPv6 Agent that supplies other configuration data. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mConfigure : 1;
|
||||
bool mConfigure : 1;
|
||||
|
||||
/**
|
||||
* TRUE, if this border router is a default route for @p mPrefix. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mDefaultRoute : 1;
|
||||
bool mDefaultRoute : 1;
|
||||
|
||||
/**
|
||||
* TRUE, if this configuration is considered Stable Network Data. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mStable : 1;
|
||||
bool mStable : 1;
|
||||
} otBorderRouterConfig;
|
||||
|
||||
/**
|
||||
@@ -326,12 +326,12 @@ typedef struct otExternalRouteConfig
|
||||
/**
|
||||
* A 2-bit signed integer indicating router preference as defined in RFC 4291.
|
||||
*/
|
||||
int8_t mPreference : 2;
|
||||
int mPreference : 2;
|
||||
|
||||
/**
|
||||
* TRUE, if this configuration is considered Stable Network Data. FALSE, otherwise.
|
||||
*/
|
||||
uint8_t mStable : 1;
|
||||
bool mStable : 1;
|
||||
} otExternalRouteConfig;
|
||||
|
||||
/**
|
||||
|
||||
+16
-8
@@ -332,10 +332,14 @@ void Interpreter::ProcessIpAddr(int argc, char *argv[])
|
||||
for (const otNetifAddress *addr = otGetUnicastAddresses(); addr; addr = addr->mNext)
|
||||
{
|
||||
sServer->OutputFormat("%x:%x:%x:%x:%x:%x:%x:%x\r\n",
|
||||
HostSwap16(addr->mAddress.m16[0]), HostSwap16(addr->mAddress.m16[1]),
|
||||
HostSwap16(addr->mAddress.m16[2]), HostSwap16(addr->mAddress.m16[3]),
|
||||
HostSwap16(addr->mAddress.m16[4]), HostSwap16(addr->mAddress.m16[5]),
|
||||
HostSwap16(addr->mAddress.m16[6]), HostSwap16(addr->mAddress.m16[7]));
|
||||
HostSwap16(addr->mAddress.mFields.m16[0]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[1]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[2]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[3]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[4]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[5]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[6]),
|
||||
HostSwap16(addr->mAddress.mFields.m16[7]));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -558,10 +562,14 @@ void Interpreter::HandleEchoResponse(void *aContext, Message &aMessage, const Ip
|
||||
|
||||
sServer->OutputFormat("%d bytes from ", aMessage.GetLength() - aMessage.GetOffset());
|
||||
sServer->OutputFormat("%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().m16[0]), HostSwap16(aMessageInfo.GetPeerAddr().m16[1]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().m16[2]), HostSwap16(aMessageInfo.GetPeerAddr().m16[3]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().m16[4]), HostSwap16(aMessageInfo.GetPeerAddr().m16[5]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().m16[6]), HostSwap16(aMessageInfo.GetPeerAddr().m16[7]));
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[0]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[1]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[2]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[3]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[4]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[5]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[6]),
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7]));
|
||||
sServer->OutputFormat(": icmp_seq=%d hlim=%d\r\n", icmp6Header.GetSequence(), aMessageInfo.mHopLimit);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ uint16_t Ip6::UpdateChecksum(uint16_t checksum, const void *buf, uint16_t len)
|
||||
|
||||
uint16_t Ip6::UpdateChecksum(uint16_t checksum, const Address &address)
|
||||
{
|
||||
return Ip6::UpdateChecksum(checksum, address.m8, sizeof(address));
|
||||
return Ip6::UpdateChecksum(checksum, address.mFields.m8, sizeof(address));
|
||||
}
|
||||
|
||||
uint16_t Ip6::ComputePseudoheaderChecksum(const Address &src, const Address &dst, uint16_t length, IpProto proto)
|
||||
@@ -105,7 +105,7 @@ ThreadError AddMplOption(Message &message, Header &header, IpProto nextHeader, u
|
||||
|
||||
hbhHeader.SetNextHeader(nextHeader);
|
||||
hbhHeader.SetLength(0);
|
||||
sMpl.InitOption(mplOption, HostSwap16(header.GetSource().m16[7]));
|
||||
sMpl.InitOption(mplOption, HostSwap16(header.GetSource().mFields.m16[7]));
|
||||
SuccessOrExit(error = message.Prepend(&mplOption, sizeof(mplOption)));
|
||||
SuccessOrExit(error = message.Prepend(&hbhHeader, sizeof(hbhHeader)));
|
||||
header.SetPayloadLength(sizeof(hbhHeader) + sizeof(mplOption) + payloadLength);
|
||||
|
||||
@@ -47,22 +47,22 @@ namespace Ip6 {
|
||||
|
||||
bool Address::IsUnspecified(void) const
|
||||
{
|
||||
return (m32[0] == 0 && m32[1] == 0 && m32[2] == 0 && m32[3] == 0);
|
||||
return (mFields.m32[0] == 0 && mFields.m32[1] == 0 && mFields.m32[2] == 0 && mFields.m32[3] == 0);
|
||||
}
|
||||
|
||||
bool Address::IsLoopback(void) const
|
||||
{
|
||||
return (m32[0] == 0 && m32[1] == 0 && m32[2] == 0 && m32[3] == HostSwap32(1));
|
||||
return (mFields.m32[0] == 0 && mFields.m32[1] == 0 && mFields.m32[2] == 0 && mFields.m32[3] == HostSwap32(1));
|
||||
}
|
||||
|
||||
bool Address::IsLinkLocal(void) const
|
||||
{
|
||||
return (m8[0] == 0xfe) && ((m8[1] & 0xc0) == 0x80);
|
||||
return (mFields.m8[0] == 0xfe) && ((mFields.m8[1] & 0xc0) == 0x80);
|
||||
}
|
||||
|
||||
bool Address::IsMulticast(void) const
|
||||
{
|
||||
return m8[0] == 0xff;
|
||||
return mFields.m8[0] == 0xff;
|
||||
}
|
||||
|
||||
bool Address::IsLinkLocalMulticast(void) const
|
||||
@@ -72,14 +72,14 @@ bool Address::IsLinkLocalMulticast(void) const
|
||||
|
||||
bool Address::IsLinkLocalAllNodesMulticast(void) const
|
||||
{
|
||||
return (m32[0] == HostSwap32(0xff020000) && m32[1] == 0 &&
|
||||
m32[2] == 0 && m32[3] == HostSwap32(0x01));
|
||||
return (mFields.m32[0] == HostSwap32(0xff020000) && mFields.m32[1] == 0 &&
|
||||
mFields.m32[2] == 0 && mFields.m32[3] == HostSwap32(0x01));
|
||||
}
|
||||
|
||||
bool Address::IsLinkLocalAllRoutersMulticast(void) const
|
||||
{
|
||||
return (m32[0] == HostSwap32(0xff020000) && m32[1] == 0 &&
|
||||
m32[2] == 0 && m32[3] == HostSwap32(0x02));
|
||||
return (mFields.m32[0] == HostSwap32(0xff020000) && mFields.m32[1] == 0 &&
|
||||
mFields.m32[2] == 0 && mFields.m32[3] == HostSwap32(0x02));
|
||||
}
|
||||
|
||||
bool Address::IsRealmLocalMulticast(void) const
|
||||
@@ -89,48 +89,48 @@ bool Address::IsRealmLocalMulticast(void) const
|
||||
|
||||
bool Address::IsRealmLocalAllNodesMulticast(void) const
|
||||
{
|
||||
return (m32[0] == HostSwap32(0xff030000) && m32[1] == 0 &&
|
||||
m32[2] == 0 && m32[3] == HostSwap32(0x01));
|
||||
return (mFields.m32[0] == HostSwap32(0xff030000) && mFields.m32[1] == 0 &&
|
||||
mFields.m32[2] == 0 && mFields.m32[3] == HostSwap32(0x01));
|
||||
}
|
||||
|
||||
bool Address::IsRealmLocalAllRoutersMulticast(void) const
|
||||
{
|
||||
return (m32[0] == HostSwap32(0xff030000) && m32[1] == 0 &&
|
||||
m32[2] == 0 && m32[3] == HostSwap32(0x02));
|
||||
return (mFields.m32[0] == HostSwap32(0xff030000) && mFields.m32[1] == 0 &&
|
||||
mFields.m32[2] == 0 && mFields.m32[3] == HostSwap32(0x02));
|
||||
}
|
||||
|
||||
bool Address::IsRoutingLocator(void) const
|
||||
{
|
||||
return (m16[4] == HostSwap16(0x0000) && m16[5] == HostSwap16(0x00ff) &&
|
||||
m16[6] == HostSwap16(0xfe00));
|
||||
return (mFields.m16[4] == HostSwap16(0x0000) && mFields.m16[5] == HostSwap16(0x00ff) &&
|
||||
mFields.m16[6] == HostSwap16(0xfe00));
|
||||
}
|
||||
|
||||
const uint8_t *Address::GetIid(void) const
|
||||
{
|
||||
return m8 + kInterfaceIdentifierOffset;
|
||||
return mFields.m8 + kInterfaceIdentifierOffset;
|
||||
}
|
||||
|
||||
uint8_t *Address::GetIid(void)
|
||||
{
|
||||
return m8 + kInterfaceIdentifierOffset;
|
||||
return mFields.m8 + kInterfaceIdentifierOffset;
|
||||
}
|
||||
|
||||
void Address::SetIid(const uint8_t *aIid)
|
||||
{
|
||||
memcpy(m8 + kInterfaceIdentifierOffset, aIid, kInterfaceIdentifierSize);
|
||||
memcpy(mFields.m8 + kInterfaceIdentifierOffset, aIid, kInterfaceIdentifierSize);
|
||||
}
|
||||
|
||||
void Address::SetIid(const Mac::ExtAddress &aEui64)
|
||||
{
|
||||
memcpy(m8 + kInterfaceIdentifierOffset, aEui64.m8, kInterfaceIdentifierSize);
|
||||
m8[kInterfaceIdentifierOffset] ^= 0x02;
|
||||
memcpy(mFields.m8 + kInterfaceIdentifierOffset, aEui64.m8, kInterfaceIdentifierSize);
|
||||
mFields.m8[kInterfaceIdentifierOffset] ^= 0x02;
|
||||
}
|
||||
|
||||
uint8_t Address::GetScope(void) const
|
||||
{
|
||||
if (IsMulticast())
|
||||
{
|
||||
return m8[1] & 0xf;
|
||||
return mFields.m8[1] & 0xf;
|
||||
}
|
||||
else if (IsLinkLocal())
|
||||
{
|
||||
@@ -151,7 +151,7 @@ uint8_t Address::PrefixMatch(const Address &aOther) const
|
||||
|
||||
for (uint8_t i = 0; i < sizeof(Address); i++)
|
||||
{
|
||||
diff = m8[i] ^ aOther.m8[i];
|
||||
diff = mFields.m8[i] ^ aOther.mFields.m8[i];
|
||||
|
||||
if (diff == 0)
|
||||
{
|
||||
@@ -174,19 +174,19 @@ uint8_t Address::PrefixMatch(const Address &aOther) const
|
||||
|
||||
bool Address::operator==(const Address &aOther) const
|
||||
{
|
||||
return memcmp(m8, aOther.m8, sizeof(m8)) == 0;
|
||||
return memcmp(mFields.m8, aOther.mFields.m8, sizeof(mFields.m8)) == 0;
|
||||
}
|
||||
|
||||
bool Address::operator!=(const Address &aOther) const
|
||||
{
|
||||
return memcmp(m8, aOther.m8, sizeof(m8)) != 0;
|
||||
return memcmp(mFields.m8, aOther.mFields.m8, sizeof(mFields.m8)) != 0;
|
||||
}
|
||||
|
||||
ThreadError Address::FromString(const char *aBuf)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
uint8_t *dst = reinterpret_cast<uint8_t *>(m8);
|
||||
uint8_t *endp = reinterpret_cast<uint8_t *>(m8 + 15);
|
||||
uint8_t *dst = reinterpret_cast<uint8_t *>(mFields.m8);
|
||||
uint8_t *endp = reinterpret_cast<uint8_t *>(mFields.m8 + 15);
|
||||
uint8_t *colonp = NULL;
|
||||
uint16_t val = 0;
|
||||
uint8_t count = 0;
|
||||
@@ -194,7 +194,7 @@ ThreadError Address::FromString(const char *aBuf)
|
||||
uint8_t ch;
|
||||
uint8_t d;
|
||||
|
||||
memset(m8, 0, 16);
|
||||
memset(mFields.m8, 0, 16);
|
||||
|
||||
dst--;
|
||||
|
||||
@@ -258,10 +258,10 @@ exit:
|
||||
const char *Address::ToString(char *aBuf, uint16_t aSize) const
|
||||
{
|
||||
snprintf(aBuf, aSize, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
HostSwap16(m16[0]), HostSwap16(m16[1]),
|
||||
HostSwap16(m16[2]), HostSwap16(m16[3]),
|
||||
HostSwap16(m16[4]), HostSwap16(m16[5]),
|
||||
HostSwap16(m16[6]), HostSwap16(m16[7]));
|
||||
HostSwap16(mFields.m16[0]), HostSwap16(mFields.m16[1]),
|
||||
HostSwap16(mFields.m16[2]), HostSwap16(mFields.m16[3]),
|
||||
HostSwap16(mFields.m16[4]), HostSwap16(mFields.m16[5]),
|
||||
HostSwap16(mFields.m16[6]), HostSwap16(mFields.m16[7]));
|
||||
return aBuf;
|
||||
}
|
||||
|
||||
|
||||
@@ -299,24 +299,26 @@ ThreadError otAddBorderRouter(const otBorderRouterConfig *aConfig)
|
||||
flags |= NetworkData::BorderRouterEntry::kDefaultRouteFlag;
|
||||
}
|
||||
|
||||
return sThreadNetif->GetNetworkDataLocal().AddOnMeshPrefix(aConfig->mPrefix.mPrefix.m8, aConfig->mPrefix.mLength,
|
||||
return sThreadNetif->GetNetworkDataLocal().AddOnMeshPrefix(aConfig->mPrefix.mPrefix.mFields.m8,
|
||||
aConfig->mPrefix.mLength,
|
||||
aConfig->mPreference, flags, aConfig->mStable);
|
||||
}
|
||||
|
||||
ThreadError otRemoveBorderRouter(const otIp6Prefix *aPrefix)
|
||||
{
|
||||
return sThreadNetif->GetNetworkDataLocal().RemoveOnMeshPrefix(aPrefix->mPrefix.m8, aPrefix->mLength);
|
||||
return sThreadNetif->GetNetworkDataLocal().RemoveOnMeshPrefix(aPrefix->mPrefix.mFields.m8, aPrefix->mLength);
|
||||
}
|
||||
|
||||
ThreadError otAddExternalRoute(const otExternalRouteConfig *aConfig)
|
||||
{
|
||||
return sThreadNetif->GetNetworkDataLocal().AddHasRoutePrefix(aConfig->mPrefix.mPrefix.m8, aConfig->mPrefix.mLength,
|
||||
return sThreadNetif->GetNetworkDataLocal().AddHasRoutePrefix(aConfig->mPrefix.mPrefix.mFields.m8,
|
||||
aConfig->mPrefix.mLength,
|
||||
aConfig->mPreference, aConfig->mStable);
|
||||
}
|
||||
|
||||
ThreadError otRemoveExternalRoute(const otIp6Prefix *aPrefix)
|
||||
{
|
||||
return sThreadNetif->GetNetworkDataLocal().RemoveHasRoutePrefix(aPrefix->mPrefix.m8, aPrefix->mLength);
|
||||
return sThreadNetif->GetNetworkDataLocal().RemoveHasRoutePrefix(aPrefix->mPrefix.mFields.m8, aPrefix->mLength);
|
||||
}
|
||||
|
||||
ThreadError otSendServerData(void)
|
||||
|
||||
@@ -185,8 +185,8 @@ ThreadError AddressResolver::SendAddressQuery(const Ip6::Address &aEid)
|
||||
SuccessOrExit(error = message->Append(&targetTlv, sizeof(targetTlv)));
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
messageInfo.GetPeerAddr().m16[0] = HostSwap16(0xff03);
|
||||
messageInfo.GetPeerAddr().m16[7] = HostSwap16(0x0002);
|
||||
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xff03);
|
||||
messageInfo.GetPeerAddr().mFields.m16[7] = HostSwap16(0x0002);
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
messageInfo.mInterfaceId = mNetif.GetInterfaceId();
|
||||
|
||||
@@ -230,7 +230,7 @@ void AddressResolver::HandleAddressNotification(Coap::Header &aHeader, Message &
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, ;);
|
||||
|
||||
otLogInfoArp("Received address notification from %04x\n", HostSwap16(aMessageInfo.GetPeerAddr().m16[7]));
|
||||
otLogInfoArp("Received address notification from %04x\n", HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7]));
|
||||
|
||||
SuccessOrExit(ThreadTlv::GetTlv(aMessage, ThreadTlv::kTarget, sizeof(targetTlv), targetTlv));
|
||||
VerifyOrExit(targetTlv.IsValid(), ;);
|
||||
@@ -342,8 +342,8 @@ ThreadError AddressResolver::SendAddressError(const ThreadTargetTlv &aTarget, co
|
||||
|
||||
if (aDestination == NULL)
|
||||
{
|
||||
messageInfo.GetPeerAddr().m16[0] = HostSwap16(0xff03);
|
||||
messageInfo.GetPeerAddr().m16[7] = HostSwap16(0x0002);
|
||||
messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xff03);
|
||||
messageInfo.GetPeerAddr().mFields.m16[7] = HostSwap16(0x0002);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -427,7 +427,7 @@ void AddressResolver::HandleAddressError(Coap::Header &aHeader, Message &aMessag
|
||||
memset(&children[i].mIp6Address[j], 0, sizeof(children[i].mIp6Address[j]));
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(children[i].mMacAddr);
|
||||
|
||||
SendAddressError(targetTlv, mlIidTlv, &destination);
|
||||
@@ -459,7 +459,7 @@ void AddressResolver::HandleAddressQuery(Coap::Header &aHeader, Message &aMessag
|
||||
VerifyOrExit(aHeader.GetType() == Coap::Header::kTypeNonConfirmable &&
|
||||
aHeader.GetCode() == Coap::Header::kCodePost, ;);
|
||||
|
||||
otLogInfoArp("Received address query from %04x\n", HostSwap16(aMessageInfo.GetPeerAddr().m16[7]));
|
||||
otLogInfoArp("Received address query from %04x\n", HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7]));
|
||||
|
||||
SuccessOrExit(ThreadTlv::GetTlv(aMessage, ThreadTlv::kTarget, sizeof(targetTlv), targetTlv));
|
||||
VerifyOrExit(targetTlv.IsValid(), ;);
|
||||
|
||||
+44
-44
@@ -56,8 +56,8 @@ ThreadError Lowpan::CopyContext(const Context &aContext, Ip6::Address &aAddress)
|
||||
|
||||
for (int i = (aContext.mPrefixLength & ~7); i < aContext.mPrefixLength; i++)
|
||||
{
|
||||
aAddress.m8[i / CHAR_BIT] &= ~(0x80 >> (i % CHAR_BIT));
|
||||
aAddress.m8[i / CHAR_BIT] |= aContext.mPrefix[i / CHAR_BIT] & (0x80 >> (i % CHAR_BIT));
|
||||
aAddress.mFields.m8[i / CHAR_BIT] &= ~(0x80 >> (i % CHAR_BIT));
|
||||
aAddress.mFields.m8[i / CHAR_BIT] |= aContext.mPrefix[i / CHAR_BIT] & (0x80 >> (i % CHAR_BIT));
|
||||
}
|
||||
|
||||
return kThreadError_None;
|
||||
@@ -68,10 +68,10 @@ ThreadError Lowpan::ComputeIid(const Mac::Address &aMacAddr, const Context &aCon
|
||||
switch (aMacAddr.mLength)
|
||||
{
|
||||
case 2:
|
||||
aIpAddress.m16[4] = HostSwap16(0x0000);
|
||||
aIpAddress.m16[5] = HostSwap16(0x00ff);
|
||||
aIpAddress.m16[6] = HostSwap16(0xfe00);
|
||||
aIpAddress.m16[7] = HostSwap16(aMacAddr.mShortAddress);
|
||||
aIpAddress.mFields.m16[4] = HostSwap16(0x0000);
|
||||
aIpAddress.mFields.m16[5] = HostSwap16(0x00ff);
|
||||
aIpAddress.mFields.m16[6] = HostSwap16(0xfe00);
|
||||
aIpAddress.mFields.m16[7] = HostSwap16(aMacAddr.mShortAddress);
|
||||
break;
|
||||
|
||||
case Ip6::Address::kInterfaceIdentifierSize:
|
||||
@@ -86,8 +86,8 @@ ThreadError Lowpan::ComputeIid(const Mac::Address &aMacAddr, const Context &aCon
|
||||
{
|
||||
for (int i = (aContext.mPrefixLength & ~7); i < aContext.mPrefixLength; i++)
|
||||
{
|
||||
aIpAddress.m8[i / CHAR_BIT] &= ~(0x80 >> (i % CHAR_BIT));
|
||||
aIpAddress.m8[i / CHAR_BIT] |= aContext.mPrefix[i / CHAR_BIT] & (0x80 >> (i % CHAR_BIT));
|
||||
aIpAddress.mFields.m8[i / CHAR_BIT] &= ~(0x80 >> (i % CHAR_BIT));
|
||||
aIpAddress.mFields.m8[i / CHAR_BIT] |= aContext.mPrefix[i / CHAR_BIT] & (0x80 >> (i % CHAR_BIT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,14 +110,14 @@ int Lowpan::CompressSourceIid(const Mac::Address &aMacAddr, const Ip6::Address &
|
||||
else
|
||||
{
|
||||
tmp.mLength = sizeof(tmp.mShortAddress);
|
||||
tmp.mShortAddress = HostSwap16(aIpAddr.m16[7]);
|
||||
tmp.mShortAddress = HostSwap16(aIpAddr.mFields.m16[7]);
|
||||
ComputeIid(tmp, aContext, ipaddr);
|
||||
|
||||
if (memcmp(ipaddr.GetIid(), aIpAddr.GetIid(), Ip6::Address::kInterfaceIdentifierSize) == 0)
|
||||
{
|
||||
aHcCtl |= kHcSrcAddrMode2;
|
||||
cur[0] = aIpAddr.m8[14];
|
||||
cur[1] = aIpAddr.m8[15];
|
||||
cur[0] = aIpAddr.mFields.m8[14];
|
||||
cur[1] = aIpAddr.mFields.m8[15];
|
||||
cur += 2;
|
||||
}
|
||||
else
|
||||
@@ -147,14 +147,14 @@ int Lowpan::CompressDestinationIid(const Mac::Address &aMacAddr, const Ip6::Addr
|
||||
else
|
||||
{
|
||||
tmp.mLength = sizeof(tmp.mShortAddress);
|
||||
tmp.mShortAddress = HostSwap16(aIpAddr.m16[7]);
|
||||
tmp.mShortAddress = HostSwap16(aIpAddr.mFields.m16[7]);
|
||||
ComputeIid(tmp, aContext, ipaddr);
|
||||
|
||||
if (memcmp(ipaddr.GetIid(), aIpAddr.GetIid(), Ip6::Address::kInterfaceIdentifierSize) == 0)
|
||||
{
|
||||
aHcCtl |= kHcDstAddrMode2;
|
||||
cur[0] = aIpAddr.m8[14];
|
||||
cur[1] = aIpAddr.m8[15];
|
||||
cur[0] = aIpAddr.mFields.m8[14];
|
||||
cur[1] = aIpAddr.mFields.m8[15];
|
||||
cur += 2;
|
||||
}
|
||||
else
|
||||
@@ -176,31 +176,31 @@ int Lowpan::CompressMulticast(const Ip6::Address &aIpAddr, uint16_t &aHcCtl, uin
|
||||
|
||||
for (unsigned int i = 2; i < sizeof(Ip6::Address); i++)
|
||||
{
|
||||
if (aIpAddr.m8[i])
|
||||
if (aIpAddr.mFields.m8[i])
|
||||
{
|
||||
if (aIpAddr.m8[1] == 0x02 && i >= 15)
|
||||
if (aIpAddr.mFields.m8[1] == 0x02 && i >= 15)
|
||||
{
|
||||
aHcCtl |= kHcDstAddrMode3;
|
||||
cur[0] = aIpAddr.m8[15];
|
||||
cur[0] = aIpAddr.mFields.m8[15];
|
||||
cur++;
|
||||
}
|
||||
else if (i >= 13)
|
||||
{
|
||||
aHcCtl |= kHcDstAddrMode2;
|
||||
cur[0] = aIpAddr.m8[1];
|
||||
memcpy(cur + 1, aIpAddr.m8 + 13, 3);
|
||||
cur[0] = aIpAddr.mFields.m8[1];
|
||||
memcpy(cur + 1, aIpAddr.mFields.m8 + 13, 3);
|
||||
cur += 4;
|
||||
}
|
||||
else if (i >= 9)
|
||||
{
|
||||
aHcCtl |= kHcDstAddrMode1;
|
||||
cur[0] = aIpAddr.m8[1];
|
||||
memcpy(cur + 1, aIpAddr.m8 + 11, 5);
|
||||
cur[0] = aIpAddr.mFields.m8[1];
|
||||
memcpy(cur + 1, aIpAddr.mFields.m8 + 11, 5);
|
||||
cur += 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(cur, aIpAddr.m8, sizeof(Ip6::Address));
|
||||
memcpy(cur, aIpAddr.mFields.m8, sizeof(Ip6::Address));
|
||||
cur += sizeof(Ip6::Address);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ int Lowpan::Compress(Message &aMessage, const Mac::Address &aMacSource, const Ma
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(cur, ip6Header.GetSource().m8, sizeof(ip6Header.GetSource()));
|
||||
memcpy(cur, ip6Header.GetSource().mFields.m8, sizeof(ip6Header.GetSource()));
|
||||
cur += sizeof(Ip6::Address);
|
||||
}
|
||||
|
||||
@@ -591,9 +591,9 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
|
||||
break;
|
||||
|
||||
case kHcSrcAddrMode2:
|
||||
ip6Header.GetSource().m8[11] = 0xff;
|
||||
ip6Header.GetSource().m8[12] = 0xfe;
|
||||
memcpy(ip6Header.GetSource().m8 + 14, cur, 2);
|
||||
ip6Header.GetSource().mFields.m8[11] = 0xff;
|
||||
ip6Header.GetSource().mFields.m8[12] = 0xfe;
|
||||
memcpy(ip6Header.GetSource().mFields.m8 + 14, cur, 2);
|
||||
cur += 2;
|
||||
break;
|
||||
|
||||
@@ -606,7 +606,7 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
|
||||
{
|
||||
if ((hcCtl & kHcSrcAddrModeMask) != 0)
|
||||
{
|
||||
ip6Header.GetSource().m16[0] = HostSwap16(0xfe80);
|
||||
ip6Header.GetSource().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -632,9 +632,9 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
|
||||
break;
|
||||
|
||||
case kHcDstAddrMode2:
|
||||
ip6Header.GetDestination().m8[11] = 0xff;
|
||||
ip6Header.GetDestination().m8[12] = 0xfe;
|
||||
memcpy(ip6Header.GetDestination().m8 + 14, cur, 2);
|
||||
ip6Header.GetDestination().mFields.m8[11] = 0xff;
|
||||
ip6Header.GetDestination().mFields.m8[12] = 0xfe;
|
||||
memcpy(ip6Header.GetDestination().mFields.m8 + 14, cur, 2);
|
||||
cur += 2;
|
||||
break;
|
||||
|
||||
@@ -647,7 +647,7 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
|
||||
{
|
||||
if ((hcCtl & kHcDstAddrModeMask) != 0)
|
||||
{
|
||||
ip6Header.GetDestination().m16[0] = HostSwap16(0xfe80);
|
||||
ip6Header.GetDestination().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -660,32 +660,32 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
|
||||
{
|
||||
// Multicast Destination Address
|
||||
|
||||
ip6Header.GetDestination().m8[0] = 0xff;
|
||||
ip6Header.GetDestination().mFields.m8[0] = 0xff;
|
||||
|
||||
if ((hcCtl & kHcDstAddrContext) == 0)
|
||||
{
|
||||
switch (hcCtl & kHcDstAddrModeMask)
|
||||
{
|
||||
case kHcDstAddrMode0:
|
||||
memcpy(ip6Header.GetDestination().m8, cur, sizeof(Ip6::Address));
|
||||
memcpy(ip6Header.GetDestination().mFields.m8, cur, sizeof(Ip6::Address));
|
||||
cur += sizeof(Ip6::Address);
|
||||
break;
|
||||
|
||||
case kHcDstAddrMode1:
|
||||
ip6Header.GetDestination().m8[1] = cur[0];
|
||||
memcpy(ip6Header.GetDestination().m8 + 11, cur + 1, 5);
|
||||
ip6Header.GetDestination().mFields.m8[1] = cur[0];
|
||||
memcpy(ip6Header.GetDestination().mFields.m8 + 11, cur + 1, 5);
|
||||
cur += 6;
|
||||
break;
|
||||
|
||||
case kHcDstAddrMode2:
|
||||
ip6Header.GetDestination().m8[1] = cur[0];
|
||||
memcpy(ip6Header.GetDestination().m8 + 13, cur + 1, 3);
|
||||
ip6Header.GetDestination().mFields.m8[1] = cur[0];
|
||||
memcpy(ip6Header.GetDestination().mFields.m8 + 13, cur + 1, 3);
|
||||
cur += 4;
|
||||
break;
|
||||
|
||||
case kHcDstAddrMode3:
|
||||
ip6Header.GetDestination().m8[1] = 0x02;
|
||||
ip6Header.GetDestination().m8[15] = cur[0];
|
||||
ip6Header.GetDestination().mFields.m8[1] = 0x02;
|
||||
ip6Header.GetDestination().mFields.m8[15] = cur[0];
|
||||
cur++;
|
||||
break;
|
||||
}
|
||||
@@ -696,11 +696,11 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
|
||||
{
|
||||
case 0:
|
||||
VerifyOrExit(dstContextValid, error = kThreadError_Parse);
|
||||
ip6Header.GetDestination().m8[1] = cur[0];
|
||||
ip6Header.GetDestination().m8[2] = cur[1];
|
||||
ip6Header.GetDestination().m8[3] = dstContext.mPrefixLength;
|
||||
memcpy(ip6Header.GetDestination().m8 + 4, dstContext.mPrefix, 8);
|
||||
memcpy(ip6Header.GetDestination().m8 + 12, cur + 2, 4);
|
||||
ip6Header.GetDestination().mFields.m8[1] = cur[0];
|
||||
ip6Header.GetDestination().mFields.m8[2] = cur[1];
|
||||
ip6Header.GetDestination().mFields.m8[3] = dstContext.mPrefixLength;
|
||||
memcpy(ip6Header.GetDestination().mFields.m8 + 4, dstContext.mPrefix, 8);
|
||||
memcpy(ip6Header.GetDestination().mFields.m8 + 12, cur + 2, 4);
|
||||
cur += 6;
|
||||
break;
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ ThreadError MeshForwarder::UpdateIp6Route(Message &aMessage)
|
||||
// FFD - peform full routing
|
||||
if (mMle.IsRoutingLocator(ip6Header.GetDestination()))
|
||||
{
|
||||
rloc16 = HostSwap16(ip6Header.GetDestination().m16[7]);
|
||||
rloc16 = HostSwap16(ip6Header.GetDestination().mFields.m16[7]);
|
||||
VerifyOrExit(mMle.GetRouterId(rloc16) < Mle::kMaxRouterId, error = kThreadError_Drop);
|
||||
mMeshDest = rloc16;
|
||||
}
|
||||
@@ -608,21 +608,21 @@ ThreadError MeshForwarder::GetMacDestinationAddress(const Ip6::Address &aIp6Addr
|
||||
aMacAddr.mLength = sizeof(aMacAddr.mShortAddress);
|
||||
aMacAddr.mShortAddress = Mac::kShortAddrBroadcast;
|
||||
}
|
||||
else if (aIp6Addr.m16[0] == HostSwap16(0xfe80) &&
|
||||
aIp6Addr.m16[1] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.m16[2] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.m16[3] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.m16[4] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.m16[5] == HostSwap16(0x00ff) &&
|
||||
aIp6Addr.m16[6] == HostSwap16(0xfe00))
|
||||
else if (aIp6Addr.mFields.m16[0] == HostSwap16(0xfe80) &&
|
||||
aIp6Addr.mFields.m16[1] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.mFields.m16[2] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.mFields.m16[3] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.mFields.m16[4] == HostSwap16(0x0000) &&
|
||||
aIp6Addr.mFields.m16[5] == HostSwap16(0x00ff) &&
|
||||
aIp6Addr.mFields.m16[6] == HostSwap16(0xfe00))
|
||||
{
|
||||
aMacAddr.mLength = sizeof(aMacAddr.mShortAddress);
|
||||
aMacAddr.mShortAddress = HostSwap16(aIp6Addr.m16[7]);
|
||||
aMacAddr.mShortAddress = HostSwap16(aIp6Addr.mFields.m16[7]);
|
||||
}
|
||||
else if (mMle.IsRoutingLocator(aIp6Addr))
|
||||
{
|
||||
aMacAddr.mLength = sizeof(aMacAddr.mShortAddress);
|
||||
aMacAddr.mShortAddress = HostSwap16(aIp6Addr.m16[7]);
|
||||
aMacAddr.mShortAddress = HostSwap16(aIp6Addr.mFields.m16[7]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -991,14 +991,14 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame, ThreadError aError)
|
||||
if (aError == kThreadError_Security)
|
||||
{
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
|
||||
switch (macSource.mLength)
|
||||
{
|
||||
case 2:
|
||||
destination.m16[5] = HostSwap16(0x00ff);
|
||||
destination.m16[6] = HostSwap16(0xfe00);
|
||||
destination.m16[7] = HostSwap16(macSource.mShortAddress);
|
||||
destination.mFields.m16[5] = HostSwap16(0x00ff);
|
||||
destination.mFields.m16[6] = HostSwap16(0xfe00);
|
||||
destination.mFields.m16[7] = HostSwap16(macSource.mShortAddress);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
+38
-38
@@ -82,7 +82,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
|
||||
// link-local 64
|
||||
memset(&mLinkLocal64, 0, sizeof(mLinkLocal64));
|
||||
mLinkLocal64.GetAddress().m16[0] = HostSwap16(0xfe80);
|
||||
mLinkLocal64.GetAddress().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
mLinkLocal64.GetAddress().SetIid(*mMac.GetExtAddress());
|
||||
mLinkLocal64.mPrefixLength = 64;
|
||||
mLinkLocal64.mPreferredLifetime = 0xffffffff;
|
||||
@@ -91,48 +91,48 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
|
||||
// link-local 16
|
||||
memset(&mLinkLocal16, 0, sizeof(mLinkLocal16));
|
||||
mLinkLocal16.GetAddress().m16[0] = HostSwap16(0xfe80);
|
||||
mLinkLocal16.GetAddress().m16[5] = HostSwap16(0x00ff);
|
||||
mLinkLocal16.GetAddress().m16[6] = HostSwap16(0xfe00);
|
||||
mLinkLocal16.GetAddress().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
mLinkLocal16.GetAddress().mFields.m16[5] = HostSwap16(0x00ff);
|
||||
mLinkLocal16.GetAddress().mFields.m16[6] = HostSwap16(0xfe00);
|
||||
mLinkLocal16.mPrefixLength = 64;
|
||||
mLinkLocal16.mPreferredLifetime = 0xffffffff;
|
||||
mLinkLocal16.mValidLifetime = 0xffffffff;
|
||||
|
||||
// initialize Mesh Local Prefix
|
||||
mMeshLocal64.GetAddress().m8[0] = 0xfd;
|
||||
memcpy(mMeshLocal64.GetAddress().m8 + 1, mMac.GetExtendedPanId(), 5);
|
||||
mMeshLocal64.GetAddress().m8[6] = 0x00;
|
||||
mMeshLocal64.GetAddress().m8[7] = 0x00;
|
||||
mMeshLocal64.GetAddress().mFields.m8[0] = 0xfd;
|
||||
memcpy(mMeshLocal64.GetAddress().mFields.m8 + 1, mMac.GetExtendedPanId(), 5);
|
||||
mMeshLocal64.GetAddress().mFields.m8[6] = 0x00;
|
||||
mMeshLocal64.GetAddress().mFields.m8[7] = 0x00;
|
||||
|
||||
// mesh-local 64
|
||||
for (int i = 8; i < 16; i++)
|
||||
{
|
||||
mMeshLocal64.GetAddress().m8[i] = otPlatRandomGet();
|
||||
mMeshLocal64.GetAddress().mFields.m8[i] = otPlatRandomGet();
|
||||
}
|
||||
|
||||
mMeshLocal64.mPrefixLength = 64;
|
||||
mMeshLocal64.mPreferredLifetime = 0xffffffff;
|
||||
mMeshLocal64.mValidLifetime = 0xffffffff;
|
||||
SetMeshLocalPrefix(mMeshLocal64.GetAddress().m8); // Also calls AddUnicastAddress
|
||||
SetMeshLocalPrefix(mMeshLocal64.GetAddress().mFields.m8); // Also calls AddUnicastAddress
|
||||
|
||||
// mesh-local 16
|
||||
mMeshLocal16.GetAddress().m16[4] = HostSwap16(0x0000);
|
||||
mMeshLocal16.GetAddress().m16[5] = HostSwap16(0x00ff);
|
||||
mMeshLocal16.GetAddress().m16[6] = HostSwap16(0xfe00);
|
||||
mMeshLocal16.GetAddress().mFields.m16[4] = HostSwap16(0x0000);
|
||||
mMeshLocal16.GetAddress().mFields.m16[5] = HostSwap16(0x00ff);
|
||||
mMeshLocal16.GetAddress().mFields.m16[6] = HostSwap16(0xfe00);
|
||||
mMeshLocal16.mPrefixLength = 64;
|
||||
mMeshLocal16.mPreferredLifetime = 0xffffffff;
|
||||
mMeshLocal16.mValidLifetime = 0xffffffff;
|
||||
|
||||
// link-local all thread nodes
|
||||
mLinkLocalAllThreadNodes.GetAddress().m16[0] = HostSwap16(0xff32);
|
||||
mLinkLocalAllThreadNodes.GetAddress().m16[6] = HostSwap16(0x0000);
|
||||
mLinkLocalAllThreadNodes.GetAddress().m16[7] = HostSwap16(0x0001);
|
||||
mLinkLocalAllThreadNodes.GetAddress().mFields.m16[0] = HostSwap16(0xff32);
|
||||
mLinkLocalAllThreadNodes.GetAddress().mFields.m16[6] = HostSwap16(0x0000);
|
||||
mLinkLocalAllThreadNodes.GetAddress().mFields.m16[7] = HostSwap16(0x0001);
|
||||
mNetif.SubscribeMulticast(mLinkLocalAllThreadNodes);
|
||||
|
||||
// realm-local all thread nodes
|
||||
mRealmLocalAllThreadNodes.GetAddress().m16[0] = HostSwap16(0xff33);
|
||||
mRealmLocalAllThreadNodes.GetAddress().m16[6] = HostSwap16(0x0000);
|
||||
mRealmLocalAllThreadNodes.GetAddress().m16[7] = HostSwap16(0x0001);
|
||||
mRealmLocalAllThreadNodes.GetAddress().mFields.m16[0] = HostSwap16(0xff33);
|
||||
mRealmLocalAllThreadNodes.GetAddress().mFields.m16[6] = HostSwap16(0x0000);
|
||||
mRealmLocalAllThreadNodes.GetAddress().mFields.m16[7] = HostSwap16(0x0001);
|
||||
mNetif.SubscribeMulticast(mRealmLocalAllThreadNodes);
|
||||
|
||||
mNetifCallback.Set(&HandleNetifStateChanged, this);
|
||||
@@ -345,7 +345,7 @@ exit:
|
||||
|
||||
const uint8_t *Mle::GetMeshLocalPrefix(void) const
|
||||
{
|
||||
return mMeshLocal16.GetAddress().m8;
|
||||
return mMeshLocal16.GetAddress().mFields.m8;
|
||||
}
|
||||
|
||||
ThreadError Mle::SetMeshLocalPrefix(const uint8_t *aMeshLocalPrefix)
|
||||
@@ -354,14 +354,14 @@ ThreadError Mle::SetMeshLocalPrefix(const uint8_t *aMeshLocalPrefix)
|
||||
mNetif.RemoveUnicastAddress(mMeshLocal64);
|
||||
mNetif.RemoveUnicastAddress(mMeshLocal16);
|
||||
|
||||
memcpy(mMeshLocal64.GetAddress().m8, aMeshLocalPrefix, 8);
|
||||
memcpy(mMeshLocal16.GetAddress().m8, mMeshLocal64.GetAddress().m8, 8);
|
||||
memcpy(mMeshLocal64.GetAddress().mFields.m8, aMeshLocalPrefix, 8);
|
||||
memcpy(mMeshLocal16.GetAddress().mFields.m8, mMeshLocal64.GetAddress().mFields.m8, 8);
|
||||
|
||||
mLinkLocalAllThreadNodes.GetAddress().m8[3] = 64;
|
||||
memcpy(mLinkLocalAllThreadNodes.GetAddress().m8 + 4, mMeshLocal64.GetAddress().m8, 8);
|
||||
mLinkLocalAllThreadNodes.GetAddress().mFields.m8[3] = 64;
|
||||
memcpy(mLinkLocalAllThreadNodes.GetAddress().mFields.m8 + 4, mMeshLocal64.GetAddress().mFields.m8, 8);
|
||||
|
||||
mRealmLocalAllThreadNodes.GetAddress().m8[3] = 64;
|
||||
memcpy(mRealmLocalAllThreadNodes.GetAddress().m8 + 4, mMeshLocal64.GetAddress().m8, 8);
|
||||
mRealmLocalAllThreadNodes.GetAddress().mFields.m8[3] = 64;
|
||||
memcpy(mRealmLocalAllThreadNodes.GetAddress().mFields.m8 + 4, mMeshLocal64.GetAddress().mFields.m8, 8);
|
||||
|
||||
// Add the address back into the table.
|
||||
mNetif.AddUnicastAddress(mMeshLocal64);
|
||||
@@ -410,11 +410,11 @@ ThreadError Mle::SetRloc16(uint16_t aRloc16)
|
||||
if (aRloc16 != Mac::kShortAddrInvalid)
|
||||
{
|
||||
// link-local 16
|
||||
mLinkLocal16.GetAddress().m16[7] = HostSwap16(aRloc16);
|
||||
mLinkLocal16.GetAddress().mFields.m16[7] = HostSwap16(aRloc16);
|
||||
mNetif.AddUnicastAddress(mLinkLocal16);
|
||||
|
||||
// mesh-local 16
|
||||
mMeshLocal16.GetAddress().m16[7] = HostSwap16(aRloc16);
|
||||
mMeshLocal16.GetAddress().mFields.m16[7] = HostSwap16(aRloc16);
|
||||
mNetif.AddUnicastAddress(mMeshLocal16);
|
||||
}
|
||||
|
||||
@@ -457,10 +457,10 @@ ThreadError Mle::GetLeaderAddress(Ip6::Address &aAddress) const
|
||||
VerifyOrExit(GetRloc16() != Mac::kShortAddrInvalid, error = kThreadError_Detached);
|
||||
|
||||
memcpy(&aAddress, &mMeshLocal16.GetAddress(), 8);
|
||||
aAddress.m16[4] = HostSwap16(0x0000);
|
||||
aAddress.m16[5] = HostSwap16(0x00ff);
|
||||
aAddress.m16[6] = HostSwap16(0xfe00);
|
||||
aAddress.m16[7] = HostSwap16(GetRloc16(mLeaderData.GetLeaderRouterId()));
|
||||
aAddress.mFields.m16[4] = HostSwap16(0x0000);
|
||||
aAddress.mFields.m16[5] = HostSwap16(0x00ff);
|
||||
aAddress.mFields.m16[6] = HostSwap16(0xfe00);
|
||||
aAddress.mFields.m16[7] = HostSwap16(GetRloc16(mLeaderData.GetLeaderRouterId()));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -747,7 +747,7 @@ void Mle::HandleNetifStateChanged(uint32_t aFlags)
|
||||
// Mesh Local EID was removed, choose a new one and add it back
|
||||
for (int i = 8; i < 16; i++)
|
||||
{
|
||||
mMeshLocal64.GetAddress().m8[i] = otPlatRandomGet();
|
||||
mMeshLocal64.GetAddress().mFields.m8[i] = otPlatRandomGet();
|
||||
}
|
||||
|
||||
mNetif.AddUnicastAddress(mMeshLocal64);
|
||||
@@ -916,8 +916,8 @@ ThreadError Mle::SendParentRequest(void)
|
||||
SuccessOrExit(error = AppendVersion(*message));
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xff02);
|
||||
destination.m16[7] = HostSwap16(0x0002);
|
||||
destination.mFields.m16[0] = HostSwap16(0xff02);
|
||||
destination.mFields.m16[7] = HostSwap16(0x0002);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
|
||||
switch (mParentRequestState)
|
||||
@@ -970,7 +970,7 @@ ThreadError Mle::SendChildIdRequest(void)
|
||||
SuccessOrExit(error = AppendTlvRequest(*message, tlvs, sizeof(tlvs)));
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(mParent.mMacAddr);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
otLogInfoMle("Sent Child ID Request\n");
|
||||
@@ -1099,7 +1099,7 @@ ThreadError Mle::SendChildUpdateRequest(void)
|
||||
}
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(mParent.mMacAddr);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
|
||||
@@ -1945,7 +1945,7 @@ ThreadError Mle::CheckReachability(uint16_t aMeshSource, uint16_t aMeshDest, Ip6
|
||||
}
|
||||
|
||||
memcpy(&dst, GetMeshLocal16(), kRlocPrefixLength);
|
||||
dst.m16[7] = HostSwap16(aMeshSource);
|
||||
dst.mFields.m16[7] = HostSwap16(aMeshSource);
|
||||
Ip6::Icmp::SendError(dst, Ip6::IcmpHeader::kTypeDstUnreach, Ip6::IcmpHeader::kCodeDstUnreachNoRoute, aIp6Header);
|
||||
|
||||
exit:
|
||||
|
||||
@@ -467,8 +467,8 @@ ThreadError MleRouter::SendAdvertisement(void)
|
||||
}
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xff02);
|
||||
destination.m16[7] = HostSwap16(0x0001);
|
||||
destination.mFields.m16[0] = HostSwap16(0xff02);
|
||||
destination.mFields.m16[7] = HostSwap16(0x0001);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
|
||||
otLogInfoMle("Sent advertisement\n");
|
||||
@@ -528,9 +528,9 @@ ThreadError MleRouter::SendLinkRequest(Neighbor *aNeighbor)
|
||||
}
|
||||
|
||||
SuccessOrExit(error = AppendChallenge(*message, mChallenge, sizeof(mChallenge)));
|
||||
destination.m8[0] = 0xff;
|
||||
destination.m8[1] = 0x02;
|
||||
destination.m8[15] = 2;
|
||||
destination.mFields.m8[0] = 0xff;
|
||||
destination.mFields.m8[1] = 0x02;
|
||||
destination.mFields.m8[15] = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,7 +540,7 @@ ThreadError MleRouter::SendLinkRequest(Neighbor *aNeighbor)
|
||||
}
|
||||
|
||||
SuccessOrExit(error = AppendChallenge(*message, mChallenge, sizeof(mChallenge)));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(aNeighbor->mMacAddr);
|
||||
}
|
||||
|
||||
@@ -1539,7 +1539,7 @@ ThreadError MleRouter::SendParentResponse(Child *aChild, const ChallengeTlv &cha
|
||||
SuccessOrExit(error = AppendVersion(*message));
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(aChild->mMacAddr);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
|
||||
@@ -1802,8 +1802,8 @@ ThreadError MleRouter::HandleNetworkDataUpdateRouter(void)
|
||||
VerifyOrExit(mDeviceState == kDeviceStateRouter || mDeviceState == kDeviceStateLeader, ;);
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xff02);
|
||||
destination.m16[7] = HostSwap16(0x0001);
|
||||
destination.mFields.m16[0] = HostSwap16(0xff02);
|
||||
destination.mFields.m16[7] = HostSwap16(0x0001);
|
||||
|
||||
SendDataResponse(destination, tlvs, sizeof(tlvs));
|
||||
|
||||
@@ -1857,7 +1857,7 @@ ThreadError MleRouter::SendChildIdResponse(Child *aChild)
|
||||
mNetif.SetStateChangedFlags(OT_THREAD_CHILD_ADDED);
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(aChild->mMacAddr);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
|
||||
@@ -2084,12 +2084,12 @@ Neighbor *MleRouter::GetNeighbor(const Ip6::Address &aAddress)
|
||||
|
||||
if (aAddress.IsLinkLocal())
|
||||
{
|
||||
if (aAddress.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.m16[6] == HostSwap16(0xfe00))
|
||||
if (aAddress.mFields.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.mFields.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.mFields.m16[6] == HostSwap16(0xfe00))
|
||||
{
|
||||
macaddr.mLength = sizeof(macaddr.mShortAddress);
|
||||
macaddr.mShortAddress = HostSwap16(aAddress.m16[7]);
|
||||
macaddr.mShortAddress = HostSwap16(aAddress.mFields.m16[7]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2115,17 +2115,17 @@ Neighbor *MleRouter::GetNeighbor(const Ip6::Address &aAddress)
|
||||
}
|
||||
|
||||
if (context.mContextId == 0 &&
|
||||
aAddress.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.m16[6] == HostSwap16(0xfe00) &&
|
||||
aAddress.m16[7] == HostSwap16(child->mValid.mRloc16))
|
||||
aAddress.mFields.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.mFields.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.mFields.m16[6] == HostSwap16(0xfe00) &&
|
||||
aAddress.mFields.m16[7] == HostSwap16(child->mValid.mRloc16))
|
||||
{
|
||||
ExitNow(rval = child);
|
||||
}
|
||||
|
||||
for (int j = 0; j < Child::kMaxIp6AddressPerChild; j++)
|
||||
{
|
||||
if (memcmp(&child->mIp6Address[j], aAddress.m8, sizeof(child->mIp6Address[j])) == 0)
|
||||
if (memcmp(&child->mIp6Address[j], aAddress.mFields.m8, sizeof(child->mIp6Address[j])) == 0)
|
||||
{
|
||||
ExitNow(rval = child);
|
||||
}
|
||||
@@ -2143,10 +2143,10 @@ Neighbor *MleRouter::GetNeighbor(const Ip6::Address &aAddress)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aAddress.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.m16[6] == HostSwap16(0xfe00) &&
|
||||
aAddress.m16[7] == HostSwap16(router->mValid.mRloc16))
|
||||
if (aAddress.mFields.m16[4] == HostSwap16(0x0000) &&
|
||||
aAddress.mFields.m16[5] == HostSwap16(0x00ff) &&
|
||||
aAddress.mFields.m16[6] == HostSwap16(0xfe00) &&
|
||||
aAddress.mFields.m16[7] == HostSwap16(router->mValid.mRloc16))
|
||||
{
|
||||
ExitNow(rval = router);
|
||||
}
|
||||
@@ -2216,7 +2216,7 @@ void MleRouter::HandleMacDataRequest(const Child &aChild)
|
||||
VerifyOrExit(aChild.mState == Neighbor::kStateValid && (aChild.mMode & ModeTlv::kModeRxOnWhenIdle) == 0, ;);
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.m16[0] = HostSwap16(0xfe80);
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
destination.SetIid(aChild.mMacAddr);
|
||||
|
||||
if (aChild.mMode & ModeTlv::kModeFullNetworkData)
|
||||
@@ -2286,7 +2286,7 @@ ThreadError MleRouter::CheckReachability(uint16_t aMeshSource, uint16_t aMeshDes
|
||||
}
|
||||
|
||||
memcpy(&destination, GetMeshLocal16(), 14);
|
||||
destination.m16[7] = HostSwap16(aMeshSource);
|
||||
destination.mFields.m16[7] = HostSwap16(aMeshSource);
|
||||
Ip6::Icmp::SendError(destination, Ip6::IcmpHeader::kTypeDstUnreach, Ip6::IcmpHeader::kCodeDstUnreachNoRoute,
|
||||
aIp6Header);
|
||||
|
||||
@@ -2336,7 +2336,7 @@ ThreadError MleRouter::SendAddressSolicit(void)
|
||||
messageInfo.mPeerPort = kCoapUdpPort;
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
otLogInfoMle("Sent address solicit to %04x\n", HostSwap16(messageInfo.GetPeerAddr().m16[7]));
|
||||
otLogInfoMle("Sent address solicit to %04x\n", HostSwap16(messageInfo.GetPeerAddr().mFields.m16[7]));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -109,7 +109,7 @@ ThreadError Leader::GetContext(const Ip6::Address &aAddress, Lowpan::Context &aC
|
||||
|
||||
aContext.mPrefixLength = 0;
|
||||
|
||||
if (PrefixMatch(mMle.GetMeshLocalPrefix(), aAddress.m8, 64) >= 0)
|
||||
if (PrefixMatch(mMle.GetMeshLocalPrefix(), aAddress.mFields.m8, 64) >= 0)
|
||||
{
|
||||
aContext.mPrefix = mMle.GetMeshLocalPrefix();
|
||||
aContext.mPrefixLength = 64;
|
||||
@@ -127,7 +127,7 @@ ThreadError Leader::GetContext(const Ip6::Address &aAddress, Lowpan::Context &aC
|
||||
|
||||
prefix = reinterpret_cast<PrefixTlv *>(cur);
|
||||
|
||||
if (PrefixMatch(prefix->GetPrefix(), aAddress.m8, prefix->GetPrefixLength()) < 0)
|
||||
if (PrefixMatch(prefix->GetPrefix(), aAddress.mFields.m8, prefix->GetPrefixLength()) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ ThreadError Leader::ConfigureAddress(PrefixTlv &aPrefix)
|
||||
{
|
||||
if (mAddresses[i].mValidLifetime != 0 &&
|
||||
mAddresses[i].mPrefixLength == aPrefix.GetPrefixLength() &&
|
||||
PrefixMatch(mAddresses[i].mAddress.m8, aPrefix.GetPrefix(), aPrefix.GetPrefixLength()) >= 0)
|
||||
PrefixMatch(mAddresses[i].mAddress.mFields.m8, aPrefix.GetPrefix(), aPrefix.GetPrefixLength()) >= 0)
|
||||
{
|
||||
mAddresses[i].mPreferredLifetime = entry->IsPreferred() ? 0xffffffff : 0;
|
||||
ExitNow();
|
||||
@@ -269,11 +269,11 @@ ThreadError Leader::ConfigureAddress(PrefixTlv &aPrefix)
|
||||
}
|
||||
|
||||
memset(&mAddresses[i], 0, sizeof(mAddresses[i]));
|
||||
memcpy(mAddresses[i].mAddress.m8, aPrefix.GetPrefix(), BitVectorBytes(aPrefix.GetPrefixLength()));
|
||||
memcpy(mAddresses[i].mAddress.mFields.m8, aPrefix.GetPrefix(), BitVectorBytes(aPrefix.GetPrefixLength()));
|
||||
|
||||
for (size_t j = 8; j < sizeof(mAddresses[i].mAddress); j++)
|
||||
{
|
||||
mAddresses[i].mAddress.m8[j] = otPlatRandomGet();
|
||||
mAddresses[i].mAddress.mFields.m8[j] = otPlatRandomGet();
|
||||
}
|
||||
|
||||
mAddresses[i].mPrefixLength = aPrefix.GetPrefixLength();
|
||||
@@ -292,7 +292,7 @@ bool Leader::IsOnMesh(const Ip6::Address &aAddress)
|
||||
PrefixTlv *prefix;
|
||||
bool rval = false;
|
||||
|
||||
if (memcmp(aAddress.m8, mMle.GetMeshLocalPrefix(), 8) == 0)
|
||||
if (memcmp(aAddress.mFields.m8, mMle.GetMeshLocalPrefix(), 8) == 0)
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ bool Leader::IsOnMesh(const Ip6::Address &aAddress)
|
||||
|
||||
prefix = reinterpret_cast<PrefixTlv *>(cur);
|
||||
|
||||
if (PrefixMatch(prefix->GetPrefix(), aAddress.m8, prefix->GetPrefixLength()) < 0)
|
||||
if (PrefixMatch(prefix->GetPrefix(), aAddress.mFields.m8, prefix->GetPrefixLength()) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ ThreadError Leader::RouteLookup(const Ip6::Address &aSource, const Ip6::Address
|
||||
|
||||
prefix = reinterpret_cast<PrefixTlv *>(cur);
|
||||
|
||||
if (PrefixMatch(prefix->GetPrefix(), aSource.m8, prefix->GetPrefixLength()) >= 0)
|
||||
if (PrefixMatch(prefix->GetPrefix(), aSource.mFields.m8, prefix->GetPrefixLength()) >= 0)
|
||||
{
|
||||
if (ExternalRouteLookup(prefix->GetDomainId(), aDestination, aPrefixMatch, aRloc16) == kThreadError_None)
|
||||
{
|
||||
@@ -393,7 +393,7 @@ ThreadError Leader::ExternalRouteLookup(uint8_t aDomainId, const Ip6::Address &a
|
||||
continue;
|
||||
}
|
||||
|
||||
plen = PrefixMatch(prefix->GetPrefix(), aDestination.m8, prefix->GetPrefixLength());
|
||||
plen = PrefixMatch(prefix->GetPrefix(), aDestination.mFields.m8, prefix->GetPrefixLength());
|
||||
|
||||
if (plen > rval_plen)
|
||||
{
|
||||
@@ -555,7 +555,7 @@ void Leader::HandleServerData(Coap::Header &aHeader, Message &aMessage,
|
||||
tlvsLength = aMessage.GetLength() - aMessage.GetOffset();
|
||||
|
||||
aMessage.Read(aMessage.GetOffset(), tlvsLength, tlvs);
|
||||
rloc16 = HostSwap16(aMessageInfo.mPeerAddr.m16[7]);
|
||||
rloc16 = HostSwap16(aMessageInfo.mPeerAddr.mFields.m16[7]);
|
||||
|
||||
SendServerDataResponse(aHeader, aMessageInfo, tlvs, tlvsLength);
|
||||
RegisterNetworkData(rloc16, tlvs, tlvsLength);
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ libopenthread_ncp_a_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/third_party \
|
||||
-D_GNU_SOURCE \
|
||||
$(OPENTHREAD_TARGET_DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
@@ -71,7 +72,7 @@ if OPENTHREAD_BUILD_TESTS
|
||||
|
||||
noinst_PROGRAMS = spinel-test
|
||||
spinel_test_SOURCES = spinel.c
|
||||
spinel_test_CFLAGS = -DSPINEL_SELF_TEST=1
|
||||
spinel_test_CFLAGS = -DSPINEL_SELF_TEST=1 -D_GNU_SOURCE
|
||||
|
||||
TESTS = spinel-test
|
||||
|
||||
|
||||
@@ -1501,10 +1501,10 @@ void NcpBase::GetPropertyHandler_IPV6_ML_PREFIX(uint8_t header, spinel_prop_key_
|
||||
{
|
||||
otIp6Address addr;
|
||||
|
||||
memcpy(addr.m8, ml_prefix, 8);
|
||||
memcpy(addr.mFields.m8, ml_prefix, 8);
|
||||
|
||||
// Zero out the last 8 bytes.
|
||||
memset(addr.m8 + 8, 0, 8);
|
||||
memset(addr.mFields.m8 + 8, 0, 8);
|
||||
|
||||
SendPropteryUpdate(
|
||||
header,
|
||||
|
||||
+1
-1
@@ -346,7 +346,7 @@ spinel_datatype_vunpack(const uint8_t *data_ptr, spinel_size_t data_len, const c
|
||||
|
||||
case SPINEL_DATATYPE_UINT_PACKED_C:
|
||||
{
|
||||
uint32_t *arg_ptr = va_arg(args, uint32_t *);
|
||||
unsigned int *arg_ptr = va_arg(args, unsigned int *);
|
||||
spinel_ssize_t pui_len = spinel_packed_uint_decode(data_ptr, data_len, arg_ptr);
|
||||
|
||||
require(pui_len > 0, bail);
|
||||
|
||||
Reference in New Issue
Block a user