⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zdsecmgr.s51

📁 用IAR开发的ZIGBEE网络路由例子
💻 S51
📖 第 1 页 / 共 5 页
字号:
//   81 #define ZDSecMgrKeyFwdToChild  APSME_KeyFwdToChild
//   82 
//   83 /******************************************************************************
//   84  * TYPEDEFS
//   85  */
//   86 typedef struct
//   87 {
//   88   uint8 extAddr[Z_EXTADDR_LEN];
//   89   uint8 key[SEC_KEY_LEN];
//   90 } ZDSecMgrPreConfigData_t;
//   91 
//   92 typedef struct
//   93 {
//   94   uint16 ami;
//   95   uint8  key[SEC_KEY_LEN];
//   96 } ZDSecMgrMasterKeyData_t;
//   97 
//   98 //should match APSME_LinkKeyData_t;
//   99 typedef struct
//  100 {
//  101   uint8               key[SEC_KEY_LEN];
//  102   APSME_LinkKeyData_t apsmelkd;
//  103 } ZDSecMgrLinkKeyData_t;
//  104 
//  105 typedef struct
//  106 {
//  107   uint16                ami;
//  108   ZDSecMgrLinkKeyData_t lkd;
//  109 } ZDSecMgrEntry_t;
//  110 
//  111 typedef struct
//  112 {
//  113   ZDSecMgrEntry_t* entry;
//  114   uint16           parentAddr;
//  115   uint8            secure;
//  116   uint8            state;
//  117   uint8            cntr;
//  118   //uint8          next;
//  119 } ZDSecMgrCtrl_t;
//  120 
//  121 typedef struct
//  122 {
//  123   uint16          nwkAddr;
//  124   uint8*          extAddr;
//  125   uint16          parentAddr;
//  126   uint8           secure;
//  127   ZDSecMgrCtrl_t* ctrl;
//  128 } ZDSecMgrDevice_t;
//  129 
//  130 /******************************************************************************
//  131  * LOCAL VARIABLES
//  132  */
//  133 #if defined ( ZDSECMGR_SECURE ) && defined ( ZDO_COORDINATOR )
//  134 uint8 ZDSecMgrRestrictedDevices[ZDSECMGR_RESTRICTED_DEVICES][Z_EXTADDR_LEN] =
//  135 {
//  136   { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
//  137   { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
//  138 };
//  139 #endif // defined ( ZDSECMGR_SECURE ) && defined ( ZDO_COORDINATOR )
//  140 
//  141 #if defined ( ZDSECMGR_COMMERCIAL )
//  142 #if ( ZDSECMGR_PRECONFIG_MAX != 0 )
//  143 const ZDSecMgrPreConfigData_t ZDSecMgrPreConfigData[ZDSECMGR_PRECONFIG_MAX] =
//  144 {
//  145   //---------------------------------------------------------------------------
//  146   // DEVICE A
//  147   //---------------------------------------------------------------------------
//  148   {
//  149     // extAddr
//  150     {0x7C,0x01,0x12,0x13,0x14,0x15,0x16,0x17},
//  151 
//  152     // key
//  153     {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//  154      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
//  155   },
//  156   //---------------------------------------------------------------------------
//  157   // DEVICE B
//  158   //---------------------------------------------------------------------------
//  159   {
//  160     // extAddr
//  161     {0x84,0x03,0x00,0x00,0x00,0x4B,0x12,0x00},
//  162 
//  163     // key
//  164     {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//  165      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
//  166   },
//  167   //---------------------------------------------------------------------------
//  168   // DEVICE C
//  169   //---------------------------------------------------------------------------
//  170   {
//  171     // extAddr
//  172     {0x3E,0x01,0x12,0x13,0x14,0x15,0x16,0x17},
//  173 
//  174     // key
//  175     {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//  176      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
//  177   },
//  178 };
//  179 #endif // ( ZDSECMGR_PRECONFIG_MAX != 0 )
//  180 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  181 
//  182 #if defined ( ZDSECMGR_COMMERCIAL )
//  183 ZDSecMgrMasterKeyData_t* ZDSecMgrMasterKeyData = NULL;
//  184 ZDSecMgrEntry_t*         ZDSecMgrEntries       = NULL;
//  185 ZDSecMgrCtrl_t*          ZDSecMgrCtrlData      = NULL;
//  186 void ZDSecMgrAddrMgrUpdate( uint16 ami, uint16 nwkAddr );
//  187 void ZDSecMgrAddrMgrCB( uint8 update, AddrMgrEntry_t* newEntry, AddrMgrEntry_t* oldEntry );
//  188 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  189 
//  190 #if defined ( ZDSECMGR_SECURE ) && defined ( ZDO_COORDINATOR )
//  191 uint8 ZDSecMgrPermitJoiningEnabled;
//  192 uint8 ZDSecMgrPermitJoiningTimed;
//  193 #endif // defined ( ZDSECMGR_SECURE ) && defined ( ZDO_COORDINATOR )
//  194 
//  195 #if defined ( ZDSECMGR_SECURE )
//  196 /******************************************************************************
//  197  * PRIVATE FUNCTIONS
//  198  *
//  199  *   ZDSecMgrMasterKeyInit
//  200  *   ZDSecMgrExtAddrLookup
//  201  *   ZDSecMgrExtAddrStore
//  202  *   ZDSecMgrMasterKeyLookup
//  203  *   ZDSecMgrMasterKeyStore
//  204  *   ZDSecMgrEntryInit
//  205  *   ZDSecMgrEntryLookup
//  206  *   ZDSecMgrEntryLookupAMI
//  207  *   ZDSecMgrEntryLookupExt
//  208  *   ZDSecMgrEntryFree
//  209  *   ZDSecMgrEntryNew
//  210  *   ZDSecMgrCtrlInit
//  211  *   ZDSecMgrCtrlRelease
//  212  *   ZDSecMgrCtrlLookup
//  213  *   ZDSecMgrCtrlSet
//  214  *   ZDSecMgrCtrlAdd
//  215  *   ZDSecMgrCtrlTerm
//  216  *   ZDSecMgrCtrlReset
//  217  *   ZDSecMgrMasterKeyLoad
//  218  *   ZDSecMgrAppKeyGet
//  219  *   ZDSecMgrAppKeyReq
//  220  *   ZDSecMgrEstablishKey
//  221  *   ZDSecMgrSendMasterKey
//  222  *   ZDSecMgrSendNwkKey
//  223  *   ZDSecMgrDeviceEntryRemove
//  224  *   ZDSecMgrDeviceEntryAdd
//  225  *   ZDSecMgrDeviceCtrlHandler
//  226  *   ZDSecMgrDeviceCtrlSetup
//  227  *   ZDSecMgrDeviceCtrlUpdate
//  228  *   ZDSecMgrDeviceRemove
//  229  *   ZDSecMgrDeviceValidateSKKE
//  230  *   ZDSecMgrDeviceValidateRM
//  231  *   ZDSecMgrDeviceValidateCM
//  232  *   ZDSecMgrDeviceValidate
//  233  *   ZDSecMgrDeviceJoin
//  234  *   ZDSecMgrDeviceJoinDirect
//  235  *   ZDSecMgrDeviceJoinFwd
//  236  *   ZDSecMgrDeviceNew
//  237  *   ZDSecMgrAssocDeviceAuth
//  238  */
//  239 //-----------------------------------------------------------------------------
//  240 // master key data
//  241 //-----------------------------------------------------------------------------
//  242 void ZDSecMgrMasterKeyInit( void );
//  243 
//  244 //-----------------------------------------------------------------------------
//  245 // EXT address management
//  246 //-----------------------------------------------------------------------------
//  247 ZStatus_t ZDSecMgrExtAddrLookup( uint8* extAddr, uint16* ami );
//  248 ZStatus_t ZDSecMgrExtAddrStore( uint8* extAddr, uint16* ami );
//  249 
//  250 //-----------------------------------------------------------------------------
//  251 // MASTER key data
//  252 //-----------------------------------------------------------------------------
//  253 ZStatus_t ZDSecMgrMasterKeyLookup( uint16 ami, uint8** key );
//  254 ZStatus_t ZDSecMgrMasterKeyStore( uint16 ami, uint8* key );
//  255 
//  256 //-----------------------------------------------------------------------------
//  257 // entry data
//  258 //-----------------------------------------------------------------------------
//  259 void ZDSecMgrEntryInit( void );
//  260 ZStatus_t ZDSecMgrEntryLookup( uint16 nwkAddr, ZDSecMgrEntry_t** entry );
//  261 ZStatus_t ZDSecMgrEntryLookupAMI( uint16 ami, ZDSecMgrEntry_t** entry );
//  262 ZStatus_t ZDSecMgrEntryLookupExt( uint8* extAddr, ZDSecMgrEntry_t** entry );
//  263 void ZDSecMgrEntryFree( ZDSecMgrEntry_t* entry );
//  264 ZStatus_t ZDSecMgrEntryNew( ZDSecMgrEntry_t** entry );
//  265 
//  266 //-----------------------------------------------------------------------------
//  267 // control data
//  268 //-----------------------------------------------------------------------------
//  269 void ZDSecMgrCtrlInit( void );
//  270 void ZDSecMgrCtrlRelease( ZDSecMgrCtrl_t* ctrl );
//  271 void ZDSecMgrCtrlLookup( ZDSecMgrEntry_t* entry, ZDSecMgrCtrl_t** ctrl );
//  272 void ZDSecMgrCtrlSet( ZDSecMgrDevice_t* device,
//  273                       ZDSecMgrEntry_t*  entry,
//  274                       ZDSecMgrCtrl_t*   ctrl );
//  275 ZStatus_t ZDSecMgrCtrlAdd( ZDSecMgrDevice_t* device, ZDSecMgrEntry_t*  entry );
//  276 void ZDSecMgrCtrlTerm( ZDSecMgrEntry_t* entry );
//  277 ZStatus_t ZDSecMgrCtrlReset( ZDSecMgrDevice_t* device,
//  278                              ZDSecMgrEntry_t*  entry );
//  279 
//  280 //-----------------------------------------------------------------------------
//  281 // key support
//  282 //-----------------------------------------------------------------------------
//  283 void ZDSecMgrMasterKeyLoad( uint16 nwkAddr, uint8* extAddr, uint8* key );
//  284 ZStatus_t ZDSecMgrAppKeyGet( uint16  initNwkAddr,
//  285                              uint8*  initExtAddr,
//  286                              uint16  partNwkAddr,
//  287                              uint8*  partExtAddr,
//  288                              uint8** key,
//  289                              uint8*  keyType );
//  290 void ZDSecMgrAppKeyReq( ZDO_RequestKeyInd_t* ind );
//  291 ZStatus_t ZDSecMgrEstablishKey( ZDSecMgrDevice_t* device );
//  292 ZStatus_t ZDSecMgrSendMasterKey( ZDSecMgrDevice_t* device );
//  293 ZStatus_t ZDSecMgrSendNwkKey( ZDSecMgrDevice_t* device );
//  294 
//  295 //-----------------------------------------------------------------------------
//  296 // device entry
//  297 //-----------------------------------------------------------------------------
//  298 void ZDSecMgrDeviceEntryRemove( ZDSecMgrEntry_t* entry );
//  299 ZStatus_t ZDSecMgrDeviceEntryAdd( ZDSecMgrDevice_t* device, uint16 ami );
//  300 
//  301 //-----------------------------------------------------------------------------
//  302 // device control
//  303 //-----------------------------------------------------------------------------
//  304 void ZDSecMgrDeviceCtrlHandler( ZDSecMgrDevice_t* device );
//  305 void ZDSecMgrDeviceCtrlSetup( ZDSecMgrDevice_t* device );
//  306 void ZDSecMgrDeviceCtrlUpdate( uint8* extAddr, uint8 state );
//  307 
//  308 //-----------------------------------------------------------------------------
//  309 // device management
//  310 //-----------------------------------------------------------------------------
//  311 void ZDSecMgrDeviceRemove( ZDSecMgrDevice_t* device );
//  312 ZStatus_t ZDSecMgrDeviceValidateSKKE( ZDSecMgrDevice_t* device );
//  313 ZStatus_t ZDSecMgrDeviceValidateRM( ZDSecMgrDevice_t* device );
//  314 ZStatus_t ZDSecMgrDeviceValidateCM( ZDSecMgrDevice_t* device );
//  315 ZStatus_t ZDSecMgrDeviceValidate( ZDSecMgrDevice_t* device );
//  316 ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device );
//  317 ZStatus_t ZDSecMgrDeviceJoinDirect( ZDSecMgrDevice_t* device );
//  318 ZStatus_t ZDSecMgrDeviceJoinFwd( ZDSecMgrDevice_t* device );
//  319 ZStatus_t ZDSecMgrDeviceNew( ZDSecMgrDevice_t* device );
//  320 
//  321 //-----------------------------------------------------------------------------
//  322 // association management
//  323 //-----------------------------------------------------------------------------
//  324 void ZDSecMgrAssocDeviceAuth( associated_devices_t* assoc );
//  325 
//  326 #if defined ( ZDSECMGR_COMMERCIAL )
//  327 /******************************************************************************
//  328  * @fn          ZDSecMgrMasterKeyInit                     ]
//  329  *
//  330  * @brief       Initialize master key data.
//  331  *
//  332  * @param       none
//  333  *
//  334  * @return      none
//  335  */
//  336 void ZDSecMgrMasterKeyInit( void )
//  337 {
//  338   uint16         index;
//  339   uint16         size;
//  340   AddrMgrEntry_t entry;
//  341 
//  342 
//  343   // allocate MASTER key data
//  344   size = (short)( sizeof(ZDSecMgrMasterKeyData_t) * ZDSECMGR_MASTERKEY_MAX );
//  345 
//  346   ZDSecMgrMasterKeyData = osal_mem_alloc( size );
//  347 
//  348   // initialize MASTER key data
//  349   if ( ZDSecMgrMasterKeyData != NULL )
//  350   {
//  351     for ( index = 0; index < ZDSECMGR_MASTERKEY_MAX; index++ )
//  352     {
//  353       ZDSecMgrMasterKeyData[index].ami = INVALID_NODE_ADDR;
//  354     }
//  355 
//  356     // check if preconfigured keys are enabled
//  357     //-------------------------------------------------------------------------
//  358     #if ( ZDSECMGR_PRECONFIG_MAX != 0 )
//  359     //-------------------------------------------------------------------------
//  360     if ( zgPreConfigKeys == TRUE )
//  361     {
//  362       // sync configured data
//  363       entry.user = ADDRMGR_USER_SECURITY;
//  364 
//  365       for ( index = 0; index < ZDSECMGR_PRECONFIG_MAX; index++ )
//  366       {
//  367         // check for Address Manager entry
//  368         AddrMgrExtAddrSet( entry.extAddr,
//  369                            (uint8*)ZDSecMgrPreConfigData[index].extAddr );
//  370 
//  371         if ( AddrMgrEntryLookupExt( &entry ) != TRUE )
//  372         {
//  373           // update Address Manager
//  374           AddrMgrEntryUpdate( &entry );
//  375         }
//  376 
//  377         if ( entry.index != INVALID_NODE_ADDR )
//  378         {
//  379           // sync MASTER keys with Address Manager index
//  380           ZDSecMgrMasterKeyData[index].ami = entry.index;
//  381 
//  382           osal_cpyExtAddr( ZDSecMgrMasterKeyData[index].key,
//  383                            (void*)ZDSecMgrPreConfigData[index].key );
//  384         }
//  385       }
//  386     }
//  387     //-------------------------------------------------------------------------
//  388     #endif // ( ZDSECMGR_PRECONFIG_MAX != 0 )
//  389     //-------------------------------------------------------------------------
//  390   }
//  391 }
//  392 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  393 
//  394 #if defined ( ZDSECMGR_COMMERCIAL )
//  395 /******************************************************************************
//  396  * @fn          ZDSecMgrExtAddrLookup
//  397  *
//  398  * @brief       Lookup index for specified EXT address.
//  399  *
//  400  * @param       extAddr - [in] EXT address
//  401  * @param       ami     - [out] Address Manager index
//  402  *
//  403  * @return      ZStatus_t
//  404  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -