zdsecmgr.s51
来自「TI的基于ZIGBEE2006的协议栈」· S51 代码 · 共 1,559 行 · 第 1/5 页
S51
1,559 行
// 965 #if defined ( ZDSECMGR_COMMERCIAL )
// 966 /******************************************************************************
// 967 * @fn ZDSecMgrCtrlTerm
// 968 *
// 969 * @brief Terminate device control.
// 970 *
// 971 * @param entry - [in] valid entry data
// 972 *
// 973 * @return none
// 974 */
// 975 void ZDSecMgrCtrlTerm( ZDSecMgrEntry_t* entry )
// 976 {
// 977 //---------------------------------------------------------------------------
// 978 #if defined ( ZDO_COORDINATOR )
// 979 //---------------------------------------------------------------------------
// 980 ZDSecMgrCtrl_t* ctrl;
// 981
// 982
// 983 // remove device from control data
// 984 ZDSecMgrCtrlLookup ( entry, &ctrl );
// 985
// 986 if ( ctrl != NULL )
// 987 {
// 988 ZDSecMgrCtrlRelease ( ctrl );
// 989 }
// 990 //---------------------------------------------------------------------------
// 991 #endif // defined ( ZDO_COORDINATOR )
// 992 //---------------------------------------------------------------------------
// 993 }
// 994 #endif // defined ( ZDSECMGR_COMMERCIAL )
// 995
// 996 #if defined ( ZDSECMGR_COMMERCIAL )
// 997 /******************************************************************************
// 998 * @fn ZDSecMgrCtrlReset
// 999 *
// 1000 * @brief Reset control data.
// 1001 *
// 1002 * @param device - [in] valid device data
// 1003 * @param entry - [in] valid entry data
// 1004 *
// 1005 * @return none
// 1006 */
// 1007 ZStatus_t ZDSecMgrCtrlReset( ZDSecMgrDevice_t* device, ZDSecMgrEntry_t* entry )
// 1008 {
// 1009 //---------------------------------------------------------------------------
// 1010 #if defined ( ZDO_COORDINATOR )
// 1011 //---------------------------------------------------------------------------
// 1012 ZStatus_t status;
// 1013 ZDSecMgrCtrl_t* ctrl;
// 1014
// 1015
// 1016 // initialize results
// 1017 status = ZNwkUnknownDevice;
// 1018
// 1019 // look for a match for the entry
// 1020 ZDSecMgrCtrlLookup( entry, &ctrl );
// 1021
// 1022 if ( ctrl != NULL )
// 1023 {
// 1024 ZDSecMgrCtrlSet( device, entry, ctrl );
// 1025
// 1026 status = ZSuccess;
// 1027 }
// 1028 else
// 1029 {
// 1030 status = ZDSecMgrCtrlAdd( device, entry );
// 1031 }
// 1032
// 1033 return status;
// 1034 //---------------------------------------------------------------------------
// 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;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?