[mac] inline shorter methods / rename frame preparing methods (#3914)

This commit is contained in:
Abtin Keshavarzian
2019-06-14 09:33:40 -07:00
committed by Jonathan Hui
parent 6f290088f2
commit b4c56c447e
2 changed files with 18 additions and 33 deletions
+6 -27
View File
@@ -345,11 +345,6 @@ exit:
return;
}
void Mac::SetShortAddress(ShortAddress aShortAddress)
{
mSubMac.SetShortAddress(aShortAddress);
}
otError Mac::SetPanChannel(uint8_t aChannel)
{
otError error = OT_ERROR_NONE;
@@ -433,11 +428,6 @@ exit:
return;
}
otError Mac::SetNetworkName(const char *aNetworkName)
{
return SetNetworkName(aNetworkName, OT_NETWORK_NAME_MAX_SIZE + 1);
}
otError Mac::SetNetworkName(const char *aBuffer, uint8_t aLength)
{
otError error = OT_ERROR_NONE;
@@ -717,18 +707,19 @@ void Mac::GenerateNonce(const ExtAddress &aAddress, uint32_t aFrameCounter, uint
aNonce[0] = aSecurityLevel;
}
void Mac::SendBeaconRequest(Frame &aFrame)
void Mac::PrepareBeaconRequest(Frame &aFrame)
{
// initialize MAC header
uint16_t fcf = Frame::kFcfFrameMacCmd | Frame::kFcfDstAddrShort | Frame::kFcfSrcAddrNone;
aFrame.InitMacHeader(fcf, Frame::kSecNone);
aFrame.SetDstPanId(kShortAddrBroadcast);
aFrame.SetDstAddr(kShortAddrBroadcast);
aFrame.SetCommandId(Frame::kMacCmdBeaconRequest);
otLogInfoMac("Sending Beacon Request");
}
void Mac::SendBeacon(Frame &aFrame)
void Mac::PrepareBeacon(Frame &aFrame)
{
uint8_t numUnsecurePorts;
uint8_t beaconLength;
@@ -736,13 +727,11 @@ void Mac::SendBeacon(Frame &aFrame)
Beacon * beacon = NULL;
BeaconPayload *beaconPayload = NULL;
// initialize MAC header
fcf = Frame::kFcfFrameBeacon | Frame::kFcfDstAddrNone | Frame::kFcfSrcAddrExt;
aFrame.InitMacHeader(fcf, Frame::kSecNone);
aFrame.SetSrcPanId(mPanId);
aFrame.SetSrcAddr(GetExtAddress());
// write payload
beacon = reinterpret_cast<Beacon *>(aFrame.GetPayload());
beacon->Init();
beaconLength = sizeof(*beacon);
@@ -919,7 +908,7 @@ void Mac::BeginTransmit(void)
case kOperationActiveScan:
mSubMac.SetPanId(kPanIdBroadcast);
sendFrame.SetChannel(mScanChannel);
SendBeaconRequest(sendFrame);
PrepareBeaconRequest(sendFrame);
sendFrame.SetSequence(0);
sendFrame.SetMaxCsmaBackoffs(kMaxCsmaBackoffsDirect);
sendFrame.SetMaxFrameRetries(kMaxFrameRetriesDirect);
@@ -927,7 +916,7 @@ void Mac::BeginTransmit(void)
case kOperationTransmitBeacon:
sendFrame.SetChannel(mRadioChannel);
SendBeacon(sendFrame);
PrepareBeacon(sendFrame);
sendFrame.SetSequence(mBeaconSequence++);
sendFrame.SetMaxCsmaBackoffs(kMaxCsmaBackoffsDirect);
sendFrame.SetMaxFrameRetries(kMaxFrameRetriesDirect);
@@ -1730,11 +1719,6 @@ exit:
return error;
}
void Mac::SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext)
{
mSubMac.SetPcapCallback(aPcapCallback, aCallbackContext);
}
void Mac::SetPromiscuous(bool aPromiscuous)
{
mPromiscuous = aPromiscuous;
@@ -1749,11 +1733,6 @@ void Mac::SetPromiscuous(bool aPromiscuous)
UpdateIdleMode();
}
void Mac::SetEnabled(bool aEnable)
{
mEnabled = aEnable;
}
void Mac::ResetCounters(void)
{
memset(&mCounters, 0, sizeof(mCounters));
+12 -6
View File
@@ -262,7 +262,7 @@ public:
* @param[in] aShortAddress The IEEE 802.15.4 Short Address.
*
*/
void SetShortAddress(ShortAddress aShortAddress);
void SetShortAddress(ShortAddress aShortAddress) { mSubMac.SetShortAddress(aShortAddress); }
/**
* This method returns the IEEE 802.15.4 PAN Channel.
@@ -358,7 +358,10 @@ public:
* @retval OT_ERROR_INVALID_ARGS Given name is too long.
*
*/
otError SetNetworkName(const char *aNetworkName);
otError SetNetworkName(const char *aNetworkName)
{
return SetNetworkName(aNetworkName, OT_NETWORK_NAME_MAX_SIZE + 1);
}
/**
* This method sets the IEEE 802.15.4 Network Name.
@@ -489,7 +492,10 @@ public:
* @param[in] aCallbackContext A pointer to application-specific context.
*
*/
void SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext);
void SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext)
{
mSubMac.SetPcapCallback(aPcapCallback, aCallbackContext);
}
/**
* This method indicates whether or not promiscuous mode is enabled at the link layer.
@@ -549,7 +555,7 @@ public:
* @param[in] aEnable The requested State for the MAC layer. true - Start, false - Stop.
*
*/
void SetEnabled(bool aEnable);
void SetEnabled(bool aEnable) { mEnabled = aEnable; }
/**
* This method indicates whether or not the link layer is enabled.
@@ -612,8 +618,8 @@ private:
void StartOperation(Operation aOperation);
void FinishOperation(void);
void PerformNextOperation(void);
void SendBeaconRequest(Frame &aFrame);
void SendBeacon(Frame &aFrame);
void PrepareBeaconRequest(Frame &aFrame);
void PrepareBeacon(Frame &aFrame);
bool ShouldSendBeacon(void) const;
void BeginTransmit(void);
otError HandleMacCommand(Frame &aFrame);