Restrict the non joinable beacons (#1783)

Respond to the beacon requests with the beacon only if they are joinable
to reduce the traffic.
This commit is contained in:
dgowri
2017-06-15 13:05:48 -07:00
committed by Jonathan Hui
parent 8b4d468c3c
commit 9a37984715
3 changed files with 47 additions and 2 deletions
+26 -2
View File
@@ -633,7 +633,6 @@ void Mac::SendBeaconRequest(Frame &aFrame)
aFrame.SetDstPanId(kShortAddrBroadcast);
aFrame.SetDstAddr(kShortAddrBroadcast);
aFrame.SetCommandId(Frame::kMacCmdBeaconRequest);
otLogInfoMac(GetInstance(), "Sending Beacon Request");
}
@@ -1681,7 +1680,11 @@ otError Mac::HandleMacCommand(Frame &aFrame)
mCounters.mRxBeaconRequest++;
otLogInfoMac(GetInstance(), "Received Beacon Request");
if (mBeaconsEnabled)
if ((mBeaconsEnabled)
#if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
&& (IsBeaconJoinable())
#endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
)
{
mTransmitBeacon = true;
@@ -1762,5 +1765,26 @@ void Mac::ResetCounters(void)
memset(&mCounters, 0, sizeof(mCounters));
}
#if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
bool Mac::IsBeaconJoinable(void)
{
uint8_t numUnsecurePorts;
bool joinable = false;
mNetif.GetIp6Filter().GetUnsecurePorts(numUnsecurePorts);
if (numUnsecurePorts)
{
joinable = true;
}
else
{
joinable = false;
}
return joinable;
}
#endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
} // namespace Mac
} // namespace ot
+11
View File
@@ -608,6 +608,17 @@ public:
*/
void ResetCounters(void);
#if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
/**
* This method indicates if the beacon is joinable or non-joinable
*
* @retval true Beacon is joinable.
* @retval false Beacon is non-joinable.
*
*/
bool IsBeaconJoinable(void);
#endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
/**
* This method returns the MAC counter.
*
+10
View File
@@ -738,6 +738,16 @@
#define OPENTHREAD_CONFIG_ENABLE_AUTO_START_SUPPORT 1
#endif
/**
* @def OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
*
* Define to 1 if you want to enable beacon response for joinable networks.
*
*/
#ifndef OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
#define OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE
*