ソースを参照

New Lan config interface

zhangbo 5 年 前
コミット
39e23a982e
38 ファイル変更3213 行追加1934 行削除
  1. 49 1
      app/bmc/Api.c
  2. 1 0
      app/bmc/Api.h
  3. 5 1
      app/bmc/BmcType.h
  4. 21 60
      app/bmc/ChassisTimer/ChassisTimerTask.c
  5. 7 0
      app/bmc/Makefile
  6. 184 0
      app/bmc/PendActionTask/PendActionTask.c
  7. 14 0
      app/bmc/PendActionTask/PendActionTask.h
  8. 132 0
      app/bmc/Util.c
  9. 72 0
      app/bmc/Util.h
  10. BIN
      app/bmc/bmc_app
  11. 11 14
      app/bmc/main.c
  12. 2 1
      app/bmc/main.h
  13. 2 2
      app/bmc/msghndlr/App/IPMDevice/IPMDevice.c
  14. 6 6
      app/bmc/msghndlr/Chassis/ChassisDevice.c
  15. 2 1
      app/bmc/msghndlr/MsgHndlrTask.c
  16. 3 0
      app/bmc/msghndlr/PDKCmds.c
  17. 40 0
      app/bmc/msghndlr/Storlead/Storlead.c
  18. 4 1
      app/bmc/msghndlr/Storlead/Storlead.h
  19. 48 58
      app/bmc/msghndlr/Transport/DeviceConfig.c
  20. 35 0
      app/bmc/msghndlr/Transport/DeviceConfig.h
  21. 989 1686
      app/bmc/msghndlr/Transport/LANConfig.c
  22. 63 0
      app/bmc/msghndlr/Transport/LANConfig.h
  23. 780 0
      app/bmc/msghndlr/Transport/nwcfg.h
  24. 29 25
      app/bmc/msghndlr/cmdselect.c
  25. 103 0
      app/bmc/util.c
  26. 32 0
      app/common_include/com_BMCCfg.h
  27. 11 0
      app/common_include/com_BmcType.h
  28. 4 1
      app/common_include/com_IPMIDefs.h
  29. 44 0
      app/common_include/com_IPMI_DeviceConfig.h
  30. 133 60
      app/common_include/com_IPMI_LANConfig.h
  31. 3 0
      app/common_include/com_IPMI_Storlead.h
  32. 1 0
      app/goahead-3.6.5/projects/goahead-linux-static.mk
  33. 2 0
      app/goahead-3.6.5/src/goahead.c
  34. 2 0
      app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h
  35. 46 0
      app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c
  36. 2 2
      app/goahead-3.6.5/src/web_interface/inc/config.h
  37. 326 10
      app/goahead-3.6.5/src/web_interface/src/config.c
  38. 5 5
      gd32450i-eval.busybox

+ 49 - 1
app/bmc/Api.c

@@ -17,6 +17,7 @@
 #include "MsgHndlr.h"
 
 
+
 int InitSdrConfig(void)
 {
 	printf("Init SDR Config...\r\n");
@@ -133,6 +134,7 @@ int PlatformInit(void)
 	g_BMCInfo.CurTimerTick				=	0;
 	g_BMCInfo.CurTimerSecond			=	0;
 	g_BMCInfo.BootValidMinutes			=	0;
+	g_BMCInfo.m_Lan_SetInProgress 		=	0;
 	
 		
 	return 0;
@@ -228,8 +230,33 @@ int Init_IPMI_FRU_SDR_SEL(void)
 		g_BMCInfo.IpmiConfig.SecondaryIPMBBus 		= 	SECONDARY_IPMB_BUS;
 		g_BMCInfo.IpmiConfig.PrimaryIPMBAddr 		= 	PRIMARY_IPMB_ADDR;
 		g_BMCInfo.IpmiConfig.SecondaryIPMBAddr 		= 	SECONDARY_IPMB_ADDR;
+
+		//LAN
+		strcpy(g_BMCInfo.IpmiConfig.LanInfo[0].EthName, "eth0");
+		g_BMCInfo.IpmiConfig.LanInfo[0].IPAddrSrc 	= 	0x01;	//static
+		g_BMCInfo.IpmiConfig.LanInfo[0].IPAddr[0]	=	192;
+		g_BMCInfo.IpmiConfig.LanInfo[0].IPAddr[1]	=	168;
+		g_BMCInfo.IpmiConfig.LanInfo[0].IPAddr[2]	=	0;
+		g_BMCInfo.IpmiConfig.LanInfo[0].IPAddr[3]	=	208;
+		g_BMCInfo.IpmiConfig.LanInfo[0].BroadCast[0]	=	192;
+		g_BMCInfo.IpmiConfig.LanInfo[0].BroadCast[1]	=	168;
+		g_BMCInfo.IpmiConfig.LanInfo[0].BroadCast[2]	=	0;
+		g_BMCInfo.IpmiConfig.LanInfo[0].BroadCast[3]	=	255;
+		g_BMCInfo.IpmiConfig.LanInfo[0].NetMask[0]	=	255;
+		g_BMCInfo.IpmiConfig.LanInfo[0].NetMask[1]	=	255;
+		g_BMCInfo.IpmiConfig.LanInfo[0].NetMask[2]	=	255;
+		g_BMCInfo.IpmiConfig.LanInfo[0].NetMask[3]	=	0;
+		g_BMCInfo.IpmiConfig.LanInfo[0].DefaultGW[0] 	= 	192;
+		g_BMCInfo.IpmiConfig.LanInfo[0].DefaultGW[1] 	= 	168;
+		g_BMCInfo.IpmiConfig.LanInfo[0].DefaultGW[2] 	= 	0;
+		g_BMCInfo.IpmiConfig.LanInfo[0].DefaultGW[3] 	= 	1;
+		g_BMCInfo.IpmiConfig.LanInfo[0].MACAddr[0]	=	0xC0;
+		g_BMCInfo.IpmiConfig.LanInfo[0].MACAddr[1]	=	0xB1;
+		g_BMCInfo.IpmiConfig.LanInfo[0].MACAddr[2]	=	0x3C;
+		g_BMCInfo.IpmiConfig.LanInfo[0].MACAddr[3]	=	0x88;
+		g_BMCInfo.IpmiConfig.LanInfo[0].MACAddr[4]	=	0x88;
+		g_BMCInfo.IpmiConfig.LanInfo[0].MACAddr[5]	=	0x85;
 		
-				
 		//Init FRU
 		memcpy(&g_BMCInfo.FRU, &Default_FRUData, sizeof(OemFRUData_T));
 		
@@ -504,6 +531,27 @@ char* getip(char *ip_buf)
     return ip_buf;
 }
 
+char* getnetmask(char *netmask_buf)
+{
+    struct ifreq temp;
+    struct sockaddr_in *myaddr;
+    int fd = 0;
+    int ret = -1;
+    strcpy(temp.ifr_name, "eth0");
+    if((fd=socket(AF_INET, SOCK_STREAM, 0))<0)
+    {
+        return NULL;
+    }
+    ret = ioctl(fd, SIOCGIFNETMASK, &temp);
+    close(fd);
+    if(ret < 0)
+        return NULL;
+    myaddr = (struct sockaddr_in *)&(temp.ifr_addr);
+    strcpy(netmask_buf, (char*)inet_ntoa(myaddr->sin_addr));
+
+    return netmask_buf;
+}
+
 char* getmac(char *mac_buf)
 {
     struct ifreq temp;

+ 1 - 0
app/bmc/Api.h

@@ -28,6 +28,7 @@ int PostEventMessage (uint8_t *EventMsg,uint8_t size);
 
 char* getip(char *ip_buf);
 int setip(char *ip);
+char* getnetmask(char *netmask_buf);
 char* getmac(char *mac_buf);
 
 int FlushUserInfoTbl(void);

+ 5 - 1
app/bmc/BmcType.h

@@ -33,6 +33,7 @@ typedef enum
   ORIGIN_NM,
 }BridgeOrigin;
 
+
 typedef struct
 {
 	char	FirstPowerOnStr[32];	//first power on the bmc 
@@ -70,6 +71,9 @@ typedef struct
 	
 	uint8_t		MaxSession;
 	uint32_t	LogOutTimeout;
+
+	//lan configuration
+	LanInfo_T 	LanInfo[1];	//方便扩展多个网卡。
 } IPMIConfig_T;
 
 
@@ -125,7 +129,7 @@ typedef struct
 	UserInfo_T			*pUserInfo;
 	uint8_t				CurrentNoUser;
 	
-
+	uint8_t 			m_Lan_SetInProgress;
 	
 	uint8_t				FwMajorVer;
 	uint8_t				FwMinorVer;

+ 21 - 60
app/bmc/ChassisTimer/ChassisTimerTask.c

@@ -20,6 +20,8 @@
 #include "ChassisTimerTask.h"
 #include "ChassisDevice.h"
 #include "com_IPMI_Chassis.h"
+#include "com_IPMI_LANConfig.h"
+#include "com_IPMI_DeviceConfig.h"
 #include "SensorMonitor.h"
 #include "time.h"
 
@@ -27,7 +29,7 @@
 #include "hal_interface_api.h"
 
 
-int gFd_ChassisPwrHndlrQue;
+//int gFd_ChassisPwrHndlrQue;
 
 void *ChassisTimerTask(void* pArg)
 {
@@ -36,74 +38,33 @@ void *ChassisTimerTask(void* pArg)
 	uint32_t	preFanSeconds;
 	uint32_t	preIdentifySeconds = 0;
 	uint8_t		IdentifyTickCnt = 0;
+	char  		cmdStr[100] = {0};
+	SetLanConfigReq_T  *pSetLanCfg;
 	prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
 
 	printf("ChassisTimerTask Started... \n");
 
-	//create 
-    if(-1 != access(CHASSIS_PWR_HNDLR_Q, F_OK))
-    {
-        remove(CHASSIS_PWR_HNDLR_Q);
-    }
-    if(0 != mkfifo (CHASSIS_PWR_HNDLR_Q, 0777))
-    {
-        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, CHASSIS_PWR_HNDLR_Q, strerror(errno));
-        return (void*)-1;
-    }
-    gFd_ChassisPwrHndlrQue = open (CHASSIS_PWR_HNDLR_Q, O_RDWR);
-    if(-1 == gFd_ChassisPwrHndlrQue)
-    {
-        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, CHASSIS_PWR_HNDLR_Q, strerror(errno));
-        return (void*)-1;
-    }
+	// //create 
+ //    if(-1 != access(CHASSIS_PWR_HNDLR_Q, F_OK))
+ //    {
+ //        remove(CHASSIS_PWR_HNDLR_Q);
+ //    }
+ //    if(0 != mkfifo (CHASSIS_PWR_HNDLR_Q, 0777))
+ //    {
+ //        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, CHASSIS_PWR_HNDLR_Q, strerror(errno));
+ //        return (void*)-1;
+ //    }
+ //    gFd_ChassisPwrHndlrQue = open (CHASSIS_PWR_HNDLR_Q, O_RDWR);
+ //    if(-1 == gFd_ChassisPwrHndlrQue)
+ //    {
+ //        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, CHASSIS_PWR_HNDLR_Q, strerror(errno));
+ //        return (void*)-1;
+ //    }
 
 	preChassisSeconds	=	g_BMCInfo.CurTimerSecond;
 	preFanSeconds	=	g_BMCInfo.CurTimerSecond;
 	while(1)
 	{
-		if(GetMsg(gFd_ChassisPwrHndlrQue, &MsgPkt,  0) == 0)
-		{
-			if(MsgPkt.Param == PARAM_CHASSIS)
-			{
-				//Chassis power control
-				if((NET_FN(MsgPkt.NetFnLUN) == NETFN_CHASSIS) && (MsgPkt.Cmd == CMD_CHASSIS_CONTROL))
-				{
-					switch(MsgPkt.Data[0])
-					{
-						case CHASSIS_POWER_DOWN:
-							PDK_PowerOffChassis();
-							break;
-						case CHASSIS_POWER_UP:
-							PDK_PowerOnChassis();
-							break;
-						case CHASSIS_POWER_CYCLE:
-							PDK_PowerCycleChassis();
-							break;
-						case CHASSIS_HARD_RESET:
-							PDK_ResetChassis();
-							break;
-						case CHASSIS_PULSE_DIAGNOSTIC_INTERRUPT:
-							PDK_DiagInterruptChassis();
-							break;
-						case CHASSIS_SOFT_SHUTDOWN:
-							PDK_SoftOffChassis();
-							break;
-						default:
-							printf("Invalid power control cmd\r\n");
-							break;
-					}
-				}
-			}
-			else if(MsgPkt.Param == PARAM_MC)
-			{
-				if(((MsgPkt.NetFnLUN>>2) == NETFN_APP) && ((MsgPkt.Cmd == CMD_COLD_RESET) || (MsgPkt.Cmd == CMD_WARM_RESET))) 
-				{
-					sleep(1);	//wait ipmi request response finish.
-					stm32_reset_mcu();
-				}
-			}
-		}
-		
 		//Chassis timer interval
 		if((g_BMCInfo.CurTimerSecond != preChassisSeconds) 
 			&&((g_BMCInfo.CurTimerSecond - preChassisSeconds) >= g_BMCInfo.IpmiConfig.ChassisTimerInterval))

+ 7 - 0
app/bmc/Makefile

@@ -16,6 +16,7 @@ SRC	+= ./Api.c
 SRC	+= ./sensor_driver.c
 SRC	+= ./sensor_sdr.c
 SRC	+= ./OemFRU.c
+SRC	+= ./Util.c
 
 SRC	+= ./SysTimer/TimerTask.c
 
@@ -26,6 +27,8 @@ SRC += ./lan/RMCP+.c
 
 SRC += ./ipmb/IPMBIfc.c
 
+SRC += ./PendActionTask/PendActionTask.c
+
 SRC += ./encryption/MD2.c
 SRC += ./encryption/md2_dgst.c
 SRC += ./encryption/MD5.c
@@ -59,6 +62,9 @@ SRC += ./msghndlr/Storage/FRUDevice/FRU.c
 SRC += ./msghndlr/Storage/SDRDevice/SDR.c
 SRC += ./msghndlr/Storage/SELDevice/SEL.c
 
+SRC += ./msghndlr/Transport/LANConfig.c
+SRC += ./msghndlr/Transport/DeviceConfig.c
+
 SRC += ./msghndlr/Storlead/Storlead.c
 
 SRC += ./AuthChip/CM_BURNFUZE.c
@@ -121,6 +127,7 @@ CFLAGS	+= -I ./ChassisTimer
 CFLAGS	+= -I ./encryption
 CFLAGS	+= -I ./ipmb
 CFLAGS	+= -I ./lan
+CFLAGS	+= -I ./PendActionTask
 
 CFLAGS	+= -I ./msghndlr
 CFLAGS	+= -I ./msghndlr/App

+ 184 - 0
app/bmc/PendActionTask/PendActionTask.c

@@ -0,0 +1,184 @@
+#include "main.h"
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/prctl.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <pthread.h>
+
+#include "main.h"
+#include "ChassisTimerTask.h"
+#include "ChassisDevice.h"
+#include "com_IPMI_Chassis.h"
+#include "com_IPMI_LANConfig.h"
+#include "com_IPMI_DeviceConfig.h"
+#include "SensorMonitor.h"
+#include "time.h"
+#include "com_IPMI_Storlead.h"
+
+#include "com_IPMI_App.h"
+#include "hal_interface_api.h"
+
+int 		gPendActionIfc;
+
+void *PendActionTask(void *Param)
+{
+	MsgPkt_T	MsgPkt;
+	char  		cmdStr[100] = {0};
+	SetLanConfigReq_T  *pSetLanCfg;
+	prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+
+	printf("PendActionTask Started... \n");
+
+	//create 
+    if(-1 != access(PEND_ACTION_HNDLR_Q, F_OK))
+    {
+        remove(PEND_ACTION_HNDLR_Q);
+    }
+    if(0 != mkfifo (PEND_ACTION_HNDLR_Q, 0777))
+    {
+        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, PEND_ACTION_HNDLR_Q, strerror(errno));
+        return (void*)-1;
+    }
+    gPendActionIfc = open (PEND_ACTION_HNDLR_Q, O_RDWR);
+    if(-1 == gPendActionIfc)
+    {
+        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, PEND_ACTION_HNDLR_Q, strerror(errno));
+        return (void*)-1;
+    }
+
+    while(1)
+    {
+		if(GetMsg(gPendActionIfc, &MsgPkt,  WAIT_INFINITE) == 0)
+		{
+			if(MsgPkt.Param == PARAM_CHASSIS)
+			{
+				//Chassis power control
+				if((NET_FN(MsgPkt.NetFnLUN) == NETFN_CHASSIS) && (MsgPkt.Cmd == CMD_CHASSIS_CONTROL))
+				{
+					switch(MsgPkt.Data[0])
+					{
+						case CHASSIS_POWER_DOWN:
+							PDK_PowerOffChassis();
+							break;
+						case CHASSIS_POWER_UP:
+							PDK_PowerOnChassis();
+							break;
+						case CHASSIS_POWER_CYCLE:
+							PDK_PowerCycleChassis();
+							break;
+						case CHASSIS_HARD_RESET:
+							PDK_ResetChassis();
+							break;
+						case CHASSIS_PULSE_DIAGNOSTIC_INTERRUPT:
+							PDK_DiagInterruptChassis();
+							break;
+						case CHASSIS_SOFT_SHUTDOWN:
+							PDK_SoftOffChassis();
+							break;
+						default:
+							printf("Invalid power control cmd\r\n");
+							break;
+					}
+				}
+			}
+			else if(MsgPkt.Param == PARAM_MC)
+			{
+				if(((MsgPkt.NetFnLUN>>2) == NETFN_APP) && ((MsgPkt.Cmd == CMD_COLD_RESET) || (MsgPkt.Cmd == CMD_WARM_RESET))) 
+				{
+					sleep(1);	//wait ipmi request response finish.
+					stm32_reset_mcu();
+				}
+			}
+			else if(MsgPkt.Param == PARAM_LAN)
+			{
+				pSetLanCfg = (SetLanConfigReq_T*)MsgPkt.Data;
+				printf("---> PARAM_LAN, NetFnLUN: %#x, cmd: %#x\n", MsgPkt.NetFnLUN, MsgPkt.Cmd);
+				printf("---> Data: %#x %#x %#x %#x %#x\n", MsgPkt.Data[0], MsgPkt.Data[1], MsgPkt.Data[2], MsgPkt.Data[3], MsgPkt.Data[4]);
+				if(((MsgPkt.NetFnLUN>>2) == NETFN_TRANSPORT) 
+					&& (MsgPkt.Cmd == CMD_SET_LAN_CONFIGURATION_PARAMETERS)
+					&& (pSetLanCfg->ChannelNum == LAN_RMCP_CHANNEL)) 
+				{
+					//Modify IP
+					if(pSetLanCfg->ParameterSelect == LAN_PARAM_IP_ADDRESS)
+					{
+						
+						sprintf(cmdStr, "ifconfig eth0 %d.%d.%d.%d up", 
+							pSetLanCfg->ConfigData.IPAddr[0], pSetLanCfg->ConfigData.IPAddr[1],
+							pSetLanCfg->ConfigData.IPAddr[2], pSetLanCfg->ConfigData.IPAddr[3]);
+						printf("Execute cmd: %s\n", cmdStr);
+						sleep(1);
+						system(cmdStr);
+					}
+					else if(pSetLanCfg->ParameterSelect == LAN_PARAM_MAC_ADDRESS)
+					{
+						sprintf(cmdStr, "ifconfig eth0 hw ether %02x:%02x:%02x:%02x:%02x:%02x", 
+							pSetLanCfg->ConfigData.MACAddr[0], pSetLanCfg->ConfigData.MACAddr[1],
+							pSetLanCfg->ConfigData.MACAddr[2], pSetLanCfg->ConfigData.MACAddr[3],
+							pSetLanCfg->ConfigData.MACAddr[4], pSetLanCfg->ConfigData.MACAddr[5]);
+						printf("Execute cmd: %s\n", cmdStr);
+						sleep(1);
+						system("ifconfig eth0 down");						
+						system(cmdStr);
+						system("ifconfig eth0 up");
+					}
+					else if(pSetLanCfg->ParameterSelect == LAN_PARAM_SUBNET_MASK)
+					{
+						sprintf(cmdStr, "ifconfig eth0 netmask %d.%d.%d.%d", 
+							pSetLanCfg->ConfigData.SubNetMask[0], pSetLanCfg->ConfigData.SubNetMask[1],
+							pSetLanCfg->ConfigData.SubNetMask[2], pSetLanCfg->ConfigData.SubNetMask[3]);
+						printf("Execute cmd: %s\n", cmdStr);
+						sleep(1);
+						system(cmdStr);
+					}
+					else if(pSetLanCfg->ParameterSelect == LAN_PARAM_DEFAULT_GATEWAY_IP)
+					{
+						sprintf(cmdStr, "route add default gw %d.%d.%d.%d", 
+							pSetLanCfg->ConfigData.DefaultGatewayIPAddr[0], pSetLanCfg->ConfigData.DefaultGatewayIPAddr[1],
+							pSetLanCfg->ConfigData.DefaultGatewayIPAddr[2], pSetLanCfg->ConfigData.DefaultGatewayIPAddr[3]);
+						printf("Execute cmd: %s\n", cmdStr);
+						sleep(1);
+						system(cmdStr);
+					}
+
+				}
+				else if(((MsgPkt.NetFnLUN>>2) == NETFN_STORLEAD) 
+					&& (MsgPkt.Cmd == CMD_SET_LAN_INFO))
+				{
+					LanInfo_T *pSetLanInfo = (LanInfo_T*)MsgPkt.Data;
+					sleep(1);
+					//down
+					sprintf(cmdStr, "ifconfig %s down", pSetLanInfo->EthName);
+					printf("%s\n", cmdStr);
+					system(cmdStr);
+					//set mac
+					sprintf(cmdStr, "ifconfig %s hw ether %02x:%02x:%02x:%02x:%02x:%02x", 
+						pSetLanInfo->EthName, pSetLanInfo->MACAddr[0], pSetLanInfo->MACAddr[1],
+						pSetLanInfo->MACAddr[2], pSetLanInfo->MACAddr[3], 
+						pSetLanInfo->MACAddr[4], pSetLanInfo->MACAddr[5]);
+					printf("%s\n", cmdStr);
+					system(cmdStr);
+					//ip, broadcast, netmask
+					sprintf(cmdStr, "ifconfig %s %d.%d.%d.%d broadcast %d.%d.%d.%d netmask %d.%d.%d.%d up",
+						pSetLanInfo->EthName, pSetLanInfo->IPAddr[0], pSetLanInfo->IPAddr[1],
+						pSetLanInfo->IPAddr[2], pSetLanInfo->IPAddr[3], pSetLanInfo->BroadCast[0],
+						pSetLanInfo->BroadCast[1], pSetLanInfo->BroadCast[2], pSetLanInfo->BroadCast[3],
+						pSetLanInfo->NetMask[0], pSetLanInfo->NetMask[1], pSetLanInfo->NetMask[2],
+						pSetLanInfo->NetMask[3]);
+					printf("%s\n", cmdStr);
+					system(cmdStr);
+					//default gw
+					sprintf(cmdStr, "route add default gw %d.%d.%d.%d", pSetLanInfo->DefaultGW[0],
+						pSetLanInfo->DefaultGW[1],pSetLanInfo->DefaultGW[2],pSetLanInfo->DefaultGW[3]);
+					printf("%s\n", cmdStr);
+					system(cmdStr);
+				} 
+			}
+		}
+	}
+}

+ 14 - 0
app/bmc/PendActionTask/PendActionTask.h

@@ -0,0 +1,14 @@
+#ifndef __PEND_ACTION_TASK_H__
+#define __PEND_ACTION_TASK_H__
+
+
+void *PendActionTask(void *Param);
+
+
+
+
+
+
+
+
+#endif /* __PEND_ACTION_TASK_H__ */

+ 132 - 0
app/bmc/Util.c

@@ -0,0 +1,132 @@
+
+#include "Util.h"
+#include <sys/sysinfo.h> 
+
+
+/*----------------------------------------
+ * GetBits
+ *----------------------------------------*/
+uint8_t
+GetBits (uint8_t Val, uint8_t Mask)
+{
+    uint8_t ExtVal = 0;
+    while (0 != Mask)
+    {
+        if (0 != (Mask & 0x80))
+        {
+            ExtVal <<= 1;
+            if (0 != (Val & 0x80)) { ExtVal += 0x01; }
+        }
+
+        Val <<= 1;
+        Mask <<= 1;
+    }
+
+    return ExtVal;
+}
+
+/*------------------------------------------
+ * SetBits
+ *------------------------------------------*/
+uint8_t
+SetBits (uint8_t Mask, uint8_t Val)
+{
+    uint8_t FinVal = 0;
+    uint8_t i;
+
+    for (i = 0; i < 8; i++)
+    {
+        FinVal >>= 1;
+        if (0 != (Mask & 0x01))
+        {
+            if (0 != (Val & 0x01)) { FinVal |= 0x80; }
+                Val >>= 1;
+        }
+        Mask   >>= 1;
+    }
+
+    return FinVal;
+}
+
+/*------------------------------------------
+ * CalculateCheckSum
+ *------------------------------------------*/
+uint8_t
+CalculateCheckSum (uint8_t* Data, uint16_t Len)
+{
+    uint8_t   Sum;
+    uint16_t  i;
+
+    Sum = 0;
+    for (i = 0; i < Len; i++)
+    {
+        Sum += Data [i];
+    }
+    return (0x100 - Sum);
+}
+
+/*
+* @fn TimeUpdate
+* @return Returns the system uptime
+*/
+uint32_t TimeUpdate()
+{
+    struct sysinfo time;
+    sysinfo(&time);
+    return time.uptime;
+}
+
+// /**
+// *@fn GetSysCtlvalue
+// *@brief This function retrieves the values from Sysctl
+// *@param TagName -Tagname form which value has to be retrieved
+// *@param SysVal - Where the value is stored
+// *@return Returns 0 on success
+// *            Returns 1 on failure
+// */
+// int GetJiffySysCtlvalue (const char *TagName, long long *SysVal)
+// {
+//     unsigned long RetVal;
+//     FILE* SysFile = fopen (TagName, "r");
+//     unsigned long Hertz = sysconf(_SC_CLK_TCK);
+
+//     if ((!SysFile) || (!SysVal))
+//         return 1;
+
+//     fscanf (SysFile, "%lu", &RetVal);
+//     fclose (SysFile);
+
+//     *SysVal = (RetVal*1000)/Hertz;
+//     return 0;
+// }
+
+int FlushUserInfo(void)
+{
+    //TODO:
+    return 0;
+}
+
+int FlushFRU(void)
+{
+    //TODO:
+    return 0;
+}
+
+int FlushSDR(void)
+{
+    //TODO:
+    return 0;
+}
+
+int FlushIpmiConfig(void)
+{
+    //TODO:
+    return 0;
+}
+
+int FlushSEL(void)
+{
+    //TODO:
+    return 0;
+}
+

+ 72 - 0
app/bmc/Util.h

@@ -0,0 +1,72 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * util.h
+ * Utility functions.
+ *
+ * Author: Govind Kothandapani <govindk@ami.com> 
+ * 
+ *****************************************************************/
+#ifndef UTIL_H
+#define UTIL_H
+
+#include "com_IPMIDefs.h"
+#include <stdio.h>
+
+/**
+ * Returns the maximum of two values
+**/
+#define UTIL_MAX(val1, val2) \
+    ((val1 > val2) ? val1 : val2)
+
+/**
+ * Returns the minimum of two values
+**/
+#define UTIL_MIN(val1, val2) \
+    ((val1 < val2) ? val1 : val2)
+
+/**
+ * @brief Extracts the contents of the bits corresponding to the mask.
+**/
+ uint8_t GetBits (uint8_t Val, uint8_t Mask);
+
+/**
+ * @brief Sets the bits corresponding to the mask according to the value.
+**/
+ uint8_t SetBits (uint8_t Mask, uint8_t Val);
+
+/**
+ * @brief Find the checksum
+**/
+ uint8_t CalculateCheckSum (uint8_t* Data, uint16_t Len);
+
+// *
+// *@ brief Retrieves the value from sysctl
+
+// int GetJiffySysCtlvalue (const char *TagName, long long *SysVal);
+
+int FlushUserInfo(void);
+int FlushFRU(void);
+int FlushSDR(void);
+int FlushIpmiConfig(void);
+int FlushSEL(void);
+
+
+
+
+
+
+
+#endif	/* UTIL_H */

BIN
app/bmc/bmc_app


+ 11 - 14
app/bmc/main.c

@@ -32,6 +32,7 @@
 #include "com_gpio.h"
 #include "hal_interface_api.h"
 #include "com_BMCCfg.h"
+#include "PendActionTask.h"
 
 
 /* gloabl varible */
@@ -39,6 +40,7 @@ BMCInfo_t 	g_BMCInfo;
 pthread_t 	gThreadIDs[256];
 uint8_t		gThreadIndex = 0;
 SensorHistoryInfo_T 	gSensorHistoryInfo[SENSOR_NUMBERS];
+
 FanInfo_T	gFanInfo[FAN_NUMBERS] = {
 								/* Index | name | mode | level | speed  */
 									{0, {"Fan1"}, 0, 0, 0 },
@@ -171,6 +173,12 @@ void main(void)
  //      printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
  //  }
 
+    /* Create PendActionTask */
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,PendActionTask,NULL))
+    {
+        printf("%s: Create PendActionTask thread failed!\n", __FUNCTION__);
+    }
 
 	/* Create Update FPGA thread */
 
@@ -185,23 +193,12 @@ void main(void)
     // uint8_t buf[7] = {0x20, 0xb8, 0x8, 0x20, 0x4, 0x1, 0xdb };
     // gThreadIndex++;
     // pthread_create(&gThreadIDs[gThreadIndex],NULL,test_thread,NULL);
+
+    
+
 	while(1)	//在这里实现各线程的健康状态检测,发现出错的线程就重启它。
 	{
-		// if(test_flag)
-		// {
-		// 	test_flag = 0;
-
-		// 	pthread_mutex_lock(&mutex);
-		// 	if(0 != stm32_i2c_master_write(tmp_fd, buf[0], &buf[1], 6))
-		// 	{
-		// 		printf("---> Send ipmb error!\n");
-		// 	}
-		// 	else
-		// 		printf("---> send ipmb ok\n");
-		// 	pthread_mutex_unlock(&mutex);
-		// }	
 		sleep(1);
-		//printf("Hello...\n");
 	}
 }
 

+ 2 - 1
app/bmc/main.h

@@ -95,9 +95,10 @@ extern uint8_t		gThreadIndex;
 extern int gFd_LanIfcQ, gFd_LanResQ;
 extern int gFdUdsIfc, gFdUdsRes;
 extern int gFd_MsgHndlrIfc;
-extern int gFd_ChassisPwrHndlrQue;
+//extern int gFd_ChassisPwrHndlrQue;
 extern int gFd_PrimaryIpmbIfcQ, gFd_PrimaryIpmbResQ;
 extern int gFd_SecondaryIpmbIfcQ, gFd_SecondaryIpmbResQ;
+extern int gPendActionIfc;
 extern TLS_T g_tls;
 extern PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
 extern PendingSeqNoTbl_T		m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];

+ 2 - 2
app/bmc/msghndlr/App/IPMDevice/IPMDevice.c

@@ -122,7 +122,7 @@ ColdReset ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 	MsgPkt.NetFnLUN = NETFN_APP<<2; 
 	MsgPkt.Cmd = CMD_COLD_RESET;
 	
-	PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+	PostMsg(gPendActionIfc, &MsgPkt);
     *pRes = CC_NORMAL;
     return sizeof (*pRes);
 }
@@ -139,7 +139,7 @@ WarmReset ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 	MsgPkt.NetFnLUN = NETFN_APP<<2; 
 	MsgPkt.Cmd = CMD_WARM_RESET;
 	
-	PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+	PostMsg(gPendActionIfc, &MsgPkt);
 	*pRes = CC_NORMAL;
 	return sizeof (*pRes);
 }

+ 6 - 6
app/bmc/msghndlr/Chassis/ChassisDevice.c

@@ -195,7 +195,7 @@ ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
 			MsgPkt.Cmd		=	0x02;
 			MsgPkt.Data[0]	=	CHASSIS_POWER_DOWN;
 			MsgPkt.Size     =    1;
-            PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);	
+            PostMsg(gPendActionIfc, &MsgPkt);	
 
 //            g_BMCInfo.HostOFFStopWDT = TRUE ;
             g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
@@ -210,7 +210,7 @@ ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
 			MsgPkt.Cmd		=	0x02;
 			MsgPkt.Data[0]	=	CHASSIS_POWER_UP;
             MsgPkt.Size     =    1;
-			PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+			PostMsg(gPendActionIfc, &MsgPkt);
             g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
 //            OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
 //            g_BMCInfo.Msghndlr.ChassisControl = CHASSIS_POWER_UP;
@@ -229,7 +229,7 @@ ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
 		MsgPkt.Cmd		=	0x02;
 		MsgPkt.Data[0]	=	CHASSIS_POWER_CYCLE;
         MsgPkt.Size     =    1;
-		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+		PostMsg(gPendActionIfc, &MsgPkt);
 	
         g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
 //        OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
@@ -249,7 +249,7 @@ ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
 		MsgPkt.Cmd		=	0x02;
 		MsgPkt.Data[0]	=	CHASSIS_HARD_RESET;
         MsgPkt.Size     =    1;
-		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);	
+		PostMsg(gPendActionIfc, &MsgPkt);	
         g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
 //        OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
 //        g_BMCInfo.Msghndlr.ChassisControl = CHASSIS_HARD_RESET;
@@ -262,7 +262,7 @@ ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
 		MsgPkt.Cmd		=	0x02;
 		MsgPkt.Data[0]	=	CHASSIS_PULSE_DIAGNOSTIC_INTERRUPT;
         MsgPkt.Size     =    1;
-		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+		PostMsg(gPendActionIfc, &MsgPkt);
         //Platform_HostDiagInt ();
         break;
 
@@ -273,7 +273,7 @@ ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
 		MsgPkt.Cmd		=	0x02;
 		MsgPkt.Data[0]	=	CHASSIS_SOFT_SHUTDOWN;
         MsgPkt.Size     =    1;
-		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+		PostMsg(gPendActionIfc, &MsgPkt);
         //Platform_HostSoftShutDown (BMCInst);
         break;
 

+ 2 - 1
app/bmc/msghndlr/MsgHndlrTask.c

@@ -29,6 +29,7 @@
 #include "com_IPMI_App.h"
 #include "com_IPMI_Storage.h"
 #include "com_IPMI_SDR.h"
+#include "DeviceConfig.h"
 
 //#include "main.h"
 #include <string.h>
@@ -46,7 +47,7 @@ MsgHndlrTbl_T m_MsgHndlrTbl [] =	//notice!
 	{ NETFN_BRIDGE,                 g_Bridge_CmdHndlr               },
 	{ NETFN_SENSOR,                 g_SensorEvent_CmdHndlr          },
 	{ NETFN_STORAGE,                g_Storage_CmdHndlr              },
-//	{ NETFN_TRANSPORT,              g_Config_CmdHndlr               },
+	{ NETFN_TRANSPORT,              g_Config_CmdHndlr               },
 //	{ NETFN_AMI,                    (CmdHndlrMap_T*)g_AMI_CmdHndlr  },
 	{	0,							0	},
 };

+ 3 - 0
app/bmc/msghndlr/PDKCmds.c

@@ -347,6 +347,9 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_SET_MANAGE_FN,         PRIV_USER,      Storlead_SetBladeManageFn,         0xff,  0xAAAA  ,0xFFFF},     { CMD_SET_FAN_INFO,         PRIV_USER,      Storlead_SetFanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_MANAGE_FN,         PRIV_USER,      Storlead_GetBladeManageFn,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_CHASSIS_INFO,      PRIV_USER,      Storlead_GetChassisInfo,         0xff,  0xAAAA  ,0xFFFF},
+    { CMD_RESTORE_FACTORY_SET,      PRIV_USER,      Storlead_RestoreFactorSettings,         0xff,  0xAAAA  ,0xFFFF},
+    { CMD_GET_LAN_INFO,      PRIV_USER,      Storlead_GetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
+    { CMD_SET_LAN_INFO,      PRIV_USER,      Storlead_SetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 40 - 0
app/bmc/msghndlr/Storlead/Storlead.c

@@ -494,3 +494,43 @@ int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
 
     return 1;
 }
+
+int Storlead_GetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;
+    uint8_t index = pReq[0];
+    if(index > 0)
+    {
+        pRes[0] = CC_PARAM_OUT_OF_RANGE;
+        return 1;
+    }
+
+    memcpy(pRes+1, &g_BMCInfo.IpmiConfig.LanInfo[index], sizeof(LanInfo_T));
+
+    return 1+sizeof(LanInfo_T);
+}
+
+int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    MsgPkt_T m_MsgPkt;
+    uint8_t index = pReq[0];
+    LanInfo_T *pLanInfo = (LanInfo_T*)&pReq[1];
+
+    if(index > 0)   //只有一张网卡,index只能是0
+    {
+        pRes[0] = CC_PARAM_OUT_OF_RANGE;
+        return 1;
+    }
+
+    memcpy(&g_BMCInfo.IpmiConfig.LanInfo[index], pLanInfo, sizeof(LanInfo_T));
+
+    m_MsgPkt.Param      = PARAM_LAN;
+    m_MsgPkt.NetFnLUN   = NETFNLUN_IPMI_STORLEAD;
+    m_MsgPkt.Cmd        = CMD_SET_LAN_INFO;
+    m_MsgPkt.Size       = sizeof(LanInfo_T);
+    memcpy(m_MsgPkt.Data, pLanInfo, sizeof(LanInfo_T));
+    PostMsg(gPendActionIfc, &m_MsgPkt);
+    
+    pRes[0] = CC_NORMAL;
+    return 1;
+}

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

@@ -13,4 +13,7 @@ int Storlead_SetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_SetBladeManageFn(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetBladeManageFn(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
-int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+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);

+ 48 - 58
app/bmc/msghndlr/Transport/DeviceConfig.c

@@ -1,63 +1,53 @@
-// /****************************************************************
-//  ****************************************************************
-//  **                                                            **
-//  **    (C)Copyright 2005-2006, American Megatrends Inc.        **
-//  **                                                            **
-//  **            All Rights Reserved.                            **
-//  **                                                            **
-//  **        6145-F, Northbelt Parkway, Norcross,                **
-//  **                                                            **
-//  **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
-//  **                                                            **
-//  ****************************************************************
-//  *****************************************************************
-//  *
-//  * DeviceConfig.c
-//  * Device Configuration Handler
-//  *
-//  * Author: Govind Kothandapani <govindk@ami.com>
-//  *       : Rama Bisa <ramab@ami.com>
-//  *       : Basavaraj Astekar <basavaraja@ami.com>
-//  *       : Bakka Ravinder Reddy <bakkar@ami.com>
-//  *
-//  *****************************************************************/
-// #define UNIMPLEMENTED_AS_FUNC
-// #include "MsgHndlr.h"
-// #include "DeviceConfig.h"
-// #include "IPMI_SerialModem.h"
-// #include "IPMI_LANConfig.h"
-// #include "IPMI_SOLConfig.h"
-// #include "SerialModem.h"
-// #include "LANConfig.h"
-// #include "SOLConfig.h"
-// #include "Support.h"
 
-// /**
-//  * @var g_Config_CmdHndlr
-//  * @brief Transport Configuration Commands Map
-// **/
-// const CmdHndlrMap_T g_Config_CmdHndlr [] =
-// {
-//     /*------------------------- IPM Device Commands --------------------------------------*/
-//     { CMD_SET_LAN_CONFIGURATION_PARAMETERS,     PRIV_ADMIN,     SET_LAN_CONFIGURATION_PARAMETERS,   0xFF,   0xAAAA  ,LAN_IFC_SUP},
-//     { CMD_GET_LAN_CONFIGURATION_PARAMETERS,     PRIV_OPERATOR,  GET_LAN_CONFIGURATION_PARAMETERS,   sizeof (GetLanConfigReq_T), 0xAAAA  ,LAN_IFC_SUP},
-//     { CMD_SUSPEND_BMC_ARPS,                    	PRIV_ADMIN,     SUSPEND_BMC_ARPS,                   sizeof (SuspendBMCArpsReq_T),   0xAAAA ,LAN_IFC_SUP},
-//     { CMD_GET_IP_UDP_RMCP_STATISTICS,    		PRIV_ADMIN,     GET_IP_UDP_RMCP_STATISTICS,   0xFF,   0xAAAA  ,LAN_IFC_SUP},
+ /*****************************************************************
+ *
+ * DeviceConfig.c
+ * Device Configuration Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
 
-//     /*--------------------- Serial/Modem Device Commands ---------------------------------*/
-//     { CMD_SET_SERIAL_MODEM_CONFIG,  PRIV_ADMIN,     SET_SERIAL_MODEM_CONFIGURATION,  0xFF,  0xAAAA  ,SERIAL_IFC_SUP},
-//     { CMD_GET_SERIAL_MODEM_CONFIG,  PRIV_OPERATOR,  GET_SERIAL_MODEM_CONFIGURATION,  sizeof (GetSerialModemConfigReq_T),    0xAAAA ,SERIAL_IFC_SUP},
-//     { CMD_SET_SERIAL_MODEM_MUX,     PRIV_OPERATOR,  SET_SERIAL_MODEM_MUX,            sizeof (SetMuxReq_T),  0xAAAA  ,SERIAL_IFC_SUP},
-//     { CMD_SERIAL_MODEM_CONNECTION_ACTIVITY,     PRIV_OPERATOR,  SERIAL_MODEM_CONNECTION_ACTIVITY,sizeof (SerialModemActivePingReq_T),   0xAAAA ,SERIAL_IFC_SUP},
-//     { CMD_CALLBACK,                 PRIV_ADMIN,     CALLBACK,                        sizeof (CallbackReq_T) ,   0xAAAA  ,SERIAL_IFC_SUP},
-//     { CMD_SET_USER_CALLBACK_OPTION, PRIV_ADMIN,     SET_USER_CALLBACK_OPTIONS,       sizeof (SetUserCallbackReq_T), 0xAAAA  ,SERIAL_IFC_SUP},
-//     { CMD_GET_USER_CALLBACK_OPTION, PRIV_USER,      GET_USER_CALLBACK_OPTIONS,       sizeof (GetUserCallbackReq_T), 0xAAAA  ,SERIAL_IFC_SUP},
-//     { CMD_GET_TAP_RES_CODES,        PRIV_USER,      GET_TAP_RESPONSE,                sizeof (GetTAPResCodeReq_T),   0xAAAA  ,SERIAL_IFC_SUP},
+#include "MsgHndlr.h"
+#include "DeviceConfig.h"
+//#include "IPMI_SerialModem.h"
+#include "com_IPMI_LANConfig.h"
+#include "com_IPMI_DeviceConfig.h"
+//#include "IPMI_SOLConfig.h"
+//#include "SerialModem.h"
+#include "LANConfig.h"
+//#include "SOLConfig.h"
+#include "Support.h"
 
-//     /*------------------------- Serial Over LAN Commands ---------------------------------*/
-//     { CMD_GET_SOL_CONFIGURATION,    PRIV_USER,      GET_SOL_CONFIGURATION,          sizeof (GetSOLConfigReq_T), 0xAAAA  ,SOL_IFC_SUP},
-//     { CMD_SET_SOL_CONFIGURATION,    PRIV_ADMIN,     SET_SOL_CONFIGURATION,          0xFF,       0xAAAA  ,SOL_IFC_SUP},
+/**
+ * @var g_Config_CmdHndlr
+ * @brief Transport Configuration Commands Map
+**/
+const CmdHndlrMap_T g_Config_CmdHndlr [] =
+{
+    /*------------------------- IPM Device Commands --------------------------------------*/
+    { CMD_SET_LAN_CONFIGURATION_PARAMETERS,     PRIV_ADMIN,     SET_LAN_CONFIGURATION_PARAMETERS,   0xFF,   0xAAAA  ,LAN_IFC_SUP},
+//    { CMD_GET_LAN_CONFIGURATION_PARAMETERS,     PRIV_OPERATOR,  GET_LAN_CONFIGURATION_PARAMETERS,   sizeof (GetLanConfigReq_T), 0xAAAA  ,LAN_IFC_SUP},
+//    { CMD_SUSPEND_BMC_ARPS,                    	PRIV_ADMIN,     SUSPEND_BMC_ARPS,                   sizeof (SuspendBMCArpsReq_T),   0xAAAA ,LAN_IFC_SUP},
+//    { CMD_GET_IP_UDP_RMCP_STATISTICS,    		PRIV_ADMIN,     GET_IP_UDP_RMCP_STATISTICS,   0xFF,   0xAAAA  ,LAN_IFC_SUP},
 
-//     { 0x00,                         0x00,           0x00,                            0x00,  0x0000    ,0x0000}
-// };
+    // /*--------------------- Serial/Modem Device Commands ---------------------------------*/
+    // { CMD_SET_SERIAL_MODEM_CONFIG,  PRIV_ADMIN,     SET_SERIAL_MODEM_CONFIGURATION,  0xFF,  0xAAAA  ,SERIAL_IFC_SUP},
+    // { CMD_GET_SERIAL_MODEM_CONFIG,  PRIV_OPERATOR,  GET_SERIAL_MODEM_CONFIGURATION,  sizeof (GetSerialModemConfigReq_T),    0xAAAA ,SERIAL_IFC_SUP},
+    // { CMD_SET_SERIAL_MODEM_MUX,     PRIV_OPERATOR,  SET_SERIAL_MODEM_MUX,            sizeof (SetMuxReq_T),  0xAAAA  ,SERIAL_IFC_SUP},
+    // { CMD_SERIAL_MODEM_CONNECTION_ACTIVITY,     PRIV_OPERATOR,  SERIAL_MODEM_CONNECTION_ACTIVITY,sizeof (SerialModemActivePingReq_T),   0xAAAA ,SERIAL_IFC_SUP},
+    // { CMD_CALLBACK,                 PRIV_ADMIN,     CALLBACK,                        sizeof (CallbackReq_T) ,   0xAAAA  ,SERIAL_IFC_SUP},
+    // { CMD_SET_USER_CALLBACK_OPTION, PRIV_ADMIN,     SET_USER_CALLBACK_OPTIONS,       sizeof (SetUserCallbackReq_T), 0xAAAA  ,SERIAL_IFC_SUP},
+    // { CMD_GET_USER_CALLBACK_OPTION, PRIV_USER,      GET_USER_CALLBACK_OPTIONS,       sizeof (GetUserCallbackReq_T), 0xAAAA  ,SERIAL_IFC_SUP},
+    // { CMD_GET_TAP_RES_CODES,        PRIV_USER,      GET_TAP_RESPONSE,                sizeof (GetTAPResCodeReq_T),   0xAAAA  ,SERIAL_IFC_SUP},
+
+    // /*------------------------- Serial Over LAN Commands ---------------------------------*/
+    // { CMD_GET_SOL_CONFIGURATION,    PRIV_USER,      GET_SOL_CONFIGURATION,          sizeof (GetSOLConfigReq_T), 0xAAAA  ,SOL_IFC_SUP},
+    // { CMD_SET_SOL_CONFIGURATION,    PRIV_ADMIN,     SET_SOL_CONFIGURATION,          0xFF,       0xAAAA  ,SOL_IFC_SUP},
+
+    { 0x00,                         0x00,           0x00,                            0x00,  0x0000    ,0x0000}
+};
 

+ 35 - 0
app/bmc/msghndlr/Transport/DeviceConfig.h

@@ -0,0 +1,35 @@
+/*****************************************************************
+ *
+ * DeviceConfig.h
+ * Device Configuration Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#ifndef DEVICE_CONFIG_H
+#define DEVICE_CONFIG_H
+
+#include <stdio.h>
+#include "MsgHndlr.h"
+#include "com_IPMI_DeviceConfig.h"
+
+/**
+ * @var g_Config_CmdHndlr
+ * @brief Transport Configuration Commands Map.
+**/
+extern const CmdHndlrMap_T  g_Config_CmdHndlr [];
+
+
+/**
+ * @defgroup devcfg Device Configuration Module
+ * IPMI Device Configuration command interface. This module
+ * implements configuration and access commands for transport modules
+ * such as LAN, Serial/Modem, Serial Over LAN.
+ * @{
+**/
+/** @} */
+
+#endif  /* DEVICE_CONFIG_H */

ファイルの差分が大きいため隠しています
+ 989 - 1686
app/bmc/msghndlr/Transport/LANConfig.c


+ 63 - 0
app/bmc/msghndlr/Transport/LANConfig.h

@@ -0,0 +1,63 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *****************************************************************
+ *
+ * lanconfig.h
+ * Lan configuration command handler
+ *
+ * Author: Bakka Ravinder Reddy <bakkar@ami.com>
+ * 
+ *****************************************************************/
+#ifndef LANCONFIG_H
+#define LANCONFIG_H
+
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+#include "com_IPMI_LANConfig.h"
+
+
+
+
+
+/**
+ * @defgroup lcc LAN Configuration Command handlers
+ * @ingroup devcfg
+ * IPMI LAN interface configuration command handlers.
+ * Get/Set commands allow retrieval and updation of various LAN parameters.
+ * @{
+**/
+ int SetLanConfigParam  (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes );
+// int GetLanConfigParam  (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes );
+// int SuspendBMCArps (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes );
+// int GetIPUDPRMCPStats (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes );
+
+/** @} */
+
+/**
+ * @brief Initialize LAN Configuration Data.
+**/
+// void InitLanConfigData(void);
+
+/**
+ * @brief Update ARP Status information.
+ * @param EthIndex - Ethernet index
+ * @param IsTimerRunning - indicates timer state.
+**/
+// uint8_t UpdateArpStatus   (uint8_t EthIndex, BOOL IsTimerRunning, int BMCInst);
+
+/**
+ * @brief Gratuitous ARP generation task. 
+**/
+// void* GratuitousARPTask (uint8_t *Addr);
+
+#endif /* LANCONFIG_H */

+ 780 - 0
app/bmc/msghndlr/Transport/nwcfg.h

@@ -0,0 +1,780 @@
+/***************************************************************
+**                                                            **
+**    (C)Copyright 2006-2009, American Megatrends Inc.        **
+**                                                            **
+**            All Rights Reserved.                            **
+**                                                            **
+**        5555 Oakbrook Pkwy Suite 200, Norcross,             **
+**                                                            **
+**        Georgia - 30093, USA. Phone-(770)-246-8600.         **
+**                                                            **
+****************************************************************
+* Filename: nwcfg.h
+*
+* Description: Contains code for the basic network library APIs.
+*
+****************************************************************/
+
+#ifndef _NWCFG_H
+#define _NWCFG_H
+
+
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+//#include <Types.h>
+//#include "hostname.h"
+#include <com_IPMIDefs.h>
+#include <com_BmcType.h>
+
+
+// /* External dependencies */
+// #define	PROC_NET_ROUTE_FILE	"/proc/net/route"
+// /* ipv6 */
+// #define	PROC_NET_IPV6ROUTE_FILE "/proc/net/ipv6_route"
+// #define DHCPD_PID_FILE		"/var/run/udhcpc.eth0.pid"
+// #define DHCP6C_PID_FILE		"/var/run/dhcp6c.pid"
+
+// #define DHCPD_CONFIG_FILE   "/conf/dhcpc-config"
+// #define DHCPD_CONFIG_FILE_TEMP      "/var/dhcp-config.tmp"
+// #define RESOLV_CONF_FILE    "/conf/resolv.conf"
+// #define RESOLV_CONF_DISABLED_FILE    "/conf/resolv_disabled.conf"
+// #define RESOLV_CONF_FILE_TEMP    "/var/resolv.conf.tmp"
+// #define DNS_CONFIG_FILE   "/conf/dns.conf"
+// #define DNS_CONFIG_FILE_TEMP      "/var/dns.conf.tmp"
+// #define IFUP_BIN_PATH       "/sbin/ifup"
+// #define IFDOWN_BIN_PATH     "/sbin/ifdown"
+#define ZERO_IP         "0.0.0.0"
+#define DEFAULT_GW_STR      "0.0.0.0"
+/* /etc/network/interfaces file defines */
+// #define NETWORK_IF_FILE		"/etc/network/interfaces"
+// #define NETWORK_IF_FILE_TMP         "/conf/interfaces.tmp"
+// #define NETWORK_DNS_TMP             "/conf/dns.tmp"
+// #define NETWORK_IP_SRC_FILE	"/conf/ipaddrsource"
+#define AUTO_LOCAL_STR		"auto lo\n"
+#define AUTO_LOCAL_LOOPBACK_STR	"iface lo inet loopback\n"
+#define IF_STATIC_IP_STR	"address"
+#define IF_STATIC_MASK_STR	"netmask"
+#define IF_STATIC_BCAST_STR	"broadcast"
+#define IF_STATIC_GW_STR	"gateway"
+#define IF_STATIC_MTU_STRING "mtu"
+#define DEFAULT_GW_FLAGS	0x0003
+// #define DEV_FILE	"/proc/net/dev"
+
+// #define VLAN_ID_SETTING_STR "vlanid"
+// #define VLAN_INTERFACES_FILE    "/conf/vlaninterfaces"
+// #define VLAN_PRIORITY_SETTING_STR     "vlanpriority"
+// #define VLAN_INDEX_STR       "index"
+// #define VLANSETTING_CONF_FILE "/conf/vlansetting.conf"
+
+// #define VLAN_NETWORK_DECONFIG_FILE    "/etc/init.d/vlannetworking stop"
+// #define VLAN_NETWORK_CONFIG_FILE    "/etc/init.d/vlannetworking start"
+// #define VLAN_ONLY_IFDOWN    "/etc/init.d/vlannetworking downvlan"
+// #define VLAN_PROC_SYS_RAC_NCSI_ENABLE_LAN    "echo 1 > /proc/sys/ractrends/ncsi/Enable"
+
+// #define VLAN_NETWORK_IP_CONFIGFILE    "/etc/init.d/vlannetworking enableip"
+// #define IF_STATIC_ADDR_STR " pre-up ip addr add"
+
+// /*Bond*/
+// #define BONDING_CONF_FILE   "/conf/bond.conf"
+// #define BONDING_SYSTEM_FILE "/sys/class/net"
+#define IFACE_ENABLED     0x01
+#define IFACE_DISABLED      0x00
+#define BOND_ROUND_ROBIN    0x00
+#define BOND_ACTIVE_BACKUP  0x01
+#define MAX_BOND_MODE           0x06
+#define MAX_BOND                0x03
+#define ETH_IFACE_TYPE      0x01
+#define BOND_IFACE_TYPE     0x02
+#define BOND_MAX_SLAVE      8
+
+#define MAX_CHANNEL    0x04
+#define MAX_ETH   5
+
+
+///* IPv6 */
+//#define KERNEL_IPV6_FILE "/proc/net/if_inet6"
+
+#define MAX_MAC_LEN 	64
+#define MAC_ADDR_LEN	6
+#define IP_ADDR_LEN	4
+#define IP6_ADDR_LEN	16
+#define MAX_STR_LENGTH 	128
+#define ROUTE_GW_LENGTH 100
+
+#define MAX_IPV6ADDRS  16
+#define DOMAIN_DHCP_LEN  7
+#define LOOPBACK_ADDR_LEN 9
+#define STR1_LEN 1
+#define STR2_LEN 2
+#define STR3_LEN 3
+#define STR4_LEN 4
+#define STR5_LEN 5
+
+/* DNS */
+#define MAX_HOST_NAME_STRING_SIZE       64
+#define MAX_DOMAIN_NAME_STRING_SIZE     256
+#define HOSTNAME_SETTING_MANUAL			0
+#define HOSTNAME_SETTING_AUTO			1
+#define ONELINE_LEN                     300
+#define DNS_SERVERIP_LEN                26
+
+#define REG_BMC_ENABLE                  0x01	//0th bit enable of BMC register
+#define REG_BMC_TSIG                    0x02	//1st bit enable of BMC register
+#define REG_BMC_FQDN                    0x10	//DHCP Option 81
+#define REG_BMC_HOSTNAME                0x20	//DHCP Option 12
+
+#define REG_BMC_RESERVED                0xCE	//Binary value 1100 1110
+#define REG_BMC_RESERVED_TSIG           0xFD	//Binary value 1111 1101
+
+/* TSIG Configuration */
+// #define CONF_LOCATION				"/conf/"
+// #define TEMP_LOCATION				"/tmp/"
+// #define TSIG_PRIVATE_FILE			"tsig.private"
+// #define CONF_TSIG_PRIVATE_FILE		CONF_LOCATION TSIG_PRIVATE_FILE
+// #define TEMP_TSIG_PRIVATE_FILE		TEMP_LOCATION TSIG_PRIVATE_FILE
+// #define MAX_TSIG_PRIVKEY_SIZE		(8 * 1024)
+// #define TSIG_ALG_TYPE_HMAC_MD5		"Algorithm: 157 (HMAC_MD5)\n"
+
+/* Type of network configuration */
+#define CFGMETHOD_STATIC    1
+#define CFGMETHOD_DHCP      2
+#define CFGMETHOD_BIOS      3
+#define CFGMETHOD_OTHER     4
+
+#define NWCFGTYPE_STATIC        0x1
+#define NWCFGTYPE_DHCP          0x2
+#define NWCFGTYPE_DHCPFIRST     0x4
+
+/*Interface enable state*/
+#define NW_INTERFACE_ENABLE     0x1
+#define NW_INTERFACE_DISABLE    0x2
+#define NW_INTERFACE_UNKNOWN    0x3
+
+#define NW_AUTO_NEG_ON  0x1
+#define NW_AUTO_NEG_OFF 0x2
+
+#define NW_DUPLEX_FULL 0x1
+#define NW_DUPLEX_HALF 0x2
+
+/*
+ * ETHSET FLAG: See nwSetNWExtEthCfg API
+ */
+#define NWEXT_ETHCFG_LAMAC      0x1
+#define NWEXT_ETHCFG_BURNEDMAC  0x2
+#define NWEXT_ETHCFG_SPEED      0x4
+#define NWEXT_ETHCFG_DUPLEX     0x8
+#define NWEXT_ETHCFG_AUTONEG    0x10
+#define NWEXT_ETHCFG_MTU        0x20
+#define NWEXT_ETHCFG_WOL        0x40
+#define NWEXT_ETHCFG_ALL (NWEXT_ETHCFG_LAMAC \
+                            | NWEXT_ETHCFG_BURNEDMAC \
+                            | NWEXT_ETHCFG_SPEED \
+                            | NWEXT_ETHCFG_DUPLEX \
+                            | NWEXT_ETHCFG_AUTONEG \
+                            | NWEXT_ETHCFG_MTU \
+                            | NWEXT_ETHCFG_WOL)
+
+/*
+ * NWSET FLAG: See nwSetNWExtIPCfg API
+ */
+#define NWEXT_IPCFG_INTFSTATE   0x1
+#define NWEXT_IPCFG_CFGMETHOD   0x2
+#define NWEXT_IPCFG_IP          0x4
+#define NWEXT_IPCFG_MASK        0x8
+#define NWEXT_IPCFG_GW          0x10
+#define NWEXT_IPCFG_FBIP        0x20
+#define NWEXT_IPCFG_FBMASK      0x40
+#define NWEXT_IPCFG_FBGW        0x80
+#define NWEXT_IPCFG_ALL (NWEXT_IPCFG_INTFSTATE \
+                         | NWEXT_IPCFG_CFGMETHOD \
+                         | NWEXT_IPCFG_FBIP \
+                         | NWEXT_IPCFG_FBMASK \
+                         | NWEXT_IPCFG_FBGW \
+                         | NWEXT_IPCFG_IP \
+                         | NWEXT_IPCFG_MASK \
+                         | NWEXT_IPCFG_GW)
+
+#define MAX_RESTART_SERVICE     4
+
+#define MAX_SERVICE    5
+
+/*Used to check the flag status*/
+#define CHECK_FLAG(in,level) ((in&level) == level)
+
+/*Used to set flag value*/
+#define SET_FLAG(out,level) (out|=level)
+
+/* Enable or disable Auto-Negotiation */
+#define AUTONEG_DISABLE		0x00
+#define AUTONEG_ENABLE		0x01
+
+/* Network Link modes */
+#define PHY_SPEED_10		10
+#define PHY_SPEED_100		100
+#define PHY_SPEED_1000		1000
+
+#define PHY_DUPLEX_HALF	0x0
+#define PHY_DUPLEX_FULL	0x1
+
+#define PHY_SPEED_AN_MASK	0x8000    /*Auto-Negotiation Mask for Speed*/
+#define PHY_DUPLEX_AN_MASK	0x4000    /*Auto-Negotiation Mask for Duplex*/
+
+
+/* MII registers for PHY */
+#define MII_BMCR            0x00        /* Basic mode control register */
+#define MII_BMSR            0x01        /* Basic mode status register  */
+#define MII_PHY_ID1         0x02        /* PHY identifier 1            */
+#define MII_PHY_ID2         0x03        /* PHY identifier 2            */
+#define MII_ADVERTISE       0x04        /* Advertisement control reg   */
+#define MII_LPA             0x05        /* Link partner ability reg    */
+#define MII_EXPANSION       0x06        /* Expansion register          */
+#define MII_CTRL1000        0x09        /* 1000BASE-T control          */
+#define MII_STAT1000        0x0a        /* 1000BASE-T status           */
+
+/* Mask for BMCR Register settings for Speed/Duplex */
+#define PHY_BMCR_10_FD    0x0100
+#define PHY_BMCR_10_HD    0x0000
+#define PHY_BMCR_100_FD   0x2100
+#define PHY_BMCR_100_HD   0x2000
+#define PHY_BMCR_1000_FD  0x1140
+#define PHY_BMCR_AUTO_NEG 0x3000
+
+/* Mask for ADVERTISE Register settings for Speed/Duplex */
+#define PHY_ADV_AUTO_NEG  0x05e1
+#define PHY_ADV_1000_FD   0x0401
+
+/* Mask for Gigabit Control Register settings for Speed/Duplex */
+#define PHY_GBCR_AUTO_NEG 0x0300
+
+
+#pragma pack (1)
+typedef struct
+{
+    uint8_t AutoNegotiationEnable;
+    uint16_t Speed;
+    uint8_t Duplex;
+    uint8_t Interface;
+    uint8_t CapabilitiesSupported;
+}   PHYConfig_T;
+
+typedef struct
+{
+    uint8_t   Enable;                                                             /*Enable/Disable*/
+    uint8_t   BondIndex;                                                      /*Index value of Bond Interface*/
+    uint8_t   BondMode;                                                       /*Bond Mode*/
+    uint16_t   MiiInterval;                                                     /*MII Interval*/
+    uint8_t   Slaves;                                                           /*Each bit represents the interface Index value i.e 0-7*/
+    uint8_t   AutoConf;
+}  BondIface;
+typedef struct{
+	unsigned char CfgMethod; /* This field can either be NWCFGTYPE_DHCP or NWCFGTYPE_STATIC */
+	unsigned char MAC[6];
+	unsigned char Local_MAC[6];
+	unsigned char IPAddr[4];
+	unsigned char Broadcast[4];
+	unsigned char Mask[4];
+	unsigned char Gateway[4];
+	unsigned char  BackupGateway[4];
+	  /* If interface is enabled, value is
+     * NW_INTERFACE_ENABLE otherwise NW_INTERFACE_DISABLE
+     */
+    unsigned char enable;
+	unsigned char IFName[10];
+	unsigned short VLANID;
+	unsigned char vlanpriority;
+        unsigned char Master;
+        unsigned char Slave;
+        unsigned char BondIndex;
+}   NWCFG_STRUCT;
+/*ipv6*/
+typedef struct{
+	unsigned char enable;
+       unsigned char MAC[6];
+	unsigned char CfgMethod; /* This field can either be NWCFGTYPE_DHCP or NWCFGTYPE_STATIC */
+	unsigned char LinkIPAddr[16];
+	unsigned char LinkPrefix;
+	unsigned char SiteIPAddr[16];
+	unsigned char SitePrefix;
+	unsigned char GlobalIPAddr[MAX_IPV6ADDRS][16];   //anyCast Globel address    //UniCast Globel address
+	unsigned char GlobalPrefix[MAX_IPV6ADDRS];
+	unsigned char Gateway[16];
+       unsigned char IFName[10];
+}   NWCFG6_STRUCT;
+
+typedef struct {
+        unsigned char Enable;
+        unsigned short MiiInterval;
+        unsigned char BondMode;
+        unsigned char Slave;
+}  BondConf;
+
+typedef struct {
+    unsigned char Upslave;
+}  ActiveConf;
+
+typedef struct
+{
+    int8_t Ifcname[16];
+    uint8_t Index;
+    uint8_t Enabled;
+}  IfcName_T;
+
+typedef struct{
+	unsigned short Family;
+		NWCFG_STRUCT 	IPv4;
+		NWCFG6_STRUCT	IPv6;
+}   ALL_NWCFG_STRUCT;
+
+
+typedef struct{
+	NWCFG_STRUCT NwInfo[10];
+	int IFCount;
+}   NWCFGS;
+
+typedef struct
+{
+    /* This field can either be NW_DUPLEX_FULL or NW_DUPLEX_HALF */
+    unsigned long speed;
+
+    /* This field can either be NW_DUPLEX_FULL or NW_DUPLEX_HALF */
+    unsigned int duplex;
+
+    /* This field can either be  NW_AUTO_NEG_ON or NW_AUTO_NEG_OFF,
+     * Auto negotiation is applicable for both speed & duplex.
+     */
+    unsigned int autoneg;
+
+    /* This field features the link modes that are supported by the interface */
+    unsigned char supported; 
+
+    /*Max transmission unit*/
+    unsigned long maxtxpkt;
+
+    unsigned long wolsupported;
+    unsigned long wolopts;
+
+}   ETHCFG_STRUCT;
+
+typedef struct{
+        ETHCFG_STRUCT EthInfo[10];
+}   ETHCFGS;
+
+
+typedef struct{
+
+    /* Name of the interface, example: eth0, eth1, ethernet,...*/
+    char IFName[10];
+
+    /*
+     * This field can either be NWCFGTYPE_DHCP or
+     * NWCFGTYPE_STATIC or NWCFGTYPE_DHCPFIRST
+     */
+    unsigned char CfgMethod;
+
+    /*
+     *  If interface is enabled, value is NW_INTERFACE_ENABLE
+     *  otherwise NW_INTERFACE_DISABLE
+     */
+    unsigned char Enable;
+
+    /*
+     * Current IP Origin NWCFGTYPE_DHCP or NWCFGTYPE_STATIC
+     */
+    unsigned char IPOrigin;
+
+    /*
+     * IP assigned: If IPOrgin is DHCP, then this is DHCP IP,
+     * if the IPOrigin is Static, then this is Static IP address
+     */
+    unsigned char IPAddr[4];
+    unsigned char Mask[4];
+    unsigned char Gateway[4];
+
+    /*
+     *  Manually configured Fall back (FB) IP
+     */
+    unsigned char FB_IPAddr[4];
+    unsigned char FB_Mask[4];
+    unsigned char FB_Gateway[4];
+
+}   NWEXT_IPCFG;
+
+
+typedef struct
+{
+    /*Burned-in MAC address*/
+    unsigned char BurnedMAC[6];
+
+    /* Locally admin-MAC: Setting Local MAC to other than 00:00:00:00:00:00
+     * makes it as current MAC. If a platform does not support. If this is
+     * non-zero then this is current MAC while getting
+     */
+    unsigned char Local_MAC[6];
+
+}  NWEXT_MACCFG;
+
+
+typedef struct
+{
+
+    /* MAC Configuration */
+    NWEXT_MACCFG mac_cfg;
+
+    /* Ethernet Configuration */
+    ETHCFG_STRUCT eth_cfg;
+
+}   NWEXT_ETHCFG;
+
+typedef struct
+{
+    unsigned char DNSDhcpEnable;                             /*Specifies that the DNS server IP addresses should be assigned from the DHCP server*/
+    unsigned char DNSServerEthIndex;                         /*Specifies that from which DHCP server the IP addresses should be assigned */
+    unsigned char DNSServer1[IP_ADDR_LEN];                   /*Specifies the IP address for DNS server 1*/
+    unsigned char DNSServer2[IP_ADDR_LEN];                   /*Specifies the IP address for DNS server 2*/
+    unsigned char v4v6;
+    unsigned char RegisterBMCFQDN[MAX_CHANNEL];  	     /*Register the BMC host name using FQDN method */
+    unsigned char DNSRegisterBMC[MAX_CHANNEL];               /*Enable registering the BMC host name on the DNS server*/
+    unsigned char DNSBMCHostSetting;                         /*Specifies host name is Automatic or Manual */
+    unsigned char DNSBMCHostNameLen;
+    unsigned char DNSBMCHostName[MAX_HOST_NAME_STRING_SIZE];          /*Specifies the DNS BMC host name*/
+    unsigned char DNSDomainNameDhcpEnable;                   /*Specifies that the DNS domain name should be assigned from the DHCP server*/
+    unsigned char DNSDomainNameEthIndex;                     /*Specifies that from which DHCP server the DNS domain name should be assigned */    
+    unsigned char DNSDomainNameLen;
+    unsigned char DNSDomainName[MAX_DOMAIN_NAME_STRING_SIZE];/*The DNS domain name string*/
+
+}    DNS_CONFIG;
+
+#define DNSCFG_MAX_DOMAIN_NAME_LEN 256 //with null
+#define DNSCFG_MAX_RAC_NAME_LEN    64
+
+/*DNS-Manual enable state*/
+#define DNS_MANUAL_ENABLE   0x1
+#define DNS_MANUAL_DISABLE  0x2
+
+typedef struct
+{
+    unsigned char dnsEnable;
+    unsigned char manualDNSDomain1Length;
+    char manualDNSDomainName1[DNSCFG_MAX_DOMAIN_NAME_LEN];
+    unsigned char manualDNSDomain2Length;
+    char manualDNSDomainName2[DNSCFG_MAX_DOMAIN_NAME_LEN];
+    struct in_addr manualDNSServer1;
+    struct in_addr manualDNSServer2;
+    struct in_addr manualDNSServer3;
+
+}   MANUAL_DNS_CONFIG;
+
+
+// /*********************************/
+// /* DNS Configuration structures */
+// /*********************************/
+// #define DOMAIN_V4 1
+// #define DOMAIN_V6 2
+
+// #define CONFDNSCONF "/conf/dns.conf"
+// #define CONFDNSCONF_TMP "/conf/dns.conf.tmp"
+
+// typedef struct
+// {
+//     uint8_t HostSetting;                         /*Specifies host name is Automatic or Manual */
+//     uint8_t HostNameLen;
+//     uint8_t HostName[MAX_HOSTNAME_LEN];          Specifies the DNS BMC host name
+    
+// }  HOSTNAMECONF;
+
+// typedef struct
+// {
+//     uint8_t    dhcpEnable;
+//     uint8_t    EthIndex;
+//     uint8_t    v4v6;
+//     uint8_t    domainname[DNSCFG_MAX_DOMAIN_NAME_LEN];
+//     uint8_t    domainnamelen;
+// }  DOMAINCONF;
+
+// typedef struct
+// {
+//     uint8_t   DNSIP1[IP6_ADDR_LEN];
+//     uint8_t   DNSIP2[IP6_ADDR_LEN];
+//     uint8_t   DNSIP3[IP6_ADDR_LEN];
+//     uint8_t   DNSEnable;
+//     uint8_t   DNSDHCP;
+//     uint8_t   DNSIndex;
+//     uint8_t   IPPriority;
+// }  DNSCONF;
+
+
+
+/* Define the network interface */
+typedef enum
+{
+    PENDING=1, // Interface having configured/pending settings
+    ACTIVE     // Interface having current/active settings
+}NW_INTERFACE;
+
+typedef struct
+{
+	uint8_t param;
+	uint8_t NwRestartNeeded; 	
+}  MONSETLANPARAM_STRUCT;
+
+
+// typedef struct
+// {
+// 	NWCFG_STRUCT cfgIPv4[MAX_ETH];
+// 	NWCFG6_STRUCT cfgIPv6[MAX_ETH];
+// 	BondIface BondConfig;
+// 	PHYConfig_T   PHYConfig[MAX_ETH];
+// 	unsigned short mtu_size[MAX_ETH];
+// 	HOSTNAMECONF HostnameConfig;
+// 	DOMAINCONF DomainConfig;
+// 	uint8_t regBMC_FQDN[MAX_CHANNEL];
+// 	uint8_t TypeOfService[MAX_ETH];
+// 	DNSCONF DnsIPConfig;
+// }  DELAYEDLANRESTART_NWDATA;
+
+
+#pragma pack ()
+
+// /* Functions to read/write current network status */
+// int nwReadNWCfgs(NWCFGS *cfg, ETHCFGS *ethcfg);
+// int IsLinkModeSupported(ETHCFG_STRUCT *ethcfg,uint16_t speed,uint8_t duplex);
+// int nwGetEthInformation(ETHCFG_STRUCT *ethcfg, char * IFName);
+// int nwSetEthInformation(unsigned long speed, unsigned int duplex, char * IFName);
+// int nwWriteNWCfgNoUpDown(NWCFG_STRUCT *cfg);
+// int nwSetEthMTUSize(int mtu, char * IFName);
+
+// int nwSetBkupGWyAddr(unsigned char *ip,uint8_t EthIndex);
+// int nwGetBkupGWyAddr(unsigned char *ip,uint8_t EthIndex);
+// /* One should pass the buffer of size MAX_MAC_LEN to the following function */
+// int nwGetMACAddr(char *MAC);
+// int nwSetMACAddr(char *MAC, int Index);
+// int nwSetGateway(uint8_t* GwIP,uint8_t EthIndex);
+// int nwDelExistingGateway(uint8_t EthIndex);
+
+// /* Functions to set/get MDIO PHY registers */
+// /* These can be used by OEMs to monitor/control the speed/duplex of the PHY */
+// int nwGetPHYRegister(char regNo, char *IfcName);
+// int nwSetPHYRegister(unsigned short regValue, char regNo, char *IfcName);
+
+// /* Function to generate an IPv6 address based on EUI-64 algo */
+// int nwFormIPv6Addr_EUI64(uint8_t *IPv6Addr, uint8_t EthIndex, int GlobalIPv6);
+
+// int nwGetNWInformations(NWCFG_STRUCT *cfg,char *IFName);
+
+// int nwMakeIFDown(uint8_t EthIndex);
+// int nwMakeIFUp(uint8_t  EthIndex);
+// extern void GetNwCfgInfo(void);
+// extern int GetNoofInterface(void);
+
+// /* Extended API for network*/
+// int GetHostEthbyIPAddr(char *IPAddr);
+// int GetHostEthByIPv6Addr(char *IPAddr);
+// int GetIfcNameByIndex(int Index, char * IfcName);
+// int nwGetSrcMacAddr(uint8_t* IpAddr,uint8_t EthIndex,uint8_t *MacAddr);
+// int nwGetSrcCacheMacAddr(uint8_t* IpAddr, uint8_t EthIndex, uint8_t *MacAddr);
+// int nwGetSrcMacAddr_IPV6(uint8_t* IpAddr,uint8_t *MacAddr);
+// int nwGetNWExtEthCfg(NWEXT_ETHCFG *cfg);
+// int nwGetNWInterfaceStatus(void);
+// int nwSetNWExtEthCfg(NWEXT_ETHCFG *cfg, int nwSetFlag);
+// int nwSetNWExtIPCfg (NWEXT_IPCFG *cfg, int nwSetFlag,int global_ipv6);
+// int GetNwLinkStatus(int fd,char *ifname);
+// int GetNwLinkType_mii(char *ifname);
+
+// /**
+// *@fn nwUpdateVLANInterfacesFile
+// *@brief This function is invoked to update vlan interfaces file
+// */
+// int nwUpdateVLANInterfacesFile(void);
+
+// /**
+// *@fn ReadVLANFile
+// *@brief This function is invoked to read the vlan configuration files
+// *@param SettingStr - Pointer to setting name that we want to read from vlan configurations file
+// *@param desArr - pointer to an array where the reading has to be stored
+// */
+// int ReadVLANFile(char *SettingStr, uint16_t *desArr);
+
+// /**
+// *@fn WriteVLANFile
+// *@brief This function is invoked to write all the vlan configuration files
+// *@param SettingStr - Pointer to setting name that we want to write into vlan configurations file
+// *@param desArr - pointer to an array where the reading has to be stored
+// *@param EthIndex - char value to Ethernet index
+// *@param val - short int to the value that has to be written
+// */
+// int WriteVLANFile(char *SettingStr, uint16_t *desArr, uint8_t EthIndex, uint16_t val);
+
+// /*ipv6*/
+// void ConvertIP6numToStr(unsigned char *var, unsigned int len,unsigned char *string) ;
+// int nwReadNWCfg_IPv6(NWCFG6_STRUCT *cfg,uint8_t EthIndex);
+// int GetDefaultGateway_ipv6(unsigned char *gw,uint8_t *Interface);
+// int nwGetResolvConf_v4_v6(char* DNS1,char*DNS2,char *DNS3, uint8_t DNSIPPriority,char* domain,unsigned char* domainnamelen);
+
+// /**
+// *@fn nwReadNWCfg_v4_v6
+// *@brief This function is invoked to Get the current network status of both IPv4 and IPv6 networks.
+// *@		If there is no need of IPv6 data means, then just pass NULL to IPv6 pointer.
+// *@param cfg - Pointer to Structure used to get IPv4 network configurations.
+// *@param cfg6 - Pointer to Structure used to get IPv6 network configurations.
+// *@param EthIndex - pointer to char used to store Interface Index value.
+// *@return Returns 0 on success and -1 on fails
+// */
+// int nwReadNWCfg_v4_v6(NWCFG_STRUCT *cfg, NWCFG6_STRUCT *cfg6, uint8_t EthIndex,int global_ipv6);
+
+// /**
+// *@fn nwWriteNWCfg_ipv4_v6
+// *@brief This function is invoked to set both IPv4 and IPv6 network configurations.
+// *@		If there is no need to write IPv6 data means, then just pass NULL to IPv6 pointer.
+// *@param cfg - Pointer to Structure used to set IPv4 network configurations
+// *@param cfg6 - Pointer to Structure used to set IPv6 network configurations
+// *@param EthIndex - pointer to char used to store Interface Index value.
+// *@return Returns 0 on success and -1 on fails
+// */
+// int nwWriteNWCfg_ipv4_v6(NWCFG_STRUCT *cfg, NWCFG6_STRUCT *cfg6, uint8_t EthIndex);
+
+
+//  * @fn nwConfigureBonding
+//  * @brief This function will Enable/Disable the bonding support
+//  * @param BondCfg [in] Bonding configuration table
+//  * @param BondIndex [in] Index value of Bond interface to be configured
+//  * @return 0 on success, -1 on failure
+ 
+// int nwConfigureBonding(BondIface *BondCfg,uint8_t EthIndex,int timeoutd_sess_timeout,int global_ipv6);
+
+// /*
+//  * @fn nwGetBondConf
+//  * @brief This function will Get the bonding Configuration of Specified index
+//  * @param BondCfg [out] Bonding configuration table
+//  * @param BondIndex [in] Index value of Bond interface 
+//  * @return 0 on success, -1 on failure
+//  */
+// int nwGetBondConf(BondIface *BondCfg,uint8_t BondIndex);
+
+// /*
+//  * @fn CheckIfcEntry
+//  * @brief This function will check the interface presence in ifcname table
+//  * @param Index [in] index value 
+//  * @param IfcType [in] interface type
+//  * @return 0 in success, -1 on failure
+//  */
+// int CheckIfcEntry(uint8_t Index,uint8_t IfcType);
+
+// /*
+//  * @fn CheckBondSlave
+//  * @brief This function will check the given interfaces slave status
+//  * @param EthIndex[in] interface's Ethindex value
+//  * @returns 1 if the interface is a slave of any bond interface, otherwise 0
+//  */
+// int CheckBondSlave(uint8_t EthIndex);
+
+// /*
+//  * @fn CheckIfcLinkStatus
+//  * @brief This function will check the interface's Link health
+//  * @param Index [in] index value 
+//  * @return -1 on failure
+//  */
+// int CheckIfcLinkStatus(uint8_t Index);
+
+// /*
+//  * @fn InitIfcNameTable
+//  * @brief This function is used to initialize the Ifcname table based on NIC count
+//  * @return -1 on failure
+//  */
+// int InitIfcNameTable();
+
+// /**
+// *@fn IsKernelIPv6Enabled
+// *@brief This function is used to check for IPv6 support in the kernel.
+// *@return Returns 1 on success and 0 on fails
+// */
+// int IsKernelIPv6Enabled();
+
+// /*
+//  * @fn nwActiveSlave
+//  * @brief This function will active the single slave for the bonding interface
+//  * @param SlaveIndex to be activated
+//  * @return 0 on success, -1 on failure
+// */
+// int nwActiveSlave(uint8_t BondIndex,uint8_t SlaveIndex);
+
+// /*
+//  * @fn nwGetActiveSlave
+//  * @brief This function will gets the active interface of specified bondindex
+//  * @param Bondindex [in] bonding index, Activeindex[out] active slaves
+//  * @return 0 on success, -1 on failure
+//  */
+// int nwGetActiveSlave(uint8_t BondIndex,uint8_t *ActiveIndex);
+
+// /**
+// *@fn Write_dhcp6c_conf
+// *@brief This function is used to write interface wise entries for dhcp6c.conf file.
+// *@return Returns 0 on success and -1 on fails
+// */
+// int Write_dhcp6c_conf();
+
+// /**
+// *@fn IsValidGlobalIPv6Addr
+// *@brief This function will check the given IPv6 address as global IP address or not
+// *@return Return 0 on success and -1 on failure
+// */
+// int IsValidGlobalIPv6Addr(struct in6_addr * IPv6Addr);
+
+// /* DNS */
+// int nwSetResolvConf_v4_v6(char* dns1,char* dns2,char* dnsv3,char* domain);
+
+// int ReadDNSConfFile ( DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig,uint8_t *regBMC_FQDN);
+// int WriteDNSConfFile ( DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig, uint8_t *regBMC_FQDN);
+// int nwGetAllDNSConf( HOSTNAMECONF *HostnameConfig, DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig,uint8_t *regBMC_FQDN );
+// int nwSetAllDNSConf( HOSTNAMECONF *HostnameConfig, DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig,uint8_t *regBMC_FQDN );
+
+// /* Library for AMI Extended DNS command  */
+// int nwSetHostName(char *name);
+// int nwGetDNSConf(unsigned char* UseDHCPForDNS,unsigned char* UseDHCPForDomain,unsigned char* DoDDNS);
+// int nwGetAllDNSCfg(DNS_CONFIG* dnscfg);
+// int nwSetDNSConf(unsigned char UseDHCPForDNS,unsigned char UseDHCPForDomain,unsigned char DoDDNS);
+// int nwSetAllDNSCfg_NotRestart(DNS_CONFIG* dnscfg);
+
+// int nwGetDHCPServerIP(char *dhcpServerIP);
+// /*!
+// * @brief Reading current/active network configuration using netman script
+// * #param[out] cfg - IP, Netmask, Gateway, Conf method(dhcp/statis)
+// * @returns 0 on succee , -1 on failure
+// */
+// int nwGetNwActIPCfg( NWEXT_IPCFG *cfg );
+// int GetIPAdrressType(uint8_t* IPAddr);
+
+// int nwSyncNWCfg_ipv4_v6(NWCFG_STRUCT *cfg,NWCFG6_STRUCT *cfg6, uint8_t EthIndex);
+
+// /**
+// *@fn GetIPAddrstr
+// *@brief This function is used to get IP address string for given ip or hostname
+// *@param addr - pointer to string of IP address of hostname
+// *@param pResIPaddr - pointer to IP address string
+// *@return Returns address family (AF_INET or AF_INET6) on success and -1 on failure
+// */
+
+// int GetIPAddrstr(unsigned char *addr, char *pResIPaddr);
+// int getFullyQualifiedDName(char *fqdname, uint8_t EthIndex);
+// int nwGetExtMACAddr(unsigned char *MAC);
+
+
+// /*
+//  * @fn IsBMCNFSMode
+//  * @brief Check whether BMC is in BMC Mode.
+//  * @return 0 for FALSE,
+//  *         1 for TRUE.
+//  */
+// int IsBMCNFSMode();
+
+// int nwSyncBondCfg(BondIface *pBondCfg);
+// void GetNwStruct_v4_v6(NWCFG_STRUCT *pCFGIPv4,NWCFG6_STRUCT *pCFGIPv6);
+// int HandleDelayedNwRestart(DELAYEDLANRESTART_NWDATA *pDelyedLAN_NwCfgs, uint8_t Flag_SetDNS, uint8_t EthIndex);
+// int SetNWSpeed(PHYConfig_T *pPHYConfig, char * IFName);
+
+// int SetNWMTUSize(int mtu, char * IFName);
+// int SetVLANPriority(uint16_t vlanID, uint8_t VLANPriority, uint8_t TypeOfService, char *IfcName);
+
+#endif /* _NWCFG_H */

+ 29 - 25
app/bmc/msghndlr/cmdselect.c

@@ -30,7 +30,8 @@
 #include "com_IPMI_Storage.h"
 #include "OemSMMCmds.h"
 #include "Storlead.h"
-//#include "IPMI_Transport.h"
+//#include "com_IPMI_Transport.h"
+#include "com_IPMI_DeviceConfig.h"
 //#include "OemSMMCmds.h"
 //#include "main.h"
 
@@ -247,29 +248,29 @@ const NetFnCmds_T g_Storage [] =
 
 };
 
-//const NetFnCmds_T g_Transport [] = 
-//{
-//	/*------------------------- IPM Device Commands --------------------------------------*/
-//	{ CMD_SET_LAN_CONFIGURATION_PARAMETERS          ,ENABLED},
-//	{ CMD_GET_LAN_CONFIGURATION_PARAMETERS          ,ENABLED},
-//	{ CMD_SUSPEND_BMC_ARPS                                       ,ENABLED},
-//	{ CMD_GET_IP_UDP_RMCP_STATISTICS                       ,DISABLED},
-
-//	/*--------------------- Serial/Modem Device Commands ---------------------------------*/
-//	{ CMD_SET_SERIAL_MODEM_CONFIG                           ,ENABLED},
-//	{ CMD_GET_SERIAL_MODEM_CONFIG                           ,ENABLED},
-//	{ CMD_SET_SERIAL_MODEM_MUX                                ,ENABLED},
-//	{ CMD_SERIAL_MODEM_CONNECTION_ACTIVITY          ,DISABLED},
-//	{ CMD_CALLBACK                                                       ,ENABLED},
-//	{ CMD_SET_USER_CALLBACK_OPTION                         ,ENABLED},
-//	{ CMD_GET_USER_CALLBACK_OPTION                         ,ENABLED},
-//	{ CMD_GET_TAP_RES_CODES                                      ,ENABLED},
-
-//	/*------------------------- Serial Over LAN Commands ---------------------------------*/
-//	{ CMD_GET_SOL_CONFIGURATION                              ,ENABLED},
-//	{ CMD_SET_SOL_CONFIGURATION                              ,ENABLED},
-//	{ 0                                                                            ,0            }
-//};
+const NetFnCmds_T g_Transport [] = 
+{
+	/*------------------------- IPM Device Commands --------------------------------------*/
+	{ CMD_SET_LAN_CONFIGURATION_PARAMETERS          ,ENABLED},
+	{ CMD_GET_LAN_CONFIGURATION_PARAMETERS          ,ENABLED},
+	{ CMD_SUSPEND_BMC_ARPS                                       ,ENABLED},
+	{ CMD_GET_IP_UDP_RMCP_STATISTICS                       ,DISABLED},
+
+	/*--------------------- Serial/Modem Device Commands ---------------------------------*/
+	{ CMD_SET_SERIAL_MODEM_CONFIG                           ,ENABLED},
+	{ CMD_GET_SERIAL_MODEM_CONFIG                           ,ENABLED},
+	{ CMD_SET_SERIAL_MODEM_MUX                                ,ENABLED},
+	{ CMD_SERIAL_MODEM_CONNECTION_ACTIVITY          ,DISABLED},
+	{ CMD_CALLBACK                                                       ,ENABLED},
+	{ CMD_SET_USER_CALLBACK_OPTION                         ,ENABLED},
+	{ CMD_GET_USER_CALLBACK_OPTION                         ,ENABLED},
+	{ CMD_GET_TAP_RES_CODES                                      ,ENABLED},
+
+	/*------------------------- Serial Over LAN Commands ---------------------------------*/
+	{ CMD_GET_SOL_CONFIGURATION                              ,ENABLED},
+	{ CMD_SET_SOL_CONFIGURATION                              ,ENABLED},
+	{ 0                                                                            ,0            }
+};
 
 //const NetFnCmds_T g_AMI [] = 
 //{
@@ -808,6 +809,9 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_SET_MANAGE_FN          ,ENABLED},	
 	{ CMD_GET_MANAGE_FN          ,ENABLED},	
 	{ CMD_GET_CHASSIS_INFO          ,ENABLED},	
+	{ CMD_RESTORE_FACTORY_SET          ,ENABLED},	
+	{ CMD_GET_LAN_INFO          ,ENABLED},	
+	{ CMD_SET_LAN_INFO          ,ENABLED},	
 	{0,				0		},
 };
 
@@ -819,7 +823,7 @@ NETFNTable_T Netfntbl [] =
 	{ NETFN_SENSOR,     GRPEXT_NA,      g_Sensor    },
 	{ NETFN_STORAGE,    GRPEXT_NA,      g_Storage   },
 	{ NETFN_STORLEAD,    GRPEXT_NA,      g_Storlead   },
-//	{ NETFN_TRANSPORT,  GRPEXT_NA,      g_Transport },
+	{ NETFN_TRANSPORT,  GRPEXT_NA,      g_Transport },
 //	{ NETFN_AMI,        GRPEXT_NA,      g_AMI       },
 //	{ NETFN_OPMA1,      GRPEXT_NA,      g_opma1     },
 //	{ NETFN_OPMA2,      GRPEXT_NA,      g_opma2     },

+ 103 - 0
app/bmc/util.c

@@ -0,0 +1,103 @@
+
+#include "Util.h"
+#include <sys/sysinfo.h> 
+
+
+/*----------------------------------------
+ * GetBits
+ *----------------------------------------*/
+INT8U
+GetBits (INT8U Val, INT8U Mask)
+{
+    INT8U ExtVal = 0;
+    while (0 != Mask)
+    {
+        if (0 != (Mask & 0x80))
+        {
+            ExtVal <<= 1;
+            if (0 != (Val & 0x80)) { ExtVal += 0x01; }
+        }
+
+        Val <<= 1;
+        Mask <<= 1;
+    }
+
+    return ExtVal;
+}
+
+/*------------------------------------------
+ * SetBits
+ *------------------------------------------*/
+INT8U
+SetBits (INT8U Mask, INT8U Val)
+{
+    INT8U FinVal = 0;
+    INT8U i;
+
+    for (i = 0; i < 8; i++)
+    {
+        FinVal >>= 1;
+        if (0 != (Mask & 0x01))
+        {
+            if (0 != (Val & 0x01)) { FinVal |= 0x80; }
+                Val >>= 1;
+        }
+        Mask   >>= 1;
+    }
+
+    return FinVal;
+}
+
+/*------------------------------------------
+ * CalculateCheckSum
+ *------------------------------------------*/
+INT8U
+CalculateCheckSum (INT8U* Data, INT16U Len)
+{
+    INT8U   Sum;
+    INT16U  i;
+
+    Sum = 0;
+    for (i = 0; i < Len; i++)
+    {
+        Sum += Data [i];
+    }
+    return (0x100 - Sum);
+}
+
+/*
+* @fn TimeUpdate
+* @return Returns the system uptime
+*/
+INT32U TimeUpdate()
+{
+    struct sysinfo time;
+    sysinfo(&time);
+    return time.uptime;
+}
+
+/**
+*@fn GetSysCtlvalue
+*@brief This function retrieves the values from Sysctl
+*@param TagName -Tagname form which value has to be retrieved
+*@param SysVal - Where the value is stored
+*@return Returns 0 on success
+*            Returns 1 on failure
+*/
+int GetJiffySysCtlvalue (const char *TagName, long long *SysVal)
+{
+    unsigned long RetVal;
+    FILE* SysFile = fopen (TagName, "r");
+    unsigned long Hertz = sysconf(_SC_CLK_TCK);
+
+    if ((!SysFile) || (!SysVal))
+        return 1;
+
+    fscanf (SysFile, "%lu", &RetVal);
+    fclose (SysFile);
+
+    *SysVal = (RetVal*1000)/Hertz;
+    return 0;
+}
+
+

+ 32 - 0
app/common_include/com_BMCCfg.h

@@ -4,6 +4,38 @@
 #define 	FAN_NUMBERS		4
 #define 	BLADE_NUMBERS	5
 
+/*
+0x00 0000 ~ 0x7F FFFF 	8MB		BMC Firmware
+=============================================
+0x80 0000 ~ 0x80 0FFF	4KB		User info		
+0x80 1000 ~ 0x80 FFFF	60KB 	Reserve
+---------------------------------------------
+0x81 0000 ~ 0x81 0FFF	4KB 	FRU
+0x81 1000 ~ 0x81 FFFF	60KB 	Reserve
+---------------------------------------------
+0x82 0000 ~ 0x82 0FFF 	4KB 	SDR
+0x82 1000 ~ 0x82 1FFF	60KB 	Reserve
+---------------------------------------------
+0x83 0000 ~ 0x83 0FFF 	4KB 	IpmiConfig_0
+0x83 1000 ~ 0x83 1FFF 	4KB 	IpmiConfig_1
+0x83 2000 ~ 0x83 2FFF 	4KB 	IpmiConfig_2
+0x83 3000 ~ 0x83 3FFF 	4KB 	IpmiConfig_3
+...
+0x83 F000 ~ 0x83 FFFF	4KB 	IpmiConfig_n
+---------------------------------------------
+0x84 0000 ~ 0x84 FFFF 	64KB	SEL
+---------------------------------------------
+0x85 0000 ~ 0x8F FFFF 	704KB 	Reserve
+=============================================
+0x90 0000 ~ 0xFF FFFF 	7MB 	Reserve
+*/
+#define CONFIG_FLASH_START 	0x800000
+#define USERTBL_FLASH_ADDR 	0x800000
+#define FRU_FLASH_ADDR 		0x810000
+#define SDR_FLASH_ADDR 		0x820000
+#define IPMI_CFG_FLASH_ADDR 0x830000
+#define SEL_FLASH_ADDR 		0x840000
+
 
 
 #endif /* __COM_BMC_CFG_H__ */

+ 11 - 0
app/common_include/com_BmcType.h

@@ -329,5 +329,16 @@ typedef struct{
     uint8_t pwrStatus;
 } BladeStatus_T;
 
+
+typedef struct{
+    uint8_t EthName[20];
+    uint8_t IPAddrSrc;  //0:unspecified 1:Static 2:DHCP  3:BIOS 4:other
+    uint8_t IPAddr[4];
+    uint8_t BroadCast[4];
+    uint8_t NetMask[4];
+    uint8_t DefaultGW[4];
+    uint8_t MACAddr[6];
+} LanInfo_T;
+
 #pragma pack()
 #endif /* __BMC_TYPE_H__ */

+ 4 - 1
app/common_include/com_IPMIDefs.h

@@ -49,7 +49,6 @@
 
 
 
-#define USERTBL_FLASH_ADDR 0x800000
 
 #define MAX_STR_LENGTH          128
 #define SOCKET_PATH_LEN         108
@@ -135,6 +134,8 @@
  * ---------------------------------------------*/
 #define CHASSIS_PWR_HNDLR_Q   "/var/CHASSIS_PWR_HNDLR_Q"
 
+#define PEND_ACTION_HNDLR_Q   "/var/PEND_ACTION_HNDLR_Q"
+
 /*----------------------------------------------
  * Channel
  *----------------------------------------------*/
@@ -161,6 +162,7 @@
 #define PARAM_NORMAL_RESPONSE   0x11
 #define PARAM_BRIDGE            0x12
 #define BRIDGING_REQUEST        PARAM_BRIDGE
+#define PARAM_LAN 				0x13
 
 
 
@@ -228,6 +230,7 @@
 #define NETFNLUN_IPMI_APP					0x18
 #define NETFNLUN_IPMI_SENSOR				0x10
 #define NETFNLUN_IPMI_STORAGE				0x28
+#define NETFNLUN_IPMI_TRANSPORT				0x30
 #define NETFNLUN_IPMI_CHASSIS               0x00
 #define NETFNLUN_IPMI_OEM					0xB8
 #define NETFNLUN_IPMI_STORLEAD				0xC8

+ 44 - 0
app/common_include/com_IPMI_DeviceConfig.h

@@ -0,0 +1,44 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ *
+ * IPMI_DeviceConfig.h
+ * Device Configuration Commands
+ *
+ *****************************************************************/
+#ifndef IPMI_DEVICE_CONFIG_H
+#define IPMI_DEVICE_CONFIG_H
+
+/* LAN Configuration Commands */
+#define CMD_SET_LAN_CONFIGURATION_PARAMETERS        0x01
+#define CMD_GET_LAN_CONFIGURATION_PARAMETERS        0x02
+#define CMD_SUSPEND_BMC_ARPS                        0x03
+#define CMD_GET_IP_UDP_RMCP_STATISTICS              0x04
+
+/* Serial Configuration Commands */
+#define CMD_SERIAL_MODEM_CONNECTION_ACTIVITY        0x18
+#define CMD_SET_SERIAL_MODEM_CONFIG                 0x10
+#define CMD_GET_SERIAL_MODEM_CONFIG                 0x11
+#define CMD_SET_SERIAL_MODEM_MUX                    0x12
+#define CMD_GET_TAP_RES_CODES                       0x13
+#define CMD_CALLBACK                                0x19
+#define CMD_SET_USER_CALLBACK_OPTION                0x1a
+#define CMD_GET_USER_CALLBACK_OPTION                0x1b
+
+/* Serial Over Lan Configuration Commands */
+#define CMD_GET_SOL_CONFIGURATION                   0x22
+#define CMD_SET_SOL_CONFIGURATION                   0x21
+
+
+#endif  /* IPMI_DEVICE_CONFIG_H */

+ 133 - 60
app/common_include/com_IPMI_LANConfig.h

@@ -24,6 +24,7 @@
 #define IPMI_LANCONFIG_H
 
 #include <stdint.h>
+//#include <nwcfg.h>
 
 /*** External Definitions ***/
 #define IP_ADDR_LEN             4
@@ -38,6 +39,69 @@
 #define MIN_LAN_OEM_CONF_PARAM			192
 #define MAX_LAN_OEM_CONF_PARAM			255
 
+#define LAN_PARAM_SET_IN_PROGRESS               0
+#define LAN_PARAM_AUTH_TYPE_SUPPORT             1
+#define LAN_PARAM_AUTH_TYPE_ENABLES             2
+#define LAN_PARAM_IP_ADDRESS                    3
+#define LAN_PARAM_IP_ADDRESS_SOURCE             4
+#define LAN_PARAM_MAC_ADDRESS                   5
+#define LAN_PARAM_SUBNET_MASK                   6
+#define LAN_PARAM_IPv4_HEADER                   7
+#define LAN_PARAM_PRI_RMCP_PORT                 8
+#define LAN_PARAM_SEC_RMCP_PORT                 9
+#define LAN_PARAM_BMC_GENERATED_ARP_CONTROL     10
+#define LAN_PARAM_GRATITIOUS_ARP_INTERVAL       11
+#define LAN_PARAM_DEFAULT_GATEWAY_IP            12
+#define LAN_PARAM_DEFAULT_GATEWAY_MAC           13
+#define LAN_PARAM_BACKUP_GATEWAY_IP             14
+#define LAN_PARAM_BACKUP_GATEWAY_MAC            15
+#define LAN_PARAM_COMMUNITY_STRING              16
+#define LAN_PARAM_DEST_NUM                      17
+#define LAN_PARAM_SELECT_DEST_TYPE              18
+#define LAN_PARAM_SELECT_DEST_ADDR              19
+#define LAN_PARAM_VLAN_ID                       20
+#define LAN_PARAM_VLAN_PRIORITY                 21
+#define LAN_PARAM_CIPHER_SUITE_ENTRY_SUP        22
+#define LAN_PARAM_CIPHER_SUITE_ENTRIES          23
+#define LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS      24
+#define LAN_PARAM_VLAN_TAGS                     25
+#define LAN_PARAMS_BAD_PASSWORD_THRESHOLD       26
+
+#define LAN_PARAMS_AMI_OEM_VLANIFC_ENABLE               192
+#define LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR             193
+#define LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC               194
+
+#define LAN_PARAMS_AMI_OEM_IPV6_ENABLE                  195
+#define LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE          196
+#define LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR                 197
+#define LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR               207
+#define LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX        208
+#define LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH           198
+#define LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP              199
+#define LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64           211
+
+/* Parameter No. 200 to 202 are specified as SSI OEM LAN Parameters */
+#define LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR         200
+#define LAN_PARAMS_SSI_OEM_LINK_CTRL                    201
+#define LAN_PARAMS_SSI_OEM_CMM_IP_ADDR                  202
+
+#define LAN_PARAMS_AMI_OEM_IPV6_DNS_SETTINGS            203
+#define LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM              204
+#define LAN_PARAMS_AMI_OEM_NCSI_SETTINGS                205
+#define LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE             210
+#define LAN_PARAMS_AMI_OEM_NCSI_EXTENSION               212
+
+#define LAN_PARAMS_AMI_OEM_PHY_SETTINGS                 206
+#define LAN_PARAMS_AMI_OEM_MTU_SETTINGS                 209
+
+#define UNSPECIFIED_IP_SOURCE   0x00
+#define STATIC_IP_SOURCE                0x01
+#define DHCP_IP_SOURCE                  0x02
+#define BIOS_IP_SOURCE                  0x03
+#define BMC_OTHER_SOURCE                0x04
+
+#define VLAN_MASK_BIT  0x8000       /* VLAN enable bit */
+
 /**
  * @struct AuthTypeEnables_T
  * @brief Authentication Type Enables
@@ -162,59 +226,68 @@ typedef struct
     uint8_t               IPv6_PrefixLen;
 }IPv6Prefix_T;
 
-///**
-// * @struct LANConfigUn_T
-// * @brief LAN Configuration Parameters.
-//**/
-//typedef union {
-
-//    uint8_t               SetInProgress;
-//    uint8_t               AuthTypeSupport;
-//    AuthTypeEnables_T   AuthTypeEnables;
-//    uint8_t               IPAddr [4];
-//    uint8_t               IPAddrSrc;
-//    uint8_t               MACAddr [6];
-//    uint8_t               SubNetMask [4];
-//    IPv4HdrParams_T     Ipv4HdrParam;
-//    uint16_t              PrimaryRMCPPort;
-//    uint16_t              SecondaryPort;
-//    uint8_t               BMCGeneratedARPControl;
-//    uint8_t               GratitousARPInterval;
-//    uint8_t               DefaultGatewayIPAddr [IP_ADDR_LEN];
-//    uint8_t               DefaultGatewayMACAddr [MAC_ADDR_LEN];
-//    uint8_t               BackupGatewayIPAddr [IP_ADDR_LEN];
-//    uint8_t               BackupGatewayMACAddr [MAC_ADDR_LEN];
-//    uint8_t               CommunityStr [MAX_COMM_STRING_SIZE];
-//    uint8_t               NumDest;
-//    LANDestType_T       DestType;
-//    LANDestAddr_T       DestAddr;
-//    LANDestv6Addr_T     Destv6Addr;
-//    uint16_t              VLANID;
-//    uint8_t               VLANPriority;
-//    uint8_t               CipherSuiteSup;
-//    uint8_t               CipherSuiteEntries [17];
-//    uint8_t               CipherSuitePrivLevels [MAX_NUM_CIPHER_SUITE_PRIV_LEVELS];
-//    BadPassword_T       BadPasswd;
-//    uint8_t               EthIndex;
-//    uint8_t               ChangeMACEnabled;
-//    uint8_t               IPv6_Enable;
-//    uint8_t               IPv6_IPAddrSrc;
-//    uint8_t               IPv6_LinkAddr [IP6_ADDR_LEN];
-//    IPv6Addr_T          IPv6Addr;
-//    IPv6Prefix_T        IPv6Prefix;
-//    uint8_t               IPv6_LinkAddrPrefix;
-//    uint8_t               IPv6_GatewayIPAddr[IP6_ADDR_LEN];
-//    uint8_t               NumNCSIPortConfigs;
-//    NCSIPortConfig_T    NCSIPortConfig;
-//    PHYConfig_T         PHYConfig;
-//    uint8_t               SSI2ndPriEthMACAddr[MAC_ADDR_LEN];
-//    uint8_t               SSILinkControl;
-//    uint8_t               CMMIPAddr[IP_ADDR_LEN];
-//    uint16_t              MTU_size;
-//    NCSIModeConfig_T	NCSIModeConfig;
-//    NCSIPHYConfigSet_T	NCSIPHYConfigSet;
-//    NCSIPHYConfigGet_T	NCSIPHYConfigGet;
-//} LANConfigUn_T;
+typedef struct
+{
+    uint8_t AutoNegotiationEnable;
+    uint16_t Speed;
+    uint8_t Duplex;
+    uint8_t Interface;
+    uint8_t CapabilitiesSupported;
+}   PHYConfig_T;
+
+/**
+* @struct LANConfigUn_T
+* @brief LAN Configuration Parameters.
+**/
+typedef union {
+
+   uint8_t               SetInProgress;
+   uint8_t               AuthTypeSupport;
+   AuthTypeEnables_T   AuthTypeEnables;
+   uint8_t               IPAddr [4];
+   uint8_t               IPAddrSrc;
+   uint8_t               MACAddr [6];
+   uint8_t               SubNetMask [4];
+   IPv4HdrParams_T     Ipv4HdrParam;
+   uint16_t              PrimaryRMCPPort;
+   uint16_t              SecondaryPort;
+   uint8_t               BMCGeneratedARPControl;
+   uint8_t               GratitousARPInterval;
+   uint8_t               DefaultGatewayIPAddr [IP_ADDR_LEN];
+   uint8_t               DefaultGatewayMACAddr [MAC_ADDR_LEN];
+   uint8_t               BackupGatewayIPAddr [IP_ADDR_LEN];
+   uint8_t               BackupGatewayMACAddr [MAC_ADDR_LEN];
+   uint8_t               CommunityStr [MAX_COMM_STRING_SIZE];
+   uint8_t               NumDest;
+   LANDestType_T       DestType;
+   LANDestAddr_T       DestAddr;
+   LANDestv6Addr_T     Destv6Addr;
+   uint16_t              VLANID;
+   uint8_t               VLANPriority;
+   uint8_t               CipherSuiteSup;
+   uint8_t               CipherSuiteEntries [17];
+   uint8_t               CipherSuitePrivLevels [MAX_NUM_CIPHER_SUITE_PRIV_LEVELS];
+   BadPassword_T       BadPasswd;
+   uint8_t               EthIndex;
+   uint8_t               ChangeMACEnabled;
+   uint8_t               IPv6_Enable;
+   uint8_t               IPv6_IPAddrSrc;
+   uint8_t               IPv6_LinkAddr [IP6_ADDR_LEN];
+   IPv6Addr_T          IPv6Addr;
+   IPv6Prefix_T        IPv6Prefix;
+   uint8_t               IPv6_LinkAddrPrefix;
+   uint8_t               IPv6_GatewayIPAddr[IP6_ADDR_LEN];
+   uint8_t               NumNCSIPortConfigs;
+   NCSIPortConfig_T    NCSIPortConfig;
+   PHYConfig_T         PHYConfig;
+   uint8_t               SSI2ndPriEthMACAddr[MAC_ADDR_LEN];
+   uint8_t               SSILinkControl;
+   uint8_t               CMMIPAddr[IP_ADDR_LEN];
+   uint16_t              MTU_size;
+   NCSIModeConfig_T	NCSIModeConfig;
+   NCSIPHYConfigSet_T	NCSIPHYConfigSet;
+   NCSIPHYConfigGet_T	NCSIPHYConfigGet;
+} LANConfigUn_T;
 
 
 /* GetLanCCRev_T */
@@ -260,14 +333,14 @@ typedef struct
     /* OEM parameter should be added below*/
 }   SetLanConfigOEMReq_T;
 
-///* SetLanConfigReq_T */
-//typedef struct 
-//{
-//    uint8_t           ChannelNum;
-//    uint8_t           ParameterSelect;
-//    LANConfigUn_T   ConfigData;
+/* SetLanConfigReq_T */
+typedef struct 
+{
+   uint8_t           ChannelNum;
+   uint8_t           ParameterSelect;
+   LANConfigUn_T   ConfigData;
 
-//}   SetLanConfigReq_T;
+}   SetLanConfigReq_T;
 
 
 /* SetLanConfigRes_T */

+ 3 - 0
app/common_include/com_IPMI_Storlead.h

@@ -12,6 +12,9 @@
 #define CMD_SET_MANAGE_FN		0x8
 #define CMD_GET_MANAGE_FN		0x9
 #define CMD_GET_CHASSIS_INFO	0xA
+#define CMD_RESTORE_FACTORY_SET 0xB
+#define CMD_GET_LAN_INFO		0xC
+#define CMD_SET_LAN_INFO		0xD
 
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

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

@@ -508,6 +508,7 @@ DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_Sensor.h
 DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_SDRRecord.h
 DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_PEF.h
 DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_Storlead.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_LANConfig.h
 DEPS_USER_C2 += $(BUILD)/inc/com_BMCCfg.h
 
 

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

@@ -231,6 +231,8 @@ websDefineAction("setFanInfo", setFanInfo);
 //config
 websDefineAction("restoreFactorySettings", restoreFactorySettings);
 websDefineAction("web_ResetBMC", web_ResetBMC);
+websDefineAction("web_GetLanInfo", web_GetLanInfo);
+websDefineAction("web_SetLanInfo", web_SetLanInfo);
 
 
 /**************** user code after goahead end************************/

+ 2 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -109,5 +109,7 @@ int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo
 //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);
 uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, 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);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 46 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -781,4 +781,50 @@ uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, int timeout)
 						timeout);
 	
 	return (wRet);
+}
+
+uint16_t IPMICMD_SetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout)
+{
+	uint16_t wRet;
+	uint32_t dwResLen;
+	uint8_t res[10];
+	uint8_t req[100];
+	
+	req[0] = index; 
+	memcpy(&req[1], pLanInfo, sizeof(LanInfo_T));
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
+						NETFNLUN_IPMI_STORLEAD, CMD_SET_LAN_INFO,
+						req, sizeof(LanInfo_T)+1,
+						(uint8_t*)res, &dwResLen,
+						timeout);
+	if(res[0] != 0)
+	{
+		printf("Set lan Info error!\n");
+		return -1;
+	}
+	
+	return (wRet);
+}
+
+uint16_t IPMICMD_GetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout)
+{
+	uint16_t wRet;
+	uint32_t dwResLen;
+	uint8_t res[100];
+	uint8_t req[10];
+	
+	req[0] = index; 
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
+						NETFNLUN_IPMI_STORLEAD, CMD_GET_LAN_INFO,
+						req, 1,
+						res, &dwResLen,
+						timeout);
+	if(res[0] != 0)
+	{
+		printf("Get lan info error!\n");
+		return -1;
+	}
+
+	memcpy(pLanInfo, res+1, sizeof(LanInfo_T));
+	return (wRet);
 }

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

@@ -3,9 +3,9 @@
 
 #include "goahead.h"
 
-void setIpAddr(Webs *wp);
-void setMacAddr(Webs *wp);
 void restoreFactorySettings(Webs *wp);
 void web_ResetBMC(Webs *wp);
+void web_GetLanInfo(Webs *wp);
+void web_SetLanInfo(Webs *wp);
 
 #endif /* __CONFIG_H__ */

+ 326 - 10
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -11,17 +11,12 @@
 #include <unistd.h>
 #include "com_BmcType.h"
 #include "libipmi_usermgmt.h"
+#include <string.h>
+#include <math.h>
+#include "com_IPMI_LANConfig.h"
 
-void setIpAddr(Webs *wp)
-{
-
-}
-
-void setMacAddr(Webs *wp)
-{
-
-}
-
+uint8_t mac2hex(const char *strMac, uint8_t index);
+uint8_t ip2dec(const char *strIp, uint8_t index);
 
 
 void restoreFactorySettings(Webs *wp){
@@ -110,3 +105,324 @@ void web_ResetBMC(Webs *wp){
 }
 
 
+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);
+
+    if(strcmp(EthName, "eth0") == 0)
+    {
+        index = 0;
+    }
+    else
+    {
+        websError(wp, 404, "Invalid eth name!");
+        return;
+    }
+
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
+    if(wRet != 0)
+    {
+        websError(wp, 404, "Get Lan Info fail!");
+    }
+
+    //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_AddStringToObject(data, "eth", LanInfo.EthName);
+
+    if(LanInfo.IPAddrSrc == STATIC_IP_SOURCE)
+        cJSON_AddStringToObject(data, "mode", "static");
+    else if(LanInfo.IPAddrSrc == DHCP_IP_SOURCE)
+        cJSON_AddStringToObject(data, "mode", "DHCP");
+    else if(LanInfo.IPAddrSrc == BIOS_IP_SOURCE)
+        cJSON_AddStringToObject(data, "mode", "BIOS");
+    else 
+        cJSON_AddStringToObject(data, "mode", "Other");
+    
+    char strIp[16] = {0};
+    sprintf(strIp, "%d.%d.%d.%d", LanInfo.IPAddr[0], LanInfo.IPAddr[1], 
+        LanInfo.IPAddr[2], LanInfo.IPAddr[3]);
+    cJSON_AddStringToObject(data, "ip", strIp);
+
+    char strMac[18] = {0};
+    sprintf(strMac, "%02x:%02x:%02x:%02x:%02x:%02x", LanInfo.MACAddr[0], LanInfo.MACAddr[1], 
+        LanInfo.MACAddr[2], LanInfo.MACAddr[3], LanInfo.MACAddr[4], LanInfo.MACAddr[5]);
+    cJSON_AddStringToObject(data, "mac", strMac);
+
+    char strBrdCast[16] = {0};
+    sprintf(strBrdCast, "%d.%d.%d.%d", LanInfo.BroadCast[0], LanInfo.BroadCast[1], 
+        LanInfo.BroadCast[2], LanInfo.BroadCast[3]);
+    cJSON_AddStringToObject(data, "broadcast", strBrdCast);
+
+    char strMask[16] = {0};
+    sprintf(strMask, "%d.%d.%d.%d", LanInfo.NetMask[0], LanInfo.NetMask[1], 
+        LanInfo.NetMask[2], LanInfo.NetMask[3]);
+    cJSON_AddStringToObject(data, "netmask", strMask);
+
+    char strGw[16] = {0};
+    sprintf(strGw, "%d.%d.%d.%d", LanInfo.DefaultGW[0], LanInfo.DefaultGW[1], 
+        LanInfo.DefaultGW[2], LanInfo.DefaultGW[3]);
+    cJSON_AddStringToObject(data, "defaultgw", strGw);
+
+    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 web_SetLanInfo(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);    //eth0
+    char *strMode = websGetVar(wp, "mode", NULL);   //static DHCP
+    char *strMac = websGetVar(wp, "mac", NULL);     //00:12:34:56:78:88
+    char *strIp = websGetVar(wp, "ip", NULL);       //192.168.0.208
+    char *strBrdCast = websGetVar(wp, "broadcast", NULL);   //192.168.0.255
+    char *strMask = websGetVar(wp, "netmask", NULL);        //255.255.255.0
+    char *strGw = websGetVar(wp, "defaultgw", NULL);        //192.168.0.1
+
+    if(strlen(EthName) > 20)
+    {
+        printf("EthName is too long! %s\n", EthName);
+        websError(wp, 404, "EthName is too long!");
+        return;
+    }
+
+    if(strcmp(EthName, "eth0") == 0)    //目前只有一个网卡
+    {
+        index = 0;
+    }
+    else
+    {
+        websError(wp, 404, "Invalid eth name!");
+        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))
+    {
+        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);
+
+    wRet = IPMICMD_SetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
+    if(wRet != 0)
+    {
+        websError(wp, 404, "Reset BMC fail!");
+    }
+
+    //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);
+}
+
+
+/*
+    index = 0,1,2,3,4,5
+*/
+uint8_t mac2hex(const char *strMac, uint8_t index)
+{
+    int i = 0;
+    char    *pStr = (char *)strMac;
+    char    *pTmp = NULL;
+    uint8_t macByte = 0;;
+    char    tmp[3] = {0};
+
+    if(index > 5)
+    {
+        printf("Invalid index %d\n", index);
+        return -1;
+    }
+
+    //find
+    while(pStr)
+    {
+        if(i == index)
+            break;
+
+        if(*pStr == ':')
+            i++;
+        
+        pStr++;
+    }
+
+    if(*(pStr+1) == ':')
+    {
+        tmp[0] = *pStr;
+        tmp[1] = '\0';
+        tmp[2] = '\0';
+    }
+    else
+    {
+        tmp[0] = *pStr;
+        tmp[1] = *(pStr+1);
+        tmp[2] = '\0';
+    }
+
+    i=0;
+    macByte = 0;
+    while(tmp[i])
+    {
+        macByte = macByte<<4;
+        if((tmp[i]>='0') && (tmp[i]<='9'))
+            macByte += (tmp[i]-'0');
+        else if((tmp[i]>='a') && (tmp[i]<='f'))
+            macByte += (tmp[i]-'a') + 10;
+        else if((tmp[i]>='A') && (tmp[i]<='F'))
+            macByte += (tmp[i]-'A') + 10;
+
+        i++;
+    }
+
+    return macByte;     
+}
+
+/*
+    index = 0,1,2,3
+*/
+uint8_t ip2dec(const char *strIp, uint8_t index)
+{
+    int i = 0;
+    char    *pStr = (char *)strIp;
+    uint8_t ipByte = 0;;
+    char    tmp[4] = {0};
+
+    if(index > 3)
+    {
+        printf("Invalid index %d\n", index);
+        return -1;
+    }
+
+    //find
+    while(pStr)
+    {
+        if(i == index)
+            break;
+
+        if(*pStr == '.')
+            i++;
+        
+        pStr++;
+    }
+
+    if(*(pStr+1) == '.')
+    {
+        tmp[0] = *pStr;
+        tmp[1] = '\0';
+        tmp[2] = '\0';
+        tmp[3] = '\0';
+    }
+    else if(*(pStr+2) == '.')
+    {
+        tmp[0] = *pStr;
+        tmp[1] = *(pStr+1);
+        tmp[2] = '\0';
+        tmp[3] = '\0';
+    }
+    else
+    {
+        tmp[0] = *pStr;
+        tmp[1] = *(pStr+1);
+        tmp[2] = *(pStr+2);
+        tmp[3] = '\0';
+    }
+
+    ipByte = atoi(tmp);
+
+    return ipByte;     
+}
+
+

+ 5 - 5
gd32450i-eval.busybox

@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Busybox version: 1.17.0
-# Mon Apr 13 23:55:43 2020
+# Mon May 11 15:12:23 2020
 #
 CONFIG_HAVE_DOT_CONFIG=y
 
@@ -719,10 +719,10 @@ CONFIG_HOSTNAME=y
 # CONFIG_FEATURE_HTTPD_PROXY is not set
 CONFIG_IFCONFIG=y
 CONFIG_FEATURE_IFCONFIG_STATUS=y
-# CONFIG_FEATURE_IFCONFIG_SLIP is not set
-# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
-# CONFIG_FEATURE_IFCONFIG_HW is not set
-# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
+CONFIG_FEATURE_IFCONFIG_SLIP=y
+CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
+CONFIG_FEATURE_IFCONFIG_HW=y
+CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
 # CONFIG_IFENSLAVE is not set
 # CONFIG_IFPLUGD is not set
 # CONFIG_IFUPDOWN is not set

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません