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

📄 zdsecmgr.s51

📁 用IAR开发的ZIGBEE网络路由例子
💻 S51
📖 第 1 页 / 共 5 页
字号:
//  405 ZStatus_t ZDSecMgrExtAddrLookup( uint8* extAddr, uint16* ami )
//  406 {
//  407   ZStatus_t      status;
//  408   AddrMgrEntry_t entry;
//  409 
//  410 
//  411   // lookup entry
//  412   entry.user = ADDRMGR_USER_SECURITY;
//  413   AddrMgrExtAddrSet( entry.extAddr, extAddr );
//  414 
//  415   if ( AddrMgrEntryLookupExt( &entry ) == TRUE )
//  416   {
//  417     // return successful results
//  418     *ami   = entry.index;
//  419     status = ZSuccess;
//  420   }
//  421   else
//  422   {
//  423     // return failed results
//  424     *ami   = entry.index;
//  425     status = ZNwkUnknownDevice;
//  426   }
//  427 
//  428   return status;
//  429 }
//  430 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  431 
//  432 #if defined ( ZDSECMGR_COMMERCIAL )
//  433 /******************************************************************************
//  434  * @fn          ZDSecMgrExtAddrStore
//  435  *
//  436  * @brief       Store EXT address.
//  437  *
//  438  * @param       extAddr - [in] EXT address
//  439  * @param       ami     - [out] Address Manager index
//  440  *
//  441  * @return      ZStatus_t
//  442  */
//  443 ZStatus_t ZDSecMgrExtAddrStore( uint8* extAddr, uint16* ami )
//  444 {
//  445   ZStatus_t      status;
//  446   AddrMgrEntry_t entry;
//  447 
//  448 
//  449   // add entry
//  450   entry.user    = ADDRMGR_USER_SECURITY;
//  451   entry.nwkAddr = INVALID_NODE_ADDR;
//  452   AddrMgrExtAddrSet( entry.extAddr, extAddr );
//  453 
//  454   if ( AddrMgrEntryUpdate( &entry ) == TRUE )
//  455   {
//  456     // return successful results
//  457     *ami   = entry.index;
//  458     status = ZSuccess;
//  459   }
//  460   else
//  461   {
//  462     // return failed results
//  463     *ami   = entry.index;
//  464     status = ZNwkUnknownDevice;
//  465   }
//  466 
//  467   return status;
//  468 }
//  469 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  470 
//  471 #if defined ( ZDSECMGR_COMMERCIAL )
//  472 /******************************************************************************
//  473  * @fn          ZDSecMgrMasterKeyLookup
//  474  *
//  475  * @brief       Lookup MASTER key for specified address index.
//  476  *
//  477  * @param       ami - [in] Address Manager index
//  478  * @param       key - [out] valid MASTER key
//  479  *
//  480  * @return      ZStatus_t
//  481  */
//  482 ZStatus_t ZDSecMgrMasterKeyLookup( uint16 ami, uint8** key )
//  483 {
//  484   ZStatus_t status;
//  485   uint16    index;
//  486 
//  487 
//  488   // initialize results
//  489   *key   = NULL;
//  490   status = ZNwkUnknownDevice;
//  491 
//  492   // verify data is available
//  493   if ( ZDSecMgrMasterKeyData != NULL )
//  494   {
//  495     for ( index = 0; index < ZDSECMGR_MASTERKEY_MAX ; index++ )
//  496     {
//  497       if ( ZDSecMgrMasterKeyData[index].ami == ami )
//  498       {
//  499         // return successful results
//  500         *key   = ZDSecMgrMasterKeyData[index].key;
//  501         status = ZSuccess;
//  502 
//  503         // break from loop
//  504         index  = ZDSECMGR_MASTERKEY_MAX;
//  505       }
//  506     }
//  507   }
//  508 
//  509   return status;
//  510 }
//  511 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  512 
//  513 #if defined ( ZDSECMGR_COMMERCIAL )
//  514 /******************************************************************************
//  515  * @fn          ZDSecMgrMasterKeyStore
//  516  *
//  517  * @brief       Store MASTER key for specified address index.
//  518  *
//  519  * @param       ami - [in] Address Manager index
//  520  * @param       key - [in] valid key to store
//  521  *
//  522  * @return      ZStatus_t
//  523  */
//  524 ZStatus_t ZDSecMgrMasterKeyStore( uint16 ami, uint8* key )
//  525 {
//  526   ZStatus_t status;
//  527   uint16    index;
//  528   uint8*    entry;
//  529 
//  530 
//  531   // initialize results
//  532   status = ZNwkUnknownDevice;
//  533 
//  534   // verify data is available
//  535   if ( ZDSecMgrMasterKeyData != NULL )
//  536   {
//  537     for ( index = 0; index < ZDSECMGR_MASTERKEY_MAX ; index++ )
//  538     {
//  539       if ( ZDSecMgrMasterKeyData[index].ami == INVALID_NODE_ADDR )
//  540       {
//  541         // store EXT address index
//  542         ZDSecMgrMasterKeyData[index].ami = ami;
//  543 
//  544         entry = ZDSecMgrMasterKeyData[index].key;
//  545 
//  546         if ( key != NULL )
//  547         {
//  548           osal_cpyExtAddr( entry, key );
//  549         }
//  550         else
//  551         {
//  552           osal_memset( entry, 0, SEC_KEY_LEN );
//  553         }
//  554 
//  555         // return successful results
//  556         status = ZSuccess;
//  557 
//  558         // break from loop
//  559         index  = ZDSECMGR_MASTERKEY_MAX;
//  560       }
//  561     }
//  562   }
//  563 
//  564   return status;
//  565 }
//  566 #endif // !defined ( ZDSECMGR_COMMERCIAL )
//  567 
//  568 #if defined ( ZDSECMGR_COMMERCIAL )
//  569 /******************************************************************************
//  570  * @fn          ZDSecMgrEntryInit
//  571  *
//  572  * @brief       Initialize entry sub module
//  573  *
//  574  * @param       none
//  575  *
//  576  * @return      none
//  577  */
//  578 void ZDSecMgrEntryInit( void )
//  579 {
//  580   uint16 size;
//  581   uint16 index;
//  582 
//  583 
//  584   // allocate entry data
//  585   size = (short)( sizeof(ZDSecMgrEntry_t) * ZDSECMGR_ENTRY_MAX );
//  586 
//  587   ZDSecMgrEntries = osal_mem_alloc( size );
//  588 
//  589   // initialize data
//  590   if ( ZDSecMgrEntries != NULL )
//  591   {
//  592     for( index = 0; index < ZDSECMGR_ENTRY_MAX; index++ )
//  593     {
//  594       ZDSecMgrEntries[index].ami = INVALID_NODE_ADDR;
//  595     }
//  596   }
//  597 }
//  598 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  599 
//  600 #if defined ( ZDSECMGR_COMMERCIAL )
//  601 /******************************************************************************
//  602  * @fn          ZDSecMgrEntryLookup
//  603  *
//  604  * @brief       Lookup entry index using specified NWK address.
//  605  *
//  606  * @param       nwkAddr - [in] NWK address
//  607  * @param       entry   - [out] valid entry
//  608  *
//  609  * @return      ZStatus_t
//  610  */
//  611 ZStatus_t ZDSecMgrEntryLookup( uint16 nwkAddr, ZDSecMgrEntry_t** entry )
//  612 {
//  613   ZStatus_t      status;
//  614   uint16         index;
//  615   AddrMgrEntry_t addrMgrEntry;
//  616 
//  617 
//  618   // initialize results
//  619   *entry = NULL;
//  620   status = ZNwkUnknownDevice;
//  621 
//  622   // verify data is available
//  623   if ( ZDSecMgrEntries != NULL )
//  624   {
//  625     addrMgrEntry.user    = ADDRMGR_USER_SECURITY;
//  626     addrMgrEntry.nwkAddr = nwkAddr;
//  627 
//  628     if ( AddrMgrEntryLookupNwk( &addrMgrEntry ) == TRUE )
//  629     {
//  630       for ( index = 0; index < ZDSECMGR_ENTRY_MAX ; index++ )
//  631       {
//  632         if ( addrMgrEntry.index == ZDSecMgrEntries[index].ami )
//  633         {
//  634           // return successful results
//  635           *entry = &ZDSecMgrEntries[index];
//  636           status = ZSuccess;
//  637 
//  638           // break from loop
//  639           index = ZDSECMGR_ENTRY_MAX;
//  640         }
//  641       }
//  642     }
//  643   }
//  644 
//  645   return status;
//  646 }
//  647 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  648 
//  649 #if defined ( ZDSECMGR_COMMERCIAL )
//  650 /******************************************************************************
//  651  * @fn          ZDSecMgrEntryLookupAMI
//  652  *
//  653  * @brief       Lookup entry using specified address index
//  654  *
//  655  * @param       ami   - [in] Address Manager index
//  656  * @param       entry - [out] valid entry
//  657  *
//  658  * @return      ZStatus_t
//  659  */
//  660 ZStatus_t ZDSecMgrEntryLookupAMI( uint16 ami, ZDSecMgrEntry_t** entry )
//  661 {
//  662   ZStatus_t status;
//  663   uint16    index;
//  664 
//  665 
//  666   // initialize results
//  667   *entry = NULL;
//  668   status = ZNwkUnknownDevice;
//  669 
//  670   // verify data is available
//  671   if ( ZDSecMgrEntries != NULL )
//  672   {
//  673     for ( index = 0; index < ZDSECMGR_ENTRY_MAX ; index++ )
//  674     {
//  675       if ( ZDSecMgrEntries[index].ami == ami )
//  676       {
//  677         // return successful results
//  678         *entry = &ZDSecMgrEntries[index];
//  679         status = ZSuccess;
//  680 
//  681         // break from loop
//  682         index = ZDSECMGR_ENTRY_MAX;
//  683       }
//  684     }
//  685   }
//  686 
//  687   return status;
//  688 }
//  689 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  690 
//  691 #if defined ( ZDSECMGR_COMMERCIAL )
//  692 /******************************************************************************
//  693  * @fn          ZDSecMgrEntryLookupExt
//  694  *
//  695  * @brief       Lookup entry index using specified EXT address.
//  696  *
//  697  * @param       extAddr - [in] EXT address
//  698  * @param       entry   - [out] valid entry
//  699  *
//  700  * @return      ZStatus_t
//  701  */
//  702 ZStatus_t ZDSecMgrEntryLookupExt( uint8* extAddr, ZDSecMgrEntry_t** entry )
//  703 {
//  704   ZStatus_t status;
//  705   uint16    ami;
//  706 
//  707 
//  708   // initialize results
//  709   *entry = NULL;
//  710   status = ZNwkUnknownDevice;
//  711 
//  712   // lookup address index
//  713   if ( ZDSecMgrExtAddrLookup( extAddr, &ami ) == ZSuccess )
//  714   {
//  715     status = ZDSecMgrEntryLookupAMI( ami, entry );
//  716   }
//  717 
//  718   return status;
//  719 }
//  720 #endif // defined ( ZDSECMGR_COMMERCIAL )
//  721 
//  722 #if defined ( ZDSECMGR_COMMERCIAL )
//  723 /******************************************************************************
//  724  * @fn          ZDSecMgrEntryFree
//  725  *
//  726  * @brief       Free entry.
//  727  *
//  728  * @param       entry - [in] valid entry

⌨️ 快捷键说明

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