浏览代码

Resolve GetAllSELEntriesSorted failed problem

zhangbo 5 年之前
父节点
当前提交
740066efe8

二进制
app/UpdateFirmware/updateFW_app


二进制
app/bmc/bmc_app


+ 3 - 3
app/goahead-3.6.5/src/libipmi/inc/libipmi_StorDevice.h

@@ -142,9 +142,9 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
 		// 		uint8_t *nFRUs,
 		// 		int timeout);
 
- //  uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession,
-	// SELEventRecordWithSensorName_T *pSELEntriesBuffer,
-	// int timeout);
+  uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession,
+	SELEventRecordWithSensorName_T *pSELEntriesBuffer,
+	int timeout);
 
   uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 				int timeout);

+ 4 - 1
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -9,6 +9,7 @@
 #include "libipmi_struct.h"
 #include <stdint.h>
 #include "com_BmcType.h"
+#include "libipmi_StorDevice.h"
 
 #define MAX_TITLE_LEN	20
 #define MAX_TEXT_LEN		256
@@ -87,6 +88,8 @@ typedef struct{
 	uint8_t SensorHistoryEnable;
 } SensorHistoryCapability_T;
 
+#pragma pack()
+
 extern OemWebFlags_T g_OemWebFlags;
 //uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);
 
@@ -104,7 +107,7 @@ int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo
 //int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout);
 //int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t* SensorHistoryEnable, int timeout);
 //int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);
+uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout);
 
-#pragma pack()
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 5 - 8
app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c

@@ -29,6 +29,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "goahead.h"
+
 /* Helper function */
 uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
 {
@@ -509,10 +511,6 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 					SELEventRecordWithSensorName_T *pSELEntriesBuffer,
 					int timeout)
 {
-
-	// first SEL record and complete record,
-	// starting at offset 0 of each record.
-	//uint32_t DataLen = 0;
 	uint16_t wRet = 0;
 	SDRRepositoryAllocInfo_T SDRAllocationInfo;
 	SDRRepositoryInfo_T SDRReposInfo;
@@ -524,7 +522,7 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 	uint32_t nNumSelEntries = 0;
 	int q = 0;
 
-
+	
 	/***********************************Get all Sel Entries now*********************************************/
 	/* We want to read full records */
 	//DataLen = sizeof(GetSELRes_T) + sizeof(SELEventRecord_T);
@@ -565,7 +563,7 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 	printf("---> SDRCount: %d, MaxSDRLen: %d\n", SDRCount, MaxSDRLen);
 
 	/* Allocate the buffer */
-	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
+	pSDRBuff = (uint8_t *) walloc(MaxSDRLen * SDRCount);
 	if(!pSDRBuff)
 	{
 		printf("Error allocating memopry for SDRs in GetAllEventsWithSensorNames\n");
@@ -580,7 +578,6 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
                                      timeout*4);
 
 	/*************************************Get The SDR once so that we can get sensor names*******************/
-
 	/******************Now parse through sensor headers and get names corresponding to each event************/
 	for(q=0;q<nNumSelEntries;q++)
 	{
@@ -630,7 +627,7 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 			pSDRBuff += MaxSDRLen;
 		}
 	}
-	free(pSDRStart);
+	wfree(pSDRStart);
 	return wRet;
 }
 

+ 1 - 1
app/goahead-3.6.5/src/libipmi/src/libipmi_sdr.c

@@ -23,6 +23,7 @@
 #include "libipmi_errorcodes.h"
 #include "libipmi_sdr.h"
 #include "com_IPMI_Storage.h"
+#include "goahead.h"
 
 
 
@@ -69,7 +70,6 @@
                                             (uint8_t*)Req, 0,
                                             (uint8_t *)pResGetSDRRepositoryAllocInfo, &dwResLen,
                                             timeout);
-
     return wRet;
 }
 

+ 11 - 11
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -7,6 +7,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "goahead.h"
+
 #include "libipmi_AppDevice.h"
 #include "libipmi_session.h"
 #include "libipmi_errorcodes.h"
@@ -646,8 +648,9 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 	int j=0;
 	uint16_t i=0,recindex=0;
 	uint16_t LastRecID = 0xFFFF,MaxSELEntries=0;
+	uint32_t max_sel_len = MAX_SEL_RECORD*sizeof(SELRec_T) + sizeof(AMIGetSELEntriesRes_T) + 256;//margin
 	
-	SELEntries = (uint8_t *)malloc(MAX_SEL_RECORD);
+	SELEntries = (uint8_t *)walloc(max_sel_len);
 	if(SELEntries == NULL)
 	{
 		printf("Memory allocation error in LIBIPMI_HL_AMIGetSELEntires \n");
@@ -655,7 +658,7 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 		return wRet;
 	}
 	
-	memset(SELEntries,0,MAX_SEL_RECORD);
+	memset(SELEntries,0,max_sel_len);
 	pAMIGetSelEntiresRes = (AMIGetSELEntriesRes_T *)SELEntries;
 	
 	do
@@ -665,7 +668,7 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 		{
 			for(i = 0; i < pAMIGetSelEntiresRes->Noofentries; i++)
 			{
-				memcpy((uint8_t *)&pSELEntriesBuffer[i+*nNumSelEntries].EventRecord,&(SELEntries)[sizeof(AMIGetSELEntriesRes_T) + (i * sizeof(SELRec_T))],
+				memcpy((uint8_t *)&pSELEntriesBuffer[i+*nNumSelEntries].EventRecord,&(SELEntries[sizeof(AMIGetSELEntriesRes_T) + (i * sizeof(SELRec_T))]),
 							   sizeof(SELRec_T));
 			}
 	
@@ -683,13 +686,13 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 			{
 				*nNumSelEntries += pAMIGetSelEntiresRes->Noofentries;
 				pAMIGetSelEntriesReq.Noofentretrieved = *nNumSelEntries;
-				memset(SELEntries,0,MAX_SEL_RECORD);
+				memset(SELEntries,0,max_sel_len);
 				continue;
 			}
 		}
 		else if((wRet & 0xFF) == LIBIPMI_E_SEL_CLEARED)
 		{
-			memset(SELEntries,0,MAX_SEL_RECORD);
+			memset(SELEntries,0,max_sel_len);
 			memset((uint8_t*)&pSELEntriesBuffer[0],0,sizeof(SELEventRecordWithSensorName_T) * *nNumSelEntries);
 			*nNumSelEntries =  pAMIGetSelEntriesReq.Noofentretrieved = 0;
 			continue;
@@ -707,8 +710,7 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 		}
 	}while(1);
 	
-	free(SELEntries);
-	
+	wfree(SELEntries);
 	
 	if(wRet == LIBIPMI_E_SUCCESS)
 	{
@@ -736,7 +738,7 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 					}
 	
 					/*SEL Records added lastely will be displayed first */
-					CircSELEntries = (SELEventRecordWithSensorName_T *)malloc (sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
+					CircSELEntries = (SELEventRecordWithSensorName_T *)walloc (sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
 					if(CircSELEntries != NULL)
 					{
 						memset(CircSELEntries,0,sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
@@ -756,13 +758,11 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 						{
 							memcpy((uint8_t*)&pSELEntriesBuffer[i],(uint8_t*)&CircSELEntries[*nNumSelEntries - j],sizeof(SELEventRecordWithSensorName_T));
 						}
-	
-						free(CircSELEntries);
+						wfree(CircSELEntries);
 					}
 				}
 			}
 		}
 	}
-	
 	return (wRet);
 }

+ 19 - 38
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -62,7 +62,7 @@ void GetAllSELEntriesSorted(Webs *wp)
 	int wRet = 0;
 	unsigned short nEntries = 0;
 	SELEventRecordWithSensorName_T *pSELBuff = NULL;
-	uint8 *pStartBuff = NULL;
+	//uint8 *pStartBuff = NULL;
 	uint16 nMaxEntries = 0;
 	IPMI20_UDS_SESSION_T    UDSSession;
 	
@@ -108,33 +108,13 @@ void GetAllSELEntriesSorted(Webs *wp)
 		pSELBuff = (SELEventRecordWithSensorName_T *) walloc(nMaxEntries * sizeof(SELEventRecordWithSensorName_T));
 		if(pSELBuff == NULL)
 		{
-			char *pStr;
-		    int code = 200;
-		    cJSON *root =  cJSON_CreateObject();
-		    cJSON  *pJsonArry,*pJsonsub;
-		    pJsonArry=cJSON_CreateArray();   /*创建数组*/
-		    cJSON_AddItemToObject(root, "data", pJsonArry);
-		    pStr = cJSON_PrintUnformatted(root);
-		    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
-
-		    websSetStatus(wp, 200);
-		    websWriteHeaders(wp, -1, 0);
-		    websWriteEndHeaders(wp); 
-		    websWrite(wp, pStr);
-		    websDone(wp);
-
-			// printf("Error allocating memory for SEL entries!!\n");
-			// wRet = -1;
-			// goto error_out;
-			return;
+			goto error_out;
 		}
-		pStartBuff = (uint8 *)pSELBuff;
+		//pStartBuff = (uint8 *)pSELBuff;
 
 		printf("before get all sel entried\n");
 		/* Now pass this buffer pointer to the function to get all SEL entries */
 		wRet = LIBIPMI_HL_GetAllSelEntriesWithSensorNames(&UDSSession, pSELBuff, DEFAULT_TIMEOUT);
-		//Close session
-    	LIBIPMI_CloseSession(&UDSSession );
 
 		if(wRet == 0)
 		{
@@ -170,17 +150,21 @@ void GetAllSELEntriesSorted(Webs *wp)
 		    websWrite(wp, pStr);
 		    websDone(wp);
 
-		    if(root)
-		        cJSON_Delete(root);
-		    if(pStr)
-		    	wfree(pStr);
+		    
 		} else {
 			printf("Error reading All SEL entries\n");
-		}
-		wfree(pStartBuff);
+		}		
 	}
 
+	//Close session
+    LIBIPMI_CloseSession(&UDSSession );
 	
+	if(root)
+        cJSON_Delete(root);
+    if(pStr)
+    	wfree(pStr);
+   	if(pSELBuff)
+		wfree(pSELBuff);
 
 	return;
 
@@ -188,15 +172,12 @@ error_out:
 	//Close session
     LIBIPMI_CloseSession(&UDSSession );
 	websError(wp, 404, "Get SEL error!");
-	// cJSON_AddItemToObject(root, "data", pJsonArry);
- //    pStr = cJSON_PrintUnformatted(root);
- //    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
-
- //    websSetStatus(wp, 200);
- //    websWriteHeaders(wp, -1, 0);
- //    websWriteEndHeaders(wp); 
- //    websWrite(wp, pStr);
- //    websDone(wp);
+	if(root)
+        cJSON_Delete(root);
+    if(pStr)
+    	wfree(pStr);
+   	if(pSELBuff)
+		wfree(pSELBuff);
 
 }
 

二进制
app/ipmitool-1.8.18/ipmitool


二进制
app/test_app/test_app