Ver código fonte

New FRU function

zhangbo 5 anos atrás
pai
commit
c7b07bb49f

BIN
app/bmc/bmc_app


+ 9 - 9
app/bmc/msghndlr/MsgHndlrTask.c

@@ -132,11 +132,11 @@ void *MsgHndlrTask( void *pArg )
 	while(1)
 	{
 		while(GetMsg(gFd_MsgHndlrIfc, &reqMsgPkt, WAIT_INFINITE) != 0);
-		printf("Mrx: ");
-		int i;
-		for(i=0;i<reqMsgPkt.Size;i++)
-			printf("%#x ", reqMsgPkt.Data[i]);
-		printf("\n");
+		// printf("Mrx: ");
+		// int i;
+		// for(i=0;i<reqMsgPkt.Size;i++)
+		// 	printf("%#x ", reqMsgPkt.Data[i]);
+		// printf("\n");
 
 		pthread_setspecific(g_tls.CurChannel,&reqMsgPkt.Channel);
 		pthread_setspecific(g_tls.CurPrivLevel,&reqMsgPkt.Privilege);
@@ -167,10 +167,10 @@ void *MsgHndlrTask( void *pArg )
 			
 			resMsgPkt.SessionID = reqMsgPkt.SessionID;
 		}
-		printf("Mtx: ");
-		for(i=0;i<resMsgPkt.Size;i++)
-			printf("%#x ", resMsgPkt.Data[i]);
-		printf("\n");
+		// printf("Mtx: ");
+		// for(i=0;i<resMsgPkt.Size;i++)
+		// 	printf("%#x ", resMsgPkt.Data[i]);
+		// printf("\n");
 
 		//send response pkt to source queue.
 		PostMsg(resMsgPkt.SrcQ, &resMsgPkt);

BIN
app/goahead-3.6.5/build/linux-arm-static/bin/goahead


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/gopass


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/libgo.a


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/libgoahead-mbedtls.a


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/libmbedtls.a


+ 5 - 0
app/goahead-3.6.5/build/linux-arm-static/inc/fru.h

@@ -2,5 +2,10 @@
 #define __FRU_H__
 
 #include "goahead.h"
+//void getFruInfo(Webs *wp);
+
+void getFruChassisInfo(Webs *wp);
+void getFruBoardInfo(Webs *wp);
+void getFruProductInfo(Webs *wp);
 
 #endif /* __FRU_H__ */

+ 13 - 13
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_StorDevice.h

@@ -76,11 +76,11 @@ extern "C" {
 					uint8_t SensorNum,
 					uint8_t *SensorName,
 					int timeout);
-uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint8_t *pFRUIDs,
-					uint8_t *nFRUs,
-					uint8_t nFRUsName[][16],
-					int timeout);
+// uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					uint8_t *pFRUIDs,
+// 					uint8_t *nFRUs,
+// 					uint8_t nFRUsName[][16],
+// 					int timeout);
 
 /*****************************************************************************
 	Field Replacement Unit (FRU)
@@ -136,15 +136,15 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
 				FRUWriteRes_T* pFRUWriteResData,
 				int timeout);
 
-  uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
-				uint8_t *pFRUIDs,
-				uint8_t *pFRUNames,
-				uint8_t *nFRUs,
-				int timeout);
+  // uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
+		// 		uint8_t *pFRUIDs,
+		// 		uint8_t *pFRUNames,
+		// 		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);

+ 21 - 8
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_fru.h

@@ -30,6 +30,7 @@
 #include "libipmi_sensor.h"
 #include "com_IPMI_SDRRecord.h"
 #include "com_IPMI_FRU.h"
+#include "com_BmcType.h"
 
 
 typedef struct
@@ -82,14 +83,26 @@ typedef struct fru_t
 
 }FRU_T;
 
-
-  uint16_t LIBIPMI_HL_GetFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint8_t fru_device_id,
-				  	uint32_t* p_fru_size,
-				  	FRUData_T* fru_data,
-					int timeout);
-
-void LIBIPMI_HL_FreeFRUData(FRUData_T* fru_data);
+// uint16_t LIBIPMI_HL_GetFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					uint8_t fru_device_id,
+// 				  	uint32_t* p_fru_size,
+// 				  	OemFRUData_T* fru_data,
+// 					int timeout);
+uint16_t LIBIPMI_HL_GetFRUChassisData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUChassisInfo_T* chassis_data,
+                    int timeout);
+uint16_t LIBIPMI_HL_GetFRUBoardData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUBoardInfo_T* board_data,
+                    int timeout);
+uint16_t LIBIPMI_HL_GetFRUProductData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUProductInfo_T* product_data,
+                    int timeout);
 
 #pragma pack()
 #endif

+ 4 - 4
app/goahead-3.6.5/build/linux-arm-static/inc/me.h

@@ -112,7 +112,7 @@
     #define ME_GOAHEAD_DIGEST 1
 #endif
 #ifndef ME_GOAHEAD_DOCUMENTS
-    #define ME_GOAHEAD_DOCUMENTS "web"
+    #define ME_GOAHEAD_DOCUMENTS "/var/www/goahead"
 #endif
 #ifndef ME_GOAHEAD_JAVASCRIPT
     #define ME_GOAHEAD_JAVASCRIPT 1
@@ -193,7 +193,7 @@
     #define ME_GOAHEAD_SSL_CACHE 512
 #endif
 #ifndef ME_GOAHEAD_SSL_CERTIFICATE
-    #define ME_GOAHEAD_SSL_CERTIFICATE "self.crt"
+    #define ME_GOAHEAD_SSL_CERTIFICATE "/etc/goahead/self.crt"
 #endif
 #ifndef ME_GOAHEAD_SSL_CIPHERS
     #define ME_GOAHEAD_SSL_CIPHERS ""
@@ -202,7 +202,7 @@
     #define ME_GOAHEAD_SSL_HANDSHAKES 1
 #endif
 #ifndef ME_GOAHEAD_SSL_KEY
-    #define ME_GOAHEAD_SSL_KEY "self.key"
+    #define ME_GOAHEAD_SSL_KEY "/etc/goahead/self.key"  //jimbo
 #endif
 #ifndef ME_GOAHEAD_SSL_LOG_LEVEL
     #define ME_GOAHEAD_SSL_LOG_LEVEL 5
@@ -273,7 +273,7 @@
     #define ME_BASE_PREFIX "/usr/local"
 #endif
 #ifndef ME_DATA_PREFIX
-    #define ME_DATA_PREFIX "/"
+    #define ME_DATA_PREFIX "/etc/goahead"   //"/"
 #endif
 #ifndef ME_STATE_PREFIX
     #define ME_STATE_PREFIX "/var"

+ 4 - 4
app/goahead-3.6.5/projects/goahead-linux-static-me.h

@@ -112,7 +112,7 @@
     #define ME_GOAHEAD_DIGEST 1
 #endif
 #ifndef ME_GOAHEAD_DOCUMENTS
-    #define ME_GOAHEAD_DOCUMENTS "web"
+    #define ME_GOAHEAD_DOCUMENTS "/var/www/goahead"
 #endif
 #ifndef ME_GOAHEAD_JAVASCRIPT
     #define ME_GOAHEAD_JAVASCRIPT 1
@@ -193,7 +193,7 @@
     #define ME_GOAHEAD_SSL_CACHE 512
 #endif
 #ifndef ME_GOAHEAD_SSL_CERTIFICATE
-    #define ME_GOAHEAD_SSL_CERTIFICATE "self.crt"
+    #define ME_GOAHEAD_SSL_CERTIFICATE "/etc/goahead/self.crt"
 #endif
 #ifndef ME_GOAHEAD_SSL_CIPHERS
     #define ME_GOAHEAD_SSL_CIPHERS ""
@@ -202,7 +202,7 @@
     #define ME_GOAHEAD_SSL_HANDSHAKES 1
 #endif
 #ifndef ME_GOAHEAD_SSL_KEY
-    #define ME_GOAHEAD_SSL_KEY "self.key"
+    #define ME_GOAHEAD_SSL_KEY "/etc/goahead/self.key"  //jimbo
 #endif
 #ifndef ME_GOAHEAD_SSL_LOG_LEVEL
     #define ME_GOAHEAD_SSL_LOG_LEVEL 5
@@ -273,7 +273,7 @@
     #define ME_BASE_PREFIX "/usr/local"
 #endif
 #ifndef ME_DATA_PREFIX
-    #define ME_DATA_PREFIX "/"
+    #define ME_DATA_PREFIX "/etc/goahead"   //"/"
 #endif
 #ifndef ME_STATE_PREFIX
     #define ME_STATE_PREFIX "/var"

+ 9 - 0
app/goahead-3.6.5/projects/goahead-linux-static.mk

@@ -562,6 +562,13 @@ $(BUILD)/obj/sensor_helpers.o: \
 		-D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" \
 		-DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) \
 		"-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/sensor_helpers.c
+$(BUILD)/obj/libipmi_StorDevice.o: \
+    src/libipmi/src/libipmi_StorDevice.c $(DEPS_USER_C2)
+	@echo '   [Compile] $(BUILD)/obj/libipmi_StorDevice.o'
+	$(CC) -c -o $(BUILD)/obj/libipmi_StorDevice.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) \
+		-D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" \
+		-DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) \
+		"-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_StorDevice.c
 
 
 DEPS_USER_C3 += $(BUILD)/inc/goahead.h
@@ -1003,6 +1010,7 @@ DEPS_36 += $(BUILD)/obj/libipmi_sdr.o
 DEPS_36 += $(BUILD)/obj/libipmi_sensor.o
 DEPS_36 += $(BUILD)/obj/libipmi_storlead_OEM.o
 DEPS_36 += $(BUILD)/obj/sensor_helpers.o
+DEPS_36 += $(BUILD)/obj/libipmi_StorDevice.o
 
 ## resultUtils
 DEPS_36 += $(BUILD)/obj/ResultUtils.o
@@ -1026,6 +1034,7 @@ $(BUILD)/bin/libgo.a: $(DEPS_36)
 		"$(BUILD)/obj/libipmi_uds_session.o" "$(BUILD)/obj/libipmi_IPM.o" "$(BUILD)/obj/libipmi_fru.o" \
 		"$(BUILD)/obj/libipmi_Chassis.o" "$(BUILD)/obj/libipmi_PEF.o" "$(BUILD)/obj/libipmi_sdr.o" \
 		"$(BUILD)/obj/libipmi_sensor.o" "$(BUILD)/obj/libipmi_storlead_OEM.o" "$(BUILD)/obj/sensor_helpers.o"  \
+		"$(BUILD)/obj/libipmi_StorDevice.o"  \
 		"$(BUILD)/obj/config.o" "$(BUILD)/obj/dashboard.o" "$(BUILD)/obj/fan.o" "$(BUILD)/obj/fru.o" \
 		"$(BUILD)/obj/fw_update.o" "$(BUILD)/obj/remote_control.o" "$(BUILD)/obj/sel.o" \
 		"$(BUILD)/obj/server_health.o" 

+ 7 - 4
app/goahead-3.6.5/src/goahead.c

@@ -62,8 +62,8 @@ MAIN(goahead, int argc, char **argv, char **envp)
         return 0;
     }
 #endif
-    route = "route.txt";
-    auth = "auth.txt";
+    route = "/etc/goahead/route.txt";
+    auth = "/etc/goahead/auth.txt";
 
 /**************** user code before goahead ************************/   
     cJSON_Hooks hooks;
@@ -180,8 +180,11 @@ websDefineAction("getSensorInfo", getSensorInfo);
 //remote control
 websDefineAction("chassisPwrCtrl", chassisPwrCtrl);
 websDefineAction("getChassisStatus", getChassisStatus);
-
- 
+//Fru 
+//websDefineAction("getFruInfo", getFruInfo);
+websDefineAction("getFruChassisInfo", getFruChassisInfo);
+websDefineAction("getFruBoardInfo", getFruBoardInfo);
+websDefineAction("getFruProductInfo", getFruProductInfo);
 
 
 

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

@@ -76,11 +76,11 @@ extern "C" {
 					uint8_t SensorNum,
 					uint8_t *SensorName,
 					int timeout);
-uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint8_t *pFRUIDs,
-					uint8_t *nFRUs,
-					uint8_t nFRUsName[][16],
-					int timeout);
+// uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					uint8_t *pFRUIDs,
+// 					uint8_t *nFRUs,
+// 					uint8_t nFRUsName[][16],
+// 					int timeout);
 
 /*****************************************************************************
 	Field Replacement Unit (FRU)
@@ -136,15 +136,15 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
 				FRUWriteRes_T* pFRUWriteResData,
 				int timeout);
 
-  uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
-				uint8_t *pFRUIDs,
-				uint8_t *pFRUNames,
-				uint8_t *nFRUs,
-				int timeout);
+  // uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
+		// 		uint8_t *pFRUIDs,
+		// 		uint8_t *pFRUNames,
+		// 		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);

+ 21 - 8
app/goahead-3.6.5/src/libipmi/inc/libipmi_fru.h

@@ -30,6 +30,7 @@
 #include "libipmi_sensor.h"
 #include "com_IPMI_SDRRecord.h"
 #include "com_IPMI_FRU.h"
+#include "com_BmcType.h"
 
 
 typedef struct
@@ -82,14 +83,26 @@ typedef struct fru_t
 
 }FRU_T;
 
-
-  uint16_t LIBIPMI_HL_GetFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint8_t fru_device_id,
-				  	uint32_t* p_fru_size,
-				  	FRUData_T* fru_data,
-					int timeout);
-
-void LIBIPMI_HL_FreeFRUData(FRUData_T* fru_data);
+// uint16_t LIBIPMI_HL_GetFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					uint8_t fru_device_id,
+// 				  	uint32_t* p_fru_size,
+// 				  	OemFRUData_T* fru_data,
+// 					int timeout);
+uint16_t LIBIPMI_HL_GetFRUChassisData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUChassisInfo_T* chassis_data,
+                    int timeout);
+uint16_t LIBIPMI_HL_GetFRUBoardData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUBoardInfo_T* board_data,
+                    int timeout);
+uint16_t LIBIPMI_HL_GetFRUProductData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUProductInfo_T* product_data,
+                    int timeout);
 
 #pragma pack()
 #endif

+ 225 - 223
app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c

@@ -24,7 +24,7 @@
 #include "libipmi_session.h"
 #include "libipmi_errorcodes.h"
 #include "libipmi_StorDevice.h"
-#include "libipmi_AMIOEM.h"
+//#include "libipmi_AMIOEM.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -46,7 +46,7 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
 /*****************************************************************************
 	System Event Log
 ******************************************************************************/
-uint16_t IPMICMD_GetSELInfo(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_GetSELInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 				SELInfo_T *pResGetSELInfo,
 				int timeout)
 {
@@ -56,7 +56,7 @@ uint16_t IPMICMD_GetSELInfo(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SELInfo_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_GET_SEL_INFO,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pResGetSELInfo, &dwResLen,
@@ -66,7 +66,7 @@ uint16_t IPMICMD_GetSELInfo(IPMI20_SESSION_T *pSession,
 
 
 
-uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELAllocInfo_T *pResGetSELAllocInfo,
 					int timeout)
 {
@@ -76,7 +76,7 @@ uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SELAllocInfo_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_GET_SEL_ALLOCATION_INFO,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pResGetSELAllocInfo, &dwResLen,
@@ -85,7 +85,7 @@ uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_SESSION_T *pSession,
 }
 
 /* This function reserves SEL and returns SEL reservation ID */
-uint16_t IPMICMD_ReserveSEL(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 					ReserveSELRes_T* pReserveSelRes,
 					int timeout)
 {
@@ -95,7 +95,7 @@ uint16_t IPMICMD_ReserveSEL(IPMI20_SESSION_T *pSession,
 	memset(pReserveSelRes, 0, sizeof(ReserveSELRes_T));
 
 	dwResLen = sizeof(ReserveSELRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)pReserveSelRes, &dwResLen,
@@ -118,7 +118,7 @@ uint16_t IPMICMD_ReserveSEL(IPMI20_SESSION_T *pSession,
 }
 
 /* This function gets an entry from SEL. */
-uint16_t IPMICMD_GetSELEntry(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELReq_T* pGetSELReqData,
 				uint8_t* pGetSELResData,
 				uint32_t ResDataLen,
@@ -127,7 +127,7 @@ uint16_t IPMICMD_GetSELEntry(IPMI20_SESSION_T *pSession,
 	uint16_t wRet = 0;
 	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_GET_SEL_ENTRY,
 						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
 						(uint8_t *)pGetSELResData, &ResDataLen,
@@ -136,7 +136,7 @@ uint16_t IPMICMD_GetSELEntry(IPMI20_SESSION_T *pSession,
 }
 
 /* This function adds an entry into SEL. */
-uint16_t IPMICMD_AddSELEntry(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				SELEventRecord_T* pSELReqData,
 				AddSELRes_T* pSELResData,
 				int timeout)
@@ -146,7 +146,7 @@ uint16_t IPMICMD_AddSELEntry(IPMI20_SESSION_T *pSession,
 	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(AddSELRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_ADD_SEL_ENTRY,
 						(uint8_t*)pSELReqData, sizeof(SELEventRecord_T),
 						(uint8_t *)pSELResData, &dwResLen,
@@ -155,7 +155,7 @@ uint16_t IPMICMD_AddSELEntry(IPMI20_SESSION_T *pSession,
 }
 
 /* This function deletes an entry from SEL. */
-uint16_t IPMICMD_DeleteSELEntry(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				uint16_t RecordID,
 				int timeout)
 {
@@ -171,7 +171,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_SESSION_T *pSession,
 
 	//first do a SEL reservation
 	dwResLen = sizeof(ReserveSELRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
@@ -195,7 +195,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_SESSION_T *pSession,
 
 	DeleteSELReqData.RecID = RecordID;
 
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						(NETFN_STORAGE << 2), CMD_DELETE_SEL_ENTRY,
 						(uint8_t*)&DeleteSELReqData, sizeof(DeleteSELReqData),
 						(uint8_t *)&DeleteSELResData, &dwResLen,
@@ -203,7 +203,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint16_t IPMICMD_ClearSEL(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 				int timeout)
 {
 	uint16_t	wRet;
@@ -218,7 +218,7 @@ uint16_t IPMICMD_ClearSEL(IPMI20_SESSION_T *pSession,
 
 	//first do a SEL reservation
  	dwResLen = sizeof(ReserveSELRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_RESERVE_SEL,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
@@ -247,7 +247,7 @@ uint16_t IPMICMD_ClearSEL(IPMI20_SESSION_T *pSession,
 	ClearSelReq.InitOrStatus = 0xAA;
 
 	dwResLen = sizeof(ClearSELRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_CLEAR_SEL,
 						(uint8_t*)&ClearSelReq, sizeof(ClearSELReq_T),
 						(uint8_t *)&ClearSelRes, &dwResLen,
@@ -258,38 +258,38 @@ uint16_t IPMICMD_ClearSEL(IPMI20_SESSION_T *pSession,
 *****************************Higher level commands*****************************
 **************************************************************************************/
 /* This function returns total number of SEL entries present in the system at that time */
-uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_SESSION_T *pSession,
+uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint16_t* nNumOfSELEntries,
 					int timeout)
 {
 	uint16_t wRet = 0;
 	SELInfo_T SELInfo;
 
-	wRet =  IPMICMD_GetSELInfo(pSession,&SELInfo,timeout);
+	wRet =  IPMICMD_GetSELInfo(pUDSSession,&SELInfo,timeout);
 	if(wRet != 0)
 	{
 		printf("LIBIPMI_HL_GetNumOfSELEntries: Error getting SEL info\n");
 		return wRet;
 	}
-	*nNumOfSELEntries = ipmitoh_u16(SELInfo.RecCt);
+	*nNumOfSELEntries =  (SELInfo.RecCt);
 	return wRet;
 }
 
 /* This function returns max possible number of SEL entries in the system at any time */
-uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_SESSION_T *pSession,
+uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 						uint16_t* nMaxPossibleSELEntries,
 						int timeout)
 {
 	uint16_t wRet = 0;
 	SELAllocInfo_T SELAllocInfo;
 
-	wRet =  IPMICMD_GetSELAllocationInfo(pSession,&SELAllocInfo,timeout);
+	wRet =  IPMICMD_GetSELAllocationInfo(pUDSSession,&SELAllocInfo,timeout);
 	if(wRet != 0)
 	{
 		printf("LIBIPMI_HL_GetMaxPossibleSELEntries: Error getting SEL Alloc info\n");
 		return wRet;
 	}
-	*nMaxPossibleSELEntries = ipmitoh_u16(SELAllocInfo.NumAllocUnits);
+	*nMaxPossibleSELEntries =  (SELAllocInfo.NumAllocUnits);
 	return wRet;
 }
 
@@ -302,7 +302,7 @@ uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_SESSION_T *pSession,
    Alternatively, you can call LIBIPMI_HL_GetMaxPossibleSELEntries() to get the maximum possible
    number of SEL entries present in the system at any given time, and allocate the buffer to hold those
    many entries. It's just that this approach would allocate a bigger buffer size. */
-uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_SESSION_T *pSession,
+uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELEventRecord_T *pSELEntriesBuffer,
 					int timeout)
 {
@@ -325,7 +325,7 @@ uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_SESSION_T *pSession,
 	/* Fill in the Record data first */
 	while(1)
 	{
-		wRet = IPMICMD_GetSELEntry(pSession, &GetSELReqData, GetSELResData, DataLen,timeout);
+		wRet = IPMICMD_GetSELEntry(pUDSSession, &GetSELReqData, GetSELResData, DataLen,timeout);
 		if(wRet == LIBIPMI_E_SUCCESS)
 		{
 			ptrToSELRecord = (SELEventRecord_T *) (GetSELResData + sizeof(GetSELRes_T));
@@ -352,7 +352,7 @@ uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_SESSION_T *pSession,
 
 
 					
-uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
+uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint8_t **SDRBuff,
 					int *SDRCount,
 					int *MaxSDRLen,
@@ -366,7 +366,7 @@ uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
     	int SDRCnt = 0;
 
 	/* Get max buffer size to be allocated to read all SDRs in the system */
-	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Allocation Info\n");
@@ -374,7 +374,7 @@ uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
 	}
 	
 	/* Get repository information */
-	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Info\n");
@@ -382,10 +382,10 @@ uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
 	}
 
 	/* Determine max SDR entry length */
-	MaxLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+	MaxLen = SDRAllocationInfo.MaxRecSize *  ( SDRAllocationInfo.AllocUnitSize );
 
 	/* Determine total number of SDRs stored */
-	SDRCnt = ipmitoh_u16( SDRReposInfo.RecCt );
+	SDRCnt =  ( SDRReposInfo.RecCt );
 
 	/* Allocate the buffer */
 	pSDRBuff = (uint8_t *) malloc(MaxLen * SDRCnt);
@@ -396,7 +396,7 @@ uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
 
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
                                      pSDRBuff,(MaxLen * SDRCnt),
                                      timeout*4);
 	*MaxSDRLen=MaxLen;
@@ -406,7 +406,7 @@ uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
+uint16_t LIBIPMI_HL_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint8_t SlaveAdd,
 					uint8_t LUNid,
 					uint8_t SensorNum,
@@ -423,14 +423,14 @@ uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
 	uint8_t *pSDRStart = NULL;
 
 	/* Get max buffer size to be allocated to read all SDRs in the system */
-	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Allocation Info\n");
 		return wRet;
 	}
 	/* Get repository information */
-	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Info\n");
@@ -438,10 +438,10 @@ uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
 	}
 
 	/* Determine max SDR entry length */
-	MaxSDRLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+	MaxSDRLen = SDRAllocationInfo.MaxRecSize *  ( SDRAllocationInfo.AllocUnitSize );
 
 	/* Determine total number of SDRs stored */
-	SDRCount = ipmitoh_u16( SDRReposInfo.RecCt );
+	SDRCount =  ( SDRReposInfo.RecCt );
 
 	/* Allocate the buffer */
 	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
@@ -452,7 +452,7 @@ uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
 	pSDRStart = pSDRBuff;
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
                                      pSDRBuff,(MaxSDRLen * SDRCount),
                                      timeout*4);
 
@@ -497,142 +497,142 @@ uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-/*this function wants to be nice to all nice people in the world who display
-sensor information. Instead of letting them go nuts getting all sel entires first
-an then looping thru all sel entires to go get all the sensor names and then each time to
-get a sensor name read SDR
-it just does that for them
-GetAllSelEntires
-Also GetAllSDR stuff once
-then loop and fill it all up internally*/
-uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_SESSION_T *pSession,
-					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;
-	int MaxSDRLen = 0;
-	int i,SDRCount = 0;
-	uint8_t *pSDRBuff = NULL;
-	SDRHeader *pSDRHeader = NULL;
-	uint8_t *pSDRStart = NULL;
-	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);
-
-	wRet = LIBIPMI_HL_AMIGetSELEntires(pSession,pSELEntriesBuffer,&nNumSelEntries,timeout);
-	if(wRet != LIBIPMI_E_SUCCESS)
-	{
-		printf("LIBIPMI_HL_AMIGetSELEntires : Error getting SEL Entries \n");
-		return wRet;
-	}
-
-
-	/*************************************Get The SDR once so that we can get sensor names*******************/
-	/* Get max buffer size to be allocated to read all SDRs in the system */
-	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
-	if( wRet != 0 )
-	{
-		printf("Error getting SDR Repository Allocation Info\n");
-		return wRet;
-	}
-	/* Get repository information */
-	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
-	if( wRet != 0 )
-	{
-		printf("Error getting SDR Repository Info\n");
-		return wRet;
-	}
-
-	/* Determine max SDR entry length */
-	MaxSDRLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
-
-	/* Determine total number of SDRs stored */
-	SDRCount = ipmitoh_u16( SDRReposInfo.RecCt );
-
-	/* Allocate the buffer */
-	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
-	if(!pSDRBuff)
-	{
-		printf("Error allocating memopry for SDRs in GetAllEventsWithSensorNames\n");
-		wRet = STATUS_CODE(IPMI_ERROR_FLAG,CC_OUT_OF_SPACE);
-		return wRet;
-	}
-	pSDRStart = pSDRBuff;
-
-	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
-                                     pSDRBuff,(MaxSDRLen * SDRCount),
-                                     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++)
-	{
-
-		strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
-
-		pSDRBuff = pSDRStart;
-		for( i = 0; i < SDRCount; i++)
-		{
-			pSDRHeader = (SDRHeader *) pSDRBuff;
-			if((pSDRHeader->RecordType >= 0x01) && (pSDRHeader->RecordType <= 0x03))
-			{
-				/* Compare SlaveAdd and LUNid fields */
-				uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader);
-				uint8_t len = 0;
-
-
-
-				if((pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[0] == *pTmp) && (pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[1] == *(pTmp+1)))
-				{
-
-					/* Now compare the sensor number */
-					if(pSELEntriesBuffer[q].EventRecord.EvtRecord.SensorNum == *(pTmp+2))
-					{
-						/* Get the Name and return */
-						if(pSDRHeader->RecordType == 0x01)
-							pTmp = pSDRBuff + sizeof(SDRHeader) + 42;
-						else if(pSDRHeader->RecordType == 0x02)
-							pTmp = pSDRBuff + sizeof(SDRHeader) + 26;
-						else
-							pTmp = pSDRBuff + sizeof(SDRHeader) + 11;
-
-						len = GetBits(*pTmp,5,0);
-						if(len)
-						{
-							pTmp++;
-
-							memcpy(pSELEntriesBuffer[q].SensorName,pTmp,len);
-							pSELEntriesBuffer[q].SensorName[len] = 0;
-
-						}
-						else
-							strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
-					}
-				}
-			}
-			pSDRBuff += MaxSDRLen;
-		}
-	}
-	free(pSDRStart);
-	return wRet;
-}
+// /*this function wants to be nice to all nice people in the world who display
+// sensor information. Instead of letting them go nuts getting all sel entires first
+// an then looping thru all sel entires to go get all the sensor names and then each time to
+// get a sensor name read SDR
+// it just does that for them
+// GetAllSelEntires
+// Also GetAllSDR stuff once
+// then loop and fill it all up internally*/
+// uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					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;
+// 	int MaxSDRLen = 0;
+// 	int i,SDRCount = 0;
+// 	uint8_t *pSDRBuff = NULL;
+// 	SDRHeader *pSDRHeader = NULL;
+// 	uint8_t *pSDRStart = NULL;
+// 	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);
+
+// 	wRet = LIBIPMI_HL_AMIGetSELEntires(pUDSSession,pSELEntriesBuffer,&nNumSelEntries,timeout);
+// 	if(wRet != LIBIPMI_E_SUCCESS)
+// 	{
+// 		printf("LIBIPMI_HL_AMIGetSELEntires : Error getting SEL Entries \n");
+// 		return wRet;
+// 	}
+
+
+// 	/*************************************Get The SDR once so that we can get sensor names*******************/
+// 	/* Get max buffer size to be allocated to read all SDRs in the system */
+// 	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
+// 	if( wRet != 0 )
+// 	{
+// 		printf("Error getting SDR Repository Allocation Info\n");
+// 		return wRet;
+// 	}
+// 	/* Get repository information */
+// 	wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
+// 	if( wRet != 0 )
+// 	{
+// 		printf("Error getting SDR Repository Info\n");
+// 		return wRet;
+// 	}
+
+// 	/* Determine max SDR entry length */
+// 	MaxSDRLen = SDRAllocationInfo.MaxRecSize *  ( SDRAllocationInfo.AllocUnitSize );
+
+// 	/* Determine total number of SDRs stored */
+// 	SDRCount =  ( SDRReposInfo.RecCt );
+
+// 	/* Allocate the buffer */
+// 	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
+// 	if(!pSDRBuff)
+// 	{
+// 		printf("Error allocating memopry for SDRs in GetAllEventsWithSensorNames\n");
+// 		wRet = STATUS_CODE(IPMI_ERROR_FLAG,CC_OUT_OF_SPACE);
+// 		return wRet;
+// 	}
+// 	pSDRStart = pSDRBuff;
+
+// 	/* Call the function to read all the SDRs into this buffer */
+// 	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
+//                                      pSDRBuff,(MaxSDRLen * SDRCount),
+//                                      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++)
+// 	{
+
+// 		strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
+
+// 		pSDRBuff = pSDRStart;
+// 		for( i = 0; i < SDRCount; i++)
+// 		{
+// 			pSDRHeader = (SDRHeader *) pSDRBuff;
+// 			if((pSDRHeader->RecordType >= 0x01) && (pSDRHeader->RecordType <= 0x03))
+// 			{
+// 				/* Compare SlaveAdd and LUNid fields */
+// 				uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader);
+// 				uint8_t len = 0;
+
+
+
+// 				if((pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[0] == *pTmp) && (pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[1] == *(pTmp+1)))
+// 				{
+
+// 					/* Now compare the sensor number */
+// 					if(pSELEntriesBuffer[q].EventRecord.EvtRecord.SensorNum == *(pTmp+2))
+// 					{
+// 						/* Get the Name and return */
+// 						if(pSDRHeader->RecordType == 0x01)
+// 							pTmp = pSDRBuff + sizeof(SDRHeader) + 42;
+// 						else if(pSDRHeader->RecordType == 0x02)
+// 							pTmp = pSDRBuff + sizeof(SDRHeader) + 26;
+// 						else
+// 							pTmp = pSDRBuff + sizeof(SDRHeader) + 11;
+
+// 						len = GetBits(*pTmp,5,0);
+// 						if(len)
+// 						{
+// 							pTmp++;
+
+// 							memcpy(pSELEntriesBuffer[q].SensorName,pTmp,len);
+// 							pSELEntriesBuffer[q].SensorName[len] = 0;
+
+// 						}
+// 						else
+// 							strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
+// 					}
+// 				}
+// 			}
+// 			pSDRBuff += MaxSDRLen;
+// 		}
+// 	}
+// 	free(pSDRStart);
+// 	return wRet;
+// }
 
 /*****************************************************************************
 	Field Replacement Unit (FRU)
 ******************************************************************************/
-uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 				FRUInventoryAreaInfoReq_T *pReqFRUInventoryAreaInfo,
 				FRUInventoryAreaInfoRes_T *pResFRUInventoryAreaInfo,
 				int timeout)
@@ -642,18 +642,18 @@ uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUInventoryAreaInfoRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_FRU_INVENTORY_AREA_INFO,
 						(uint8_t *)pReqFRUInventoryAreaInfo, sizeof(FRUInventoryAreaInfoReq_T),
 						(uint8_t *)pResFRUInventoryAreaInfo, &dwResLen,
 						timeout);
 	/* Do we need to do the following??? I guess so...test and make sure */
-	tmp = ipmitoh_u16(pResFRUInventoryAreaInfo->Size);
+	tmp =  (pResFRUInventoryAreaInfo->Size);
 	pResFRUInventoryAreaInfo->Size = tmp;
 	return wRet;
 }
 
-uint16_t IPMICMD_ReadFRUData(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_ReadFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 				FRUReadReq_T* pFRUReadReqData,
 				FRUReadRes_T* pFRUReadResData,
 				int timeout)
@@ -663,7 +663,7 @@ uint16_t IPMICMD_ReadFRUData(IPMI20_SESSION_T *pSession,
 	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUReadRes_T) + (pFRUReadReqData->CountToRead);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_READ_FRU_DATA,
 						(uint8_t *)pFRUReadReqData, sizeof(FRUReadReq_T),
 						(uint8_t *)pFRUReadResData, &dwResLen,
@@ -671,7 +671,7 @@ uint16_t IPMICMD_ReadFRUData(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint16_t IPMICMD_WriteFRUData(IPMI20_SESSION_T *pSession,
+uint16_t IPMICMD_WriteFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 				FRUWriteReq_T* pFRUWriteReqData,
 				uint32_t ReqDataLen /* Bytes to be written + sizeof(FRUWriteReq_T) */,
 				FRUWriteRes_T* pFRUWriteResData,
@@ -682,7 +682,7 @@ uint16_t IPMICMD_WriteFRUData(IPMI20_SESSION_T *pSession,
 	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUWriteRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_WRITE_FRU_DATA,
 						(uint8_t *)pFRUWriteReqData, ReqDataLen,
 						(uint8_t *)pFRUWriteResData, &dwResLen,
@@ -690,7 +690,7 @@ uint16_t IPMICMD_WriteFRUData(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
+uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint8_t *pFRUIDs,
 					uint8_t *pFRUNames,
 					uint8_t *nFRUs,
@@ -708,14 +708,14 @@ uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
 	*nFRUs = 0;
 
 	/* Get max buffer size to be allocated to read all SDRs in the system */
-	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Allocation Info\n");
 		return wRet;
 	}
 	/* Get repository information */
-	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Info\n");
@@ -723,11 +723,11 @@ uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
 	}
 
 	/* Determine max SDR entry length */
-	MaxSDRLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+	MaxSDRLen = SDRAllocationInfo.MaxRecSize *  ( SDRAllocationInfo.AllocUnitSize );
 
 //	printf("MaxSDRLen = %d\n",MaxSDRLen);
 	/* Determine total number of SDRs stored */
-	SDRCount = ipmitoh_u16( SDRReposInfo.RecCt );
+	SDRCount =  ( SDRReposInfo.RecCt );
 //	printf("SDRCount = %d\n",SDRCount);
 
 	/* Allocate the buffer */
@@ -740,7 +740,7 @@ uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
 	pSDRStart = pSDRBuff;
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
                                      pSDRBuff,(MaxSDRLen * SDRCount),
                                      timeout*4);
 	if(wRet != 0)
@@ -813,42 +813,44 @@ uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
 //	printf("numFRUs = %d\n",*nFRUs);
 	return wRet;
 }
-uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_SESSION_T *pSession,
-					uint8_t *pFRUIDs,
-					uint8_t *nFRUs,
-					uint8_t nFRUsName[][16],
-					int timeout)
-{
-    int wRet = 0,i=0;
-    AMIGetFruDetailReq_T GetFruDetReq;
-    AMIGetFruDetailRes_T GetFruDetRes;
-
-     GetFruDetReq.FruReq = 0xFF;		
-     /* To get the total fru's */
-    wRet = IPMICMD_FRUDetails(pSession, &GetFruDetReq,&GetFruDetRes, timeout);
-    if( wRet != 0 )
-    {
-        printf("Error getting total fru's\n");
-        return wRet;
-    }
-   *nFRUs = GetFruDetRes.TotalFru;
-    for (i=0;i< *nFRUs;i++)
-    {
-        GetFruDetReq.FruReq = i;
-        /* To get the total fru's */
-        wRet = IPMICMD_FRUDetails(pSession, &GetFruDetReq,&GetFruDetRes, timeout);
-        if( wRet != 0 )
-        {
-            printf("Error getting total fru's\n");
-            return wRet;
-        }   
-        pFRUIDs[i] = GetFruDetRes.DeviceNo;
-        strcpy((char *)nFRUsName[i],(char *)GetFruDetRes.FRUName); 
-    }
-    return 0;	
-}
 
-uint8_t IPMICMD_GetSELTime(IPMI20_SESSION_T *pSession,
+
+// uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					uint8_t *pFRUIDs,
+// 					uint8_t *nFRUs,
+// 					uint8_t nFRUsName[][16],
+// 					int timeout)
+// {
+//     int wRet = 0,i=0;
+//     AMIGetFruDetailReq_T GetFruDetReq;
+//     AMIGetFruDetailRes_T GetFruDetRes;
+
+//      GetFruDetReq.FruReq = 0xFF;		
+//      /* To get the total fru's */
+//     wRet = IPMICMD_FRUDetails(pUDSSession, &GetFruDetReq,&GetFruDetRes, timeout);
+//     if( wRet != 0 )
+//     {
+//         printf("Error getting total fru's\n");
+//         return wRet;
+//     }
+//    *nFRUs = GetFruDetRes.TotalFru;
+//     for (i=0;i< *nFRUs;i++)
+//     {
+//         GetFruDetReq.FruReq = i;
+//         /* To get the total fru's */
+//         wRet = IPMICMD_FRUDetails(pUDSSession, &GetFruDetReq,&GetFruDetRes, timeout);
+//         if( wRet != 0 )
+//         {
+//             printf("Error getting total fru's\n");
+//             return wRet;
+//         }   
+//         pFRUIDs[i] = GetFruDetRes.DeviceNo;
+//         strcpy((char *)nFRUsName[i],(char *)GetFruDetRes.FRUName); 
+//     }
+//     return 0;	
+// }
+
+uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeRes_T *pGetSELTimeRes, int timeout)
 {
 	uint16_t	wRet;
@@ -857,7 +859,7 @@ uint8_t IPMICMD_GetSELTime(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(GetSELTimeRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_GET_SEL_TIME,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeRes, &dwResLen,
@@ -869,7 +871,7 @@ uint8_t IPMICMD_GetSELTime(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint8_t IPMICMD_SetSELTime(IPMI20_SESSION_T *pSession,
+uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeReq_T *pSetSELTimeReq, int timeout)
 {
 	uint16_t	wRet;
@@ -878,7 +880,7 @@ uint8_t IPMICMD_SetSELTime(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(uint8_t);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_SET_SEL_TIME,
 						(uint8_t *)pSetSELTimeReq, sizeof(SetSELTimeReq_T),
 						(uint8_t *)DummyResData, &dwResLen,
@@ -890,7 +892,7 @@ uint8_t IPMICMD_SetSELTime(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
+uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout)
 {
 	uint16_t	wRet;
@@ -899,7 +901,7 @@ uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(GetSELTimeUTCOffsetRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_GET_SEL_TIME_UTC_OFFSET,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeUTCOffsetRes, &dwResLen,
@@ -911,7 +913,7 @@ uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
 	return wRet;
 }
 
-uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
+uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout)
 {
 	uint16_t	wRet;
@@ -920,7 +922,7 @@ uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
 	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SetSELTimeUTCOffsetRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 						NetFnLunStorage, CMD_SET_SEL_TIME_UTC_OFFSET,
 						(uint8_t *)pSetSELTimeUTCOffsetReq, sizeof(SetSELTimeUTCOffsetReq_T),
 						(uint8_t *)&pSetSELTimeUTCOffsetRes, &dwResLen,

+ 1263 - 1120
app/goahead-3.6.5/src/libipmi/src/libipmi_fru.c

@@ -22,6 +22,7 @@
 #include <stdarg.h>
 
 #include "libipmi_fru.h"
+#include "com_BmcType.h"
 
 
 #ifdef _USE_ARR_MALLOCS_
@@ -69,1175 +70,1317 @@ const char * buf2str(uint8_t * buf, int len)
     return (const char *)str;
 }
 
-static uint32_t GetStringFromType(uint8_t *startBuff, uint8_t **str)
-{
-	//static const char bcd_plus[] = "0123456789 -.:,_";
-	uint8_t type = 0;
-	uint8_t len = 0;
-	uint8_t size = 0;
-	uint8_t i, j, k;
-	char binarystring[4];
-	int loop;
-
-	union
-	{
-		uint32_t bits;
-		char chars[4];
-	}u;
-
-	type =((*startBuff & 0xC0) >> 6);
-
-	len = GetBits(*startBuff, 5, 0);
-
-
-	switch (type)
-	{
-		case 0:
-			/** 00b:
-			 * binary/unspecified
-			 **/
-			//! hex dump -> 2x length
-			size =(len*2);
-			break;
-		case 2:
-			/** 10b:
-			 * 6 - bit ASCII
-			 **/
-			//! 4 chars per group of 1 - 3 bytes
-			size =((((len + 2)*4)/3) & ~3);
-			break;
-		case 3:
-				/** 11b:
-			8 - bit ASCII */
-		case 1:
-			/** 01b:
-			 * BCD plus
-			 **/
-			//! no length adjustment
-			size = len;
-			break;
-	}
 
+// union
+// {
+//     uint32_t bits;
+//     char chars[4];
+// }u;
+
+// static uint32_t GetStringFromType(uint8_t *startBuff, uint8_t **str)
+// {
+// 	//static const char bcd_plus[] = "0123456789 -.:,_";
+// 	uint8_t type = 0;
+// 	uint8_t len = 0;
+// 	uint8_t size = 0;
+// 	uint8_t i, j, k;
+// 	char binarystring[4];
+// 	int loop;
+
+
+// 	type =((*startBuff & 0xC0) >> 6);
+
+// 	len = GetBits(*startBuff, 5, 0);
+
+
+// 	switch (type)
+// 	{
+// 		case 0:
+// 			/** 00b:
+// 			 * binary/unspecified
+// 			 **/
+// 			//! hex dump -> 2x length
+// 			size =(len*2);
+// 			break;
+// 		case 2:
+// 			/** 10b:
+// 			 * 6 - bit ASCII
+// 			 **/
+// 			//! 4 chars per group of 1 - 3 bytes
+// 			size =((((len + 2)*4)/3) & ~3);
+// 			break;
+// 		case 3:
+// 				/** 11b:
+// 			8 - bit ASCII */
+// 		case 1:
+// 			/** 01b:
+// 			 * BCD plus
+// 			 **/
+// 			//! no length adjustment
+// 			size = len;
+// 			break;
+// 	}
+
+
+// 	*str =(uint8_t *) malloc(size + 1);
+//          if(*str == NULL)
+//            {
+//              printf ("libipmi_fru.c: Error allocating memory for str\n");
+// 	     return -1;
+//    	   }    
+
+// 	startBuff++;
+
+// 	switch (type)
+// 	{
+// 		case 0:                 //! Binary
+// 			{
+// 				memset(*str,0x00,size);
+// 				for(loop = 0; loop < (size/2); ++loop)
+// 				{
+// 					sprintf(binarystring,"%02X",*(startBuff+loop));
+// 					strncat((char*)(*str),binarystring,2);
+// 				}
+// 			}
+// 			break;
+
+// 		case 1:                 //! BCD plus
+// 			strcpy((char*)(*str), "\0");
+// 			break;
+
+// 		case 2:                 //! 6 - bit ASCII
+// 			for (i = j = 0; i < len; i += 3)
+// 			{
+// 				u.bits = 0;
+// 				k =((len - i) < 3 ?(len - i) : 3);
+// 		#if 1
+// 				u.chars[3] = *(startBuff + i);
+// 				u.chars[2] =(k > 1 ? *(startBuff + i + 1) : 0);
+// 				u.chars[1] =(k > 2 ? *(startBuff + i + 2) : 0);
+// 		#define CHAR_IDX 3
+// 		#else
+// 				memcpy((void *)&u.bits, startBuff + i, k);
+// 		#define CHAR_IDX 0
+// 		#endif
+// 				for (k = 0; k < 4; k++)
+// 				{
+// 				*(*str + j) =((u.chars[CHAR_IDX] & 0x3f) + 0x20);
+// 				u.bits >>= 6;
+// 				j++;
+// 				}
+// 			}
+// 			*(*str + j) = '\0';
+
+
+// 			break;
+// 		case 3:
+// 			memcpy(*str, startBuff, len);
+// 			*(*str + len) = '\0';
+// 			break;
+// 	}
+// 	return (size + 1);
+// }
+
+
+// static int  GetInternalUseArea(uint8_t *pBuff, OemFRUData_T *FRU)
+// {
+//     FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+//     uint8_t *pInternalUseArea = pBuff +(pTmp->InternalUseAreaStartOffset * 8);
+//     uint32_t len = 0;
+
+//     uint32_t size = 0;
+//     uint8_t *tmpPtr = NULL;
+
+
+//     FRU->InternalInfo.FormatVersion =	*pInternalUseArea;
+//     pInternalUseArea++;
+
+//     len = GetBits(*pInternalUseArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->InternalInfo.Data =(uint8_t *) malloc(8);
+//            if(FRU->InternalInfo.Data  == NULL)
+//            {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData_T\n");
+//              return -1;
+//            }
+
+//         strcpy((char*)(FRU->InternalInfo.Data), "\0");
+//         pInternalUseArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pInternalUseArea, &tmpPtr);
+//         FRU->InternalInfo.Data =(uint8_t *) malloc(size);
+// 	   if(FRU->InternalInfo.Data  == NULL)
+//            {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData_T\n");
+//              return -1;
+//            }
+
+//         memcpy(FRU->InternalInfo.Data, tmpPtr, size);
+//         pInternalUseArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+
+// #ifdef _USE_ARR_MALLOCS_
+// 	arrMallocs[nMallocs] = FRU->InternalInfo.Data;
+//     nMallocs++;
+// #endif
+
+// return 0;
+
+// }
+
+
+// static int GetChassisInfoArea(uint8_t *pBuff, OemFRUData_T *FRU)
+// {
+//     FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+//     uint8_t *pChassisArea = pBuff +(pTmp->ChassisInfoAreaStartOffset * 8);
+//     uint32_t len = 0, chassisAreaLen = 0;
+//     uint32_t size = 0; 
+//     uint8_t *tmpPtr = NULL;
+//     int Index = 0;
+//     static const char * chassis_type[] = {
+// 		"Unspecified", "Other", "Unknown",
+// 		"Desktop", "Low Profile Desktop", "Pizza Box",
+// 		"Mini Tower", "Tower",
+// 		"Portable", "LapTop", "Notebook", "Hand Held",
+// 		"Docking Station", "All in One", "Sub Notebook",
+// 		"Space-saving", "Lunch Box", "Main Server Chassis",
+// 		"Expansion Chassis", "SubChassis", "Bus Expansion Chassis",
+// 		"Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis"};
+
+//     FRU->ChassisInfo.ChassisInfoAreaFormatVersion =	*pChassisArea;
+//     pChassisArea++;
+//     FRU->ChassisInfo.ChassisInfoAreaLength = *pChassisArea;
+//     pChassisArea++;
+//     printf ("Chassis type : %d %d\n", (uint8_t)*pChassisArea, sizeof (chassis_type)/ sizeof (char *));
+//     if ((*pChassisArea) >= sizeof (chassis_type)/ sizeof (char *))
+//         *pChassisArea = 0;
+//     size = strlen(chassis_type[*pChassisArea]);
+//     FRU->ChassisInfo.ChassisType =(uint8_t *) malloc(size + 1);
+// 	   if(FRU->ChassisInfo.ChassisType  == NULL)
+//            {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisType\n");
+//              return -1;
+//            }
+
+//     memcpy(FRU->ChassisInfo.ChassisType, chassis_type[*pChassisArea], size);
+//     FRU->ChassisInfo.ChassisType[size] = '\0';
+//     pChassisArea++;
+
+//     len = GetBits(*pChassisArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ChassisInfo.ChassisPartNum =(uint8_t *) malloc(8);
+//         if(FRU->ChassisInfo.ChassisPartNum == NULL)
+//            {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisPartNum\n");
+//              return -1;
+//            }
+
+//         strcpy((char*)(FRU->ChassisInfo.ChassisPartNum), "\0");
+//         pChassisArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pChassisArea, &tmpPtr);
+//         FRU->ChassisInfo.ChassisPartNum =(uint8_t *) malloc(size);
+//         if(FRU->ChassisInfo.ChassisPartNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisPartNum\n");
+//         	return -1;
+//         }
+//         memcpy(FRU->ChassisInfo.ChassisPartNum, tmpPtr, size);
+//         pChassisArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ChassisInfo.ChassisPartNum;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pChassisArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ChassisInfo.ChassisSerialNum =(uint8_t *) malloc(8);
+//         if(FRU->ChassisInfo.ChassisSerialNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisSerialNum\n");
+//              return -1;
+//            }
+
+//         strcpy((char*)(FRU->ChassisInfo.ChassisSerialNum), "\0");
+//         pChassisArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pChassisArea, &tmpPtr);
+//         FRU->ChassisInfo.ChassisSerialNum =(uint8_t *) malloc(size);
+//         if(FRU->ChassisInfo.ChassisSerialNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisSerialNum\n");
+//              return -1;
+//         }
+//         memcpy(FRU->ChassisInfo.ChassisSerialNum, tmpPtr, size);
+//         pChassisArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ChassisInfo.ChassisSerialNum;
+//     nMallocs++;
+// #endif
+
+
+//     FRU->ChassisInfo.Total_Chassis_CustomField = 0;
+//     tmpPtr =  pChassisArea;
+//     chassisAreaLen = (unsigned long int)(((pBuff +(pTmp->ChassisInfoAreaStartOffset * 8)) + 
+//                             (FRU->ChassisInfo.ChassisInfoAreaLength * 8)) -1);
+//     while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  chassisAreaLen))
+//     {
+//     	len = GetBits(*tmpPtr, 5, 0);
+//         tmpPtr += len + 1;
+//         FRU->ChassisInfo.Total_Chassis_CustomField += 1;
+//     }
+//     if(FRU->ChassisInfo.Total_Chassis_CustomField > 0)
+//     {
+//         FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(FRU->ChassisInfo.Total_Chassis_CustomField * sizeof(char *));
+//         if(FRU->ChassisInfo.CustomFields != NULL)
+//         {
+//         	while((*pChassisArea != CUSTOM_AREA_FIELD) && (Index < FRU->ChassisInfo.Total_Chassis_CustomField))
+//          	{
+//         		len = GetBits(*pChassisArea, 5, 0);
+//          		if (len == 0)
+//          		{	
+//          			//FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(1);
+//          			FRU->ChassisInfo.CustomFields[Index] =(uint8_t *) malloc(8);
+//          			if( FRU->ChassisInfo.CustomFields[Index] != NULL )
+//          			{
+//          				strcpy((char*)(FRU->ChassisInfo.CustomFields[Index]), "\0");
+//          			}
+//          			else{
+// 			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
+// 			             return -1;
+// 				    }
+//          			pChassisArea += 1;
+
+//          		}
+//        			else
+//        			{
+//        				size = GetStringFromType(pChassisArea, &tmpPtr);
+//        				//FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(1);
+//        				FRU->ChassisInfo.CustomFields[Index] =(uint8_t *) malloc(size);
+//        				if(FRU->ChassisInfo.CustomFields[Index] != NULL)
+//        				{
+//        					memcpy((FRU->ChassisInfo.CustomFields[Index]), tmpPtr, size);
+//        				}
+//        				else{
+// 			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
+// 			             return -1;
+// 				    } 
+//        				SAFE_FREE (tmpPtr);
+//        				pChassisArea += len + 1;
+//        				//FRU->ChassisInfo.Total_Chassis_CustomField +=1;
+//        			}
+//        			++ Index;
+//        		}
+//        	}
+//        	else{
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
+//              return -1;
+//         } 
+//    }
+
+//    return 0; 
+// }
+
+// static int GetBoardInfoArea(uint8_t *pBuff, OemFRUData_T *FRU)
+// {
+
+//     FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+//     uint8_t *pBoardArea = pBuff +(pTmp->BoardInfoAreaStartOffset * 8);
+//     uint32_t len = 0, boardAreaLen = 0;
+//     int Index = 0;
+
+//     uint32_t size = 0;  
+//     uint8_t *tmpPtr = NULL;
+
+
+//     FRU->BoardInfo.BoardInfoAreaFormatVersion = *pBoardArea;
+//     pBoardArea++;
+//     FRU->BoardInfo.BoardInfoAreaLength = *pBoardArea;
+//     pBoardArea++;
+//     FRU->BoardInfo.Language = *pBoardArea;
+//     pBoardArea++;
+//     memcpy(FRU->BoardInfo.MfgDateTime, pBoardArea, 3);
+//     pBoardArea += 3;
+//     len = GetBits(*pBoardArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->BoardInfo.BoardMfr =(uint8_t *) malloc(8);
+//         if(FRU->BoardInfo.BoardMfr == NULL)
+// 		{
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardMfr\n");
+//              return -1; 
+//         }
+
+//         strcpy((char*)(FRU->BoardInfo.BoardMfr), "\0");
+//         pBoardArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pBoardArea, &tmpPtr);
+//         FRU->BoardInfo.BoardMfr =(uint8_t *) malloc(size);
+//         if(FRU->BoardInfo.BoardMfr == NULL)
+//        	{
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardMfr\n");
+//              return -1; 
+//         }
+//         memcpy(FRU->BoardInfo.BoardMfr, tmpPtr, size);
+//         SAFE_FREE (tmpPtr);
+//         pBoardArea += len + 1;
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->BoardInfo.BoardMfr;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pBoardArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->BoardInfo.BoardProductName =(uint8_t *) malloc(8);
+//         if(FRU->BoardInfo.BoardProductName == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardProductName\n");
+//              return -1; 
+//         }
+//         strcpy((char*)(FRU->BoardInfo.BoardProductName), "\0");
+//         pBoardArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pBoardArea, &tmpPtr);
+//         FRU->BoardInfo.BoardProductName =(uint8_t *) malloc(size);
+//         if(FRU->BoardInfo.BoardProductName == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardProductName\n");
+//        		 return -1;
+//         }
+//         memcpy(FRU->BoardInfo.BoardProductName, tmpPtr, size);
+//         SAFE_FREE (tmpPtr);
+//         pBoardArea += len + 1;
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->BoardInfo.BoardProductName;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pBoardArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->BoardInfo.BoardSerialNum =(uint8_t *) malloc(8);
+//         if(FRU->BoardInfo.BoardSerialNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardSerialNum\n");
+//         	return -1;
+//         } 
+//         strcpy((char*)(FRU->BoardInfo.BoardSerialNum), "\0");
+//         pBoardArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pBoardArea, &tmpPtr);
+//         FRU->BoardInfo.BoardSerialNum =(uint8_t *) malloc(size);
+//         if(FRU->BoardInfo.BoardSerialNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardSerialNum\n");
+//              return -1; 
+//          }
+//         memcpy(FRU->BoardInfo.BoardSerialNum, tmpPtr, size);
+//         SAFE_FREE (tmpPtr);
+//         pBoardArea += len + 1;
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->BoardInfo.BoardSerialNum;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pBoardArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->BoardInfo.BoardPartNum =(uint8_t *) malloc(8);
+// 		if(FRU->BoardInfo.BoardPartNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardPartNum\n");
+//              return -1; 
+//         }
+//         strcpy((char*)(FRU->BoardInfo.BoardPartNum), "\0");
+//         pBoardArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pBoardArea, &tmpPtr);
+//         FRU->BoardInfo.BoardPartNum =(uint8_t *) malloc(size);
+// 		if(FRU->BoardInfo.BoardPartNum == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardPartNum\n");
+//              return -1; 
+//         }
+//         memcpy(FRU->BoardInfo.BoardPartNum, tmpPtr, size);
+//         SAFE_FREE (tmpPtr);
+//         pBoardArea += len + 1;
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//    arrMallocs[nMallocs] = FRU->BoardInfo.BoardPartNum;
+//    nMallocs++;
+// #endif
+//     len = GetBits(*pBoardArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->BoardInfo.FRUFileID =(uint8_t *) malloc(8);
+// 		if(FRU->BoardInfo.FRUFileID == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field FRUFileID\n");
+//              return -1; 
+//         }
+//         strcpy((char*)(FRU->BoardInfo.FRUFileID), "\0");
+//         pBoardArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pBoardArea, &tmpPtr);
+//         FRU->BoardInfo.FRUFileID =(uint8_t *) malloc(size);
+// 		if(FRU->BoardInfo.FRUFileID == NULL)
+//         {
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table field FRUFileID\n");
+//              return -1; 
+//         }
+//         memcpy(FRU->BoardInfo.FRUFileID, tmpPtr, size);
+//         SAFE_FREE (tmpPtr);
+//         pBoardArea += len + 1;
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->BoardInfo.FRUFileID;
+//     nMallocs++;
+// #endif
+ 
+//      FRU->BoardInfo.Total_Board_CustomField = 0;
+//      tmpPtr =  pBoardArea;
+//      boardAreaLen = (unsigned long int)(((pBuff +(pTmp->BoardInfoAreaStartOffset * 8)) + 
+//                              (FRU->BoardInfo.BoardInfoAreaLength * 8)) -1); 
+//      while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  boardAreaLen))
+//      {
+//      	len = GetBits(*tmpPtr, 5, 0);
+//      	tmpPtr += len + 1;
+//      	FRU->BoardInfo.Total_Board_CustomField += 1;
+//      }
+//      if(FRU->BoardInfo.Total_Board_CustomField > 0)
+//      {
+//      	FRU->BoardInfo.CustomFields =(uint8_t **) malloc(FRU->BoardInfo.Total_Board_CustomField * sizeof(char *));
+//      	if( FRU->BoardInfo.CustomFields != NULL )
+//      	{
+//      		while((*pBoardArea!= CUSTOM_AREA_FIELD) && (Index < FRU->BoardInfo.Total_Board_CustomField))
+//      		{
+//      			len = GetBits(*pBoardArea, 5, 0);
+//      			if (len == 0)
+//      			{	
+//      				//FRU->BoardInfo.CustomFields =(uint8_t **) malloc(1);
+//      				FRU->BoardInfo.CustomFields[Index] =(uint8_t *) malloc(8);
+//      				if(FRU->BoardInfo.CustomFields[Index] !=  NULL )
+//      				{
+//      					strcpy((char*)(FRU->BoardInfo.CustomFields[Index]), "\0");
+//      				}
+//      				else{
+// 			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
+//         			     return -1;
+// 				    } 
+//      				pBoardArea += 1;
+//      			}
+//      			else
+//      			{
+//      				size = GetStringFromType(pBoardArea, &tmpPtr);
+//      				//FRU->BoardInfo.CustomFields =(uint8_t **) malloc(1);
+//      				FRU->BoardInfo.CustomFields[Index] =(uint8_t *) malloc(size);
+//      				if(FRU->BoardInfo.CustomFields[Index] != NULL)
+//      				{
+//      					memcpy((FRU->BoardInfo.CustomFields[Index]), tmpPtr, size);
+//      				}
+//      				else{
+// 			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
+// 			             return -1;
+// 				    } 
+//      				SAFE_FREE (tmpPtr);
+//      				pBoardArea += len + 1;
+//      				//FRU->BoardInfo.Total_Board_CustomField +=1;
+//      			}
+//      			++ Index;
+//      		}
+//      	}
+//      	else{
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
+//              return -1;
+// 	    } 
+//      }
+//    return 0; 
+// }
+
+
+// static int GetProductInfoArea(uint8_t *pBuff, OemFRUData_T *FRU)
+// {
+//     FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+//     uint8_t *pProductArea = pBuff +(pTmp->ProductInfoAreaStartOffset * 8);
+//     uint8_t len = 0;
+//     uint32_t size = 0, productAreaLen = 0;
+//     int Index = 0;
+
+//     uint8_t *tmpPtr = NULL;
+
+//     if(pProductArea == NULL)
+// 	return -1;
+
+//     FRU->ProductInfo.ProductInfoAreaFormatVersion = *pProductArea;
+//     pProductArea++;
+//     FRU->ProductInfo.ProductInfoAreaLength = *pProductArea;
+//     pProductArea++;
+//     FRU->ProductInfo.Language = *pProductArea;
+//     pProductArea++;
+
+//     len = GetBits(*pProductArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.MfrName =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.MfrName == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo MfrName\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.MfrName), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.MfrName =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.MfrName == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo MfrName\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.MfrName), (const char *)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.MfrName;
+//     nMallocs++;
+// #endif
+
+//     len = GetBits(*pProductArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.ProductName =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.ProductName == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductName\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductName), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.ProductName =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.ProductName == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductName\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductName), (const char*)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.ProductName;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pProductArea, 5, 0);
+
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.ProductPartNum =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.ProductPartNum == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductPartNum\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductPartNum), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.ProductPartNum =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.ProductPartNum == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductPartNum\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductPartNum), (const char*)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.ProductPartNum;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pProductArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.ProductVersion =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.ProductVersion == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductVersion\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductVersion), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.ProductVersion =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.ProductVersion == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductVersion\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductVersion), (const char*)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.ProductVersion;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pProductArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.ProductSerialNum =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.ProductSerialNum == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductSerialNum\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductSerialNum), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.ProductSerialNum =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.ProductSerialNum == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductSerialNum\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.ProductSerialNum), (const char*)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.ProductSerialNum;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pProductArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.AssetTag =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.AssetTag == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-AssetTag\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.AssetTag), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.AssetTag =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.AssetTag == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-AssetTag\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.AssetTag), (const char*)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.AssetTag;
+//     nMallocs++;
+// #endif
+//     len = GetBits(*pProductArea, 5, 0);
+//     if (len == 0)
+//     {
+//         FRU->ProductInfo.FRUFileID =(uint8_t *) malloc(8);
+//         if(FRU->ProductInfo.FRUFileID == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-FRUFileID\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.FRUFileID), "\0");
+//         pProductArea += 1;
+//     }
+//     else
+//     {
+//         size = GetStringFromType(pProductArea, &tmpPtr);
+//         FRU->ProductInfo.FRUFileID =(uint8_t *) malloc(size);
+//         if(FRU->ProductInfo.FRUFileID == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-FRUFileID\n");
+// 		     return -1; 
+// 		}
+//         strcpy((char*)(FRU->ProductInfo.FRUFileID), (const char*)tmpPtr);
+//         pProductArea += len + 1;
+//         SAFE_FREE (tmpPtr);
+//     }
+// #ifdef _USE_ARR_MALLOCS_
+//     arrMallocs[nMallocs] = FRU->ProductInfo.FRUFileID;
+//     nMallocs++;
+// #endif
+
+
+//     FRU->ProductInfo.Total_Product_CustomField = 0;
+//     tmpPtr =  pProductArea;
+//     productAreaLen = (unsigned long int)(((pBuff +(pTmp->ProductInfoAreaStartOffset * 8)) + 
+//                             (FRU->ProductInfo.ProductInfoAreaLength * 8)) -1);
+//     while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  productAreaLen))
+//     {
+//     	len = GetBits(*tmpPtr, 5, 0);
+//         tmpPtr += len + 1;
+//         FRU->ProductInfo.Total_Product_CustomField += 1;
+//     }
+//     if(FRU->ProductInfo.Total_Product_CustomField > 0)
+//     {
+//         FRU->ProductInfo.CustomFields =(uint8_t **) malloc(FRU->ProductInfo.Total_Product_CustomField * sizeof(char *));
+//         if(FRU->ProductInfo.CustomFields  != NULL)
+//         {
+//         	while((*pProductArea!= CUSTOM_AREA_FIELD) && (Index < FRU->ProductInfo.Total_Product_CustomField))
+//         	{
+//         		len = GetBits(*pProductArea, 5, 0);
+//         		if (len == 0)
+//         		{	
+//         			//FRU->ProductInfo.CustomFields =(uint8_t **) malloc(1);
+//         			FRU->ProductInfo.CustomFields[Index] =(uint8_t *) malloc(8);
+//         			if(FRU->ProductInfo.CustomFields[Index] != NULL)
+//         			{
+//         				strcpy((char*)(FRU->ProductInfo.CustomFields[Index]), "\0");
+//         			}
+//         			else{
+// 			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
+// 			             return -1;			
+// 				    } 
+//         			pProductArea += 1;
+//         		}
+//         		else
+//         		{
+//         			size = GetStringFromType(pProductArea, &tmpPtr);
+//         			//FRU->ProductInfo.CustomFields =(uint8_t **) malloc(1);
+//         			FRU->ProductInfo.CustomFields[Index] =(uint8_t *) malloc(size);
+//         			if(FRU->ProductInfo.CustomFields[Index] != NULL)
+//         			{
+//         				memcpy((FRU->ProductInfo.CustomFields[Index]), tmpPtr, size);
+//         			}
+//         			else{
+// 			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
+// 			             return -1;
+// 				    } 
+//         			SAFE_FREE (tmpPtr);
+//         			pProductArea += len + 1;
+//         			//FRU->ProductInfo.Total_Product_CustomField +=1;
+//         		}
+//         		++ Index;
+//         	}
+//         }
+//         else{
+//              printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
+//              return -1;	
+// 	    } 
+//     }
+
+//    return 0;
+
+// }
+
+// int InterpretFRUData(uint8_t *pBuff, OemFRUData_T *FRU,uint32_t  FRU_Size)
+// {
+// 	FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+// 	int i;
+// 	printf("\n---> InterpretFRUData Enter: ");
+// 	for(i=0;i<256;i++)
+// 		printf("%#x ", pBuff[i]);
+// 	printf("\n");
+// 	if (pBuff == NULL)
+// 	{
+// 		memset(FRU, 0, sizeof(OemFRUData_T));
+// 	}
+// 	else
+// 	{
+// 		//! Copy full Common Header
+// 		memcpy(&(FRU->CommonHeader), pTmp, sizeof(FRUCommonHeader_T));
+// 	}
+
+// 	/**
+// 	 * ********************** Internal Use Area *******************************
+// 	 **/
+// 	if (FRU->CommonHeader.InternalUseAreaStartOffset != 0)
+// 	{
+// 		printf("---> InterpretFRUData log1");
+// 		if((uint32_t)((pTmp->InternalUseAreaStartOffset * 8)) > FRU_Size)
+// 		{		  	
+// 			printf(" return error!\n");
+// 			return FRU_INVALID_AREA;
+// 		}
+// 		printf("\n");
+// 		GetInternalUseArea(pBuff, FRU);
+// 	}
+
+// 	/**
+// 	 * ********************** Chassis Info Area *******************************
+// 	 **/
+// 	if (FRU->CommonHeader.ChassisInfoAreaStartOffset != 0)
+// 	{
+// 		printf("---> InterpretFRUData log2");
+// 		if((uint32_t)((pTmp->ChassisInfoAreaStartOffset * 8)) > FRU_Size)
+// 		{		  	
+// 			printf(" return error!\n");
+// 			return FRU_INVALID_AREA;
+// 		}
+// 		printf("\n");
+// 		if(GetChassisInfoArea(pBuff, FRU)!= 0)
+// 		{
+//                       return -1;
+// 		}
+// 	}
+
+// 	/**
+// 	 * ********************** Board Info Area *******************************
+// 	 **/
+// 	if (FRU->CommonHeader.BoardInfoAreaStartOffset != 0)
+// 	{
+// 		printf("---> InterpretFRUData log3");
+// 		if((uint32_t)((pTmp->BoardInfoAreaStartOffset * 8)) > FRU_Size)
+// 		{		  	
+// 			printf(" return error!\n");
+// 			return FRU_INVALID_AREA;
+// 		}
+// 		printf("\n");
+// 		if(GetBoardInfoArea(pBuff, FRU)!=0)
+// 		{
+//                       return -1;
+// 		}
+// 	}
+
+// 	/**
+// 	 * ********************** Product Info Area *******************************
+// 	 **/
+// 	if (FRU->CommonHeader.ProductInfoAreaStartOffset != 0)
+// 	{
+// 		printf("---> InterpretFRUData log4");
+// 		if((uint32_t)((pTmp->ProductInfoAreaStartOffset * 8)) > FRU_Size)
+// 		{		  	
+// 			printf(" return error!\n");
+// 			return FRU_INVALID_AREA;
+// 		}
+		
+// 		if( GetProductInfoArea(pBuff, FRU) != 0)
+// 		{
+// 			printf("GetProductInfoArea return error!\n");
+//                       return -1;
+// 		}
+// 	}
+	
+// return 0;
 
-	*str =(uint8_t *) malloc(size + 1);
-         if(*str == NULL)
-           {
-             printf ("libipmi_fru.c: Error allocating memory for str\n");
-	     return -1;
-   	   }    
+// }
 
-	startBuff++;
 
-	switch (type)
-	{
-		case 0:                 //! Binary
-			{
-				memset(*str,0x00,size);
-				for(loop = 0; loop < (size/2); ++loop)
-				{
-					sprintf(binarystring,"%02X",*(startBuff+loop));
-					strncat((char*)(*str),binarystring,2);
-				}
-			}
-			break;
-
-		case 1:                 //! BCD plus
-			strcpy((char*)(*str), "\0");
-			break;
-
-		case 2:                 //! 6 - bit ASCII
-			for (i = j = 0; i < len; i += 3)
-			{
-				u.bits = 0;
-				k =((len - i) < 3 ?(len - i) : 3);
-		#if 1
-				u.chars[3] = *(startBuff + i);
-				u.chars[2] =(k > 1 ? *(startBuff + i + 1) : 0);
-				u.chars[1] =(k > 2 ? *(startBuff + i + 2) : 0);
-		#define CHAR_IDX 3
-		#else
-				memcpy((void *)&u.bits, startBuff + i, k);
-		#define CHAR_IDX 0
-		#endif
-				for (k = 0; k < 4; k++)
-				{
-				*(*str + j) =((u.chars[CHAR_IDX] & 0x3f) + 0x20);
-				u.bits >>= 6;
-				j++;
-				}
-			}
-			*(*str + j) = '\0';
-
-
-			break;
-		case 3:
-			memcpy(*str, startBuff, len);
-			*(*str + len) = '\0';
-			break;
-	}
-	return (size + 1);
-}
 
 
-static int  GetInternalUseArea(uint8_t *pBuff, FRUData_T *FRU)
+// static uint16_t get_fru_info (IPMI20_UDS_SESSION_T* pUDSSession,
+// 				  uint8_t fru_device_id,
+// 				  uint32_t* p_fru_size,
+// 				  OemFRUData_T* fru_data,
+// 				  int timeout)
+// {
+// 	FRUInventoryAreaInfoReq_T 	fru_inv_area_req;
+// 	FRUInventoryAreaInfoRes_T 	fru_inv_area_res;
+	
+// 	uint8_t*							fru_res_data = NULL;
+// 	uint32_t							fru_res_data_len = 0;
+// 	FRUReadReq_T				fru_read_req;
+
+// 	uint32_t							wRet = 0;
+// 	uint32_t							fru_size = 0;
+// 	uint8_t								BLOCK_OF_DATA_TO_READ = 128;
+// 	uint8_t                         isValidFRU = 0;
+// 	FRUCommonHeader_T *pTmp = NULL;
+// 	int i = 0;
+//     //uint8_t*                            tempFRUBuff = NULL;
+//     uint8_t*                            pFRUBuff = (uint8_t*)fru_data;
+// 	/**
+// 	 * returns the overall size(in bytes) of the FRU
+// 	 * inventory area in this device
+// 	 **/
+// 	fru_inv_area_req.FRUDeviceID = fru_device_id;
+
+// 	wRet = IPMICMD_GetFRUInventoryAreaInfo (pUDSSession,
+// 											&fru_inv_area_req,
+// 											&fru_inv_area_res,
+// 											timeout);
+// 	if ((wRet != 0) &&((fru_inv_area_res.CompletionCode & 0xFF) != 0xCB))
+// 	{
+// 		printf("---> error log 1, wRet = %#x\n", wRet);
+// 		return wRet;
+// 	}
+// 	else
+// 	{
+// 		if ((fru_inv_area_res.CompletionCode & 0xFF) == 0xCB)
+// 		{
+// 			printf("---> error log 2\n");
+// 			return wRet;
+// 		}
+
+// 		*p_fru_size = fru_size = (uint32_t)fru_inv_area_res.Size;
+// 		printf("---> fru_size = %d\n", fru_size);
+
+// 		// //! Allocate the buffer size to read FRU data for this FRU device
+// 		// tempFRUBuff = pFRUBuff 	= (uint8_t* ) malloc (fru_size);
+// 		// if( tempFRUBuff == NULL)
+// 		// {
+// 		//      printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+// 		//      return -1; 
+// 		// }
+
+// 		// if (0 == pFRUBuff ) goto _exit_get_fru_info_;
+
+
+// 		//! Read complete FRU Data now
+// 		fru_read_req.FRUDeviceID = fru_device_id;
+// 		fru_read_req.Offset 	 = 0x00; //! go to start of FRU area
+
+// 		fru_res_data_len		 = 	sizeof(FRUReadRes_T) + BLOCK_OF_DATA_TO_READ;
+// 		fru_res_data 			 = (uint8_t* ) malloc ( fru_res_data_len );
+// 		if( fru_res_data == NULL)
+// 		{
+// 		     printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+// 		     return -1; 
+// 		}
+
+// 		if (NULL == fru_res_data)
+// 		{
+// 			return wRet;
+// 		}
+
+// 		// Initially read only the FRU header.
+// 		fru_read_req.CountToRead = sizeof (FRUCommonHeader_T);
+		
+// 		while (fru_size) //! while there is data to read
+// 		{
+// 			printf("---> get_fru_info, fru_size = %d, CountToRead = %d\n", fru_size, fru_read_req.CountToRead);
+// 			wRet = IPMICMD_ReadFRUData (pUDSSession,
+// 										&fru_read_req,
+// 										(FRUReadRes_T *) fru_res_data,
+// 										timeout);
+// 			// for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+// 			// 	printf("%#x ", fru_res_data[2+i]);
+// 			// printf("\n");
+// 			if (wRet != 0)
+// 			{
+// 				SAFE_FREE (fru_res_data);
+// 				//SAFE_FREE (tempFRUBuff);
+// 				return wRet;
+
+// 			}
+// 			else
+// 			{
+			    
+// 				// Validate the FRU Header and proceed for further bytes.
+// 				if (0 == isValidFRU)
+// 				{
+// 					printf("---> log log 2\n");
+// 					pTmp = (FRUCommonHeader_T *) (fru_res_data + sizeof(FRUReadRes_T));
+// 					if(pTmp->CommonHeaderFormatVersion != IPMI_FRU_VALID_VERSION)
+// 					{
+// 						SAFE_FREE (fru_res_data);
+// 						//SAFE_FREE (tempFRUBuff);
+// 						wRet = FRU_INVALID_HEADER_VERSION;
+// 						return wRet;
+// 					}
+// 					isValidFRU = 1;
+// 				}
+// 				memcpy (pFRUBuff,
+// 						(fru_res_data + sizeof(FRUReadRes_T)),
+// 						fru_read_req.CountToRead);
+// 				pFRUBuff += (fru_read_req.CountToRead);
+// 			}
+			
+// 			//! recalculate the size left out
+// 			fru_size 			-= fru_read_req.CountToRead;
+// 			fru_read_req.Offset  = (fru_read_req.Offset + fru_read_req.CountToRead);
+			
+// 			//! read only 128 bytes at-a-time
+// 			fru_read_req.CountToRead = ( (fru_size > BLOCK_OF_DATA_TO_READ) ? BLOCK_OF_DATA_TO_READ : fru_size );
+// 		}
+// 		SAFE_FREE (fru_res_data);
+// 	}
+
+// 	return wRet;
+// }
+
+// uint16_t LIBIPMI_HL_GetFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
+// 					uint8_t fru_device_id,
+// 				  	uint32_t* p_fru_size,
+// 				  	OemFRUData_T* fru_data,
+// 					int timeout)
+// {
+// 	return(get_fru_info(pUDSSession,fru_device_id,p_fru_size,fru_data,timeout));
+
+// }
+
+uint16_t LIBIPMI_HL_GetFRUChassisData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUChassisInfo_T* chassis_data,
+                    int timeout)
 {
-    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
-    uint8_t *pInternalUseArea = pBuff +(pTmp->InternalUseAreaStartOffset * 8);
-    uint32_t len = 0;
-
-    uint32_t size = 0;
-    uint8_t *tmpPtr = NULL;
-
-
-    FRU->InternalInfo.FormatVersion =	*pInternalUseArea;
-    pInternalUseArea++;
-
-    len = GetBits(*pInternalUseArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->InternalInfo.Data =(uint8_t *) malloc(8);
-           if(FRU->InternalInfo.Data  == NULL)
-           {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData_T\n");
-             return -1;
-           }
-
-        strcpy((char*)(FRU->InternalInfo.Data), "\0");
-        pInternalUseArea += 1;
-    }
-    else
+    uint8_t*                    fru_res_data = NULL;
+    uint32_t                    fru_res_data_len = 0;
+    FRUReadReq_T                fru_read_req;
+
+    uint32_t                    wRet = 0;
+    uint32_t                    fru_size = 0;
+    uint8_t                     BLOCK_OF_DATA_TO_READ = 128;
+    FRUCommonHeader_T *pTmp = NULL;
+  
+    //! Read complete FRU Data now
+    fru_read_req.FRUDeviceID = fru_device_id;
+    fru_read_req.Offset      = 0x00; //! go to start of FRU area
+
+    fru_res_data_len         =  sizeof(FRUReadRes_T) + BLOCK_OF_DATA_TO_READ;
+    fru_res_data             = (uint8_t* ) malloc ( fru_res_data_len );
+    if( fru_res_data == NULL)
     {
-        size = GetStringFromType(pInternalUseArea, &tmpPtr);
-        FRU->InternalInfo.Data =(uint8_t *) malloc(size);
-	   if(FRU->InternalInfo.Data  == NULL)
-           {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData_T\n");
-             return -1;
-           }
-
-        memcpy(FRU->InternalInfo.Data, tmpPtr, size);
-        pInternalUseArea += len + 1;
-        SAFE_FREE (tmpPtr);
+         printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+         return -1; 
     }
 
-#ifdef _USE_ARR_MALLOCS_
-	arrMallocs[nMallocs] = FRU->InternalInfo.Data;
-    nMallocs++;
-#endif
-
-return 0;
-
-}
-
-
-static int GetChassisInfoArea(uint8_t *pBuff, FRUData_T *FRU)
-{
-    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
-    uint8_t *pChassisArea = pBuff +(pTmp->ChassisInfoAreaStartOffset * 8);
-    uint32_t len = 0, chassisAreaLen = 0;
-    uint32_t size = 0; 
-    uint8_t *tmpPtr = NULL;
-    int Index = 0;
-    static const char * chassis_type[] = {
-		"Unspecified", "Other", "Unknown",
-		"Desktop", "Low Profile Desktop", "Pizza Box",
-		"Mini Tower", "Tower",
-		"Portable", "LapTop", "Notebook", "Hand Held",
-		"Docking Station", "All in One", "Sub Notebook",
-		"Space-saving", "Lunch Box", "Main Server Chassis",
-		"Expansion Chassis", "SubChassis", "Bus Expansion Chassis",
-		"Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis"};
-
-    FRU->ChassisInfo.ChassisInfoAreaFormatVersion =	*pChassisArea;
-    pChassisArea++;
-    FRU->ChassisInfo.ChassisInfoAreaLength = *pChassisArea;
-    pChassisArea++;
-    printf ("Chassis type : %d %d\n", (uint8_t)*pChassisArea, sizeof (chassis_type)/ sizeof (char *));
-    if ((*pChassisArea) >= sizeof (chassis_type)/ sizeof (char *))
-        *pChassisArea = 0;
-    size = strlen(chassis_type[*pChassisArea]);
-    FRU->ChassisInfo.ChassisType =(uint8_t *) malloc(size + 1);
-	   if(FRU->ChassisInfo.ChassisType  == NULL)
-           {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisType\n");
-             return -1;
-           }
-
-    memcpy(FRU->ChassisInfo.ChassisType, chassis_type[*pChassisArea], size);
-    FRU->ChassisInfo.ChassisType[size] = '\0';
-    pChassisArea++;
-
-    len = GetBits(*pChassisArea, 5, 0);
-    if (len == 0)
+    fru_read_req.CountToRead = sizeof (FRUCommonHeader_T);
+    printf("---> get_fru_info, fru_size = %d, CountToRead = %d\n", fru_size, fru_read_req.CountToRead);
+    wRet = IPMICMD_ReadFRUData (pUDSSession,
+                                &fru_read_req,
+                                (FRUReadRes_T *) fru_res_data,
+                                timeout);
+    // int i;
+    // for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+    //     printf("%#x ", fru_res_data[2+i]);
+    // printf("\n");
+    if (wRet != 0)
     {
-        FRU->ChassisInfo.ChassisPartNum =(uint8_t *) malloc(8);
-        if(FRU->ChassisInfo.ChassisPartNum == NULL)
-           {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisPartNum\n");
-             return -1;
-           }
-
-        strcpy((char*)(FRU->ChassisInfo.ChassisPartNum), "\0");
-        pChassisArea += 1;
+        SAFE_FREE (fru_res_data);
+        return wRet;
     }
     else
     {
-        size = GetStringFromType(pChassisArea, &tmpPtr);
-        FRU->ChassisInfo.ChassisPartNum =(uint8_t *) malloc(size);
-        if(FRU->ChassisInfo.ChassisPartNum == NULL)
+        pTmp = (FRUCommonHeader_T *) (fru_res_data + sizeof(FRUReadRes_T));
+        if(pTmp->CommonHeaderFormatVersion != IPMI_FRU_VALID_VERSION)
         {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisPartNum\n");
-        	return -1;
+            SAFE_FREE (fru_res_data);
+            wRet = FRU_INVALID_HEADER_VERSION;
+            return wRet;
         }
-        memcpy(FRU->ChassisInfo.ChassisPartNum, tmpPtr, size);
-        pChassisArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ChassisInfo.ChassisPartNum;
-    nMallocs++;
-#endif
-    len = GetBits(*pChassisArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ChassisInfo.ChassisSerialNum =(uint8_t *) malloc(8);
-        if(FRU->ChassisInfo.ChassisSerialNum == NULL)
+        if(pTmp->ChassisInfoAreaStartOffset == 0)
         {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisSerialNum\n");
-             return -1;
-           }
-
-        strcpy((char*)(FRU->ChassisInfo.ChassisSerialNum), "\0");
-        pChassisArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pChassisArea, &tmpPtr);
-        FRU->ChassisInfo.ChassisSerialNum =(uint8_t *) malloc(size);
-        if(FRU->ChassisInfo.ChassisSerialNum == NULL)
+            SAFE_FREE (fru_res_data);
+            wRet = FRU_INVALID_AREA;
+            return wRet;
+        }
+        fru_read_req.Offset  = pTmp->ChassisInfoAreaStartOffset * 8;
+        *p_fru_size = fru_read_req.CountToRead = sizeof(OemFRUChassisInfo_T);
+        wRet = IPMICMD_ReadFRUData (pUDSSession,
+                                &fru_read_req,
+                                (FRUReadRes_T *) fru_res_data,
+                                timeout);
+        // for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+        //     printf("%#x ", fru_res_data[2+i]);
+        // printf("\n");
+        if (wRet != 0)
         {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisSerialNum\n");
-             return -1;
+            SAFE_FREE (fru_res_data);
+            return wRet;
         }
-        memcpy(FRU->ChassisInfo.ChassisSerialNum, tmpPtr, size);
-        pChassisArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ChassisInfo.ChassisSerialNum;
-    nMallocs++;
-#endif
-
 
-    FRU->ChassisInfo.Total_Chassis_CustomField = 0;
-    tmpPtr =  pChassisArea;
-    chassisAreaLen = (unsigned long int)(((pBuff +(pTmp->ChassisInfoAreaStartOffset * 8)) + 
-                            (FRU->ChassisInfo.ChassisInfoAreaLength * 8)) -1);
-    while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  chassisAreaLen))
-    {
-    	len = GetBits(*tmpPtr, 5, 0);
-        tmpPtr += len + 1;
-        FRU->ChassisInfo.Total_Chassis_CustomField += 1;
+        memcpy (chassis_data, (fru_res_data + sizeof(FRUReadRes_T)), 
+            fru_read_req.CountToRead);
     }
-    if(FRU->ChassisInfo.Total_Chassis_CustomField > 0)
-    {
-        FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(FRU->ChassisInfo.Total_Chassis_CustomField * sizeof(char *));
-        if(FRU->ChassisInfo.CustomFields != NULL)
-        {
-        	while((*pChassisArea != CUSTOM_AREA_FIELD) && (Index < FRU->ChassisInfo.Total_Chassis_CustomField))
-         	{
-        		len = GetBits(*pChassisArea, 5, 0);
-         		if (len == 0)
-         		{	
-         			//FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(1);
-         			FRU->ChassisInfo.CustomFields[Index] =(uint8_t *) malloc(8);
-         			if( FRU->ChassisInfo.CustomFields[Index] != NULL )
-         			{
-         				strcpy((char*)(FRU->ChassisInfo.CustomFields[Index]), "\0");
-         			}
-         			else{
-			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
-			             return -1;
-				    }
-         			pChassisArea += 1;
-
-         		}
-       			else
-       			{
-       				size = GetStringFromType(pChassisArea, &tmpPtr);
-       				//FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(1);
-       				FRU->ChassisInfo.CustomFields[Index] =(uint8_t *) malloc(size);
-       				if(FRU->ChassisInfo.CustomFields[Index] != NULL)
-       				{
-       					memcpy((FRU->ChassisInfo.CustomFields[Index]), tmpPtr, size);
-       				}
-       				else{
-			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
-			             return -1;
-				    } 
-       				SAFE_FREE (tmpPtr);
-       				pChassisArea += len + 1;
-       				//FRU->ChassisInfo.Total_Chassis_CustomField +=1;
-       			}
-       			++ Index;
-       		}
-       	}
-       	else{
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
-             return -1;
-        } 
-   }
-
-   return 0; 
+    
 }
-
-static int GetBoardInfoArea(uint8_t *pBuff, FRUData_T *FRU)
+  
+uint16_t LIBIPMI_HL_GetFRUBoardData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUBoardInfo_T* board_data,
+                    int timeout)
 {
-
-    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
-    uint8_t *pBoardArea = pBuff +(pTmp->BoardInfoAreaStartOffset * 8);
-    uint32_t len = 0, boardAreaLen = 0;
-    int Index = 0;
-
-    uint32_t size = 0;  
-    uint8_t *tmpPtr = NULL;
-
-
-    FRU->BoardInfo.BoardInfoAreaFormatVersion = *pBoardArea;
-    pBoardArea++;
-    FRU->BoardInfo.BoardInfoAreaLength = *pBoardArea;
-    pBoardArea++;
-    FRU->BoardInfo.Language = *pBoardArea;
-    pBoardArea++;
-    memcpy(FRU->BoardInfo.MfgDateTime, pBoardArea, 3);
-    pBoardArea += 3;
-    len = GetBits(*pBoardArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->BoardInfo.BoardMfr =(uint8_t *) malloc(8);
-        if(FRU->BoardInfo.BoardMfr == NULL)
-		{
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardMfr\n");
-             return -1; 
-        }
-
-        strcpy((char*)(FRU->BoardInfo.BoardMfr), "\0");
-        pBoardArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pBoardArea, &tmpPtr);
-        FRU->BoardInfo.BoardMfr =(uint8_t *) malloc(size);
-        if(FRU->BoardInfo.BoardMfr == NULL)
-       	{
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardMfr\n");
-             return -1; 
-        }
-        memcpy(FRU->BoardInfo.BoardMfr, tmpPtr, size);
-        SAFE_FREE (tmpPtr);
-        pBoardArea += len + 1;
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->BoardInfo.BoardMfr;
-    nMallocs++;
-#endif
-    len = GetBits(*pBoardArea, 5, 0);
-    if (len == 0)
+    uint8_t*                    fru_res_data = NULL;
+    uint32_t                    fru_res_data_len = 0;
+    FRUReadReq_T                fru_read_req;
+
+    uint32_t                    wRet = 0;
+    uint32_t                    fru_size = 0;
+    uint8_t                     BLOCK_OF_DATA_TO_READ = 128;
+    FRUCommonHeader_T *pTmp = NULL;
+  
+    //! Read complete FRU Data now
+    fru_read_req.FRUDeviceID = fru_device_id;
+    fru_read_req.Offset      = 0x00; //! go to start of FRU area
+
+    fru_res_data_len         =  sizeof(FRUReadRes_T) + BLOCK_OF_DATA_TO_READ;
+    fru_res_data             = (uint8_t* ) malloc ( fru_res_data_len );
+    if( fru_res_data == NULL)
     {
-        FRU->BoardInfo.BoardProductName =(uint8_t *) malloc(8);
-        if(FRU->BoardInfo.BoardProductName == NULL)
-        {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardProductName\n");
-             return -1; 
-        }
-        strcpy((char*)(FRU->BoardInfo.BoardProductName), "\0");
-        pBoardArea += 1;
+         printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+         return -1; 
     }
-    else
-    {
-        size = GetStringFromType(pBoardArea, &tmpPtr);
-        FRU->BoardInfo.BoardProductName =(uint8_t *) malloc(size);
-        if(FRU->BoardInfo.BoardProductName == NULL)
-        {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardProductName\n");
-       		 return -1;
-        }
-        memcpy(FRU->BoardInfo.BoardProductName, tmpPtr, size);
-        SAFE_FREE (tmpPtr);
-        pBoardArea += len + 1;
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->BoardInfo.BoardProductName;
-    nMallocs++;
-#endif
-    len = GetBits(*pBoardArea, 5, 0);
-    if (len == 0)
+
+    fru_read_req.CountToRead = sizeof (FRUCommonHeader_T);
+    printf("---> get_fru_info, fru_size = %d, CountToRead = %d\n", fru_size, fru_read_req.CountToRead);
+    wRet = IPMICMD_ReadFRUData (pUDSSession,
+                                &fru_read_req,
+                                (FRUReadRes_T *) fru_res_data,
+                                timeout);
+    // int i;
+    // for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+    //     printf("%#x ", fru_res_data[2+i]);
+    // printf("\n");
+    if (wRet != 0)
     {
-        FRU->BoardInfo.BoardSerialNum =(uint8_t *) malloc(8);
-        if(FRU->BoardInfo.BoardSerialNum == NULL)
-        {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardSerialNum\n");
-        	return -1;
-        } 
-        strcpy((char*)(FRU->BoardInfo.BoardSerialNum), "\0");
-        pBoardArea += 1;
+        SAFE_FREE (fru_res_data);
+        return wRet;
     }
     else
     {
-        size = GetStringFromType(pBoardArea, &tmpPtr);
-        FRU->BoardInfo.BoardSerialNum =(uint8_t *) malloc(size);
-        if(FRU->BoardInfo.BoardSerialNum == NULL)
-        {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardSerialNum\n");
-             return -1; 
-         }
-        memcpy(FRU->BoardInfo.BoardSerialNum, tmpPtr, size);
-        SAFE_FREE (tmpPtr);
-        pBoardArea += len + 1;
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->BoardInfo.BoardSerialNum;
-    nMallocs++;
-#endif
-    len = GetBits(*pBoardArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->BoardInfo.BoardPartNum =(uint8_t *) malloc(8);
-		if(FRU->BoardInfo.BoardPartNum == NULL)
+        pTmp = (FRUCommonHeader_T *) (fru_res_data + sizeof(FRUReadRes_T));
+        if(pTmp->CommonHeaderFormatVersion != IPMI_FRU_VALID_VERSION)
         {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardPartNum\n");
-             return -1; 
+            SAFE_FREE (fru_res_data);
+            wRet = FRU_INVALID_HEADER_VERSION;
+            return wRet;
         }
-        strcpy((char*)(FRU->BoardInfo.BoardPartNum), "\0");
-        pBoardArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pBoardArea, &tmpPtr);
-        FRU->BoardInfo.BoardPartNum =(uint8_t *) malloc(size);
-		if(FRU->BoardInfo.BoardPartNum == NULL)
+        if(pTmp->BoardInfoAreaStartOffset == 0)
         {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardPartNum\n");
-             return -1; 
+            SAFE_FREE (fru_res_data);
+            wRet = FRU_INVALID_AREA;
+            return wRet;
         }
-        memcpy(FRU->BoardInfo.BoardPartNum, tmpPtr, size);
-        SAFE_FREE (tmpPtr);
-        pBoardArea += len + 1;
-    }
-#ifdef _USE_ARR_MALLOCS_
-   arrMallocs[nMallocs] = FRU->BoardInfo.BoardPartNum;
-   nMallocs++;
-#endif
-    len = GetBits(*pBoardArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->BoardInfo.FRUFileID =(uint8_t *) malloc(8);
-		if(FRU->BoardInfo.FRUFileID == NULL)
-        {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field FRUFileID\n");
-             return -1; 
-        }
-        strcpy((char*)(FRU->BoardInfo.FRUFileID), "\0");
-        pBoardArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pBoardArea, &tmpPtr);
-        FRU->BoardInfo.FRUFileID =(uint8_t *) malloc(size);
-		if(FRU->BoardInfo.FRUFileID == NULL)
+
+        fru_read_req.Offset  = pTmp->BoardInfoAreaStartOffset * 8;
+        *p_fru_size = fru_read_req.CountToRead = sizeof(OemFRUBoardInfo_T);
+        wRet = IPMICMD_ReadFRUData (pUDSSession,
+                                &fru_read_req,
+                                (FRUReadRes_T *) fru_res_data,
+                                timeout);
+        // for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+        //     printf("%#x ", fru_res_data[2+i]);
+        // printf("\n");
+        if (wRet != 0)
         {
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field FRUFileID\n");
-             return -1; 
+            SAFE_FREE (fru_res_data);
+            return wRet;
         }
-        memcpy(FRU->BoardInfo.FRUFileID, tmpPtr, size);
-        SAFE_FREE (tmpPtr);
-        pBoardArea += len + 1;
+
+        memcpy (board_data, (fru_res_data + sizeof(FRUReadRes_T)), 
+            fru_read_req.CountToRead);
     }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->BoardInfo.FRUFileID;
-    nMallocs++;
-#endif
- 
-     FRU->BoardInfo.Total_Board_CustomField = 0;
-     tmpPtr =  pBoardArea;
-     boardAreaLen = (unsigned long int)(((pBuff +(pTmp->BoardInfoAreaStartOffset * 8)) + 
-                             (FRU->BoardInfo.BoardInfoAreaLength * 8)) -1); 
-     while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  boardAreaLen))
-     {
-     	len = GetBits(*tmpPtr, 5, 0);
-     	tmpPtr += len + 1;
-     	FRU->BoardInfo.Total_Board_CustomField += 1;
-     }
-     if(FRU->BoardInfo.Total_Board_CustomField > 0)
-     {
-     	FRU->BoardInfo.CustomFields =(uint8_t **) malloc(FRU->BoardInfo.Total_Board_CustomField * sizeof(char *));
-     	if( FRU->BoardInfo.CustomFields != NULL )
-     	{
-     		while((*pBoardArea!= CUSTOM_AREA_FIELD) && (Index < FRU->BoardInfo.Total_Board_CustomField))
-     		{
-     			len = GetBits(*pBoardArea, 5, 0);
-     			if (len == 0)
-     			{	
-     				//FRU->BoardInfo.CustomFields =(uint8_t **) malloc(1);
-     				FRU->BoardInfo.CustomFields[Index] =(uint8_t *) malloc(8);
-     				if(FRU->BoardInfo.CustomFields[Index] !=  NULL )
-     				{
-     					strcpy((char*)(FRU->BoardInfo.CustomFields[Index]), "\0");
-     				}
-     				else{
-			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
-        			     return -1;
-				    } 
-     				pBoardArea += 1;
-     			}
-     			else
-     			{
-     				size = GetStringFromType(pBoardArea, &tmpPtr);
-     				//FRU->BoardInfo.CustomFields =(uint8_t **) malloc(1);
-     				FRU->BoardInfo.CustomFields[Index] =(uint8_t *) malloc(size);
-     				if(FRU->BoardInfo.CustomFields[Index] != NULL)
-     				{
-     					memcpy((FRU->BoardInfo.CustomFields[Index]), tmpPtr, size);
-     				}
-     				else{
-			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
-			             return -1;
-				    } 
-     				SAFE_FREE (tmpPtr);
-     				pBoardArea += len + 1;
-     				//FRU->BoardInfo.Total_Board_CustomField +=1;
-     			}
-     			++ Index;
-     		}
-     	}
-     	else{
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
-             return -1;
-	    } 
-     }
-   return 0; 
+    
 }
 
-
-static int GetProductInfoArea(uint8_t *pBuff, FRUData_T *FRU)
+uint16_t LIBIPMI_HL_GetFRUProductData(IPMI20_UDS_SESSION_T *pUDSSession,
+                    uint8_t fru_device_id,
+                    uint32_t* p_fru_size,
+                    OemFRUProductInfo_T* product_data,
+                    int timeout)
 {
-    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
-    uint8_t *pProductArea = pBuff +(pTmp->ProductInfoAreaStartOffset * 8);
-    uint8_t len = 0;
-    uint32_t size = 0, productAreaLen = 0;
-    int Index = 0;
-
-    uint8_t *tmpPtr = NULL;
-
-    if(pProductArea == NULL)
-	return -1;
-
-    FRU->ProductInfo.ProductInfoAreaFormatVersion = *pProductArea;
-    pProductArea++;
-    FRU->ProductInfo.ProductInfoAreaLength = *pProductArea;
-    pProductArea++;
-    FRU->ProductInfo.Language = *pProductArea;
-    pProductArea++;
-
-    len = GetBits(*pProductArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ProductInfo.MfrName =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.MfrName == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo MfrName\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.MfrName), "\0");
-        pProductArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.MfrName =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.MfrName == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo MfrName\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.MfrName), (const char *)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.MfrName;
-    nMallocs++;
-#endif
-
-    len = GetBits(*pProductArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ProductInfo.ProductName =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.ProductName == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductName\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductName), "\0");
-        pProductArea += 1;
-    }
-    else
+    uint8_t*                    fru_res_data = NULL;
+    uint32_t                    fru_res_data_len = 0;
+    FRUReadReq_T                fru_read_req;
+
+    uint32_t                    wRet = 0;
+    uint32_t                    fru_size = 0;
+    uint8_t                     BLOCK_OF_DATA_TO_READ = 128;
+    FRUCommonHeader_T *pTmp = NULL;
+  
+    //! Read complete FRU Data now
+    fru_read_req.FRUDeviceID = fru_device_id;
+    fru_read_req.Offset      = 0x00; //! go to start of FRU area
+
+    fru_res_data_len         =  sizeof(FRUReadRes_T) + BLOCK_OF_DATA_TO_READ;
+    fru_res_data             = (uint8_t* ) malloc ( fru_res_data_len );
+    if( fru_res_data == NULL)
     {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.ProductName =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.ProductName == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductName\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductName), (const char*)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
+         printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+         return -1; 
     }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.ProductName;
-    nMallocs++;
-#endif
-    len = GetBits(*pProductArea, 5, 0);
 
-    if (len == 0)
+    fru_read_req.CountToRead = sizeof (FRUCommonHeader_T);
+    printf("---> get_fru_info, fru_size = %d, CountToRead = %d\n", fru_size, fru_read_req.CountToRead);
+    wRet = IPMICMD_ReadFRUData (pUDSSession,
+                                &fru_read_req,
+                                (FRUReadRes_T *) fru_res_data,
+                                timeout);
+    // int i;
+    // for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+    //     printf("%#x ", fru_res_data[2+i]);
+    // printf("\n");
+    if (wRet != 0)
     {
-        FRU->ProductInfo.ProductPartNum =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.ProductPartNum == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductPartNum\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductPartNum), "\0");
-        pProductArea += 1;
+        SAFE_FREE (fru_res_data);
+        return wRet;
     }
     else
     {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.ProductPartNum =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.ProductPartNum == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductPartNum\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductPartNum), (const char*)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.ProductPartNum;
-    nMallocs++;
-#endif
-    len = GetBits(*pProductArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ProductInfo.ProductVersion =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.ProductVersion == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductVersion\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductVersion), "\0");
-        pProductArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.ProductVersion =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.ProductVersion == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductVersion\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductVersion), (const char*)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.ProductVersion;
-    nMallocs++;
-#endif
-    len = GetBits(*pProductArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ProductInfo.ProductSerialNum =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.ProductSerialNum == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductSerialNum\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductSerialNum), "\0");
-        pProductArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.ProductSerialNum =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.ProductSerialNum == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductSerialNum\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.ProductSerialNum), (const char*)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.ProductSerialNum;
-    nMallocs++;
-#endif
-    len = GetBits(*pProductArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ProductInfo.AssetTag =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.AssetTag == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-AssetTag\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.AssetTag), "\0");
-        pProductArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.AssetTag =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.AssetTag == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-AssetTag\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.AssetTag), (const char*)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.AssetTag;
-    nMallocs++;
-#endif
-    len = GetBits(*pProductArea, 5, 0);
-    if (len == 0)
-    {
-        FRU->ProductInfo.FRUFileID =(uint8_t *) malloc(8);
-        if(FRU->ProductInfo.FRUFileID == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-FRUFileID\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.FRUFileID), "\0");
-        pProductArea += 1;
-    }
-    else
-    {
-        size = GetStringFromType(pProductArea, &tmpPtr);
-        FRU->ProductInfo.FRUFileID =(uint8_t *) malloc(size);
-        if(FRU->ProductInfo.FRUFileID == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-FRUFileID\n");
-		     return -1; 
-		}
-        strcpy((char*)(FRU->ProductInfo.FRUFileID), (const char*)tmpPtr);
-        pProductArea += len + 1;
-        SAFE_FREE (tmpPtr);
-    }
-#ifdef _USE_ARR_MALLOCS_
-    arrMallocs[nMallocs] = FRU->ProductInfo.FRUFileID;
-    nMallocs++;
-#endif
-
-
-    FRU->ProductInfo.Total_Product_CustomField = 0;
-    tmpPtr =  pProductArea;
-    productAreaLen = (unsigned long int)(((pBuff +(pTmp->ProductInfoAreaStartOffset * 8)) + 
-                            (FRU->ProductInfo.ProductInfoAreaLength * 8)) -1);
-    while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  productAreaLen))
-    {
-    	len = GetBits(*tmpPtr, 5, 0);
-        tmpPtr += len + 1;
-        FRU->ProductInfo.Total_Product_CustomField += 1;
-    }
-    if(FRU->ProductInfo.Total_Product_CustomField > 0)
-    {
-        FRU->ProductInfo.CustomFields =(uint8_t **) malloc(FRU->ProductInfo.Total_Product_CustomField * sizeof(char *));
-        if(FRU->ProductInfo.CustomFields  != NULL)
+        pTmp = (FRUCommonHeader_T *) (fru_res_data + sizeof(FRUReadRes_T));
+        if(pTmp->CommonHeaderFormatVersion != IPMI_FRU_VALID_VERSION)
         {
-        	while((*pProductArea!= CUSTOM_AREA_FIELD) && (Index < FRU->ProductInfo.Total_Product_CustomField))
-        	{
-        		len = GetBits(*pProductArea, 5, 0);
-        		if (len == 0)
-        		{	
-        			//FRU->ProductInfo.CustomFields =(uint8_t **) malloc(1);
-        			FRU->ProductInfo.CustomFields[Index] =(uint8_t *) malloc(8);
-        			if(FRU->ProductInfo.CustomFields[Index] != NULL)
-        			{
-        				strcpy((char*)(FRU->ProductInfo.CustomFields[Index]), "\0");
-        			}
-        			else{
-			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
-			             return -1;			
-				    } 
-        			pProductArea += 1;
-        		}
-        		else
-        		{
-        			size = GetStringFromType(pProductArea, &tmpPtr);
-        			//FRU->ProductInfo.CustomFields =(uint8_t **) malloc(1);
-        			FRU->ProductInfo.CustomFields[Index] =(uint8_t *) malloc(size);
-        			if(FRU->ProductInfo.CustomFields[Index] != NULL)
-        			{
-        				memcpy((FRU->ProductInfo.CustomFields[Index]), tmpPtr, size);
-        			}
-        			else{
-			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
-			             return -1;
-				    } 
-        			SAFE_FREE (tmpPtr);
-        			pProductArea += len + 1;
-        			//FRU->ProductInfo.Total_Product_CustomField +=1;
-        		}
-        		++ Index;
-        	}
+            SAFE_FREE (fru_res_data);
+            wRet = FRU_INVALID_HEADER_VERSION;
+            return wRet;
+        }
+        if(pTmp->ProductInfoAreaStartOffset == 0)
+        {
+            SAFE_FREE (fru_res_data);
+            wRet = FRU_INVALID_AREA;
+            return wRet;
         }
-        else{
-             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
-             return -1;	
-	    } 
-    }
-
-   return 0;
-
-}
-
-int InterpretFRUData(uint8_t *pBuff, FRUData_T *FRU,uint32_t  FRU_Size)
-{
-	FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
-	int i;
-	printf("\n---> InterpretFRUData Enter: ");
-	for(i=0;i<256;i++)
-		printf("%#x ", pBuff[i]);
-	printf("\n");
-	if (pBuff == NULL)
-	{
-		memset(FRU, 0, sizeof(FRUData_T));
-	}
-	else
-	{
-		//! Copy full Common Header
-		memcpy(&(FRU->CommonHeader), pTmp, sizeof(FRUCommonHeader_T));
-	}
-
-	/**
-	 * ********************** Internal Use Area *******************************
-	 **/
-	if (FRU->CommonHeader.InternalUseAreaStartOffset != 0)
-	{
-		printf("---> InterpretFRUData log1");
-		if((uint32_t)((pTmp->InternalUseAreaStartOffset * 8)) > FRU_Size)
-		{		  	
-			printf(" return error!\n");
-			return FRU_INVALID_AREA;
-		}
-		printf("\n");
-		GetInternalUseArea(pBuff, FRU);
-	}
-
-	/**
-	 * ********************** Chassis Info Area *******************************
-	 **/
-	if (FRU->CommonHeader.ChassisInfoAreaStartOffset != 0)
-	{
-		printf("---> InterpretFRUData log2");
-		if((uint32_t)((pTmp->ChassisInfoAreaStartOffset * 8)) > FRU_Size)
-		{		  	
-			printf(" return error!\n");
-			return FRU_INVALID_AREA;
-		}
-		printf("\n");
-		if(GetChassisInfoArea(pBuff, FRU)!= 0)
-		{
-                      return -1;
-		}
-	}
-
-	/**
-	 * ********************** Board Info Area *******************************
-	 **/
-	if (FRU->CommonHeader.BoardInfoAreaStartOffset != 0)
-	{
-		printf("---> InterpretFRUData log3");
-		if((uint32_t)((pTmp->BoardInfoAreaStartOffset * 8)) > FRU_Size)
-		{		  	
-			printf(" return error!\n");
-			return FRU_INVALID_AREA;
-		}
-		printf("\n");
-		if(GetBoardInfoArea(pBuff, FRU)!=0)
-		{
-                      return -1;
-		}
-	}
-
-	/**
-	 * ********************** Product Info Area *******************************
-	 **/
-	if (FRU->CommonHeader.ProductInfoAreaStartOffset != 0)
-	{
-		printf("---> InterpretFRUData log4");
-		if((uint32_t)((pTmp->ProductInfoAreaStartOffset * 8)) > FRU_Size)
-		{		  	
-			printf(" return error!\n");
-			return FRU_INVALID_AREA;
-		}
-		
-		if( GetProductInfoArea(pBuff, FRU) != 0)
-		{
-			printf("GetProductInfoArea return error!\n");
-                      return -1;
-		}
-	}
-	
-return 0;
-
-}
-
-
-
-
-static uint16_t get_fru_info (IPMI20_UDS_SESSION_T* pUDSSession,
-				  uint8_t fru_device_id,
-				  uint32_t* p_fru_size,
-				  FRUData_T* fru_data,
-				  int timeout)
-{
-	FRUInventoryAreaInfoReq_T 	fru_inv_area_req;
-	FRUInventoryAreaInfoRes_T 	fru_inv_area_res;
-	uint8_t*							pFRUBuff = NULL;
-	uint8_t*							tempFRUBuff = NULL;
-	uint8_t*							fru_res_data = NULL;
-	uint32_t							fru_res_data_len = 0;
-	FRUReadReq_T				fru_read_req;
-
-	uint32_t							wRet = 0;
-	uint32_t							fru_size = 0;
-	uint8_t								BLOCK_OF_DATA_TO_READ = 128;
-	uint8_t                         isValidFRU = 0;
-	FRUCommonHeader_T *pTmp = NULL;
-	int i = 0;
-
-	// if(pUDSSession->byMediumType == IPMB_MEDIUM)
-	// {
-	// 	BLOCK_OF_DATA_TO_READ = 24;	//IPMB max message packet is 32 bytes. 
-	// 											//24 + message header + completion code + checksum2 = 32
-	// }
-	/**
-	 * returns the overall size(in bytes) of the FRU
-	 * inventory area in this device
-	 **/
-	fru_inv_area_req.FRUDeviceID = fru_device_id;
-
-	wRet = IPMICMD_GetFRUInventoryAreaInfo (pUDSSession,
-											&fru_inv_area_req,
-											&fru_inv_area_res,
-											timeout);
-	if ((wRet != 0) &&((fru_inv_area_res.CompletionCode & 0xFF) != 0xCB))
-	{
-		printf("---> error log 1, wRet = %#x\n", wRet);
-		goto _exit_get_fru_info_;
-	}
-	else
-	{
-		if ((fru_inv_area_res.CompletionCode & 0xFF) == 0xCB)
-		{
-			printf("---> error log 2\n");
-			goto InterpretFRU;
-		}
-
-		*p_fru_size = fru_size = (uint32_t)fru_inv_area_res.Size;
-		printf("---> fru_size = %d\n", fru_size);
-
-		//! Allocate the buffer size to read FRU data for this FRU device
-		tempFRUBuff = pFRUBuff 	= (uint8_t* ) malloc (fru_size);
-		if( tempFRUBuff == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
-		     return -1; 
-		}
-
-		if (0 == pFRUBuff ) goto _exit_get_fru_info_;
-
-
-		//! Read complete FRU Data now
-		fru_read_req.FRUDeviceID = fru_device_id;
-		fru_read_req.Offset 	 = 0x00; //! go to start of FRU area
-
-		fru_res_data_len		 = 	sizeof(FRUReadRes_T) + BLOCK_OF_DATA_TO_READ;
-		fru_res_data 			 = (uint8_t* ) malloc ( fru_res_data_len );
-		if( fru_res_data == NULL)
-		{
-		     printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
-		     return -1; 
-		}
-
-		if (NULL == fru_res_data)
-		{
-			SAFE_FREE (tempFRUBuff);
-			goto _exit_get_fru_info_;
-		}
-
-		// Initially read only the FRU header.
-		fru_read_req.CountToRead = sizeof (FRUCommonHeader_T);
-		
-		while (fru_size) //! while there is data to read
-		{
-			printf("---> get_fru_info log1, fru_size = %d, CountToRead = %d\n", fru_size, fru_read_req.CountToRead);
-			wRet = IPMICMD_ReadFRUData (pUDSSession,
-										&fru_read_req,
-										(FRUReadRes_T *) fru_res_data,
-										timeout);
-			for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
-				printf("%#x ", fru_res_data[2+i]);
-			printf("\n");
-			if (wRet != 0)
-			{
-				SAFE_FREE (fru_res_data);
-				SAFE_FREE (tempFRUBuff);
-				goto _exit_get_fru_info_;
-
-			}
-			else
-			{
-			    
-				// Validate the FRU Header and proceed for further bytes.
-				if (0 == isValidFRU)
-				{
-					printf("---> log log 2\n");
-					pTmp = (FRUCommonHeader_T *) (fru_res_data + sizeof(FRUReadRes_T));
-					if(pTmp->CommonHeaderFormatVersion != IPMI_FRU_VALID_VERSION)
-					{
-						SAFE_FREE (fru_res_data);
-						SAFE_FREE (tempFRUBuff);
-						wRet = FRU_INVALID_HEADER_VERSION;
-						goto _exit_get_fru_info_;
-					}
-					isValidFRU = 1;
-				}
-				memcpy (pFRUBuff,
-						(fru_res_data + sizeof(FRUReadRes_T)),
-						fru_read_req.CountToRead);
-				pFRUBuff += (fru_read_req.CountToRead);
-			}
-			
-			//! recalculate the size left out
-			fru_size 			-= fru_read_req.CountToRead;
-			fru_read_req.Offset  = htoipmi_u16((ipmitoh_u16(fru_read_req.Offset) + fru_read_req.CountToRead));
-			
-			//! read only 128 bytes at-a-time
-			fru_read_req.CountToRead = ( (fru_size > BLOCK_OF_DATA_TO_READ) ? BLOCK_OF_DATA_TO_READ : fru_size );
-		}
-		SAFE_FREE (fru_res_data);
-
-InterpretFRU:
-		memset(fru_data, 0, sizeof(FRUData_T));
-
-		//! Interpret FRU Data
-		wRet = InterpretFRUData (tempFRUBuff, fru_data,*p_fru_size);
-		if(wRet!=0)
-			goto _exit_get_fru_info_;
-
-		SAFE_FREE (tempFRUBuff);
-	}
-
-_exit_get_fru_info_:
-	return wRet;
-}
-
-uint16_t LIBIPMI_HL_GetFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint8_t fru_device_id,
-				  	uint32_t* p_fru_size,
-				  	FRUData_T* fru_data,
-					int timeout)
-{
-	return(get_fru_info(pUDSSession,fru_device_id,p_fru_size,fru_data,timeout));
-
-}
-
-/*!
-  * @brief       Free the fru data which includes chassis, board and product informations.
-  * @param[in] fru_data - which contains the fru data.
-  */
-void LIBIPMI_HL_FreeFRUData( FRUData_T* fru_data )
-{
-    int i;
-    
-    //Chassis type
-	SAFE_FREE(fru_data->ChassisInfo.ChassisType);
-    
-    //Chassis Part Num
-    SAFE_FREE(fru_data->ChassisInfo.ChassisPartNum);
-
-    //Chassis Serial Num
-    SAFE_FREE(fru_data->ChassisInfo.ChassisSerialNum)
-
-    // Chassis Custom field
-    for (i = 0; i< fru_data->ChassisInfo.Total_Chassis_CustomField; i++)
-    {
-        SAFE_FREE(fru_data->ChassisInfo.CustomFields[i]);
-    }
-    SAFE_FREE(fru_data->ChassisInfo.CustomFields);
-    
-    //InternalInof Data
-    SAFE_FREE(fru_data->InternalInfo.Data);
-    
-    // Board MfrName
-    SAFE_FREE(fru_data->BoardInfo.BoardMfr);
-
-    // Borad product name
-    SAFE_FREE(fru_data->BoardInfo.BoardProductName);
-
-    //Board Serial Num
-    SAFE_FREE(fru_data->BoardInfo.BoardSerialNum);
-
-    //Board Part Num
-    SAFE_FREE(fru_data->BoardInfo.BoardPartNum);
 
-    //Board FRUID
-    SAFE_FREE(fru_data->BoardInfo.FRUFileID);
+        fru_read_req.Offset  = pTmp->ProductInfoAreaStartOffset * 8;
+        *p_fru_size = fru_read_req.CountToRead = sizeof(OemFRUProductInfo_T);
+        wRet = IPMICMD_ReadFRUData (pUDSSession,
+                                &fru_read_req,
+                                (FRUReadRes_T *) fru_res_data,
+                                timeout);
+        // for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+        //     printf("%#x ", fru_res_data[2+i]);
+        // printf("\n");
+        if (wRet != 0)
+        {
+            SAFE_FREE (fru_res_data);
+            return wRet;
+        }
 
-    //Board Custom fields
-    for (i = 0; i< fru_data->BoardInfo.Total_Board_CustomField; i++)
-    {
-        SAFE_FREE(fru_data->BoardInfo.CustomFields[i]);
+        memcpy (product_data, (fru_res_data + sizeof(FRUReadRes_T)), 
+            fru_read_req.CountToRead);
     }
-    SAFE_FREE(fru_data->BoardInfo.CustomFields);
-
-    //Product MfrName
-    SAFE_FREE(fru_data->ProductInfo.MfrName);
     
-    //Product Name
-    SAFE_FREE(fru_data->ProductInfo.ProductName);
-
-    //Product Part Num
-    SAFE_FREE(fru_data->ProductInfo.ProductPartNum);
-
-    // Freeing Product version
-    SAFE_FREE(fru_data->ProductInfo.ProductVersion);
-
-    //Product Serial Num
-    SAFE_FREE(fru_data->ProductInfo.ProductSerialNum);
-
-    //Product asset tag
-    SAFE_FREE(fru_data->ProductInfo.AssetTag);
-
-    // Product FRUID
-    SAFE_FREE(fru_data->ProductInfo.FRUFileID);
-
-    // Product Custom filed
-    for (i = 0; i< fru_data->ProductInfo.Total_Product_CustomField; i++)
-    {
-        SAFE_FREE(fru_data->ProductInfo.CustomFields[i]);
-    }
-    SAFE_FREE(fru_data->ProductInfo.CustomFields);
- }
-
+}

+ 5 - 0
app/goahead-3.6.5/src/web_interface/inc/fru.h

@@ -2,5 +2,10 @@
 #define __FRU_H__
 
 #include "goahead.h"
+//void getFruInfo(Webs *wp);
+
+void getFruChassisInfo(Webs *wp);
+void getFruBoardInfo(Webs *wp);
+void getFruProductInfo(Webs *wp);
 
 #endif /* __FRU_H__ */

+ 811 - 0
app/goahead-3.6.5/src/web_interface/src/fru.c

@@ -0,0 +1,811 @@
+#include "fru.h"
+#include "com_IPMI_FRU.h"
+#include    "goahead.h"
+#include    "libipmi_IPM.h"
+#include    "com_IPMIDefs.h"
+#include    "ResultUtils.h"
+#include    "cJSON.h"
+#include    "libipmi_storlead_OEM.h"
+#include    "libsensor.h"
+#include    <stdio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include "libipmi_ChassisDevice.h"
+#include <time.h>
+#include "com_BmcType.h"
+#include <string.h>
+#include "libipmi_fru.h"
+
+
+/*获取FRU信息*/
+void getFruChassisInfo(Webs *wp)
+{
+	int wRet = 0;
+	uint32_t fru_size;
+	OemFRUChassisInfo_T chassis_data;
+	uint8_t fruIndex = 1;	//FRUDeviceID
+	char *pTmpStr = NULL;
+	uint8_t strLen = 0;
+
+	char *_chassisPartNum=NULL;
+	char *_chassisSerialNum=NULL;
+	char *_chassisType=NULL;
+	char *_chassisCustomField=NULL;
+	IPMI20_UDS_SESSION_T    UDSSession;
+
+	//Create session
+	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+	wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,&chassis_data,DEFAULT_TIMEOUT);
+	if(wRet==FRU_INVALID_HEADER_VERSION)
+	{
+		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
+	}
+	if(wRet==FRU_INVALID_AREA)
+	{
+		printf("FRU Invalid Area for ID : %d\n", fruIndex);
+	}
+	if(wRet!=0)
+	{
+		printf("Device not present for ID : %d\n", fruIndex);
+	}
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+    int i;
+    uint8_t *pDebug = (uint8_t*)&chassis_data;
+    printf("chassis_info %d: ", fru_size);
+    for(i=0;i<fru_size;i++)
+    	printf("%#x ", pDebug[i]);
+    printf("\n");
+	//_chassisPartNum
+	strLen = chassis_data.Data[0] & 0x3F;
+	pTmpStr = &chassis_data.Data[1];
+	_chassisPartNum = walloc(strLen+1);
+	memset(_chassisPartNum, 0, strLen+1);
+	strncpy(_chassisPartNum, pTmpStr, strLen);
+	
+	//_chassisSerialNum
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_chassisSerialNum = walloc(strLen+1);
+	memset(_chassisSerialNum, 0, strLen+1);
+	strncpy(_chassisSerialNum, pTmpStr, strLen);
+	
+	//extra info
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_chassisCustomField = walloc(strLen+1);
+	memset(_chassisCustomField, 0, strLen+1);
+	strncpy(_chassisCustomField, pTmpStr, strLen);
+
+	//_chassisType
+	_chassisType = walloc(30);
+	memset(_chassisType, 0, 30);
+	switch(chassis_data.ChassisType)
+	{
+	case Other:
+		strcpy(_chassisType, "Other");
+		break;
+	case ChassisUnknown:
+		strcpy(_chassisType, "ChassisUnknown");
+		break;
+	case Desktop:
+		strcpy(_chassisType, "Desktop");
+		break;
+	case LowProfileDesktop:
+		strcpy(_chassisType, "LowProfileDesktop");
+		break;
+	case MiniTower:
+		strcpy(_chassisType, "MiniTower");
+		break;
+	case Tower:
+		strcpy(_chassisType, "Tower");
+		break;
+	case Portable:
+		strcpy(_chassisType, "Portable");
+		break;
+	case Notebook:
+		strcpy(_chassisType, "Notebook");
+		break;
+	case HandHeld:
+		strcpy(_chassisType, "HandHeld");
+		break;
+	case DockingStation:
+		strcpy(_chassisType, "DockingStation");
+		break;
+	case AllinOne:
+		strcpy(_chassisType, "AllinOne");
+		break;
+	case SubNotebook:
+		strcpy(_chassisType, "SubNotebook");
+		break;
+	case SpaceSaving:
+		strcpy(_chassisType, "SpaceSaving");
+		break;
+	case LunchBox:
+		strcpy(_chassisType, "LunchBox");
+		break;
+	case MainServerChassis:
+		strcpy(_chassisType, "MainServerChassis");
+		break;
+	case SubChassis:
+		strcpy(_chassisType, "SubChassis");
+		break;
+	case BusExpansionChassis:
+		strcpy(_chassisType, "BusExpansionChassis");
+		break;
+	case PeripheralChassis:
+		strcpy(_chassisType, "PeripheralChassis");
+		break;
+	case RAIDChassis:
+		strcpy(_chassisType, "RAIDChassis");
+		break;
+	case RackMountChassis:
+		strcpy(_chassisType, "RackMountChassis");
+		break;
+	default:
+		strcpy(_chassisType, "Unknown");
+		break;
+	}		
+
+
+	char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+
+    //data
+    cJSON_AddStringToObject(data, "Type", _chassisType);
+    cJSON_AddStringToObject(data, "PN", _chassisPartNum);
+    cJSON_AddStringToObject(data, "SN", _chassisSerialNum);
+    cJSON_AddStringToObject(data, "OEM", _chassisCustomField);
+
+    pStr = cJSON_Print(root);
+    
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
+    websWriteEndHeaders(wp);
+    int ret;
+    websWrite(wp, "%s", pStr); printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
+    if(ret != 1)
+    	printf("websFlush ret = %d\n", ret);
+    
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+
+    if(_chassisPartNum) 		wfree(_chassisPartNum);
+	if(_chassisSerialNum) 		wfree(_chassisSerialNum);
+	if(_chassisType) 			wfree(_chassisType);
+	if(_chassisCustomField) 	wfree(_chassisCustomField);
+	
+	printf("getFruChassisInfo over!\n");
+}
+
+void getFruBoardInfo(Webs *wp)
+{
+	int wRet = 0;
+	uint32_t fru_size;
+	OemFRUBoardInfo_T board_data;
+	uint8_t fruIndex = 1;	//FRUDeviceID
+	char *pTmpStr = NULL;
+	uint8_t strLen = 0;
+	time_t tval;
+	//char *mfrdate = NULL;
+	static const uint32_t  secs_from_1970_1996 = 820450800;
+
+	char *_boardMfr=NULL;
+	char *_boardProductName=NULL;
+	char *_boardSerialNum=NULL;
+	char *_boardPartNum=NULL;
+	char *_boardCustomField=NULL;
+	char *_MfrDate = NULL;
+
+	IPMI20_UDS_SESSION_T    UDSSession;
+
+	//Create session
+	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+	wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+	if(wRet==FRU_INVALID_HEADER_VERSION)
+	{
+		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
+	}
+	if(wRet==FRU_INVALID_AREA)
+	{
+		printf("FRU Invalid Area for ID : %d\n", fruIndex);
+	}
+	if(wRet!=0)
+	{
+		printf("Device not present for ID : %d\n", fruIndex);
+	}
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+	//Manufactor
+	strLen = board_data.Data[0] & 0x3F;
+	pTmpStr = &board_data.Data[1];
+	_boardMfr = walloc(strLen+1);
+	memset(_boardMfr, 0, strLen+1);
+	strncpy(_boardMfr, pTmpStr, strLen);
+
+	//Product name
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_boardProductName = walloc(strLen+1);
+	memset(_boardProductName, 0, strLen+1);
+	strncpy(_boardProductName, pTmpStr, strLen);
+
+	//Serial number
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_boardSerialNum = walloc(strLen+1);
+	memset(_boardSerialNum, 0, strLen+1);
+	strncpy(_boardSerialNum, pTmpStr, strLen);
+
+	//Part number
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_boardPartNum = walloc(strLen+1);
+	memset(_boardPartNum, 0, strLen+1);
+	strncpy(_boardPartNum, pTmpStr, strLen);
+
+	//FILE ID
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+
+	//Extra Info
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_boardCustomField = walloc(strLen+1);
+	memset(_boardCustomField, 0, strLen+1);
+	strncpy(_boardCustomField, pTmpStr, strLen);
+
+	//Date
+	tval = ((board_data.MfgDateTime[2] << 16) + (board_data.MfgDateTime[1] << 8) + (board_data.MfgDateTime[0]));
+	tval = tval * 60;
+	tval = tval + secs_from_1970_1996;
+	_MfrDate = asctime(localtime(&tval));
+
+	char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+
+    //data
+    cJSON_AddStringToObject(data, "Date", _MfrDate);
+    cJSON_AddStringToObject(data, "Mfr", _boardMfr);
+    cJSON_AddStringToObject(data, "Name", _boardProductName);
+    cJSON_AddStringToObject(data, "SN", _boardSerialNum);
+    cJSON_AddStringToObject(data, "PN", _boardPartNum);
+    cJSON_AddStringToObject(data, "OEM", _boardCustomField);
+
+    pStr = cJSON_Print(root);
+    
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
+    websWriteEndHeaders(wp);
+    int ret;
+    websWrite(wp, "%s", pStr); printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
+    if(ret != 1)
+    	printf("websFlush ret = %d\n", ret);
+    
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+
+    if(_boardMfr) 				wfree(_boardMfr);
+	if(_boardProductName) 		wfree(_boardProductName);
+	if(_boardSerialNum) 		wfree(_boardSerialNum);
+	if(_boardPartNum) 			wfree(_boardPartNum);
+	if(_boardCustomField) 		wfree(_boardCustomField);
+	if(_MfrDate) 				wfree(_MfrDate);
+	
+	printf("getFruChassisInfo over!\n");
+
+}
+
+void getFruProductInfo(Webs *wp)
+{
+	int wRet = 0;
+	uint32_t fru_size;
+	OemFRUProductInfo_T product_data;
+	uint8_t fruIndex = 1;	//FRUDeviceID
+	char *pTmpStr = NULL;
+	uint8_t strLen = 0;
+	
+	char *_ProductName=NULL;
+	char *_ProductPartNum=NULL;
+	char *_ProductVersion=NULL;
+	char *_ProductSerialNum=NULL;
+	char *_productCustomField=NULL;
+	char *_MfrName=NULL;
+	IPMI20_UDS_SESSION_T    UDSSession;
+
+	//Create session
+	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+	wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
+	if(wRet==FRU_INVALID_HEADER_VERSION)
+	{
+		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
+	}
+	if(wRet==FRU_INVALID_AREA)
+	{
+		printf("FRU Invalid Area for ID : %d\n", fruIndex);
+	}
+	if(wRet!=0)
+	{
+		printf("Device not present for ID : %d\n", fruIndex);
+	}
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+	//Manufactor
+	strLen = product_data.Data[0] & 0x3F;
+	pTmpStr = &product_data.Data[1];
+	_MfrName = walloc(strLen+1);
+	memset(_MfrName, 0, strLen+1);
+	strncpy(_MfrName, pTmpStr, strLen);
+
+	//Product Name
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_ProductName = walloc(strLen+1);
+	memset(_ProductName, 0, strLen+1);
+	strncpy(_ProductName, pTmpStr, strLen);
+
+	//Part Number
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_ProductPartNum = walloc(strLen+1);
+	memset(_ProductPartNum, 0, strLen+1);
+	strncpy(_ProductPartNum, pTmpStr, strLen);
+
+	//Version
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_ProductVersion = walloc(strLen+1);
+	memset(_ProductVersion, 0, strLen+1);
+	strncpy(_ProductVersion, pTmpStr, strLen);
+
+	//Serial Number
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_ProductSerialNum = walloc(strLen+1);
+	memset(_ProductSerialNum, 0, strLen+1);
+	strncpy(_ProductSerialNum, pTmpStr, strLen);
+
+	//Assert Tag
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	// _AssetTag = walloc(strLen+1);
+	// memset(_AssetTag, 0, strLen+1);
+	// strncpy(_AssetTag, pTmpStr, strLen);
+
+	//File ID
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	// _FRUFileID = walloc(strLen+1);
+	// memset(_FRUFileID, 0, strLen+1);
+	// strncpy(_FRUFileID, pTmpStr, strLen);
+
+	//Extra info
+	pTmpStr += strLen;
+	strLen = pTmpStr[0] & 0x3F;
+	pTmpStr++;
+	_productCustomField = walloc(strLen+1);
+	memset(_productCustomField, 0, strLen+1);
+	strncpy(_productCustomField, pTmpStr, strLen);
+
+	char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+    cJSON_AddStringToObject(data, "Mfr", _MfrName);
+    cJSON_AddStringToObject(data, "Name", _ProductName);
+    cJSON_AddStringToObject(data, "PN", _ProductPartNum);
+    cJSON_AddStringToObject(data, "Ver", _ProductVersion);
+    cJSON_AddStringToObject(data, "SN", _ProductSerialNum);
+    cJSON_AddStringToObject(data, "OEM", _productCustomField);
+    pStr = cJSON_Print(root);
+    
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
+    websWriteEndHeaders(wp);
+    int ret;
+    websWrite(wp, "%s", pStr); printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
+    if(ret != 1)
+    	printf("websFlush ret = %d\n", ret);
+    
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+
+    if(_MfrName) 				wfree(_MfrName);
+    if(_ProductName) 			wfree(_ProductName);
+	if(_ProductPartNum) 		wfree(_ProductPartNum);
+	if(_ProductVersion) 		wfree(_ProductVersion);
+	if(_ProductSerialNum) 		wfree(_ProductSerialNum);
+	if(_productCustomField) 	wfree(_productCustomField);
+	
+	printf("getFruChassisInfo over!\n");
+
+}
+
+
+// /*获取FRU信息*/
+// void getFruInfo(Webs *wp)
+// {
+// 	int wRet = 0;
+// 	uint32_t fru_size;
+// 	OemFRUData_T fru_data;
+// 	uint8_t fruIndex = 1;	//FRUDeviceID
+// 	char *pTmpStr = NULL;
+// 	uint8_t strLen = 0;
+
+// 	time_t tval;
+// 	//char *mfrdate = NULL;
+// 	static const uint32_t  secs_from_1970_1996 = 820450800;
+
+// 	char *_chassisPartNum=NULL;
+// 	char *_chassisSerialNum=NULL;
+// 	char *_chassisType=NULL;
+// 	char *_chassisCustomField=NULL;
+// 	char *_boardMfr=NULL;
+// 	char *_boardProductName=NULL;
+// 	char *_boardSerialNum=NULL;
+// 	char *_boardPartNum=NULL;
+// 	char *_boardCustomField=NULL;
+// 	char *_MfrName=NULL;
+// 	char *_MfrDate = NULL;
+// 	char *_ProductName=NULL;
+// 	char *_ProductPartNum=NULL;
+// 	char *_ProductVersion=NULL;
+// 	char *_ProductSerialNum=NULL;
+// 	char *_productCustomField=NULL;
+// 	IPMI20_UDS_SESSION_T    UDSSession;
+
+// 	//Create session
+// 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+// 	wRet = LIBIPMI_HL_GetFRUData(&UDSSession,fruIndex,&fru_size,&fru_data,DEFAULT_TIMEOUT);
+// 	if(wRet==FRU_INVALID_HEADER_VERSION)
+// 	{
+// 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
+// 	}
+// 	if(wRet==FRU_INVALID_AREA)
+// 	{
+// 		printf("FRU Invalid Area for ID : %d\n", fruIndex);
+// 	}
+// 	if(wRet!=0)
+// 	{
+// 		printf("Device not present for ID : %d\n", fruIndex);
+// 	}
+//     //Close session
+//     LIBIPMI_CloseSession(&UDSSession );
+
+// 	//Get ChassisInfo
+// 	if(fru_data.CommonHeader.ChassisInfoAreaStartOffset != 0)
+// 	{
+// 		//_chassisPartNum
+// 		strLen = fru_data.ChassisInfo.Data[0] & 0x3F;
+// 		pTmpStr = &fru_data.ChassisInfo.Data[1];
+// 		_chassisPartNum = walloc(strLen+1);
+// 		memset(_chassisPartNum, 0, strLen+1);
+// 		strncpy(_chassisPartNum, pTmpStr, strLen);
+		
+// 		//_chassisSerialNum
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_chassisSerialNum = walloc(strLen+1);
+// 		memset(_chassisSerialNum, 0, strLen+1);
+// 		strncpy(_chassisSerialNum, pTmpStr, strLen);
+		
+// 		//extra info
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_chassisCustomField = walloc(strLen+1);
+// 		memset(_chassisCustomField, 0, strLen+1);
+// 		strncpy(_chassisCustomField, pTmpStr, strLen);
+
+// 		//_chassisType
+// 		_chassisType = walloc(30);
+// 		memset(_chassisType, 0, 30);
+// 		switch(fru_data.ChassisInfo.ChassisType)
+// 		{
+// 		case Other:
+// 			strcpy(_chassisType, "Other");
+// 			break;
+//     	case ChassisUnknown:
+// 			strcpy(_chassisType, "ChassisUnknown");
+// 			break;
+//     	case Desktop:
+// 			strcpy(_chassisType, "Desktop");
+// 			break;
+//     	case LowProfileDesktop:
+// 			strcpy(_chassisType, "LowProfileDesktop");
+// 			break;
+//     	case MiniTower:
+// 			strcpy(_chassisType, "MiniTower");
+// 			break;
+//     	case Tower:
+// 			strcpy(_chassisType, "Tower");
+// 			break;
+//     	case Portable:
+// 			strcpy(_chassisType, "Portable");
+// 			break;
+//     	case Notebook:
+// 			strcpy(_chassisType, "Notebook");
+// 			break;
+//     	case HandHeld:
+// 			strcpy(_chassisType, "HandHeld");
+// 			break;
+//     	case DockingStation:
+// 			strcpy(_chassisType, "DockingStation");
+// 			break;
+//     	case AllinOne:
+// 			strcpy(_chassisType, "AllinOne");
+// 			break;
+//     	case SubNotebook:
+// 			strcpy(_chassisType, "SubNotebook");
+// 			break;
+//     	case SpaceSaving:
+// 			strcpy(_chassisType, "SpaceSaving");
+// 			break;
+//     	case LunchBox:
+// 			strcpy(_chassisType, "LunchBox");
+// 			break;
+//     	case MainServerChassis:
+// 			strcpy(_chassisType, "MainServerChassis");
+// 			break;
+//     	case SubChassis:
+// 			strcpy(_chassisType, "SubChassis");
+// 			break;
+//     	case BusExpansionChassis:
+// 			strcpy(_chassisType, "BusExpansionChassis");
+// 			break;
+//     	case PeripheralChassis:
+// 			strcpy(_chassisType, "PeripheralChassis");
+// 			break;
+//     	case RAIDChassis:
+// 			strcpy(_chassisType, "RAIDChassis");
+// 			break;
+//     	case RackMountChassis:
+// 			strcpy(_chassisType, "RackMountChassis");
+// 			break;
+// 		default:
+// 			strcpy(_chassisType, "Unknown");
+// 			break;
+// 		}		
+// 	}
+	
+// 	//Get BoardInfo
+// 	if(fru_data.CommonHeader.BoardInfoAreaStartOffset != 0)
+// 	{
+// 		//Manufactor
+// 		strLen = fru_data.BoardInfo.Data[0] & 0x3F;
+// 		pTmpStr = &fru_data.BoardInfo.Data[1];
+// 		_boardMfr = walloc(strLen+1);
+// 		memset(_boardMfr, 0, strLen+1);
+// 		strncpy(_boardMfr, pTmpStr, strLen);
+
+// 		//Product name
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_boardProductName = walloc(strLen+1);
+// 		memset(_boardProductName, 0, strLen+1);
+// 		strncpy(_boardProductName, pTmpStr, strLen);
+
+// 		//Serial number
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_boardSerialNum = walloc(strLen+1);
+// 		memset(_boardSerialNum, 0, strLen+1);
+// 		strncpy(_boardSerialNum, pTmpStr, strLen);
+
+// 		//Part number
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_boardPartNum = walloc(strLen+1);
+// 		memset(_boardPartNum, 0, strLen+1);
+// 		strncpy(_boardPartNum, pTmpStr, strLen);
+
+// 		//FILE ID
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+
+// 		//Extra Info
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_boardCustomField = walloc(strLen+1);
+// 		memset(_boardCustomField, 0, strLen+1);
+// 		strncpy(_boardCustomField, pTmpStr, strLen);
+
+// 		//Date
+// 		tval = ((fru_data.BoardInfo.MfgDateTime[2] << 16) + (fru_data.BoardInfo.MfgDateTime[1] << 8) + (fru_data.BoardInfo.MfgDateTime[0]));
+// 		tval = tval * 60;
+// 		tval = tval + secs_from_1970_1996;
+// 		_MfrDate = asctime(localtime(&tval));
+// 	}
+
+// 	//Get Product Info
+// 	if(fru_data.CommonHeader.ProductInfoAreaStartOffset != 0)
+// 	{
+// 		//Manufactor
+// 		strLen = fru_data.ProductInfo.Data[0] & 0x3F;
+// 		pTmpStr = &fru_data.ProductInfo.Data[1];
+// 		_MfrName = walloc(strLen+1);
+// 		memset(_MfrName, 0, strLen+1);
+// 		strncpy(_MfrName, pTmpStr, strLen);
+
+// 		//Product Name
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_ProductName = walloc(strLen+1);
+// 		memset(_ProductName, 0, strLen+1);
+// 		strncpy(_ProductName, pTmpStr, strLen);
+
+// 		//Part Number
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_ProductPartNum = walloc(strLen+1);
+// 		memset(_ProductPartNum, 0, strLen+1);
+// 		strncpy(_ProductPartNum, pTmpStr, strLen);
+
+// 		//Version
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_ProductVersion = walloc(strLen+1);
+// 		memset(_ProductVersion, 0, strLen+1);
+// 		strncpy(_ProductVersion, pTmpStr, strLen);
+
+// 		//Serial Number
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_ProductSerialNum = walloc(strLen+1);
+// 		memset(_ProductSerialNum, 0, strLen+1);
+// 		strncpy(_ProductSerialNum, pTmpStr, strLen);
+
+// 		//Assert Tag
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		// _AssetTag = walloc(strLen+1);
+// 		// memset(_AssetTag, 0, strLen+1);
+// 		// strncpy(_AssetTag, pTmpStr, strLen);
+
+// 		//File ID
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		// _FRUFileID = walloc(strLen+1);
+// 		// memset(_FRUFileID, 0, strLen+1);
+// 		// strncpy(_FRUFileID, pTmpStr, strLen);
+
+// 		//Extra info
+// 		pTmpStr += strLen;
+// 		strLen = pTmpStr[0] & 0x3F;
+// 		pTmpStr++;
+// 		_productCustomField = walloc(strLen+1);
+// 		memset(_productCustomField, 0, strLen+1);
+// 		strncpy(_productCustomField, pTmpStr, strLen);
+// 	}
+
+// 	char *pStr1, *pStr2, *pStr3;
+//     cJSON * chassis =  cJSON_CreateObject();
+//     cJSON * board =  cJSON_CreateObject();
+//     cJSON * product =  cJSON_CreateObject();
+//     //chassis
+//     cJSON_AddStringToObject(chassis, "Type", _chassisType);
+//     cJSON_AddStringToObject(chassis, "PN", _chassisPartNum);
+//     cJSON_AddStringToObject(chassis, "SN", _chassisSerialNum);
+//     cJSON_AddStringToObject(chassis, "OEM", _chassisCustomField);
+
+//     //board
+//     cJSON_AddStringToObject(board, "Date", _MfrDate);
+//     cJSON_AddStringToObject(board, "Mfr", _boardMfr);
+//     cJSON_AddStringToObject(board, "Name", _boardProductName);
+//     cJSON_AddStringToObject(board, "SN", _boardSerialNum);
+//     cJSON_AddStringToObject(board, "PN", _boardPartNum);
+//     cJSON_AddStringToObject(board, "OEM", _boardCustomField);
+
+//     //product
+//     cJSON_AddStringToObject(product, "Mfr", _MfrName);
+//     cJSON_AddStringToObject(product, "Name", _ProductName);
+//     cJSON_AddStringToObject(product, "PN", _ProductPartNum);
+//     cJSON_AddStringToObject(product, "Ver", _ProductVersion);
+//     cJSON_AddStringToObject(product, "SN", _ProductSerialNum);
+//     cJSON_AddStringToObject(product, "OEM", _productCustomField);
+
+//     pStr1 = cJSON_Print(chassis);
+//     pStr2 = cJSON_Print(board);
+//     pStr3 = cJSON_Print(product);
+    
+//     websSetStatus(wp, 200);
+//     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
+//     websWriteEndHeaders(wp);
+//     int ret;
+//     //websWrite(wp, "{\n");
+//     websWrite(wp, "%s", pStr1); printf("---> cJSON Str1: %d \n%s\n", strlen(pStr1), pStr1);
+//     //websWrite(wp, "%s", pStr2); printf("---> cJSON Str2: %d \n%s\n", strlen(pStr2), pStr2);
+//     //websWrite(wp, "%s", pStr3); printf("---> cJSON Str3: %d \n%s\n", strlen(pStr3), pStr3);
+//     //websWrite(wp, "msg:\"\",\ncode:200\n}");
+    
+//     ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
+//     //if(ret != 1)
+//     	printf("websFlush ret = %d\n", ret);
+    
+//     websDone(wp);
+
+//     if(pStr1)
+//         wfree(pStr1);
+//     if(pStr2)
+//         wfree(pStr2);
+//     if(pStr3)
+//         wfree(pStr3);
+//     if(chassis)
+//         cJSON_Delete(chassis);
+//     if(board)
+//         cJSON_Delete(board);
+//     if(product)
+//         cJSON_Delete(product);
+
+//     if(_chassisPartNum) 		wfree(_chassisPartNum);
+// 	if(_chassisSerialNum) 		wfree(_chassisSerialNum);
+// 	if(_chassisType) 			wfree(_chassisType);
+// 	if(_chassisCustomField) 	wfree(_chassisCustomField);
+// 	if(_boardMfr) 				wfree(_boardMfr);
+// 	if(_boardProductName) 		wfree(_boardProductName);
+// 	if(_boardSerialNum) 		wfree(_boardSerialNum);
+// 	if(_boardPartNum) 			wfree(_boardPartNum);
+// 	if(_boardCustomField) 		wfree(_boardCustomField);
+// 	if(_MfrName) 				wfree(_MfrName);
+// 	if(_MfrDate) 				wfree(_MfrDate);
+// 	if(_ProductName) 			wfree(_ProductName);
+// 	if(_ProductPartNum) 		wfree(_ProductPartNum);
+// 	if(_ProductVersion) 		wfree(_ProductVersion);
+// 	if(_ProductSerialNum) 		wfree(_ProductSerialNum);
+// 	if(_productCustomField) 	wfree(_productCustomField);
+// 	printf("getFruInfo over!\n");
+// }

+ 1 - 1
local/rc

@@ -36,4 +36,4 @@ mknod /dev/adc1 c 105 0
 /usr/bin/bmc_app & 
 sleep 3
 #/usr/bin/test_app 
-/usr/bin/goahead-3.6.5 -v --home /etc/goahead /var/www/goahead &
+/usr/bin/goahead-3.6.5 -v --home /etc/goahead &