7 Sitoutukset 31b3ed8663 ... 9b9eb6ca11

Tekijä SHA1 Viesti Päivämäärä
  zhangbo 9b9eb6ca11 Merge branch 'master' of https://gogs.storlead.com/zhangbo/GD32F450_BMC_BaseCode 3 vuotta sitten
  zhangbo 98dc4132af add isChMC 3 vuotta sitten
  zhangbo 8911a7755a merge conflicts 3 vuotta sitten
  zhangbo fa0dd5ec4d for sync 3 vuotta sitten
  zhangbo abeaa4097b for sync 3 vuotta sitten
  zhangbo a698fef254 debug sel 3 vuotta sitten
  zhangbo a23d6cb29d dashboard, fan ok 3 vuotta sitten
32 muutettua tiedostoa jossa 2199 lisäystä ja 2757 poistoa
  1. BIN
      app/NCP81111_Config/ncp81111_cfg
  2. BIN
      app/UpdateFirmware/updateFW_app
  3. 1 1
      app/bmc/Api.c
  4. 1 1
      app/bmc/msghndlr/PDKCmds.c
  5. 1 1
      app/bmc/msghndlr/Storage/SDRDevice/SDR.c
  6. 32 34
      app/bmc/msghndlr/Storlead/Storlead.c
  7. 2 1
      app/bmc/msghndlr/Storlead/Storlead.h
  8. 1 1
      app/bmc/msghndlr/cmdselect.c
  9. 11 9
      app/common_include/com_BMCCfg.h
  10. 1 0
      app/common_include/com_BmcType.h
  11. 1 1
      app/common_include/com_IPMIDefs.h
  12. 1 0
      app/common_include/com_IPMI_Storlead.h
  13. 1 0
      app/goahead-3.6.5/src/libipmi/inc/libipmi_IPM.h
  14. 33 3
      app/goahead-3.6.5/src/libipmi/inc/libipmi_StorDevice.h
  15. 14 2
      app/goahead-3.6.5/src/libipmi/inc/libipmi_sdr.h
  16. 5 3
      app/goahead-3.6.5/src/libipmi/inc/libipmi_sensor.h
  17. 11 12
      app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h
  18. 34 0
      app/goahead-3.6.5/src/libipmi/src/libipmi_IPM.c
  19. 533 110
      app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c
  20. 2 1103
      app/goahead-3.6.5/src/libipmi/src/libipmi_fru.c
  21. 245 108
      app/goahead-3.6.5/src/libipmi/src/libipmi_sdr.c
  22. 184 206
      app/goahead-3.6.5/src/libipmi/src/libipmi_sensor.c
  23. 343 203
      app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c
  24. 80 80
      app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c
  25. 231 200
      app/goahead-3.6.5/src/web_interface/src/dashboard.c
  26. 48 21
      app/goahead-3.6.5/src/web_interface/src/fan.c
  27. 55 397
      app/goahead-3.6.5/src/web_interface/src/fru.c
  28. 6 6
      app/goahead-3.6.5/src/web_interface/src/fw_update.c
  29. 322 254
      app/goahead-3.6.5/src/web_interface/src/sel.c
  30. BIN
      app/i2c_scan/i2c-scan
  31. BIN
      app/ipmitool-1.8.18/ipmitool
  32. BIN
      app/test_app/test_app

BIN
app/NCP81111_Config/ncp81111_cfg


BIN
app/UpdateFirmware/updateFW_app


+ 1 - 1
app/bmc/Api.c

@@ -56,7 +56,7 @@ int PlatformInit(void)
 	pSetLanInfo->IPAddr[0] = 192;
 	pSetLanInfo->IPAddr[1] = 168;
 	pSetLanInfo->IPAddr[2] = 1;		//网段
-	pSetLanInfo->IPAddr[3] = 10+g_BMCInfo.SlotID; 
+	pSetLanInfo->IPAddr[3] = 120+g_BMCInfo.SlotID; 
 	pSetLanInfo->BroadCast[0] = 192;
 	pSetLanInfo->BroadCast[1] = 168; 
 	pSetLanInfo->BroadCast[2] = 1; //网段

+ 1 - 1
app/bmc/msghndlr/PDKCmds.c

@@ -348,7 +348,7 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_GET_LAN_INFO,      PRIV_USER,      Storlead_GetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_SET_LAN_INFO,      PRIV_USER,      Storlead_SetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_BLADE_INFO,      PRIV_USER,      Storlead_GetBladeInfo,         0xff,  0xAAAA  ,0xFFFF},
-    
+    { CMD_GET_SENSOR_NAME,      PRIV_USER,      Storlead_GetSensorName,         0xff,  0xAAAA  ,0xFFFF},
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 1 - 1
app/bmc/msghndlr/Storage/SDRDevice/SDR.c

@@ -45,7 +45,7 @@
 
 #define SDR_FIRST_FREE_BYTE()   ((( uint8_t*)g_BMCInfo.IpmiConfig.SDRConfig.SDRRAM) + g_BMCInfo.IpmiConfig.SDRConfig.SDRRAM->Size)
 
-#define MAX_SDR_LEN             25
+#define MAX_SDR_LEN             255
 
 #define MAX_RES_LEN             128
 #define SDR_VERSION             0x51

+ 32 - 34
app/bmc/msghndlr/Storlead/Storlead.c

@@ -389,15 +389,7 @@ int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
 int Storlead_GetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
 {
     *pRes = CC_NORMAL;
-    
     memcpy(pRes+1, (uint8_t*)gFanInfo, FAN_NUMBERS*sizeof(FanInfo_T));
-
-    // int i;
-    // printf("=======FAN==========\n");
-    // for(i=0;i<FAN_NUMBERS*sizeof(FanInfo_T)+1;i++)
-    //     printf("%02x ", pRes[i]);
-    // printf("\n");
-
     return FAN_NUMBERS*sizeof(FanInfo_T) + 1;   
 }
 
@@ -446,7 +438,8 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     MsgPkt_T    ResPkt;
     pRes[0] = CC_NORMAL;
 
-    if(pReq[0] == 0)
+    //if(pReq[0] == 0)
+    if(g_BMCInfo.isChMC == 0)
     {
         for(i=0;i<BLADE_NUMBERS;i++)
         {
@@ -463,6 +456,8 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
             memcpy(gBladeStatus[g_BMCInfo.IndexInChassis].bladeName, g_BMCInfo.BladeName, 31);
             gBladeStatus[g_BMCInfo.IndexInChassis].slotID = g_BMCInfo.SlotID;
             gBladeStatus[g_BMCInfo.IndexInChassis].pwrStatus = g_BMCInfo.PowerGoodFlag;
+            gBladeStatus[g_BMCInfo.IndexInChassis].isChMC = 1;  //从模块不能管理机箱,网页内显示机箱的默认选中刀片。
+
         }
     }
     else
@@ -475,6 +470,7 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
                 memcpy(gBladeStatus[index].bladeName, g_BMCInfo.BladeName, 31);
                 gBladeStatus[index].slotID = g_BMCInfo.SlotID;
                 gBladeStatus[index].pwrStatus = g_BMCInfo.PowerGoodFlag;
+                gBladeStatus[index].isChMC = 1;
                 continue;
             }
 
@@ -495,6 +491,7 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
                     memcpy(gBladeStatus[index].bladeName, &ResPkt.Data[2], 31);
                     gBladeStatus[index].slotID = ResPkt.Data[33];
                     gBladeStatus[index].pwrStatus = ResPkt.Data[34];
+                    gBladeStatus[index].isChMC = 0;
                 }
                 else
                 {
@@ -502,6 +499,7 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
                     sprintf(gBladeStatus[index].bladeName, "---");
                     gBladeStatus[index].slotID = 0;
                     gBladeStatus[index].pwrStatus = 0;
+                    gBladeStatus[index].isChMC = 0;
                 }
             }
             else
@@ -510,9 +508,8 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
                 sprintf(gBladeStatus[index].bladeName, "---");
                 gBladeStatus[index].slotID = 0;
                 gBladeStatus[index].pwrStatus = 0;
+                gBladeStatus[index].isChMC = 0;
             }
-
-            
         }
 
     }
@@ -521,28 +518,6 @@ int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     return 1+(BLADE_NUMBERS*sizeof(BladeStatus_T));
 }
 
-// int Storlead_SetBladeManageFn(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
-// {
-//     if(pReq[0] > 1)
-//     {
-//         printf("Invalid param %d\n", pReq[0]);
-//         pRes[0] = CC_PARAM_OUT_OF_RANGE;
-//         return 1;
-//     }
-    
-//     g_BMCInfo.BladeManageEn = pReq[0];
-//     pRes[0] = CC_NORMAL;
-//     return 1;
-// }
-
-// int Storlead_GetBladeManageFn(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
-// {
-    
-//     pRes[0] = CC_NORMAL;
-//     pRes[1] = g_BMCInfo.BladeManageEn;
-//     return 2;
-// }
-
 int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
 {
     /*
@@ -556,7 +531,7 @@ int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     pRes[0] = CC_NORMAL;
     pRes[1] = BLADE_NUMBERS;
     pRes[2] = g_BMCInfo.isChMC;
-    pRes[3] = 0;//g_BMCInfo.BladeManageEn;  //reserve
+    pRes[3] = 0;//g_BMCInfo.BladeManageEn;  //机箱管理使能,该字段废弃了。
     pRes[4] = g_BMCInfo.IndexInChassis;
     return 5;
 }
@@ -661,4 +636,27 @@ int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     pRes[34] = g_BMCInfo.PowerGoodFlag;
 
     return 35;
+}
+
+/*
+    Req[0] : sensor name
+
+*/
+int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    int i;
+    SensorInfo_T*           pSensorInfo;
+
+    memset(pRes, 0, MAX_ID_STR_LEN+1);    
+    for(i=0;i<SENSOR_NUMBERS;i++)
+    {
+        pSensorInfo = (SensorInfo_T *)&g_BMCInfo.SensorSharedMem.SensorInfo [i];
+        if(pReq[0] == pSensorInfo->SensorNumber)
+        {
+            memcpy(&pRes[1], ((FullSensorRec_T*)pSensorInfo->SDRRec)->IDStr, MAX_ID_STR_LEN);
+            break;
+        }
+    }
+
+    return MAX_ID_STR_LEN+1;
 }

+ 2 - 1
app/bmc/msghndlr/Storlead/Storlead.h

@@ -17,4 +17,5 @@ int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
-int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

+ 1 - 1
app/bmc/msghndlr/cmdselect.c

@@ -813,7 +813,7 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_GET_LAN_INFO          ,ENABLED},	
 	{ CMD_SET_LAN_INFO          ,ENABLED},	
 	{ CMD_GET_BLADE_INFO          ,ENABLED},	
-
+	{ CMD_GET_SENSOR_NAME          ,ENABLED},	
 	{0,				0		},
 };
 

+ 11 - 9
app/common_include/com_BMCCfg.h

@@ -1,11 +1,12 @@
 #ifndef __COM_BMC_CFG_H__
 #define __COM_BMC_CFG_H__
 
-#define 	FAN_NUMBERS		0
+#define 	FAN_NUMBERS		0		//当前板卡有0个风扇。
+#define 	MAX_FAN_NUMS 	10		//该系统最多支持10个风扇
 #define 	BLADE_NUMBERS	10
 #define SENSOR_NUMBERS				(15)
 #define FW_VERSION_MAJOR			(1)
-#define FW_VERSION_MINOR			(2)
+#define FW_VERSION_MINOR			(3)
 
 extern uint8_t ChassisPrimaryIPMBAddr[BLADE_NUMBERS];
 extern uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS];
@@ -40,14 +41,15 @@ extern uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS];
 ---------------------------------------------
 0x76 0000 ~ 0x7F FFFF 	640KB 	Reserve
 =============================================
+以上改为16MB的Flash
 */
-#define CONFIG_FLASH_START 	0x700000
-#define IPMI_CFG_FLASH_ADDR 0x700000
-#define USERTBL_FLASH_ADDR 	0x710000
-#define FRU_FLASH_ADDR 		0x720000
-#define SDR_FLASH_ADDR 		0x730000
-#define SENSOR_HISTORY_FLASH_ADDR 	0x740000
-#define SEL_FLASH_ADDR 		0x750000
+#define CONFIG_FLASH_START 	0xF00000
+#define IPMI_CFG_FLASH_ADDR 0xF00000
+#define USERTBL_FLASH_ADDR 	0xF10000
+#define FRU_FLASH_ADDR 		0xF20000
+#define SDR_FLASH_ADDR 		0xF30000
+#define SENSOR_HISTORY_FLASH_ADDR 	0xF40000
+#define SEL_FLASH_ADDR 		0xF50000
 
 
 

+ 1 - 0
app/common_include/com_BmcType.h

@@ -317,6 +317,7 @@ typedef struct{
     uint8_t bladeName[31];  //10个汉字或30个字符
     uint8_t slotID;         
     uint8_t pwrStatus;      //0:未上电(灰色)     1:已上电(绿色)
+    uint8_t isChMC;         //是否是主模块,网页默认显示主模块的内容。
 } BladeStatus_T;
 
 

+ 1 - 1
app/common_include/com_IPMIDefs.h

@@ -55,7 +55,7 @@
 #define SESSION_TIMEOUT         30	//10
 #define MAX_PYLDS_SUPPORT       2
 #define MAX_SENSOR_NUMBERS      32
-#define DEFAULT_TIMEOUT			30	//10
+#define DEFAULT_TIMEOUT			10
 #define MAX_USER_NUM			(10)
 #define MAX_SEL_RECORD			(100)
 #define MAX_ID_STR_LEN  		16

+ 1 - 0
app/common_include/com_IPMI_Storlead.h

@@ -16,6 +16,7 @@
 #define CMD_GET_LAN_INFO		0xC
 #define CMD_SET_LAN_INFO		0xD
 #define CMD_GET_BLADE_INFO		0xE
+#define CMD_GET_SENSOR_NAME		0xF
 
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

+ 1 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_IPM.h

@@ -29,6 +29,7 @@ extern "C" {
 extern uint16_t	IPMICMD_GetDeviceID( IPMI20_UDS_SESSION_T *pUDSSession/*in*/,
 										GetDevIDRes_T *pGetDeviceID/*out*/,
 										int timeout/*in*/);
+extern uint16_t	IPMC_GetDeviceID( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T	*pGetDeviceID, int timeout );	
 /* Device GUID */
 extern uint16_t	IPMICMD_GetDeviceGUID( IPMI20_UDS_SESSION_T *pUDSSession/*in*/, 
                                         GetDevGUIDRes_T *pGetDeviceGUID/*out*/,

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

@@ -41,11 +41,24 @@ extern "C" {
   uint16_t IPMICMD_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 					ReserveSELRes_T* pReserveSelRes,
 					int timeout);
+  uint16_t IPMC_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+					ReserveSELRes_T* pReserveSelRes,
+					int timeout);
   uint16_t IPMICMD_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 					GetSELReq_T* pGetSELReqData,
 					uint8_t* pGetSELResData,
 					uint32_t ResDataLen,
 					int timeout);
+ uint16_t IPMI_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout);
+ uint16_t IPMC_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout);
   uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELEventRecord_T* pSELReqData,
 					AddSELRes_T* pSELResData,
@@ -58,9 +71,15 @@ extern "C" {
   uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint16_t* nNumOfSELEntries,
 					int timeout);
-  uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint16_t* nMaxPossibleSELEntries,
+  uint16_t IPMC_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+					uint16_t* nNumOfSELEntries,
 					int timeout);
+  // uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
+		// 			uint16_t* nMaxPossibleSELEntries,
+		// 			int timeout);
+  // uint16_t IPMC_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+		// 				uint16_t* nMaxPossibleSELEntries,
+		// 				int timeout);
   uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELEventRecord_T *pSELEntriesBuffer,
 					int timeout);
@@ -142,24 +161,35 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
 		// 		uint8_t *nFRUs,
 		// 		int timeout);
 
-  uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession,
+  uint16_t Storlead_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
 	SELEventRecordWithSensorName_T *pSELEntriesBuffer,
 	int timeout);
 
   uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 				int timeout);
 
+  uint16_t IPMC_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+				int timeout);
+
   uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeRes_T *pGetSELTimeRes, int timeout);
+  uint8_t IPMC_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeRes_T *pGetSELTimeRes, int timeout);
 
   uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeReq_T *pSetSELTimeReq, int timeout);
+  uint8_t IPMC_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				SetSELTimeReq_T *pSetSELTimeReq, int timeout);
 
   uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout);
+  uint8_t IPMC_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout);
 
   uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout);
+  uint8_t IPMC_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout);
 
 
 #ifdef  __cplusplus

+ 14 - 2
app/goahead-3.6.5/src/libipmi/inc/libipmi_sdr.h

@@ -24,11 +24,17 @@ extern "C" {
   uint16_t	IPMICMD_GetSDRRepositoryInfo( IPMI20_UDS_SESSION_T *pUDSSession,
 										SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
 										int timeout);
+uint16_t    IPMC_GetSDRRepositoryInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+                                        SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
+                                        int timeout);
 
 /* Get SDR Repository Allocation Info Command */
   uint16_t	IPMICMD_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession,
 										SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
 										int timeout);
+  uint16_t    IPMC_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+                                        SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
+                                        int timeout);
 
 /* Reserve SDR Repository Command */
   uint16_t	IPMICMD_ReserveSDRRepository( IPMI20_UDS_SESSION_T *pUDSSession,
@@ -96,14 +102,14 @@ extern "C" {
 									int timeout);
 
 /*---------- LIBIPMI Higher level routines -----------*/
-  uint16_t LIBIPMI_HL_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession,
+uint16_t Storlead_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                               uint16_t record_id,
                                               uint16_t *next_record_id,
                                               uint8_t *sdr_buffer,
                                               size_t buffer_len,
                                               int timeout );
 
-  uint16_t LIBIPMI_HL_GetAllSDRs( IPMI20_UDS_SESSION_T *pUDSSession,
+  uint16_t Storlead_GetAllSDRs( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                           uint8_t *sdr_buffer, size_t buffer_len,
                                           int timeout );
 
@@ -114,6 +120,12 @@ extern "C" {
                                             GetSDRRes_T *pGetSDRRes,
                                             uint32_t *dwDataLen,
                                             int timeout );
+  uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+                                              uint16_t reservation_id,
+                                              uint16_t record_id,
+                          GetSDRRes_T *pGetSDRRes,
+                          uint32_t *dwDataLen,
+                                              int timeout );
 //#define SDR_CACHE_PATH "/var/sdrcache"
 
 #define ERR_SDRCACHE_SUCCESS 		0

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

@@ -77,13 +77,13 @@ extern "C" {
                                                  int timeout);
 
 /* 35.12 ReArm Sensor Events Command */
-  uint16_t	IPMICMD_ReArmSensorEvents( IPMI20_UDS_SESSION_T *pUDSSession,
+  uint16_t  IPMICMD_ReArmSensorEvents( IPMI20_UDS_SESSION_T *pUDSSession,
                                                  ReArmSensorReq_T *pReArmSensorReq,
                                                  ReArmSensorRes_T *pReArmSensorRes,
                                                  int timeout);
 
 /* 35.13 Get Sensor Event Status Command */
-  uint16_t	IPMICMD_GetSensorEventStatus( IPMI20_UDS_SESSION_T *pUDSSession,
+  uint16_t  IPMICMD_GetSensorEventStatus( IPMI20_UDS_SESSION_T *pUDSSession,
                                                  GetSensorEventStatusReq_T *pReqGetSensorEventStatus,
                                                  GetSensorEventStatusRes_T *pResGetSensorEventStatus,
                                                  int timeout);
@@ -165,10 +165,12 @@ LIBIPMI_HL_LoadSensorSDRs( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t **sdr_buff
 
   uint16_t
 LIBIPMI_HL_GetSensorCount( IPMI20_UDS_SESSION_T *pUDSSession, int *sdr_count, int timeout );
-
+uint16_t IPMC_GetSensorCount( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int *sdr_count, int timeout );
   uint16_t
 LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession,
                                  struct sensor_data *sensor_list, uint32_t nNumSensor,int timeout );
+uint16_t
+IPMC_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, struct sensor_data *sensor_list, uint32_t nNumSensor, int timeout );
 
 
   uint16_t 

+ 11 - 12
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -44,8 +44,8 @@ typedef struct{
 
 typedef struct{
 	uint8_t slotNum; //total slot numbers of chassis.
-	uint8_t supportChassisManageFn;
-	uint8_t chassisManageFnEnable;
+	uint8_t isChMC;		
+	uint8_t chassisManageFnEnable;		//废弃了
 	uint8_t curIndex;
 } OemChassisInfo_T;
 
@@ -98,24 +98,23 @@ extern uint8_t gChassisManageEn;
 //uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);
 
 uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
-//int LIBIPMI_HL_GetFanStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout);
+uint16_t IPMC_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
 uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pSysInfo, int timeout);
+uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, SysInfo_T *pSysInfo, int timeout);
 uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
-//uint16_t LIBIPMI_HL_GetAllCards(IPMI20_UDS_SESSION_T *pUDSSession, CardStatus_T*	pResBladeSts, int timeout);
-//int	 LIBIPMI_HL_GetChassisInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemChassisInfo_T* pBladeInfo, int timeout);
 int 	 LIBIPMI_HL_GetAllBladeStatus(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t chassisManageEn, BladeStatus_T* pBladeStatus, int timeout);
-//int LIBIPMI_HL_GetIPMCCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t bladeIndex, OemIPMCCapability_T* pIPMCCapability, int timeout);
-//int LIBIPMI_HL_SetBladeManageFn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t enable, int timeout);
-//int LIBIPMI_HL_GetBladeManageFn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t *enable, int timeout);
 int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo, int timeout);
-//int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout);
-//int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t* SensorHistoryEnable, int timeout);
-//int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);
-uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout);
+int IPMC_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, FanInfo_T* pFanInfo, int timeout);
+uint16_t Storlead_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+	SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout);
 uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, int timeout);
+uint16_t IPMC_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout);
 uint16_t IPMICMD_SetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout);
 uint16_t IPMICMD_GetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout);
 uint16_t IPMICMD_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, int timeout);
+uint16_t IPMC_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout);
 int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T *DevIDRes, int timeout);
+int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
+int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 34 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_IPM.c

@@ -49,6 +49,40 @@ uint16_t	IPMICMD_GetDeviceID( IPMI20_UDS_SESSION_T *pUDSSession, GetDevIDRes_T	*
 	return wRet;
 }
 
+uint16_t	IPMC_GetDeviceID( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T	*pGetDeviceID, int timeout )
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[100] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_DEV_ID;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+	
+	memcpy(pGetDeviceID, &Res[6], sizeof(GetDevIDRes_T));
+	if(( wRet != 0 ) || (Res[6] != 0))
+	{
+			printf("Error IPMC GetDeviceID\n");
+			return -1;
+	}
+
+	return wRet;
+}
+
+
 /**
 \breif	Executes GetDeviceGUID IPMI command.
  @param	pSession		[in]Session handle

+ 533 - 110
app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c

@@ -30,6 +30,7 @@
 #include <string.h>
 
 #include "goahead.h"
+#include "com_IPMI_App.h"
 
 /* Helper function */
 uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
@@ -48,25 +49,6 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
 /*****************************************************************************
 	System Event Log
 ******************************************************************************/
-uint16_t IPMICMD_GetSELInfo(IPMI20_UDS_SESSION_T *pUDSSession,
-				SELInfo_T *pResGetSELInfo,
-				int timeout)
-{
-	uint16_t	wRet;
-	uint32_t	dwResLen;
-	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
-
-	dwResLen = sizeof(SELInfo_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_INFO,
-						(uint8_t*)DummyReqData, 0,
-						(uint8_t *)pResGetSELInfo, &dwResLen,
-						timeout);
-	return wRet;
-}
-
-
 
 uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELAllocInfo_T *pResGetSELAllocInfo,
@@ -75,11 +57,10 @@ uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SELAllocInfo_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_ALLOCATION_INFO,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_ALLOCATION_INFO,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pResGetSELAllocInfo, &dwResLen,
 						timeout);
@@ -95,28 +76,65 @@ uint16_t IPMICMD_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint32_t	dwResLen = 0;
 
 	memset(pReserveSelRes, 0, sizeof(ReserveSELRes_T));
-
-	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)pReserveSelRes, &dwResLen,
 						timeout);
 
-	if ( (wRet != 0) && (pReserveSelRes->CompletionCode != CC_INV_CMD) )
+	/* If ReserveSEL command is not implemented, return 0x0000 as reservation ID */
+	if ( pReserveSelRes->CompletionCode == CC_INV_CMD )
+	{
+		pReserveSelRes->ReservationID = 0x0000;
+		return 0;
+	}
+
+	if(wRet != 0) 
 	{
 		printf("Could not get SEL reservation!!\n");
 		return wRet;
 	}
+	return 0;
+}
+
+uint16_t IPMC_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+					ReserveSELRes_T* pReserveSelRes,
+					int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_RESERVE_SEL;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
 
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+
+	memcpy(pReserveSelRes, &Res[6], sizeof(ReserveSELRes_T));
 	/* If ReserveSEL command is not implemented, return 0x0000 as reservation ID */
 	if ( pReserveSelRes->CompletionCode == CC_INV_CMD )
 	{
 		pReserveSelRes->ReservationID = 0x0000;
-		wRet = 0;
+		return 0;
 	}
 
-	return wRet;
+	if(wRet != 0) 
+	{
+		printf("Could not get SEL reservation!!\n");
+		return wRet;
+	}
+	return 0;
 }
 
 /* This function gets an entry from SEL. */
@@ -127,16 +145,94 @@ uint16_t IPMICMD_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				int timeout)
 {
 	uint16_t wRet = 0;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_ENTRY,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_ENTRY,
 						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
 						(uint8_t *)pGetSELResData, &ResDataLen,
 						timeout);
 	return wRet;
 }
 
+uint16_t IPMI_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout)
+{
+	uint16_t 	wRet = 0;
+	uint8_t 	Res[50];
+	uint32_t	dwResLen;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_ENTRY,
+						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
+						Res, &dwResLen,
+						timeout);
+	// printf("---> Res ");
+	// int i;
+	// for(i=0;i<17;i++)
+	// 	printf("%02x ", Res[i]);
+	// printf("\n");
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("IPMI_GetSELEntry failed\n");
+		*nextRecID = 0xffff;
+		memset(pSELEventData, 0, sizeof(SELEventRecord_T));
+		return wRet;
+	}
+
+	*nextRecID = (Res[2]<<8) | Res[1];
+	memcpy(pSELEventData, &Res[3], sizeof(SELEventRecord_T));
+
+	return 0;
+}
+
+uint16_t IPMC_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_ENTRY;	
+	Req[7] = pGetSELReqData->ReservationID&0xff;
+	Req[8] = (pGetSELReqData->ReservationID>>8)&0xff;
+	Req[9] = pGetSELReqData->RecID&0xff;
+	Req[10] = (pGetSELReqData->RecID>>8)&0xff;
+	Req[11] = pGetSELReqData->Offset;
+	Req[12] = pGetSELReqData->Size;
+	Req[13] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11] + Req[12])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 14,
+							Res,  &dwResLen,
+							timeout);
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMI_GetSELEntry failed\n");
+		*nextRecID = 0xffff;
+		memset(pSELEventData, 0, sizeof(SELEventRecord_T));
+		return wRet;
+	}
+
+	*nextRecID = (Res[8]<<8) | Res[7];
+	memcpy(pSELEventData, &Res[9], sizeof(SELEventRecord_T));
+
+	return 0;
+}
+
 /* This function adds an entry into SEL. */
 uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				SELEventRecord_T* pSELReqData,
@@ -145,11 +241,10 @@ uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(AddSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_ADD_SEL_ENTRY,
+						NETFNLUN_IPMI_APP, CMD_ADD_SEL_ENTRY,
 						(uint8_t*)pSELReqData, sizeof(SELEventRecord_T),
 						(uint8_t *)pSELResData, &dwResLen,
 						timeout);
@@ -174,7 +269,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	//first do a SEL reservation
 	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
 						timeout);
@@ -198,7 +293,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	DeleteSELReqData.RecID = RecordID;
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						(NETFN_STORAGE << 2), CMD_DELETE_SEL_ENTRY,
+						NETFNLUN_IPMI_APP, CMD_DELETE_SEL_ENTRY,
 						(uint8_t*)&DeleteSELReqData, sizeof(DeleteSELReqData),
 						(uint8_t *)&DeleteSELResData, &dwResLen,
 						timeout);
@@ -216,12 +311,10 @@ uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	uint8_t DummyReqData[8];
 
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
-
 	//first do a SEL reservation
  	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
 						timeout);
@@ -250,12 +343,87 @@ uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(ClearSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_CLEAR_SEL,
+						NETFNLUN_IPMI_APP, CMD_CLEAR_SEL,
 						(uint8_t*)&ClearSelReq, sizeof(ClearSELReq_T),
 						(uint8_t *)&ClearSelRes, &dwResLen,
 						timeout);
 	return wRet;
 }
+
+uint16_t IPMC_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+				int timeout)
+{
+	uint16_t 	ReservationID = 0;
+
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	//first do a SEL reservation
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_RESERVE_SEL;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+
+	if ( (wRet != 0)  )
+	{
+		printf("Could not get SEL reservation while trying to clear event log!!\n");
+		return wRet;
+	}
+
+	if (Res[6] == CC_INV_CMD)
+	{
+		// Reservation ID should be set as 0x0000 for implementations that don't
+		// implement ReserveSEL command
+		ReservationID = 0x0000;
+
+	}
+	else
+	{
+		ReservationID = (Res[8]<<8) | Res[7];
+	}
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_CLEAR_SEL;	
+	Req[7] = ReservationID&0xff;
+	Req[8] = (ReservationID>>8)&0xff;
+	Req[9] = 'C';
+	Req[10] = 'L';
+	Req[11] = 'R';
+	Req[12] = 0xAA;	//InitOrStatus
+	Req[13] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11] + Req[12])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 14,
+							Res,  &dwResLen,
+							timeout);
+
+	if ( (wRet != 0) || (Res[6] != 0) )
+	{
+		printf("Clear event log failed!\n");
+		return wRet;
+	}
+
+	return wRet;
+}
+
 /**************************************************************************************
 *****************************Higher level commands*****************************
 **************************************************************************************/
@@ -264,37 +432,66 @@ uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint16_t* nNumOfSELEntries,
 					int timeout)
 {
-	uint16_t wRet = 0;
 	SELInfo_T SELInfo;
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyReqData[8];
 
-	wRet =  IPMICMD_GetSELInfo(pUDSSession,&SELInfo,timeout);
-	if(wRet != 0)
+	dwResLen = sizeof(SELInfo_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_INFO,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)&SELInfo, &dwResLen,
+						timeout);
+	if((wRet != 0) || (SELInfo.CompletionCode != 0))
 	{
 		printf("LIBIPMI_HL_GetNumOfSELEntries: Error getting SEL info\n");
+		*nNumOfSELEntries = 0;
 		return wRet;
 	}
 	*nNumOfSELEntries =  (SELInfo.RecCt);
-	return wRet;
+	return 0;
 }
 
-/* This function returns max possible number of SEL entries in the system at any time */
-uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
-						uint16_t* nMaxPossibleSELEntries,
-						int timeout)
+uint16_t IPMC_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+					uint16_t* nNumOfSELEntries,
+					int timeout)
 {
-	uint16_t wRet = 0;
-	SELAllocInfo_T SELAllocInfo;
+	SELInfo_T *pSELInfo;
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_INFO;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
 
-	wRet =  IPMICMD_GetSELAllocationInfo(pUDSSession,&SELAllocInfo,timeout);
-	if(wRet != 0)
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+
+	if ( (wRet != 0) || (Res[6] != 0) )
 	{
-		printf("LIBIPMI_HL_GetMaxPossibleSELEntries: Error getting SEL Alloc info\n");
+		printf("Get SEL Number failed!\n");
+		*nNumOfSELEntries = 0;
 		return wRet;
 	}
-	*nMaxPossibleSELEntries =  (SELAllocInfo.NumAllocUnits);
-	return wRet;
+
+	pSELInfo = (SELInfo_T *)&Res[6];
+	*nNumOfSELEntries =  (pSELInfo->RecCt);
+
+	return 0;
 }
 
+
 /* This function returns total number of SEL entries present in the system at that time.
    IMPORTANT:
    Before you call this function, call LIBIPMI_HL_GetNumOfSELEntries() to get the number of
@@ -398,7 +595,7 @@ uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
+	wRet = Storlead_GetAllSDRs(pUDSSession, 0x20, 
                                      pSDRBuff,(MaxLen * SDRCnt),
                                      timeout*4);
 	*MaxSDRLen=MaxLen;
@@ -454,7 +651,7 @@ uint16_t LIBIPMI_HL_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession,
 	pSDRStart = pSDRBuff;
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
+	wRet = Storlead_GetAllSDRs(pUDSSession, 0x20,
                                      pSDRBuff,(MaxSDRLen * SDRCount),
                                      timeout*4);
 
@@ -507,7 +704,7 @@ 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,
+uint16_t Storlead_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
 					SELEventRecordWithSensorName_T *pSELEntriesBuffer,
 					int timeout)
 {
@@ -527,7 +724,7 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 	/* We want to read full records */
 	//DataLen = sizeof(GetSELRes_T) + sizeof(SELEventRecord_T);
 
-	wRet = LIBIPMI_HL_AMIGetSELEntires(pUDSSession,pSELEntriesBuffer,&nNumSelEntries,timeout);
+	wRet = Storlead_AMIGetSELEntires(pUDSSession, IpmbAddr, pSELEntriesBuffer,&nNumSelEntries,timeout);
 	if(wRet != LIBIPMI_E_SUCCESS)
 	{
 		printf("LIBIPMI_HL_AMIGetSELEntires : Error getting SEL Entries \n");
@@ -537,7 +734,14 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 	
 	/*************************************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(IpmbAddr == 0x20)
+	{
+		wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
+	}
+	else
+	{
+		wRet = IPMC_GetSDRRepositoryAllocInfo(pUDSSession, IpmbAddr, &SDRAllocationInfo, timeout);	
+	}
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Allocation Info\n");
@@ -548,7 +752,14 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 		SDRAllocationInfo.LargestFreeBlock, SDRAllocationInfo.MaxRecSize);
 
 	/* Get repository information */
-	wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
+	if(IpmbAddr == 0x20)
+	{
+		wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
+	}
+	else
+	{
+		wRet = IPMC_GetSDRRepositoryInfo(pUDSSession, IpmbAddr, &SDRReposInfo,timeout);	
+	}
 	if( wRet != 0 )
 	{
 		printf("Error getting SDR Repository Info\n");
@@ -573,7 +784,7 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 	pSDRStart = pSDRBuff;
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
+	wRet = Storlead_GetAllSDRs(pUDSSession, IpmbAddr, 
                                      pSDRBuff,(MaxSDRLen * SDRCount),
                                      timeout*4);
 
@@ -631,6 +842,128 @@ uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSe
 	return wRet;
 }
 
+uint16_t IPMC_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+					SELEventRecordWithSensorName_T *pSELEntriesBuffer,
+					int timeout)
+{
+	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 = Storlead_AMIGetSELEntires(pUDSSession, 0x20, 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;
+	}
+	printf("---> NumAllocUnits: %d, AllocUnitSize: %d, NumFreeAllocUnits: %d, LargestFreeBlock: %d, MaxRecSize: %d\n", \
+		SDRAllocationInfo.NumAllocUnits, SDRAllocationInfo.AllocUnitSize, SDRAllocationInfo.NumFreeAllocUnits, \
+		SDRAllocationInfo.LargestFreeBlock, SDRAllocationInfo.MaxRecSize);
+
+	/* 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 );
+	printf("---> SDRCount: %d, MaxSDRLen: %d\n", SDRCount, MaxSDRLen);
+
+	/* Allocate the buffer */
+	pSDRBuff = (uint8_t *) walloc(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 = Storlead_GetAllSDRs(pUDSSession, 0x20, 
+                                     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;
+		}
+	}
+	wfree(pSDRStart);
+	return wRet;
+}
 /*****************************************************************************
 	Field Replacement Unit (FRU)
 ******************************************************************************/
@@ -641,11 +974,10 @@ uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t	wRet,tmp;
 	uint32_t	dwResLen;
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUInventoryAreaInfoRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_FRU_INVENTORY_AREA_INFO,
+						NETFNLUN_IPMI_APP, CMD_FRU_INVENTORY_AREA_INFO,
 						(uint8_t *)pReqFRUInventoryAreaInfo, sizeof(FRUInventoryAreaInfoReq_T),
 						(uint8_t *)pResFRUInventoryAreaInfo, &dwResLen,
 						timeout);
@@ -662,11 +994,10 @@ uint16_t IPMICMD_ReadFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUReadRes_T) + (pFRUReadReqData->CountToRead);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_READ_FRU_DATA,
+						NETFNLUN_IPMI_APP, CMD_READ_FRU_DATA,
 						(uint8_t *)pFRUReadReqData, sizeof(FRUReadReq_T),
 						(uint8_t *)pFRUReadResData, &dwResLen,
 						timeout);
@@ -681,11 +1012,10 @@ uint16_t IPMICMD_WriteFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUWriteRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_WRITE_FRU_DATA,
+						NETFNLUN_IPMI_APP, CMD_WRITE_FRU_DATA,
 						(uint8_t *)pFRUWriteReqData, ReqDataLen,
 						(uint8_t *)pFRUWriteResData, &dwResLen,
 						timeout);
@@ -742,7 +1072,7 @@ uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
 	pSDRStart = pSDRBuff;
 
 	/* Call the function to read all the SDRs into this buffer */
-	wRet = LIBIPMI_HL_GetAllSDRs(pUDSSession,
+	wRet = Storlead_GetAllSDRs(pUDSSession, 0x20,
                                      pSDRBuff,(MaxSDRLen * SDRCount),
                                      timeout*4);
 	if(wRet != 0)
@@ -816,53 +1146,16 @@ uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
-
-// 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;
 	uint32_t	dwResLen;
 	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(GetSELTimeRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_TIME,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_TIME,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeRes, &dwResLen,
 						timeout);
@@ -873,17 +1166,49 @@ uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
+uint8_t IPMC_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeRes_T *pGetSELTimeRes, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_TIME;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMC Error getting SEL Time::%x\n",wRet);
+		pGetSELTimeRes->CompletionCode = Res[6];
+		pGetSELTimeRes->Time = 0;
+		return wRet;
+	}
+	memcpy(pGetSELTimeRes, &Res[6], sizeof(GetSELTimeRes_T));
+	return 0;
+}
+
 uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeReq_T *pSetSELTimeReq, int timeout)
 {
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyResData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(uint8_t);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_SET_SEL_TIME,
+						NETFNLUN_IPMI_APP, CMD_SET_SEL_TIME,
 						(uint8_t *)pSetSELTimeReq, sizeof(SetSELTimeReq_T),
 						(uint8_t *)DummyResData, &dwResLen,
 						timeout);
@@ -894,17 +1219,49 @@ uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
+uint8_t IPMC_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				SetSELTimeReq_T *pSetSELTimeReq, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SET_SEL_TIME;	
+	Req[7] = pSetSELTimeReq->Time&0xff;
+	Req[8] = (pSetSELTimeReq->Time>>8)&0xff;
+	Req[9] = (pSetSELTimeReq->Time>>16)&0xff;
+	Req[10] = (pSetSELTimeReq->Time>>24)&0xff;
+	Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 12,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("Error setting SEL Time::%x\n",wRet);
+	}
+	return wRet;
+}
+
 uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout)
 {
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(GetSELTimeUTCOffsetRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_TIME_UTC_OFFSET,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_TIME_UTC_OFFSET,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeUTCOffsetRes, &dwResLen,
 						timeout);
@@ -915,17 +1272,49 @@ uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
+uint8_t IPMC_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_TIME_UTC_OFFSET;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("Error getting SEL Time UTC Offset::%x\n",wRet);
+		pGetSELTimeUTCOffsetRes->CompletionCode;
+		pGetSELTimeUTCOffsetRes->UTCOffset = 0;
+		return wRet;
+	}
+	memcpy(pGetSELTimeUTCOffsetRes, &Res[6], sizeof(GetSELTimeUTCOffsetRes_T));
+	return 0;
+}
+
 uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout)
 {
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	SetSELTimeUTCOffsetRes_T pSetSELTimeUTCOffsetRes;
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SetSELTimeUTCOffsetRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_SET_SEL_TIME_UTC_OFFSET,
+						NETFNLUN_IPMI_APP, CMD_SET_SEL_TIME_UTC_OFFSET,
 						(uint8_t *)pSetSELTimeUTCOffsetReq, sizeof(SetSELTimeUTCOffsetReq_T),
 						(uint8_t *)&pSetSELTimeUTCOffsetRes, &dwResLen,
 						timeout);
@@ -935,3 +1324,37 @@ uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 	}
 	return wRet;
 }
+
+uint8_t IPMC_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SET_SEL_TIME_UTC_OFFSET;	
+	Req[7] = pSetSELTimeUTCOffsetReq->UTCOffset&0xff;
+	Req[8] = (pSetSELTimeUTCOffsetReq->UTCOffset>>8)&0xff;
+	Req[9] = (pSetSELTimeUTCOffsetReq->UTCOffset>>16)&0xff;
+	Req[10] = (pSetSELTimeUTCOffsetReq->UTCOffset>>24)&0xff;
+	Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 12,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("Error setting SEL Time UTC Offset::%x\n",wRet);
+		return wRet;
+	}
+	return 0;
+}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 2 - 1103
app/goahead-3.6.5/src/libipmi/src/libipmi_fru.c


+ 245 - 108
app/goahead-3.6.5/src/libipmi/src/libipmi_sdr.c

@@ -24,6 +24,7 @@
 #include "libipmi_sdr.h"
 #include "com_IPMI_Storage.h"
 #include "goahead.h"
+#include "com_IPMI_App.h"
 
 
 
@@ -55,6 +56,40 @@
     return wRet;
 }
 
+uint16_t    IPMC_GetSDRRepositoryInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+                                        SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
+                                        int timeout)
+{
+    int wRet = 0;
+    uint32_t    dwResLen;
+    uint8_t     Req[50] = {0};
+    uint8_t     Res[50] = {0};
+
+    Req[0] = 0x40;  //Track | channel 0
+    Req[1] = IpmbAddr;
+    Req[2] = NETFNLUN_IPMI_STORAGE;
+    Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
+    Req[4] = 0x20;
+    Req[5] = 0x10;
+    Req[6] = CMD_GET_SDR_REPOSITORY_INFO;   
+    Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+                            NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+                            Req, 8,
+                            Res,  &dwResLen,
+                            timeout);
+    if((wRet != 0) || (Res[6] != 0))
+    {
+        printf("IPMC_GetSDRRepositoryInfo failed!\n");
+        return -1;
+    }
+
+
+    memcpy(pResGetSDRRepositoryInfo, &Res[6], sizeof(SDRRepositoryInfo_T));
+    return wRet;
+}
+
 /* Get SDR Repository Allocation Info Command */
   uint16_t    IPMICMD_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession,
                                         SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
@@ -73,6 +108,41 @@
     return wRet;
 }
 
+uint16_t    IPMC_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
+                                        SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
+                                        int timeout)
+{
+    int wRet = 0;
+    uint32_t    dwResLen;
+    uint8_t     Req[50] = {0};
+    uint8_t     Res[50] = {0};
+
+    Req[0] = 0x40;  //Track | channel 0
+    Req[1] = IpmbAddr;
+    Req[2] = NETFNLUN_IPMI_STORAGE;
+    Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
+    Req[4] = 0x20;
+    Req[5] = 0x10;
+    Req[6] = CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO;   
+    Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+                            NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+                            Req, 8,
+                            Res,  &dwResLen,
+                            timeout);
+
+    if((wRet != 0) || (Res[6] != 0))
+    {
+        printf("IPMC_GetSDRRepositoryAllocInfo failed!\n");
+        return -1;
+    }
+
+
+    memcpy(pResGetSDRRepositoryAllocInfo, &Res[6], sizeof(SDRRepositoryAllocInfo_T));
+    return wRet;
+}
+
 /* Reserve SDR Repository Command */
   uint16_t    IPMICMD_ReserveSDRRepository( IPMI20_UDS_SESSION_T *pUDSSession,
                                         ReserveSDRRepositoryRes_T *pResReserveSDRRepository,
@@ -300,109 +370,147 @@
 static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
                                               uint16_t reservation_id,
                                               uint16_t record_id,
-					      GetSDRRes_T *pGetSDRRes,
-					      uint32_t *dwRecordLen,
+                          GetSDRRes_T *pGetSDRRes,
+                          uint32_t *dwRecordLen,
                                               int timeout )
 {
-#define IPMB_SDR_MAX_SINGLE_READ	(22)	//32 bytes - ipmb message header - response header - checksum2
-	uint8_t offset = (uint8_t)0;
-	uint8_t remaining_bytes;
-	uint8_t bytes_to_read;
-	uint32_t dwRetLen;
-	uint16_t wRet;
-	
-	uint8_t	data_buffer[255];
-	GetSDRReq_T get_sdr_req;
-	SDRRecHdr_T	*sdr_record;
-	
-	uint8_t	*output_buffer;
-	uint32_t	output_buffer_ix=0;
-	
-	output_buffer = (uint8_t *)pGetSDRRes;
-	
-	/* Find the record length first */
-	get_sdr_req.ReservationID =  (reservation_id);
-	get_sdr_req.RecID =  ( record_id );
-	get_sdr_req.Offset = 0;
-	get_sdr_req.Size = sizeof(SDRRecHdr_T);
-	dwRetLen = sizeof(SDRRecHdr_T) + sizeof(GetSDRRes_T);
-	wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, (GetSDRRes_T *)&data_buffer[0],
-			&dwRetLen, timeout );
-	
-	if(wRet != LIBIPMI_E_SUCCESS)
-		return wRet;
-		
-	/* We got record length. Now we read the record */
-	sdr_record = (SDRRecHdr_T*)&data_buffer[sizeof(GetSDRRes_T)];
-	offset = sizeof(SDRRecHdr_T);
-	remaining_bytes = sdr_record->Len;
-	
-	/* copy to output buffer */
-	memcpy(&output_buffer[output_buffer_ix], data_buffer, dwRetLen);
-	output_buffer_ix += dwRetLen;
-	
-	do {
-		bytes_to_read = (remaining_bytes > IPMB_SDR_MAX_SINGLE_READ)? IPMB_SDR_MAX_SINGLE_READ : remaining_bytes;
-		
-		get_sdr_req.ReservationID =  (reservation_id);
-		get_sdr_req.RecID =  ( record_id );
-		get_sdr_req.Offset = offset;
-		get_sdr_req.Size = bytes_to_read;
-		dwRetLen = bytes_to_read + sizeof(GetSDRRes_T);
-		wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, (GetSDRRes_T*)&data_buffer[0],
-				&dwRetLen, timeout );
-		
-		if(wRet != LIBIPMI_E_SUCCESS)
-			return wRet;
-		
-		memcpy(&output_buffer[output_buffer_ix], &data_buffer[sizeof(GetSDRRes_T)], bytes_to_read);
-		output_buffer_ix += bytes_to_read;
-		
-		offset += bytes_to_read;
-		remaining_bytes -= bytes_to_read;
-	
-	}while( remaining_bytes > 0 );
-	
-	sdr_record = (SDRRecHdr_T*)&output_buffer[sizeof(GetSDRRes_T)];
-	*dwRecordLen = sdr_record->Len + sizeof(SDRRecHdr_T);
-
-	return LIBIPMI_E_SUCCESS;	
+#define IPMB_SDR_MAX_SINGLE_READ    (22)    //32 bytes - ipmb message header - response header - checksum2
+    uint8_t offset = (uint8_t)0;
+    uint8_t remaining_bytes;
+    uint8_t bytes_to_read;
+    uint32_t dwRetLen;
+    uint16_t wRet;
+    
+    uint8_t data_buffer[255];
+    GetSDRReq_T get_sdr_req;
+    SDRRecHdr_T *sdr_record;
+    
+    uint8_t *output_buffer;
+    uint32_t    output_buffer_ix=0;
+    
+    output_buffer = (uint8_t *)pGetSDRRes;
+    
+    /* Find the record length first */
+    get_sdr_req.ReservationID =  (reservation_id);
+    get_sdr_req.RecID =  ( record_id );
+    get_sdr_req.Offset = 0;
+    get_sdr_req.Size = sizeof(SDRRecHdr_T);
+    dwRetLen = sizeof(SDRRecHdr_T) + sizeof(GetSDRRes_T);
+    wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, (GetSDRRes_T *)&data_buffer[0],
+            &dwRetLen, timeout );
+    
+    if(wRet != LIBIPMI_E_SUCCESS)
+        return wRet;
+        
+    /* We got record length. Now we read the record */
+    sdr_record = (SDRRecHdr_T*)&data_buffer[sizeof(GetSDRRes_T)];
+    offset = sizeof(SDRRecHdr_T);
+    remaining_bytes = sdr_record->Len;
+    
+    /* copy to output buffer */
+    memcpy(&output_buffer[output_buffer_ix], data_buffer, dwRetLen);
+    output_buffer_ix += dwRetLen;
+    
+    do {
+        bytes_to_read = (remaining_bytes > IPMB_SDR_MAX_SINGLE_READ)? IPMB_SDR_MAX_SINGLE_READ : remaining_bytes;
+        
+        get_sdr_req.ReservationID =  (reservation_id);
+        get_sdr_req.RecID =  ( record_id );
+        get_sdr_req.Offset = offset;
+        get_sdr_req.Size = bytes_to_read;
+        dwRetLen = bytes_to_read + sizeof(GetSDRRes_T);
+        wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, (GetSDRRes_T*)&data_buffer[0],
+                &dwRetLen, timeout );
+        
+        if(wRet != LIBIPMI_E_SUCCESS)
+            return wRet;
+        
+        memcpy(&output_buffer[output_buffer_ix], &data_buffer[sizeof(GetSDRRes_T)], bytes_to_read);
+        output_buffer_ix += bytes_to_read;
+        
+        offset += bytes_to_read;
+        remaining_bytes -= bytes_to_read;
+    
+    }while( remaining_bytes > 0 );
+    
+    sdr_record = (SDRRecHdr_T*)&output_buffer[sizeof(GetSDRRes_T)];
+    *dwRecordLen = sdr_record->Len + sizeof(SDRRecHdr_T);
+
+    return LIBIPMI_E_SUCCESS;   
 }
 
   uint16_t LIBIPMI_HL_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession,
                                               uint16_t reservation_id,
                                               uint16_t record_id,
-					      GetSDRRes_T *pGetSDRRes,
-					      uint32_t *dwDataLen,
+                          GetSDRRes_T *pGetSDRRes,
+                          uint32_t *dwDataLen,
                                               int timeout )
 {
-	uint16_t	wRet=LIBIPMI_E_SUCCESS;
-	
-	
-	// if( pUDSSession->byMediumType == IPMB_MEDIUM )
-	// {
-	// 	wRet = ipmb_get_sdr(pUDSSession, reservation_id, 
-	// 				record_id,
-	// 				pGetSDRRes,
-	// 				dwDataLen,
-	// 				timeout );
-	// }
-	// else
-	{
-		GetSDRReq_T get_sdr_req;
-			
-		get_sdr_req.ReservationID =  (reservation_id);
-		get_sdr_req.RecID =  ( record_id );
-		get_sdr_req.Offset = 0;
-		get_sdr_req.Size = 0xff;
-    	wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, pGetSDRRes,
-                           dwDataLen, timeout );
-	}
-
-	return wRet;	
+    uint16_t    wRet=LIBIPMI_E_SUCCESS;
+    
+    GetSDRReq_T get_sdr_req;
+        
+    get_sdr_req.ReservationID =  (reservation_id);
+    get_sdr_req.RecID =  ( record_id );
+    get_sdr_req.Offset = 0;
+    get_sdr_req.Size = 0xff;
+    wRet = IPMICMD_GetSDR( pUDSSession, &get_sdr_req, pGetSDRRes,
+                       dwDataLen, timeout );
+
+    return wRet;    
 }
 
-  uint16_t LIBIPMI_HL_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession,
+uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+                                              uint16_t reservation_id,
+                                              uint16_t record_id,
+                          GetSDRRes_T *pGetSDRRes,
+                          uint32_t *dwDataLen,
+                                              int timeout )
+{
+    int wRet = 0;
+    uint32_t    dwResLen;
+    uint8_t     Req[50] = {0};
+    uint8_t     Res[100] = {0};
+
+    //first do a SEL reservation
+    Req[0] = 0x40;  //Track | channel 0
+    Req[1] = IpmbAddr;
+    Req[2] = NETFNLUN_IPMI_STORAGE;
+    Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
+    Req[4] = 0x20;
+    Req[5] = 0x10;
+    Req[6] = CMD_GET_SDR;   
+    Req[7] = reservation_id&0xff;
+    Req[8] = (reservation_id>>8)&0xff;
+    Req[9] = (record_id)&0xff;
+    Req[10] = (record_id>>8)&0xff;
+    Req[11] = 0;    //offset
+    Req[12] = 0xff; //size
+    Req[13] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11] + Req[12])&0xff;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+                            NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+                            Req, 14,
+                            Res,  &dwResLen,
+                            timeout);
+    // printf("======> ");
+    // int i;
+    // for(i=0;i<dwResLen;i++)
+    //     printf("%#x ", Res[i]);
+    // printf("\n");
+
+    if((wRet != 0) || (Res[6] != 0))
+    {
+        printf("IPMC_GetSDR!\n");
+        return -1;
+    }
+
+    *dwDataLen = dwResLen - 7;
+    memcpy(pGetSDRRes, &Res[6], *dwDataLen);
+    return wRet;    
+}
+
+  uint16_t Storlead_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                               uint16_t record_id,
                                               uint16_t *next_record_id,
                                               uint8_t *sdr_buffer,
@@ -418,7 +526,14 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
     int max_sdr_len;
 
     /* Get repository allocation information */
-    wRet = IPMICMD_GetSDRRepositoryAllocInfo( pUDSSession, &alloc_info, timeout );
+    if(IpmbAddr == 0x20)
+    {
+        wRet = IPMICMD_GetSDRRepositoryAllocInfo( pUDSSession, &alloc_info, timeout );
+    }
+    else
+    {
+        wRet = IPMC_GetSDRRepositoryAllocInfo( pUDSSession, IpmbAddr, &alloc_info, timeout );   
+    }
     if( wRet != LIBIPMI_E_SUCCESS )
         return( wRet );
     
@@ -437,8 +552,16 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
         return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
     
     get_sdr_res = (GetSDRRes_T *)temp_buffer;
-    wRet = LIBIPMI_HL_GetSDR(pUDSSession,  (reservation.ReservationID),
-    					record_id, (GetSDRRes_T *)temp_buffer, &blen, timeout);
+    if(IpmbAddr == 0x20)
+    {
+        wRet = LIBIPMI_HL_GetSDR(pUDSSession,  (reservation.ReservationID),
+                        record_id, (GetSDRRes_T *)temp_buffer, &blen, timeout);
+    }
+    else
+    {
+        wRet = IPMC_GetSDR(pUDSSession,  IpmbAddr, (reservation.ReservationID),
+                        record_id, (GetSDRRes_T *)temp_buffer, &blen, timeout);
+    }
     if( wRet != LIBIPMI_E_SUCCESS )
     {
         printf("---> LIBIPMI_HL_GetSDR error!\n");
@@ -454,8 +577,8 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
     return( wRet );
 }
 
-
-  uint16_t LIBIPMI_HL_GetAllSDRs( IPMI20_UDS_SESSION_T *pUDSSession,
+//LIBIPMI_HL_GetAllSDRs
+  uint16_t Storlead_GetAllSDRs( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                           uint8_t *sdr_buffer, size_t buffer_len,
                                           int timeout )
 {
@@ -468,12 +591,26 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
     int i;
 
     /* Get repository allocation information */
-    wRet = IPMICMD_GetSDRRepositoryAllocInfo( pUDSSession, &alloc_info, timeout );
+    if(IpmbAddr == 0x20)
+    {
+        wRet = IPMICMD_GetSDRRepositoryAllocInfo( pUDSSession, &alloc_info, timeout );
+    }
+    else
+    {
+        wRet = IPMC_GetSDRRepositoryAllocInfo( pUDSSession, IpmbAddr, &alloc_info, timeout );   
+    }
     if( wRet != LIBIPMI_E_SUCCESS )
         return( wRet );
 
     /* Get repository information */
-    wRet = IPMICMD_GetSDRRepositoryInfo( pUDSSession, &repo_info, timeout );
+    if(IpmbAddr == 0x20)
+    {    
+        wRet = IPMICMD_GetSDRRepositoryInfo( pUDSSession, &repo_info, timeout );
+    }
+    else
+    {
+        wRet = IPMC_GetSDRRepositoryInfo( pUDSSession, IpmbAddr, &repo_info, timeout );
+    }
     if( wRet != LIBIPMI_E_SUCCESS )
         return( -1 );
 
@@ -494,7 +631,7 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
         uint16_t next_record_id;
 
         /* Read the full SDR into the buffer */
-        wRet = LIBIPMI_HL_GetCompleteSDR( pUDSSession, record_id, &next_record_id,
+        wRet = Storlead_GetCompleteSDR( pUDSSession, IpmbAddr, record_id, &next_record_id,
                                           &sdr_buffer[ i * max_sdr_len ],
                                           max_sdr_len, timeout );
         //printf("---> i: %d, record_id: %d, next_record_id: %d\n", i, record_id, next_record_id);
@@ -511,17 +648,17 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
 
   uint16_t LIBIPMI_HL_GetAllSDRs_Cached( IPMI20_UDS_SESSION_T *pUDSSession,
                                           uint8_t *sdr_buffer, 
-										  uint32_t* sdr_buff_size,
-										  uint32_t* max_sdr_len,
-										  uint32_t * sdr_count,
+                                          uint32_t* sdr_buff_size,
+                                          uint32_t* max_sdr_len,
+                                          uint32_t * sdr_count,
                                           int timeout )
 {
-	uint16_t wRet;
+    uint16_t wRet;
 
-//	wRet = CacheGetAllSDRS(pUDSSession,sdr_buffer,sdr_buff_size,max_sdr_len,sdr_count);
+//  wRet = CacheGetAllSDRS(pUDSSession,sdr_buffer,sdr_buff_size,max_sdr_len,sdr_count);
 
     
-	return wRet;
+    return wRet;
 }
 
   uint16_t LIBIPMI_HL_GetSpecificSDR( IPMI20_UDS_SESSION_T *pUDSSession,
@@ -532,7 +669,7 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
 {
     ReserveSDRRepositoryRes_T ResReserveSDRRepository;
     uint8_t *data_buffer = walloc(255);
-    FullSensorRec_T	*sdr_record = (FullSensorRec_T*) &data_buffer[sizeof(GetSDRRes_T)];
+    FullSensorRec_T *sdr_record = (FullSensorRec_T*) &data_buffer[sizeof(GetSDRRes_T)];
     GetSDRReq_T ReqGetSDR;
     GetSDRRes_T *pResGetSDR = (GetSDRRes_T *) &data_buffer[0];
     uint32_t      dwRetLen = 255;   //sizeof(data_buffer);
@@ -549,7 +686,7 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
         ReqGetSDR.Size = 0xff;
         wRet = IPMICMD_GetSDR(pUDSSession, &ReqGetSDR, pResGetSDR, &dwRetLen, timeout);
         //TODO: IPMICMD_GetSDR replaced by LIBIPMI_HL_GetSDR, by jimbo
-        //wRet = LIBIPMI_HL_GetSDR(pUDSSession,	ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
+        //wRet = LIBIPMI_HL_GetSDR(pUDSSession, ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
         if (wRet != LIBIPMI_E_SUCCESS)
         {
             printf("Get SDR error!\n");

+ 184 - 206
app/goahead-3.6.5/src/libipmi/src/libipmi_sensor.c

@@ -31,6 +31,7 @@
 #include "com_BmcType.h"
 #include "com_IPMIDefs.h"
 #include "com_IPMI_Storlead.h"
+#include "com_IPMI_App.h"
 
 
 #define PACKED __attribute__ ((packed))
@@ -603,162 +604,62 @@ LIBIPMI_HL_LoadSensorSDRs( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t **sdr_buff
 }
 
 
-  uint16_t
-LIBIPMI_HL_GetSensorCount( IPMI20_UDS_SESSION_T *pUDSSession, int *sdr_count, int timeout )
+uint16_t LIBIPMI_HL_GetSensorCount( IPMI20_UDS_SESSION_T *pUDSSession, int *sdr_count, int timeout )
 {
-    uint16_t wRet;
-    SDRRepositoryInfo_T pResSDRRepoInfo;
+    uint8_t    	Req[20];
+    uint8_t 	Res[50];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
 
-    wRet =  IPMICMD_GetSDRRepositoryInfo( pUDSSession,
-                                                        &pResSDRRepoInfo,
-                                                        timeout);
-    if(wRet != LIBIPMI_E_SUCCESS)
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+                                            NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_INFO,
+                                            Req, 0,
+                                            Res, &dwResLen,
+                                            timeout);
+    if((wRet != LIBIPMI_E_SUCCESS) || (Res[0] != 0))
     {
-        printf("Error in Getting Num of Sensor infon\n");
+        printf("Error in Getting Num of Sensor infor\n");
+        *sdr_count = 0;
         return wRet;
     }
 
-    *sdr_count = pResSDRRepoInfo.RecCt;
-    return wRet;
+    *sdr_count = (Res[3]<<8) | Res[2];
+    return 0;
 }
 
-#if 0
-  uint16_t
-LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession,
-                                 struct sensor_data *sensor_list, int timeout )
+uint16_t IPMC_GetSensorCount( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int *sdr_count, int timeout )
 {
-    uint16_t wRet;
-    uint8_t *sdr_buffer;
-    int sdr_count;
-    int i;
-    GetSensorThresholdReq_T * pReqGetSensorThreshold;
-    GetSensorThresholdRes_T * pResGetSensorThreshold;
-
-    /* Load the SDRs related to sensors into memory */
-    wRet = LIBIPMI_HL_LoadSensorSDRs( pUDSSession, &sdr_buffer, &sdr_count, timeout );
-    if( wRet != LIBIPMI_E_SUCCESS )
-    {
-        printf( "Cannot load sensor SDRs\n" );
-        return( wRet );
-    }
+    int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SDR_REPOSITORY_INFO;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
 
-    /* For each SDR entry... */
-    for( i = 0; i < sdr_count; i++ )
+    if((wRet != LIBIPMI_E_SUCCESS) || (Res[6] != 0))
     {
-        uint8_t raw_reading;
-        float reading;
-        uint8_t discrete;
-        struct sensor_info *sensor = &( ( (struct sensor_info *)sdr_buffer )[ i ] );
-        FullSensorRec_T *record = (FullSensorRec_T *)( sensor->sdr_buffer );
-
-        /* Get the reading from this sensor */
-        wRet = LIBIPMI_HL_ReadSensorFromSDR( pUDSSession, sensor->sdr_buffer,
-                                             &raw_reading, &reading, &discrete, 15 );
-
-        //assume sensor is accessible till we find out otherwise
-        sensor_list[i].SensorAccessibleFlags = 0;
-
-        if( wRet != LIBIPMI_E_SUCCESS )
-        {
-            if(GET_ERROR_CODE(wRet) == 0xD5)
-            {
-                //sensor is not accessbile
-                printf("Sensor is not accessible..server maybe powered off\n");
-                sensor_list[i].SensorAccessibleFlags = GET_ERROR_CODE(wRet);
-            }
-            else if(GET_ERROR_CODE(wRet) == OEMCC_SENSOR_DISABLED)
-            {
-                sensor_list[i].SensorAccessibleFlags = 0xD5;
-            }
-            raw_reading = 0x00;
-            reading = 0x00;
-            discrete = 0x00;
-        }
-
-        /*Get Updated Threshold Values*/
-        pReqGetSensorThreshold = malloc(sizeof(GetSensorThresholdReq_T));
-        if(NULL == pReqGetSensorThreshold)
-            return -1;
-        pResGetSensorThreshold = malloc(sizeof(GetSensorThresholdRes_T));
-        if(NULL == pResGetSensorThreshold)
-        {
-            free(pReqGetSensorThreshold);
-            return -1;
-        }
-        memset(pResGetSensorThreshold, 0, sizeof(GetSensorThresholdRes_T));
-
-        pReqGetSensorThreshold->SensorNum = record->SensorNum;
-        wRet = IPMICMD_GetSensorThreshold(pUDSSession, pReqGetSensorThreshold, 
-                                                                pResGetSensorThreshold, 15);
-
-        if( wRet == LIBIPMI_E_SUCCESS )
-        {
-            record->UpperNonRecoverable = pResGetSensorThreshold->UpperNonRecoverable;
-            record->UpperNonCritical = pResGetSensorThreshold->UpperNonCritical;
-            record->UpperCritical= pResGetSensorThreshold->UpperCritical;
-            record->LowerNonRecoverable  = pResGetSensorThreshold->LowerNonRecoverable;
-            record->LowerNonCritical = pResGetSensorThreshold->LowerNonCritical;
-            record->LowerCritical = pResGetSensorThreshold->LowerCritical;
-        }
-
-        /* Copy the relevant sensor data into caller's array */
-        strcpy( sensor_list[ i ].sensor_name, sensor->description );
-        sensor_list[ i ].sensor_num = record->SensorNum;
-        sensor_list[ i ].owner_id = record->OwnerID;
-        sensor_list[ i ].owner_lun = record->OwnerLUN;
-        sensor_list[ i ].sensor_type = record->SensorType;
-        sensor_list[ i ].sensor_units[ 0 ] = record->Units1;
-        sensor_list[ i ].sensor_units[ 1 ] = record->Units2;
-        sensor_list[ i ].sensor_units[ 2 ] = record->Units3;
-        sensor_list[ i ].sensor_reading = reading;
-        sensor_list[ i ].raw_reading = raw_reading;
-
-        /* If we have a discrete sensor... */
-        if( discrete )
-        {
-            /* ...copy just the discrete state */
-            sensor_list[ i ].sensor_state = 0;
-            sensor_list[ i ].discrete_state = discrete;
-        }
-        else
-        {
-            int retval;
-
-            /* ...if we have thresholds, get the threshold state and copy */
-            /* all the threshold information to the caller's array.       */
-            retval = GetSensorState( pUDSSession, raw_reading, sensor->sdr_buffer, & (sensor_list[ i ].sensor_state) , 15);
-            if( retval < 0 )
-                printf( "get_sdr_sensor_state failed\n" );
-            sensor_list[ i ].discrete_state = 0;
-        ipmi_convert_reading(sensor->sdr_buffer, 
-            pResGetSensorThreshold->LowerNonRecoverable,
-            &sensor_list[ i ].low_non_recov_thresh);
-        ipmi_convert_reading(sensor->sdr_buffer, 
-            pResGetSensorThreshold->LowerCritical,
-            &sensor_list[ i ].low_crit_thresh);
-        ipmi_convert_reading(sensor->sdr_buffer, 
-            pResGetSensorThreshold->LowerNonCritical,
-            &sensor_list[ i ].low_non_crit_thresh);
-        ipmi_convert_reading(sensor->sdr_buffer, 
-            pResGetSensorThreshold->UpperNonCritical,
-            &sensor_list[ i ].high_non_crit_thresh);
-        ipmi_convert_reading(sensor->sdr_buffer, 
-            pResGetSensorThreshold->UpperCritical,
-            &sensor_list[ i ].high_crit_thresh);
-        ipmi_convert_reading(sensor->sdr_buffer, 
-            pResGetSensorThreshold->UpperNonRecoverable,
-            &sensor_list[ i ].high_non_recov_thresh);
-        }
-        free(pReqGetSensorThreshold);
-        free(pResGetSensorThreshold);
+        printf("Error in Getting Num of Sensor infor\n");
+        *sdr_count = 0;
+        return wRet;
     }
 
-    /* The sdr list was allocated by sdr_load, and we must free it */
-    free( sdr_buffer );
-    return( 0 );
+    *sdr_count = (Res[9]<<8) | Res[8];
+    return 0;
 }
-#endif
-
 
   uint16_t	LIBIPMI_HL_GetSensorReadingFactors( IPMI20_UDS_SESSION_T *pUDSSession,
 										GetSensorReadingFactorReq_T	*pReqGetSensorReadingFactor,
@@ -780,72 +681,11 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession,
 											&dwResLen,
 											timeout);
 	
-#if 0
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
-	                     
-						NetFnLunBladeSts, 
-						CMD_GET_BLADE_STS,
-						(uint8_t*)&ReqData, 
-						(uint32_t)1,
-						(uint8_t*)pResBladeSts, &dwResLen,
-						timeout);
-
-
-	uint16_t	wRet;
-	uint32_t	dwResLen;
-	
-	dwResLen = sizeof(GetSensorReadingFactorRes_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-											NETFNLUN_IPMI_SENSOR, CMD_GET_SENSOR_READING_FACTORS,
-											(uint8_t*)pReqGetSensorReadingFactor, 
-											sizeof(GetSensorReadingFactorReq_T),
-											(uint8_t *)pResGetSensorReadingFactor, &dwResLen,
-											timeout);
-#endif	
 
 	return wRet;
 }
 
-//
-//  uint16_t LIBIPMI_HL_GetSensorHistoryReadingData( IPMI20_UDS_SESSION_T *pUDSSession,            SensorhistoryData_T *pHistoryData, uint8_t nNumSensor, int timeout)
-//{
-//	uint8_t	nReq;
-//	uint16_t	wRet;
-//	uint32_t	dwResLen;
-//	int i;
-//
-//	nReq = nNumSensor;
-//	printf("LIBIPMI_HL_GetSensorHistoryReadingData: nReq=%d\n",nReq);
-//	dwResLen = sizeof(SensorhistoryData_T);
-//	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
-//		                                     
-//										    NETFN_OEM<<2,  
-//										    0x0A,
-//										    (uint8_t*)&nReq, 
-//										    1,
-//										    (uint8_t *)pHistoryData, 
-//										    &dwResLen,
-//										    timeout);
-//
-//    for(i=1; i<=481; i++)
-//    {	printf("pHistoryData=%d", pHistoryData->records[i]);
-//    	pHistoryData->records[i]= i+1;
-//    }
-//	printf("\n");
-//	return wRet;
-//}
-
-
-
-/**
- * @fn LIBIPMI_HL_GetAllSensorReadings
- * @brief High Level API to get all the sensor Info
- * @params Session, sensor_list, nNumSensor, timout
- * @return proper completion code on success
- */
-
-  uint16_t
-LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, struct sensor_data *sensor_list, uint32_t nNumSensor, int timeout )
+uint16_t LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, struct sensor_data *sensor_list, uint32_t nNumSensor, int timeout )
 {
     uint16_t wRet;
     int sdr_count;
@@ -945,8 +785,6 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, struct senso
 	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
 	        	sensor_list[i].min_reading = tmp_float;
 
-	        	
-
 	            /*Get the Sensor state*/
 	            SensorState(pSensorBuff->SensorReading,&tmp_hw,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
 	            sensor_list[i].sensor_state = tmp_hw;
@@ -973,3 +811,143 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, struct senso
 }
 
 
+uint16_t IPMC_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, struct sensor_data *sensor_list, uint32_t nNumSensor, int timeout )
+{
+
+    int sdr_count;
+    int i ;
+  	StorleadGetSensorInfoRes_T *pGetSensorInfoRes; 
+  	SenInfo_T *pSensorBuff;
+  	float tmp_float;
+  	uint16_t tmp_hw;
+
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[100] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SENSOR_INFO;	
+	Req[7] = 0;
+	Req[8] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7])&0xff;
+
+    for(i = 0; i < nNumSensor; i++)
+    {
+    	Req[7] = i;
+		Req[8] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7])&0xff;    	
+		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 	//notice!
+						DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+						Req, 9,
+						Res, &dwResLen,
+						timeout);
+		//printf("---> i = %d, ccode = %d\n", i, Res[6]);
+		if((wRet == LIBIPMI_E_SUCCESS) && (Res[6] == 0))
+		{
+			pGetSensorInfoRes = (StorleadGetSensorInfoRes_T*)&Res[6];
+			pSensorBuff = &pGetSensorInfoRes->SensorInfo;
+			sensor_list[ i ].sensor_num = pSensorBuff->SensorNumber;
+	        sensor_list[ i ].owner_id = pSensorBuff->OwnerID;
+	        sensor_list[ i ].owner_lun = pSensorBuff->OwnerLUN;
+	        sensor_list[ i ].sensor_type = pSensorBuff->SensorTypeCode;
+	        sensor_list[ i ].sensor_units[ 0 ] = pSensorBuff->Units1;
+	        sensor_list[ i ].sensor_units[ 1 ] = pSensorBuff->Units2;
+	        sensor_list[ i ].sensor_units[ 2 ] = pSensorBuff->Units3;
+	        sensor_list[ i ].raw_reading = pSensorBuff->SensorReading;
+	        strncpy(sensor_list[ i ].sensor_name,pSensorBuff->SensorName,MAX_ID_STR_LEN);
+	        sensor_list[i].SensorAccessibleFlags = 0;
+
+	        if(pSensorBuff->EventTypeCode > 1)
+	        {
+	            /*Updating the discrete sensor details*/
+	            sensor_list[i].discrete_state = pSensorBuff->EventTypeCode;
+	            sensor_list[i].sensor_state = 0;
+	            sensor_list[ i ].sensor_reading = (float)(pSensorBuff->ComparisonStatus | (pSensorBuff->OptionalStatus << 8));
+	        }
+	        else
+	        {
+	            sensor_list[ i ].discrete_state = 0;
+	            sensor_list[ i ].Settable_Readable_ThreshMask=pSensorBuff->Settable_Readable_ThreshMask;
+	            
+	            //if(pSensorBuff->SensorReading>0)
+	            /*Convert Sensor Reading*/
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->SensorReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].sensor_reading = tmp_float;
+
+	            /*Convert LowerNonRecoverable*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT2)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonRecoverable, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].low_non_recov_thresh = tmp_float;
+
+	            /*Convert LowerCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT1)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].low_crit_thresh = tmp_float;
+
+	            /*Convert LowerNonCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT0)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].low_non_crit_thresh = tmp_float;
+
+	            /*Convert UpperNonCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT3)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].high_non_crit_thresh = tmp_float;
+
+	            /*Convert UpperCritical*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT4)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].high_crit_thresh = tmp_float;
+
+	            /*Convert UpperNonRecoverable*/
+	            if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonRecoverable, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].high_non_recov_thresh = tmp_float;
+
+	        	//MAX reading
+	        	if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->MaxReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].max_reading = tmp_float;
+
+	        	//MIN reading
+	        	if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->MinReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].min_reading = tmp_float;
+
+	            /*Get the Sensor state*/
+	            SensorState(pSensorBuff->SensorReading,&tmp_hw,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
+	            sensor_list[i].sensor_state = tmp_hw;
+            }
+
+	        /* If sensor scanning is disabled or the reading is unavailable... */
+	        if( !( pSensorBuff->Flags & SENSOR_SCANNING_BIT)  || (pSensorBuff->Flags & UNABLE_TO_READ_SENSOR) )
+	        {
+	            /* Return an error code to let the caller know */
+	            sensor_list[i].SensorAccessibleFlags = SENSOR_NOT_AVAILABLE;
+	            sensor_list[i].sensor_reading = 0;
+	            sensor_list[i].discrete_state = 0;
+	            sensor_list[i].raw_reading = 0;
+	        }
+
+	        //printf("sensor_list[%d]: SensorNum %d, SensorName %s, SensorReading = %f\n", i, sensor_list[i].sensor_num, sensor_list[i].sensor_name, sensor_list[i].sensor_reading);
+		}
+		else
+		{
+			printf("error getting sensor info %d\n",wRet);
+		}
+    }
+    return wRet ;
+}

+ 343 - 203
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -237,6 +237,39 @@ uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIn
 	return wRet;
 }
 
+uint16_t IPMC_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SET_FAN_INFO;	
+	Req[7] = fanIndex;
+	Req[8] = fanMode;
+	Req[9] = fanLevel;
+	Req[10] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 11,
+											Res, &dwResLen,
+											timeout);
+	if(( wRet != 0 ) || (Res[6] != 0))
+	{
+			printf("Error IPMC_SetFanInfo\n");
+			return -1;
+	}
+	return wRet;
+}
+
 uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pSysInfo, int timeout)
 {
 	
@@ -290,6 +323,79 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 	return 0;
 }
 
+uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, SysInfo_T *pSysInfo, int timeout)
+{
+	
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[20] = {0};
+	uint8_t		Res[MAX_TEXT_LEN+5];
+	uint16_t 	strLen, remainLen;
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SYS_INFO;	
+	Req[7] = 0;
+	Req[8] = 0;
+	Req[9] = 0;
+	Req[10] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
+	Req[11] = MAX_TITLE_LEN&0xff;
+	Req[12] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 13,
+											Res, &dwResLen,
+											timeout);
+
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> get Title error\n");
+		return -1;
+	}
+	strLen = (Res[7]<<8) | Res[8];
+	remainLen = (Res[9]<<8) | Res[10];
+	memcpy(pSysInfo->title,&Res[11],strLen);
+
+	//get text
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SYS_INFO;	
+	Req[7] = 1;
+	Req[8] = 0;
+	Req[9] = 0;
+	Req[10] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
+	Req[11] = MAX_TEXT_LEN&0xff;
+	Req[12] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 13,
+											Res, &dwResLen,
+											timeout);
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> get Text error\n");
+		return -1;
+	}
+	strLen = (Res[7]<<8) | Res[8];
+	remainLen = (Res[9]<<8) | Res[10];
+	memcpy(pSysInfo->text,&Res[11],strLen);
+	
+	return 0;
+}
 
 
 uint16_t
@@ -387,27 +493,6 @@ LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_s
 	return 0;
 }
 
-
-// uint16_t	LIBIPMI_HL_GetAllCards(IPMI20_UDS_SESSION_T *pUDSSession,
-// 		         CardStatus_T*	pResBladeSts,
-// 					int timeout)
-// {
-// 	uint16_t	wRet;
-// 	uint32_t	dwResLen;
-// 	uint8_t	  ReqData = g_OemWebFlags.bladeNum;
-	
-// 	dwResLen = sizeof(CardStatus_T);
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-// 						0x2e<<2, 0x82,
-// 						(uint8_t*)&ReqData, (uint32_t)1,
-// 						(uint8_t*)pResBladeSts, &dwResLen,
-// 						timeout);
-// 	if( wRet != 0 )
-// 		printf("Error getting Blade Status Info\n");
-						
-// 	return wRet;
-// }
-
 // /************************************************* new add **********************************************************************/
 int LIBIPMI_HL_GetChassisInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemChassisInfo_T* pChassisInfo, int timeout)
 {
@@ -419,12 +504,18 @@ int LIBIPMI_HL_GetChassisInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemChassisInfo_
 							NULL, 0,
 							(uint8_t*)pRes,  &dwResLen,
 							timeout);
-	if( wRet != 0 )
+	if(( wRet != 0 ) || (pRes[0] != 0))
+	{
 		printf("Error getting Blade Status Info\n");
+		memset(pChassisInfo, 0, sizeof(OemChassisInfo_T));
+		pChassisInfo->slotNum = BLADE_NUMBERS;
+		pChassisInfo->curIndex = 0;
+		return -1;
+	}
 		
 	pChassisInfo->slotNum = pRes[1];
-	pChassisInfo->supportChassisManageFn = pRes[2];
-	pChassisInfo->chassisManageFnEnable = pRes[3];
+	pChassisInfo->isChMC = pRes[2];
+	pChassisInfo->chassisManageFnEnable = pRes[3];	//该字段废弃。
 	pChassisInfo->curIndex = pRes[4];
 	return 0;
 }
@@ -439,172 +530,68 @@ int LIBIPMI_HL_GetAllBladeStatus(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t chas
 							(uint8_t*)&chassisManageEn, 1,
 							(uint8_t*)pRes,  &dwResLen,
 							timeout);
-	if( wRet != 0 )
+	if(( wRet != 0 ) || (pRes[0] != 0))
+	{
 			printf("Error getting Blade Status Info\n");
+			memset(BladeStatus, 0, BLADE_NUMBERS*sizeof(BladeStatus_T));
+	}
 		
 	memcpy(BladeStatus, pRes+1, BLADE_NUMBERS*sizeof(BladeStatus_T));
 	return 0;
 }
 
-// int LIBIPMI_HL_GetIPMCCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t bladeIndex, OemIPMCCapability_T* pIPMCCapability, int timeout)
-// {
-// 	int wRet = 0;
-// 	uint32_t	dwResLen;
-// 	uint8_t pRes[sizeof(OemIPMCCapability_T)+1];
-	
-
-// 	if(pUDSSession->byMediumType == UDS_MEDIUM)
-// 	{
-// 		pRes[1] = 1;
-// 		pRes[2] = 1;
-// 		pRes[3] = 1;
-// 		pRes[4] = 1;
-// 		pRes[5] = 1;
-// 		pRes[6] = 1;
-// 		pRes[7] = 1;
-// 	}
-// 	else
-// 	{
-// 			wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-// 									0x2e<<2, 0x88,
-// 									NULL, 0,
-// 									(uint8_t*)pRes,  &dwResLen,
-// 									timeout);
-// 			if( wRet != 0 )
-// 					printf("Error LIBIPMI_HL_GetIPMCCapability\n");
-// 	}
-	
-// 	memcpy(pIPMCCapability, pRes+1, sizeof(OemIPMCCapability_T));
-	
-// 	return 0;
-// }
-
-// int LIBIPMI_HL_SetBladeManageFn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t enable, int timeout)
-// {
-// 	int wRet = 0;
-// 	uint32_t	dwResLen;
-// 	uint8_t pReq[10];
-// 	uint8_t pRes[10];
-	
-// 	pReq[0] = enable;
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-// 							NETFNLUN_IPMI_STORLEAD, CMD_SET_MANAGE_FN,
-// 							(uint8_t*)pReq,	(uint32_t)1,
-// 							(uint8_t*)pRes,  &dwResLen,
-// 							timeout);
-// 	if( wRet != 0 )
-// 			printf("Error LIBIPMI_HL_SetBladeManageFn\n");
-		
-// 	return 0;
-// }
-
-// int LIBIPMI_HL_GetBladeManageFn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t *enable, int timeout)
-// {
-// 	int wRet = 0;
-// 	uint32_t	dwResLen;
-// 	uint8_t pRes[10];
-
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-// 							NETFNLUN_IPMI_STORLEAD, CMD_GET_MANAGE_FN,
-// 							NULL,	(uint32_t)0,
-// 							(uint8_t*)pRes,  &dwResLen,
-// 							timeout);
-// 	if(( wRet != 0 ) || (pRes[0] != 0))
-// 	{
-// 			printf("Error LIBIPMI_HL_SetBladeManageFn\n");
-// 			return -1;
-// 	}
-		
-// 	*enable = pRes[1];
-// 	return 0;
-// }
-
 
 int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo, int timeout)
 {
 	int wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t 	*pRes = (uint8_t *)walloc(FAN_NUMBERS*sizeof(FanInfo_T) + 10);
+	uint8_t 	*pRes = (uint8_t *)walloc(MAX_FAN_NUMS*sizeof(FanInfo_T) + 10);
 	
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 							NETFNLUN_IPMI_STORLEAD, CMD_GET_FAN_INFO,
 							NULL,	0,
 							(uint8_t*)pRes,  &dwResLen,
 							timeout);
-	if( wRet != 0 )
+	if(( wRet != 0 ) || (pRes[0] != 0))
 	{
 		printf("Error LIBIPMI_HL_GetFanInfo\n");
 		return -1;
 	}
 
-	memcpy((uint8_t*)pFanInfo, pRes+1, FAN_NUMBERS*sizeof(FanInfo_T));
-
-	// int i;
-	// printf("==========Fan get ==========\n");
-	// for(i=0;i<FAN_NUMBERS*sizeof(FanInfo_T)+1;i++)
-	// 	printf("%02x ", pRes[i]);
-	// printf("\n");
-	
+	memcpy((uint8_t*)pFanInfo, pRes+1, dwResLen-1);
 	return 0;
 }
 
-// int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout)
-// {
-// 	int wRet = 0;
-// 	uint32_t	dwResLen;
-// 	uint8_t pRes[10];
-	
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-// 							0x2e<<2, 0x88,
-// 							(uint8_t*)&sensorNum,	1,
-// 							(uint8_t*)pRes,  &dwResLen,
-// 							timeout);
-// 	if( wRet != 0 )
-// 			printf("Error LIBIPMI_HL_GetSensorHistoryCapability\n");
-	
-// 	pSensorHistoryCapability->isSupportSensorHistory = pRes[1];
-// 	pSensorHistoryCapability->SensorHistoryEnable	=	pRes[2];
-// 	return 0;
-// }
+int IPMC_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, FanInfo_T* pFanInfo, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		*Res = (uint8_t *)walloc(MAX_FAN_NUMS*sizeof(FanInfo_T) + 20);
 
-//int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t* SensorHistoryEnable, int timeout)
-//{
-// int wRet = 0;
-// uint32_t dwResLen;
-// uint8_t pRes[10];
-// 
-// wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-//       0x2e<<2, 0x8c,
-//       NULL, 0,
-//       (uint8_t*)pRes,  &dwResLen,
-//       timeout);
-// if( wRet != 0 )
-//   printf("Error LIBIPMI_HL_GetSensorHistoryEn\n");
-// 
-// *SensorHistoryEnable = pRes[1];
-// return 0;
-//}
-
-// int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout)
-// {
-//  int wRet = 0;
-//  uint32_t dwResLen;
-//  uint8_t pRes[10];
-//  uint8_t pReq[10];
- 
-//  pReq[0] = sensorNum;
-//  pReq[1] = SensorHistoryEnable;
-//  wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-//        0x2e<<2, 0x8d,
-//        (uint8_t*)pReq, 2,
-//        (uint8_t*)pRes,  &dwResLen,
-//        timeout);
-//  if( wRet != 0 )
-//    printf("Error LIBIPMI_HL_SetSensorHistoryEn\n");
- 
-//  return 0;
-// }
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_FAN_INFO;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
 
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+	if(( wRet != 0 ) || (Res[6] != 0))
+	{
+			printf("Error IPMC_GetFanInfo\n");
+			return -1;
+	}
+
+	memcpy((uint8_t*)pFanInfo, &Res[7], dwResLen-8);	//remove header and chksum
+	return 0;
+}
 
 /*
 *@fn IPMICMD_AMIGetSELEntires
@@ -630,6 +617,45 @@ uint16_t IPMICMD_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,AMIGetSELEnt
 	return (wRet);
 }
 
+uint16_t IPMC_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,  uint8_t IpmbAddr, AMIGetSELEntriesReq_T *pAMIGetSelEntriesReq,
+											   AMIGetSELEntriesRes_T *pAMIGetSelEntiresRes,int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	//first do a SEL reservation
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_ENTIRES;	
+	Req[7] = pAMIGetSelEntriesReq->Noofentretrieved&0xff;
+	Req[8] = (pAMIGetSelEntriesReq->Noofentretrieved>>8)&0xff;
+	Req[9] = (pAMIGetSelEntriesReq->Noofentretrieved>>16)&0xff;
+	Req[10] = (pAMIGetSelEntriesReq->Noofentretrieved>>24)&0xff;
+	Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 12,
+							Res,  &dwResLen,
+							timeout);
+
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("get sel entires failed!\n");
+		memset(pAMIGetSelEntiresRes, 0, sizeof(AMIGetSELEntriesRes_T));
+		return -1;
+	}
+
+	memcpy(pAMIGetSelEntiresRes, &Res[6], sizeof(AMIGetSELEntriesRes_T));
+	return (wRet);
+}
+
 
 /*
 *@fn LIBIPMI_HL_AMIGetSELEntires
@@ -641,7 +667,8 @@ uint16_t IPMICMD_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,AMIGetSELEnt
 *@return Returns LIBIPMI_E_SUCCESS on success
 *@return Returns proper completion code on error
 **/
-uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout)
+uint16_t Storlead_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+	SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout)
 {
 	AMIGetSELEntriesReq_T pAMIGetSelEntriesReq = {0};
 	AMIGetSELEntriesRes_T *pAMIGetSelEntiresRes;
@@ -666,7 +693,14 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 	
 	do
 	{
-		wRet = IPMICMD_AMIGetSELEntires(pUDSSession,&pAMIGetSelEntriesReq,(AMIGetSELEntriesRes_T *)SELEntries,timeout);
+		if(IpmbAddr == 0x20)
+		{
+			wRet = IPMICMD_AMIGetSELEntires(pUDSSession,&pAMIGetSelEntriesReq,(AMIGetSELEntriesRes_T *)SELEntries,timeout);
+		}
+		else
+		{
+			wRet = IPMC_AMIGetSELEntires(pUDSSession, IpmbAddr, &pAMIGetSelEntriesReq,(AMIGetSELEntriesRes_T *)SELEntries,timeout);
+		}
 		if(wRet == LIBIPMI_E_SUCCESS)
 		{
 			for(i = 0; i < pAMIGetSelEntiresRes->Noofentries; i++)
@@ -719,50 +753,46 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 	{
 		if(LastRecID != 0xFFFF)
 		{
-			wRet = LIBIPMI_HL_GetMaxPossibleSELEntries(pUDSSession,&MaxSELEntries,timeout);
-			if(wRet == LIBIPMI_E_SUCCESS)
+			if(LastRecID > MAX_SEL_RECORD)
 			{
-				 if(LastRecID > MaxSELEntries)
+				for(i = 0; i < *nNumSelEntries; i++)
 				{
-					for(i = 0; i < *nNumSelEntries; i++)
+					if(pSELEntriesBuffer[i].EventRecord.EvtRecord.hdr.ID == LastRecID)
 					{
-						if(pSELEntriesBuffer[i].EventRecord.EvtRecord.hdr.ID == LastRecID)
-						{
-							recindex = i;
-							break;
-						}
+						recindex = i;
+						break;
 					}
-	
-					/* Last Record is not found if reached till end of SEL Entries*/
-					if(i == *nNumSelEntries)
+				}
+
+				/* Last Record is not found if reached till end of SEL Entries*/
+				if(i == *nNumSelEntries)
+				{
+					wRet = 0xFF;
+					return wRet;
+				}
+
+				/*SEL Records added lastely will be displayed first */
+				CircSELEntries = (SELEventRecordWithSensorName_T *)walloc (sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
+				if(CircSELEntries != NULL)
+				{
+					memset(CircSELEntries,0,sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
+					j = recindex; i = 0;
+					while(j >= 0)
 					{
-						wRet = 0xFF;
-						return wRet;
+						memcpy((uint8_t *)&CircSELEntries[i],(uint8_t*)&pSELEntriesBuffer[j],sizeof(SELEventRecordWithSensorName_T));
+						j--;i++;
 					}
-	
-					/*SEL Records added lastely will be displayed first */
-					CircSELEntries = (SELEventRecordWithSensorName_T *)walloc (sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
-					if(CircSELEntries != NULL)
+
+					for(j = recindex + 1,i = 1; j < *nNumSelEntries; j++,i++)
 					{
-						memset(CircSELEntries,0,sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
-						j = recindex; i = 0;
-						while(j >= 0)
-						{
-							memcpy((uint8_t *)&CircSELEntries[i],(uint8_t*)&pSELEntriesBuffer[j],sizeof(SELEventRecordWithSensorName_T));
-							j--;i++;
-						}
-	
-						for(j = recindex + 1,i = 1; j < *nNumSelEntries; j++,i++)
-						{
-							memcpy((uint8_t*)&CircSELEntries[j],(uint8_t*)&pSELEntriesBuffer[*nNumSelEntries - i ],sizeof(SELEventRecordWithSensorName_T));
-						}
-	
-						for(i = 0,j=1;i< *nNumSelEntries; i++,j++)
-						{
-							memcpy((uint8_t*)&pSELEntriesBuffer[i],(uint8_t*)&CircSELEntries[*nNumSelEntries - j],sizeof(SELEventRecordWithSensorName_T));
-						}
-						wfree(CircSELEntries);
+						memcpy((uint8_t*)&CircSELEntries[j],(uint8_t*)&pSELEntriesBuffer[*nNumSelEntries - i ],sizeof(SELEventRecordWithSensorName_T));
 					}
+
+					for(i = 0,j=1;i< *nNumSelEntries; i++,j++)
+					{
+						memcpy((uint8_t*)&pSELEntriesBuffer[i],(uint8_t*)&CircSELEntries[*nNumSelEntries - j],sizeof(SELEventRecordWithSensorName_T));
+					}
+					wfree(CircSELEntries);
 				}
 			}
 		}
@@ -785,6 +815,32 @@ uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, int timeout)
 	return (wRet);
 }
 
+uint16_t IPMC_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[10] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_COLD_RESET;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+	
+	
+	return (wRet);
+}
+
 uint16_t IPMICMD_SetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout)
 {
 	uint16_t wRet;
@@ -846,6 +902,32 @@ uint16_t IPMICMD_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, int t
 	return (wRet);
 }
 
+uint16_t IPMC_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout)
+{
+	uint16_t    wRet = 0;
+    uint8_t     Req[20] = {0};
+    uint8_t     Res[10];
+    uint32_t    dwResLen;
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_RESTORE_FACTORY_SET;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req,8,
+											Res, &dwResLen,
+											timeout);
+
+	return (wRet);
+}
+
 int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T *DevIDRes, int timeout)
 {
 	int wRet = 0;
@@ -876,12 +958,70 @@ int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr
 	}
 	printf("\n");
 
-	memcpy(DevIDRes, Res, sizeof(GetDevIDRes_T));
-	if(( wRet != 0 ) || (Res[0] != 0))
+	memcpy(DevIDRes, &Res[6], sizeof(GetDevIDRes_T));
+	if(( wRet != 0 ) || (Res[6] != 0))
 	{
 			printf("Error IPMC GetDeviceID\n");
 			return -1;
 	}
 		
+	return 0;
+}
+
+int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *sensor_name, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = sensor_number;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_STORLEAD, CMD_GET_SENSOR_NAME,
+							Req, 1,
+							Res,  &dwResLen,
+							timeout);
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("IPMI_GetSensorName failed!\n");
+		memset(sensor_name, 0, MAX_ID_STR_LEN);
+		return -1;
+	}
+
+	memcpy(sensor_name, &Res[1], MAX_ID_STR_LEN);
+	return 0;
+}
+
+int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SENSOR_NAME;	
+	Req[7] = sensor_number;
+	Req[8] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 9,
+							Res,  &dwResLen,
+							timeout);
+
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMI_GetSensorName failed!\n");
+		memset(sensor_name, 0, MAX_ID_STR_LEN);
+		return -1;
+	}
+
+	memcpy(sensor_name, &Res[7], MAX_ID_STR_LEN);
 	return 0;
 }

+ 80 - 80
app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c

@@ -539,49 +539,49 @@ int get_sdr_sensor_state( uint8_t sensor_reading, uint8_t *sdr_buffer, uint16_t
 }
 
 int GetSensorState(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_reading, 
-	uint8_t *sdr_buffer, uint16_t *current_state, int timeout  )
+    uint8_t *sdr_buffer, uint16_t *current_state, int timeout  )
 {
-	SDRRecHdr_T *header = (SDRRecHdr_T *)sdr_buffer;
-	//number_type reading_format = Unsigned;
-	int  RetVal = 0;
+    SDRRecHdr_T *header = (SDRRecHdr_T *)sdr_buffer;
+    //number_type reading_format = Unsigned;
+    int  RetVal = 0;
        GetSensorEventStatusReq_T pReqGetSensorEventStatus;
        GetSensorEventStatusRes_T pResGetSensorEventStatus;
 #ifdef CFG_PROJ_REARM_SENSOR
        ReArmSensorReq_T ReArmSensorReq;
        ReArmSensorRes_T ReArmSensorRes;
 #endif
-	//INT16U AssertionEvent = 0, DeAssertionEvent = 0;
+    //INT16U AssertionEvent = 0, DeAssertionEvent = 0;
 
-	*current_state = THRESH_UNINITIALIZED;
+    *current_state = THRESH_UNINITIALIZED;
 
-	if( header->Type == FULL_SDR_REC )
-	{
-		FullSensorRec_T *record = (FullSensorRec_T *)sdr_buffer;
+    if( header->Type == FULL_SDR_REC )
+    {
+        FullSensorRec_T *record = (FullSensorRec_T *)sdr_buffer;
 
-		/* For inverse linear sensors, a raw reading of 0 is off the chart. */
-		/* We want a low reading, because this corresponds to what most     */
-		/* people expect for most sensors.  We usually get a raw reading of */
-		/* 0 when the device (like a fan) is not connected, and so          */
-		/* (logically), it is below low thresholds, not above high ones.    */
-		/* So, for purposes of determining our state, use 0xff for the      */
-		/* reading instead of 0.                                            */
+        /* For inverse linear sensors, a raw reading of 0 is off the chart. */
+        /* We want a low reading, because this corresponds to what most     */
+        /* people expect for most sensors.  We usually get a raw reading of */
+        /* 0 when the device (like a fan) is not connected, and so          */
+        /* (logically), it is below low thresholds, not above high ones.    */
+        /* So, for purposes of determining our state, use 0xff for the      */
+        /* reading instead of 0.                                            */
 
-		if((record->Linearization == (uint8_t)7 ) && ( sensor_reading == (uint8_t)0))
-		{
-			sensor_reading = (uint8_t)0xff;
-		}
+        if((record->Linearization == (uint8_t)7 ) && ( sensor_reading == (uint8_t)0))
+        {
+            sensor_reading = (uint8_t)0xff;
+        }
 
-		/* Get the format of the sensor/threshold readings */
-		//reading_format = (number_type)( record->Units1 >> 6 );
+        /* Get the format of the sensor/threshold readings */
+        //reading_format = (number_type)( record->Units1 >> 6 );
 
-		/*Threshold EventMask were swapped in SDR*/
-	//	printf("->SensorNum %d \t AssertionMask %X \t DeAssertionMask %X reading_format %d \n", 
-	//	record->SensorNum, record->AssertionEventMask, record->DeAssertionEventMask, reading_format);
-		/* If the sensor is threshold based... */
-		if( record->EventTypeCode == 0x01 )
-		{
-			/*Default Sensor State*/
-			*current_state = THRESH_NORMAL;
+        /*Threshold EventMask were swapped in SDR*/
+    //  printf("->SensorNum %d \t AssertionMask %X \t DeAssertionMask %X reading_format %d \n", 
+    //  record->SensorNum, record->AssertionEventMask, record->DeAssertionEventMask, reading_format);
+        /* If the sensor is threshold based... */
+        if( record->EventTypeCode == 0x01 )
+        {
+            /*Default Sensor State*/
+            *current_state = THRESH_NORMAL;
 
 
 #ifdef CFG_PROJ_REARM_SENSOR
@@ -594,51 +594,51 @@ int GetSensorState(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_reading,
             pReqGetSensorEventStatus.SensorNum = record->SensorNum;
             RetVal = IPMICMD_GetSensorEventStatus(pUDSSession, &pReqGetSensorEventStatus, 
                                 &pResGetSensorEventStatus, timeout);
-			
-	     if( RetVal != LIBIPMI_E_SUCCESS )
-	    		return -1;
-	    
-	     /*Do not Change the sequence of condition*/
-	     if((pResGetSensorEventStatus.AssertionEvents1 & 0x80) == 0x80)
-			*current_state = THRESH_UP_NONCRIT;
-						
-	     if((pResGetSensorEventStatus.AssertionEvents2 & 0x02) == 0x02)
-			*current_state = THRESH_UP_CRITICAL;
-						
-	     if((pResGetSensorEventStatus.AssertionEvents2 & 0x08) == 0x08)
-			*current_state = THRESH_UP_NON_RECOV;
-			
-	     if((pResGetSensorEventStatus.AssertionEvents1 & 0x01 ) == 0x01)
-			*current_state = THRESH_LOW_NONCRIT;
-						
-	     if((pResGetSensorEventStatus.AssertionEvents1 & 0x04 ) == 0x04)
-			*current_state = THRESH_LOW_CRITICAL;
-							
-	     if((pResGetSensorEventStatus.AssertionEvents1 & 0x10) == 0x10)
-			*current_state = THRESH_LOW_NON_RECOV;
-	   } /* if sensor is threshold based */
-	   else
-	   {
-			/* This sensor is discrete */
-			*current_state = (uint16_t)sensor_reading;
-	   }
-	}
-	else if( header->Type == COMPACT_SDR_REC )
-	{
-		CompactSensorRec_T *record = (CompactSensorRec_T *)sdr_buffer;
-
-		if( record->EventTypeCode > (uint8_t)1 )
-		*current_state = (uint16_t)sensor_reading;
-		else
-		*current_state = THRESH_UNINITIALIZED;
-	}
-	else
-	{
-		*current_state = THRESH_UNINITIALIZED;
-		return( -1 );
-	}
-
-	return( 0 );
+            
+         if( RetVal != LIBIPMI_E_SUCCESS )
+                return -1;
+        
+         /*Do not Change the sequence of condition*/
+         if((pResGetSensorEventStatus.AssertionEvents1 & 0x80) == 0x80)
+            *current_state = THRESH_UP_NONCRIT;
+                        
+         if((pResGetSensorEventStatus.AssertionEvents2 & 0x02) == 0x02)
+            *current_state = THRESH_UP_CRITICAL;
+                        
+         if((pResGetSensorEventStatus.AssertionEvents2 & 0x08) == 0x08)
+            *current_state = THRESH_UP_NON_RECOV;
+            
+         if((pResGetSensorEventStatus.AssertionEvents1 & 0x01 ) == 0x01)
+            *current_state = THRESH_LOW_NONCRIT;
+                        
+         if((pResGetSensorEventStatus.AssertionEvents1 & 0x04 ) == 0x04)
+            *current_state = THRESH_LOW_CRITICAL;
+                            
+         if((pResGetSensorEventStatus.AssertionEvents1 & 0x10) == 0x10)
+            *current_state = THRESH_LOW_NON_RECOV;
+       } /* if sensor is threshold based */
+       else
+       {
+            /* This sensor is discrete */
+            *current_state = (uint16_t)sensor_reading;
+       }
+    }
+    else if( header->Type == COMPACT_SDR_REC )
+    {
+        CompactSensorRec_T *record = (CompactSensorRec_T *)sdr_buffer;
+
+        if( record->EventTypeCode > (uint8_t)1 )
+        *current_state = (uint16_t)sensor_reading;
+        else
+        *current_state = THRESH_UNINITIALIZED;
+    }
+    else
+    {
+        *current_state = THRESH_UNINITIALIZED;
+        return( -1 );
+    }
+
+    return( 0 );
 }
 
 
@@ -685,7 +685,7 @@ int read_sensor_sdrs( IPMI20_UDS_SESSION_T *pUDSSession, struct sensor_info **se
         return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
 
     /* Read all the SDRs */
-    wRet = LIBIPMI_HL_GetAllSDRs( pUDSSession, sdr_buffer, buffer_len, timeout );
+    wRet = Storlead_GetAllSDRs( pUDSSession, 0x20, sdr_buffer, buffer_len, timeout );
     if( wRet != LIBIPMI_E_SUCCESS )
     {
         printf( "Failure getting all SDRs\n" );
@@ -822,7 +822,7 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
     int sensor_min, sensor_max;
     
  //   printf("uint8_t Min : 0x%02x,uint8_t Max : 0x%02x,uint8_t Units1: 0x%02x,uint8_t Lin: 0x%02x,uint8_t Mval: 0x%02x,uint8_t Bval: 0x%02x,uint8_t M_Tol: 0x%02x,uint8_t B_Acc: 0x%02x,uint8_t R_B_Ex: 0x%02x\n",
- //   		 Min, Max, Units1, Lin, Mval, Bval, M_Tol, B_Acc, R_B_Ex
+ //          Min, Max, Units1, Lin, Mval, Bval, M_Tol, B_Acc, R_B_Ex
  //   );
 
     if( SDRType != FULL_SDR_REC )
@@ -1028,14 +1028,14 @@ int SensorState( uint8_t sensor_reading, uint16_t *current_state,uint8_t SDRType
 
 /* sdr_convert_sensor_value_to_raw  -  convert sensor reading back to raw
  *
- * @sdr_record:	sdr_record
- * @val:	converted sensor reading
+ * @sdr_record: sdr_record
+ * @val:    converted sensor reading
  *
  * returns raw sensor reading
  * Reference: This function is implement IPMI SPEC. 2.0 
  * Session 36.3 Sensor Reading Conversion Formula
  */
-unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T	*sdr_record, double val)
+unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, double val)
 {
     int m, b, k1, k2;
     double result;

+ 231 - 200
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -10,7 +10,10 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
-
+/*
+    废弃机箱管理是能按钮。由BMC程序里的g_BMCInfo.isChMC代替。ChMC默认就支持机箱管理,IPMC默认不支持。
+    gChassisManageEn、setBladeManage、getBladeManage保留但是用不到。
+*/
 uint8_t gIPMBAddr[BLADE_NUMBERS] = {0x20, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94};
 uint8_t gChassisManageEn = 0;
 /*获取设备信息*/
@@ -22,67 +25,80 @@ void getDeviceInfo(Webs *wp){
     int sock;
     struct sockaddr_in *myaddr;
     IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
 
     char BuildTime[30] = {0};
     char FwVersion[10] = {0};
     char MacAddr[18] = {0};
     char IpAddr[16] = {0};
 
-    printf("---> getSensorInfo, wp.index = %d\n", wp->index);
-
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    //get build time
-    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
-
-    //get firmware version
-    wRet = IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
-    if (wRet == LIBIPMI_E_SUCCESS)
-    {
-        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
-    }
-
-    //Close session
-    LIBIPMI_CloseSession(&UDSSession );
-
-    //get mac adn ip address
-    if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
-    {
-        printf("Get mac address socket fail!\n");
-    }
-    else
+ //   wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
     {
-        strcpy(ifreq.ifr_name,"eth0");
-
-        //MAC
-        if(ioctl(sock,SIOCGIFHWADDR,&ifreq)<0)
+        //get build time
+        sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
+        //get firmware version
+        wRet = IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
+        if (wRet == LIBIPMI_E_SUCCESS)
         {
-            printf("Get mac address ioctl fail!\n");
+            sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
         }
-        else
+        //get mac adn ip address
+        if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
         {
-            sprintf(MacAddr, "%02x:%02x:%02x:%02x:%02x:%02x",
-                    (unsigned char)ifreq.ifr_hwaddr.sa_data[0],
-                    (unsigned char)ifreq.ifr_hwaddr.sa_data[1],
-                    (unsigned char)ifreq.ifr_hwaddr.sa_data[2],
-                    (unsigned char)ifreq.ifr_hwaddr.sa_data[3],
-                    (unsigned char)ifreq.ifr_hwaddr.sa_data[4],
-                    (unsigned char)ifreq.ifr_hwaddr.sa_data[5]);
+            printf("Get mac address socket fail!\n");
         }
-
-        //IP
-        if(ioctl(sock, SIOCGIFADDR, &ifreq) < 0)
+        else
         {
-            printf("Get ip address ioctl fail!\n");
+            strcpy(ifreq.ifr_name,"eth0");
+            //MAC
+            if(ioctl(sock,SIOCGIFHWADDR,&ifreq)<0)
+            {
+                printf("Get mac address ioctl fail!\n");
+            }
+            else
+            {
+                sprintf(MacAddr, "%02x:%02x:%02x:%02x:%02x:%02x",
+                        (unsigned char)ifreq.ifr_hwaddr.sa_data[0],
+                        (unsigned char)ifreq.ifr_hwaddr.sa_data[1],
+                        (unsigned char)ifreq.ifr_hwaddr.sa_data[2],
+                        (unsigned char)ifreq.ifr_hwaddr.sa_data[3],
+                        (unsigned char)ifreq.ifr_hwaddr.sa_data[4],
+                        (unsigned char)ifreq.ifr_hwaddr.sa_data[5]);
+            }
+            //IP
+            if(ioctl(sock, SIOCGIFADDR, &ifreq) < 0)
+            {
+                printf("Get ip address ioctl fail!\n");
+            }
+            else
+            {
+                myaddr = (struct sockaddr_in *)&(ifreq.ifr_addr);
+                strcpy(IpAddr, inet_ntoa(myaddr->sin_addr));   
+            }
         }
-        else
+        close(sock);    
+    }
+    else
+    {
+        //get build time
+        sprintf(BuildTime, "--");
+        sprintf(MacAddr, "--");
+        sprintf(IpAddr, "--");   
+        //get firmware version
+        wRet = IPMC_GetDeviceID( &UDSSession, target_addr, &DeviceID, DEFAULT_TIMEOUT);
+        if (wRet == LIBIPMI_E_SUCCESS)
         {
-            myaddr = (struct sockaddr_in *)&(ifreq.ifr_addr);
-            strcpy(IpAddr, inet_ntoa(myaddr->sin_addr));   
+            sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
         }
     }
-    close(sock);    
+
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
     
     char *pStr;
     cJSON * root =  cJSON_CreateObject();
@@ -97,8 +113,6 @@ void getDeviceInfo(Webs *wp){
     cJSON_AddStringToObject(data, "netMode", "static");
 
     pStr = cJSON_PrintUnformatted(root);
-
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
@@ -106,6 +120,7 @@ void getDeviceInfo(Webs *wp){
     websFlush(wp, 0);
     websDone(wp);
 
+    printf("---> cJSON Str:\n%s\n", pStr);
     if(pStr)
         wfree(pStr);
     if(root)
@@ -119,9 +134,8 @@ void getSysInfo(Webs *wp){
     int wRet;
     SysInfo_T sysInfo;
     IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;    
 
-
-    printf("---> getSysInfo, wp.index = %d\n", wp->index);
     sysInfo.title = walloc(MAX_TITLE_LEN);
     if(sysInfo.title == NULL)
     {
@@ -129,7 +143,9 @@ void getSysInfo(Webs *wp){
         goto sys_info_end;
     }
     else
+    {
         memset(sysInfo.title, 0, MAX_TITLE_LEN);
+    }
     
     sysInfo.text = walloc(MAX_TEXT_LEN);
     if(sysInfo.text == NULL)
@@ -138,12 +154,23 @@ void getSysInfo(Webs *wp){
         goto sys_info_end;
     }
     else
+    {
         memset(sysInfo.text, 0, MAX_TEXT_LEN);
+    }
 
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
     
-    LIBIPMI_HL_GetSysInfo(&UDSSession, &sysInfo, DEFAULT_TIMEOUT);
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        LIBIPMI_HL_GetSysInfo(&UDSSession, &sysInfo, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        IPMC_GetSysInfo(&UDSSession, target_addr, &sysInfo, DEFAULT_TIMEOUT);
+    }
 
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
@@ -158,14 +185,13 @@ void getSysInfo(Webs *wp){
     cJSON_AddStringToObject(data, "text", sysInfo.text);
 
     pStr = cJSON_PrintUnformatted(root);
-
- //   printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
 sys_info_end: 
     if(sysInfo.title)
@@ -211,139 +237,171 @@ void getSensorInfo(Webs *wp){
     char maxReading[10], minReading[10];
     unsigned char *pStartBuff = NULL;
     IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
     
-    printf("---> getSensorInfo, wp.index = %d\n", wp->index);
     //Create session
     LIBIPMI_CreateSession(&UDSSession, 10000);
-   
-    /* Get number of SEL records in the system at this time */
-    wRet = LIBIPMI_HL_GetSensorCount(&UDSSession,&nSensors,DEFAULT_TIMEOUT);
-    if( wRet != 0 )
+     
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
     {
-        printf("Error getting num of sensors\n");
-        goto error_out;
-    }
-    else
-    {
-        //printf("success getting num of sensors: %d\n",nSensors);  //this is all sensor count
-        /* Now get all sensors records */
-        if(!nSensors)
+        /* Get number of SEL records in the system at this time */
+        wRet = LIBIPMI_HL_GetSensorCount(&UDSSession,&nSensors,DEFAULT_TIMEOUT);
+        if( wRet != 0 )
         {
-            /* There are no sensors present at this time */
+            printf("Error getting num of sensors\n");
             goto error_out;
         }
-
-        /* Allocate the buffer to hold sensors records */
-        pSensorBuff = (struct sensor_data *) walloc(nSensors * sizeof(struct sensor_data));
-        if(pSensorBuff == NULL)
+        else
         {
-            printf("Error alloc memory!\n");
-            goto error_out;
-        }
-        memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
-        pStartBuff = (unsigned char *)pSensorBuff;
-
-        //printf("sensorcount = %d\n", nSensors);
-        nSensors -= 1;  //remove first sdr
-        wRet = LIBIPMI_HL_GetAllSensorReadings(&UDSSession,pSensorBuff, nSensors,DEFAULT_TIMEOUT);
-        
-        //Close session
-        LIBIPMI_CloseSession(&UDSSession );
+            //printf("success getting num of sensors: %d\n",nSensors);  //this is all sensor count
+            /* Now get all sensors records */
+            if(!nSensors)
+            {
+                /* There are no sensors present at this time */
+                goto error_out;
+            }
+
+            /* Allocate the buffer to hold sensors records */
+            pSensorBuff = (struct sensor_data *) walloc(nSensors * sizeof(struct sensor_data));
+            if(pSensorBuff == NULL)
+            {
+                printf("Error alloc memory!\n");
+                goto error_out;
+            }
+            memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
+            pStartBuff = (unsigned char *)pSensorBuff;
 
-        if(wRet != 0)
+            //printf("sensorcount = %d\n", nSensors);
+            nSensors -= 1;  //remove first sdr
+            wRet = LIBIPMI_HL_GetAllSensorReadings(&UDSSession,pSensorBuff, nSensors,DEFAULT_TIMEOUT);
+        }
+    }
+    else
+    {
+        /* Get number of SEL records in the system at this time */
+        wRet = IPMC_GetSensorCount(&UDSSession, target_addr, &nSensors,DEFAULT_TIMEOUT);
+        if( wRet != 0 )
         {
-            printf("Error reading All Sensors\n");
+            printf("Error getting num of sensors\n");
             goto error_out;
         }
         else
         {
+            //printf("success getting num of sensors: %d\n",nSensors);  //this is all sensor count
+            /* Now get all sensors records */
+            if(!nSensors)
+            {
+                /* There are no sensors present at this time */
+                goto error_out;
+            }
+
+            /* Allocate the buffer to hold sensors records */
+            pSensorBuff = (struct sensor_data *) walloc(nSensors * sizeof(struct sensor_data));
+            if(pSensorBuff == NULL)
+            {
+                printf("Error alloc memory!\n");
+                goto error_out;
+            }
+            memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
+            pStartBuff = (unsigned char *)pSensorBuff;
+
+            nSensors -= 1;  //remove first sdr
+            //printf("sensorcount = %d\n", nSensors);
+            wRet = IPMC_GetAllSensorReadings(&UDSSession,target_addr, pSensorBuff, nSensors,DEFAULT_TIMEOUT);
+        }
+    }
 
-            char *pStr;
-            int code = 200;
-            cJSON * root =  cJSON_CreateObject();
-            cJSON  *pJsonArry,*pJsonsub;
-            pJsonArry=cJSON_CreateArray();   /*创建数组*/
-            while(nSensors)
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+    if(wRet != 0)
+    {
+        printf("Error reading All Sensors\n");
+        goto error_out;
+    }
+    else
+    {
+
+        char *pStr;
+        int code = 200;
+        cJSON * root =  cJSON_CreateObject();
+        cJSON  *pJsonArry,*pJsonsub;
+        pJsonArry=cJSON_CreateArray();   /*创建数组*/
+        while(nSensors)
+        {
+            sprintf(reading, "%.3f", pSensorBuff->sensor_reading);
+            sprintf(lownr, "%.3f", pSensorBuff->low_non_recov_thresh);
+            sprintf(lowct, "%.3f", pSensorBuff->low_crit_thresh);
+            sprintf(lownc, "%.3f", pSensorBuff->low_non_crit_thresh);
+            sprintf(highnc, "%.3f", pSensorBuff->high_non_crit_thresh);
+            sprintf(highct, "%.3f", pSensorBuff->high_crit_thresh);
+            sprintf(highnr, "%.3f", pSensorBuff->high_non_recov_thresh);
+            sprintf(maxReading, "%.3f", pSensorBuff->max_reading);
+            sprintf(minReading, "%.3f", pSensorBuff->min_reading);
+
+            cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
+            cJSON_AddNumberToObject(pJsonsub, "sensorNum", pSensorBuff->sensor_num); 
+            cJSON_AddStringToObject(pJsonsub, "sensorName", pSensorBuff->sensor_name);
+
+            cJSON_AddStringToObject(pJsonsub, "reading", reading);      /* 给对象增加内容 */    
+            cJSON_AddStringToObject(pJsonsub, "lownr", lownr);                                        
+            cJSON_AddStringToObject(pJsonsub, "lowct", lowct);   
+            cJSON_AddStringToObject(pJsonsub, "lownc", lownc);                                                       
+            cJSON_AddStringToObject(pJsonsub, "highnc", highnc);                 
+            cJSON_AddStringToObject(pJsonsub, "highct", highct);   
+            cJSON_AddStringToObject(pJsonsub, "highnr", highnr);  
+            cJSON_AddStringToObject(pJsonsub, "maxReading", maxReading);  
+            cJSON_AddStringToObject(pJsonsub, "minReading", minReading);  
+
+            switch(pSensorBuff->sensor_units[1])    //sensorUinits2
             {
-                sprintf(reading, "%.3f", pSensorBuff->sensor_reading);
-                sprintf(lownr, "%.3f", pSensorBuff->low_non_recov_thresh);
-                sprintf(lowct, "%.3f", pSensorBuff->low_crit_thresh);
-                sprintf(lownc, "%.3f", pSensorBuff->low_non_crit_thresh);
-                sprintf(highnc, "%.3f", pSensorBuff->high_non_crit_thresh);
-                sprintf(highct, "%.3f", pSensorBuff->high_crit_thresh);
-                sprintf(highnr, "%.3f", pSensorBuff->high_non_recov_thresh);
-                sprintf(maxReading, "%.3f", pSensorBuff->max_reading);
-                sprintf(minReading, "%.3f", pSensorBuff->min_reading);
-
-                cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
-                cJSON_AddNumberToObject(pJsonsub, "sensorNum", pSensorBuff->sensor_num); 
-                cJSON_AddStringToObject(pJsonsub, "sensorName", pSensorBuff->sensor_name);
-
-            
-                cJSON_AddStringToObject(pJsonsub, "reading", reading);      /* 给对象增加内容 */    
-                cJSON_AddStringToObject(pJsonsub, "lownr", lownr);                                        
-                cJSON_AddStringToObject(pJsonsub, "lowct", lowct);   
-                cJSON_AddStringToObject(pJsonsub, "lownc", lownc);                                                       
-                cJSON_AddStringToObject(pJsonsub, "highnc", highnc);                 
-                cJSON_AddStringToObject(pJsonsub, "highct", highct);   
-                cJSON_AddStringToObject(pJsonsub, "highnr", highnr);  
-                cJSON_AddStringToObject(pJsonsub, "maxReading", maxReading);  
-                cJSON_AddStringToObject(pJsonsub, "minReading", minReading);  
-
-                switch(pSensorBuff->sensor_units[1])    //sensorUinits2
-                {
-                case 0: cJSON_AddStringToObject(pJsonsub, "unit", "unspecified"); break;                    
-                case 1: cJSON_AddStringToObject(pJsonsub, "unit", "degree C"); break;
-                case 2: cJSON_AddStringToObject(pJsonsub, "unit", "degree F"); break;
-                case 3: cJSON_AddStringToObject(pJsonsub, "unit", "degree K"); break;
-                case 4: cJSON_AddStringToObject(pJsonsub, "unit", "Volts"); break;
-                case 5: cJSON_AddStringToObject(pJsonsub, "unit", "Amps"); break;
-                case 6: cJSON_AddStringToObject(pJsonsub, "unit", "Watts"); break;
-                case 18: cJSON_AddStringToObject(pJsonsub, "unit", "RPM"); break;
-                default: cJSON_AddStringToObject(pJsonsub, "unit", "unknown"); break;
-                }
-
-                switch(pSensorBuff->sensor_state)
-                {
-                case 0x1:  cJSON_AddStringToObject(pJsonsub, "state", "ok"); cJSON_AddStringToObject(pJsonsub, "status", "1"); break;
-                case 0x2:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Critical"); cJSON_AddStringToObject(pJsonsub, "status", "2"); break;    
-                case 0x4:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Critical Threshold");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
-                case 0x8:  cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Critical");cJSON_AddStringToObject(pJsonsub, "status", "2"); break;    
-                case 0x10:  cJSON_AddStringToObject(pJsonsub, "state", "Lower Critical");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
-                case 0x20:  cJSON_AddStringToObject(pJsonsub, "state", "Access failed");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
-                case 0x40:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
-                case 0x80:  cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
-                default:  cJSON_AddNumberToObject(pJsonsub, "state", pSensorBuff->sensor_state);cJSON_AddStringToObject(pJsonsub, "status", "3"); break;      
-                }
-         
-                pSensorBuff++;
-                nSensors--;
+            case 0: cJSON_AddStringToObject(pJsonsub, "unit", "unspecified"); break;                    
+            case 1: cJSON_AddStringToObject(pJsonsub, "unit", "degree C"); break;
+            case 2: cJSON_AddStringToObject(pJsonsub, "unit", "degree F"); break;
+            case 3: cJSON_AddStringToObject(pJsonsub, "unit", "degree K"); break;
+            case 4: cJSON_AddStringToObject(pJsonsub, "unit", "Volts"); break;
+            case 5: cJSON_AddStringToObject(pJsonsub, "unit", "Amps"); break;
+            case 6: cJSON_AddStringToObject(pJsonsub, "unit", "Watts"); break;
+            case 18: cJSON_AddStringToObject(pJsonsub, "unit", "RPM"); break;
+            default: cJSON_AddStringToObject(pJsonsub, "unit", "unknown"); break;
             }
 
-            // cJSON_AddItemToObject(root, "data", pJsonArry);//根节点下添加
-            // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-            // cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-            // pStr = cJSON_Print(pJsonArry);
-            cJSON_AddItemToObject(root, "data", pJsonArry);
-            pStr = cJSON_PrintUnformatted(root);
-            // printf("---> pStr %d: %s\n", strlen(pStr), pStr);
-
-            websSetStatus(wp, 200);
-            websWriteHeaders(wp, -1, 0);
-            websWriteEndHeaders(wp); 
-            //websWrite(wp, "[");
-            websWrite(wp, pStr);
-            //websWrite(wp, "]");
-            //websFlush(wp, 0);
-            websDone(wp);
-
-            if(root)
-                cJSON_Delete(root);
-            if(pStr)
-                wfree(pStr);          
+            switch(pSensorBuff->sensor_state)
+            {
+            case 0x1:  cJSON_AddStringToObject(pJsonsub, "state", "ok"); cJSON_AddStringToObject(pJsonsub, "status", "1"); break;
+            case 0x2:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Critical"); cJSON_AddStringToObject(pJsonsub, "status", "2"); break;    
+            case 0x4:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Critical Threshold");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
+            case 0x8:  cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Critical");cJSON_AddStringToObject(pJsonsub, "status", "2"); break;    
+            case 0x10:  cJSON_AddStringToObject(pJsonsub, "state", "Lower Critical");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
+            case 0x20:  cJSON_AddStringToObject(pJsonsub, "state", "Access failed");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
+            case 0x40:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
+            case 0x80:  cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;    
+            default:  cJSON_AddNumberToObject(pJsonsub, "state", pSensorBuff->sensor_state);cJSON_AddStringToObject(pJsonsub, "status", "3"); break;      
+            }
+     
+            pSensorBuff++;
+            nSensors--;
         }
+
+       
+        cJSON_AddItemToObject(root, "data", pJsonArry);
+        pStr = cJSON_PrintUnformatted(root);
+
+        websSetStatus(wp, 200);
+        websWriteHeaders(wp, -1, 0);
+        websWriteEndHeaders(wp); 
+        websWrite(wp, pStr);
+        websFlush(wp, 0);
+        websDone(wp);
+        printf("---> cJSON Str:\n%s\n", pStr);
+
+        if(root)
+            cJSON_Delete(root);
+        if(pStr)
+            wfree(pStr);          
     }
-    //TODO: lusa
 error_out:
     if(pStartBuff)
         free(pStartBuff);
@@ -434,17 +492,18 @@ void getAllBladeInfo(Webs *wp){
         cJSON_AddNumberToObject(pJsonsub, "slot", pBladeStatus[i].slotID); 
         cJSON_AddNumberToObject(pJsonsub, "power", pBladeStatus[i].pwrStatus); 
         cJSON_AddStringToObject(pJsonsub, "name", pBladeStatus[i].bladeName); 
+        cJSON_AddNumberToObject(pJsonsub, "isChMC", pBladeStatus[i].isChMC); 
     }
   
     pStr = cJSON_PrintUnformatted(root);
 
- //   printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -455,6 +514,7 @@ void getAllBladeInfo(Webs *wp){
 
 }
 
+//废弃
 void setBladeManage(Webs *wp){
     char *strEnable = websGetVar(wp, "enable", NULL);
 
@@ -468,14 +528,14 @@ void setBladeManage(Webs *wp){
     cJSON_AddNumberToObject(root, "code", 200);
     
     pStr = cJSON_PrintUnformatted(root);
-
- //   printf("---> cJSON Str:\n%s\n", pStr);
+ 
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -484,45 +544,25 @@ void setBladeManage(Webs *wp){
 
 }
 
+//废弃
 void getBladeManage(Webs *wp){
-    // uint16_t    wRet = LIBIPMI_E_SUCCESS;
-    // IPMI20_UDS_SESSION_T    UDSSession;
-    // uint8_t     enable = 0;
-
-    // //Create session
-    // LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-
-    // wRet = LIBIPMI_HL_GetBladeManageFn(&UDSSession, &enable, DEFAULT_TIMEOUT);
-    // if(wRet != 0)
-    // {
-    //     printf("Set Blade Manage error!\n");
-    //     websError(wp, 404, "Set Blade Manage Error!");
-    //     LIBIPMI_CloseSession(&UDSSession );
-    //     return;
-    // }
-
-    // //Close session
-    // LIBIPMI_CloseSession(&UDSSession );
-
-    
     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_AddNumberToObject(data, "isEnable", gChassisManageEn);  //机箱管理功能是否已经打开    
     
     pStr = cJSON_PrintUnformatted(root);
 
- //   printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -551,7 +591,7 @@ void getChassisInfo(Webs *wp){
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-    if(ChassisInfo.supportChassisManageFn)
+    if(ChassisInfo.isChMC)
     {
         if(ChassisInfo.curIndex < BLADE_NUMBERS)
         {
@@ -567,13 +607,6 @@ void getChassisInfo(Webs *wp){
         gChassisManageEn = 0;
     }
 
-    // int i;
-    // printf("IPMBAddr ");
-    // for(i=0;i<BLADE_NUMBERS;i++)
-    // {
-    //     printf("%#X ", gIPMBAddr[i]);
-    // }
-    // printf("\n");
 
     char *pStr;
     cJSON * root =  cJSON_CreateObject();
@@ -583,20 +616,18 @@ void getChassisInfo(Webs *wp){
     cJSON_AddNumberToObject(root, "code", 200);
 
     cJSON_AddNumberToObject(data, "slotNum", ChassisInfo.slotNum);    //机箱内一共有多少个槽位
-    cJSON_AddNumberToObject(data, "supportManage", ChassisInfo.supportChassisManageFn); //是否支持机箱管理功能。 0:不支持, 1:支持
+    cJSON_AddNumberToObject(data, "supportManage", ChassisInfo.isChMC); //是否支持机箱管理功能。 0:不支持, 1:支持
     cJSON_AddNumberToObject(data, "ManageEn", gChassisManageEn);   //是否打开机箱管理功能。0:关闭, 1:打开
     cJSON_AddNumberToObject(data, "curIndex", ChassisInfo.curIndex);   //当前刀片插在第几个槽位。
     
     pStr = cJSON_PrintUnformatted(root);
-
-
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 48 - 21
app/goahead-3.6.5/src/web_interface/src/fan.c

@@ -16,19 +16,35 @@
 #include <stdlib.h>
 
 void getAllFanInfo(Webs *wp){
-	FanInfo_T fanInfo[FAN_NUMBERS];
+	FanInfo_T fanInfo[MAX_FAN_NUMS] = {0xff};
 	uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     int i;
+    uint8_t target_addr;
 
+    //将风扇的索引初始化为0xff,读到有效值后会被修改。
+    for(i=0;i<MAX_FAN_NUMS;i++)
+    {
+        fanInfo[i].index = 0xff;
+    }
 	//Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-	wRet = LIBIPMI_HL_GetFanInfo( &UDSSession, fanInfo, DEFAULT_TIMEOUT);
-	if(wRet != 0)
-	{
-		websError(wp, 404, "getAllFanInfo error!");
-	}
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+    	wRet = LIBIPMI_HL_GetFanInfo( &UDSSession, fanInfo, DEFAULT_TIMEOUT);    	
+    }
+    else
+    {
+        wRet = IPMC_GetFanInfo( &UDSSession, target_addr, fanInfo, DEFAULT_TIMEOUT); 
+    }
+
+    if(wRet != 0)
+    {
+        websError(wp, 404, "getAllFanInfo error!");
+    }
 
 	//Close session
     LIBIPMI_CloseSession(&UDSSession );
@@ -41,26 +57,28 @@ void getAllFanInfo(Webs *wp){
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
 
-    for(i=0;i<FAN_NUMBERS;i++)
+    for(i=0;i<MAX_FAN_NUMS;i++)
     {
-    	cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
-        cJSON_AddNumberToObject(pJsonsub, "index", fanInfo[i].index); 
-        cJSON_AddStringToObject(pJsonsub, "name", fanInfo[i].name);
-        cJSON_AddNumberToObject(pJsonsub, "mode", fanInfo[i].mode);			//0: 自动, 1:手动
-        cJSON_AddNumberToObject(pJsonsub, "level", fanInfo[i].level);
-        cJSON_AddNumberToObject(pJsonsub, "speed", fanInfo[i].speed);
+        if(fanInfo[i].index != 0xff)
+        {
+        	cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
+            cJSON_AddNumberToObject(pJsonsub, "index", fanInfo[i].index); 
+            cJSON_AddStringToObject(pJsonsub, "name", fanInfo[i].name);
+            cJSON_AddNumberToObject(pJsonsub, "mode", fanInfo[i].mode);			//0: 自动, 1:手动
+            cJSON_AddNumberToObject(pJsonsub, "level", fanInfo[i].level);
+            cJSON_AddNumberToObject(pJsonsub, "speed", fanInfo[i].speed);
+        }
     }
     
    
     pStr = cJSON_PrintUnformatted(root);
-
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -72,6 +90,7 @@ void setFanInfo(Webs *wp){
 	uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     int i;
+    uint8_t target_addr;
 
     char *strIndex = websGetVar(wp, "index", NULL);
     char *strMode = websGetVar(wp, "mode", NULL);
@@ -81,7 +100,7 @@ void setFanInfo(Webs *wp){
     uint8_t mode = atoi(strMode);
     uint8_t level = atoi(strLevel);
 
-    if(index >= FAN_NUMBERS)
+    if(index >= MAX_FAN_NUMS)
     {
     	websError(wp, 404, "Invalid index!");
     	return ;
@@ -99,7 +118,17 @@ void setFanInfo(Webs *wp){
 	//Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-	wRet = LIBIPMI_HL_SetFanInfo( &UDSSession, index, mode, level, DEFAULT_TIMEOUT);
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+	   wRet = LIBIPMI_HL_SetFanInfo( &UDSSession, index, mode, level, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_SetFanInfo( &UDSSession, target_addr, index, mode, level, DEFAULT_TIMEOUT);
+    }
+
 	if(wRet != 0)
 	{
 		websError(wp, 404, "getAllFanInfo error!");
@@ -108,23 +137,21 @@ void setFanInfo(Webs *wp){
 	//Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-	char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
 
-  
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 55 - 397
app/goahead-3.6.5/src/web_interface/src/fru.c

@@ -23,10 +23,11 @@ void getFruChassisInfo(Webs *wp)
 {
 	int wRet = 0;
 	uint32_t fru_size;
-	OemFRUChassisInfo_T chassis_data;
+	OemFRUChassisInfo_T *pChassis_data = walloc(sizeof(OemFRUChassisInfo_T));
 	uint8_t fruIndex = 1;	//FRUDeviceID
 	char *pTmpStr = NULL;
 	uint8_t strLen = 0;
+	uint8_t target_addr;
 
 	char *_chassisPartNum=NULL;
 	char *_chassisSerialNum=NULL;
@@ -36,7 +37,17 @@ void getFruChassisInfo(Webs *wp)
 
 	//Create session
 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,&chassis_data,DEFAULT_TIMEOUT);
+//	wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+		wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,pChassis_data,DEFAULT_TIMEOUT);
+	}
+	else
+	{
+		wRet = IPMC_GetFRUChassisData(&UDSSession,target_addr, fruIndex,&fru_size,pChassis_data,DEFAULT_TIMEOUT);
+	}
+
 	if(wRet==FRU_INVALID_HEADER_VERSION)
 	{
 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
@@ -52,15 +63,9 @@ void getFruChassisInfo(Webs *wp)
     //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];
+	strLen = pChassis_data->Data[0] & 0x3F;
+	pTmpStr = &pChassis_data->Data[1];
 	_chassisPartNum = walloc(strLen+1);
 	memset(_chassisPartNum, 0, strLen+1);
 	strncpy(_chassisPartNum, pTmpStr, strLen);
@@ -84,7 +89,7 @@ void getFruChassisInfo(Webs *wp)
 	//_chassisType
 	_chassisType = walloc(30);
 	memset(_chassisType, 0, 30);
-	switch(chassis_data.ChassisType)
+	switch(pChassis_data->ChassisType)
 	{
 	case Other:
 		strcpy(_chassisType, "Other");
@@ -152,7 +157,7 @@ void getFruChassisInfo(Webs *wp)
 	}		
 
 
-	char *pStr;
+	
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);
@@ -165,19 +170,15 @@ void getFruChassisInfo(Webs *wp)
     cJSON_AddStringToObject(data, "SN", _chassisSerialNum);
     cJSON_AddStringToObject(data, "OEM", _chassisCustomField);
 
+    char *pStr;
     pStr = cJSON_PrintUnformatted(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);
-    
+    websFlush(wp, 0);	//wait for all data to be written to the socket 
     websDone(wp);
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
 
     if(pStr)
         wfree(pStr);
@@ -188,8 +189,8 @@ void getFruChassisInfo(Webs *wp)
 	if(_chassisSerialNum) 		wfree(_chassisSerialNum);
 	if(_chassisType) 			wfree(_chassisType);
 	if(_chassisCustomField) 	wfree(_chassisCustomField);
+	if(pChassis_data)			wfree(pChassis_data);
 	
-	printf("getFruChassisInfo over!\n");
 }
 
 void getFruBoardInfo(Webs *wp)
@@ -201,7 +202,8 @@ void getFruBoardInfo(Webs *wp)
 	char *pTmpStr = NULL;
 	uint8_t strLen = 0;
 	time_t tval;
-	//char *mfrdate = NULL;
+	uint8_t target_addr;
+	
 	static const uint32_t  secs_from_1970_1996 = 820450800;
 
 	char *_boardMfr=NULL;
@@ -215,7 +217,18 @@ void getFruBoardInfo(Webs *wp)
 
 	//Create session
 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+
+//	wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+		wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+	}
+	else
+	{
+		wRet = IPMC_GetFRUBoardData(&UDSSession,target_addr, fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+	}
+
 	if(wRet==FRU_INVALID_HEADER_VERSION)
 	{
 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
@@ -281,7 +294,7 @@ void getFruBoardInfo(Webs *wp)
 	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);
@@ -296,19 +309,15 @@ void getFruBoardInfo(Webs *wp)
     cJSON_AddStringToObject(data, "PN", _boardPartNum);
     cJSON_AddStringToObject(data, "OEM", _boardCustomField);
 
+    char *pStr;
     pStr = cJSON_PrintUnformatted(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);
-    
+    websWrite(wp, "%s", pStr);     
+    websFlush(wp, 0);	//wait for all data to be written to the socket 
     websDone(wp);
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
 
     if(pStr)
         wfree(pStr);
@@ -321,8 +330,6 @@ void getFruBoardInfo(Webs *wp)
 	if(_boardPartNum) 			wfree(_boardPartNum);
 	if(_boardCustomField) 		wfree(_boardCustomField);
 	if(_MfrDate) 				wfree(_MfrDate);
-	
-	printf("getFruChassisInfo over!\n");
 
 }
 
@@ -334,6 +341,7 @@ void getFruProductInfo(Webs *wp)
 	uint8_t fruIndex = 1;	//FRUDeviceID
 	char *pTmpStr = NULL;
 	uint8_t strLen = 0;
+	uint8_t target_addr;
 	
 	char *_ProductName=NULL;
 	char *_ProductPartNum=NULL;
@@ -345,7 +353,16 @@ void getFruProductInfo(Webs *wp)
 
 	//Create session
 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
+//	wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+		wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
+	}
+	else
+	{
+		wRet = IPMC_GetFRUProductData(&UDSSession,target_addr, fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);	
+	}
 	if(wRet==FRU_INVALID_HEADER_VERSION)
 	{
 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
@@ -404,17 +421,11 @@ void getFruProductInfo(Webs *wp)
 	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;
@@ -424,7 +435,6 @@ void getFruProductInfo(Webs *wp)
 	memset(_productCustomField, 0, strLen+1);
 	strncpy(_productCustomField, pTmpStr, strLen);
 
-	char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);
@@ -436,19 +446,16 @@ void getFruProductInfo(Webs *wp)
     cJSON_AddStringToObject(data, "Ver", _ProductVersion);
     cJSON_AddStringToObject(data, "SN", _ProductSerialNum);
     cJSON_AddStringToObject(data, "OEM", _productCustomField);
+
+    char *pStr;
     pStr = cJSON_PrintUnformatted(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);
-    
+    websFlush(wp, 0);	
     websDone(wp);
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
 
     if(pStr)
         wfree(pStr);
@@ -461,354 +468,5 @@ void getFruProductInfo(Webs *wp)
 	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_PrintUnformatted(chassis);
-//     pStr2 = cJSON_PrintUnformatted(board);
-//     pStr3 = cJSON_PrintUnformatted(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");
-// }

+ 6 - 6
app/goahead-3.6.5/src/web_interface/src/fw_update.c

@@ -27,7 +27,7 @@ static uint8_t target_addr;
 */
 void prepareDevice(Webs *wp)
 {
-    wp->index = TEST_INDEX;
+//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {
@@ -79,7 +79,7 @@ void uploadFirmware(Webs *wp)
     WebsUpload      *up;
     char            *upfile;
 
-    wp->index = TEST_INDEX;
+//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {
@@ -134,7 +134,7 @@ void updateFlash(Webs *wp)
     uint8_t cmd[50] = {0};
     progress = 0;
 
-    wp->index = TEST_INDEX;
+//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {
@@ -182,7 +182,7 @@ void getUpdateProgress(Webs *wp)
     uint8_t progressStr[10] = {0};
     FILE *fp;
 
-    wp->index = TEST_INDEX;
+//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {
@@ -243,7 +243,7 @@ void getVerifyStatus(Webs *wp)
     uint8_t verigyStr[13] = {0};
     FILE *fp;
 
-    wp->index = TEST_INDEX;
+//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {
@@ -309,7 +309,7 @@ void resetBmc(Webs *wp)
     websWriteEndHeaders(wp);
     websDone(wp);
 
-    wp->index = TEST_INDEX;
+//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     {

+ 322 - 254
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -14,22 +14,29 @@
 
 void Web_ClearSEL(Webs *wp)
 {
-	int wRet = 0;
+    int wRet = 0;
 
-	IPMI20_UDS_SESSION_T    UDSSession;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
 
-	//Create session
+    //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    //get firmware version
-    wRet = IPMICMD_ClearSEL( &UDSSession, DEFAULT_TIMEOUT);
-    if(wRet != 0)
-		printf("Error trying to clear SEL!! %x\n", wRet);
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        //get firmware version
+        wRet = IPMICMD_ClearSEL( &UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_ClearSEL( &UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
+
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-
-	char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -37,19 +44,20 @@ void Web_ClearSEL(Webs *wp)
     cJSON_AddNumberToObject(root, "code", 200);
 
     if(wRet != 0)
-    	cJSON_AddStringToObject(data, "status", "fail");
+        cJSON_AddStringToObject(data, "status", "fail");
     else
-    	cJSON_AddStringToObject(data, "status", "success");
+        cJSON_AddStringToObject(data, "status", "success");
 
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
 
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -57,169 +65,305 @@ void Web_ClearSEL(Webs *wp)
         cJSON_Delete(root);
 }
 
+typedef struct {
+    uint8_t sensor_number;
+    uint8_t sensor_name[MAX_ID_STR_LEN+1];
+} SensorNumNameTab_T;
+
 void GetAllSELEntriesSorted(Webs *wp)
 {
-	int wRet = 0;
-	unsigned short nEntries = 0;
-	SELEventRecordWithSensorName_T *pSELBuff = NULL;
-	//uint8 *pStartBuff = NULL;
-	uint16 nMaxEntries = 0;
-	IPMI20_UDS_SESSION_T    UDSSession;
-	
-
-	char *pStr;
+    int wRet = 0;
+    unsigned short nEntries = 0;
+    SELEventRecordWithSensorName_T *pSELBuff = NULL;
+    int i;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t         target_addr;
+    SensorNumNameTab_T senNumNameTab[MAX_SENSOR_NUMBERS];   //之前获取到的传感器名称暂存在这里,避免反复获取,浪费总线带宽。
+    GetSELReq_T     GetSelReq;
+    uint16_t        ReserveID;
+    ReserveSELRes_T ReserveSelRes;
+    uint16_t        RecID = 0;
+    uint8_t         Res[50];
+    SELEventRecord_T   SELEventData;
+    uint8_t         sensorName[MAX_ID_STR_LEN+1];
+    int             found_flag = 0;
+    
     int code = 200;
     cJSON * root =  cJSON_CreateObject();
     cJSON  *pJsonArry,*pJsonsub;
     pJsonArry=cJSON_CreateArray();   /*创建数组*/
+    cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
 
-	//Create session
+    //初始化传感器序号和名称对应表
+    for(i=0;i<MAX_SENSOR_NUMBERS;i++)
+    {
+        senNumNameTab[i].sensor_number = 0xff;
+        senNumNameTab[i].sensor_name[0] = '\0';
+    }
+
+    //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	/* Get number of SEL records in the system at this time */
-	wRet = LIBIPMI_HL_GetNumOfSELEntries(&UDSSession, &nEntries, DEFAULT_TIMEOUT);
-	if(wRet != 0)
-	{
-		printf("Error getting num of sel recods\n");
-		goto error_out;
-	}
-	else
-	{
-		printf("success getting num of sel recods: %d\n",nEntries);
-		/* Now get all sel records */
-		//now find maximum possible sel entries and allocate that much
-		wRet = LIBIPMI_HL_GetMaxPossibleSELEntries(&UDSSession,&nMaxEntries,DEFAULT_TIMEOUT);
-		if(wRet != 0)
-		{
-			printf("Error getting maximum no of entries..assuming 1024\n");
-			nMaxEntries = 1024;
-		}
-		else
-		{
-			printf("MAX Possible SEL entries : %d\n",nMaxEntries);
-		}
-
-		// if(!nEntries)
-		// {
-		// 	/* There are no entries present at this time */
-		// 	goto error_out;
-		// }
-
-		/* Allocate the buffer to hold SEL entries */
-		pSELBuff = (SELEventRecordWithSensorName_T *) walloc(nMaxEntries * sizeof(SELEventRecordWithSensorName_T));
-		if(pSELBuff == NULL)
-		{
-			goto error_out;
-		}
-		//pStartBuff = (uint8 *)pSELBuff;
-
-		printf("before get all sel entried\n");
-		/* Now pass this buffer pointer to the function to get all SEL entries */
-		wRet = LIBIPMI_HL_GetAllSelEntriesWithSensorNames(&UDSSession, pSELBuff, DEFAULT_TIMEOUT);
-
-		if(wRet == 0)
-		{
-			/* Write entries here */
-			while(nEntries)
-			{
-				if(pSELBuff[nEntries-1].EventRecord.Valid != 0xA5)
-				{
-					cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
-                	cJSON_AddNumberToObject(pJsonsub, "RecordID", pSELBuff[nEntries-1].EventRecord.EvtRecord.hdr.ID);
-                	cJSON_AddNumberToObject(pJsonsub, "RecordType", pSELBuff[nEntries-1].EventRecord.EvtRecord.hdr.Type);
-                	cJSON_AddNumberToObject(pJsonsub, "TimeStamp", pSELBuff[nEntries-1].EventRecord.EvtRecord.hdr.TimeStamp);
-                	cJSON_AddNumberToObject(pJsonsub, "GenID1", pSELBuff[nEntries-1].EventRecord.EvtRecord.GenID[0]);
-                	cJSON_AddNumberToObject(pJsonsub, "GenID2", pSELBuff[nEntries-1].EventRecord.EvtRecord.GenID[1]);
-                	cJSON_AddNumberToObject(pJsonsub, "EvmRev", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvMRev);
-					cJSON_AddNumberToObject(pJsonsub, "SensorType", pSELBuff[nEntries-1].EventRecord.EvtRecord.SensorType);
-					cJSON_AddStringToObject(pJsonsub, "SensorName", pSELBuff[nEntries-1].SensorName);
-					cJSON_AddNumberToObject(pJsonsub, "EventDirType", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtDirType);
-					cJSON_AddNumberToObject(pJsonsub, "EventData1", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtData1);
-					cJSON_AddNumberToObject(pJsonsub, "EventData2", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtData2);
-					cJSON_AddNumberToObject(pJsonsub, "EventData3", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtData3);							
-				}
-				nEntries--;
-			}
-
-			cJSON_AddItemToObject(root, "data", pJsonArry);
-		    pStr = cJSON_PrintUnformatted(root);
-		    //printf("---> pStr %d: %s\n", strlen(pStr), pStr);
-
-		    websSetStatus(wp, 200);
-		    websWriteHeaders(wp, -1, 0);
-		    websWriteEndHeaders(wp); 
-		    websWrite(wp, pStr);
-		    websDone(wp);
-
-		    
-		} else {
-			printf("Error reading All SEL entries\n");
-		}		
-	}
-
-	//Close session
+
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        /* Get number of SEL records in the system at this time */
+        wRet = LIBIPMI_HL_GetNumOfSELEntries(&UDSSession, &nEntries, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_GetNumOfSELEntries(&UDSSession, target_addr, &nEntries, DEFAULT_TIMEOUT);
+    }
+
+    if(wRet != 0)
+    {
+        printf("Error getting num of sel recods\n");
+        goto error_out;
+    }
+    else
+    {
+        //printf("---> nEntries %d\n", nEntries);
+        if(nEntries > MAX_SEL_RECORD)   nEntries = MAX_SEL_RECORD;  //最大只能显示这么多日志
+        if(nEntries == 0)
+        {
+            cJSON_AddItemToObject(root, "data", pJsonArry);
+
+            char *pStr;
+            pStr = cJSON_PrintUnformatted(root);
+            websSetStatus(wp, 200);
+            websWriteHeaders(wp, -1, 0);
+            websWriteEndHeaders(wp); 
+            websWrite(wp, pStr);
+            websFlush(wp, 0);
+            websDone(wp);
+            printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+            
+            if(root)
+                cJSON_Delete(root);
+            if(pStr)
+                wfree(pStr);
+
+            return;
+        }
+
+        /* Allocate the buffer to hold SEL entries */
+        pSELBuff = (SELEventRecordWithSensorName_T *) walloc(nEntries * sizeof(SELEventRecordWithSensorName_T) + 10);   //margin 10
+        if(pSELBuff == NULL)
+        {
+            goto error_out;
+        }
+
+        //Reserve SEL
+        if(target_addr == 0x20)
+        {
+            wRet = IPMICMD_ReserveSEL(&UDSSession, &ReserveSelRes, DEFAULT_TIMEOUT);
+        }
+        else
+        {
+            wRet = IPMC_ReserveSEL(&UDSSession, target_addr, &ReserveSelRes, DEFAULT_TIMEOUT);
+        }
+
+        if(wRet == 0)
+        {
+            ReserveID = ReserveSelRes.ReservationID;
+            RecID = 0;  //first record
+            for(i=0;i<nEntries;i++)
+            {
+                //获取日志
+                GetSelReq.ReservationID = ReserveID;
+                GetSelReq.RecID = RecID;
+                GetSelReq.Offset = 0;
+                GetSelReq.Size = 0xff;  //FFh means read entire record.
+                if(target_addr == 0x20)
+                {
+                    wRet = IPMI_GetSELEntry(&UDSSession, &GetSelReq,  &SELEventData, &RecID, DEFAULT_TIMEOUT);
+                }
+                else
+                {
+                    wRet = IPMC_GetSELEntry(&UDSSession, target_addr, &GetSelReq,  &SELEventData, &RecID, DEFAULT_TIMEOUT);
+                }
+                if((wRet != 0))
+                {
+                    break;
+                }
+                // cJSON_AddNumberToObject(pJsonsub, "1", SELEventData.hdr.ID);
+                // cJSON_AddNumberToObject(pJsonsub, "2", SELEventData.hdr.Type);
+                // cJSON_AddNumberToObject(pJsonsub, "3", SELEventData.hdr.TimeStamp);
+                // cJSON_AddNumberToObject(pJsonsub, "4", SELEventData.GenID[0]);
+                // cJSON_AddNumberToObject(pJsonsub, "5", SELEventData.GenID[1]);
+                // cJSON_AddNumberToObject(pJsonsub, "6", SELEventData.EvMRev);
+                // cJSON_AddNumberToObject(pJsonsub, "7", SELEventData.SensorType);
+                // cJSON_AddNumberToObject(pJsonsub, "8", SELEventData.EvtDirType);
+                // cJSON_AddNumberToObject(pJsonsub, "9", SELEventData.EvtData1);
+                // cJSON_AddNumberToObject(pJsonsub, "a", SELEventData.EvtData2);
+                // cJSON_AddNumberToObject(pJsonsub, "b", SELEventData.EvtData3);
+
+                cJSON_AddNumberToObject(pJsonsub, "RecordID", SELEventData.hdr.ID);
+                cJSON_AddNumberToObject(pJsonsub, "RecordType", SELEventData.hdr.Type);
+                cJSON_AddNumberToObject(pJsonsub, "TimeStamp", SELEventData.hdr.TimeStamp);
+                cJSON_AddNumberToObject(pJsonsub, "GenID1", SELEventData.GenID[0]);
+                cJSON_AddNumberToObject(pJsonsub, "GenID2", SELEventData.GenID[1]);
+                cJSON_AddNumberToObject(pJsonsub, "EvmRev", SELEventData.EvMRev);
+                cJSON_AddNumberToObject(pJsonsub, "SensorType", SELEventData.SensorType);
+                cJSON_AddNumberToObject(pJsonsub, "EventDirType", SELEventData.EvtDirType);
+                cJSON_AddNumberToObject(pJsonsub, "EventData1", SELEventData.EvtData1);
+                cJSON_AddNumberToObject(pJsonsub, "EventData2", SELEventData.EvtData2);
+                cJSON_AddNumberToObject(pJsonsub, "EventData3", SELEventData.EvtData3);
+                //获取传感器名称
+                //printf("sensor number %d\n", SELEventData.SensorNum);
+                if((SELEventData.SensorNum != 0xff) && (SELEventData.hdr.Type == 0x02))
+                {
+                    found_flag = 0;
+                    for(i=0;i<MAX_SENSOR_NUMBERS;i++)   //先从之前的缓存里查找传感器名称
+                    {
+                        if(senNumNameTab[i].sensor_number == 0xff)  //再往后没有内容了。
+                            break;
+
+                        if(senNumNameTab[i].sensor_number == SELEventData.SensorNum)
+                        {                        
+                            //cJSON_AddStringToObject(pJsonsub, "c", senNumNameTab[i].sensor_name);
+                            cJSON_AddStringToObject(pJsonsub, "SensorName", senNumNameTab[i].sensor_name);
+                            found_flag = 1;
+                            break;
+                        }
+                    }
+
+                    if(found_flag == 0) //在缓存里没有找到
+                    {
+                        if(target_addr == 0x20)
+                        {
+                            wRet = IPMI_GetSensorName(&UDSSession, SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                            //printf("---> get sensor name: %s\n", sensorName);
+                        }
+                        else
+                        {
+                            wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                        }
+                        //cJSON_AddStringToObject(pJsonsub, "c", sensorName);
+                        cJSON_AddStringToObject(pJsonsub, "SensorName", senNumNameTab[i].sensor_name);
+                        if(wRet == 0)
+                        {
+                            //将得到的传感器名称保存到缓存中
+                            for(i=0;i<MAX_SENSOR_NUMBERS;i++)
+                            {
+                                if(senNumNameTab[i].sensor_number == 0xff)
+                                {
+                                    //printf("---> keep sensor name\n");
+                                    senNumNameTab[i].sensor_number = SELEventData.SensorNum;
+                                    strcpy(senNumNameTab[i].sensor_name, sensorName);                                
+                                    break;
+                                }
+                            }
+                        }    
+                    }                
+                }
+                else
+                {
+                    cJSON_AddStringToObject(pJsonsub, "SensorName", "--");
+                }
+
+                if(RecID == 0xffff) //last record
+                    break;
+            }
+        }
+    }
+
+    //Close session
     LIBIPMI_CloseSession(&UDSSession );
-	
-	if(root)
+
+    cJSON_AddItemToObject(root, "data", pJsonArry);
+
+    char *pStr;
+    pStr = cJSON_PrintUnformatted(root);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, pStr);
+    websFlush(wp, 0);
+    websDone(wp);
+    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+    
+    if(root)
         cJSON_Delete(root);
     if(pStr)
-    	wfree(pStr);
-   	if(pSELBuff)
-		wfree(pSELBuff);
+        wfree(pStr);
+    if(pSELBuff)
+        wfree(pSELBuff);
 
-	return;
+    return;
 
 error_out:
-	//Close session
+    //Close session
     LIBIPMI_CloseSession(&UDSSession );
-	websError(wp, 404, "Get SEL error!");
-	if(root)
+    websError(wp, 404, "Get SEL error!");
+    if(root)
         cJSON_Delete(root);
     if(pStr)
-    	wfree(pStr);
-   	if(pSELBuff)
-		wfree(pSELBuff);
+        wfree(pStr);
+    if(pSELBuff)
+        wfree(pSELBuff);
 
 }
 
 
 void SetTime(Webs *wp)
 {
-	int wRet = 0;
-	IPMI20_UDS_SESSION_T    UDSSession;
-	SetSELTimeReq_T SetSELTimeReq;
-	SetSELTimeUTCOffsetReq_T SetSELTimeUTCOffsetReq;
-	
-	char *strUTCOffset = websGetVar(wp, "UTCOffset", NULL);	//这里的时区单位是 分钟
-	char *strTime = websGetVar(wp, "time", NULL);
-
-    SetSELTimeUTCOffsetReq.UTCOffset = atoi(strUTCOffset);	//东8区就是 8*60
+    int wRet = 0;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    SetSELTimeReq_T SetSELTimeReq;
+    SetSELTimeUTCOffsetReq_T SetSELTimeUTCOffsetReq;
+    uint8_t target_addr;
+    
+    char *strUTCOffset = websGetVar(wp, "UTCOffset", NULL); //这里的时区单位是 分钟
+    char *strTime = websGetVar(wp, "time", NULL);
+
+    SetSELTimeUTCOffsetReq.UTCOffset = atoi(strUTCOffset);  //东8区就是 8*60
     printf("strUTCOffset: %s, UTCOffset: %d\n", strUTCOffset, SetSELTimeUTCOffsetReq.UTCOffset);
-	
+    
     SetSELTimeReq.Time = atoi(strTime);
     printf("strTime: %s, Time: %d\n", strTime, SetSELTimeReq.Time);
   
-	//Create session
+    //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-    wRet = IPMICMD_SetSELTime(&UDSSession,	&SetSELTimeReq, DEFAULT_TIMEOUT);
+    
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_SetSELTime(&UDSSession,  &SetSELTimeReq, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_SetSELTime(&UDSSession, target_addr, &SetSELTimeReq, DEFAULT_TIMEOUT);
+    }
     if(wRet != 0)
     {
-    	websError(wp, 404, "Set sel time fail!");
-    	//Close session
-    	LIBIPMI_CloseSession(&UDSSession );
-    	return;
+        websError(wp, 404, "Set sel time fail!");
+        //Close session
+        LIBIPMI_CloseSession(&UDSSession );
+        return;
+    }
+
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_SetSELTimeUTCOffset(&UDSSession, &SetSELTimeUTCOffsetReq, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_SetSELTimeUTCOffset(&UDSSession, target_addr, &SetSELTimeUTCOffsetReq, DEFAULT_TIMEOUT);
     }
-    wRet = IPMICMD_SetSELTimeUTCOffset(&UDSSession,	&SetSELTimeUTCOffsetReq, DEFAULT_TIMEOUT);
     if(wRet != 0)
     {
-    	websError(wp, 404, "Set sel time UTC offset fail!");
-    	//Close session
-    	LIBIPMI_CloseSession(&UDSSession );
-    	return;
+        websError(wp, 404, "Set sel time UTC offset fail!");
+        //Close session
+        LIBIPMI_CloseSession(&UDSSession );
+        return;
     }
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
-	
-	char *pStr;
+    
+    char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -247,148 +391,72 @@ void SetTime(Webs *wp)
 
 void GetTime(Webs *wp)
 {
-	int wRet = 0;
-	IPMI20_UDS_SESSION_T    UDSSession;
-	GetSELTimeRes_T GetSELTimeRes;
-	GetSELTimeUTCOffsetRes_T GetSELTimeUTCOffsetRes;
+    int wRet = 0;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    GetSELTimeRes_T GetSELTimeRes;
+    GetSELTimeUTCOffsetRes_T GetSELTimeUTCOffsetRes;
+    uint8_t target_addr;
   
-	//Create session
+    //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-    wRet = IPMICMD_GetSELTime(&UDSSession, &GetSELTimeRes, DEFAULT_TIMEOUT);
+
+//    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_GetSELTime(&UDSSession, &GetSELTimeRes, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_GetSELTime(&UDSSession, target_addr, &GetSELTimeRes, DEFAULT_TIMEOUT);
+    }
     if(wRet != 0)
     {
-    	websError(wp, 404, "Get sel time fail!");
-    	//Close session
-    	LIBIPMI_CloseSession(&UDSSession );
-    	return;
+        websError(wp, 404, "Get sel time fail!");
+        //Close session
+        LIBIPMI_CloseSession(&UDSSession );
+        return;
+    }
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_GetSELTimeUTCOffset(&UDSSession, &GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_GetSELTimeUTCOffset(&UDSSession, target_addr, &GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
     }
-    wRet = IPMICMD_GetSELTimeUTCOffset(&UDSSession,	&GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
     if(wRet != 0)
     {
-    	websError(wp, 404, "Get time UTC offset fail!");
-    	//Close session
-    	LIBIPMI_CloseSession(&UDSSession );
-    	return;
+        websError(wp, 404, "Get time UTC offset fail!");
+        //Close session
+        LIBIPMI_CloseSession(&UDSSession );
+        return;
     }
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
-	
-	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_AddNumberToObject(data, "time", GetSELTimeRes.Time);	//据1970年的秒数,UTC时间
-    cJSON_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);	//时区
+    cJSON_AddNumberToObject(data, "time", GetSELTimeRes.Time);  //据1970年的秒数,UTC时间
+    cJSON_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);   //时区
 
-  
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
     if(root)
         cJSON_Delete(root);
 }
-
-
-// void SetTimeUTCOffset(Webs *wp)
-// {
-// 	int wRet = 0;
-// 	IPMI20_UDS_SESSION_T    UDSSession;
-// 	SetSELTimeUTCOffsetReq_T SetSELTimeUTCOffsetReq;
-// 	char *strUTCOffset = websGetVar(wp, "UTCOffset", NULL);	//这里的时区单位是 分钟
-
-//     SetSELTimeUTCOffsetReq.UTCOffset = atoi(strUTCOffset);	//东8区就是 8*60
-//     printf("Str: %s, int: %d\n", strUTCOffset, SetSELTimeUTCOffsetReq.UTCOffset);
-  
-// 	//Create session
-//     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-//     wRet = IPMICMD_SetSELTimeUTCOffset(&UDSSession,	&SetSELTimeUTCOffsetReq, DEFAULT_TIMEOUT);
-//     if(wRet != 0)
-//     {
-//     	websError(wp, 404, "Set sel time UTC offset fail!");
-//     	//Close session
-//     	LIBIPMI_CloseSession(&UDSSession );
-//     	return;
-//     }
-//     //Close session
-//     LIBIPMI_CloseSession(&UDSSession );
-	
-// 	char *pStr;
-//     cJSON * root =  cJSON_CreateObject();
-//     cJSON * data =  cJSON_CreateObject();
-//     cJSON_AddItemToObject(root, "data", data);//根节点下添加
-//     cJSON_AddStringToObject(root, "msg", "");
-//     cJSON_AddNumberToObject(root, "code", 200);
-
-//     pStr = cJSON_PrintUnformatted(root);
-
-//     printf("---> cJSON Str:\n%s\n", pStr);
-//     websSetStatus(wp, 200);
-//     websWriteHeaders(wp, -1, 0);
-//     websWriteEndHeaders(wp); 
-//     websWrite(wp,"%s", pStr);
-//     websFlush(wp, 0);
-//     websDone(wp);
-
-//     if(pStr)
-//         wfree(pStr);
-//     if(root)
-//         cJSON_Delete(root);
-// }
-
-
-// void GetTimeUTCOffset(Webs *wp)	//这里返回的时区单位是 分钟
-// {
-// 	int wRet = 0;
-// 	IPMI20_UDS_SESSION_T    UDSSession;
-// 	GetSELTimeUTCOffsetRes_T GetSELTimeUTCOffsetRes;
-  
-// 	//Create session
-//     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-//     wRet = IPMICMD_GetSELTimeUTCOffset(&UDSSession,	&GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
-//     if(wRet != 0)
-//     {
-//     	websError(wp, 404, "Get time UTC offset fail!");
-//     	//Close session
-//     	LIBIPMI_CloseSession(&UDSSession );
-//     	return;
-//     }
-//     //Close session
-//     LIBIPMI_CloseSession(&UDSSession );
-	
-// 	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_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);
-
-  
-//     pStr = cJSON_PrintUnformatted(root);
-
-//     printf("---> cJSON Str:\n%s\n", pStr);
-//     websSetStatus(wp, 200);
-//     websWriteHeaders(wp, -1, 0);
-//     websWriteEndHeaders(wp); 
-//     websWrite(wp,"%s", pStr);
-//     websFlush(wp, 0);
-//     websDone(wp);
-
-//     if(pStr)
-//         wfree(pStr);
-//     if(root)
-//         cJSON_Delete(root);
-// }

BIN
app/i2c_scan/i2c-scan


BIN
app/ipmitool-1.8.18/ipmitool


BIN
app/test_app/test_app


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä