📄 ztceventmonitor.c
字号:
/******************************************************************************
* This module implements the monitoring of the SAPs of the BeeStack layers and
* MAC/ASP. This module also gives an extension to incorporate the
* inject/monitor and hooking activity for Application
*
*
* (c) Copyright 2006, Freescale, Inc. All rights reserved.
*
* Freescale Semiconductor Confidential Proprietary
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale Semiconductor Danmark A/S.
*
******************************************************************************/
#include "EmbeddedTypes.h"
#if ( gZtcIncluded_d == 1 )
#include "ZtcInterface.h"
#include "ZtcEventMonitor.h"
#include "ZtcQueue.h"
#include "ZtcFilter.h"
#include "ZtcPrimitiveHandler.h"
#if gBeeStackIncluded_d == 1
#include "ApsNwkInterface.h"
#include "NwkCommon.h"
#endif /* gBeeStackIncluded_d */
#include "ZtcConfiguration.h"
/******************************************************************************
*******************************************************************************
* Private macros
*******************************************************************************
******************************************************************************/
/* Used for ZDO message types */
#define mMaskResponseBit_c 0x7f
#define mMsgTypeForAFToAppSAP 0xFA
#define mApsmeSetToReadyState 0x0C
/******************************************************************************
*******************************************************************************
* Private prototypes
*******************************************************************************
******************************************************************************/
#if gZTC_AutomatedScriptEnabled_d == 1
/*****************************************************************************
* This function used to send the event on SAP handler called in BeeStack to
* the test client.
*
* Interface assumptions:
* This is an option feature. This feature will be enable to help in automated
* testing. Test script used to test the hook and monitor feature can be
* automated using this feature.
*
* The routine limitations.
* None
*
* Return value:
* None
*
* Effects on global data.
* None
*
* Source of algorithm used.
* None
*
* Revison history:
*
* date Author Comments
* ------ ------ --------
* 240306 LS, Updated
*****************************************************************************/
static void ZTCEventMonitor_SendSAPHandlerCallEvent
(
const uint8_t SAPId, /* IN: SAP ID used in the ZTC */
const uint8_t msgId /* IN: Message ID passed to the layer */
);
#endif /* gAZTCutomatedScriptEnabled_d */
/******************************************************************************
*******************************************************************************
* Private type definitions
*******************************************************************************
******************************************************************************/
/* To automate test script, events are sent to test client to ensure that in
monitor mode the upper SAP is getting called and in the hook mode the upper
layer SAP is not getting called. The event sent has two bytes, first byte
tells which SAP Handler got called and the next byte gives the detail
of the message type sent to the SAP. The following enum defines the position
of these field in the event format. */
enum{
gFirstFieldForTheSAPCalledEvent_c,
gSecondFieldForTheSAPCalledEvent_c,
gLengthOfSAPCalledEvent
};
/******************************************************************************
*******************************************************************************
* Private memory declarations
*******************************************************************************
******************************************************************************/
/* This table stores the starting index of the message Id for a particular SAP.
The message id starts from 0 in BeeStack for each SAP. So to translate to a
unique message Id used in ZTC, this table stores the starting index of the
primitive for each SAP */
static const uint8_t maStartMsgIdForSAPId[] = {
gZTC_MCPSDataReq_c, gZTC_MCPSDataConf_c,
gZTC_MLMEAssociateReq_c, gZTCNwkAssociateInd_c,
gZTC_ASPGetTimeReq_c, gZTCAppGetTimeConf_c
#if gBeeStackIncluded_d == 1
,
gZTC_NLDEDataReq_c - gNldeDataReq_c, gZTC_NLDEDataConf_c - gNldeDataCnf_c,
gZTC_NLMENwkDiscoveryReq_c - gNlmeNetworkDiscoveryRequest_c,
gZTC_NLMENwkDiscoveryConf_c - gNlmeNetworkDiscoveryConfirm_c,
gZTC_APSDEDataReq_c, gZTC_APSDEDataConf_c,
gZTCRegEp_c, gZTC_AFDataConf_c
#endif
};
#if gBeeStackIncluded_d == 1
/* The following two look up table is used to get the APSME primitive ID used
in ZTC. To match the enum values to their original value '0's are introduced
in between */
static const uint8_t maZDO_APSMENonSecPrimitivesToZTCMsgId[] = {
gZTC_APSMEBindReq_c,
0, 0, /* Padded with zero for proper indexing */
gZTC_APSMEGetReq_c,
0, 0, /* Padded with zero for proper indexing */
gZTC_APSMESetReq_c,
0, 0, /* Padded with zero for proper indexing */
gZTC_APSMEUnbindReq_c,
0, gZTC_APSMEReset_c, gZTC_APSMESetToReadyState_c
};
static const uint8_t maZDO_APSMESecPrimitivesToZTCMsgId[] = {
gZTC_APSMEEstablishKeyReq_c ,
gZTC_APSMEEstablishKeyResp_c ,
gZTC_APSMETransportKeyReq_c ,
0 , /* Padded with zero for proper indexing */
gZTC_APSMERequestKeyReq_c ,
gZTC_APSMESwitchKeyReq_c ,
gZTC_APSMEEstablishKeyConf_c ,
gZTC_APAMEEstablishKeyInd_c ,
gZTC_APSMEUpdateDeviceInd_c ,
gZTC_APSMERemoveDeviceInd_c ,
0, 0, 0, 0, 0, 0 , /* Padded with zero for proper indexing */
0, 0, 0, 0, 0, 0 , /* Padded with zero for proper indexing */
0, 0, 0, 0, 0, 0 , /* Padded with zero for proper indexing */
0, 0, 0, 0, 0, 0 , /* Padded with zero for proper indexing */
gZTC_APSMESwitchKeyInd_c ,
gZTC_APSMETransportKeyInd_c ,
gZTC_APSMEUpdateDeviceReq_c ,
gZTC_APSMERemoveDeviceReq_c ,
};
/* The following two look up table is used to get the ZDP primitive ID used
in ZTC. To match the enum values to their original value '0's are introduced
in between */
static const uint8_t maZDPPrimitivesToZTCMsgId[] = {
gZTCNwkAddrReq_c ,
gZTC_IEEEAddrReq_c ,
gZTCNodeDescReq_c ,
gZTCPowerDescReq_c ,
gZTCSimpleDescReq_c ,
gZTCActiveEpReq_c ,
gZTCMatchDescReq_c ,
0, 0, 0, 0, 0, 0, 0, 0 ,0 , /* Padded with zero for proper indexing */
gZTCComplexDescReq_c ,
gZTCUserDescReq_c ,
gZTCDiscRegReq_c ,
gZTCEndDevAnnounce_c ,
gZTCUserDescSet_c ,
0, 0, 0, 0, 0, 0, 0, 0, 0 , /* Padded with zero for proper indexing */
0, 0 , /* Padded with zero for proper indexing */
gZTCEndDevBindReq_c ,
gZTCBindReq_c ,
gZTCUnbindReq_c ,
0, 0, 0, 0, 0, 0, 0, 0, 0 , /* Padded with zero for proper indexing */
0, 0,0,0 , /* Padded with zero for proper indexing */
gZTCMgmtNwkDiscReq_c ,
gZTCMgmtLQIReq_c ,
gZTCMgmtRtgReq_c ,
gZTCMgmtBindReq_c ,
gZTCMgmtLeaveReq_c ,
gZTCMgmtDirectJoinReq_c ,
gZTC_ZDPNwkPermitJoinReq_c ,
0, 0 , /* Padded with zero for proper indexing */
gZTC_ZDPNwkDirectJoinReq_c ,
0, 0, /* Padded with zero for proper indexing */
gZTC_ZDPNwkSyncReq_c ,
0, 0, 0, 0 , /* Padded with zero for proper indexing */
gZTC_ZDPDiscConf_c ,
0, gZTC_ZDPNwkPermitJoinConf_c ,
0, 0, 0 , /* Padded with zero for proper indexing */
gZTC_ZDPDirectJoinConf_c ,
0, 0, 0 , /* Padded with zero for proper indexing */
gZTC_ZDPSyncInd_c ,
gZTC_ZDPSyncConf_c ,
0, 0, 0 , /* Padded with zero for proper indexing */
gZTC_ZDPNwkDiscReq_c
};
/* Look up table to find out the ZTC message ID for ZDP primitives which
doesn't have corresponding responce for the request
For proper indexing it is padded with 0 */
static const uint8_t maOtherZDPPrimitivesToZTCMsgId[] = {
gZTC_ZDP_APSMEEstablishKeyReq_c, gZTC_ZDP_APSMEEstablishKeyResp_c,
gZTC_ZDP_APSMETransportKeyReq_c, gZTCReadExtendedReq_c,
gZTC_ZDP_APSMERequestKeyReq_c, gZTC_ZDP_APSMESwitchKeyReq_c,
gZTC_ZDP_APSMEEstablishKeyConf_c, gZTC_ZDP_APSMEEstablishKeyInd_c,
gZTC_ZDO_APSMEUpdateDevInd_c, gZTC_ZDP_APSMERemoveDevInd_c,
gZTC_ZDP_APSMERequestKeyInd_c, gZTCWriteConfigureAttribReq_c,
gZTCWriteExtendedAddrReq_c, gZTCStopNwkReq_c,
gZTCWriteConfigureAttribConf_c, gZTCWriteExtendedAddrConf_c,
gZTCStartNwkReq_c, gZTCRestartNwkReq_c,
gZTCFindNumOfEpReq_c, gZTCFindEPDescReq_c,
gZTCFindEpListReq_c, gZTCBeestackSaveReq_c,
gZTCBeestackSaveConf_c, 0,
0, 0,
0, gZTCInitStackUsage_c,
gZTCMaximumStackUsed_c , 0, 0, 0, 0, 0,
gZTC_ZDP_APSMESwitchKeyInd_c, gZTC_ZDP_APSMETransportKeyInd_c,
gZTC_ZDP_APSMEUpdateDevReq_c, gZTC_ZDP_APSMERemoveDevReq_c
};
/* Look up table to get the address of the Queue for SAP */
static anchor_t * const maAddrOfSAPQueueTable[ ] ={
NULL, /* NWK_MCPS_SapHandler */
&mMcpsNwkInputQueue, /* MCPS_NWK_SapHandler */
NULL, /* NWK_MLME_SapHandler */
&mMlmeNwkInputQueue, /* MLME_NWK_SapHandler */
NULL, /* APP_ASP_SapHandler */
NULL, /* ASP_APP_SapHandler */
&mApsNldeInputQueue, /* APS_NLDE_SapHandler */
&gNldeQueue, /* NLDE_APS_SapHandler */
&mZdoNlmeInputQueue, /* ZDO_NLME_SapHandler */
&mNlmeZdoInputQueue, /* NLME_ZDO_SapHandler */
&gApsdeQueue, /* AF_APSDE_SapHandler */
&gApsToAfdeQ, /* APSDE_AF_SapHandler */
NULL, /* AppAfdeDummy_SapHandler */
NULL, /* AfdeAppDummy_SapHandler */
#if ( gResCapability_d == 1 ) || ( gComCapability_d == 1 )
&mApsmeZdoInputQueue, /* APSME_ZDO_SapHandler */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -