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

📄 zdsecmgr.s51

📁 cc2430应用实例
💻 S51
📖 第 1 页 / 共 5 页
字号:
// 1035   #else // !defined ( ZDO_COORDINATOR )
// 1036   //---------------------------------------------------------------------------
// 1037   return ZSuccess;
// 1038   //---------------------------------------------------------------------------
// 1039   #endif // !defined ( ZDO_COORDINATOR )
// 1040   //---------------------------------------------------------------------------
// 1041 }
// 1042 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1043 
// 1044 #if defined ( ZDSECMGR_COMMERCIAL )
// 1045 /******************************************************************************
// 1046  * @fn          ZDSecMgrMasterKeyLoad
// 1047  *
// 1048  * @brief       Load the MASTER key for device with specified EXT
// 1049  *              address.
// 1050  *
// 1051  * @param       nwkAddr - [in] NWK address of Trust Center
// 1052  * @param       extAddr - [in] EXT address of Trust Center
// 1053  * @param       key     - [in] MASTER key shared with Trust Center
// 1054  *
// 1055  * @return      none
// 1056  */
// 1057 void ZDSecMgrMasterKeyLoad( uint16 nwkAddr, uint8* extAddr, uint8* key )
// 1058 {
// 1059   AddrMgrEntry_t addr;
// 1060   uint8*         loaded;
// 1061 
// 1062 
// 1063   // check if Trust Center address is configured and correct
// 1064   // check if MASTER key has already been sent
// 1065 
// 1066   // add address data
// 1067   addr.user    = ADDRMGR_USER_SECURITY;
// 1068   addr.nwkAddr = nwkAddr;
// 1069   AddrMgrExtAddrSet( addr.extAddr, extAddr );
// 1070 
// 1071   if ( AddrMgrEntryUpdate( &addr ) == TRUE )
// 1072   {
// 1073     if ( ZDSecMgrMasterKeyLookup( addr.index, &loaded ) != ZSuccess )
// 1074     {
// 1075       ZDSecMgrMasterKeyStore( addr.index, key );
// 1076     }
// 1077   }
// 1078 }
// 1079 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1080 
// 1081 #if defined ( ZDSECMGR_COMMERCIAL )
// 1082 /******************************************************************************
// 1083  * @fn          ZDSecMgrAppKeyGet
// 1084  *
// 1085  * @brief       get an APP key - option APP(MASTER or LINK) key
// 1086  *
// 1087  * @param       initNwkAddr - [in] NWK address of initiator device
// 1088  * @param       initExtAddr - [in] EXT address of initiator device
// 1089  * @param       partNwkAddr - [in] NWK address of partner device
// 1090  * @param       partExtAddr - [in] EXT address of partner device
// 1091  * @param       key         - [out] APP(MASTER or LINK) key
// 1092  * @param       keyType     - [out] APP(MASTER or LINK) key type
// 1093  *
// 1094  * @return      pointer to MASTER key
// 1095  */
// 1096 ZStatus_t ZDSecMgrAppKeyGet( uint16  initNwkAddr,
// 1097                              uint8*  initExtAddr,
// 1098                              uint16  partNwkAddr,
// 1099                              uint8*  partExtAddr,
// 1100                              uint8** key,
// 1101                              uint8*  keyType )
// 1102 {
// 1103   //---------------------------------------------------------------------------
// 1104   // note:
// 1105   // should use a robust mechanism to generate keys, for example
// 1106   // combine EXT addresses and call a hash function
// 1107   //---------------------------------------------------------------------------
// 1108   osal_memset( *key, 0, SEC_KEY_LEN );
// 1109 
// 1110   *keyType = KEY_TYPE_APP_LINK;
// 1111   //or       KEY_TYPE_APP_MASTER;
// 1112 
// 1113   return ZSuccess;
// 1114 }
// 1115 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1116 
// 1117 #if defined ( ZDSECMGR_COMMERCIAL )
// 1118 /******************************************************************************
// 1119  * @fn          ZDSecMgrAppKeyReq
// 1120  *
// 1121  * @brief       Process request for APP key between two devices.
// 1122  *
// 1123  * @param       device - [in] ZDO_RequestKeyInd_t, request info
// 1124  *
// 1125  * @return      none
// 1126  */
// 1127 void ZDSecMgrAppKeyReq( ZDO_RequestKeyInd_t* ind )
// 1128 {
// 1129   APSME_TransportKeyReq_t req;
// 1130   uint8                   initExtAddr[Z_EXTADDR_LEN];
// 1131   uint16                  partNwkAddr;
// 1132   uint8                   key[SEC_KEY_LEN];
// 1133 
// 1134 
// 1135   // validate initiator and partner
// 1136   if ( ( APSME_LookupNwkAddr( ind->partExtAddr, &partNwkAddr ) == TRUE ) &&
// 1137        ( APSME_LookupExtAddr( ind->srcAddr, initExtAddr ) == TRUE      )   )
// 1138   {
// 1139     // point the key to some memory
// 1140     req.key = key;
// 1141 
// 1142     // get an APP key - option APP (MASTER or LINK) key
// 1143     if ( ZDSecMgrAppKeyGet( ind->srcAddr,
// 1144                             initExtAddr,
// 1145                             partNwkAddr,
// 1146                             ind->partExtAddr,
// 1147                             &req.key,
// 1148                             &req.keyType ) == ZSuccess )
// 1149     {
// 1150       // always secure
// 1151       req.secure = TRUE;
// 1152 
// 1153       // send key to initiator device
// 1154       req.dstAddr   = ind->srcAddr;
// 1155       req.extAddr   = ind->partExtAddr;
// 1156       req.initiator = TRUE;
// 1157       APSME_TransportKeyReq( &req );
// 1158 
// 1159       // send key to partner device
// 1160       req.dstAddr   = partNwkAddr;
// 1161       req.extAddr   = initExtAddr;
// 1162       req.initiator = FALSE;
// 1163       APSME_TransportKeyReq( &req );
// 1164     }
// 1165   }
// 1166 }
// 1167 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1168 
// 1169 #if defined ( ZDSECMGR_COMMERCIAL )
// 1170 /******************************************************************************
// 1171  * @fn          ZDSecMgrEstablishKey
// 1172  *
// 1173  * @brief       Start SKKE with device joining network.
// 1174  *
// 1175  * @param       device - [in] ZDSecMgrDevice_t, device info
// 1176  *
// 1177  * @return      ZStatus_t
// 1178  */
// 1179 ZStatus_t ZDSecMgrEstablishKey( ZDSecMgrDevice_t* device )
// 1180 {
// 1181   ZStatus_t               status;
// 1182   APSME_EstablishKeyReq_t req;
// 1183 
// 1184 
// 1185   req.respExtAddr = device->extAddr;
// 1186   req.method      = APSME_SKKE_METHOD;
// 1187 
// 1188   if ( device->parentAddr == NLME_GetShortAddr() )
// 1189   {
// 1190     req.dstAddr = device->nwkAddr;
// 1191     req.secure  = FALSE;
// 1192   }
// 1193   else
// 1194   {
// 1195     req.dstAddr = device->parentAddr;
// 1196     req.secure  = TRUE;
// 1197   }
// 1198 
// 1199   status = APSME_EstablishKeyReq( &req );
// 1200 
// 1201   return status;
// 1202 }
// 1203 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1204 
// 1205 #if defined ( ZDSECMGR_COMMERCIAL )
// 1206 /******************************************************************************
// 1207  * @fn          ZDSecMgrSendMasterKey
// 1208  *
// 1209  * @brief       Send MASTER key to device joining network.
// 1210  *
// 1211  * @param       device - [in] ZDSecMgrDevice_t, device info
// 1212  *
// 1213  * @return      ZStatus_t
// 1214  */
// 1215 ZStatus_t ZDSecMgrSendMasterKey( ZDSecMgrDevice_t* device )
// 1216 {
// 1217   ZStatus_t               status;
// 1218   APSME_TransportKeyReq_t req;
// 1219 
// 1220 
// 1221   req.keyType = KEY_TYPE_TC_MASTER;
// 1222   req.extAddr = device->extAddr;
// 1223 
// 1224   ZDSecMgrMasterKeyLookup( device->ctrl->entry->ami, &req.key );
// 1225 
// 1226   //check if using secure hop to to parent
// 1227   if ( device->parentAddr != NLME_GetShortAddr() )
// 1228   {
// 1229     //send to parent with security
// 1230     req.dstAddr = device->parentAddr;
// 1231     req.secure  = TRUE;
// 1232   }
// 1233   else
// 1234   {
// 1235     //direct with no security
// 1236     req.dstAddr = device->nwkAddr;
// 1237     req.secure  = FALSE;
// 1238   }
// 1239 
// 1240   status = APSME_TransportKeyReq( &req );
// 1241 
// 1242   return status;
// 1243 }
// 1244 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1245 
// 1246 /******************************************************************************
// 1247  * @fn          ZDSecMgrSendNwkKey
// 1248  *
// 1249  * @brief       Send NWK key to device joining network.
// 1250  *
// 1251  * @param       device - [in] ZDSecMgrDevice_t, device info
// 1252  *
// 1253  * @return      ZStatus_t
// 1254  */
// 1255 ZStatus_t ZDSecMgrSendNwkKey( ZDSecMgrDevice_t* device )
// 1256 {
// 1257   ZStatus_t               status;
// 1258   APSME_TransportKeyReq_t req;
// 1259 
// 1260 
// 1261   //---------------------------------------------------------------------------
// 1262   #if defined ( ZDSECMGR_COMMERCIAL )
// 1263   //---------------------------------------------------------------------------
// 1264   {
// 1265     // set values
// 1266     req.extAddr   = device->extAddr;
// 1267     req.keyType   = KEY_TYPE_NWK;
// 1268     req.keySeqNum = _NIB.nwkActiveKey.keySeqNum;
// 1269     req.key       = _NIB.nwkActiveKey.key;
// 1270 
// 1271     // check if using secure hop to to parent
// 1272     if ( device->parentAddr == NLME_GetShortAddr() )
// 1273     {
// 1274       req.dstAddr = device->nwkAddr;
// 1275       req.secure  = FALSE;
// 1276     }
// 1277     else
// 1278     {
// 1279       req.dstAddr = device->parentAddr;
// 1280       req.secure  = TRUE;
// 1281     }
// 1282   }
// 1283   //---------------------------------------------------------------------------
// 1284   #else // defined( ZDSECMGR_RESIDENTIAL )
// 1285   //---------------------------------------------------------------------------
// 1286   {
// 1287     // default values
// 1288     req.dstAddr = device->nwkAddr;
// 1289     req.secure  = device->secure;
// 1290     req.keyType = KEY_TYPE_NWK;
// 1291     req.extAddr = device->extAddr;
// 1292 
// 1293     // special cases
// 1294     if ( device->secure == FALSE )
// 1295     {
// 1296       req.keySeqNum = _NIB.nwkActiveKey.keySeqNum;
// 1297       req.key       = _NIB.nwkActiveKey.key;
// 1298 
// 1299       // check if using secure hop to to parent
// 1300       if ( device->parentAddr != NLME_GetShortAddr() )
// 1301       {
// 1302         req.dstAddr = device->parentAddr;
// 1303         req.secure  = TRUE;
// 1304       }
// 1305     }
// 1306     else
// 1307     {
// 1308       req.key       = NULL;
// 1309       req.keySeqNum = 0;
// 1310     }
// 1311   }
// 1312   //-------------------------------------------------------------------------
// 1313   #endif // defined( ZDSECMGR_RESIDENTIAL )
// 1314   //-------------------------------------------------------------------------
// 1315 
// 1316   status = APSME_TransportKeyReq( &req );
// 1317 
// 1318   return status;
// 1319 }
// 1320 
// 1321 #if defined ( ZDSECMGR_COMMERCIAL )
// 1322 /******************************************************************************
// 1323  * @fn          ZDSecMgrDeviceEntryRemove
// 1324  *
// 1325  * @brief       Remove device entry.
// 1326  *
// 1327  * @param       entry - [in] valid entry
// 1328  *
// 1329  * @return      none
// 1330  */
// 1331 void ZDSecMgrDeviceEntryRemove( ZDSecMgrEntry_t* entry )
// 1332 {
// 1333   // terminate device control
// 1334   ZDSecMgrCtrlTerm( entry );
// 1335 
// 1336   // remove device from entry data
// 1337   ZDSecMgrEntryFree( entry );
// 1338 
// 1339   // remove EXT address
// 1340   //ZDSecMgrExtAddrRelease( aiOld );
// 1341 }
// 1342 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 1343 
// 1344 #if defined ( ZDSECMGR_COMMERCIAL )
// 1345 /******************************************************************************
// 1346  * @fn          ZDSecMgrDeviceEntryAdd
// 1347  *
// 1348  * @brief       Add entry.
// 1349  *
// 1350  * @param       device - [in] ZDSecMgrDevice_t, device info
// 1351  * @param       ami    - [in] Address Manager index
// 1352  *
// 1353  * @return      ZStatus_t
// 1354  */
// 1355 void ZDSecMgrAddrMgrUpdate( uint16 ami, uint16 n

⌨️ 快捷键说明

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