diff --git a/examples/platforms/cc2538/radio.c b/examples/platforms/cc2538/radio.c index 4d8aef9ff..723a18e80 100644 --- a/examples/platforms/cc2538/radio.c +++ b/examples/platforms/cc2538/radio.c @@ -364,6 +364,12 @@ void readFrame(void) sReceiveFrame.mLength = length; sReceiveFrame.mLqi = crcCorr & CC2538_LQI_BIT_MASK; } + else + { + // resets rxfifo + HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX; + HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX; + } // check for rxfifo overflow if ((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) != 0 && @@ -382,8 +388,7 @@ void cc2538RadioProcess(otInstance *aInstance) readFrame(); if ((sState == kStateReceive && sReceiveFrame.mLength > 0) || - (sState == kStateTransmit && sReceiveFrame.mLength > 0 && - (sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) != IEEE802154_FRAME_TYPE_ACK)) + (sState == kStateTransmit && sReceiveFrame.mLength > IEEE802154_ACK_LENGTH)) { #if OPENTHREAD_ENABLE_DIAG @@ -394,7 +399,14 @@ void cc2538RadioProcess(otInstance *aInstance) else #endif { - otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); + // signal MAC layer for each received frame if promiscous is enabled + // otherwise only signal MAC layer for non-ACK frame + if (((HWREG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) == 0) || + (sReceiveFrame.mLength > IEEE802154_ACK_LENGTH)) + { + + otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError); + } } } diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 5d494f173..89cad3d7a 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -937,6 +937,7 @@ void Mac::SentFrame(ThreadError aError) } mTransmitAttempts = 0; + mCsmaAttempts = 0; if (sendFrame.GetAckRequest()) { diff --git a/src/core/net/ip6_address.cpp b/src/core/net/ip6_address.cpp index 816216c65..402becf6b 100644 --- a/src/core/net/ip6_address.cpp +++ b/src/core/net/ip6_address.cpp @@ -117,6 +117,12 @@ bool Address::IsRoutingLocator(void) const mFields.m16[6] == HostSwap16(0xfe00)); } +bool Address::IsAnycastRoutingLocator(void) const +{ + return (mFields.m16[4] == HostSwap16(0x0000) && mFields.m16[5] == HostSwap16(0x00ff) && + mFields.m16[6] == HostSwap16(0xfe00) && mFields.m8[14] == 0xfc); +} + bool Address::IsSubnetRouterAnycast(void) const { return (mFields.m32[2] == 0 && mFields.m32[3] == 0); @@ -130,7 +136,7 @@ bool Address::IsReservedSubnetAnycast(void) const bool Address::IsIidReserved(void) const { - return IsSubnetRouterAnycast() || IsReservedSubnetAnycast(); + return IsSubnetRouterAnycast() || IsReservedSubnetAnycast() || IsAnycastRoutingLocator(); } diff --git a/src/core/net/ip6_address.hpp b/src/core/net/ip6_address.hpp index 9b7b974b7..0a29603cc 100644 --- a/src/core/net/ip6_address.hpp +++ b/src/core/net/ip6_address.hpp @@ -197,6 +197,15 @@ public: */ bool IsRoutingLocator(void) const; + /** + * This method indicates whether or not the IPv6 address is an Anycast RLOC address. + * + * @retval TRUE If the IPv6 address is an Anycast RLOC address. + * @retval FALSE If the IPv6 address is not an Anycast RLOC address. + * + */ + bool IsAnycastRoutingLocator(void) const; + /** * This method indicates whether or not the IPv6 address is Subnet-Router Anycast (RFC 4291), * diff --git a/src/core/net/ip6_mpl.hpp b/src/core/net/ip6_mpl.hpp index 26646a4c1..5af36ba35 100644 --- a/src/core/net/ip6_mpl.hpp +++ b/src/core/net/ip6_mpl.hpp @@ -396,7 +396,7 @@ public: * @returns The offset from the the transmission time to the end of trickle interval. * */ - uint32_t GetIntervalOffset() const { return mIntervalOffset; } + uint8_t GetIntervalOffset() const { return mIntervalOffset; } /** * This method sets the offset from the transmission time to the end of trickle interval. diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 2cb8ab18c..131a7591e 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -305,7 +305,6 @@ void AddressResolver::SendAddressNotificationResponse(const Coap::Header &aReque SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength())); - memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr)); SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo)); otLogInfoArp("Sent address notification acknowledgment"); @@ -378,7 +377,6 @@ void AddressResolver::SendAddressErrorResponse(const Coap::Header &aRequestHeade SuccessOrExit(error = message->Append(responseHeader.GetBytes(), responseHeader.GetLength())); - memset(&responseInfo.mSockAddr, 0, sizeof(responseInfo.mSockAddr)); SuccessOrExit(error = mCoapServer.SendMessage(*message, responseInfo)); otLogInfoArp("Sent address error notification acknowledgment"); diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index de8560701..9db57f2f2 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -451,35 +451,10 @@ exit: return error; } -void MeshForwarder::MoveToResolving(const Ip6::Address &aDestination) -{ - Message *cur, *next; - Ip6::Address ip6Dst; - - for (cur = mSendQueue.GetHead(); cur; cur = next) - { - next = cur->GetNext(); - - if (cur->GetType() != Message::kTypeIp6) - { - continue; - } - - cur->Read(Ip6::Header::GetDestinationOffset(), sizeof(ip6Dst), &ip6Dst); - - if (memcmp(&ip6Dst, &aDestination, sizeof(ip6Dst)) == 0) - { - mSendQueue.Dequeue(*cur); - mResolvingQueue.Enqueue(*cur); - } - } -} - Message *MeshForwarder::GetDirectTransmission() { Message *curMessage, *nextMessage; ThreadError error = kThreadError_None; - Ip6::Address ip6Dst; for (curMessage = mSendQueue.GetHead(); curMessage; curMessage = nextMessage) { @@ -510,8 +485,8 @@ Message *MeshForwarder::GetDirectTransmission() ExitNow(); case kThreadError_AddressQuery: - curMessage->Read(Ip6::Header::GetDestinationOffset(), sizeof(ip6Dst), &ip6Dst); - MoveToResolving(ip6Dst); + mSendQueue.Dequeue(*curMessage); + mResolvingQueue.Enqueue(*curMessage); continue; case kThreadError_Drop: @@ -1256,8 +1231,6 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, ThreadError aError) mSendBusy = false; VerifyOrExit(mSendMessage != NULL, ;); - mSendMessage->SetOffset(mMessageNextOffset); - aFrame.GetDstAddr(macDest); if ((neighbor = mMle.GetNeighbor(macDest)) != NULL) @@ -1353,6 +1326,7 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, ThreadError aError) mSendQueue.Dequeue(*mSendMessage); mSendMessage->Free(); mSendMessage = NULL; + mMessageNextOffset = 0; } mScheduleTransmissionTask.Post(); diff --git a/src/core/thread/mesh_forwarder.hpp b/src/core/thread/mesh_forwarder.hpp index 9b9aa6d9d..2dde21c2c 100644 --- a/src/core/thread/mesh_forwarder.hpp +++ b/src/core/thread/mesh_forwarder.hpp @@ -221,7 +221,6 @@ private: const Mac::Address &aMacSource, const Mac::Address &aMacDest, const ThreadMessageInfo &aMessageInfo); void HandleDataRequest(const Mac::Address &aMacSource, const ThreadMessageInfo &aMessageInfo); - void MoveToResolving(const Ip6::Address &aDestination); ThreadError SendPoll(Message &aMessage, Mac::Frame &aFrame); ThreadError SendMesh(Message &aMessage, Mac::Frame &aFrame); ThreadError SendFragment(Message &aMessage, Mac::Frame &aFrame);