diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 1465811c8..1b0fd7567 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -437,16 +437,12 @@ public: bool IsInTransmitState(void) const; /** - * Registers a callback to provide received raw IEEE 802.15.4 frames. + * Registers a callback to provide received packet capture for IEEE 802.15.4 frames. * - * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame - * or `nullptr` to disable the callback. - * @param[in] aCallbackContext A pointer to application-specific context. + * @param[in] aCallback The packet capture callback, or `nullptr` to disable packet capture. + * @param[in] aContext A pointer to application-specific context. */ - void SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext) - { - mLinks.SetPcapCallback(aPcapCallback, aCallbackContext); - } + void SetPcapCallback(PcapCallback aCallback, void *aContext) { mLinks.SetPcapCallback(aCallback, aContext); } /** * Indicates whether or not promiscuous mode is enabled at the link layer. diff --git a/src/core/mac/mac_links.hpp b/src/core/mac/mac_links.hpp index 4120e02b3..2df16565c 100644 --- a/src/core/mac/mac_links.hpp +++ b/src/core/mac/mac_links.hpp @@ -395,17 +395,16 @@ public: /** * Registers a callback to provide received packet capture for IEEE 802.15.4 frames. * - * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame - * or nullptr to disable the callback. - * @param[in] aCallbackContext A pointer to application-specific context. + * @param[in] aCallback The packet capture callback, or `nullptr` to disable packet capture. + * @param[in] aContext A pointer to application-specific context. */ - void SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext) + void SetPcapCallback(PcapCallback aCallback, void *aContext) { #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE - mSubMac.SetPcapCallback(aPcapCallback, aCallbackContext); + mSubMac.SetPcapCallback(aCallback, aContext); #endif - OT_UNUSED_VARIABLE(aPcapCallback); - OT_UNUSED_VARIABLE(aCallbackContext); + OT_UNUSED_VARIABLE(aCallback); + OT_UNUSED_VARIABLE(aContext); } /** diff --git a/src/core/mac/mac_types.hpp b/src/core/mac/mac_types.hpp index 3fd7b97b0..85fd09b11 100644 --- a/src/core/mac/mac_types.hpp +++ b/src/core/mac/mac_types.hpp @@ -84,6 +84,11 @@ constexpr ShortAddress kShortAddrInvalid = OT_RADIO_INVALID_SHORT_ADDR; ///< constexpr bool kDefaultMacKeysExportable = OPENTHREAD_CONFIG_PLATFORM_MAC_KEYS_EXPORTABLE_ENABLE; ///< Default exportability policy for MAC key refs. +/** + * Represents the packet capture callback function pointer. + */ +typedef otLinkPcapCallback PcapCallback; + /** * Represents the wake-up identifier. */ diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index 193c1e444..d28dedfba 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -263,14 +263,10 @@ public: /** * Registers a callback to provide received packet capture for IEEE 802.15.4 frames. * - * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame - * or `nullptr` to disable the callback. - * @param[in] aCallbackContext A pointer to application-specific context. + * @param[in] aCallback The packet capture callback, or `nullptr` to disable packet capture. + * @param[in] aContext A pointer to application-specific context. */ - void SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackContext) - { - mPcapCallback.Set(aPcapCallback, aCallbackContext); - } + void SetPcapCallback(PcapCallback aCallback, void *aContext) { mPcapCallback.Set(aCallback, aContext); } /** * Indicates whether radio should stay in Receive or Sleep during idle periods. @@ -654,16 +650,16 @@ private: #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE bool mRadioFilterEnabled : 1; #endif - int8_t mEnergyScanMaxRssi; - TimeMilli mEnergyScanEndTime; - TxFrame &mTransmitFrame; - Callbacks mCallbacks; - Callback mPcapCallback; - KeyMaterial mPrevKey; - KeyMaterial mCurrKey; - KeyMaterial mNextKey; - uint32_t mFrameCounter; - uint8_t mKeyIndex; + int8_t mEnergyScanMaxRssi; + TimeMilli mEnergyScanEndTime; + TxFrame &mTransmitFrame; + Callbacks mCallbacks; + Callback mPcapCallback; + KeyMaterial mPrevKey; + KeyMaterial mCurrKey; + KeyMaterial mNextKey; + uint32_t mFrameCounter; + uint8_t mKeyIndex; #if OPENTHREAD_CONFIG_MAC_ADD_DELAY_ON_NO_ACK_ERROR_BEFORE_RETRY uint8_t mRetxDelayBackOffExponent; #endif