Ver código fonte

Merge UTCOffset interface to Get/SetTime interface

zhangbo 5 anos atrás
pai
commit
e3007d1b7f

Diferenças do arquivo suprimidas por serem muito extensas
+ 188 - 239
app/bmc/msghndlr/Transport/LANConfig.c


+ 2 - 2
app/goahead-3.6.5/src/goahead.c

@@ -201,8 +201,8 @@ websDefineAction("Web_ClearSEL", Web_ClearSEL);
 websDefineAction("GetAllSELEntriesSorted", GetAllSELEntriesSorted);
 websDefineAction("GetAllSELEntriesSorted", GetAllSELEntriesSorted);
 websDefineAction("SetTime", SetTime);
 websDefineAction("SetTime", SetTime);
 websDefineAction("GetTime", GetTime);
 websDefineAction("GetTime", GetTime);
-websDefineAction("SetTimeUTCOffset", SetTimeUTCOffset);
-websDefineAction("GetTimeUTCOffset", GetTimeUTCOffset);
+//websDefineAction("SetTimeUTCOffset", SetTimeUTCOffset);
+//websDefineAction("GetTimeUTCOffset", GetTimeUTCOffset);
 
 
 //user
 //user
 websDefineAction("getAllUserInfo", getAllUserInfo);
 websDefineAction("getAllUserInfo", getAllUserInfo);

+ 2 - 2
app/goahead-3.6.5/src/web_interface/inc/sel.h

@@ -8,7 +8,7 @@ void GetAllSELEntriesSorted(Webs *wp);
 
 
 void SetTime(Webs *wp);
 void SetTime(Webs *wp);
 void GetTime(Webs *wp);
 void GetTime(Webs *wp);
-void SetTimeUTCOffset(Webs *wp);
-void GetTimeUTCOffset(Webs *wp);
+//void SetTimeUTCOffset(Webs *wp);
+//void GetTimeUTCOffset(Webs *wp);
 
 
 #endif /* __SEL_H__ */
 #endif /* __SEL_H__ */

+ 91 - 0
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -0,0 +1,91 @@
+#include    "goahead.h"
+#include    "libipmi_IPM.h"
+#include    "com_IPMIDefs.h"
+#include    "ResultUtils.h"
+#include    "cJSON.h"
+#include    "libipmi_storlead_OEM.h"
+#include    "libsensor.h"
+#include    <stdio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include "com_BmcType.h"
+#include "libipmi_usermgmt.h"
+
+void setIpAddr(Webs *wp)
+{
+
+}
+
+void setMacAddr(Webs *wp)
+{
+
+}
+
+
+
+// void restoreFactorySettings(Webs *wp){
+// 	uint16_t    wRet = LIBIPMI_E_SUCCESS;
+//     IPMI20_UDS_SESSION_T    UDSSession;
+//     int i;
+
+//     char *strIndex = websGetVar(wp, "index", NULL);
+//     char *strMode = websGetVar(wp, "mode", NULL);
+//     char *strLevel = websGetVar(wp, "level", NULL);
+
+//     uint8_t index = atoi(strIndex);
+//     uint8_t mode = atoi(strMode);
+//     uint8_t level = atoi(strLevel);
+
+//     if(index >= FAN_NUMBERS)
+//     {
+//     	websError(wp, 404, "Invalid index!");
+//     	return ;
+//     }
+
+//     if(mode > 1)
+//     {
+// 		websError(wp, 404, "Invalid mode!");    	
+// 		return;
+//     }
+
+//     if(level > 100)
+//     	level = 100;
+
+// 	//Create session
+//     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+// 	wRet = LIBIPMI_HL_SetFanInfo( &UDSSession, index, mode, level, DEFAULT_TIMEOUT);
+// 	if(wRet != 0)
+// 	{
+// 		websError(wp, 404, "getAllFanInfo error!");
+// 	}
+
+// 	//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);
+// }
+
+

+ 108 - 86
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -187,12 +187,16 @@ void SetTime(Webs *wp)
 	int wRet = 0;
 	int wRet = 0;
 	IPMI20_UDS_SESSION_T    UDSSession;
 	IPMI20_UDS_SESSION_T    UDSSession;
 	SetSELTimeReq_T SetSELTimeReq;
 	SetSELTimeReq_T SetSELTimeReq;
-
+	SetSELTimeUTCOffsetReq_T SetSELTimeUTCOffsetReq;
+	
+	char *strUTCOffset = websGetVar(wp, "UTCOffset", NULL);	//这里的时区单位是 分钟
 	char *strTime = websGetVar(wp, "time", 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);
     SetSELTimeReq.Time = atoi(strTime);
-
-    printf("Time: %s, second: %d\n", strTime, SetSELTimeReq.Time);
+    printf("strTime: %s, Time: %d\n", strTime, SetSELTimeReq.Time);
   
   
 	//Create session
 	//Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
@@ -204,6 +208,14 @@ void SetTime(Webs *wp)
     	LIBIPMI_CloseSession(&UDSSession );
     	LIBIPMI_CloseSession(&UDSSession );
     	return;
     	return;
     }
     }
+    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
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
     LIBIPMI_CloseSession(&UDSSession );
 	
 	
@@ -238,6 +250,7 @@ void GetTime(Webs *wp)
 	int wRet = 0;
 	int wRet = 0;
 	IPMI20_UDS_SESSION_T    UDSSession;
 	IPMI20_UDS_SESSION_T    UDSSession;
 	GetSELTimeRes_T GetSELTimeRes;
 	GetSELTimeRes_T GetSELTimeRes;
+	GetSELTimeUTCOffsetRes_T GetSELTimeUTCOffsetRes;
   
   
 	//Create session
 	//Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
@@ -249,52 +262,10 @@ void GetTime(Webs *wp)
     	LIBIPMI_CloseSession(&UDSSession );
     	LIBIPMI_CloseSession(&UDSSession );
     	return;
     	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);
-
-  
-    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 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);
+    wRet = IPMICMD_GetSELTimeUTCOffset(&UDSSession,	&GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
     if(wRet != 0)
     if(wRet != 0)
     {
     {
-    	websError(wp, 404, "Set sel time UTC offset fail!");
+    	websError(wp, 404, "Get time UTC offset fail!");
     	//Close session
     	//Close session
     	LIBIPMI_CloseSession(&UDSSession );
     	LIBIPMI_CloseSession(&UDSSession );
     	return;
     	return;
@@ -309,6 +280,10 @@ void SetTimeUTCOffset(Webs *wp)
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
     cJSON_AddNumberToObject(root, "code", 200);
 
 
+    cJSON_AddNumberToObject(data, "time", GetSELTimeRes.Time);	//据1970年的秒数,UTC时间
+    cJSON_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);	//时区
+
+  
     pStr = cJSON_PrintUnformatted(root);
     pStr = cJSON_PrintUnformatted(root);
 
 
     printf("---> cJSON Str:\n%s\n", pStr);
     printf("---> cJSON Str:\n%s\n", pStr);
@@ -326,47 +301,94 @@ void SetTimeUTCOffset(Webs *wp)
 }
 }
 
 
 
 
-void GetTimeUTCOffset(Webs *wp)	//这里返回的时区单位是 分钟
-{
-	int wRet = 0;
-	IPMI20_UDS_SESSION_T    UDSSession;
-	GetSELTimeUTCOffsetRes_T GetSELTimeUTCOffsetRes;
+// 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_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 );
+// 	//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);
-
-    cJSON_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);
-
+// 	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;
   
   
-    pStr = cJSON_PrintUnformatted(root);
+// 	//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);
 
 
-    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);
+//     cJSON_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);
 
 
-    if(pStr)
-        wfree(pStr);
-    if(root)
-        cJSON_Delete(root);
-}
+  
+//     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);
+// }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff