|
@@ -22,15 +22,31 @@ uint8_t ip2dec(const char *strIp, uint8_t index);
|
|
|
void restoreFactorySettings(Webs *wp){
|
|
|
uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
- //擦除Flash的配置区
|
|
|
- IPMICMD_restoreFactorySettings(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ //擦除Flash的配置区
|
|
|
+ wRet = IPMICMD_restoreFactorySettings(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_restoreFactorySettings(&UDSSession, target_addr, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
|
|
|
//重启BMC
|
|
|
- wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_ResetBMC(&UDSSession, target_addr,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
if(wRet != 0)
|
|
|
{
|
|
|
websError(wp, 404, "Reset BMC fail!");
|
|
@@ -39,23 +55,22 @@ void restoreFactorySettings(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:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -67,11 +82,20 @@ void restoreFactorySettings(Webs *wp){
|
|
|
void web_ResetBMC(Webs *wp){
|
|
|
uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
- wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_ResetBMC(&UDSSession, target_addr, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
if(wRet != 0)
|
|
|
{
|
|
|
websError(wp, 404, "Reset BMC fail!");
|
|
@@ -80,23 +104,22 @@ void web_ResetBMC(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:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -104,13 +127,13 @@ void web_ResetBMC(Webs *wp){
|
|
|
cJSON_Delete(root);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void web_GetLanInfo(Webs *wp){
|
|
|
uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
LanInfo_T LanInfo;
|
|
|
uint8_t index = 0;
|
|
|
char *EthName = websGetVar(wp, "eth", NULL);
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
if(strcmp(EthName, "eth0") == 0)
|
|
|
{
|
|
@@ -125,16 +148,25 @@ void web_GetLanInfo(Webs *wp){
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
- wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
|
|
|
- if(wRet != 0)
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "Get Lan Info fail!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- websError(wp, 404, "Get Lan Info fail!");
|
|
|
+ memset(&LanInfo, 0, sizeof(LanInfo_T));
|
|
|
+ strcpy(LanInfo.EthName, "--");
|
|
|
}
|
|
|
|
|
|
//Close session
|
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
- char *pStr;
|
|
|
+
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
@@ -177,15 +209,15 @@ void web_GetLanInfo(Webs *wp){
|
|
|
LanInfo.DefaultGW[2], LanInfo.DefaultGW[3]);
|
|
|
cJSON_AddStringToObject(data, "defaultgw", strGw);
|
|
|
|
|
|
+ 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:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -199,6 +231,7 @@ void web_SetLanInfo(Webs *wp){
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
LanInfo_T LanInfo;
|
|
|
uint8_t index = 0;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
char *EthName = websGetVar(wp, "eth", NULL); //eth0
|
|
|
char *strMode = websGetVar(wp, "mode", NULL); //static DHCP
|
|
@@ -225,83 +258,86 @@ void web_SetLanInfo(Webs *wp){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- strcpy(LanInfo.EthName, EthName);
|
|
|
- if((strcmp(strMode, "static") == 0) || (strcmp(strMode, "Static") == 0)
|
|
|
- || (strcmp(strMode, "STATIC") == 0))
|
|
|
- {
|
|
|
- LanInfo.IPAddrSrc = STATIC_IP_SOURCE; //0:unspecified 1:Static 2:DHCP 3:BIOS 4:other
|
|
|
- }
|
|
|
- else if((strcmp(strMode, "DHCP") == 0) || (strcmp(strMode, "Dhcp") == 0 )
|
|
|
- || (strcmp(strMode, "dhcp") == 0))
|
|
|
- {
|
|
|
- LanInfo.IPAddrSrc = DHCP_IP_SOURCE;
|
|
|
- }
|
|
|
- else if((strcmp(strMode, "BIOS") == 0) || (strcmp(strMode, "Bios") == 0 )
|
|
|
- || (strcmp(strMode, "bios") == 0))
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
{
|
|
|
- LanInfo.IPAddrSrc = BIOS_IP_SOURCE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LanInfo.IPAddrSrc = BMC_OTHER_SOURCE;
|
|
|
- }
|
|
|
+ strcpy(LanInfo.EthName, EthName);
|
|
|
+ if((strcmp(strMode, "static") == 0) || (strcmp(strMode, "Static") == 0)
|
|
|
+ || (strcmp(strMode, "STATIC") == 0))
|
|
|
+ {
|
|
|
+ LanInfo.IPAddrSrc = STATIC_IP_SOURCE; //0:unspecified 1:Static 2:DHCP 3:BIOS 4:other
|
|
|
+ }
|
|
|
+ else if((strcmp(strMode, "DHCP") == 0) || (strcmp(strMode, "Dhcp") == 0 )
|
|
|
+ || (strcmp(strMode, "dhcp") == 0))
|
|
|
+ {
|
|
|
+ LanInfo.IPAddrSrc = DHCP_IP_SOURCE;
|
|
|
+ }
|
|
|
+ else if((strcmp(strMode, "BIOS") == 0) || (strcmp(strMode, "Bios") == 0 )
|
|
|
+ || (strcmp(strMode, "bios") == 0))
|
|
|
+ {
|
|
|
+ LanInfo.IPAddrSrc = BIOS_IP_SOURCE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LanInfo.IPAddrSrc = BMC_OTHER_SOURCE;
|
|
|
+ }
|
|
|
+
|
|
|
+ LanInfo.IPAddr[0] = ip2dec(strIp, 0);
|
|
|
+ LanInfo.IPAddr[1] = ip2dec(strIp, 1);
|
|
|
+ LanInfo.IPAddr[2] = ip2dec(strIp, 2);
|
|
|
+ LanInfo.IPAddr[3] = ip2dec(strIp, 3);
|
|
|
+
|
|
|
+ LanInfo.BroadCast[0] = ip2dec(strBrdCast, 0);
|
|
|
+ LanInfo.BroadCast[1] = ip2dec(strBrdCast, 1);
|
|
|
+ LanInfo.BroadCast[2] = ip2dec(strBrdCast, 2);
|
|
|
+ LanInfo.BroadCast[3] = ip2dec(strBrdCast, 3);
|
|
|
+
|
|
|
+ LanInfo.NetMask[0] = ip2dec(strMask, 0);
|
|
|
+ LanInfo.NetMask[1] = ip2dec(strMask, 1);
|
|
|
+ LanInfo.NetMask[2] = ip2dec(strMask, 2);
|
|
|
+ LanInfo.NetMask[3] = ip2dec(strMask, 3);
|
|
|
+
|
|
|
+ LanInfo.DefaultGW[0] = ip2dec(strGw, 0);
|
|
|
+ LanInfo.DefaultGW[1] = ip2dec(strGw, 1);
|
|
|
+ LanInfo.DefaultGW[2] = ip2dec(strGw, 2);
|
|
|
+ LanInfo.DefaultGW[3] = ip2dec(strGw, 3);
|
|
|
+
|
|
|
+ LanInfo.MACAddr[0] = mac2hex(strMac, 0);
|
|
|
+ LanInfo.MACAddr[1] = mac2hex(strMac, 1);
|
|
|
+ LanInfo.MACAddr[2] = mac2hex(strMac, 2);
|
|
|
+ LanInfo.MACAddr[3] = mac2hex(strMac, 3);
|
|
|
+ LanInfo.MACAddr[4] = mac2hex(strMac, 4);
|
|
|
+ LanInfo.MACAddr[5] = mac2hex(strMac, 5);
|
|
|
+
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
- LanInfo.IPAddr[0] = ip2dec(strIp, 0);
|
|
|
- LanInfo.IPAddr[1] = ip2dec(strIp, 1);
|
|
|
- LanInfo.IPAddr[2] = ip2dec(strIp, 2);
|
|
|
- LanInfo.IPAddr[3] = ip2dec(strIp, 3);
|
|
|
-
|
|
|
- LanInfo.BroadCast[0] = ip2dec(strBrdCast, 0);
|
|
|
- LanInfo.BroadCast[1] = ip2dec(strBrdCast, 1);
|
|
|
- LanInfo.BroadCast[2] = ip2dec(strBrdCast, 2);
|
|
|
- LanInfo.BroadCast[3] = ip2dec(strBrdCast, 3);
|
|
|
-
|
|
|
- LanInfo.NetMask[0] = ip2dec(strMask, 0);
|
|
|
- LanInfo.NetMask[1] = ip2dec(strMask, 1);
|
|
|
- LanInfo.NetMask[2] = ip2dec(strMask, 2);
|
|
|
- LanInfo.NetMask[3] = ip2dec(strMask, 3);
|
|
|
-
|
|
|
- LanInfo.DefaultGW[0] = ip2dec(strGw, 0);
|
|
|
- LanInfo.DefaultGW[1] = ip2dec(strGw, 1);
|
|
|
- LanInfo.DefaultGW[2] = ip2dec(strGw, 2);
|
|
|
- LanInfo.DefaultGW[3] = ip2dec(strGw, 3);
|
|
|
-
|
|
|
- LanInfo.MACAddr[0] = mac2hex(strMac, 0);
|
|
|
- LanInfo.MACAddr[1] = mac2hex(strMac, 1);
|
|
|
- LanInfo.MACAddr[2] = mac2hex(strMac, 2);
|
|
|
- LanInfo.MACAddr[3] = mac2hex(strMac, 3);
|
|
|
- LanInfo.MACAddr[4] = mac2hex(strMac, 4);
|
|
|
- LanInfo.MACAddr[5] = mac2hex(strMac, 5);
|
|
|
-
|
|
|
- //Create session
|
|
|
- LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+ wRet = IPMICMD_SetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "Reset BMC fail!");
|
|
|
+ }
|
|
|
|
|
|
- wRet = IPMICMD_SetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
|
|
|
- if(wRet != 0)
|
|
|
- {
|
|
|
- websError(wp, 404, "Reset BMC fail!");
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
}
|
|
|
|
|
|
- //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:%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|