libipmi_sdr.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*****************************************************************
  2. ******************************************************************
  3. *** ***
  4. *** (C)Copyright 2008, American Megatrends Inc. ***
  5. *** ***
  6. *** All Rights Reserved ***
  7. *** ***
  8. *** 5555 Oakbrook Parkway, Norcross, GA 30093, USA ***
  9. *** ***
  10. *** Phone 770.246.8600 ***
  11. *** ***
  12. ******************************************************************
  13. ******************************************************************
  14. ******************************************************************
  15. *
  16. * Filename: libipmi_sdr.c
  17. *
  18. ******************************************************************/
  19. #include <string.h>
  20. #include <stdlib.h>
  21. #include "libipmi_session.h"
  22. #include "libipmi_errorcodes.h"
  23. #include "libipmi_sdr.h"
  24. #include "com_IPMI_Storage.h"
  25. /** \brief gcc method for designating a packed struct */
  26. #define PACKED __attribute__ ((packed))
  27. #include "com_IPMI_SDRRecord.h"
  28. /* Get SDR Repository Info Command */
  29. uint16_t IPMICMD_GetSDRRepositoryInfo( IPMI20_UDS_SESSION_T *pUDSSession,
  30. SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
  31. int timeout)
  32. {
  33. uint8_t Req[20];
  34. uint16_t wRet;
  35. uint32_t dwResLen;
  36. dwResLen = sizeof(SDRRepositoryInfo_T);
  37. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  38. NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_INFO,
  39. (uint8_t*)Req, 0,
  40. (uint8_t *)pResGetSDRRepositoryInfo, &dwResLen,
  41. timeout);
  42. return wRet;
  43. }
  44. /* Get SDR Repository Allocation Info Command */
  45. uint16_t IPMICMD_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession,
  46. SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
  47. int timeout)
  48. {
  49. uint8_t Req[20];
  50. uint16_t wRet;
  51. uint32_t dwResLen;
  52. dwResLen = sizeof(SDRRepositoryAllocInfo_T);
  53. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  54. NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO,
  55. (uint8_t*)Req, 0,
  56. (uint8_t *)pResGetSDRRepositoryAllocInfo, &dwResLen,
  57. timeout);
  58. return wRet;
  59. }
  60. /* Reserve SDR Repository Command */
  61. uint16_t IPMICMD_ReserveSDRRepository( IPMI20_UDS_SESSION_T *pUDSSession,
  62. ReserveSDRRepositoryRes_T *pResReserveSDRRepository,
  63. int timeout)
  64. {
  65. uint8_t Req[20];
  66. uint16_t wRet;
  67. uint32_t dwResLen;
  68. dwResLen = sizeof(ReserveSDRRepositoryRes_T);
  69. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  70. NETFNLUN_IPMI_STORAGE, CMD_RESERVE_SDR_REPOSITORY,
  71. (uint8_t*)Req, 0,
  72. (uint8_t *)pResReserveSDRRepository, &dwResLen,
  73. timeout);
  74. return wRet;
  75. }
  76. /* Get SDR Command */
  77. uint16_t IPMICMD_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  78. GetSDRReq_T *pReqGetSDR,
  79. GetSDRRes_T *pResGetSDR,
  80. uint32_t *pdwOutBuffLen,
  81. int timeout)
  82. {
  83. uint16_t wRet;
  84. uint32_t dwResLen;
  85. dwResLen = *pdwOutBuffLen;
  86. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  87. NETFNLUN_IPMI_STORAGE, CMD_GET_SDR,
  88. (uint8_t*)pReqGetSDR, sizeof(GetSDRReq_T),
  89. (uint8_t *)pResGetSDR, &dwResLen,
  90. timeout);
  91. *pdwOutBuffLen = dwResLen;
  92. return wRet;
  93. }
  94. /* Add SDR Command */
  95. uint16_t IPMICMD_AddSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  96. uint8_t *pReqAddSDR,
  97. uint32_t dwInBuffLen,
  98. AddSDRRes_T *pResAddSDR,
  99. int timeout)
  100. {
  101. uint16_t wRet;
  102. uint32_t dwResLen;
  103. dwResLen = sizeof(AddSDRRes_T);
  104. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  105. NETFNLUN_IPMI_STORAGE, CMD_ADD_SDR,
  106. (uint8_t*)pReqAddSDR, dwInBuffLen,
  107. (uint8_t *)pResAddSDR, &dwResLen,
  108. timeout);
  109. return wRet;
  110. }
  111. /* Partial Add SDR Command */
  112. uint16_t IPMICMD_PartialAddSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  113. PartialAddSDRReq_T *pReqPartialAddSDR,
  114. uint32_t dwInBuffLen,
  115. PartialAddSDRRes_T *pResPartialAddSDR,
  116. int timeout)
  117. {
  118. uint16_t wRet;
  119. uint32_t dwResLen;
  120. dwResLen = sizeof(PartialAddSDRRes_T);
  121. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  122. NETFNLUN_IPMI_STORAGE, CMD_PARTIAL_ADD_SDR,
  123. (uint8_t*)pReqPartialAddSDR, dwInBuffLen,
  124. (uint8_t *)pResPartialAddSDR, &dwResLen,
  125. timeout);
  126. return wRet;
  127. }
  128. /* Delete SDR Command */
  129. uint16_t IPMICMD_DeleteSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  130. DeleteSDRReq_T *pReqDeleteSDR,
  131. DeleteSDRReq_T *pResDeleteSDR,
  132. int timeout)
  133. {
  134. uint16_t wRet;
  135. uint32_t dwResLen;
  136. dwResLen = sizeof(DeleteSDRReq_T);
  137. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  138. NETFNLUN_IPMI_STORAGE, CMD_DELETE_SDR,
  139. (uint8_t*)pReqDeleteSDR, sizeof(DeleteSDRReq_T),
  140. (uint8_t *)pResDeleteSDR, &dwResLen,
  141. timeout);
  142. return wRet;
  143. }
  144. /* Clear SDR Repository Command */
  145. uint16_t IPMICMD_ClearSDRRepository( IPMI20_UDS_SESSION_T *pUDSSession,
  146. ClearSDRReq_T *pReqClearSDR,
  147. ClearSDRRes_T *pResClearSDR,
  148. int timeout)
  149. {
  150. uint16_t wRet;
  151. uint32_t dwResLen;
  152. dwResLen = sizeof(ClearSDRRes_T);
  153. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  154. NETFNLUN_IPMI_STORAGE, CMD_CLEAR_SDR_REPOSITORY,
  155. (uint8_t*)pReqClearSDR, sizeof(ClearSDRReq_T),
  156. (uint8_t *)pResClearSDR, &dwResLen,
  157. timeout);
  158. return wRet;
  159. }
  160. /* Get SDR Repository Time Command */
  161. uint16_t IPMICMD_GetSDRRepositoryTime( IPMI20_UDS_SESSION_T *pUDSSession,
  162. GetSDRRepositoryTimeRes_T *pResGetSDRRepositoryTime,
  163. int timeout)
  164. {
  165. uint8_t Req[20];
  166. uint16_t wRet;
  167. uint32_t dwResLen;
  168. dwResLen = sizeof(GetSDRRepositoryTimeRes_T);
  169. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  170. NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_TIME,
  171. (uint8_t*)Req, 0,
  172. (uint8_t *)pResGetSDRRepositoryTime, &dwResLen,
  173. timeout);
  174. return wRet;
  175. }
  176. /* Set SDR Repository Time Command */
  177. uint16_t IPMICMD_SetSDRRepositoryTime( IPMI20_UDS_SESSION_T *pUDSSession,
  178. SetSDRRepositoryTimeReq_T *pReqSetSDRRepositoryTime,
  179. uint8_t *pResSetSDRRepositoryTime,
  180. int timeout)
  181. {
  182. uint16_t wRet;
  183. uint32_t dwResLen;
  184. dwResLen = sizeof(uint8_t);
  185. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  186. NETFNLUN_IPMI_STORAGE, CMD_SET_SDR_REPOSITORY_TIME,
  187. (uint8_t*)pReqSetSDRRepositoryTime, sizeof(SetSDRRepositoryTimeReq_T),
  188. (uint8_t *)pResSetSDRRepositoryTime, &dwResLen,
  189. timeout);
  190. return wRet;
  191. }
  192. /* Enter SDR Repository Update Mode Command */
  193. uint16_t IPMICMD_EnterSDRUpdateMode( IPMI20_UDS_SESSION_T *pUDSSession,
  194. EnterSDRUpdateModeRes_T *pResEnterSDRUpdateMode,
  195. int timeout)
  196. {
  197. uint8_t Req[20];
  198. uint16_t wRet;
  199. uint32_t dwResLen;
  200. dwResLen = sizeof(EnterSDRUpdateModeRes_T);
  201. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  202. NETFNLUN_IPMI_STORAGE, CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE,
  203. (uint8_t*)Req, 0,
  204. (uint8_t *)pResEnterSDRUpdateMode, &dwResLen,
  205. timeout);
  206. return wRet;
  207. }
  208. /* Exit SDR Repository Update Mode Command */
  209. uint16_t IPMICMD_ExitSDRUpdateMode( IPMI20_UDS_SESSION_T *pUDSSession,
  210. ExitSDRUpdateModeRes_T *pResExitSDRUpdateMode,
  211. int timeout)
  212. {
  213. uint8_t Req[20];
  214. uint16_t wRet;
  215. uint32_t dwResLen;
  216. dwResLen = sizeof(ExitSDRUpdateModeRes_T);
  217. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  218. NETFNLUN_IPMI_STORAGE, CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE,
  219. (uint8_t*)Req, 0,
  220. (uint8_t *)pResExitSDRUpdateMode, &dwResLen,
  221. timeout);
  222. return wRet;
  223. }
  224. /* Run Initialization Agent Command */
  225. uint16_t IPMICMD_RunInitAgent( IPMI20_UDS_SESSION_T *pUDSSession,
  226. RunInitAgentReq_T *pReqRunInitAgent,
  227. RunInitAgentRes_T *pResRunInitAgent,
  228. int timeout)
  229. {
  230. uint16_t wRet;
  231. uint32_t dwResLen;
  232. dwResLen = sizeof(RunInitAgentRes_T);
  233. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
  234. NETFNLUN_IPMI_STORAGE, CMD_RUN_INITIALIZATION_AGENT,
  235. (uint8_t*)pReqRunInitAgent, sizeof(RunInitAgentReq_T),
  236. (uint8_t *)pResRunInitAgent, &dwResLen,
  237. timeout);
  238. return wRet;
  239. }
  240. /***************** High level SDR commands *********************/
  241. static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
  242. uint16_t reservation_id,
  243. uint16_t record_id,
  244. GetSDRRes_T *pGetSDRRes,
  245. uint32_t *dwRecordLen,
  246. int timeout )
  247. {
  248. #define IPMB_SDR_MAX_SINGLE_READ (22) //32 bytes - ipmb message header - response header - checksum2
  249. uint8_t offset = (uint8_t)0;
  250. uint8_t remaining_bytes;
  251. uint8_t bytes_to_read;
  252. uint32_t dwRetLen;
  253. uint16_t wRet;
  254. uint8_t data_buffer[255];
  255. GetSDRReq_T get_sdr_req;
  256. SDRRecHdr_T *sdr_record;
  257. uint8_t *output_buffer;
  258. uint32_t output_buffer_ix=0;
  259. output_buffer = (uint8_t *)pGetSDRRes;
  260. /* Find the record length first */
  261. get_sdr_req.ReservationID = (reservation_id);
  262. get_sdr_req.RecID = ( record_id );
  263. get_sdr_req.Offset = 0;
  264. get_sdr_req.Size = sizeof(SDRRecHdr_T);
  265. dwRetLen = sizeof(SDRRecHdr_T) + sizeof(GetSDRRes_T);
  266. wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, (GetSDRRes_T *)&data_buffer[0],
  267. &dwRetLen, timeout );
  268. if(wRet != LIBIPMI_E_SUCCESS)
  269. return wRet;
  270. /* We got record length. Now we read the record */
  271. sdr_record = (SDRRecHdr_T*)&data_buffer[sizeof(GetSDRRes_T)];
  272. offset = sizeof(SDRRecHdr_T);
  273. remaining_bytes = sdr_record->Len;
  274. /* copy to output buffer */
  275. memcpy(&output_buffer[output_buffer_ix], data_buffer, dwRetLen);
  276. output_buffer_ix += dwRetLen;
  277. do {
  278. bytes_to_read = (remaining_bytes > IPMB_SDR_MAX_SINGLE_READ)? IPMB_SDR_MAX_SINGLE_READ : remaining_bytes;
  279. get_sdr_req.ReservationID = (reservation_id);
  280. get_sdr_req.RecID = ( record_id );
  281. get_sdr_req.Offset = offset;
  282. get_sdr_req.Size = bytes_to_read;
  283. dwRetLen = bytes_to_read + sizeof(GetSDRRes_T);
  284. wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, (GetSDRRes_T*)&data_buffer[0],
  285. &dwRetLen, timeout );
  286. if(wRet != LIBIPMI_E_SUCCESS)
  287. return wRet;
  288. memcpy(&output_buffer[output_buffer_ix], &data_buffer[sizeof(GetSDRRes_T)], bytes_to_read);
  289. output_buffer_ix += bytes_to_read;
  290. offset += bytes_to_read;
  291. remaining_bytes -= bytes_to_read;
  292. }while( remaining_bytes > 0 );
  293. sdr_record = (SDRRecHdr_T*)&output_buffer[sizeof(GetSDRRes_T)];
  294. *dwRecordLen = sdr_record->Len + sizeof(SDRRecHdr_T);
  295. return LIBIPMI_E_SUCCESS;
  296. }
  297. uint16_t LIBIPMI_HL_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  298. uint16_t reservation_id,
  299. uint16_t record_id,
  300. GetSDRRes_T *pGetSDRRes,
  301. uint32_t *dwDataLen,
  302. int timeout )
  303. {
  304. uint16_t wRet=LIBIPMI_E_SUCCESS;
  305. // if( pUDSSession->byMediumType == IPMB_MEDIUM )
  306. // {
  307. // wRet = ipmb_get_sdr(pUDSSession, reservation_id,
  308. // record_id,
  309. // pGetSDRRes,
  310. // dwDataLen,
  311. // timeout );
  312. // }
  313. // else
  314. {
  315. GetSDRReq_T get_sdr_req;
  316. get_sdr_req.ReservationID = (reservation_id);
  317. get_sdr_req.RecID = ( record_id );
  318. get_sdr_req.Offset = 0;
  319. get_sdr_req.Size = 0xff;
  320. wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, pGetSDRRes,
  321. dwDataLen, timeout );
  322. }
  323. return wRet;
  324. }
  325. uint16_t LIBIPMI_HL_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  326. uint16_t record_id,
  327. uint16_t *next_record_id,
  328. uint8_t *sdr_buffer,
  329. size_t buffer_len,
  330. int timeout )
  331. {
  332. uint16_t wRet;
  333. ReserveSDRRepositoryRes_T reservation;
  334. SDRRepositoryAllocInfo_T alloc_info;
  335. uint8_t *temp_buffer;
  336. GetSDRRes_T *get_sdr_res;
  337. uint32_t blen = 0;
  338. int max_sdr_len;
  339. /* Get repository allocation information */
  340. wRet = IPMICMD_GetSDRRepositoryAllocInfo( pUDSSession, &alloc_info, timeout );
  341. if( wRet != LIBIPMI_E_SUCCESS )
  342. return( wRet );
  343. reservation.ReservationID = 0; //Setting reservation ID as zero as we are trying to get complete SDR.
  344. /* Determine max SDR entry length */
  345. max_sdr_len = alloc_info.MaxRecSize * ( alloc_info.AllocUnitSize );
  346. /* Make sure the calling function has space for this thing */
  347. if( buffer_len < (size_t) max_sdr_len )
  348. return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
  349. temp_buffer = (uint8_t*)walloc( max_sdr_len + sizeof( GetSDRRes_T ) );
  350. if( temp_buffer == NULL )
  351. return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
  352. get_sdr_res = (GetSDRRes_T *)temp_buffer;
  353. wRet = LIBIPMI_HL_GetSDR(pUDSSession, (reservation.ReservationID),
  354. record_id, (GetSDRRes_T *)temp_buffer, &blen, timeout);
  355. if( wRet != LIBIPMI_E_SUCCESS )
  356. {
  357. printf("---> LIBIPMI_HL_GetSDR error!\n");
  358. wfree( temp_buffer );
  359. return( wRet );
  360. }
  361. *next_record_id = ( get_sdr_res->NextRecID );
  362. memcpy( sdr_buffer, temp_buffer + sizeof( GetSDRRes_T ), blen );
  363. wfree( temp_buffer );
  364. return( wRet );
  365. }
  366. uint16_t LIBIPMI_HL_GetAllSDRs( IPMI20_UDS_SESSION_T *pUDSSession,
  367. uint8_t *sdr_buffer, size_t buffer_len,
  368. int timeout )
  369. {
  370. uint16_t wRet;
  371. uint16_t record_id = 0;
  372. int max_sdr_len;
  373. int sdr_count;
  374. SDRRepositoryAllocInfo_T alloc_info;
  375. SDRRepositoryInfo_T repo_info;
  376. int i;
  377. /* Get repository allocation information */
  378. wRet = IPMICMD_GetSDRRepositoryAllocInfo( pUDSSession, &alloc_info, timeout );
  379. if( wRet != LIBIPMI_E_SUCCESS )
  380. return( wRet );
  381. /* Get repository information */
  382. wRet = IPMICMD_GetSDRRepositoryInfo( pUDSSession, &repo_info, timeout );
  383. if( wRet != LIBIPMI_E_SUCCESS )
  384. return( -1 );
  385. /* Determine max SDR entry length */
  386. max_sdr_len = alloc_info.MaxRecSize * ( alloc_info.AllocUnitSize );
  387. /* Determine total number of SDRs stored */
  388. sdr_count = ( repo_info.RecCt );
  389. /* Make sure the passed buffer is large enough */
  390. if( buffer_len < (size_t) ( max_sdr_len * sdr_count ) )
  391. return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
  392. //printf("---> LIBIPMI_HL_GetAllSDRs, max_sdr_len: %d, sdr_count: %d\n", max_sdr_len, sdr_count);
  393. /* Read all the SDRs in this loop */
  394. for( i = 0; i < sdr_count; i++ )
  395. {
  396. uint16_t next_record_id;
  397. /* Read the full SDR into the buffer */
  398. wRet = LIBIPMI_HL_GetCompleteSDR( pUDSSession, record_id, &next_record_id,
  399. &sdr_buffer[ i * max_sdr_len ],
  400. max_sdr_len, timeout );
  401. //printf("---> i: %d, record_id: %d, next_record_id: %d\n", i, record_id, next_record_id);
  402. if( wRet != LIBIPMI_E_SUCCESS )
  403. return( wRet );
  404. record_id = next_record_id;
  405. }
  406. return( wRet );
  407. }
  408. //int CacheGetAllSDRS(IPMI20_UDS_SESSION_T* pUDSSession,uint8_t* sdr_buffer,uint32_t* buff_size,uint32_t* max_sdr_len,uint32_t* sdr_count);
  409. uint16_t LIBIPMI_HL_GetAllSDRs_Cached( IPMI20_UDS_SESSION_T *pUDSSession,
  410. uint8_t *sdr_buffer,
  411. uint32_t* sdr_buff_size,
  412. uint32_t* max_sdr_len,
  413. uint32_t * sdr_count,
  414. int timeout )
  415. {
  416. uint16_t wRet;
  417. // wRet = CacheGetAllSDRS(pUDSSession,sdr_buffer,sdr_buff_size,max_sdr_len,sdr_count);
  418. return wRet;
  419. }
  420. uint16_t LIBIPMI_HL_GetSpecificSDR( IPMI20_UDS_SESSION_T *pUDSSession,
  421. uint8_t *sdr_buffer,
  422. uint32_t* sdr_buff_size,
  423. int SensorNumber,
  424. int timeout )
  425. {
  426. ReserveSDRRepositoryRes_T ResReserveSDRRepository;
  427. uint8_t *data_buffer = walloc(255);
  428. FullSensorRec_T *sdr_record = (FullSensorRec_T*) &data_buffer[sizeof(GetSDRRes_T)];
  429. GetSDRReq_T ReqGetSDR;
  430. GetSDRRes_T *pResGetSDR = (GetSDRRes_T *) &data_buffer[0];
  431. uint32_t dwRetLen = 255; //sizeof(data_buffer);
  432. int wRet = 0;
  433. wRet = IPMICMD_ReserveSDRRepository(pUDSSession, &ResReserveSDRRepository, timeout);
  434. pResGetSDR->NextRecID = 0;
  435. while (1)
  436. {
  437. ReqGetSDR.ReservationID = ResReserveSDRRepository.ReservationID;
  438. ReqGetSDR.RecID = pResGetSDR->NextRecID;
  439. ReqGetSDR.Offset = 0;
  440. ReqGetSDR.Size = 0xff;
  441. wRet = IPMICMD_GetSDR(pUDSSession, &ReqGetSDR, pResGetSDR, &dwRetLen, timeout);
  442. //TODO: IPMICMD_GetSDR replaced by LIBIPMI_HL_GetSDR, by jimbo
  443. //wRet = LIBIPMI_HL_GetSDR(pUDSSession, ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
  444. if (wRet != LIBIPMI_E_SUCCESS)
  445. {
  446. printf("Get SDR error!\n");
  447. break;
  448. }
  449. if (sdr_record->SensorNum == SensorNumber)
  450. {
  451. //printf("Find %d: %s\n", sdr_record->SensorNum , sdr_record->IDStr);
  452. break; // found
  453. }
  454. }
  455. dwRetLen -= sizeof(GetSDRRes_T);
  456. *sdr_buff_size = *sdr_buff_size >= dwRetLen ? dwRetLen : *sdr_buff_size;
  457. memcpy(sdr_buffer, sdr_record, *sdr_buff_size);
  458. //printf("sdr_buff_size: %d\n", *sdr_buff_size);
  459. wfree(data_buffer);
  460. return wRet;
  461. }